@snaptrude/plugin-core 1.0.2-plainpoint-20261102.2 → 1.0.3

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 (106) hide show
  1. package/AGENTS.md +17 -0
  2. package/CHANGELOG.md +6 -0
  3. package/api-manifest.json +35 -31
  4. package/dist/api/core/camera/index.d.ts +6 -16
  5. package/dist/api/core/camera/index.d.ts.map +1 -1
  6. package/dist/api/core/comment/index.d.ts +3 -7
  7. package/dist/api/core/comment/index.d.ts.map +1 -1
  8. package/dist/api/core/geom/create/index.d.ts +21 -69
  9. package/dist/api/core/geom/create/index.d.ts.map +1 -1
  10. package/dist/api/core/geom/query/circle.d.ts +11 -31
  11. package/dist/api/core/geom/query/circle.d.ts.map +1 -1
  12. package/dist/api/core/geom/query/contour.d.ts +7 -19
  13. package/dist/api/core/geom/query/contour.d.ts.map +1 -1
  14. package/dist/api/core/geom/query/curve.d.ts +24 -72
  15. package/dist/api/core/geom/query/curve.d.ts.map +1 -1
  16. package/dist/api/core/geom/query/profile.d.ts +7 -19
  17. package/dist/api/core/geom/query/profile.d.ts.map +1 -1
  18. package/dist/api/core/geom/update/contour.d.ts +12 -36
  19. package/dist/api/core/geom/update/contour.d.ts.map +1 -1
  20. package/dist/api/core/geom/update/curve.d.ts +5 -13
  21. package/dist/api/core/geom/update/curve.d.ts.map +1 -1
  22. package/dist/api/core/geom/update/profile.d.ts +12 -36
  23. package/dist/api/core/geom/update/profile.d.ts.map +1 -1
  24. package/dist/api/core/io/import/index.d.ts +3 -7
  25. package/dist/api/core/io/import/index.d.ts.map +1 -1
  26. package/dist/api/core/math/quat.d.ts +2 -2
  27. package/dist/api/core/math/quat.d.ts.map +1 -1
  28. package/dist/api/core/math/vec3.d.ts +15 -15
  29. package/dist/api/core/math/vec3.d.ts.map +1 -1
  30. package/dist/api/core/storeys/index.d.ts +0 -5
  31. package/dist/api/core/storeys/index.d.ts.map +1 -1
  32. package/dist/api/design/boolean/index.d.ts +4 -20
  33. package/dist/api/design/boolean/index.d.ts.map +1 -1
  34. package/dist/api/design/create/bulk-items.d.ts +20 -85
  35. package/dist/api/design/create/bulk-items.d.ts.map +1 -1
  36. package/dist/api/design/create/index.d.ts +71 -134
  37. package/dist/api/design/create/index.d.ts.map +1 -1
  38. package/dist/api/design/create/opening-fields.d.ts +6 -18
  39. package/dist/api/design/create/opening-fields.d.ts.map +1 -1
  40. package/dist/api/design/delete/index.d.ts +7 -14
  41. package/dist/api/design/delete/index.d.ts.map +1 -1
  42. package/dist/api/design/dimensions.d.ts +4 -12
  43. package/dist/api/design/dimensions.d.ts.map +1 -1
  44. package/dist/api/design/doors/index.d.ts +37 -0
  45. package/dist/api/design/doors/index.d.ts.map +1 -1
  46. package/dist/api/design/edit/index.d.ts +3 -7
  47. package/dist/api/design/edit/index.d.ts.map +1 -1
  48. package/dist/api/design/family.d.ts +1 -5
  49. package/dist/api/design/family.d.ts.map +1 -1
  50. package/dist/api/design/index.d.ts +1 -0
  51. package/dist/api/design/index.d.ts.map +1 -1
  52. package/dist/api/design/lock.d.ts +0 -3
  53. package/dist/api/design/lock.d.ts.map +1 -1
  54. package/dist/api/design/opening-placement.d.ts +123 -0
  55. package/dist/api/design/opening-placement.d.ts.map +1 -0
  56. package/dist/api/design/transform/index.d.ts +8 -28
  57. package/dist/api/design/transform/index.d.ts.map +1 -1
  58. package/dist/api/design/windows/index.d.ts +23 -0
  59. package/dist/api/design/windows/index.d.ts.map +1 -1
  60. package/dist/api/entity/space.d.ts +6 -30
  61. package/dist/api/entity/space.d.ts.map +1 -1
  62. package/dist/api/entity/story.d.ts +0 -4
  63. package/dist/api/entity/story.d.ts.map +1 -1
  64. package/dist/api/presentation/drawings.d.ts +1 -1
  65. package/dist/api/presentation/views.d.ts +1 -5
  66. package/dist/api/presentation/views.d.ts.map +1 -1
  67. package/dist/handles.d.ts +0 -8
  68. package/dist/handles.d.ts.map +1 -1
  69. package/dist/index.cjs +2496 -2441
  70. package/dist/index.cjs.map +1 -1
  71. package/dist/index.js +2493 -2440
  72. package/dist/index.js.map +1 -1
  73. package/package.json +13 -13
  74. package/src/api/core/camera/index.ts +7 -9
  75. package/src/api/core/comment/index.ts +3 -3
  76. package/src/api/core/geom/create/index.ts +25 -25
  77. package/src/api/core/geom/query/circle.ts +11 -11
  78. package/src/api/core/geom/query/contour.ts +6 -7
  79. package/src/api/core/geom/query/curve.ts +25 -25
  80. package/src/api/core/geom/query/profile.ts +6 -7
  81. package/src/api/core/geom/update/contour.ts +11 -12
  82. package/src/api/core/geom/update/curve.ts +5 -5
  83. package/src/api/core/geom/update/profile.ts +11 -12
  84. package/src/api/core/io/import/index.ts +2 -3
  85. package/src/api/core/math/quat.ts +2 -2
  86. package/src/api/core/math/vec3.ts +16 -16
  87. package/src/api/core/storeys/index.ts +0 -5
  88. package/src/api/design/boolean/index.ts +2 -2
  89. package/src/api/design/create/bulk-items.ts +6 -8
  90. package/src/api/design/create/index.ts +58 -34
  91. package/src/api/design/create/opening-fields.ts +7 -7
  92. package/src/api/design/delete/index.ts +7 -14
  93. package/src/api/design/dimensions.ts +4 -5
  94. package/src/api/design/doors/index.ts +43 -0
  95. package/src/api/design/edit/index.ts +3 -3
  96. package/src/api/design/family.ts +1 -2
  97. package/src/api/design/index.ts +1 -0
  98. package/src/api/design/lock.ts +0 -6
  99. package/src/api/design/opening-placement.ts +79 -0
  100. package/src/api/design/transform/index.ts +7 -15
  101. package/src/api/design/windows/index.ts +29 -0
  102. package/src/api/entity/space.ts +4 -5
  103. package/src/api/entity/story.ts +0 -4
  104. package/src/api/presentation/views.ts +2 -7
  105. package/src/handles.ts +0 -11
  106. package/test/handles.test.mjs +0 -36
