@snaptrude/plugin-core 0.7.1 → 0.9.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 (193) hide show
  1. package/CHANGELOG.md +29 -0
  2. package/api-manifest.full.json +7703 -0
  3. package/api-manifest.json +2946 -259
  4. package/dist/api/analysis/daylight.d.ts +603 -0
  5. package/dist/api/analysis/daylight.d.ts.map +1 -0
  6. package/dist/api/analysis/heatmaps.d.ts +438 -14
  7. package/dist/api/analysis/heatmaps.d.ts.map +1 -1
  8. package/dist/api/analysis/index.d.ts +15 -0
  9. package/dist/api/analysis/index.d.ts.map +1 -1
  10. package/dist/api/analysis/solar.d.ts +249 -0
  11. package/dist/api/analysis/solar.d.ts.map +1 -0
  12. package/dist/api/analysis/weather.d.ts +193 -0
  13. package/dist/api/analysis/weather.d.ts.map +1 -0
  14. package/dist/api/core/camera/index.d.ts +245 -0
  15. package/dist/api/core/camera/index.d.ts.map +1 -0
  16. package/dist/api/core/comment/index.d.ts +105 -2
  17. package/dist/api/core/comment/index.d.ts.map +1 -1
  18. package/dist/api/core/geom/create/index.d.ts +331 -14
  19. package/dist/api/core/geom/create/index.d.ts.map +1 -1
  20. package/dist/api/core/geom/delete/index.d.ts +8 -2
  21. package/dist/api/core/geom/delete/index.d.ts.map +1 -1
  22. package/dist/api/core/geom/query/arc.d.ts +5 -5
  23. package/dist/api/core/geom/query/brep.d.ts +18 -18
  24. package/dist/api/core/geom/query/circle.d.ts +18 -18
  25. package/dist/api/core/geom/query/contour.d.ts +20 -20
  26. package/dist/api/core/geom/query/curve.d.ts +49 -49
  27. package/dist/api/core/geom/query/edge.d.ts +5 -5
  28. package/dist/api/core/geom/query/face.d.ts +16 -16
  29. package/dist/api/core/geom/query/halfedge.d.ts +8 -8
  30. package/dist/api/core/geom/query/profile.d.ts +19 -19
  31. package/dist/api/core/geom/query/vertex.d.ts +8 -8
  32. package/dist/api/core/geom/update/contour.d.ts +14 -14
  33. package/dist/api/core/geom/update/curve.d.ts +7 -7
  34. package/dist/api/core/geom/update/profile.d.ts +16 -16
  35. package/dist/api/core/handles/index.d.ts +210 -0
  36. package/dist/api/core/handles/index.d.ts.map +1 -0
  37. package/dist/api/core/index.d.ts +24 -0
  38. package/dist/api/core/index.d.ts.map +1 -1
  39. package/dist/api/core/io/export/index.d.ts +134 -0
  40. package/dist/api/core/io/export/index.d.ts.map +1 -0
  41. package/dist/api/core/io/import/index.d.ts +62 -1
  42. package/dist/api/core/io/import/index.d.ts.map +1 -1
  43. package/dist/api/core/io/index.d.ts +5 -0
  44. package/dist/api/core/io/index.d.ts.map +1 -1
  45. package/dist/api/core/layers.d.ts +7 -7
  46. package/dist/api/core/mode/index.d.ts +99 -0
  47. package/dist/api/core/mode/index.d.ts.map +1 -0
  48. package/dist/api/core/proposals/index.d.ts +65 -9
  49. package/dist/api/core/proposals/index.d.ts.map +1 -1
  50. package/dist/api/core/storeys/index.d.ts +251 -0
  51. package/dist/api/core/storeys/index.d.ts.map +1 -0
  52. package/dist/api/core/tags.d.ts +24 -0
  53. package/dist/api/core/tags.d.ts.map +1 -1
  54. package/dist/api/core/user.d.ts +44 -0
  55. package/dist/api/core/user.d.ts.map +1 -0
  56. package/dist/api/core/zoom/index.d.ts +4 -0
  57. package/dist/api/core/zoom/index.d.ts.map +1 -1
  58. package/dist/api/design/boolean/index.d.ts +4 -4
  59. package/dist/api/design/create/index.d.ts +253 -47
  60. package/dist/api/design/create/index.d.ts.map +1 -1
  61. package/dist/api/design/delete/index.d.ts +3 -0
  62. package/dist/api/design/delete/index.d.ts.map +1 -1
  63. package/dist/api/design/doors/index.d.ts +36 -0
  64. package/dist/api/design/doors/index.d.ts.map +1 -1
  65. package/dist/api/design/edit/index.d.ts +1 -1
  66. package/dist/api/design/erase/index.d.ts +2 -2
  67. package/dist/api/design/furniture/index.d.ts +114 -3
  68. package/dist/api/design/furniture/index.d.ts.map +1 -1
  69. package/dist/api/design/index.d.ts +10 -0
  70. package/dist/api/design/index.d.ts.map +1 -1
  71. package/dist/api/design/materials/index.d.ts +111 -14
  72. package/dist/api/design/materials/index.d.ts.map +1 -1
  73. package/dist/api/design/query/geometry/index.d.ts +112 -0
  74. package/dist/api/design/query/geometry/index.d.ts.map +1 -1
  75. package/dist/api/design/query/index.d.ts +35 -1
  76. package/dist/api/design/query/index.d.ts.map +1 -1
  77. package/dist/api/design/query/referenceLines.d.ts +45 -0
  78. package/dist/api/design/query/referenceLines.d.ts.map +1 -0
  79. package/dist/api/design/query/spaces.d.ts +178 -5
  80. package/dist/api/design/query/spaces.d.ts.map +1 -1
  81. package/dist/api/design/transform/index.d.ts +95 -14
  82. package/dist/api/design/transform/index.d.ts.map +1 -1
  83. package/dist/api/design/types/index.d.ts +181 -0
  84. package/dist/api/design/types/index.d.ts.map +1 -0
  85. package/dist/api/design/update/index.d.ts +385 -2
  86. package/dist/api/design/update/index.d.ts.map +1 -1
  87. package/dist/api/design/visibility.d.ts +98 -0
  88. package/dist/api/design/visibility.d.ts.map +1 -0
  89. package/dist/api/entity/buildableEnvelope.d.ts +4 -0
  90. package/dist/api/entity/buildableEnvelope.d.ts.map +1 -1
  91. package/dist/api/entity/referenceLine.d.ts +10 -2
  92. package/dist/api/entity/referenceLine.d.ts.map +1 -1
  93. package/dist/api/entity/space.d.ts +19 -19
  94. package/dist/api/entity/story.d.ts +148 -15
  95. package/dist/api/entity/story.d.ts.map +1 -1
  96. package/dist/api/index.d.ts +5 -0
  97. package/dist/api/index.d.ts.map +1 -1
  98. package/dist/api/presentation/annotate.d.ts +448 -0
  99. package/dist/api/presentation/annotate.d.ts.map +1 -0
  100. package/dist/api/presentation/diagrams.d.ts +49 -8
  101. package/dist/api/presentation/diagrams.d.ts.map +1 -1
  102. package/dist/api/presentation/export.d.ts +108 -0
  103. package/dist/api/presentation/export.d.ts.map +1 -0
  104. package/dist/api/presentation/import.d.ts +6 -0
  105. package/dist/api/presentation/import.d.ts.map +1 -1
  106. package/dist/api/presentation/index.d.ts +47 -0
  107. package/dist/api/presentation/index.d.ts.map +1 -1
  108. package/dist/api/presentation/placedViews.d.ts +370 -0
  109. package/dist/api/presentation/placedViews.d.ts.map +1 -0
  110. package/dist/api/presentation/shapes.d.ts +481 -0
  111. package/dist/api/presentation/shapes.d.ts.map +1 -0
  112. package/dist/api/presentation/sheets.d.ts +410 -13
  113. package/dist/api/presentation/sheets.d.ts.map +1 -1
  114. package/dist/api/presentation/views.d.ts +165 -10
  115. package/dist/api/presentation/views.d.ts.map +1 -1
  116. package/dist/api/program/areas.d.ts +63 -3
  117. package/dist/api/program/areas.d.ts.map +1 -1
  118. package/dist/api/program/cores.d.ts +3 -99
  119. package/dist/api/program/cores.d.ts.map +1 -1
  120. package/dist/api/program/index.d.ts +2 -2
  121. package/dist/api/program/index.d.ts.map +1 -1
  122. package/dist/api/program/layout.d.ts +172 -12
  123. package/dist/api/program/layout.d.ts.map +1 -1
  124. package/dist/api/program/site.d.ts +105 -8
  125. package/dist/api/program/site.d.ts.map +1 -1
  126. package/dist/api/program/spreadsheet.d.ts +365 -41
  127. package/dist/api/program/spreadsheet.d.ts.map +1 -1
  128. package/dist/api/workspace/index.d.ts +460 -0
  129. package/dist/api/workspace/index.d.ts.map +1 -0
  130. package/dist/handles.d.ts +64 -25
  131. package/dist/handles.d.ts.map +1 -1
  132. package/dist/index.cjs +3210 -1671
  133. package/dist/index.cjs.map +1 -1
  134. package/dist/index.js +3008 -1666
  135. package/dist/index.js.map +1 -1
  136. package/package.json +3 -2
  137. package/scripts/generate-manifest.mjs +45 -0
  138. package/src/api/analysis/daylight.ts +470 -0
  139. package/src/api/analysis/heatmaps.ts +444 -17
  140. package/src/api/analysis/index.ts +15 -0
  141. package/src/api/analysis/solar.ts +237 -0
  142. package/src/api/analysis/weather.ts +179 -0
  143. package/src/api/core/camera/index.ts +251 -0
  144. package/src/api/core/comment/index.ts +120 -2
  145. package/src/api/core/geom/create/index.ts +344 -1
  146. package/src/api/core/geom/delete/index.ts +6 -0
  147. package/src/api/core/handles/index.ts +233 -0
  148. package/src/api/core/index.ts +24 -0
  149. package/src/api/core/io/export/index.ts +126 -0
  150. package/src/api/core/io/import/index.ts +64 -0
  151. package/src/api/core/io/index.ts +5 -0
  152. package/src/api/core/mode/index.ts +96 -0
  153. package/src/api/core/proposals/index.ts +71 -11
  154. package/src/api/core/storeys/index.ts +279 -0
  155. package/src/api/core/tags.ts +27 -0
  156. package/src/api/core/user.ts +46 -0
  157. package/src/api/core/zoom/index.ts +4 -0
  158. package/src/api/design/create/index.ts +303 -36
  159. package/src/api/design/delete/index.ts +3 -0
  160. package/src/api/design/doors/index.ts +40 -0
  161. package/src/api/design/furniture/index.ts +127 -3
  162. package/src/api/design/index.ts +10 -0
  163. package/src/api/design/materials/index.ts +157 -30
  164. package/src/api/design/query/geometry/index.ts +125 -3
  165. package/src/api/design/query/index.ts +37 -7
  166. package/src/api/design/query/referenceLines.ts +52 -0
  167. package/src/api/design/query/spaces.ts +143 -0
  168. package/src/api/design/transform/index.ts +101 -12
  169. package/src/api/design/types/index.ts +156 -0
  170. package/src/api/design/update/index.ts +467 -6
  171. package/src/api/design/visibility.ts +109 -0
  172. package/src/api/entity/buildableEnvelope.ts +4 -0
  173. package/src/api/entity/referenceLine.ts +8 -0
  174. package/src/api/entity/story.ts +161 -15
  175. package/src/api/index.ts +5 -0
  176. package/src/api/presentation/annotate.ts +360 -0
  177. package/src/api/presentation/diagrams.ts +53 -8
  178. package/src/api/presentation/export.ts +108 -0
  179. package/src/api/presentation/import.ts +6 -0
  180. package/src/api/presentation/index.ts +55 -0
  181. package/src/api/presentation/placedViews.ts +363 -0
  182. package/src/api/presentation/shapes.ts +274 -0
  183. package/src/api/presentation/sheets.ts +346 -13
  184. package/src/api/presentation/views.ts +164 -12
  185. package/src/api/program/areas.ts +57 -6
  186. package/src/api/program/cores.ts +3 -91
  187. package/src/api/program/index.ts +2 -2
  188. package/src/api/program/layout.ts +182 -12
  189. package/src/api/program/site.ts +106 -8
  190. package/src/api/program/spreadsheet.ts +376 -35
  191. package/src/api/workspace/index.ts +516 -0
  192. package/src/handles.ts +77 -13
  193. package/tsconfig.json +7 -2
