@snaptrude/plugin-core 0.7.1 → 0.8.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.
- package/CHANGELOG.md +14 -0
- package/api-manifest.full.json +6442 -0
- package/api-manifest.json +2029 -128
- package/dist/api/core/camera/index.d.ts +208 -0
- package/dist/api/core/camera/index.d.ts.map +1 -0
- package/dist/api/core/comment/index.d.ts +105 -2
- package/dist/api/core/comment/index.d.ts.map +1 -1
- package/dist/api/core/geom/create/index.d.ts +13 -13
- package/dist/api/core/geom/delete/index.d.ts +8 -2
- package/dist/api/core/geom/delete/index.d.ts.map +1 -1
- package/dist/api/core/geom/query/arc.d.ts +5 -5
- package/dist/api/core/geom/query/brep.d.ts +18 -18
- package/dist/api/core/geom/query/circle.d.ts +18 -18
- package/dist/api/core/geom/query/contour.d.ts +20 -20
- package/dist/api/core/geom/query/curve.d.ts +49 -49
- package/dist/api/core/geom/query/edge.d.ts +5 -5
- package/dist/api/core/geom/query/face.d.ts +16 -16
- package/dist/api/core/geom/query/halfedge.d.ts +8 -8
- package/dist/api/core/geom/query/profile.d.ts +19 -19
- package/dist/api/core/geom/query/vertex.d.ts +8 -8
- package/dist/api/core/geom/update/contour.d.ts +14 -14
- package/dist/api/core/geom/update/curve.d.ts +7 -7
- package/dist/api/core/geom/update/profile.d.ts +16 -16
- package/dist/api/core/handles/index.d.ts +210 -0
- package/dist/api/core/handles/index.d.ts.map +1 -0
- package/dist/api/core/index.d.ts +15 -0
- package/dist/api/core/index.d.ts.map +1 -1
- package/dist/api/core/io/export/index.d.ts +132 -0
- package/dist/api/core/io/export/index.d.ts.map +1 -0
- package/dist/api/core/io/import/index.d.ts +1 -1
- package/dist/api/core/io/index.d.ts +5 -0
- package/dist/api/core/io/index.d.ts.map +1 -1
- package/dist/api/core/layers.d.ts +7 -7
- package/dist/api/core/proposals/index.d.ts +65 -9
- package/dist/api/core/proposals/index.d.ts.map +1 -1
- package/dist/api/core/user.d.ts +44 -0
- package/dist/api/core/user.d.ts.map +1 -0
- package/dist/api/design/boolean/index.d.ts +4 -4
- package/dist/api/design/create/index.d.ts +139 -44
- package/dist/api/design/create/index.d.ts.map +1 -1
- package/dist/api/design/doors/index.d.ts +36 -0
- package/dist/api/design/doors/index.d.ts.map +1 -1
- package/dist/api/design/edit/index.d.ts +1 -1
- package/dist/api/design/erase/index.d.ts +2 -2
- package/dist/api/design/furniture/index.d.ts +114 -3
- package/dist/api/design/furniture/index.d.ts.map +1 -1
- package/dist/api/design/index.d.ts +10 -0
- package/dist/api/design/index.d.ts.map +1 -1
- package/dist/api/design/materials/index.d.ts +111 -14
- package/dist/api/design/materials/index.d.ts.map +1 -1
- package/dist/api/design/query/index.d.ts +31 -1
- package/dist/api/design/query/index.d.ts.map +1 -1
- package/dist/api/design/query/spaces.d.ts +5 -5
- package/dist/api/design/transform/index.d.ts +83 -14
- package/dist/api/design/transform/index.d.ts.map +1 -1
- package/dist/api/design/types/index.d.ts +181 -0
- package/dist/api/design/types/index.d.ts.map +1 -0
- package/dist/api/design/update/index.d.ts +335 -2
- package/dist/api/design/update/index.d.ts.map +1 -1
- package/dist/api/design/visibility.d.ts +98 -0
- package/dist/api/design/visibility.d.ts.map +1 -0
- package/dist/api/entity/referenceLine.d.ts +2 -2
- package/dist/api/entity/space.d.ts +19 -19
- package/dist/api/entity/story.d.ts +128 -15
- package/dist/api/entity/story.d.ts.map +1 -1
- package/dist/api/presentation/annotate.d.ts +448 -0
- package/dist/api/presentation/annotate.d.ts.map +1 -0
- package/dist/api/presentation/diagrams.d.ts +49 -8
- package/dist/api/presentation/diagrams.d.ts.map +1 -1
- package/dist/api/presentation/export.d.ts +104 -0
- package/dist/api/presentation/export.d.ts.map +1 -0
- package/dist/api/presentation/index.d.ts +38 -0
- package/dist/api/presentation/index.d.ts.map +1 -1
- package/dist/api/presentation/sheets.d.ts +410 -13
- package/dist/api/presentation/sheets.d.ts.map +1 -1
- package/dist/api/presentation/views.d.ts +165 -10
- package/dist/api/presentation/views.d.ts.map +1 -1
- package/dist/api/program/areas.d.ts +63 -3
- package/dist/api/program/areas.d.ts.map +1 -1
- package/dist/api/program/cores.d.ts +3 -99
- package/dist/api/program/cores.d.ts.map +1 -1
- package/dist/api/program/index.d.ts +2 -2
- package/dist/api/program/index.d.ts.map +1 -1
- package/dist/api/program/layout.d.ts +172 -12
- package/dist/api/program/layout.d.ts.map +1 -1
- package/dist/api/program/site.d.ts +11 -8
- package/dist/api/program/site.d.ts.map +1 -1
- package/dist/api/program/spreadsheet.d.ts +105 -13
- package/dist/api/program/spreadsheet.d.ts.map +1 -1
- package/dist/handles.d.ts +64 -25
- package/dist/handles.d.ts.map +1 -1
- package/dist/index.cjs +2316 -1644
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +2224 -1639
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/api/core/camera/index.ts +212 -0
- package/src/api/core/comment/index.ts +120 -2
- package/src/api/core/geom/delete/index.ts +6 -0
- package/src/api/core/handles/index.ts +233 -0
- package/src/api/core/index.ts +15 -0
- package/src/api/core/io/export/index.ts +124 -0
- package/src/api/core/io/index.ts +5 -0
- package/src/api/core/proposals/index.ts +71 -11
- package/src/api/core/user.ts +46 -0
- package/src/api/design/create/index.ts +166 -36
- package/src/api/design/doors/index.ts +40 -0
- package/src/api/design/furniture/index.ts +127 -3
- package/src/api/design/index.ts +10 -0
- package/src/api/design/materials/index.ts +157 -30
- package/src/api/design/query/index.ts +33 -7
- package/src/api/design/transform/index.ts +89 -12
- package/src/api/design/types/index.ts +156 -0
- package/src/api/design/update/index.ts +402 -6
- package/src/api/design/visibility.ts +109 -0
- package/src/api/entity/story.ts +141 -15
- package/src/api/presentation/annotate.ts +360 -0
- package/src/api/presentation/diagrams.ts +53 -8
- package/src/api/presentation/export.ts +104 -0
- package/src/api/presentation/index.ts +46 -0
- package/src/api/presentation/sheets.ts +346 -13
- package/src/api/presentation/views.ts +164 -12
- package/src/api/program/areas.ts +57 -6
- package/src/api/program/cores.ts +3 -91
- package/src/api/program/index.ts +2 -2
- package/src/api/program/layout.ts +182 -12
- package/src/api/program/site.ts +11 -8
- package/src/api/program/spreadsheet.ts +125 -29
- package/src/handles.ts +77 -13
- package/tsconfig.json +7 -2
package/src/api/entity/story.ts
CHANGED
|
@@ -102,21 +102,32 @@ export abstract class PluginStoryApi {
|
|
|
102
102
|
): PluginApiReturn<PluginStoryCreateResult>
|
|
103
103
|
|
|
104
104
|
/**
|
|
105
|
-
* Update a story's floor-to-floor height
|
|
105
|
+
* Update a story's floor-to-floor `height` and/or `name`.
|
|
106
106
|
*
|
|
107
|
-
*
|
|
108
|
-
* walls, columns, and masses on the story are **stretched** to the new
|
|
109
|
-
* every story **above shifts up/down** by the delta so the stack stays
|
|
107
|
+
* **Height** is the same operation as editing the height in the Stories panel:
|
|
108
|
+
* the walls, columns, and masses on the story are **stretched** to the new
|
|
109
|
+
* height, every story **above shifts up/down** by the delta so the stack stays
|
|
110
110
|
* contiguous, and coupled elements (staircases, parametric curtain walls,
|
|
111
|
-
* furniture offsets) are re-fitted. The whole cascade is committed as
|
|
112
|
-
* undo step**. Height-locked elements are left untouched.
|
|
111
|
+
* furniture offsets) are re-fitted. The whole height cascade is committed as
|
|
112
|
+
* **one undo step**. Height-locked elements are left untouched.
|
|
113
|
+
*
|
|
114
|
+
* **Name** is the same as renaming the story in the Stories panel: it is
|
|
115
|
+
* persisted immediately (saved to the project) but, mirroring the panel, is
|
|
116
|
+
* **not** part of the height undo step.
|
|
117
|
+
*
|
|
118
|
+
* At least one of `height` or `options.name` must be supplied. Omitting the
|
|
119
|
+
* `height` argument (e.g. for a rename-only update) leaves the height
|
|
120
|
+
* untouched.
|
|
113
121
|
*
|
|
114
122
|
* @param storyValue - Integer storey number
|
|
115
123
|
* identifying the story to update
|
|
116
124
|
* @param height - New floor-to-floor height in
|
|
117
|
-
* Babylon units
|
|
118
|
-
* @
|
|
125
|
+
* Babylon units. Omit to leave the height unchanged.
|
|
126
|
+
* @param options - `name` (new display name for the story)
|
|
127
|
+
* @returns A {@linkcode PluginStoryUpdateResult} with the story's
|
|
128
|
+
* `storyValue`, `height`, and `name` after the update
|
|
119
129
|
* @throws `PRECONDITION_FAILED` if no story has the given value;
|
|
130
|
+
* `VALIDATION` if neither `height` nor `options.name` is supplied;
|
|
120
131
|
* `STORY_HEIGHT_REJECTED` if the engine rejects the height (e.g. out of
|
|
121
132
|
* range — the change silently reverts host-side and is surfaced as this
|
|
122
133
|
* error); `STORY_UPDATE_FAILED` if the story cannot be re-read after the
|
|
@@ -124,21 +135,77 @@ export abstract class PluginStoryApi {
|
|
|
124
135
|
*
|
|
125
136
|
* @examplePrompt Change the ground floor height to 3.5 metres
|
|
126
137
|
* @examplePrompt Make the second storey taller
|
|
138
|
+
* @examplePrompt Rename the ground floor to "Lobby"
|
|
127
139
|
* @examplePrompt Set the floor-to-floor height of level 1
|
|
128
|
-
* @examplePrompt
|
|
140
|
+
* @examplePrompt Rename storey 2 and make it taller in one go
|
|
129
141
|
*
|
|
130
142
|
* # Example
|
|
131
143
|
* ```ts
|
|
132
144
|
* // Set ground floor height to 5 Babylon units — walls stretch and the
|
|
133
145
|
* // floors above move up to match, all in a single undo step.
|
|
134
146
|
* const result = await snaptrude.entity.story.update(1, 5)
|
|
147
|
+
* // Rename only, leaving the height untouched.
|
|
148
|
+
* await snaptrude.entity.story.update(1, undefined, { name: "Lobby" })
|
|
135
149
|
* ```
|
|
136
150
|
*/
|
|
137
151
|
public abstract update(
|
|
138
152
|
storyValue: number,
|
|
139
|
-
height
|
|
153
|
+
height?: number,
|
|
154
|
+
options?: { name?: string },
|
|
140
155
|
): PluginApiReturn<PluginStoryUpdateResult>
|
|
141
156
|
|
|
157
|
+
/**
|
|
158
|
+
* Make a story the active story — the same as clicking it in the storey/layer
|
|
159
|
+
* panel. Subsequent draws and creates target this story, and in 2D the
|
|
160
|
+
* viewport switches to it. This is a view/navigation change: it is **not**
|
|
161
|
+
* undoable and commits nothing to the model.
|
|
162
|
+
*
|
|
163
|
+
* @param storyValue - Integer storey number to activate
|
|
164
|
+
* @returns A {@linkcode PluginStorySetActiveResult} echoing the now-active `storyValue`
|
|
165
|
+
* @throws `PRECONDITION_FAILED` if no story has the given value
|
|
166
|
+
*
|
|
167
|
+
* @examplePrompt Switch to the second floor
|
|
168
|
+
* @examplePrompt Make the ground storey active
|
|
169
|
+
* @examplePrompt Go to the basement level
|
|
170
|
+
* @examplePrompt Set level 3 as the current storey
|
|
171
|
+
*
|
|
172
|
+
* # Example
|
|
173
|
+
* ```ts
|
|
174
|
+
* // Activate story 2, then draw a wall — it lands on story 2.
|
|
175
|
+
* await snaptrude.entity.story.setActive(2)
|
|
176
|
+
* ```
|
|
177
|
+
*/
|
|
178
|
+
public abstract setActive(
|
|
179
|
+
storyValue: number,
|
|
180
|
+
): PluginApiReturn<PluginStorySetActiveResult>
|
|
181
|
+
|
|
182
|
+
/**
|
|
183
|
+
* Delete a story and everything on it — the same as removing it from the
|
|
184
|
+
* storey panel. Every element placed on the story (walls, floors, masses, …)
|
|
185
|
+
* is deleted with it, the remaining stories are re-stacked, and the active
|
|
186
|
+
* story falls back to an adjacent one. Committed as a single undo step.
|
|
187
|
+
*
|
|
188
|
+
* @param storyValue - Integer storey number to delete
|
|
189
|
+
* @returns A {@linkcode PluginStoryDeleteResult} with the deleted `storyValue`
|
|
190
|
+
* and the `newActiveStory` the editor fell back to
|
|
191
|
+
* @throws `PRECONDITION_FAILED` if no story has the given value; or if plugin
|
|
192
|
+
* writes are disabled
|
|
193
|
+
*
|
|
194
|
+
* @examplePrompt Delete the top floor
|
|
195
|
+
* @examplePrompt Remove the basement level
|
|
196
|
+
* @examplePrompt Get rid of storey 3
|
|
197
|
+
* @examplePrompt Delete the second floor and everything on it
|
|
198
|
+
*
|
|
199
|
+
* # Example
|
|
200
|
+
* ```ts
|
|
201
|
+
* const { newActiveStory } = await snaptrude.entity.story.delete(3)
|
|
202
|
+
* console.log(`Deleted story 3; now on story ${newActiveStory}`)
|
|
203
|
+
* ```
|
|
204
|
+
*/
|
|
205
|
+
public abstract delete(
|
|
206
|
+
storyValue: number,
|
|
207
|
+
): PluginApiReturn<PluginStoryDeleteResult>
|
|
208
|
+
|
|
142
209
|
/**
|
|
143
210
|
* Duplicate a story into the adjacent level, up or down.
|
|
144
211
|
*
|
|
@@ -301,35 +368,94 @@ export const PluginStoryCreateResult = z.object({
|
|
|
301
368
|
export type PluginStoryCreateResult = z.infer<typeof PluginStoryCreateResult>
|
|
302
369
|
|
|
303
370
|
/**
|
|
304
|
-
* Arguments for {@linkcode PluginStoryApi.update}.
|
|
371
|
+
* Arguments for {@linkcode PluginStoryApi.update}. At least one of `height` or
|
|
372
|
+
* `name` must be supplied.
|
|
305
373
|
*
|
|
306
374
|
* | Property | Type | Description |
|
|
307
375
|
* |---|---|---|
|
|
308
376
|
* | `storyValue` | `number` (int) | Storey number of the story to update |
|
|
309
|
-
* | `height` | `number
|
|
377
|
+
* | `height` | `number?` | New height in Babylon units (omit to leave unchanged) |
|
|
378
|
+
* | `name` | `string?` | New display name for the story (omit to leave unchanged) |
|
|
310
379
|
*/
|
|
311
380
|
export const PluginStoryUpdateArgs = z.object({
|
|
312
381
|
storyValue: z.number().int(),
|
|
313
|
-
height: z.number(),
|
|
382
|
+
height: z.number().optional(),
|
|
383
|
+
name: z.string().optional(),
|
|
314
384
|
})
|
|
315
385
|
|
|
316
386
|
export type PluginStoryUpdateArgs = z.infer<typeof PluginStoryUpdateArgs>
|
|
317
387
|
|
|
318
388
|
/**
|
|
319
|
-
* Result of {@linkcode PluginStoryApi.update}.
|
|
389
|
+
* Result of {@linkcode PluginStoryApi.update} — the story's state after the update.
|
|
320
390
|
*
|
|
321
391
|
* | Property | Type | Description |
|
|
322
392
|
* |---|---|---|
|
|
323
393
|
* | `storyValue` | `number` | The storey number of the updated story |
|
|
324
|
-
* | `height` | `number` | The
|
|
394
|
+
* | `height` | `number` | The height after the update |
|
|
395
|
+
* | `name` | `string` | The name after the update |
|
|
325
396
|
*/
|
|
326
397
|
export const PluginStoryUpdateResult = z.object({
|
|
327
398
|
storyValue: z.number(),
|
|
328
399
|
height: z.number(),
|
|
400
|
+
name: z.string(),
|
|
329
401
|
})
|
|
330
402
|
|
|
331
403
|
export type PluginStoryUpdateResult = z.infer<typeof PluginStoryUpdateResult>
|
|
332
404
|
|
|
405
|
+
/**
|
|
406
|
+
* Arguments for {@linkcode PluginStoryApi.setActive}.
|
|
407
|
+
*
|
|
408
|
+
* | Property | Type | Description |
|
|
409
|
+
* |---|---|---|
|
|
410
|
+
* | `storyValue` | `number` (int) | Storey number to activate |
|
|
411
|
+
*/
|
|
412
|
+
export const PluginStorySetActiveArgs = z.object({
|
|
413
|
+
storyValue: z.number().int(),
|
|
414
|
+
})
|
|
415
|
+
|
|
416
|
+
export type PluginStorySetActiveArgs = z.infer<typeof PluginStorySetActiveArgs>
|
|
417
|
+
|
|
418
|
+
/**
|
|
419
|
+
* Result of {@linkcode PluginStoryApi.setActive}.
|
|
420
|
+
*
|
|
421
|
+
* | Property | Type | Description |
|
|
422
|
+
* |---|---|---|
|
|
423
|
+
* | `storyValue` | `number` | The storey number that is now active |
|
|
424
|
+
*/
|
|
425
|
+
export const PluginStorySetActiveResult = z.object({
|
|
426
|
+
storyValue: z.number(),
|
|
427
|
+
})
|
|
428
|
+
|
|
429
|
+
export type PluginStorySetActiveResult = z.infer<typeof PluginStorySetActiveResult>
|
|
430
|
+
|
|
431
|
+
/**
|
|
432
|
+
* Arguments for {@linkcode PluginStoryApi.delete}.
|
|
433
|
+
*
|
|
434
|
+
* | Property | Type | Description |
|
|
435
|
+
* |---|---|---|
|
|
436
|
+
* | `storyValue` | `number` (int) | Storey number to delete |
|
|
437
|
+
*/
|
|
438
|
+
export const PluginStoryDeleteArgs = z.object({
|
|
439
|
+
storyValue: z.number().int(),
|
|
440
|
+
})
|
|
441
|
+
|
|
442
|
+
export type PluginStoryDeleteArgs = z.infer<typeof PluginStoryDeleteArgs>
|
|
443
|
+
|
|
444
|
+
/**
|
|
445
|
+
* Result of {@linkcode PluginStoryApi.delete}.
|
|
446
|
+
*
|
|
447
|
+
* | Property | Type | Description |
|
|
448
|
+
* |---|---|---|
|
|
449
|
+
* | `storyValue` | `number` | The storey number that was deleted |
|
|
450
|
+
* | `newActiveStory` | `number` | The storey the editor fell back to as active |
|
|
451
|
+
*/
|
|
452
|
+
export const PluginStoryDeleteResult = z.object({
|
|
453
|
+
storyValue: z.number(),
|
|
454
|
+
newActiveStory: z.number(),
|
|
455
|
+
})
|
|
456
|
+
|
|
457
|
+
export type PluginStoryDeleteResult = z.infer<typeof PluginStoryDeleteResult>
|
|
458
|
+
|
|
333
459
|
/**
|
|
334
460
|
* Arguments for {@linkcode PluginStoryApi.duplicate} (options flattened).
|
|
335
461
|
*
|
|
@@ -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
|
+
>
|
|
@@ -2,23 +2,54 @@ import * as z from "zod"
|
|
|
2
2
|
import { PluginApiReturn } from "../../types"
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
|
-
* Presentation diagrams —
|
|
5
|
+
* Presentation diagrams — generate program diagrams from the model, and place
|
|
6
|
+
* diagram images onto sheets.
|
|
6
7
|
*
|
|
7
|
-
* {@linkcode PluginPresentationDiagramsApi.
|
|
8
|
-
*
|
|
9
|
-
*
|
|
8
|
+
* {@linkcode PluginPresentationDiagramsApi.generateProgram} runs the Present-mode
|
|
9
|
+
* **Program** action: it reads the project's spaces and departments and creates
|
|
10
|
+
* new layout sheets holding the generated diagram graphics.
|
|
11
|
+
* {@linkcode PluginPresentationDiagramsApi.place} drops ready diagram images (by
|
|
12
|
+
* URL) onto an existing sheet and returns the created canvas shape ids. Both
|
|
13
|
+
* require Present mode to be open. Adjacency data itself is read and computed via
|
|
10
14
|
* `program.adjacency` (see {@linkcode PluginProgramAdjacencyApi}).
|
|
11
15
|
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
+
* There is intentionally no `generateAdjacency`: the host's adjacency generator
|
|
17
|
+
* runs its sheet-creation task fire-and-forget internally, so a single call
|
|
18
|
+
* cannot return the sheets it creates. Use the Present-mode Adjacency menu for
|
|
19
|
+
* those, then `place` a pre-rendered adjacency image if you need it via the API.
|
|
16
20
|
*
|
|
17
21
|
* Accessed via `snaptrude.presentation.diagrams`.
|
|
18
22
|
*/
|
|
19
23
|
export abstract class PluginPresentationDiagramsApi {
|
|
20
24
|
constructor() {}
|
|
21
25
|
|
|
26
|
+
/**
|
|
27
|
+
* Generate the program (space + department) diagrams for the current model,
|
|
28
|
+
* creating new layout sheets.
|
|
29
|
+
*
|
|
30
|
+
* Runs the same auto-generation as the Present-mode **Program** action: reads
|
|
31
|
+
* the project's spaces and departments, lays them out to scale, and creates one
|
|
32
|
+
* or more new sheets holding the generated diagram graphics. Unlike
|
|
33
|
+
* {@linkcode PluginPresentationDiagramsApi.place} (which pastes ready image URLs
|
|
34
|
+
* onto an existing sheet), this generates the graphics from the model and
|
|
35
|
+
* creates its own sheets. Requires Present mode to be open.
|
|
36
|
+
*
|
|
37
|
+
* @returns A {@linkcode PluginPresentationDiagramsGenerateResult} with the
|
|
38
|
+
* `sheetIds` of the sheets created.
|
|
39
|
+
* @throws If Present mode is not open, or the model has no spaces/departments to
|
|
40
|
+
* generate from.
|
|
41
|
+
*
|
|
42
|
+
* @examplePrompt Generate the program diagrams for this project
|
|
43
|
+
* @examplePrompt Auto-generate the space and department diagram sheets
|
|
44
|
+
* @examplePrompt Create the program layout sheets from the model
|
|
45
|
+
*
|
|
46
|
+
* # Example
|
|
47
|
+
* ```ts
|
|
48
|
+
* const { sheetIds } = await snaptrude.presentation.diagrams.generateProgram()
|
|
49
|
+
* ```
|
|
50
|
+
*/
|
|
51
|
+
public abstract generateProgram(): PluginApiReturn<PluginPresentationDiagramsGenerateResult>
|
|
52
|
+
|
|
22
53
|
/**
|
|
23
54
|
* Place diagram images onto a sheet.
|
|
24
55
|
*
|
|
@@ -82,3 +113,17 @@ export const PluginPresentationDiagramsPlaceResult = z.object({
|
|
|
82
113
|
export type PluginPresentationDiagramsPlaceResult = z.infer<
|
|
83
114
|
typeof PluginPresentationDiagramsPlaceResult
|
|
84
115
|
>
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* Result of {@linkcode PluginPresentationDiagramsApi.generateProgram}.
|
|
119
|
+
*
|
|
120
|
+
* | Property | Type | Description |
|
|
121
|
+
* |---|---|---|
|
|
122
|
+
* | `sheetIds` | `string[]` | Ids of the sheets created by the generator |
|
|
123
|
+
*/
|
|
124
|
+
export const PluginPresentationDiagramsGenerateResult = z.object({
|
|
125
|
+
sheetIds: z.array(z.string()),
|
|
126
|
+
})
|
|
127
|
+
export type PluginPresentationDiagramsGenerateResult = z.infer<
|
|
128
|
+
typeof PluginPresentationDiagramsGenerateResult
|
|
129
|
+
>
|