@snaptrude/plugin-core 0.9.16 → 0.9.18-networks-20261016.1
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/AGENTS.md +231 -231
- package/CHANGELOG.md +408 -402
- package/CLAUDE.md +11 -11
- package/dist/api/analysis/daylight.d.ts +5 -5
- package/dist/api/analysis/solar.d.ts +2 -2
- package/dist/api/core/camera/index.d.ts +29 -0
- package/dist/api/core/camera/index.d.ts.map +1 -1
- package/dist/api/core/geom/create/index.d.ts +7 -1
- package/dist/api/core/geom/create/index.d.ts.map +1 -1
- package/dist/api/core/geom/update/contour.d.ts +8 -2
- package/dist/api/core/geom/update/contour.d.ts.map +1 -1
- package/dist/api/core/zoom/index.d.ts +13 -0
- package/dist/api/core/zoom/index.d.ts.map +1 -1
- package/dist/api/design/bim.d.ts +209 -0
- package/dist/api/design/bim.d.ts.map +1 -0
- package/dist/api/design/boolean/index.d.ts +2 -0
- package/dist/api/design/boolean/index.d.ts.map +1 -1
- package/dist/api/design/catalog.d.ts +320 -0
- package/dist/api/design/catalog.d.ts.map +1 -0
- package/dist/api/design/create/bulk-items.d.ts +65 -25
- package/dist/api/design/create/bulk-items.d.ts.map +1 -1
- package/dist/api/design/create/index.d.ts +272 -99
- package/dist/api/design/create/index.d.ts.map +1 -1
- package/dist/api/design/create/opening-fields.d.ts +13 -12
- package/dist/api/design/create/opening-fields.d.ts.map +1 -1
- package/dist/api/design/delete/index.d.ts +1 -0
- package/dist/api/design/delete/index.d.ts.map +1 -1
- package/dist/api/design/doors/index.d.ts +18 -24
- package/dist/api/design/doors/index.d.ts.map +1 -1
- package/dist/api/design/family.d.ts +797 -27
- package/dist/api/design/family.d.ts.map +1 -1
- package/dist/api/design/index.d.ts +16 -0
- package/dist/api/design/index.d.ts.map +1 -1
- package/dist/api/design/networks.d.ts +1763 -0
- package/dist/api/design/networks.d.ts.map +1 -0
- package/dist/api/design/query/index.d.ts +42 -32
- package/dist/api/design/query/index.d.ts.map +1 -1
- package/dist/api/design/selection/index.d.ts +10 -10
- package/dist/api/design/types/index.d.ts +40 -24
- package/dist/api/design/types/index.d.ts.map +1 -1
- package/dist/api/design/update/index.d.ts +43 -3
- package/dist/api/design/update/index.d.ts.map +1 -1
- package/dist/api/design/windows/index.d.ts +8 -8
- package/dist/api/design/windows/index.d.ts.map +1 -1
- package/dist/api/presentation/aiInspiration.d.ts +10 -10
- package/dist/api/presentation/annotate.d.ts +38 -22
- package/dist/api/presentation/annotate.d.ts.map +1 -1
- package/dist/api/presentation/drawingContract.d.ts +32 -0
- package/dist/api/presentation/drawingContract.d.ts.map +1 -0
- package/dist/api/presentation/drawings.d.ts +3523 -0
- package/dist/api/presentation/drawings.d.ts.map +1 -0
- package/dist/api/presentation/export.d.ts +23 -5
- package/dist/api/presentation/export.d.ts.map +1 -1
- package/dist/api/presentation/index.d.ts +41 -12
- package/dist/api/presentation/index.d.ts.map +1 -1
- package/dist/api/presentation/placedViews.d.ts +106 -6
- package/dist/api/presentation/placedViews.d.ts.map +1 -1
- package/dist/api/presentation/sections.d.ts +461 -0
- package/dist/api/presentation/sections.d.ts.map +1 -0
- package/dist/api/presentation/shapes.d.ts +2 -2
- package/dist/api/presentation/sheets.d.ts +175 -19
- package/dist/api/presentation/sheets.d.ts.map +1 -1
- package/dist/api/presentation/viewPresets.d.ts +222 -0
- package/dist/api/presentation/viewPresets.d.ts.map +1 -0
- package/dist/api/presentation/views.d.ts +103 -5
- package/dist/api/presentation/views.d.ts.map +1 -1
- package/dist/api/presentation/walkthroughs.d.ts +6 -6
- package/dist/errors/codes.d.ts +3 -1
- package/dist/errors/codes.d.ts.map +1 -1
- package/dist/index.cjs +3788 -2328
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +3650 -2328
- package/dist/index.js.map +1 -1
- package/package.json +42 -42
- package/scripts/check-dist-fresh.mjs +22 -22
- package/scripts/generate-manifest.mjs +243 -238
- package/scripts/generate-manifest.test.mjs +303 -303
- package/src/api/analysis/daylight.ts +470 -470
- package/src/api/analysis/heatmaps.ts +683 -683
- package/src/api/analysis/illuminance.ts +155 -155
- package/src/api/analysis/index.ts +61 -61
- package/src/api/analysis/shadows.ts +183 -183
- package/src/api/analysis/solar.ts +237 -237
- package/src/api/analysis/sunlightHours.ts +211 -211
- package/src/api/analysis/sunpath.ts +83 -83
- package/src/api/analysis/weather.ts +179 -179
- package/src/api/core/buildings.ts +485 -485
- package/src/api/core/camera/index.ts +696 -667
- package/src/api/core/comment/index.ts +376 -376
- package/src/api/core/geom/create/index.ts +2139 -2133
- package/src/api/core/geom/delete/index.ts +84 -84
- package/src/api/core/geom/index.ts +35 -35
- package/src/api/core/geom/query/arc.ts +169 -169
- package/src/api/core/geom/query/brep.ts +621 -621
- package/src/api/core/geom/query/circle.ts +404 -404
- package/src/api/core/geom/query/contour.ts +540 -540
- package/src/api/core/geom/query/curve.ts +1102 -1102
- package/src/api/core/geom/query/edge.ts +130 -130
- package/src/api/core/geom/query/face.ts +508 -508
- package/src/api/core/geom/query/halfedge.ts +210 -210
- package/src/api/core/geom/query/index.ts +63 -63
- package/src/api/core/geom/query/profile.ts +473 -473
- package/src/api/core/geom/query/vertex.ts +205 -205
- package/src/api/core/geom/update/contour.ts +323 -317
- package/src/api/core/geom/update/curve.ts +209 -209
- package/src/api/core/geom/update/index.ts +29 -29
- package/src/api/core/geom/update/profile.ts +379 -379
- package/src/api/core/groups.ts +521 -521
- package/src/api/core/handles/index.ts +234 -234
- package/src/api/core/history/index.ts +84 -84
- package/src/api/core/index.ts +99 -99
- package/src/api/core/io/export/index.ts +126 -126
- package/src/api/core/io/import/index.ts +504 -504
- package/src/api/core/io/index.ts +42 -42
- package/src/api/core/io/job/index.ts +140 -140
- package/src/api/core/io/query/index.ts +71 -71
- package/src/api/core/io/terrain/index.ts +360 -360
- package/src/api/core/io/underlay/index.ts +705 -705
- package/src/api/core/layers.ts +540 -540
- package/src/api/core/math/index.ts +20 -20
- package/src/api/core/math/quat.ts +172 -172
- package/src/api/core/math/vec3.ts +179 -179
- package/src/api/core/mode/index.ts +108 -108
- package/src/api/core/project/index.ts +479 -479
- package/src/api/core/proposals/index.ts +570 -570
- package/src/api/core/storeys/index.ts +308 -308
- package/src/api/core/storeys/layers.ts +339 -339
- package/src/api/core/tags.ts +911 -911
- package/src/api/core/units/index.ts +164 -164
- package/src/api/core/user.ts +46 -46
- package/src/api/core/zoom/index.ts +64 -51
- package/src/api/design/bim.ts +121 -0
- package/src/api/design/boolean/index.ts +181 -179
- package/src/api/design/catalog.ts +203 -0
- package/src/api/design/create/bulk-items.ts +294 -254
- package/src/api/design/create/grids.ts +137 -137
- package/src/api/design/create/index.ts +2148 -1980
- package/src/api/design/create/opening-fields.ts +40 -37
- package/src/api/design/delete/index.ts +75 -74
- package/src/api/design/dimensions.ts +453 -453
- package/src/api/design/doors/index.ts +516 -500
- package/src/api/design/edit/index.ts +54 -54
- package/src/api/design/erase/index.ts +151 -151
- package/src/api/design/family.ts +1334 -704
- package/src/api/design/furniture/index.ts +319 -319
- package/src/api/design/grids.ts +237 -237
- package/src/api/design/index.ts +304 -274
- package/src/api/design/lock.ts +69 -69
- package/src/api/design/materials/index.ts +608 -608
- package/src/api/design/networks.ts +667 -0
- package/src/api/design/query/geometry/index.ts +319 -319
- package/src/api/design/query/grids.ts +197 -197
- package/src/api/design/query/index.ts +1236 -1226
- package/src/api/design/query/referenceLines.ts +52 -52
- package/src/api/design/query/spaces.ts +275 -275
- package/src/api/design/selection/index.ts +273 -273
- package/src/api/design/shared.ts +40 -40
- package/src/api/design/transform/index.ts +254 -254
- package/src/api/design/types/index.ts +163 -156
- package/src/api/design/update/index.ts +1024 -983
- package/src/api/design/visibility.ts +143 -143
- package/src/api/design/windows/index.ts +351 -333
- package/src/api/entity/buildableEnvelope.ts +322 -322
- package/src/api/entity/index.ts +30 -30
- package/src/api/entity/referenceLine.ts +235 -235
- package/src/api/entity/space.ts +612 -612
- package/src/api/entity/story.ts +517 -517
- package/src/api/index.ts +47 -47
- package/src/api/presentation/aiInspiration.ts +1116 -1116
- package/src/api/presentation/annotate.ts +417 -385
- package/src/api/presentation/camera.ts +289 -289
- package/src/api/presentation/diagrams.ts +194 -194
- package/src/api/presentation/drawingContract.ts +70 -0
- package/src/api/presentation/drawings.ts +1179 -0
- package/src/api/presentation/export.ts +134 -108
- package/src/api/presentation/import.ts +159 -159
- package/src/api/presentation/index.ts +160 -126
- package/src/api/presentation/placedViews.ts +1211 -1120
- package/src/api/presentation/sections.ts +420 -0
- package/src/api/presentation/shapes.ts +274 -274
- package/src/api/presentation/sheets.ts +746 -585
- package/src/api/presentation/slideshow.ts +134 -134
- package/src/api/presentation/tables.ts +84 -84
- package/src/api/presentation/viewPresets.ts +241 -0
- package/src/api/presentation/views.ts +713 -673
- package/src/api/presentation/walkthroughs.ts +1201 -1201
- package/src/api/program/adjacency.ts +164 -164
- package/src/api/program/areas.ts +408 -408
- package/src/api/program/classification.ts +138 -138
- package/src/api/program/cores.ts +83 -83
- package/src/api/program/departments.ts +517 -517
- package/src/api/program/index.ts +73 -73
- package/src/api/program/labels.ts +332 -332
- package/src/api/program/layout.ts +422 -422
- package/src/api/program/metadata.ts +364 -364
- package/src/api/program/metrics.ts +120 -120
- package/src/api/program/site.ts +748 -748
- package/src/api/program/spreadsheet.ts +2698 -2698
- package/src/api/workspace/index.ts +612 -612
- package/src/errors/codes.ts +143 -136
- package/src/errors/envelope.ts +75 -75
- package/src/errors/index.ts +21 -21
- package/src/errors/plugin-error.ts +134 -134
- package/src/handles.ts +297 -297
- package/src/host-utils.ts +67 -67
- package/src/index.ts +7 -7
- package/src/massParameters.ops.ts +246 -246
- package/src/massParameters.ts +427 -427
- package/src/types.ts +16 -16
- package/test/drawingContract.test.mjs +288 -0
- package/test/errors.test.mjs +185 -184
- package/test/massParameters.test.mjs +952 -952
- package/tsconfig.json +22 -22
- package/tsup.config.ts +12 -12
- package/api-manifest.json +0 -9618
package/src/handles.ts
CHANGED
|
@@ -1,297 +1,297 @@
|
|
|
1
|
-
import * as z from "zod"
|
|
2
|
-
import type { ArenaKind } from "./api/core/handles"
|
|
3
|
-
|
|
4
|
-
// Runtime polyfill: engines without explicit-resource-management would otherwise
|
|
5
|
-
// evaluate the class's computed [Symbol.asyncDispose] key as undefined and
|
|
6
|
-
// silently create a property literally named "undefined".
|
|
7
|
-
;(Symbol as { asyncDispose?: symbol }).asyncDispose ??= Symbol.for("Symbol.asyncDispose")
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* An opaque, kind-tagged reference to a host-side object that crosses the RPC
|
|
11
|
-
* boundary by IDENTITY rather than by value. See `PLUGIN_API_EXPOSURE_HLD.md` §9.
|
|
12
|
-
*
|
|
13
|
-
* A handle is a small CLASS instance wrapping the wire id. The phantom
|
|
14
|
-
* `__handle` brand makes a `Handle<"profile">` incompatible with a
|
|
15
|
-
* `Handle<"vec3">` at compile time. On the wire the id string is all that
|
|
16
|
-
* travels: the client SDK unwraps `Handle` arguments to `.id` before the RPC
|
|
17
|
-
* call, and the host tags returned handles as `{ __h: "<id>" }` (via
|
|
18
|
-
* {@linkcode Handle.toJSON}) for the client to re-wrap.
|
|
19
|
-
*
|
|
20
|
-
* Plugin-side lifecycle: the client SDK interns one live instance per id and
|
|
21
|
-
* registers it with a FinalizationRegistry — dropping every reference to a
|
|
22
|
-
* handle eventually releases its host registry entry. Deterministic release is
|
|
23
|
-
* still preferred: `core.handles.release/releaseAll` or scopes.
|
|
24
|
-
*
|
|
25
|
-
* Crossing non-RPC boundaries (UI postMessage, persistence, logging):
|
|
26
|
-
* send {@linkcode Handle.id} — structured clone strips the class prototype.
|
|
27
|
-
*/
|
|
28
|
-
export class Handle<K extends string> {
|
|
29
|
-
/** Phantom brand — keeps `Handle<"vec3">` ≠ `Handle<"mass">` at compile time. */
|
|
30
|
-
declare readonly __handle: K
|
|
31
|
-
|
|
32
|
-
constructor(readonly id: string) {}
|
|
33
|
-
|
|
34
|
-
/** Wire tag — the host's result serialization (JSON round-trip) calls this. */
|
|
35
|
-
toJSON(): { __h: string } {
|
|
36
|
-
return { __h: this.id }
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
/** Template-string / logging form stays the bare id. */
|
|
40
|
-
toString(): string {
|
|
41
|
-
return this.id
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
/** Identity comparison by id — safe across re-wraps. */
|
|
45
|
-
equals(other: Handle<string>): boolean {
|
|
46
|
-
return this.id === other.id
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
/**
|
|
50
|
-
* Explicit-resource-management hook (`await using`). A no-op here; the
|
|
51
|
-
* plugin-client runtime installs the real enqueue-release behavior on the
|
|
52
|
-
* interned instance.
|
|
53
|
-
*/
|
|
54
|
-
async [Symbol.asyncDispose](): Promise<void> {}
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
/** Union of all releasable (arena-backed) handle kinds. */
|
|
58
|
-
export type AnyArenaHandle = Handle<ArenaKind>
|
|
59
|
-
|
|
60
|
-
/**
|
|
61
|
-
* A scene-entity handle. Backed by the host `Component.id` and resolved live via
|
|
62
|
-
* the host scene index (StructureCollection) — never stored in the resource
|
|
63
|
-
* registry. Stable across undo/redo and persistable across sessions (§9.2).
|
|
64
|
-
* Entity handles remain raw branded STRINGS (not {@linkcode Handle} instances):
|
|
65
|
-
* they have no arena entry, no lifecycle, and are equality-matched against
|
|
66
|
-
* plain ids embedded in result records.
|
|
67
|
-
*/
|
|
68
|
-
export type EntityId<K extends string = string> = string & { readonly __handle: K }
|
|
69
|
-
|
|
70
|
-
/** Resource handle: a host-resident, session-ephemeral geometry object (§9.2). */
|
|
71
|
-
export type ProfileHandle = Handle<"profile">
|
|
72
|
-
|
|
73
|
-
/** Resource handle: a host-resident contour (outer profile + hole profiles). */
|
|
74
|
-
export type ContourHandle = Handle<"contour">
|
|
75
|
-
|
|
76
|
-
/** Entity-handle example: a Mass / space scene object (Component.id). */
|
|
77
|
-
export type MassHandle = EntityId<"mass">
|
|
78
|
-
|
|
79
|
-
/**
|
|
80
|
-
* A scene BIM entity (wall, space, slab, floor, …). Backed by `Component.id` and
|
|
81
|
-
* resolved live via the host scene index (StructureCollection) — never stored in
|
|
82
|
-
* the resource registry. Stable across undo/redo and persistable (§9.2). This is
|
|
83
|
-
* the canonical return handle for every `design.create.*` creator. The token is
|
|
84
|
-
* the raw `Component.id` — NO `"component_"` prefix, so it round-trips with the
|
|
85
|
-
* ids the host already hands out.
|
|
86
|
-
*/
|
|
87
|
-
export type ComponentHandle = EntityId<"component">
|
|
88
|
-
|
|
89
|
-
/**
|
|
90
|
-
* A material handle. Like {@linkcode ComponentHandle}/`CommentHandle` this is an
|
|
91
|
-
* arena-free **entity-style** handle: the token IS the material's stable engine
|
|
92
|
-
* name (`Material.name`/`.id`), resolved live via `scene.getMaterialByName`
|
|
93
|
-
* host-side — no registry arena, no quota, no dispose, stable across undo/redo.
|
|
94
|
-
* Project-scoped, not a scene entity.
|
|
95
|
-
*/
|
|
96
|
-
export type MaterialHandle = EntityId<"material">
|
|
97
|
-
|
|
98
|
-
/**
|
|
99
|
-
* A placed **scene underlay** — an imported reference plane the user traces over:
|
|
100
|
-
* an image `FloorPlan`, a `PDF` overlay, or a `CAD` sketch. Entity-style: the token
|
|
101
|
-
* IS the raw `Component.id` (`fp_…` / a pdf id / `cad_…`). Resolved live host-side
|
|
102
|
-
* via the import-order layer walk (`collectStoreyImportItems`) — NOT via
|
|
103
|
-
* `ComponentUtility.FindComponentById`, which does not index underlays. No arena, no
|
|
104
|
-
* quota, stable across undo/redo. Returned by `core.io.import.{image,pdf,cadJson}`
|
|
105
|
-
* and consumed by every `core.io.underlay.*` method.
|
|
106
|
-
*/
|
|
107
|
-
export type UnderlayHandle = EntityId<"underlay">
|
|
108
|
-
|
|
109
|
-
/**
|
|
110
|
-
* The project's **site terrain** — a Mapbox-derived topography mesh. Entity-style
|
|
111
|
-
* and a project **singleton** (one terrain per project): the token is the terrain
|
|
112
|
-
* `Component.id` (`terrain-…`), resolved live via `TerrainOperations.getTerrain()`
|
|
113
|
-
* (absent from the level component collections, so NOT `FindComponentById`).
|
|
114
|
-
* Returned by `core.io.import.terrain`.
|
|
115
|
-
*/
|
|
116
|
-
export type TerrainHandle = EntityId<"terrain">
|
|
117
|
-
|
|
118
|
-
/**
|
|
119
|
-
* A **dimension line** — one measurement annotation left behind by the Measuring
|
|
120
|
-
* Tape tool (NOT a width/height/depth property; see `design.dimensions`).
|
|
121
|
-
* Entity-style: the token IS the raw engine dimension id (`dim_…`), resolved live
|
|
122
|
-
* host-side from the dimension-line registry (`getDimensionLineMap()`) — not via
|
|
123
|
-
* `ComponentUtility.FindComponentById`, which does not index dimension lines (a
|
|
124
|
-
* dimension line is not a Component). No arena, no quota, stable across
|
|
125
|
-
* undo/redo and across reloads (the record persists with the project). Returned
|
|
126
|
-
* by `design.dimensions.create` and consumed by every other
|
|
127
|
-
* `design.dimensions.*` method.
|
|
128
|
-
*/
|
|
129
|
-
export type DimensionHandle = EntityId<"dimension">
|
|
130
|
-
|
|
131
|
-
/**
|
|
132
|
-
* A handle to an **asynchronous import job** (today: a DWG → Forge conversion, which
|
|
133
|
-
* can take minutes). Returned immediately by `core.io.import.dwg`; poll it via
|
|
134
|
-
* `core.io.job.*` (`getStatus` / `isComplete` / `getResult` / `getError`). The token
|
|
135
|
-
* is the engine's import request id; job state lives in a host-side registry.
|
|
136
|
-
*/
|
|
137
|
-
export type ImportJobHandle = EntityId<"importJob">
|
|
138
|
-
|
|
139
|
-
// ── Value-kind handles (all-handle model, §11) ──────────────────────────────
|
|
140
|
-
// Under the all-handle decision every structured type is a handle. The only
|
|
141
|
-
// non-handles crossing the boundary are JS primitives (number/string/boolean)
|
|
142
|
-
// and enums — the irreducible construction/read leaves. Value handles are
|
|
143
|
-
// immutable; math/geom operate on them via host RPC (no in-worker compute).
|
|
144
|
-
export type Vec3Handle = Handle<"vec3">
|
|
145
|
-
export type QuatHandle = Handle<"quat">
|
|
146
|
-
export type LineHandle = Handle<"line">
|
|
147
|
-
export type ArcHandle = Handle<"arc">
|
|
148
|
-
/**
|
|
149
|
-
* A NURBS curve value handle (open B-spline curve). Minted by
|
|
150
|
-
* `core.geom.create.splineFromPoints` / `splineFromControlPoints`, and returned by
|
|
151
|
-
* `edge.getCurve`, `profile.listCurves` and `update.curve.reverse` for a spline run;
|
|
152
|
-
* accepted everywhere a {@linkcode CurveHandle} is (profileFromCurves, query.curve.*).
|
|
153
|
-
* Closed spline loops never exist as a single handle — a closed run is built
|
|
154
|
-
* directly as a profile via `core.geom.create.profileFromSplinePoints`.
|
|
155
|
-
*/
|
|
156
|
-
export type SplineHandle = Handle<"spline">
|
|
157
|
-
/** A curve is a line, an arc, or a spline — its handle is one of those kinds. */
|
|
158
|
-
export type CurveHandle = LineHandle | ArcHandle | SplineHandle
|
|
159
|
-
/**
|
|
160
|
-
* A circle value handle. A circle is a CLOSED curve — it deliberately does NOT
|
|
161
|
-
* join {@linkcode CurveHandle} (it has no stable start/end and would break the
|
|
162
|
-
* shared curve read contract), so it carries its own kind and its own
|
|
163
|
-
* `core.geom.query.circle` namespace (mirroring `query.arc`).
|
|
164
|
-
*/
|
|
165
|
-
export type CircleHandle = Handle<"circle">
|
|
166
|
-
|
|
167
|
-
// ── BREP topology handles (geometry-kernel resource family, §2A.2.1) ─────────
|
|
168
|
-
// Session-ephemeral, identity-deduped RESOURCE handles for the boundary-
|
|
169
|
-
// representation topology graph. Read-only via `core.geom.query.{brep,face,edge,
|
|
170
|
-
// halfedge,vertex}`; they go stale on undo/redo/re-topologize. Obtain a brep via
|
|
171
|
-
// `design.query.geometry.getBrep`; every other topology handle is minted by
|
|
172
|
-
// walking from a brep/face/edge/vertex handle already resolved off that brep.
|
|
173
|
-
export type BrepHandle = Handle<"brep">
|
|
174
|
-
export type FaceHandle = Handle<"face">
|
|
175
|
-
export type EdgeHandle = Handle<"edge">
|
|
176
|
-
/** Half-edge kind token is all-lowercase `"halfedge"` per §6.1 (no camelCase namespaces). */
|
|
177
|
-
export type HalfEdgeHandle = Handle<"halfedge">
|
|
178
|
-
export type VertexHandle = Handle<"vertex">
|
|
179
|
-
|
|
180
|
-
/**
|
|
181
|
-
* Bare primitive records — how value-handle reads return their components
|
|
182
|
-
* (§11.4). Curves have **no** by-value record: a curve crosses the boundary as a
|
|
183
|
-
* {@linkcode CurveHandle} (line/arc), and its coordinates are read via the
|
|
184
|
-
* `core.geom.query.curve` API. There is no `CurveData` under the all-handle model.
|
|
185
|
-
*/
|
|
186
|
-
export type Vec3Components = { x: number; y: number; z: number }
|
|
187
|
-
export type QuatComponents = { x: number; y: number; z: number; w: number }
|
|
188
|
-
/** Axis-aligned bounding box, read as two primitive corner records. */
|
|
189
|
-
export type BBoxComponents = { min: Vec3Components; max: Vec3Components }
|
|
190
|
-
|
|
191
|
-
/**
|
|
192
|
-
* Build a Zod schema validating a handle of the given `kind` at the trust
|
|
193
|
-
* boundary and emitting a {@linkcode Handle} instance for impl code. Inbound
|
|
194
|
-
* forms accepted:
|
|
195
|
-
* - the bare id string (the wire form — the client unwraps args to ids)
|
|
196
|
-
* - a live `Handle` instance (host-internal re-parse, direct host callers)
|
|
197
|
-
* - `{ __h: string }` (the tagged result form, echoed back as an arg)
|
|
198
|
-
* - `{ id: string }` (a Handle stripped by structured clone at the UI boundary)
|
|
199
|
-
* Shape checking stays prefix-only; existence, kind, and ownership are enforced
|
|
200
|
-
* host-side by the HandleRegistry (§9.7) — no existence oracle.
|
|
201
|
-
*/
|
|
202
|
-
export const handleSchema = <K extends string>(kind: K) =>
|
|
203
|
-
z
|
|
204
|
-
.preprocess(
|
|
205
|
-
(v) => {
|
|
206
|
-
if (typeof v === "string") return v
|
|
207
|
-
if (v instanceof Handle) return v.id
|
|
208
|
-
if (v && typeof v === "object") {
|
|
209
|
-
const o = v as Record<string, unknown>
|
|
210
|
-
if (typeof o.__h === "string") return o.__h
|
|
211
|
-
if (typeof o.id === "string") return o.id
|
|
212
|
-
}
|
|
213
|
-
return v
|
|
214
|
-
},
|
|
215
|
-
z.string().regex(new RegExp(`^${kind}_[A-Za-z0-9_-]+$`), `expected a "${kind}" handle`)
|
|
216
|
-
)
|
|
217
|
-
.transform((s) => new Handle<K>(s))
|
|
218
|
-
|
|
219
|
-
export const ProfileHandle = handleSchema("profile")
|
|
220
|
-
export const ContourHandle = handleSchema("contour")
|
|
221
|
-
|
|
222
|
-
/**
|
|
223
|
-
* Entity handles are raw `Component.id` strings (no `"<kind>_"` prefix) — validated
|
|
224
|
-
* only as a non-empty string, resolved live via the scene index host-side.
|
|
225
|
-
*/
|
|
226
|
-
export const ComponentHandle = z
|
|
227
|
-
.string()
|
|
228
|
-
.min(1)
|
|
229
|
-
.transform((s) => s as ComponentHandle)
|
|
230
|
-
|
|
231
|
-
/**
|
|
232
|
-
* Material handles are the raw `Material.name` string (entity-style, no `"<kind>_"`
|
|
233
|
-
* prefix) — validated only as non-empty, resolved live via `scene.getMaterialByName`.
|
|
234
|
-
*/
|
|
235
|
-
export const MaterialHandle = z
|
|
236
|
-
.string()
|
|
237
|
-
.min(1)
|
|
238
|
-
.transform((s) => s as MaterialHandle)
|
|
239
|
-
|
|
240
|
-
/**
|
|
241
|
-
* {@linkcode UnderlayHandle} / {@linkcode TerrainHandle} / {@linkcode ImportJobHandle}
|
|
242
|
-
* are entity-style handles — raw host ids, validated only as a non-empty string
|
|
243
|
-
* (no `"<kind>_"` prefix), resolved live host-side (existence enforced there).
|
|
244
|
-
*/
|
|
245
|
-
export const UnderlayHandle = z
|
|
246
|
-
.string()
|
|
247
|
-
.min(1)
|
|
248
|
-
.transform((s) => s as UnderlayHandle)
|
|
249
|
-
export const TerrainHandle = z
|
|
250
|
-
.string()
|
|
251
|
-
.min(1)
|
|
252
|
-
.transform((s) => s as TerrainHandle)
|
|
253
|
-
export const ImportJobHandle = z
|
|
254
|
-
.string()
|
|
255
|
-
.min(1)
|
|
256
|
-
.transform((s) => s as ImportJobHandle)
|
|
257
|
-
|
|
258
|
-
/**
|
|
259
|
-
* {@linkcode DimensionHandle} is an entity-style handle — the raw `dim_…` engine
|
|
260
|
-
* id, validated only as a non-empty string (no `"<kind>_"` prefix enforcement),
|
|
261
|
-
* resolved live host-side against the dimension-line registry (existence
|
|
262
|
-
* enforced there, as `HANDLE_INVALID`).
|
|
263
|
-
*/
|
|
264
|
-
export const DimensionHandle = z
|
|
265
|
-
.string()
|
|
266
|
-
.min(1)
|
|
267
|
-
.transform((s) => s as DimensionHandle)
|
|
268
|
-
|
|
269
|
-
// Value-kind handle schemas (all-handle model, §11).
|
|
270
|
-
export const Vec3Handle = handleSchema("vec3")
|
|
271
|
-
export const QuatHandle = handleSchema("quat")
|
|
272
|
-
export const LineHandle = handleSchema("line")
|
|
273
|
-
export const ArcHandle = handleSchema("arc")
|
|
274
|
-
export const SplineHandle = handleSchema("spline")
|
|
275
|
-
// Explicitly typed (rather than inferred): the inferred union type prints its
|
|
276
|
-
// three fully-expanded member schemas into handles.d.ts, which is served to
|
|
277
|
-
// agents whole and has a size budget. ZodUnion (not ZodType) keeps `.options`.
|
|
278
|
-
export const CurveHandle: z.ZodUnion<
|
|
279
|
-
readonly [typeof LineHandle, typeof ArcHandle, typeof SplineHandle]
|
|
280
|
-
> = z.union([LineHandle, ArcHandle, SplineHandle])
|
|
281
|
-
export const CircleHandle = handleSchema("circle")
|
|
282
|
-
|
|
283
|
-
// BREP topology handle schemas (§2A.2.1). Prefix-shape validation only; existence,
|
|
284
|
-
// kind, and ownership are enforced host-side by the HandleRegistry topology arena.
|
|
285
|
-
export const BrepHandle = handleSchema("brep")
|
|
286
|
-
export const FaceHandle = handleSchema("face")
|
|
287
|
-
export const EdgeHandle = handleSchema("edge")
|
|
288
|
-
export const HalfEdgeHandle = handleSchema("halfedge")
|
|
289
|
-
export const VertexHandle = handleSchema("vertex")
|
|
290
|
-
export const Vec3Components = z.object({ x: z.number(), y: z.number(), z: z.number() })
|
|
291
|
-
export const QuatComponents = z.object({
|
|
292
|
-
x: z.number(),
|
|
293
|
-
y: z.number(),
|
|
294
|
-
z: z.number(),
|
|
295
|
-
w: z.number(),
|
|
296
|
-
})
|
|
297
|
-
export const BBoxComponents = z.object({ min: Vec3Components, max: Vec3Components })
|
|
1
|
+
import * as z from "zod"
|
|
2
|
+
import type { ArenaKind } from "./api/core/handles"
|
|
3
|
+
|
|
4
|
+
// Runtime polyfill: engines without explicit-resource-management would otherwise
|
|
5
|
+
// evaluate the class's computed [Symbol.asyncDispose] key as undefined and
|
|
6
|
+
// silently create a property literally named "undefined".
|
|
7
|
+
;(Symbol as { asyncDispose?: symbol }).asyncDispose ??= Symbol.for("Symbol.asyncDispose")
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* An opaque, kind-tagged reference to a host-side object that crosses the RPC
|
|
11
|
+
* boundary by IDENTITY rather than by value. See `PLUGIN_API_EXPOSURE_HLD.md` §9.
|
|
12
|
+
*
|
|
13
|
+
* A handle is a small CLASS instance wrapping the wire id. The phantom
|
|
14
|
+
* `__handle` brand makes a `Handle<"profile">` incompatible with a
|
|
15
|
+
* `Handle<"vec3">` at compile time. On the wire the id string is all that
|
|
16
|
+
* travels: the client SDK unwraps `Handle` arguments to `.id` before the RPC
|
|
17
|
+
* call, and the host tags returned handles as `{ __h: "<id>" }` (via
|
|
18
|
+
* {@linkcode Handle.toJSON}) for the client to re-wrap.
|
|
19
|
+
*
|
|
20
|
+
* Plugin-side lifecycle: the client SDK interns one live instance per id and
|
|
21
|
+
* registers it with a FinalizationRegistry — dropping every reference to a
|
|
22
|
+
* handle eventually releases its host registry entry. Deterministic release is
|
|
23
|
+
* still preferred: `core.handles.release/releaseAll` or scopes.
|
|
24
|
+
*
|
|
25
|
+
* Crossing non-RPC boundaries (UI postMessage, persistence, logging):
|
|
26
|
+
* send {@linkcode Handle.id} — structured clone strips the class prototype.
|
|
27
|
+
*/
|
|
28
|
+
export class Handle<K extends string> {
|
|
29
|
+
/** Phantom brand — keeps `Handle<"vec3">` ≠ `Handle<"mass">` at compile time. */
|
|
30
|
+
declare readonly __handle: K
|
|
31
|
+
|
|
32
|
+
constructor(readonly id: string) {}
|
|
33
|
+
|
|
34
|
+
/** Wire tag — the host's result serialization (JSON round-trip) calls this. */
|
|
35
|
+
toJSON(): { __h: string } {
|
|
36
|
+
return { __h: this.id }
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/** Template-string / logging form stays the bare id. */
|
|
40
|
+
toString(): string {
|
|
41
|
+
return this.id
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/** Identity comparison by id — safe across re-wraps. */
|
|
45
|
+
equals(other: Handle<string>): boolean {
|
|
46
|
+
return this.id === other.id
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Explicit-resource-management hook (`await using`). A no-op here; the
|
|
51
|
+
* plugin-client runtime installs the real enqueue-release behavior on the
|
|
52
|
+
* interned instance.
|
|
53
|
+
*/
|
|
54
|
+
async [Symbol.asyncDispose](): Promise<void> {}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/** Union of all releasable (arena-backed) handle kinds. */
|
|
58
|
+
export type AnyArenaHandle = Handle<ArenaKind>
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* A scene-entity handle. Backed by the host `Component.id` and resolved live via
|
|
62
|
+
* the host scene index (StructureCollection) — never stored in the resource
|
|
63
|
+
* registry. Stable across undo/redo and persistable across sessions (§9.2).
|
|
64
|
+
* Entity handles remain raw branded STRINGS (not {@linkcode Handle} instances):
|
|
65
|
+
* they have no arena entry, no lifecycle, and are equality-matched against
|
|
66
|
+
* plain ids embedded in result records.
|
|
67
|
+
*/
|
|
68
|
+
export type EntityId<K extends string = string> = string & { readonly __handle: K }
|
|
69
|
+
|
|
70
|
+
/** Resource handle: a host-resident, session-ephemeral geometry object (§9.2). */
|
|
71
|
+
export type ProfileHandle = Handle<"profile">
|
|
72
|
+
|
|
73
|
+
/** Resource handle: a host-resident contour (outer profile + hole profiles). */
|
|
74
|
+
export type ContourHandle = Handle<"contour">
|
|
75
|
+
|
|
76
|
+
/** Entity-handle example: a Mass / space scene object (Component.id). */
|
|
77
|
+
export type MassHandle = EntityId<"mass">
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* A scene BIM entity (wall, space, slab, floor, …). Backed by `Component.id` and
|
|
81
|
+
* resolved live via the host scene index (StructureCollection) — never stored in
|
|
82
|
+
* the resource registry. Stable across undo/redo and persistable (§9.2). This is
|
|
83
|
+
* the canonical return handle for every `design.create.*` creator. The token is
|
|
84
|
+
* the raw `Component.id` — NO `"component_"` prefix, so it round-trips with the
|
|
85
|
+
* ids the host already hands out.
|
|
86
|
+
*/
|
|
87
|
+
export type ComponentHandle = EntityId<"component">
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* A material handle. Like {@linkcode ComponentHandle}/`CommentHandle` this is an
|
|
91
|
+
* arena-free **entity-style** handle: the token IS the material's stable engine
|
|
92
|
+
* name (`Material.name`/`.id`), resolved live via `scene.getMaterialByName`
|
|
93
|
+
* host-side — no registry arena, no quota, no dispose, stable across undo/redo.
|
|
94
|
+
* Project-scoped, not a scene entity.
|
|
95
|
+
*/
|
|
96
|
+
export type MaterialHandle = EntityId<"material">
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* A placed **scene underlay** — an imported reference plane the user traces over:
|
|
100
|
+
* an image `FloorPlan`, a `PDF` overlay, or a `CAD` sketch. Entity-style: the token
|
|
101
|
+
* IS the raw `Component.id` (`fp_…` / a pdf id / `cad_…`). Resolved live host-side
|
|
102
|
+
* via the import-order layer walk (`collectStoreyImportItems`) — NOT via
|
|
103
|
+
* `ComponentUtility.FindComponentById`, which does not index underlays. No arena, no
|
|
104
|
+
* quota, stable across undo/redo. Returned by `core.io.import.{image,pdf,cadJson}`
|
|
105
|
+
* and consumed by every `core.io.underlay.*` method.
|
|
106
|
+
*/
|
|
107
|
+
export type UnderlayHandle = EntityId<"underlay">
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* The project's **site terrain** — a Mapbox-derived topography mesh. Entity-style
|
|
111
|
+
* and a project **singleton** (one terrain per project): the token is the terrain
|
|
112
|
+
* `Component.id` (`terrain-…`), resolved live via `TerrainOperations.getTerrain()`
|
|
113
|
+
* (absent from the level component collections, so NOT `FindComponentById`).
|
|
114
|
+
* Returned by `core.io.import.terrain`.
|
|
115
|
+
*/
|
|
116
|
+
export type TerrainHandle = EntityId<"terrain">
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* A **dimension line** — one measurement annotation left behind by the Measuring
|
|
120
|
+
* Tape tool (NOT a width/height/depth property; see `design.dimensions`).
|
|
121
|
+
* Entity-style: the token IS the raw engine dimension id (`dim_…`), resolved live
|
|
122
|
+
* host-side from the dimension-line registry (`getDimensionLineMap()`) — not via
|
|
123
|
+
* `ComponentUtility.FindComponentById`, which does not index dimension lines (a
|
|
124
|
+
* dimension line is not a Component). No arena, no quota, stable across
|
|
125
|
+
* undo/redo and across reloads (the record persists with the project). Returned
|
|
126
|
+
* by `design.dimensions.create` and consumed by every other
|
|
127
|
+
* `design.dimensions.*` method.
|
|
128
|
+
*/
|
|
129
|
+
export type DimensionHandle = EntityId<"dimension">
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
* A handle to an **asynchronous import job** (today: a DWG → Forge conversion, which
|
|
133
|
+
* can take minutes). Returned immediately by `core.io.import.dwg`; poll it via
|
|
134
|
+
* `core.io.job.*` (`getStatus` / `isComplete` / `getResult` / `getError`). The token
|
|
135
|
+
* is the engine's import request id; job state lives in a host-side registry.
|
|
136
|
+
*/
|
|
137
|
+
export type ImportJobHandle = EntityId<"importJob">
|
|
138
|
+
|
|
139
|
+
// ── Value-kind handles (all-handle model, §11) ──────────────────────────────
|
|
140
|
+
// Under the all-handle decision every structured type is a handle. The only
|
|
141
|
+
// non-handles crossing the boundary are JS primitives (number/string/boolean)
|
|
142
|
+
// and enums — the irreducible construction/read leaves. Value handles are
|
|
143
|
+
// immutable; math/geom operate on them via host RPC (no in-worker compute).
|
|
144
|
+
export type Vec3Handle = Handle<"vec3">
|
|
145
|
+
export type QuatHandle = Handle<"quat">
|
|
146
|
+
export type LineHandle = Handle<"line">
|
|
147
|
+
export type ArcHandle = Handle<"arc">
|
|
148
|
+
/**
|
|
149
|
+
* A NURBS curve value handle (open B-spline curve). Minted by
|
|
150
|
+
* `core.geom.create.splineFromPoints` / `splineFromControlPoints`, and returned by
|
|
151
|
+
* `edge.getCurve`, `profile.listCurves` and `update.curve.reverse` for a spline run;
|
|
152
|
+
* accepted everywhere a {@linkcode CurveHandle} is (profileFromCurves, query.curve.*).
|
|
153
|
+
* Closed spline loops never exist as a single handle — a closed run is built
|
|
154
|
+
* directly as a profile via `core.geom.create.profileFromSplinePoints`.
|
|
155
|
+
*/
|
|
156
|
+
export type SplineHandle = Handle<"spline">
|
|
157
|
+
/** A curve is a line, an arc, or a spline — its handle is one of those kinds. */
|
|
158
|
+
export type CurveHandle = LineHandle | ArcHandle | SplineHandle
|
|
159
|
+
/**
|
|
160
|
+
* A circle value handle. A circle is a CLOSED curve — it deliberately does NOT
|
|
161
|
+
* join {@linkcode CurveHandle} (it has no stable start/end and would break the
|
|
162
|
+
* shared curve read contract), so it carries its own kind and its own
|
|
163
|
+
* `core.geom.query.circle` namespace (mirroring `query.arc`).
|
|
164
|
+
*/
|
|
165
|
+
export type CircleHandle = Handle<"circle">
|
|
166
|
+
|
|
167
|
+
// ── BREP topology handles (geometry-kernel resource family, §2A.2.1) ─────────
|
|
168
|
+
// Session-ephemeral, identity-deduped RESOURCE handles for the boundary-
|
|
169
|
+
// representation topology graph. Read-only via `core.geom.query.{brep,face,edge,
|
|
170
|
+
// halfedge,vertex}`; they go stale on undo/redo/re-topologize. Obtain a brep via
|
|
171
|
+
// `design.query.geometry.getBrep`; every other topology handle is minted by
|
|
172
|
+
// walking from a brep/face/edge/vertex handle already resolved off that brep.
|
|
173
|
+
export type BrepHandle = Handle<"brep">
|
|
174
|
+
export type FaceHandle = Handle<"face">
|
|
175
|
+
export type EdgeHandle = Handle<"edge">
|
|
176
|
+
/** Half-edge kind token is all-lowercase `"halfedge"` per §6.1 (no camelCase namespaces). */
|
|
177
|
+
export type HalfEdgeHandle = Handle<"halfedge">
|
|
178
|
+
export type VertexHandle = Handle<"vertex">
|
|
179
|
+
|
|
180
|
+
/**
|
|
181
|
+
* Bare primitive records — how value-handle reads return their components
|
|
182
|
+
* (§11.4). Curves have **no** by-value record: a curve crosses the boundary as a
|
|
183
|
+
* {@linkcode CurveHandle} (line/arc), and its coordinates are read via the
|
|
184
|
+
* `core.geom.query.curve` API. There is no `CurveData` under the all-handle model.
|
|
185
|
+
*/
|
|
186
|
+
export type Vec3Components = { x: number; y: number; z: number }
|
|
187
|
+
export type QuatComponents = { x: number; y: number; z: number; w: number }
|
|
188
|
+
/** Axis-aligned bounding box, read as two primitive corner records. */
|
|
189
|
+
export type BBoxComponents = { min: Vec3Components; max: Vec3Components }
|
|
190
|
+
|
|
191
|
+
/**
|
|
192
|
+
* Build a Zod schema validating a handle of the given `kind` at the trust
|
|
193
|
+
* boundary and emitting a {@linkcode Handle} instance for impl code. Inbound
|
|
194
|
+
* forms accepted:
|
|
195
|
+
* - the bare id string (the wire form — the client unwraps args to ids)
|
|
196
|
+
* - a live `Handle` instance (host-internal re-parse, direct host callers)
|
|
197
|
+
* - `{ __h: string }` (the tagged result form, echoed back as an arg)
|
|
198
|
+
* - `{ id: string }` (a Handle stripped by structured clone at the UI boundary)
|
|
199
|
+
* Shape checking stays prefix-only; existence, kind, and ownership are enforced
|
|
200
|
+
* host-side by the HandleRegistry (§9.7) — no existence oracle.
|
|
201
|
+
*/
|
|
202
|
+
export const handleSchema = <K extends string>(kind: K) =>
|
|
203
|
+
z
|
|
204
|
+
.preprocess(
|
|
205
|
+
(v) => {
|
|
206
|
+
if (typeof v === "string") return v
|
|
207
|
+
if (v instanceof Handle) return v.id
|
|
208
|
+
if (v && typeof v === "object") {
|
|
209
|
+
const o = v as Record<string, unknown>
|
|
210
|
+
if (typeof o.__h === "string") return o.__h
|
|
211
|
+
if (typeof o.id === "string") return o.id
|
|
212
|
+
}
|
|
213
|
+
return v
|
|
214
|
+
},
|
|
215
|
+
z.string().regex(new RegExp(`^${kind}_[A-Za-z0-9_-]+$`), `expected a "${kind}" handle`)
|
|
216
|
+
)
|
|
217
|
+
.transform((s) => new Handle<K>(s))
|
|
218
|
+
|
|
219
|
+
export const ProfileHandle = handleSchema("profile")
|
|
220
|
+
export const ContourHandle = handleSchema("contour")
|
|
221
|
+
|
|
222
|
+
/**
|
|
223
|
+
* Entity handles are raw `Component.id` strings (no `"<kind>_"` prefix) — validated
|
|
224
|
+
* only as a non-empty string, resolved live via the scene index host-side.
|
|
225
|
+
*/
|
|
226
|
+
export const ComponentHandle = z
|
|
227
|
+
.string()
|
|
228
|
+
.min(1)
|
|
229
|
+
.transform((s) => s as ComponentHandle)
|
|
230
|
+
|
|
231
|
+
/**
|
|
232
|
+
* Material handles are the raw `Material.name` string (entity-style, no `"<kind>_"`
|
|
233
|
+
* prefix) — validated only as non-empty, resolved live via `scene.getMaterialByName`.
|
|
234
|
+
*/
|
|
235
|
+
export const MaterialHandle = z
|
|
236
|
+
.string()
|
|
237
|
+
.min(1)
|
|
238
|
+
.transform((s) => s as MaterialHandle)
|
|
239
|
+
|
|
240
|
+
/**
|
|
241
|
+
* {@linkcode UnderlayHandle} / {@linkcode TerrainHandle} / {@linkcode ImportJobHandle}
|
|
242
|
+
* are entity-style handles — raw host ids, validated only as a non-empty string
|
|
243
|
+
* (no `"<kind>_"` prefix), resolved live host-side (existence enforced there).
|
|
244
|
+
*/
|
|
245
|
+
export const UnderlayHandle = z
|
|
246
|
+
.string()
|
|
247
|
+
.min(1)
|
|
248
|
+
.transform((s) => s as UnderlayHandle)
|
|
249
|
+
export const TerrainHandle = z
|
|
250
|
+
.string()
|
|
251
|
+
.min(1)
|
|
252
|
+
.transform((s) => s as TerrainHandle)
|
|
253
|
+
export const ImportJobHandle = z
|
|
254
|
+
.string()
|
|
255
|
+
.min(1)
|
|
256
|
+
.transform((s) => s as ImportJobHandle)
|
|
257
|
+
|
|
258
|
+
/**
|
|
259
|
+
* {@linkcode DimensionHandle} is an entity-style handle — the raw `dim_…` engine
|
|
260
|
+
* id, validated only as a non-empty string (no `"<kind>_"` prefix enforcement),
|
|
261
|
+
* resolved live host-side against the dimension-line registry (existence
|
|
262
|
+
* enforced there, as `HANDLE_INVALID`).
|
|
263
|
+
*/
|
|
264
|
+
export const DimensionHandle = z
|
|
265
|
+
.string()
|
|
266
|
+
.min(1)
|
|
267
|
+
.transform((s) => s as DimensionHandle)
|
|
268
|
+
|
|
269
|
+
// Value-kind handle schemas (all-handle model, §11).
|
|
270
|
+
export const Vec3Handle = handleSchema("vec3")
|
|
271
|
+
export const QuatHandle = handleSchema("quat")
|
|
272
|
+
export const LineHandle = handleSchema("line")
|
|
273
|
+
export const ArcHandle = handleSchema("arc")
|
|
274
|
+
export const SplineHandle = handleSchema("spline")
|
|
275
|
+
// Explicitly typed (rather than inferred): the inferred union type prints its
|
|
276
|
+
// three fully-expanded member schemas into handles.d.ts, which is served to
|
|
277
|
+
// agents whole and has a size budget. ZodUnion (not ZodType) keeps `.options`.
|
|
278
|
+
export const CurveHandle: z.ZodUnion<
|
|
279
|
+
readonly [typeof LineHandle, typeof ArcHandle, typeof SplineHandle]
|
|
280
|
+
> = z.union([LineHandle, ArcHandle, SplineHandle])
|
|
281
|
+
export const CircleHandle = handleSchema("circle")
|
|
282
|
+
|
|
283
|
+
// BREP topology handle schemas (§2A.2.1). Prefix-shape validation only; existence,
|
|
284
|
+
// kind, and ownership are enforced host-side by the HandleRegistry topology arena.
|
|
285
|
+
export const BrepHandle = handleSchema("brep")
|
|
286
|
+
export const FaceHandle = handleSchema("face")
|
|
287
|
+
export const EdgeHandle = handleSchema("edge")
|
|
288
|
+
export const HalfEdgeHandle = handleSchema("halfedge")
|
|
289
|
+
export const VertexHandle = handleSchema("vertex")
|
|
290
|
+
export const Vec3Components = z.object({ x: z.number(), y: z.number(), z: z.number() })
|
|
291
|
+
export const QuatComponents = z.object({
|
|
292
|
+
x: z.number(),
|
|
293
|
+
y: z.number(),
|
|
294
|
+
z: z.number(),
|
|
295
|
+
w: z.number(),
|
|
296
|
+
})
|
|
297
|
+
export const BBoxComponents = z.object({ min: Vec3Components, max: Vec3Components })
|