@@ -1,6 +1,6 @@
1
1
  import * as z from "zod"
2
2
  import { PluginApiReturn } from "../../../types"
3
- import { ComponentHandle, Vec3Handle, Vec3Input } from "../../../handles"
3
+ import { ComponentHandle, Vec3Handle } from "../../../handles"
4
4
  import { PluginDesignChangeResult } from "../lock"
5
5
 
6
6
  /**
@@ -22,17 +22,9 @@ 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}. 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).
25
+ * @param displacement - Relative translation as a {@linkcode Vec3Handle}
28
26
  * @param options - `is2D`, `trackParentChange`
29
27
  * @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.
36
28
  *
37
29
  * @examplePrompt Move the selected room 5 metres to the right
38
30
  * @examplePrompt Shift these walls 3m along the x axis
@@ -51,7 +43,7 @@ export abstract class PluginDesignTransformApi {
51
43
  */
52
44
  public abstract move(
53
45
  components: ComponentHandle[],
54
- displacement: Vec3Input,
46
+ displacement: Vec3Handle,
55
47
  options?: { is2D?: boolean; trackParentChange?: boolean },
56
48
  ): PluginApiReturn<PluginDesignChangeResult>
57
49
 
@@ -89,7 +81,7 @@ export abstract class PluginDesignTransformApi {
89
81
  public abstract rotate(
90
82
  components: ComponentHandle[],
91
83
  angleInDegrees: number,
92
- options?: { axis?: Vec3Input; pivot?: Vec3Input; is2D?: boolean },
84
+ options?: { axis?: Vec3Handle; pivot?: Vec3Handle; is2D?: boolean },
93
85
  ): PluginApiReturn<PluginDesignChangeResult>
94
86
 
95
87
  /**
@@ -213,7 +205,7 @@ export type PluginAlignEdge = z.infer<typeof PluginAlignEdge>
213
205
  */
214
206
  export const PluginDesignMoveArgs = z.object({
215
207
  components: z.array(ComponentHandle).min(1),
216
- displacement: Vec3Input,
208
+ displacement: Vec3Handle,
217
209
  is2D: z.boolean().optional(),
218
210
  trackParentChange: z.boolean().optional(),
219
211
  })
@@ -225,9 +217,9 @@ export type PluginDesignMoveArgs = z.infer<typeof PluginDesignMoveArgs>
225
217
  export const PluginDesignRotateArgs = z.object({
226
218
  components: z.array(ComponentHandle).min(1),
227
219
  angleInDegrees: z.number(),
228
- axis: Vec3Input.optional(),
220
+ axis: Vec3Handle.optional(),
229
221
  is2D: z.boolean().optional(),
230
- pivot: Vec3Input.optional(),
222
+ pivot: Vec3Handle.optional(),
231
223
  })
232
224
  export type PluginDesignRotateArgs = z.infer<typeof PluginDesignRotateArgs>
233
225
 
@@ -3,6 +3,10 @@ import { PluginApiReturn } from "../../../types"
3
3
  import { ComponentHandle } from "../../../handles"
4
4
  import { PluginDesignChangeResult } from "../lock"
5
5
  import { PluginObjectCatalogGroup, PluginObjectCatalogItem } from "../doors"
6
+ import type {
7
+ PluginOpeningPlacementArgs,
8
+ PluginOpeningPlacementResult,
9
+ } from "../opening-placement"
6
10
 
7
11
  /**
8
12
  * `snaptrude.design.windows` — window-specific reads. Creation lives at
@@ -22,6 +26,31 @@ import { PluginObjectCatalogGroup, PluginObjectCatalogItem } from "../doors"
22
26
  export abstract class PluginDesignWindowsApi {
23
27
  constructor() {}
24
28
 
29
+ /**
30
+ * Trial the native host fit and geometry rebuild, then restore the model without publishing commands.
31
+ * The first result uses the creation options; subsequent results use candidateWidths in input order.
32
+ * Widths are authored parameters, not physical envelopes or a guaranteed maximum width.
33
+ * No catalog save, history entry or model persistence occurs. Rerun after model edits.
34
+ * A failed fit leaves cut unverified. Family-host cuts are also unverified: their rebuild
35
+ * cannot supply a reversible, authoritative trial result. Material clearance checks evaluated
36
+ * parts against physical neighbours across hosts. The intended host uses native fit/cut checks.
37
+ * Creation repeats clearance immediately before placement; this report grants no later approval.
38
+ * Editing permission is required; locked hosts and an active opening tool reject.
39
+ * A requested width/height on a family sized by its Type (Custom Sizes off) picks the Type
40
+ * within 25 mm, else turns Custom Sizes on; each result's `sizing` says which. Creation
41
+ * (`design.create.window(s)`) applies the same rule, so the size you pass is the size built.
42
+ * @param options Window creation options and up to 12 alternative widths; numeric lengths use SU.
43
+ * @returns Separate fit/cut/clearance evidence, evaluated bounds and explicit limitations.
44
+ * @examplePrompt Check whether this window fits and its host can be cut
45
+ * @example
46
+ * const result = await snaptrude.design.windows.checkPlacement({
47
+ * familyId, version, hostWall, position, width: 4, sillHeight: 3,
48
+ * })
49
+ */
50
+ public abstract checkPlacement(
51
+ options: PluginOpeningPlacementArgs,
52
+ ): PluginApiReturn<PluginOpeningPlacementResult>
53
+
25
54
  /**
26
55
  * Get the type name of a window — the label that identifies which kind of
27
56
  * window the instance is, as shown in its properties.
@@ -6,7 +6,6 @@ import * as z from "zod"
6
6
  import {
7
7
  ProfileHandle,
8
8
  Vec3Handle,
9
- Vec3Input,
10
9
  Vec3Components,
11
10
  QuatComponents,
12
11
  CurveHandle,
@@ -22,7 +21,7 @@ import {
22
21
  * | `dimensions` | `{ width, height, depth }` | Box dimensions in Babylon units |
23
22
  */
24
23
  export const PluginSpaceCreateRectangularArgs = z.object({
25
- position: Vec3Input,
24
+ position: Vec3Handle,
26
25
  dimensions: z.object({
27
26
  width: z.number(),
28
27
  height: z.number(),
@@ -63,7 +62,7 @@ export const PluginSpaceCreateFromProfileArgs = z.object({
63
62
  profile: ProfileHandle,
64
63
  innerProfiles: z.array(ProfileHandle).optional(),
65
64
  extrudeHeight: z.number(),
66
- position: Vec3Input,
65
+ position: Vec3Handle,
67
66
  })
68
67
 
69
68
  export type PluginSpaceCreateFromProfileArgs = z.infer<
@@ -467,7 +466,7 @@ export type PluginSpaceUpdateResult = z.infer<typeof PluginSpaceUpdateResult>
467
466
  export const PluginSpaceBulkCreateItem = z.discriminatedUnion("kind", [
468
467
  z.object({
469
468
  kind: z.literal("rectangular"),
470
- position: Vec3Input,
469
+ position: Vec3Handle,
471
470
  dimensions: z.object({
472
471
  width: z.number(),
473
472
  height: z.number(),
@@ -483,7 +482,7 @@ export const PluginSpaceBulkCreateItem = z.discriminatedUnion("kind", [
483
482
  profile: ProfileHandle,
484
483
  innerProfiles: z.array(ProfileHandle).optional(),
485
484
  extrudeHeight: z.number(),
486
- position: Vec3Input,
485
+ position: Vec3Handle,
487
486
  room_type: z.string().optional(),
488
487
  spaceType: PluginSpaceType.optional(),
489
488
  massType: PluginMassType.optional(),
@@ -88,10 +88,6 @@ export abstract class PluginStoryApi {
88
88
  * @returns A {@linkcode PluginStoryCreateResult} with `storyId` and `storyValue`
89
89
  * @throws If a story with the given value already exists or creation fails
90
90
  *
91
- * Storeys are added at the ends of the stack only: a value above the top also creates
92
- * every storey in between (returning only the requested one), and a value inside a gap
93
- * is refused.
94
- *
95
91
  * @examplePrompt Add a third floor to the building
96
92
  * @examplePrompt Create a new storey above the second floor
97
93
  * @examplePrompt Add a basement level to this project
@@ -522,13 +522,8 @@ export type PluginPresentationViewsCreateArgs = z.infer<
522
522
  typeof PluginPresentationViewsCreateArgs
523
523
  >
524
524
 
525
- /**
526
- * Result of {@linkcode PluginPresentationViewsApi.create} — the saved view, plus `framed`:
527
- * whether the view was framed on the given elements or bounds (always `false` without `frame`).
528
- */
529
- export const PluginPresentationViewsCreateResult = PluginPresentationView.extend({
530
- framed: z.boolean().optional(),
531
- })
525
+ /** Result of {@linkcode PluginPresentationViewsApi.create} — the saved view. */
526
+ export const PluginPresentationViewsCreateResult = PluginPresentationView
532
527
  export type PluginPresentationViewsCreateResult = z.infer<
533
528
  typeof PluginPresentationViewsCreateResult
534
529
  >
package/src/handles.ts CHANGED
@@ -288,17 +288,6 @@ 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
- )
302
291
  export const QuatComponents = z.object({
303
292
  x: z.number(),
304
293
  y: z.number(),
@@ -1,36 +0,0 @@
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
- })