@snaptrude/plugin-core 0.9.16 → 0.9.18-networks-20261016.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 (215) hide show
  1. package/AGENTS.md +231 -231
  2. package/CHANGELOG.md +408 -402
  3. package/CLAUDE.md +11 -11
  4. package/dist/api/analysis/daylight.d.ts +5 -5
  5. package/dist/api/analysis/solar.d.ts +2 -2
  6. package/dist/api/core/camera/index.d.ts +29 -0
  7. package/dist/api/core/camera/index.d.ts.map +1 -1
  8. package/dist/api/core/geom/create/index.d.ts +7 -1
  9. package/dist/api/core/geom/create/index.d.ts.map +1 -1
  10. package/dist/api/core/geom/update/contour.d.ts +8 -2
  11. package/dist/api/core/geom/update/contour.d.ts.map +1 -1
  12. package/dist/api/core/zoom/index.d.ts +13 -0
  13. package/dist/api/core/zoom/index.d.ts.map +1 -1
  14. package/dist/api/design/bim.d.ts +209 -0
  15. package/dist/api/design/bim.d.ts.map +1 -0
  16. package/dist/api/design/boolean/index.d.ts +2 -0
  17. package/dist/api/design/boolean/index.d.ts.map +1 -1
  18. package/dist/api/design/catalog.d.ts +320 -0
  19. package/dist/api/design/catalog.d.ts.map +1 -0
  20. package/dist/api/design/create/bulk-items.d.ts +65 -25
  21. package/dist/api/design/create/bulk-items.d.ts.map +1 -1
  22. package/dist/api/design/create/index.d.ts +272 -99
  23. package/dist/api/design/create/index.d.ts.map +1 -1
  24. package/dist/api/design/create/opening-fields.d.ts +13 -12
  25. package/dist/api/design/create/opening-fields.d.ts.map +1 -1
  26. package/dist/api/design/delete/index.d.ts +1 -0
  27. package/dist/api/design/delete/index.d.ts.map +1 -1
  28. package/dist/api/design/doors/index.d.ts +18 -24
  29. package/dist/api/design/doors/index.d.ts.map +1 -1
  30. package/dist/api/design/family.d.ts +797 -27
  31. package/dist/api/design/family.d.ts.map +1 -1
  32. package/dist/api/design/index.d.ts +16 -0
  33. package/dist/api/design/index.d.ts.map +1 -1
  34. package/dist/api/design/networks.d.ts +1763 -0
  35. package/dist/api/design/networks.d.ts.map +1 -0
  36. package/dist/api/design/query/index.d.ts +42 -32
  37. package/dist/api/design/query/index.d.ts.map +1 -1
  38. package/dist/api/design/selection/index.d.ts +10 -10
  39. package/dist/api/design/types/index.d.ts +40 -24
  40. package/dist/api/design/types/index.d.ts.map +1 -1
  41. package/dist/api/design/update/index.d.ts +43 -3
  42. package/dist/api/design/update/index.d.ts.map +1 -1
  43. package/dist/api/design/windows/index.d.ts +8 -8
  44. package/dist/api/design/windows/index.d.ts.map +1 -1
  45. package/dist/api/presentation/aiInspiration.d.ts +10 -10
  46. package/dist/api/presentation/annotate.d.ts +38 -22
  47. package/dist/api/presentation/annotate.d.ts.map +1 -1
  48. package/dist/api/presentation/drawingContract.d.ts +32 -0
  49. package/dist/api/presentation/drawingContract.d.ts.map +1 -0
  50. package/dist/api/presentation/drawings.d.ts +3523 -0
  51. package/dist/api/presentation/drawings.d.ts.map +1 -0
  52. package/dist/api/presentation/export.d.ts +23 -5
  53. package/dist/api/presentation/export.d.ts.map +1 -1
  54. package/dist/api/presentation/index.d.ts +41 -12
  55. package/dist/api/presentation/index.d.ts.map +1 -1
  56. package/dist/api/presentation/placedViews.d.ts +106 -6
  57. package/dist/api/presentation/placedViews.d.ts.map +1 -1
  58. package/dist/api/presentation/sections.d.ts +461 -0
  59. package/dist/api/presentation/sections.d.ts.map +1 -0
  60. package/dist/api/presentation/shapes.d.ts +2 -2
  61. package/dist/api/presentation/sheets.d.ts +175 -19
  62. package/dist/api/presentation/sheets.d.ts.map +1 -1
  63. package/dist/api/presentation/viewPresets.d.ts +222 -0
  64. package/dist/api/presentation/viewPresets.d.ts.map +1 -0
  65. package/dist/api/presentation/views.d.ts +103 -5
  66. package/dist/api/presentation/views.d.ts.map +1 -1
  67. package/dist/api/presentation/walkthroughs.d.ts +6 -6
  68. package/dist/errors/codes.d.ts +3 -1
  69. package/dist/errors/codes.d.ts.map +1 -1
  70. package/dist/index.cjs +3788 -2328
  71. package/dist/index.cjs.map +1 -1
  72. package/dist/index.js +3650 -2328
  73. package/dist/index.js.map +1 -1
  74. package/package.json +42 -42
  75. package/scripts/check-dist-fresh.mjs +22 -22
  76. package/scripts/generate-manifest.mjs +243 -238
  77. package/scripts/generate-manifest.test.mjs +303 -303
  78. package/src/api/analysis/daylight.ts +470 -470
  79. package/src/api/analysis/heatmaps.ts +683 -683
  80. package/src/api/analysis/illuminance.ts +155 -155
  81. package/src/api/analysis/index.ts +61 -61
  82. package/src/api/analysis/shadows.ts +183 -183
  83. package/src/api/analysis/solar.ts +237 -237
  84. package/src/api/analysis/sunlightHours.ts +211 -211
  85. package/src/api/analysis/sunpath.ts +83 -83
  86. package/src/api/analysis/weather.ts +179 -179
  87. package/src/api/core/buildings.ts +485 -485
  88. package/src/api/core/camera/index.ts +696 -667
  89. package/src/api/core/comment/index.ts +376 -376
  90. package/src/api/core/geom/create/index.ts +2139 -2133
  91. package/src/api/core/geom/delete/index.ts +84 -84
  92. package/src/api/core/geom/index.ts +35 -35
  93. package/src/api/core/geom/query/arc.ts +169 -169
  94. package/src/api/core/geom/query/brep.ts +621 -621
  95. package/src/api/core/geom/query/circle.ts +404 -404
  96. package/src/api/core/geom/query/contour.ts +540 -540
  97. package/src/api/core/geom/query/curve.ts +1102 -1102
  98. package/src/api/core/geom/query/edge.ts +130 -130
  99. package/src/api/core/geom/query/face.ts +508 -508
  100. package/src/api/core/geom/query/halfedge.ts +210 -210
  101. package/src/api/core/geom/query/index.ts +63 -63
  102. package/src/api/core/geom/query/profile.ts +473 -473
  103. package/src/api/core/geom/query/vertex.ts +205 -205
  104. package/src/api/core/geom/update/contour.ts +323 -317
  105. package/src/api/core/geom/update/curve.ts +209 -209
  106. package/src/api/core/geom/update/index.ts +29 -29
  107. package/src/api/core/geom/update/profile.ts +379 -379
  108. package/src/api/core/groups.ts +521 -521
  109. package/src/api/core/handles/index.ts +234 -234
  110. package/src/api/core/history/index.ts +84 -84
  111. package/src/api/core/index.ts +99 -99
  112. package/src/api/core/io/export/index.ts +126 -126
  113. package/src/api/core/io/import/index.ts +504 -504
  114. package/src/api/core/io/index.ts +42 -42
  115. package/src/api/core/io/job/index.ts +140 -140
  116. package/src/api/core/io/query/index.ts +71 -71
  117. package/src/api/core/io/terrain/index.ts +360 -360
  118. package/src/api/core/io/underlay/index.ts +705 -705
  119. package/src/api/core/layers.ts +540 -540
  120. package/src/api/core/math/index.ts +20 -20
  121. package/src/api/core/math/quat.ts +172 -172
  122. package/src/api/core/math/vec3.ts +179 -179
  123. package/src/api/core/mode/index.ts +108 -108
  124. package/src/api/core/project/index.ts +479 -479
  125. package/src/api/core/proposals/index.ts +570 -570
  126. package/src/api/core/storeys/index.ts +308 -308
  127. package/src/api/core/storeys/layers.ts +339 -339
  128. package/src/api/core/tags.ts +911 -911
  129. package/src/api/core/units/index.ts +164 -164
  130. package/src/api/core/user.ts +46 -46
  131. package/src/api/core/zoom/index.ts +64 -51
  132. package/src/api/design/bim.ts +121 -0
  133. package/src/api/design/boolean/index.ts +181 -179
  134. package/src/api/design/catalog.ts +203 -0
  135. package/src/api/design/create/bulk-items.ts +294 -254
  136. package/src/api/design/create/grids.ts +137 -137
  137. package/src/api/design/create/index.ts +2148 -1980
  138. package/src/api/design/create/opening-fields.ts +40 -37
  139. package/src/api/design/delete/index.ts +75 -74
  140. package/src/api/design/dimensions.ts +453 -453
  141. package/src/api/design/doors/index.ts +516 -500
  142. package/src/api/design/edit/index.ts +54 -54
  143. package/src/api/design/erase/index.ts +151 -151
  144. package/src/api/design/family.ts +1334 -704
  145. package/src/api/design/furniture/index.ts +319 -319
  146. package/src/api/design/grids.ts +237 -237
  147. package/src/api/design/index.ts +304 -274
  148. package/src/api/design/lock.ts +69 -69
  149. package/src/api/design/materials/index.ts +608 -608
  150. package/src/api/design/networks.ts +667 -0
  151. package/src/api/design/query/geometry/index.ts +319 -319
  152. package/src/api/design/query/grids.ts +197 -197
  153. package/src/api/design/query/index.ts +1236 -1226
  154. package/src/api/design/query/referenceLines.ts +52 -52
  155. package/src/api/design/query/spaces.ts +275 -275
  156. package/src/api/design/selection/index.ts +273 -273
  157. package/src/api/design/shared.ts +40 -40
  158. package/src/api/design/transform/index.ts +254 -254
  159. package/src/api/design/types/index.ts +163 -156
  160. package/src/api/design/update/index.ts +1024 -983
  161. package/src/api/design/visibility.ts +143 -143
  162. package/src/api/design/windows/index.ts +351 -333
  163. package/src/api/entity/buildableEnvelope.ts +322 -322
  164. package/src/api/entity/index.ts +30 -30
  165. package/src/api/entity/referenceLine.ts +235 -235
  166. package/src/api/entity/space.ts +612 -612
  167. package/src/api/entity/story.ts +517 -517
  168. package/src/api/index.ts +47 -47
  169. package/src/api/presentation/aiInspiration.ts +1116 -1116
  170. package/src/api/presentation/annotate.ts +417 -385
  171. package/src/api/presentation/camera.ts +289 -289
  172. package/src/api/presentation/diagrams.ts +194 -194
  173. package/src/api/presentation/drawingContract.ts +70 -0
  174. package/src/api/presentation/drawings.ts +1179 -0
  175. package/src/api/presentation/export.ts +134 -108
  176. package/src/api/presentation/import.ts +159 -159
  177. package/src/api/presentation/index.ts +160 -126
  178. package/src/api/presentation/placedViews.ts +1211 -1120
  179. package/src/api/presentation/sections.ts +420 -0
  180. package/src/api/presentation/shapes.ts +274 -274
  181. package/src/api/presentation/sheets.ts +746 -585
  182. package/src/api/presentation/slideshow.ts +134 -134
  183. package/src/api/presentation/tables.ts +84 -84
  184. package/src/api/presentation/viewPresets.ts +241 -0
  185. package/src/api/presentation/views.ts +713 -673
  186. package/src/api/presentation/walkthroughs.ts +1201 -1201
  187. package/src/api/program/adjacency.ts +164 -164
  188. package/src/api/program/areas.ts +408 -408
  189. package/src/api/program/classification.ts +138 -138
  190. package/src/api/program/cores.ts +83 -83
  191. package/src/api/program/departments.ts +517 -517
  192. package/src/api/program/index.ts +73 -73
  193. package/src/api/program/labels.ts +332 -332
  194. package/src/api/program/layout.ts +422 -422
  195. package/src/api/program/metadata.ts +364 -364
  196. package/src/api/program/metrics.ts +120 -120
  197. package/src/api/program/site.ts +748 -748
  198. package/src/api/program/spreadsheet.ts +2698 -2698
  199. package/src/api/workspace/index.ts +612 -612
  200. package/src/errors/codes.ts +143 -136
  201. package/src/errors/envelope.ts +75 -75
  202. package/src/errors/index.ts +21 -21
  203. package/src/errors/plugin-error.ts +134 -134
  204. package/src/handles.ts +297 -297
  205. package/src/host-utils.ts +67 -67
  206. package/src/index.ts +7 -7
  207. package/src/massParameters.ops.ts +246 -246
  208. package/src/massParameters.ts +427 -427
  209. package/src/types.ts +16 -16
  210. package/test/drawingContract.test.mjs +288 -0
  211. package/test/errors.test.mjs +185 -184
  212. package/test/massParameters.test.mjs +952 -952
  213. package/tsconfig.json +22 -22
  214. package/tsup.config.ts +12 -12
  215. package/api-manifest.json +0 -9618
