@snaptrude/plugin-core 0.8.0 → 0.9.1

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 (129) hide show
  1. package/CHANGELOG.md +35 -1
  2. package/api-manifest.full.json +1350 -89
  3. package/api-manifest.json +1146 -48
  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 +37 -0
  15. package/dist/api/core/camera/index.d.ts.map +1 -1
  16. package/dist/api/core/geom/create/index.d.ts +318 -1
  17. package/dist/api/core/geom/create/index.d.ts.map +1 -1
  18. package/dist/api/core/index.d.ts +9 -0
  19. package/dist/api/core/index.d.ts.map +1 -1
  20. package/dist/api/core/io/export/index.d.ts +3 -1
  21. package/dist/api/core/io/export/index.d.ts.map +1 -1
  22. package/dist/api/core/io/import/index.d.ts +61 -0
  23. package/dist/api/core/io/import/index.d.ts.map +1 -1
  24. package/dist/api/core/io/terrain/index.d.ts +132 -0
  25. package/dist/api/core/io/terrain/index.d.ts.map +1 -1
  26. package/dist/api/core/mode/index.d.ts +99 -0
  27. package/dist/api/core/mode/index.d.ts.map +1 -0
  28. package/dist/api/core/storeys/index.d.ts +251 -0
  29. package/dist/api/core/storeys/index.d.ts.map +1 -0
  30. package/dist/api/core/tags.d.ts +24 -0
  31. package/dist/api/core/tags.d.ts.map +1 -1
  32. package/dist/api/core/zoom/index.d.ts +4 -0
  33. package/dist/api/core/zoom/index.d.ts.map +1 -1
  34. package/dist/api/design/create/index.d.ts +115 -4
  35. package/dist/api/design/create/index.d.ts.map +1 -1
  36. package/dist/api/design/delete/index.d.ts +3 -0
  37. package/dist/api/design/delete/index.d.ts.map +1 -1
  38. package/dist/api/design/query/geometry/index.d.ts +112 -0
  39. package/dist/api/design/query/geometry/index.d.ts.map +1 -1
  40. package/dist/api/design/query/index.d.ts +4 -0
  41. package/dist/api/design/query/index.d.ts.map +1 -1
  42. package/dist/api/design/query/referenceLines.d.ts +45 -0
  43. package/dist/api/design/query/referenceLines.d.ts.map +1 -0
  44. package/dist/api/design/query/spaces.d.ts +173 -0
  45. package/dist/api/design/query/spaces.d.ts.map +1 -1
  46. package/dist/api/design/transform/index.d.ts +12 -0
  47. package/dist/api/design/transform/index.d.ts.map +1 -1
  48. package/dist/api/design/update/index.d.ts +51 -1
  49. package/dist/api/design/update/index.d.ts.map +1 -1
  50. package/dist/api/entity/buildableEnvelope.d.ts +4 -0
  51. package/dist/api/entity/buildableEnvelope.d.ts.map +1 -1
  52. package/dist/api/entity/referenceLine.d.ts +8 -0
  53. package/dist/api/entity/referenceLine.d.ts.map +1 -1
  54. package/dist/api/entity/story.d.ts +20 -0
  55. package/dist/api/entity/story.d.ts.map +1 -1
  56. package/dist/api/index.d.ts +5 -0
  57. package/dist/api/index.d.ts.map +1 -1
  58. package/dist/api/presentation/annotate.d.ts +23 -4
  59. package/dist/api/presentation/annotate.d.ts.map +1 -1
  60. package/dist/api/presentation/diagrams.d.ts +64 -2
  61. package/dist/api/presentation/diagrams.d.ts.map +1 -1
  62. package/dist/api/presentation/export.d.ts +4 -0
  63. package/dist/api/presentation/export.d.ts.map +1 -1
  64. package/dist/api/presentation/import.d.ts +6 -0
  65. package/dist/api/presentation/import.d.ts.map +1 -1
  66. package/dist/api/presentation/index.d.ts +20 -1
  67. package/dist/api/presentation/index.d.ts.map +1 -1
  68. package/dist/api/presentation/placedViews.d.ts +1139 -0
  69. package/dist/api/presentation/placedViews.d.ts.map +1 -0
  70. package/dist/api/presentation/shapes.d.ts +481 -0
  71. package/dist/api/presentation/shapes.d.ts.map +1 -0
  72. package/dist/api/presentation/sheets.d.ts +42 -0
  73. package/dist/api/presentation/sheets.d.ts.map +1 -1
  74. package/dist/api/presentation/slideshow.d.ts +125 -0
  75. package/dist/api/presentation/slideshow.d.ts.map +1 -0
  76. package/dist/api/presentation/tables.d.ts +81 -0
  77. package/dist/api/presentation/tables.d.ts.map +1 -0
  78. package/dist/api/program/site.d.ts +260 -2
  79. package/dist/api/program/site.d.ts.map +1 -1
  80. package/dist/api/program/spreadsheet.d.ts +260 -28
  81. package/dist/api/program/spreadsheet.d.ts.map +1 -1
  82. package/dist/api/workspace/index.d.ts +505 -0
  83. package/dist/api/workspace/index.d.ts.map +1 -0
  84. package/dist/index.cjs +2904 -1761
  85. package/dist/index.cjs.map +1 -1
  86. package/dist/index.js +2762 -1761
  87. package/dist/index.js.map +1 -1
  88. package/package.json +3 -2
  89. package/scripts/generate-manifest.mjs +45 -0
  90. package/src/api/analysis/daylight.ts +470 -0
  91. package/src/api/analysis/heatmaps.ts +444 -17
  92. package/src/api/analysis/index.ts +15 -0
  93. package/src/api/analysis/solar.ts +237 -0
  94. package/src/api/analysis/weather.ts +179 -0
  95. package/src/api/core/camera/index.ts +39 -0
  96. package/src/api/core/geom/create/index.ts +344 -1
  97. package/src/api/core/index.ts +9 -0
  98. package/src/api/core/io/export/index.ts +3 -1
  99. package/src/api/core/io/import/index.ts +64 -0
  100. package/src/api/core/io/terrain/index.ts +143 -0
  101. package/src/api/core/mode/index.ts +96 -0
  102. package/src/api/core/storeys/index.ts +279 -0
  103. package/src/api/core/tags.ts +27 -0
  104. package/src/api/core/zoom/index.ts +4 -0
  105. package/src/api/design/create/index.ts +138 -1
  106. package/src/api/design/delete/index.ts +3 -0
  107. package/src/api/design/query/geometry/index.ts +125 -3
  108. package/src/api/design/query/index.ts +4 -0
  109. package/src/api/design/query/referenceLines.ts +52 -0
  110. package/src/api/design/query/spaces.ts +143 -0
  111. package/src/api/design/transform/index.ts +12 -0
  112. package/src/api/design/update/index.ts +66 -1
  113. package/src/api/entity/buildableEnvelope.ts +4 -0
  114. package/src/api/entity/referenceLine.ts +8 -0
  115. package/src/api/entity/story.ts +20 -0
  116. package/src/api/index.ts +5 -0
  117. package/src/api/presentation/annotate.ts +27 -2
  118. package/src/api/presentation/diagrams.ts +67 -2
  119. package/src/api/presentation/export.ts +4 -0
  120. package/src/api/presentation/import.ts +6 -0
  121. package/src/api/presentation/index.ts +20 -1
  122. package/src/api/presentation/placedViews.ts +1120 -0
  123. package/src/api/presentation/shapes.ts +274 -0
  124. package/src/api/presentation/sheets.ts +54 -0
  125. package/src/api/presentation/slideshow.ts +134 -0
  126. package/src/api/presentation/tables.ts +84 -0
  127. package/src/api/program/site.ts +205 -2
  128. package/src/api/program/spreadsheet.ts +251 -6
  129. package/src/api/workspace/index.ts +563 -0
