@snaptrude/plugin-core 1.0.1 → 1.0.2-plainpoint-20261026.2
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 +0 -6
- package/api-manifest.json +1581 -94
- package/dist/api/core/camera/index.d.ts +12 -4
- package/dist/api/core/camera/index.d.ts.map +1 -1
- package/dist/api/core/comment/index.d.ts +7 -3
- package/dist/api/core/comment/index.d.ts.map +1 -1
- package/dist/api/core/geom/create/index.d.ts +69 -21
- package/dist/api/core/geom/create/index.d.ts.map +1 -1
- package/dist/api/core/geom/query/circle.d.ts +31 -11
- package/dist/api/core/geom/query/circle.d.ts.map +1 -1
- package/dist/api/core/geom/query/contour.d.ts +19 -7
- package/dist/api/core/geom/query/contour.d.ts.map +1 -1
- package/dist/api/core/geom/query/curve.d.ts +72 -24
- package/dist/api/core/geom/query/curve.d.ts.map +1 -1
- package/dist/api/core/geom/query/profile.d.ts +19 -7
- package/dist/api/core/geom/query/profile.d.ts.map +1 -1
- package/dist/api/core/geom/update/contour.d.ts +36 -12
- package/dist/api/core/geom/update/contour.d.ts.map +1 -1
- package/dist/api/core/geom/update/curve.d.ts +13 -5
- package/dist/api/core/geom/update/curve.d.ts.map +1 -1
- package/dist/api/core/geom/update/profile.d.ts +36 -12
- package/dist/api/core/geom/update/profile.d.ts.map +1 -1
- package/dist/api/core/io/import/index.d.ts +7 -3
- package/dist/api/core/io/import/index.d.ts.map +1 -1
- package/dist/api/core/math/quat.d.ts +2 -2
- package/dist/api/core/math/quat.d.ts.map +1 -1
- package/dist/api/core/math/vec3.d.ts +15 -15
- package/dist/api/core/math/vec3.d.ts.map +1 -1
- package/dist/api/design/boolean/index.d.ts +20 -4
- package/dist/api/design/boolean/index.d.ts.map +1 -1
- package/dist/api/design/create/bulk-items.d.ts +20 -4
- package/dist/api/design/create/bulk-items.d.ts.map +1 -1
- package/dist/api/design/create/index.d.ts +67 -27
- package/dist/api/design/create/index.d.ts.map +1 -1
- package/dist/api/design/delete/index.d.ts +14 -7
- package/dist/api/design/delete/index.d.ts.map +1 -1
- package/dist/api/design/dimensions.d.ts +12 -4
- package/dist/api/design/dimensions.d.ts.map +1 -1
- package/dist/api/design/edit/index.d.ts +7 -3
- package/dist/api/design/edit/index.d.ts.map +1 -1
- package/dist/api/design/erase/index.d.ts +10 -2
- package/dist/api/design/erase/index.d.ts.map +1 -1
- package/dist/api/design/family.d.ts +5 -1
- package/dist/api/design/family.d.ts.map +1 -1
- package/dist/api/design/lock.d.ts +3 -0
- package/dist/api/design/lock.d.ts.map +1 -1
- package/dist/api/design/transform/index.d.ts +28 -8
- package/dist/api/design/transform/index.d.ts.map +1 -1
- package/dist/api/entity/space.d.ts +30 -6
- package/dist/api/entity/space.d.ts.map +1 -1
- package/dist/api/presentation/drawings.d.ts +1 -1
- package/dist/handles.d.ts +8 -0
- package/dist/handles.d.ts.map +1 -1
- package/dist/index.cjs +91 -79
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +90 -79
- package/dist/index.js.map +1 -1
- package/package.json +13 -13
- package/src/api/core/camera/index.ts +5 -5
- package/src/api/core/comment/index.ts +3 -3
- package/src/api/core/geom/create/index.ts +25 -25
- package/src/api/core/geom/query/circle.ts +11 -11
- package/src/api/core/geom/query/contour.ts +7 -6
- package/src/api/core/geom/query/curve.ts +25 -25
- package/src/api/core/geom/query/profile.ts +7 -6
- package/src/api/core/geom/update/contour.ts +12 -11
- package/src/api/core/geom/update/curve.ts +5 -5
- package/src/api/core/geom/update/profile.ts +12 -11
- package/src/api/core/io/import/index.ts +3 -2
- package/src/api/core/math/quat.ts +2 -2
- package/src/api/core/math/vec3.ts +16 -16
- package/src/api/design/boolean/index.ts +2 -2
- package/src/api/design/create/bulk-items.ts +3 -2
- package/src/api/design/create/index.ts +27 -26
- package/src/api/design/delete/index.ts +14 -7
- package/src/api/design/dimensions.ts +5 -4
- package/src/api/design/edit/index.ts +3 -3
- package/src/api/design/erase/index.ts +2 -2
- package/src/api/design/family.ts +2 -1
- package/src/api/design/lock.ts +6 -0
- package/src/api/design/transform/index.ts +15 -7
- package/src/api/entity/space.ts +5 -4
- package/src/handles.ts +11 -0
- package/test/handles.test.mjs +36 -0
|
@@ -5,6 +5,7 @@ import {
|
|
|
5
5
|
DimensionHandle,
|
|
6
6
|
Vec3Components,
|
|
7
7
|
Vec3Handle,
|
|
8
|
+
Vec3Input,
|
|
8
9
|
} from "../../handles"
|
|
9
10
|
|
|
10
11
|
/**
|
|
@@ -94,8 +95,8 @@ export abstract class PluginDesignDimensionsApi {
|
|
|
94
95
|
* ```
|
|
95
96
|
*/
|
|
96
97
|
public abstract create(
|
|
97
|
-
from:
|
|
98
|
-
to:
|
|
98
|
+
from: Vec3Input,
|
|
99
|
+
to: Vec3Input,
|
|
99
100
|
anchor: ComponentHandle,
|
|
100
101
|
options?: { anchorTo?: ComponentHandle; offset?: number },
|
|
101
102
|
): PluginApiReturn<DimensionHandle>
|
|
@@ -362,8 +363,8 @@ export type PluginDimensionsChangeResult = z.infer<
|
|
|
362
363
|
* TRANSPORT: positional args — validated host-side as this object.
|
|
363
364
|
*/
|
|
364
365
|
export const PluginDesignDimensionsCreateArgs = z.object({
|
|
365
|
-
from:
|
|
366
|
-
to:
|
|
366
|
+
from: Vec3Input,
|
|
367
|
+
to: Vec3Input,
|
|
367
368
|
anchor: ComponentHandle,
|
|
368
369
|
anchorTo: ComponentHandle.optional(),
|
|
369
370
|
offset: z.number().finite().optional(),
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as z from "zod"
|
|
2
2
|
import { PluginApiReturn } from "../../../types"
|
|
3
|
-
import { ComponentHandle,
|
|
3
|
+
import { ComponentHandle, Vec3Input } from "../../../handles"
|
|
4
4
|
import { OffsetSplitOutcome } from "../shared"
|
|
5
5
|
|
|
6
6
|
/**
|
|
@@ -41,7 +41,7 @@ export abstract class PluginDesignEditApi {
|
|
|
41
41
|
public abstract offsetSplit(
|
|
42
42
|
component: ComponentHandle,
|
|
43
43
|
offsetDistance: number,
|
|
44
|
-
options?: { profilePickPoint?:
|
|
44
|
+
options?: { profilePickPoint?: Vec3Input },
|
|
45
45
|
): PluginApiReturn<OffsetSplitOutcome>
|
|
46
46
|
}
|
|
47
47
|
|
|
@@ -49,6 +49,6 @@ export abstract class PluginDesignEditApi {
|
|
|
49
49
|
export const PluginDesignOffsetSplitArgs = z.object({
|
|
50
50
|
component: ComponentHandle,
|
|
51
51
|
offsetDistance: z.number(),
|
|
52
|
-
profilePickPoint:
|
|
52
|
+
profilePickPoint: Vec3Input.optional(),
|
|
53
53
|
})
|
|
54
54
|
export type PluginDesignOffsetSplitArgs = z.infer<typeof PluginDesignOffsetSplitArgs>
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as z from "zod"
|
|
2
2
|
import { PluginApiReturn } from "../../../types"
|
|
3
|
-
import { ComponentHandle,
|
|
3
|
+
import { ComponentHandle, Vec3Input } from "../../../handles"
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* The erase strategies exposed to plugins. `SplitAndUnion` is *enumerable* but
|
|
@@ -38,7 +38,7 @@ export const ErasableEdgeRef = z.object({
|
|
|
38
38
|
/** The components this edge is incident to — one for external (DirectDelete); two or more for internal (DirectUnion; 3+ at T-junctions where several masses share the edge). */
|
|
39
39
|
components: z.array(ComponentHandle),
|
|
40
40
|
/** A representative point on the edge (its head endpoint). Diagnostic only. */
|
|
41
|
-
snapPoint:
|
|
41
|
+
snapPoint: Vec3Input,
|
|
42
42
|
})
|
|
43
43
|
export type ErasableEdgeRef = z.infer<typeof ErasableEdgeRef>
|
|
44
44
|
|
package/src/api/design/family.ts
CHANGED
|
@@ -5,6 +5,7 @@ import {
|
|
|
5
5
|
ComponentHandle,
|
|
6
6
|
Vec3Components,
|
|
7
7
|
Vec3Handle,
|
|
8
|
+
Vec3Input,
|
|
8
9
|
} from "../../handles"
|
|
9
10
|
import { NetworkFamilyContract } from "./networks"
|
|
10
11
|
|
|
@@ -1319,7 +1320,7 @@ export type PluginDesignFamilyDeleteArgs = z.infer<
|
|
|
1319
1320
|
export const PluginDesignFamilyPlaceArgs = z.object({
|
|
1320
1321
|
id: z.string().optional(),
|
|
1321
1322
|
version: z.number().int().positive().optional(),
|
|
1322
|
-
position: z.union([
|
|
1323
|
+
position: z.union([Vec3Input, Vec3Components]).optional(),
|
|
1323
1324
|
rotation: z.number().optional(),
|
|
1324
1325
|
values: z.record(z.string(), z.union([z.number(), z.string()])).optional(),
|
|
1325
1326
|
storey: z.number().int().optional(),
|
package/src/api/design/lock.ts
CHANGED
|
@@ -9,6 +9,12 @@ import { ComponentHandle } from "../../handles"
|
|
|
9
9
|
*/
|
|
10
10
|
export const PluginDesignChangeResult = z.object({
|
|
11
11
|
affected: z.array(ComponentHandle),
|
|
12
|
+
/** Derived BIM (walls/floors/slabs) the parametric engine removed with its host. Delete only. */
|
|
13
|
+
cascaded: z.array(ComponentHandle).optional(),
|
|
14
|
+
/** Handles that no longer resolved when the call ran and were skipped. Delete only. */
|
|
15
|
+
missing: z.array(ComponentHandle).optional(),
|
|
16
|
+
/** Handles the engine accepted but left standing; delete them again or report them. Delete only. */
|
|
17
|
+
rejected: z.array(ComponentHandle).optional(),
|
|
12
18
|
})
|
|
13
19
|
export type PluginDesignChangeResult = z.infer<typeof PluginDesignChangeResult>
|
|
14
20
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as z from "zod"
|
|
2
2
|
import { PluginApiReturn } from "../../../types"
|
|
3
|
-
import { ComponentHandle, Vec3Handle } from "../../../handles"
|
|
3
|
+
import { ComponentHandle, Vec3Handle, Vec3Input } from "../../../handles"
|
|
4
4
|
import { PluginDesignChangeResult } from "../lock"
|
|
5
5
|
|
|
6
6
|
/**
|
|
@@ -22,9 +22,17 @@ export abstract class PluginDesignTransformApi {
|
|
|
22
22
|
* component's absolute position as the anchor). Undoable.
|
|
23
23
|
*
|
|
24
24
|
* @param components - Entities to move
|
|
25
|
-
* @param displacement - Relative translation as a {@linkcode Vec3Handle}
|
|
25
|
+
* @param displacement - Relative translation as a {@linkcode Vec3Handle}. A displacement
|
|
26
|
+
* shorter than 1e-6 is a no-op that succeeds (hosts before Oct 2026 throw
|
|
27
|
+
* `OPERATION_FAILED` "No movement occurred" instead, so skip the call when nothing moves).
|
|
26
28
|
* @param options - `is2D`, `trackParentChange`
|
|
27
29
|
* @returns {@linkcode PluginDesignChangeResult}
|
|
30
|
+
* @throws `OPERATION_FAILED` when the engine drops the whole move. A single connected
|
|
31
|
+
* parametric wall moves only across its own line: the vertical part and the part along
|
|
32
|
+
* the line are dropped. Move the whole connected run in one call to lift walls; to slide
|
|
33
|
+
* or lengthen one wall, delete it and create it again on the new line. Graph-bound walls
|
|
34
|
+
* made by Sketch-to-BIM refuse `move` outright (`TOPOLOGY_ERROR` / `ZERO_MOVEMENT`):
|
|
35
|
+
* adjust the room boundary that owns the wall instead.
|
|
28
36
|
*
|
|
29
37
|
* @examplePrompt Move the selected room 5 metres to the right
|
|
30
38
|
* @examplePrompt Shift these walls 3m along the x axis
|
|
@@ -43,7 +51,7 @@ export abstract class PluginDesignTransformApi {
|
|
|
43
51
|
*/
|
|
44
52
|
public abstract move(
|
|
45
53
|
components: ComponentHandle[],
|
|
46
|
-
displacement:
|
|
54
|
+
displacement: Vec3Input,
|
|
47
55
|
options?: { is2D?: boolean; trackParentChange?: boolean },
|
|
48
56
|
): PluginApiReturn<PluginDesignChangeResult>
|
|
49
57
|
|
|
@@ -81,7 +89,7 @@ export abstract class PluginDesignTransformApi {
|
|
|
81
89
|
public abstract rotate(
|
|
82
90
|
components: ComponentHandle[],
|
|
83
91
|
angleInDegrees: number,
|
|
84
|
-
options?: { axis?:
|
|
92
|
+
options?: { axis?: Vec3Input; pivot?: Vec3Input; is2D?: boolean },
|
|
85
93
|
): PluginApiReturn<PluginDesignChangeResult>
|
|
86
94
|
|
|
87
95
|
/**
|
|
@@ -205,7 +213,7 @@ export type PluginAlignEdge = z.infer<typeof PluginAlignEdge>
|
|
|
205
213
|
*/
|
|
206
214
|
export const PluginDesignMoveArgs = z.object({
|
|
207
215
|
components: z.array(ComponentHandle).min(1),
|
|
208
|
-
displacement:
|
|
216
|
+
displacement: Vec3Input,
|
|
209
217
|
is2D: z.boolean().optional(),
|
|
210
218
|
trackParentChange: z.boolean().optional(),
|
|
211
219
|
})
|
|
@@ -217,9 +225,9 @@ export type PluginDesignMoveArgs = z.infer<typeof PluginDesignMoveArgs>
|
|
|
217
225
|
export const PluginDesignRotateArgs = z.object({
|
|
218
226
|
components: z.array(ComponentHandle).min(1),
|
|
219
227
|
angleInDegrees: z.number(),
|
|
220
|
-
axis:
|
|
228
|
+
axis: Vec3Input.optional(),
|
|
221
229
|
is2D: z.boolean().optional(),
|
|
222
|
-
pivot:
|
|
230
|
+
pivot: Vec3Input.optional(),
|
|
223
231
|
})
|
|
224
232
|
export type PluginDesignRotateArgs = z.infer<typeof PluginDesignRotateArgs>
|
|
225
233
|
|
package/src/api/entity/space.ts
CHANGED
|
@@ -6,6 +6,7 @@ import * as z from "zod"
|
|
|
6
6
|
import {
|
|
7
7
|
ProfileHandle,
|
|
8
8
|
Vec3Handle,
|
|
9
|
+
Vec3Input,
|
|
9
10
|
Vec3Components,
|
|
10
11
|
QuatComponents,
|
|
11
12
|
CurveHandle,
|
|
@@ -21,7 +22,7 @@ import {
|
|
|
21
22
|
* | `dimensions` | `{ width, height, depth }` | Box dimensions in Babylon units |
|
|
22
23
|
*/
|
|
23
24
|
export const PluginSpaceCreateRectangularArgs = z.object({
|
|
24
|
-
position:
|
|
25
|
+
position: Vec3Input,
|
|
25
26
|
dimensions: z.object({
|
|
26
27
|
width: z.number(),
|
|
27
28
|
height: z.number(),
|
|
@@ -62,7 +63,7 @@ export const PluginSpaceCreateFromProfileArgs = z.object({
|
|
|
62
63
|
profile: ProfileHandle,
|
|
63
64
|
innerProfiles: z.array(ProfileHandle).optional(),
|
|
64
65
|
extrudeHeight: z.number(),
|
|
65
|
-
position:
|
|
66
|
+
position: Vec3Input,
|
|
66
67
|
})
|
|
67
68
|
|
|
68
69
|
export type PluginSpaceCreateFromProfileArgs = z.infer<
|
|
@@ -466,7 +467,7 @@ export type PluginSpaceUpdateResult = z.infer<typeof PluginSpaceUpdateResult>
|
|
|
466
467
|
export const PluginSpaceBulkCreateItem = z.discriminatedUnion("kind", [
|
|
467
468
|
z.object({
|
|
468
469
|
kind: z.literal("rectangular"),
|
|
469
|
-
position:
|
|
470
|
+
position: Vec3Input,
|
|
470
471
|
dimensions: z.object({
|
|
471
472
|
width: z.number(),
|
|
472
473
|
height: z.number(),
|
|
@@ -482,7 +483,7 @@ export const PluginSpaceBulkCreateItem = z.discriminatedUnion("kind", [
|
|
|
482
483
|
profile: ProfileHandle,
|
|
483
484
|
innerProfiles: z.array(ProfileHandle).optional(),
|
|
484
485
|
extrudeHeight: z.number(),
|
|
485
|
-
position:
|
|
486
|
+
position: Vec3Input,
|
|
486
487
|
room_type: z.string().optional(),
|
|
487
488
|
spaceType: PluginSpaceType.optional(),
|
|
488
489
|
massType: PluginMassType.optional(),
|
package/src/handles.ts
CHANGED
|
@@ -288,6 +288,17 @@ export const EdgeHandle = handleSchema("edge")
|
|
|
288
288
|
export const HalfEdgeHandle = handleSchema("halfedge")
|
|
289
289
|
export const VertexHandle = handleSchema("vertex")
|
|
290
290
|
export const Vec3Components = z.object({ x: z.number(), y: z.number(), z: z.number() })
|
|
291
|
+
/**
|
|
292
|
+
* A vec3 ARGUMENT: a {@linkcode Vec3Handle} in any inbound form, or a plain finite
|
|
293
|
+
* `{ x, y, z }` point. Geometry reads return plain points, and callers pass them straight
|
|
294
|
+
* back where a vec3 is expected; the host resolves the point as a vector. Returns stay
|
|
295
|
+
* {@linkcode Vec3Handle}. Explicitly typed to keep handles.d.ts inside its size budget.
|
|
296
|
+
*/
|
|
297
|
+
export type Vec3Input = Handle<"vec3"> | Vec3Components
|
|
298
|
+
export const Vec3Input: z.ZodUnion<readonly [typeof Vec3Handle, typeof Vec3Components]> = z.union(
|
|
299
|
+
[Vec3Handle, Vec3Components],
|
|
300
|
+
{ error: 'expected a "vec3" handle or a plain { x, y, z } point' }
|
|
301
|
+
)
|
|
291
302
|
export const QuatComponents = z.object({
|
|
292
303
|
x: z.number(),
|
|
293
304
|
y: z.number(),
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
// Node built-in test runner suite for the handle schemas.
|
|
2
|
+
// Imports the BUILT package (dist) — run `pnpm build` first.
|
|
3
|
+
import test from "node:test"
|
|
4
|
+
import assert from "node:assert/strict"
|
|
5
|
+
import { Vec3Handle, Vec3Input, Handle, PluginDesignMoveArgs } from "../dist/index.js"
|
|
6
|
+
|
|
7
|
+
test("a vec3 handle parses in every inbound form, and only as a handle", () => {
|
|
8
|
+
for (const v of ["vec3_abc", new Handle("vec3_abc"), { __h: "vec3_abc" }, { id: "vec3_abc" }]) {
|
|
9
|
+
const out = Vec3Handle.parse(v)
|
|
10
|
+
assert.ok(out instanceof Handle)
|
|
11
|
+
assert.equal(out.id, "vec3_abc")
|
|
12
|
+
}
|
|
13
|
+
assert.equal(Vec3Handle.safeParse({ x: 1, y: 2, z: 3 }).success, false)
|
|
14
|
+
const bad = Vec3Handle.safeParse("profile_1")
|
|
15
|
+
assert.equal(bad.success, false)
|
|
16
|
+
assert.match(bad.error.issues[0].message, /expected a "vec3" handle/)
|
|
17
|
+
})
|
|
18
|
+
|
|
19
|
+
test("Vec3Input takes a handle or a plain { x, y, z } point", () => {
|
|
20
|
+
// Geometry reads return plain points; agents pass them back where a vec3 belongs.
|
|
21
|
+
const point = { x: 1, y: 2.5, z: -3 }
|
|
22
|
+
assert.deepEqual(Vec3Input.parse(point), point)
|
|
23
|
+
assert.ok(Vec3Input.parse("vec3_abc") instanceof Handle)
|
|
24
|
+
const args = PluginDesignMoveArgs.parse({ components: ["wl_1"], displacement: { x: 0, y: 0, z: 10 } })
|
|
25
|
+
assert.deepEqual(args.displacement, { x: 0, y: 0, z: 10 })
|
|
26
|
+
const handled = PluginDesignMoveArgs.parse({ components: ["wl_1"], displacement: "vec3_d" })
|
|
27
|
+
assert.equal(handled.displacement.id, "vec3_d")
|
|
28
|
+
})
|
|
29
|
+
|
|
30
|
+
test("Vec3Input still rejects non-points and wrong handles, with one message", () => {
|
|
31
|
+
for (const v of [{ x: 1, y: 2 }, { x: 1, y: Number.NaN, z: 3 }, { x: "1", y: 2, z: 3 }, "profile_1", null, 42]) {
|
|
32
|
+
const r = Vec3Input.safeParse(v)
|
|
33
|
+
assert.equal(r.success, false, JSON.stringify(v))
|
|
34
|
+
assert.equal(r.error.issues[0].message, 'expected a "vec3" handle or a plain { x, y, z } point')
|
|
35
|
+
}
|
|
36
|
+
})
|