@snaptrude/plugin-core 0.7.0 → 0.8.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 (133) hide show
  1. package/CHANGELOG.md +22 -0
  2. package/api-manifest.full.json +360 -19
  3. package/api-manifest.json +915 -37
  4. package/dist/api/core/camera/index.d.ts +208 -0
  5. package/dist/api/core/camera/index.d.ts.map +1 -0
  6. package/dist/api/core/comment/index.d.ts +105 -2
  7. package/dist/api/core/comment/index.d.ts.map +1 -1
  8. package/dist/api/core/geom/create/index.d.ts +13 -13
  9. package/dist/api/core/geom/delete/index.d.ts +8 -2
  10. package/dist/api/core/geom/delete/index.d.ts.map +1 -1
  11. package/dist/api/core/geom/query/arc.d.ts +5 -5
  12. package/dist/api/core/geom/query/brep.d.ts +18 -18
  13. package/dist/api/core/geom/query/circle.d.ts +18 -18
  14. package/dist/api/core/geom/query/contour.d.ts +20 -20
  15. package/dist/api/core/geom/query/curve.d.ts +49 -49
  16. package/dist/api/core/geom/query/edge.d.ts +5 -5
  17. package/dist/api/core/geom/query/face.d.ts +16 -16
  18. package/dist/api/core/geom/query/halfedge.d.ts +8 -8
  19. package/dist/api/core/geom/query/profile.d.ts +19 -19
  20. package/dist/api/core/geom/query/vertex.d.ts +8 -8
  21. package/dist/api/core/geom/update/contour.d.ts +14 -14
  22. package/dist/api/core/geom/update/curve.d.ts +7 -7
  23. package/dist/api/core/geom/update/profile.d.ts +16 -16
  24. package/dist/api/core/handles/index.d.ts +210 -0
  25. package/dist/api/core/handles/index.d.ts.map +1 -0
  26. package/dist/api/core/index.d.ts +15 -0
  27. package/dist/api/core/index.d.ts.map +1 -1
  28. package/dist/api/core/io/export/index.d.ts +132 -0
  29. package/dist/api/core/io/export/index.d.ts.map +1 -0
  30. package/dist/api/core/io/import/index.d.ts +1 -1
  31. package/dist/api/core/io/index.d.ts +5 -0
  32. package/dist/api/core/io/index.d.ts.map +1 -1
  33. package/dist/api/core/layers.d.ts +7 -7
  34. package/dist/api/core/proposals/index.d.ts +65 -9
  35. package/dist/api/core/proposals/index.d.ts.map +1 -1
  36. package/dist/api/core/user.d.ts +44 -0
  37. package/dist/api/core/user.d.ts.map +1 -0
  38. package/dist/api/design/boolean/index.d.ts +4 -4
  39. package/dist/api/design/create/index.d.ts +139 -44
  40. package/dist/api/design/create/index.d.ts.map +1 -1
  41. package/dist/api/design/doors/index.d.ts +36 -0
  42. package/dist/api/design/doors/index.d.ts.map +1 -1
  43. package/dist/api/design/edit/index.d.ts +1 -1
  44. package/dist/api/design/erase/index.d.ts +2 -2
  45. package/dist/api/design/furniture/index.d.ts +114 -3
  46. package/dist/api/design/furniture/index.d.ts.map +1 -1
  47. package/dist/api/design/index.d.ts +10 -0
  48. package/dist/api/design/index.d.ts.map +1 -1
  49. package/dist/api/design/materials/index.d.ts +111 -14
  50. package/dist/api/design/materials/index.d.ts.map +1 -1
  51. package/dist/api/design/query/index.d.ts +31 -1
  52. package/dist/api/design/query/index.d.ts.map +1 -1
  53. package/dist/api/design/query/spaces.d.ts +5 -5
  54. package/dist/api/design/transform/index.d.ts +83 -14
  55. package/dist/api/design/transform/index.d.ts.map +1 -1
  56. package/dist/api/design/types/index.d.ts +181 -0
  57. package/dist/api/design/types/index.d.ts.map +1 -0
  58. package/dist/api/design/update/index.d.ts +335 -2
  59. package/dist/api/design/update/index.d.ts.map +1 -1
  60. package/dist/api/design/visibility.d.ts +98 -0
  61. package/dist/api/design/visibility.d.ts.map +1 -0
  62. package/dist/api/entity/referenceLine.d.ts +2 -2
  63. package/dist/api/entity/space.d.ts +19 -19
  64. package/dist/api/entity/story.d.ts +128 -15
  65. package/dist/api/entity/story.d.ts.map +1 -1
  66. package/dist/api/presentation/aiInspiration.d.ts +1967 -7
  67. package/dist/api/presentation/aiInspiration.d.ts.map +1 -1
  68. package/dist/api/presentation/annotate.d.ts +448 -0
  69. package/dist/api/presentation/annotate.d.ts.map +1 -0
  70. package/dist/api/presentation/diagrams.d.ts +49 -8
  71. package/dist/api/presentation/diagrams.d.ts.map +1 -1
  72. package/dist/api/presentation/export.d.ts +104 -0
  73. package/dist/api/presentation/export.d.ts.map +1 -0
  74. package/dist/api/presentation/index.d.ts +40 -3
  75. package/dist/api/presentation/index.d.ts.map +1 -1
  76. package/dist/api/presentation/sheets.d.ts +410 -13
  77. package/dist/api/presentation/sheets.d.ts.map +1 -1
  78. package/dist/api/presentation/views.d.ts +165 -10
  79. package/dist/api/presentation/views.d.ts.map +1 -1
  80. package/dist/api/program/areas.d.ts +63 -3
  81. package/dist/api/program/areas.d.ts.map +1 -1
  82. package/dist/api/program/cores.d.ts +3 -99
  83. package/dist/api/program/cores.d.ts.map +1 -1
  84. package/dist/api/program/index.d.ts +2 -2
  85. package/dist/api/program/index.d.ts.map +1 -1
  86. package/dist/api/program/layout.d.ts +172 -12
  87. package/dist/api/program/layout.d.ts.map +1 -1
  88. package/dist/api/program/site.d.ts +11 -8
  89. package/dist/api/program/site.d.ts.map +1 -1
  90. package/dist/api/program/spreadsheet.d.ts +105 -13
  91. package/dist/api/program/spreadsheet.d.ts.map +1 -1
  92. package/dist/handles.d.ts +64 -25
  93. package/dist/handles.d.ts.map +1 -1
  94. package/dist/index.cjs +2502 -1466
  95. package/dist/index.cjs.map +1 -1
  96. package/dist/index.js +2369 -1461
  97. package/dist/index.js.map +1 -1
  98. package/package.json +1 -1
  99. package/src/api/core/camera/index.ts +212 -0
  100. package/src/api/core/comment/index.ts +120 -2
  101. package/src/api/core/geom/delete/index.ts +6 -0
  102. package/src/api/core/handles/index.ts +233 -0
  103. package/src/api/core/index.ts +15 -0
  104. package/src/api/core/io/export/index.ts +124 -0
  105. package/src/api/core/io/index.ts +5 -0
  106. package/src/api/core/proposals/index.ts +71 -11
  107. package/src/api/core/user.ts +46 -0
  108. package/src/api/design/create/index.ts +166 -36
  109. package/src/api/design/doors/index.ts +40 -0
  110. package/src/api/design/furniture/index.ts +127 -3
  111. package/src/api/design/index.ts +10 -0
  112. package/src/api/design/materials/index.ts +157 -30
  113. package/src/api/design/query/index.ts +33 -7
  114. package/src/api/design/transform/index.ts +89 -12
  115. package/src/api/design/types/index.ts +156 -0
  116. package/src/api/design/update/index.ts +402 -6
  117. package/src/api/design/visibility.ts +109 -0
  118. package/src/api/entity/story.ts +141 -15
  119. package/src/api/presentation/aiInspiration.ts +761 -7
  120. package/src/api/presentation/annotate.ts +360 -0
  121. package/src/api/presentation/diagrams.ts +53 -8
  122. package/src/api/presentation/export.ts +104 -0
  123. package/src/api/presentation/index.ts +48 -3
  124. package/src/api/presentation/sheets.ts +346 -13
  125. package/src/api/presentation/views.ts +164 -12
  126. package/src/api/program/areas.ts +57 -6
  127. package/src/api/program/cores.ts +3 -91
  128. package/src/api/program/index.ts +2 -2
  129. package/src/api/program/layout.ts +182 -12
  130. package/src/api/program/site.ts +11 -8
  131. package/src/api/program/spreadsheet.ts +125 -29
  132. package/src/handles.ts +77 -13
  133. package/tsconfig.json +7 -2
