@snaptrude/plugin-core 0.2.9 → 0.5.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.
Files changed (269) hide show
  1. package/AGENTS.md +128 -50
  2. package/CHANGELOG.md +52 -6
  3. package/api-manifest.full.json +3999 -0
  4. package/api-manifest.json +3845 -0
  5. package/dist/api/core/buildings.d.ts +427 -0
  6. package/dist/api/core/buildings.d.ts.map +1 -0
  7. package/dist/api/core/comment/index.d.ts +230 -0
  8. package/dist/api/core/comment/index.d.ts.map +1 -0
  9. package/dist/api/core/geom/create/index.d.ts +247 -0
  10. package/dist/api/core/geom/create/index.d.ts.map +1 -0
  11. package/dist/api/core/geom/delete/index.d.ts +72 -0
  12. package/dist/api/core/geom/delete/index.d.ts.map +1 -0
  13. package/dist/api/core/geom/index.d.ts +24 -23
  14. package/dist/api/core/geom/index.d.ts.map +1 -1
  15. package/dist/api/core/geom/query/arc.d.ts +169 -0
  16. package/dist/api/core/geom/query/arc.d.ts.map +1 -0
  17. package/dist/api/core/geom/query/brep.d.ts +402 -0
  18. package/dist/api/core/geom/query/brep.d.ts.map +1 -0
  19. package/dist/api/core/geom/query/circle.d.ts +378 -0
  20. package/dist/api/core/geom/query/circle.d.ts.map +1 -0
  21. package/dist/api/core/geom/query/contour.d.ts +450 -0
  22. package/dist/api/core/geom/query/contour.d.ts.map +1 -0
  23. package/dist/api/core/geom/query/curve.d.ts +918 -0
  24. package/dist/api/core/geom/query/curve.d.ts.map +1 -0
  25. package/dist/api/core/geom/query/edge.d.ts +128 -0
  26. package/dist/api/core/geom/query/edge.d.ts.map +1 -0
  27. package/dist/api/core/geom/query/face.d.ts +363 -0
  28. package/dist/api/core/geom/query/face.d.ts.map +1 -0
  29. package/dist/api/core/geom/query/halfedge.d.ts +206 -0
  30. package/dist/api/core/geom/query/halfedge.d.ts.map +1 -0
  31. package/dist/api/core/geom/query/index.d.ts +61 -0
  32. package/dist/api/core/geom/query/index.d.ts.map +1 -0
  33. package/dist/api/core/geom/query/profile.d.ts +410 -0
  34. package/dist/api/core/geom/query/profile.d.ts.map +1 -0
  35. package/dist/api/core/geom/query/vertex.d.ts +187 -0
  36. package/dist/api/core/geom/query/vertex.d.ts.map +1 -0
  37. package/dist/api/core/geom/update/contour.d.ts +272 -0
  38. package/dist/api/core/geom/update/contour.d.ts.map +1 -0
  39. package/dist/api/core/geom/update/curve.d.ts +180 -0
  40. package/dist/api/core/geom/update/curve.d.ts.map +1 -0
  41. package/dist/api/core/geom/update/index.d.ts +27 -0
  42. package/dist/api/core/geom/update/index.d.ts.map +1 -0
  43. package/dist/api/core/geom/update/profile.d.ts +329 -0
  44. package/dist/api/core/geom/update/profile.d.ts.map +1 -0
  45. package/dist/api/core/groups.d.ts +485 -0
  46. package/dist/api/core/groups.d.ts.map +1 -0
  47. package/dist/api/core/history/index.d.ts +78 -0
  48. package/dist/api/core/history/index.d.ts.map +1 -0
  49. package/dist/api/core/index.d.ts +46 -1
  50. package/dist/api/core/index.d.ts.map +1 -1
  51. package/dist/api/core/layers.d.ts +402 -0
  52. package/dist/api/core/layers.d.ts.map +1 -0
  53. package/dist/api/core/math/quat.d.ts +111 -128
  54. package/dist/api/core/math/quat.d.ts.map +1 -1
  55. package/dist/api/core/math/vec3.d.ts +120 -102
  56. package/dist/api/core/math/vec3.d.ts.map +1 -1
  57. package/dist/api/core/project/index.d.ts +399 -0
  58. package/dist/api/core/project/index.d.ts.map +1 -0
  59. package/dist/api/core/tags.d.ts +755 -0
  60. package/dist/api/core/tags.d.ts.map +1 -0
  61. package/dist/api/core/units/index.d.ts +175 -0
  62. package/dist/api/core/units/index.d.ts.map +1 -0
  63. package/dist/api/core/zoom/index.d.ts +45 -0
  64. package/dist/api/core/zoom/index.d.ts.map +1 -0
  65. package/dist/api/design/boolean/index.d.ts +168 -0
  66. package/dist/api/design/boolean/index.d.ts.map +1 -0
  67. package/dist/api/design/create/index.d.ts +828 -0
  68. package/dist/api/design/create/index.d.ts.map +1 -0
  69. package/dist/api/design/delete/index.d.ts +63 -0
  70. package/dist/api/design/delete/index.d.ts.map +1 -0
  71. package/dist/api/design/doors/index.d.ts +268 -0
  72. package/dist/api/design/doors/index.d.ts.map +1 -0
  73. package/dist/api/design/edit/index.d.ts +49 -0
  74. package/dist/api/design/edit/index.d.ts.map +1 -0
  75. package/dist/api/design/erase/index.d.ts +160 -0
  76. package/dist/api/design/erase/index.d.ts.map +1 -0
  77. package/dist/api/design/furniture/index.d.ts +123 -0
  78. package/dist/api/design/furniture/index.d.ts.map +1 -0
  79. package/dist/api/design/index.d.ts +153 -0
  80. package/dist/api/design/index.d.ts.map +1 -0
  81. package/dist/api/design/lock.d.ts +41 -0
  82. package/dist/api/design/lock.d.ts.map +1 -0
  83. package/dist/api/design/materials/index.d.ts +297 -0
  84. package/dist/api/design/materials/index.d.ts.map +1 -0
  85. package/dist/api/design/query/geometry/index.d.ts +140 -0
  86. package/dist/api/design/query/geometry/index.d.ts.map +1 -0
  87. package/dist/api/design/query/index.d.ts +1011 -0
  88. package/dist/api/design/query/index.d.ts.map +1 -0
  89. package/dist/api/design/query/spaces.d.ts +221 -0
  90. package/dist/api/design/query/spaces.d.ts.map +1 -0
  91. package/dist/api/design/selection/index.d.ts +138 -0
  92. package/dist/api/design/selection/index.d.ts.map +1 -0
  93. package/dist/api/design/shared.d.ts +38 -0
  94. package/dist/api/design/shared.d.ts.map +1 -0
  95. package/dist/api/design/transform/index.d.ts +87 -0
  96. package/dist/api/design/transform/index.d.ts.map +1 -0
  97. package/dist/api/design/update/index.d.ts +178 -0
  98. package/dist/api/design/update/index.d.ts.map +1 -0
  99. package/dist/api/design/windows/index.d.ts +189 -0
  100. package/dist/api/design/windows/index.d.ts.map +1 -0
  101. package/dist/api/entity/buildableEnvelope.d.ts +51 -23
  102. package/dist/api/entity/buildableEnvelope.d.ts.map +1 -1
  103. package/dist/api/entity/department.d.ts +0 -98
  104. package/dist/api/entity/department.d.ts.map +1 -1
  105. package/dist/api/entity/index.d.ts +4 -9
  106. package/dist/api/entity/index.d.ts.map +1 -1
  107. package/dist/api/entity/referenceLine.d.ts +49 -106
  108. package/dist/api/entity/referenceLine.d.ts.map +1 -1
  109. package/dist/api/entity/space.d.ts +76 -828
  110. package/dist/api/entity/space.d.ts.map +1 -1
  111. package/dist/api/entity/story.d.ts +47 -37
  112. package/dist/api/entity/story.d.ts.map +1 -1
  113. package/dist/api/index.d.ts +17 -17
  114. package/dist/api/index.d.ts.map +1 -1
  115. package/dist/api/presentation/aiInspiration.d.ts +440 -0
  116. package/dist/api/presentation/aiInspiration.d.ts.map +1 -0
  117. package/dist/api/presentation/diagrams.d.ts +81 -0
  118. package/dist/api/presentation/diagrams.d.ts.map +1 -0
  119. package/dist/api/presentation/import.d.ts +113 -0
  120. package/dist/api/presentation/import.d.ts.map +1 -0
  121. package/dist/api/presentation/index.d.ts +46 -0
  122. package/dist/api/presentation/index.d.ts.map +1 -0
  123. package/dist/api/presentation/sheets.d.ts +176 -0
  124. package/dist/api/presentation/sheets.d.ts.map +1 -0
  125. package/dist/api/presentation/views.d.ts +296 -0
  126. package/dist/api/presentation/views.d.ts.map +1 -0
  127. package/dist/api/program/adjacency.d.ts +155 -0
  128. package/dist/api/program/adjacency.d.ts.map +1 -0
  129. package/dist/api/program/areas.d.ts +360 -0
  130. package/dist/api/program/areas.d.ts.map +1 -0
  131. package/dist/api/program/classification.d.ts +135 -0
  132. package/dist/api/program/classification.d.ts.map +1 -0
  133. package/dist/api/program/cores.d.ts +174 -0
  134. package/dist/api/program/cores.d.ts.map +1 -0
  135. package/dist/api/program/departments.d.ts +431 -0
  136. package/dist/api/program/departments.d.ts.map +1 -0
  137. package/dist/api/program/index.d.ts +69 -0
  138. package/dist/api/program/index.d.ts.map +1 -0
  139. package/dist/api/program/layout.d.ts +63 -0
  140. package/dist/api/program/layout.d.ts.map +1 -0
  141. package/dist/api/program/metrics.d.ts +108 -0
  142. package/dist/api/program/metrics.d.ts.map +1 -0
  143. package/dist/api/program/site.d.ts +367 -0
  144. package/dist/api/program/site.d.ts.map +1 -0
  145. package/dist/api/program/spreadsheet.d.ts +2041 -0
  146. package/dist/api/program/spreadsheet.d.ts.map +1 -0
  147. package/dist/handles.d.ts +138 -0
  148. package/dist/handles.d.ts.map +1 -0
  149. package/dist/host-utils.d.ts +7 -5
  150. package/dist/host-utils.d.ts.map +1 -1
  151. package/dist/index.cjs +3897 -1542
  152. package/dist/index.cjs.map +1 -1
  153. package/dist/index.d.ts +1 -0
  154. package/dist/index.d.ts.map +1 -1
  155. package/dist/index.js +3326 -1462
  156. package/dist/index.js.map +1 -1
  157. package/package.json +6 -2
  158. package/scripts/generate-manifest.mjs +193 -0
  159. package/scripts/generate-manifest.test.mjs +193 -0
  160. package/src/api/core/buildings.ts +485 -0
  161. package/src/api/core/comment/index.ts +258 -0
  162. package/src/api/core/geom/create/index.ts +293 -0
  163. package/src/api/core/geom/delete/index.ts +78 -0
  164. package/src/api/core/geom/index.ts +24 -23
  165. package/src/api/core/geom/query/arc.ts +169 -0
  166. package/src/api/core/geom/query/brep.ts +444 -0
  167. package/src/api/core/geom/query/circle.ts +404 -0
  168. package/src/api/core/geom/query/contour.ts +540 -0
  169. package/src/api/core/geom/query/curve.ts +1078 -0
  170. package/src/api/core/geom/query/edge.ts +130 -0
  171. package/src/api/core/geom/query/face.ts +403 -0
  172. package/src/api/core/geom/query/halfedge.ts +210 -0
  173. package/src/api/core/geom/query/index.ts +63 -0
  174. package/src/api/core/geom/query/profile.ts +473 -0
  175. package/src/api/core/geom/query/vertex.ts +205 -0
  176. package/src/api/core/geom/update/contour.ts +315 -0
  177. package/src/api/core/geom/update/curve.ts +209 -0
  178. package/src/api/core/geom/update/index.ts +29 -0
  179. package/src/api/core/geom/update/profile.ts +377 -0
  180. package/src/api/core/groups.ts +521 -0
  181. package/src/api/core/history/index.ts +84 -0
  182. package/src/api/core/index.ts +46 -1
  183. package/src/api/core/layers.ts +333 -0
  184. package/src/api/core/math/quat.ts +112 -235
  185. package/src/api/core/math/vec3.ts +124 -159
  186. package/src/api/core/project/index.ts +418 -0
  187. package/src/api/core/tags.ts +808 -0
  188. package/src/api/core/units/index.ts +164 -0
  189. package/src/api/core/zoom/index.ts +47 -0
  190. package/src/api/design/boolean/index.ts +179 -0
  191. package/src/api/design/create/index.ts +886 -0
  192. package/src/api/design/delete/index.ts +67 -0
  193. package/src/api/design/doors/index.ts +285 -0
  194. package/src/api/design/edit/index.ts +54 -0
  195. package/src/api/design/erase/index.ts +151 -0
  196. package/src/api/design/furniture/index.ts +130 -0
  197. package/src/api/design/index.ts +162 -0
  198. package/src/api/design/lock.ts +42 -0
  199. package/src/api/design/materials/index.ts +301 -0
  200. package/src/api/design/query/geometry/index.ts +166 -0
  201. package/src/api/design/query/index.ts +937 -0
  202. package/src/api/design/query/spaces.ts +132 -0
  203. package/src/api/design/selection/index.ts +144 -0
  204. package/src/api/design/shared.ts +40 -0
  205. package/src/api/design/transform/index.ts +93 -0
  206. package/src/api/design/update/index.ts +117 -0
  207. package/src/api/design/windows/index.ts +207 -0
  208. package/src/api/entity/buildableEnvelope.ts +64 -23
  209. package/src/api/entity/department.ts +0 -113
  210. package/src/api/entity/index.ts +4 -9
  211. package/src/api/entity/referenceLine.ts +50 -38
  212. package/src/api/entity/space.ts +84 -440
  213. package/src/api/entity/story.ts +53 -42
  214. package/src/api/index.ts +17 -17
  215. package/src/api/presentation/aiInspiration.ts +362 -0
  216. package/src/api/presentation/diagrams.ts +84 -0
  217. package/src/api/presentation/import.ts +112 -0
  218. package/src/api/presentation/index.ts +48 -0
  219. package/src/api/presentation/sheets.ts +198 -0
  220. package/src/api/presentation/views.ts +303 -0
  221. package/src/api/program/adjacency.ts +164 -0
  222. package/src/api/program/areas.ts +335 -0
  223. package/src/api/program/classification.ts +138 -0
  224. package/src/api/program/cores.ts +171 -0
  225. package/src/api/program/departments.ts +465 -0
  226. package/src/api/program/index.ts +71 -0
  227. package/src/api/program/layout.ts +68 -0
  228. package/src/api/program/metrics.ts +120 -0
  229. package/src/api/program/site.ts +326 -0
  230. package/src/api/program/spreadsheet.ts +2075 -0
  231. package/src/handles.ts +148 -0
  232. package/src/host-utils.ts +10 -6
  233. package/src/index.ts +1 -0
  234. package/dist/api/core/geom/arc.d.ts +0 -81
  235. package/dist/api/core/geom/arc.d.ts.map +0 -1
  236. package/dist/api/core/geom/curve.d.ts +0 -70
  237. package/dist/api/core/geom/curve.d.ts.map +0 -1
  238. package/dist/api/core/geom/line.d.ts +0 -56
  239. package/dist/api/core/geom/line.d.ts.map +0 -1
  240. package/dist/api/core/geom/profile.d.ts +0 -121
  241. package/dist/api/core/geom/profile.d.ts.map +0 -1
  242. package/dist/api/documentation/aiInspiration.d.ts +0 -2155
  243. package/dist/api/documentation/aiInspiration.d.ts.map +0 -1
  244. package/dist/api/documentation/index.d.ts +0 -13
  245. package/dist/api/documentation/index.d.ts.map +0 -1
  246. package/dist/api/tools/copy.d.ts +0 -59
  247. package/dist/api/tools/copy.d.ts.map +0 -1
  248. package/dist/api/tools/index.d.ts +0 -29
  249. package/dist/api/tools/index.d.ts.map +0 -1
  250. package/dist/api/tools/offset.d.ts +0 -43
  251. package/dist/api/tools/offset.d.ts.map +0 -1
  252. package/dist/api/tools/selection.d.ts +0 -48
  253. package/dist/api/tools/selection.d.ts.map +0 -1
  254. package/dist/api/tools/transform.d.ts +0 -114
  255. package/dist/api/tools/transform.d.ts.map +0 -1
  256. package/dist/api/units/index.d.ts +0 -163
  257. package/dist/api/units/index.d.ts.map +0 -1
  258. package/src/api/core/geom/arc.ts +0 -70
  259. package/src/api/core/geom/curve.ts +0 -41
  260. package/src/api/core/geom/line.ts +0 -53
  261. package/src/api/core/geom/profile.ts +0 -94
  262. package/src/api/documentation/aiInspiration.ts +0 -871
  263. package/src/api/documentation/index.ts +0 -15
  264. package/src/api/tools/copy.ts +0 -55
  265. package/src/api/tools/index.ts +0 -35
  266. package/src/api/tools/offset.ts +0 -43
  267. package/src/api/tools/selection.ts +0 -51
  268. package/src/api/tools/transform.ts +0 -117
  269. package/src/api/units/index.ts +0 -163
