@snaptrude/plugin-core 0.3.0 → 0.6.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 (302) hide show
  1. package/AGENTS.md +130 -48
  2. package/CHANGELOG.md +163 -0
  3. package/api-manifest.full.json +5600 -0
  4. package/api-manifest.json +5502 -0
  5. package/dist/api/analysis/heatmaps.d.ts +234 -0
  6. package/dist/api/analysis/heatmaps.d.ts.map +1 -0
  7. package/dist/api/analysis/illuminance.d.ts +145 -0
  8. package/dist/api/analysis/illuminance.d.ts.map +1 -0
  9. package/dist/api/analysis/index.d.ts +44 -0
  10. package/dist/api/analysis/index.d.ts.map +1 -0
  11. package/dist/api/analysis/shadows.d.ts +165 -0
  12. package/dist/api/analysis/shadows.d.ts.map +1 -0
  13. package/dist/api/analysis/sunlightHours.d.ts +208 -0
  14. package/dist/api/analysis/sunlightHours.d.ts.map +1 -0
  15. package/dist/api/analysis/sunpath.d.ts +80 -0
  16. package/dist/api/analysis/sunpath.d.ts.map +1 -0
  17. package/dist/api/core/buildings.d.ts +427 -0
  18. package/dist/api/core/buildings.d.ts.map +1 -0
  19. package/dist/api/core/comment/index.d.ts +230 -0
  20. package/dist/api/core/comment/index.d.ts.map +1 -0
  21. package/dist/api/core/geom/create/index.d.ts +247 -0
  22. package/dist/api/core/geom/create/index.d.ts.map +1 -0
  23. package/dist/api/core/geom/delete/index.d.ts +72 -0
  24. package/dist/api/core/geom/delete/index.d.ts.map +1 -0
  25. package/dist/api/core/geom/index.d.ts +24 -23
  26. package/dist/api/core/geom/index.d.ts.map +1 -1
  27. package/dist/api/core/geom/query/arc.d.ts +169 -0
  28. package/dist/api/core/geom/query/arc.d.ts.map +1 -0
  29. package/dist/api/core/geom/query/brep.d.ts +402 -0
  30. package/dist/api/core/geom/query/brep.d.ts.map +1 -0
  31. package/dist/api/core/geom/query/circle.d.ts +378 -0
  32. package/dist/api/core/geom/query/circle.d.ts.map +1 -0
  33. package/dist/api/core/geom/query/contour.d.ts +450 -0
  34. package/dist/api/core/geom/query/contour.d.ts.map +1 -0
  35. package/dist/api/core/geom/query/curve.d.ts +918 -0
  36. package/dist/api/core/geom/query/curve.d.ts.map +1 -0
  37. package/dist/api/core/geom/query/edge.d.ts +128 -0
  38. package/dist/api/core/geom/query/edge.d.ts.map +1 -0
  39. package/dist/api/core/geom/query/face.d.ts +363 -0
  40. package/dist/api/core/geom/query/face.d.ts.map +1 -0
  41. package/dist/api/core/geom/query/halfedge.d.ts +206 -0
  42. package/dist/api/core/geom/query/halfedge.d.ts.map +1 -0
  43. package/dist/api/core/geom/query/index.d.ts +61 -0
  44. package/dist/api/core/geom/query/index.d.ts.map +1 -0
  45. package/dist/api/core/geom/query/profile.d.ts +410 -0
  46. package/dist/api/core/geom/query/profile.d.ts.map +1 -0
  47. package/dist/api/core/geom/query/vertex.d.ts +187 -0
  48. package/dist/api/core/geom/query/vertex.d.ts.map +1 -0
  49. package/dist/api/core/geom/update/contour.d.ts +272 -0
  50. package/dist/api/core/geom/update/contour.d.ts.map +1 -0
  51. package/dist/api/core/geom/update/curve.d.ts +180 -0
  52. package/dist/api/core/geom/update/curve.d.ts.map +1 -0
  53. package/dist/api/core/geom/update/index.d.ts +27 -0
  54. package/dist/api/core/geom/update/index.d.ts.map +1 -0
  55. package/dist/api/core/geom/update/profile.d.ts +329 -0
  56. package/dist/api/core/geom/update/profile.d.ts.map +1 -0
  57. package/dist/api/core/groups.d.ts +485 -0
  58. package/dist/api/core/groups.d.ts.map +1 -0
  59. package/dist/api/core/history/index.d.ts +78 -0
  60. package/dist/api/core/history/index.d.ts.map +1 -0
  61. package/dist/api/core/index.d.ts +51 -1
  62. package/dist/api/core/index.d.ts.map +1 -1
  63. package/dist/api/core/io/import/index.d.ts +392 -0
  64. package/dist/api/core/io/import/index.d.ts.map +1 -0
  65. package/dist/api/core/io/index.d.ts +35 -0
  66. package/dist/api/core/io/index.d.ts.map +1 -0
  67. package/dist/api/core/io/job/index.d.ts +139 -0
  68. package/dist/api/core/io/job/index.d.ts.map +1 -0
  69. package/dist/api/core/io/query/index.d.ts +74 -0
  70. package/dist/api/core/io/query/index.d.ts.map +1 -0
  71. package/dist/api/core/io/terrain/index.d.ts +206 -0
  72. package/dist/api/core/io/terrain/index.d.ts.map +1 -0
  73. package/dist/api/core/io/underlay/index.d.ts +286 -0
  74. package/dist/api/core/io/underlay/index.d.ts.map +1 -0
  75. package/dist/api/core/layers.d.ts +402 -0
  76. package/dist/api/core/layers.d.ts.map +1 -0
  77. package/dist/api/core/math/quat.d.ts +111 -128
  78. package/dist/api/core/math/quat.d.ts.map +1 -1
  79. package/dist/api/core/math/vec3.d.ts +120 -102
  80. package/dist/api/core/math/vec3.d.ts.map +1 -1
  81. package/dist/api/core/project/index.d.ts +399 -0
  82. package/dist/api/core/project/index.d.ts.map +1 -0
  83. package/dist/api/core/tags.d.ts +755 -0
  84. package/dist/api/core/tags.d.ts.map +1 -0
  85. package/dist/api/core/units/index.d.ts +175 -0
  86. package/dist/api/core/units/index.d.ts.map +1 -0
  87. package/dist/api/core/zoom/index.d.ts +45 -0
  88. package/dist/api/core/zoom/index.d.ts.map +1 -0
  89. package/dist/api/design/boolean/index.d.ts +168 -0
  90. package/dist/api/design/boolean/index.d.ts.map +1 -0
  91. package/dist/api/design/create/index.d.ts +837 -0
  92. package/dist/api/design/create/index.d.ts.map +1 -0
  93. package/dist/api/design/delete/index.d.ts +63 -0
  94. package/dist/api/design/delete/index.d.ts.map +1 -0
  95. package/dist/api/design/doors/index.d.ts +268 -0
  96. package/dist/api/design/doors/index.d.ts.map +1 -0
  97. package/dist/api/design/edit/index.d.ts +49 -0
  98. package/dist/api/design/edit/index.d.ts.map +1 -0
  99. package/dist/api/design/erase/index.d.ts +160 -0
  100. package/dist/api/design/erase/index.d.ts.map +1 -0
  101. package/dist/api/design/furniture/index.d.ts +123 -0
  102. package/dist/api/design/furniture/index.d.ts.map +1 -0
  103. package/dist/api/design/index.d.ts +153 -0
  104. package/dist/api/design/index.d.ts.map +1 -0
  105. package/dist/api/design/lock.d.ts +41 -0
  106. package/dist/api/design/lock.d.ts.map +1 -0
  107. package/dist/api/design/materials/index.d.ts +297 -0
  108. package/dist/api/design/materials/index.d.ts.map +1 -0
  109. package/dist/api/design/query/geometry/index.d.ts +140 -0
  110. package/dist/api/design/query/geometry/index.d.ts.map +1 -0
  111. package/dist/api/design/query/index.d.ts +1011 -0
  112. package/dist/api/design/query/index.d.ts.map +1 -0
  113. package/dist/api/design/query/spaces.d.ts +221 -0
  114. package/dist/api/design/query/spaces.d.ts.map +1 -0
  115. package/dist/api/design/selection/index.d.ts +282 -0
  116. package/dist/api/design/selection/index.d.ts.map +1 -0
  117. package/dist/api/design/shared.d.ts +38 -0
  118. package/dist/api/design/shared.d.ts.map +1 -0
  119. package/dist/api/design/transform/index.d.ts +87 -0
  120. package/dist/api/design/transform/index.d.ts.map +1 -0
  121. package/dist/api/design/update/index.d.ts +178 -0
  122. package/dist/api/design/update/index.d.ts.map +1 -0
  123. package/dist/api/design/windows/index.d.ts +189 -0
  124. package/dist/api/design/windows/index.d.ts.map +1 -0
  125. package/dist/api/entity/buildableEnvelope.d.ts +261 -0
  126. package/dist/api/entity/buildableEnvelope.d.ts.map +1 -0
  127. package/dist/api/entity/department.d.ts +0 -98
  128. package/dist/api/entity/department.d.ts.map +1 -1
  129. package/dist/api/entity/index.d.ts +9 -9
  130. package/dist/api/entity/index.d.ts.map +1 -1
  131. package/dist/api/entity/referenceLine.d.ts +49 -106
  132. package/dist/api/entity/referenceLine.d.ts.map +1 -1
  133. package/dist/api/entity/space.d.ts +484 -251
  134. package/dist/api/entity/space.d.ts.map +1 -1
  135. package/dist/api/entity/story.d.ts +49 -39
  136. package/dist/api/entity/story.d.ts.map +1 -1
  137. package/dist/api/index.d.ts +22 -12
  138. package/dist/api/index.d.ts.map +1 -1
  139. package/dist/api/presentation/aiInspiration.d.ts +440 -0
  140. package/dist/api/presentation/aiInspiration.d.ts.map +1 -0
  141. package/dist/api/presentation/diagrams.d.ts +81 -0
  142. package/dist/api/presentation/diagrams.d.ts.map +1 -0
  143. package/dist/api/presentation/import.d.ts +113 -0
  144. package/dist/api/presentation/import.d.ts.map +1 -0
  145. package/dist/api/presentation/index.d.ts +46 -0
  146. package/dist/api/presentation/index.d.ts.map +1 -0
  147. package/dist/api/presentation/sheets.d.ts +176 -0
  148. package/dist/api/presentation/sheets.d.ts.map +1 -0
  149. package/dist/api/presentation/views.d.ts +296 -0
  150. package/dist/api/presentation/views.d.ts.map +1 -0
  151. package/dist/api/program/adjacency.d.ts +155 -0
  152. package/dist/api/program/adjacency.d.ts.map +1 -0
  153. package/dist/api/program/areas.d.ts +360 -0
  154. package/dist/api/program/areas.d.ts.map +1 -0
  155. package/dist/api/program/classification.d.ts +135 -0
  156. package/dist/api/program/classification.d.ts.map +1 -0
  157. package/dist/api/program/cores.d.ts +174 -0
  158. package/dist/api/program/cores.d.ts.map +1 -0
  159. package/dist/api/program/departments.d.ts +431 -0
  160. package/dist/api/program/departments.d.ts.map +1 -0
  161. package/dist/api/program/index.d.ts +69 -0
  162. package/dist/api/program/index.d.ts.map +1 -0
  163. package/dist/api/program/layout.d.ts +63 -0
  164. package/dist/api/program/layout.d.ts.map +1 -0
  165. package/dist/api/program/metrics.d.ts +108 -0
  166. package/dist/api/program/metrics.d.ts.map +1 -0
  167. package/dist/api/program/site.d.ts +451 -0
  168. package/dist/api/program/site.d.ts.map +1 -0
  169. package/dist/api/program/spreadsheet.d.ts +2041 -0
  170. package/dist/api/program/spreadsheet.d.ts.map +1 -0
  171. package/dist/handles.d.ts +171 -0
  172. package/dist/handles.d.ts.map +1 -0
  173. package/dist/host-utils.d.ts +7 -5
  174. package/dist/host-utils.d.ts.map +1 -1
  175. package/dist/index.cjs +4344 -899
  176. package/dist/index.cjs.map +1 -1
  177. package/dist/index.d.ts +1 -0
  178. package/dist/index.d.ts.map +1 -1
  179. package/dist/index.js +3682 -865
  180. package/dist/index.js.map +1 -1
  181. package/package.json +6 -2
  182. package/scripts/generate-manifest.mjs +193 -0
  183. package/scripts/generate-manifest.test.mjs +215 -0
  184. package/src/api/analysis/heatmaps.ts +256 -0
  185. package/src/api/analysis/illuminance.ts +155 -0
  186. package/src/api/analysis/index.ts +46 -0
  187. package/src/api/analysis/shadows.ts +183 -0
  188. package/src/api/analysis/sunlightHours.ts +211 -0
  189. package/src/api/analysis/sunpath.ts +83 -0
  190. package/src/api/core/buildings.ts +485 -0
  191. package/src/api/core/comment/index.ts +258 -0
  192. package/src/api/core/geom/create/index.ts +293 -0
  193. package/src/api/core/geom/delete/index.ts +78 -0
  194. package/src/api/core/geom/index.ts +24 -23
  195. package/src/api/core/geom/query/arc.ts +169 -0
  196. package/src/api/core/geom/query/brep.ts +444 -0
  197. package/src/api/core/geom/query/circle.ts +404 -0
  198. package/src/api/core/geom/query/contour.ts +540 -0
  199. package/src/api/core/geom/query/curve.ts +1078 -0
  200. package/src/api/core/geom/query/edge.ts +130 -0
  201. package/src/api/core/geom/query/face.ts +403 -0
  202. package/src/api/core/geom/query/halfedge.ts +210 -0
  203. package/src/api/core/geom/query/index.ts +63 -0
  204. package/src/api/core/geom/query/profile.ts +473 -0
  205. package/src/api/core/geom/query/vertex.ts +205 -0
  206. package/src/api/core/geom/update/contour.ts +315 -0
  207. package/src/api/core/geom/update/curve.ts +209 -0
  208. package/src/api/core/geom/update/index.ts +29 -0
  209. package/src/api/core/geom/update/profile.ts +377 -0
  210. package/src/api/core/groups.ts +521 -0
  211. package/src/api/core/history/index.ts +84 -0
  212. package/src/api/core/index.ts +51 -1
  213. package/src/api/core/io/import/index.ts +432 -0
  214. package/src/api/core/io/index.ts +37 -0
  215. package/src/api/core/io/job/index.ts +140 -0
  216. package/src/api/core/io/query/index.ts +71 -0
  217. package/src/api/core/io/terrain/index.ts +214 -0
  218. package/src/api/core/io/underlay/index.ts +295 -0
  219. package/src/api/core/layers.ts +333 -0
  220. package/src/api/core/math/quat.ts +112 -235
  221. package/src/api/core/math/vec3.ts +124 -159
  222. package/src/api/core/project/index.ts +418 -0
  223. package/src/api/core/tags.ts +808 -0
  224. package/src/api/core/units/index.ts +164 -0
  225. package/src/api/core/zoom/index.ts +47 -0
  226. package/src/api/design/boolean/index.ts +179 -0
  227. package/src/api/design/create/index.ts +895 -0
  228. package/src/api/design/delete/index.ts +67 -0
  229. package/src/api/design/doors/index.ts +285 -0
  230. package/src/api/design/edit/index.ts +54 -0
  231. package/src/api/design/erase/index.ts +151 -0
  232. package/src/api/design/furniture/index.ts +130 -0
  233. package/src/api/design/index.ts +162 -0
  234. package/src/api/design/lock.ts +42 -0
  235. package/src/api/design/materials/index.ts +301 -0
  236. package/src/api/design/query/geometry/index.ts +166 -0
  237. package/src/api/design/query/index.ts +937 -0
  238. package/src/api/design/query/spaces.ts +132 -0
  239. package/src/api/design/selection/index.ts +273 -0
  240. package/src/api/design/shared.ts +40 -0
  241. package/src/api/design/transform/index.ts +93 -0
  242. package/src/api/design/update/index.ts +117 -0
  243. package/src/api/design/windows/index.ts +207 -0
  244. package/src/api/entity/buildableEnvelope.ts +318 -0
  245. package/src/api/entity/department.ts +0 -113
  246. package/src/api/entity/index.ts +9 -9
  247. package/src/api/entity/referenceLine.ts +50 -38
  248. package/src/api/entity/space.ts +285 -226
  249. package/src/api/entity/story.ts +53 -42
  250. package/src/api/index.ts +22 -12
  251. package/src/api/presentation/aiInspiration.ts +362 -0
  252. package/src/api/presentation/diagrams.ts +84 -0
  253. package/src/api/presentation/import.ts +112 -0
  254. package/src/api/presentation/index.ts +48 -0
  255. package/src/api/presentation/sheets.ts +198 -0
  256. package/src/api/presentation/views.ts +303 -0
  257. package/src/api/program/adjacency.ts +164 -0
  258. package/src/api/program/areas.ts +335 -0
  259. package/src/api/program/classification.ts +138 -0
  260. package/src/api/program/cores.ts +171 -0
  261. package/src/api/program/departments.ts +465 -0
  262. package/src/api/program/index.ts +71 -0
  263. package/src/api/program/layout.ts +68 -0
  264. package/src/api/program/metrics.ts +120 -0
  265. package/src/api/program/site.ts +419 -0
  266. package/src/api/program/spreadsheet.ts +2075 -0
  267. package/src/handles.ts +194 -0
  268. package/src/host-utils.ts +10 -6
  269. package/src/index.ts +1 -0
  270. package/dist/api/core/geom/arc.d.ts +0 -81
  271. package/dist/api/core/geom/arc.d.ts.map +0 -1
  272. package/dist/api/core/geom/curve.d.ts +0 -70
  273. package/dist/api/core/geom/curve.d.ts.map +0 -1
  274. package/dist/api/core/geom/line.d.ts +0 -56
  275. package/dist/api/core/geom/line.d.ts.map +0 -1
  276. package/dist/api/core/geom/profile.d.ts +0 -121
  277. package/dist/api/core/geom/profile.d.ts.map +0 -1
  278. package/dist/api/tools/copy.d.ts +0 -59
  279. package/dist/api/tools/copy.d.ts.map +0 -1
  280. package/dist/api/tools/index.d.ts +0 -33
  281. package/dist/api/tools/index.d.ts.map +0 -1
  282. package/dist/api/tools/material.d.ts +0 -51
  283. package/dist/api/tools/material.d.ts.map +0 -1
  284. package/dist/api/tools/offset.d.ts +0 -43
  285. package/dist/api/tools/offset.d.ts.map +0 -1
  286. package/dist/api/tools/selection.d.ts +0 -48
  287. package/dist/api/tools/selection.d.ts.map +0 -1
  288. package/dist/api/tools/transform.d.ts +0 -114
  289. package/dist/api/tools/transform.d.ts.map +0 -1
  290. package/dist/api/units/index.d.ts +0 -163
  291. package/dist/api/units/index.d.ts.map +0 -1
  292. package/src/api/core/geom/arc.ts +0 -70
  293. package/src/api/core/geom/curve.ts +0 -41
  294. package/src/api/core/geom/line.ts +0 -53
  295. package/src/api/core/geom/profile.ts +0 -94
  296. package/src/api/tools/copy.ts +0 -55
  297. package/src/api/tools/index.ts +0 -39
  298. package/src/api/tools/material.ts +0 -49
  299. package/src/api/tools/offset.ts +0 -43
  300. package/src/api/tools/selection.ts +0 -51
  301. package/src/api/tools/transform.ts +0 -117
  302. package/src/api/units/index.ts +0 -163