package/src/handles.ts CHANGED
@@ -1,22 +1,71 @@
1
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")
2
8
 
3
9
  /**
4
10
  * An opaque, kind-tagged reference to a host-side object that crosses the RPC
5
11
  * boundary by IDENTITY rather than by value. See `PLUGIN_API_EXPOSURE_HLD.md` §9.
6
12
  *
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.
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 (popup UI postMessage, persistence, logging):
26
+ * send {@linkcode Handle.id} — structured clone strips the class prototype.
11
27
  */
12
- export type Handle<K extends string> = string & { readonly __handle: K }
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>
13
59
 
14
60
  /**
15
61
  * A scene-entity handle. Backed by the host `Component.id` and resolved live via
16
62
  * the host scene index (StructureCollection) — never stored in the resource
17
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.
18
67
  */
19
- export type EntityId<K extends string = string> = Handle<K>
68
+ export type EntityId<K extends string = string> = string & { readonly __handle: K }
20
69
 
21
70
  /** Resource handle: a host-resident, session-ephemeral geometry object (§9.2). */
22
71
  export type ProfileHandle = Handle<"profile">
@@ -119,19 +168,34 @@ export type BBoxComponents = { min: Vec3Components; max: Vec3Components }
119
168
 
120
169
  /**
121
170
  * Build a Zod schema validating a handle of the given `kind` at the trust
122
- * boundary. It checks only the `"<kind>_"` prefix shape; existence, kind, and
123
- * ownership are enforced host-side by the HandleRegistry (§9.7). Keeping it to
124
- * the prefix is engine-free and avoids an existence oracle.
171
+ * boundary and emitting a {@linkcode Handle} instance for impl code. Inbound
172
+ * forms accepted:
173
+ * - the bare id string (the wire form the client unwraps args to ids)
174
+ * - a live `Handle` instance (host-internal re-parse, direct host callers)
175
+ * - `{ __h: string }` (the tagged result form, echoed back as an arg)
176
+ * - `{ id: string }` (a Handle stripped by structured clone at the popup-UI boundary)
177
+ * Shape checking stays prefix-only; existence, kind, and ownership are enforced
178
+ * host-side by the HandleRegistry (§9.7) — no existence oracle.
125
179
  */