package/src/handles.ts ADDED
@@ -0,0 +1,148 @@
1
+ import * as z from "zod"
2
+
3
+ /**
4
+ * An opaque, kind-tagged reference to a host-side object that crosses the RPC
5
+ * boundary by IDENTITY rather than by value. See `PLUGIN_API_EXPOSURE_HLD.md` §9.
6
+ *
7
+ * The phantom `__handle` brand makes a `Handle<"profile">` incompatible with a
8
+ * `Handle<"mass">` at compile time. At runtime a handle is just a string of the
9
+ * form `"<kind>_<token>"` (e.g. `"profile_k3f9a2x"`), so it is structured-clone
10
+ * safe and engine-free — plugin-core never imports the engine type it points at.
11
+ */
12
+ export type Handle<K extends string> = string & { readonly __handle: K }
13
+
14
+ /**
15
+ * A scene-entity handle. Backed by the host `Component.id` and resolved live via
16
+ * the host scene index (StructureCollection) — never stored in the resource
17
+ * registry. Stable across undo/redo and persistable across sessions (§9.2).
18
+ */
19
+ export type EntityId<K extends string = string> = Handle<K>
20
+
21
+ /** Resource handle: a host-resident, session-ephemeral geometry object (§9.2). */
22
+ export type ProfileHandle = Handle<"profile">
23
+
24
+ /** Resource handle: a host-resident contour (outer profile + hole profiles). */
25
+ export type ContourHandle = Handle<"contour">
26
+
27
+ /** Entity-handle example: a Mass / space scene object (Component.id). */
28
+ export type MassHandle = EntityId<"mass">
29
+
30
+ /**
31
+ * A scene BIM entity (wall, space, slab, floor, …). Backed by `Component.id` and
32
+ * resolved live via the host scene index (StructureCollection) — never stored in
33
+ * the resource registry. Stable across undo/redo and persistable (§9.2). This is
34
+ * the canonical return handle for every `design.create.*` creator. The token is
35
+ * the raw `Component.id` — NO `"component_"` prefix, so it round-trips with the
36
+ * ids the host already hands out.
37
+ */
38
+ export type ComponentHandle = EntityId<"component">
39
+
40
+ /**
41
+ * A material handle. Like {@linkcode ComponentHandle}/`CommentHandle` this is an
42
+ * arena-free **entity-style** handle: the token IS the material's stable engine
43
+ * name (`Material.name`/`.id`), resolved live via `scene.getMaterialByName`
44
+ * host-side — no registry arena, no quota, no dispose, stable across undo/redo.
45
+ * Project-scoped, not a scene entity.
46
+ */
47
+ export type MaterialHandle = EntityId<"material">
48
+
49
+ // ── Value-kind handles (all-handle model, §11) ──────────────────────────────
50
+ // Under the all-handle decision every structured type is a handle. The only
51
+ // non-handles crossing the boundary are JS primitives (number/string/boolean)
52
+ // and enums — the irreducible construction/read leaves. Value handles are
53
+ // immutable; math/geom operate on them via host RPC (no in-worker compute).
54
+ export type Vec3Handle = Handle<"vec3">
55
+ export type QuatHandle = Handle<"quat">
56
+ export type LineHandle = Handle<"line">
57
+ export type ArcHandle = Handle<"arc">
58
+ /** A curve is a line or an arc — its handle is one of those kinds. */
59
+ export type CurveHandle = LineHandle | ArcHandle
60
+ /**
61
+ * A circle value handle. A circle is a CLOSED curve — it deliberately does NOT
62
+ * join {@linkcode CurveHandle} (it has no stable start/end and would break the
63
+ * shared curve read contract), so it carries its own kind and its own
64
+ * `core.geom.query.circle` namespace (mirroring `query.arc`).
65
+ */
66
+ export type CircleHandle = Handle<"circle">
67
+
68
+ // ── BREP topology handles (geometry-kernel resource family, §2A.2.1) ─────────
69
+ // Session-ephemeral, identity-deduped RESOURCE handles for the boundary-
70
+ // representation topology graph. Read-only via `core.geom.query.{brep,face,edge,
71
+ // halfedge,vertex}`; they go stale on undo/redo/re-topologize. Obtain a brep via
72
+ // `design.query.geometry.getBrep`; every other topology handle is minted by
73
+ // walking from a brep/face/edge/vertex handle already resolved off that brep.
74
+ export type BrepHandle = Handle<"brep">
75
+ export type FaceHandle = Handle<"face">
76
+ export type EdgeHandle = Handle<"edge">
77
+ /** Half-edge kind token is all-lowercase `"halfedge"` per §6.1 (no camelCase namespaces). */
78
+ export type HalfEdgeHandle = Handle<"halfedge">
79
+ export type VertexHandle = Handle<"vertex">
80
+
81
+ /**
82
+ * Bare primitive records — how value-handle reads return their components
83
+ * (§11.4). Curves have **no** by-value record: a curve crosses the boundary as a
84
+ * {@linkcode CurveHandle} (line/arc), and its coordinates are read via the
85
+ * `core.geom.query.curve` API. There is no `CurveData` under the all-handle model.
86
+ */
87
+ export type Vec3Components = { x: number; y: number; z: number }
88
+ export type QuatComponents = { x: number; y: number; z: number; w: number }
89
+ /** Axis-aligned bounding box, read as two primitive corner records. */
90
+ export type BBoxComponents = { min: Vec3Components; max: Vec3Components }
91
+
92
+ /**
93
+ * Build a Zod schema validating a handle of the given `kind` at the trust
94
+ * boundary. It checks only the `"<kind>_"` prefix shape; existence, kind, and
95
+ * ownership are enforced host-side by the HandleRegistry (§9.7). Keeping it to
96
+ * the prefix is engine-free and avoids an existence oracle.
97
+ */
98
+ export const handleSchema = <K extends string>(kind: K) =>
99
+ z
100
+ .string()
101
+ .regex(new RegExp(`^${kind}_[A-Za-z0-9_-]+$`), `expected a "${kind}" handle`)
102
+ .transform((s) => s as Handle<K>)
103
+
104
+ export const ProfileHandle = handleSchema("profile")
105
+ export const ContourHandle = handleSchema("contour")
106
+ export const MassHandle = handleSchema("mass")
107
+
108
+ /**
109
+ * Entity handles are raw `Component.id` strings (no `"<kind>_"` prefix) — validated
110
+ * only as a non-empty string, resolved live via the scene index host-side.
111
+ */
112
+ export const ComponentHandle = z
113
+ .string()
114
+ .min(1)
115
+ .transform((s) => s as ComponentHandle)
116
+
117
+ /**
118
+ * Material handles are the raw `Material.name` string (entity-style, no `"<kind>_"`
119
+ * prefix) — validated only as non-empty, resolved live via `scene.getMaterialByName`.
120
+ */
121
+ export const MaterialHandle = z
122
+ .string()
123
+ .min(1)
124
+ .transform((s) => s as MaterialHandle)
125
+
126
+ // Value-kind handle schemas (all-handle model, §11).
127
+ export const Vec3Handle = handleSchema("vec3")
128
+ export const QuatHandle = handleSchema("quat")
129
+ export const LineHandle = handleSchema("line")
130
+ export const ArcHandle = handleSchema("arc")
131
+ export const CurveHandle = z.union([LineHandle, ArcHandle])
132
+ export const CircleHandle = handleSchema("circle")
133
+
134
+ // BREP topology handle schemas (§2A.2.1). Prefix-shape validation only; existence,
135
+ // kind, and ownership are enforced host-side by the HandleRegistry topology arena.
136
+ export const BrepHandle = handleSchema("brep")
137
+ export const FaceHandle = handleSchema("face")
138
+ export const EdgeHandle = handleSchema("edge")
139
+ export const HalfEdgeHandle = handleSchema("halfedge")
140
+ export const VertexHandle = handleSchema("vertex")
141
+ export const Vec3Components = z.object({ x: z.number(), y: z.number(), z: z.number() })
142
+ export const QuatComponents = z.object({
143
+ x: z.number(),
144
+ y: z.number(),
145
+ z: z.number(),
146
+ w: z.number(),
147
+ })
148
+ export const BBoxComponents = z.object({ min: Vec3Components, max: Vec3Components })
package/src/host-utils.ts CHANGED
@@ -13,8 +13,11 @@ type UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends (
13
13
 
14
14
  type Flatten<T> = { [K in keyof T]: T[K] }
15
15
 
16
- type MethodArgs<F extends (...args: any[]) => any> =
17
- Parameters<F> extends [infer A] ? A : void
16
+ /**
17
+ * The full parameter tuple of a method — the positional-args transport forwards
18
+ * the whole argument list (`[]` for no-arg methods).
19
+ */
20
+ type MethodArgs<F extends (...args: any[]) => any> = Parameters<F>
18
21
 
19
22
  type MethodReturn<F extends (...args: any[]) => any> = Awaited<ReturnType<F>>
20
23
 
@@ -45,10 +48,11 @@ export type PluginApiMethodMap = Flatten<
45
48
 
46
49
  export type PluginApiMethod = keyof PluginApiMethodMap
47
50
 
48
- export type PluginApiCallPayload<M extends PluginApiMethod = PluginApiMethod> =
49
- PluginApiMethodMap[M]["args"] extends void
50
- ? { method: M; args?: void }
51
- : { method: M; args: PluginApiMethodMap[M]["args"] }
51
+ export type PluginApiCallPayload<M extends PluginApiMethod = PluginApiMethod> = {
52
+ method: M
53
+ /** Positional argument tuple, spread back into the method host-side. */
54
+ args: PluginApiMethodMap[M]["args"]
55
+ }
52
56
 
53
57
  export type PluginApiCallResult<M extends PluginApiMethod> =
54
58
  PluginApiMethodMap[M]["return"]
package/src/index.ts CHANGED
@@ -1,3 +1,4 @@
1
1
  export * from "./api"
2
2
  export * from "./types"
3
3
  export * from "./host-utils"
4
+ export * from "./handles"
@@ -1,81 +0,0 @@
1
- import * as z from "zod";
2
- import { PVec3 } from "../math/vec3";
3
- /**
4
- * Arc construction.
5
- *
6
- * A {@linkcode PArc} represents a circular arc in 3D space, defined by
7
- * start/end points, a centre, and a rotation axis. Arcs can be wrapped
8
- * as a {@linkcode PCurve} and combined into a {@linkcode PProfile}.
9
- *
10
- * Accessed via `snaptrude.core.geom.arc`.
11
- */
12
- export declare abstract class PluginArcApi {
13
- constructor();
14
- /**
15
- * Create a new arc from start, end, centre, and axis.
16
- *
17
- * The arc sweeps from {@linkcode startPoint} to {@linkcode endPoint}
18
- * along the circle centred at {@linkcode centrePoint}, in the
19
- * direction determined by the right-hand rule around {@linkcode axis}.
20
- *
21
- * @param startPoint - The start point as a {@linkcode PVec3}
22
- * @param endPoint - The end point as a {@linkcode PVec3}
23
- * @param centrePoint - The centre of the arc's circle as a {@linkcode PVec3}
24
- * @param axis - The arc's rotation axis as a {@linkcode PVec3}
25
- * (perpendicular to the arc's plane)
26
- * @returns A new {@linkcode PArc}
27
- *
28
- * # Example
29
- * ```ts
30
- * const { vec3 } = snaptrude.core.math
31
- * const { arc } = snaptrude.core.geom
32
- *
33
- * // Quarter-circle arc on the XZ plane
34
- * const a = arc.new(
35
- * vec3.new(1, 0, 0), // start
36
- * vec3.new(0, 0, 1), // end
37
- * vec3.new(0, 0, 0), // centre
38
- * vec3.new(0, 1, 0), // Y-up axis
39
- * )
40
- * ```
41
- */
42
- new(startPoint: PVec3, endPoint: PVec3, centrePoint: PVec3, axis: PVec3): PArc;
43
- }
44
- /**
45
- * A circular arc defined by start, end, centre, and axis.
46
- *
47
- * Discriminated by `curveType: "Arc"` within the {@linkcode PCurve} union.
48
- *
49
- * | Property | Type | Description |
50
- * |---|---|---|
51
- * | `curveType` | `"Arc"` | Discriminator tag |
52
- * | `startPoint` | {@linkcode PVec3} | Start point of the arc |
53
- * | `endPoint` | {@linkcode PVec3} | End point of the arc |
54
- * | `centrePoint` | {@linkcode PVec3} | Centre of the arc's circle |
55
- * | `axis` | {@linkcode PVec3} | Rotation axis (normal to the arc's plane) |
56
- */
57
- export declare const PArc: z.ZodObject<{
58
- curveType: z.ZodLiteral<"Arc">;
59
- startPoint: z.ZodObject<{
60
- x: z.ZodNumber;
61
- y: z.ZodNumber;
62
- z: z.ZodNumber;
63
- }, z.core.$strip>;
64
- endPoint: z.ZodObject<{
65
- x: z.ZodNumber;
66
- y: z.ZodNumber;
67
- z: z.ZodNumber;
68
- }, z.core.$strip>;
69
- centrePoint: z.ZodObject<{
70
- x: z.ZodNumber;
71
- y: z.ZodNumber;
72
- z: z.ZodNumber;
73
- }, z.core.$strip>;
74
- axis: z.ZodObject<{
75
- x: z.ZodNumber;
76
- y: z.ZodNumber;
77
- z: z.ZodNumber;
78
- }, z.core.$strip>;
79
- }, z.core.$strip>;
80
- export type PArc = z.infer<typeof PArc>;
81
- //# sourceMappingURL=arc.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"arc.d.ts","sourceRoot":"","sources":["../../../../src/api/core/geom/arc.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,KAAK,CAAA;AACxB,OAAO,EAAE,KAAK,EAAE,MAAM,cAAc,CAAA;AAEpC;;;;;;;;GAQG;AACH,8BAAsB,YAAY;;IAGhC;;;;;;;;;;;;;;;;;;;;;;;;;;;OA2BG;IACH,GAAG,CAAC,UAAU,EAAE,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,WAAW,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,GAAG,IAAI;CAG/E;AAED;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,IAAI;;;;;;;;;;;;;;;;;;;;;;iBAMf,CAAA;AAEF,MAAM,MAAM,IAAI,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,IAAI,CAAC,CAAA"}
@@ -1,70 +0,0 @@
1
- import * as z from "zod";
2
- import { PLine } from "./line";
3
- import { PArc } from "./arc";
4
- /**
5
- * Unified curve wrapper — either a {@linkcode PLine} or a {@linkcode PArc}.
6
- *
7
- * Use this to build heterogeneous curve lists (mixing lines and arcs)
8
- * when constructing a {@linkcode PProfile}.
9
- *
10
- * Accessed via `snaptrude.core.geom.curve`.
11
- */
12
- export declare abstract class PluginCurveApi {
13
- constructor();
14
- /**
15
- * Wrap a {@linkcode PLine} or {@linkcode PArc} as a {@linkcode PCurve}.
16
- *
17
- * This is an identity operation — it simply returns the input unchanged.
18
- * It exists for type-level clarity when building mixed curve lists.
19
- *
20
- * @param curve - A {@linkcode PLine} or {@linkcode PArc} to wrap
21
- * @returns The same value typed as {@linkcode PCurve}
22
- */
23
- new(curve: PLine | PArc): PCurve;
24
- }
25
- /**
26
- * A discriminated union of {@linkcode PLine} and {@linkcode PArc}.
27
- *
28
- * Discriminated on the `curveType` field:
29
- * - `"Line"` → {@linkcode PLine}
30
- * - `"Arc"` → {@linkcode PArc}
31
- *
32
- * Use `curve.curveType` to narrow the type in a switch or if-statement.
33
- */
34
- export declare const PCurve: z.ZodDiscriminatedUnion<[z.ZodObject<{
35
- curveType: z.ZodLiteral<"Line">;
36
- startPoint: z.ZodObject<{
37
- x: z.ZodNumber;
38
- y: z.ZodNumber;
39
- z: z.ZodNumber;
40
- }, z.core.$strip>;
41
- endPoint: z.ZodObject<{
42
- x: z.ZodNumber;
43
- y: z.ZodNumber;
44
- z: z.ZodNumber;
45
- }, z.core.$strip>;
46
- }, z.core.$strip>, z.ZodObject<{
47
- curveType: z.ZodLiteral<"Arc">;
48
- startPoint: z.ZodObject<{
49
- x: z.ZodNumber;
50
- y: z.ZodNumber;
51
- z: z.ZodNumber;
52
- }, z.core.$strip>;
53
- endPoint: z.ZodObject<{
54
- x: z.ZodNumber;
55
- y: z.ZodNumber;
56
- z: z.ZodNumber;
57
- }, z.core.$strip>;
58
- centrePoint: z.ZodObject<{
59
- x: z.ZodNumber;
60
- y: z.ZodNumber;
61
- z: z.ZodNumber;
62
- }, z.core.$strip>;
63
- axis: z.ZodObject<{
64
- x: z.ZodNumber;
65
- y: z.ZodNumber;
66
- z: z.ZodNumber;
67
- }, z.core.$strip>;
68
- }, z.core.$strip>], "curveType">;
69
- export type PCurve = z.infer<typeof PCurve>;
70
- //# sourceMappingURL=curve.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"curve.d.ts","sourceRoot":"","sources":["../../../../src/api/core/geom/curve.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,KAAK,CAAA;AACxB,OAAO,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAA;AAC9B,OAAO,EAAE,IAAI,EAAE,MAAM,OAAO,CAAA;AAE5B;;;;;;;GAOG;AACH,8BAAsB,cAAc;;IAGlC;;;;;;;;OAQG;IACH,GAAG,CAAC,KAAK,EAAE,KAAK,GAAG,IAAI,GAAG,MAAM;CAGjC;AAED;;;;;;;;GAQG;AACH,eAAO,MAAM,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;gCAAmD,CAAA;AAEtE,MAAM,MAAM,MAAM,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,MAAM,CAAC,CAAA"}
@@ -1,56 +0,0 @@
1
- import * as z from "zod";
2
- import { PVec3 } from "../math/vec3";
3
- /**
4
- * Line segment construction.
5
- *
6
- * A {@linkcode PLine} is the simplest curve primitive — a straight
7
- * segment between two 3D points. Lines can be wrapped as a
8
- * {@linkcode PCurve} and combined into a {@linkcode PProfile}.
9
- *
10
- * Accessed via `snaptrude.core.geom.line`.
11
- */
12
- export declare abstract class PluginLineApi {
13
- constructor();
14
- /**
15
- * Create a new line segment between two points.
16
- *
17
- * @param startPoint - The start point as a {@linkcode PVec3}
18
- * @param endPoint - The end point as a {@linkcode PVec3}
19
- * @returns A new {@linkcode PLine}
20
- *
21
- * # Example
22
- * ```ts
23
- * const { vec3 } = snaptrude.core.math
24
- * const { line } = snaptrude.core.geom
25
- *
26
- * const edge = line.new(vec3.new(0, 0, 0), vec3.new(5, 0, 0))
27
- * ```
28
- */
29
- new(startPoint: PVec3, endPoint: PVec3): PLine;
30
- }
31
- /**
32
- * A line segment defined by a start and end point.
33
- *
34
- * Discriminated by `curveType: "Line"` within the {@linkcode PCurve} union.
35
- *
36
- * | Property | Type | Description |
37
- * |---|---|---|
38
- * | `curveType` | `"Line"` | Discriminator tag |
39
- * | `startPoint` | {@linkcode PVec3} | Start point of the segment |
40
- * | `endPoint` | {@linkcode PVec3} | End point of the segment |
41
- */
42
- export declare const PLine: z.ZodObject<{
43
- curveType: z.ZodLiteral<"Line">;
44
- startPoint: z.ZodObject<{
45
- x: z.ZodNumber;
46
- y: z.ZodNumber;
47
- z: z.ZodNumber;
48
- }, z.core.$strip>;
49
- endPoint: z.ZodObject<{
50
- x: z.ZodNumber;
51
- y: z.ZodNumber;
52
- z: z.ZodNumber;
53
- }, z.core.$strip>;
54
- }, z.core.$strip>;
55
- export type PLine = z.infer<typeof PLine>;
56
- //# sourceMappingURL=line.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"line.d.ts","sourceRoot":"","sources":["../../../../src/api/core/geom/line.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,KAAK,CAAA;AACxB,OAAO,EAAE,KAAK,EAAE,MAAM,cAAc,CAAA;AAEpC;;;;;;;;GAQG;AACH,8BAAsB,aAAa;;IAGjC;;;;;;;;;;;;;;OAcG;IACH,GAAG,CAAC,UAAU,EAAE,KAAK,EAAE,QAAQ,EAAE,KAAK,GAAG,KAAK;CAG/C;AAED;;;;;;;;;;GAUG;AACH,eAAO,MAAM,KAAK;;;;;;;;;;;;iBAIhB,CAAA;AAEF,MAAM,MAAM,KAAK,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,KAAK,CAAC,CAAA"}
@@ -1,121 +0,0 @@
1
- import * as z from "zod";
2
- import { PluginApiReturn } from "../../../types";
3
- import { PCurve } from "./curve";
4
- /**
5
- * Profile construction — a closed loop of {@linkcode PCurve}s.
6
- *
7
- * Profiles are the primary 2D shape primitive used for creating
8
- * extruded entities like spaces. Build profiles either from an
9
- * explicit list of curves or from a list of points (auto-connected
10
- * with line segments).
11
- *
12
- * Accessed via `snaptrude.core.geom.profile`.
13
- */
14
- export declare abstract class PluginProfileApi {
15
- constructor();
16
- /**
17
- * Create a profile from an ordered list of curves.
18
- *
19
- * The curves should form a closed loop — the end point of each curve
20
- * should coincide with the start point of the next.
21
- *
22
- * @param curves - An ordered array of {@linkcode PCurve}s forming a closed loop
23
- * @returns A new {@linkcode PProfile}
24
- */
25
- new(curves: PCurve[]): PProfile;
26
- /**
27
- * Create a profile by connecting a list of points with line segments.
28
- *
29
- * The points are connected in order, with the last point automatically
30
- * connected back to the first to close the loop.
31
- *
32
- * This is a **host API call** — it returns a `Promise`.
33
- *
34
- * @param args - An object containing:
35
- * - {@linkcode PluginProfileFromLinePointsArgs.points args.points} — An ordered
36
- * array of {@linkcode PVec3} forming the profile vertices
37
- * @returns A {@linkcode PProfile} with line-segment curves connecting the points
38
- *
39
- * # Example
40
- * ```ts
41
- * const { vec3 } = snaptrude.core.math
42
- *
43
- * // Create an L-shaped profile
44
- * const profile = await snaptrude.core.geom.profile.fromLinePoints({
45
- * points: [
46
- * vec3.new(0, 0, 0),
47
- * vec3.new(10, 0, 0),
48
- * vec3.new(10, 0, 5),
49
- * vec3.new(5, 0, 5),
50
- * vec3.new(5, 0, 10),
51
- * vec3.new(0, 0, 10),
52
- * ],
53
- * })
54
- * ```
55
- */
56
- abstract fromLinePoints(args: PluginProfileFromLinePointsArgs): PluginApiReturn<PProfile>;
57
- }
58
- /**
59
- * Arguments for {@linkcode PluginProfileApi.fromLinePoints}.
60
- *
61
- * | Property | Type | Description |
62
- * |---|---|---|
63
- * | `points` | {@linkcode PVec3}`[]` | Ordered vertices of the profile |
64
- */
65
- export declare const PluginProfileFromLinePointsArgs: z.ZodObject<{
66
- points: z.ZodArray<z.ZodObject<{
67
- x: z.ZodNumber;
68
- y: z.ZodNumber;
69
- z: z.ZodNumber;
70
- }, z.core.$strip>>;
71
- }, z.core.$strip>;
72
- export type PluginProfileFromLinePointsArgs = z.infer<typeof PluginProfileFromLinePointsArgs>;
73
- /**
74
- * A closed profile composed of an ordered list of curves.
75
- *
76
- * Profiles are used as input to entity creation methods like
77
- * {@linkcode PluginSpaceApi.createFromProfile}.
78
- *
79
- * | Property | Type | Description |
80
- * |---|---|---|
81
- * | `curves` | {@linkcode PCurve}`[]` | Ordered curves forming a closed loop |
82
- */
83
- export declare const PProfile: z.ZodObject<{
84
- curves: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
85
- curveType: z.ZodLiteral<"Line">;
86
- startPoint: z.ZodObject<{
87
- x: z.ZodNumber;
88
- y: z.ZodNumber;
89
- z: z.ZodNumber;
90
- }, z.core.$strip>;
91
- endPoint: z.ZodObject<{
92
- x: z.ZodNumber;
93
- y: z.ZodNumber;
94
- z: z.ZodNumber;
95
- }, z.core.$strip>;
96
- }, z.core.$strip>, z.ZodObject<{
97
- curveType: z.ZodLiteral<"Arc">;
98
- startPoint: z.ZodObject<{
99
- x: z.ZodNumber;
100
- y: z.ZodNumber;
101
- z: z.ZodNumber;
102
- }, z.core.$strip>;
103
- endPoint: z.ZodObject<{
104
- x: z.ZodNumber;
105
- y: z.ZodNumber;
106
- z: z.ZodNumber;
107
- }, z.core.$strip>;
108
- centrePoint: z.ZodObject<{
109
- x: z.ZodNumber;
110
- y: z.ZodNumber;
111
- z: z.ZodNumber;
112
- }, z.core.$strip>;
113
- axis: z.ZodObject<{
114
- x: z.ZodNumber;
115
- y: z.ZodNumber;
116
- z: z.ZodNumber;
117
- }, z.core.$strip>;
118
- }, z.core.$strip>], "curveType">>;
119
- }, z.core.$strip>;
120
- export type PProfile = z.infer<typeof PProfile>;
121
- //# sourceMappingURL=profile.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"profile.d.ts","sourceRoot":"","sources":["../../../../src/api/core/geom/profile.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,KAAK,CAAA;AACxB,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAA;AAEhD,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAA;AAEhC;;;;;;;;;GASG;AACH,8BAAsB,gBAAgB;;IAGpC;;;;;;;;OAQG;IACH,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,QAAQ;IAI/B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA6BG;aACa,cAAc,CAC5B,IAAI,EAAE,+BAA+B,GACpC,eAAe,CAAC,QAAQ,CAAC;CAC7B;AAED;;;;;;GAMG;AACH,eAAO,MAAM,+BAA+B;;;;;;iBAE1C,CAAA;AAEF,MAAM,MAAM,+BAA+B,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,+BAA+B,CAAC,CAAA;AAE7F;;;;;;;;;GASG;AACH,eAAO,MAAM,QAAQ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAEnB,CAAA;AAEF,MAAM,MAAM,QAAQ,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,QAAQ,CAAC,CAAA"}