@snaptrude/plugin-core 0.7.0 → 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.
Files changed (133) hide show
  1. package/CHANGELOG.md +22 -0
  2. package/api-manifest.full.json +360 -19
  3. package/api-manifest.json +915 -37
  4. package/dist/api/core/camera/index.d.ts +208 -0
  5. package/dist/api/core/camera/index.d.ts.map +1 -0
  6. package/dist/api/core/comment/index.d.ts +105 -2
  7. package/dist/api/core/comment/index.d.ts.map +1 -1
  8. package/dist/api/core/geom/create/index.d.ts +13 -13
  9. package/dist/api/core/geom/delete/index.d.ts +8 -2
  10. package/dist/api/core/geom/delete/index.d.ts.map +1 -1
  11. package/dist/api/core/geom/query/arc.d.ts +5 -5
  12. package/dist/api/core/geom/query/brep.d.ts +18 -18
  13. package/dist/api/core/geom/query/circle.d.ts +18 -18
  14. package/dist/api/core/geom/query/contour.d.ts +20 -20
  15. package/dist/api/core/geom/query/curve.d.ts +49 -49
  16. package/dist/api/core/geom/query/edge.d.ts +5 -5
  17. package/dist/api/core/geom/query/face.d.ts +16 -16
  18. package/dist/api/core/geom/query/halfedge.d.ts +8 -8
  19. package/dist/api/core/geom/query/profile.d.ts +19 -19
  20. package/dist/api/core/geom/query/vertex.d.ts +8 -8
  21. package/dist/api/core/geom/update/contour.d.ts +14 -14
  22. package/dist/api/core/geom/update/curve.d.ts +7 -7
  23. package/dist/api/core/geom/update/profile.d.ts +16 -16
  24. package/dist/api/core/handles/index.d.ts +210 -0
  25. package/dist/api/core/handles/index.d.ts.map +1 -0
  26. package/dist/api/core/index.d.ts +15 -0
  27. package/dist/api/core/index.d.ts.map +1 -1
  28. package/dist/api/core/io/export/index.d.ts +132 -0
  29. package/dist/api/core/io/export/index.d.ts.map +1 -0
  30. package/dist/api/core/io/import/index.d.ts +1 -1
  31. package/dist/api/core/io/index.d.ts +5 -0
  32. package/dist/api/core/io/index.d.ts.map +1 -1
  33. package/dist/api/core/layers.d.ts +7 -7
  34. package/dist/api/core/proposals/index.d.ts +65 -9
  35. package/dist/api/core/proposals/index.d.ts.map +1 -1
  36. package/dist/api/core/user.d.ts +44 -0
  37. package/dist/api/core/user.d.ts.map +1 -0
  38. package/dist/api/design/boolean/index.d.ts +4 -4
  39. package/dist/api/design/create/index.d.ts +139 -44
  40. package/dist/api/design/create/index.d.ts.map +1 -1
  41. package/dist/api/design/doors/index.d.ts +36 -0
  42. package/dist/api/design/doors/index.d.ts.map +1 -1
  43. package/dist/api/design/edit/index.d.ts +1 -1
  44. package/dist/api/design/erase/index.d.ts +2 -2
  45. package/dist/api/design/furniture/index.d.ts +114 -3
  46. package/dist/api/design/furniture/index.d.ts.map +1 -1
  47. package/dist/api/design/index.d.ts +10 -0
  48. package/dist/api/design/index.d.ts.map +1 -1
  49. package/dist/api/design/materials/index.d.ts +111 -14
  50. package/dist/api/design/materials/index.d.ts.map +1 -1
  51. package/dist/api/design/query/index.d.ts +31 -1
  52. package/dist/api/design/query/index.d.ts.map +1 -1
  53. package/dist/api/design/query/spaces.d.ts +5 -5
  54. package/dist/api/design/transform/index.d.ts +83 -14
  55. package/dist/api/design/transform/index.d.ts.map +1 -1
  56. package/dist/api/design/types/index.d.ts +181 -0
  57. package/dist/api/design/types/index.d.ts.map +1 -0
  58. package/dist/api/design/update/index.d.ts +335 -2
  59. package/dist/api/design/update/index.d.ts.map +1 -1
  60. package/dist/api/design/visibility.d.ts +98 -0
  61. package/dist/api/design/visibility.d.ts.map +1 -0
  62. package/dist/api/entity/referenceLine.d.ts +2 -2
  63. package/dist/api/entity/space.d.ts +19 -19
  64. package/dist/api/entity/story.d.ts +128 -15
  65. package/dist/api/entity/story.d.ts.map +1 -1
  66. package/dist/api/presentation/aiInspiration.d.ts +1967 -7
  67. package/dist/api/presentation/aiInspiration.d.ts.map +1 -1
  68. package/dist/api/presentation/annotate.d.ts +448 -0
  69. package/dist/api/presentation/annotate.d.ts.map +1 -0
  70. package/dist/api/presentation/diagrams.d.ts +49 -8
  71. package/dist/api/presentation/diagrams.d.ts.map +1 -1
  72. package/dist/api/presentation/export.d.ts +104 -0
  73. package/dist/api/presentation/export.d.ts.map +1 -0
  74. package/dist/api/presentation/index.d.ts +40 -3
  75. package/dist/api/presentation/index.d.ts.map +1 -1
  76. package/dist/api/presentation/sheets.d.ts +410 -13
  77. package/dist/api/presentation/sheets.d.ts.map +1 -1
  78. package/dist/api/presentation/views.d.ts +165 -10
  79. package/dist/api/presentation/views.d.ts.map +1 -1
  80. package/dist/api/program/areas.d.ts +63 -3
  81. package/dist/api/program/areas.d.ts.map +1 -1
  82. package/dist/api/program/cores.d.ts +3 -99
  83. package/dist/api/program/cores.d.ts.map +1 -1
  84. package/dist/api/program/index.d.ts +2 -2
  85. package/dist/api/program/index.d.ts.map +1 -1
  86. package/dist/api/program/layout.d.ts +172 -12
  87. package/dist/api/program/layout.d.ts.map +1 -1
  88. package/dist/api/program/site.d.ts +11 -8
  89. package/dist/api/program/site.d.ts.map +1 -1
  90. package/dist/api/program/spreadsheet.d.ts +105 -13
  91. package/dist/api/program/spreadsheet.d.ts.map +1 -1
  92. package/dist/handles.d.ts +64 -25
  93. package/dist/handles.d.ts.map +1 -1
  94. package/dist/index.cjs +2502 -1466
  95. package/dist/index.cjs.map +1 -1
  96. package/dist/index.js +2369 -1461
  97. package/dist/index.js.map +1 -1
  98. package/package.json +1 -1
  99. package/src/api/core/camera/index.ts +212 -0
  100. package/src/api/core/comment/index.ts +120 -2
  101. package/src/api/core/geom/delete/index.ts +6 -0
  102. package/src/api/core/handles/index.ts +233 -0
  103. package/src/api/core/index.ts +15 -0
  104. package/src/api/core/io/export/index.ts +124 -0
  105. package/src/api/core/io/index.ts +5 -0
  106. package/src/api/core/proposals/index.ts +71 -11
  107. package/src/api/core/user.ts +46 -0
  108. package/src/api/design/create/index.ts +166 -36
  109. package/src/api/design/doors/index.ts +40 -0
  110. package/src/api/design/furniture/index.ts +127 -3
  111. package/src/api/design/index.ts +10 -0
  112. package/src/api/design/materials/index.ts +157 -30
  113. package/src/api/design/query/index.ts +33 -7
  114. package/src/api/design/transform/index.ts +89 -12
  115. package/src/api/design/types/index.ts +156 -0
  116. package/src/api/design/update/index.ts +402 -6
  117. package/src/api/design/visibility.ts +109 -0
  118. package/src/api/entity/story.ts +141 -15
  119. package/src/api/presentation/aiInspiration.ts +761 -7
  120. package/src/api/presentation/annotate.ts +360 -0
  121. package/src/api/presentation/diagrams.ts +53 -8
  122. package/src/api/presentation/export.ts +104 -0
  123. package/src/api/presentation/index.ts +48 -3
  124. package/src/api/presentation/sheets.ts +346 -13
  125. package/src/api/presentation/views.ts +164 -12
  126. package/src/api/program/areas.ts +57 -6
  127. package/src/api/program/cores.ts +3 -91
  128. package/src/api/program/index.ts +2 -2
  129. package/src/api/program/layout.ts +182 -12
  130. package/src/api/program/site.ts +11 -8
  131. package/src/api/program/spreadsheet.ts +125 -29
  132. package/src/handles.ts +77 -13
  133. package/tsconfig.json +7 -2
