@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
@@ -41,6 +41,8 @@ export abstract class PluginStoryApi {
41
41
  * const info = await snaptrude.entity.story.get(1, ["height", "name", "spacesCount"])
42
42
  * console.log(info.name, info.height, info.spacesCount)
43
43
  * ```
44
+ *
45
+ * @deprecated Use `core.storeys.get`
44
46
  */
45
47
  public abstract get(
46
48
  storyValue: number,
@@ -68,6 +70,8 @@ export abstract class PluginStoryApi {
68
70
  * console.log(`Story ${s.value}: ${s.name} (id: ${s.id})`)
69
71
  * }
70
72
  * ```
73
+ *
74
+ * @deprecated Use `core.storeys.list`
71
75
  */
72
76
  public abstract getAll(): PluginApiReturn<PluginStoryGetAllResult>
73
77
 
@@ -95,6 +99,8 @@ export abstract class PluginStoryApi {
95
99
  * // Create a new third floor with custom height
96
100
  * const { storyId } = await snaptrude.entity.story.create(3, 4.5)
97
101
  * ```
102
+ *
103
+ * @deprecated Use `core.storeys.create`
98
104
  */
99
105
  public abstract create(
100
106
  storyValue: number,
@@ -102,21 +108,32 @@ export abstract class PluginStoryApi {
102
108
  ): PluginApiReturn<PluginStoryCreateResult>
103
109
 
104
110
  /**
105
- * Update a story's floor-to-floor height, cascading the full geometry change.
111
+ * Update a story's floor-to-floor `height` and/or `name`.
106
112
  *
107
- * This is the same operation as editing the height in the Stories panel: the
108
- * walls, columns, and masses on the story are **stretched** to the new height,
109
- * every story **above shifts up/down** by the delta so the stack stays
113
+ * **Height** is the same operation as editing the height in the Stories panel:
114
+ * the walls, columns, and masses on the story are **stretched** to the new
115
+ * height, every story **above shifts up/down** by the delta so the stack stays
110
116
  * contiguous, and coupled elements (staircases, parametric curtain walls,
111
- * furniture offsets) are re-fitted. The whole cascade is committed as **one
112
- * undo step**. Height-locked elements are left untouched.
117
+ * furniture offsets) are re-fitted. The whole height cascade is committed as
118
+ * **one undo step**. Height-locked elements are left untouched.
119
+ *
120
+ * **Name** is the same as renaming the story in the Stories panel: it is
121
+ * persisted immediately (saved to the project) but, mirroring the panel, is
122
+ * **not** part of the height undo step.
123
+ *
124
+ * At least one of `height` or `options.name` must be supplied. Omitting the
125
+ * `height` argument (e.g. for a rename-only update) leaves the height
126
+ * untouched.
113
127
  *
114
128
  * @param storyValue - Integer storey number
115
129
  * identifying the story to update
116
130
  * @param height - New floor-to-floor height in
117
- * Babylon units
118
- * @returns A {@linkcode PluginStoryUpdateResult} with the updated `storyValue` and `height`
131
+ * Babylon units. Omit to leave the height unchanged.
132
+ * @param options - `name` (new display name for the story)
133
+ * @returns A {@linkcode PluginStoryUpdateResult} with the story's
134
+ * `storyValue`, `height`, and `name` after the update
119
135
  * @throws `PRECONDITION_FAILED` if no story has the given value;
136
+ * `VALIDATION` if neither `height` nor `options.name` is supplied;
120
137
  * `STORY_HEIGHT_REJECTED` if the engine rejects the height (e.g. out of
121
138
  * range — the change silently reverts host-side and is surfaced as this
122
139
  * error); `STORY_UPDATE_FAILED` if the story cannot be re-read after the
@@ -124,21 +141,83 @@ export abstract class PluginStoryApi {
124
141
  *
125
142
  * @examplePrompt Change the ground floor height to 3.5 metres
126
143
  * @examplePrompt Make the second storey taller
144
+ * @examplePrompt Rename the ground floor to "Lobby"
127
145
  * @examplePrompt Set the floor-to-floor height of level 1
128
- * @examplePrompt Increase the height of the third floor
146
+ * @examplePrompt Rename storey 2 and make it taller in one go
129
147
  *
130
148
  * # Example
131
149
  * ```ts
132
150
  * // Set ground floor height to 5 Babylon units — walls stretch and the
133
151
  * // floors above move up to match, all in a single undo step.
134
152
  * const result = await snaptrude.entity.story.update(1, 5)
153
+ * // Rename only, leaving the height untouched.
154
+ * await snaptrude.entity.story.update(1, undefined, { name: "Lobby" })
135
155
  * ```
156
+ *
157
+ * @deprecated Use `core.storeys.update`
136
158
  */
137
159
  public abstract update(
138
160
  storyValue: number,
139
- height: number,
161
+ height?: number,
162
+ options?: { name?: string },
140
163
  ): PluginApiReturn<PluginStoryUpdateResult>
141
164
 
165
+ /**
166
+ * Make a story the active story — the same as clicking it in the storey/layer
167
+ * panel. Subsequent draws and creates target this story, and in 2D the
168
+ * viewport switches to it. This is a view/navigation change: it is **not**
169
+ * undoable and commits nothing to the model.
170
+ *
171
+ * @param storyValue - Integer storey number to activate
172
+ * @returns A {@linkcode PluginStorySetActiveResult} echoing the now-active `storyValue`
173
+ * @throws `PRECONDITION_FAILED` if no story has the given value
174
+ *
175
+ * @examplePrompt Switch to the second floor
176
+ * @examplePrompt Make the ground storey active
177
+ * @examplePrompt Go to the basement level
178
+ * @examplePrompt Set level 3 as the current storey
179
+ *
180
+ * # Example
181
+ * ```ts
182
+ * // Activate story 2, then draw a wall — it lands on story 2.
183
+ * await snaptrude.entity.story.setActive(2)
184
+ * ```
185
+ *
186
+ * @deprecated Use `core.storeys.setActive`
187
+ */
188
+ public abstract setActive(
189
+ storyValue: number,
190
+ ): PluginApiReturn<PluginStorySetActiveResult>
191
+
192
+ /**
193
+ * Delete a story and everything on it — the same as removing it from the
194
+ * storey panel. Every element placed on the story (walls, floors, masses, …)
195
+ * is deleted with it, the remaining stories are re-stacked, and the active
196
+ * story falls back to an adjacent one. Committed as a single undo step.
197
+ *
198
+ * @param storyValue - Integer storey number to delete
199
+ * @returns A {@linkcode PluginStoryDeleteResult} with the deleted `storyValue`
200
+ * and the `newActiveStory` the editor fell back to
201
+ * @throws `PRECONDITION_FAILED` if no story has the given value; or if plugin
202
+ * writes are disabled
203
+ *
204
+ * @examplePrompt Delete the top floor
205
+ * @examplePrompt Remove the basement level
206
+ * @examplePrompt Get rid of storey 3
207
+ * @examplePrompt Delete the second floor and everything on it
208
+ *
209
+ * # Example
210
+ * ```ts
211
+ * const { newActiveStory } = await snaptrude.entity.story.delete(3)
212
+ * console.log(`Deleted story 3; now on story ${newActiveStory}`)
213
+ * ```
214
+ *
215
+ * @deprecated Use `core.storeys.delete`
216
+ */
217
+ public abstract delete(
218
+ storyValue: number,
219
+ ): PluginApiReturn<PluginStoryDeleteResult>
220
+
142
221
  /**
143
222
  * Duplicate a story into the adjacent level, up or down.
144
223
  *
@@ -173,6 +252,12 @@ export abstract class PluginStoryApi {
173
252
  * @examplePrompt Repeat this level upwards with its own independent geometry
174
253
  * @examplePrompt Duplicate just the selected walls onto the next floor up
175
254
  *
255
+ * @performance For storeys that share a layout, duplicate the storey instead of recreating
256
+ * its contents floor by floor — this copies every eligible element in one call, and the
257
+ * default instanced copies keep the floors linked. To stack many identical floors, either
258
+ * call this per level or capture the storey's component ids and
259
+ * `design.create.copy(ids, oneFloorRise, { count })` to lay them all down in a single call.
260
+ *
176
261
  * # Example
177
262
  * ```ts
178
263
  * // Duplicate the whole active story one level up (instanced copies).
@@ -181,6 +266,8 @@ export abstract class PluginStoryApi {
181
266
  * console.log(`Copied ${created.length} elements onto story ${targetStories}`)
182
267
  * if (skipped) console.log(`${skipped} elements were skipped`)
183
268
  * ```
269
+ *
270
+ * @deprecated Use `core.storeys.copy`
184
271
  */
185
272
  public abstract duplicate(
186
273
  direction: "up" | "down",
@@ -301,35 +388,94 @@ export const PluginStoryCreateResult = z.object({
301
388
  export type PluginStoryCreateResult = z.infer<typeof PluginStoryCreateResult>
302
389
 
303
390
  /**
304
- * Arguments for {@linkcode PluginStoryApi.update}.
391
+ * Arguments for {@linkcode PluginStoryApi.update}. At least one of `height` or
392
+ * `name` must be supplied.
305
393
  *
306
394
  * | Property | Type | Description |
307
395
  * |---|---|---|
308
396
  * | `storyValue` | `number` (int) | Storey number of the story to update |
309
- * | `height` | `number` | New height in Babylon units |
397
+ * | `height` | `number?` | New height in Babylon units (omit to leave unchanged) |
398
+ * | `name` | `string?` | New display name for the story (omit to leave unchanged) |
310
399
  */
311
400
  export const PluginStoryUpdateArgs = z.object({
312
401
  storyValue: z.number().int(),
313
- height: z.number(),
402
+ height: z.number().optional(),
403
+ name: z.string().optional(),
314
404
  })
315
405
 
316
406
  export type PluginStoryUpdateArgs = z.infer<typeof PluginStoryUpdateArgs>
317
407
 
318
408
  /**
319
- * Result of {@linkcode PluginStoryApi.update}.
409
+ * Result of {@linkcode PluginStoryApi.update} — the story's state after the update.
320
410
  *
321
411
  * | Property | Type | Description |
322
412
  * |---|---|---|
323
413
  * | `storyValue` | `number` | The storey number of the updated story |
324
- * | `height` | `number` | The new height after the update |
414
+ * | `height` | `number` | The height after the update |
415
+ * | `name` | `string` | The name after the update |
325
416
  */
326
417
  export const PluginStoryUpdateResult = z.object({
327
418
  storyValue: z.number(),
328
419
  height: z.number(),
420
+ name: z.string(),
329
421
  })
330
422
 
331
423
  export type PluginStoryUpdateResult = z.infer<typeof PluginStoryUpdateResult>
332
424
 
425
+ /**
426
+ * Arguments for {@linkcode PluginStoryApi.setActive}.
427
+ *
428
+ * | Property | Type | Description |
429
+ * |---|---|---|
430
+ * | `storyValue` | `number` (int) | Storey number to activate |
431
+ */
432
+ export const PluginStorySetActiveArgs = z.object({
433
+ storyValue: z.number().int(),
434
+ })
435
+
436
+ export type PluginStorySetActiveArgs = z.infer<typeof PluginStorySetActiveArgs>
437
+
438
+ /**
439
+ * Result of {@linkcode PluginStoryApi.setActive}.
440
+ *
441
+ * | Property | Type | Description |
442
+ * |---|---|---|
443
+ * | `storyValue` | `number` | The storey number that is now active |
444
+ */
445
+ export const PluginStorySetActiveResult = z.object({
446
+ storyValue: z.number(),
447
+ })
448
+
449
+ export type PluginStorySetActiveResult = z.infer<typeof PluginStorySetActiveResult>
450
+
451
+ /**
452
+ * Arguments for {@linkcode PluginStoryApi.delete}.
453
+ *
454
+ * | Property | Type | Description |
455
+ * |---|---|---|
456
+ * | `storyValue` | `number` (int) | Storey number to delete |
457
+ */
458
+ export const PluginStoryDeleteArgs = z.object({
459
+ storyValue: z.number().int(),
460
+ })
461
+
462
+ export type PluginStoryDeleteArgs = z.infer<typeof PluginStoryDeleteArgs>
463
+
464
+ /**
465
+ * Result of {@linkcode PluginStoryApi.delete}.
466
+ *
467
+ * | Property | Type | Description |
468
+ * |---|---|---|
469
+ * | `storyValue` | `number` | The storey number that was deleted |
470
+ * | `newActiveStory` | `number` | The storey the editor fell back to as active |
471
+ */
472
+ export const PluginStoryDeleteResult = z.object({
473
+ storyValue: z.number(),
474
+ newActiveStory: z.number(),
475
+ })
476
+
477
+ export type PluginStoryDeleteResult = z.infer<typeof PluginStoryDeleteResult>
478
+
333
479
  /**
334
480
  * Arguments for {@linkcode PluginStoryApi.duplicate} (options flattened).
335
481
  *
package/src/api/index.ts CHANGED
@@ -4,6 +4,7 @@ import { PluginEntityApi } from "./entity"
4
4
  import { PluginProgramApi } from "./program"
5
5
  import { PluginPresentationApi } from "./presentation"
6
6
  import { PluginAnalysisApi } from "./analysis"
7
+ import { PluginWorkspaceApi } from "./workspace"
7
8
 
8
9
  /**
9
10
  * Root API surface for Snaptrude plugins.
@@ -16,6 +17,7 @@ import { PluginAnalysisApi } from "./analysis"
16
17
  * - {@linkcode PluginApi.program} — Program-mode planning reads (departments, metrics)
17
18
  * - {@linkcode PluginApi.presentation} — Presentation preparation (views, AI Inspiration)
18
19
  * - {@linkcode PluginApi.analysis} — Sustainability analysis (sunpath, shadows, sunlight/illuminance heatmaps)
20
+ * - {@linkcode PluginApi.workspace} — Dashboard surface: projects and teams
19
21
  */
20
22
  export abstract class PluginApi {
21
23
  /** Core math, geometry, history, and units primitives. See {@linkcode PluginCoreApi}. */
@@ -30,6 +32,8 @@ export abstract class PluginApi {
30
32
  public abstract presentation: PluginPresentationApi
31
33
  /** Sustainability analysis — sun & daylight studies. See {@linkcode PluginAnalysisApi}. */
32
34
  public abstract analysis: PluginAnalysisApi
35
+ /** Dashboard surface — projects and teams. See {@linkcode PluginWorkspaceApi}. */
36
+ public abstract workspace: PluginWorkspaceApi
33
37
 
34
38
  constructor() {}
35
39
  }
@@ -40,3 +44,4 @@ export * from "./entity"
40
44
  export * from "./program"
41
45
  export * from "./presentation"
42
46
  export * from "./analysis"
47
+ export * from "./workspace"
@@ -0,0 +1,360 @@
1
+ import * as z from "zod"
2
+ import { PluginApiReturn } from "../../types"
3
+
4
+ /**
5
+ * Presentation annotate — add annotations to Present-mode sheets.
6
+ *
7
+ * The scriptable counterparts to the Present toolbar's annotation tools (all
8
+ * require Present mode to be open; each returns the created canvas shape id):
9
+ *
10
+ * - {@linkcode PluginPresentationAnnotateApi.text} — text labels (titles, captions)
11
+ * - {@linkcode PluginPresentationAnnotateApi.arrow} — arrows pointing between two points
12
+ * - {@linkcode PluginPresentationAnnotateApi.note} — sticky notes
13
+ * - {@linkcode PluginPresentationAnnotateApi.shape} — geo shapes (rectangle, ellipse, cloud, …)
14
+ *
15
+ * The freehand Draw tool is not scriptable (a stroke is an interactive gesture,
16
+ * not a single call) and is intentionally not exposed here.
17
+ *
18
+ * Accessed via `snaptrude.presentation.annotate`.
19
+ */
20
+ export abstract class PluginPresentationAnnotateApi {
21
+ constructor() {}
22
+
23
+ /**
24
+ * Add a text label to a sheet.
25
+ *
26
+ * Creates a text shape on the given sheet and returns the id of the created
27
+ * canvas shape. Requires Present mode to be open.
28
+ *
29
+ * @param sheetId - The sheet to annotate.
30
+ * @param text - The label text.
31
+ * @param options - Optional `position` (`{ x, y }`, relative to the sheet's
32
+ * top-left, in canvas units — defaults to the sheet's top-left corner),
33
+ * `size` (`"s" | "m" | "l" | "xl"`, default `"m"`), and `color` (a named
34
+ * palette color, default `"black"`).
35
+ * @returns A {@linkcode PluginPresentationAnnotateTextResult} with the created
36
+ * `shapeId`.
37
+ * @throws If Present mode is not open or the sheet id is invalid.
38
+ *
39
+ * @examplePrompt Add a title "Ground Floor" to Sheet 1
40
+ * @examplePrompt Label the cover sheet with the project name
41
+ * @examplePrompt Caption this view with "Proposed layout"
42
+ * @examplePrompt Put a red note on the sheet
43
+ *
44
+ * # Example
45
+ * ```ts
46
+ * const { shapeId } = await snaptrude.presentation.annotate.text(
47
+ * "sheet_1",
48
+ * "Ground Floor",
49
+ * { position: { x: 40, y: 40 }, size: "xl", color: "blue" },
50
+ * )
51
+ * ```
52
+ */
53
+ public abstract text(
54
+ sheetId: string,
55
+ text: string,
56
+ options?: {
57
+ position?: { x: number; y: number }
58
+ size?: PluginAnnotateTextSize
59
+ color?: PluginAnnotateTextColor
60
+ },
61
+ ): PluginApiReturn<PluginPresentationAnnotateTextResult>
62
+
63
+ /**
64
+ * Draw an arrow on a sheet.
65
+ *
66
+ * Creates an arrow shape from `start` to `end` (both relative to the sheet's
67
+ * top-left, in canvas units — the same Arrow tool as the Present toolbar) and
68
+ * returns the id of the created canvas shape. Requires Present mode to be open.
69
+ *
70
+ * @param sheetId - The sheet to annotate.
71
+ * @param start - Arrow tail position (`{ x, y }`, relative to the sheet's top-left).
72
+ * @param end - Arrow head position (`{ x, y }`, relative to the sheet's top-left).
73
+ * @param options - Optional `color` (a named palette color, default `"black"`)
74
+ * and `size` (stroke weight preset, `"s" | "m" | "l" | "xl"`, default `"m"`).
75
+ * @returns A {@linkcode PluginPresentationAnnotateResult} with the created
76
+ * `shapeId`.
77
+ * @throws If Present mode is not open or the sheet id is invalid.
78
+ *
79
+ * @examplePrompt Draw an arrow pointing at the entrance on Sheet 1
80
+ * @examplePrompt Add a red arrow from the title to the plan view
81
+ * @examplePrompt Point an arrow at the top-left view on the cover sheet
82
+ *
83
+ * # Example
84
+ * ```ts
85
+ * const { shapeId } = await snaptrude.presentation.annotate.arrow(
86
+ * "sheet_1",
87
+ * { x: 100, y: 200 },
88
+ * { x: 300, y: 250 },
89
+ * { color: "red" },
90
+ * )
91
+ * ```
92
+ */
93
+ public abstract arrow(
94
+ sheetId: string,
95
+ start: { x: number; y: number },
96
+ end: { x: number; y: number },
97
+ options?: {
98
+ color?: PluginAnnotateTextColor
99
+ size?: PluginAnnotateTextSize
100
+ },
101
+ ): PluginApiReturn<PluginPresentationAnnotateResult>
102
+
103
+ /**
104
+ * Add a sticky note to a sheet.
105
+ *
106
+ * Creates a note shape (the same Note tool as the Present toolbar — a
107
+ * fixed-size sticky square that grows with its text) and returns the id of
108
+ * the created canvas shape. Requires Present mode to be open.
109
+ *
110
+ * @param sheetId - The sheet to annotate.
111
+ * @param text - The note text.
112
+ * @param options - Optional `position` (`{ x, y }`, relative to the sheet's
113
+ * top-left, in canvas units — defaults to the sheet's top-left corner),
114
+ * `color` (a named palette color, default `"black"` — rendered as the
115
+ * note's sticky fill), and `size` (text size preset,
116
+ * `"s" | "m" | "l" | "xl"`, default `"m"`).
117
+ * @returns A {@linkcode PluginPresentationAnnotateResult} with the created
118
+ * `shapeId`.
119
+ * @throws If Present mode is not open or the sheet id is invalid.
120
+ *
121
+ * @examplePrompt Add a sticky note "Review this wall" to Sheet 1
122
+ * @examplePrompt Put a yellow note on the cover sheet
123
+ * @examplePrompt Leave a note next to the ground floor plan
124
+ *
125
+ * # Example
126
+ * ```ts
127
+ * const { shapeId } = await snaptrude.presentation.annotate.note(
128
+ * "sheet_1",
129
+ * "Review this wall",
130
+ * { position: { x: 60, y: 120 }, color: "yellow" },
131
+ * )
132
+ * ```
133
+ */
134
+ public abstract note(
135
+ sheetId: string,
136
+ text: string,
137
+ options?: {
138
+ position?: { x: number; y: number }
139
+ color?: PluginAnnotateTextColor
140
+ size?: PluginAnnotateTextSize
141
+ },
142
+ ): PluginApiReturn<PluginPresentationAnnotateResult>
143
+
144
+ /**
145
+ * Draw a geo shape (rectangle, ellipse, cloud, …) on a sheet.
146
+ *
147
+ * Creates a geo shape of the given `kind` — the same shapes as the Present
148
+ * toolbar's shape flyout — sized to `bounds` (relative to the sheet's
149
+ * top-left, in canvas units) and returns the id of the created canvas shape.
150
+ * Requires Present mode to be open.
151
+ *
152
+ * @param sheetId - The sheet to annotate.
153
+ * @param kind - The shape kind ({@linkcode PluginAnnotateGeoKind}), e.g.
154
+ * `"rectangle"`, `"ellipse"`, `"cloud"`.
155
+ * @param bounds - Placement box `{ x, y, w, h }` — `x`/`y` are the shape's
156
+ * top-left relative to the sheet's top-left; `w`/`h` must be positive.
157
+ * @param options - Optional `color` (a named palette color, default
158
+ * `"black"`) and `fill` ({@linkcode PluginAnnotateFill}, default `"none"` —
159
+ * outline only).
160
+ * @returns A {@linkcode PluginPresentationAnnotateResult} with the created
161
+ * `shapeId`.
162
+ * @throws If Present mode is not open or the sheet id is invalid.
163
+ *
164
+ * @examplePrompt Draw a revision cloud around the kitchen on Sheet 2
165
+ * @examplePrompt Add a red rectangle highlight to the sheet
166
+ * @examplePrompt Draw an ellipse around the entrance on the cover sheet
167
+ *
168
+ * # Example
169
+ * ```ts
170
+ * const { shapeId } = await snaptrude.presentation.annotate.shape(
171
+ * "sheet_1",
172
+ * "cloud",
173
+ * { x: 80, y: 80, w: 240, h: 160 },
174
+ * { color: "red" },
175
+ * )
176
+ * ```
177
+ */
178
+ public abstract shape(
179
+ sheetId: string,
180
+ kind: PluginAnnotateGeoKind,
181
+ bounds: { x: number; y: number; w: number; h: number },
182
+ options?: {
183
+ color?: PluginAnnotateTextColor
184
+ fill?: PluginAnnotateFill
185
+ },
186
+ ): PluginApiReturn<PluginPresentationAnnotateResult>
187
+ }
188
+
189
+ /** Text size preset (the same s/m/l/xl scale as the Present-mode text tool). */
190
+ export const PluginAnnotateTextSize = z.enum(["s", "m", "l", "xl"])
191
+ export type PluginAnnotateTextSize = z.infer<typeof PluginAnnotateTextSize>
192
+
193
+ /** Named palette color (the same swatches as the Present-mode style panel). */
194
+ export const PluginAnnotateTextColor = z.enum([
195
+ "black",
196
+ "grey",
197
+ "light-violet",
198
+ "violet",
199
+ "blue",
200
+ "light-blue",
201
+ "yellow",
202
+ "orange",
203
+ "green",
204
+ "light-green",
205
+ "light-red",
206
+ "red",
207
+ "white",
208
+ ])
209
+ export type PluginAnnotateTextColor = z.infer<typeof PluginAnnotateTextColor>
210
+
211
+ /**
212
+ * Arguments for {@linkcode PluginPresentationAnnotateApi.text}.
213
+ *
214
+ * | Property | Type | Description |
215
+ * |---|---|---|
216
+ * | `sheetId` | `string` | The sheet to annotate |
217
+ * | `text` | `string` | The label text |
218
+ * | `position` | `{ x: number; y: number } \| undefined` | Where to place it (relative to the sheet) |
219
+ * | `size` | {@linkcode PluginAnnotateTextSize}` \| undefined` | Text size preset |
220
+ * | `color` | {@linkcode PluginAnnotateTextColor}` \| undefined` | Text color |
221
+ */
222
+ export const PluginPresentationAnnotateTextArgs = z.object({
223
+ sheetId: z.string(),
224
+ text: z.string(),
225
+ position: z.object({ x: z.number(), y: z.number() }).optional(),
226
+ size: PluginAnnotateTextSize.optional(),
227
+ color: PluginAnnotateTextColor.optional(),
228
+ })
229
+ export type PluginPresentationAnnotateTextArgs = z.infer<
230
+ typeof PluginPresentationAnnotateTextArgs
231
+ >
232
+
233
+ /**
234
+ * Result of {@linkcode PluginPresentationAnnotateApi.text}.
235
+ *
236
+ * | Property | Type | Description |
237
+ * |---|---|---|
238
+ * | `shapeId` | `string` | Id of the created text shape |
239
+ */
240
+ export const PluginPresentationAnnotateTextResult = z.object({
241
+ shapeId: z.string(),
242
+ })
243
+ export type PluginPresentationAnnotateTextResult = z.infer<
244
+ typeof PluginPresentationAnnotateTextResult
245
+ >
246
+
247
+ /**
248
+ * Geo shape kind — the shapes offered by the Present-mode toolbar's shape
249
+ * flyout.
250
+ */
251
+ export const PluginAnnotateGeoKind = z.enum([
252
+ "rectangle",
253
+ "ellipse",
254
+ "triangle",
255
+ "diamond",
256
+ "hexagon",
257
+ "oval",
258
+ "rhombus",
259
+ "star",
260
+ "cloud",
261
+ "heart",
262
+ "x-box",
263
+ "check-box",
264
+ "arrow-left",
265
+ "arrow-up",
266
+ "arrow-right",
267
+ "arrow-down",
268
+ ])
269
+ export type PluginAnnotateGeoKind = z.infer<typeof PluginAnnotateGeoKind>
270
+
271
+ /** Fill style for geo shapes (the same fills as the Present-mode style panel). */
272
+ export const PluginAnnotateFill = z.enum(["none", "semi", "solid", "pattern"])
273
+ export type PluginAnnotateFill = z.infer<typeof PluginAnnotateFill>
274
+
275
+ /**
276
+ * Arguments for {@linkcode PluginPresentationAnnotateApi.arrow}.
277
+ *
278
+ * | Property | Type | Description |
279
+ * |---|---|---|
280
+ * | `sheetId` | `string` | The sheet to annotate |
281
+ * | `start` | `{ x: number; y: number }` | Arrow tail (relative to the sheet) |
282
+ * | `end` | `{ x: number; y: number }` | Arrow head (relative to the sheet) |
283
+ * | `color` | {@linkcode PluginAnnotateTextColor}` \| undefined` | Arrow color |
284
+ * | `size` | {@linkcode PluginAnnotateTextSize}` \| undefined` | Stroke weight preset |
285
+ */
286
+ export const PluginPresentationAnnotateArrowArgs = z.object({
287
+ sheetId: z.string(),
288
+ start: z.object({ x: z.number(), y: z.number() }),
289
+ end: z.object({ x: z.number(), y: z.number() }),
290
+ color: PluginAnnotateTextColor.optional(),
291
+ size: PluginAnnotateTextSize.optional(),
292
+ })
293
+ export type PluginPresentationAnnotateArrowArgs = z.infer<
294
+ typeof PluginPresentationAnnotateArrowArgs
295
+ >
296
+
297
+ /**
298
+ * Arguments for {@linkcode PluginPresentationAnnotateApi.note}.
299
+ *
300
+ * | Property | Type | Description |
301
+ * |---|---|---|
302
+ * | `sheetId` | `string` | The sheet to annotate |
303
+ * | `text` | `string` | The note text |
304
+ * | `position` | `{ x: number; y: number } \| undefined` | Where to place it (relative to the sheet) |
305
+ * | `color` | {@linkcode PluginAnnotateTextColor}` \| undefined` | Sticky fill color |
306
+ * | `size` | {@linkcode PluginAnnotateTextSize}` \| undefined` | Text size preset |
307
+ */
308
+ export const PluginPresentationAnnotateNoteArgs = z.object({
309
+ sheetId: z.string(),
310
+ text: z.string(),
311
+ position: z.object({ x: z.number(), y: z.number() }).optional(),
312
+ color: PluginAnnotateTextColor.optional(),
313
+ size: PluginAnnotateTextSize.optional(),
314
+ })
315
+ export type PluginPresentationAnnotateNoteArgs = z.infer<
316
+ typeof PluginPresentationAnnotateNoteArgs
317
+ >
318
+
319
+ /**
320
+ * Arguments for {@linkcode PluginPresentationAnnotateApi.shape}.
321
+ *
322
+ * | Property | Type | Description |
323
+ * |---|---|---|
324
+ * | `sheetId` | `string` | The sheet to annotate |
325
+ * | `kind` | {@linkcode PluginAnnotateGeoKind} | The shape kind |
326
+ * | `bounds` | `{ x: number; y: number; w: number; h: number }` | Placement box (relative to the sheet; `w`/`h` positive) |
327
+ * | `color` | {@linkcode PluginAnnotateTextColor}` \| undefined` | Outline color |
328
+ * | `fill` | {@linkcode PluginAnnotateFill}` \| undefined` | Fill style |
329
+ */
330
+ export const PluginPresentationAnnotateShapeArgs = z.object({
331
+ sheetId: z.string(),
332
+ kind: PluginAnnotateGeoKind,
333
+ bounds: z.object({
334
+ x: z.number(),
335
+ y: z.number(),
336
+ w: z.number().positive(),
337
+ h: z.number().positive(),
338
+ }),
339
+ color: PluginAnnotateTextColor.optional(),
340
+ fill: PluginAnnotateFill.optional(),
341
+ })
342
+ export type PluginPresentationAnnotateShapeArgs = z.infer<
343
+ typeof PluginPresentationAnnotateShapeArgs
344
+ >
345
+
346
+ /**
347
+ * Result of {@linkcode PluginPresentationAnnotateApi.arrow},
348
+ * {@linkcode PluginPresentationAnnotateApi.note}, and
349
+ * {@linkcode PluginPresentationAnnotateApi.shape}.
350
+ *
351
+ * | Property | Type | Description |
352
+ * |---|---|---|
353
+ * | `shapeId` | `string` | Id of the created canvas shape |
354
+ */
355
+ export const PluginPresentationAnnotateResult = z.object({
356
+ shapeId: z.string(),
357
+ })
358
+ export type PluginPresentationAnnotateResult = z.infer<
359
+ typeof PluginPresentationAnnotateResult
360
+ >