126
180
  export const handleSchema = <K extends string>(kind: K) =>
127
181
  z
128
- .string()
129
- .regex(new RegExp(`^${kind}_[A-Za-z0-9_-]+$`), `expected a "${kind}" handle`)
130
- .transform((s) => s as Handle<K>)
182
+ .preprocess(
183
+ (v) => {
184
+ if (typeof v === "string") return v
185
+ if (v instanceof Handle) return v.id
186
+ if (v && typeof v === "object") {
187
+ const o = v as Record<string, unknown>
188
+ if (typeof o.__h === "string") return o.__h
189
+ if (typeof o.id === "string") return o.id
190
+ }
191
+ return v
192
+ },
193
+ z.string().regex(new RegExp(`^${kind}_[A-Za-z0-9_-]+$`), `expected a "${kind}" handle`)
194
+ )
195
+ .transform((s) => new Handle<K>(s))
131
196
 
132
197
  export const ProfileHandle = handleSchema("profile")
133
198
  export const ContourHandle = handleSchema("contour")
134
- export const MassHandle = handleSchema("mass")
135
199
 
136
200
  /**
137
201
  * Entity handles are raw `Component.id` strings (no `"<kind>_"` prefix) — validated
package/tsconfig.json CHANGED
@@ -3,7 +3,10 @@
3
3
  "target": "ES2020",
4
4
  "module": "ES2020",
5
5
  "moduleResolution": "bundler",
6
- "lib": ["ES2020"],
6
+ "lib": [
7
+ "ES2020",
8
+ "ESNext.Disposable"
9
+ ],
7
10
  "strict": true,
8
11
  "esModuleInterop": true,
9
12
  "skipLibCheck": true,
@@ -13,5 +16,7 @@
13
16
  "declarationMap": true,
14
17
  "outDir": "dist"
15
18
  },
16
- "include": ["src/**/*.ts"]
19
+ "include": [
20
+ "src/**/*.ts"
21
+ ]
17
22
  }