@faicad/faijs 0.33.1 → 0.35.2
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.
- package/dist/api/api-namespace.d.ts +14 -14
- package/dist/api/api-namespace.d.ts.map +1 -1
- package/dist/api/api-namespace.js +40 -14
- package/dist/api/api-namespace.js.map +1 -1
- package/dist/api/appearance.d.ts +47 -6
- package/dist/api/appearance.d.ts.map +1 -1
- package/dist/api/appearance.js.map +1 -1
- package/dist/api/assembly/solve-tree.d.ts +1 -0
- package/dist/api/assembly/solve-tree.d.ts.map +1 -1
- package/dist/api/assembly/solve-tree.js +42 -17
- package/dist/api/assembly/solve-tree.js.map +1 -1
- package/dist/api/assembly/solve.d.ts +1 -0
- package/dist/api/assembly/solve.d.ts.map +1 -1
- package/dist/api/assembly/solve.js.map +1 -1
- package/dist/api/assembly/solvers/global-solver.d.ts.map +1 -1
- package/dist/api/assembly/solvers/global-solver.js +130 -23
- package/dist/api/assembly/solvers/global-solver.js.map +1 -1
- package/dist/api/assembly/solvers/pose-from-delta.d.ts +9 -0
- package/dist/api/assembly/solvers/pose-from-delta.d.ts.map +1 -1
- package/dist/api/assembly/solvers/pose-from-delta.js +23 -0
- package/dist/api/assembly/solvers/pose-from-delta.js.map +1 -1
- package/dist/api/assembly/solvers/types.d.ts +20 -2
- package/dist/api/assembly/solvers/types.d.ts.map +1 -1
- package/dist/api/assembly/solvers/types.js.map +1 -1
- package/dist/api/chamfer.d.ts +7 -4
- package/dist/api/chamfer.d.ts.map +1 -1
- package/dist/api/chamfer.js +57 -13
- package/dist/api/chamfer.js.map +1 -1
- package/dist/api/draft.d.ts +7 -4
- package/dist/api/draft.d.ts.map +1 -1
- package/dist/api/draft.js +11 -6
- package/dist/api/draft.js.map +1 -1
- package/dist/api/edge-ref.d.ts +4 -4
- package/dist/api/edge-ref.js +4 -4
- package/dist/api/edge-ref.js.map +1 -1
- package/dist/api/extrude.d.ts +10 -6
- package/dist/api/extrude.d.ts.map +1 -1
- package/dist/api/extrude.js +50 -25
- package/dist/api/extrude.js.map +1 -1
- package/dist/api/face-ref.d.ts +4 -4
- package/dist/api/face-ref.js +4 -4
- package/dist/api/face-ref.js.map +1 -1
- package/dist/api/feature-repair.d.ts +6 -3
- package/dist/api/feature-repair.d.ts.map +1 -1
- package/dist/api/feature-repair.js +12 -7
- package/dist/api/feature-repair.js.map +1 -1
- package/dist/api/fillet-variable.d.ts +6 -2
- package/dist/api/fillet-variable.d.ts.map +1 -1
- package/dist/api/fillet-variable.js +24 -6
- package/dist/api/fillet-variable.js.map +1 -1
- package/dist/api/fillet.d.ts +7 -4
- package/dist/api/fillet.d.ts.map +1 -1
- package/dist/api/fillet.js +45 -12
- package/dist/api/fillet.js.map +1 -1
- package/dist/api/helix.d.ts +13 -13
- package/dist/api/helix.d.ts.map +1 -1
- package/dist/api/helix.js +19 -24
- package/dist/api/helix.js.map +1 -1
- package/dist/api/import-brep.d.ts +10 -18
- package/dist/api/import-brep.d.ts.map +1 -1
- package/dist/api/import-brep.js +17 -25
- package/dist/api/import-brep.js.map +1 -1
- package/dist/api/import-step.d.ts +10 -15
- package/dist/api/import-step.d.ts.map +1 -1
- package/dist/api/import-step.js +24 -29
- package/dist/api/import-step.js.map +1 -1
- package/dist/api/index.js +2 -2
- package/dist/api/index.js.map +1 -1
- package/dist/api/internal/export-members.js.map +1 -1
- package/dist/api/loft-advanced.d.ts +4 -0
- package/dist/api/loft-advanced.d.ts.map +1 -1
- package/dist/api/loft-advanced.js +4 -0
- package/dist/api/loft-advanced.js.map +1 -1
- package/dist/api/loft.d.ts +5 -3
- package/dist/api/loft.d.ts.map +1 -1
- package/dist/api/loft.js +5 -3
- package/dist/api/loft.js.map +1 -1
- package/dist/api/meta.d.ts +42 -6
- package/dist/api/meta.d.ts.map +1 -1
- package/dist/api/meta.js.map +1 -1
- package/dist/api/punch-hole.d.ts +5 -2
- package/dist/api/punch-hole.d.ts.map +1 -1
- package/dist/api/punch-hole.js +4 -1
- package/dist/api/punch-hole.js.map +1 -1
- package/dist/api/replicate.d.ts +4 -5
- package/dist/api/replicate.d.ts.map +1 -1
- package/dist/api/replicate.js +4 -5
- package/dist/api/replicate.js.map +1 -1
- package/dist/api/selectors-to-refs.d.ts +83 -0
- package/dist/api/selectors-to-refs.d.ts.map +1 -0
- package/dist/api/selectors-to-refs.js +211 -0
- package/dist/api/selectors-to-refs.js.map +1 -0
- package/dist/api/shell.d.ts +17 -8
- package/dist/api/shell.d.ts.map +1 -1
- package/dist/api/shell.js +45 -15
- package/dist/api/shell.js.map +1 -1
- package/dist/api/sketch-on-face.d.ts +12 -6
- package/dist/api/sketch-on-face.d.ts.map +1 -1
- package/dist/api/sketch-on-face.js +31 -4
- package/dist/api/sketch-on-face.js.map +1 -1
- package/dist/api/sketch-on-plane.d.ts +3 -0
- package/dist/api/sketch-on-plane.d.ts.map +1 -1
- package/dist/api/sketch-on-plane.js +3 -0
- package/dist/api/sketch-on-plane.js.map +1 -1
- package/dist/api/sketch-on-surface.d.ts +4 -1
- package/dist/api/sketch-on-surface.d.ts.map +1 -1
- package/dist/api/sketch-on-surface.js +4 -1
- package/dist/api/sketch-on-surface.js.map +1 -1
- package/dist/api/view/view-projection.d.ts.map +1 -1
- package/dist/api/view/view-projection.js +9 -2
- package/dist/api/view/view-projection.js.map +1 -1
- package/dist/brep/brep-chain.js +2 -2
- package/dist/brep/brep-chain.js.map +1 -1
- package/dist/brep/brep-ops.d.ts +1 -1
- package/dist/brep/brep-ops.js +1 -1
- package/dist/brep/brep-ops.js.map +1 -1
- package/dist/brep/engine/adapters/brep-mock.d.ts.map +1 -1
- package/dist/brep/engine/adapters/brep-mock.js +45 -0
- package/dist/brep/engine/adapters/brep-mock.js.map +1 -1
- package/dist/brep/engine/primitives.d.ts +87 -3
- package/dist/brep/engine/primitives.d.ts.map +1 -1
- package/dist/brep/engine/primitives.js +1 -1
- package/dist/brep/engine/primitives.js.map +1 -1
- package/dist/brep/engine/registry.d.ts +33 -7
- package/dist/brep/engine/registry.d.ts.map +1 -1
- package/dist/brep/engine/registry.js +47 -16
- package/dist/brep/engine/registry.js.map +1 -1
- package/dist/brep/handle-bridge.d.ts +14 -15
- package/dist/brep/handle-bridge.d.ts.map +1 -1
- package/dist/brep/handle-bridge.js +35 -15
- package/dist/brep/handle-bridge.js.map +1 -1
- package/dist/brep/primitives-brep.js +2 -2
- package/dist/brep/primitives-brep.js.map +1 -1
- package/dist/brep/text/text-to-solid.d.ts +40 -3
- package/dist/brep/text/text-to-solid.d.ts.map +1 -1
- package/dist/brep/text/text-to-solid.js +104 -24
- package/dist/brep/text/text-to-solid.js.map +1 -1
- package/dist/brepkit-kernel/brepkitKernel.d.ts +2 -2
- package/dist/brepkit-kernel/brepkitKernel.d.ts.map +1 -1
- package/dist/brepkit-kernel/brepkitKernel.js +315 -36
- package/dist/brepkit-kernel/brepkitKernel.js.map +1 -1
- package/dist/brepkit-kernel/brepkitWasm.js +7 -7
- package/dist/brepkit-kernel/brepkitWasm.js.map +1 -1
- package/dist/brepkit-kernel/multi-version-test.d.ts +2 -2
- package/dist/brepkit-kernel/multi-version-test.d.ts.map +1 -1
- package/dist/brepkit-kernel/multi-version-test.js +6 -6
- package/dist/brepkit-kernel/multi-version-test.js.map +1 -1
- package/dist/browser.d.ts +2 -3
- package/dist/browser.d.ts.map +1 -1
- package/dist/browser.js +1 -2
- package/dist/browser.js.map +1 -1
- package/dist/cad-runtime/admit-compat-lib.d.ts +9 -1
- package/dist/cad-runtime/admit-compat-lib.d.ts.map +1 -1
- package/dist/cad-runtime/admit-compat-lib.js +11 -1
- package/dist/cad-runtime/admit-compat-lib.js.map +1 -1
- package/dist/cad-runtime/browser-lib-loader.d.ts +16 -11
- package/dist/cad-runtime/browser-lib-loader.d.ts.map +1 -1
- package/dist/cad-runtime/browser-lib-loader.js +16 -8
- package/dist/cad-runtime/browser-lib-loader.js.map +1 -1
- package/dist/cad-runtime/direct-executor.d.ts +62 -5
- package/dist/cad-runtime/direct-executor.d.ts.map +1 -1
- package/dist/cad-runtime/direct-executor.js +617 -42
- package/dist/cad-runtime/direct-executor.js.map +1 -1
- package/dist/cad-runtime/interp/closure.d.ts +3 -2
- package/dist/cad-runtime/interp/closure.d.ts.map +1 -1
- package/dist/cad-runtime/interp/closure.js.map +1 -1
- package/dist/cad-runtime/interp/env.d.ts +9 -6
- package/dist/cad-runtime/interp/env.d.ts.map +1 -1
- package/dist/cad-runtime/interp/env.js +4 -2
- package/dist/cad-runtime/interp/env.js.map +1 -1
- package/dist/cad-runtime/lib-decl.d.ts +121 -0
- package/dist/cad-runtime/lib-decl.d.ts.map +1 -0
- package/dist/cad-runtime/lib-decl.js +100 -0
- package/dist/cad-runtime/lib-decl.js.map +1 -0
- package/dist/cad-runtime/ports.d.ts +12 -0
- package/dist/cad-runtime/ports.d.ts.map +1 -1
- package/dist/cad-runtime/ports.js.map +1 -1
- package/dist/cad-runtime/runtime.d.ts +59 -5
- package/dist/cad-runtime/runtime.d.ts.map +1 -1
- package/dist/cad-runtime/runtime.js +237 -18
- package/dist/cad-runtime/runtime.js.map +1 -1
- package/dist/extra/browser.d.ts +9 -0
- package/dist/extra/browser.d.ts.map +1 -0
- package/dist/extra/browser.js +9 -0
- package/dist/extra/browser.js.map +1 -0
- package/dist/extra/editor-ops.d.ts +22 -0
- package/dist/extra/editor-ops.d.ts.map +1 -0
- package/dist/extra/editor-ops.js +21 -0
- package/dist/extra/editor-ops.js.map +1 -0
- package/dist/extra/extras/svg-extrude.d.ts +45 -0
- package/dist/extra/extras/svg-extrude.d.ts.map +1 -0
- package/dist/extra/extras/svg-extrude.js +110 -0
- package/dist/extra/extras/svg-extrude.js.map +1 -0
- package/dist/extra/extras/text-cjk.d.ts +36 -0
- package/dist/extra/extras/text-cjk.d.ts.map +1 -0
- package/dist/extra/extras/text-cjk.js +86 -0
- package/dist/extra/extras/text-cjk.js.map +1 -0
- package/dist/extra/extras/text-geometry.d.ts +69 -0
- package/dist/extra/extras/text-geometry.d.ts.map +1 -0
- package/dist/extra/extras/text-geometry.js +188 -0
- package/dist/extra/extras/text-geometry.js.map +1 -0
- package/dist/extra/index.d.ts +40 -0
- package/dist/extra/index.d.ts.map +1 -0
- package/dist/extra/index.js +40 -0
- package/dist/extra/index.js.map +1 -0
- package/dist/extra/mesh/drill-hole/DrillHoleCore.d.ts +94 -0
- package/dist/extra/mesh/drill-hole/DrillHoleCore.d.ts.map +1 -0
- package/dist/extra/mesh/drill-hole/DrillHoleCore.js +282 -0
- package/dist/extra/mesh/drill-hole/DrillHoleCore.js.map +1 -0
- package/dist/extra/mesh/drill-hole/drill-types.d.ts +34 -0
- package/dist/extra/mesh/drill-hole/drill-types.d.ts.map +1 -0
- package/dist/extra/mesh/drill-hole/drill-types.js +7 -0
- package/dist/extra/mesh/drill-hole/drill-types.js.map +1 -0
- package/dist/extra/mesh/engrave-decoration.d.ts +42 -0
- package/dist/extra/mesh/engrave-decoration.d.ts.map +1 -0
- package/dist/extra/mesh/engrave-decoration.js +39 -0
- package/dist/extra/mesh/engrave-decoration.js.map +1 -0
- package/dist/extra/mesh/fai_drill.d.ts +21 -0
- package/dist/extra/mesh/fai_drill.d.ts.map +1 -0
- package/dist/extra/mesh/fai_drill.js +89 -0
- package/dist/extra/mesh/fai_drill.js.map +1 -0
- package/dist/extra/mesh/fai_extrude.d.ts +24 -0
- package/dist/extra/mesh/fai_extrude.d.ts.map +1 -0
- package/dist/extra/mesh/fai_extrude.js +42 -0
- package/dist/extra/mesh/fai_extrude.js.map +1 -0
- package/dist/extra/mesh/fai_split.d.ts +164 -0
- package/dist/extra/mesh/fai_split.d.ts.map +1 -0
- package/dist/extra/mesh/fai_split.js +269 -0
- package/dist/extra/mesh/fai_split.js.map +1 -0
- package/dist/extra/mesh/primitives.d.ts +29 -0
- package/dist/extra/mesh/primitives.d.ts.map +1 -0
- package/dist/extra/mesh/primitives.js +41 -0
- package/dist/extra/mesh/primitives.js.map +1 -0
- package/dist/extra/op-names.d.ts +37 -0
- package/dist/extra/op-names.d.ts.map +1 -0
- package/dist/extra/op-names.js +46 -0
- package/dist/extra/op-names.js.map +1 -0
- package/dist/extra/ops/compound.d.ts +140 -0
- package/dist/extra/ops/compound.d.ts.map +1 -0
- package/dist/extra/ops/compound.js +167 -0
- package/dist/extra/ops/compound.js.map +1 -0
- package/dist/extra/ops/copy.d.ts +40 -0
- package/dist/extra/ops/copy.d.ts.map +1 -0
- package/dist/extra/ops/copy.js +83 -0
- package/dist/extra/ops/copy.js.map +1 -0
- package/dist/extra/ops/fai_drill.d.ts +51 -0
- package/dist/extra/ops/fai_drill.d.ts.map +1 -0
- package/dist/extra/ops/fai_drill.js +233 -0
- package/dist/extra/ops/fai_drill.js.map +1 -0
- package/dist/extra/ops/fai_extrude.d.ts +36 -0
- package/dist/extra/ops/fai_extrude.d.ts.map +1 -0
- package/dist/extra/ops/fai_extrude.js +84 -0
- package/dist/extra/ops/fai_extrude.js.map +1 -0
- package/dist/extra/ops/fai_split.d.ts +46 -0
- package/dist/extra/ops/fai_split.d.ts.map +1 -0
- package/dist/extra/ops/fai_split.js +235 -0
- package/dist/extra/ops/fai_split.js.map +1 -0
- package/dist/extra/ops/load.d.ts +49 -0
- package/dist/extra/ops/load.d.ts.map +1 -0
- package/dist/extra/ops/load.js +385 -0
- package/dist/extra/ops/load.js.map +1 -0
- package/dist/extra/ops/svg-extrude.d.ts +32 -0
- package/dist/extra/ops/svg-extrude.d.ts.map +1 -0
- package/dist/extra/ops/svg-extrude.js +74 -0
- package/dist/extra/ops/svg-extrude.js.map +1 -0
- package/dist/extra/ops/text.d.ts +34 -0
- package/dist/extra/ops/text.d.ts.map +1 -0
- package/dist/extra/ops/text.js +100 -0
- package/dist/extra/ops/text.js.map +1 -0
- package/dist/geometry2d/bridge/lift-on-plane.d.ts +8 -5
- package/dist/geometry2d/bridge/lift-on-plane.d.ts.map +1 -1
- package/dist/geometry2d/bridge/lift-on-plane.js +8 -5
- package/dist/geometry2d/bridge/lift-on-plane.js.map +1 -1
- package/dist/index.d.ts +6 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +8 -2
- package/dist/index.js.map +1 -1
- package/dist/lang/symbol-table.d.ts +3 -3
- package/dist/lang/symbol-table.generated.d.ts +10 -0
- package/dist/lang/symbol-table.generated.d.ts.map +1 -1
- package/dist/lang/symbol-table.generated.js +10 -0
- package/dist/lang/symbol-table.generated.js.map +1 -1
- package/dist/lang/symbol-table.js +3 -3
- package/dist/lang/symbol-table.js.map +1 -1
- package/dist/math3d/index.d.ts +1 -1
- package/dist/math3d/index.js +1 -1
- package/dist/math3d/index.js.map +1 -1
- package/dist/mesh/engrave.d.ts +2 -3
- package/dist/mesh/engrave.d.ts.map +1 -1
- package/dist/mesh/engrave.js +4 -11
- package/dist/mesh/engrave.js.map +1 -1
- package/dist/mesh/index.d.ts +0 -2
- package/dist/mesh/index.d.ts.map +1 -1
- package/dist/mesh/index.js +0 -2
- package/dist/mesh/index.js.map +1 -1
- package/dist/mesh/primitives.d.ts +1 -1
- package/dist/mesh/primitives.js +1 -1
- package/dist/mesh/primitives.js.map +1 -1
- package/dist/node-host/cli.d.ts +20 -4
- package/dist/node-host/cli.d.ts.map +1 -1
- package/dist/node-host/cli.js +84 -35
- package/dist/node-host/cli.js.map +1 -1
- package/dist/node-host/execute-script.d.ts.map +1 -1
- package/dist/node-host/execute-script.js +3 -4
- package/dist/node-host/execute-script.js.map +1 -1
- package/dist/node-host/lib-package-json.d.ts +36 -0
- package/dist/node-host/lib-package-json.d.ts.map +1 -0
- package/dist/node-host/lib-package-json.js +73 -0
- package/dist/node-host/lib-package-json.js.map +1 -0
- package/dist/occt-kernel/occt-primitives.d.ts.map +1 -1
- package/dist/occt-kernel/occt-primitives.js +41 -0
- package/dist/occt-kernel/occt-primitives.js.map +1 -1
- package/dist/occt-kernel/occtKernel.d.ts +1 -1
- package/dist/occt-kernel/occtKernel.js +1 -1
- package/dist/occt-kernel/occtKernel.js.map +1 -1
- package/dist/runtime-state.d.ts +28 -1
- package/dist/runtime-state.d.ts.map +1 -1
- package/dist/runtime-state.js +14 -1
- package/dist/runtime-state.js.map +1 -1
- package/dist/sdk.d.ts +2 -2
- package/dist/sdk.d.ts.map +1 -1
- package/dist/sdk.js +11 -2
- package/dist/sdk.js.map +1 -1
- package/dist/sketch/bspline.d.ts +58 -0
- package/dist/sketch/bspline.d.ts.map +1 -0
- package/dist/sketch/bspline.js +104 -0
- package/dist/sketch/bspline.js.map +1 -0
- package/dist/sketch/canonical.d.ts +239 -0
- package/dist/sketch/canonical.d.ts.map +1 -0
- package/dist/sketch/canonical.js +17 -0
- package/dist/sketch/canonical.js.map +1 -0
- package/dist/sketch/contour.d.ts +43 -0
- package/dist/sketch/contour.d.ts.map +1 -0
- package/dist/sketch/contour.js +202 -0
- package/dist/sketch/contour.js.map +1 -0
- package/dist/sketch/dim-spec.d.ts +32 -0
- package/dist/sketch/dim-spec.d.ts.map +1 -0
- package/dist/sketch/dim-spec.js +112 -0
- package/dist/sketch/dim-spec.js.map +1 -0
- package/dist/sketch/faces.d.ts +45 -0
- package/dist/sketch/faces.d.ts.map +1 -0
- package/dist/sketch/faces.js +108 -0
- package/dist/sketch/faces.js.map +1 -0
- package/dist/sketch/fcstd-types.d.ts +194 -0
- package/dist/sketch/fcstd-types.d.ts.map +1 -0
- package/dist/sketch/fcstd-types.js +67 -0
- package/dist/sketch/fcstd-types.js.map +1 -0
- package/dist/sketch/index.d.ts +46 -0
- package/dist/sketch/index.d.ts.map +1 -0
- package/dist/sketch/index.js +39 -0
- package/dist/sketch/index.js.map +1 -0
- package/dist/sketch/node.d.ts +14 -0
- package/dist/sketch/node.d.ts.map +1 -0
- package/dist/sketch/node.js +43 -0
- package/dist/sketch/node.js.map +1 -0
- package/dist/sketch/op.d.ts +111 -0
- package/dist/sketch/op.d.ts.map +1 -0
- package/dist/sketch/op.js +185 -0
- package/dist/sketch/op.js.map +1 -0
- package/dist/sketch/planegcs-backend.d.ts +69 -0
- package/dist/sketch/planegcs-backend.d.ts.map +1 -0
- package/dist/sketch/planegcs-backend.js +812 -0
- package/dist/sketch/planegcs-backend.js.map +1 -0
- package/dist/sketch/project.d.ts +176 -0
- package/dist/sketch/project.d.ts.map +1 -0
- package/dist/sketch/project.js +656 -0
- package/dist/sketch/project.js.map +1 -0
- package/dist/sketch/shapes.d.ts +370 -0
- package/dist/sketch/shapes.d.ts.map +1 -0
- package/dist/sketch/shapes.js +959 -0
- package/dist/sketch/shapes.js.map +1 -0
- package/dist/sketch/solve.d.ts +21 -0
- package/dist/sketch/solve.d.ts.map +1 -0
- package/dist/sketch/solve.js +144 -0
- package/dist/sketch/solve.js.map +1 -0
- package/dist/sketch/solver-loader.d.ts +47 -0
- package/dist/sketch/solver-loader.d.ts.map +1 -0
- package/dist/sketch/solver-loader.js +77 -0
- package/dist/sketch/solver-loader.js.map +1 -0
- package/dist/sketch/solver.d.ts +63 -0
- package/dist/sketch/solver.d.ts.map +1 -0
- package/dist/sketch/solver.js +28 -0
- package/dist/sketch/solver.js.map +1 -0
- package/dist/sketch/verify.d.ts +53 -0
- package/dist/sketch/verify.d.ts.map +1 -0
- package/dist/sketch/verify.js +71 -0
- package/dist/sketch/verify.js.map +1 -0
- package/dist/weapp.d.ts +1 -1
- package/dist/weapp.d.ts.map +1 -1
- package/dist/weapp.js +1 -1
- package/dist/weapp.js.map +1 -1
- package/package.json +43 -11
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @faicad/faijs/sketch — faijs sketch & constraint capability.
|
|
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
|
+
* - the `cad.sketch` script-face op.
|
|
9
|
+
*
|
|
10
|
+
* The cad namespace is now fully assembled inside `createApiNamespace()`;
|
|
11
|
+
* hosts no longer need to merge/register sketch symbols. Solver wasm is
|
|
12
|
+
* injected via `setSketchSolverInitFn()` (see `./solver-loader`).
|
|
13
|
+
*
|
|
14
|
+
* Node-only symbols (`planegcsWasmPath`, `createNodePlanegcsSolver`) are
|
|
15
|
+
* deliberately NOT re-exported from this entry — `./node.js` statically
|
|
16
|
+
* imports `node:module` / `node:path`, and a static re-export would drag
|
|
17
|
+
* `node:*` into browser/worker bundles. They live on the dedicated
|
|
18
|
+
* `@faicad/faijs/sketch/node` subpath (guarded by
|
|
19
|
+
* `test/sketch/sketch-entry-browser.test.ts`).
|
|
20
|
+
*/
|
|
21
|
+
export type { At, Ref, SketchGeom, SketchConstraint, SketchConstraintKind, SketchInput, SolveStatus, SolveOutcome, ConflictDetail, } from './canonical.js';
|
|
22
|
+
export { SketchProjectionError, atToFreeCad, atFromFreeCad, atToCadQuery, atFromCadQuery, buildTagIndex, refToFreeCad, toFreeCadGeoms, fromFreeCadGeoms, toFreeCadConstraints, fromFreeCadConstraints, CONSTRAINT_KIND_TO_CADQUERY, CADQUERY_TO_CONSTRAINT_KIND, constraintKindToCadQuery, constraintKindFromCadQuery, } from './project.js';
|
|
23
|
+
export type { ProjectedConstraints, UnmappedConstraint, FromFreeCadConstraints } from './project.js';
|
|
24
|
+
export { solveSketch } from './solve.js';
|
|
25
|
+
export type { SolveSketchOptions } from './solve.js';
|
|
26
|
+
export { sketchFaces, shapeFromSolved } from './faces.js';
|
|
27
|
+
export type { SketchFacesOptions } from './faces.js';
|
|
28
|
+
export { expandShapes, nextShapeTag, shapeHandles, dragShapeHandle, handleForGeomControl, refsOfConstraint, SketchShapeError, rectCorners, regularPolygonVertices, slotOutline, trapezoidCorners, clampedUniformKnots, arcPoints, arcSweep, } from './shapes.js';
|
|
29
|
+
export type { SketchShape, SketchMode, ShapeBase, ShapeSpan, ExpandedShapes, ShapeHandle, ShapeHandleKind, GeomControl, Pt2, } from './shapes.js';
|
|
30
|
+
export { shapesDimSpec, constraintsDimSpec, sketchDimSpec } from './dim-spec.js';
|
|
31
|
+
export type { SketchSolver, FcstdSolveOutcome, ExternalFixedSeg } from './solver.js';
|
|
32
|
+
export { SUPPORTED_CONSTRAINT_TYPES, allConstraintsSupported } from './solver.js';
|
|
33
|
+
export { createPlanegcsSolver, PlanegcsSolver } from './planegcs-backend.js';
|
|
34
|
+
export type { PlanegcsSolverOptions } from './planegcs-backend.js';
|
|
35
|
+
export { extractContours } from './contour.js';
|
|
36
|
+
export type { Contour, ContourSeg } from './contour.js';
|
|
37
|
+
export { evalBSpline, sampleBSpline, bsplineToSegments } from './bspline.js';
|
|
38
|
+
export type { BSPole, BSplineCurveData } from './bspline.js';
|
|
39
|
+
export { anchorPoints, maxPointDistance, classifySketch } from './verify.js';
|
|
40
|
+
export type { SketchVerdict } from './verify.js';
|
|
41
|
+
export { ConstraintType, CONSTRAINT_NAMES, GeoId, PointPos, } from './fcstd-types.js';
|
|
42
|
+
export type { FcstdSketchGeom, FcstdGeoRef, FcstdSketchCon, FcstdParsedSketch, } from './fcstd-types.js';
|
|
43
|
+
export { sketch, assertSketchParams, installSketchSolver, uninstallSketchSolver, setSketchDiagnosticSink, SKETCH_OP_NAME, } from './op.js';
|
|
44
|
+
export type { SketchParams } from './op.js';
|
|
45
|
+
export { setSketchSolverInitFn, initSketchSolver, } from './solver-loader.js';
|
|
46
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/sketch/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAGH,YAAY,EACV,EAAE,EAAE,GAAG,EAAE,UAAU,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,WAAW,EACxE,WAAW,EAAE,YAAY,EAAE,cAAc,GAC1C,MAAM,gBAAgB,CAAA;AAGvB,OAAO,EACL,qBAAqB,EACrB,WAAW,EAAE,aAAa,EAAE,YAAY,EAAE,cAAc,EACxD,aAAa,EA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AE,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,gBAAgB,GACxC,MAAM,oBAAoB,CAAA"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @faicad/faijs/sketch — faijs sketch & constraint capability.
|
|
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
|
+
* - the `cad.sketch` script-face op.
|
|
9
|
+
*
|
|
10
|
+
* The cad namespace is now fully assembled inside `createApiNamespace()`;
|
|
11
|
+
* hosts no longer need to merge/register sketch symbols. Solver wasm is
|
|
12
|
+
* injected via `setSketchSolverInitFn()` (see `./solver-loader`).
|
|
13
|
+
*
|
|
14
|
+
* Node-only symbols (`planegcsWasmPath`, `createNodePlanegcsSolver`) are
|
|
15
|
+
* deliberately NOT re-exported from this entry — `./node.js` statically
|
|
16
|
+
* imports `node:module` / `node:path`, and a static re-export would drag
|
|
17
|
+
* `node:*` into browser/worker bundles. They live on the dedicated
|
|
18
|
+
* `@faicad/faijs/sketch/node` subpath (guarded by
|
|
19
|
+
* `test/sketch/sketch-entry-browser.test.ts`).
|
|
20
|
+
*/
|
|
21
|
+
// ── projection table (§4.5) ──
|
|
22
|
+
export { SketchProjectionError, atToFreeCad, atFromFreeCad, atToCadQuery, atFromCadQuery, buildTagIndex, refToFreeCad, toFreeCadGeoms, fromFreeCadGeoms, toFreeCadConstraints, fromFreeCadConstraints, CONSTRAINT_KIND_TO_CADQUERY, CADQUERY_TO_CONSTRAINT_KIND, constraintKindToCadQuery, constraintKindFromCadQuery, } from './project.js';
|
|
23
|
+
// ── solve + faces ──
|
|
24
|
+
export { solveSketch } from './solve.js';
|
|
25
|
+
export { sketchFaces, shapeFromSolved } from './faces.js';
|
|
26
|
+
// ── semantic shape surface (`cad.sketch({ shapes })`) ──
|
|
27
|
+
export { expandShapes, nextShapeTag, shapeHandles, dragShapeHandle, handleForGeomControl, refsOfConstraint, SketchShapeError, rectCorners, regularPolygonVertices, slotOutline, trapezoidCorners, clampedUniformKnots, arcPoints, arcSweep, } from './shapes.js';
|
|
28
|
+
// ── serialize dimension spec (`cad.sketch` unit-aware codegen) ──
|
|
29
|
+
export { shapesDimSpec, constraintsDimSpec, sketchDimSpec } from './dim-spec.js';
|
|
30
|
+
export { SUPPORTED_CONSTRAINT_TYPES, allConstraintsSupported } from './solver.js';
|
|
31
|
+
export { createPlanegcsSolver, PlanegcsSolver } from './planegcs-backend.js';
|
|
32
|
+
export { extractContours } from './contour.js';
|
|
33
|
+
export { evalBSpline, sampleBSpline, bsplineToSegments } from './bspline.js';
|
|
34
|
+
export { anchorPoints, maxPointDistance, classifySketch } from './verify.js';
|
|
35
|
+
export { ConstraintType, CONSTRAINT_NAMES, GeoId, PointPos, } from './fcstd-types.js';
|
|
36
|
+
// ── cad.sketch op ──
|
|
37
|
+
export { sketch, assertSketchParams, installSketchSolver, uninstallSketchSolver, setSketchDiagnosticSink, SKETCH_OP_NAME, } from './op.js';
|
|
38
|
+
export { setSketchSolverInitFn, initSketchSolver, } from './solver-loader.js';
|
|
39
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/sketch/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAQH,gCAAgC;AAChC,OAAO,EACL,qBAAqB,EACrB,WAAW,EAAE,aAAa,EAAE,YAAY,EAAE,cAAc,EACxD,aAAa,EAAE,YAAY,EAC3B,cAAc,EAAE,gBAAgB,EAChC,oBAAoB,EAAE,sBAAsB,EAC5C,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;AAGzD,0DAA0D;AAC1D,OAAO,EACL,YAAY,EAAE,YAAY,EAAE,YAAY,EAAE,eAAe,EAAE,oBAAoB,EAC/E,gBAAgB,EAChB,gBAAgB,EAChB,WAAW,EAAE,sBAAsB,EAAE,WAAW,EAAE,gBAAgB,EAAE,mBAAmB,EACvF,SAAS,EAAE,QAAQ,GACpB,MAAM,aAAa,CAAA;AAMpB,mEAAmE;AACnE,OAAO,EAAE,aAAa,EAAE,kBAAkB,EAAE,aAAa,EAAE,MAAM,eAAe,CAAA;AAIhF,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,sBAAsB;AACtB,OAAO,EACL,MAAM,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,qBAAqB,EACtE,uBAAuB,EAAE,cAAc,GACxC,MAAM,SAAS,CAAA;AAEhB,OAAO,EACL,qBAAqB,EAAE,gBAAgB,GACxC,MAAM,oBAAoB,CAAA","sourcesContent":["/**\n * @faicad/faijs/sketch — faijs sketch & constraint capability.\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 * - the `cad.sketch` script-face op.\n *\n * The cad namespace is now fully assembled inside `createApiNamespace()`;\n * hosts no longer need to merge/register sketch symbols. Solver wasm is\n * injected via `setSketchSolverInitFn()` (see `./solver-loader`).\n *\n * Node-only symbols (`planegcsWasmPath`, `createNodePlanegcsSolver`) are\n * deliberately NOT re-exported from this entry — `./node.js` statically\n * imports `node:module` / `node:path`, and a static re-export would drag\n * `node:*` into browser/worker bundles. They live on the dedicated\n * `@faicad/faijs/sketch/node` subpath (guarded by\n * `test/sketch/sketch-entry-browser.test.ts`).\n */\n\n// ── canonical model (§4) ──\nexport type {\n At, Ref, SketchGeom, SketchConstraint, SketchConstraintKind, SketchInput,\n SolveStatus, SolveOutcome, ConflictDetail,\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, fromFreeCadConstraints,\n CONSTRAINT_KIND_TO_CADQUERY, CADQUERY_TO_CONSTRAINT_KIND,\n constraintKindToCadQuery, constraintKindFromCadQuery,\n} from './project.js'\nexport type { ProjectedConstraints, UnmappedConstraint, FromFreeCadConstraints } 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// ── semantic shape surface (`cad.sketch({ shapes })`) ──\nexport {\n expandShapes, nextShapeTag, shapeHandles, dragShapeHandle, handleForGeomControl,\n refsOfConstraint,\n SketchShapeError,\n rectCorners, regularPolygonVertices, slotOutline, trapezoidCorners, clampedUniformKnots,\n arcPoints, arcSweep,\n} from './shapes.js'\nexport type {\n SketchShape, SketchMode, ShapeBase, ShapeSpan, ExpandedShapes,\n ShapeHandle, ShapeHandleKind, GeomControl, Pt2,\n} from './shapes.js'\n\n// ── serialize dimension spec (`cad.sketch` unit-aware codegen) ──\nexport { shapesDimSpec, constraintsDimSpec, sketchDimSpec } from './dim-spec.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 ──\nexport {\n sketch, assertSketchParams, installSketchSolver, uninstallSketchSolver,\n setSketchDiagnosticSink, SKETCH_OP_NAME,\n} from './op.js'\nexport type { SketchParams } from './op.js'\nexport {\n setSketchSolverInitFn, initSketchSolver,\n} from './solver-loader.js'"]}
|
|
@@ -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/sketch/node.ts"],"names":[],"mappings":"AAoBA,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"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @faicad/faijs/sketch/node — Node-only sketch solver entry.
|
|
3
|
+
*
|
|
4
|
+
* Resolves the planegcs WASM binary from the installed package and creates
|
|
5
|
+
* a solver. In the merged-core model, Node hosts do NOT need to call this
|
|
6
|
+
* explicitly — `initSketchSolver()` (from `./solver-loader`) auto-resolves
|
|
7
|
+
* the wasm path when running under Node. This entry is retained for
|
|
8
|
+
* downstream consumers that import it directly (e.g. faijs-cadquery).
|
|
9
|
+
*
|
|
10
|
+
* Browser/worker hosts must NOT import this subpath — they call
|
|
11
|
+
* `setSketchSolverInitFn()` with a factory that knows the wasm URL.
|
|
12
|
+
*
|
|
13
|
+
* This module is NOT re-exported from `./index.ts` (the main `@faicad/faijs/sketch`
|
|
14
|
+
* entry): its top-level `node:module` / `node:path` imports would leak into
|
|
15
|
+
* browser bundles through a static re-export. It is reachable only via the
|
|
16
|
+
* dedicated `@faicad/faijs/sketch/node` subpath.
|
|
17
|
+
*/
|
|
18
|
+
import { createRequire } from 'node:module';
|
|
19
|
+
import { dirname, join } from 'node:path';
|
|
20
|
+
import { createPlanegcsSolver } from './planegcs-backend.js';
|
|
21
|
+
const require = createRequire(import.meta.url);
|
|
22
|
+
let wasmPathCache;
|
|
23
|
+
/**
|
|
24
|
+
* Resolve the planegcs WASM binary path from the installed package.
|
|
25
|
+
*
|
|
26
|
+
* @returns the absolute path of `planegcs.wasm` inside `@salusoft89/planegcs`.
|
|
27
|
+
*/
|
|
28
|
+
export function planegcsWasmPath() {
|
|
29
|
+
if (!wasmPathCache) {
|
|
30
|
+
const pkgDir = dirname(require.resolve('@salusoft89/planegcs/package.json'));
|
|
31
|
+
wasmPathCache = join(pkgDir, 'dist', 'planegcs_dist', 'planegcs.wasm');
|
|
32
|
+
}
|
|
33
|
+
return wasmPathCache;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Instantiate the planegcs solver using the installed wasm binary.
|
|
37
|
+
*
|
|
38
|
+
* @returns a `SketchSolver` backed by the planegcs WASM module.
|
|
39
|
+
*/
|
|
40
|
+
export async function createNodePlanegcsSolver() {
|
|
41
|
+
return createPlanegcsSolver({ wasmPath: planegcsWasmPath() });
|
|
42
|
+
}
|
|
43
|
+
//# sourceMappingURL=node.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"node.js","sourceRoot":"","sources":["../../src/sketch/node.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AACH,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAC3C,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AACzC,OAAO,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAA;AAG5D,MAAM,OAAO,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;AAE9C,IAAI,aAAiC,CAAA;AAErC;;;;GAIG;AACH,MAAM,UAAU,gBAAgB;IAC9B,IAAI,CAAC,aAAa,EAAE,CAAC;QACnB,MAAM,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,mCAAmC,CAAC,CAAC,CAAA;QAC5E,aAAa,GAAG,IAAI,CAAC,MAAM,EAAE,MAAM,EAAE,eAAe,EAAE,eAAe,CAAC,CAAA;IACxE,CAAC;IACD,OAAO,aAAa,CAAA;AACtB,CAAC;AAED;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,wBAAwB;IAC5C,OAAO,oBAAoB,CAAC,EAAE,QAAQ,EAAE,gBAAgB,EAAE,EAAE,CAAC,CAAA;AAC/D,CAAC","sourcesContent":["/**\n * @faicad/faijs/sketch/node — Node-only sketch solver entry.\n *\n * Resolves the planegcs WASM binary from the installed package and creates\n * a solver. In the merged-core model, Node hosts do NOT need to call this\n * explicitly — `initSketchSolver()` (from `./solver-loader`) auto-resolves\n * the wasm path when running under Node. This entry is retained for\n * downstream consumers that import it directly (e.g. faijs-cadquery).\n *\n * Browser/worker hosts must NOT import this subpath — they call\n * `setSketchSolverInitFn()` with a factory that knows the wasm URL.\n *\n * This module is NOT re-exported from `./index.ts` (the main `@faicad/faijs/sketch`\n * entry): its top-level `node:module` / `node:path` imports would leak into\n * browser bundles through a static re-export. It is reachable only via the\n * dedicated `@faicad/faijs/sketch/node` subpath.\n */\nimport { createRequire } from 'node:module'\nimport { dirname, join } from 'node:path'\nimport { createPlanegcsSolver } from './planegcs-backend.js'\nimport type { SketchSolver } from './solver.js'\n\nconst require = createRequire(import.meta.url)\n\nlet wasmPathCache: string | undefined\n\n/**\n * Resolve the planegcs WASM binary path from the installed package.\n *\n * @returns the absolute path of `planegcs.wasm` inside `@salusoft89/planegcs`.\n */\nexport function planegcsWasmPath(): string {\n if (!wasmPathCache) {\n const pkgDir = dirname(require.resolve('@salusoft89/planegcs/package.json'))\n wasmPathCache = join(pkgDir, 'dist', 'planegcs_dist', 'planegcs.wasm')\n }\n return wasmPathCache\n}\n\n/**\n * Instantiate the planegcs solver using the installed wasm binary.\n *\n * @returns a `SketchSolver` backed by the planegcs WASM module.\n */\nexport async function createNodePlanegcsSolver(): Promise<SketchSolver> {\n return createPlanegcsSolver({ wasmPath: planegcsWasmPath() })\n}\n"]}
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import type { Shape } from '../mesh/types.js';
|
|
2
|
+
import type { SketchConstraint, SketchGeom, SolveOutcome } from './canonical.js';
|
|
3
|
+
import { type SketchShape } from './shapes.js';
|
|
4
|
+
import type { SketchSolver, ExternalFixedSeg } from './solver.js';
|
|
5
|
+
/** The op name `cad.sketch`. */
|
|
6
|
+
export declare const SKETCH_OP_NAME: "sketch";
|
|
7
|
+
/**
|
|
8
|
+
* Install the host's planegcs solver factory (deprecated alias).
|
|
9
|
+
*
|
|
10
|
+
* Use `setSketchSolverInitFn` from `./solver-loader` instead. This alias
|
|
11
|
+
* is retained for one release to avoid breaking downstream call sites.
|
|
12
|
+
*
|
|
13
|
+
* @param factory - async factory returning a `SketchSolver`.
|
|
14
|
+
*/
|
|
15
|
+
export declare function installSketchSolver(factory: () => Promise<SketchSolver>): void;
|
|
16
|
+
/** Undo {@link installSketchSolver}. */
|
|
17
|
+
export declare function uninstallSketchSolver(): void;
|
|
18
|
+
/**
|
|
19
|
+
* Install a diagnostics sink for non-`solved` outcomes (§5: allow ≠ silent).
|
|
20
|
+
*
|
|
21
|
+
* Hosts bridge this to their `HostPorts.events` sink / UI. Under-, redundant-
|
|
22
|
+
* and conflicting-constraint sketches still produce geometry, but the
|
|
23
|
+
* diagnostic must reach the host.
|
|
24
|
+
*
|
|
25
|
+
* @param sink - receives every non-`solved` solve outcome; `null` clears it.
|
|
26
|
+
*/
|
|
27
|
+
export declare function setSketchDiagnosticSink(sink: ((outcome: SolveOutcome) => void) | null): void;
|
|
28
|
+
/** `cad.sketch` parameters. */
|
|
29
|
+
export interface SketchParams {
|
|
30
|
+
/**
|
|
31
|
+
* 语义图元清单(**与 `geoms` 二选一**):矩形/圆/圆角矩形/椭圆/正多边形/长圆槽/梯形
|
|
32
|
+
* + 画笔图元(线/弧/样条/点)+ `close`。脚本面推荐这一形态——"画矩形"在语句里
|
|
33
|
+
* 就是矩形,而不是 4 条线 + 8 条约束(铺开由库面 `expandShapes` 一处负责)。
|
|
34
|
+
*/
|
|
35
|
+
shapes?: SketchShape[];
|
|
36
|
+
/** 展开后的 canonical 几何(**与 `shapes` 二选一**;存量语句继续用这一形态)。 */
|
|
37
|
+
geoms?: SketchGeom[];
|
|
38
|
+
/** Optional — a constraint-free sketch is equivalent to `cad.profile` usage. */
|
|
39
|
+
constraints?: SketchConstraint[];
|
|
40
|
+
/** Product form: `'face'` (default) or `'wire'` (outer wire for sweep spines). */
|
|
41
|
+
as?: 'face' | 'wire';
|
|
42
|
+
/**
|
|
43
|
+
* Named plane (`'XY'` default; e.g. `'XZ'` / `'YZ'`) or an explicit plane
|
|
44
|
+
* frame (A3, 2026-09-28): `{ origin, normal, xAxis? }` — places the solved
|
|
45
|
+
* contours on an arbitrary plane in one step (the sketchOnPlane hand-off;
|
|
46
|
+
* no post-hoc `cad.place` needed).
|
|
47
|
+
*/
|
|
48
|
+
plane?: string | {
|
|
49
|
+
origin: [number, number, number];
|
|
50
|
+
normal: [number, number, number];
|
|
51
|
+
xAxis?: [number, number, number];
|
|
52
|
+
};
|
|
53
|
+
/**
|
|
54
|
+
* Fixed external geometry the constraints may reference (IRON RULE patch,
|
|
55
|
+
* 2026-10-04): each entry is the converter-resolved polyline of one external
|
|
56
|
+
* geoId (geoId <= -3), pinned as fixed solver points so external refs
|
|
57
|
+
* resolve STATICALLY — a ref with no matching entry here is an unresolvable
|
|
58
|
+
* constraint, not a run-time guess.
|
|
59
|
+
*/
|
|
60
|
+
external?: ExternalFixedSeg[];
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Validate `cad.sketch` parameters: **exactly one** of `shapes` / `geoms` must be a
|
|
64
|
+
* non-empty array, `constraints` (when present) an array, `plane` a named plane or
|
|
65
|
+
* an explicit frame.
|
|
66
|
+
*
|
|
67
|
+
* @param params - the raw sketch operation parameters.
|
|
68
|
+
*/
|
|
69
|
+
export declare function assertSketchParams(params: Record<string, unknown>): void;
|
|
70
|
+
/**
|
|
71
|
+
* Sketch (semantic shapes / geometry + constraints) → solve → face / outer wire.
|
|
72
|
+
*
|
|
73
|
+
* 两条入口(二选一):
|
|
74
|
+
* - `shapes`:语义图元(矩形/圆/……/画笔图元/close)→ 库面 `expandShapes` 展开成
|
|
75
|
+
* canonical 几何 + 形状自带约束,再与调用方给的 `constraints` 合并求解;
|
|
76
|
+
* - `geoms`:直接给展开后的 canonical 几何(存量语句形态)。
|
|
77
|
+
*
|
|
78
|
+
* Permanently brep-only (D5, 2026-09-27): the mesh path reports
|
|
79
|
+
* `E_MESH_UNSUPPORTED`. Sketch APIs never get a mesh path — industry
|
|
80
|
+
* precedent (CadQuery, FreeCAD) solves sketches onto exact BREP edges.
|
|
81
|
+
*
|
|
82
|
+
* @group 创建
|
|
83
|
+
* @inputs 0
|
|
84
|
+
* @async true
|
|
85
|
+
* @qual ok
|
|
86
|
+
* @name sketch
|
|
87
|
+
* @returns Shape 平面几何(求解后构面);`as:'wire'` 时返回外环 1D 曲线。
|
|
88
|
+
* @param params.shapes - 语义图元清单(与 geoms 二选一)。type:SketchShape[] required:false
|
|
89
|
+
* @param params.geoms - 展开后的草图几何(线段/圆/圆弧,与 shapes 二选一)。type:SketchGeom[] required:false
|
|
90
|
+
* @param params.constraints - 草图约束(可空;追加在形状自带约束之后)。type:SketchConstraint[] required:false
|
|
91
|
+
* @param params.as - 产物形态:'face'(默认)构面;'wire' 只交外环 wire。type:'face'|'wire' required:false
|
|
92
|
+
* @param params.plane - 放置目标命名平面(默认 'XY';如 'XZ' / 'YZ')。type:string required:false
|
|
93
|
+
* @example
|
|
94
|
+
* const plate = cad.sketch({
|
|
95
|
+
* plane: 'XY',
|
|
96
|
+
* shapes: [
|
|
97
|
+
* { kind: 'rect', w: 100, d: 60, tag: 'g0' },
|
|
98
|
+
* { kind: 'circle', r: 10, cx: 30, cy: 20, tag: 'hole', mode: 's' },
|
|
99
|
+
* ],
|
|
100
|
+
* constraints: [{ kind: 'length', of: { tag: 'g0.0' }, value: 100 }],
|
|
101
|
+
* })
|
|
102
|
+
* @example
|
|
103
|
+
* const f = cad.sketch({
|
|
104
|
+
* geoms: [{ tag:'bottom', kind:'line', x1:0, y1:0, x2:80, y2:3 }],
|
|
105
|
+
* constraints: [{ kind:'horizontal', of: { tag:'bottom' } }, { kind:'length', of: { tag:'bottom' }, value: 80 }],
|
|
106
|
+
* })
|
|
107
|
+
*/
|
|
108
|
+
export declare const sketch: ((params: Record<string, unknown>) => Promise<Shape>) & {
|
|
109
|
+
__faijs__dualOp?: import("../define-op.js").DualOpMeta;
|
|
110
|
+
};
|
|
111
|
+
//# sourceMappingURL=op.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"op.d.ts","sourceRoot":"","sources":["../../src/sketch/op.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,eAAe,CAAA;AAC1C,OAAO,KAAK,EAAE,gBAAgB,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAEhF,OAAO,EAAgB,KAAK,WAAW,EAAE,MAAM,aAAa,CAAA;AAE5D,OAAO,KAAK,EAAE,YAAY,EAAE,g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+1,185 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* op — the `cad.sketch` script-face op (sketch geometry + constraints → face).
|
|
3
|
+
*
|
|
4
|
+
* This op is provided by the sketch library, not core: a host merges it into
|
|
5
|
+
* the `cad` namespace (see `./namespace`) only when it wants sketch support.
|
|
6
|
+
* The planegcs solver is host-injected (`installSketchSolver`) because the wasm
|
|
7
|
+
* source differs between Node and browser hosts — the library itself never
|
|
8
|
+
* imports `node:*`.
|
|
9
|
+
*/
|
|
10
|
+
import { defineOp } from '../sdk.js';
|
|
11
|
+
import { fromBase } from '../units.js';
|
|
12
|
+
import { sketchFaces } from './faces.js';
|
|
13
|
+
import { expandShapes } from './shapes.js';
|
|
14
|
+
import { sketchDimSpec } from './dim-spec.js';
|
|
15
|
+
import { setSketchSolverInitFn, initSketchSolver } from './solver-loader.js';
|
|
16
|
+
/** The op name `cad.sketch`. */
|
|
17
|
+
export const SKETCH_OP_NAME = 'sketch';
|
|
18
|
+
// ── degree → radian boundary (unit-system D8) ─────────────────────────────
|
|
19
|
+
// The script face declares every angle field `dim: 'angle'` whose base unit is
|
|
20
|
+
// DEGREE, so the runtime hands numbers here in degrees. The sketch library
|
|
21
|
+
// internals (expandShapes, planegcs, Math.cos/sin) all work in radians. This
|
|
22
|
+
// boundary converts once, at op entry — internals never see degrees. The
|
|
23
|
+
// conversion goes through the unit system (`fromBase`), not a local constant.
|
|
24
|
+
function degToRad(angle) {
|
|
25
|
+
return fromBase(angle, 'radian', 'angle');
|
|
26
|
+
}
|
|
27
|
+
/** Convert a plain record in place, returning it for chaining. */
|
|
28
|
+
function convertAngles(obj, keys) {
|
|
29
|
+
for (const k of keys) {
|
|
30
|
+
if (typeof obj[k] === 'number')
|
|
31
|
+
obj[k] = degToRad(obj[k]);
|
|
32
|
+
}
|
|
33
|
+
return obj;
|
|
34
|
+
}
|
|
35
|
+
/** Angle-bearing fields per semantic shape kind (see `dim-spec.ts` shapeCases). */
|
|
36
|
+
const SHAPE_ANGLE_KEYS = {
|
|
37
|
+
rect: ['angle'], roundedRect: ['angle'], ellipse: ['angle'], polygon: ['angle'],
|
|
38
|
+
slot: ['angle'], trapezoid: ['a1', 'a2'], arc: ['a0', 'a1'],
|
|
39
|
+
};
|
|
40
|
+
/** Angle-bearing fields per canonical geom kind (see `dim-spec.ts` geomCases). */
|
|
41
|
+
const GEOM_ANGLE_KEYS = {
|
|
42
|
+
arc: ['a0', 'a1'], ellipse: ['angle', 'a0', 'a1'],
|
|
43
|
+
};
|
|
44
|
+
/** Constraint kinds whose `value` is an angle (see `dim-spec.ts` constraintCases). */
|
|
45
|
+
const ANGLE_VALUE_CONSTRAINTS = new Set(['angle', 'arcAngle']);
|
|
46
|
+
/**
|
|
47
|
+
* Convert script-face angle values (degrees) into library-internal radians,
|
|
48
|
+
* mutating the given arrays' entries in place. Unknown kinds pass through
|
|
49
|
+
* untouched (the library validates them downstream).
|
|
50
|
+
*/
|
|
51
|
+
function anglesToRadians(shapes, geoms, constraints) {
|
|
52
|
+
for (const s of shapes ?? [])
|
|
53
|
+
convertAngles(s, SHAPE_ANGLE_KEYS[s.kind] ?? []);
|
|
54
|
+
for (const g of geoms ?? [])
|
|
55
|
+
convertAngles(g, GEOM_ANGLE_KEYS[g.kind] ?? []);
|
|
56
|
+
for (const c of constraints ?? []) {
|
|
57
|
+
if (ANGLE_VALUE_CONSTRAINTS.has(c.kind))
|
|
58
|
+
convertAngles(c, ['value']);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
let diagnosticSink;
|
|
62
|
+
/**
|
|
63
|
+
* Install the host's planegcs solver factory (deprecated alias).
|
|
64
|
+
*
|
|
65
|
+
* Use `setSketchSolverInitFn` from `./solver-loader` instead. This alias
|
|
66
|
+
* is retained for one release to avoid breaking downstream call sites.
|
|
67
|
+
*
|
|
68
|
+
* @param factory - async factory returning a `SketchSolver`.
|
|
69
|
+
*/
|
|
70
|
+
export function installSketchSolver(factory) {
|
|
71
|
+
setSketchSolverInitFn(factory);
|
|
72
|
+
}
|
|
73
|
+
/** Undo {@link installSketchSolver}. */
|
|
74
|
+
export function uninstallSketchSolver() {
|
|
75
|
+
setSketchSolverInitFn(null);
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Install a diagnostics sink for non-`solved` outcomes (§5: allow ≠ silent).
|
|
79
|
+
*
|
|
80
|
+
* Hosts bridge this to their `HostPorts.events` sink / UI. Under-, redundant-
|
|
81
|
+
* and conflicting-constraint sketches still produce geometry, but the
|
|
82
|
+
* diagnostic must reach the host.
|
|
83
|
+
*
|
|
84
|
+
* @param sink - receives every non-`solved` solve outcome; `null` clears it.
|
|
85
|
+
*/
|
|
86
|
+
export function setSketchDiagnosticSink(sink) {
|
|
87
|
+
diagnosticSink = sink ?? undefined;
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Validate `cad.sketch` parameters: **exactly one** of `shapes` / `geoms` must be a
|
|
91
|
+
* non-empty array, `constraints` (when present) an array, `plane` a named plane or
|
|
92
|
+
* an explicit frame.
|
|
93
|
+
*
|
|
94
|
+
* @param params - the raw sketch operation parameters.
|
|
95
|
+
*/
|
|
96
|
+
export function assertSketchParams(params) {
|
|
97
|
+
const hasShapes = params.shapes !== undefined;
|
|
98
|
+
const hasGeoms = params.geoms !== undefined;
|
|
99
|
+
if (hasShapes && hasGeoms) {
|
|
100
|
+
throw new Error('E_SKETCHC_BOTH_ENTRIES: sketch takes either `shapes` (semantic primitives) or `geoms` (expanded geometry), not both');
|
|
101
|
+
}
|
|
102
|
+
const entry = hasShapes ? params.shapes : params.geoms;
|
|
103
|
+
if (!Array.isArray(entry) || entry.length === 0) {
|
|
104
|
+
throw new Error('E_SKETCHC_NO_GEOMS: sketch requires at least one geometry');
|
|
105
|
+
}
|
|
106
|
+
if (params.constraints !== undefined && !Array.isArray(params.constraints)) {
|
|
107
|
+
throw new Error('E_SKETCHC_BAD_CONSTRAINTS: constraints must be an array');
|
|
108
|
+
}
|
|
109
|
+
if (params.plane !== undefined && typeof params.plane !== 'string' &&
|
|
110
|
+
(typeof params.plane !== 'object' || params.plane === null ||
|
|
111
|
+
!Array.isArray(params.plane.origin) ||
|
|
112
|
+
!Array.isArray(params.plane.normal))) {
|
|
113
|
+
throw new Error('E_SKETCHC_BAD_PLANE: plane must be a named plane string or an explicit frame { origin, normal, xAxis? }');
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
async function resolveSolver() {
|
|
117
|
+
return initSketchSolver();
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Sketch (semantic shapes / geometry + constraints) → solve → face / outer wire.
|
|
121
|
+
*
|
|
122
|
+
* 两条入口(二选一):
|
|
123
|
+
* - `shapes`:语义图元(矩形/圆/……/画笔图元/close)→ 库面 `expandShapes` 展开成
|
|
124
|
+
* canonical 几何 + 形状自带约束,再与调用方给的 `constraints` 合并求解;
|
|
125
|
+
* - `geoms`:直接给展开后的 canonical 几何(存量语句形态)。
|
|
126
|
+
*
|
|
127
|
+
* Permanently brep-only (D5, 2026-09-27): the mesh path reports
|
|
128
|
+
* `E_MESH_UNSUPPORTED`. Sketch APIs never get a mesh path — industry
|
|
129
|
+
* precedent (CadQuery, FreeCAD) solves sketches onto exact BREP edges.
|
|
130
|
+
*
|
|
131
|
+
* @group 创建
|
|
132
|
+
* @inputs 0
|
|
133
|
+
* @async true
|
|
134
|
+
* @qual ok
|
|
135
|
+
* @name sketch
|
|
136
|
+
* @returns Shape 平面几何(求解后构面);`as:'wire'` 时返回外环 1D 曲线。
|
|
137
|
+
* @param params.shapes - 语义图元清单(与 geoms 二选一)。type:SketchShape[] required:false
|
|
138
|
+
* @param params.geoms - 展开后的草图几何(线段/圆/圆弧,与 shapes 二选一)。type:SketchGeom[] required:false
|
|
139
|
+
* @param params.constraints - 草图约束(可空;追加在形状自带约束之后)。type:SketchConstraint[] required:false
|
|
140
|
+
* @param params.as - 产物形态:'face'(默认)构面;'wire' 只交外环 wire。type:'face'|'wire' required:false
|
|
141
|
+
* @param params.plane - 放置目标命名平面(默认 'XY';如 'XZ' / 'YZ')。type:string required:false
|
|
142
|
+
* @example
|
|
143
|
+
* const plate = cad.sketch({
|
|
144
|
+
* plane: 'XY',
|
|
145
|
+
* shapes: [
|
|
146
|
+
* { kind: 'rect', w: 100, d: 60, tag: 'g0' },
|
|
147
|
+
* { kind: 'circle', r: 10, cx: 30, cy: 20, tag: 'hole', mode: 's' },
|
|
148
|
+
* ],
|
|
149
|
+
* constraints: [{ kind: 'length', of: { tag: 'g0.0' }, value: 100 }],
|
|
150
|
+
* })
|
|
151
|
+
* @example
|
|
152
|
+
* const f = cad.sketch({
|
|
153
|
+
* geoms: [{ tag:'bottom', kind:'line', x1:0, y1:0, x2:80, y2:3 }],
|
|
154
|
+
* constraints: [{ kind:'horizontal', of: { tag:'bottom' } }, { kind:'length', of: { tag:'bottom' }, value: 80 }],
|
|
155
|
+
* })
|
|
156
|
+
*/
|
|
157
|
+
export const sketch = defineOp({
|
|
158
|
+
name: SKETCH_OP_NAME,
|
|
159
|
+
async brep(params) {
|
|
160
|
+
assertSketchParams(params);
|
|
161
|
+
const solver = await resolveSolver();
|
|
162
|
+
const p = params;
|
|
163
|
+
// Unit boundary: script-face angles arrive in degrees (angle base unit);
|
|
164
|
+
// library internals work in radians. Mutates the caller's arrays — safe
|
|
165
|
+
// because params are per-execution, never retained by the host.
|
|
166
|
+
anglesToRadians(p.shapes, p.geoms, p.constraints);
|
|
167
|
+
const expansion = p.shapes ? expandShapes(p.shapes) : undefined;
|
|
168
|
+
const geoms = expansion ? expansion.geoms : p.geoms;
|
|
169
|
+
const constraints = [...(expansion ? expansion.constraints : []), ...(p.constraints ?? [])];
|
|
170
|
+
return sketchFaces(geoms, constraints, {
|
|
171
|
+
solver,
|
|
172
|
+
as: p.as,
|
|
173
|
+
plane: p.plane,
|
|
174
|
+
external: p.external,
|
|
175
|
+
expectHoles: (expansion?.subtractRanges.length ?? 0) > 0,
|
|
176
|
+
onDiagnostic: (outcome) => {
|
|
177
|
+
if (outcome.status !== 'solved')
|
|
178
|
+
diagnosticSink?.(outcome);
|
|
179
|
+
},
|
|
180
|
+
});
|
|
181
|
+
},
|
|
182
|
+
naming: { kind: 'construct', newFaces: { via: 'explicit', vocab: [] } },
|
|
183
|
+
spec: sketchDimSpec(),
|
|
184
|
+
});
|
|
185
|
+
//# sourceMappingURL=op.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"op.js","sourceRoot":"","sources":["../../src/sketch/op.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAA;AACjC,OAAO,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAA;AAInC,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAA;AACxC,OAAO,EAAE,YAAY,EAAoB,MAAM,aAAa,CAAA;AAC5D,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAA;AAE7C,OAAO,EAAE,qBAAqB,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAA;AAE5E,gCAAgC;AAChC,MAAM,CAAC,MAAM,cAAc,GAAG,QAAiB,CAAA;AAE/C,6EAA6E;AAC7E,+EAA+E;AAC/E,2EAA2E;AAC3E,6EAA6E;AAC7E,yEAAyE;AACzE,8EAA8E;AAE9E,SAAS,QAAQ,CAAC,KAAa;IAC7B,OAAO,QAAQ,CAAC,KAAK,EAAE,QAAQ,EAAE,OAAO,CAAC,CAAA;AAC3C,CAAC;AAED,kEAAkE;AAClE,SAAS,aAAa,CAAoC,GAAM,EAAE,IAAuB;IACvF,KAAK,MAAM,CAAC,IAAI,IAAI,EAAE,CAAC;QACrB,IAAI,OAAO,GAAG,CAAC,CAAC,CAAC,KAAK,QAAQ;YAAG,GAA+B,CAAC,CAAC,CAAC,GAAG,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAW,CAAC,CAAA;IAClG,CAAC;IACD,OAAO,GAAG,CAAA;AACZ,CAAC;AAED,mFA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AE,CAAC,CAAC,QAAQ;YACpB,WAAW,EAAE,CAAC,SAAS,EAAE,cAAc,CAAC,MAAM,IAAI,CAAC,CAAC,GAAG,CAAC;YACxD,YAAY,EAAE,CAAC,OAAO,EAAE,EAAE;gBACxB,IAAI,OAAO,CAAC,MAAM,KAAK,QAAQ;oBAAE,cAAc,EAAE,CAAC,OAAO,CAAC,CAAA;YAC5D,CAAC;SACF,CAAC,CAAA;IACJ,CAAC;IACD,MAAM,EAAE,EAAE,IAAI,EAAE,WAAW,EAAE,QAAQ,EAAE,EAAE,GAAG,EAAE,UAAU,EAAE,KAAK,EAAE,EAAE,EAAE,EAAgB;IACrF,IAAI,EAAE,aAAa,EAAE;CACtB,CAAC,CAAA","sourcesContent":["/**\n * op — the `cad.sketch` script-face op (sketch geometry + constraints → face).\n *\n * This op is provided by the sketch library, not core: a host merges it into\n * the `cad` namespace (see `./namespace`) only when it wants sketch support.\n * The planegcs solver is host-injected (`installSketchSolver`) because the wasm\n * source differs between Node and browser hosts — the library itself never\n * imports `node:*`.\n */\nimport { defineOp } from '../sdk'\nimport { fromBase } from '../units'\nimport type { Provenance } from '../topology/naming'\nimport type { Shape } from '../mesh/types'\nimport type { SketchConstraint, SketchGeom, SolveOutcome } from './canonical.js'\nimport { sketchFaces } from './faces.js'\nimport { expandShapes, type SketchShape } from './shapes.js'\nimport { sketchDimSpec } from './dim-spec.js'\nimport type { SketchSolver, ExternalFixedSeg } from './solver.js'\nimport { setSketchSolverInitFn, initSketchSolver } from './solver-loader.js'\n\n/** The op name `cad.sketch`. */\nexport const SKETCH_OP_NAME = 'sketch' as const\n\n// ── degree → radian boundary (unit-system D8) ─────────────────────────────\n// The script face declares every angle field `dim: 'angle'` whose base unit is\n// DEGREE, so the runtime hands numbers here in degrees. The sketch library\n// internals (expandShapes, planegcs, Math.cos/sin) all work in radians. This\n// boundary converts once, at op entry — internals never see degrees. The\n// conversion goes through the unit system (`fromBase`), not a local constant.\n\nfunction degToRad(angle: number): number {\n return fromBase(angle, 'radian', 'angle')\n}\n\n/** Convert a plain record in place, returning it for chaining. */\nfunction convertAngles<T extends Record<string, unknown>>(obj: T, keys: readonly string[]): T {\n for (const k of keys) {\n if (typeof obj[k] === 'number') (obj as Record<string, unknown>)[k] = degToRad(obj[k] as number)\n }\n return obj\n}\n\n/** Angle-bearing fields per semantic shape kind (see `dim-spec.ts` shapeCases). */\nconst SHAPE_ANGLE_KEYS: Record<string, readonly string[]> = {\n rect: ['angle'], roundedRect: ['angle'], ellipse: ['angle'], polygon: ['angle'],\n slot: ['angle'], trapezoid: ['a1', 'a2'], arc: ['a0', 'a1'],\n}\n\n/** Angle-bearing fields per canonical geom kind (see `dim-spec.ts` geomCases). */\nconst GEOM_ANGLE_KEYS: Record<string, readonly string[]> = {\n arc: ['a0', 'a1'], ellipse: ['angle', 'a0', 'a1'],\n}\n\n/** Constraint kinds whose `value` is an angle (see `dim-spec.ts` constraintCases). */\nconst ANGLE_VALUE_CONSTRAINTS: ReadonlySet<string> = new Set(['angle', 'arcAngle'])\n\n/**\n * Convert script-face angle values (degrees) into library-internal radians,\n * mutating the given arrays' entries in place. Unknown kinds pass through\n * untouched (the library validates them downstream).\n */\nfunction anglesToRadians(\n shapes: Array<Record<string, unknown>> | undefined,\n geoms: Array<Record<string, unknown>> | undefined,\n constraints: Array<Record<string, unknown>> | undefined,\n): void {\n for (const s of shapes ?? []) convertAngles(s, SHAPE_ANGLE_KEYS[s.kind as string] ?? [])\n for (const g of geoms ?? []) convertAngles(g, GEOM_ANGLE_KEYS[g.kind as string] ?? [])\n for (const c of constraints ?? []) {\n if (ANGLE_VALUE_CONSTRAINTS.has(c.kind as string)) convertAngles(c, ['value'])\n }\n}\n\nlet diagnosticSink: ((outcome: SolveOutcome) => void) | undefined\n\n/**\n * Install the host's planegcs solver factory (deprecated alias).\n *\n * Use `setSketchSolverInitFn` from `./solver-loader` instead. This alias\n * is retained for one release to avoid breaking downstream call sites.\n *\n * @param factory - async factory returning a `SketchSolver`.\n */\nexport function installSketchSolver(factory: () => Promise<SketchSolver>): void {\n setSketchSolverInitFn(factory)\n}\n\n/** Undo {@link installSketchSolver}. */\nexport function uninstallSketchSolver(): void {\n setSketchSolverInitFn(null)\n}\n\n/**\n * Install a diagnostics sink for non-`solved` outcomes (§5: allow ≠ silent).\n *\n * Hosts bridge this to their `HostPorts.events` sink / UI. Under-, redundant-\n * and conflicting-constraint sketches still produce geometry, but the\n * diagnostic must reach the host.\n *\n * @param sink - receives every non-`solved` solve outcome; `null` clears it.\n */\nexport function setSketchDiagnosticSink(sink: ((outcome: SolveOutcome) => void) | null): void {\n diagnosticSink = sink ?? undefined\n}\n\n/** `cad.sketch` parameters. */\nexport interface SketchParams {\n /**\n * 语义图元清单(**与 `geoms` 二选一**):矩形/圆/圆角矩形/椭圆/正多边形/长圆槽/梯形\n * + 画笔图元(线/弧/样条/点)+ `close`。脚本面推荐这一形态——\"画矩形\"在语句里\n * 就是矩形,而不是 4 条线 + 8 条约束(铺开由库面 `expandShapes` 一处负责)。\n */\n shapes?: SketchShape[]\n /** 展开后的 canonical 几何(**与 `shapes` 二选一**;存量语句继续用这一形态)。 */\n geoms?: SketchGeom[]\n /** Optional — a constraint-free sketch is equivalent to `cad.profile` usage. */\n constraints?: SketchConstraint[]\n /** Product form: `'face'` (default) or `'wire'` (outer wire for sweep spines). */\n as?: 'face' | 'wire'\n /**\n * Named plane (`'XY'` default; e.g. `'XZ'` / `'YZ'`) or an explicit plane\n * frame (A3, 2026-09-28): `{ origin, normal, xAxis? }` — places the solved\n * contours on an arbitrary plane in one step (the sketchOnPlane hand-off;\n * no post-hoc `cad.place` needed).\n */\n plane?: string | { origin: [number, number, number]; normal: [number, number, number]; xAxis?: [number, number, number] }\n /**\n * Fixed external geometry the constraints may reference (IRON RULE patch,\n * 2026-10-04): each entry is the converter-resolved polyline of one external\n * geoId (geoId <= -3), pinned as fixed solver points so external refs\n * resolve STATICALLY — a ref with no matching entry here is an unresolvable\n * constraint, not a run-time guess.\n */\n external?: ExternalFixedSeg[]\n}\n\n/**\n * Validate `cad.sketch` parameters: **exactly one** of `shapes` / `geoms` must be a\n * non-empty array, `constraints` (when present) an array, `plane` a named plane or\n * an explicit frame.\n *\n * @param params - the raw sketch operation parameters.\n */\nexport function assertSketchParams(params: Record<string, unknown>): void {\n const hasShapes = params.shapes !== undefined\n const hasGeoms = params.geoms !== undefined\n if (hasShapes && hasGeoms) {\n throw new Error(\n 'E_SKETCHC_BOTH_ENTRIES: sketch takes either `shapes` (semantic primitives) or `geoms` (expanded geometry), not both',\n )\n }\n const entry = hasShapes ? params.shapes : params.geoms\n if (!Array.isArray(entry) || entry.length === 0) {\n throw new Error('E_SKETCHC_NO_GEOMS: sketch requires at least one geometry')\n }\n if (params.constraints !== undefined && !Array.isArray(params.constraints)) {\n throw new Error('E_SKETCHC_BAD_CONSTRAINTS: constraints must be an array')\n }\n if (params.plane !== undefined && typeof params.plane !== 'string' &&\n (typeof params.plane !== 'object' || params.plane === null ||\n !Array.isArray((params.plane as { origin?: unknown }).origin) ||\n !Array.isArray((params.plane as { normal?: unknown }).normal))) {\n throw new Error('E_SKETCHC_BAD_PLANE: plane must be a named plane string or an explicit frame { origin, normal, xAxis? }')\n }\n}\n\nasync function resolveSolver(): Promise<SketchSolver> {\n return initSketchSolver()\n}\n\n/**\n * Sketch (semantic shapes / geometry + constraints) → solve → face / outer wire.\n *\n * 两条入口(二选一):\n * - `shapes`:语义图元(矩形/圆/……/画笔图元/close)→ 库面 `expandShapes` 展开成\n * canonical 几何 + 形状自带约束,再与调用方给的 `constraints` 合并求解;\n * - `geoms`:直接给展开后的 canonical 几何(存量语句形态)。\n *\n * Permanently brep-only (D5, 2026-09-27): the mesh path reports\n * `E_MESH_UNSUPPORTED`. Sketch APIs never get a mesh path — industry\n * precedent (CadQuery, FreeCAD) solves sketches onto exact BREP edges.\n *\n * @group 创建\n * @inputs 0\n * @async true\n * @qual ok\n * @name sketch\n * @returns Shape 平面几何(求解后构面);`as:'wire'` 时返回外环 1D 曲线。\n * @param params.shapes - 语义图元清单(与 geoms 二选一)。type:SketchShape[] required:false\n * @param params.geoms - 展开后的草图几何(线段/圆/圆弧,与 shapes 二选一)。type:SketchGeom[] required:false\n * @param params.constraints - 草图约束(可空;追加在形状自带约束之后)。type:SketchConstraint[] required:false\n * @param params.as - 产物形态:'face'(默认)构面;'wire' 只交外环 wire。type:'face'|'wire' required:false\n * @param params.plane - 放置目标命名平面(默认 'XY';如 'XZ' / 'YZ')。type:string required:false\n * @example\n * const plate = cad.sketch({\n * plane: 'XY',\n * shapes: [\n * { kind: 'rect', w: 100, d: 60, tag: 'g0' },\n * { kind: 'circle', r: 10, cx: 30, cy: 20, tag: 'hole', mode: 's' },\n * ],\n * constraints: [{ kind: 'length', of: { tag: 'g0.0' }, value: 100 }],\n * })\n * @example\n * const f = cad.sketch({\n * geoms: [{ tag:'bottom', kind:'line', x1:0, y1:0, x2:80, y2:3 }],\n * constraints: [{ kind:'horizontal', of: { tag:'bottom' } }, { kind:'length', of: { tag:'bottom' }, value: 80 }],\n * })\n */\nexport const sketch = defineOp({\n name: SKETCH_OP_NAME,\n async brep(params: Record<string, unknown>): Promise<Shape> {\n assertSketchParams(params)\n const solver = await resolveSolver()\n const p = params as unknown as SketchParams\n // Unit boundary: script-face angles arrive in degrees (angle base unit);\n // library internals work in radians. Mutates the caller's arrays — safe\n // because params are per-execution, never retained by the host.\n anglesToRadians(\n p.shapes as Array<Record<string, unknown>> | undefined,\n p.geoms as Array<Record<string, unknown>> | undefined,\n p.constraints as Array<Record<string, unknown>> | undefined,\n )\n const expansion = p.shapes ? expandShapes(p.shapes) : undefined\n const geoms = expansion ? expansion.geoms : p.geoms!\n const constraints = [...(expansion ? expansion.constraints : []), ...(p.constraints ?? [])]\n return sketchFaces(geoms, constraints, {\n solver,\n as: p.as,\n plane: p.plane,\n external: p.external,\n expectHoles: (expansion?.subtractRanges.length ?? 0) > 0,\n onDiagnostic: (outcome) => {\n if (outcome.status !== 'solved') diagnosticSink?.(outcome)\n },\n })\n },\n naming: { kind: 'construct', newFaces: { via: 'explicit', vocab: [] } } as Provenance,\n spec: sketchDimSpec(),\n})"]}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* M3.2/M3.3/M3.4 — planegcs WASM backend for the SketchSolver interface.
|
|
3
|
+
*
|
|
4
|
+
* M3.3: geometry → GCS primitives, including the implicit fixed RtPnt/HAxis/
|
|
5
|
+
* VAxis (geoId -1/-2, plan §5.4). External geometry (geoId <= -3) is rejected
|
|
6
|
+
* upstream (D4: whole sketch downgrades to L2).
|
|
7
|
+
* M3.4: constraints → GCS primitives for the P0 set (plan §7 M3.4).
|
|
8
|
+
* M3.5 helper: solved params are pulled back and geometry rebuilt, so the
|
|
9
|
+
* caller can compare against on-disk coordinates (D2).
|
|
10
|
+
*/
|
|
11
|
+
import { GcsWrapper } from '@salusoft89/planegcs';
|
|
12
|
+
import { type Result } from '../api/result.js';
|
|
13
|
+
import type { FcstdSketchGeom, FcstdSketchCon } from './fcstd-types.js';
|
|
14
|
+
import type { FcstdSolveOutcome, SketchSolver } from './solver.js';
|
|
15
|
+
/** Options for instantiating the planegcs WASM solver. */
|
|
16
|
+
export interface PlanegcsSolverOptions {
|
|
17
|
+
/** Absolute filesystem path or fetchable URL of `planegcs.wasm`; the module reads the bytes itself. */
|
|
18
|
+
wasmPath?: string;
|
|
19
|
+
/** Raw wasm bytes, for hosts that already hold the binary. */
|
|
20
|
+
wasmBytes?: Uint8Array | ArrayBuffer;
|
|
21
|
+
/**
|
|
22
|
+
* Code-package path that only the **platform's own wasm loader** can turn into
|
|
23
|
+
* a module (WeChat mini program: `WXWebAssembly.instantiate(path, imports)`).
|
|
24
|
+
*
|
|
25
|
+
* Unlike `wasmPath`, faijs never fetches this path — the host must have
|
|
26
|
+
* installed an adapter routing `WebAssembly.instantiate` to the platform
|
|
27
|
+
* loader, which is what actually compiles those bytes.
|
|
28
|
+
*/
|
|
29
|
+
wasmLoaderPath?: string;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Instantiate the planegcs WASM solver.
|
|
33
|
+
*
|
|
34
|
+
* The host declares the wasm source; exactly one of the three options must be
|
|
35
|
+
* given — the choice is a static fact about the host, never a runtime fallback:
|
|
36
|
+
* - `wasmPath`: Node / browser hosts where the module can read a path or fetch a URL;
|
|
37
|
+
* - `wasmBytes`: hosts that already hold the binary;
|
|
38
|
+
* - `wasmLoaderPath`: platforms that can only instantiate from a code-package
|
|
39
|
+
* path (WeChat mini program) — see the option's own docs.
|
|
40
|
+
*
|
|
41
|
+
* @param options - the single wasm source for this host.
|
|
42
|
+
* @returns a `SketchSolver` backed by the planegcs WASM module.
|
|
43
|
+
* @throws when no source, or more than one source, is supplied.
|
|
44
|
+
*/
|
|
45
|
+
export declare function createPlanegcsSolver(options: PlanegcsSolverOptions): Promise<SketchSolver>;
|
|
46
|
+
/**
|
|
47
|
+
* planegcs WASM implementation of the `SketchSolver` interface (M3.2–M3.4):
|
|
48
|
+
* pushes geometry/constraints into the GCS, solves, and pulls the solved
|
|
49
|
+
* parameters back into `FcstdSketchGeom` values.
|
|
50
|
+
*/
|
|
51
|
+
export declare class PlanegcsSolver implements SketchSolver {
|
|
52
|
+
private wrapper;
|
|
53
|
+
constructor(wrapper: GcsWrapper);
|
|
54
|
+
solve(geoms: FcstdSketchGeom[], constraints: FcstdSketchCon[], external?: import('./solver.js').ExternalFixedSeg[]): Promise<Result<FcstdSolveOutcome, never>>;
|
|
55
|
+
/**
|
|
56
|
+
* Remaining degrees of freedom after a successful solve (-1 if unavailable).
|
|
57
|
+
*
|
|
58
|
+
* @returns the DoF count, or -1 if the backend does not report it.
|
|
59
|
+
*/
|
|
60
|
+
getDof(): number;
|
|
61
|
+
private constraintToPrimitives;
|
|
62
|
+
private pullBack;
|
|
63
|
+
/** Read a point's solved coordinates from the sketch index.
|
|
64
|
+
* apply_solution() already pulled every primitive's solved values back into
|
|
65
|
+
* sketch_index (gcs_wrapper.js:104-108), so get_primitive is authoritative. */
|
|
66
|
+
private readPoint;
|
|
67
|
+
private readCircleRadius;
|
|
68
|
+
}
|
|
69
|
+
//# sourceMappingURL=planegcs-backend.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"planegcs-backend.d.ts","sourceRoot":"","sources":["../../src/sketch/planegcs-backend.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,EAAE,UAAU,EAAmC,MAAM,sBAAsB,CAAC;AACnF,OAAO,EAAM,KAAK,MAAM,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,KAAK,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAExE,OAAO,KAAK,EAAE,iBAAiB,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAEnE,0DAA0D;AAC1D,MAAM,WAAW,qBAAqB;IACpC,uGAAuG;IACvG,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,8DAA8D;IAC9D,SAAS,CAAC,EAAE,UAAU,GAAG,WAAW,CAAA;IACpC;;;;;;;OAOG;IACH,cAAc,CAAC,EAAE,MAAM,CAAA;CACxB;AAyBD;;;;;;;;;;;;;GAaG;AACH,wBAAsB,oBAAoB,CAAC,OAAO,EAAE,qBAAqB,GAAG,OAAO,CAAC,YAAY,CAAC,CAyBhG;AAkBD;;;;GAIG;AACH,qBAAa,cAAe,YAAW,YAAY;IACrC,OAAO,CAAC,OAAO;gBAAP,OAAO,EAAE,UAAU;IAEjC,KAAK,CACT,KAAK,EAAE,eAAe,EAAE,EACxB,WAAW,EAAE,cAAc,EAAE,EAC7B,QAAQ,CAAC,EAAE,OAAO,aAAa,EAAE,gBAAgB,EAAE,GAClD,OAAO,CAAC,MAAM,CAAC,iBAAiB,EAAE,KAAK,CAAC,CAAC;IAkS5C;;;;OAIG;IACH,MAAM,IAAI,MAAM;IAShB,OAAO,CAAC,sBAAsB;IA4T9B,OAAO,CAAC,QAAQ;IAkFhB;;mFAE+E;IAC/E,OAAO,CAAC,SAAS;IAMjB,OAAO,CAAC,gBAAgB;CAIzB"}
|