@@ -0,0 +1,1120 @@
1
+ import * as z from "zod"
2
+ import { PluginApiReturn } from "../../types"
3
+ import { PluginSheetPosition } from "./sheets"
4
+
5
+ /**
6
+ * Placed views — the view shapes already laid out on the Present canvas.
7
+ *
8
+ * A **placed view** is a saved view that has been dropped onto a layout sheet
9
+ * (or the open canvas) — the live linked view shape
10
+ * {@linkcode PluginPresentationSheetsApi.place} and the Present views panel's
11
+ * drag-drop create. These methods read and edit the **layout** of those
12
+ * shapes: where they sit, how big they are, their rotation, their
13
+ * architectural scale, and their crop. To refresh a placed view's **content** from the current model,
14
+ * use `sheets.updatePlacedView` — content refresh lives on `sheets`,
15
+ * layout lives here.
16
+ *
17
+ * Reads (`list`) return `[]` when Present mode is closed; `get` and every
18
+ * write require Present mode to be open.
19
+ *
20
+ * Accessed via `snaptrude.presentation.placedViews`.
21
+ */
22
+ export abstract class PluginPresentationPlacedViewsApi {
23
+ constructor() {}
24
+
25
+ /**
26
+ * List the placed views in the presentation.
27
+ *
28
+ * Returns every placed view shape on the Present canvas — those nested on a
29
+ * layout sheet (with that sheet's id) and those sitting loose on the canvas
30
+ * (`sheetId: null`). Pass `sheetId` to list only the views placed on that
31
+ * sheet.
32
+ *
33
+ * @param sheetId - Optional sheet id to filter by.
34
+ * @returns A {@linkcode PluginPresentationPlacedViewsListResult} with a
35
+ * `placedViews` array (empty when Present mode is closed or nothing is
36
+ * placed).
37
+ * @throws If `sheetId` is given but is not a sheet (with Present mode open).
38
+ *
39
+ * @examplePrompt Which views are placed on this sheet?
40
+ * @examplePrompt List all the placed views in the presentation
41
+ * @examplePrompt What's laid out on sheet 2?
42
+ * @examplePrompt Show me every view on the Present canvas
43
+ *
44
+ * # Example
45
+ * ```ts
46
+ * const { placedViews } = await snaptrude.presentation.placedViews.list("sheet_1")
47
+ * ```
48
+ */
49
+ public abstract list(
50
+ sheetId?: string,
51
+ ): PluginApiReturn<PluginPresentationPlacedViewsListResult>
52
+
53
+ /**
54
+ * Get a single placed view by its shape id.
55
+ *
56
+ * `shapeId` is the id `sheets.place` returned (also reported by `list`).
57
+ *
58
+ * @param shapeId - The id of the placed view shape to read.
59
+ * @returns The matching {@linkcode PluginPlacedView}.
60
+ * @throws If Present mode is not open, or `shapeId` is unknown or is not a
61
+ * placed view.
62
+ *
63
+ * @examplePrompt Get the placed view I just dropped on the sheet
64
+ * @examplePrompt Read the position and scale of this placed view
65
+ * @examplePrompt What's the crop on shape_123?
66
+ *
67
+ * # Example
68
+ * ```ts
69
+ * const placed = await snaptrude.presentation.placedViews.get(shapeId)
70
+ * console.log(placed.position, placed.scale)
71
+ * ```
72
+ */
73
+ public abstract get(shapeId: string): PluginApiReturn<PluginPlacedView>
74
+
75
+ /**
76
+ * Move a placed view.
77
+ *
78
+ * Repositions the placed view on its sheet — `position` is the new top-left
79
+ * in sheet coordinates (page coordinates when the view is not on a sheet).
80
+ * Pass `options.sheetId` to move it onto another sheet: the view is
81
+ * reparented to that sheet and then positioned at `position` in the new
82
+ * sheet's coordinates. A grouped placed view (e.g. a sustainability 3D view
83
+ * with its legend) moves as one unit. Requires Present mode to be open.
84
+ *
85
+ * @param shapeId - The placed view shape to move.
86
+ * @param position - New top-left position (sheet-local; page coordinates
87
+ * when off-sheet).
88
+ * @param options - Optional `sheetId` — move the view onto that sheet.
89
+ * @returns The updated {@linkcode PluginPlacedView}.
90
+ * @throws If Present mode is not open, `shapeId` is unknown or is not a
91
+ * placed view, or `options.sheetId` is given but is not a sheet.
92
+ *
93
+ * @examplePrompt Move the site plan view to the top-left of sheet 2
94
+ * @examplePrompt Reposition this placed view to 100, 200
95
+ * @examplePrompt Move the hero perspective onto the cover sheet
96
+ *
97
+ * # Example
98
+ * ```ts
99
+ * await snaptrude.presentation.placedViews.move(shapeId, { x: 50, y: 50 }, {
100
+ * sheetId: "sheet_2",
101
+ * })
102
+ * ```
103
+ */
104
+ public abstract move(
105
+ shapeId: string,
106
+ position: PluginSheetPosition,
107
+ options?: { sheetId?: string },
108
+ ): PluginApiReturn<PluginPlacedView>
109
+
110
+ /**
111
+ * Resize a placed view by a uniform factor.
112
+ *
113
+ * Scales the placed view about its top-left corner — the same resize as
114
+ * dragging a corner handle, aspect ratio held. Works for 2D and 3D views;
115
+ * labels and grouped legends resize with it. For a 2D view the **printed
116
+ * architectural scale changes proportionally** (doubling the size of a
117
+ * 1:100 plan makes it a 1:50 plan) — use
118
+ * {@linkcode PluginPresentationPlacedViewsApi.setScale} to land on an exact
119
+ * standard scale instead. Requires Present mode to be open.
120
+ *
121
+ * @param shapeId - The placed view shape to resize.
122
+ * @param factor - Uniform scale factor, between `0.01` and `100`
123
+ * (`2` doubles the size, `0.5` halves it).
124
+ * @returns The updated {@linkcode PluginPlacedView}.
125
+ * @throws If Present mode is not open, `shapeId` is unknown or is not a
126
+ * placed view, or `factor` is not a finite number between 0.01 and 100.
127
+ *
128
+ * @examplePrompt Make this placed view twice as big
129
+ * @examplePrompt Shrink the placed 3D view to half its size
130
+ * @examplePrompt Scale the placed plan up by 50%
131
+ *
132
+ * # Example
133
+ * ```ts
134
+ * await snaptrude.presentation.placedViews.scale(shapeId, 2)
135
+ * ```
136
+ */
137
+ public abstract scale(
138
+ shapeId: string,
139
+ factor: number,
140
+ ): PluginApiReturn<PluginPlacedView>
141
+
142
+ /**
143
+ * Set a placed view's architectural scale.
144
+ *
145
+ * Applies a standard architectural scale — the same write the placed view's
146
+ * Scale dropdown performs. The view (and its labels) is resized about its
147
+ * top-left corner so it prints at the given scale. `scale` must be one of
148
+ * the standard values for the project's unit system (metric `10, 20, 50,
149
+ * 100, 150, 200, 250, 500, 1000`; imperial e.g. `48` for 1/4″ = 1′, `96`
150
+ * for 1/8″ = 1′, `120` for 1″ = 10′) — the same validation as
151
+ * `sheets.place`. 3D views have no architectural scale — calling this on
152
+ * one throws. Requires Present mode to be open.
153
+ *
154
+ * @param shapeId - The placed view shape to set the scale of.
155
+ * @param scale - A standard scale value for the project's unit system.
156
+ * @returns The updated {@linkcode PluginPlacedView}.
157
+ * @throws If Present mode is not open, `shapeId` is unknown or is not a
158
+ * placed view, `scale` is not a standard value for the project's unit
159
+ * system, or the placed view is a 3D view.
160
+ *
161
+ * @examplePrompt Set the plan to 1:100
162
+ * @examplePrompt Change the placed floor plan to 1:50 scale
163
+ * @examplePrompt Make this view print at quarter-inch scale
164
+ *
165
+ * # Example
166
+ * ```ts
167
+ * await snaptrude.presentation.placedViews.setScale(shapeId, 100) // 1:100
168
+ * ```
169
+ */
170
+ public abstract setScale(
171
+ shapeId: string,
172
+ scale: number,
173
+ ): PluginApiReturn<PluginPlacedView>
174
+
175
+ /**
176
+ * Crop a placed view, or clear its crop.
177
+ *
178
+ * `crop` selects the visible window as **fractions (0–1) of the uncropped
179
+ * view** — `topLeft` must be strictly less than `bottomRight` on both axes.
180
+ * The visible region stays anchored on the page (the same behavior as the
181
+ * interactive crop), labels that fall outside the crop are hidden, and the
182
+ * view's architectural scale is untouched. Pass `null` to clear the crop
183
+ * and restore the full view in its uncropped footprint (the interactive
184
+ * double-click-edge reset). The crop **survives a content refresh**
185
+ * (`sheets.updatePlacedView` recomputes it against the refreshed content
186
+ * and only clears it when the refreshed view no longer overlaps the cropped
187
+ * region). Requires Present mode to be open.
188
+ *
189
+ * @param shapeId - The placed view shape to crop.
190
+ * @param crop - The crop window ({@linkcode PluginPlacedViewCrop},
191
+ * fractions of the uncropped view), or `null` to clear.
192
+ * @returns The updated {@linkcode PluginPlacedView}.
193
+ * @throws If Present mode is not open, `shapeId` is unknown or is not a
194
+ * placed view, or `crop` is not a valid 0–1 rectangle with
195
+ * `topLeft < bottomRight` on both axes.
196
+ *
197
+ * @examplePrompt Crop the placed view to its left half
198
+ * @examplePrompt Crop this view to the top-right quarter
199
+ * @examplePrompt Remove the crop from the placed plan
200
+ *
201
+ * # Example
202
+ * ```ts
203
+ * // keep the left half of the view
204
+ * await snaptrude.presentation.placedViews.setCrop(shapeId, {
205
+ * topLeft: { x: 0, y: 0 },
206
+ * bottomRight: { x: 0.5, y: 1 },
207
+ * })
208
+ * await snaptrude.presentation.placedViews.setCrop(shapeId, null) // clear
209
+ * ```
210
+ */
211
+ public abstract setCrop(
212
+ shapeId: string,
213
+ crop: PluginPlacedViewCrop | null,
214
+ ): PluginApiReturn<PluginPlacedView>
215
+
216
+ /**
217
+ * Set a placed view's rotation.
218
+ *
219
+ * `rotation` is the **absolute** angle in radians (tldraw convention) — the
220
+ * value the record's `rotation` field reads back. Values are canonicalized
221
+ * into `[0, 2π)`, so pass values in that range for an exact round-trip
222
+ * (`setRotation(-0.1)` reads back as `2π − 0.1`). The view rotates about
223
+ * its bounds center (the same pivot as the UI rotation handle). One undo
224
+ * step. Joins the absolute-setter family
225
+ * `setScale`/`setCrop`/`setOpacity`/`setMask`.
226
+ *
227
+ * **3D placed views only.** 2D and site-plan views cannot rotate — the
228
+ * canvas hides their rotate handle and reverts any rotation applied to
229
+ * them — so calling this on one is refused with a typed
230
+ * `PRECONDITION_FAILED` instead of silently no-opping. Requires Present
231
+ * mode to be open.
232
+ *
233
+ * @param shapeId - The placed view shape to rotate.
234
+ * @param rotation - Absolute rotation in radians.
235
+ * @returns The updated {@linkcode PluginPlacedView}.
236
+ * @throws If Present mode is not open, `shapeId` is unknown or is not a
237
+ * placed view, `rotation` is not a finite number, or the placed view is
238
+ * a 2D/site-plan view (`PRECONDITION_FAILED` — only 3D views rotate).
239
+ *
240
+ * @examplePrompt Rotate the placed plan 90 degrees
241
+ * @examplePrompt Set this view's rotation to 45 degrees
242
+ * @examplePrompt Straighten the placed view back to zero rotation
243
+ *
244
+ * # Example
245
+ * ```ts
246
+ * await snaptrude.presentation.placedViews.setRotation(shapeId, Math.PI / 2)
247
+ * ```
248
+ */
249
+ public abstract setRotation(
250
+ shapeId: string,
251
+ rotation: number,
252
+ ): PluginApiReturn<PluginPlacedView>
253
+
254
+ // ── Present-mode styling ──────────────────────────────────────────────────
255
+
256
+ /**
257
+ * Read a placed view's (or sheet's) per-category presentation styles.
258
+ *
259
+ * Returns one entry per style category (Site, Topography, Space, Department,
260
+ * Envelope, Facade/Mass, Dimension, Reference Line, Adjacency Line,
261
+ * Landscape elements — sheets/auto-diagrams use their 3-category subset)
262
+ * with the **fully-resolved** setting values (defaults merged with this
263
+ * shape's overrides), which setting ids the category supports, whether the
264
+ * category is currently disabled (not visible in the view), and — where the
265
+ * category has a Text tab — its label font styles. Styles are stored **per
266
+ * placed shape instance**: the same saved view placed twice can read
267
+ * differently. Requires Present mode to be open.
268
+ *
269
+ * @param shapeId - The placed view (or sheet) shape to read.
270
+ * @throws If Present mode is not open or `shapeId` is not a styleable shape.
271
+ *
272
+ * @examplePrompt What line weights is this placed plan using?
273
+ * @examplePrompt Read the styling of the placed view
274
+ * @examplePrompt Which categories can I restyle on this sheet?
275
+ *
276
+ * # Example
277
+ * ```ts
278
+ * const styles = await snaptrude.presentation.placedViews.getStyles(shapeId)
279
+ * const space = styles.categories.find((c) => c.category === "Space")
280
+ * console.log(space?.settings.cutWidth, space?.settings.lineStyle)
281
+ * ```
282
+ */
283
+ public abstract getStyles(
284
+ shapeId: string,
285
+ ): PluginApiReturn<PluginPlacedViewStylesResult>
286
+
287
+ /**
288
+ * Update one style category on a placed view (or sheet) — the same writes
289
+ * the Present sidebar's per-category configure panel performs.
290
+ *
291
+ * The patch may set any subset of the category's settings: line style (7
292
+ * dash patterns), line color, dash-length multiplier, line weights in mm
293
+ * (`cutWidth` vs `projectionWidth` — Revit-style cut/projection distinction;
294
+ * `lineWidth` where the category has a single weight; `treeLineWidth` /
295
+ * `parkingLineWidth` for Landscape), fill `colorMode` (`department`,
296
+ * `texture`, `monochrome`, or `tag:<tagCategoryId>`), per-category fill
297
+ * `opacity` (0–100), category `hide` (cascades to that category's labels),
298
+ * the shape restyle `viewStyle` (`NONE` block / `FILLET` rounded with
299
+ * `radius` / `BUBBLE`) with `radius` and `inset`, and Topography's
300
+ * map/building sub-controls. Settings a category does not support are
301
+ * rejected. Writes are validated, undoable (one history stop per call), and
302
+ * re-render immediately; on an auto-diagram sheet the write fans out to
303
+ * every sheet in its diagram set. Requires Present mode to be open.
304
+ *
305
+ * @param shapeId - The placed view (or sheet) shape to restyle.
306
+ * @param category - The style category to update.
307
+ * @param patch - The settings to change (at least one).
308
+ * @returns The category's resolved styles after the update.
309
+ * @throws If Present mode is not open, `shapeId` is not a styleable shape,
310
+ * the category does not apply to this shape, or a patched setting is not
311
+ * supported by the category or fails validation.
312
+ *
313
+ * @examplePrompt Set the Space cut line weight to 0.5 mm
314
+ * @examplePrompt Make the Department lines dashed
315
+ * @examplePrompt Color the plan by department
316
+ * @examplePrompt Hide the dimension lines on this view
317
+ * @examplePrompt Round the space corners with a 2 ft radius
318
+ *
319
+ * # Example
320
+ * ```ts
321
+ * await snaptrude.presentation.placedViews.updateStyles(shapeId, "Space", {
322
+ * cutWidth: 0.5,
323
+ * projectionWidth: 0.18,
324
+ * lineStyle: "dashed",
325
+ * colorMode: "department",
326
+ * })
327
+ * ```
328
+ */
329
+ public abstract updateStyles(
330
+ shapeId: string,
331
+ category: PluginViewSettingCategory,
332
+ patch: PluginPlacedViewStylePatch,
333
+ ): PluginApiReturn<PluginPlacedViewCategoryStyles>
334
+
335
+ /**
336
+ * Reset a placed view's styling to defaults — the sidebar's Reset button:
337
+ * clears every per-category override and view-style restyle, resets font
338
+ * styles, and un-hides labels hidden by styling. Undoable. Requires Present
339
+ * mode to be open.
340
+ *
341
+ * @param shapeId - The placed view (or sheet) shape to reset.
342
+ * @throws If Present mode is not open or `shapeId` is not a styleable shape.
343
+ *
344
+ * @examplePrompt Reset this view's styling
345
+ * @examplePrompt Clear all the style overrides on the placed plan
346
+ * @examplePrompt Put the sheet styles back to default
347
+ */
348
+ public abstract resetStyles(shapeId: string): PluginApiReturn<void>
349
+
350
+ /**
351
+ * Update a category's label typography on a placed view (or sheet) — the
352
+ * configure panel's Text tab.
353
+ *
354
+ * Each category carries font styles per label type — `objectLabels` (the
355
+ * name), `department`, and `areas` — with `fontFamily` (system families or
356
+ * any Google Font; the font is loaded automatically and the weight is
357
+ * coerced to an available variant), `fontWeight` (numeric string, e.g.
358
+ * `"700"`), `fontStyle` (`normal`/`italic`), and `fontSize` in px.
359
+ * `visibleTypes` controls which label types render (an empty array hides
360
+ * all). Not every category has a Text tab — Topography, Facade/Mass,
361
+ * Reference Line and Adjacency Line reject font writes. Undoable. Requires
362
+ * Present mode to be open.
363
+ *
364
+ * @param shapeId - The placed view (or sheet) shape.
365
+ * @param category - The style category whose labels to restyle.
366
+ * @param patch - The font styles to change (at least one field).
367
+ * @throws If Present mode is not open, `shapeId` is not a styleable shape,
368
+ * or the category has no Text tab.
369
+ *
370
+ * @examplePrompt Set the space labels to Roboto 24px bold
371
+ * @examplePrompt Hide the area values on this plan
372
+ * @examplePrompt Make the department labels italic
373
+ *
374
+ * # Example
375
+ * ```ts
376
+ * await snaptrude.presentation.placedViews.updateFontStyles(shapeId, "Space", {
377
+ * objectLabels: { fontFamily: "Roboto", fontWeight: "700", fontSize: 24 },
378
+ * visibleTypes: ["objectLabels", "areas"],
379
+ * })
380
+ * ```
381
+ */
382
+ public abstract updateFontStyles(
383
+ shapeId: string,
384
+ category: PluginViewSettingCategory,
385
+ patch: PluginPlacedViewFontStylesPatch,
386
+ ): PluginApiReturn<void>
387
+
388
+ // ── Labels ────────────────────────────────────────────────────────────────
389
+
390
+ /**
391
+ * List a placed view's labels — the text children generated from the view's
392
+ * content (space names, departments, areas, dimension texts). Each label is
393
+ * individually addressable: it can be moved and hidden. Returns `[]` when
394
+ * the view has no labels. Requires Present mode to be open.
395
+ *
396
+ * @param shapeId - The placed view shape whose labels to list.
397
+ * @throws If Present mode is not open or `shapeId` is not a placed view.
398
+ *
399
+ * @examplePrompt List the labels on this placed plan
400
+ * @examplePrompt Where are the space labels on this view?
401
+ * @examplePrompt Show every label with its position
402
+ *
403
+ * # Example
404
+ * ```ts
405
+ * const { labels } = await snaptrude.presentation.placedViews.listLabels(shapeId)
406
+ * for (const l of labels) console.log(l.text, l.position, l.hidden)
407
+ * ```
408
+ */
409
+ public abstract listLabels(
410
+ shapeId: string,
411
+ ): PluginApiReturn<PluginPlacedViewLabelsResult>
412
+
413
+ /**
414
+ * Move a label to a new position (coordinates relative to its placed view,
415
+ * the same space `listLabels` reports). The manual position survives style
416
+ * changes. Undoable. Requires Present mode to be open.
417
+ *
418
+ * @param labelId - The label to move (from `listLabels`).
419
+ * @param position - New position, parent-view-relative.
420
+ * @throws If Present mode is not open or `labelId` is not a view label.
421
+ *
422
+ * @examplePrompt Move the kitchen label out of the hatched area
423
+ * @examplePrompt Nudge this label 20 units right
424
+ * @examplePrompt Reposition the area text
425
+ */
426
+ public abstract moveLabel(
427
+ labelId: string,
428
+ position: PluginSheetPosition,
429
+ ): PluginApiReturn<PluginPlacedViewLabel>
430
+
431
+ /**
432
+ * Hide or show a single label (independent of the category-level label
433
+ * visibility). Undoable. Requires Present mode to be open.
434
+ *
435
+ * @param labelId - The label to hide/show (from `listLabels`).
436
+ * @param hidden - `true` to hide, `false` to show.
437
+ * @throws If Present mode is not open or `labelId` is not a view label.
438
+ *
439
+ * @examplePrompt Hide the corridor label
440
+ * @examplePrompt Show that label again
441
+ */
442
+ public abstract setLabelHidden(
443
+ labelId: string,
444
+ hidden: boolean,
445
+ ): PluginApiReturn<PluginPlacedViewLabel>
446
+
447
+ // ── Canvas shapes (generated outputs, images, annotations) ────────────────
448
+
449
+ /**
450
+ * List the top-level shapes on the Present canvas — not just placed views:
451
+ * AI-generated outputs, placed diagram images, plugin-created shapes, and
452
+ * annotations, each with an `origin` classification. Sheets (frames) are
453
+ * not listed — use `sheets.list`. Pass `sheetId` to list only shapes on
454
+ * that sheet. Returns `[]` when Present mode is closed.
455
+ *
456
+ * @param sheetId - Optional sheet id to filter by.
457
+ *
458
+ * @examplePrompt List everything on the Present canvas
459
+ * @examplePrompt What AI outputs are on this sheet?
460
+ * @examplePrompt Show all the shapes with their positions
461
+ *
462
+ * # Example
463
+ * ```ts
464
+ * const { shapes } = await snaptrude.presentation.placedViews.listShapes()
465
+ * const aiOutputs = shapes.filter((s) => s.origin === "aiOutput")
466
+ * ```
467
+ */
468
+ public abstract listShapes(
469
+ sheetId?: string,
470
+ ): PluginApiReturn<PluginCanvasShapesListResult>
471
+
472
+ /**
473
+ * Get one Present-canvas shape by id — works for any top-level shape
474
+ * (placed view, AI output, diagram image, plugin shape, annotation), unlike
475
+ * `get` which requires a placed view. Requires Present mode to be open.
476
+ *
477
+ * @param shapeId - The shape to read.
478
+ * @throws If Present mode is not open or `shapeId` is unknown or a sheet.
479
+ *
480
+ * @examplePrompt Inspect the AI render I just generated
481
+ * @examplePrompt Get the bounds of that diagram image
482
+ */
483
+ public abstract getShape(shapeId: string): PluginApiReturn<PluginCanvasShape>
484
+
485
+ /**
486
+ * Move any Present-canvas shape (AI outputs, diagram images, plugin shapes,
487
+ * annotations — placed views too). Same coordinate semantics as `move`:
488
+ * sheet-local when on a sheet, page coordinates otherwise; pass
489
+ * `options.sheetId` to reparent onto a sheet. Undoable. Requires Present
490
+ * mode to be open.
491
+ *
492
+ * @param shapeId - The shape to move.
493
+ * @param position - New top-left position.
494
+ * @param options - Optional `sheetId` to move the shape onto that sheet.
495
+ * @throws If Present mode is not open, `shapeId` is unknown or a sheet, or
496
+ * `options.sheetId` is not a sheet.
497
+ *
498
+ * @examplePrompt Move the AI render to the top of the sheet
499
+ * @examplePrompt Put the diagram image at 100, 200
500
+ */
501
+ public abstract moveShape(
502
+ shapeId: string,
503
+ position: PluginSheetPosition,
504
+ options?: { sheetId?: string },
505
+ ): PluginApiReturn<PluginCanvasShape>
506
+
507
+ /**
508
+ * Resize any Present-canvas shape by a uniform factor about its top-left
509
+ * corner (aspect ratio held) — the generic counterpart of `scale`, which
510
+ * requires a placed view. Undoable. Requires Present mode to be open.
511
+ *
512
+ * @param shapeId - The shape to resize.
513
+ * @param factor - Uniform scale factor, between `0.01` and `100`.
514
+ * @throws If Present mode is not open, `shapeId` is unknown or a sheet, or
515
+ * `factor` is out of range.
516
+ *
517
+ * @examplePrompt Make the AI output half its size
518
+ * @examplePrompt Double the size of that image
519
+ */
520
+ public abstract resizeShape(
521
+ shapeId: string,
522
+ factor: number,
523
+ ): PluginApiReturn<PluginCanvasShape>
524
+
525
+ /**
526
+ * Rotate any Present-canvas shape (AI outputs, diagram images, plugin
527
+ * shapes, annotations — placed views too) — the generic counterpart of
528
+ * `setRotation`, same target rules as `moveShape`. Same semantics:
529
+ * **absolute** angle in radians (tldraw convention) about the shape's
530
+ * bounds center, canonicalized into `[0, 2π)` (pass values in that range
531
+ * for an exact round-trip via `getShape`), one undo step. A placed view
532
+ * passed here falls under the same 3D-only rule as `setRotation`: 2D and
533
+ * site-plan views cannot rotate and are refused with a typed
534
+ * `PRECONDITION_FAILED`. Requires Present mode to be open.
535
+ *
536
+ * @param shapeId - The shape to rotate.
537
+ * @param rotation - Absolute rotation in radians.
538
+ * @throws If Present mode is not open, `shapeId` is unknown or a sheet,
539
+ * `rotation` is not a finite number, or the target is a 2D/site-plan
540
+ * placed view (`PRECONDITION_FAILED` — only 3D views rotate).
541
+ *
542
+ * @examplePrompt Rotate the AI render 15 degrees
543
+ * @examplePrompt Turn that image sideways
544
+ * @examplePrompt Reset the diagram image's rotation
545
+ */
546
+ public abstract rotateShape(
547
+ shapeId: string,
548
+ rotation: number,
549
+ ): PluginApiReturn<PluginCanvasShape>
550
+
551
+ /**
552
+ * Delete Present-canvas shapes. One undoable step for the whole batch, and
553
+ * the batch is atomic — if any id is rejected, nothing is deleted.
554
+ *
555
+ * Deletable: placed views, AI-generated outputs, placed diagram images, and
556
+ * shapes created by plugins. **Not deletable here:** sheets (use
557
+ * `sheets.delete`) and user-drawn annotations (draw, geo, arrow, note,
558
+ * text, highlight, line shapes without a plugin ownership stamp) — those
559
+ * reject with a validation error. Requires Present mode to be open.
560
+ *
561
+ * @param shapeIds - The shapes to delete (at least one).
562
+ * @returns The deleted shape ids.
563
+ * @throws If Present mode is not open, or any id is unknown, a sheet, or a
564
+ * protected user annotation.
565
+ *
566
+ * @examplePrompt Delete the old AI renders from the sheet
567
+ * @examplePrompt Remove that placed view
568
+ * @examplePrompt Clear the diagram images I placed
569
+ *
570
+ * # Example
571
+ * ```ts
572
+ * const { deleted } = await snaptrude.presentation.placedViews.deleteShapes([
573
+ * out1.shapeId,
574
+ * out2.shapeId,
575
+ * ])
576
+ * ```
577
+ */
578
+ public abstract deleteShapes(
579
+ shapeIds: string[],
580
+ ): PluginApiReturn<PluginCanvasShapesDeleteResult>
581
+
582
+ /**
583
+ * Set a Present-canvas shape's opacity (`0` transparent .. `1` opaque) —
584
+ * the sidebar's whole-shape opacity slider (distinct from the per-category
585
+ * fill opacity in `updateStyles`). Works for any top-level shape. Undoable.
586
+ * Requires Present mode to be open.
587
+ *
588
+ * @param shapeId - The shape to change.
589
+ * @param opacity - Target opacity, `0`..`1`.
590
+ * @throws If Present mode is not open or `shapeId` is unknown or a sheet.
591
+ *
592
+ * @examplePrompt Fade the placed view to 50%
593
+ * @examplePrompt Make the AI render semi-transparent
594
+ */
595
+ public abstract setOpacity(
596
+ shapeId: string,
597
+ opacity: number,
598
+ ): PluginApiReturn<void>
599
+
600
+ /**
601
+ * Toggle "mask context buildings" on a placed view — mutes the inactive
602
+ * proposal buildings in the view (the sidebar checkbox). Views only.
603
+ * Undoable. Requires Present mode to be open.
604
+ *
605
+ * @param shapeId - The placed view shape.
606
+ * @param enabled - `true` to mask context buildings.
607
+ * @throws If Present mode is not open or `shapeId` is not a placed view.
608
+ *
609
+ * @examplePrompt Mask the context buildings in this view
610
+ * @examplePrompt Show the neighboring proposals again in the placed view
611
+ */
612
+ public abstract setMask(
613
+ shapeId: string,
614
+ enabled: boolean,
615
+ ): PluginApiReturn<void>
616
+ }
617
+
618
+ /** A point in crop space — fractions (0–1) of the uncropped view. */
619
+ const PluginPlacedViewCropPoint = z.object({
620
+ x: z.number().min(0).max(1),
621
+ y: z.number().min(0).max(1),
622
+ })
623
+
624
+ /**
625
+ * A crop window on a placed view, as fractions (0–1) of the **uncropped**
626
+ * view. `topLeft` must be strictly less than `bottomRight` on both axes.
627
+ *
628
+ * | Property | Type | Description |
629
+ * |---|---|---|
630
+ * | `topLeft` | `{ x: number, y: number }` | Top-left of the visible window (fractions 0–1) |
631
+ * | `bottomRight` | `{ x: number, y: number }` | Bottom-right of the visible window (fractions 0–1) |
632
+ */
633
+ export const PluginPlacedViewCrop = z
634
+ .object({
635
+ topLeft: PluginPlacedViewCropPoint,
636
+ bottomRight: PluginPlacedViewCropPoint,
637
+ })
638
+ .refine(
639
+ (c) => c.topLeft.x < c.bottomRight.x && c.topLeft.y < c.bottomRight.y,
640
+ { message: "topLeft must be strictly less than bottomRight on both axes" },
641
+ )
642
+ export type PluginPlacedViewCrop = z.infer<typeof PluginPlacedViewCrop>
643
+
644
+ /**
645
+ * A view placed on the Present canvas.
646
+ *
647
+ * | Property | Type | Description |
648
+ * |---|---|---|
649
+ * | `shapeId` | `string` | Id of the placed view shape (the id `sheets.place` returns) |
650
+ * | `sheetId` | `string \| null` | The sheet it sits on (`null` when placed loose on the canvas) |
651
+ * | `title` | `string` | The saved view's title |
652
+ * | `viewId` | `string` | Id of the saved view it was placed from |
653
+ * | `position` | {@linkcode PluginSheetPosition} | Top-left position — sheet-local when on a sheet, page coordinates otherwise |
654
+ * | `size` | `{ width: number, height: number }` | Displayed size on the canvas |
655
+ * | `scale` | `number \| null` | Architectural scale (e.g. `100` = 1:100); `null` for 3D views |
656
+ * | `is3d` | `boolean` | Whether it is a 3D view (no architectural scale) |
657
+ * | `rotation` | `number` | Rotation in radians, `[0, 2π)` (nonzero only for 3D views — 2D views cannot rotate; set with `setRotation`) |
658
+ * | `crop` | {@linkcode PluginPlacedViewCrop}` \| null` | Crop window (`null` when uncropped) |
659
+ * | `isUnlinked` | `boolean` | Whether the source proposal was removed (an unlinked view no longer refreshes) |
660
+ */
661
+ export const PluginPlacedView = z.object({
662
+ shapeId: z.string(),
663
+ sheetId: z.string().nullable(),
664
+ title: z.string(),
665
+ viewId: z.string(),
666
+ position: PluginSheetPosition,
667
+ size: z.object({ width: z.number(), height: z.number() }),
668
+ scale: z.number().nullable(),
669
+ is3d: z.boolean(),
670
+ rotation: z.number(),
671
+ crop: PluginPlacedViewCrop.nullable(),
672
+ isUnlinked: z.boolean(),
673
+ })
674
+ export type PluginPlacedView = z.infer<typeof PluginPlacedView>
675
+
676
+ /** Arguments for {@linkcode PluginPresentationPlacedViewsApi.list}. */
677
+ export const PluginPresentationPlacedViewsListArgs = z.object({
678
+ sheetId: z.string().optional(),
679
+ })
680
+ export type PluginPresentationPlacedViewsListArgs = z.infer<
681
+ typeof PluginPresentationPlacedViewsListArgs
682
+ >
683
+
684
+ /** Result of {@linkcode PluginPresentationPlacedViewsApi.list}. */
685
+ export const PluginPresentationPlacedViewsListResult = z.object({
686
+ placedViews: z.array(PluginPlacedView),
687
+ })
688
+ export type PluginPresentationPlacedViewsListResult = z.infer<
689
+ typeof PluginPresentationPlacedViewsListResult
690
+ >
691
+
692
+ /** Arguments for {@linkcode PluginPresentationPlacedViewsApi.get}. */
693
+ export const PluginPresentationPlacedViewsGetArgs = z.object({
694
+ shapeId: z.string(),
695
+ })
696
+ export type PluginPresentationPlacedViewsGetArgs = z.infer<
697
+ typeof PluginPresentationPlacedViewsGetArgs
698
+ >
699
+
700
+ /**
701
+ * Arguments for {@linkcode PluginPresentationPlacedViewsApi.move}.
702
+ *
703
+ * | Property | Type | Description |
704
+ * |---|---|---|
705
+ * | `shapeId` | `string` | The placed view shape to move |
706
+ * | `position` | {@linkcode PluginSheetPosition} | New top-left position (sheet-local; page coordinates when off-sheet) |
707
+ * | `sheetId` | `string`? | Move the view onto this sheet |
708
+ */
709
+ export const PluginPresentationPlacedViewsMoveArgs = z.object({
710
+ shapeId: z.string(),
711
+ position: PluginSheetPosition,
712
+ sheetId: z.string().optional(),
713
+ })
714
+ export type PluginPresentationPlacedViewsMoveArgs = z.infer<
715
+ typeof PluginPresentationPlacedViewsMoveArgs
716
+ >
717
+
718
+ /**
719
+ * Arguments for {@linkcode PluginPresentationPlacedViewsApi.scale}.
720
+ *
721
+ * | Property | Type | Description |
722
+ * |---|---|---|
723
+ * | `shapeId` | `string` | The placed view shape to resize |
724
+ * | `factor` | `number` | Uniform scale factor (0.01–100) |
725
+ */
726
+ export const PluginPresentationPlacedViewsScaleArgs = z.object({
727
+ shapeId: z.string(),
728
+ factor: z.number().finite().min(0.01).max(100),
729
+ })
730
+ export type PluginPresentationPlacedViewsScaleArgs = z.infer<
731
+ typeof PluginPresentationPlacedViewsScaleArgs
732
+ >
733
+
734
+ /**
735
+ * Arguments for {@linkcode PluginPresentationPlacedViewsApi.setScale}.
736
+ *
737
+ * | Property | Type | Description |
738
+ * |---|---|---|
739
+ * | `shapeId` | `string` | The placed view shape to set the scale of |
740
+ * | `scale` | `number` | A standard scale value for the project's unit system |
741
+ */
742
+ export const PluginPresentationPlacedViewsSetScaleArgs = z.object({
743
+ shapeId: z.string(),
744
+ scale: z.number().positive(),
745
+ })
746
+ export type PluginPresentationPlacedViewsSetScaleArgs = z.infer<
747
+ typeof PluginPresentationPlacedViewsSetScaleArgs
748
+ >
749
+
750
+ /**
751
+ * Arguments for {@linkcode PluginPresentationPlacedViewsApi.setCrop}.
752
+ *
753
+ * | Property | Type | Description |
754
+ * |---|---|---|
755
+ * | `shapeId` | `string` | The placed view shape to crop |
756
+ * | `crop` | {@linkcode PluginPlacedViewCrop}` \| null` | The crop window, or `null` to clear |
757
+ */
758
+ export const PluginPresentationPlacedViewsSetCropArgs = z.object({
759
+ shapeId: z.string(),
760
+ crop: PluginPlacedViewCrop.nullable(),
761
+ })
762
+ export type PluginPresentationPlacedViewsSetCropArgs = z.infer<
763
+ typeof PluginPresentationPlacedViewsSetCropArgs
764
+ >
765
+
766
+ /**
767
+ * Arguments for {@linkcode PluginPresentationPlacedViewsApi.setRotation}.
768
+ *
769
+ * | Property | Type | Description |
770
+ * |---|---|---|
771
+ * | `shapeId` | `string` | The placed view shape to rotate |
772
+ * | `rotation` | `number` | Absolute rotation in radians (tldraw convention) |
773
+ */
774
+ export const PluginPresentationPlacedViewsSetRotationArgs = z.object({
775
+ shapeId: z.string().min(1),
776
+ rotation: z.number().finite(),
777
+ })
778
+ export type PluginPresentationPlacedViewsSetRotationArgs = z.infer<
779
+ typeof PluginPresentationPlacedViewsSetRotationArgs
780
+ >
781
+
782
+ // ── Styling ─────────────────────────────────────────────────────────────────
783
+
784
+ /**
785
+ * A Present-mode style category — mirrors the host's view-settings CATEGORIES
786
+ * exactly. Sheets/auto-diagrams use the subset Space / Department /
787
+ * Adjacency Line.
788
+ */
789
+ export const PluginViewSettingCategory = z.enum([
790
+ "Site",
791
+ "Topography",
792
+ "Space",
793
+ "Department",
794
+ "Envelope",
795
+ "Facade/Mass",
796
+ "Dimension",
797
+ "Reference Line",
798
+ "Adjacency Line",
799
+ "Landscape elements",
800
+ ])
801
+ export type PluginViewSettingCategory = z.infer<typeof PluginViewSettingCategory>
802
+
803
+ /** The 7 line dash styles (mirrors the host's LINE_STYLES). */
804
+ export const PluginViewLineStyle = z.enum([
805
+ "solid",
806
+ "dashed",
807
+ "dashdot",
808
+ "hidden",
809
+ "center",
810
+ "phantom",
811
+ "propertyLine",
812
+ ])
813
+ export type PluginViewLineStyle = z.infer<typeof PluginViewLineStyle>
814
+
815
+ /**
816
+ * A style patch for one category — any subset of the category's settings.
817
+ * Line weights are in **mm** (the printed weight); `opacity` values are 0–100;
818
+ * `colorMode` is `department` / `texture` / `monochrome` or `tag:<tagCategoryId>`
819
+ * (color by a project tag category).
820
+ *
821
+ * | Property | Type | Description |
822
+ * |---|---|---|
823
+ * | `hide` | `boolean`? | Hide the category (cascades to its labels) |
824
+ * | `lineStyle` | {@linkcode PluginViewLineStyle}? | Dash pattern |
825
+ * | `lineColor` | `string`? | Line color, 6-digit hex (`#` optional) |
826
+ * | `dashLength` | `number`? | Dash-length multiplier (> 0; `1` = default) |
827
+ * | `lineWidth` | `number`? | Single line weight in mm (categories without cut/projection) |
828
+ * | `cutWidth` | `number`? | Cut-line weight in mm |
829
+ * | `projectionWidth` | `number`? | Projection-line weight in mm |
830
+ * | `treeLineWidth` | `number`? | Tree line weight in mm (Landscape) |
831
+ * | `parkingLineWidth` | `number`? | Parking line weight in mm (Landscape) |
832
+ * | `colorMode` | `string`? | `department` \| `texture` \| `monochrome` \| `tag:<id>` |
833
+ * | `opacity` | `number`? | Category fill opacity, 0–100 |
834
+ * | `mapOpacity` | `number`? | Topography: map image opacity, 0–100 |
835
+ * | `buildingOpacity` | `number`? | Topography: context-building opacity, 0–100 |
836
+ * | `mapHide` | `boolean`? | Topography: hide the map image |
837
+ * | `buildingHide` | `boolean`? | Topography: hide context buildings |
838
+ * | `noBuilding` | `boolean`? | Topography: suppress buildings entirely |
839
+ * | `viewStyle` | `"NONE" \| "FILLET" \| "BUBBLE"`? | Shape restyle: block / rounded corner / bubble |
840
+ * | `radius` | `number`? | Corner radius for `FILLET` (feet) |
841
+ * | `inset` | `number`? | Shape inset/offset |
842
+ */
843
+ export const PluginPlacedViewStylePatch = z
844
+ .object({
845
+ hide: z.boolean().optional(),
846
+ lineStyle: PluginViewLineStyle.optional(),
847
+ lineColor: z
848
+ .string()
849
+ .regex(/^#?[0-9a-fA-F]{6}$/, "lineColor must be a 6-digit hex color")
850
+ .optional(),
851
+ dashLength: z.number().finite().positive().optional(),
852
+ lineWidth: z.number().finite().min(0).optional(),
853
+ cutWidth: z.number().finite().min(0).optional(),
854
+ projectionWidth: z.number().finite().min(0).optional(),
855
+ treeLineWidth: z.number().finite().min(0).optional(),
856
+ parkingLineWidth: z.number().finite().min(0).optional(),
857
+ colorMode: z
858
+ .string()
859
+ .refine(
860
+ (v) => ["department", "texture", "monochrome"].includes(v) || v.startsWith("tag:"),
861
+ { message: "colorMode must be department, texture, monochrome, or tag:<tagCategoryId>" },
862
+ )
863
+ .optional(),
864
+ opacity: z.number().finite().min(0).max(100).optional(),
865
+ mapOpacity: z.number().finite().min(0).max(100).optional(),
866
+ buildingOpacity: z.number().finite().min(0).max(100).optional(),
867
+ mapHide: z.boolean().optional(),
868
+ buildingHide: z.boolean().optional(),
869
+ noBuilding: z.boolean().optional(),
870
+ viewStyle: z.enum(["NONE", "FILLET", "BUBBLE"]).optional(),
871
+ radius: z.number().finite().min(0).optional(),
872
+ inset: z.number().finite().min(0).optional(),
873
+ })
874
+ .strict()
875
+ .refine((p) => Object.keys(p).length > 0, { message: "patch must set at least one setting" })
876
+ export type PluginPlacedViewStylePatch = z.infer<typeof PluginPlacedViewStylePatch>
877
+
878
+ /** Label types that carry typography in a category's Text tab. */
879
+ export const PluginViewLabelType = z.enum(["objectLabels", "department", "areas"])
880
+ export type PluginViewLabelType = z.infer<typeof PluginViewLabelType>
881
+
882
+ /** Typography patch for one label type. `fontSize` is in px. */
883
+ const PluginViewFontVariantPatch = z
884
+ .object({
885
+ fontFamily: z.string().min(1).optional(),
886
+ fontWeight: z
887
+ .string()
888
+ .regex(/^\d{3}$/, 'fontWeight must be a numeric string like "400" or "700"')
889
+ .optional(),
890
+ fontStyle: z.enum(["normal", "italic"]).optional(),
891
+ fontSize: z.number().finite().positive().max(200).optional(),
892
+ })
893
+ .strict()
894
+
895
+ /**
896
+ * Font-styles patch for one category's Text tab.
897
+ *
898
+ * | Property | Type | Description |
899
+ * |---|---|---|
900
+ * | `visibleTypes` | {@linkcode PluginViewLabelType}`[]`? | Which label types render (`[]` hides all) |
901
+ * | `objectLabels` | variant? | Typography for the name label |
902
+ * | `department` | variant? | Typography for the department label |
903
+ * | `areas` | variant? | Typography for the area/tag values |
904
+ */
905
+ export const PluginPlacedViewFontStylesPatch = z
906
+ .object({
907
+ visibleTypes: z.array(PluginViewLabelType).optional(),
908
+ objectLabels: PluginViewFontVariantPatch.optional(),
909
+ department: PluginViewFontVariantPatch.optional(),
910
+ areas: PluginViewFontVariantPatch.optional(),
911
+ })
912
+ .strict()
913
+ .refine((p) => Object.keys(p).length > 0, { message: "patch must set at least one field" })
914
+ export type PluginPlacedViewFontStylesPatch = z.infer<typeof PluginPlacedViewFontStylesPatch>
915
+
916
+ /** Resolved font styles for one label type (fontSize in px). */
917
+ export type PluginViewFontVariant = {
918
+ fontFamily?: string
919
+ fontWeight?: string
920
+ fontStyle?: "normal" | "italic"
921
+ fontSize?: number
922
+ }
923
+
924
+ /**
925
+ * One category's resolved styles on a placed view or sheet.
926
+ *
927
+ * | Property | Type | Description |
928
+ * |---|---|---|
929
+ * | `category` | {@linkcode PluginViewSettingCategory} | The category |
930
+ * | `disabled` | `boolean` | Not visible in this view — settings are inert |
931
+ * | `supported` | `string[]` | Setting ids this category accepts in `updateStyles` |
932
+ * | `settings` | {@linkcode PluginPlacedViewStylePatch} | Fully-resolved values (defaults + overrides) |
933
+ * | `fontStyles` | object? | Resolved Text-tab typography (absent when the category has no Text tab) |
934
+ */
935
+ export type PluginPlacedViewCategoryStyles = {
936
+ category: PluginViewSettingCategory
937
+ disabled: boolean
938
+ supported: string[]
939
+ settings: PluginPlacedViewStylePatch
940
+ fontStyles?: {
941
+ visibleTypes: PluginViewLabelType[]
942
+ objectLabels?: PluginViewFontVariant
943
+ department?: PluginViewFontVariant
944
+ areas?: PluginViewFontVariant
945
+ }
946
+ }
947
+
948
+ /**
949
+ * Result of {@link PluginPresentationPlacedViewsApi.getStyles}.
950
+ *
951
+ * | Property | Type | Description |
952
+ * |---|---|---|
953
+ * | `shapeId` | `string` | The styleable shape read |
954
+ * | `kind` | `"view" \| "sheet"` | Placed view or auto-diagram sheet |
955
+ * | `categories` | {@linkcode PluginPlacedViewCategoryStyles}`[]` | One entry per applicable category |
956
+ */
957
+ export type PluginPlacedViewStylesResult = {
958
+ shapeId: string
959
+ kind: "view" | "sheet"
960
+ categories: PluginPlacedViewCategoryStyles[]
961
+ }
962
+
963
+ /** Arguments for {@link PluginPresentationPlacedViewsApi.updateStyles}. */
964
+ export const PluginPlacedViewsUpdateStylesArgs = z.object({
965
+ shapeId: z.string().min(1),
966
+ category: PluginViewSettingCategory,
967
+ patch: PluginPlacedViewStylePatch,
968
+ })
969
+ export type PluginPlacedViewsUpdateStylesArgs = z.infer<typeof PluginPlacedViewsUpdateStylesArgs>
970
+
971
+ /** Arguments for {@link PluginPresentationPlacedViewsApi.updateFontStyles}. */
972
+ export const PluginPlacedViewsUpdateFontStylesArgs = z.object({
973
+ shapeId: z.string().min(1),
974
+ category: PluginViewSettingCategory,
975
+ patch: PluginPlacedViewFontStylesPatch,
976
+ })
977
+ export type PluginPlacedViewsUpdateFontStylesArgs = z.infer<
978
+ typeof PluginPlacedViewsUpdateFontStylesArgs
979
+ >
980
+
981
+ // ── Labels ──────────────────────────────────────────────────────────────────
982
+
983
+ /**
984
+ * A label on a placed view — a text child generated from the view content.
985
+ *
986
+ * | Property | Type | Description |
987
+ * |---|---|---|
988
+ * | `labelId` | `string` | The label's shape id (addressable in `moveLabel`/`setLabelHidden`) |
989
+ * | `category` | `string \| null` | The style category it belongs to (`null` when untagged) |
990
+ * | `text` | `string` | The rendered text |
991
+ * | `position` | {@linkcode PluginSheetPosition} | Position relative to the placed view |
992
+ * | `scale` | `number` | The label's scale factor |
993
+ * | `hidden` | `boolean` | Whether it is currently hidden |
994
+ */
995
+ export type PluginPlacedViewLabel = {
996
+ labelId: string
997
+ category: string | null
998
+ text: string
999
+ position: PluginSheetPosition
1000
+ scale: number
1001
+ hidden: boolean
1002
+ }
1003
+
1004
+ /** Result of {@link PluginPresentationPlacedViewsApi.listLabels}. */
1005
+ export type PluginPlacedViewLabelsResult = {
1006
+ labels: PluginPlacedViewLabel[]
1007
+ }
1008
+
1009
+ /** Arguments for {@link PluginPresentationPlacedViewsApi.moveLabel}. */
1010
+ export const PluginPlacedViewsMoveLabelArgs = z.object({
1011
+ labelId: z.string().min(1),
1012
+ position: PluginSheetPosition,
1013
+ })
1014
+ export type PluginPlacedViewsMoveLabelArgs = z.infer<typeof PluginPlacedViewsMoveLabelArgs>
1015
+
1016
+ /** Arguments for {@link PluginPresentationPlacedViewsApi.setLabelHidden}. */
1017
+ export const PluginPlacedViewsSetLabelHiddenArgs = z.object({
1018
+ labelId: z.string().min(1),
1019
+ hidden: z.boolean(),
1020
+ })
1021
+ export type PluginPlacedViewsSetLabelHiddenArgs = z.infer<
1022
+ typeof PluginPlacedViewsSetLabelHiddenArgs
1023
+ >
1024
+
1025
+ // ── Canvas shapes ───────────────────────────────────────────────────────────
1026
+
1027
+ /**
1028
+ * Origin classification of a Present-canvas shape: a placed view, an
1029
+ * AI-generated output, a placed diagram image, a plugin-created shape, a
1030
+ * user annotation, a plain image, or other.
1031
+ */
1032
+ export const PluginCanvasShapeOrigin = z.enum([
1033
+ "view",
1034
+ "aiOutput",
1035
+ "diagram",
1036
+ "pluginShape",
1037
+ "annotation",
1038
+ "image",
1039
+ "other",
1040
+ ])
1041
+ export type PluginCanvasShapeOrigin = z.infer<typeof PluginCanvasShapeOrigin>
1042
+
1043
+ /**
1044
+ * A top-level shape on the Present canvas.
1045
+ *
1046
+ * | Property | Type | Description |
1047
+ * |---|---|---|
1048
+ * | `shapeId` | `string` | The shape id |
1049
+ * | `type` | `string` | The canvas shape type (`view`, `image`, `geo`, `text`, …) |
1050
+ * | `origin` | {@linkcode PluginCanvasShapeOrigin} | What created it |
1051
+ * | `sheetId` | `string \| null` | The sheet it sits on (`null` when loose on the canvas) |
1052
+ * | `position` | {@linkcode PluginSheetPosition} | Top-left position (sheet-local; page coordinates off-sheet) |
1053
+ * | `size` | `{ width: number, height: number }` | Displayed size |
1054
+ * | `rotation` | `number` | Rotation in radians |
1055
+ * | `opacity` | `number` | Whole-shape opacity, 0–1 |
1056
+ */
1057
+ export type PluginCanvasShape = {
1058
+ shapeId: string
1059
+ type: string
1060
+ origin: PluginCanvasShapeOrigin
1061
+ sheetId: string | null
1062
+ position: PluginSheetPosition
1063
+ size: { width: number; height: number }
1064
+ rotation: number
1065
+ opacity: number
1066
+ }
1067
+
1068
+ /** Result of {@link PluginPresentationPlacedViewsApi.listShapes}. */
1069
+ export type PluginCanvasShapesListResult = {
1070
+ shapes: PluginCanvasShape[]
1071
+ }
1072
+
1073
+ /** Result of {@link PluginPresentationPlacedViewsApi.deleteShapes}. */
1074
+ export type PluginCanvasShapesDeleteResult = {
1075
+ deleted: string[]
1076
+ }
1077
+
1078
+ /** Arguments for {@link PluginPresentationPlacedViewsApi.moveShape}. */
1079
+ export const PluginPlacedViewsMoveShapeArgs = z.object({
1080
+ shapeId: z.string().min(1),
1081
+ position: PluginSheetPosition,
1082
+ sheetId: z.string().optional(),
1083
+ })
1084
+ export type PluginPlacedViewsMoveShapeArgs = z.infer<typeof PluginPlacedViewsMoveShapeArgs>
1085
+
1086
+ /** Arguments for {@link PluginPresentationPlacedViewsApi.resizeShape}. */
1087
+ export const PluginPlacedViewsResizeShapeArgs = z.object({
1088
+ shapeId: z.string().min(1),
1089
+ factor: z.number().finite().min(0.01).max(100),
1090
+ })
1091
+ export type PluginPlacedViewsResizeShapeArgs = z.infer<typeof PluginPlacedViewsResizeShapeArgs>
1092
+
1093
+ /** Arguments for {@link PluginPresentationPlacedViewsApi.rotateShape}. */
1094
+ export const PluginPresentationPlacedViewsRotateShapeArgs = z.object({
1095
+ shapeId: z.string().min(1),
1096
+ rotation: z.number().finite(),
1097
+ })
1098
+ export type PluginPresentationPlacedViewsRotateShapeArgs = z.infer<
1099
+ typeof PluginPresentationPlacedViewsRotateShapeArgs
1100
+ >
1101
+
1102
+ /** Arguments for {@link PluginPresentationPlacedViewsApi.deleteShapes}. */
1103
+ export const PluginPlacedViewsDeleteShapesArgs = z.object({
1104
+ shapeIds: z.array(z.string().min(1)).min(1).max(500),
1105
+ })
1106
+ export type PluginPlacedViewsDeleteShapesArgs = z.infer<typeof PluginPlacedViewsDeleteShapesArgs>
1107
+
1108
+ /** Arguments for {@link PluginPresentationPlacedViewsApi.setOpacity}. */
1109
+ export const PluginPlacedViewsSetOpacityArgs = z.object({
1110
+ shapeId: z.string().min(1),
1111
+ opacity: z.number().finite().min(0).max(1),
1112
+ })
1113
+ export type PluginPlacedViewsSetOpacityArgs = z.infer<typeof PluginPlacedViewsSetOpacityArgs>
1114
+
1115
+ /** Arguments for {@link PluginPresentationPlacedViewsApi.setMask}. */
1116
+ export const PluginPlacedViewsSetMaskArgs = z.object({
1117
+ shapeId: z.string().min(1),
1118
+ enabled: z.boolean(),
1119
+ })
1120
+ export type PluginPlacedViewsSetMaskArgs = z.infer<typeof PluginPlacedViewsSetMaskArgs>