@@ -52,6 +52,9 @@ export abstract class PluginDesignDeleteApi {
52
52
  * @examplePrompt Delete all the furniture I picked
53
53
  * @examplePrompt Remove the door and window I just created
54
54
  *
55
+ * @performance Array delete — pass every target in one call (one host round-trip). There is
56
+ * no per-item delete; collect the whole set and never loop this per entity.
57
+ *
55
58
  * # Example
56
59
  * ```ts
57
60
  * // Hard-delete every furniture item on storey 2 (a single undo entry)
@@ -105,6 +105,30 @@ export abstract class PluginDesignDoorsApi {
105
105
  */
106
106
  public abstract getHeight(door: ComponentHandle): PluginApiReturn<number | null>
107
107
 
108
+ /**
109
+ * Get a door's full dimensions in one call — width along the wall, vertical
110
+ * height, and thickness through the wall — measured in the door's local
111
+ * oriented space. Parity with {@linkcode PluginDesignWindowsApi.getDimensions}.
112
+ *
113
+ * @param door The door to query
114
+ * @returns The dimensions, or `null`
115
+ *
116
+ * @examplePrompt What are the dimensions of this door?
117
+ * @examplePrompt How big is the selected door?
118
+ * @examplePrompt Give me the width, height and depth of this door
119
+ * @examplePrompt Measure the entrance door including its thickness through the wall
120
+ *
121
+ * # Example
122
+ * ```ts
123
+ * const [door] = await snaptrude.design.query.listDoors({ isSelected: true })
124
+ * const dims = await snaptrude.design.doors.getDimensions(door)
125
+ * if (dims) console.log(dims.width, dims.height, dims.thickness)
126
+ * ```
127
+ */
128
+ public abstract getDimensions(
129
+ door: ComponentHandle
130
+ ): PluginApiReturn<PluginDoorDimensions | null>
131
+
108
132
  /**
109
133
  * Get the floor a door is hosted on — the storey/level component that
110
134
  * supports the door.
@@ -329,6 +353,22 @@ export const PluginDesignDoorArgs = z.object({
329
353
  })
330
354
  export type PluginDesignDoorArgs = z.infer<typeof PluginDesignDoorArgs>
331
355
 
356
+ /**
357
+ * A door's dimensions (engine units), symmetric with {@linkcode PluginWindowDimensions}.
358
+ *
359
+ * | Property | Type | Description |
360
+ * |---|---|---|
361
+ * | `width` | `number` | Along the wall |
362
+ * | `height` | `number` | Vertical |
363
+ * | `thickness` | `number` | Through the wall (engine `length` axis) |
364
+ */
365
+ export const PluginDoorDimensions = z.object({
366
+ width: z.number(),
367
+ height: z.number(),
368
+ thickness: z.number(),
369
+ })
370
+ export type PluginDoorDimensions = z.infer<typeof PluginDoorDimensions>
371
+
332
372
  /** Mirror axis — tokens mirror the engine `FlipDirection` verbatim (§6.1). */
333
373
  export const PluginMirrorAxis = z.enum(["x", "y", "z"])
334
374
  export type PluginMirrorAxis = z.infer<typeof PluginMirrorAxis>
@@ -1,19 +1,78 @@
1
1
  import * as z from "zod"
2
2
  import { PluginApiReturn } from "../../../types"
3
+ import { ComponentHandle } from "../../../handles"
4
+ import { PluginDesignChangeResult } from "../lock"
3
5
 
4
6
  /**
5
7
  * `snaptrude.design.furniture` — the placeable furniture **catalog** (a library of
6
- * source items, NOT scene entities). Placement lives at `design.create.furniture`
7
- * (returns a {@linkcode ComponentHandle}); reads of placed furniture live at
8
- * `design.query.listFurniture`/`getProperties`.
8
+ * source items, NOT scene entities) plus dimension reads/edits of PLACED furniture.
9
+ * Placement lives at `design.create.furniture` (returns a {@linkcode ComponentHandle});
10
+ * generic reads of placed furniture live at `design.query.listFurniture`/`getProperties`.
9
11
  *
10
12
  * Catalog items are plain value records ({@linkcode PluginFurnitureCatalogItem}) keyed
11
13
  * by a library id (team `_id` or general `fullName`) — not handles. Reads are async
12
14
  * (network-backed) but carry no `Async` suffix (§6.6).
15
+ *
16
+ * {@linkcode PluginDesignFurnitureApi.getDimensions} / {@linkcode PluginDesignFurnitureApi.setDimensions}
17
+ * target a PLACED furniture {@linkcode ComponentHandle} (not a catalog id) — `length`
18
+ * along the object, `width` across it, `height` up. Values are engine units, matching
19
+ * the length/width/height fields the furniture properties panel shows.
13
20
  */
14
21
  export abstract class PluginDesignFurnitureApi {
15
22
  constructor() {}
16
23
 
24
+ /**
25
+ * Get the dimensions of a PLACED furniture item — `length` (along the object),
26
+ * `width` (across it) and `height` (vertical), in engine units. Mirrors the
27
+ * Length/Width/Height fields of the furniture properties panel.
28
+ *
29
+ * @param item The placed furniture to query
30
+ * @returns The dimensions, or `null` if the geometry is degenerate
31
+ *
32
+ * @examplePrompt How big is this sofa?
33
+ * @examplePrompt What are the dimensions of the selected furniture?
34
+ * @examplePrompt Measure the length, width and height of this table
35
+ * @examplePrompt Get the size of the chair I just placed
36
+ *
37
+ * # Example
38
+ * ```ts
39
+ * const [item] = await snaptrude.design.query.listFurniture({ isSelected: true })
40
+ * const dims = await snaptrude.design.furniture.getDimensions(item)
41
+ * if (dims) console.log(dims.length, dims.width, dims.height)
42
+ * ```
43
+ */
44
+ public abstract getDimensions(
45
+ item: ComponentHandle
46
+ ): PluginApiReturn<PluginFurnitureDimensions | null>
47
+
48
+ /**
49
+ * Resize a PLACED furniture item along one or more axes — `length`, `width`
50
+ * and/or `height` (engine units). Omitted axes are left unchanged. Each supplied
51
+ * axis is an undoable command, mirroring editing the furniture properties panel.
52
+ *
53
+ * @param item The placed furniture to resize
54
+ * @param dimensions New `length` / `width` / `height` (each optional, engine units)
55
+ * @returns The affected furniture
56
+ *
57
+ * @examplePrompt Make this table 1.8m long
58
+ * @examplePrompt Resize the selected sofa to 2000 wide
59
+ * @examplePrompt Set this furniture to 800mm tall
60
+ * @examplePrompt Change the desk to 1500 long and 700 deep
61
+ *
62
+ * # Example
63
+ * ```ts
64
+ * const [item] = await snaptrude.design.query.listFurniture({ isSelected: true })
65
+ * const { affected } = await snaptrude.design.furniture.setDimensions(item, {
66
+ * length: 1800,
67
+ * height: 750
68
+ * })
69
+ * ```
70
+ */
71
+ public abstract setDimensions(
72
+ item: ComponentHandle,
73
+ dimensions: PluginFurnitureDimensionUpdates
74
+ ): PluginApiReturn<PluginDesignChangeResult>
75
+
17
76
  /**
18
77
  * List the categories (Living, Bedroom, Kitchen, …) that organize the
19
78
  * furniture catalog — the picker taxonomy, merged from built-in categories,
@@ -159,3 +218,68 @@ export type PluginDesignFurnitureGetCatalogItemArgs = z.infer<
159
218
 
160
219
  export const PluginDesignFurnitureExistsArgs = PluginDesignFurnitureGetCatalogItemArgs
161
220
  export type PluginDesignFurnitureExistsArgs = z.infer<typeof PluginDesignFurnitureExistsArgs>
221
+
222
+ // ---------------------------------------------------------------------------
223
+ // placed-furniture dimensions
224
+ // ---------------------------------------------------------------------------
225
+
226
+ /**
227
+ * A placed furniture item's dimensions (engine units).
228
+ *
229
+ * | Property | Type | Description |
230
+ * |---|---|---|
231
+ * | `length` | `number` | Along the object (panel "Length") |
232
+ * | `width` | `number` | Across the object (panel "Width") |
233
+ * | `height` | `number` | Vertical (panel "Height") |
234
+ */
235
+ export const PluginFurnitureDimensions = z.object({
236
+ length: z.number(),
237
+ width: z.number(),
238
+ height: z.number(),
239
+ })
240
+ export type PluginFurnitureDimensions = z.infer<typeof PluginFurnitureDimensions>
241
+
242
+ /**
243
+ * Arguments for {@linkcode PluginDesignFurnitureApi.getDimensions}.
244
+ *
245
+ * | Property | Type | Description |
246
+ * |---|---|---|
247
+ * | `item` | {@linkcode ComponentHandle} | The placed furniture to query |
248
+ */
249
+ export const PluginDesignFurnitureItemArgs = z.object({
250
+ item: ComponentHandle,
251
+ })
252
+ export type PluginDesignFurnitureItemArgs = z.infer<typeof PluginDesignFurnitureItemArgs>
253
+
254
+ /**
255
+ * A partial dimension patch — each axis is optional; omitted axes are unchanged.
256
+ * Every supplied axis must be a positive engine-unit length.
257
+ *
258
+ * | Property | Type | Description |
259
+ * |---|---|---|
260
+ * | `length` | `number`? | New length along the object (engine units, > 0) |
261
+ * | `width` | `number`? | New width across the object (engine units, > 0) |
262
+ * | `height` | `number`? | New height (engine units, > 0) |
263
+ */
264
+ export const PluginFurnitureDimensionUpdates = z.object({
265
+ length: z.number().positive().optional(),
266
+ width: z.number().positive().optional(),
267
+ height: z.number().positive().optional(),
268
+ })
269
+ export type PluginFurnitureDimensionUpdates = z.infer<typeof PluginFurnitureDimensionUpdates>
270
+
271
+ /**
272
+ * Arguments for {@linkcode PluginDesignFurnitureApi.setDimensions}.
273
+ *
274
+ * | Property | Type | Description |
275
+ * |---|---|---|
276
+ * | `item` | {@linkcode ComponentHandle} | The placed furniture to resize |
277
+ * | `dimensions` | {@linkcode PluginFurnitureDimensionUpdates} | The axes to change (each optional) |
278
+ */
279
+ export const PluginDesignFurnitureSetDimensionsArgs = z.object({
280
+ item: ComponentHandle,
281
+ dimensions: PluginFurnitureDimensionUpdates,
282
+ })
283
+ export type PluginDesignFurnitureSetDimensionsArgs = z.infer<
284
+ typeof PluginDesignFurnitureSetDimensionsArgs
285
+ >
@@ -13,6 +13,8 @@ import { PluginDesignBooleanApi } from "./boolean"
13
13
  import { PluginDesignTransformApi } from "./transform"
14
14
  import { PluginDesignEditApi } from "./edit"
15
15
  import { PluginDesignUpdateApi } from "./update"
16
+ import { PluginDesignVisibilityApi } from "./visibility"
17
+ import { PluginDesignTypesApi } from "./types"
16
18
  import { PluginDesignChangeResult } from "./lock"
17
19
 
18
20
  /**
@@ -27,6 +29,8 @@ import { PluginDesignChangeResult } from "./lock"
27
29
  * - {@linkcode PluginDesignApi.boolean} — CSG boolean ops (union / subtract / intersect)
28
30
  * - {@linkcode PluginDesignApi.erase} — plan-level adjacency-edge erase (NOT hard delete)
29
31
  * - {@linkcode PluginDesignApi.delete} — hard entity removal
32
+ * - {@linkcode PluginDesignApi.visibility} — hide / isolate / reveal entities
33
+ * - {@linkcode PluginDesignApi.types} — read-only building type / assembly reference
30
34
  * - {@linkcode PluginDesignApi.lock} / {@linkcode PluginDesignApi.unlock} / {@linkcode PluginDesignApi.isLocked} / {@linkcode PluginDesignApi.listLocked} — lock state (top-level design verbs, §2A.1)
31
35
  * - {@linkcode PluginDesignApi.lockArea} / {@linkcode PluginDesignApi.unlockArea} / {@linkcode PluginDesignApi.isAreaLocked} / {@linkcode PluginDesignApi.listAreaLocked} — footprint-area lock for Room/Department spaces
32
36
  *
@@ -59,6 +63,10 @@ export abstract class PluginDesignApi {
59
63
  public abstract edit: PluginDesignEditApi
60
64
  /** Update existing entities — properties + geometry. See {@linkcode PluginDesignUpdateApi}. */
61
65
  public abstract update: PluginDesignUpdateApi
66
+ /** Hide / isolate / reveal entities. See {@linkcode PluginDesignVisibilityApi}. */
67
+ public abstract visibility: PluginDesignVisibilityApi
68
+ /** Read-only building type / assembly reference. See {@linkcode PluginDesignTypesApi}. */
69
+ public abstract types: PluginDesignTypesApi
62
70
 
63
71
  /**
64
72
  * Lock entities so they cannot be edited. Undoable. Cascades to void/door/window
@@ -247,3 +255,5 @@ export * from "./boolean"
247
255
  export * from "./transform"
248
256
  export * from "./edit"
249
257
  export * from "./update"
258
+ export * from "./visibility"
259
+ export * from "./types"
@@ -8,7 +8,9 @@ import { ComponentHandle, MaterialHandle } from "../../../handles"
8
8
  * Materials are {@linkcode MaterialHandle}s (entity-style, name-addressed). Reads return
9
9
  * a {@linkcode MaterialHandle}/{@linkcode PluginMaterialInfo}; `apply`/`reset` mutate the
10
10
  * scene (undoable via `save`, default `true`). `create` mints a material from a
11
- * {@linkcode PluginMaterialSpec} (idempotent by name).
11
+ * {@linkcode PluginMaterialSpec} (idempotent by name). `list` reads the materials loaded
12
+ * in the project; `listPresets` reads the browsable preset/library catalog (handle-less
13
+ * {@linkcode PluginPresetMaterial} records that become materials via `create`/`apply`).
12
14
  *
13
15
  * Per-face assignment — {@linkcode PluginDesignMaterialsApi.applyToFaces} /
14
16
  * {@linkcode PluginDesignMaterialsApi.resetFaces} plus per-face reads
@@ -24,23 +26,59 @@ export abstract class PluginDesignMaterialsApi {
24
26
  constructor() {}
25
27
 
26
28
  /**
27
- * List the project materials.
28
- * @param scope Which library to list (optional)
29
+ * List the materials loaded in the project — every named material in the live
30
+ * scene (applied finishes, plugin-created materials, and type defaults in use).
31
+ * For the browsable preset/library catalog (finishes not yet in the project),
32
+ * use {@linkcode PluginDesignMaterialsApi.listPresets}.
33
+ *
29
34
  * @returns The materials as {@linkcode MaterialHandle}`[]`
30
35
  *
31
36
  * @examplePrompt List all the materials in this project
32
37
  * @examplePrompt What materials do I have available to apply?
33
- * @examplePrompt Show me the preset materials library
34
38
  * @examplePrompt Which finishes exist in this model?
35
39
  * @examplePrompt Get every material in the project palette
36
40
  *
37
41
  * # Example
38
42
  * ```ts
39
- * const presets = await snaptrude.design.materials.list("preset")
40
- * console.log(presets.length, "preset materials")
43
+ * const materials = await snaptrude.design.materials.list()
44
+ * console.log(materials.length, "materials in the project")
41
45
  * ```
42
46
  */
43
- public abstract list(scope?: "project" | "preset"): PluginApiReturn<MaterialHandle[]>
47
+ public abstract list(): PluginApiReturn<MaterialHandle[]>
48
+
49
+ /**
50
+ * List the preset material library — the catalog the app's material browser
51
+ * shows (the built-in finishes plus the workspace's uploaded materials),
52
+ * fetched from the material library service. Library entries are **not**
53
+ * scene materials and carry no {@linkcode MaterialHandle}; each is a named
54
+ * texture record. To use one, feed it to
55
+ * {@linkcode PluginDesignMaterialsApi.create} /
56
+ * {@linkcode PluginDesignMaterialsApi.apply} as a
57
+ * {@linkcode PluginMaterialSpec}: `{ name, textureUrl, materialType: category }`.
58
+ *
59
+ * @returns The library as {@linkcode PluginPresetMaterial}`[]` (`[]` when the
60
+ * library service is unreachable)
61
+ *
62
+ * @examplePrompt Show me the preset materials library
63
+ * @examplePrompt What wood finishes are available in the material library?
64
+ * @examplePrompt Browse the material catalog and apply a brick texture
65
+ * @examplePrompt Which preset materials can I choose from?
66
+ *
67
+ * # Example
68
+ * ```ts
69
+ * const presets = await snaptrude.design.materials.listPresets()
70
+ * const brick = presets.find((p) => p.category.toLowerCase().includes("brick"))
71
+ * if (brick) {
72
+ * const walls = await snaptrude.design.query.listWalls()
73
+ * await snaptrude.design.materials.apply(walls, {
74
+ * name: brick.name,
75
+ * textureUrl: brick.textureUrl,
76
+ * materialType: brick.category,
77
+ * })
78
+ * }
79
+ * ```
80
+ */
81
+ public abstract listPresets(): PluginApiReturn<PluginPresetMaterial[]>
44
82
 
45
83
  /**
46
84
  * Read a material's descriptor — its name, color, opacity, and texture
@@ -61,7 +99,43 @@ export abstract class PluginDesignMaterialsApi {
61
99
  * if (info) console.log(info.name, info.colorHex, info.alpha)
62
100
  * ```
63
101
  */
64
- public abstract getInfo(material: MaterialHandle): PluginApiReturn<PluginMaterialInfo | null>
102
+ public abstract getInfo(
103
+ material: MaterialHandle,
104
+ ): PluginApiReturn<PluginMaterialInfo | null>
105
+
106
+ /**
107
+ * Read the material applied to a component **as a whole** — the eyedropper. For a
108
+ * uniformly-painted component this is that single material; for a per-face-painted
109
+ * component it is the material on the component's base/first face. Use
110
+ * {@linkcode PluginDesignMaterialsApi.getByFace} /
111
+ * {@linkcode PluginDesignMaterialsApi.listByFace} for the per-face breakdown.
112
+ *
113
+ * @param component The component to sample
114
+ * @returns The whole-object material as a {@linkcode PluginComponentMaterial} — its
115
+ * handle (chain it into `apply` / `getInfo`), engine id, name, and whether the
116
+ * component carries its type `default` or an explicitly `applied` finish — or `null`
117
+ * if the component carries no material
118
+ *
119
+ * @examplePrompt What material is on this wall?
120
+ * @examplePrompt Eyedrop the finish of the selected object
121
+ * @examplePrompt Which material does this slab use?
122
+ * @examplePrompt Read the material on this column so I can paint others with it
123
+ * @examplePrompt Is this component painted, and with what?
124
+ *
125
+ * # Example
126
+ * ```ts
127
+ * const [component] = await snaptrude.design.selection.get()
128
+ * const sampled = await snaptrude.design.materials.get(component)
129
+ * if (sampled) {
130
+ * console.log(sampled.name, sampled.source) // e.g. "Brick Red" "applied"
131
+ * const info = await snaptrude.design.materials.getInfo(sampled.material)
132
+ * console.log(info?.colorHex)
133
+ * }
134
+ * ```
135
+ */
136
+ public abstract get(
137
+ component: ComponentHandle,
138
+ ): PluginApiReturn<PluginComponentMaterial | null>
65
139
 
66
140
  /**
67
141
  * Apply a material to one or more components — an existing project material by
@@ -90,7 +164,7 @@ export abstract class PluginDesignMaterialsApi {
90
164
  public abstract apply(
91
165
  targets: ComponentHandle[],
92
166
  material: MaterialHandle | PluginMaterialSpec,
93
- save?: boolean
167
+ save?: boolean,
94
168
  ): PluginApiReturn<PluginMaterialResult>
95
169
 
96
170
  /**
@@ -116,7 +190,7 @@ export abstract class PluginDesignMaterialsApi {
116
190
  */
117
191
  public abstract reset(
118
192
  components: ComponentHandle[],
119
- save?: boolean
193
+ save?: boolean,
120
194
  ): PluginApiReturn<PluginMaterialResult>
121
195
 
122
196
  /**
@@ -155,7 +229,7 @@ export abstract class PluginDesignMaterialsApi {
155
229
  component: ComponentHandle,
156
230
  faces: number[],
157
231
  material: MaterialHandle | PluginMaterialSpec,
158
- save?: boolean
232
+ save?: boolean,
159
233
  ): PluginApiReturn<PluginMaterialResult>
160
234
 
161
235
  /**
@@ -183,7 +257,7 @@ export abstract class PluginDesignMaterialsApi {
183
257
  public abstract resetFaces(
184
258
  component: ComponentHandle,
185
259
  faces: number[],
186
- save?: boolean
260
+ save?: boolean,
187
261
  ): PluginApiReturn<PluginMaterialResult>
188
262
 
189
263
  /**
@@ -207,7 +281,7 @@ export abstract class PluginDesignMaterialsApi {
207
281
  */
208
282
  public abstract getByFace(
209
283
  component: ComponentHandle,
210
- face: number
284
+ face: number,
211
285
  ): PluginApiReturn<MaterialHandle | null>
212
286
 
213
287
  /**
@@ -230,7 +304,7 @@ export abstract class PluginDesignMaterialsApi {
230
304
  * ```
231
305
  */
232
306
  public abstract listByFace(
233
- component: ComponentHandle
307
+ component: ComponentHandle,
234
308
  ): PluginApiReturn<PluginFaceMaterial[]>
235
309
 
236
310
  /**
@@ -253,7 +327,9 @@ export abstract class PluginDesignMaterialsApi {
253
327
  * await snaptrude.design.materials.apply(walls, glass)
254
328
  * ```
255
329
  */
256
- public abstract create(spec: PluginMaterialSpec): PluginApiReturn<MaterialHandle>
330
+ public abstract create(
331
+ spec: PluginMaterialSpec,
332
+ ): PluginApiReturn<MaterialHandle>
257
333
 
258
334
  /**
259
335
  * Get the default material for a component's type.
@@ -272,7 +348,9 @@ export abstract class PluginDesignMaterialsApi {
272
348
  * if (defaultMaterial) console.log(await snaptrude.design.materials.getInfo(defaultMaterial))
273
349
  * ```
274
350
  */
275
- public abstract getDefault(component: ComponentHandle): PluginApiReturn<MaterialHandle | null>
351
+ public abstract getDefault(
352
+ component: ComponentHandle,
353
+ ): PluginApiReturn<MaterialHandle | null>
276
354
 
277
355
  /**
278
356
  * Test whether a component carries its (type) default material.
@@ -291,7 +369,9 @@ export abstract class PluginDesignMaterialsApi {
291
369
  * console.log(untouched ? "still default" : "has been painted")
292
370
  * ```
293
371
  */
294
- public abstract isDefault(component: ComponentHandle): PluginApiReturn<boolean>
372
+ public abstract isDefault(
373
+ component: ComponentHandle,
374
+ ): PluginApiReturn<boolean>
295
375
 
296
376
  /**
297
377
  * Test whether a component has a single (uniform) material across all faces.
@@ -310,7 +390,9 @@ export abstract class PluginDesignMaterialsApi {
310
390
  * console.log(uniform ? "one material all over" : "painted per face")
311
391
  * ```
312
392
  */
313
- public abstract isUniform(component: ComponentHandle): PluginApiReturn<boolean>
393
+ public abstract isUniform(
394
+ component: ComponentHandle,
395
+ ): PluginApiReturn<boolean>
314
396
 
315
397
  /**
316
398
  * Test whether a material has a texture.
@@ -392,18 +474,54 @@ export const PluginFaceMaterial = z.object({
392
474
  })
393
475
  export type PluginFaceMaterial = z.infer<typeof PluginFaceMaterial>
394
476
 
395
- /** Arguments for {@linkcode PluginDesignMaterialsApi.list}. */
396
- export const PluginDesignMaterialsListArgs = z.object({
397
- scope: z.enum(["project", "preset"]).optional(),
477
+ /**
478
+ * The material on a component **as a whole** — the eyedropper read returned by
479
+ * {@linkcode PluginDesignMaterialsApi.get} (value record, plus a reusable handle).
480
+ *
481
+ * | Property | Type | Description |
482
+ * |---|---|---|
483
+ * | `material` | {@linkcode MaterialHandle} | The whole-object material — chain into `apply` / `getInfo` |
484
+ * | `id` | `string` | Engine material id |
485
+ * | `name` | `string` | Material name (== the handle token) |
486
+ * | `source` | `"default" \| "applied"` | Whether it is the component's type default or an explicitly-applied finish |
487
+ */
488
+ export const PluginComponentMaterial = z.object({
489
+ material: MaterialHandle,
490
+ id: z.string(),
491
+ name: z.string(),
492
+ source: z.enum(["default", "applied"]),
493
+ })
494
+ export type PluginComponentMaterial = z.infer<typeof PluginComponentMaterial>
495
+
496
+ /**
497
+ * A preset material library entry (value record — NOT a handle), returned by
498
+ * {@linkcode PluginDesignMaterialsApi.listPresets}.
499
+ *
500
+ * | Property | Type | Description |
501
+ * |---|---|---|
502
+ * | `name` | `string` | Display name of the library entry |
503
+ * | `category` | `string` | Library category (camelCase, e.g. `"wood"`, `"colors"`, `"brick"`) |
504
+ * | `textureUrl` | `string` | Texture/swatch image URL — feed to {@linkcode PluginMaterialSpec}`.textureUrl` |
505
+ */
506
+ export const PluginPresetMaterial = z.object({
507
+ name: z.string(),
508
+ category: z.string(),
509
+ textureUrl: z.string(),
398
510
  })
399
- export type PluginDesignMaterialsListArgs = z.infer<typeof PluginDesignMaterialsListArgs>
511
+ export type PluginPresetMaterial = z.infer<typeof PluginPresetMaterial>
400
512
 
401
513
  /** Arguments for {@linkcode PluginDesignMaterialsApi.getInfo} / `hasTexture`. */
402
- export const PluginDesignMaterialsGetInfoArgs = z.object({ material: MaterialHandle })
403
- export type PluginDesignMaterialsGetInfoArgs = z.infer<typeof PluginDesignMaterialsGetInfoArgs>
514
+ export const PluginDesignMaterialsGetInfoArgs = z.object({
515
+ material: MaterialHandle,
516
+ })
517
+ export type PluginDesignMaterialsGetInfoArgs = z.infer<
518
+ typeof PluginDesignMaterialsGetInfoArgs
519
+ >
404
520
 
405
521
  /** Arguments for component-scoped predicates (`getDefault`/`isDefault`/`isUniform`). */
406
- export const PluginDesignMaterialsComponentArgs = z.object({ component: ComponentHandle })
522
+ export const PluginDesignMaterialsComponentArgs = z.object({
523
+ component: ComponentHandle,
524
+ })
407
525
  export type PluginDesignMaterialsComponentArgs = z.infer<
408
526
  typeof PluginDesignMaterialsComponentArgs
409
527
  >
@@ -422,18 +540,26 @@ export const PluginDesignMaterialsApplyArgs = z.object({
422
540
  material: z.union([MaterialHandle, PluginMaterialSpec]),
423
541
  save: z.boolean().optional(),
424
542
  })
425
- export type PluginDesignMaterialsApplyArgs = z.infer<typeof PluginDesignMaterialsApplyArgs>
543
+ export type PluginDesignMaterialsApplyArgs = z.infer<
544
+ typeof PluginDesignMaterialsApplyArgs
545
+ >
426
546
 
427
547
  /** Arguments for {@linkcode PluginDesignMaterialsApi.reset}. */
428
548
  export const PluginDesignMaterialsResetArgs = z.object({
429
549
  components: z.array(ComponentHandle),
430
550
  save: z.boolean().optional(),
431
551
  })
432
- export type PluginDesignMaterialsResetArgs = z.infer<typeof PluginDesignMaterialsResetArgs>
552
+ export type PluginDesignMaterialsResetArgs = z.infer<
553
+ typeof PluginDesignMaterialsResetArgs
554
+ >
433
555
 
434
556
  /** Arguments for {@linkcode PluginDesignMaterialsApi.create}. */
435
- export const PluginDesignMaterialsCreateArgs = z.object({ spec: PluginMaterialSpec })
436
- export type PluginDesignMaterialsCreateArgs = z.infer<typeof PluginDesignMaterialsCreateArgs>
557
+ export const PluginDesignMaterialsCreateArgs = z.object({
558
+ spec: PluginMaterialSpec,
559
+ })
560
+ export type PluginDesignMaterialsCreateArgs = z.infer<
561
+ typeof PluginDesignMaterialsCreateArgs
562
+ >
437
563
 
438
564
  /**
439
565
  * Arguments for {@linkcode PluginDesignMaterialsApi.applyToFaces}.
@@ -475,7 +601,8 @@ export type PluginDesignMaterialsGetByFaceArgs = z.infer<
475
601
  >
476
602
 
477
603
  /** Arguments for {@linkcode PluginDesignMaterialsApi.listByFace} (component only). */
478
- export const PluginDesignMaterialsListByFaceArgs = PluginDesignMaterialsComponentArgs
604
+ export const PluginDesignMaterialsListByFaceArgs =
605
+ PluginDesignMaterialsComponentArgs
479
606
  export type PluginDesignMaterialsListByFaceArgs = z.infer<
480
607
  typeof PluginDesignMaterialsListByFaceArgs
481
608
  >