khalidadil
  • Joined on 2025-08-25

@khalidadil/laser-geometry (0.1.3)

Published 2026-08-11 14:13:12 +00:00 by khalidadil

Installation

@khalidadil:registry=
npm install @khalidadil/laser-geometry@0.1.3
"@khalidadil/laser-geometry": "0.1.3"

About this package

@khalidadil/laser-geometry

Shared laser name-art geometry engine + client render, imported by pattern-svg-builder (the editor) and artisan-cuts (the storefront) so both produce the same cut geometry and the same on-screen look.

Two entry points:

  • @khalidadil/laser-geometry/core — Node + native. The Clipper2 geometry pipeline (text→outlines→pattern→stencil→bridges→ring), warnings, and both SVG emit surfaces. Behavioural forks between the two apps are options whose defaults reproduce the editor; the storefront passes flags:

    import { buildTextFillGeometry, emitCompoundSvg, buildFinalSVG } from '@khalidadil/laser-geometry/core';
    
    // editor: default (no perimeter band, whole bridge bars, round tabs)
    const g = await buildTextFillGeometry(project);
    
    // storefront: perimeter band, clipped void-only tabs, hourglass web
    const g2 = await buildTextFillGeometry(project, {
      patternPerimeterMm: 2.5, clipBridges: true, bridgeProfile: 'hourglass',
    });
    
  • @khalidadil/laser-geometry/render — browser, pure JS. buildArtSvg (wood-photo clip vs flat plastic), the materials palette, the wall-plane homography, and the instant approx preview.

The caller owns font/pattern loading and all file/DB/HTTP I/O; the package is pure geometry + emit. setDiagSink() optionally routes the core's diagnostic events to the host's logger (default: no-op).

Native binary

native/ is a napi-rs Clipper2 crate. A darwin-arm64 prebuild is committed for local dev. Other platforms compile from the Rust source:

npm run build:native   # cd native && napi build --release

Each consuming app's Dockerfile runs this against node_modules/@khalidadil/laser-geometry/native to produce the Linux .node (the same way the apps already build their vendored crate).

Parity gate

node test/golden-parity.mjs drives the real builder + shop engines and the package over a text/pattern/outline/bridge matrix and asserts byte-identical output (defaults === editor, shop-opts === storefront). Run it after any change to the geometry.

Publish (Gitea npm registry)

Reads are public; publishing needs a Gitea token (Khalid, like an image push):

npm publish

(publishConfig.registry points at https://git.kadil.dev/api/packages/khalidadil/npm/. Authenticate once with a Gitea package-write token in ~/.npmrc.)

Dependencies

Dependencies

ID Version
@xmldom/xmldom ^0.8.10
opentype.js ^1.3.4
paper ^0.12.17
paperjs-offset ^1.0.8

Development Dependencies

ID Version
@napi-rs/cli ^2.18.0
Details
npm
2026-08-11 14:13:12 +00:00
15
312 KiB
Assets (1)
Versions (17) View all
0.11.0 2026-10-14
0.10.0 2026-09-18
0.9.0 2026-09-18
0.8.0 2026-09-10
0.7.0 2026-09-10