@snaptrude/plugin-core 0.9.6 → 0.9.8

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 (37) hide show
  1. package/CHANGELOG.md +24 -0
  2. package/api-manifest.full.json +8443 -0
  3. package/api-manifest.json +167 -10
  4. package/dist/api/core/io/import/index.d.ts +3 -1
  5. package/dist/api/core/io/import/index.d.ts.map +1 -1
  6. package/dist/api/design/create/bulk-items.d.ts +185 -0
  7. package/dist/api/design/create/bulk-items.d.ts.map +1 -0
  8. package/dist/api/design/create/index.d.ts +310 -22
  9. package/dist/api/design/create/index.d.ts.map +1 -1
  10. package/dist/api/design/create/opening-fields.d.ts +37 -0
  11. package/dist/api/design/create/opening-fields.d.ts.map +1 -0
  12. package/dist/api/design/delete/index.d.ts +4 -0
  13. package/dist/api/design/delete/index.d.ts.map +1 -1
  14. package/dist/api/design/dimensions.d.ts +427 -0
  15. package/dist/api/design/dimensions.d.ts.map +1 -0
  16. package/dist/api/design/doors/index.d.ts +20 -13
  17. package/dist/api/design/doors/index.d.ts.map +1 -1
  18. package/dist/api/design/index.d.ts +5 -0
  19. package/dist/api/design/index.d.ts.map +1 -1
  20. package/dist/api/presentation/annotate.d.ts +2 -2
  21. package/dist/api/presentation/shapes.d.ts +2 -2
  22. package/dist/handles.d.ts +19 -0
  23. package/dist/handles.d.ts.map +1 -1
  24. package/dist/index.cjs +2011 -1869
  25. package/dist/index.cjs.map +1 -1
  26. package/dist/index.js +1988 -1869
  27. package/dist/index.js.map +1 -1
  28. package/package.json +1 -1
  29. package/src/api/core/io/import/index.ts +11 -3
  30. package/src/api/design/create/bulk-items.ts +186 -0
  31. package/src/api/design/create/index.ts +335 -38
  32. package/src/api/design/create/opening-fields.ts +37 -0
  33. package/src/api/design/delete/index.ts +4 -0
  34. package/src/api/design/dimensions.ts +453 -0
  35. package/src/api/design/doors/index.ts +20 -13
  36. package/src/api/design/index.ts +5 -0
  37. package/src/handles.ts +24 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@snaptrude/plugin-core",
