@snaptrude/plugin-core 0.7.1 → 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.
- package/CHANGELOG.md +14 -0
- package/api-manifest.full.json +6442 -0
- package/api-manifest.json +2029 -128
- package/dist/api/core/camera/index.d.ts +208 -0
- package/dist/api/core/camera/index.d.ts.map +1 -0
- package/dist/api/core/comment/index.d.ts +105 -2
- package/dist/api/core/comment/index.d.ts.map +1 -1
- package/dist/api/core/geom/create/index.d.ts +13 -13
- package/dist/api/core/geom/delete/index.d.ts +8 -2
- package/dist/api/core/geom/delete/index.d.ts.map +1 -1
- package/dist/api/core/geom/query/arc.d.ts +5 -5
- package/dist/api/core/geom/query/brep.d.ts +18 -18
- package/dist/api/core/geom/query/circle.d.ts +18 -18
- package/dist/api/core/geom/query/contour.d.ts +20 -20
- package/dist/api/core/geom/query/curve.d.ts +49 -49
- package/dist/api/core/geom/query/edge.d.ts +5 -5
- package/dist/api/core/geom/query/face.d.ts +16 -16
- package/dist/api/core/geom/query/halfedge.d.ts +8 -8
- package/dist/api/core/geom/query/profile.d.ts +19 -19
- package/dist/api/core/geom/query/vertex.d.ts +8 -8
- package/dist/api/core/geom/update/contour.d.ts +14 -14
- package/dist/api/core/geom/update/curve.d.ts +7 -7
- package/dist/api/core/geom/update/profile.d.ts +16 -16
- 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/index.d.ts +15 -0
- package/dist/api/core/index.d.ts.map +1 -1
- package/dist/api/core/io/export/index.d.ts +132 -0
- package/dist/api/core/io/export/index.d.ts.map +1 -0
- package/dist/api/core/io/import/index.d.ts +1 -1
- package/dist/api/core/io/index.d.ts +5 -0
- package/dist/api/core/io/index.d.ts.map +1 -1
- package/dist/api/core/layers.d.ts +7 -7
- package/dist/api/core/proposals/index.d.ts +65 -9
- package/dist/api/core/proposals/index.d.ts.map +1 -1
- package/dist/api/core/user.d.ts +44 -0
- package/dist/api/core/user.d.ts.map +1 -0
- package/dist/api/design/boolean/index.d.ts +4 -4
- package/dist/api/design/create/index.d.ts +139 -44
- package/dist/api/design/create/index.d.ts.map +1 -1
- package/dist/api/design/doors/index.d.ts +36 -0
- package/dist/api/design/doors/index.d.ts.map +1 -1
- package/dist/api/design/edit/index.d.ts +1 -1
- package/dist/api/design/erase/index.d.ts +2 -2
- package/dist/api/design/furniture/index.d.ts +114 -3
- package/dist/api/design/furniture/index.d.ts.map +1 -1
- package/dist/api/design/index.d.ts +10 -0
- package/dist/api/design/index.d.ts.map +1 -1
- package/dist/api/design/materials/index.d.ts +111 -14
- package/dist/api/design/materials/index.d.ts.map +1 -1
- package/dist/api/design/query/index.d.ts +31 -1
- package/dist/api/design/query/index.d.ts.map +1 -1
- package/dist/api/design/query/spaces.d.ts +5 -5
- package/dist/api/design/transform/index.d.ts +83 -14
- package/dist/api/design/transform/index.d.ts.map +1 -1
- 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 +335 -2
- package/dist/api/design/update/index.d.ts.map +1 -1
- package/dist/api/design/visibility.d.ts +98 -0
- package/dist/api/design/visibility.d.ts.map +1 -0
- package/dist/api/entity/referenceLine.d.ts +2 -2
- package/dist/api/entity/space.d.ts +19 -19
- package/dist/api/entity/story.d.ts +128 -15
- package/dist/api/entity/story.d.ts.map +1 -1
- package/dist/api/presentation/annotate.d.ts +448 -0
- package/dist/api/presentation/annotate.d.ts.map +1 -0
- package/dist/api/presentation/diagrams.d.ts +49 -8
- package/dist/api/presentation/diagrams.d.ts.map +1 -1
- package/dist/api/presentation/export.d.ts +104 -0
- package/dist/api/presentation/export.d.ts.map +1 -0
- package/dist/api/presentation/index.d.ts +38 -0
- package/dist/api/presentation/index.d.ts.map +1 -1
- package/dist/api/presentation/sheets.d.ts +410 -13
- package/dist/api/presentation/sheets.d.ts.map +1 -1
- package/dist/api/presentation/views.d.ts +165 -10
- package/dist/api/presentation/views.d.ts.map +1 -1
- package/dist/api/program/areas.d.ts +63 -3
- package/dist/api/program/areas.d.ts.map +1 -1
- package/dist/api/program/cores.d.ts +3 -99
- package/dist/api/program/cores.d.ts.map +1 -1
- package/dist/api/program/index.d.ts +2 -2
- package/dist/api/program/index.d.ts.map +1 -1
- package/dist/api/program/layout.d.ts +172 -12
- package/dist/api/program/layout.d.ts.map +1 -1
- package/dist/api/program/site.d.ts +11 -8
- package/dist/api/program/site.d.ts.map +1 -1
- package/dist/api/program/spreadsheet.d.ts +105 -13
- package/dist/api/program/spreadsheet.d.ts.map +1 -1
- package/dist/handles.d.ts +64 -25
- package/dist/handles.d.ts.map +1 -1
- package/dist/index.cjs +2316 -1644
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +2224 -1639
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/api/core/camera/index.ts +212 -0
- package/src/api/core/comment/index.ts +120 -2
- package/src/api/core/geom/delete/index.ts +6 -0
- package/src/api/core/handles/index.ts +233 -0
- package/src/api/core/index.ts +15 -0
- package/src/api/core/io/export/index.ts +124 -0
- package/src/api/core/io/index.ts +5 -0
- package/src/api/core/proposals/index.ts +71 -11
- package/src/api/core/user.ts +46 -0
- package/src/api/design/create/index.ts +166 -36
- package/src/api/design/doors/index.ts +40 -0
- package/src/api/design/furniture/index.ts +127 -3
- package/src/api/design/index.ts +10 -0
- package/src/api/design/materials/index.ts +157 -30
- package/src/api/design/query/index.ts +33 -7
- package/src/api/design/transform/index.ts +89 -12
- package/src/api/design/types/index.ts +156 -0
- package/src/api/design/update/index.ts +402 -6
- package/src/api/design/visibility.ts +109 -0
- package/src/api/entity/story.ts +141 -15
- package/src/api/presentation/annotate.ts +360 -0
- package/src/api/presentation/diagrams.ts +53 -8
- package/src/api/presentation/export.ts +104 -0
- package/src/api/presentation/index.ts +46 -0
- package/src/api/presentation/sheets.ts +346 -13
- package/src/api/presentation/views.ts +164 -12
- package/src/api/program/areas.ts +57 -6
- package/src/api/program/cores.ts +3 -91
- package/src/api/program/index.ts +2 -2
- package/src/api/program/layout.ts +182 -12
- package/src/api/program/site.ts +11 -8
- package/src/api/program/spreadsheet.ts +125 -29
- package/src/handles.ts +77 -13
- 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
|
-
*
|
|
8
|
-
* `Handle<"
|
|
9
|
-
*
|
|
10
|
-
*
|
|
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
|
|
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> =
|
|
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
|
|
123
|
-
*
|
|
124
|
-
* the
|
|
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
|
-
.
|
|
129
|
-
|
|
130
|
-
|
|
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": [
|
|
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": [
|
|
19
|
+
"include": [
|
|
20
|
+
"src/**/*.ts"
|
|
21
|
+
]
|
|
17
22
|
}
|