@@ -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 — place diagram images onto sheets.
5
+ * Presentation diagrams — generate program diagrams from the model, and place
6
+ * diagram images onto sheets.
6
7
  *
7
- * {@linkcode PluginPresentationDiagramsApi.place} drops diagram images (by
8
- * URL) onto a sheet and returns the created canvas shape ids (requires Present
9
- * mode to be open). Adjacency data itself is read and computed via
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
- * A future one-step spec-based `place` which would render a diagram spec
13
- * and place it in a single call — awaits a public generator from the
14
- * documentation engine; until that generator exists, `place` takes ready
15
- * image `urls` (we do not ship a spec-based `place` that would only throw).
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
+ >
@@ -0,0 +1,104 @@
1
+ import * as z from "zod"
2
+
3
+ /**
4
+ * Presentation export — render the Present-mode layout sheets to a downloadable
5
+ * file (PDF / PNG / JPG) and hand the plugin the bytes as base64.
6
+ *
7
+ * This wraps the same pipeline the Present-mode **Export** dialog drives:
8
+ * each sheet is serialized to an SVG, then either composed into a PDF
9
+ * (svg2pdf/jspdf) or rasterized to a PNG/JPG. Nothing is written to disk
10
+ * host-side — the plugin receives the encoded bytes and decides what to do
11
+ * with them (save, upload, preview).
12
+ *
13
+ * Requires **Present mode to be open** (the documentation editor); the call
14
+ * throws `PRECONDITION_FAILED` when it is not.
15
+ *
16
+ * The result is always a uniform `{ files }` array (see
17
+ * {@linkcode PluginPresentationExportResult}):
18
+ * - `pdf` with `combine` (the default) → a single multi-page file.
19
+ * - `pdf` with `combine: false`, or any `png`/`jpg` → one file per sheet.
20
+ *
21
+ * Accessed via `snaptrude.presentation.export`.
22
+ *
23
+ * The schemas and result types live here; the callable method is declared on
24
+ * {@linkcode PluginPresentationApi.export}.
25
+ */
26
+
27
+ /** Output file format: a vector `pdf`, or a rasterized `png` / `jpg`. */
28
+ export const PluginPresentationExportFormat = z.enum(["pdf", "png", "jpg"])
29
+ export type PluginPresentationExportFormat = z.infer<
30
+ typeof PluginPresentationExportFormat
31
+ >
32
+
33
+ /**
34
+ * Target pixel dimensions for a rasterized (`png`/`jpg`) export. Ignored for
35
+ * `pdf`, which stays vector and takes its size from the sheet.
36
+ *
37
+ * | Property | Type | Description |
38
+ * |---|---|---|
39
+ * | `width` | `number` | Output width in pixels |
40
+ * | `height` | `number` | Output height in pixels |
41
+ */
42
+ export const PluginPresentationExportResolution = z.object({
43
+ width: z.number().positive(),
44
+ height: z.number().positive(),
45
+ })
46
+ export type PluginPresentationExportResolution = z.infer<
47
+ typeof PluginPresentationExportResolution
48
+ >
49
+
50
+ /**
51
+ * Arguments for {@linkcode PluginPresentationApi.export}.
52
+ *
53
+ * | Property | Type | Description |
54
+ * |---|---|---|
55
+ * | `format` | `"pdf" \| "png" \| "jpg"` | Output format |
56
+ * | `sheetIds` | `string[] \| undefined` | Sheets to export (all sheets when omitted) |
57
+ * | `combine` | `boolean \| undefined` | PDF only: one multi-page file (default `true`) vs one file per sheet |
58
+ * | `resolution` | {@linkcode PluginPresentationExportResolution}` \| undefined` | Raster target size (`png`/`jpg` only) |
59
+ * | `fileName` | `string \| undefined` | Base file name (without extension) |
60
+ */
61
+ export const PluginPresentationExportArgs = z.object({
62
+ format: PluginPresentationExportFormat,
63
+ sheetIds: z.array(z.string()).optional(),
64
+ combine: z.boolean().optional(),
65
+ resolution: PluginPresentationExportResolution.optional(),
66
+ fileName: z.string().optional(),
67
+ })
68
+ export type PluginPresentationExportArgs = z.infer<
69
+ typeof PluginPresentationExportArgs
70
+ >
71
+
72
+ /**
73
+ * A single exported file.
74
+ *
75
+ * | Property | Type | Description |
76
+ * |---|---|---|
77
+ * | `fileName` | `string` | File name including extension |
78
+ * | `mimeType` | `string` | MIME type (`application/pdf`, `image/png`, `image/jpeg`) |
79
+ * | `dataBase64` | `string` | The file bytes, base64-encoded (no data-URL prefix) |
80
+ */
81
+ export const PluginPresentationExportFile = z.object({
82
+ fileName: z.string(),
83
+ mimeType: z.string(),
84
+ dataBase64: z.string(),
85
+ })
86
+ export type PluginPresentationExportFile = z.infer<
87
+ typeof PluginPresentationExportFile
88
+ >
89
+
90
+ /**
91
+ * Result of {@linkcode PluginPresentationApi.export} — always a `files` array.
92
+ * A combined PDF yields one entry; per-sheet exports yield one entry each, in
93
+ * sheet order.
94
+ *
95
+ * | Property | Type | Description |
96
+ * |---|---|---|
97
+ * | `files` | {@linkcode PluginPresentationExportFile}`[]` | The exported files |
98
+ */
99
+ export const PluginPresentationExportResult = z.object({
100
+ files: z.array(PluginPresentationExportFile),
101
+ })
102
+ export type PluginPresentationExportResult = z.infer<
103
+ typeof PluginPresentationExportResult
104
+ >
@@ -1,8 +1,15 @@
1
+ import { PluginApiReturn } from "../../types"
1
2
  import { PluginPresentationViewsApi } from "./views"