3
- "version": "0.9.6",
3
+ "version": "0.9.8",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.js",
@@ -183,7 +183,10 @@ export abstract class PluginCoreIoImportApi {
183
183
  * if (cad) console.log("DWG imported as CAD underlay:", cad)
184
184
  * ```
185
185
  */
186
- public abstract dwg(source: string, storey?: number): PluginApiReturn<ImportJobHandle>
186
+ public abstract dwg(
187
+ source: string,
188
+ storey?: number,
189
+ ): PluginApiReturn<ImportJobHandle>
187
190
 
188
191
  /**
189
192
  * Sketch a CAD underlay from **already-parsed CAD JSON** — synchronous, with no
@@ -214,7 +217,10 @@ export abstract class PluginCoreIoImportApi {
214
217
  * )
215
218
  * ```
216
219
  */
217
- public abstract cadJson(cad: CadJsonInput, storey?: number): PluginApiReturn<UnderlayHandle>
220
+ public abstract cadJson(
221
+ cad: CadJsonInput,
222
+ storey?: number,
223
+ ): PluginApiReturn<UnderlayHandle>
218
224
 
219
225
  /**
220
226
  * Import a **3D model** file and place it in the scene as a component.
@@ -239,7 +245,9 @@ export abstract class PluginCoreIoImportApi {
239
245
  * @returns the placed {@linkcode ComponentHandle}.
240
246
  * @throws if writes are disabled, the source can't be loaded, the format is
241
247
  * unsupported, conversion/placement fails, or the converted model cannot be
242
- * found in the library after upload.
248
+ * found in the library after upload; `PRECONDITION_FAILED`
249
+ * (`details.engineCode: "TOOL_ACTIVE"`) while the interactive furniture tool is
250
+ * active — finish or cancel it first.
243
251
  *
244
252
  * @examplePrompt Import this SketchUp model onto storey 1
245
253
  * @examplePrompt Bring in this OBJ file and place it at the origin
@@ -0,0 +1,186 @@
1
+ import * as z from "zod"
2
+ import { ContourHandle, ProfileHandle, Vec3Handle } from "../../../handles"
3
+ import { PluginOpeningBaseOptions } from "./opening-fields"
4
+
5
+ /**
6
+ * Maximum items per bulk `design.create.*` call. A bounded request keeps
7
+ * validation, command capture and rollback work finite; split a larger import
8
+ * into separate awaited batches, each with its own undo entry.
9
+ */
10
+ export const PLUGIN_CREATE_BATCH_LIMIT = 1000
11
+
12
+ // ---------------------------------------------------------------------------
13
+ // wallRuns
14
+ // ---------------------------------------------------------------------------
15
+
16
+ /**
17
+ * One wall run to create via {@linkcode PluginDesignCreateApi.wallRuns} — the
18
+ * same inputs as {@linkcode PluginDesignCreateApi.walls}, one run per item.
19
+ *
20
+ * | Property | Type | Description |
21
+ * |---|---|---|
22
+ * | `profile` | {@linkcode ProfileHandle} | Ordered curve chain (wall centerlines) |
23
+ * | `height` | `number`? | Wall height (Snaptrude units, > 0; default engine default) |
24
+ * | `thickness` | `number`? | Wall thickness (Snaptrude units, > 0; default: `wallType`'s total layer thickness when given, else engine default) |
25
+ * | `wallType` | `string`? | Wall type name from `design.types.list("wall")` — layers/material/thickness defaults (default generic) |
26
+ * | `storey` | `number`? (int) | Target storey (must exist) — the run's walls are assigned + lifted to its base in the same undo entry (default: geometry-derived) |
27
+ */
28
+ export const PluginCreateWallRunItem = z.object({
29
+ profile: ProfileHandle,
30
+ height: z.number().optional(),
31
+ thickness: z.number().optional(),
32
+ wallType: z.string().min(1).optional(),
33
+ storey: z.number().int().optional(),
34
+ })
35
+ export type PluginCreateWallRunItem = z.infer<typeof PluginCreateWallRunItem>
36
+
37
+ /** The `items` array of {@linkcode PluginDesignCreateApi.wallRuns} (1…1000). */
38
+ export const PluginCreateWallRunItems = z
39
+ .array(PluginCreateWallRunItem)
40
+ .min(1)
41
+ .max(PLUGIN_CREATE_BATCH_LIMIT)
42
+ export type PluginCreateWallRunItems = z.infer<typeof PluginCreateWallRunItems>
43
+
44
+ // ---------------------------------------------------------------------------
45
+ // floors
46
+ // ---------------------------------------------------------------------------
47
+
48
+ /**
49
+ * One floor to create via {@linkcode PluginDesignCreateApi.floors} — the same
50
+ * footprint-extrude inputs as {@linkcode PluginDesignCreateApi.floor}.
51
+ *
52
+ * | Property | Type | Description |
53
+ * |---|---|---|
54
+ * | `contour` | {@linkcode ContourHandle} | Footprint (outer profile + holes) |
55
+ * | `thickness` | `number` | Floor thickness (Snaptrude units, > 0) |
56
+ * | `position` | {@linkcode Vec3Handle}? | Offset from origin (default origin) |
57
+ */
58
+ export const PluginCreateFloorItem = z.object({
59
+ contour: ContourHandle,
60
+ thickness: z.number(),
61
+ position: Vec3Handle.optional(),
62
+ })
63
+ export type PluginCreateFloorItem = z.infer<typeof PluginCreateFloorItem>
64
+
65
+ /** The `items` array of {@linkcode PluginDesignCreateApi.floors} (1…1000). */
66
+ export const PluginCreateFloorItems = z
67
+ .array(PluginCreateFloorItem)
68
+ .min(1)
69
+ .max(PLUGIN_CREATE_BATCH_LIMIT)
70
+ export type PluginCreateFloorItems = z.infer<typeof PluginCreateFloorItems>
71
+
72
+ // ---------------------------------------------------------------------------
73
+ // doors / windows
74
+ // ---------------------------------------------------------------------------
75
+
76
+ /**
77
+ * One door to place via {@linkcode PluginDesignCreateApi.doors} — the same
78
+ * fields as a `"door"` {@linkcode PluginDesignCreateOpeningOptions}, so the
79
+ * size overrides singular {@linkcode PluginDesignCreateApi.door} lacks are
80
+ * available per item. `facing` and `hinge` are WORLD POINTS, not directions:
81
+ * `facing` on the side of the wall the door swings open to, `hinge` near the
82
+ * jamb it is hinged on. Rejects unknown fields.
83
+ *
84
+ * | Property | Type | Description |
85
+ * |---|---|---|
86
+ * | `catalogId` | `string` | Library id: team `_id` or general `fullName` |
87
+ * | `hostWall` | {@linkcode ComponentHandle} | The wall to host the door |
88
+ * | `position` | {@linkcode Vec3Handle} | World point projected onto the wall |
89
+ * | `facing` | {@linkcode Vec3Handle}? | World point on the side the door swings open to (default engine-chosen) |
90
+ * | `hinge` | {@linkcode Vec3Handle}? | World point near the jamb the door is hinged on (default the catalog item's authored side) |
91
+ * | `label` | `string`? | Instance name (optional) |
92
+ * | `width` | `number`? | Width override (Snaptrude units, > 0; default the catalog item's) |
93
+ * | `height` | `number`? | Height override (Snaptrude units, > 0; default the catalog item's) |
94
+ */
95
+ export const PluginCreateDoorItem = z
96
+ .object({ ...PluginOpeningBaseOptions })
97
+ .strict()
98
+ export type PluginCreateDoorItem = z.infer<typeof PluginCreateDoorItem>
99
+
100
+ /** The `items` array of {@linkcode PluginDesignCreateApi.doors} (1…1000). */
101
+ export const PluginCreateDoorItems = z
102
+ .array(PluginCreateDoorItem)
103
+ .min(1)
104
+ .max(PLUGIN_CREATE_BATCH_LIMIT)
105
+ export type PluginCreateDoorItems = z.infer<typeof PluginCreateDoorItems>
106
+
107
+ /**
108
+ * One window to place via {@linkcode PluginDesignCreateApi.windows} — the same
109
+ * fields as a `"window"` {@linkcode PluginDesignCreateOpeningOptions}.
110
+ * `sillHeight` is a nonnegative Snaptrude-unit distance from the host wall's
111
+ * base to the BOTTOM of the window, not to its center. `facing` and `hinge`
112
+ * are WORLD POINTS, not directions: `facing` on the side of the wall the
113
+ * window opens to, `hinge` near the jamb it is hinged on. Rejects unknown
114
+ * fields.
115
+ *
116
+ * | Property | Type | Description |
117
+ * |---|---|---|
118
+ * | `catalogId` | `string` | Library id: team `_id` or general `fullName` |
119
+ * | `hostWall` | {@linkcode ComponentHandle} | The wall to host the window |
120
+ * | `position` | {@linkcode Vec3Handle} | World point projected onto the wall |
121
+ * | `facing` | {@linkcode Vec3Handle}? | World point on the side the window opens to (default engine-chosen) |
122
+ * | `hinge` | {@linkcode Vec3Handle}? | World point near the jamb the window is hinged on (default the catalog item's authored side) |
123
+ * | `label` | `string`? | Instance name (optional) |
124
+ * | `width` | `number`? | Width override (Snaptrude units, > 0; default the catalog item's) |
125
+ * | `height` | `number`? | Height override (Snaptrude units, > 0; default the catalog item's) |
126
+ * | `sillHeight` | `number`? | Wall base to window bottom (Snaptrude units, ≥ 0; default the catalog item's) |
127
+ */
128
+ export const PluginCreateWindowItem = z
129
+ .object({
130
+ ...PluginOpeningBaseOptions,
131
+ sillHeight: z.number().finite().nonnegative().optional(),
132
+ })
133
+ .strict()
134
+ export type PluginCreateWindowItem = z.infer<typeof PluginCreateWindowItem>
135
+
136
+ /** The `items` array of {@linkcode PluginDesignCreateApi.windows} (1…1000). */
137
+ export const PluginCreateWindowItems = z
138
+ .array(PluginCreateWindowItem)
139
+ .min(1)
140
+ .max(PLUGIN_CREATE_BATCH_LIMIT)
141
+ export type PluginCreateWindowItems = z.infer<typeof PluginCreateWindowItems>
142
+
143
+ // ---------------------------------------------------------------------------
144
+ // furnitureItems
145
+ // ---------------------------------------------------------------------------
146
+
147
+ /**
148
+ * One furniture instance to place via
149
+ * {@linkcode PluginDesignCreateApi.furnitureItems} — the same inputs as
150
+ * {@linkcode PluginDesignCreateApi.furniture} minus `createNewSourceMesh`: in a
151
+ * batch the host owns source-mesh persistence (a source is recorded once per
152
+ * call, however many items reuse it).
153
+ *
154
+ * `position.y` is the REST elevation: the item is grounded so its bounding-box
155
+ * base sits exactly at `position.y` (the same surface-flush contract as
156
+ * interactive drag-drop) — pass the floor/storey elevation to stand furniture
157
+ * on it; never add half the item's height yourself.
158
+ *
159
+ * | Property | Type | Description |
160
+ * |---|---|---|
161
+ * | `catalogId` | `string` | Library id: team `_id` or general `fullName` |
162
+ * | `position` | {@linkcode Vec3Handle} | Absolute world placement point (`y` = rest elevation) |
163
+ * | `label` | `string`? | Instance name and readable label (default auto `${name}Ins${n}`) |
164
+ * | `angleInDegrees` | `number`? | Rotation about the vertical axis, in degrees (default unrotated) |
165
+ */
166
+ export const PluginCreateFurnitureItem = z.object({
167
+ catalogId: z.string().min(1),
168
+ position: Vec3Handle,
169
+ label: z.string().optional(),
170
+ angleInDegrees: z.number().optional(),
171
+ })
172
+ export type PluginCreateFurnitureItem = z.infer<
173
+ typeof PluginCreateFurnitureItem
174
+ >
175
+
176
+ /**
177
+ * The `items` array of {@linkcode PluginDesignCreateApi.furnitureItems}
178
+ * (1…1000).
179
+ */
180
+ export const PluginCreateFurnitureItems = z
181
+ .array(PluginCreateFurnitureItem)
182
+ .min(1)
183
+ .max(PLUGIN_CREATE_BATCH_LIMIT)
184
+ export type PluginCreateFurnitureItems = z.infer<
185
+ typeof PluginCreateFurnitureItems
186
+ >