@snaptrude/plugin-core 0.0.0-bimsvg-20260928124803
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 -0
- package/CHANGELOG.md +341 -0
- package/CLAUDE.md +11 -0
- package/api-manifest.json +9120 -0
- package/dist/api/analysis/daylight.d.ts +603 -0
- package/dist/api/analysis/daylight.d.ts.map +1 -0
- package/dist/api/analysis/heatmaps.d.ts +658 -0
- package/dist/api/analysis/heatmaps.d.ts.map +1 -0
- package/dist/api/analysis/illuminance.d.ts +145 -0
- package/dist/api/analysis/illuminance.d.ts.map +1 -0
- package/dist/api/analysis/index.d.ts +59 -0
- package/dist/api/analysis/index.d.ts.map +1 -0
- package/dist/api/analysis/shadows.d.ts +165 -0
- package/dist/api/analysis/shadows.d.ts.map +1 -0
- package/dist/api/analysis/solar.d.ts +249 -0
- package/dist/api/analysis/solar.d.ts.map +1 -0
- package/dist/api/analysis/sunlightHours.d.ts +208 -0
- package/dist/api/analysis/sunlightHours.d.ts.map +1 -0
- package/dist/api/analysis/sunpath.d.ts +80 -0
- package/dist/api/analysis/sunpath.d.ts.map +1 -0
- package/dist/api/analysis/weather.d.ts +193 -0
- package/dist/api/analysis/weather.d.ts.map +1 -0
- package/dist/api/core/buildings.d.ts +427 -0
- package/dist/api/core/buildings.d.ts.map +1 -0
- package/dist/api/core/camera/index.d.ts +261 -0
- package/dist/api/core/camera/index.d.ts.map +1 -0
- package/dist/api/core/comment/index.d.ts +333 -0
- package/dist/api/core/comment/index.d.ts.map +1 -0
- package/dist/api/core/geom/create/index.d.ts +1073 -0
- package/dist/api/core/geom/create/index.d.ts.map +1 -0
- package/dist/api/core/geom/delete/index.d.ts +78 -0
- package/dist/api/core/geom/delete/index.d.ts.map +1 -0
- package/dist/api/core/geom/index.d.ts +33 -0
- package/dist/api/core/geom/index.d.ts.map +1 -0
- package/dist/api/core/geom/query/arc.d.ts +169 -0
- package/dist/api/core/geom/query/arc.d.ts.map +1 -0
- package/dist/api/core/geom/query/brep.d.ts +514 -0
- package/dist/api/core/geom/query/brep.d.ts.map +1 -0
- package/dist/api/core/geom/query/circle.d.ts +378 -0
- package/dist/api/core/geom/query/circle.d.ts.map +1 -0
- package/dist/api/core/geom/query/contour.d.ts +450 -0
- package/dist/api/core/geom/query/contour.d.ts.map +1 -0
- package/dist/api/core/geom/query/curve.d.ts +918 -0
- package/dist/api/core/geom/query/curve.d.ts.map +1 -0
- package/dist/api/core/geom/query/edge.d.ts +128 -0
- package/dist/api/core/geom/query/edge.d.ts.map +1 -0
- package/dist/api/core/geom/query/face.d.ts +363 -0
- package/dist/api/core/geom/query/face.d.ts.map +1 -0
- package/dist/api/core/geom/query/halfedge.d.ts +206 -0
- package/dist/api/core/geom/query/halfedge.d.ts.map +1 -0
- package/dist/api/core/geom/query/index.d.ts +61 -0
- package/dist/api/core/geom/query/index.d.ts.map +1 -0
- package/dist/api/core/geom/query/profile.d.ts +410 -0
- package/dist/api/core/geom/query/profile.d.ts.map +1 -0
- package/dist/api/core/geom/query/vertex.d.ts +187 -0
- package/dist/api/core/geom/query/vertex.d.ts.map +1 -0
- package/dist/api/core/geom/update/contour.d.ts +272 -0
- package/dist/api/core/geom/update/contour.d.ts.map +1 -0
- package/dist/api/core/geom/update/curve.d.ts +180 -0
- package/dist/api/core/geom/update/curve.d.ts.map +1 -0
- package/dist/api/core/geom/update/index.d.ts +27 -0
- package/dist/api/core/geom/update/index.d.ts.map +1 -0
- package/dist/api/core/geom/update/profile.d.ts +329 -0
- package/dist/api/core/geom/update/profile.d.ts.map +1 -0
- package/dist/api/core/groups.d.ts +485 -0
- package/dist/api/core/groups.d.ts.map +1 -0
- package/dist/api/core/handles/index.d.ts +210 -0
- package/dist/api/core/handles/index.d.ts.map +1 -0
- package/dist/api/core/history/index.d.ts +78 -0
- package/dist/api/core/history/index.d.ts.map +1 -0
- package/dist/api/core/index.d.ts +97 -0
- package/dist/api/core/index.d.ts.map +1 -0
- package/dist/api/core/io/export/index.d.ts +134 -0
- package/dist/api/core/io/export/index.d.ts.map +1 -0
- package/dist/api/core/io/import/index.d.ts +455 -0
- package/dist/api/core/io/import/index.d.ts.map +1 -0
- package/dist/api/core/io/index.d.ts +40 -0
- package/dist/api/core/io/index.d.ts.map +1 -0
- package/dist/api/core/io/job/index.d.ts +139 -0
- package/dist/api/core/io/job/index.d.ts.map +1 -0
- package/dist/api/core/io/query/index.d.ts +74 -0
- package/dist/api/core/io/query/index.d.ts.map +1 -0
- package/dist/api/core/io/terrain/index.d.ts +341 -0
- package/dist/api/core/io/terrain/index.d.ts.map +1 -0
- package/dist/api/core/io/underlay/index.d.ts +805 -0
- package/dist/api/core/io/underlay/index.d.ts.map +1 -0
- package/dist/api/core/layers.d.ts +402 -0
- package/dist/api/core/layers.d.ts.map +1 -0
- package/dist/api/core/math/index.d.ts +18 -0
- package/dist/api/core/math/index.d.ts.map +1 -0
- package/dist/api/core/math/quat.d.ts +170 -0
- package/dist/api/core/math/quat.d.ts.map +1 -0
- package/dist/api/core/math/vec3.d.ts +174 -0
- package/dist/api/core/math/vec3.d.ts.map +1 -0
- package/dist/api/core/mode/index.d.ts +111 -0
- package/dist/api/core/mode/index.d.ts.map +1 -0
- package/dist/api/core/project/index.d.ts +466 -0
- package/dist/api/core/project/index.d.ts.map +1 -0
- package/dist/api/core/proposals/index.d.ts +531 -0
- package/dist/api/core/proposals/index.d.ts.map +1 -0
- package/dist/api/core/storeys/index.d.ts +265 -0
- package/dist/api/core/storeys/index.d.ts.map +1 -0
- package/dist/api/core/tags.d.ts +860 -0
- package/dist/api/core/tags.d.ts.map +1 -0
- package/dist/api/core/units/index.d.ts +175 -0
- package/dist/api/core/units/index.d.ts.map +1 -0
- package/dist/api/core/user.d.ts +44 -0
- package/dist/api/core/user.d.ts.map +1 -0
- package/dist/api/core/zoom/index.d.ts +49 -0
- package/dist/api/core/zoom/index.d.ts.map +1 -0
- package/dist/api/design/boolean/index.d.ts +168 -0
- package/dist/api/design/boolean/index.d.ts.map +1 -0
- package/dist/api/design/create/bulk-items.d.ts +185 -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 +1747 -0
- package/dist/api/design/create/index.d.ts.map +1 -0
- package/dist/api/design/create/opening-fields.d.ts +37 -0
- package/dist/api/design/create/opening-fields.d.ts.map +1 -0
- package/dist/api/design/delete/index.d.ts +70 -0
- package/dist/api/design/delete/index.d.ts.map +1 -0
- 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 +470 -0
- package/dist/api/design/doors/index.d.ts.map +1 -0
- package/dist/api/design/edit/index.d.ts +49 -0
- package/dist/api/design/edit/index.d.ts.map +1 -0
- package/dist/api/design/erase/index.d.ts +160 -0
- package/dist/api/design/erase/index.d.ts.map +1 -0
- package/dist/api/design/family.d.ts +611 -0
- package/dist/api/design/family.d.ts.map +1 -0
- package/dist/api/design/furniture/index.d.ts +296 -0
- package/dist/api/design/furniture/index.d.ts.map +1 -0
- 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 +260 -0
- package/dist/api/design/index.d.ts.map +1 -0
- package/dist/api/design/lock.d.ts +67 -0
- package/dist/api/design/lock.d.ts.map +1 -0
- package/dist/api/design/materials/index.d.ts +551 -0
- package/dist/api/design/materials/index.d.ts.map +1 -0
- package/dist/api/design/query/geometry/index.d.ts +252 -0
- package/dist/api/design/query/geometry/index.d.ts.map +1 -0
- 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 +1318 -0
- package/dist/api/design/query/index.d.ts.map +1 -0
- package/dist/api/design/query/referenceLines.d.ts +45 -0
- package/dist/api/design/query/referenceLines.d.ts.map +1 -0
- package/dist/api/design/query/spaces.d.ts +394 -0
- package/dist/api/design/query/spaces.d.ts.map +1 -0
- package/dist/api/design/selection/index.d.ts +282 -0
- package/dist/api/design/selection/index.d.ts.map +1 -0
- package/dist/api/design/shared.d.ts +38 -0
- package/dist/api/design/shared.d.ts.map +1 -0
- package/dist/api/design/transform/index.d.ts +249 -0
- package/dist/api/design/transform/index.d.ts.map +1 -0
- package/dist/api/design/types/index.d.ts +181 -0
- package/dist/api/design/types/index.d.ts.map +1 -0
- package/dist/api/design/update/index.d.ts +803 -0
- package/dist/api/design/update/index.d.ts.map +1 -0
- package/dist/api/design/visibility.d.ts +126 -0
- package/dist/api/design/visibility.d.ts.map +1 -0
- package/dist/api/design/windows/index.d.ts +300 -0
- package/dist/api/design/windows/index.d.ts.map +1 -0
- package/dist/api/entity/buildableEnvelope.d.ts +265 -0
- package/dist/api/entity/buildableEnvelope.d.ts.map +1 -0
- package/dist/api/entity/department.d.ts +1 -0
- package/dist/api/entity/department.d.ts.map +1 -0
- package/dist/api/entity/index.d.ts +28 -0
- package/dist/api/entity/index.d.ts.map +1 -0
- package/dist/api/entity/referenceLine.d.ts +210 -0
- package/dist/api/entity/referenceLine.d.ts.map +1 -0
- package/dist/api/entity/space.d.ts +846 -0
- package/dist/api/entity/space.d.ts.map +1 -0
- package/dist/api/entity/story.d.ts +476 -0
- package/dist/api/entity/story.d.ts.map +1 -0
- package/dist/api/index.d.ts +45 -0
- package/dist/api/index.d.ts.map +1 -0
- package/dist/api/presentation/aiInspiration.d.ts +2400 -0
- package/dist/api/presentation/aiInspiration.d.ts.map +1 -0
- package/dist/api/presentation/annotate.d.ts +483 -0
- package/dist/api/presentation/annotate.d.ts.map +1 -0
- package/dist/api/presentation/diagrams.d.ts +184 -0
- package/dist/api/presentation/diagrams.d.ts.map +1 -0
- package/dist/api/presentation/drawings.d.ts +2900 -0
- package/dist/api/presentation/drawings.d.ts.map +1 -0
- package/dist/api/presentation/export.d.ts +126 -0
- package/dist/api/presentation/export.d.ts.map +1 -0
- package/dist/api/presentation/import.d.ts +164 -0
- package/dist/api/presentation/import.d.ts.map +1 -0
- package/dist/api/presentation/index.d.ts +114 -0
- package/dist/api/presentation/index.d.ts.map +1 -0
- package/dist/api/presentation/placedViews.d.ts +1232 -0
- package/dist/api/presentation/placedViews.d.ts.map +1 -0
- package/dist/api/presentation/shapes.d.ts +481 -0
- package/dist/api/presentation/shapes.d.ts.map +1 -0
- package/dist/api/presentation/sheets.d.ts +643 -0
- package/dist/api/presentation/sheets.d.ts.map +1 -0
- package/dist/api/presentation/slideshow.d.ts +125 -0
- package/dist/api/presentation/slideshow.d.ts.map +1 -0
- package/dist/api/presentation/tables.d.ts +81 -0
- package/dist/api/presentation/tables.d.ts.map +1 -0
- package/dist/api/presentation/viewPresets.d.ts +70 -0
- package/dist/api/presentation/viewPresets.d.ts.map +1 -0
- package/dist/api/presentation/views.d.ts +741 -0
- package/dist/api/presentation/views.d.ts.map +1 -0
- package/dist/api/program/adjacency.d.ts +155 -0
- package/dist/api/program/adjacency.d.ts.map +1 -0
- package/dist/api/program/areas.d.ts +450 -0
- package/dist/api/program/areas.d.ts.map +1 -0
- package/dist/api/program/classification.d.ts +135 -0
- package/dist/api/program/classification.d.ts.map +1 -0
- package/dist/api/program/cores.d.ts +78 -0
- package/dist/api/program/cores.d.ts.map +1 -0
- package/dist/api/program/departments.d.ts +487 -0
- package/dist/api/program/departments.d.ts.map +1 -0
- package/dist/api/program/index.d.ts +71 -0
- package/dist/api/program/index.d.ts.map +1 -0
- package/dist/api/program/labels.d.ts +355 -0
- package/dist/api/program/labels.d.ts.map +1 -0
- package/dist/api/program/layout.d.ts +398 -0
- package/dist/api/program/layout.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/metrics.d.ts +108 -0
- package/dist/api/program/metrics.d.ts.map +1 -0
- package/dist/api/program/site.d.ts +823 -0
- package/dist/api/program/site.d.ts.map +1 -0
- package/dist/api/program/spreadsheet.d.ts +2628 -0
- package/dist/api/program/spreadsheet.d.ts.map +1 -0
- package/dist/api/workspace/index.d.ts +552 -0
- package/dist/api/workspace/index.d.ts.map +1 -0
- package/dist/errors/codes.d.ts +34 -0
- package/dist/errors/codes.d.ts.map +1 -0
- package/dist/errors/envelope.d.ts +56 -0
- package/dist/errors/envelope.d.ts.map +1 -0
- package/dist/errors/index.d.ts +6 -0
- package/dist/errors/index.d.ts.map +1 -0
- package/dist/errors/plugin-error.d.ts +69 -0
- package/dist/errors/plugin-error.d.ts.map +1 -0
- package/dist/handles.d.ts +229 -0
- package/dist/handles.d.ts.map +1 -0
- package/dist/host-utils.d.ts +47 -0
- package/dist/host-utils.d.ts.map +1 -0
- package/dist/index.cjs +8836 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +7568 -0
- package/dist/index.js.map +1 -0
- package/dist/types.d.ts +16 -0
- package/dist/types.d.ts.map +1 -0
- package/package.json +41 -0
- package/scripts/generate-manifest.mjs +238 -0
- package/scripts/generate-manifest.test.mjs +292 -0
- package/src/api/analysis/daylight.ts +470 -0
- package/src/api/analysis/heatmaps.ts +683 -0
- package/src/api/analysis/illuminance.ts +155 -0
- package/src/api/analysis/index.ts +61 -0
- package/src/api/analysis/shadows.ts +183 -0
- package/src/api/analysis/solar.ts +237 -0
- package/src/api/analysis/sunlightHours.ts +211 -0
- package/src/api/analysis/sunpath.ts +83 -0
- package/src/api/analysis/weather.ts +179 -0
- package/src/api/core/buildings.ts +485 -0
- package/src/api/core/camera/index.ts +268 -0
- package/src/api/core/comment/index.ts +376 -0
- package/src/api/core/geom/create/index.ts +1204 -0
- package/src/api/core/geom/delete/index.ts +84 -0
- package/src/api/core/geom/index.ts +35 -0
- package/src/api/core/geom/query/arc.ts +169 -0
- package/src/api/core/geom/query/brep.ts +563 -0
- package/src/api/core/geom/query/circle.ts +404 -0
- package/src/api/core/geom/query/contour.ts +540 -0
- package/src/api/core/geom/query/curve.ts +1078 -0
- package/src/api/core/geom/query/edge.ts +130 -0
- package/src/api/core/geom/query/face.ts +403 -0
- package/src/api/core/geom/query/halfedge.ts +210 -0
- package/src/api/core/geom/query/index.ts +63 -0
- package/src/api/core/geom/query/profile.ts +473 -0
- package/src/api/core/geom/query/vertex.ts +205 -0
- package/src/api/core/geom/update/contour.ts +315 -0
- package/src/api/core/geom/update/curve.ts +209 -0
- package/src/api/core/geom/update/index.ts +29 -0
- package/src/api/core/geom/update/profile.ts +377 -0
- package/src/api/core/groups.ts +521 -0
- package/src/api/core/handles/index.ts +233 -0
- package/src/api/core/history/index.ts +84 -0
- package/src/api/core/index.ts +99 -0
- package/src/api/core/io/export/index.ts +126 -0
- package/src/api/core/io/import/index.ts +504 -0
- package/src/api/core/io/index.ts +42 -0
- package/src/api/core/io/job/index.ts +140 -0
- package/src/api/core/io/query/index.ts +71 -0
- package/src/api/core/io/terrain/index.ts +360 -0
- package/src/api/core/io/underlay/index.ts +705 -0
- package/src/api/core/layers.ts +333 -0
- package/src/api/core/math/index.ts +20 -0
- package/src/api/core/math/quat.ts +172 -0
- package/src/api/core/math/vec3.ts +179 -0
- package/src/api/core/mode/index.ts +108 -0
- package/src/api/core/project/index.ts +479 -0
- package/src/api/core/proposals/index.ts +569 -0
- package/src/api/core/storeys/index.ts +294 -0
- package/src/api/core/tags.ts +911 -0
- package/src/api/core/units/index.ts +164 -0
- package/src/api/core/user.ts +46 -0
- package/src/api/core/zoom/index.ts +51 -0
- package/src/api/design/boolean/index.ts +179 -0
- package/src/api/design/create/bulk-items.ts +186 -0
- package/src/api/design/create/grids.ts +137 -0
- package/src/api/design/create/index.ts +1954 -0
- package/src/api/design/create/opening-fields.ts +37 -0
- package/src/api/design/delete/index.ts +74 -0
- package/src/api/design/dimensions.ts +453 -0
- package/src/api/design/doors/index.ts +500 -0
- package/src/api/design/edit/index.ts +54 -0
- package/src/api/design/erase/index.ts +151 -0
- package/src/api/design/family.ts +646 -0
- package/src/api/design/furniture/index.ts +319 -0
- package/src/api/design/grids.ts +237 -0
- package/src/api/design/index.ts +274 -0
- package/src/api/design/lock.ts +69 -0
- package/src/api/design/materials/index.ts +608 -0
- package/src/api/design/query/geometry/index.ts +288 -0
- package/src/api/design/query/grids.ts +197 -0
- package/src/api/design/query/index.ts +1176 -0
- package/src/api/design/query/referenceLines.ts +52 -0
- package/src/api/design/query/spaces.ts +275 -0
- package/src/api/design/selection/index.ts +273 -0
- package/src/api/design/shared.ts +40 -0
- package/src/api/design/transform/index.ts +254 -0
- package/src/api/design/types/index.ts +156 -0
- package/src/api/design/update/index.ts +798 -0
- package/src/api/design/visibility.ts +143 -0
- package/src/api/design/windows/index.ts +333 -0
- package/src/api/entity/buildableEnvelope.ts +322 -0
- package/src/api/entity/department.ts +0 -0
- package/src/api/entity/index.ts +30 -0
- package/src/api/entity/referenceLine.ts +235 -0
- package/src/api/entity/space.ts +612 -0
- package/src/api/entity/story.ts +517 -0
- package/src/api/index.ts +47 -0
- package/src/api/presentation/aiInspiration.ts +1116 -0
- package/src/api/presentation/annotate.ts +417 -0
- package/src/api/presentation/diagrams.ts +194 -0
- package/src/api/presentation/drawings.ts +529 -0
- package/src/api/presentation/export.ts +133 -0
- package/src/api/presentation/import.ts +159 -0
- package/src/api/presentation/index.ts +129 -0
- package/src/api/presentation/placedViews.ts +1203 -0
- package/src/api/presentation/shapes.ts +274 -0
- package/src/api/presentation/sheets.ts +616 -0
- package/src/api/presentation/slideshow.ts +134 -0
- package/src/api/presentation/tables.ts +84 -0
- package/src/api/presentation/viewPresets.ts +83 -0
- package/src/api/presentation/views.ts +698 -0
- package/src/api/program/adjacency.ts +164 -0
- package/src/api/program/areas.ts +408 -0
- package/src/api/program/classification.ts +138 -0
- package/src/api/program/cores.ts +83 -0
- package/src/api/program/departments.ts +517 -0
- package/src/api/program/index.ts +73 -0
- package/src/api/program/labels.ts +332 -0
- package/src/api/program/layout.ts +422 -0
- package/src/api/program/metadata.ts +364 -0
- package/src/api/program/metrics.ts +120 -0
- package/src/api/program/site.ts +748 -0
- package/src/api/program/spreadsheet.ts +2698 -0
- package/src/api/workspace/index.ts +612 -0
- package/src/errors/codes.ts +136 -0
- package/src/errors/envelope.ts +75 -0
- package/src/errors/index.ts +21 -0
- package/src/errors/plugin-error.ts +134 -0
- package/src/handles.ts +282 -0
- package/src/host-utils.ts +68 -0
- package/src/index.ts +5 -0
- package/src/types.ts +16 -0
- package/test/errors.test.mjs +184 -0
- package/tsconfig.json +22 -0
- package/tsup.config.ts +12 -0
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The closed error-code registry — the single source of truth for every error
|
|
3
|
+
* that crosses the plugin wire (host → worker) or is minted client-side.
|
|
4
|
+
*
|
|
5
|
+
* APPEND-ONLY: codes are a published contract; never rename or remove one.
|
|
6
|
+
* Handle-resolution failures deliberately collapse to ONE code
|
|
7
|
+
* (`HANDLE_INVALID`) so error responses cannot be used as an existence /
|
|
8
|
+
* ownership oracle (PLUGIN_HANDLE_MIGRATION_HLD §6). `HANDLE_KIND_MISMATCH`
|
|
9
|
+
* stays distinct because the kind is information the caller already holds.
|
|
10
|
+
*/
|
|
11
|
+
export const PLUGIN_ERROR_CODES = [
|
|
12
|
+
"VALIDATION",
|
|
13
|
+
"INVALID_RPC_FORMAT",
|
|
14
|
+
"METHOD_NOT_FOUND",
|
|
15
|
+
"METHOD_NOT_PERMITTED",
|
|
16
|
+
"HANDLE_INVALID",
|
|
17
|
+
"HANDLE_KIND_MISMATCH",
|
|
18
|
+
"RESOURCE_QUOTA_EXCEEDED",
|
|
19
|
+
"RATE_LIMITED",
|
|
20
|
+
"PRECONDITION_FAILED",
|
|
21
|
+
"OPERATION_FAILED",
|
|
22
|
+
"TIMEOUT",
|
|
23
|
+
"CALL_TIMEOUT",
|
|
24
|
+
"TRANSPORT_LOST",
|
|
25
|
+
"PLUGIN_NOT_READY",
|
|
26
|
+
"PLUGIN_TERMINATED",
|
|
27
|
+
"RESULT_NOT_SERIALIZABLE",
|
|
28
|
+
"RESULT_TOO_LARGE",
|
|
29
|
+
"BATCH_PARTIAL",
|
|
30
|
+
"STORY_UPDATE_FAILED",
|
|
31
|
+
"STORY_HEIGHT_REJECTED",
|
|
32
|
+
"NO_ACTIVE_STRUCTURE",
|
|
33
|
+
"NO_ELIGIBLE_ELEMENTS",
|
|
34
|
+
"PROPOSAL_SWITCH_BLOCKED",
|
|
35
|
+
"INTERNAL",
|
|
36
|
+
"UNKNOWN",
|
|
37
|
+
] as const
|
|
38
|
+
|
|
39
|
+
export type PluginErrorCode = (typeof PLUGIN_ERROR_CODES)[number]
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* A known code, or a string outside the union — a plugin built against an
|
|
43
|
+
* older SDK may receive codes a newer host appended. Keeps autocomplete for
|
|
44
|
+
* known codes while staying open on the wire (forward compatibility).
|
|
45
|
+
*/
|
|
46
|
+
export type WirePluginErrorCode = PluginErrorCode | (string & {})
|
|
47
|
+
|
|
48
|
+
export type PluginErrorCategory =
|
|
49
|
+
| "validation"
|
|
50
|
+
| "not_found"
|
|
51
|
+
| "permission"
|
|
52
|
+
| "handle"
|
|
53
|
+
| "quota"
|
|
54
|
+
| "timeout"
|
|
55
|
+
| "transport"
|
|
56
|
+
| "lifecycle"
|
|
57
|
+
| "execution"
|
|
58
|
+
| "internal"
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Client-side metadata for a code. NOT carried on the wire — every field is a
|
|
62
|
+
* pure function of the code, and this table ships inside plugin-core, so both
|
|
63
|
+
* endpoints derive it locally.
|
|
64
|
+
*/
|
|
65
|
+
export interface CodeMeta {
|
|
66
|
+
/** Family of the code; picks the `PluginError` sugar subclass. */
|
|
67
|
+
category: PluginErrorCategory
|
|
68
|
+
/** Fallback `hint` when the throw site provides none. */
|
|
69
|
+
hintTemplate?: string
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
export const CODE_META: Record<PluginErrorCode, CodeMeta> = {
|
|
73
|
+
VALIDATION: {
|
|
74
|
+
category: "validation",
|
|
75
|
+
hintTemplate: "Check details.issues for the failing argument.",
|
|
76
|
+
},
|
|
77
|
+
INVALID_RPC_FORMAT: { category: "validation" },
|
|
78
|
+
METHOD_NOT_FOUND: {
|
|
79
|
+
category: "not_found",
|
|
80
|
+
hintTemplate: "Check details.didYouMean for a close match.",
|
|
81
|
+
},
|
|
82
|
+
METHOD_NOT_PERMITTED: { category: "permission" },
|
|
83
|
+
HANDLE_INVALID: {
|
|
84
|
+
category: "handle",
|
|
85
|
+
hintTemplate: "Re-query the entity; do not cache handles across undo/reload.",
|
|
86
|
+
},
|
|
87
|
+
HANDLE_KIND_MISMATCH: { category: "handle" },
|
|
88
|
+
RESOURCE_QUOTA_EXCEEDED: {
|
|
89
|
+
category: "quota",
|
|
90
|
+
hintTemplate: "Release unused handles (core.handles.release) or use scopes.",
|
|
91
|
+
},
|
|
92
|
+
RATE_LIMITED: {
|
|
93
|
+
category: "quota",
|
|
94
|
+
hintTemplate: "Wait details.retryAfterMs before retrying.",
|
|
95
|
+
},
|
|
96
|
+
PRECONDITION_FAILED: { category: "execution" },
|
|
97
|
+
OPERATION_FAILED: { category: "execution" },
|
|
98
|
+
TIMEOUT: { category: "timeout" },
|
|
99
|
+
CALL_TIMEOUT: { category: "timeout" },
|
|
100
|
+
TRANSPORT_LOST: { category: "transport" },
|
|
101
|
+
PLUGIN_NOT_READY: { category: "lifecycle" },
|
|
102
|
+
PLUGIN_TERMINATED: { category: "lifecycle" },
|
|
103
|
+
RESULT_NOT_SERIALIZABLE: { category: "execution" },
|
|
104
|
+
RESULT_TOO_LARGE: { category: "execution" },
|
|
105
|
+
BATCH_PARTIAL: { category: "execution" },
|
|
106
|
+
STORY_UPDATE_FAILED: {
|
|
107
|
+
category: "execution",
|
|
108
|
+
hintTemplate: "The storey update could not be applied; re-read the storey and retry.",
|
|
109
|
+
},
|
|
110
|
+
STORY_HEIGHT_REJECTED: {
|
|
111
|
+
category: "execution",
|
|
112
|
+
hintTemplate: "The requested height was out of range; pick a value within the storey's limits.",
|
|
113
|
+
},
|
|
114
|
+
NO_ACTIVE_STRUCTURE: {
|
|
115
|
+
category: "execution",
|
|
116
|
+
hintTemplate: "Activate a structure before running this operation.",
|
|
117
|
+
},
|
|
118
|
+
NO_ELIGIBLE_ELEMENTS: {
|
|
119
|
+
category: "execution",
|
|
120
|
+
hintTemplate: "The storey has no elements eligible for this operation.",
|
|
121
|
+
},
|
|
122
|
+
PROPOSAL_SWITCH_BLOCKED: {
|
|
123
|
+
category: "execution",
|
|
124
|
+
hintTemplate: "Wait for the in-canvas agent run to finish, then retry.",
|
|
125
|
+
},
|
|
126
|
+
INTERNAL: {
|
|
127
|
+
category: "internal",
|
|
128
|
+
hintTemplate: "Host-side fault. Report with errorId.",
|
|
129
|
+
},
|
|
130
|
+
UNKNOWN: { category: "internal" },
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
/** Narrow an arbitrary string to a member of the closed code union. */
|
|
134
|
+
export function isPluginErrorCode(value: string): value is PluginErrorCode {
|
|
135
|
+
return (PLUGIN_ERROR_CODES as readonly string[]).includes(value)
|
|
136
|
+
}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import type { WirePluginErrorCode } from "./codes"
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Structured error payload carried on the `{success: false}` branch of the RPC
|
|
5
|
+
* wire result, next to the legacy `error: string` field (additive — old
|
|
6
|
+
* clients ignore it, old hosts never set it).
|
|
7
|
+
*
|
|
8
|
+
* Errors cross the worker boundary as THIS plain object, never as a thrown
|
|
9
|
+
* class: Comlink's throw transfer strips subclasses and custom fields and
|
|
10
|
+
* leaks host stacks. plugin-client reconstructs a typed `PluginError` from it
|
|
11
|
+
* (`fromEnvelope`).
|
|
12
|
+
*/
|
|
13
|
+
export const ERROR_ENVELOPE_VERSION = 1 as const
|
|
14
|
+
|
|
15
|
+
export interface ErrorEnvelope {
|
|
16
|
+
envelopeVersion: typeof ERROR_ENVELOPE_VERSION
|
|
17
|
+
code: WirePluginErrorCode
|
|
18
|
+
/**
|
|
19
|
+
* Human-readable failure description. For INTERNAL/UNKNOWN this is a GENERIC
|
|
20
|
+
* message — the real message and stack stay host-side, logged under
|
|
21
|
+
* `errorId` (the worker is untrusted; internals must not leak).
|
|
22
|
+
*/
|
|
23
|
+
message: string
|
|
24
|
+
/**
|
|
25
|
+
* Per-occurrence id. For INTERNAL the host logs the real message and stack
|
|
26
|
+
* under this id (the sanitized message would otherwise be an undebuggable
|
|
27
|
+
* dead end). Other codes carry the id only to identify the occurrence in
|
|
28
|
+
* bug reports — the host does not log them. Client-minted ids carry a `c-`
|
|
29
|
+
* prefix.
|
|
30
|
+
*/
|
|
31
|
+
errorId: string
|
|
32
|
+
/** Structured, JSON-safe, code-specific data (issues / retryAfterMs / didYouMean / handles…). */
|
|
33
|
+
details?: Record<string, unknown>
|
|
34
|
+
/**
|
|
35
|
+
* Wire id of the single primary offending handle, when the failure is
|
|
36
|
+
* handle-scoped. Multiple offenders go in `details.handles: string[]`.
|
|
37
|
+
* May echo ONLY ids the caller itself supplied (anti-oracle rule).
|
|
38
|
+
*/
|
|
39
|
+
handle?: string
|
|
40
|
+
/** Dotted method path of the failed call (e.g. "design.boolean.union"). */
|
|
41
|
+
methodPath?: string
|
|
42
|
+
/** Machine-actionable fix suggestion (written for LLM plugin authors). */
|
|
43
|
+
hint?: string
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Structural guard for a wire value claiming to be an `ErrorEnvelope`.
|
|
48
|
+
*
|
|
49
|
+
* Checks shape only — deliberately does NOT reject codes outside the known
|
|
50
|
+
* union, so envelopes from a newer host still pass (forward compatibility).
|
|
51
|
+
*/
|
|
52
|
+
export function isErrorEnvelope(value: unknown): value is ErrorEnvelope {
|
|
53
|
+
if (typeof value !== "object" || value === null) return false
|
|
54
|
+
const record = value as Record<string, unknown>
|
|
55
|
+
return (
|
|
56
|
+
record.envelopeVersion === ERROR_ENVELOPE_VERSION &&
|
|
57
|
+
typeof record.code === "string" &&
|
|
58
|
+
typeof record.message === "string" &&
|
|
59
|
+
typeof record.errorId === "string"
|
|
60
|
+
)
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
let idCounter = 0
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Mint a per-occurrence error id. Uses `crypto.randomUUID` when available
|
|
67
|
+
* (browser main thread and workers both have it); falls back to a
|
|
68
|
+
* counter+random suffix — uniqueness within a session is all that is needed.
|
|
69
|
+
*/
|
|
70
|
+
export function newErrorId(prefix = ""): string {
|
|
71
|
+
const cryptoApi = (globalThis as { crypto?: { randomUUID?: () => string } }).crypto
|
|
72
|
+
if (cryptoApi?.randomUUID) return `${prefix}${cryptoApi.randomUUID()}`
|
|
73
|
+
idCounter += 1
|
|
74
|
+
return `${prefix}${Date.now().toString(36)}-${idCounter}-${Math.random().toString(36).slice(2, 10)}`
|
|
75
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export { PLUGIN_ERROR_CODES, CODE_META, isPluginErrorCode } from "./codes"
|
|
2
|
+
export type { PluginErrorCode, WirePluginErrorCode, PluginErrorCategory, CodeMeta } from "./codes"
|
|
3
|
+
|
|
4
|
+
export { ERROR_ENVELOPE_VERSION, isErrorEnvelope, newErrorId } from "./envelope"
|
|
5
|
+
export type { ErrorEnvelope } from "./envelope"
|
|
6
|
+
|
|
7
|
+
export {
|
|
8
|
+
PluginError,
|
|
9
|
+
PluginValidationError,
|
|
10
|
+
PluginNotFoundError,
|
|
11
|
+
PluginPermissionError,
|
|
12
|
+
PluginHandleError,
|
|
13
|
+
PluginQuotaError,
|
|
14
|
+
PluginTimeoutError,
|
|
15
|
+
PluginTransportError,
|
|
16
|
+
PluginLifecycleError,
|
|
17
|
+
PluginExecutionError,
|
|
18
|
+
PluginInternalError,
|
|
19
|
+
fromEnvelope,
|
|
20
|
+
makeClientEnvelope,
|
|
21
|
+
} from "./plugin-error"
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import { CODE_META, isPluginErrorCode } from "./codes"
|
|
2
|
+
import type { PluginErrorCategory, PluginErrorCode, WirePluginErrorCode } from "./codes"
|
|
3
|
+
import { ERROR_ENVELOPE_VERSION, newErrorId } from "./envelope"
|
|
4
|
+
import type { ErrorEnvelope } from "./envelope"
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Cross-copy brand: a plugin bundle may contain its OWN copy of this module,
|
|
8
|
+
* in which case `instanceof` fails across the two class identities.
|
|
9
|
+
* `Symbol.for` resolves to the same symbol in every copy within a realm, so
|
|
10
|
+
* `PluginError.is()` keeps working. Canonical check = `.is()` + `code`.
|
|
11
|
+
*/
|
|
12
|
+
const BRAND = Symbol.for("snaptrude.pluginError")
|
|
13
|
+
|
|
14
|
+
interface Branded {
|
|
15
|
+
[BRAND]?: boolean
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Typed error every failed plugin API call rejects with.
|
|
20
|
+
*
|
|
21
|
+
* Rehydrated client-side from the wire `ErrorEnvelope` (`fromEnvelope`) — the
|
|
22
|
+
* class itself never crosses the worker boundary. Branch on the stable string
|
|
23
|
+
* `code`; use `PluginError.is()` rather than `instanceof` (a bundled duplicate
|
|
24
|
+
* SDK copy breaks `instanceof`, never the brand).
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* ```ts
|
|
28
|
+
* try {
|
|
29
|
+
* await snaptrude.design.boolean.union(handles)
|
|
30
|
+
* } catch (e) {
|
|
31
|
+
* if (PluginError.is(e) && e.code === "RATE_LIMITED") {
|
|
32
|
+
* await sleep(e.details?.retryAfterMs as number)
|
|
33
|
+
* } else {
|
|
34
|
+
* throw e
|
|
35
|
+
* }
|
|
36
|
+
* }
|
|
37
|
+
* ```
|
|
38
|
+
*/
|
|
39
|
+
export class PluginError extends Error {
|
|
40
|
+
readonly code: WirePluginErrorCode
|
|
41
|
+
readonly errorId: string
|
|
42
|
+
readonly details?: Record<string, unknown>
|
|
43
|
+
readonly handle?: string
|
|
44
|
+
readonly methodPath?: string
|
|
45
|
+
readonly hint?: string
|
|
46
|
+
|
|
47
|
+
constructor(envelope: ErrorEnvelope) {
|
|
48
|
+
super(envelope.message)
|
|
49
|
+
this.name = new.target.name
|
|
50
|
+
this.code = envelope.code
|
|
51
|
+
this.errorId = envelope.errorId
|
|
52
|
+
this.details = envelope.details
|
|
53
|
+
this.handle = envelope.handle
|
|
54
|
+
this.methodPath = envelope.methodPath
|
|
55
|
+
this.hint = envelope.hint ?? hintFor(envelope.code)
|
|
56
|
+
;(this as Branded)[BRAND] = true
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/** Canonical check — survives bundled duplicate SDK copies where `instanceof` fails. */
|
|
60
|
+
static is(value: unknown): value is PluginError {
|
|
61
|
+
return (
|
|
62
|
+
typeof value === "object" &&
|
|
63
|
+
value !== null &&
|
|
64
|
+
(value as Branded)[BRAND] === true
|
|
65
|
+
)
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/** Derived (not wire-carried) family of the code; unknown codes map to "internal". */
|
|
69
|
+
get category(): PluginErrorCategory {
|
|
70
|
+
return isPluginErrorCode(this.code) ? CODE_META[this.code].category : "internal"
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
// Category sugar — same brand, so `PluginError.is()` matches all of them.
|
|
75
|
+
// Convenience for single-SDK-copy plugins; docs teach `.is()` + `code`.
|
|
76
|
+
export class PluginValidationError extends PluginError {}
|
|
77
|
+
export class PluginNotFoundError extends PluginError {}
|
|
78
|
+
export class PluginPermissionError extends PluginError {}
|
|
79
|
+
export class PluginHandleError extends PluginError {}
|
|
80
|
+
export class PluginQuotaError extends PluginError {}
|
|
81
|
+
export class PluginTimeoutError extends PluginError {}
|
|
82
|
+
export class PluginTransportError extends PluginError {}
|
|
83
|
+
export class PluginLifecycleError extends PluginError {}
|
|
84
|
+
export class PluginExecutionError extends PluginError {}
|
|
85
|
+
export class PluginInternalError extends PluginError {}
|
|
86
|
+
|
|
87
|
+
type PluginErrorConstructor = new (envelope: ErrorEnvelope) => PluginError
|
|
88
|
+
|
|
89
|
+
const CATEGORY_CLASS: Record<PluginErrorCategory, PluginErrorConstructor> = {
|
|
90
|
+
validation: PluginValidationError,
|
|
91
|
+
not_found: PluginNotFoundError,
|
|
92
|
+
permission: PluginPermissionError,
|
|
93
|
+
handle: PluginHandleError,
|
|
94
|
+
quota: PluginQuotaError,
|
|
95
|
+
timeout: PluginTimeoutError,
|
|
96
|
+
transport: PluginTransportError,
|
|
97
|
+
lifecycle: PluginLifecycleError,
|
|
98
|
+
execution: PluginExecutionError,
|
|
99
|
+
internal: PluginInternalError,
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
function hintFor(code: WirePluginErrorCode): string | undefined {
|
|
103
|
+
return isPluginErrorCode(code) ? CODE_META[code].hintTemplate : undefined
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* Rehydrate a wire envelope into the typed error the plugin catches.
|
|
108
|
+
* A code outside the known union (newer host) constructs the base
|
|
109
|
+
* `PluginError` with the code preserved verbatim.
|
|
110
|
+
*/
|
|
111
|
+
export function fromEnvelope(envelope: ErrorEnvelope): PluginError {
|
|
112
|
+
if (!isPluginErrorCode(envelope.code)) return new PluginError(envelope)
|
|
113
|
+
const ErrorClass = CATEGORY_CLASS[CODE_META[envelope.code].category]
|
|
114
|
+
return new ErrorClass(envelope)
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* Build an envelope for a CLIENT-detected failure (transport rejection,
|
|
119
|
+
* legacy host without `errorInfo`). Host-originated envelopes are built by
|
|
120
|
+
* the host's `toErrorEnvelope` mapper, never by this.
|
|
121
|
+
*/
|
|
122
|
+
export function makeClientEnvelope(
|
|
123
|
+
code: PluginErrorCode,
|
|
124
|
+
message: string,
|
|
125
|
+
extra?: Partial<Pick<ErrorEnvelope, "details" | "handle" | "methodPath" | "hint">>
|
|
126
|
+
): ErrorEnvelope {
|
|
127
|
+
return {
|
|
128
|
+
envelopeVersion: ERROR_ENVELOPE_VERSION,
|
|
129
|
+
code,
|
|
130
|
+
message,
|
|
131
|
+
errorId: newErrorId("c-"),
|
|
132
|
+
...extra,
|
|
133
|
+
}
|
|
134
|
+
}
|
package/src/handles.ts
ADDED
|
@@ -0,0 +1,282 @@
|
|
|
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
|
+
/** A curve is a line or an arc — its handle is one of those kinds. */
|
|
149
|
+
export type CurveHandle = LineHandle | ArcHandle
|
|
150
|
+
/**
|
|
151
|
+
* A circle value handle. A circle is a CLOSED curve — it deliberately does NOT
|
|
152
|
+
* join {@linkcode CurveHandle} (it has no stable start/end and would break the
|
|
153
|
+
* shared curve read contract), so it carries its own kind and its own
|
|
154
|
+
* `core.geom.query.circle` namespace (mirroring `query.arc`).
|
|
155
|
+
*/
|
|
156
|
+
export type CircleHandle = Handle<"circle">
|
|
157
|
+
|
|
158
|
+
// ── BREP topology handles (geometry-kernel resource family, §2A.2.1) ─────────
|
|
159
|
+
// Session-ephemeral, identity-deduped RESOURCE handles for the boundary-
|
|
160
|
+
// representation topology graph. Read-only via `core.geom.query.{brep,face,edge,
|
|
161
|
+
// halfedge,vertex}`; they go stale on undo/redo/re-topologize. Obtain a brep via
|
|
162
|
+
// `design.query.geometry.getBrep`; every other topology handle is minted by
|
|
163
|
+
// walking from a brep/face/edge/vertex handle already resolved off that brep.
|
|
164
|
+
export type BrepHandle = Handle<"brep">
|
|
165
|
+
export type FaceHandle = Handle<"face">
|
|
166
|
+
export type EdgeHandle = Handle<"edge">
|
|
167
|
+
/** Half-edge kind token is all-lowercase `"halfedge"` per §6.1 (no camelCase namespaces). */
|
|
168
|
+
export type HalfEdgeHandle = Handle<"halfedge">
|
|
169
|
+
export type VertexHandle = Handle<"vertex">
|
|
170
|
+
|
|
171
|
+
/**
|
|
172
|
+
* Bare primitive records — how value-handle reads return their components
|
|
173
|
+
* (§11.4). Curves have **no** by-value record: a curve crosses the boundary as a
|
|
174
|
+
* {@linkcode CurveHandle} (line/arc), and its coordinates are read via the
|
|
175
|
+
* `core.geom.query.curve` API. There is no `CurveData` under the all-handle model.
|
|
176
|
+
*/
|
|
177
|
+
export type Vec3Components = { x: number; y: number; z: number }
|
|
178
|
+
export type QuatComponents = { x: number; y: number; z: number; w: number }
|
|
179
|
+
/** Axis-aligned bounding box, read as two primitive corner records. */
|
|
180
|
+
export type BBoxComponents = { min: Vec3Components; max: Vec3Components }
|
|
181
|
+
|
|
182
|
+
/**
|
|
183
|
+
* Build a Zod schema validating a handle of the given `kind` at the trust
|
|
184
|
+
* boundary and emitting a {@linkcode Handle} instance for impl code. Inbound
|
|
185
|
+
* forms accepted:
|
|
186
|
+
* - the bare id string (the wire form — the client unwraps args to ids)
|
|
187
|
+
* - a live `Handle` instance (host-internal re-parse, direct host callers)
|
|
188
|
+
* - `{ __h: string }` (the tagged result form, echoed back as an arg)
|
|
189
|
+
* - `{ id: string }` (a Handle stripped by structured clone at the UI boundary)
|
|
190
|
+
* Shape checking stays prefix-only; existence, kind, and ownership are enforced
|
|
191
|
+
* host-side by the HandleRegistry (§9.7) — no existence oracle.
|
|
192
|
+
*/
|
|
193
|
+
export const handleSchema = <K extends string>(kind: K) =>
|
|
194
|
+
z
|
|
195
|
+
.preprocess(
|
|
196
|
+
(v) => {
|
|
197
|
+
if (typeof v === "string") return v
|
|
198
|
+
if (v instanceof Handle) return v.id
|
|
199
|
+
if (v && typeof v === "object") {
|
|
200
|
+
const o = v as Record<string, unknown>
|
|
201
|
+
if (typeof o.__h === "string") return o.__h
|
|
202
|
+
if (typeof o.id === "string") return o.id
|
|
203
|
+
}
|
|
204
|
+
return v
|
|
205
|
+
},
|
|
206
|
+
z.string().regex(new RegExp(`^${kind}_[A-Za-z0-9_-]+$`), `expected a "${kind}" handle`)
|
|
207
|
+
)
|
|
208
|
+
.transform((s) => new Handle<K>(s))
|
|
209
|
+
|
|
210
|
+
export const ProfileHandle = handleSchema("profile")
|
|
211
|
+
export const ContourHandle = handleSchema("contour")
|
|
212
|
+
|
|
213
|
+
/**
|
|
214
|
+
* Entity handles are raw `Component.id` strings (no `"<kind>_"` prefix) — validated
|
|
215
|
+
* only as a non-empty string, resolved live via the scene index host-side.
|
|
216
|
+
*/
|
|
217
|
+
export const ComponentHandle = z
|
|
218
|
+
.string()
|
|
219
|
+
.min(1)
|
|
220
|
+
.transform((s) => s as ComponentHandle)
|
|
221
|
+
|
|
222
|
+
/**
|
|
223
|
+
* Material handles are the raw `Material.name` string (entity-style, no `"<kind>_"`
|
|
224
|
+
* prefix) — validated only as non-empty, resolved live via `scene.getMaterialByName`.
|
|
225
|
+
*/
|
|
226
|
+
export const MaterialHandle = z
|
|
227
|
+
.string()
|
|
228
|
+
.min(1)
|
|
229
|
+
.transform((s) => s as MaterialHandle)
|
|
230
|
+
|
|
231
|
+
/**
|
|
232
|
+
* {@linkcode UnderlayHandle} / {@linkcode TerrainHandle} / {@linkcode ImportJobHandle}
|
|
233
|
+
* are entity-style handles — raw host ids, validated only as a non-empty string
|
|
234
|
+
* (no `"<kind>_"` prefix), resolved live host-side (existence enforced there).
|
|
235
|
+
*/
|
|
236
|
+
export const UnderlayHandle = z
|
|
237
|
+
.string()
|
|
238
|
+
.min(1)
|
|
239
|
+
.transform((s) => s as UnderlayHandle)
|
|
240
|
+
export const TerrainHandle = z
|
|
241
|
+
.string()
|
|
242
|
+
.min(1)
|
|
243
|
+
.transform((s) => s as TerrainHandle)
|
|
244
|
+
export const ImportJobHandle = z
|
|
245
|
+
.string()
|
|
246
|
+
.min(1)
|
|
247
|
+
.transform((s) => s as ImportJobHandle)
|
|
248
|
+
|
|
249
|
+
/**
|
|
250
|
+
* {@linkcode DimensionHandle} is an entity-style handle — the raw `dim_…` engine
|
|
251
|
+
* id, validated only as a non-empty string (no `"<kind>_"` prefix enforcement),
|
|
252
|
+
* resolved live host-side against the dimension-line registry (existence
|
|
253
|
+
* enforced there, as `HANDLE_INVALID`).
|
|
254
|
+
*/
|
|
255
|
+
export const DimensionHandle = z
|
|
256
|
+
.string()
|
|
257
|
+
.min(1)
|
|
258
|
+
.transform((s) => s as DimensionHandle)
|
|
259
|
+
|
|
260
|
+
// Value-kind handle schemas (all-handle model, §11).
|
|
261
|
+
export const Vec3Handle = handleSchema("vec3")
|
|
262
|
+
export const QuatHandle = handleSchema("quat")
|
|
263
|
+
export const LineHandle = handleSchema("line")
|
|
264
|
+
export const ArcHandle = handleSchema("arc")
|
|
265
|
+
export const CurveHandle = z.union([LineHandle, ArcHandle])
|
|
266
|
+
export const CircleHandle = handleSchema("circle")
|
|
267
|
+
|
|
268
|
+
// BREP topology handle schemas (§2A.2.1). Prefix-shape validation only; existence,
|
|
269
|
+
// kind, and ownership are enforced host-side by the HandleRegistry topology arena.
|
|
270
|
+
export const BrepHandle = handleSchema("brep")
|
|
271
|
+
export const FaceHandle = handleSchema("face")
|
|
272
|
+
export const EdgeHandle = handleSchema("edge")
|
|
273
|
+
export const HalfEdgeHandle = handleSchema("halfedge")
|
|
274
|
+
export const VertexHandle = handleSchema("vertex")
|
|
275
|
+
export const Vec3Components = z.object({ x: z.number(), y: z.number(), z: z.number() })
|
|
276
|
+
export const QuatComponents = z.object({
|
|
277
|
+
x: z.number(),
|
|
278
|
+
y: z.number(),
|
|
279
|
+
z: z.number(),
|
|
280
|
+
w: z.number(),
|
|
281
|
+
})
|
|
282
|
+
export const BBoxComponents = z.object({ min: Vec3Components, max: Vec3Components })
|