@snaptrude/plugin-core 0.10.0 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AGENTS.md +4 -0
- package/CHANGELOG.md +187 -3
- package/api-manifest.json +929 -25
- 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 +463 -0
- package/dist/api/core/camera/index.d.ts.map +1 -1
- package/dist/api/core/geom/create/index.d.ts +942 -101
- package/dist/api/core/geom/create/index.d.ts.map +1 -1
- package/dist/api/core/geom/query/brep.d.ts +59 -2
- package/dist/api/core/geom/query/brep.d.ts.map +1 -1
- package/dist/api/core/geom/query/curve.d.ts +59 -35
- package/dist/api/core/geom/query/curve.d.ts.map +1 -1
- package/dist/api/core/geom/query/edge.d.ts +2 -2
- package/dist/api/core/geom/query/face.d.ts +105 -0
- package/dist/api/core/geom/query/face.d.ts.map +1 -1
- package/dist/api/core/geom/update/contour.d.ts +10 -2
- package/dist/api/core/geom/update/contour.d.ts.map +1 -1
- package/dist/api/core/geom/update/curve.d.ts +5 -5
- package/dist/api/core/geom/update/profile.d.ts +3 -1
- package/dist/api/core/geom/update/profile.d.ts.map +1 -1
- package/dist/api/core/handles/index.d.ts +4 -2
- package/dist/api/core/handles/index.d.ts.map +1 -1
- package/dist/api/core/index.d.ts +4 -4
- package/dist/api/core/index.d.ts.map +1 -1
- package/dist/api/core/io/import/index.d.ts +3 -1
- package/dist/api/core/io/import/index.d.ts.map +1 -1
- package/dist/api/core/layers.d.ts +377 -255
- package/dist/api/core/layers.d.ts.map +1 -1
- package/dist/api/core/mode/index.d.ts +19 -7
- package/dist/api/core/mode/index.d.ts.map +1 -1
- package/dist/api/core/project/index.d.ts +68 -1
- package/dist/api/core/project/index.d.ts.map +1 -1
- package/dist/api/core/proposals/index.d.ts +4 -3
- package/dist/api/core/proposals/index.d.ts.map +1 -1
- package/dist/api/core/storeys/index.d.ts +31 -2
- package/dist/api/core/storeys/index.d.ts.map +1 -1
- package/dist/api/core/storeys/layers.d.ts +408 -0
- package/dist/api/core/storeys/layers.d.ts.map +1 -0
- package/dist/api/core/tags.d.ts +84 -3
- package/dist/api/core/tags.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 +299 -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 +269 -0
- package/dist/api/design/create/bulk-items.d.ts.map +1 -0
- package/dist/api/design/create/grids.d.ts +132 -0
- package/dist/api/design/create/grids.d.ts.map +1 -0
- package/dist/api/design/create/index.d.ts +752 -78
- package/dist/api/design/create/index.d.ts.map +1 -1
- package/dist/api/design/create/opening-fields.d.ts +38 -0
- package/dist/api/design/create/opening-fields.d.ts.map +1 -0
- package/dist/api/design/delete/index.d.ts +5 -0
- package/dist/api/design/delete/index.d.ts.map +1 -1
- package/dist/api/design/dimensions.d.ts +427 -0
- package/dist/api/design/dimensions.d.ts.map +1 -0
- package/dist/api/design/doors/index.d.ts +24 -23
- package/dist/api/design/doors/index.d.ts.map +1 -1
- package/dist/api/design/family.d.ts +1446 -0
- package/dist/api/design/family.d.ts.map +1 -0
- package/dist/api/design/furniture/index.d.ts +33 -0
- package/dist/api/design/furniture/index.d.ts.map +1 -1
- package/dist/api/design/grids.d.ts +237 -0
- package/dist/api/design/grids.d.ts.map +1 -0
- package/dist/api/design/index.d.ts +30 -0
- package/dist/api/design/index.d.ts.map +1 -1
- package/dist/api/design/networks.d.ts +1703 -0
- package/dist/api/design/networks.d.ts.map +1 -0
- package/dist/api/design/query/geometry/index.d.ts +33 -5
- package/dist/api/design/query/geometry/index.d.ts.map +1 -1
- package/dist/api/design/query/grids.d.ts +287 -0
- package/dist/api/design/query/grids.d.ts.map +1 -0
- package/dist/api/design/query/index.d.ts +143 -34
- package/dist/api/design/query/index.d.ts.map +1 -1
- package/dist/api/design/query/spaces.d.ts +5 -5
- package/dist/api/design/selection/index.d.ts +12 -12
- 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 +412 -8
- package/dist/api/design/update/index.d.ts.map +1 -1
- package/dist/api/design/visibility.d.ts +28 -0
- package/dist/api/design/visibility.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/entity/buildableEnvelope.d.ts +84 -2
- package/dist/api/entity/buildableEnvelope.d.ts.map +1 -1
- package/dist/api/entity/referenceLine.d.ts +13 -1
- package/dist/api/entity/referenceLine.d.ts.map +1 -1
- package/dist/api/entity/space.d.ts +12 -12
- package/dist/api/entity/story.d.ts +4 -4
- package/dist/api/presentation/aiInspiration.d.ts +24 -24
- package/dist/api/presentation/annotate.d.ts +38 -22
- package/dist/api/presentation/annotate.d.ts.map +1 -1
- package/dist/api/presentation/camera.d.ts +265 -0
- package/dist/api/presentation/camera.d.ts.map +1 -0
- 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/graphics.d.ts +419 -0
- package/dist/api/presentation/graphics.d.ts.map +1 -0
- package/dist/api/presentation/index.d.ts +66 -12
- package/dist/api/presentation/index.d.ts.map +1 -1
- package/dist/api/presentation/placedViews.d.ts +116 -16
- 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/standards.d.ts +590 -0
- package/dist/api/presentation/standards.d.ts.map +1 -0
- 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 +144 -9
- package/dist/api/presentation/views.d.ts.map +1 -1
- package/dist/api/presentation/walkthroughs.d.ts +1350 -0
- package/dist/api/presentation/walkthroughs.d.ts.map +1 -0
- package/dist/api/program/departments.d.ts +58 -2
- package/dist/api/program/departments.d.ts.map +1 -1
- package/dist/api/program/index.d.ts +16 -6
- package/dist/api/program/index.d.ts.map +1 -1
- package/dist/api/program/labels.d.ts +355 -0
- package/dist/api/program/labels.d.ts.map +1 -0
- package/dist/api/program/metadata.d.ts +328 -0
- package/dist/api/program/metadata.d.ts.map +1 -0
- package/dist/api/program/site.d.ts +4 -4
- package/dist/api/program/spreadsheet.d.ts +267 -4
- package/dist/api/program/spreadsheet.d.ts.map +1 -1
- package/dist/api/workspace/index.d.ts +49 -2
- package/dist/api/workspace/index.d.ts.map +1 -1
- package/dist/errors/codes.d.ts +3 -1
- package/dist/errors/codes.d.ts.map +1 -1
- package/dist/handles.d.ts +32 -3
- package/dist/handles.d.ts.map +1 -1
- package/dist/index.cjs +6539 -2804
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6121 -2801
- package/dist/index.js.map +1 -1
- package/dist/massParameters.d.ts +287 -0
- package/dist/massParameters.d.ts.map +1 -0
- package/dist/massParameters.ops.d.ts +138 -0
- package/dist/massParameters.ops.d.ts.map +1 -0
- package/package.json +14 -13
- package/scripts/check-dist-fresh.mjs +22 -0
- package/scripts/generate-manifest.mjs +5 -0
- package/scripts/generate-manifest.test.mjs +14 -3
- package/src/api/core/camera/index.ts +446 -1
- package/src/api/core/geom/create/index.ts +1037 -102
- package/src/api/core/geom/query/brep.ts +60 -2
- package/src/api/core/geom/query/curve.ts +26 -2
- package/src/api/core/geom/query/edge.ts +2 -2
- package/src/api/core/geom/query/face.ts +109 -4
- package/src/api/core/geom/update/contour.ts +10 -2
- package/src/api/core/geom/update/profile.ts +2 -0
- package/src/api/core/handles/index.ts +3 -2
- package/src/api/core/index.ts +4 -4
- package/src/api/core/io/import/index.ts +11 -3
- package/src/api/core/layers.ts +380 -173
- package/src/api/core/mode/index.ts +19 -7
- package/src/api/core/project/index.ts +62 -1
- package/src/api/core/proposals/index.ts +4 -3
- package/src/api/core/storeys/index.ts +34 -2
- package/src/api/core/storeys/layers.ts +339 -0
- package/src/api/core/tags.ts +76 -0
- package/src/api/core/zoom/index.ts +13 -0
- package/src/api/design/bim.ts +210 -0
- package/src/api/design/boolean/index.ts +2 -0
- package/src/api/design/catalog.ts +203 -0
- package/src/api/design/create/bulk-items.ts +294 -0
- package/src/api/design/create/grids.ts +137 -0
- package/src/api/design/create/index.ts +823 -114
- package/src/api/design/create/opening-fields.ts +40 -0
- package/src/api/design/delete/index.ts +5 -0
- package/src/api/design/dimensions.ts +453 -0
- package/src/api/design/doors/index.ts +64 -41
- package/src/api/design/family.ts +1342 -0
- package/src/api/design/furniture/index.ts +34 -0
- package/src/api/design/grids.ts +237 -0
- package/src/api/design/index.ts +49 -4
- package/src/api/design/networks.ts +607 -0
- package/src/api/design/query/geometry/index.ts +35 -4
- package/src/api/design/query/grids.ts +197 -0
- package/src/api/design/query/index.ts +105 -3
- package/src/api/design/types/index.ts +31 -24
- package/src/api/design/update/index.ts +398 -4
- package/src/api/design/visibility.ts +34 -0
- package/src/api/design/windows/index.ts +40 -22
- package/src/api/entity/buildableEnvelope.ts +77 -2
- package/src/api/entity/referenceLine.ts +25 -12
- package/src/api/presentation/annotate.ts +90 -58
- package/src/api/presentation/camera.ts +289 -0
- package/src/api/presentation/drawingContract.ts +70 -0
- package/src/api/presentation/drawings.ts +1179 -0
- package/src/api/presentation/export.ts +32 -6
- package/src/api/presentation/graphics.ts +324 -0
- package/src/api/presentation/index.ts +73 -14
- package/src/api/presentation/placedViews.ts +119 -28
- package/src/api/presentation/sections.ts +420 -0
- package/src/api/presentation/sheets.ts +181 -20
- package/src/api/presentation/standards.ts +445 -0
- package/src/api/presentation/viewPresets.ts +241 -0
- package/src/api/presentation/views.ts +81 -10
- package/src/api/presentation/walkthroughs.ts +1201 -0
- package/src/api/program/departments.ts +54 -2
- package/src/api/program/index.ts +16 -6
- package/src/api/program/labels.ts +332 -0
- package/src/api/program/metadata.ts +364 -0
- package/src/api/program/spreadsheet.ts +282 -0
- package/src/api/workspace/index.ts +51 -2
- package/src/errors/codes.ts +7 -0
- package/src/handles.ts +42 -3
- package/src/index.ts +2 -0
- package/src/massParameters.ops.ts +246 -0
- package/src/massParameters.ts +427 -0
- package/test/drawingContract.test.mjs +288 -0
- package/test/errors.test.mjs +1 -0
- package/test/massParameters.test.mjs +952 -0
- package/test/paperPensContract.test.mjs +75 -0
- package/test/presentationViewSettings.test.mjs +85 -0
|
@@ -10,13 +10,16 @@ import { PluginApiReturn } from "../../types"
|
|
|
10
10
|
* Teams are **read-only** here (no create/invite/delete in v1, a deliberate
|
|
11
11
|
* safety decision); there are no folders in v1. A `projectId` is the project's
|
|
12
12
|
* floorkey. Plan limits are enforced by the backend — a limit rejection surfaces
|
|
13
|
-
* as a normal host error. It also carries the workspace-level mode
|
|
13
|
+
* as a normal host error. It also carries the workspace-level mode switches for
|
|
14
14
|
* Present mode ({@linkcode PluginWorkspaceApi.openPresentMode} /
|
|
15
|
-
* {@linkcode PluginWorkspaceApi.closePresentMode})
|
|
15
|
+
* {@linkcode PluginWorkspaceApi.closePresentMode}) and Program mode
|
|
16
|
+
* ({@linkcode PluginWorkspaceApi.openProgramMode} /
|
|
17
|
+
* {@linkcode PluginWorkspaceApi.closeProgramMode}).
|
|
16
18
|
*
|
|
17
19
|
* - {@linkcode PluginWorkspaceApi.projects} — Create, copy, list, read & rename projects
|
|
18
20
|
* - {@linkcode PluginWorkspaceApi.teams} — Read teams and their members
|
|
19
21
|
* - {@linkcode PluginWorkspaceApi.openPresentMode} / {@linkcode PluginWorkspaceApi.closePresentMode} — Open/close the Present-mode documentation editor
|
|
22
|
+
* - {@linkcode PluginWorkspaceApi.openProgramMode} / {@linkcode PluginWorkspaceApi.closeProgramMode} — Open/close the Program tab (the spreadsheet the `program.spreadsheet.*` calls run in)
|
|
20
23
|
*/
|
|
21
24
|
export abstract class PluginWorkspaceApi {
|
|
22
25
|
/** Projects — create, copy, list, read & rename. See {@linkcode PluginWorkspaceProjectsApi}. */
|
|
@@ -68,6 +71,52 @@ export abstract class PluginWorkspaceApi {
|
|
|
68
71
|
*/
|
|
69
72
|
public abstract closePresentMode(): PluginApiReturn<void>
|
|
70
73
|
|
|
74
|
+
/**
|
|
75
|
+
* Open Program mode — the Program tab the `program.spreadsheet.*` calls run in.
|
|
76
|
+
*
|
|
77
|
+
* Runs the top bar's own Program-button sequence (remember the preference,
|
|
78
|
+
* open or re-link the paired Program window) and resolves only once that tab
|
|
79
|
+
* has connected to the editor over its channel, so a `program.spreadsheet.*`
|
|
80
|
+
* call issued right after this resolves finds the tab open. The open happens
|
|
81
|
+
* outside a user gesture, so the browser may block the pop-up; the editor
|
|
82
|
+
* then shows its "Allow pop-up to continue" modal and this call keeps waiting
|
|
83
|
+
* (up to ~90s) for the user to confirm. Idempotent — resolves immediately
|
|
84
|
+
* when the Program tab is already connected, and is a no-op when the plugin is
|
|
85
|
+
* itself running in the Program tab. Write-gated.
|
|
86
|
+
*
|
|
87
|
+
* @throws `PRECONDITION_FAILED` if the user dismisses the pop-up modal or the
|
|
88
|
+
* Program tab does not connect within the timeout.
|
|
89
|
+
*
|
|
90
|
+
* @examplePrompt Open program mode
|
|
91
|
+
* @examplePrompt Open the Program tab so I can build a custom sheet
|
|
92
|
+
* @examplePrompt Switch to the program spreadsheet
|
|
93
|
+
*
|
|
94
|
+
* # Example
|
|
95
|
+
* ```ts
|
|
96
|
+
* await snaptrude.workspace.openProgramMode()
|
|
97
|
+
* const { sheets } = await snaptrude.program.spreadsheet.listSheets()
|
|
98
|
+
* ```
|
|
99
|
+
*/
|
|
100
|
+
public abstract openProgramMode(): PluginApiReturn<void>
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* Close the Program tab.
|
|
104
|
+
*
|
|
105
|
+
* Idempotent — a no-op when no Program tab is connected. Write-gated, like
|
|
106
|
+
* {@linkcode PluginWorkspaceApi.openProgramMode}.
|
|
107
|
+
*
|
|
108
|
+
* @throws `PRECONDITION_FAILED` if the tab is still connected after ~15s.
|
|
109
|
+
*
|
|
110
|
+
* @examplePrompt Close program mode
|
|
111
|
+
* @examplePrompt Close the Program tab
|
|
112
|
+
*
|
|
113
|
+
* # Example
|
|
114
|
+
* ```ts
|
|
115
|
+
* await snaptrude.workspace.closeProgramMode()
|
|
116
|
+
* ```
|
|
117
|
+
*/
|
|
118
|
+
public abstract closeProgramMode(): PluginApiReturn<void>
|
|
119
|
+
|
|
71
120
|
constructor() {}
|
|
72
121
|
}
|
|
73
122
|
|
package/src/errors/codes.ts
CHANGED
|
@@ -7,6 +7,8 @@
|
|
|
7
7
|
* (`HANDLE_INVALID`) so error responses cannot be used as an existence /
|
|
8
8
|
* ownership oracle (PLUGIN_HANDLE_MIGRATION_HLD §6). `HANDLE_KIND_MISMATCH`
|
|
9
9
|
* stays distinct because the kind is information the caller already holds.
|
|
10
|
+
* `HANDLE_STALE` is the one deliberate exception: a handle the caller
|
|
11
|
+
* legitimately held whose entity was since retired (deleted or rebuilt).
|
|
10
12
|
*/
|
|
11
13
|
export const PLUGIN_ERROR_CODES = [
|
|
12
14
|
"VALIDATION",
|
|
@@ -34,6 +36,7 @@ export const PLUGIN_ERROR_CODES = [
|
|
|
34
36
|
"PROPOSAL_SWITCH_BLOCKED",
|
|
35
37
|
"INTERNAL",
|
|
36
38
|
"UNKNOWN",
|
|
39
|
+
"HANDLE_STALE",
|
|
37
40
|
] as const
|
|
38
41
|
|
|
39
42
|
export type PluginErrorCode = (typeof PLUGIN_ERROR_CODES)[number]
|
|
@@ -85,6 +88,10 @@ export const CODE_META: Record<PluginErrorCode, CodeMeta> = {
|
|
|
85
88
|
hintTemplate: "Re-query the entity; do not cache handles across undo/reload.",
|
|
86
89
|
},
|
|
87
90
|
HANDLE_KIND_MISMATCH: { category: "handle" },
|
|
91
|
+
HANDLE_STALE: {
|
|
92
|
+
category: "handle",
|
|
93
|
+
hintTemplate: "The entity was deleted or rebuilt; re-query it for a fresh handle.",
|
|
94
|
+
},
|
|
88
95
|
RESOURCE_QUOTA_EXCEEDED: {
|
|
89
96
|
category: "quota",
|
|
90
97
|
hintTemplate: "Release unused handles (core.handles.release) or use scopes.",
|
package/src/handles.ts
CHANGED
|
@@ -115,6 +115,19 @@ export type UnderlayHandle = EntityId<"underlay">
|
|
|
115
115
|
*/
|
|
116
116
|
export type TerrainHandle = EntityId<"terrain">
|
|
117
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
|
+
|
|
118
131
|
/**
|
|
119
132
|
* A handle to an **asynchronous import job** (today: a DWG → Forge conversion, which
|
|
120
133
|
* can take minutes). Returned immediately by `core.io.import.dwg`; poll it via
|
|
@@ -132,8 +145,17 @@ export type Vec3Handle = Handle<"vec3">
|
|
|
132
145
|
export type QuatHandle = Handle<"quat">
|
|
133
146
|
export type LineHandle = Handle<"line">
|
|
134
147
|
export type ArcHandle = Handle<"arc">
|
|
135
|
-
/**
|
|
136
|
-
|
|
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
|
|
137
159
|
/**
|
|
138
160
|
* A circle value handle. A circle is a CLOSED curve — it deliberately does NOT
|
|
139
161
|
* join {@linkcode CurveHandle} (it has no stable start/end and would break the
|
|
@@ -233,12 +255,29 @@ export const ImportJobHandle = z
|
|
|
233
255
|
.min(1)
|
|
234
256
|
.transform((s) => s as ImportJobHandle)
|
|
235
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
|
+
|
|
236
269
|
// Value-kind handle schemas (all-handle model, §11).
|
|
237
270
|
export const Vec3Handle = handleSchema("vec3")
|
|
238
271
|
export const QuatHandle = handleSchema("quat")
|
|
239
272
|
export const LineHandle = handleSchema("line")
|
|
240
273
|
export const ArcHandle = handleSchema("arc")
|
|
241
|
-
export const
|
|
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])
|
|
242
281
|
export const CircleHandle = handleSchema("circle")
|
|
243
282
|
|
|
244
283
|
// BREP topology handle schemas (§2A.2.1). Prefix-shape validation only; existence,
|
package/src/index.ts
CHANGED
|
@@ -0,0 +1,246 @@
|
|
|
1
|
+
import * as z from "zod"
|
|
2
|
+
import {
|
|
3
|
+
ContourRecord,
|
|
4
|
+
CurveRecord,
|
|
5
|
+
LoftOptions,
|
|
6
|
+
MAX_LOFT_SECTIONS,
|
|
7
|
+
MAX_PATH_CURVES,
|
|
8
|
+
MAX_SWEEP_PATH_POINTS,
|
|
9
|
+
SweepAlongCurveRecordOptions,
|
|
10
|
+
SweepOptions,
|
|
11
|
+
XYZ,
|
|
12
|
+
} from "./massParameters"
|
|
13
|
+
import type { CurveKind, SurfaceKind } from "./massParameters"
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* The **operation half** of a mass creation-parameter record: which edge or
|
|
17
|
+
* face of the recipe's solid a kernel step used, the step itself, and the
|
|
18
|
+
* values a `design.update.parameters` patch may carry.
|
|
19
|
+
*
|
|
20
|
+
* Split out of `massParameters.ts` so that each file stays under the size limit
|
|
21
|
+
* at which the agent runtime still serves a type module in ONE whole read (the
|
|
22
|
+
* record module alone had grown past it). Do not merge the two back. It is
|
|
23
|
+
* re-exported from there and from the package root, so every import path keeps
|
|
24
|
+
* working.
|
|
25
|
+
*
|
|
26
|
+
* Everything here is **pure JSON** by construction, exactly as in
|
|
27
|
+
* {@linkcode MassParametersRecord}: plain objects, numbers and arrays only, one
|
|
28
|
+
* `{x, y, z}` point shape, no class instances.
|
|
29
|
+
*/
|
|
30
|
+
|
|
31
|
+
/** Maximum kernel operations chained onto one recipe. */
|
|
32
|
+
export const MAX_OPERATIONS = 8
|
|
33
|
+
/** Maximum edges one fillet/chamfer operation may select. */
|
|
34
|
+
export const MAX_OPERATION_EDGES = 64
|
|
35
|
+
/** Maximum faces one shell operation may open. */
|
|
36
|
+
export const MAX_OPERATION_FACES = 32
|
|
37
|
+
/** Maximum rows in a variable-fillet radius law. */
|
|
38
|
+
export const MAX_FILLET_LAW_SAMPLES = 32
|
|
39
|
+
|
|
40
|
+
// `XYZ` and the record schemas below are resolved through `z.lazy`: this module
|
|
41
|
+
// and `massParameters.ts` re-export each other, and this one is evaluated first,
|
|
42
|
+
// so their consts are not yet initialised while these schemas are built. The
|
|
43
|
+
// closures run at parse time, when both modules are live.
|
|
44
|
+
const At: z.ZodType<XYZ, XYZ> = z.lazy(() => XYZ)
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Which EDGE of the input solid an operation used: its index in
|
|
48
|
+
* `core.geom.query.brep.listEdges` order at authoring time, the indices of the
|
|
49
|
+
* two faces it lies between, and its curve kind. This is topology, not
|
|
50
|
+
* coordinates — it survives a scalar edit of the base recipe (which moves every
|
|
51
|
+
* edge) and trips on a reorder or a topology change. Read-only: to blend a
|
|
52
|
+
* different edge, re-select it on the new shape and re-apply the operation.
|
|
53
|
+
*/
|
|
54
|
+
export type EdgeSelector = {
|
|
55
|
+
index: number
|
|
56
|
+
faces: [number, number]
|
|
57
|
+
curve: CurveKind
|
|
58
|
+
/** Where the edge sits INSIDE its solid: its midpoint in the record's own
|
|
59
|
+
* frame, divided by the solid's bounding-box extent — a ratio per axis,
|
|
60
|
+
* never a length, so it survives a scalar edit that scales the whole shape.
|
|
61
|
+
* Written only when the discriminators above cannot tell two edges apart. A
|
|
62
|
+
* tiebreak, never a coordinate fingerprint: a replay checks it within 0.02 of
|
|
63
|
+
* the solid's own box and refuses on a miss — it never searches for a better
|
|
64
|
+
* candidate. */
|
|
65
|
+
at?: XYZ
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Which FACE of the input solid an operation used: its index in
|
|
70
|
+
* `core.geom.query.brep.listFaces` order, its surface kind, and the number of
|
|
71
|
+
* edges in its outer loop. Read-only, like {@linkcode EdgeSelector}.
|
|
72
|
+
*/
|
|
73
|
+
export type FaceSelector = {
|
|
74
|
+
index: number
|
|
75
|
+
kind: SurfaceKind
|
|
76
|
+
edgeCount: number
|
|
77
|
+
/** The face's centroid under the same normalisation and the same tiebreak
|
|
78
|
+
* rule as {@linkcode EdgeSelector}'s `at` — written only where the
|
|
79
|
+
* discriminators above cannot separate two faces, which on a freeform solid
|
|
80
|
+
* (every face answers `"spline"`) is the common case. */
|
|
81
|
+
at?: XYZ
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/** The input solid's topology at authoring time — the counts a replay checks first. */
|
|
85
|
+
export type TopologyCounts = { faceCount: number; edgeCount: number }
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* One kernel operation applied to the base recipe's solid, in order. `input`
|
|
89
|
+
* pins the topology the operation was authored against, so a base edit that
|
|
90
|
+
* changes the topology is refused rather than mis-applied.
|
|
91
|
+
*
|
|
92
|
+
* Edit one by patching the whole list back:
|
|
93
|
+
* `design.update.parameters(mass, { operations })`.
|
|
94
|
+
*/
|
|
95
|
+
export type OperationRecord =
|
|
96
|
+
| {
|
|
97
|
+
op: "fillet"
|
|
98
|
+
edges: EdgeSelector[]
|
|
99
|
+
radius: number
|
|
100
|
+
/** Radius at the far end of the blend contour, internal length units — a
|
|
101
|
+
* linear variable blend from `radius`. One edge, and never with `radii`. */
|
|
102
|
+
endRadius?: number
|
|
103
|
+
/** The blend's radius law instead: `position` is normalised arc length
|
|
104
|
+
* along the blend contour (a ratio 0..1, never converted), `radius` is
|
|
105
|
+
* internal length units. 2..32 rows, strictly increasing `position`.
|
|
106
|
+
* One edge, and never with `endRadius`. */
|
|
107
|
+
radii?: { position: number; radius: number }[]
|
|
108
|
+
input: TopologyCounts
|
|
109
|
+
}
|
|
110
|
+
| { op: "chamfer"; edges: EdgeSelector[]; distance: number; input: TopologyCounts }
|
|
111
|
+
| { op: "shell"; openFaces: FaceSelector[]; thickness: number; input: TopologyCounts }
|
|
112
|
+
| { op: "offset"; distance: number; input: TopologyCounts }
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* One value of a `MassParametersPatch` — whatever a record's `values` key (or
|
|
116
|
+
* `operations`) may hold. Each key you send replaces that value whole — a
|
|
117
|
+
* scalar, a point, a list or a record (`contour`, `profile`, `sections`,
|
|
118
|
+
* `path`, `options`, `operations`) alike — so send the complete value you read.
|
|
119
|
+
*/
|
|
120
|
+
export type ParameterPatchValue =
|
|
121
|
+
| number
|
|
122
|
+
| XYZ
|
|
123
|
+
| XYZ[]
|
|
124
|
+
| ContourRecord
|
|
125
|
+
| ContourRecord[]
|
|
126
|
+
| CurveRecord[]
|
|
127
|
+
| LoftOptions
|
|
128
|
+
| SweepOptions
|
|
129
|
+
| SweepAlongCurveRecordOptions
|
|
130
|
+
| OperationRecord[]
|
|
131
|
+
|
|
132
|
+
const FaceIndex = z.number().int().nonnegative()
|
|
133
|
+
|
|
134
|
+
/** See {@linkcode EdgeSelector}. */
|
|
135
|
+
export const EdgeSelector: z.ZodType<EdgeSelector, EdgeSelector> = z.strictObject({
|
|
136
|
+
index: FaceIndex,
|
|
137
|
+
faces: z.tuple([FaceIndex, FaceIndex]),
|
|
138
|
+
curve: z.enum(["line", "arc", "circle", "spline"]),
|
|
139
|
+
at: At.optional(),
|
|
140
|
+
})
|
|
141
|
+
|
|
142
|
+
/** See {@linkcode FaceSelector}. */
|
|
143
|
+
export const FaceSelector: z.ZodType<FaceSelector, FaceSelector> = z.strictObject({
|
|
144
|
+
index: FaceIndex,
|
|
145
|
+
kind: z.enum(["plane", "cylinder", "cone", "sphere", "torus", "spline"]),
|
|
146
|
+
edgeCount: z.number().int().positive(),
|
|
147
|
+
at: At.optional(),
|
|
148
|
+
})
|
|
149
|
+
|
|
150
|
+
/** See {@linkcode TopologyCounts}. */
|
|
151
|
+
export const TopologyCounts: z.ZodType<TopologyCounts, TopologyCounts> = z.strictObject({
|
|
152
|
+
faceCount: z.number().int().positive(),
|
|
153
|
+
edgeCount: z.number().int().positive(),
|
|
154
|
+
})
|
|
155
|
+
|
|
156
|
+
/** One row of a variable fillet's radius law. See {@linkcode OperationRecord}. */
|
|
157
|
+
const FilletLawRow = z.strictObject({
|
|
158
|
+
position: z.number().finite().min(0).max(1),
|
|
159
|
+
radius: z.number().finite().positive(),
|
|
160
|
+
})
|
|
161
|
+
|
|
162
|
+
/**
|
|
163
|
+
* See {@linkcode OperationRecord}.
|
|
164
|
+
*
|
|
165
|
+
* A variable fillet — `endRadius` or `radii` — names ONE edge: the law is a
|
|
166
|
+
* property of the blend contour that edge belongs to, and `position` is measured
|
|
167
|
+
* from that edge's start, so a second edge would have no origin. The two forms
|
|
168
|
+
* are mutually exclusive and `radii` rows run strictly forward.
|
|
169
|
+
*/
|
|
170
|
+
export const OperationRecord: z.ZodType<OperationRecord, OperationRecord> = z
|
|
171
|
+
.discriminatedUnion("op", [
|
|
172
|
+
z.strictObject({
|
|
173
|
+
op: z.literal("fillet"),
|
|
174
|
+
edges: z.array(EdgeSelector).min(1).max(MAX_OPERATION_EDGES),
|
|
175
|
+
radius: z.number().finite().positive(),
|
|
176
|
+
endRadius: z.number().finite().positive().optional(),
|
|
177
|
+
radii: z.array(FilletLawRow).min(2).max(MAX_FILLET_LAW_SAMPLES).optional(),
|
|
178
|
+
input: TopologyCounts,
|
|
179
|
+
}),
|
|
180
|
+
z.strictObject({
|
|
181
|
+
op: z.literal("chamfer"),
|
|
182
|
+
edges: z.array(EdgeSelector).min(1).max(MAX_OPERATION_EDGES),
|
|
183
|
+
distance: z.number().finite().positive(),
|
|
184
|
+
input: TopologyCounts,
|
|
185
|
+
}),
|
|
186
|
+
z.strictObject({
|
|
187
|
+
op: z.literal("shell"),
|
|
188
|
+
openFaces: z.array(FaceSelector).min(1).max(MAX_OPERATION_FACES),
|
|
189
|
+
thickness: z.number().finite().positive(),
|
|
190
|
+
input: TopologyCounts,
|
|
191
|
+
}),
|
|
192
|
+
z.strictObject({
|
|
193
|
+
op: z.literal("offset"),
|
|
194
|
+
distance: z
|
|
195
|
+
.number()
|
|
196
|
+
.finite()
|
|
197
|
+
.refine((value) => value !== 0, { message: "distance must be non-zero" }),
|
|
198
|
+
input: TopologyCounts,
|
|
199
|
+
}),
|
|
200
|
+
])
|
|
201
|
+
.superRefine((operation, ctx) => {
|
|
202
|
+
if (operation.op !== "fillet") return
|
|
203
|
+
const { edges, endRadius, radii } = operation
|
|
204
|
+
if (endRadius === undefined && radii === undefined) return
|
|
205
|
+
if (endRadius !== undefined && radii !== undefined) {
|
|
206
|
+
ctx.addIssue({
|
|
207
|
+
code: "custom",
|
|
208
|
+
message: "endRadius is mutually exclusive with radii",
|
|
209
|
+
})
|
|
210
|
+
}
|
|
211
|
+
if (edges.length !== 1) {
|
|
212
|
+
ctx.addIssue({
|
|
213
|
+
code: "custom",
|
|
214
|
+
message: "a variable fillet names exactly one edge — the blend contour it runs along",
|
|
215
|
+
})
|
|
216
|
+
}
|
|
217
|
+
if (radii?.some((row, i) => i > 0 && row.position <= radii[i - 1].position)) {
|
|
218
|
+
ctx.addIssue({
|
|
219
|
+
code: "custom",
|
|
220
|
+
message: "radii positions must strictly increase",
|
|
221
|
+
})
|
|
222
|
+
}
|
|
223
|
+
})
|
|
224
|
+
|
|
225
|
+
/**
|
|
226
|
+
* One value of a parameter patch. See {@linkcode ParameterPatchValue}.
|
|
227
|
+
*
|
|
228
|
+
* Deliberately a CLOSED union of the shapes a record's `values` actually hold —
|
|
229
|
+
* no `z.unknown()`, nothing recursive: an unrecognised value is a VALIDATION at
|
|
230
|
+
* the wire, not a silent write of nonsense onto a mass. It only ever widens, so
|
|
231
|
+
* every value it accepted before it still accepts.
|
|
232
|
+
*/
|
|
233
|
+
export const ParameterPatchValue: z.ZodType<ParameterPatchValue, ParameterPatchValue> = z.lazy(() =>
|
|
234
|
+
z.union([
|
|
235
|
+
z.number().finite(),
|
|
236
|
+
XYZ,
|
|
237
|
+
z.array(XYZ).max(MAX_SWEEP_PATH_POINTS),
|
|
238
|
+
ContourRecord,
|
|
239
|
+
z.array(ContourRecord).max(MAX_LOFT_SECTIONS),
|
|
240
|
+
z.array(CurveRecord).max(MAX_PATH_CURVES),
|
|
241
|
+
LoftOptions,
|
|
242
|
+
SweepOptions,
|
|
243
|
+
SweepAlongCurveRecordOptions,
|
|
244
|
+
z.array(OperationRecord).max(MAX_OPERATIONS),
|
|
245
|
+
]),
|
|
246
|
+
)
|