package/AGENTS.md CHANGED
@@ -10,6 +10,73 @@ considering your work done**.
10
10
  - Shared types (`src/types.ts`) — `ComponentId`, `PluginApiReturn<T>`, etc.
11
11
  - Host utilities (`src/host-utils.ts`) — `PluginApiMethodMap`, `PluginApiMethod`, RPC payload types
12
12
 
13
+ ## Transport model — Handle vs value
14
+
15
+ Every plugin API argument and return value crosses the worker↔host RPC boundary by one
16
+ of exactly **two transports**. Choose the transport per type **before** writing the
17
+ signature — it is a contract decision, not an implementation detail. Authoritative design
18
+ record: [`PLUGIN_HANDLE_MIGRATION_HLD.md`](../../PLUGIN_HANDLE_MIGRATION_HLD.md) §2–§6.
19
+ Handle types + Zod schemas live in `src/handles.ts`.
20
+
21
+ ### The decision rule (Handle or value)
22
+
23
+ > **Is the type a JS primitive (`number` / `string` / `boolean`) or a string enum?**
24
+ > **Yes → value. No (any structured type) → handle.** No third option: no value DTOs, no
25
+ > `{x,y,z}`-as-input objects, no converter layer.
26
+
27
+ - A `Vec3`, `Quat`, `Line`, `Arc`, `Curve`, `Circle`, `Profile`, `Contour`, a BREP
28
+ topology object, or any scene entity is **structured → always a handle** — even a vec3,
29
+ which is "just three numbers". We never send its components across as an input object.
30
+ - A distance in mm, a boolean flag, a count, a `"round" | "square"` enum → **value**.
31
+ - **Reads are the one exception:** a read returns a bare **primitive record** (e.g.
32
+ `{ x, y, z }`) by value. That is not a value transport for a structured *type*; it is the
33
+ irreducible read leaf. A read must never mint a handle per call (§3).
34
+
35
+ ### Value transport — rules
36
+
37
+ - Primitives and enums only. No object arg may stand in for a structured type.
38
+ - Validated for **shape** at the router (`validateRPCCall`); numbers use Zod `.finite()`
39
+ wherever a schema exists. Trusted for shape only — never for identity or existence.
40
+ - Stateless: no arena, no registry, no lifecycle, no `dispose`.
41
+
42
+ ### Handle transport — rules
43
+
44
+ A handle is an opaque, kind-tagged string `"<kind>_<token>"` (`Handle<K>`), engine-free
45
+ and structured-clone-safe. The three method shapes:
46
+
47
+ - **Construction** — primitives in → handle out, async: `vec3.new({x,y,z}): Promise<Vec3Handle>`.
48
+ - **Operations** — handles in → handle out, async (every op is a host round-trip):
49
+ `vec3.add({a,b}): Promise<Vec3Handle>`.
50
+ - **Reads** — handle in → **primitive record out** (never a handle, never a DTO):
51
+ `vec3.components({v}): Promise<{x,y,z}>`.
52
+
53
+ Crossing/security rules:
54
+
55
+ - **Validation**: `handleSchema(kind)` checks only the `"<kind>_"` prefix at the trust
56
+ boundary; existence + kind + ownership are enforced host-side on resolve, and any miss
57
+ throws one `HANDLE_INVALID` (anti-oracle). Never resolve a handle in plugin-core.
58
+ - **Host wiring**: add a `register*`/`resolve*` pair in `plugins/handles/valueResolvers.ts`
59
+ (the one handle↔object converter) for value/resource handles. Entity handles are **not**
60
+ registered — they resolve live via the scene index. Reads build the record inline
61
+ (`{ x: v.x, y: v.y, z: v.z }`), never via a converter.
62
+
63
+ #### Handle classes — pick by lifecycle
64
+
65
+ All three are handles; they differ only in storage + lifecycle. Choose per backing object:
66
+
67
+ | Class | Kinds | Token shape | Storage | Lifecycle |
68
+ | ------------ | ---------------------------------------------------------------------------------- | ---------------------------------------- | ---------------------------------------------------------- | --------------------------------------------------------------- |
69
+ | **Value** | `vec3`, `quat`, `line`, `arc`, `curve`, `circle` | `<kind>_<token>` | value arena (quota 100k) | immutable; freed on plugin teardown; **not** deduped |
70
+ | **Resource** | `profile`, `contour`, `brep`, `face`, `edge`, `halfedge`, `vertex` | `<kind>_<token>` | resource arena (quota 10k) | session-ephemeral; explicit `dispose` + teardown; dedup by identity |
71
+ | **Entity** | `component`/`mass`, `material`, `story`, `referenceLine`, `department`, `buildableEnvelope` | raw `Component.id` / `Material.name` (**no prefix**) | not stored — resolved live via `StructureCollection` / `getMaterialByName` | scene-owned; stable across undo/redo; persistable across sessions |
72
+
73
+ - **Value vs Resource**: a lightweight immutable math/geom value with high churn → value
74
+ arena (big quota, no dispose obligation). A heavier engine object a plugin holds then
75
+ releases → resource arena (small quota, must `dispose`; deduped by object identity).
76
+ - **Entity**: any live scene object with a stable `Component.id` → entity handle. No arena,
77
+ no quota, no `<kind>_` prefix — the token IS the id, so it round-trips with the ids the
78
+ host already hands out.
79
+
13
80
  ## Quick commands
