@faicad/faijs 0.19.0 → 0.22.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/brep-mirror/joinery-brep.d.ts.map +1 -1
- package/dist/api/brep-mirror/joinery-brep.js +3 -1
- package/dist/api/brep-mirror/joinery-brep.js.map +1 -1
- package/dist/api/generated/script-face-manifest.d.ts +4 -0
- package/dist/api/generated/script-face-manifest.d.ts.map +1 -1
- package/dist/api/generated/script-face-manifest.js.map +1 -1
- package/dist/api/knurl.d.ts.map +1 -1
- package/dist/api/knurl.js +1 -0
- package/dist/api/knurl.js.map +1 -1
- package/dist/api/primitives.d.ts +4 -3
- package/dist/api/primitives.d.ts.map +1 -1
- package/dist/api/primitives.js +9 -3
- package/dist/api/primitives.js.map +1 -1
- package/dist/api/profile.d.ts +34 -5
- package/dist/api/profile.d.ts.map +1 -1
- package/dist/api/profile.js +60 -9
- package/dist/api/profile.js.map +1 -1
- package/dist/api/punch-hole.d.ts +3 -0
- package/dist/api/punch-hole.d.ts.map +1 -1
- package/dist/api/punch-hole.js.map +1 -1
- package/dist/api/sketch-on-plane.d.ts +12 -6
- package/dist/api/sketch-on-plane.d.ts.map +1 -1
- package/dist/api/sketch-on-plane.js +11 -8
- package/dist/api/sketch-on-plane.js.map +1 -1
- package/dist/api/surface/arg-spec.d.ts +8 -0
- package/dist/api/surface/arg-spec.d.ts.map +1 -1
- package/dist/api/surface/arg-spec.js.map +1 -1
- package/dist/api/transform.d.ts +5 -5
- package/dist/api/transform.d.ts.map +1 -1
- package/dist/api/transform.js +12 -10
- package/dist/api/transform.js.map +1 -1
- package/dist/api/xml-dom.d.ts +27 -0
- package/dist/api/xml-dom.d.ts.map +1 -0
- package/dist/api/xml-dom.js +45 -0
- package/dist/api/xml-dom.js.map +1 -0
- package/dist/brep/brep-ops.d.ts +4 -4
- package/dist/brep/brep-ops.d.ts.map +1 -1
- package/dist/brep/brep-ops.js +8 -6
- package/dist/brep/brep-ops.js.map +1 -1
- package/dist/brep/brep-topology.d.ts.map +1 -1
- package/dist/brep/brep-topology.js +3 -1
- package/dist/brep/brep-topology.js.map +1 -1
- package/dist/brep/export/export-model.d.ts +79 -0
- package/dist/brep/export/export-model.d.ts.map +1 -0
- package/dist/brep/export/export-model.js +335 -0
- package/dist/brep/export/export-model.js.map +1 -0
- package/dist/brep/primitives-brep.d.ts.map +1 -1
- package/dist/brep/primitives-brep.js +3 -1
- package/dist/brep/primitives-brep.js.map +1 -1
- package/dist/brepkit-kernel/brepkitKernel.d.ts.map +1 -1
- package/dist/brepkit-kernel/brepkitKernel.js +4 -2
- package/dist/brepkit-kernel/brepkitKernel.js.map +1 -1
- package/dist/cad-runtime/direct-executor.d.ts +4 -0
- package/dist/cad-runtime/direct-executor.d.ts.map +1 -1
- package/dist/cad-runtime/direct-executor.js +17 -1
- package/dist/cad-runtime/direct-executor.js.map +1 -1
- package/dist/cad-runtime/runtime.d.ts +24 -1
- package/dist/cad-runtime/runtime.d.ts.map +1 -1
- package/dist/cad-runtime/runtime.js +53 -3
- package/dist/cad-runtime/runtime.js.map +1 -1
- package/dist/define-op.d.ts +22 -0
- package/dist/define-op.d.ts.map +1 -1
- package/dist/define-op.js +15 -0
- package/dist/define-op.js.map +1 -1
- package/dist/env-agnostic.d.ts +7 -7
- package/dist/env-agnostic.d.ts.map +1 -1
- package/dist/env-agnostic.js +3 -3
- package/dist/env-agnostic.js.map +1 -1
- package/dist/geometry2d/bridge/lift-on-plane.d.ts.map +1 -1
- package/dist/geometry2d/bridge/lift-on-plane.js +6 -0
- package/dist/geometry2d/bridge/lift-on-plane.js.map +1 -1
- package/dist/geometry2d/pen-sketcher.d.ts +25 -0
- package/dist/geometry2d/pen-sketcher.d.ts.map +1 -1
- package/dist/geometry2d/pen-sketcher.js +43 -0
- package/dist/geometry2d/pen-sketcher.js.map +1 -1
- package/dist/lang/code-to-args.d.ts +29 -3
- package/dist/lang/code-to-args.d.ts.map +1 -1
- package/dist/lang/code-to-args.js +41 -2
- package/dist/lang/code-to-args.js.map +1 -1
- package/dist/lang/codegen.d.ts +45 -1
- package/dist/lang/codegen.d.ts.map +1 -1
- package/dist/lang/codegen.js +135 -6
- package/dist/lang/codegen.js.map +1 -1
- package/dist/lang/host-arg.d.ts +6 -0
- package/dist/lang/host-arg.d.ts.map +1 -1
- package/dist/lang/host-arg.js.map +1 -1
- package/dist/lang/metadata-extractor.d.ts +25 -0
- package/dist/lang/metadata-extractor.d.ts.map +1 -1
- package/dist/lang/metadata-extractor.js +289 -25
- package/dist/lang/metadata-extractor.js.map +1 -1
- package/dist/lang/parse-error.d.ts +7 -1
- package/dist/lang/parse-error.d.ts.map +1 -1
- package/dist/lang/parse-error.js.map +1 -1
- package/dist/lang/security-scanner.d.ts +9 -1
- package/dist/lang/security-scanner.d.ts.map +1 -1
- package/dist/lang/security-scanner.js +38 -1
- package/dist/lang/security-scanner.js.map +1 -1
- package/dist/mesh/io.d.ts +62 -9
- package/dist/mesh/io.d.ts.map +1 -1
- package/dist/mesh/io.js +124 -17
- package/dist/mesh/io.js.map +1 -1
- package/dist/mesh/threemf-loader.d.ts +15 -0
- package/dist/mesh/threemf-loader.d.ts.map +1 -0
- package/dist/mesh/threemf-loader.js +163 -0
- package/dist/mesh/threemf-loader.js.map +1 -0
- package/dist/mesh/transform.d.ts +2 -2
- package/dist/mesh/transform.d.ts.map +1 -1
- package/dist/mesh/transform.js +3 -3
- package/dist/mesh/transform.js.map +1 -1
- package/dist/mesh/types.d.ts +1 -1
- package/dist/mesh/types.d.ts.map +1 -1
- package/dist/mesh/types.js.map +1 -1
- package/dist/node-host/cli.d.ts.map +1 -1
- package/dist/node-host/cli.js +53 -26
- package/dist/node-host/cli.js.map +1 -1
- package/dist/occt-kernel/occtKernel.d.ts.map +1 -1
- package/dist/occt-kernel/occtKernel.js +4 -2
- package/dist/occt-kernel/occtKernel.js.map +1 -1
- package/dist/occt-kernel/topologyExt.d.ts.map +1 -1
- package/dist/occt-kernel/topologyExt.js +4 -1
- package/dist/occt-kernel/topologyExt.js.map +1 -1
- package/dist/runtime-state.d.ts +18 -0
- package/dist/runtime-state.d.ts.map +1 -1
- package/dist/runtime-state.js +23 -0
- package/dist/runtime-state.js.map +1 -1
- package/dist/sdk.d.ts +1 -1
- package/dist/sdk.d.ts.map +1 -1
- package/dist/sdk.js +1 -1
- package/dist/sdk.js.map +1 -1
- package/dist/tolerance.d.ts +38 -0
- package/dist/tolerance.d.ts.map +1 -0
- package/dist/tolerance.js +40 -0
- package/dist/tolerance.js.map +1 -0
- package/dist/topology/naming/score.js +3 -3
- package/dist/topology/naming/score.js.map +1 -1
- package/dist/units.d.ts +248 -0
- package/dist/units.d.ts.map +1 -0
- package/dist/units.js +397 -0
- package/dist/units.js.map +1 -0
- package/package.json +11 -2
package/dist/define-op.d.ts
CHANGED
|
@@ -30,6 +30,7 @@ import { type SlotMap } from './api/internal/dual-form-args.js';
|
|
|
30
30
|
import { type ResultLike } from './api/internal/result-unwrap.js';
|
|
31
31
|
import type { Shape } from './mesh/types.js';
|
|
32
32
|
import { type BrepEngineId, type BrepHandle } from './brep/engine/types.js';
|
|
33
|
+
import type { DimName } from './units.js';
|
|
33
34
|
import { type Provenance } from './topology/naming/lineage.js';
|
|
34
35
|
/** Raw mesh data (structurally identical to Shape; mesh impls return it). */
|
|
35
36
|
export type MeshData = {
|
|
@@ -111,6 +112,14 @@ export interface DualOpOptions {
|
|
|
111
112
|
* missing naming = compile-time error (G4: no undeclared ops).
|
|
112
113
|
*/
|
|
113
114
|
naming: Provenance;
|
|
115
|
+
/**
|
|
116
|
+
* Script-side dimension declaration (unit-system D8): per-parameter dim for
|
|
117
|
+
* the static `dimension` check stage. Params absent here are treated as
|
|
118
|
+
* dimensionless and exempt from the check. `DimName` is a pure type import.
|
|
119
|
+
*/
|
|
120
|
+
paramDims?: Record<string, DimName>;
|
|
121
|
+
/** Return dimension declaration (D8): the value produced carries this dim. */
|
|
122
|
+
retDim?: DimName;
|
|
114
123
|
}
|
|
115
124
|
/** Implementation set (at least one of mesh/brep is required, D1/D1b); options are siblings of the implementations. */
|
|
116
125
|
export type DualOpImpls<A extends unknown[]> = (DualOpOptions & {
|
|
@@ -136,6 +145,10 @@ export interface DualOpMeta {
|
|
|
136
145
|
slotMap?: SlotMap;
|
|
137
146
|
/** Topology identity provenance (Phase 2.3, mirrors DualOpOptions.naming). */
|
|
138
147
|
naming: Provenance;
|
|
148
|
+
/** Script-side dimension declaration (D8, mirrors DualOpOptions.paramDims). */
|
|
149
|
+
paramDims?: Record<string, DimName>;
|
|
150
|
+
/** Return dimension declaration (D8). */
|
|
151
|
+
retDim?: DimName;
|
|
139
152
|
}
|
|
140
153
|
/** Property key carrying DualOpMeta on wrapped functions. */
|
|
141
154
|
export declare const DUAL_OP_META = "__faijs__dualOp";
|
|
@@ -189,6 +202,15 @@ export declare function defineOp<A extends unknown[]>(decl: DualOpImpls<A>): ((.
|
|
|
189
202
|
* @returns `true` if at least one exported value is a dual-op function.
|
|
190
203
|
*/
|
|
191
204
|
export declare function hasDualOp(ns: Record<string, unknown>): boolean;
|
|
205
|
+
/**
|
|
206
|
+
* Read the dual-op metadata of a wrapped function (unit-system D8 declaration
|
|
207
|
+
* surface). Returns `undefined` when the function carries no dual-op metadata,
|
|
208
|
+
* so callers never probe the private key directly.
|
|
209
|
+
*
|
|
210
|
+
* @param fn - a function that may have been produced by `defineOp`/`compatOp`.
|
|
211
|
+
* @returns the op's metadata, or `undefined`.
|
|
212
|
+
*/
|
|
213
|
+
export declare function dualOpMetaOf(fn: unknown): DualOpMeta | undefined;
|
|
192
214
|
/**
|
|
193
215
|
* Assert that a library conforms to the dual-op contract: if it exports any
|
|
194
216
|
* dual-op function, it must also export `contractVersion` matching the engine's.
|
package/dist/define-op.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"define-op.d.ts","sourceRoot":"","sources":["../src/define-op.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;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C,KAAK,WAAW,GAAG;IAAE,CAAC,YAAY,CAAC,CAAC,EAAE,UAAU,CAAA;CAAE,CAAA;AAwFlD;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,QAAQ,CAAC,CAAC,SAAS,OAAO,EAAE,EAC1C,IAAI,EAAE,WAAW,CAAC,CAAC,CAAC,GAAG;IAAE,OAAO,EAAE,MAAM,EAAE,CAAA;CAAE,GAC3C,CAAC,CAAC,GAAG,IAAI,EAAE,CAAC,KAAK,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC,CAAC,GAAG,WAAW,CAAA;AACjE;;;;GAIG;AACH,wBAAgB,QAAQ,CAAC,CAAC,SAAS,OAAO,EAAE,EAC1C,IAAI,EAAE,WAAW,CAAC,CAAC,CAAC,GACnB,CAAC,CAAC,GAAG,IAAI,EAAE,CAAC,KAAK,OAAO,CAAC,KAAK,CAAC,CAAC,GAAG,WAAW,CAAA;AAkIjD;;;;;;;;;;GAUG;AACH;;;;;;;GAOG;AACH,wBAAgB,SAAS,CAAC,EAAE,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,OAAO,CAG9D;AAED;;;;;;;GAOG;AACH,wBAAgB,YAAY,CAAC,EAAE,EAAE,OAAO,GAAG,UAAU,GAAG,SAAS,CAGhE;AAED;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CA4DpE"}
|
package/dist/define-op.js
CHANGED
|
@@ -163,6 +163,8 @@ export function defineOp(decl) {
|
|
|
163
163
|
schema: decl.schema,
|
|
164
164
|
slotMap: decl.slotMap,
|
|
165
165
|
naming: decl.naming,
|
|
166
|
+
paramDims: decl.paramDims,
|
|
167
|
+
retDim: decl.retDim,
|
|
166
168
|
};
|
|
167
169
|
// Async wrapper: implementations may be sync or async (stdlib mesh paths are
|
|
168
170
|
// often async, e.g. drill/engrave/boolean). The compiled .fai.js product always
|
|
@@ -281,6 +283,19 @@ export function hasDualOp(ns) {
|
|
|
281
283
|
const values = Object.values(ns);
|
|
282
284
|
return values.some((v) => typeof v === 'function' && v[DUAL_OP_META]);
|
|
283
285
|
}
|
|
286
|
+
/**
|
|
287
|
+
* Read the dual-op metadata of a wrapped function (unit-system D8 declaration
|
|
288
|
+
* surface). Returns `undefined` when the function carries no dual-op metadata,
|
|
289
|
+
* so callers never probe the private key directly.
|
|
290
|
+
*
|
|
291
|
+
* @param fn - a function that may have been produced by `defineOp`/`compatOp`.
|
|
292
|
+
* @returns the op's metadata, or `undefined`.
|
|
293
|
+
*/
|
|
294
|
+
export function dualOpMetaOf(fn) {
|
|
295
|
+
if (typeof fn !== 'function')
|
|
296
|
+
return undefined;
|
|
297
|
+
return fn[DUAL_OP_META];
|
|
298
|
+
}
|
|
284
299
|
/**
|
|
285
300
|
* Assert that a library conforms to the dual-op contract: if it exports any
|
|
286
301
|
* dual-op function, it must also export `contractVersion` matching the engine's.
|
package/dist/define-op.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"define-op.js","sourceRoot":"","sources":["../src/define-op.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAEH,OAAO,EAAE,YAAY,EAAE,sBAAsB,EAA2B,MAAM,gCAAgC,CAAA;AAC9G,OAAO,EACL,gBAAgB,EAChB,oBAAoB,EACpB,oBAAoB,EACpB,cAAc,EACd,eAAe,EACf,MAAM,GACP,MAAM,iBAAiB,CAAA;AACxB,OAAO,EAAE,QAAQ,EAAiB,MAAM,YAAY,CAAA;AACpD,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,SAAS,CAAA;AAC3D,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAA;AAC1C,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAA;AAC3E,OAA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,OAAO,CAAC,KAAK,QAAQ,CAAC,CAAC;QAAE,OAAO,KAAK,CAAA;IACzG,MAAM,KAAK,GAAI,IAAiC,CAAC,UAAU,CAAA;IAC3D,IAAI,KAAK,KAAK,SAAS,IAAI,CAAC,OAAO,KAAK,KAAK,QAAQ,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,KAAK,CAAC,IAAI,KAAK,GAAG,CAAC,CAAC;QAAE,OAAO,KAAK,CAAA;IAC7G,OAAO,IAAI,CAAA;AACb,CAAC;AAED,0DAA0D;AAC1D,SAAS,aAAa,CAAC,MAAe;IACpC,IAAI,MAAM,KAAK,IAAI,IAAI,OAAO,MAAM,KAAK,QAAQ,IAAI,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC;QAAE,OAAO,KAAK,CAAA;IACxF,OAAO,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,OAAO,CAAC,KAAK,QAAQ,IAAI,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,CAAA;AAClF,CAAC","sourcesContent":["/**\n * define-op — dual-path implementation decorator for geometry functions\n * (D-face contract: mesh mandatory as the default path, BREP optional).\n *\n *\n * `defineOp({ mesh?, brep?, ... })` declares the implementation set of a\n * geometry function (a function whose signature returns `SolidShape`). The\n * wrapper:\n * - auto-collects geometry inputs via `args.filter(isGeometryInput)` — a shape\n * that is identity-registered (`isShape`) or a structural mesh shape\n * (`isMeshShape`, positions + indices — e.g. bare ManifoldMeshData handed in\n * by a host via `geoToManifoldMesh`). The old per-function form passed the\n * actual geometry args (`dispatchPath([input], ...)`), so a bare mesh input\n * dispatched to the mesh path (`hasBrep=false`); the re-collection must keep\n * that compatibility. No `inputs` field — decided at runtime by the args\n * themselves, not the author.\n * - calls the engine's `dispatchPath` to select brep/mesh by mode (static,\n * no runtime fallback);\n * - wraps raw products: mesh path → `solid()`, brep path → `fromHandle()` /\n * `fromBrep()` (D3/D4: products must come from constructors, brep products\n * must carry a BREP slot).\n *\n * Zero heavy runtime dependencies: imports only runtime-state / shape /\n * handle-bridge / backend-dispatch / mesh/types (a zero-import module holding\n * the Shape type and the structural `isMeshShape` guard) — the dist/sdk.js\n * static-import guard keeps passing.\n */\n\nimport { dispatchPath, firstMissingCapability, type BrepCapabilityName } from './cad-runtime/backend-dispatch'\nimport {\n CONTRACT_VERSION,\n BrepUnsupportedError,\n MeshUnsupportedError,\n getCurrentStmt,\n getRuntimeState,\n nameOf,\n} from './runtime-state'\nimport { asStmtId, type PartName } from './identity'\nimport { isShape, solid, fromBrep, getSlot } from './shape'\nimport { isMeshShape } from './mesh/types'\nimport { fromHandle, meshHandle, isOcctHandle } from './brep/handle-bridge'\nimport { positionalToObject, type SlotMap } from './api/internal/dual-form-args'\nimport { toOpFailure, unwrapResult, OpError, type ResultLike } from './api/internal/result-unwrap'\nimport type { Shape } from './mesh/types'\nimport { BREP_ENGINE_IDS, type BrepEngineId, type BrepHandle } from './brep/engine/types'\nimport { type Provenance, runtimeLineage } from './topology/naming/lineage'\n\n/** 合法引擎 id 集合(assertLibConforms 的 engines 校验用,D11-1)。 */\nconst BREP_ENGINE_ID_SET = new Set<string>(BREP_ENGINE_IDS)\n\n/** Raw mesh data (structurally identical to Shape; mesh impls return it). */\nexport type MeshData = { positions: Float32Array; indices: Uint32Array }\n\n/**\n * Geometry-input recognition for dispatch auto-collection.\n *\n * Compat rule: the old per-function form passed the *actual* geometry args to\n * `dispatchPath` (`[input]` / `shapes`), so a bare ManifoldMeshData object\n * (e.g. `geoToManifoldMesh` output passed straight by a host) had no BREP slot\n * → `hasBrep=false` → mesh path. defineOp must keep that: an input counts as\n * geometry when it is identity-registered (`isShape`, constructor product) OR\n * structurally a mesh shape (`positions` + `indices`). Params objects and other\n * scalar args are not geometry inputs.\n *\n * @param v - the candidate argument.\n * @returns true when the argument is a geometry input (registered shape or bare mesh data).\n */\nexport function isGeometryInput(v: unknown): v is Shape {\n return isShape(v) || isMeshShape(v)\n}\n\n/**\n * §1.4 registration guard: the StmtId whose top-level `wrapped` is currently\n * registering a lineage node. Nested op calls (an impl invoking another op /\n * itself) share the same `getCurrentStmt()` anchor and are skipped so they\n * don't trip N3 (E_TOPO_DUPLICATE_STMT) with identical content. C1 (single\n * live runtime) means at most one statement registers at a time.\n *\n * The marker lives on the runtime state and is reset at statement boundaries\n * (runtime-state.setCurrentStmt: anchor change / end-of-statement), NOT at op\n * granularity — a TS library function (cq-compat Workplane op, etc.) may call\n * several defineOps within one statement, and only the first one must register.\n */\n\n/** Product of a mesh implementation: raw mesh data, a wrapped Shape, or (with `outputs`) a record of named products. */\nexport type MeshProduct = MeshData | Shape | Record<string, MeshData | Shape>\n\n/** Mesh implementation: sync or async (stdlib mesh paths are often async); returns a mesh product. */\nexport type MeshImpl<A extends unknown[]> = (...args: A) => MeshProduct | Promise<MeshProduct>\n\n/** BREP implementation result: a raw handle, or a handle plus face evolution. */\nexport interface BrepResult {\n solid: BrepHandle\n faceEvolution?: Map<number, number[]>\n}\n\n/** Product of a BREP implementation: a raw handle, { solid, faceEvolution }, a wrapped Shape, or (with `outputs`) a record of named products. */\nexport type BrepProduct =\n | BrepHandle\n | BrepResult\n | Shape\n | Record<string, BrepHandle | BrepResult | Shape>\n | ResultLike\n\n/** BREP implementation: sync or async; returns a brep product. */\nexport type BrepImpl<A extends unknown[]> = (...args: A) => BrepProduct | Promise<BrepProduct>\n\n/** Optional declaration: capabilities (D5) and named multi-products (split, scheme C). */\nexport interface DualOpOptions {\n /** Op name (error messages); falls back to an anonymous prefix when absent. */\n name?: string\n capabilities?: BrepCapabilityName[]\n /**\n * 平台身份声明(D11,narrowing plan 2026-09-24):本 op 实现可运行在哪些\n * BREP 引擎上——一个**引擎白名单**。缺省 = 全平台(中立 op——实现只用 L1 核心面)。\n *\n * 平台 op(实现 import 了 `occt-kernel/*` / `brepkit-kernel/*`,调用该平台\n * 原生方法)**必须**声明 `engines` 自证身份。\n *\n * 与 `capabilities` **可以并存**(2026-09-24 撤销 D11-7 互斥):两者是正交的两轴——\n * `engines` 收窄「在哪些引擎上跑」,`capabilities` 声明「需要哪些内核能力」。判定\n * 次序 `engines` 在先(D11-2),能力门随后对同一引擎继续求交,故同时声明等于\n * 「只在这些引擎上,且要求这些能力」——不会静默放行\"目标引擎缺该能力\"的组合。\n */\n engines?: readonly BrepEngineId[]\n outputs?: string[]\n /** L3 schema per named parameter (G1 codegen + UI panel, plain string form). */\n schema?: Record<string, string>\n /**\n * D11 slot-map declaration (§4.2): the positional→object boxing table\n * (SlotMap) mapping a brepjs-style positional call onto this op's native\n * object form. Ops without it accept only the form their implementation\n * natively takes.\n */\n slotMap?: SlotMap\n /**\n * Topology identity provenance (plan §4.4 / Phase 2.3, **required**).\n * Declares the op's face-mapping category + new-face vocabulary.\n * The lineage registrar (§4.3) reads this to build the blood-line graph;\n * missing naming = compile-time error (G4: no undeclared ops).\n */\n naming: Provenance\n}\n\n/** Implementation set (at least one of mesh/brep is required, D1/D1b); options are siblings of the implementations. */\nexport type DualOpImpls<A extends unknown[]> =\n | (DualOpOptions & { mesh: MeshImpl<A>; brep?: BrepImpl<A> })\n | (DualOpOptions & { mesh?: never; brep: BrepImpl<A> })\n\n/** Metadata hung on the wrapped function object (K5: function info is data). */\nexport interface DualOpMeta {\n kind: 'dual-op'\n mesh?: unknown\n brep?: unknown\n /** Op name (error messages). */\n name?: string\n capabilities?: BrepCapabilityName[]\n /** 平台身份声明(D11,镜像 DualOpOptions.engines)。 */\n engines?: readonly BrepEngineId[]\n outputs?: string[]\n schema?: Record<string, string>\n /** D11 slot-map declaration (positional → object boxing table, §9 naming). */\n slotMap?: SlotMap\n /** Topology identity provenance (Phase 2.3, mirrors DualOpOptions.naming). */\n naming: Provenance\n}\n\n/** Property key carrying DualOpMeta on wrapped functions. */\nexport const DUAL_OP_META = '__faijs__dualOp'\n\ntype MetaCarrier = { [DUAL_OP_META]?: DualOpMeta }\n\nfunction wrapMeshOne(v: unknown): Shape {\n if (isShape(v)) return v\n return solid(v as MeshData)\n}\n\nfunction wrapBrepOne(v: unknown): Shape {\n if (isShape(v)) return v\n if (v !== null && typeof v === 'object' && 'faceEvolution' in v) {\n const res = v as BrepResult\n return fromBrep(meshHandle(res.solid), res)\n }\n // A plain object that is not a Shape and not an OCCT handle is a data\n // product (e.g. a compat fn returning a sheetmetal-style record), not a\n // geometry handle — pass it through so it lands in the engine's value\n // store instead of being tessellated as if it were a bare handle. Native\n // OCCT handles from an implementation are hand-computed shape numbers\n // (from a branded number return) or objects; only the number path reaches\n // fromHandle. The handle/data distinction must go through the shared\n // isOcctHandle leaf (handle-bridge) — never a hardcoded '__occtWasm' in v.\n if (v !== null && typeof v === 'object' && !isOcctHandle(v)) {\n return v as unknown as Shape\n }\n return fromHandle(v)\n}\n\nfunction wrapByKeys(r: unknown, keys: string[], wrapOne: (v: unknown) => Shape): Record<string, Shape> {\n const src = (r ?? {}) as Record<string, unknown>\n const out: Record<string, Shape> = {}\n for (const k of keys) {\n const v = src[k]\n // An output may be an array (e.g. the compat adapter adopts each element of\n // an array-valued `outputs` field); wrap element-wise so arrays stay arrays.\n out[k] = Array.isArray(v) ? (v.map(wrapOne) as unknown as Shape) : wrapOne(v)\n }\n // Pass through non-shape data keys (e.g. autoHeal's `report`): declared\n // outputs are the geometry that gets Shape-wrapped, but sibling data products\n // of the same op result must survive the statement boundary (§5.4 selfhost).\n for (const k of Object.keys(src)) {\n if (!keys.includes(k)) out[k] = src[k] as unknown as Shape\n }\n return out\n}\n\n/** Human-readable op label for error messages (falls back when unnamed). */\nfunction opLabel(meta: DualOpMeta): string {\n return meta.name ?? '<anon>'\n}\n\n/**\n * Run one implementation through the unified Result boundary (§5.2, D1).\n *\n * Transition contract: an implementation may\n * ① return a `Result` → unwrapped here (`err` becomes a throw);\n * ② throw → normalized into an op-labelled error;\n * ③ return a plain product → passed through untouched.\n *\n * The two engine-level routing errors keep their class: `runtime.ts` matches\n * `BrepUnsupportedError` / `MeshUnsupportedError` by `instanceof` to turn them\n * into `ExecutionResult.failedAt`, so they must not be re-wrapped.\n *\n * @param meta - the op's metadata (name).\n * @param impl - the implementation to run.\n * @param args - the normalized argument list.\n * @returns the (unwrapped) implementation product.\n */\nasync function runImpl(\n meta: DualOpMeta,\n impl: ((...a: unknown[]) => unknown) | undefined,\n args: unknown[],\n): Promise<unknown> {\n const label = opLabel(meta)\n let product: unknown\n try {\n product = await (impl as (...a: unknown[]) => unknown)(...args)\n } catch (e) {\n if (e instanceof BrepUnsupportedError || e instanceof MeshUnsupportedError) throw e\n // An OpError is already the engine-recognizable statement failure (thrown\n // by the compat adapter's Result unwrap, or by impls returning a Result);\n // re-wrapping it into a plain Error would make CadRuntime treat it as an\n // uncaught bug instead of a statement failure.\n if (e instanceof OpError) throw e\n throw toOpFailure(label, e)\n }\n return unwrapResult(product, label)\n}\n\n/**\n * Declare a geometry function's dual-path implementation set.\n *\n * At least one implementation (mesh or brep) is required — enforced at\n * compile time by the union type and at construction time by a runtime check.\n * Geometry inputs are auto-collected by identity-or-structure\n * (`args.filter(isGeometryInput)` = `isShape` ∨ `isMeshShape`); raw mesh\n * products are wrapped by `solid()`, raw brep products by\n * `fromHandle()` / `fromBrep()`. `mode` selects the engine path via the\n * engine's static `dispatchPath` — the author never writes an `if (path)`\n * branch.\n *\n * @param decl - the declaration object: implementations `{ mesh }` (mesh-only),\n * `{ brep }` (brep-only, D1b), or `{ mesh, brep }` (dual-path), plus optional\n * `capabilities` (D5: missing capability degrades in auto, errors in brep mode)\n * and `outputs` (named multi-products, e.g. split) as siblings.\n * @returns the wrapped geometry function with dual-op metadata attached.\n */\nexport function defineOp<A extends unknown[]>(\n decl: DualOpImpls<A> & { outputs: string[] },\n): ((...args: A) => Promise<Record<string, Shape>>) & MetaCarrier\n/**\n * Overload without `outputs`: single-product functions resolve to a `Promise<Shape>`.\n * @param decl - the declaration object: implementations `{ mesh }`, `{ brep }`, or `{ mesh, brep }`.\n * @returns the wrapped geometry function with dual-op metadata attached.\n */\nexport function defineOp<A extends unknown[]>(\n decl: DualOpImpls<A>,\n): ((...args: A) => Promise<Shape>) & MetaCarrier\n/** Implementation signature (not visible to callers); matches the union of both overloads. */\nexport function defineOp<A extends unknown[]>(\n decl: DualOpImpls<A>,\n): ((...args: A) => Promise<Shape | Record<string, Shape>>) & MetaCarrier {\n // Construction-time check (②): implementations must be functions, then at\n // least one implementation must be present.\n if (decl.mesh !== undefined && typeof decl.mesh !== 'function') {\n throw new Error('[faijs/defineOp] mesh must be a function')\n }\n if (decl.brep !== undefined && typeof decl.brep !== 'function') {\n throw new Error('[faijs/defineOp] brep must be a function')\n }\n if (typeof decl.mesh !== 'function' && typeof decl.brep !== 'function') {\n throw new Error('[faijs/defineOp] at least one implementation (mesh or brep) is required')\n }\n\n const meta: DualOpMeta = {\n kind: 'dual-op',\n mesh: decl.mesh,\n brep: decl.brep,\n name: decl.name,\n capabilities: decl.capabilities,\n engines: decl.engines,\n outputs: decl.outputs,\n schema: decl.schema,\n slotMap: decl.slotMap,\n naming: decl.naming,\n }\n\n // Async wrapper: implementations may be sync or async (stdlib mesh paths are\n // often async, e.g. drill/engrave/boolean). The compiled .fai.js product always\n // awaits the call, so returning a Promise is transparent.\n const wrapped = async (...args: A): Promise<Shape | Record<string, Shape>> => {\n // D11 (§4.2): faijs-native ops declare an object-form implementation, so a\n // brepjs-style positional call is boxed into the object form here — before\n // dispatch, so geometry inputs are collected from the normalized arg list.\n const callArgs = (\n meta.slotMap ? positionalToObject(args as unknown[], meta.slotMap, opLabel(meta)) : args\n ) as A\n // Geometry inputs: identity-or-structure auto collection (execution-time\n // read, same nature as hasBrep — decided before the implementation runs).\n // Compat: bare ManifoldMeshData args (host geoToManifoldMesh output) are\n // geometry inputs too — old form passed [input] so they reached the mesh path.\n const inputs = (callArgs as unknown[]).filter(isGeometryInput) as Shape[]\n // §1.4 lineage registration (plan §4.3): every top-level dual-op execution\n // records a blood-line node via `runtimeLineage.register`, which enforces\n // N1 (untracked input → throw, never default to chain-root) / N2\n // (stmt↔anchor mismatch) / N3 (conflicting re-register). The graph is\n // cleared per program execution (direct-executor runCode) and C1 guarantees\n // a single live runtime, so the anchor is authoritative inside a statement.\n // Skip when no anchor is set (the op was invoked outside a statement\n // context — there is no lineage to record, and N2 must not fire on a context\n // that legitimately has none).\n //\n // Guard: a statement executes exactly one *top-level* op; an op's\n // implementation may invoke other ops (or itself) internally, and those\n // nested calls share the same `getCurrentStmt()` anchor. They are\n // implementation details, not statements, so they must NOT register a second\n // node under the same StmtId — that would trip N3 (E_TOPO_DUPLICATE_STMT)\n // on identical content. Only the outermost `wrapped` for the current\n // statement registers; the flag below stays set for the *entire* statement\n // execution (including the awaited impl), so nested calls see it and skip.\n const anchor = getCurrentStmt()\n const st = getRuntimeState()\n const isOuter = anchor != null && st.registeredStmtId !== anchor.id\n if (isOuter) st.registeredStmtId = asStmtId(anchor.id)\n try {\n if (isOuter && anchor) {\n runtimeLineage.register(\n {\n stmt: asStmtId(anchor.id),\n op: opLabel(meta),\n inputs,\n outputs: anchor.outputs as [PartName, ...PartName[]],\n provenance: meta.naming,\n },\n {\n nameOf,\n currentStmt: () => {\n const a = getCurrentStmt()\n return a ? { id: a.id } : undefined\n },\n },\n )\n }\n // D5 capability routing: feed the first missing capability to dispatchPath\n // (auto degrades to mesh, brep mode errors). Matched as a concrete name\n // against the engine's declaration set (family booleans + its `evolution`\n // list of *WithHistory kernel function names) — see firstMissingCapability.\n const missing = firstMissingCapability(meta.capabilities)\n const path = dispatchPath(inputs, meta, missing, meta.engines)\n if (path === 'brep') {\n const r = await runImpl(meta, decl.brep as unknown as ((...a: unknown[]) => unknown) | undefined, callArgs)\n const out = meta.outputs ? wrapByKeys(r, meta.outputs, wrapBrepOne) : wrapBrepOne(r)\n // 1.10 前置①:执行期把 hash 演化挂到血缘节点(kernel 类回走推进的数据源)。\n // 演化在几何算完那一刻可得(fromBrep → slot.faceEvolution),事后补挂不参与\n // N3 的内容比较(lineage.ts 设计如此)。无演化(identity/construct 等无历史\n // 输出)时跳过——identity 类推进不依赖演化,construct 词汇在节点 provenance 里。\n const outShape = (typeof out === 'object' && out !== null ? Object.values(out)[0] : out) as Shape | undefined\n const evolution = outShape ? getSlot(outShape)?.faceEvolution : undefined\n if (outShape && evolution) {\n runtimeLineage.attachEvolution(asStmtId(anchor!.id), evolution)\n }\n // 1.10 前置③:part 键的 roleTable 旁挂在这里记录(不是 fromBrep)——\n // impl 返回后 anchor.outputs 名字已定,而 fromBrep 时刻 shape 还未被\n // executor 命名(nameOf 为 undefined)。op 实现读输入表(inputRoleTable)\n // 与解析读表(tableOfPart)都走这份 part 键权威表。\n if (outShape && anchor && anchor.outputs.length > 0) {\n const stmtId = asStmtId(anchor.id)\n const table = runtimeLineage.outputTableOf(stmtId)\n const solid = runtimeLineage.outputHandleOf(stmtId)\n if (table) runtimeLineage.recordOutput(stmtId, table, solid, anchor.outputs[0] as PartName)\n }\n return out\n }\n const m = await runImpl(meta, decl.mesh as unknown as ((...a: unknown[]) => unknown) | undefined, callArgs)\n return meta.outputs ? wrapByKeys(m, meta.outputs, wrapMeshOne) : wrapMeshOne(m)\n } finally {\n // 同语句去重标记不在 op 粒度清理——语句边界由 runtime-state.setCurrentStmt\n // 在锚点变化时重置;TS 库函数体内连续 op 调用共享锚点,嵌套调用正确跳过。\n }\n }\n\n Object.defineProperty(wrapped, DUAL_OP_META, { value: meta, enumerable: false })\n return wrapped as ((...args: A) => Promise<Shape | Record<string, Shape>>) & MetaCarrier\n}\n\n/**\n * Assembly-time validation (③, strict mode, D-4): a library that exports any\n * dual-op function must carry a matching `contractVersion`, and every exported\n * dual-op must be structurally valid (mesh a function, brep a function or\n * undefined, capabilities/outputs well-formed). Called by `registerLib`.\n *\n * Functions without dual-op metadata are left untouched (declarative\n * enforcement boundary — K5 forbids name-based classification).\n *\n * @param lib - the library namespace object being registered.\n */\n/**\n * Detect whether a library namespace exports any dual-op function (carries\n * `DUAL_OP_META`). Used by `registerLib`'s inferred `autoLift` default: a\n * library that already declares dual-ops does not need bare-function lifting.\n *\n * @param ns - the library namespace object.\n * @returns `true` if at least one exported value is a dual-op function.\n */\nexport function hasDualOp(ns: Record<string, unknown>): boolean {\n const values = Object.values(ns)\n return values.some((v) => typeof v === 'function' && (v as MetaCarrier)[DUAL_OP_META])\n}\n\n/**\n * Assert that a library conforms to the dual-op contract: if it exports any\n * dual-op function, it must also export `contractVersion` matching the engine's.\n *\n * @param lib - the library namespace object being registered.\n * @throws {Error} when dual-op functions are present without a matching contract version.\n */\nexport function assertLibConforms(lib: Record<string, unknown>): void {\n if (hasDualOp(lib) && lib.contractVersion !== CONTRACT_VERSION) {\n throw new Error(\n `[faijs] library with dual-op functions must export contractVersion = ${CONTRACT_VERSION} (got ${String(lib.contractVersion)})`,\n )\n }\n\n for (const [name, value] of Object.entries(lib)) {\n if (typeof value !== 'function') continue\n const meta = (value as MetaCarrier)[DUAL_OP_META]\n if (!meta || meta.kind !== 'dual-op') continue\n if (typeof meta.mesh !== 'function' && typeof meta.brep !== 'function') {\n throw new Error(`[faijs] lib function '${name}' declares dual-op without any implementation`)\n }\n if (meta.mesh !== undefined && typeof meta.mesh !== 'function') {\n throw new Error(`[faijs] lib function '${name}' declares dual-op with a non-function mesh implementation`)\n }\n if (meta.brep !== undefined && typeof meta.brep !== 'function') {\n throw new Error(`[faijs] lib function '${name}' declares dual-op with a non-function brep implementation`)\n }\n if (meta.capabilities !== undefined && !Array.isArray(meta.capabilities)) {\n throw new Error(`[faijs] lib function '${name}' declares invalid capabilities (expected string[])`)\n }\n // D11-7 互斥**已撤销**(2026-09-24 用户裁决):engines 与 capabilities 是两条正交的\n // 声明轴——前者是引擎身份白名单(在哪些引擎上跑),后者是实现所需内核能力清单\n // (要用哪些方法)。两者并存是合法且更诚实的写法:engines 收窄候选集,能力门随后\n // 对同一引擎继续求交(dispatchPath 的求值次序本就是 engines 在先,D11-2)。\n // 曾经的理由「能力名空间只收 L1 中立名」与事实不符——BrepCapabilityName 含\n // BrepMethodKind 逐核真名(isNull / dispose / chamfer / shell / ...,见\n // brep/engine/types.ts),本就是内核名空间;平台 op 声明能力名并不越界。\n // 故此处不再校验两者是否同时出现。\n if (meta.engines !== undefined) {\n if (!Array.isArray(meta.engines) || meta.engines.length === 0) {\n throw new Error(`[faijs] lib function '${name}' declares invalid engines (expected non-empty BrepEngineId[])`)\n }\n const bad = meta.engines.find((e) => !BREP_ENGINE_ID_SET.has(e))\n if (bad !== undefined) {\n throw new Error(\n `[faijs] lib function '${name}' declares unknown engine '${String(bad)}' — expected one of ${BREP_ENGINE_IDS.join(', ')}`,\n )\n }\n }\n if (\n meta.outputs !== undefined\n && (!Array.isArray(meta.outputs) || meta.outputs.some((k) => typeof k !== 'string'))\n ) {\n throw new Error(`[faijs] lib function '${name}' declares invalid outputs (expected string[])`)\n }\n if (meta.schema !== undefined && !isValidSchema(meta.schema)) {\n throw new Error(`[faijs] lib function '${name}' declares invalid schema (expected Record<string, string>)`)\n }\n if (meta.name !== undefined && typeof meta.name !== 'string') {\n throw new Error(`[faijs] lib function '${name}' declares invalid name (expected string)`)\n }\n if (meta.slotMap !== undefined && !isValidSlotMap(meta.slotMap)) {\n throw new Error(\n `[faijs] lib function '${name}' declares invalid slotMap (expected { keys: string[]; vec3Keys?: string[]; shapeArity?: number })`,\n )\n }\n }\n}\n\n/** True when the D11 slot-map declaration has a non-empty string `keys` list. */\nfunction isValidSlotMap(form: unknown): form is SlotMap {\n if (form === null || typeof form !== 'object') return false\n const keys = (form as { keys?: unknown }).keys\n if (!Array.isArray(keys) || keys.some((k) => typeof k !== 'string')) return false\n const vec3 = (form as { vec3Keys?: unknown }).vec3Keys\n if (vec3 !== undefined && (!Array.isArray(vec3) || vec3.some((k) => typeof k !== 'string'))) return false\n const arity = (form as { shapeArity?: unknown }).shapeArity\n if (arity !== undefined && (typeof arity !== 'number' || !Number.isInteger(arity) || arity < 0)) return false\n return true\n}\n\n/** True when every schema value is a non-empty string. */\nfunction isValidSchema(schema: unknown): schema is Record<string, string> {\n if (schema === null || typeof schema !== 'object' || Array.isArray(schema)) return false\n return Object.values(schema).every((v) => typeof v === 'string' && v.length > 0)\n}\n"]}
|
|
1
|
+
{"version":3,"file":"define-op.js","sourceRoot":"","sources":["../src/define-op.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAEH,OAAO,EAAE,YAAY,EAAE,sBAAsB,EAA2B,MAAM,gCAAgC,CAAA;AAC9G,OAAO,EACL,gBAAgB,EAChB,oBAAoB,EACpB,oBAAoB,EACpB,cAAc,EACd,eAAe,EACf,MAAM,GACP,MAAM,iBAAiB,CAAA;AACxB,OAAO,EAAE,QAAQ,EAAiB,MAAM,YAAY,CAAA;AACpD,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,SAAS,CAAA;AAC3D,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAA;AAC1C,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAA;AAC3E,OAAO,EAAE,kBAAkB,EAAgB,MAAM,+BAA+B,CAAA;AAChF,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,OAAO,EAAmB,MAAM,8BAA8B,CAAA;AAElG,OAAO,EAAE,eAAe,EAAsC,MAAM,qBAAqB,CAAA;AAEzF,OAAO,EAAmB,cAAc,EAAE,MAAM,2BAA2B,CAAA;AAE3E,yDAAyD;AACzD,MAAM,kBAAkB,GAAG,IAAI,GAAG,CAAS,eAAe,CAAC,CAAA;AAK3D;;;;;;;;;;;;;GAaG;AACH,MAAM,UAAU,eAAe,CAAC,CAAU;IACxC,OAAO,OAAO,CAAC,CAAC,CAAC,IAAI,WAAW,CAAC,CAAC,CAAC,CAAA;AACrC,CAAC;AA8GD,6DAA6D;AAC7D,MAAM,CAAC,MAAM,YAAY,GAAG,iBAAiB,CAAA;AAI7C,SAAS,WAAW,CAAC,CAAU;IAC7B,IAAI,OAAO,CAAC,CAA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AAC1D,SAAS,aAAa,CAAC,MAAe;IACpC,IAAI,MAAM,KAAK,IAAI,IAAI,OAAO,MAAM,KAAK,QAAQ,IAAI,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC;QAAE,OAAO,KAAK,CAAA;IACxF,OAAO,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,OAAO,CAAC,KAAK,QAAQ,IAAI,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,CAAA;AAClF,CAAC","sourcesContent":["/**\n * define-op — dual-path implementation decorator for geometry functions\n * (D-face contract: mesh mandatory as the default path, BREP optional).\n *\n *\n * `defineOp({ mesh?, brep?, ... })` declares the implementation set of a\n * geometry function (a function whose signature returns `SolidShape`). The\n * wrapper:\n * - auto-collects geometry inputs via `args.filter(isGeometryInput)` — a shape\n * that is identity-registered (`isShape`) or a structural mesh shape\n * (`isMeshShape`, positions + indices — e.g. bare ManifoldMeshData handed in\n * by a host via `geoToManifoldMesh`). The old per-function form passed the\n * actual geometry args (`dispatchPath([input], ...)`), so a bare mesh input\n * dispatched to the mesh path (`hasBrep=false`); the re-collection must keep\n * that compatibility. No `inputs` field — decided at runtime by the args\n * themselves, not the author.\n * - calls the engine's `dispatchPath` to select brep/mesh by mode (static,\n * no runtime fallback);\n * - wraps raw products: mesh path → `solid()`, brep path → `fromHandle()` /\n * `fromBrep()` (D3/D4: products must come from constructors, brep products\n * must carry a BREP slot).\n *\n * Zero heavy runtime dependencies: imports only runtime-state / shape /\n * handle-bridge / backend-dispatch / mesh/types (a zero-import module holding\n * the Shape type and the structural `isMeshShape` guard) — the dist/sdk.js\n * static-import guard keeps passing.\n */\n\nimport { dispatchPath, firstMissingCapability, type BrepCapabilityName } from './cad-runtime/backend-dispatch'\nimport {\n CONTRACT_VERSION,\n BrepUnsupportedError,\n MeshUnsupportedError,\n getCurrentStmt,\n getRuntimeState,\n nameOf,\n} from './runtime-state'\nimport { asStmtId, type PartName } from './identity'\nimport { isShape, solid, fromBrep, getSlot } from './shape'\nimport { isMeshShape } from './mesh/types'\nimport { fromHandle, meshHandle, isOcctHandle } from './brep/handle-bridge'\nimport { positionalToObject, type SlotMap } from './api/internal/dual-form-args'\nimport { toOpFailure, unwrapResult, OpError, type ResultLike } from './api/internal/result-unwrap'\nimport type { Shape } from './mesh/types'\nimport { BREP_ENGINE_IDS, type BrepEngineId, type BrepHandle } from './brep/engine/types'\nimport type { DimName } from './units'\nimport { type Provenance, runtimeLineage } from './topology/naming/lineage'\n\n/** 合法引擎 id 集合(assertLibConforms 的 engines 校验用,D11-1)。 */\nconst BREP_ENGINE_ID_SET = new Set<string>(BREP_ENGINE_IDS)\n\n/** Raw mesh data (structurally identical to Shape; mesh impls return it). */\nexport type MeshData = { positions: Float32Array; indices: Uint32Array }\n\n/**\n * Geometry-input recognition for dispatch auto-collection.\n *\n * Compat rule: the old per-function form passed the *actual* geometry args to\n * `dispatchPath` (`[input]` / `shapes`), so a bare ManifoldMeshData object\n * (e.g. `geoToManifoldMesh` output passed straight by a host) had no BREP slot\n * → `hasBrep=false` → mesh path. defineOp must keep that: an input counts as\n * geometry when it is identity-registered (`isShape`, constructor product) OR\n * structurally a mesh shape (`positions` + `indices`). Params objects and other\n * scalar args are not geometry inputs.\n *\n * @param v - the candidate argument.\n * @returns true when the argument is a geometry input (registered shape or bare mesh data).\n */\nexport function isGeometryInput(v: unknown): v is Shape {\n return isShape(v) || isMeshShape(v)\n}\n\n/**\n * §1.4 registration guard: the StmtId whose top-level `wrapped` is currently\n * registering a lineage node. Nested op calls (an impl invoking another op /\n * itself) share the same `getCurrentStmt()` anchor and are skipped so they\n * don't trip N3 (E_TOPO_DUPLICATE_STMT) with identical content. C1 (single\n * live runtime) means at most one statement registers at a time.\n *\n * The marker lives on the runtime state and is reset at statement boundaries\n * (runtime-state.setCurrentStmt: anchor change / end-of-statement), NOT at op\n * granularity — a TS library function (cq-compat Workplane op, etc.) may call\n * several defineOps within one statement, and only the first one must register.\n */\n\n/** Product of a mesh implementation: raw mesh data, a wrapped Shape, or (with `outputs`) a record of named products. */\nexport type MeshProduct = MeshData | Shape | Record<string, MeshData | Shape>\n\n/** Mesh implementation: sync or async (stdlib mesh paths are often async); returns a mesh product. */\nexport type MeshImpl<A extends unknown[]> = (...args: A) => MeshProduct | Promise<MeshProduct>\n\n/** BREP implementation result: a raw handle, or a handle plus face evolution. */\nexport interface BrepResult {\n solid: BrepHandle\n faceEvolution?: Map<number, number[]>\n}\n\n/** Product of a BREP implementation: a raw handle, { solid, faceEvolution }, a wrapped Shape, or (with `outputs`) a record of named products. */\nexport type BrepProduct =\n | BrepHandle\n | BrepResult\n | Shape\n | Record<string, BrepHandle | BrepResult | Shape>\n | ResultLike\n\n/** BREP implementation: sync or async; returns a brep product. */\nexport type BrepImpl<A extends unknown[]> = (...args: A) => BrepProduct | Promise<BrepProduct>\n\n/** Optional declaration: capabilities (D5) and named multi-products (split, scheme C). */\nexport interface DualOpOptions {\n /** Op name (error messages); falls back to an anonymous prefix when absent. */\n name?: string\n capabilities?: BrepCapabilityName[]\n /**\n * 平台身份声明(D11,narrowing plan 2026-09-24):本 op 实现可运行在哪些\n * BREP 引擎上——一个**引擎白名单**。缺省 = 全平台(中立 op——实现只用 L1 核心面)。\n *\n * 平台 op(实现 import 了 `occt-kernel/*` / `brepkit-kernel/*`,调用该平台\n * 原生方法)**必须**声明 `engines` 自证身份。\n *\n * 与 `capabilities` **可以并存**(2026-09-24 撤销 D11-7 互斥):两者是正交的两轴——\n * `engines` 收窄「在哪些引擎上跑」,`capabilities` 声明「需要哪些内核能力」。判定\n * 次序 `engines` 在先(D11-2),能力门随后对同一引擎继续求交,故同时声明等于\n * 「只在这些引擎上,且要求这些能力」——不会静默放行\"目标引擎缺该能力\"的组合。\n */\n engines?: readonly BrepEngineId[]\n outputs?: string[]\n /** L3 schema per named parameter (G1 codegen + UI panel, plain string form). */\n schema?: Record<string, string>\n /**\n * D11 slot-map declaration (§4.2): the positional→object boxing table\n * (SlotMap) mapping a brepjs-style positional call onto this op's native\n * object form. Ops without it accept only the form their implementation\n * natively takes.\n */\n slotMap?: SlotMap\n /**\n * Topology identity provenance (plan §4.4 / Phase 2.3, **required**).\n * Declares the op's face-mapping category + new-face vocabulary.\n * The lineage registrar (§4.3) reads this to build the blood-line graph;\n * missing naming = compile-time error (G4: no undeclared ops).\n */\n naming: Provenance\n /**\n * Script-side dimension declaration (unit-system D8): per-parameter dim for\n * the static `dimension` check stage. Params absent here are treated as\n * dimensionless and exempt from the check. `DimName` is a pure type import.\n */\n paramDims?: Record<string, DimName>\n /** Return dimension declaration (D8): the value produced carries this dim. */\n retDim?: DimName\n}\n\n/** Implementation set (at least one of mesh/brep is required, D1/D1b); options are siblings of the implementations. */\nexport type DualOpImpls<A extends unknown[]> =\n | (DualOpOptions & { mesh: MeshImpl<A>; brep?: BrepImpl<A> })\n | (DualOpOptions & { mesh?: never; brep: BrepImpl<A> })\n\n/** Metadata hung on the wrapped function object (K5: function info is data). */\nexport interface DualOpMeta {\n kind: 'dual-op'\n mesh?: unknown\n brep?: unknown\n /** Op name (error messages). */\n name?: string\n capabilities?: BrepCapabilityName[]\n /** 平台身份声明(D11,镜像 DualOpOptions.engines)。 */\n engines?: readonly BrepEngineId[]\n outputs?: string[]\n schema?: Record<string, string>\n /** D11 slot-map declaration (positional → object boxing table, §9 naming). */\n slotMap?: SlotMap\n /** Topology identity provenance (Phase 2.3, mirrors DualOpOptions.naming). */\n naming: Provenance\n /** Script-side dimension declaration (D8, mirrors DualOpOptions.paramDims). */\n paramDims?: Record<string, DimName>\n /** Return dimension declaration (D8). */\n retDim?: DimName\n}\n\n/** Property key carrying DualOpMeta on wrapped functions. */\nexport const DUAL_OP_META = '__faijs__dualOp'\n\ntype MetaCarrier = { [DUAL_OP_META]?: DualOpMeta }\n\nfunction wrapMeshOne(v: unknown): Shape {\n if (isShape(v)) return v\n return solid(v as MeshData)\n}\n\nfunction wrapBrepOne(v: unknown): Shape {\n if (isShape(v)) return v\n if (v !== null && typeof v === 'object' && 'faceEvolution' in v) {\n const res = v as BrepResult\n return fromBrep(meshHandle(res.solid), res)\n }\n // A plain object that is not a Shape and not an OCCT handle is a data\n // product (e.g. a compat fn returning a sheetmetal-style record), not a\n // geometry handle — pass it through so it lands in the engine's value\n // store instead of being tessellated as if it were a bare handle. Native\n // OCCT handles from an implementation are hand-computed shape numbers\n // (from a branded number return) or objects; only the number path reaches\n // fromHandle. The handle/data distinction must go through the shared\n // isOcctHandle leaf (handle-bridge) — never a hardcoded '__occtWasm' in v.\n if (v !== null && typeof v === 'object' && !isOcctHandle(v)) {\n return v as unknown as Shape\n }\n return fromHandle(v)\n}\n\nfunction wrapByKeys(r: unknown, keys: string[], wrapOne: (v: unknown) => Shape): Record<string, Shape> {\n const src = (r ?? {}) as Record<string, unknown>\n const out: Record<string, Shape> = {}\n for (const k of keys) {\n const v = src[k]\n // An output may be an array (e.g. the compat adapter adopts each element of\n // an array-valued `outputs` field); wrap element-wise so arrays stay arrays.\n out[k] = Array.isArray(v) ? (v.map(wrapOne) as unknown as Shape) : wrapOne(v)\n }\n // Pass through non-shape data keys (e.g. autoHeal's `report`): declared\n // outputs are the geometry that gets Shape-wrapped, but sibling data products\n // of the same op result must survive the statement boundary (§5.4 selfhost).\n for (const k of Object.keys(src)) {\n if (!keys.includes(k)) out[k] = src[k] as unknown as Shape\n }\n return out\n}\n\n/** Human-readable op label for error messages (falls back when unnamed). */\nfunction opLabel(meta: DualOpMeta): string {\n return meta.name ?? '<anon>'\n}\n\n/**\n * Run one implementation through the unified Result boundary (§5.2, D1).\n *\n * Transition contract: an implementation may\n * ① return a `Result` → unwrapped here (`err` becomes a throw);\n * ② throw → normalized into an op-labelled error;\n * ③ return a plain product → passed through untouched.\n *\n * The two engine-level routing errors keep their class: `runtime.ts` matches\n * `BrepUnsupportedError` / `MeshUnsupportedError` by `instanceof` to turn them\n * into `ExecutionResult.failedAt`, so they must not be re-wrapped.\n *\n * @param meta - the op's metadata (name).\n * @param impl - the implementation to run.\n * @param args - the normalized argument list.\n * @returns the (unwrapped) implementation product.\n */\nasync function runImpl(\n meta: DualOpMeta,\n impl: ((...a: unknown[]) => unknown) | undefined,\n args: unknown[],\n): Promise<unknown> {\n const label = opLabel(meta)\n let product: unknown\n try {\n product = await (impl as (...a: unknown[]) => unknown)(...args)\n } catch (e) {\n if (e instanceof BrepUnsupportedError || e instanceof MeshUnsupportedError) throw e\n // An OpError is already the engine-recognizable statement failure (thrown\n // by the compat adapter's Result unwrap, or by impls returning a Result);\n // re-wrapping it into a plain Error would make CadRuntime treat it as an\n // uncaught bug instead of a statement failure.\n if (e instanceof OpError) throw e\n throw toOpFailure(label, e)\n }\n return unwrapResult(product, label)\n}\n\n/**\n * Declare a geometry function's dual-path implementation set.\n *\n * At least one implementation (mesh or brep) is required — enforced at\n * compile time by the union type and at construction time by a runtime check.\n * Geometry inputs are auto-collected by identity-or-structure\n * (`args.filter(isGeometryInput)` = `isShape` ∨ `isMeshShape`); raw mesh\n * products are wrapped by `solid()`, raw brep products by\n * `fromHandle()` / `fromBrep()`. `mode` selects the engine path via the\n * engine's static `dispatchPath` — the author never writes an `if (path)`\n * branch.\n *\n * @param decl - the declaration object: implementations `{ mesh }` (mesh-only),\n * `{ brep }` (brep-only, D1b), or `{ mesh, brep }` (dual-path), plus optional\n * `capabilities` (D5: missing capability degrades in auto, errors in brep mode)\n * and `outputs` (named multi-products, e.g. split) as siblings.\n * @returns the wrapped geometry function with dual-op metadata attached.\n */\nexport function defineOp<A extends unknown[]>(\n decl: DualOpImpls<A> & { outputs: string[] },\n): ((...args: A) => Promise<Record<string, Shape>>) & MetaCarrier\n/**\n * Overload without `outputs`: single-product functions resolve to a `Promise<Shape>`.\n * @param decl - the declaration object: implementations `{ mesh }`, `{ brep }`, or `{ mesh, brep }`.\n * @returns the wrapped geometry function with dual-op metadata attached.\n */\nexport function defineOp<A extends unknown[]>(\n decl: DualOpImpls<A>,\n): ((...args: A) => Promise<Shape>) & MetaCarrier\n/** Implementation signature (not visible to callers); matches the union of both overloads. */\nexport function defineOp<A extends unknown[]>(\n decl: DualOpImpls<A>,\n): ((...args: A) => Promise<Shape | Record<string, Shape>>) & MetaCarrier {\n // Construction-time check (②): implementations must be functions, then at\n // least one implementation must be present.\n if (decl.mesh !== undefined && typeof decl.mesh !== 'function') {\n throw new Error('[faijs/defineOp] mesh must be a function')\n }\n if (decl.brep !== undefined && typeof decl.brep !== 'function') {\n throw new Error('[faijs/defineOp] brep must be a function')\n }\n if (typeof decl.mesh !== 'function' && typeof decl.brep !== 'function') {\n throw new Error('[faijs/defineOp] at least one implementation (mesh or brep) is required')\n }\n\n const meta: DualOpMeta = {\n kind: 'dual-op',\n mesh: decl.mesh,\n brep: decl.brep,\n name: decl.name,\n capabilities: decl.capabilities,\n engines: decl.engines,\n outputs: decl.outputs,\n schema: decl.schema,\n slotMap: decl.slotMap,\n naming: decl.naming,\n paramDims: decl.paramDims,\n retDim: decl.retDim,\n }\n\n // Async wrapper: implementations may be sync or async (stdlib mesh paths are\n // often async, e.g. drill/engrave/boolean). The compiled .fai.js product always\n // awaits the call, so returning a Promise is transparent.\n const wrapped = async (...args: A): Promise<Shape | Record<string, Shape>> => {\n // D11 (§4.2): faijs-native ops declare an object-form implementation, so a\n // brepjs-style positional call is boxed into the object form here — before\n // dispatch, so geometry inputs are collected from the normalized arg list.\n const callArgs = (\n meta.slotMap ? positionalToObject(args as unknown[], meta.slotMap, opLabel(meta)) : args\n ) as A\n // Geometry inputs: identity-or-structure auto collection (execution-time\n // read, same nature as hasBrep — decided before the implementation runs).\n // Compat: bare ManifoldMeshData args (host geoToManifoldMesh output) are\n // geometry inputs too — old form passed [input] so they reached the mesh path.\n const inputs = (callArgs as unknown[]).filter(isGeometryInput) as Shape[]\n // §1.4 lineage registration (plan §4.3): every top-level dual-op execution\n // records a blood-line node via `runtimeLineage.register`, which enforces\n // N1 (untracked input → throw, never default to chain-root) / N2\n // (stmt↔anchor mismatch) / N3 (conflicting re-register). The graph is\n // cleared per program execution (direct-executor runCode) and C1 guarantees\n // a single live runtime, so the anchor is authoritative inside a statement.\n // Skip when no anchor is set (the op was invoked outside a statement\n // context — there is no lineage to record, and N2 must not fire on a context\n // that legitimately has none).\n //\n // Guard: a statement executes exactly one *top-level* op; an op's\n // implementation may invoke other ops (or itself) internally, and those\n // nested calls share the same `getCurrentStmt()` anchor. They are\n // implementation details, not statements, so they must NOT register a second\n // node under the same StmtId — that would trip N3 (E_TOPO_DUPLICATE_STMT)\n // on identical content. Only the outermost `wrapped` for the current\n // statement registers; the flag below stays set for the *entire* statement\n // execution (including the awaited impl), so nested calls see it and skip.\n const anchor = getCurrentStmt()\n const st = getRuntimeState()\n const isOuter = anchor != null && st.registeredStmtId !== anchor.id\n if (isOuter) st.registeredStmtId = asStmtId(anchor.id)\n try {\n if (isOuter && anchor) {\n runtimeLineage.register(\n {\n stmt: asStmtId(anchor.id),\n op: opLabel(meta),\n inputs,\n outputs: anchor.outputs as [PartName, ...PartName[]],\n provenance: meta.naming,\n },\n {\n nameOf,\n currentStmt: () => {\n const a = getCurrentStmt()\n return a ? { id: a.id } : undefined\n },\n },\n )\n }\n // D5 capability routing: feed the first missing capability to dispatchPath\n // (auto degrades to mesh, brep mode errors). Matched as a concrete name\n // against the engine's declaration set (family booleans + its `evolution`\n // list of *WithHistory kernel function names) — see firstMissingCapability.\n const missing = firstMissingCapability(meta.capabilities)\n const path = dispatchPath(inputs, meta, missing, meta.engines)\n if (path === 'brep') {\n const r = await runImpl(meta, decl.brep as unknown as ((...a: unknown[]) => unknown) | undefined, callArgs)\n const out = meta.outputs ? wrapByKeys(r, meta.outputs, wrapBrepOne) : wrapBrepOne(r)\n // 1.10 前置①:执行期把 hash 演化挂到血缘节点(kernel 类回走推进的数据源)。\n // 演化在几何算完那一刻可得(fromBrep → slot.faceEvolution),事后补挂不参与\n // N3 的内容比较(lineage.ts 设计如此)。无演化(identity/construct 等无历史\n // 输出)时跳过——identity 类推进不依赖演化,construct 词汇在节点 provenance 里。\n const outShape = (typeof out === 'object' && out !== null ? Object.values(out)[0] : out) as Shape | undefined\n const evolution = outShape ? getSlot(outShape)?.faceEvolution : undefined\n if (outShape && evolution) {\n runtimeLineage.attachEvolution(asStmtId(anchor!.id), evolution)\n }\n // 1.10 前置③:part 键的 roleTable 旁挂在这里记录(不是 fromBrep)——\n // impl 返回后 anchor.outputs 名字已定,而 fromBrep 时刻 shape 还未被\n // executor 命名(nameOf 为 undefined)。op 实现读输入表(inputRoleTable)\n // 与解析读表(tableOfPart)都走这份 part 键权威表。\n if (outShape && anchor && anchor.outputs.length > 0) {\n const stmtId = asStmtId(anchor.id)\n const table = runtimeLineage.outputTableOf(stmtId)\n const solid = runtimeLineage.outputHandleOf(stmtId)\n if (table) runtimeLineage.recordOutput(stmtId, table, solid, anchor.outputs[0] as PartName)\n }\n return out\n }\n const m = await runImpl(meta, decl.mesh as unknown as ((...a: unknown[]) => unknown) | undefined, callArgs)\n return meta.outputs ? wrapByKeys(m, meta.outputs, wrapMeshOne) : wrapMeshOne(m)\n } finally {\n // 同语句去重标记不在 op 粒度清理——语句边界由 runtime-state.setCurrentStmt\n // 在锚点变化时重置;TS 库函数体内连续 op 调用共享锚点,嵌套调用正确跳过。\n }\n }\n\n Object.defineProperty(wrapped, DUAL_OP_META, { value: meta, enumerable: false })\n return wrapped as ((...args: A) => Promise<Shape | Record<string, Shape>>) & MetaCarrier\n}\n\n/**\n * Assembly-time validation (③, strict mode, D-4): a library that exports any\n * dual-op function must carry a matching `contractVersion`, and every exported\n * dual-op must be structurally valid (mesh a function, brep a function or\n * undefined, capabilities/outputs well-formed). Called by `registerLib`.\n *\n * Functions without dual-op metadata are left untouched (declarative\n * enforcement boundary — K5 forbids name-based classification).\n *\n * @param lib - the library namespace object being registered.\n */\n/**\n * Detect whether a library namespace exports any dual-op function (carries\n * `DUAL_OP_META`). Used by `registerLib`'s inferred `autoLift` default: a\n * library that already declares dual-ops does not need bare-function lifting.\n *\n * @param ns - the library namespace object.\n * @returns `true` if at least one exported value is a dual-op function.\n */\nexport function hasDualOp(ns: Record<string, unknown>): boolean {\n const values = Object.values(ns)\n return values.some((v) => typeof v === 'function' && (v as MetaCarrier)[DUAL_OP_META])\n}\n\n/**\n * Read the dual-op metadata of a wrapped function (unit-system D8 declaration\n * surface). Returns `undefined` when the function carries no dual-op metadata,\n * so callers never probe the private key directly.\n *\n * @param fn - a function that may have been produced by `defineOp`/`compatOp`.\n * @returns the op's metadata, or `undefined`.\n */\nexport function dualOpMetaOf(fn: unknown): DualOpMeta | undefined {\n if (typeof fn !== 'function') return undefined\n return (fn as MetaCarrier)[DUAL_OP_META]\n}\n\n/**\n * Assert that a library conforms to the dual-op contract: if it exports any\n * dual-op function, it must also export `contractVersion` matching the engine's.\n *\n * @param lib - the library namespace object being registered.\n * @throws {Error} when dual-op functions are present without a matching contract version.\n */\nexport function assertLibConforms(lib: Record<string, unknown>): void {\n if (hasDualOp(lib) && lib.contractVersion !== CONTRACT_VERSION) {\n throw new Error(\n `[faijs] library with dual-op functions must export contractVersion = ${CONTRACT_VERSION} (got ${String(lib.contractVersion)})`,\n )\n }\n\n for (const [name, value] of Object.entries(lib)) {\n if (typeof value !== 'function') continue\n const meta = (value as MetaCarrier)[DUAL_OP_META]\n if (!meta || meta.kind !== 'dual-op') continue\n if (typeof meta.mesh !== 'function' && typeof meta.brep !== 'function') {\n throw new Error(`[faijs] lib function '${name}' declares dual-op without any implementation`)\n }\n if (meta.mesh !== undefined && typeof meta.mesh !== 'function') {\n throw new Error(`[faijs] lib function '${name}' declares dual-op with a non-function mesh implementation`)\n }\n if (meta.brep !== undefined && typeof meta.brep !== 'function') {\n throw new Error(`[faijs] lib function '${name}' declares dual-op with a non-function brep implementation`)\n }\n if (meta.capabilities !== undefined && !Array.isArray(meta.capabilities)) {\n throw new Error(`[faijs] lib function '${name}' declares invalid capabilities (expected string[])`)\n }\n // D11-7 互斥**已撤销**(2026-09-24 用户裁决):engines 与 capabilities 是两条正交的\n // 声明轴——前者是引擎身份白名单(在哪些引擎上跑),后者是实现所需内核能力清单\n // (要用哪些方法)。两者并存是合法且更诚实的写法:engines 收窄候选集,能力门随后\n // 对同一引擎继续求交(dispatchPath 的求值次序本就是 engines 在先,D11-2)。\n // 曾经的理由「能力名空间只收 L1 中立名」与事实不符——BrepCapabilityName 含\n // BrepMethodKind 逐核真名(isNull / dispose / chamfer / shell / ...,见\n // brep/engine/types.ts),本就是内核名空间;平台 op 声明能力名并不越界。\n // 故此处不再校验两者是否同时出现。\n if (meta.engines !== undefined) {\n if (!Array.isArray(meta.engines) || meta.engines.length === 0) {\n throw new Error(`[faijs] lib function '${name}' declares invalid engines (expected non-empty BrepEngineId[])`)\n }\n const bad = meta.engines.find((e) => !BREP_ENGINE_ID_SET.has(e))\n if (bad !== undefined) {\n throw new Error(\n `[faijs] lib function '${name}' declares unknown engine '${String(bad)}' — expected one of ${BREP_ENGINE_IDS.join(', ')}`,\n )\n }\n }\n if (\n meta.outputs !== undefined\n && (!Array.isArray(meta.outputs) || meta.outputs.some((k) => typeof k !== 'string'))\n ) {\n throw new Error(`[faijs] lib function '${name}' declares invalid outputs (expected string[])`)\n }\n if (meta.schema !== undefined && !isValidSchema(meta.schema)) {\n throw new Error(`[faijs] lib function '${name}' declares invalid schema (expected Record<string, string>)`)\n }\n if (meta.name !== undefined && typeof meta.name !== 'string') {\n throw new Error(`[faijs] lib function '${name}' declares invalid name (expected string)`)\n }\n if (meta.slotMap !== undefined && !isValidSlotMap(meta.slotMap)) {\n throw new Error(\n `[faijs] lib function '${name}' declares invalid slotMap (expected { keys: string[]; vec3Keys?: string[]; shapeArity?: number })`,\n )\n }\n }\n}\n\n/** True when the D11 slot-map declaration has a non-empty string `keys` list. */\nfunction isValidSlotMap(form: unknown): form is SlotMap {\n if (form === null || typeof form !== 'object') return false\n const keys = (form as { keys?: unknown }).keys\n if (!Array.isArray(keys) || keys.some((k) => typeof k !== 'string')) return false\n const vec3 = (form as { vec3Keys?: unknown }).vec3Keys\n if (vec3 !== undefined && (!Array.isArray(vec3) || vec3.some((k) => typeof k !== 'string'))) return false\n const arity = (form as { shapeArity?: unknown }).shapeArity\n if (arity !== undefined && (typeof arity !== 'number' || !Number.isInteger(arity) || arity < 0)) return false\n return true\n}\n\n/** True when every schema value is a non-empty string. */\nfunction isValidSchema(schema: unknown): schema is Record<string, string> {\n if (schema === null || typeof schema !== 'object' || Array.isArray(schema)) return false\n return Object.values(schema).every((v) => typeof v === 'string' && v.length > 0)\n}\n"]}
|
package/dist/env-agnostic.d.ts
CHANGED
|
@@ -13,20 +13,20 @@
|
|
|
13
13
|
*/
|
|
14
14
|
export type { FileId, InnerId, ScopedId, StmtId, PartName, GroupName, RefId, ReferenceId, SelectorKey, OccurrenceId, ShapeId, FaceId, EdgeId, NodeId, StatementId, FaceSelector, } from './identity.js';
|
|
15
15
|
export { asFileId, asInnerId, asScopedId, asStmtId, asPartName, asGroupName, asRefId, asReferenceId, asSelectorKey, asOccurrenceId, asShapeId, asFaceId, asEdgeId, asNodeId, toScopedId, splitScopedId, isScopedId, toInnerId, } from './identity.js';
|
|
16
|
-
export { configureBackends, getBackends, setCurrentStmt, getCurrentStmt, keep, keepHidden, getRuntimeState, nameOf, setName, setKeepSink, setPendingAssemblyTransforms, takePendingAssemblyTransforms, assertContractVersion, CONTRACT_VERSION, } from './runtime-state.js';
|
|
17
|
-
export type { Backends, FaijsRuntimeState, ShapeSlot, KeepSink, RuntimeExecutionMode, AssemblyTransform, StdlibFn, StdlibNamespace, ExecutionAnchor, } from './runtime-state.js';
|
|
16
|
+
export { configureBackends, getBackends, setCurrentStmt, getCurrentStmt, keep, keepHidden, getRuntimeState, nameOf, setName, setKeepSink, setPendingAssemblyTransforms, takePendingAssemblyTransforms, assertContractVersion, setPendingDetectedUnit, takePendingDetectedUnits, CONTRACT_VERSION, } from './runtime-state.js';
|
|
17
|
+
export type { Backends, FaijsRuntimeState, ShapeSlot, KeepSink, RuntimeExecutionMode, AssemblyTransform, StdlibFn, StdlibNamespace, ExecutionAnchor, DetectedUnits, } from './runtime-state.js';
|
|
18
18
|
export type { Vec3, JsonValue, TerminalShape, ParamDef, } from './lang/types.js';
|
|
19
19
|
export type { Provenance, NewFaceRule } from './topology/naming/lineage.js';
|
|
20
20
|
export { derivePartName, getMaxModelNum, } from './lang/allocate-id.js';
|
|
21
21
|
export type { DerivePartNameInput, DerivePartNameResult } from './lang/allocate-id.js';
|
|
22
|
-
export { fmtNum, formatCodeLine } from './lang/codegen.js';
|
|
23
|
-
export type { FormatCodeLineInput } from './lang/codegen.js';
|
|
22
|
+
export { fmtNum, formatCodeLine, fmtUnitNum, formatUnitLiteral } from './lang/codegen.js';
|
|
23
|
+
export type { FormatCodeLineInput, UnitSerializeOptions } from './lang/codegen.js';
|
|
24
24
|
export { analyzeCode } from './lang/statement-summary.js';
|
|
25
25
|
export type { StatementSummary } from './lang/statement-summary.js';
|
|
26
|
-
export { codeToArgs } from './lang/code-to-args.js';
|
|
27
|
-
export type { CodeToArgsResult } from './lang/code-to-args.js';
|
|
26
|
+
export { codeToArgs, parseUnitLiteral } from './lang/code-to-args.js';
|
|
27
|
+
export type { CodeToArgsResult, CodeToArgsOptions } from './lang/code-to-args.js';
|
|
28
28
|
export { extractMetadata } from './lang/metadata-extractor.js';
|
|
29
|
-
export type { UiMetadata, ArgSource, ParamEntry, ImportEntry, FunctionEntry, BlockEntry, KeepEntry, ExtractMetadataOptions, } from './lang/metadata-extractor.js';
|
|
29
|
+
export type { UiMetadata, ArgSource, ParamEntry, ImportEntry, FunctionEntry, BlockEntry, KeepEntry, ExtractMetadataOptions, OpDimMap, OpDimDecl, } from './lang/metadata-extractor.js';
|
|
30
30
|
export { scanSource, scanAst, assertSecure } from './lang/security-scanner.js';
|
|
31
31
|
export type { SecurityPolicy, SecurityRuleId, SecurityViolation, SecurityScanOptions, SecurityScanResult, } from './lang/security-scanner.js';
|
|
32
32
|
export { validateExpression } from './lang/expr-validate.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"env-agnostic.d.ts","sourceRoot":"","sources":["../src/env-agnostic.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAGH,YAAY,EACV,MAAM,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,SAAS,EACtD,KAAK,EAAE,WAAW,EAAE,WAAW,EAAE,YAAY,EAAE,OAAO,EACtD,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,WAAW,EAAE,YAAY,GAClD,MAAM,YAAY,CAAA;AACnB,OAAO,EACL,QAAQ,EAAE,SAAS,EAAE,UAAU,EAAE,QAAQ,EAAE,UAAU,EAAE,WAAW,EAClE,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,cAAc,EAAE,SAAS,EAChE,QAAQ,EAAE,QAAQ,EAAE,QAAQ,EAC5B,UAAU,EAAE,aAAa,EAAE,UAAU,EAAE,SAAS,GACjD,MAAM,YAAY,CAAA;AAGnB,OAAO,EACL,iBAAiB,EAAE,WAAW,EAAE,cAAc,EAAE,cAAc,EAC9D,IAAI,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,EAAE,OAAO,EAAE,WAAW,EAC/D,4BAA4B,EAAE,6BAA6B,EAAE,qBAAqB,EAClF,gBAAgB,GACjB,MAAM,iBAAiB,CAAA;AACxB,YAAY,EACV,QAAQ,EAAE,iBAAiB,EAAE,SAAS,EAAE,QAAQ,EAAE,oBAAoB,EACtE,iBAAiB,EAAE,QAAQ,EAAE,eAAe,EAAE,eAAe,
|
|
1
|
+
{"version":3,"file":"env-agnostic.d.ts","sourceRoot":"","sources":["../src/env-agnostic.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAGH,YAAY,EACV,MAAM,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,SAAS,EACtD,KAAK,EAAE,WAAW,EAAE,WAAW,EAAE,YAAY,EAAE,OAAO,EACtD,MAAM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AAE,mBAAmB,EAAE,aAAa,GACzE,MAAM,oBAAoB,CAAA"}
|
package/dist/env-agnostic.js
CHANGED
|
@@ -13,11 +13,11 @@
|
|
|
13
13
|
*/
|
|
14
14
|
export { asFileId, asInnerId, asScopedId, asStmtId, asPartName, asGroupName, asRefId, asReferenceId, asSelectorKey, asOccurrenceId, asShapeId, asFaceId, asEdgeId, asNodeId, toScopedId, splitScopedId, isScopedId, toInnerId, } from './identity.js';
|
|
15
15
|
// ── runtime-state:运行时状态锚点(零依赖层;引擎与库共享)──
|
|
16
|
-
export { configureBackends, getBackends, setCurrentStmt, getCurrentStmt, keep, keepHidden, getRuntimeState, nameOf, setName, setKeepSink, setPendingAssemblyTransforms, takePendingAssemblyTransforms, assertContractVersion, CONTRACT_VERSION, } from './runtime-state.js';
|
|
16
|
+
export { configureBackends, getBackends, setCurrentStmt, getCurrentStmt, keep, keepHidden, getRuntimeState, nameOf, setName, setKeepSink, setPendingAssemblyTransforms, takePendingAssemblyTransforms, assertContractVersion, setPendingDetectedUnit, takePendingDetectedUnits, CONTRACT_VERSION, } from './runtime-state.js';
|
|
17
17
|
export { derivePartName, getMaxModelNum, } from './lang/allocate-id.js';
|
|
18
|
-
export { fmtNum, formatCodeLine } from './lang/codegen.js';
|
|
18
|
+
export { fmtNum, formatCodeLine, fmtUnitNum, formatUnitLiteral } from './lang/codegen.js';
|
|
19
19
|
export { analyzeCode } from './lang/statement-summary.js';
|
|
20
|
-
export { codeToArgs } from './lang/code-to-args.js';
|
|
20
|
+
export { codeToArgs, parseUnitLiteral } from './lang/code-to-args.js';
|
|
21
21
|
// MetadataExtractor — 无 IR 元数据提取器(UI 通道语义源;UiMetadata 全量)
|
|
22
22
|
export { extractMetadata } from './lang/metadata-extractor.js';
|
|
23
23
|
// SecurityScanner — 静态安全门禁(纵深防御第一层)
|
package/dist/env-agnostic.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"env-agnostic.js","sourceRoot":"","sources":["../src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AAqB,EAClF,sBAAsB,EAAE,wBAAwB,EAChD,gBAAgB,GACjB,MAAM,iBAAiB,CAAA;AAaxB,OAAO,EACL,cAAc,EAAE,cAAc,GAC/B,MAAM,oBAAoB,CAAA;AAE3B,OAAO,EAAE,MAAM,EAAE,cAAc,EAAE,UAAU,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAA;AAEtF,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAA;AAEtD,OAAO,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAA;AAElE,0DAA0D;AAC1D,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAA;AAK3D,oCAAoC;AACpC,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAA;AAK3E,qCAAqC;AACrC,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAA;AAEzD,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAMlD,OAAO,EACL,YAAY,EAAE,cAAc,EAAE,aAAa,EAAE,aAAa,EAAE,SAAS,EACrE,gBAAgB,EAAE,gBAAgB,EAAE,cAAc,GACnD,MAAM,iBAAiB,CAAA;AAExB,+BAA+B;AAC/B,gEAAgE;AAChE,mEAAmE;AACnE,+DAA+D;AAC/D,0EAA0E;AAC1E,qDAAqD;AACrD,OAAO,EAAE,wBAAwB,EAAE,MAAM,2BAA2B,CAAA","sourcesContent":["/**\n * env-agnostic.ts — environment-agnostic shared surface (weapp plan §9.1)\n *\n * One home for the exports that every host entry (index / browser / weapp)\n * must share: identity + runtime-state + lang/* text-layer tools. Umbrella\n * entries re-export this module instead of hand-listing the same symbols three\n * times — hand lists are how drift (and entry leaks) happened before.\n *\n * Constraint: NOTHING in this module's dependency graph may be\n * platform-specific. No node:*, no DOM, no three (the weapp main thread holds\n * its own three copy — a second copy via this entry is a hard failure), no\n * brepkit, no wasm loaders. Guarded by entry-boundary.test.ts.\n */\n\n// ── identity:品牌类型 + 信任点(f0,零依赖)──\nexport type {\n FileId, InnerId, ScopedId, StmtId, PartName, GroupName,\n RefId, ReferenceId, SelectorKey, OccurrenceId, ShapeId,\n FaceId, EdgeId, NodeId, StatementId, FaceSelector,\n} from './identity'\nexport {\n asFileId, asInnerId, asScopedId, asStmtId, asPartName, asGroupName,\n asRefId, asReferenceId, asSelectorKey, asOccurrenceId, asShapeId,\n asFaceId, asEdgeId, asNodeId,\n toScopedId, splitScopedId, isScopedId, toInnerId,\n} from './identity'\n\n// ── runtime-state:运行时状态锚点(零依赖层;引擎与库共享)──\nexport {\n configureBackends, getBackends, setCurrentStmt, getCurrentStmt,\n keep, keepHidden, getRuntimeState, nameOf, setName, setKeepSink,\n setPendingAssemblyTransforms, takePendingAssemblyTransforms, assertContractVersion,\n setPendingDetectedUnit, takePendingDetectedUnits,\n CONTRACT_VERSION,\n} from './runtime-state'\nexport type {\n Backends, FaijsRuntimeState, ShapeSlot, KeepSink, RuntimeExecutionMode,\n AssemblyTransform, StdlibFn, StdlibNamespace, ExecutionAnchor, DetectedUnits,\n} from './runtime-state'\n\n// ── L0 lang/ 文本面(IR 是引擎内部实现细节,不导出;公开面只有代码文本工具与结果类型)──\nexport type {\n Vec3, JsonValue,\n TerminalShape, ParamDef,\n} from './lang/types'\n// 拓扑身份 provenance 类型(op 级命名 / 拓扑身份系统公开面)。\nexport type { Provenance, NewFaceRule } from './topology/naming/lineage'\nexport {\n derivePartName, getMaxModelNum,\n} from './lang/allocate-id'\nexport type { DerivePartNameInput, DerivePartNameResult } from './lang/allocate-id'\nexport { fmtNum, formatCodeLine, fmtUnitNum, formatUnitLiteral } from './lang/codegen'\nexport type { FormatCodeLineInput, UnitSerializeOptions } from './lang/codegen'\nexport { analyzeCode } from './lang/statement-summary'\nexport type { StatementSummary } from './lang/statement-summary'\nexport { codeToArgs, parseUnitLiteral } from './lang/code-to-args'\nexport type { CodeToArgsResult, CodeToArgsOptions } from './lang/code-to-args'\n// MetadataExtractor — 无 IR 元数据提取器(UI 通道语义源;UiMetadata 全量)\nexport { extractMetadata } from './lang/metadata-extractor'\nexport type {\n UiMetadata, ArgSource, ParamEntry, ImportEntry, FunctionEntry, BlockEntry, KeepEntry,\n ExtractMetadataOptions, OpDimMap, OpDimDecl,\n} from './lang/metadata-extractor'\n// SecurityScanner — 静态安全门禁(纵深防御第一层)\nexport { scanSource, scanAst, assertSecure } from './lang/security-scanner'\nexport type {\n SecurityPolicy, SecurityRuleId, SecurityViolation,\n SecurityScanOptions, SecurityScanResult,\n} from './lang/security-scanner'\n// 参数表达式编辑(P0-C/P0-D):实时校验层 + 编辑面板纯函数\nexport { validateExpression } from './lang/expr-validate'\nexport type { ExprValidateInput, ExprValidateResult } from './lang/expr-validate'\nexport { editArgSource } from './lang/source-edit'\nexport type { EditSourceError } from './lang/source-edit'\n// HostArg — 宿主友好位置参数类型(IR 屏蔽层)\nexport type {\n HostArg, HostRef, HostVarRef, HostParamRef, HostCallRef, HostExprRef, HostRefKind,\n} from './lang/host-arg'\nexport {\n isHostVarRef, isHostParamRef, isHostCallRef, isHostExprRef, isHostRef,\n hostArgToDisplay, hostArgToLiteral, HOST_REF_KINDS,\n} from './lang/host-arg'\n\n// ── mesh 工具面(环境无关):折边法线数据版 ──\n// weapp 方案 §9.1 第 4 项:GeometryBinding 下沉 scene-kernel 后,共享层需要的是\n// 「positions / indices 进、法线 Float32Array 出」的版本,且模块链不得 import three\n// (端侧只能有一份 0.162)。算法在 boolean/creased-normals.ts(零依赖移植 three 的\n// toCreasedNormals);three 版 deriveNormals(boolean/deriveNormals.ts)只是本数据版\n// 的 BufferGeometry 薄适配,留在 browser/index 面供 web 场景使用。\nexport { deriveCreasedNormalsData } from './boolean/creased-normals'\nexport type { CreasedNormalsInput, CreasedNormalsResult } from './boolean/creased-normals'\n\n// ── primitives 纯类型(零运行时依赖;primitive-emission 共享层消费)──\nexport type {\n PrimitiveType, PrimitiveParamsRecord, PrimitiveArgsRecord, PrimitiveMeta,\n} from './primitives/types'\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lift-on-plane.d.ts","sourceRoot":"","sources":["../../../src/geometry2d/bridge/lift-on-plane.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAA;AACjE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAA;AACzD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA;AAE5C,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AAC7C,OAAO,EAAgC,KAAK,KAAK,EAAa,MAAM,SAAS,CAAA;AAE7E,oEAAoE;AACpE,MAAM,MAAM,eAAe,GAAG,IAAI,CAAC,aAAa,EAAE,cAAc,GAAG,aAAa,GAAG,gBAAgB,GAAG,UAAU,CAAC,CAAA;AAEjH;;;;;;;;;;GAUG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,eAAe,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,EAAE,UAAU,GAAG,UAAU,EAAE,
|
|
1
|
+
{"version":3,"file":"lift-on-plane.d.ts","sourceRoot":"","sources":["../../../src/geometry2d/bridge/lift-on-plane.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAA;AACjE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAA;AACzD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA;AAE5C,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AAC7C,OAAO,EAAgC,KAAK,KAAK,EAAa,MAAM,SAAS,CAAA;AAE7E,oEAAoE;AACpE,MAAM,MAAM,eAAe,GAAG,IAAI,CAAC,aAAa,EAAE,cAAc,GAAG,aAAa,GAAG,gBAAgB,GAAG,UAAU,CAAC,CAAA;AAEjH;;;;;;;;;;GAUG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,eAAe,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,EAAE,UAAU,GAAG,UAAU,EAAE,CA4BrG;AAaD;;;;;;GAMG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,eAAe,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,SAAS,UAAU,EAAE,GAAG,UAAU,EAAE,CAIvH;AAED;;;;;;;GAOG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE,eAAe,EAAE,WAAW,EAAE,KAAK,GAAG,MAAM,EAAE,EAAE,EAAE,SAAS,GAAG,UAAU,CAG5G;AAED,OAAO,EAAE,gBAAgB,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,SAAS,CAAA;AACzE,YAAY,EAAE,KAAK,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,SAAS,CAAA"}
|
|
@@ -15,6 +15,12 @@ export function liftCurve2dToPlane(kernel, plane, c) {
|
|
|
15
15
|
const on = (c2, t) => liftPointToPlane(plane, ...evaluateCurve2d(c2, t));
|
|
16
16
|
switch (c.kind2d) {
|
|
17
17
|
case 'line':
|
|
18
|
+
// P2 (2026-09-28, ArchDetail class): a fully-trimmed sketch can carry a
|
|
19
|
+
// ZERO-LENGTH line; makeLineEdge(start, start) is rejected by the OCCT
|
|
20
|
+
// kernel and killed the whole sketchOnPlane call. A zero-length segment
|
|
21
|
+
// contributes nothing to the wire — skip it.
|
|
22
|
+
if (c.len === 0)
|
|
23
|
+
return [];
|
|
18
24
|
return [
|
|
19
25
|
kernel.makeLineEdge(liftPointToPlane(plane, c.ox, c.oy), liftPointToPlane(plane, c.ox + c.dx * c.len, c.oy + c.dy * c.len)),
|
|
20
26
|
];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lift-on-plane.js","sourceRoot":"","sources":["../../../src/geometry2d/bridge/lift-on-plane.ts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MAAM,UAAU,oBAAoB,CAAC,MAAuB,EAAE,KAAY,EAAE,MAA6B;IACvG,MAAM,GAAG,GAAiB,EAAE,CAAA;IAC5B,KAAK,MAAM,CAAC,IAAI,MAAM;QAAE,GAAG,CAAC,IAAI,CAAC,GAAG,kBAAkB,CAAC,MAAM,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,CAAA;IACzE,OAAO,GAAG,CAAA;AACZ,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,YAAY,CAAC,MAAuB,EAAE,WAA2B,EAAE,EAAa;IAC9F,MAAM,KAAK,GAAG,OAAO,WAAW,KAAK,QAAQ,CAAC,CAAC,CAAC,UAAU,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,WAAW,CAAA;IACrF,OAAO,MAAM,CAAC,QAAQ,CAAC,oBAAoB,CAAC,MAAM,EAAE,KAAK,EAAE,EAAE,CAAC,MAAM,CAAC,CAAC,CAAA;AACxE,CAAC;AAED,OAAO,EAAE,gBAAgB,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,SAAS,CAAA","sourcesContent":["/**\n * 2D curve → 3D plane placement primitives (E2, occt-only bridge layer).\n *\n * This is the \"lift\" half of `sketchOnPlane`: it maps a pure-2D `Curve2dObj[]`\n * (or `Blueprint`) onto an arbitrary plane and assembles the resulting 3D edges\n * into a wire. `curvesAsEdgesOnPlane` / `assembleWire` mirror the plan's E2 work\n * items. The kernel edge/wire primitives are accepted as `Pick<BrepEngineApi, …>`\n * (the bridge may import the kernel contract, only `api/` is off-limits) so\n * callers pass `getBrepApi()` directly with no casts.\n * @module\n */\nimport type { BrepEngineApi } from '../../brep/engine/primitives'\nimport type { BrepHandle } from '../../brep/engine/types'\nimport type { Curve2dObj } from '../curve2d'\nimport { evaluateCurve2d } from '../curve2d'\nimport type { Blueprint } from '../blueprint'\nimport { namedPlane, liftPointToPlane, type Plane, type Vec3 } from './plane'\n\n/** Minimal kernel edge/wire surface needed for planar placement. */\nexport type PlaneWireKernel = Pick<BrepEngineApi, 'makeLineEdge' | 'makeArcEdge' | 'makeBezierEdge' | 'makeWire'>\n\n/**\n * Build the 3D edge(s) for a single 2D curve lifted onto a plane. Line and\n * bezier build exact analytic edges; circle / trimmed-circle build a true arc\n * edge from three on-plane lift points (a full circle is split into two arcs to\n * keep `makeArcEdge` well-formed); ellipse / bspline fall back to a dense\n * sampled polyline.\n * @param kernel - the kernel edge primitives.\n * @param plane - the target plane frame.\n * @param c - the ordered 2D curve to lift.\n * @returns the lifted 3D edge handle(s), in curve order.\n */\nexport function liftCurve2dToPlane(kernel: PlaneWireKernel, plane: Plane, c: Curve2dObj): BrepHandle[] {\n const on = (c2: Curve2dObj, t: number): Vec3 => liftPointToPlane(plane, ...evaluateCurve2d(c2, t))\n switch (c.kind2d) {\n case 'line':\n return [\n kernel.makeLineEdge(\n liftPointToPlane(plane, c.ox, c.oy),\n liftPointToPlane(plane, c.ox + c.dx * c.len, c.oy + c.dy * c.len),\n ),\n ]\n case 'bezier':\n return [kernel.makeBezierEdge(c.poles.map(([x, y]) => liftPointToPlane(plane, x, y)))]\n case 'circle':\n return [\n kernel.makeArcEdge(on(c, 0), on(c, Math.PI / 2), on(c, Math.PI)),\n kernel.makeArcEdge(on(c, Math.PI), on(c, (3 * Math.PI) / 2), on(c, 2 * Math.PI)),\n ]\n case 'trimmed':\n if (c.basis.kind2d === 'circle') return [kernel.makeArcEdge(on(c, 0), on(c, 0.5), on(c, 1))]\n return sampledEdges(kernel, plane, c)\n default:\n return sampledEdges(kernel, plane, c)\n }\n}\n\n/** Sample a non-analytic curve into a polyline of `makeLineEdge`s on the plane. */\nfunction sampledEdges(kernel: PlaneWireKernel, plane: Plane, c: Curve2dObj): BrepHandle[] {\n const out: BrepHandle[] = []\n for (let k = 0; k < 32; k++) {\n const t0 = k / 32\n const t1 = (k + 1) / 32\n out.push(kernel.makeLineEdge(liftPointToPlane(plane, ...evaluateCurve2d(c, t0)), liftPointToPlane(plane, ...evaluateCurve2d(c, t1))))\n }\n return out\n}\n\n/**\n * Lift an ordered list of 2D curves to edges on a plane frame.\n * @param kernel - the kernel edge/wire primitives.\n * @param plane - the target plane.\n * @param curves - the ordered 2D curves (a closed loop stays closed).\n * @returns the lifted 3D edge handles in the same order.\n */\nexport function curvesAsEdgesOnPlane(kernel: PlaneWireKernel, plane: Plane, curves: readonly Curve2dObj[]): BrepHandle[] {\n const out: BrepHandle[] = []\n for (const c of curves) out.push(...liftCurve2dToPlane(kernel, plane, c))\n return out\n}\n\n/**\n * Assemble a Blueprint's curves into a 3D wire on a plane — the shared placement\n * step for all of the profile / draw / sketch sources.\n * @param kernel - the curve kernel/wire primitives.\n * @param planeOrName - a plane frame or a named plane string (`'XY'` / `'XZ'` / …).\n * @param bp - the blueprint whose ordered curves become the wire.\n * @returns the assembled 3D wire.\n */\nexport function assembleWire(kernel: PlaneWireKernel, planeOrName: Plane | string, bp: Blueprint): BrepHandle {\n const plane = typeof planeOrName === 'string' ? namedPlane(planeOrName) : planeOrName\n return kernel.makeWire(curvesAsEdgesOnPlane(kernel, plane, bp.curves))\n}\n\nexport { liftPointToPlane, namedPlane, makePlane, toVec3 } from './plane'\nexport type { Plane, Vec3, Vec3Input } from './plane'"]}
|
|
1
|
+
{"version":3,"file":"lift-on-plane.js","sourceRoot":"","sources":["../../../src/geometry2d/bridge/lift-on-plane.ts"],"names":[],"mappings":"AAcA,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAA;AAE5C,OAAO,EAAE,UAAU,EAAE,gBAAgB,EAAyB,MAAM,SAAS,CAAA;AAK7E;;;;;;;;;;GAUG;AACH,MAAM,UAAU,kBAAkB,CAAC,MAAuB,EAAE,KAAY,EAAE,CAAa;IACrF,MAAM,EAAE,GAAG,CAAC,EAAc,EAAE,CAAS,EAAQ,EAAE,CAAC,gBAAgB,CAAC,KAAK,EAAE,GAAG,eAAe,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAA;IAClG,QAAQ,CAAC,CAAC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,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,YAAY,CAAC,MAAuB,EAAE,WAA2B,EAAE,EAAa;IAC9F,MAAM,KAAK,GAAG,OAAO,WAAW,KAAK,QAAQ,CAAC,CAAC,CAAC,UAAU,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,WAAW,CAAA;IACrF,OAAO,MAAM,CAAC,QAAQ,CAAC,oBAAoB,CAAC,MAAM,EAAE,KAAK,EAAE,EAAE,CAAC,MAAM,CAAC,CAAC,CAAA;AACxE,CAAC;AAED,OAAO,EAAE,gBAAgB,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,SAAS,CAAA","sourcesContent":["/**\n * 2D curve → 3D plane placement primitives (E2, occt-only bridge layer).\n *\n * This is the \"lift\" half of `sketchOnPlane`: it maps a pure-2D `Curve2dObj[]`\n * (or `Blueprint`) onto an arbitrary plane and assembles the resulting 3D edges\n * into a wire. `curvesAsEdgesOnPlane` / `assembleWire` mirror the plan's E2 work\n * items. The kernel edge/wire primitives are accepted as `Pick<BrepEngineApi, …>`\n * (the bridge may import the kernel contract, only `api/` is off-limits) so\n * callers pass `getBrepApi()` directly with no casts.\n * @module\n */\nimport type { BrepEngineApi } from '../../brep/engine/primitives'\nimport type { BrepHandle } from '../../brep/engine/types'\nimport type { Curve2dObj } from '../curve2d'\nimport { evaluateCurve2d } from '../curve2d'\nimport type { Blueprint } from '../blueprint'\nimport { namedPlane, liftPointToPlane, type Plane, type Vec3 } from './plane'\n\n/** Minimal kernel edge/wire surface needed for planar placement. */\nexport type PlaneWireKernel = Pick<BrepEngineApi, 'makeLineEdge' | 'makeArcEdge' | 'makeBezierEdge' | 'makeWire'>\n\n/**\n * Build the 3D edge(s) for a single 2D curve lifted onto a plane. Line and\n * bezier build exact analytic edges; circle / trimmed-circle build a true arc\n * edge from three on-plane lift points (a full circle is split into two arcs to\n * keep `makeArcEdge` well-formed); ellipse / bspline fall back to a dense\n * sampled polyline.\n * @param kernel - the kernel edge primitives.\n * @param plane - the target plane frame.\n * @param c - the ordered 2D curve to lift.\n * @returns the lifted 3D edge handle(s), in curve order.\n */\nexport function liftCurve2dToPlane(kernel: PlaneWireKernel, plane: Plane, c: Curve2dObj): BrepHandle[] {\n const on = (c2: Curve2dObj, t: number): Vec3 => liftPointToPlane(plane, ...evaluateCurve2d(c2, t))\n switch (c.kind2d) {\n case 'line':\n // P2 (2026-09-28, ArchDetail class): a fully-trimmed sketch can carry a\n // ZERO-LENGTH line; makeLineEdge(start, start) is rejected by the OCCT\n // kernel and killed the whole sketchOnPlane call. A zero-length segment\n // contributes nothing to the wire — skip it.\n if (c.len === 0) return []\n return [\n kernel.makeLineEdge(\n liftPointToPlane(plane, c.ox, c.oy),\n liftPointToPlane(plane, c.ox + c.dx * c.len, c.oy + c.dy * c.len),\n ),\n ]\n case 'bezier':\n return [kernel.makeBezierEdge(c.poles.map(([x, y]) => liftPointToPlane(plane, x, y)))]\n case 'circle':\n return [\n kernel.makeArcEdge(on(c, 0), on(c, Math.PI / 2), on(c, Math.PI)),\n kernel.makeArcEdge(on(c, Math.PI), on(c, (3 * Math.PI) / 2), on(c, 2 * Math.PI)),\n ]\n case 'trimmed':\n if (c.basis.kind2d === 'circle') return [kernel.makeArcEdge(on(c, 0), on(c, 0.5), on(c, 1))]\n return sampledEdges(kernel, plane, c)\n default:\n return sampledEdges(kernel, plane, c)\n }\n}\n\n/** Sample a non-analytic curve into a polyline of `makeLineEdge`s on the plane. */\nfunction sampledEdges(kernel: PlaneWireKernel, plane: Plane, c: Curve2dObj): BrepHandle[] {\n const out: BrepHandle[] = []\n for (let k = 0; k < 32; k++) {\n const t0 = k / 32\n const t1 = (k + 1) / 32\n out.push(kernel.makeLineEdge(liftPointToPlane(plane, ...evaluateCurve2d(c, t0)), liftPointToPlane(plane, ...evaluateCurve2d(c, t1))))\n }\n return out\n}\n\n/**\n * Lift an ordered list of 2D curves to edges on a plane frame.\n * @param kernel - the kernel edge/wire primitives.\n * @param plane - the target plane.\n * @param curves - the ordered 2D curves (a closed loop stays closed).\n * @returns the lifted 3D edge handles in the same order.\n */\nexport function curvesAsEdgesOnPlane(kernel: PlaneWireKernel, plane: Plane, curves: readonly Curve2dObj[]): BrepHandle[] {\n const out: BrepHandle[] = []\n for (const c of curves) out.push(...liftCurve2dToPlane(kernel, plane, c))\n return out\n}\n\n/**\n * Assemble a Blueprint's curves into a 3D wire on a plane — the shared placement\n * step for all of the profile / draw / sketch sources.\n * @param kernel - the curve kernel/wire primitives.\n * @param planeOrName - a plane frame or a named plane string (`'XY'` / `'XZ'` / …).\n * @param bp - the blueprint whose ordered curves become the wire.\n * @returns the assembled 3D wire.\n */\nexport function assembleWire(kernel: PlaneWireKernel, planeOrName: Plane | string, bp: Blueprint): BrepHandle {\n const plane = typeof planeOrName === 'string' ? namedPlane(planeOrName) : planeOrName\n return kernel.makeWire(curvesAsEdgesOnPlane(kernel, plane, bp.curves))\n}\n\nexport { liftPointToPlane, namedPlane, makePlane, toVec3 } from './plane'\nexport type { Plane, Vec3, Vec3Input } from './plane'"]}
|
|
@@ -127,6 +127,31 @@ export declare class BaseSketcher2d {
|
|
|
127
127
|
* @returns this pen, for chaining.
|
|
128
128
|
*/
|
|
129
129
|
hLineTo(xPos: number): this;
|
|
130
|
+
/**
|
|
131
|
+
* Draw a whole contour from an explicit point list, in one call.
|
|
132
|
+
*
|
|
133
|
+
* The batched counterpart of a chained `lineTo` run, and the only form that
|
|
134
|
+
* survives the `.fai.js` dialect: the parser caps AST nesting at 100
|
|
135
|
+
* (`SEC_LIMIT`), and a chained call builds a nested
|
|
136
|
+
* `MemberExpression`/`CallExpression` tree whose depth equals the segment count
|
|
137
|
+
* — a contour of a few hundred tessellated points cannot be emitted as
|
|
138
|
+
* `pen.lineTo(a).lineTo(b)…` (measured: a 150-call chain already trips the
|
|
139
|
+
* limit). Handing the points over as ONE array literal keeps the emitted depth
|
|
140
|
+
* constant (array nesting = 2) at any point count.
|
|
141
|
+
*
|
|
142
|
+
* The first point also (re)seats an empty pen, so `firstPoint` keeps its
|
|
143
|
+
* meaning for {@link close} / `movePointerTo`. GOTCHA (2026-09-28):
|
|
144
|
+
* `movePointerTo` refuses to lift the pointer once a curve exists, so ONE pen
|
|
145
|
+
* carries exactly ONE contour — a shape holding many disjoint loops (a rebuilt
|
|
146
|
+
* Draft drawing was measured carrying 12 / 36 / 56 / 61 of them) needs one pen
|
|
147
|
+
* per loop, never one pen with several lifts.
|
|
148
|
+
*
|
|
149
|
+
* @param points - the contour's points in draw order (at least 2).
|
|
150
|
+
* @param close - append a final segment back to `points[0]` (skipped when the
|
|
151
|
+
* run already ended there, mirroring {@link close}).
|
|
152
|
+
* @returns this pen, for chaining.
|
|
153
|
+
*/
|
|
154
|
+
polyline(points: Point2[], close?: boolean): this;
|
|
130
155
|
/**
|
|
131
156
|
* Draw a line to an absolute point in polar form.
|
|
132
157
|
* @param polar - `[radius, angleDeg]`.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pen-sketcher.d.ts","sourceRoot":"","sources":["../../src/geometry2d/pen-sketcher.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,EAML,KAAK,UAAU,EAChB,MAAM,WAAW,CAAA;AAOlB,yCAAyC;AACzC,MAAM,MAAM,MAAM,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;AAErC,8CAA8C;AAC9C,MAAM,MAAM,aAAa,GAAG;IAC1B,yFAAyF;IACzF,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,wFAAwF;IACxF,UAAU,CAAC,EAAE,MAAM,GAAG,WAAW,CAAA;IACjC,mCAAmC;IACnC,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,iCAAiC;IACjC,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB,CAAA;AAED,yEAAyE;AACzE,MAAM,MAAM,UAAU,GAAG,QAAQ,GAAG,SAAS,GAAG,SAAS,CAAA;AAYzD;;;;;;GA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;;OAGG;IACH,KAAK,IAAI,UAAU,EAAE;IAOrB;;;;OAIG;IACH,eAAe,IAAI,UAAU,EAAE;IAI/B;;;OAGG;IACH,MAAM,IAAI,UAAU,EAAE;CAGvB"}
|
|
@@ -179,6 +179,49 @@ export class BaseSketcher2d {
|
|
|
179
179
|
hLineTo(xPos) {
|
|
180
180
|
return this.lineTo([xPos, this.pointer[1]]);
|
|
181
181
|
}
|
|
182
|
+
/**
|
|
183
|
+
* Draw a whole contour from an explicit point list, in one call.
|
|
184
|
+
*
|
|
185
|
+
* The batched counterpart of a chained `lineTo` run, and the only form that
|
|
186
|
+
* survives the `.fai.js` dialect: the parser caps AST nesting at 100
|
|
187
|
+
* (`SEC_LIMIT`), and a chained call builds a nested
|
|
188
|
+
* `MemberExpression`/`CallExpression` tree whose depth equals the segment count
|
|
189
|
+
* — a contour of a few hundred tessellated points cannot be emitted as
|
|
190
|
+
* `pen.lineTo(a).lineTo(b)…` (measured: a 150-call chain already trips the
|
|
191
|
+
* limit). Handing the points over as ONE array literal keeps the emitted depth
|
|
192
|
+
* constant (array nesting = 2) at any point count.
|
|
193
|
+
*
|
|
194
|
+
* The first point also (re)seats an empty pen, so `firstPoint` keeps its
|
|
195
|
+
* meaning for {@link close} / `movePointerTo`. GOTCHA (2026-09-28):
|
|
196
|
+
* `movePointerTo` refuses to lift the pointer once a curve exists, so ONE pen
|
|
197
|
+
* carries exactly ONE contour — a shape holding many disjoint loops (a rebuilt
|
|
198
|
+
* Draft drawing was measured carrying 12 / 36 / 56 / 61 of them) needs one pen
|
|
199
|
+
* per loop, never one pen with several lifts.
|
|
200
|
+
*
|
|
201
|
+
* @param points - the contour's points in draw order (at least 2).
|
|
202
|
+
* @param close - append a final segment back to `points[0]` (skipped when the
|
|
203
|
+
* run already ended there, mirroring {@link close}).
|
|
204
|
+
* @returns this pen, for chaining.
|
|
205
|
+
*/
|
|
206
|
+
polyline(points, close = false) {
|
|
207
|
+
if (points.length < 2)
|
|
208
|
+
bug('polyline', 'a polyline needs at least two points');
|
|
209
|
+
const start = points[0];
|
|
210
|
+
if (this.pendingCurves.length === 0) {
|
|
211
|
+
this.pointer = [start[0], start[1]];
|
|
212
|
+
this.firstPoint = this.pointer;
|
|
213
|
+
}
|
|
214
|
+
else if (!samePoint(this.pointer, start)) {
|
|
215
|
+
bug('polyline', 'a run is already in flight — the pen must be sitting on the polyline start (use one pen per contour)');
|
|
216
|
+
}
|
|
217
|
+
for (let i = 1; i < points.length; i++) {
|
|
218
|
+
const p = points[i];
|
|
219
|
+
this.lineTo([p[0], p[1]]);
|
|
220
|
+
}
|
|
221
|
+
if (close && !samePoint(this.pointer, start))
|
|
222
|
+
this.lineTo([start[0], start[1]]);
|
|
223
|
+
return this;
|
|
224
|
+
}
|
|
182
225
|
/**
|
|
183
226
|
* Draw a line to an absolute point in polar form.
|
|
184
227
|
* @param polar - `[radius, angleDeg]`.
|