2
3
  import { PluginPresentationAIInspirationApi } from "./aiInspiration"
3
4
  import { PluginPresentationSheetsApi } from "./sheets"
4
5
  import { PluginPresentationDiagramsApi } from "./diagrams"
6
+ import { PluginPresentationAnnotateApi } from "./annotate"
5
7
  import { PluginPresentationImportApi } from "./import"
8
+ import {
9
+ PluginPresentationExportResult,
10
+ type PluginPresentationExportFormat,
11
+ type PluginPresentationExportResolution,
12
+ } from "./export"
6
13
 
7
14
  /**
8
15
  * Presentation APIs — prepare and assemble presentations.
@@ -29,14 +36,50 @@ export abstract class PluginPresentationApi {
29
36
  public abstract sheets: PluginPresentationSheetsApi
30
37
  /** Program/adjacency/site diagrams — place images on sheets. See {@linkcode PluginPresentationDiagramsApi}. */
31
38
  public abstract diagrams: PluginPresentationDiagramsApi
39
+ /** Annotations on Present-mode sheets — text/arrows/notes/geo shapes. See {@linkcode PluginPresentationAnnotateApi}. */
40
+ public abstract annotate: PluginPresentationAnnotateApi
32
41
  /** Import reference images/PDFs onto the Present canvas. See {@linkcode PluginPresentationImportApi}. */
