@faicad/faijs-sketch 0.18.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (59) hide show
  1. package/LICENSE +28 -0
  2. package/NOTICE +28 -0
  3. package/dist/bspline.d.ts +58 -0
  4. package/dist/bspline.d.ts.map +1 -0
  5. package/dist/bspline.js +93 -0
  6. package/dist/bspline.js.map +1 -0
  7. package/dist/canonical.d.ts +205 -0
  8. package/dist/canonical.d.ts.map +1 -0
  9. package/dist/canonical.js +12 -0
  10. package/dist/canonical.js.map +1 -0
  11. package/dist/contour.d.ts +43 -0
  12. package/dist/contour.d.ts.map +1 -0
  13. package/dist/contour.js +132 -0
  14. package/dist/contour.js.map +1 -0
  15. package/dist/faces.d.ts +28 -0
  16. package/dist/faces.d.ts.map +1 -0
  17. package/dist/faces.js +46 -0
  18. package/dist/faces.js.map +1 -0
  19. package/dist/fcstd-types.d.ts +177 -0
  20. package/dist/fcstd-types.d.ts.map +1 -0
  21. package/dist/fcstd-types.js +67 -0
  22. package/dist/fcstd-types.js.map +1 -0
  23. package/dist/index.d.ts +36 -0
  24. package/dist/index.d.ts.map +1 -0
  25. package/dist/index.js +28 -0
  26. package/dist/index.js.map +1 -0
  27. package/dist/namespace.d.ts +51 -0
  28. package/dist/namespace.d.ts.map +1 -0
  29. package/dist/namespace.js +67 -0
  30. package/dist/namespace.js.map +1 -0
  31. package/dist/node.d.ts +14 -0
  32. package/dist/node.d.ts.map +1 -0
  33. package/dist/node.js +34 -0
  34. package/dist/node.js.map +1 -0
  35. package/dist/op.d.ts +67 -0
  36. package/dist/op.d.ts.map +1 -0
  37. package/dist/op.js +104 -0
  38. package/dist/op.js.map +1 -0
  39. package/dist/planegcs-backend.d.ts +46 -0
  40. package/dist/planegcs-backend.d.ts.map +1 -0
  41. package/dist/planegcs-backend.js +696 -0
  42. package/dist/planegcs-backend.js.map +1 -0
  43. package/dist/project.d.ts +115 -0
  44. package/dist/project.d.ts.map +1 -0
  45. package/dist/project.js +329 -0
  46. package/dist/project.js.map +1 -0
  47. package/dist/solve.d.ts +21 -0
  48. package/dist/solve.d.ts.map +1 -0
  49. package/dist/solve.js +102 -0
  50. package/dist/solve.js.map +1 -0
  51. package/dist/solver.d.ts +63 -0
  52. package/dist/solver.d.ts.map +1 -0
  53. package/dist/solver.js +28 -0
  54. package/dist/solver.js.map +1 -0
  55. package/dist/verify.d.ts +53 -0
  56. package/dist/verify.d.ts.map +1 -0
  57. package/dist/verify.js +71 -0
  58. package/dist/verify.js.map +1 -0
  59. package/package.json +65 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"contour.js","sourceRoot":"","sources":["../src/contour.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AA2BjD,MAAM,QAAQ,GAAG,IAAI,CAAC;AAEtB,SAAS,OAAO,CAAC,CAAkB;IACjC,QAAQ,CAAC,CAAC,IAAI,EAAE,CAAC;QACf,KAAK,MAAM;YACT,OAAO;gBACL,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC,CAAC,EAAE,EAAE,EAAE,EAAE,CAAC,CAAC,EAAE,EAAE,EAAE,EAAE,CAAC,CAAC,EAAE,EAAE,EAAE,EAAE,CAAC,CAAC,EAAE,EAAE;gBACxD,EAAE,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE;gBACpB,EAAE,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE;aACrB,CAAC;QACJ,KAAK,KAAK;YACR,OAAO;gBACL;oBACE,IAAI,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC,CAAC,EAAE,EAAE,EAAE,EAAE,CAAC,CAAC,EAAE,EAAE,MAAM,EAAE,CAAC,CAAC,MAAM;oBACjD,UAAU,EAAE,CAAC,CAAC,UAAU,EAAE,QAAQ,EAAE,CAAC,CAA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,EAAE,IAAI,CAAC,EAAE,GAAG,CAAC,EAAE,GAAG,EAAE,IAAI;wBAC/C,EAAE,EAAE,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,EAAE,CAAC,CAAC,EAAE,EAAE,EAAE,EAAE,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,EAAE,CAAC,CAAC,EAAE;qBAC7D,CAAC;gBACF,MAAM,EAAE,IAAI;aACb,CAAC,CAAC;QACL,CAAC;IACH,CAAC;IACD,OAAO,QAAQ,CAAC;AAClB,CAAC;AAED,SAAS,UAAU,CAAC,CAAa;IAC/B,IAAI,CAAC,CAAC,IAAI,KAAK,MAAM;QAAE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC,CAAC,EAAE,EAAE,EAAE,EAAE,CAAC,CAAC,EAAE,EAAE,EAAE,EAAE,CAAC,CAAC,EAAE,EAAE,EAAE,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC;IACvF,OAAO,EAAE,GAAG,CAAC,EAAE,UAAU,EAAE,CAAC,CAAC,QAAQ,EAAE,QAAQ,EAAE,CAAC,CAAC,UAAU,EAAE,GAAG,EAAE,CAAC,CAAC,CAAC,GAAG,EAAE,EAAE,EAAE,CAAC,CAAC,EAAE,EAAE,EAAE,EAAE,CAAC,CAAC,EAAE,EAAE,EAAE,EAAE,CAAC,CAAC,EAAE,EAAE,EAAE,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC;AACvH,CAAC","sourcesContent":["/**\n * M3.6 — contour extraction: solved sketch geometry → closed loops → 2D\n * contour (R6: pure data, no OCCT dependency; the cad-face wiring that turns\n * contours into Blueprint/extrude inputs happens in M4.6/M5).\n *\n * Extraction: collect endpoints of every non-construction geometry, chain\n * segments sharing endpoints (tolerance-based), keep closed loops.\n */\nimport type { FcstdSketchGeom } from './fcstd-types.js';\nimport { bsplineToSegments } from './bspline.js';\n\n/** One segment of a 2D contour: either a straight line or a circular arc (planar, sketch-local coordinates). */\nexport type ContourSeg =\n | { kind: 'line'; x1: number; y1: number; x2: number; y2: number }\n | {\n kind: 'arc';\n cx: number;\n cy: number;\n radius: number;\n startAngle: number;\n endAngle: number;\n ccw: boolean;\n x1: number;\n y1: number;\n x2: number;\n y2: number;\n };\n\n/** A chained run of segments; `closed` when the chain's ends meet (R6: pure data, no OCCT dependency). */\nexport interface Contour {\n /** chained segments in traversal order */\n segments: ContourSeg[];\n /** true when the chain's endpoints meet within JOIN_TOL */\n closed: boolean;\n}\n\nconst JOIN_TOL = 1e-7;\n\nfunction segEnds(g: FcstdSketchGeom): [ContourSeg, { x: number; y: number }, { x: number; y: number }] | undefined {\n switch (g.kind) {\n case 'line':\n return [\n { kind: 'line', x1: g.x1, y1: g.y1, x2: g.x2, y2: g.y2 },\n { x: g.x1, y: g.y1 },\n { x: g.x2, y: g.y2 },\n ];\n case 'arc':\n return [\n {\n kind: 'arc', cx: g.cx, cy: g.cy, radius: g.radius,\n startAngle: g.startAngle, endAngle: g.endAngle, ccw: true,\n x1: g.x1, y1: g.y1, x2: g.x2, y2: g.y2,\n },\n { x: g.x1, y: g.y1 },\n { x: g.x2, y: g.y2 },\n ];\n case 'bspline': {\n // P4: flatten the spline into a sampled polyline. Only the FIRST\n // sub-segment is returned here so the pool gets exactly one entry per\n // geometry (no index duplication); extractContours splices the full\n // polyline run in its place (see expandBSpline below).\n const segs = bsplineToSegments({\n poles: g.poles, knots: g.knots, degree: g.degree, periodic: g.periodic,\n });\n const first = segs[0];\n const last = segs[segs.length - 1];\n if (!first || !last) return undefined;\n return [{ kind: 'line', x1: first.x1, y1: first.y1, x2: last.x2, y2: last.y2 }, { x: first.x1, y: first.y1 }, { x: last.x2, y: last.y2 }];\n }\n default:\n return undefined; // circles are closed on their own; points don't join\n }\n}\n\n/**\n * Extract closed contours (chains of segments whose endpoints meet).\n * @param geoms solved sketch geometry to chain (non-construction segments only)\n * @returns closed loops plus self-closed circles (open chains are dropped)\n */\nexport function extractContours(geoms: FcstdSketchGeom[]): Contour[] {\n const pool: { seg: ContourSeg; a: { x: number; y: number }; b: { x: number; y: number }; used: boolean; spline?: { x1: number; y1: number; x2: number; y2: number }[] }[] = [];\n for (const g of geoms) {\n const s = segEnds(g);\n if (!s) continue;\n // P4: keep the full sampled polyline for splines — after chaining, the\n // winning seg is expanded back into all sub-segments (no interior loss).\n const spline = g.kind === 'bspline'\n ? bsplineToSegments({ poles: g.poles, knots: g.knots, degree: g.degree, periodic: g.periodic })\n : undefined;\n pool.push({ seg: s[0], a: s[1], b: s[2], used: false, spline });\n }\n\n const near = (p: { x: number; y: number }, q: { x: number; y: number }): boolean =>\n Math.hypot(p.x - q.x, p.y - q.y) <= JOIN_TOL;\n\n const contours: Contour[] = [];\n for (const start of pool) {\n if (start.used) continue;\n start.used = true;\n const head = start.a;\n // GOTCHA (slittingsaw corpus, 2026-09-20): junction points with free\n // branches (three+ segments sharing an endpoint) defeat first-come\n // chaining — a branch to a dead end consumed the segments and the real\n // loop never closed. DFS with backtracking: try each candidate\n // continuation; the FIRST chain that closes at the head wins; a dead\n // branch returns its segments to the pool. Closure-stop (tap GOTCHA) and\n // pool-restart are both subsumed by the DFS ordering.\n const dfs = (tail: { x: number; y: number }, walk: ContourSeg[]): ContourSeg[] | undefined => {\n if (walk.length > 0 && near(tail, head)) return walk;\n for (const cand of pool) {\n if (cand.used) continue;\n cand.used = true;\n if (near(tail, cand.a)) {\n const r = dfs(cand.b, [...walk, cand.seg]);\n if (r) return r;\n } else if (near(tail, cand.b)) {\n const r = dfs(cand.a, [...walk, reverseSeg(cand.seg)]);\n if (r) return r;\n }\n cand.used = false; // dead branch — return the segment to the pool\n }\n return undefined;\n };\n const solved = dfs(start.b, [start.seg]);\n if (solved && solved.length > 1) {\n // P4: replace spline proxy segs with their full sampled polyline runs.\n // The proxy seg for geometry index i sits in pool order; recover the\n // spline runs by matching the seg reference against pool entries.\n const expanded: ContourSeg[] = [];\n for (const seg of solved) {\n const entry = pool.find((e) => e.seg === seg && e.spline);\n if (entry?.spline) {\n for (const sub of entry.spline) {\n expanded.push({ kind: 'line', x1: sub.x1, y1: sub.y1, x2: sub.x2, y2: sub.y2 });\n }\n } else {\n expanded.push(seg);\n }\n }\n contours.push({ segments: expanded, closed: true });\n }\n }\n\n // circles are self-closed contours\n for (const g of geoms) {\n if (g.kind === 'circle' && g.radius > 0) {\n contours.push({\n segments: [{\n kind: 'arc', cx: g.cx, cy: g.cy, radius: g.radius,\n startAngle: 0, endAngle: Math.PI * 2, ccw: true,\n x1: g.cx + g.radius, y1: g.cy, x2: g.cx + g.radius, y2: g.cy,\n }],\n closed: true,\n });\n }\n }\n return contours;\n}\n\nfunction reverseSeg(s: ContourSeg): ContourSeg {\n if (s.kind === 'line') return { kind: 'line', x1: s.x2, y1: s.y2, x2: s.x1, y2: s.y1 };\n return { ...s, startAngle: s.endAngle, endAngle: s.startAngle, ccw: !s.ccw, x1: s.x2, y1: s.y2, x2: s.x1, y2: s.y1 };\n}\n"]}