14
81
 
15
82
  ```bash
@@ -28,46 +95,42 @@ checklist:
28
95
 
29
96
  > See [`packages/plugin-client/AGENTS.md`](../../packages/plugin-client/AGENTS.md) for client-specific guidance.
30
97
 
31
- Every abstract method in `plugin-core` has a concrete implementation in `plugin-client`.
32
- The file structure mirrors this package 1:1:
33
-
34
- | plugin-core source | plugin-client counterpart |
35
- | ------------------------------------- | ------------------------------------------ |
36
- | `src/api/core/math/vec3.ts` | `src/api/core/math/vec3.ts` |
37
- | `src/api/core/math/quat.ts` | `src/api/core/math/quat.ts` |
38
- | `src/api/core/geom/line.ts` | `src/api/core/geom/line.ts` |
39
- | `src/api/core/geom/arc.ts` | `src/api/core/geom/arc.ts` |
40
- | `src/api/core/geom/curve.ts` | `src/api/core/geom/curve.ts` |
41
- | `src/api/core/geom/profile.ts` | `src/api/core/geom/profile.ts` |
42
- | `src/api/entity/space.ts` | `src/api/entity/space.ts` |
43
- | `src/api/entity/story.ts` | `src/api/entity/story.ts` |
44
- | `src/api/entity/referenceLine.ts` | `src/api/entity/referenceLine.ts` |
45
- | `src/api/entity/department.ts` | `src/api/entity/department.ts` |
46
- | `src/api/tools/selection.ts` | `src/api/tools/selection.ts` |
47
- | `src/api/tools/transform.ts` | `src/api/tools/transform.ts` |
48
- | `src/api/units/index.ts` | `src/api/units/index.ts` |
49
-
50
- - **New method**: Add the concrete implementation (pure math = direct impl; host API = `getHostApi().call(...)`)
51
- - **Removed method**: Delete from client
52
- - **Renamed/signature change**: Update the client method to match
53
- - **New API module** (new file): Create the corresponding client file and wire it into the parent barrel (`index.ts`)
98
+ Every abstract method in `plugin-core` is served to plugins by `plugin-client`, but the
99
+ client has **no per-method code**: every namespace is backed by a single generic RPC
100
+ proxy (`createRpcNamespace` in `src/rpc-proxy.ts`). All calls — including math and
101
+ geom are forwarded to the host; structured values cross as opaque handles.
102
+
103
+ | plugin-core source | plugin-client counterpart |
104
+ | ------------------- | ------------------------------------------------------------------ |
105
+ | `src/api/core/**` | `createRpcNamespace<PluginCoreApi>("core")` in `src/api/index.ts` |
106
+ | `src/api/design/**` | `createRpcNamespace<PluginDesignApi>("design")` in the same file |
107
+ | `src/api/entity/**` | `createRpcNamespace<PluginEntityApi>("entity")` in the same file |
108
+ | `src/api/tools/**` | `createRpcNamespace<PluginToolsApi>("tools")` in the same file |
109
+
110
+ - **New / removed / renamed method or signature change**: No client code change — the
111
+ proxy is generic and the types flow from plugin-core. Rebuild plugin-core so the
112
+ client picks up the new signatures.
113
+ - **New nested API module** (e.g. a new file under `core/` or `design/`): No client change
114
+ - **New top-level namespace**: Add a `createRpcNamespace<PluginXApi>("x")` property to
115
+ `ClientPluginApi` in `src/api/index.ts`
54
116
 
55
117
  ### 2. Host implementation — `apps/snaptrudereact/src/app/plugins/api/`
56
118
 
57
119
  > See [`apps/snaptrudereact/src/app/plugins/AGENTS.md`](../../apps/snaptrudereact/src/app/plugins/AGENTS.md) for host-specific guidance.
58
120
 
59
- Same 1:1 mirror. Host classes extend the abstract classes from plugin-core and provide
60
- the actual Snaptrude-internal implementation.
121
+ The host mirrors this package's `src/api/` file structure 1:1. Host classes extend the
122
+ abstract classes from plugin-core and provide the actual Snaptrude-internal implementation.
61
123
 
62
124
  - **New method**: Implement using Snaptrude internals. Use Zod `.parse()` for input validation.
63
125
  - **Removed method**: Delete from host
64
126
  - **Renamed/signature change**: Update the host method to match
65
127
  - **New API module**: Create the host file, wire into barrel, and add to `SnaptrudePluginApi` in `api/index.ts`
66
- - **New types/converters**: If the new API introduces types that bridge plugin <-> internal representations, add converters in `apps/snaptrudereact/src/app/plugins/converters/`
128
+ - **New structured type**: Structured types cross as opaque handles (all-handle model) there is no DTO converter layer. Add a `register*`/`resolve*` pair in the host's `plugins/handles/valueResolvers.ts` (the one handle ↔ live-object converter); reads return primitive records built inline via `handles/readRecords.ts`.
67
129
 
68
130
  ### 3. JSDoc — keep it complete
69
131
 
70
132
  All public methods and types **must** have JSDoc with:
133
+
71
134
  - A brief description
72
135
  - `@param` for each parameter (with type and description)
73
136
  - `@returns` description
@@ -91,17 +154,36 @@ In summary:
91
154
 
92
155
  These are in-browser integration tests that exercise the plugin API end-to-end.
93
156
 
94
- | plugin-core API module | Test file |
95
- | ----------------------------- | -------------------------- |
96
- | `core/math/*` | `tests/math.ts` |
97
- | `core/geom/*` | `tests/geom.ts` |
98
- | `entity/space.ts` | `tests/spaces.ts` |
99
- | `entity/story.ts` | `tests/story.ts` |
100
- | `entity/referenceLine.ts` | `tests/referenceLines.ts` |
101
- | `entity/department.ts` | `tests/departments.ts` |
102
- | `tools/selection.ts` | `tests/selection.ts` |
103
- | `tools/transform.ts` | `tests/transform.ts` |
104
- | `units/index.ts` | `tests/units.ts` |
157
+ | plugin-core API module | Test file |
158
+ | ------------------------------------------------- | ---------------------------- |
159
+ | `core/math/*` | `tests/math.ts` |
160
+ | `core/geom/*` (curve/arc/profile/contour) | `tests/geom.ts` |
161
+ | `core/geom/query/*` (brep/face/edge/vertex topology) | `tests/geomTopology.ts` |
162
+ | `core/units/*` | `tests/units.ts` |
163
+ | `core/history/*` | `tests/history.ts` |
164
+ | `core/zoom/*` | `tests/zoom.ts` |
165
+ | `core/project/*` | `tests/project.ts` |
166
+ | `core/comment/*` | `tests/comment.ts` |
167
+ | `design/boolean/*` | `tests/designBoolean.ts` |
168
+ | `design/create/*` | `tests/designCreate.ts` |
169
+ | `design/query/*` | `tests/designQuery.ts` |
170
+ | `design/selection/*` | `tests/designSelection.ts` |
171
+ | `design/lock.ts` | `tests/designLock.ts` |
172
+ | `design/delete/*` | `tests/delete.ts` |
173
+ | `design/erase/*` | `tests/erase.ts` |
174
+ | `design/doors/*` | `tests/doors.ts` |
175
+ | `design/windows/*` | `tests/windows.ts` |
176
+ | `design/furniture/*` | `tests/furniture.ts` |
177
+ | `design/materials/*` | `tests/materials.ts` |
178
+ | `entity/space.ts` | `tests/spaces.ts` |
179
+ | `entity/story.ts` | `tests/story.ts` |
180
+ | `entity/referenceLine.ts` | `tests/referenceLines.ts` |
181
+ | `entity/department.ts` | `tests/departments.ts` |
182
+ | `entity/buildableEnvelope.ts` | `tests/buildableEnvelope.ts` |
183
+ | `tools/selection.ts` | `tests/selection.ts` |
184
+ | `tools/transform.ts` | `tests/transform.ts` |
185
+ | `tools/copy.ts` | `tests/copy.ts` |
186
+ | `tools/offset.ts` | `tests/offset.ts` |
105
187
 
106
188
  - **New method**: Add test cases covering the new method
107
189
  - **Removed method**: Remove corresponding tests
@@ -111,11 +193,10 @@ These are in-browser integration tests that exercise the plugin API end-to-end.
111
193
  ### 6. Host-side Jest unit tests
112
194
 
113
195
  Some host implementations have co-located `.test.ts` files:
196
+
114
197
  - `api/core/math/vec3.test.ts`, `quat.test.ts`
115
- - `api/core/geom/line.test.ts`, `arc.test.ts`, `curve.test.ts`
116
- - `api/units/index.test.ts`
117
198
 
118
- If your change affects pure math/geom/units logic, update the corresponding Jest tests.
199
+ If your change affects pure math logic, update the corresponding Jest tests.
119
200
 
120
201
  ### 7. Downstream consumers (breaking changes only)
121
202
 
@@ -135,11 +216,12 @@ When adding an entirely new namespace (e.g. `snaptrude.materials`):
135
216
  1. **plugin-core**: Create abstract class + Zod schemas + types in `src/api/<namespace>/`
136
217
  2. **plugin-core**: Export from `src/api/index.ts` and add as property on `PluginApi`
137
218
  3. **plugin-core**: Verify `host-utils.ts` types auto-infer the new methods (they should via `ExtractMethodPaths`)
138
- 4. **plugin-client**: Create client implementation in `src/api/<namespace>/`
139
- 5. **plugin-client**: Wire into `ClientPluginApi` and export from `src/api/index.ts`
140
- 6. **host**: Create host implementation in `apps/snaptrudereact/src/app/plugins/api/<namespace>/`
141
- 7. **host**: Add to `SnaptrudePluginApi` class in `api/index.ts`
142
- 8. **docs**: Create doc pages, update sidebar, follow [`apps/snaptrudereact/api-docs/AGENTS.md`](../../apps/snaptrudereact/api-docs/AGENTS.md) template
143
- 9. **tests**: Add console test file + Jest tests for pure logic
144
- 10. **examples**: Update example plugins if they should showcase the new namespace
145
- 11. **build**: Run `pnpm check-types` in plugin-core, plugin-client, and snaptrudereact
219
+ 4. **plugin-client**: Only if it's a new **top-level** namespace, add a
220
+ `createRpcNamespace<PluginXApi>("x")` property to `ClientPluginApi` in
221
+ `src/api/index.ts` (nested namespaces need no client change)
222
+ 5. **host**: Create host implementation in `apps/snaptrudereact/src/app/plugins/api/<namespace>/`
223
+ 6. **host**: Add to `SnaptrudePluginApi` class in `api/index.ts`
224
+ 7. **docs**: Create doc pages, update sidebar, follow [`apps/snaptrudereact/api-docs/AGENTS.md`](../../apps/snaptrudereact/api-docs/AGENTS.md) template
225
+ 8. **tests**: Add console test file + Jest tests for pure logic
226
+ 9. **examples**: Update example plugins if they should showcase the new namespace
227
+ 10. **build**: Run `pnpm check-types` in plugin-core, plugin-client, and snaptrudereact
package/CHANGELOG.md ADDED
@@ -0,0 +1,163 @@
1
+ # @snaptrude/plugin-core
2
+
3
+ ## 0.6.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 934405e: New `analysis.heatmaps` family — render plugin-computed scalar data as a
8
+ heatmap: `renderSpaces` (flat colour per space top face), `renderGrid`
9
+ (coloured grid mesh from world-coordinate samples), `reset`, `isActive`.
10
+ Single active heatmap (a render replaces the previous one); values outside
11
+ `[min, max]` clamp to the end colours; ephemeral (auto-cleared on
12
+ scene-mutating edits, never persisted). The react host has landed, so all
13
+ members are required `abstract` and in the discovery manifest.
14
+ - a68e866: New top-level `analysis` namespace:
15
+ `analysis.sunpath` (enable/disable/isActive), `analysis.shadows`
16
+ (enable/disable/isEnabled/setDateTime/getDateTime — ISO date-time strings),
17
+ and the async heatmap job families `analysis.sunlightHours` and
18
+ `analysis.illuminance` (compute/get/cancel/reset; illuminance is Pro-gated).
19
+ Also extends `program.site` with `getLocation()` and `getNorthAngle()` geo
20
+ reads. The react host has landed, so all new members are required `abstract`
21
+ and in the discovery manifest; the plugin-client mounts the `analysis` RPC
22
+ namespace.
23
+ - New `core.io` namespace — file import, import jobs, and underlay/terrain
24
+ management:
25
+ - `core.io.import` — bring external files onto a storey: `image`, `pdf`
26
+ (page-selectable), `dwg`, `cadJson` (parsed CAD geometry as a sketch),
27
+ `model` (3D formats), and `terrain` (map snapshot at a lat/lng with
28
+ optional elevation). Slow formats return an `ImportJobHandle` instead of
29
+ blocking.
30
+ - `core.io.job` — poll those imports: `getStatus`, `isComplete`, `getResult`,
31
+ `getError`.
32
+ - `core.io.query` — pre-import inspection: `getPdfPageCount`,
33
+ `listCadLayers`.
34
+ - `core.io.underlay` — manage imported image/PDF/CAD underlays: `list`,
35
+ `getBounds`, `getScale`/`setScale`/`resetScale`, `getOpacity`/`setOpacity`,
36
+ `delete`.
37
+ - `core.io.terrain` — manage the imported map terrain: `exists`, `get`,
38
+ `getDatum` (current vertical position, world Y) / `setDatum` (relative
39
+ datum shift, not an absolute elevation), `delete`, `getReport`, elevation and satellite-imagery toggles
40
+ (`isElevationEnabled`/`enableElevation`/`disableElevation`,
41
+ `isSatelliteEnabled`/`enableSatellite`/`disableSatellite`), and
42
+ `getOpacity`/`setOpacity`.
43
+
44
+ - New `design.selection.setByFilter(filter)` — the programmatic equivalent of
45
+ the editor's **Story selection** and **Filter selection** menus. Replaces the
46
+ selection with every visible entity of the active building matching
47
+ `{ storeys?: number[], types?: PluginSelectionEntityType[] }` (fields AND,
48
+ values within a field OR; at least one field required — use `clear()` to
49
+ deselect). The new `PluginSelectionEntityType` vocabulary covers all 24 menu
50
+ kinds, including selection-only kinds the query surface can't reach (sites,
51
+ terrain, CAD/PDF/image imports, dimension lines, 3D models, neighborhood
52
+ buildings, program blocks). One-shot bulk select, not a persistent mode; not
53
+ undoable, like the other selection mutators.
54
+
55
+ ## 0.5.0
56
+
57
+ ### Minor Changes
58
+
59
+ - 7750aa3: Exposed more snaptrude APIs
60
+
61
+ ## 0.4.0
62
+
63
+ The Plugin API expose initiative. Pre-1.0, breaking changes ship as minor
64
+ version bumps.
65
+
66
+ ### Minor Changes
67
+
68
+ - **Breaking — positional arguments.** Every API method now takes positional
69
+ parameters, options-last (required first, then one optional `options`
70
+ object), replacing the single-args-object transport. Migrate by unwrapping
71
+ the object into positional args — `foo({ a, b, t })` → `foo(a, b, t)`. E.g.
72
+ `vec3.lerp(a, b, 0.5)`, `departments.assign(departmentId, spaceIds)`,
73
+ `design.query.spaces.get(space, ["area", "position"])`.
74
+ - **Breaking — handle-based boundary.** Only JS primitives and enum strings
75
+ cross the plugin ↔ host boundary by value. Every structured type (vector,
76
+ curve, profile, BREP topology, scene entity) is now an opaque, kind-tagged
77
+ string handle; scene-entity references use `ComponentHandle`. Migrate by
78
+ minting a handle instead of passing a raw object (`vec3.new(x, y, z)`, then
79
+ pass the handle) and reading values back with a query call
80
+ (`vec3.components(h)` → `{ x, y, z }`) — reads return primitive records,
81
+ never handles.
82
+ - **New namespaces.** Reorganized the surface into `core`, `design`, `entity`,
83
+ `program`, and `presentation`:
84
+ - `core`: `math` (`vec3`/`quat`), the `geom` geometry kernel, `history`
85
+ (undo/redo), `units`, `zoom`, `project`, `comment`, and the
86
+ `groups`/`buildings`/`layers`/`tags` organization families.
87
+ - `design`: `create`, `query` (+ `geom` query), `selection`, `doors`,
88
+ `windows`, `furniture`, `materials`, `boolean`, `erase`, `delete`,
89
+ `transform`, `edit`, `update`, plus top-level `lock`/`unlock`/`isLocked`/
90
+ `listLocked` verbs.
91
+ - `entity`: `story`, `referenceLine`, `buildableEnvelope`.
92
+ - `program`: `areas`, `departments`, `metrics`, `site`, `cores`,
93
+ `classification`, `adjacency`, and the `spreadsheet` reporting family.
94
+ - `presentation`: `views`, `sheets`, `diagrams`, `import`.
95
+ - Removed the legacy `entity.space.*` methods from the contract and
96
+ consolidated departments under `program.departments`. The selective space
97
+ property read is now `design.query.spaces.get`, and space adjacency is read
98
+ as an entity property via `design.query.getProperties().adjacency`. (The
99
+ host keeps a deprecated `entity.space.get` shim, but it is no longer part of
100
+ the published contract surface.)
101
+ - Added the `overlaps` entity filter to `design.query` list methods — matches
102
+ entities whose plan footprint has non-zero intersection area with a given
103
+ space's bottom-face footprint (fully-inside, boundary-nested, and overhanging
104
+ all match; edge-touching does not; holes respected). Hidden entities are
105
+ excluded unless `isHidden` is passed explicitly.
106
+ - Removed the never-shipped `computeAdjacencyMatrix`; renamed
107
+ `buildings.duplicate` → `buildings.copy`; folded `tags.createAndAssign` into
108
+ `tags.assign` (resolve-or-create, one atomic undo).
109
+
110
+ ## 0.2.8
111
+
112
+ ### Patch Changes
113
+
114
+ - 445e0b8: Add Present-mode AI Inspiration plugin APIs under `snaptrude.documentation.aiInspiration`.
115
+
116
+ ## 0.2.7
117
+
118
+ ### Patch Changes
119
+
120
+ - c5afd9a: added adjacecny
121
+
122
+ ## 0.2.6
123
+
124
+ ### Patch Changes
125
+
126
+ - c17d287: Add bulk space APIs: `space.bulkCreate`, `space.bulkUpdate`, and `space.bulkDelete`. Each batches its work into a single undo/redo step. All items are validated up front and the call throws if any item is invalid (nothing is applied), consistent with the single-item space methods. `bulkCreate` supports `spaceType`/`massType`/`departmentId` per item and returns `{ spaceIds }`; `bulkUpdate` takes geometry (`profile`+`extrudeHeight`) and/or nested `properties` per item and returns `{ spaces }` (one echoed result per item, like `update`); `bulkDelete` returns `{ deletedSpaceIds }`.
127
+ - 0683194: bulk apis
128
+
129
+ ## 0.2.5
130
+
131
+ ### Patch Changes
132
+
133
+ - Restore declaration files in published plugin packages.
134
+
135
+ ## 0.2.4
136
+
137
+ ### Patch Changes
138
+
139
+ - Add inner profile hole support to space creation from profiles.
140
+
141
+ ## 0.2.3
142
+
143
+ ### Patch Changes
144
+
145
+ - 647466b: fixed merge issues
146
+
147
+ ## 0.2.2
148
+
149
+ ### Patch Changes
150
+
151
+ - 064777a: buildable envelope apis
152
+
153
+ ## 0.2.1
154
+
155
+ ### Patch Changes
156
+
157
+ - 3b37f4a: added buildable envelop api
158
+
159
+ ## 0.2.0
160
+
161
+ ### Minor Changes
162
+
163
+ - 4d959a4: Exposed new offset and copy APIs for tools