@@ -1,673 +1,713 @@
1
- import * as z from "zod"
2
- import { PluginApiReturn } from "../../types"
3
-
4
- /**
5
- * Presentation views — read the saved 2D/3D views used to prepare presentations.
6
- *
7
- * A **view** is a saved camera/plan: a sheet-ready 2D plan or a saved 3D view.
8
- * A plugin can list and read views, capture them to images, activate one (move
9
- * the camera to it), save the current camera as a new view, rename or delete a
10
- * saved view, and read/update a view's display settings (background, color
11
- * mode, view mode, axis, edges, labels). Each view carries the `storey` it was
12
- * saved on.
13
- *
14
- * `list`/`get`/`getActive`/`capture`/`getSettings` are reads;
15
- * `setActive`/`create`/`rename`/`delete`/`updateSettings` are writes (a view is
16
- * a camera bookmark — not geometry).
17
- *
18
- * Accessed via `snaptrude.presentation.views`.
19
- */
20
- export abstract class PluginPresentationViewsApi {
21
- constructor() {}
22
-
23
- /**
24
- * List the saved views in the active project.
25
- *
26
- * @returns A {@linkcode PluginPresentationViewsListResult} with a `views` array
27
- * of 2D and 3D views (empty when the project has none).
28
- *
29
- * @examplePrompt List all the saved views
30
- * @examplePrompt What 2D and 3D views are in this project?
31
- * @examplePrompt Which view is currently active?
32
- * @examplePrompt Get the names of every presentation view
33
- * @examplePrompt Show me the 3D views I can put on a sheet
34
- *
35
- * # Example
36
- * ```ts
37
- * const { views } = await snaptrude.presentation.views.list()
38
- * const active = views.find((v) => v.isActive)
39
- * const plans = views.filter((v) => v.type === "2d")
40
- * ```
41
- */
42
- public abstract list(): PluginApiReturn<PluginPresentationViewsListResult>
43
-
44
- /**
45
- * Get a single saved view by id.
46
- *
47
- * @param viewId - The id of the view to read.
48
- * @returns The matching {@linkcode PluginPresentationView}, or `null` if no view
49
- * has that id.
50
- *
51
- * @examplePrompt Get the view with id view_12345
52
- * @examplePrompt Find the saved view called Ground Floor Plan
53
- * @examplePrompt Look up a presentation view by its id
54
- *
55
- * # Example
56
- * ```ts
57
- * const view = await snaptrude.presentation.views.get("view_123")
58
- * ```
59
- */
60
- public abstract get(
61
- viewId: string,
62
- ): PluginApiReturn<PluginPresentationViewsGetResult>
63
-
64
- /**
65
- * Get the currently active view.
66
- *
67
- * @returns The active {@linkcode PluginPresentationView}, or `null` if none is
68
- * active.
69
- *
70
- * @examplePrompt Which view is active right now?
71
- * @examplePrompt Get the current view
72
- * @examplePrompt What view am I looking at?
73
- *
74
- * # Example
75
- * ```ts
76
- * const active = await snaptrude.presentation.views.getActive()
77
- * ```
78
- */
79
- public abstract getActive(): PluginApiReturn<PluginPresentationViewsGetResult>
80
-
81
- /**
82
- * Capture a screenshot of a view as a base64 image.
83
- *
84
- * Captures the **current** viewport by default; pass `viewId` to capture a
85
- * specific saved view (which briefly applies that view to the scene). Use
86
- * `format`/`resolution` to control the output. This shoots the Design (3D)
87
- * canvas; to screenshot the Present canvas use
88
- * {@linkcode PluginPresentationCameraApi.capture}.
89
- *
90
- * @param options - All optional: `viewId` (capture this saved view; omit for the
91
- * current viewport), `format` (default `"png"`), `resolution` (e.g. `"1280x720"`).
92
- * @returns A {@linkcode PluginPresentationViewsCaptureResult} with the base64
93
- * `image` data URL.
94
- * @throws If a given `viewId` does not exist.
95
- *
96
- * @examplePrompt Take a screenshot of the current view
97
- * @examplePrompt Capture this view as a PNG
98
- * @examplePrompt Render the Site Plan view to an image
99
- * @examplePrompt Export a high-res image of what I'm looking at
100
- *
101
- * # Example
102
- * ```ts
103
- * const { image } = await snaptrude.presentation.views.capture({ format: "png" })
104
- * ```
105
- */
106
- public abstract capture(options?: {
107
- viewId?: string
108
- format?: "png" | "jpeg"
109
- resolution?: string
110
- }): PluginApiReturn<PluginPresentationViewsCaptureResult>
111
-
112
- /**
113
- * Activate a saved view — move the camera to it and restore its scene state.
114
- *
115
- * Applies the view's camera, visibility, and storey state to the live scene.
116
- * Paired with {@linkcode PluginPresentationViewsApi.getActive}.
117
- *
118
- * @param viewId - The id of the view to activate.
119
- * @returns The id of the now-active view.
120
- * @throws If no view has the given id.
121
- *
122
- * @examplePrompt Switch to the Ground Floor plan view
123
- * @examplePrompt Make the 3D view active
124
- * @examplePrompt Go to the view named Entrance
125
- * @examplePrompt Load the site plan view
126
- *
127
- * # Example
128
- * ```ts
129
- * await snaptrude.presentation.views.setActive("view_123")
130
- * ```
131
- */
132
- public abstract setActive(
133
- viewId: string,
134
- ): PluginApiReturn<PluginPresentationViewsSetActiveResult>
135
-
136
- /**
137
- * Save the current camera/scene state as a new named view.
138
- *
139
- * Creates a camera bookmark (not geometry) from where the camera is now.
140
- *
141
- * @param name - Name for the new view (a default is used when omitted).
142
- * @param options - Optional `kind` (what kind of view to save, default
143
- * `"view"`) and `storey` (save the view on a specific storey — the storey is
144
- * activated first, matching the storey the view is captured on; when omitted
145
- * the current active storey is used).
146
- * @returns The newly created {@linkcode PluginPresentationView}.
147
- * @throws If `storey` is given but no such storey exists, or the view could
148
- * not be saved.
149
- *
150
- * @examplePrompt Save the current view as Lobby Perspective
151
- * @examplePrompt Create a new saved view from where I'm looking
152
- * @examplePrompt Bookmark this camera angle
153
- * @examplePrompt Save the current 2D plan as a view
154
- * @examplePrompt Save a view on the second storey
155
- *
156
- * # Example
157
- * ```ts
158
- * const view = await snaptrude.presentation.views.create("Lobby")
159
- * // …or capture the view on a specific storey
160
- * const level2 = await snaptrude.presentation.views.create("Level 2", { storey: 2 })
161
- * ```
162
- */
163
- public abstract create(
164
- name?: string,
165
- options?: { kind?: "view" | "sitePlan"; storey?: number },
166
- ): PluginApiReturn<PluginPresentationViewsCreateResult>
167
-
168
- /**
169
- * Read a saved view's display settings (background, color mode, view mode,
170
- * axis, edges, labels).
171
- *
172
- * @param viewId - The id of the view to read settings for.
173
- * @returns The view's {@linkcode PluginPresentationViewSettings}, or `null` if
174
- * no view has that id.
175
- *
176
- * @examplePrompt What color mode is the Ground Floor view using?
177
- * @examplePrompt Get the display settings for this view
178
- * @examplePrompt Does the site plan view show axes and labels?
179
- * @examplePrompt Read the background color of the active view
180
- *
181
- * # Example
182
- * ```ts
183
- * const settings = await snaptrude.presentation.views.getSettings("view_123")
184
- * if (settings) console.log(settings.colorMode, settings.backgroundColor)
185
- * ```
186
- */
187
- public abstract getSettings(
188
- viewId: string,
189
- ): PluginApiReturn<PluginPresentationViewsGetSettingsResult>
190
-
191
- /**
192
- * Update a saved view's display settings (partial patch — only the fields you
193
- * pass change).
194
- *
195
- * Persists and broadcasts the change; if the view is currently active, the
196
- * scene updates live. **Not Ctrl+Z-undoable** — view-metadata edits publish
197
- * directly and do not land on the local undo stack; this matches how the
198
- * product's own view-settings UI behaves.
199
- *
200
- * Label patch semantics (mirroring the product, which stores no label
201
- * selection while labels are off):
202
- *
203
- * - `{ showLabels: true }` alone turns labels on; if the view has no stored
204
- * selection, the product defaults (`objectLabels`, `areas`) are applied —
205
- * labels are never "on" with an empty selection (the product has no such
206
- * state; labels render only while the selection is non-empty).
207
- * - `{ labels: [...] }` alone sets the selection **and turns labels on**.
208
- * - `{ showLabels: false }` turns labels off and **clears the stored
209
- * selection** — a later read returns `labels: []`.
210
- * - `{ showLabels: false, labels: [...] }` with a non-empty list is
211
- * contradictory and **rejected** (nothing is silently discarded).
212
- * - `{ showLabels: true, labels: [] }` is likewise contradictory and
213
- * **rejected** — pass a non-empty list, or omit `labels` to get the
214
- * defaults.
215
- *
216
- * `colorMode` accepts the `tag:<categoryId>` scheme strings returned by
217
- * {@linkcode PluginPresentationViewsApi.getSettings}, so read-then-write
218
- * round-trips a tag-based color scheme unchanged.
219
- *
220
- * `viewMode` (`"perspective"` | `"isometric"`) applies to **3D views only** —
221
- * a 2D plan is always orthographic, so a `viewMode: "perspective"` patch on a
222
- * 2D view is rejected. `"isometric"` on a 2D plan is accepted as a no-op (the
223
- * plan is already orthographic), so writing back exactly what
224
- * {@linkcode PluginPresentationViewsApi.getSettings} returned is always a
225
- * no-op. On the active view the camera switches projection live (the same
226
- * toggle the view-settings modal runs); on other views the mode is applied
227
- * the next time the view is activated.
228
- *
229
- * @param viewId - The id of the view to update.
230
- * @param settings - A partial {@linkcode PluginPresentationViewSettings}; any
231
- * omitted field is left unchanged.
232
- * @returns The updated view's `id`.
233
- * @throws If writes are disabled, no view has the given id, the patch is
234
- * contradictory (`showLabels: false` with a non-empty `labels`, or
235
- * `showLabels: true` with an explicitly empty `labels` list), or
236
- * `viewMode: "perspective"` is patched on a 2D plan view.
237
- *
238
- * @examplePrompt Switch this view to monochrome color mode
239
- * @examplePrompt Turn off the axis in the Ground Floor view
240
- * @examplePrompt Set the background of the active view to white
241
- * @examplePrompt Show area labels on this view
242
- * @examplePrompt Enable hidden-line mode for the section view
243
- * @examplePrompt Make the 3D view orthographic instead of perspective
244
- *
245
- * # Example
246
- * ```ts
247
- * await snaptrude.presentation.views.updateSettings("view_123", {
248
- * colorMode: "monochrome",
249
- * showAxis: false,
250
- * })
251
- * // switch a 3D view to an isometric (orthographic) projection
252
- * await snaptrude.presentation.views.updateSettings("view_123", {
253
- * viewMode: "isometric",
254
- * })
255
- * ```
256
- */
257
- public abstract updateSettings(
258
- viewId: string,
259
- settings: Partial<PluginPresentationViewSettings>,
260
- ): PluginApiReturn<PluginPresentationViewsUpdateSettingsResult>
261
-
262
- /**
263
- * Rename a saved view.
264
- *
265
- * Sets the view's display name — the same label the views panel shows and
266
- * that `list`/`get` read back. Names must be unique within the proposal and
267
- * cannot contain the characters `\ : { } [ ] | ; < > ? ~`.
268
- *
269
- * @param viewId - The id of the view to rename.
270
- * @param name - The new display name (non-empty after trimming).
271
- * @returns The updated {@linkcode PluginPresentationView}.
272
- * @throws If writes are disabled, no view has the given id, the name is
273
- * empty/invalid, or another view in the proposal already has that name.
274
- *
275
- * @examplePrompt Rename the view Lobby to Entrance Lobby
276
- * @examplePrompt Call this view Ground Floor Plan
277
- * @examplePrompt Change the active view's name to Final
278
- *
279
- * # Example
280
- * ```ts
281
- * const view = await snaptrude.presentation.views.rename("view_123", "Entrance")
282
- * ```
283
- */
284
- public abstract rename(
285
- viewId: string,
286
- name: string,
287
- ): PluginApiReturn<PluginPresentationViewsRenameResult>
288
-
289
- /**
290
- * Delete a saved view.
291
- *
292
- * Removes the view from the project and the views panel (the panel's own
293
- * delete action). If the deleted view was active, the product falls back to
294
- * the default plan/3D view. Default views (the built-in plan/3D/site-plan
295
- * entries) cannot be deleted.
296
- *
297
- * @param viewId - The id of the view to delete.
298
- * @returns The id of the deleted view
299
- * (a {@linkcode PluginPresentationViewsDeleteResult}).
300
- * @throws If writes are disabled, no view has the given id, or the view is a
301
- * default view.
302
- *
303
- * @examplePrompt Delete the view named Old Draft
304
- * @examplePrompt Remove this saved view
305
- * @examplePrompt Get rid of the Lobby camera bookmark
306
- *
307
- * # Example
308
- * ```ts
309
- * const { id } = await snaptrude.presentation.views.delete("view_123")
310
- * ```
311
- */
312
- public abstract delete(
313
- viewId: string,
314
- ): PluginApiReturn<PluginPresentationViewsDeleteResult>
315
- }
316
-
317
- /**
318
- * The kind of a saved view: a 2D plan view or a 3D view.
319
- */
320
- export const PluginPresentationViewType = z.enum(["2d", "3d"])
321
- export type PluginPresentationViewType = z.infer<
322
- typeof PluginPresentationViewType
323
- >
324
-
325
- /**
326
- * A saved presentation view.
327
- *
328
- * | Property | Type | Description |
329
- * |---|---|---|
330
- * | `id` | `string` | Unique view id |
331
- * | `name` | `string` | Display name |
332
- * | `type` | `"2d" \| "3d"` | Whether this is a 2D plan view or a 3D view |
333
- * | `isActive` | `boolean` | Whether this view is the currently active view |
334
- * | `storey` | `number \| null` | The storey this view was saved on (`null` on older views saved without one) |
335
- */
336
- export const PluginPresentationView = z.object({
337
- id: z.string(),
338
- name: z.string(),
339
- type: PluginPresentationViewType,
340
- isActive: z.boolean(),
341
- storey: z.number().nullable(),
342
- })
343
- export type PluginPresentationView = z.infer<typeof PluginPresentationView>
344
-
345
- /**
346
- * Result of {@linkcode PluginPresentationViewsApi.list}.
347
- *
348
- * | Property | Type | Description |
349
- * |---|---|---|
350
- * | `views` | {@linkcode PluginPresentationView}`[]` | All saved views in the project |
351
- */
352
- export const PluginPresentationViewsListResult = z.object({
353
- views: z.array(PluginPresentationView),
354
- })
355
- export type PluginPresentationViewsListResult = z.infer<
356
- typeof PluginPresentationViewsListResult
357
- >
358
-
359
- /**
360
- * Arguments for {@linkcode PluginPresentationViewsApi.get}.
361
- *
362
- * | Property | Type | Description |
363
- * |---|---|---|
364
- * | `id` | `string` | The id of the view to read |
365
- */
366
- export const PluginPresentationViewsGetArgs = z.object({
367
- id: z.string(),
368
- })
369
- export type PluginPresentationViewsGetArgs = z.infer<
370
- typeof PluginPresentationViewsGetArgs
371
- >
372
-
373
- /**
374
- * Result of {@linkcode PluginPresentationViewsApi.get} and
375
- * {@linkcode PluginPresentationViewsApi.getActive} — the view, or `null` when
376
- * there is no match / no active view.
377
- */
378
- export const PluginPresentationViewsGetResult =
379
- PluginPresentationView.nullable()
380
- export type PluginPresentationViewsGetResult = z.infer<
381
- typeof PluginPresentationViewsGetResult
382
- >
383
-
384
- /** Image format for {@linkcode PluginPresentationViewsApi.capture}. */
385
- export const PluginPresentationImageFormat = z.enum(["png", "jpeg"])
386
- export type PluginPresentationImageFormat = z.infer<
387
- typeof PluginPresentationImageFormat
388
- >
389
-
390
- /**
391
- * Arguments for {@linkcode PluginPresentationViewsApi.capture}. All optional.
392
- *
393
- * | Property | Type | Description |
394
- * |---|---|---|
395
- * | `viewId` | `string \| undefined` | Capture this saved view; omit to capture the current viewport |
396
- * | `format` | `"png" \| "jpeg" \| undefined` | Output image format (default `"png"`) |
397
- * | `resolution` | `string \| undefined` | Optional resolution hint (e.g. `"1280x720"`) |
398
- */
399
- export const PluginPresentationViewsCaptureArgs = z.object({
400
- viewId: z.string().optional(),
401
- format: PluginPresentationImageFormat.optional(),
402
- resolution: z.string().optional(),
403
- })
404
- export type PluginPresentationViewsCaptureArgs = z.infer<
405
- typeof PluginPresentationViewsCaptureArgs
406
- >
407
-
408
- /**
409
- * Result of {@linkcode PluginPresentationViewsApi.capture}.
410
- *
411
- * | Property | Type | Description |
412
- * |---|---|---|
413
- * | `image` | `string` | The captured image as a base64 data URL |
414
- */
415
- export const PluginPresentationViewsCaptureResult = z.object({
416
- image: z.string(),
417
- })
418
- export type PluginPresentationViewsCaptureResult = z.infer<
419
- typeof PluginPresentationViewsCaptureResult
420
- >
421
-
422
- /**
423
- * Arguments for {@linkcode PluginPresentationViewsApi.setActive}.
424
- *
425
- * | Property | Type | Description |
426
- * |---|---|---|
427
- * | `id` | `string` | The id of the view to activate |
428
- */
429
- export const PluginPresentationViewsSetActiveArgs = z.object({
430
- id: z.string(),
431
- })
432
- export type PluginPresentationViewsSetActiveArgs = z.infer<
433
- typeof PluginPresentationViewsSetActiveArgs
434
- >
435
-
436
- /** Result of {@linkcode PluginPresentationViewsApi.setActive} — the active view's id. */
437
- export const PluginPresentationViewsSetActiveResult = z.object({
438
- id: z.string(),
439
- })
440
- export type PluginPresentationViewsSetActiveResult = z.infer<
441
- typeof PluginPresentationViewsSetActiveResult
442
- >
443
-
444
- /**
445
- * Arguments for {@linkcode PluginPresentationViewsApi.create}. All optional.
446
- *
447
- * | Property | Type | Description |
448
- * |---|---|---|
449
- * | `name` | `string \| undefined` | Name for the new view (a default is used when omitted) |
450
- * | `kind` | `"view" \| "sitePlan" \| undefined` | What kind of view to save (default `"view"`). `"plan"` is not offered — the host cannot create a plan view without a `planId` this API does not carry. |
451
- * | `storey` | `number \| undefined` | Save the view on this storey (activated before capture); defaults to the current active storey |
452
- */
453
- export const PluginPresentationViewsCreateArgs = z.object({
454
- name: z.string().optional(),
455
- kind: z.enum(["view", "sitePlan"]).optional(),
456
- storey: z.number().optional(),
457
- })
458
- export type PluginPresentationViewsCreateArgs = z.infer<
459
- typeof PluginPresentationViewsCreateArgs
460
- >
461
-
462
- /** Result of {@linkcode PluginPresentationViewsApi.create} — the saved view. */
463
- export const PluginPresentationViewsCreateResult = PluginPresentationView
464
- export type PluginPresentationViewsCreateResult = z.infer<
465
- typeof PluginPresentationViewsCreateResult
466
- >
467
-
468
- /**
469
- * How the scene is colored in a view.
470
- *
471
- * | Value | Meaning |
472
- * |---|---|
473
- * | `monochrome` | Flat single-tone shading |
474
- * | `texture` | Material textures/colors |
475
- * | `department` | Colored by department |
476
- * | `tag:<categoryId>` | Colored by a project tag category (e.g. `tag:ZONE`) |
477
- *
478
- * The `tag:<categoryId>` form carries the product's tag-based color schemes
479
- * losslessly — reading a view that uses one returns the `tag:` string as-is,
480
- * and writing it back preserves the scheme (read-then-write is safe).
481
- */
482
- export const PluginPresentationViewColorMode = z.union([
483
- z.enum(["monochrome", "texture", "department"]),
484
- z.templateLiteral(["tag:", z.string()]),
485
- ])
486
- export type PluginPresentationViewColorMode = z.infer<
487
- typeof PluginPresentationViewColorMode
488
- >
489
-
490
- /**
491
- * A category of on-canvas labels a view can show.
492
- *
493
- * | Value | Meaning |
494
- * |---|---|
495
- * | `objectLabels` | Per-object name labels |
496
- * | `areas` | Area/room labels |
497
- * | `department` | Department labels |
498
- */
499
- export const PluginPresentationViewLabel = z.enum([
500
- "objectLabels",
501
- "areas",
502
- "department",
503
- ])
504
- export type PluginPresentationViewLabel = z.infer<
505
- typeof PluginPresentationViewLabel
506
- >
507
-
508
- /**
509
- * A view's camera projection: perspective, or isometric (orthographic).
510
- *
511
- * | Value | Meaning |
512
- * |---|---|
513
- * | `perspective` | Perspective projection (vanishing points) |
514
- * | `isometric` | Orthographic projection (no perspective distortion) |
515
- *
516
- * Applies to 3D views; a 2D plan view is always orthographic and reads
517
- * `"isometric"`.
518
- */
519
- export const PluginPresentationViewMode = z.enum(["perspective", "isometric"])
520
- export type PluginPresentationViewMode = z.infer<
521
- typeof PluginPresentationViewMode
522
- >
523
-
524
- /**
525
- * A view's display settings.
526
- *
527
- * | Property | Type | Description |
528
- * |---|---|---|
529
- * | `backgroundColor` | `string` | Canvas background as a hex color (e.g. `#ffffff`) |
530
- * | `colorMode` | {@linkcode PluginPresentationViewColorMode} | How the scene is colored (including `tag:<categoryId>` schemes) |
531
- * | `viewMode` | {@linkcode PluginPresentationViewMode} | Camera projection — `"perspective"` or `"isometric"` (orthographic). Writable on 3D views only; a 2D plan always reads `"isometric"` and accepts only `"isometric"` (a no-op) |
532
- * | `showAxis` | `boolean` | Whether the X/Y/Z axes are shown |
533
- * | `showEdges` | `boolean` | Whether edges are shown; `false` = hidden-line rendering |
534
- * | `showLabels` | `boolean` | Master label switch — whether on-canvas labels are shown at all. `true` always pairs with a non-empty `labels` selection (labels render only while the selection is non-empty; there is no labels-on-with-empty-selection state) |
535
- * | `labels` | {@linkcode PluginPresentationViewLabel}`[]` | Which label categories are selected. When `showLabels` is `false` the view stores no selection and this reads `[]` |
536
- */
537
- export const PluginPresentationViewSettings = z.object({
538
- backgroundColor: z.string(),
539
- colorMode: PluginPresentationViewColorMode,
540
- viewMode: PluginPresentationViewMode,
541
- showAxis: z.boolean(),
542
- showEdges: z.boolean(),
543
- showLabels: z.boolean(),
544
- labels: z.array(PluginPresentationViewLabel),
545
- })
546
- export type PluginPresentationViewSettings = z.infer<
547
- typeof PluginPresentationViewSettings
548
- >
549
-
550
- /**
551
- * Arguments for {@linkcode PluginPresentationViewsApi.getSettings}.
552
- *
553
- * | Property | Type | Description |
554
- * |---|---|---|
555
- * | `id` | `string` | The id of the view to read settings for |
556
- */
557
- export const PluginPresentationViewsGetSettingsArgs = z.object({
558
- id: z.string(),
559
- })
560
- export type PluginPresentationViewsGetSettingsArgs = z.infer<
561
- typeof PluginPresentationViewsGetSettingsArgs
562
- >
563
-
564
- /**
565
- * Result of {@linkcode PluginPresentationViewsApi.getSettings} — the settings,
566
- * or `null` when no view has that id.
567
- */
568
- export const PluginPresentationViewsGetSettingsResult =
569
- PluginPresentationViewSettings.nullable()
570
- export type PluginPresentationViewsGetSettingsResult = z.infer<
571
- typeof PluginPresentationViewsGetSettingsResult
572
- >
573
-
574
- /**
575
- * Arguments for {@linkcode PluginPresentationViewsApi.updateSettings}. The
576
- * `settings` patch is partial — any omitted field is left unchanged. A patch
577
- * pairing `showLabels: false` with a non-empty `labels` list, or
578
- * `showLabels: true` with an explicitly empty `labels` list, is rejected as
579
- * contradictory (see the method JSDoc for the full label patch semantics).
580
- *
581
- * | Property | Type | Description |
582
- * |---|---|---|
583
- * | `id` | `string` | The id of the view to update |
584
- * | `settings` | `Partial<`{@linkcode PluginPresentationViewSettings}`>` | The fields to change |
585
- */
586
- export const PluginPresentationViewsUpdateSettingsArgs = z
587
- .object({
588
- id: z.string(),
589
- settings: PluginPresentationViewSettings.partial(),
590
- })
591
- .refine(
592
- (v) =>
593
- !(
594
- v.settings.showLabels === false && (v.settings.labels?.length ?? 0) > 0
595
- ),
596
- {
597
- message:
598
- "Contradictory patch: labels cannot be set while showLabels is false",
599
- },
600
- )
601
- .refine(
602
- (v) =>
603
- !(
604
- v.settings.showLabels === true &&
605
- v.settings.labels !== undefined &&
606
- v.settings.labels.length === 0
607
- ),
608
- {
609
- message:
610
- "Contradictory patch: showLabels cannot be true with an explicitly empty labels list — pass a non-empty list, or omit labels to apply the defaults",
611
- },
612
- )
613
- export type PluginPresentationViewsUpdateSettingsArgs = z.infer<
614
- typeof PluginPresentationViewsUpdateSettingsArgs
615
- >
616
-
617
- /** Result of {@linkcode PluginPresentationViewsApi.updateSettings} — the updated view's id. */
618
- export const PluginPresentationViewsUpdateSettingsResult = z.object({
619
- id: z.string(),
620
- })
621
- export type PluginPresentationViewsUpdateSettingsResult = z.infer<
622
- typeof PluginPresentationViewsUpdateSettingsResult
623
- >
624
-
625
- /**
626
- * Arguments for {@linkcode PluginPresentationViewsApi.rename}.
627
- *
628
- * | Property | Type | Description |
629
- * |---|---|---|
630
- * | `id` | `string` | The id of the view to rename |
631
- * | `name` | `string` | New display name (non-empty after trimming) |
632
- */
633
- export const PluginPresentationViewsRenameArgs = z.object({
634
- id: z.string(),
635
- name: z.string().trim().min(1),
636
- })
637
- export type PluginPresentationViewsRenameArgs = z.infer<
638
- typeof PluginPresentationViewsRenameArgs
639
- >
640
-
641
- /** Result of {@linkcode PluginPresentationViewsApi.rename} — the renamed view. */
642
- export const PluginPresentationViewsRenameResult = PluginPresentationView
643
- export type PluginPresentationViewsRenameResult = z.infer<
644
- typeof PluginPresentationViewsRenameResult
645
- >
646
-
647
- /**
648
- * Arguments for {@linkcode PluginPresentationViewsApi.delete}.
649
- *
650
- * | Property | Type | Description |
651
- * |---|---|---|
652
- * | `id` | `string` | The id of the view to delete |
653
- */
654
- export const PluginPresentationViewsDeleteArgs = z.object({
655
- id: z.string(),
656
- })
657
- export type PluginPresentationViewsDeleteArgs = z.infer<
658
- typeof PluginPresentationViewsDeleteArgs
659
- >
660
-
661
- /**
662
- * Result of {@linkcode PluginPresentationViewsApi.delete}.
663
- *
664
- * | Property | Type | Description |
665
- * |---|---|---|
666
- * | `id` | `string` | Id of the deleted view |
667
- */
668
- export const PluginPresentationViewsDeleteResult = z.object({
669
- id: z.string(),
670
- })
671
- export type PluginPresentationViewsDeleteResult = z.infer<
672
- typeof PluginPresentationViewsDeleteResult
673
- >
1
+ import * as z from "zod"
2
+ import { PluginApiReturn } from "../../types"
3
+
4
+ /**
5
+ * Presentation views — read the saved plan, 3D, and elevation views used to prepare presentations.
6
+ *
7
+ * A **view** is a saved camera/plan: a sheet-ready 2D plan or a saved 3D view.
8
+ * A plugin can list and read views, capture them to images, activate one (move
9
+ * the camera to it), save the current camera as a new view, rename or delete a
10
+ * saved view, and read/update a view's display settings (background, color
11
+ * mode, view mode, axis, edges, labels). Each view carries the `storey` it was
12
+ * saved on.
13
+ *
14
+ * `list`/`get`/`getActive`/`capture`/`getSettings` are reads;
15
+ * `setActive`/`create`/`rename`/`delete`/`updateSettings` are writes (a view is
16
+ * a camera bookmark — not geometry).
17
+ *
18
+ * Accessed via `snaptrude.presentation.views`.
19
+ */
20
+ export abstract class PluginPresentationViewsApi {
21
+ constructor() {}
22
+
23
+ /**
24
+ * List the saved views in the active project.
25
+ *
26
+ * @returns A {@linkcode PluginPresentationViewsListResult} with a `views` array
27
+ * of plan, 3D, and elevation views (empty when the project has none).
28
+ *
29
+ * @examplePrompt List all the saved views
30
+ * @examplePrompt What plan, 3D, and elevation views are in this project?
31
+ * @examplePrompt Which view is currently active?
32
+ * @examplePrompt Get the names of every presentation view
33
+ * @examplePrompt Show me the 3D views I can put on a sheet
34
+ *
35
+ * # Example
36
+ * ```ts
37
+ * const { views } = await snaptrude.presentation.views.list()
38
+ * const active = views.find((v) => v.isActive)
39
+ * const plans = views.filter((v) => v.type === "2d")
40
+ * ```
41
+ */
42
+ public abstract list(): PluginApiReturn<PluginPresentationViewsListResult>
43
+
44
+ /**
45
+ * Get a single saved view by id.
46
+ *
47
+ * @param viewId - The id of the view to read.
48
+ * @returns The matching {@linkcode PluginPresentationView}, or `null` if no view
49
+ * has that id.
50
+ *
51
+ * @examplePrompt Get the view with id view_12345
52
+ * @examplePrompt Find the saved view called Ground Floor Plan
53
+ * @examplePrompt Look up a presentation view by its id
54
+ *
55
+ * # Example
56
+ * ```ts
57
+ * const view = await snaptrude.presentation.views.get("view_123")
58
+ * ```
59
+ */
60
+ public abstract get(
61
+ viewId: string,
62
+ ): PluginApiReturn<PluginPresentationViewsGetResult>
63
+
64
+ /**
65
+ * Get the currently active view.
66
+ *
67
+ * @returns The active {@linkcode PluginPresentationView}, or `null` if none is
68
+ * active.
69
+ *
70
+ * @examplePrompt Which view is active right now?
71
+ * @examplePrompt Get the current view
72
+ * @examplePrompt What view am I looking at?
73
+ *
74
+ * # Example
75
+ * ```ts
76
+ * const active = await snaptrude.presentation.views.getActive()
77
+ * ```
78
+ */
79
+ public abstract getActive(): PluginApiReturn<PluginPresentationViewsGetResult>
80
+
81
+ /**
82
+ * Capture a screenshot of a view as a base64 image.
83
+ *
84
+ * Captures the **current** viewport by default; pass `viewId` to capture a
85
+ * specific saved view (which briefly applies that view to the scene). Use
86
+ * `format`/`resolution` to control the output. This shoots the Design (3D)
87
+ * canvas; to screenshot the Present canvas use
88
+ * {@linkcode PluginPresentationCameraApi.capture}.
89
+ *
90
+ * @param options - All optional: `viewId` (capture this saved view; omit for the
91
+ * current viewport), `format` (default `"png"`), `resolution` (e.g. `"1280x720"`).
92
+ * @returns A {@linkcode PluginPresentationViewsCaptureResult} with the base64
93
+ * `image` data URL.
94
+ * @throws If a given `viewId` does not exist.
95
+ *
96
+ * @examplePrompt Take a screenshot of the current view
97
+ * @examplePrompt Capture this view as a PNG
98
+ * @examplePrompt Render the Site Plan view to an image
99
+ * @examplePrompt Export a high-res image of what I'm looking at
100
+ *
101
+ * # Example
102
+ * ```ts
103
+ * const { image } = await snaptrude.presentation.views.capture({ format: "png" })
104
+ * ```
105
+ */
106
+ public abstract capture(options?: {
107
+ viewId?: string
108
+ format?: "png" | "jpeg"
109
+ resolution?: string
110
+ }): PluginApiReturn<PluginPresentationViewsCaptureResult>
111
+
112
+ /**
113
+ * Activate a saved view — move the camera to it and restore its scene state.
114
+ *
115
+ * Applies the view's camera, visibility, and storey state to the live scene.
116
+ * Paired with {@linkcode PluginPresentationViewsApi.getActive}.
117
+ *
118
+ * While Present is open this sets the Design frame a view saved in Present
119
+ * is taken from; it never moves the Present sheet canvas; use
120
+ * `presentation.camera` for that.
121
+ *
122
+ * @param viewId - The id of the view to activate.
123
+ * @returns The id of the now-active view.
124
+ * @throws If no view has the given id.
125
+ *
126
+ * @examplePrompt Switch to the Ground Floor plan view
127
+ * @examplePrompt Make the 3D view active
128
+ * @examplePrompt Go to the view named Entrance
129
+ * @examplePrompt Load the site plan view
130
+ *
131
+ * # Example
132
+ * ```ts
133
+ * await snaptrude.presentation.views.setActive("view_123")
134
+ * ```
135
+ */
136
+ public abstract setActive(
137
+ viewId: string,
138
+ ): PluginApiReturn<PluginPresentationViewsSetActiveResult>
139
+
140
+ /**
141
+ * Save the current camera/scene state as a new named view.
142
+ *
143
+ * Creates a camera bookmark (not geometry) from where the camera is now.
144
+ *
145
+ * Works while Present mode is open. Present draws its drawings on the same
146
+ * 3D scene, so a view saved in Present takes its framing (camera, 2D or 3D
147
+ * mode, projection, storey, building) from the Design frame instead: the one
148
+ * the user had when Present opened, or one a plugin set since with
149
+ * `setActive`, `updateSettings({ viewMode })`, `core.camera`, `core.zoom`,
150
+ * `core.storeys.setActive`, `core.storeys.layers.setActive` or
151
+ * `core.buildings.setActive`. It never moves the Present sheet canvas; use
152
+ * `presentation.camera` for that.
153
+ *
154
+ * @param name - Name for the new view (a default is used when omitted).
155
+ * @param options - Optional `kind` (what kind of view to save, default
156
+ * `"view"`) and `storey` (save the view on a specific storey — the storey is
157
+ * activated first, matching the storey the view is captured on; when omitted
158
+ * the current active storey is used).
159
+ * @returns The newly created {@linkcode PluginPresentationView}.
160
+ * @throws If `storey` is given but no such storey exists, or the view could
161
+ * not be saved.
162
+ *
163
+ * @examplePrompt Save the current view as Lobby Perspective
164
+ * @examplePrompt Create a new saved view from where I'm looking
165
+ * @examplePrompt Bookmark this camera angle
166
+ * @examplePrompt Save the current 2D plan as a view
167
+ * @examplePrompt Save a view on the second storey
168
+ *
169
+ * # Example
170
+ * ```ts
171
+ * const view = await snaptrude.presentation.views.create("Lobby")
172
+ * // …or capture the view on a specific storey
173
+ * const level2 = await snaptrude.presentation.views.create("Level 2", { storey: 2 })
174
+ * ```
175
+ */
176
+ public abstract create(
177
+ name?: string,
178
+ options?: { kind?: "view" | "sitePlan"; storey?: number },
179
+ ): PluginApiReturn<PluginPresentationViewsCreateResult>
180
+
181
+ /**
182
+ * Read a saved view's display settings (background, color mode, view mode,
183
+ * axis, edges, labels).
184
+ *
185
+ * @param viewId - The id of the view to read settings for.
186
+ * @returns The view's {@linkcode PluginPresentationViewSettings}, or `null` if
187
+ * no view has that id.
188
+ *
189
+ * @examplePrompt What color mode is the Ground Floor view using?
190
+ * @examplePrompt Get the display settings for this view
191
+ * @examplePrompt Does the site plan view show axes and labels?
192
+ * @examplePrompt Read the background color of the active view
193
+ *
194
+ * # Example
195
+ * ```ts
196
+ * const settings = await snaptrude.presentation.views.getSettings("view_123")
197
+ * if (settings) console.log(settings.colorMode, settings.backgroundColor)
198
+ * ```
199
+ */
200
+ public abstract getSettings(
201
+ viewId: string,
202
+ ): PluginApiReturn<PluginPresentationViewsGetSettingsResult>
203
+
204
+ /**
205
+ * Update a saved view's display settings (partial patch — only the fields you
206
+ * pass change).
207
+ *
208
+ * Persists and broadcasts the change; if the view is currently active, the
209
+ * scene updates live. **Not Ctrl+Z-undoable** — view-metadata edits publish
210
+ * directly and do not land on the local undo stack; this matches how the
211
+ * product's own view-settings UI behaves.
212
+ *
213
+ * Label patch semantics (mirroring the product, which stores no label
214
+ * selection while labels are off):
215
+ *
216
+ * - `{ showLabels: true }` alone turns labels on; if the view has no stored
217
+ * selection, the product defaults (`objectLabels`, `areas`) are applied —
218
+ * labels are never "on" with an empty selection (the product has no such
219
+ * state; labels render only while the selection is non-empty).
220
+ * - `{ labels: [...] }` alone sets the selection **and turns labels on**.
221
+ * - `{ showLabels: false }` turns labels off and **clears the stored
222
+ * selection** — a later read returns `labels: []`.
223
+ * - `{ showLabels: false, labels: [...] }` with a non-empty list is
224
+ * contradictory and **rejected** (nothing is silently discarded).
225
+ * - `{ showLabels: true, labels: [] }` is likewise contradictory and
226
+ * **rejected** — pass a non-empty list, or omit `labels` to get the
227
+ * defaults.
228
+ *
229
+ * `colorMode` accepts the `tag:<categoryId>` scheme strings returned by
230
+ * {@linkcode PluginPresentationViewsApi.getSettings}, so read-then-write
231
+ * round-trips a tag-based color scheme unchanged.
232
+ *
233
+ * `viewMode` (`"perspective"` | `"isometric"`) applies to **3D views only** —
234
+ * a 2D plan is always orthographic, so a `viewMode: "perspective"` patch on a
235
+ * 2D view is rejected. `"isometric"` on a 2D plan is accepted as a no-op (the
236
+ * plan is already orthographic), so writing back exactly what
237
+ * {@linkcode PluginPresentationViewsApi.getSettings} returned is always a
238
+ * no-op. On the active view the camera switches projection live (the same
239
+ * toggle the view-settings modal runs); on other views the mode is applied
240
+ * the next time the view is activated.
241
+ *
242
+ * @param viewId - The id of the view to update.
243
+ * @param settings - A partial {@linkcode PluginPresentationViewSettings}; any
244
+ * omitted field is left unchanged.
245
+ * @returns The updated view's `id`.
246
+ * @throws If writes are disabled, no view has the given id, the patch is
247
+ * contradictory (`showLabels: false` with a non-empty `labels`, or
248
+ * `showLabels: true` with an explicitly empty `labels` list), or
249
+ * `viewMode: "perspective"` is patched on a 2D plan view.
250
+ *
251
+ * @examplePrompt Switch this view to monochrome color mode
252
+ * @examplePrompt Turn off the axis in the Ground Floor view
253
+ * @examplePrompt Set the background of the active view to white
254
+ * @examplePrompt Show area labels on this view
255
+ * @examplePrompt Enable hidden-line mode for the section view
256
+ * @examplePrompt Make the 3D view orthographic instead of perspective
257
+ *
258
+ * # Example
259
+ * ```ts
260
+ * await snaptrude.presentation.views.updateSettings("view_123", {
261
+ * colorMode: "monochrome",
262
+ * showAxis: false,
263
+ * })
264
+ * // switch a 3D view to an isometric (orthographic) projection
265
+ * await snaptrude.presentation.views.updateSettings("view_123", {
266
+ * viewMode: "isometric",
267
+ * })
268
+ * ```
269
+ */
270
+ public abstract updateSettings(
271
+ viewId: string,
272
+ settings: Partial<PluginPresentationViewSettings>,
273
+ ): PluginApiReturn<PluginPresentationViewsUpdateSettingsResult>
274
+
275
+ /**
276
+ * Rename a saved view.
277
+ *
278
+ * Sets the view's display name — the same label the views panel shows and
279
+ * that `list`/`get` read back. Names must be unique within the proposal and
280
+ * cannot contain the characters `\ : { } [ ] | ; < > ? ~`.
281
+ *
282
+ * @param viewId - The id of the view to rename.
283
+ * @param name - The new display name (non-empty after trimming).
284
+ * @returns The updated {@linkcode PluginPresentationView}.
285
+ * @throws If writes are disabled, no view has the given id, the name is
286
+ * empty/invalid, or another view in the proposal already has that name.
287
+ *
288
+ * @examplePrompt Rename the view Lobby to Entrance Lobby
289
+ * @examplePrompt Call this view Ground Floor Plan
290
+ * @examplePrompt Change the active view's name to Final
291
+ *
292
+ * # Example
293
+ * ```ts
294
+ * const view = await snaptrude.presentation.views.rename("view_123", "Entrance")
295
+ * ```
296
+ */
297
+ public abstract rename(
298
+ viewId: string,
299
+ name: string,
300
+ ): PluginApiReturn<PluginPresentationViewsRenameResult>
301
+
302
+ /**
303
+ * Delete a saved view.
304
+ *
305
+ * Removes the view from the project and the views panel (the panel's own
306
+ * delete action). If the deleted view was active, the product falls back to
307
+ * the default plan/3D view. Default views (the built-in plan/3D/site-plan
308
+ * entries) cannot be deleted.
309
+ *
310
+ * @param viewId - The id of the view to delete.
311
+ * @returns The id of the deleted view
312
+ * (a {@linkcode PluginPresentationViewsDeleteResult}).
313
+ * @throws If writes are disabled, no view has the given id, or the view is a
314
+ * default view.
315
+ *
316
+ * @examplePrompt Delete the view named Old Draft
317
+ * @examplePrompt Remove this saved view
318
+ * @examplePrompt Get rid of the Lobby camera bookmark
319
+ *
320
+ * # Example
321
+ * ```ts
322
+ * const { id } = await snaptrude.presentation.views.delete("view_123")
323
+ * ```
324
+ */
325
+ public abstract delete(
326
+ viewId: string,
327
+ ): PluginApiReturn<PluginPresentationViewsDeleteResult>
328
+ }
329
+
330
+ /**
331
+ * The rendering category of a saved view. Existing plan/3D values are preserved;
332
+ * elevations are identified independently of their orthographic 3D camera.
333
+ */
334
+ export const PluginPresentationViewType = z.enum(["2d", "3d", "elevation"])
335
+ export type PluginPresentationViewType = z.infer<
336
+ typeof PluginPresentationViewType
337
+ >
338
+
339
+ /** The native semantic kind persisted for a saved view. */
340
+ export const PluginPresentationViewKind = z.enum([
341
+ "plan",
342
+ "sitePlan",
343
+ "threeD",
344
+ "elevation",
345
+ ])
346
+ export type PluginPresentationViewKind = z.infer<
347
+ typeof PluginPresentationViewKind
348
+ >
349
+
350
+ /** Cardinal direction for an elevation; non-elevation views return `null`. */
351
+ export const PluginPresentationElevationDirection = z.enum([
352
+ "north",
353
+ "east",
354
+ "south",
355
+ "west",
356
+ ])
357
+ export type PluginPresentationElevationDirection = z.infer<
358
+ typeof PluginPresentationElevationDirection
359
+ >
360
+
361
+ /**
362
+ * A saved presentation view.
363
+ *
364
+ * | Property | Type | Description |
365
+ * |---|---|---|
366
+ * | `id` | `string` | Unique view id |
367
+ * | `name` | `string` | Display name |
368
+ * | `type` | `"2d" \| "3d" \| "elevation"` | Rendering category; elevations are distinct from ordinary 3D views |
369
+ * | `kind` | {@linkcode PluginPresentationViewKind} | Native semantic view kind |
370
+ * | `direction` | {@linkcode PluginPresentationElevationDirection}` \| null` | Cardinal direction for elevations; otherwise `null` |
371
+ * | `isActive` | `boolean` | Whether this view is the currently active view |
372
+ * | `storey` | `number \| null` | The storey this view was saved on (`null` on older views saved without one) |
373
+ */
374
+ export const PluginPresentationView = z.object({
375
+ id: z.string(),
376
+ name: z.string(),
377
+ type: PluginPresentationViewType,
378
+ kind: PluginPresentationViewKind,
379
+ direction: PluginPresentationElevationDirection.nullable(),
380
+ isActive: z.boolean(),
381
+ storey: z.number().nullable(),
382
+ })
383
+ export type PluginPresentationView = z.infer<typeof PluginPresentationView>
384
+
385
+ /**
386
+ * Result of {@linkcode PluginPresentationViewsApi.list}.
387
+ *
388
+ * | Property | Type | Description |
389
+ * |---|---|---|
390
+ * | `views` | {@linkcode PluginPresentationView}`[]` | All saved views in the project |
391
+ */
392
+ export const PluginPresentationViewsListResult = z.object({
393
+ views: z.array(PluginPresentationView),
394
+ })
395
+ export type PluginPresentationViewsListResult = z.infer<
396
+ typeof PluginPresentationViewsListResult
397
+ >
398
+
399
+ /**
400
+ * Arguments for {@linkcode PluginPresentationViewsApi.get}.
401
+ *
402
+ * | Property | Type | Description |
403
+ * |---|---|---|
404
+ * | `id` | `string` | The id of the view to read |
405
+ */
406
+ export const PluginPresentationViewsGetArgs = z.object({
407
+ id: z.string(),
408
+ })
409
+ export type PluginPresentationViewsGetArgs = z.infer<
410
+ typeof PluginPresentationViewsGetArgs
411
+ >
412
+
413
+ /**
414
+ * Result of {@linkcode PluginPresentationViewsApi.get} and
415
+ * {@linkcode PluginPresentationViewsApi.getActive} — the view, or `null` when
416
+ * there is no match / no active view.
417
+ */
418
+ export const PluginPresentationViewsGetResult =
419
+ PluginPresentationView.nullable()
420
+ export type PluginPresentationViewsGetResult = z.infer<
421
+ typeof PluginPresentationViewsGetResult
422
+ >
423
+
424
+ /** Image format for {@linkcode PluginPresentationViewsApi.capture}. */
425
+ export const PluginPresentationImageFormat = z.enum(["png", "jpeg"])
426
+ export type PluginPresentationImageFormat = z.infer<
427
+ typeof PluginPresentationImageFormat
428
+ >
429
+
430
+ /**
431
+ * Arguments for {@linkcode PluginPresentationViewsApi.capture}. All optional.
432
+ *
433
+ * | Property | Type | Description |
434
+ * |---|---|---|
435
+ * | `viewId` | `string \| undefined` | Capture this saved view; omit to capture the current viewport |
436
+ * | `format` | `"png" \| "jpeg" \| undefined` | Output image format (default `"png"`) |
437
+ * | `resolution` | `string \| undefined` | Optional resolution hint (e.g. `"1280x720"`) |
438
+ */
439
+ export const PluginPresentationViewsCaptureArgs = z.object({
440
+ viewId: z.string().optional(),
441
+ format: PluginPresentationImageFormat.optional(),
442
+ resolution: z.string().optional(),
443
+ })
444
+ export type PluginPresentationViewsCaptureArgs = z.infer<
445
+ typeof PluginPresentationViewsCaptureArgs
446
+ >
447
+
448
+ /**
449
+ * Result of {@linkcode PluginPresentationViewsApi.capture}.
450
+ *
451
+ * | Property | Type | Description |
452
+ * |---|---|---|
453
+ * | `image` | `string` | The captured image as a base64 data URL |
454
+ */
455
+ export const PluginPresentationViewsCaptureResult = z.object({
456
+ image: z.string(),
457
+ })
458
+ export type PluginPresentationViewsCaptureResult = z.infer<
459
+ typeof PluginPresentationViewsCaptureResult
460
+ >
461
+
462
+ /**
463
+ * Arguments for {@linkcode PluginPresentationViewsApi.setActive}.
464
+ *
465
+ * | Property | Type | Description |
466
+ * |---|---|---|
467
+ * | `id` | `string` | The id of the view to activate |
468
+ */
469
+ export const PluginPresentationViewsSetActiveArgs = z.object({
470
+ id: z.string(),
471
+ })
472
+ export type PluginPresentationViewsSetActiveArgs = z.infer<
473
+ typeof PluginPresentationViewsSetActiveArgs
474
+ >
475
+
476
+ /** Result of {@linkcode PluginPresentationViewsApi.setActive} — the active view's id. */
477
+ export const PluginPresentationViewsSetActiveResult = z.object({
478
+ id: z.string(),
479
+ })
480
+ export type PluginPresentationViewsSetActiveResult = z.infer<
481
+ typeof PluginPresentationViewsSetActiveResult
482
+ >
483
+
484
+ /**
485
+ * Arguments for {@linkcode PluginPresentationViewsApi.create}. All optional.
486
+ *
487
+ * | Property | Type | Description |
488
+ * |---|---|---|
489
+ * | `name` | `string \| undefined` | Name for the new view (a default is used when omitted) |
490
+ * | `kind` | `"view" \| "sitePlan" \| undefined` | What kind of view to save (default `"view"`). `"plan"` is not offered — the host cannot create a plan view without a `planId` this API does not carry. |
491
+ * | `storey` | `number \| undefined` | Save the view on this storey (activated before capture); defaults to the current active storey |
492
+ */
493
+ export const PluginPresentationViewsCreateArgs = z.object({
494
+ name: z.string().optional(),
495
+ kind: z.enum(["view", "sitePlan"]).optional(),
496
+ storey: z.number().optional(),
497
+ })
498
+ export type PluginPresentationViewsCreateArgs = z.infer<
499
+ typeof PluginPresentationViewsCreateArgs
500
+ >
501
+
502
+ /** Result of {@linkcode PluginPresentationViewsApi.create} — the saved view. */
503
+ export const PluginPresentationViewsCreateResult = PluginPresentationView
504
+ export type PluginPresentationViewsCreateResult = z.infer<
505
+ typeof PluginPresentationViewsCreateResult
506
+ >
507
+
508
+ /**
509
+ * How the scene is colored in a view.
510
+ *
511
+ * | Value | Meaning |
512
+ * |---|---|
513
+ * | `monochrome` | Flat single-tone shading |
514
+ * | `texture` | Material textures/colors |
515
+ * | `department` | Colored by department |
516
+ * | `tag:<categoryId>` | Colored by a project tag category (e.g. `tag:ZONE`) |
517
+ *
518
+ * The `tag:<categoryId>` form carries the product's tag-based color schemes
519
+ * losslessly — reading a view that uses one returns the `tag:` string as-is,
520
+ * and writing it back preserves the scheme (read-then-write is safe).
521
+ */
522
+ export const PluginPresentationViewColorMode = z.union([
523
+ z.enum(["monochrome", "texture", "department"]),
524
+ z.templateLiteral(["tag:", z.string()]),
525
+ ])
526
+ export type PluginPresentationViewColorMode = z.infer<
527
+ typeof PluginPresentationViewColorMode
528
+ >
529
+
530
+ /**
531
+ * A category of on-canvas labels a view can show.
532
+ *
533
+ * | Value | Meaning |
534
+ * |---|---|
535
+ * | `objectLabels` | Per-object name labels |
536
+ * | `areas` | Area/room labels |
537
+ * | `department` | Department labels |
538
+ */
539
+ export const PluginPresentationViewLabel = z.enum([
540
+ "objectLabels",
541
+ "areas",
542
+ "department",
543
+ ])
544
+ export type PluginPresentationViewLabel = z.infer<
545
+ typeof PluginPresentationViewLabel
546
+ >
547
+
548
+ /**
549
+ * A view's camera projection: perspective, or isometric (orthographic).
550
+ *
551
+ * | Value | Meaning |
552
+ * |---|---|
553
+ * | `perspective` | Perspective projection (vanishing points) |
554
+ * | `isometric` | Orthographic projection (no perspective distortion) |
555
+ *
556
+ * Applies to 3D views; a 2D plan view is always orthographic and reads
557
+ * `"isometric"`.
558
+ */
559
+ export const PluginPresentationViewMode = z.enum(["perspective", "isometric"])
560
+ export type PluginPresentationViewMode = z.infer<
561
+ typeof PluginPresentationViewMode
562
+ >
563
+
564
+ /**
565
+ * A view's display settings.
566
+ *
567
+ * | Property | Type | Description |
568
+ * |---|---|---|
569
+ * | `backgroundColor` | `string` | Canvas background as a hex color (e.g. `#ffffff`) |
570
+ * | `colorMode` | {@linkcode PluginPresentationViewColorMode} | How the scene is colored (including `tag:<categoryId>` schemes) |
571
+ * | `viewMode` | {@linkcode PluginPresentationViewMode} | Camera projection — `"perspective"` or `"isometric"` (orthographic). Writable on 3D views only; a 2D plan always reads `"isometric"` and accepts only `"isometric"` (a no-op) |
572
+ * | `showAxis` | `boolean` | Whether the X/Y/Z axes are shown |
573
+ * | `showEdges` | `boolean` | Whether edges are shown; `false` = hidden-line rendering |
574
+ * | `showLabels` | `boolean` | Master label switch — whether on-canvas labels are shown at all. `true` always pairs with a non-empty `labels` selection (labels render only while the selection is non-empty; there is no labels-on-with-empty-selection state) |
575
+ * | `labels` | {@linkcode PluginPresentationViewLabel}`[]` | Which label categories are selected. When `showLabels` is `false` the view stores no selection and this reads `[]` |
576
+ */
577
+ export const PluginPresentationViewSettings = z.object({
578
+ backgroundColor: z.string(),
579
+ colorMode: PluginPresentationViewColorMode,
580
+ viewMode: PluginPresentationViewMode,
581
+ showAxis: z.boolean(),
582
+ showEdges: z.boolean(),
583
+ showLabels: z.boolean(),
584
+ labels: z.array(PluginPresentationViewLabel),
585
+ })
586
+ export type PluginPresentationViewSettings = z.infer<
587
+ typeof PluginPresentationViewSettings
588
+ >
589
+
590
+ /**
591
+ * Arguments for {@linkcode PluginPresentationViewsApi.getSettings}.
592
+ *
593
+ * | Property | Type | Description |
594
+ * |---|---|---|
595
+ * | `id` | `string` | The id of the view to read settings for |
596
+ */
597
+ export const PluginPresentationViewsGetSettingsArgs = z.object({
598
+ id: z.string(),
599
+ })
600
+ export type PluginPresentationViewsGetSettingsArgs = z.infer<
601
+ typeof PluginPresentationViewsGetSettingsArgs
602
+ >
603
+
604
+ /**
605
+ * Result of {@linkcode PluginPresentationViewsApi.getSettings} — the settings,
606
+ * or `null` when no view has that id.
607
+ */
608
+ export const PluginPresentationViewsGetSettingsResult =
609
+ PluginPresentationViewSettings.nullable()
610
+ export type PluginPresentationViewsGetSettingsResult = z.infer<
611
+ typeof PluginPresentationViewsGetSettingsResult
612
+ >
613
+
614
+ /**
615
+ * Arguments for {@linkcode PluginPresentationViewsApi.updateSettings}. The
616
+ * `settings` patch is partial — any omitted field is left unchanged. A patch
617
+ * pairing `showLabels: false` with a non-empty `labels` list, or
618
+ * `showLabels: true` with an explicitly empty `labels` list, is rejected as
619
+ * contradictory (see the method JSDoc for the full label patch semantics).
620
+ *
621
+ * | Property | Type | Description |
622
+ * |---|---|---|
623
+ * | `id` | `string` | The id of the view to update |
624
+ * | `settings` | `Partial<`{@linkcode PluginPresentationViewSettings}`>` | The fields to change |
625
+ */
626
+ export const PluginPresentationViewsUpdateSettingsArgs = z
627
+ .object({
628
+ id: z.string(),
629
+ settings: PluginPresentationViewSettings.partial(),
630
+ })
631
+ .refine(
632
+ (v) =>
633
+ !(
634
+ v.settings.showLabels === false && (v.settings.labels?.length ?? 0) > 0
635
+ ),
636
+ {
637
+ message:
638
+ "Contradictory patch: labels cannot be set while showLabels is false",
639
+ },
640
+ )
641
+ .refine(
642
+ (v) =>
643
+ !(
644
+ v.settings.showLabels === true &&
645
+ v.settings.labels !== undefined &&
646
+ v.settings.labels.length === 0
647
+ ),
648
+ {
649
+ message:
650
+ "Contradictory patch: showLabels cannot be true with an explicitly empty labels list — pass a non-empty list, or omit labels to apply the defaults",
651
+ },
652
+ )
653
+ export type PluginPresentationViewsUpdateSettingsArgs = z.infer<
654
+ typeof PluginPresentationViewsUpdateSettingsArgs
655
+ >
656
+
657
+ /** Result of {@linkcode PluginPresentationViewsApi.updateSettings} — the updated view's id. */
658
+ export const PluginPresentationViewsUpdateSettingsResult = z.object({
659
+ id: z.string(),
660
+ })
661
+ export type PluginPresentationViewsUpdateSettingsResult = z.infer<
662
+ typeof PluginPresentationViewsUpdateSettingsResult
663
+ >
664
+
665
+ /**
666
+ * Arguments for {@linkcode PluginPresentationViewsApi.rename}.
667
+ *
668
+ * | Property | Type | Description |
669
+ * |---|---|---|
670
+ * | `id` | `string` | The id of the view to rename |
671
+ * | `name` | `string` | New display name (non-empty after trimming) |
672
+ */
673
+ export const PluginPresentationViewsRenameArgs = z.object({
674
+ id: z.string(),
675
+ name: z.string().trim().min(1),
676
+ })
677
+ export type PluginPresentationViewsRenameArgs = z.infer<
678
+ typeof PluginPresentationViewsRenameArgs
679
+ >
680
+
681
+ /** Result of {@linkcode PluginPresentationViewsApi.rename} — the renamed view. */
682
+ export const PluginPresentationViewsRenameResult = PluginPresentationView
683
+ export type PluginPresentationViewsRenameResult = z.infer<
684
+ typeof PluginPresentationViewsRenameResult
685
+ >
686
+
687
+ /**
688
+ * Arguments for {@linkcode PluginPresentationViewsApi.delete}.
689
+ *
690
+ * | Property | Type | Description |
691
+ * |---|---|---|
692
+ * | `id` | `string` | The id of the view to delete |
693
+ */
694
+ export const PluginPresentationViewsDeleteArgs = z.object({
695
+ id: z.string(),
696
+ })
697
+ export type PluginPresentationViewsDeleteArgs = z.infer<
698
+ typeof PluginPresentationViewsDeleteArgs
699
+ >
700
+
701
+ /**
702
+ * Result of {@linkcode PluginPresentationViewsApi.delete}.
703
+ *
704
+ * | Property | Type | Description |
705
+ * |---|---|---|
706
+ * | `id` | `string` | Id of the deleted view |
707
+ */
708
+ export const PluginPresentationViewsDeleteResult = z.object({
709
+ id: z.string(),
710
+ })
711
+ export type PluginPresentationViewsDeleteResult = z.infer<
712
+ typeof PluginPresentationViewsDeleteResult
713
+ >