@@ -0,0 +1,28 @@
1
+ import type { Shape } from '@faicad/faijs/mesh/types';
2
+ import type { SketchConstraint, SketchGeom, SolveOutcome } from './canonical.js';
3
+ import { type SolveSketchOptions } from './solve.js';
4
+ /** Options for {@link sketchFaces}. */
5
+ export interface SketchFacesOptions extends SolveSketchOptions {
6
+ /** Product form: `'face'` (default) builds a face; `'wire'` returns the outer wire only. */
7
+ as?: 'face' | 'wire';
8
+ /** Diagnostics observer (the script-face op forwards this to the host sink). */
9
+ onDiagnostic?: (outcome: SolveOutcome) => void;
10
+ }
11
+ /**
12
+ * Build the shape from an already-solved outcome (shared by op + wrapper).
13
+ *
14
+ * @param outcome - a converged solve outcome.
15
+ * @param as - product form: `'face'` (default) or `'wire'`.
16
+ * @returns the face or outer wire.
17
+ */
18
+ export declare function shapeFromSolved(outcome: SolveOutcome, as?: 'face' | 'wire'): Shape;
19
+ /**
20
+ * Solve a canonical sketch and build its planar face / outer wire.
21
+ *
22
+ * @param geoms - canonical geometry (stored coordinates are the initial guess).
23
+ * @param constraints - canonical constraints (default: none).
24
+ * @param opts - solver selection, product form and diagnostics observer.
25
+ * @returns the face (`as:'wire'` → the outer wire as a 1D curve).
26
+ */
27
+ export declare function sketchFaces(geoms: SketchGeom[], constraints?: SketchConstraint[], opts?: SketchFacesOptions): Promise<Shape>;
28
+ //# sourceMappingURL=faces.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"faces.d.ts","sourceRoot":"","sources":["../src/faces.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,0BAA0B,CAAA;AACrD,OAAO,KAAK,EAAE,gBAAgB,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAChF,OAAO,EAAe,KAAK,kBAAkB,EAAE,MAAM,YAAY,CAAA;AAIjE,uCAAuC;AACvC,MAAM,WAAW,kBAAmB,SAAQ,kBAAkB;IAC5D,4FAA4F;IAC5F,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;IACpB,gFAAgF;IAChF,YAAY,CAAC,EAAE,CAAC,OAAO,EAAE,YAAY,KAAK,IAAI,CAAA;CAC/C;AAED;;;;;;GAMG;AACH,wBAAgB,eAAe,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,KAAK,CAUlF;AAED;;;;;;;GAOG;AACH,wBAAsB,WAAW,CAC/B,KAAK,EAAE,UAAU,EAAE,EACnB,WAAW,GAAE,gBAAgB,EAAO,EACpC,IAAI,CAAC,EAAE,kBAAkB,GACxB,OAAO,CAAC,KAAK,CAAC,CAIhB"}
package/dist/faces.js ADDED
@@ -0,0 +1,46 @@
1
+ /**
2
+ * faces — `sketchFaces`: solve a canonical sketch, chain the solved geometry
3
+ * into closed contours and build the face through core's single face-
4
+ * construction implementation (`buildProfileShape`).
5
+ *
6
+ * The solve → contour hand-off is a distinct, failable step (§3.3): a sketch
7
+ * can solve successfully yet yield zero closed loops (dangling segments); that
8
+ * is a real failure mode and is surfaced explicitly rather than treated as a
9
+ * solved sketch.
10
+ */
11
+ import { buildProfileShape } from '@faicad/faijs/api/profile';
12
+ import { solveSketch } from './solve.js';
13
+ import { toFreeCadGeoms } from './project.js';
14
+ import { extractContours } from './contour.js';
15
+ /**
16
+ * Build the shape from an already-solved outcome (shared by op + wrapper).
17
+ *
18
+ * @param outcome - a converged solve outcome.
19
+ * @param as - product form: `'face'` (default) or `'wire'`.
20
+ * @returns the face or outer wire.
21
+ */
22
+ export function shapeFromSolved(outcome, as) {
23
+ if (!outcome.converged) {
24
+ throw new Error(`E_SKETCHC_SOLVE_FAILED: ${outcome.reason ?? outcome.status}`);
25
+ }
26
+ const contours = extractContours(toFreeCadGeoms(outcome.geoms));
27
+ if (contours.length === 0) {
28
+ throw new Error('E_SKETCHC_NO_CONTOUR: solved sketch produced no closed loop');
29
+ }
30
+ const loops = contours.map((c) => ({ segments: c.segments }));
31
+ return buildProfileShape({ contours: loops, as });
32
+ }
33
+ /**
34
+ * Solve a canonical sketch and build its planar face / outer wire.
35
+ *
36
+ * @param geoms - canonical geometry (stored coordinates are the initial guess).
37
+ * @param constraints - canonical constraints (default: none).
38
+ * @param opts - solver selection, product form and diagnostics observer.
39
+ * @returns the face (`as:'wire'` → the outer wire as a 1D curve).
40
+ */
41
+ export async function sketchFaces(geoms, constraints = [], opts) {
42
+ const outcome = await solveSketch(geoms, constraints, opts);
43
+ opts?.onDiagnostic?.(outcome);
44
+ return shapeFromSolved(outcome, opts?.as);
45
+ }
46
+ //# sourceMappingURL=faces.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"faces.js","sourceRoot":"","sources":["../src/faces.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,EAAE,iBAAiB,EAAoB,MAAM,2BAA2B,CAAA;AAG/E,OAAO,EAAE,WAAW,EAA2B,MAAM,YAAY,CAAA;AACjE,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAA;AAC7C,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA;AAU9C;;;;;;GAMG;AACH,MAAM,UAAU,eAAe,CAAC,OAAqB,EAAE,EAAoB;IACzE,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE,CAAC;QACvB,MAAM,IAAI,KAAK,CAAC,2BAA2B,OAAO,CAAC,MAAM,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC,CAAA;IAChF,CAAC;IACD,MAAM,QAAQ,GAAG,eAAe,CAAC,cAAc,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAA;IAC/D,IAAI,QAAQ,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC1B,MAAM,IAAI,KAAK,CAAC,6DAA6D,CAAC,CAAA;IAChF,CAAC;IACD,MAAM,KAAK,GAAkB,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,QAAQ,EAAE,CAAC,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAA;IAC5E,OAAO,iBAAiB,CAAC,EAAE,QAAQ,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC,CAAA;AACnD,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,CAAC,KAAK,UAAU,WAAW,CAC/B,KAAmB,EACnB,cAAkC,EAAE,EACpC,IAAyB;IAEzB,MAAM,OAAO,GAAG,MAAM,WAAW,CAAC,KAAK,EAAE,WAAW,EAAE,IAAI,CAAC,CAAA;IAC3D,IAAI,EAAE,YAAY,EAAE,CAAC,OAAO,CAAC,CAAA;IAC7B,OAAO,eAAe,CAAC,OAAO,EAAE,IAAI,EAAE,EAAE,CAAC,CAAA;AAC3C,CAAC","sourcesContent":["/**\n * faces — `sketchFaces`: solve a canonical sketch, chain the solved geometry\n * into closed contours and build the face through core's single face-\n * construction implementation (`buildProfileShape`).\n *\n * The solve → contour hand-off is a distinct, failable step (§3.3): a sketch\n * can solve successfully yet yield zero closed loops (dangling segments); that\n * is a real failure mode and is surfaced explicitly rather than treated as a\n * solved sketch.\n */\nimport { buildProfileShape, type ProfileLoop } from '@faicad/faijs/api/profile'\nimport type { Shape } from '@faicad/faijs/mesh/types'\nimport type { SketchConstraint, SketchGeom, SolveOutcome } from './canonical.js'\nimport { solveSketch, type SolveSketchOptions } from './solve.js'\nimport { toFreeCadGeoms } from './project.js'\nimport { extractContours } from './contour.js'\n\n/** Options for {@link sketchFaces}. */\nexport interface SketchFacesOptions extends SolveSketchOptions {\n /** Product form: `'face'` (default) builds a face; `'wire'` returns the outer wire only. */\n as?: 'face' | 'wire'\n /** Diagnostics observer (the script-face op forwards this to the host sink). */\n onDiagnostic?: (outcome: SolveOutcome) => void\n}\n\n/**\n * Build the shape from an already-solved outcome (shared by op + wrapper).\n *\n * @param outcome - a converged solve outcome.\n * @param as - product form: `'face'` (default) or `'wire'`.\n * @returns the face or outer wire.\n */\nexport function shapeFromSolved(outcome: SolveOutcome, as?: 'face' | 'wire'): Shape {\n if (!outcome.converged) {\n throw new Error(`E_SKETCHC_SOLVE_FAILED: ${outcome.reason ?? outcome.status}`)\n }\n const contours = extractContours(toFreeCadGeoms(outcome.geoms))\n if (contours.length === 0) {\n throw new Error('E_SKETCHC_NO_CONTOUR: solved sketch produced no closed loop')\n }\n const loops: ProfileLoop[] = contours.map((c) => ({ segments: c.segments }))\n return buildProfileShape({ contours: loops, as })\n}\n\n/**\n * Solve a canonical sketch and build its planar face / outer wire.\n *\n * @param geoms - canonical geometry (stored coordinates are the initial guess).\n * @param constraints - canonical constraints (default: none).\n * @param opts - solver selection, product form and diagnostics observer.\n * @returns the face (`as:'wire'` → the outer wire as a 1D curve).\n */\nexport async function sketchFaces(\n geoms: SketchGeom[],\n constraints: SketchConstraint[] = [],\n opts?: SketchFacesOptions,\n): Promise<Shape> {\n const outcome = await solveSketch(geoms, constraints, opts)\n opts?.onDiagnostic?.(outcome)\n return shapeFromSolved(outcome, opts?.as)\n}"]}
@@ -0,0 +1,177 @@
1
+ /**
2
+ * fcstd-types — FCStd sketch geometry / constraint model (migrated from
3
+ * `@faicad/faijs-fcstd`'s `sketch-parse.ts`, type half only).
4
+ *
5
+ * These are the FreeCAD-shaped records the solver pipeline consumes: geometry
6
+ * carries an `index` (geoId) and 3D sketch-local coordinates; constraints carry
7
+ * the `ConstraintType` integer and `(geoId, pos)` refs. The canonical,
8
+ * projection-friendly model lives in `./canonical.ts` — this module is the
9
+ * internal/FCStd-projection representation.
10
+ *
11
+ * Field format per the fcstd port plan §5.2/§5.3:
12
+ * - geometry coordinates are 3D (X/Y/Z); sketch-local Z is usually 0
13
+ * - `<Constrain>` carries Type as the ConstraintType enum integer
14
+ * - ElementIds/ElementPositions take precedence over First/Second/Third
15
+ * - IsDriving defaults to true when missing
16
+ * - geoId: >= 0 own geometry; -1 HAxis/RtPnt; -2 VAxis; <= -3 external
17
+ */
18
+ /** ConstraintType enum values (src/Mod/Sketcher/App/Constraint.h:52-77) */
19
+ export declare const ConstraintType: {
20
+ readonly Coincident: 1;
21
+ readonly Horizontal: 2;
22
+ readonly Vertical: 3;
23
+ readonly Parallel: 4;
24
+ readonly Tangent: 5;
25
+ readonly Distance: 6;
26
+ readonly DistanceX: 7;
27
+ readonly DistanceY: 8;
28
+ readonly Angle: 9;
29
+ readonly Perpendicular: 10;
30
+ readonly Radius: 11;
31
+ readonly Equal: 12;
32
+ readonly PointOnObject: 13;
33
+ readonly Symmetric: 14;
34
+ readonly InternalAlignment: 15;
35
+ readonly SnellsLaw: 16;
36
+ readonly Block: 17;
37
+ readonly Diameter: 18;
38
+ readonly Weight: 19;
39
+ readonly Group: 20;
40
+ readonly Text: 21;
41
+ };
42
+ /**
43
+ * Human-readable names for the ConstraintType enum integers (debugging/
44
+ * diagnostics only).
45
+ */
46
+ export declare const CONSTRAINT_NAMES: Record<number, string>;
47
+ /** GeoEnum (src/Mod/Sketcher/App/GeoEnum.h:71-78) */
48
+ export declare const GeoId: {
49
+ readonly RtPnt: -1;
50
+ readonly HAxis: -1;
51
+ readonly VAxis: -2;
52
+ readonly RefExt: -3;
53
+ };
54
+ /** PointPos (GeoEnum.h:88-94) */
55
+ export declare const PointPos: {
56
+ readonly none: 0;
57
+ readonly start: 1;
58
+ readonly end: 2;
59
+ readonly mid: 3;
60
+ };
61
+ /**
62
+ * One parsed sketch geometry element (point, line, circle, arc, ellipse or
63
+ * bspline), in 3D sketch-local coordinates.
64
+ */
65
+ export type FcstdSketchGeom = {
66
+ kind: 'point';
67
+ index: number;
68
+ x: number;
69
+ y: number;
70
+ z: number;
71
+ } | {
72
+ kind: 'line';
73
+ index: number;
74
+ x1: number;
75
+ y1: number;
76
+ z1: number;
77
+ x2: number;
78
+ y2: number;
79
+ z2: number;
80
+ } | {
81
+ kind: 'circle';
82
+ index: number;
83
+ cx: number;
84
+ cy: number;
85
+ cz: number;
86
+ radius: number;
87
+ } | {
88
+ kind: 'arc';
89
+ index: number;
90
+ cx: number;
91
+ cy: number;
92
+ cz: number;
93
+ radius: number;
94
+ startAngle: number;
95
+ endAngle: number;
96
+ /** arc endpoints derived from angles (kept for solver wiring) */
97
+ x1: number;
98
+ y1: number;
99
+ z1: number;
100
+ x2: number;
101
+ y2: number;
102
+ z2: number;
103
+ } | {
104
+ kind: 'ellipse';
105
+ index: number;
106
+ cx: number;
107
+ cy: number;
108
+ cz: number;
109
+ majorRadius: number;
110
+ minorRadius: number;
111
+ /** rotation of major axis, radians */
112
+ angleXU: number;
113
+ /** first focus (computed) */
114
+ fx1: number;
115
+ fy1: number;
116
+ fx2: number;
117
+ fy2: number;
118
+ } | {
119
+ /** Part::GeomBSplineCurve (Poles/Knots/Degree/IsPeriodic) */
120
+ kind: 'bspline';
121
+ index: number;
122
+ poles: {
123
+ x: number;
124
+ y: number;
125
+ }[];
126
+ knots: number[];
127
+ degree: number;
128
+ periodic: boolean;
129
+ /** curve start/end (exact for clamped splines; solver wiring + chaining) */
130
+ x1: number;
131
+ y1: number;
132
+ z1: number;
133
+ x2: number;
134
+ y2: number;
135
+ z2: number;
136
+ };
137
+ /**
138
+ * One (geometry, point) reference inside a constraint: a geoId plus a
139
+ * PointPos selector.
140
+ */
141
+ export interface FcstdGeoRef {
142
+ /** geometry id: >= 0 own geometry; -1 HAxis/RtPnt; -2 VAxis; <= -3 external */
143
+ geoId: number;
144
+ /** PointPos selector (0 = edge itself, 1/2 = start/end, 3 = center) */
145
+ pos: number;
146
+ }
147
+ /**
148
+ * One parsed sketch constraint.
149
+ */
150
+ export interface FcstdSketchCon {
151
+ /** index in the constraint list */
152
+ index: number;
153
+ /** ConstraintType integer */
154
+ type: number;
155
+ /** resolved element refs */
156
+ refs: FcstdGeoRef[];
157
+ /** driving dimension value (Distance/Angle/Radius/...) */
158
+ value: number;
159
+ /** IsDriving; missing means true */
160
+ isDriving: boolean;
161
+ /** raw name attribute */
162
+ name: string;
163
+ /** InternalAlignmentType when type === 15 */
164
+ internalAlignmentType?: number;
165
+ }
166
+ /**
167
+ * The fully parsed sketch: geometry, constraints, constrainedness and the set
168
+ * of referenced external geoIds.
169
+ */
170
+ export interface FcstdParsedSketch {
171
+ geoms: FcstdSketchGeom[];
172
+ constraints: FcstdSketchCon[];
173
+ fullyConstrained: boolean;
174
+ /** geoIds <= -3 referenced by constraints */
175
+ externalGeoIds: number[];
176
+ }
177
+ //# sourceMappingURL=fcstd-types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fcstd-types.d.ts","sourceRoot":"","sources":["../src/fcstd-types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,2EAA2E;AAC3E,eAAO,MAAM,cAAc;;;;;;;;;;;;;;;;;;;;;;CAsBjB,CAAA;AAEV;;;GAGG;AACH,eAAO,MAAM,gBAAgB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAMnD,CAAA;AAED,qDAAqD;AACrD,eAAO,MAAM,KAAK;;;;;CAKR,CAAA;AAEV,iCAAiC;AACjC,eAAO,MAAM,QAAQ;;;;;CAKX,CAA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MAAM,WAAW,iBAAiB;IAChC,KAAK,EAAE,eAAe,EAAE,CAAA;IACxB,WAAW,EAAE,cAAc,EAAE,CAAA;IAC7B,gBAAgB,EAAE,OAAO,CAAA;IACzB,6CAA6C;IAC7C,cAAc,EAAE,MAAM,EAAE,CAAA;CACzB"}
@@ -0,0 +1,67 @@
1
+ /**
2
+ * fcstd-types — FCStd sketch geometry / constraint model (migrated from
3
+ * `@faicad/faijs-fcstd`'s `sketch-parse.ts`, type half only).
4
+ *
5
+ * These are the FreeCAD-shaped records the solver pipeline consumes: geometry
6
+ * carries an `index` (geoId) and 3D sketch-local coordinates; constraints carry
7
+ * the `ConstraintType` integer and `(geoId, pos)` refs. The canonical,
8
+ * projection-friendly model lives in `./canonical.ts` — this module is the
9
+ * internal/FCStd-projection representation.
10
+ *
11
+ * Field format per the fcstd port plan §5.2/§5.3:
12
+ * - geometry coordinates are 3D (X/Y/Z); sketch-local Z is usually 0
13
+ * - `<Constrain>` carries Type as the ConstraintType enum integer
14
+ * - ElementIds/ElementPositions take precedence over First/Second/Third
15
+ * - IsDriving defaults to true when missing
16
+ * - geoId: >= 0 own geometry; -1 HAxis/RtPnt; -2 VAxis; <= -3 external
17
+ */
18
+ /** ConstraintType enum values (src/Mod/Sketcher/App/Constraint.h:52-77) */
19
+ export const ConstraintType = {
20
+ Coincident: 1,
21
+ Horizontal: 2,
22
+ Vertical: 3,
23
+ Parallel: 4,
24
+ Tangent: 5,
25
+ Distance: 6,
26
+ DistanceX: 7,
27
+ DistanceY: 8,
28
+ Angle: 9,
29
+ Perpendicular: 10,
30
+ Radius: 11,
31
+ Equal: 12,
32
+ PointOnObject: 13,
33
+ Symmetric: 14,
34
+ InternalAlignment: 15,
35
+ SnellsLaw: 16,
36
+ Block: 17,
37
+ Diameter: 18,
38
+ Weight: 19,
39
+ Group: 20,
40
+ Text: 21,
41
+ };
42
+ /**
43
+ * Human-readable names for the ConstraintType enum integers (debugging/
44
+ * diagnostics only).
45
+ */
46
+ export const CONSTRAINT_NAMES = {
47
+ 1: 'Coincident', 2: 'Horizontal', 3: 'Vertical', 4: 'Parallel', 5: 'Tangent',
48
+ 6: 'Distance', 7: 'DistanceX', 8: 'DistanceY', 9: 'Angle', 10: 'Perpendicular',
49
+ 11: 'Radius', 12: 'Equal', 13: 'PointOnObject', 14: 'Symmetric',
50
+ 15: 'InternalAlignment', 16: 'SnellsLaw', 17: 'Block', 18: 'Diameter',
51
+ 19: 'Weight', 20: 'Group', 21: 'Text',
52
+ };
53
+ /** GeoEnum (src/Mod/Sketcher/App/GeoEnum.h:71-78) */
54
+ export const GeoId = {
55
+ RtPnt: -1,
56
+ HAxis: -1,
57
+ VAxis: -2,
58
+ RefExt: -3,
59
+ };
60
+ /** PointPos (GeoEnum.h:88-94) */
61
+ export const PointPos = {
62
+ none: 0, // edge itself
63
+ start: 1,
64
+ end: 2,
65
+ mid: 3, // center of circle/ellipse
66
+ };
67
+ //# sourceMappingURL=fcstd-types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fcstd-types.js","sourceRoot":"","sources":["../src/fcstd-types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,2EAA2E;AAC3E,MAAM,CAAC,MAAM,cAAc,GAAG;IAC5B,UAAU,EAAE,CAAC;IACb,UAAU,EAAE,CAAC;IACb,QAAQ,EAAE,CAAC;IACX,QAAQ,EAAE,CAAC;IACX,OAAO,EAAE,CAAC;IACV,QAAQ,EAAE,CAAC;IACX,SAAS,EAAE,CAAC;IACZ,SAAS,EAAE,CAAC;IACZ,KAAK,EAAE,CAAC;IACR,aAAa,EAAE,EAAE;IACjB,MAAM,EAAE,EAAE;IACV,KAAK,EAAE,EAAE;IACT,aAAa,EAAE,EAAE;IACjB,SAAS,EAAE,EAAE;IACb,iBAAiB,EAAE,EAAE;IACrB,SAAS,EAAE,EAAE;IACb,KAAK,EAAE,EAAE;IACT,QAAQ,EAAE,EAAE;IACZ,MAAM,EAAE,EAAE;IACV,KAAK,EAAE,EAAE;IACT,IAAI,EAAE,EAAE;CACA,CAAA;AAEV;;;GAGG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAA2B;IACtD,CAAC,EAAE,YAAY,EAAE,CAAC,EAAE,YAAY,EAAE,CAAC,EAAE,UAAU,EAAE,CAAC,EAAE,UAAU,EAAE,CAAC,EAAE,SAAS;IAC5E,CAAC,EAAE,UAAU,EAAE,CAAC,EAAE,WAAW,EAAE,CAAC,EAAE,WAAW,EAAE,CAAC,EAAE,OAAO,EAAE,EAAE,EAAE,eAAe;IAC9E,EAAE,EAAE,QAAQ,EAAE,EAAE,EAAE,OAAO,EAAE,EAAE,EAAE,eAAe,EAAE,EAAE,EAAE,WAAW;IAC/D,EAAE,EAAE,mBAAmB,EAAE,EAAE,EAAE,WAAW,EAAE,EAAE,EAAE,OAAO,EAAE,EAAE,EAAE,UAAU;IACrE,EAAE,EAAE,QAAQ,EAAE,EAAE,EAAE,OAAO,EAAE,EAAE,EAAE,MAAM;CACtC,CAAA;AAED,qDAAqD;AACrD,MAAM,CAAC,MAAM,KAAK,GAAG;IACnB,KAAK,EAAE,CAAC,CAAC;IACT,KAAK,EAAE,CAAC,CAAC;IACT,KAAK,EAAE,CAAC,CAAC;IACT,MAAM,EAAE,CAAC,CAAC;CACF,CAAA;AAEV,iCAAiC;AACjC,MAAM,CAAC,MAAM,QAAQ,GAAG;IACtB,IAAI,EAAE,CAAC,EAAE,cAAc;IACvB,KAAK,EAAE,CAAC;IACR,GAAG,EAAE,CAAC;IACN,GAAG,EAAE,CAAC,EAAE,2BAA2B;CAC3B,CAAA","sourcesContent":["/**\n * fcstd-types — FCStd sketch geometry / constraint model (migrated from\n * `@faicad/faijs-fcstd`'s `sketch-parse.ts`, type half only).\n *\n * These are the FreeCAD-shaped records the solver pipeline consumes: geometry\n * carries an `index` (geoId) and 3D sketch-local coordinates; constraints carry\n * the `ConstraintType` integer and `(geoId, pos)` refs. The canonical,\n * projection-friendly model lives in `./canonical.ts` — this module is the\n * internal/FCStd-projection representation.\n *\n * Field format per the fcstd port plan §5.2/§5.3:\n * - geometry coordinates are 3D (X/Y/Z); sketch-local Z is usually 0\n * - `<Constrain>` carries Type as the ConstraintType enum integer\n * - ElementIds/ElementPositions take precedence over First/Second/Third\n * - IsDriving defaults to true when missing\n * - geoId: >= 0 own geometry; -1 HAxis/RtPnt; -2 VAxis; <= -3 external\n */\n\n/** ConstraintType enum values (src/Mod/Sketcher/App/Constraint.h:52-77) */\nexport const ConstraintType = {\n Coincident: 1,\n Horizontal: 2,\n Vertical: 3,\n Parallel: 4,\n Tangent: 5,\n Distance: 6,\n DistanceX: 7,\n DistanceY: 8,\n Angle: 9,\n Perpendicular: 10,\n Radius: 11,\n Equal: 12,\n PointOnObject: 13,\n Symmetric: 14,\n InternalAlignment: 15,\n SnellsLaw: 16,\n Block: 17,\n Diameter: 18,\n Weight: 19,\n Group: 20,\n Text: 21,\n} as const\n\n/**\n * Human-readable names for the ConstraintType enum integers (debugging/\n * diagnostics only).\n */\nexport const CONSTRAINT_NAMES: Record<number, string> = {\n 1: 'Coincident', 2: 'Horizontal', 3: 'Vertical', 4: 'Parallel', 5: 'Tangent',\n 6: 'Distance', 7: 'DistanceX', 8: 'DistanceY', 9: 'Angle', 10: 'Perpendicular',\n 11: 'Radius', 12: 'Equal', 13: 'PointOnObject', 14: 'Symmetric',\n 15: 'InternalAlignment', 16: 'SnellsLaw', 17: 'Block', 18: 'Diameter',\n 19: 'Weight', 20: 'Group', 21: 'Text',\n}\n\n/** GeoEnum (src/Mod/Sketcher/App/GeoEnum.h:71-78) */\nexport const GeoId = {\n RtPnt: -1,\n HAxis: -1,\n VAxis: -2,\n RefExt: -3,\n} as const\n\n/** PointPos (GeoEnum.h:88-94) */\nexport const PointPos = {\n none: 0, // edge itself\n start: 1,\n end: 2,\n mid: 3, // center of circle/ellipse\n} as const\n\n/**\n * One parsed sketch geometry element (point, line, circle, arc, ellipse or\n * bspline), in 3D sketch-local coordinates.\n */\nexport type FcstdSketchGeom =\n | { kind: 'point'; index: number; x: number; y: number; z: number }\n | { kind: 'line'; index: number; x1: number; y1: number; z1: number; x2: number; y2: number; z2: number }\n | { kind: 'circle'; index: number; cx: number; cy: number; cz: number; radius: number }\n | {\n kind: 'arc'\n index: number\n cx: number\n cy: number\n cz: number\n radius: number\n startAngle: number // radians\n endAngle: number\n /** arc endpoints derived from angles (kept for solver wiring) */\n x1: number\n y1: number\n z1: number\n x2: number\n y2: number\n z2: number\n }\n | {\n kind: 'ellipse'\n index: number\n cx: number\n cy: number\n cz: number\n majorRadius: number\n minorRadius: number\n /** rotation of major axis, radians */\n angleXU: number\n /** first focus (computed) */\n fx1: number\n fy1: number\n fx2: number\n fy2: number\n }\n | {\n /** Part::GeomBSplineCurve (Poles/Knots/Degree/IsPeriodic) */\n kind: 'bspline'\n index: number\n poles: { x: number; y: number }[]\n knots: number[]\n degree: number\n periodic: boolean\n /** curve start/end (exact for clamped splines; solver wiring + chaining) */\n x1: number\n y1: number\n z1: number\n x2: number\n y2: number\n z2: number\n }\n\n/**\n * One (geometry, point) reference inside a constraint: a geoId plus a\n * PointPos selector.\n */\nexport interface FcstdGeoRef {\n /** geometry id: >= 0 own geometry; -1 HAxis/RtPnt; -2 VAxis; <= -3 external */\n geoId: number\n /** PointPos selector (0 = edge itself, 1/2 = start/end, 3 = center) */\n pos: number // PointPos\n}\n\n/**\n * One parsed sketch constraint.\n */\nexport interface FcstdSketchCon {\n /** index in the constraint list */\n index: number\n /** ConstraintType integer */\n type: number\n /** resolved element refs */\n refs: FcstdGeoRef[]\n /** driving dimension value (Distance/Angle/Radius/...) */\n value: number\n /** IsDriving; missing means true */\n isDriving: boolean\n /** raw name attribute */\n name: string\n /** InternalAlignmentType when type === 15 */\n internalAlignmentType?: number\n}\n\n/**\n * The fully parsed sketch: geometry, constraints, constrainedness and the set\n * of referenced external geoIds.\n */\nexport interface FcstdParsedSketch {\n geoms: FcstdSketchGeom[]\n constraints: FcstdSketchCon[]\n fullyConstrained: boolean\n /** geoIds <= -3 referenced by constraints */\n externalGeoIds: number[]\n}"]}
@@ -0,0 +1,36 @@
1
+ /**
2
+ * @faicad/faijs-sketch — faijs sketch & constraint capability library.
3
+ *
4
+ * The canonical sketch model (§4) plus:
5
+ * - `solveSketch` — canonical entry to the planegcs pipeline;
6
+ * - `sketchFaces` — solve + contour + core face construction;
7
+ * - the FCStd solve pipeline (`SketchSolver` / `extractContours` / `classifySketch`)
8
+ * consumed by `@faicad/faijs-fcstd`;
9
+ * - the `cad.sketch` script-face op and its `cad`-namespace merge helpers.
10
+ *
11
+ * Node hosts import the wasm path resolver from `@faicad/faijs-sketch/node`;
12
+ * browser hosts inject wasm bytes through `HostPorts.assets`.
13
+ */
14
+ export type { At, Ref, SketchGeom, SketchConstraint, SketchConstraintKind, SketchInput, SolveStatus, SolveOutcome, } from './canonical.js';
15
+ export { SketchProjectionError, atToFreeCad, atFromFreeCad, atToCadQuery, atFromCadQuery, buildTagIndex, refToFreeCad, toFreeCadGeoms, fromFreeCadGeoms, toFreeCadConstraints, CONSTRAINT_KIND_TO_CADQUERY, CADQUERY_TO_CONSTRAINT_KIND, constraintKindToCadQuery, constraintKindFromCadQuery, } from './project.js';
16
+ export type { ProjectedConstraints } from './project.js';
17
+ export { solveSketch } from './solve.js';
18
+ export type { SolveSketchOptions } from './solve.js';
19
+ export { sketchFaces, shapeFromSolved } from './faces.js';
20
+ export type { SketchFacesOptions } from './faces.js';
21
+ export type { SketchSolver, FcstdSolveOutcome, ExternalFixedSeg } from './solver.js';
22
+ export { SUPPORTED_CONSTRAINT_TYPES, allConstraintsSupported } from './solver.js';
23
+ export { createPlanegcsSolver, PlanegcsSolver } from './planegcs-backend.js';
24
+ export type { PlanegcsSolverOptions } from './planegcs-backend.js';
25
+ export { extractContours } from './contour.js';
26
+ export type { Contour, ContourSeg } from './contour.js';
27
+ export { evalBSpline, sampleBSpline, bsplineToSegments } from './bspline.js';
28
+ export type { BSPole, BSplineCurveData } from './bspline.js';
29
+ export { anchorPoints, maxPointDistance, classifySketch } from './verify.js';
30
+ export type { SketchVerdict } from './verify.js';
31
+ export { ConstraintType, CONSTRAINT_NAMES, GeoId, PointPos, } from './fcstd-types.js';
32
+ export type { FcstdSketchGeom, FcstdGeoRef, FcstdSketchCon, FcstdParsedSketch, } from './fcstd-types.js';
33
+ export { sketch, assertSketchParams, installSketchSolver, uninstallSketchSolver, setSketchDiagnosticSink, SKETCH_OP_NAME, } from './op.js';
34
+ export type { SketchParams } from './op.js';
35
+ export { createSketchNamespace, mergeSketchNamespace, createSketchCadNamespace, registerSketchSymbols, unregisterSketchSymbols, SKETCH_OPS, } from './namespace.js';
36
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAGH,YAAY,EACV,EAAE,EAAE,GAAG,EAAE,UAAU,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,WAAW,EACxE,WAAW,EAAE,YAAY,GAC1B,MAAM,gBAAgB,CAAA;AAGvB,OAAO,EACL,qBAAqB,EACrB,WAAW,EAAE,aAAa,EAAE,YAAY,EAAE,cAAc,EACxD,aAAa,EAAE,YAAY,EAC3B,cAAc,EAAE,gBAAgB,EAChC,oBAAoB,EACpB,2BAA2B,EAAE,2BAA2B,EACxD,wBAAwB,EAAE,0BAA0B,GACrD,MAAM,cAAc,CAAA;AACrB,YAAY,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAA;AAGxD,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAA;AACxC,YAAY,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAA;AACpD,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,YAAY,CAAA;AACzD,YAAY,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAA;AAGpD,YAAY,EAAE,YAAY,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAA;AACpF,OAAO,EAAE,0BAA0B,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAA;AACjF,OAAO,EAAE,oBAAoB,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAA;AAC5E,YAAY,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAA;AAClE,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA;AAC9C,YAAY,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AACvD,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAA;AAC5E,YAAY,EAAE,MAAM,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAA;AAC5D,OAAO,EAAE,YAAY,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AAC5E,YAAY,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAChD,OAAO,EACL,cAAc,EAAE,gBAAgB,EAAE,KAAK,EAAE,QAAQ,GAClD,MAAM,kBAAkB,CAAA;AACzB,YAAY,EACV,eAAe,EAAE,WAAW,EAAE,cAAc,EAAE,iBAAiB,GAChE,MAAM,kBAAkB,CAAA;AAGzB,OAAO,EACL,MAAM,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,qBAAqB,EACtE,uBAAuB,EAAE,cAAc,GACxC,MAAM,SAAS,CAAA;AAChB,YAAY,EAAE,YAAY,EAAE,MAAM,SAAS,CAAA;AAC3C,OAAO,EACL,qBAAqB,EAAE,oBAAoB,EAAE,wBAAwB,EACrE,qBAAqB,EAAE,uBAAuB,EAAE,UAAU,GAC3D,MAAM,gBAAgB,CAAA"}
package/dist/index.js ADDED
@@ -0,0 +1,28 @@
1
+ /**
2
+ * @faicad/faijs-sketch — faijs sketch & constraint capability library.
3
+ *
4
+ * The canonical sketch model (§4) plus:
5
+ * - `solveSketch` — canonical entry to the planegcs pipeline;
6
+ * - `sketchFaces` — solve + contour + core face construction;
7
+ * - the FCStd solve pipeline (`SketchSolver` / `extractContours` / `classifySketch`)
8
+ * consumed by `@faicad/faijs-fcstd`;
9
+ * - the `cad.sketch` script-face op and its `cad`-namespace merge helpers.
10
+ *
11
+ * Node hosts import the wasm path resolver from `@faicad/faijs-sketch/node`;
12
+ * browser hosts inject wasm bytes through `HostPorts.assets`.
13
+ */
14
+ // ── projection table (§4.5) ──
15
+ export { SketchProjectionError, atToFreeCad, atFromFreeCad, atToCadQuery, atFromCadQuery, buildTagIndex, refToFreeCad, toFreeCadGeoms, fromFreeCadGeoms, toFreeCadConstraints, CONSTRAINT_KIND_TO_CADQUERY, CADQUERY_TO_CONSTRAINT_KIND, constraintKindToCadQuery, constraintKindFromCadQuery, } from './project.js';
16
+ // ── solve + faces ──
17
+ export { solveSketch } from './solve.js';
18
+ export { sketchFaces, shapeFromSolved } from './faces.js';
19
+ export { SUPPORTED_CONSTRAINT_TYPES, allConstraintsSupported } from './solver.js';
20
+ export { createPlanegcsSolver, PlanegcsSolver } from './planegcs-backend.js';
21
+ export { extractContours } from './contour.js';
22
+ export { evalBSpline, sampleBSpline, bsplineToSegments } from './bspline.js';
23
+ export { anchorPoints, maxPointDistance, classifySketch } from './verify.js';
24
+ export { ConstraintType, CONSTRAINT_NAMES, GeoId, PointPos, } from './fcstd-types.js';
25
+ // ── cad.sketch op + namespace assembly ──
26
+ export { sketch, assertSketchParams, installSketchSolver, uninstallSketchSolver, setSketchDiagnosticSink, SKETCH_OP_NAME, } from './op.js';
27
+ export { createSketchNamespace, mergeSketchNamespace, createSketchCadNamespace, registerSketchSymbols, unregisterSketchSymbols, SKETCH_OPS, } from './namespace.js';
28
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAQH,gCAAgC;AAChC,OAAO,EACL,qBAAqB,EACrB,WAAW,EAAE,aAAa,EAAE,YAAY,EAAE,cAAc,EACxD,aAAa,EAAE,YAAY,EAC3B,cAAc,EAAE,gBAAgB,EAChC,oBAAoB,EACpB,2BAA2B,EAAE,2BAA2B,EACxD,wBAAwB,EAAE,0BAA0B,GACrD,MAAM,cAAc,CAAA;AAGrB,sBAAsB;AACtB,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAA;AAExC,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,YAAY,CAAA;AAKzD,OAAO,EAAE,0BAA0B,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAA;AACjF,OAAO,EAAE,oBAAoB,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAA;AAE5E,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA;AAE9C,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAA;AAE5E,OAAO,EAAE,YAAY,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AAE5E,OAAO,EACL,cAAc,EAAE,gBAAgB,EAAE,KAAK,EAAE,QAAQ,GAClD,MAAM,kBAAkB,CAAA;AAKzB,2CAA2C;AAC3C,OAAO,EACL,MAAM,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,qBAAqB,EACtE,uBAAuB,EAAE,cAAc,GACxC,MAAM,SAAS,CAAA;AAEhB,OAAO,EACL,qBAAqB,EAAE,oBAAoB,EAAE,wBAAwB,EACrE,qBAAqB,EAAE,uBAAuB,EAAE,UAAU,GAC3D,MAAM,gBAAgB,CAAA","sourcesContent":["/**\n * @faicad/faijs-sketch — faijs sketch & constraint capability library.\n *\n * The canonical sketch model (§4) plus:\n * - `solveSketch` — canonical entry to the planegcs pipeline;\n * - `sketchFaces` — solve + contour + core face construction;\n * - the FCStd solve pipeline (`SketchSolver` / `extractContours` / `classifySketch`)\n * consumed by `@faicad/faijs-fcstd`;\n * - the `cad.sketch` script-face op and its `cad`-namespace merge helpers.\n *\n * Node hosts import the wasm path resolver from `@faicad/faijs-sketch/node`;\n * browser hosts inject wasm bytes through `HostPorts.assets`.\n */\n\n// ── canonical model (§4) ──\nexport type {\n At, Ref, SketchGeom, SketchConstraint, SketchConstraintKind, SketchInput,\n SolveStatus, SolveOutcome,\n} from './canonical.js'\n\n// ── projection table (§4.5) ──\nexport {\n SketchProjectionError,\n atToFreeCad, atFromFreeCad, atToCadQuery, atFromCadQuery,\n buildTagIndex, refToFreeCad,\n toFreeCadGeoms, fromFreeCadGeoms,\n toFreeCadConstraints,\n CONSTRAINT_KIND_TO_CADQUERY, CADQUERY_TO_CONSTRAINT_KIND,\n constraintKindToCadQuery, constraintKindFromCadQuery,\n} from './project.js'\nexport type { ProjectedConstraints } from './project.js'\n\n// ── solve + faces ──\nexport { solveSketch } from './solve.js'\nexport type { SolveSketchOptions } from './solve.js'\nexport { sketchFaces, shapeFromSolved } from './faces.js'\nexport type { SketchFacesOptions } from './faces.js'\n\n// ── FCStd solve pipeline (consumed by the fcstd port) ──\nexport type { SketchSolver, FcstdSolveOutcome, ExternalFixedSeg } from './solver.js'\nexport { SUPPORTED_CONSTRAINT_TYPES, allConstraintsSupported } from './solver.js'\nexport { createPlanegcsSolver, PlanegcsSolver } from './planegcs-backend.js'\nexport type { PlanegcsSolverOptions } from './planegcs-backend.js'\nexport { extractContours } from './contour.js'\nexport type { Contour, ContourSeg } from './contour.js'\nexport { evalBSpline, sampleBSpline, bsplineToSegments } from './bspline.js'\nexport type { BSPole, BSplineCurveData } from './bspline.js'\nexport { anchorPoints, maxPointDistance, classifySketch } from './verify.js'\nexport type { SketchVerdict } from './verify.js'\nexport {\n ConstraintType, CONSTRAINT_NAMES, GeoId, PointPos,\n} from './fcstd-types.js'\nexport type {\n FcstdSketchGeom, FcstdGeoRef, FcstdSketchCon, FcstdParsedSketch,\n} from './fcstd-types.js'\n\n// ── cad.sketch op + namespace assembly ──\nexport {\n sketch, assertSketchParams, installSketchSolver, uninstallSketchSolver,\n setSketchDiagnosticSink, SKETCH_OP_NAME,\n} from './op.js'\nexport type { SketchParams } from './op.js'\nexport {\n createSketchNamespace, mergeSketchNamespace, createSketchCadNamespace,\n registerSketchSymbols, unregisterSketchSymbols, SKETCH_OPS,\n} from './namespace.js'"]}
@@ -0,0 +1,51 @@
1
+ /**
2
+ * namespace — assemble and merge the sketch op into a host's `cad` namespace.
3
+ *
4
+ * Mirrors `@faicad/faijs-extra`'s pattern: core's `createApiNamespace()` carries
5
+ * the platform surface only; this library exports the sketch op plus a merge
6
+ * function and symbol registration, and the host decides whether to fold it in:
7
+ *
8
+ * ```ts
9
+ * import { createRuntime } from '@faicad/faijs/browser'
10
+ * import { createSketchCadNamespace, registerSketchSymbols, installSketchSolver }
11
+ * from '@faicad/faijs-sketch'
12
+ * import { createNodePlanegcsSolver } from '@faicad/faijs-sketch/node'
13
+ *
14
+ * const rt = createRuntime(ports, mode)
15
+ * rt.registerLib('cad', createSketchCadNamespace(), { default: true })
16
+ * registerSketchSymbols()
17
+ * installSketchSolver(createNodePlanegcsSolver)
18
+ * ```
19
+ */
20
+ import { type StdlibNamespace } from '@faicad/faijs/runtime-state';
21
+ /** The op names this library contributes to the `cad` namespace. */
22
+ export declare const SKETCH_OPS: readonly ["sketch"];
23
+ /**
24
+ * Assemble the sketch-owned op set into a `cad`-shaped namespace fragment.
25
+ *
26
+ * @returns the sketch namespace fragment.
27
+ */
28
+ export declare function createSketchNamespace(): StdlibNamespace;
29
+ /**
30
+ * Merge the sketch namespace over a platform namespace.
31
+ *
32
+ * Pure: no registration side effects. Sketch keys win on collision.
33
+ *
34
+ * @param platform - the platform namespace (`createApiNamespace()`).
35
+ * @returns the merged namespace to register as the host's `cad` library.
36
+ */
37
+ export declare function mergeSketchNamespace(platform: StdlibNamespace): StdlibNamespace;
38
+ /**
39
+ * The `cad` namespace a host registers: core's platform surface plus the sketch op.
40
+ *
41
+ * @returns the namespace to hand to `registerLib('cad', …)`.
42
+ */
43
+ export declare function createSketchCadNamespace(): StdlibNamespace;
44
+ /**
45
+ * Register the sketch op name in the core symbol table, so static analysis that
46
+ * reads `SYMBOL_TABLE` recognises `cad.sketch`.
47
+ */
48
+ export declare function registerSketchSymbols(): void;
49
+ /** Undo {@link registerSketchSymbols}. */
50
+ export declare function unregisterSketchSymbols(): void;
51
+ //# sourceMappingURL=namespace.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"namespace.d.ts","sourceRoot":"","sources":["../src/namespace.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AACH,OAAO,EAAoB,KAAK,eAAe,EAAE,MAAM,6BAA6B,CAAA;AAKpF,oEAAoE;AACpE,eAAO,MAAM,UAAU,qBAA4B,CAAA;AAEnD;;;;GAIG;AACH,wBAAgB,qBAAqB,IAAI,eAAe,CAKvD;AAED;;;;;;;GAOG;AACH,wBAAgB,oBAAoB,CAAC,QAAQ,EAAE,eAAe,GAAG,eAAe,CAE/E;AAED;;;;GAIG;AACH,wBAAgB,wBAAwB,IAAI,eAAe,CAE1D;AAED;;;GAGG;AACH,wBAAgB,qBAAqB,IAAI,IAAI,CAE5C;AAED,0CAA0C;AAC1C,wBAAgB,uBAAuB,IAAI,IAAI,CAE9C"}
@@ -0,0 +1,67 @@
1
+ /**
2
+ * namespace — assemble and merge the sketch op into a host's `cad` namespace.
3
+ *
4
+ * Mirrors `@faicad/faijs-extra`'s pattern: core's `createApiNamespace()` carries
5
+ * the platform surface only; this library exports the sketch op plus a merge
6
+ * function and symbol registration, and the host decides whether to fold it in:
7
+ *
8
+ * ```ts
9
+ * import { createRuntime } from '@faicad/faijs/browser'
10
+ * import { createSketchCadNamespace, registerSketchSymbols, installSketchSolver }
11
+ * from '@faicad/faijs-sketch'
12
+ * import { createNodePlanegcsSolver } from '@faicad/faijs-sketch/node'
13
+ *
14
+ * const rt = createRuntime(ports, mode)
15
+ * rt.registerLib('cad', createSketchCadNamespace(), { default: true })
16
+ * registerSketchSymbols()
17
+ * installSketchSolver(createNodePlanegcsSolver)
18
+ * ```
19
+ */
20
+ import { CONTRACT_VERSION } from '@faicad/faijs/runtime-state';
21
+ import { registerSymbolTableEntries, unregisterSymbolTableEntries } from '@faicad/faijs/symbol-table';
22
+ import { createApiNamespace } from '@faicad/faijs/api/api-namespace';
23
+ import { SKETCH_OP_NAME, sketch } from './op.js';
24
+ /** The op names this library contributes to the `cad` namespace. */
25
+ export const SKETCH_OPS = [SKETCH_OP_NAME];
26
+ /**
27
+ * Assemble the sketch-owned op set into a `cad`-shaped namespace fragment.
28
+ *
29
+ * @returns the sketch namespace fragment.
30
+ */
31
+ export function createSketchNamespace() {
32
+ return {
33
+ contractVersion: CONTRACT_VERSION,
34
+ sketch,
35
+ };
36
+ }
37
+ /**
38
+ * Merge the sketch namespace over a platform namespace.
39
+ *
40
+ * Pure: no registration side effects. Sketch keys win on collision.
41
+ *
42
+ * @param platform - the platform namespace (`createApiNamespace()`).
43
+ * @returns the merged namespace to register as the host's `cad` library.
44
+ */
45
+ export function mergeSketchNamespace(platform) {
46
+ return { ...platform, ...createSketchNamespace() };
47
+ }
48
+ /**
49
+ * The `cad` namespace a host registers: core's platform surface plus the sketch op.
50
+ *
51
+ * @returns the namespace to hand to `registerLib('cad', …)`.
52
+ */
53
+ export function createSketchCadNamespace() {
54
+ return mergeSketchNamespace(createApiNamespace());
55
+ }
56
+ /**
57
+ * Register the sketch op name in the core symbol table, so static analysis that
58
+ * reads `SYMBOL_TABLE` recognises `cad.sketch`.
59
+ */
60
+ export function registerSketchSymbols() {
61
+ registerSymbolTableEntries(SKETCH_OPS);
62
+ }
63
+ /** Undo {@link registerSketchSymbols}. */
64
+ export function unregisterSketchSymbols() {
65
+ unregisterSymbolTableEntries(SKETCH_OPS);
66
+ }
67
+ //# sourceMappingURL=namespace.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"namespace.js","sourceRoot":"","sources":["../src/namespace.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AACH,OAAO,EAAE,gBAAgB,EAAwB,MAAM,6BAA6B,CAAA;AACpF,OAAO,EAAE,0BAA0B,EAAE,4BAA4B,EAAE,MAAM,4BAA4B,CAAA;AACrG,OAAO,EAAE,kBAAkB,EAAE,MAAM,iCAAiC,CAAA;AACpE,OAAO,EAAE,cAAc,EAAE,MAAM,EAAE,MAAM,SAAS,CAAA;AAEhD,oEAAoE;AACpE,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,cAAc,CAAU,CAAA;AAEnD;;;;GAIG;AACH,MAAM,UAAU,qBAAqB;IACnC,OAAO;QACL,eAAe,EAAE,gBAAgB;QACjC,MAAM;KACuB,CAAA;AACjC,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,oBAAoB,CAAC,QAAyB;IAC5D,OAAO,EAAE,GAAG,QAAQ,EAAE,GAAG,qBAAqB,EAAE,EAAE,CAAA;AACpD,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,wBAAwB;IACtC,OAAO,oBAAoB,CAAC,kBAAkB,EAAE,CAAC,CAAA;AACnD,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,qBAAqB;IACnC,0BAA0B,CAAC,UAAU,CAAC,CAAA;AACxC,CAAC;AAED,0CAA0C;AAC1C,MAAM,UAAU,uBAAuB;IACrC,4BAA4B,CAAC,UAAU,CAAC,CAAA;AAC1C,CAAC","sourcesContent":["/**\n * namespace — assemble and merge the sketch op into a host's `cad` namespace.\n *\n * Mirrors `@faicad/faijs-extra`'s pattern: core's `createApiNamespace()` carries\n * the platform surface only; this library exports the sketch op plus a merge\n * function and symbol registration, and the host decides whether to fold it in:\n *\n * ```ts\n * import { createRuntime } from '@faicad/faijs/browser'\n * import { createSketchCadNamespace, registerSketchSymbols, installSketchSolver }\n * from '@faicad/faijs-sketch'\n * import { createNodePlanegcsSolver } from '@faicad/faijs-sketch/node'\n *\n * const rt = createRuntime(ports, mode)\n * rt.registerLib('cad', createSketchCadNamespace(), { default: true })\n * registerSketchSymbols()\n * installSketchSolver(createNodePlanegcsSolver)\n * ```\n */\nimport { CONTRACT_VERSION, type StdlibNamespace } from '@faicad/faijs/runtime-state'\nimport { registerSymbolTableEntries, unregisterSymbolTableEntries } from '@faicad/faijs/symbol-table'\nimport { createApiNamespace } from '@faicad/faijs/api/api-namespace'\nimport { SKETCH_OP_NAME, sketch } from './op.js'\n\n/** The op names this library contributes to the `cad` namespace. */\nexport const SKETCH_OPS = [SKETCH_OP_NAME] as const\n\n/**\n * Assemble the sketch-owned op set into a `cad`-shaped namespace fragment.\n *\n * @returns the sketch namespace fragment.\n */\nexport function createSketchNamespace(): StdlibNamespace {\n return {\n contractVersion: CONTRACT_VERSION,\n sketch,\n } as unknown as StdlibNamespace\n}\n\n/**\n * Merge the sketch namespace over a platform namespace.\n *\n * Pure: no registration side effects. Sketch keys win on collision.\n *\n * @param platform - the platform namespace (`createApiNamespace()`).\n * @returns the merged namespace to register as the host's `cad` library.\n */\nexport function mergeSketchNamespace(platform: StdlibNamespace): StdlibNamespace {\n return { ...platform, ...createSketchNamespace() }\n}\n\n/**\n * The `cad` namespace a host registers: core's platform surface plus the sketch op.\n *\n * @returns the namespace to hand to `registerLib('cad', …)`.\n */\nexport function createSketchCadNamespace(): StdlibNamespace {\n return mergeSketchNamespace(createApiNamespace())\n}\n\n/**\n * Register the sketch op name in the core symbol table, so static analysis that\n * reads `SYMBOL_TABLE` recognises `cad.sketch`.\n */\nexport function registerSketchSymbols(): void {\n registerSymbolTableEntries(SKETCH_OPS)\n}\n\n/** Undo {@link registerSketchSymbols}. */\nexport function unregisterSketchSymbols(): void {\n unregisterSymbolTableEntries(SKETCH_OPS)\n}"]}
package/dist/node.d.ts ADDED
@@ -0,0 +1,14 @@
1
+ import type { SketchSolver } from './solver.js';
2
+ /**
3
+ * Resolve the planegcs WASM binary path from the installed package.
4
+ *
5
+ * @returns the absolute path of `planegcs.wasm` inside `@salusoft89/planegcs`.
6
+ */
7
+ export declare function planegcsWasmPath(): string;
8
+ /**
9
+ * Instantiate the planegcs solver using the installed wasm binary.
10
+ *
11
+ * @returns a `SketchSolver` backed by the planegcs WASM module.
12
+ */
13
+ export declare function createNodePlanegcsSolver(): Promise<SketchSolver>;
14
+ //# sourceMappingURL=node.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"node.d.ts","sourceRoot":"","sources":["../src/node.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAM/C;;;;GAIG;AACH,wBAAgB,gBAAgB,IAAI,MAAM,CAMzC;AAED;;;;GAIG;AACH,wBAAsB,wBAAwB,IAAI,OAAO,CAAC,YAAY,CAAC,CAEtE"}