33
42
  public abstract import: PluginPresentationImportApi
34
43
  /**
35
44
  * Present-mode AI Inspiration image/video generation. See
36
- * {@linkcode PluginPresentationAIInspirationApi}. _(authored ahead — optional
37
- * until the host lands; the host implementation today is a stub.)_
45
+ * {@linkcode PluginPresentationAIInspirationApi}.
38
46
  */
39
- public aiInspiration?: PluginPresentationAIInspirationApi
47
+ public abstract aiInspiration: PluginPresentationAIInspirationApi
48
+
49
+ /**
50
+ * Export the presentation's layout sheets to a downloadable file (PDF / PNG /
51
+ * JPG) and return the encoded bytes as base64. Wraps the Present-mode Export
52
+ * dialog pipeline headlessly. Requires Present mode to be open.
53
+ *
54
+ * @param format - Output format: `"pdf"`, `"png"`, or `"jpg"`.
55
+ * @param options - Optional `sheetIds` (all sheets when omitted), `combine`
56
+ * (PDF only — one multi-page file vs one per sheet, default `true`),
57
+ * `resolution` (raster target size for `png`/`jpg`), and `fileName`.
58
+ * @returns A {@linkcode PluginPresentationExportResult} — always a `files`
59
+ * array (one entry for a combined PDF, one per sheet otherwise).
60
+ * @throws If Present mode is not open, a `sheetId` is unknown, or a sheet
61
+ * fails to serialize/encode.
62
+ *
63
+ * @examplePrompt Export the presentation as a PDF
64
+ * @examplePrompt Download all sheets as a single PDF
65
+ * @examplePrompt Export sheet 1 as a PNG
66
+ * @examplePrompt Save the presentation sheets as JPG images
67
+ * @examplePrompt Export these sheets to PDF at high resolution
68
+ *
69
+ * # Example
70
+ * ```ts
71
+ * const { files } = await snaptrude.presentation.export("pdf")
72
+ * ```
73
+ */
74
+ public abstract export(
75
+ format: PluginPresentationExportFormat,
76
+ options?: {
77
+ sheetIds?: string[]
78
+ combine?: boolean
79
+ resolution?: PluginPresentationExportResolution
80
+ fileName?: string
81
+ },
82
+ ): PluginApiReturn<PluginPresentationExportResult>
40
83
 
41
84
  constructor() {}
42
85
  }
@@ -44,5 +87,7 @@ export abstract class PluginPresentationApi {
44
87
  export * from "./views"
45
88
  export * from "./sheets"
46
89
  export * from "./diagrams"
90
+ export * from "./annotate"
47
91
  export * from "./import"
48
92
  export * from "./aiInspiration"
93
+ export * from "./export"