@snaptrude/plugin-core 0.0.0-dev-20260708130115 → 0.0.0-dev-20260827135706

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 (261) hide show
  1. package/CHANGELOG.md +152 -1
  2. package/api-manifest.json +3620 -276
  3. package/dist/api/analysis/daylight.d.ts +603 -0
  4. package/dist/api/analysis/daylight.d.ts.map +1 -0
  5. package/dist/api/analysis/heatmaps.d.ts +658 -0
  6. package/dist/api/analysis/heatmaps.d.ts.map +1 -0
  7. package/dist/api/analysis/illuminance.d.ts +145 -0
  8. package/dist/api/analysis/illuminance.d.ts.map +1 -0
  9. package/dist/api/analysis/index.d.ts +59 -0
  10. package/dist/api/analysis/index.d.ts.map +1 -0
  11. package/dist/api/analysis/shadows.d.ts +165 -0
  12. package/dist/api/analysis/shadows.d.ts.map +1 -0
  13. package/dist/api/analysis/solar.d.ts +249 -0
  14. package/dist/api/analysis/solar.d.ts.map +1 -0
  15. package/dist/api/analysis/sunlightHours.d.ts +208 -0
  16. package/dist/api/analysis/sunlightHours.d.ts.map +1 -0
  17. package/dist/api/analysis/sunpath.d.ts +80 -0
  18. package/dist/api/analysis/sunpath.d.ts.map +1 -0
  19. package/dist/api/analysis/weather.d.ts +193 -0
  20. package/dist/api/analysis/weather.d.ts.map +1 -0
  21. package/dist/api/core/camera/index.d.ts +261 -0
  22. package/dist/api/core/camera/index.d.ts.map +1 -0
  23. package/dist/api/core/comment/index.d.ts +105 -2
  24. package/dist/api/core/comment/index.d.ts.map +1 -1
  25. package/dist/api/core/geom/create/index.d.ts +840 -14
  26. package/dist/api/core/geom/create/index.d.ts.map +1 -1
  27. package/dist/api/core/geom/delete/index.d.ts +8 -2
  28. package/dist/api/core/geom/delete/index.d.ts.map +1 -1
  29. package/dist/api/core/geom/query/arc.d.ts +5 -5
  30. package/dist/api/core/geom/query/brep.d.ts +130 -18
  31. package/dist/api/core/geom/query/brep.d.ts.map +1 -1
  32. package/dist/api/core/geom/query/circle.d.ts +18 -18
  33. package/dist/api/core/geom/query/contour.d.ts +20 -20
  34. package/dist/api/core/geom/query/curve.d.ts +49 -49
  35. package/dist/api/core/geom/query/edge.d.ts +5 -5
  36. package/dist/api/core/geom/query/face.d.ts +16 -16
  37. package/dist/api/core/geom/query/halfedge.d.ts +8 -8
  38. package/dist/api/core/geom/query/profile.d.ts +19 -19
  39. package/dist/api/core/geom/query/vertex.d.ts +8 -8
  40. package/dist/api/core/geom/update/contour.d.ts +14 -14
  41. package/dist/api/core/geom/update/curve.d.ts +7 -7
  42. package/dist/api/core/geom/update/profile.d.ts +16 -16
  43. package/dist/api/core/handles/index.d.ts +210 -0
  44. package/dist/api/core/handles/index.d.ts.map +1 -0
  45. package/dist/api/core/index.d.ts +34 -0
  46. package/dist/api/core/index.d.ts.map +1 -1
  47. package/dist/api/core/io/export/index.d.ts +134 -0
  48. package/dist/api/core/io/export/index.d.ts.map +1 -0
  49. package/dist/api/core/io/import/index.d.ts +453 -0
  50. package/dist/api/core/io/import/index.d.ts.map +1 -0
  51. package/dist/api/core/io/index.d.ts +40 -0
  52. package/dist/api/core/io/index.d.ts.map +1 -0
  53. package/dist/api/core/io/job/index.d.ts +139 -0
  54. package/dist/api/core/io/job/index.d.ts.map +1 -0
  55. package/dist/api/core/io/query/index.d.ts +74 -0
  56. package/dist/api/core/io/query/index.d.ts.map +1 -0
  57. package/dist/api/core/io/terrain/index.d.ts +341 -0
  58. package/dist/api/core/io/terrain/index.d.ts.map +1 -0
  59. package/dist/api/core/io/underlay/index.d.ts +805 -0
  60. package/dist/api/core/io/underlay/index.d.ts.map +1 -0
  61. package/dist/api/core/layers.d.ts +7 -7
  62. package/dist/api/core/mode/index.d.ts +99 -0
  63. package/dist/api/core/mode/index.d.ts.map +1 -0
  64. package/dist/api/core/project/index.d.ts +68 -1
  65. package/dist/api/core/project/index.d.ts.map +1 -1
  66. package/dist/api/core/proposals/index.d.ts +531 -0
  67. package/dist/api/core/proposals/index.d.ts.map +1 -0
  68. package/dist/api/core/storeys/index.d.ts +265 -0
  69. package/dist/api/core/storeys/index.d.ts.map +1 -0
  70. package/dist/api/core/tags.d.ts +24 -0
  71. package/dist/api/core/tags.d.ts.map +1 -1
  72. package/dist/api/core/user.d.ts +44 -0
  73. package/dist/api/core/user.d.ts.map +1 -0
  74. package/dist/api/core/zoom/index.d.ts +4 -0
  75. package/dist/api/core/zoom/index.d.ts.map +1 -1
  76. package/dist/api/design/boolean/index.d.ts +4 -4
  77. package/dist/api/design/create/index.d.ts +568 -45
  78. package/dist/api/design/create/index.d.ts.map +1 -1
  79. package/dist/api/design/delete/index.d.ts +3 -0
  80. package/dist/api/design/delete/index.d.ts.map +1 -1
  81. package/dist/api/design/doors/index.d.ts +195 -0
  82. package/dist/api/design/doors/index.d.ts.map +1 -1
  83. package/dist/api/design/edit/index.d.ts +1 -1
  84. package/dist/api/design/erase/index.d.ts +2 -2
  85. package/dist/api/design/family.d.ts +349 -0
  86. package/dist/api/design/family.d.ts.map +1 -0
  87. package/dist/api/design/furniture/index.d.ts +181 -8
  88. package/dist/api/design/furniture/index.d.ts.map +1 -1
  89. package/dist/api/design/index.d.ts +98 -0
  90. package/dist/api/design/index.d.ts.map +1 -1
  91. package/dist/api/design/lock.d.ts +26 -0
  92. package/dist/api/design/lock.d.ts.map +1 -1
  93. package/dist/api/design/materials/index.d.ts +270 -16
  94. package/dist/api/design/materials/index.d.ts.map +1 -1
  95. package/dist/api/design/query/geometry/index.d.ts +112 -0
  96. package/dist/api/design/query/geometry/index.d.ts.map +1 -1
  97. package/dist/api/design/query/index.d.ts +282 -11
  98. package/dist/api/design/query/index.d.ts.map +1 -1
  99. package/dist/api/design/query/referenceLines.d.ts +45 -0
  100. package/dist/api/design/query/referenceLines.d.ts.map +1 -0
  101. package/dist/api/design/query/spaces.d.ts +181 -8
  102. package/dist/api/design/query/spaces.d.ts.map +1 -1
  103. package/dist/api/design/selection/index.d.ts +144 -0
  104. package/dist/api/design/selection/index.d.ts.map +1 -1
  105. package/dist/api/design/transform/index.d.ts +172 -10
  106. package/dist/api/design/transform/index.d.ts.map +1 -1
  107. package/dist/api/design/types/index.d.ts +181 -0
  108. package/dist/api/design/types/index.d.ts.map +1 -0
  109. package/dist/api/design/update/index.d.ts +553 -2
  110. package/dist/api/design/update/index.d.ts.map +1 -1
  111. package/dist/api/design/visibility.d.ts +126 -0
  112. package/dist/api/design/visibility.d.ts.map +1 -0
  113. package/dist/api/design/windows/index.d.ts +113 -2
  114. package/dist/api/design/windows/index.d.ts.map +1 -1
  115. package/dist/api/entity/buildableEnvelope.d.ts +4 -0
  116. package/dist/api/entity/buildableEnvelope.d.ts.map +1 -1
  117. package/dist/api/entity/referenceLine.d.ts +10 -2
  118. package/dist/api/entity/referenceLine.d.ts.map +1 -1
  119. package/dist/api/entity/space.d.ts +21 -21
  120. package/dist/api/entity/story.d.ts +242 -15
  121. package/dist/api/entity/story.d.ts.map +1 -1
  122. package/dist/api/index.d.ts +10 -0
  123. package/dist/api/index.d.ts.map +1 -1
  124. package/dist/api/presentation/aiInspiration.d.ts +25 -25
  125. package/dist/api/presentation/annotate.d.ts +467 -0
  126. package/dist/api/presentation/annotate.d.ts.map +1 -0
  127. package/dist/api/presentation/diagrams.d.ts +111 -8
  128. package/dist/api/presentation/diagrams.d.ts.map +1 -1
  129. package/dist/api/presentation/export.d.ts +108 -0
  130. package/dist/api/presentation/export.d.ts.map +1 -0
  131. package/dist/api/presentation/import.d.ts +55 -4
  132. package/dist/api/presentation/import.d.ts.map +1 -1
  133. package/dist/api/presentation/index.d.ts +58 -1
  134. package/dist/api/presentation/index.d.ts.map +1 -1
  135. package/dist/api/presentation/placedViews.d.ts +1139 -0
  136. package/dist/api/presentation/placedViews.d.ts.map +1 -0
  137. package/dist/api/presentation/shapes.d.ts +481 -0
  138. package/dist/api/presentation/shapes.d.ts.map +1 -0
  139. package/dist/api/presentation/sheets.d.ts +452 -13
  140. package/dist/api/presentation/sheets.d.ts.map +1 -1
  141. package/dist/api/presentation/slideshow.d.ts +125 -0
  142. package/dist/api/presentation/slideshow.d.ts.map +1 -0
  143. package/dist/api/presentation/tables.d.ts +81 -0
  144. package/dist/api/presentation/tables.d.ts.map +1 -0
  145. package/dist/api/presentation/views.d.ts +367 -7
  146. package/dist/api/presentation/views.d.ts.map +1 -1
  147. package/dist/api/program/areas.d.ts +102 -12
  148. package/dist/api/program/areas.d.ts.map +1 -1
  149. package/dist/api/program/cores.d.ts +3 -99
  150. package/dist/api/program/cores.d.ts.map +1 -1
  151. package/dist/api/program/index.d.ts +7 -15
  152. package/dist/api/program/index.d.ts.map +1 -1
  153. package/dist/api/program/layout.d.ts +346 -11
  154. package/dist/api/program/layout.d.ts.map +1 -1
  155. package/dist/api/program/site.d.ts +469 -13
  156. package/dist/api/program/site.d.ts.map +1 -1
  157. package/dist/api/program/spreadsheet.d.ts +365 -41
  158. package/dist/api/program/spreadsheet.d.ts.map +1 -1
  159. package/dist/api/workspace/index.d.ts +505 -0
  160. package/dist/api/workspace/index.d.ts.map +1 -0
  161. package/dist/errors/codes.d.ts +34 -0
  162. package/dist/errors/codes.d.ts.map +1 -0
  163. package/dist/errors/envelope.d.ts +56 -0
  164. package/dist/errors/envelope.d.ts.map +1 -0
  165. package/dist/errors/index.d.ts +6 -0
  166. package/dist/errors/index.d.ts.map +1 -0
  167. package/dist/errors/plugin-error.d.ts +69 -0
  168. package/dist/errors/plugin-error.d.ts.map +1 -0
  169. package/dist/handles.d.ts +97 -25
  170. package/dist/handles.d.ts.map +1 -1
  171. package/dist/host-utils.d.ts +4 -0
  172. package/dist/host-utils.d.ts.map +1 -1
  173. package/dist/index.cjs +4582 -1422
  174. package/dist/index.cjs.map +1 -1
  175. package/dist/index.d.ts +1 -0
  176. package/dist/index.d.ts.map +1 -1
  177. package/dist/index.js +4171 -1411
  178. package/dist/index.js.map +1 -1
  179. package/package.json +4 -2
  180. package/scripts/generate-manifest.mjs +45 -0
  181. package/scripts/generate-manifest.test.mjs +103 -4
  182. package/src/api/analysis/daylight.ts +470 -0
  183. package/src/api/analysis/heatmaps.ts +683 -0
  184. package/src/api/analysis/illuminance.ts +155 -0
  185. package/src/api/analysis/index.ts +61 -0
  186. package/src/api/analysis/shadows.ts +183 -0
  187. package/src/api/analysis/solar.ts +237 -0
  188. package/src/api/analysis/sunlightHours.ts +211 -0
  189. package/src/api/analysis/sunpath.ts +83 -0
  190. package/src/api/analysis/weather.ts +179 -0
  191. package/src/api/core/camera/index.ts +268 -0
  192. package/src/api/core/comment/index.ts +120 -2
  193. package/src/api/core/geom/create/index.ts +912 -1
  194. package/src/api/core/geom/delete/index.ts +6 -0
  195. package/src/api/core/geom/query/brep.ts +119 -0
  196. package/src/api/core/handles/index.ts +233 -0
  197. package/src/api/core/index.ts +34 -0
  198. package/src/api/core/io/export/index.ts +126 -0
  199. package/src/api/core/io/import/index.ts +496 -0
  200. package/src/api/core/io/index.ts +42 -0
  201. package/src/api/core/io/job/index.ts +140 -0
  202. package/src/api/core/io/query/index.ts +71 -0
  203. package/src/api/core/io/terrain/index.ts +360 -0
  204. package/src/api/core/io/underlay/index.ts +705 -0
  205. package/src/api/core/mode/index.ts +96 -0
  206. package/src/api/core/project/index.ts +62 -1
  207. package/src/api/core/proposals/index.ts +569 -0
  208. package/src/api/core/storeys/index.ts +294 -0
  209. package/src/api/core/tags.ts +27 -0
  210. package/src/api/core/user.ts +46 -0
  211. package/src/api/core/zoom/index.ts +4 -0
  212. package/src/api/design/create/index.ts +670 -30
  213. package/src/api/design/delete/index.ts +3 -0
  214. package/src/api/design/doors/index.ts +208 -0
  215. package/src/api/design/erase/index.ts +1 -1
  216. package/src/api/design/family.ts +388 -0
  217. package/src/api/design/furniture/index.ts +197 -8
  218. package/src/api/design/index.ts +102 -0
  219. package/src/api/design/lock.ts +27 -0
  220. package/src/api/design/materials/index.ts +334 -27
  221. package/src/api/design/query/geometry/index.ts +125 -3
  222. package/src/api/design/query/index.ts +217 -7
  223. package/src/api/design/query/referenceLines.ts +52 -0
  224. package/src/api/design/query/spaces.ts +143 -0
  225. package/src/api/design/selection/index.ts +129 -0
  226. package/src/api/design/transform/index.ts +170 -9
  227. package/src/api/design/types/index.ts +156 -0
  228. package/src/api/design/update/index.ts +631 -3
  229. package/src/api/design/visibility.ts +143 -0
  230. package/src/api/design/windows/index.ts +128 -2
  231. package/src/api/entity/buildableEnvelope.ts +4 -0
  232. package/src/api/entity/referenceLine.ts +8 -0
  233. package/src/api/entity/story.ts +259 -15
  234. package/src/api/index.ts +10 -0
  235. package/src/api/presentation/annotate.ts +385 -0
  236. package/src/api/presentation/diagrams.ts +118 -8
  237. package/src/api/presentation/export.ts +108 -0
  238. package/src/api/presentation/import.ts +51 -4
  239. package/src/api/presentation/index.ts +66 -1
  240. package/src/api/presentation/placedViews.ts +1120 -0
  241. package/src/api/presentation/shapes.ts +274 -0
  242. package/src/api/presentation/sheets.ts +400 -13
  243. package/src/api/presentation/slideshow.ts +134 -0
  244. package/src/api/presentation/tables.ts +84 -0
  245. package/src/api/presentation/views.ts +376 -8
  246. package/src/api/program/areas.ts +88 -15
  247. package/src/api/program/cores.ts +3 -91
  248. package/src/api/program/index.ts +7 -15
  249. package/src/api/program/layout.ts +365 -11
  250. package/src/api/program/site.ts +435 -13
  251. package/src/api/program/spreadsheet.ts +376 -35
  252. package/src/api/workspace/index.ts +563 -0
  253. package/src/errors/codes.ts +136 -0
  254. package/src/errors/envelope.ts +75 -0
  255. package/src/errors/index.ts +21 -0
  256. package/src/errors/plugin-error.ts +134 -0
  257. package/src/handles.ts +123 -13
  258. package/src/host-utils.ts +4 -0
  259. package/src/index.ts +1 -0
  260. package/test/errors.test.mjs +184 -0
  261. package/tsconfig.json +7 -2
@@ -0,0 +1,385 @@
1
+ import * as z from "zod"
2
+ import { PluginApiReturn } from "../../types"
3
+
4
+ /**
5
+ * Presentation annotate — add annotations to Present-mode sheets.
6
+ *
7
+ * The scriptable counterparts to the Present toolbar's annotation tools (all
8
+ * require Present mode to be open; each returns the created canvas shape id):
9
+ *
10
+ * - {@linkcode PluginPresentationAnnotateApi.text} — text labels (titles, captions)
11
+ * - {@linkcode PluginPresentationAnnotateApi.arrow} — arrows pointing between two points
12
+ * - {@linkcode PluginPresentationAnnotateApi.note} — sticky notes
13
+ * - {@linkcode PluginPresentationAnnotateApi.shape} — geo shapes (rectangle, ellipse, cloud, …)
14
+ *
15
+ * The freehand Draw tool is not scriptable (a stroke is an interactive gesture,
16
+ * not a single call) and is intentionally not exposed here.
17
+ *
18
+ * Accessed via `snaptrude.presentation.annotate`.
19
+ */
20
+ export abstract class PluginPresentationAnnotateApi {
21
+ constructor() {}
22
+
23
+ /**
24
+ * Add a text label to a sheet.
25
+ *
26
+ * Creates a text shape on the given sheet and returns the id of the created
27
+ * canvas shape. Requires Present mode to be open.
28
+ *
29
+ * Typography is optional: `fontFamily` takes a system family or any Google
30
+ * Font (loaded automatically, the same loader as the Present text panel);
31
+ * `fontWeight` is a numeric weight string like `"400"` or `"700"`,
32
+ * optionally with the `-italic` suffix (e.g. `"700-italic"`) — the Present
33
+ * text panel's value domain; a weight the chosen font does not provide
34
+ * falls back to regular. `fontSizePx` sets an exact pixel size, overriding
35
+ * the `size` preset when both are given (`size` alone keeps working).
36
+ *
37
+ * @param sheetId - The sheet to annotate.
38
+ * @param text - The label text.
39
+ * @param options - Optional `position` (`{ x, y }`, relative to the sheet's
40
+ * top-left, in canvas units — defaults to the sheet's top-left corner),
41
+ * `size` (`"s" | "m" | "l" | "xl"`, default `"m"`), `color` (a named
42
+ * palette color, default `"black"`), and typography: `fontFamily`,
43
+ * `fontWeight` (numeric string, `-italic` suffix allowed), `fontSizePx`
44
+ * (positive px size overriding the `size` preset).
45
+ * @returns A {@linkcode PluginPresentationAnnotateTextResult} with the created
46
+ * `shapeId`.
47
+ * @throws If Present mode is not open or the sheet id is invalid.
48
+ *
49
+ * @examplePrompt Add a title "Ground Floor" to Sheet 1
50
+ * @examplePrompt Label the cover sheet with the project name
51
+ * @examplePrompt Caption this view with "Proposed layout"
52
+ * @examplePrompt Put a red note on the sheet
53
+ *
54
+ * # Example
55
+ * ```ts
56
+ * const { shapeId } = await snaptrude.presentation.annotate.text(
57
+ * "sheet_1",
58
+ * "Ground Floor",
59
+ * { position: { x: 40, y: 40 }, size: "xl", color: "blue" },
60
+ * )
61
+ * ```
62
+ */
63
+ public abstract text(
64
+ sheetId: string,
65
+ text: string,
66
+ options?: {
67
+ position?: { x: number; y: number }
68
+ size?: PluginAnnotateTextSize
69
+ color?: PluginAnnotateTextColor
70
+ fontFamily?: string
71
+ fontWeight?: string
72
+ fontSizePx?: number
73
+ },
74
+ ): PluginApiReturn<PluginPresentationAnnotateTextResult>
75
+
76
+ /**
77
+ * Draw an arrow on a sheet.
78
+ *
79
+ * Creates an arrow shape from `start` to `end` (both relative to the sheet's
80
+ * top-left, in canvas units — the same Arrow tool as the Present toolbar) and
81
+ * returns the id of the created canvas shape. Requires Present mode to be open.
82
+ *
83
+ * @param sheetId - The sheet to annotate.
84
+ * @param start - Arrow tail position (`{ x, y }`, relative to the sheet's top-left).
85
+ * @param end - Arrow head position (`{ x, y }`, relative to the sheet's top-left).
86
+ * @param options - Optional `color` (a named palette color, default `"black"`)
87
+ * and `size` (stroke weight preset, `"s" | "m" | "l" | "xl"`, default `"m"`).
88
+ * @returns A {@linkcode PluginPresentationAnnotateResult} with the created
89
+ * `shapeId`.
90
+ * @throws If Present mode is not open or the sheet id is invalid.
91
+ *
92
+ * @examplePrompt Draw an arrow pointing at the entrance on Sheet 1
93
+ * @examplePrompt Add a red arrow from the title to the plan view
94
+ * @examplePrompt Point an arrow at the top-left view on the cover sheet
95
+ *
96
+ * # Example
97
+ * ```ts
98
+ * const { shapeId } = await snaptrude.presentation.annotate.arrow(
99
+ * "sheet_1",
100
+ * { x: 100, y: 200 },
101
+ * { x: 300, y: 250 },
102
+ * { color: "red" },
103
+ * )
104
+ * ```
105
+ */
106
+ public abstract arrow(
107
+ sheetId: string,
108
+ start: { x: number; y: number },
109
+ end: { x: number; y: number },
110
+ options?: {
111
+ color?: PluginAnnotateTextColor
112
+ size?: PluginAnnotateTextSize
113
+ },
114
+ ): PluginApiReturn<PluginPresentationAnnotateResult>
115
+
116
+ /**
117
+ * Add a sticky note to a sheet.
118
+ *
119
+ * Creates a note shape (the same Note tool as the Present toolbar — a
120
+ * fixed-size sticky square that grows with its text) and returns the id of
121
+ * the created canvas shape. Requires Present mode to be open.
122
+ *
123
+ * @param sheetId - The sheet to annotate.
124
+ * @param text - The note text.
125
+ * @param options - Optional `position` (`{ x, y }`, relative to the sheet's
126
+ * top-left, in canvas units — defaults to the sheet's top-left corner),
127
+ * `color` (a named palette color, default `"black"` — rendered as the
128
+ * note's sticky fill), and `size` (text size preset,
129
+ * `"s" | "m" | "l" | "xl"`, default `"m"`).
130
+ * @returns A {@linkcode PluginPresentationAnnotateResult} with the created
131
+ * `shapeId`.
132
+ * @throws If Present mode is not open or the sheet id is invalid.
133
+ *
134
+ * @examplePrompt Add a sticky note "Review this wall" to Sheet 1
135
+ * @examplePrompt Put a yellow note on the cover sheet
136
+ * @examplePrompt Leave a note next to the ground floor plan
137
+ *
138
+ * # Example
139
+ * ```ts
140
+ * const { shapeId } = await snaptrude.presentation.annotate.note(
141
+ * "sheet_1",
142
+ * "Review this wall",
143
+ * { position: { x: 60, y: 120 }, color: "yellow" },
144
+ * )
145
+ * ```
146
+ */
147
+ public abstract note(
148
+ sheetId: string,
149
+ text: string,
150
+ options?: {
151
+ position?: { x: number; y: number }
152
+ color?: PluginAnnotateTextColor
153
+ size?: PluginAnnotateTextSize
154
+ },
155
+ ): PluginApiReturn<PluginPresentationAnnotateResult>
156
+
157
+ /**
158
+ * Draw a geo shape (rectangle, ellipse, cloud, …) on a sheet.
159
+ *
160
+ * Creates a geo shape of the given `kind` — the same shapes as the Present
161
+ * toolbar's shape flyout — sized to `bounds` (relative to the sheet's
162
+ * top-left, in canvas units) and returns the id of the created canvas shape.
163
+ * Requires Present mode to be open.
164
+ *
165
+ * @param sheetId - The sheet to annotate.
166
+ * @param kind - The shape kind ({@linkcode PluginAnnotateGeoKind}), e.g.
167
+ * `"rectangle"`, `"ellipse"`, `"cloud"`.
168
+ * @param bounds - Placement box `{ x, y, w, h }` — `x`/`y` are the shape's
169
+ * top-left relative to the sheet's top-left; `w`/`h` must be positive.
170
+ * @param options - Optional `color` (a named palette color, default
171
+ * `"black"`) and `fill` ({@linkcode PluginAnnotateFill}, default `"none"` —
172
+ * outline only).
173
+ * @returns A {@linkcode PluginPresentationAnnotateResult} with the created
174
+ * `shapeId`.
175
+ * @throws If Present mode is not open or the sheet id is invalid.
176
+ *
177
+ * @examplePrompt Draw a revision cloud around the kitchen on Sheet 2
178
+ * @examplePrompt Add a red rectangle highlight to the sheet
179
+ * @examplePrompt Draw an ellipse around the entrance on the cover sheet
180
+ *
181
+ * # Example
182
+ * ```ts
183
+ * const { shapeId } = await snaptrude.presentation.annotate.shape(
184
+ * "sheet_1",
185
+ * "cloud",
186
+ * { x: 80, y: 80, w: 240, h: 160 },
187
+ * { color: "red" },
188
+ * )
189
+ * ```
190
+ */
191
+ public abstract shape(
192
+ sheetId: string,
193
+ kind: PluginAnnotateGeoKind,
194
+ bounds: { x: number; y: number; w: number; h: number },
195
+ options?: {
196
+ color?: PluginAnnotateTextColor
197
+ fill?: PluginAnnotateFill
198
+ },
199
+ ): PluginApiReturn<PluginPresentationAnnotateResult>
200
+ }
201
+
202
+ /** Text size preset (the same s/m/l/xl scale as the Present-mode text tool). */
203
+ export const PluginAnnotateTextSize = z.enum(["s", "m", "l", "xl"])
204
+ export type PluginAnnotateTextSize = z.infer<typeof PluginAnnotateTextSize>
205
+
206
+ /** Named palette color (the same swatches as the Present-mode style panel). */
207
+ export const PluginAnnotateTextColor = z.enum([
208
+ "black",
209
+ "grey",
210
+ "light-violet",
211
+ "violet",
212
+ "blue",
213
+ "light-blue",
214
+ "yellow",
215
+ "orange",
216
+ "green",
217
+ "light-green",
218
+ "light-red",
219
+ "red",
220
+ "white",
221
+ ])
222
+ export type PluginAnnotateTextColor = z.infer<typeof PluginAnnotateTextColor>
223
+
224
+ /**
225
+ * Arguments for {@linkcode PluginPresentationAnnotateApi.text}.
226
+ *
227
+ * | Property | Type | Description |
228
+ * |---|---|---|
229
+ * | `sheetId` | `string` | The sheet to annotate |
230
+ * | `text` | `string` | The label text |
231
+ * | `position` | `{ x: number; y: number } \| undefined` | Where to place it (relative to the sheet) |
232
+ * | `size` | {@linkcode PluginAnnotateTextSize}` \| undefined` | Text size preset |
233
+ * | `color` | {@linkcode PluginAnnotateTextColor}` \| undefined` | Text color |
234
+ * | `fontFamily` | `string \| undefined` | System family or any Google Font (loaded automatically) |
235
+ * | `fontWeight` | `string \| undefined` | Numeric weight like `"400"`/`"700"`, `-italic` suffix allowed |
236
+ * | `fontSizePx` | `number \| undefined` | Exact px size (overrides the `size` preset) |
237
+ */
238
+ export const PluginPresentationAnnotateTextArgs = z.object({
239
+ sheetId: z.string(),
240
+ text: z.string(),
241
+ position: z.object({ x: z.number(), y: z.number() }).optional(),
242
+ size: PluginAnnotateTextSize.optional(),
243
+ color: PluginAnnotateTextColor.optional(),
244
+ fontFamily: z.string().min(1).optional(),
245
+ fontWeight: z
246
+ .string()
247
+ .regex(
248
+ /^\d{3}(-italic)?$/,
249
+ 'fontWeight must be a numeric string like "400" or "700", optionally with the "-italic" suffix',
250
+ )
251
+ .optional(),
252
+ fontSizePx: z.number().finite().positive().optional(),
253
+ })
254
+ export type PluginPresentationAnnotateTextArgs = z.infer<
255
+ typeof PluginPresentationAnnotateTextArgs
256
+ >
257
+
258
+ /**
259
+ * Result of {@linkcode PluginPresentationAnnotateApi.text}.
260
+ *
261
+ * | Property | Type | Description |
262
+ * |---|---|---|
263
+ * | `shapeId` | `string` | Id of the created text shape |
264
+ */
265
+ export const PluginPresentationAnnotateTextResult = z.object({
266
+ shapeId: z.string(),
267
+ })
268
+ export type PluginPresentationAnnotateTextResult = z.infer<
269
+ typeof PluginPresentationAnnotateTextResult
270
+ >
271
+
272
+ /**
273
+ * Geo shape kind — the shapes offered by the Present-mode toolbar's shape
274
+ * flyout.
275
+ */
276
+ export const PluginAnnotateGeoKind = z.enum([
277
+ "rectangle",
278
+ "ellipse",
279
+ "triangle",
280
+ "diamond",
281
+ "hexagon",
282
+ "oval",
283
+ "rhombus",
284
+ "star",
285
+ "cloud",
286
+ "heart",
287
+ "x-box",
288
+ "check-box",
289
+ "arrow-left",
290
+ "arrow-up",
291
+ "arrow-right",
292
+ "arrow-down",
293
+ ])
294
+ export type PluginAnnotateGeoKind = z.infer<typeof PluginAnnotateGeoKind>
295
+
296
+ /** Fill style for geo shapes (the same fills as the Present-mode style panel). */
297
+ export const PluginAnnotateFill = z.enum(["none", "semi", "solid", "pattern"])
298
+ export type PluginAnnotateFill = z.infer<typeof PluginAnnotateFill>
299
+
300
+ /**
301
+ * Arguments for {@linkcode PluginPresentationAnnotateApi.arrow}.
302
+ *
303
+ * | Property | Type | Description |
304
+ * |---|---|---|
305
+ * | `sheetId` | `string` | The sheet to annotate |
306
+ * | `start` | `{ x: number; y: number }` | Arrow tail (relative to the sheet) |
307
+ * | `end` | `{ x: number; y: number }` | Arrow head (relative to the sheet) |
308
+ * | `color` | {@linkcode PluginAnnotateTextColor}` \| undefined` | Arrow color |
309
+ * | `size` | {@linkcode PluginAnnotateTextSize}` \| undefined` | Stroke weight preset |
310
+ */
311
+ export const PluginPresentationAnnotateArrowArgs = z.object({
312
+ sheetId: z.string(),
313
+ start: z.object({ x: z.number(), y: z.number() }),
314
+ end: z.object({ x: z.number(), y: z.number() }),
315
+ color: PluginAnnotateTextColor.optional(),
316
+ size: PluginAnnotateTextSize.optional(),
317
+ })
318
+ export type PluginPresentationAnnotateArrowArgs = z.infer<
319
+ typeof PluginPresentationAnnotateArrowArgs
320
+ >
321
+
322
+ /**
323
+ * Arguments for {@linkcode PluginPresentationAnnotateApi.note}.
324
+ *
325
+ * | Property | Type | Description |
326
+ * |---|---|---|
327
+ * | `sheetId` | `string` | The sheet to annotate |
328
+ * | `text` | `string` | The note text |
329
+ * | `position` | `{ x: number; y: number } \| undefined` | Where to place it (relative to the sheet) |
330
+ * | `color` | {@linkcode PluginAnnotateTextColor}` \| undefined` | Sticky fill color |
331
+ * | `size` | {@linkcode PluginAnnotateTextSize}` \| undefined` | Text size preset |
332
+ */
333
+ export const PluginPresentationAnnotateNoteArgs = z.object({
334
+ sheetId: z.string(),
335
+ text: z.string(),
336
+ position: z.object({ x: z.number(), y: z.number() }).optional(),
337
+ color: PluginAnnotateTextColor.optional(),
338
+ size: PluginAnnotateTextSize.optional(),
339
+ })
340
+ export type PluginPresentationAnnotateNoteArgs = z.infer<
341
+ typeof PluginPresentationAnnotateNoteArgs
342
+ >
343
+
344
+ /**
345
+ * Arguments for {@linkcode PluginPresentationAnnotateApi.shape}.
346
+ *
347
+ * | Property | Type | Description |
348
+ * |---|---|---|
349
+ * | `sheetId` | `string` | The sheet to annotate |
350
+ * | `kind` | {@linkcode PluginAnnotateGeoKind} | The shape kind |
351
+ * | `bounds` | `{ x: number; y: number; w: number; h: number }` | Placement box (relative to the sheet; `w`/`h` positive) |
352
+ * | `color` | {@linkcode PluginAnnotateTextColor}` \| undefined` | Outline color |
353
+ * | `fill` | {@linkcode PluginAnnotateFill}` \| undefined` | Fill style |
354
+ */
355
+ export const PluginPresentationAnnotateShapeArgs = z.object({
356
+ sheetId: z.string(),
357
+ kind: PluginAnnotateGeoKind,
358
+ bounds: z.object({
359
+ x: z.number(),
360
+ y: z.number(),
361
+ w: z.number().positive(),
362
+ h: z.number().positive(),
363
+ }),
364
+ color: PluginAnnotateTextColor.optional(),
365
+ fill: PluginAnnotateFill.optional(),
366
+ })
367
+ export type PluginPresentationAnnotateShapeArgs = z.infer<
368
+ typeof PluginPresentationAnnotateShapeArgs
369
+ >
370
+
371
+ /**
372
+ * Result of {@linkcode PluginPresentationAnnotateApi.arrow},
373
+ * {@linkcode PluginPresentationAnnotateApi.note}, and
374
+ * {@linkcode PluginPresentationAnnotateApi.shape}.
375
+ *
376
+ * | Property | Type | Description |
377
+ * |---|---|---|
378
+ * | `shapeId` | `string` | Id of the created canvas shape |
379
+ */
380
+ export const PluginPresentationAnnotateResult = z.object({
381
+ shapeId: z.string(),
382
+ })
383
+ export type PluginPresentationAnnotateResult = z.infer<
384
+ typeof PluginPresentationAnnotateResult
385
+ >
@@ -2,23 +2,94 @@ import * as z from "zod"
2
2
  import { PluginApiReturn } from "../../types"
3
3
 
4
4
  /**
5
- * Presentation diagrams — place diagram images onto sheets.
5
+ * Presentation diagrams — generate program diagrams from the model, and place
6
+ * diagram images onto sheets.
6
7
  *
7
- * {@linkcode PluginPresentationDiagramsApi.place} drops diagram images (by
8
- * URL) onto a sheet and returns the created canvas shape ids (requires Present
9
- * mode to be open). Adjacency data itself is read and computed via
8
+ * {@linkcode PluginPresentationDiagramsApi.generateProgram} runs the Present-mode
9
+ * **Program** action: it reads the project's spaces and departments and creates
10
+ * new layout sheets holding the generated diagram graphics.
11
+ * {@linkcode PluginPresentationDiagramsApi.generateSite} runs the site-diagram
12
+ * flow (location / streetview / climate sheets from the map terrain).
13
+ * {@linkcode PluginPresentationDiagramsApi.place} drops ready diagram images (by
14
+ * URL) onto an existing sheet and returns the created canvas shape ids. All
15
+ * require Present mode to be open. Adjacency data itself is read and computed via
10
16
  * `program.adjacency` (see {@linkcode PluginProgramAdjacencyApi}).
11
17
  *
12
- * A future one-step spec-based `place` which would render a diagram spec
13
- * and place it in a single call — awaits a public generator from the
14
- * documentation engine; until that generator exists, `place` takes ready
15
- * image `urls` (we do not ship a spec-based `place` that would only throw).
18
+ * There is intentionally no `generateAdjacency`: the host's adjacency generator
19
+ * runs its sheet-creation task fire-and-forget internally, so a single call
20
+ * cannot return the sheets it creates. Use the Present-mode Adjacency menu for
21
+ * those, then `place` a pre-rendered adjacency image if you need it via the API.
16
22
  *
17
23
  * Accessed via `snaptrude.presentation.diagrams`.
18
24
  */
19
25
  export abstract class PluginPresentationDiagramsApi {
20
26
  constructor() {}
21
27
 
28
+ /**
29
+ * Generate the program (space + department) diagrams for the current model,
30
+ * creating new layout sheets.
31
+ *
32
+ * Runs the same auto-generation as the Present-mode **Program** action: reads
33
+ * the project's spaces and departments, lays them out to scale, and creates one
34
+ * or more new sheets holding the generated diagram graphics. Unlike
35
+ * {@linkcode PluginPresentationDiagramsApi.place} (which pastes ready image URLs
36
+ * onto an existing sheet), this generates the graphics from the model and
37
+ * creates its own sheets. Requires Present mode to be open.
38
+ *
39
+ * @returns A {@linkcode PluginPresentationDiagramsGenerateResult} with the
40
+ * `sheetIds` of the sheets created.
41
+ * @throws If Present mode is not open, or the model has no spaces/departments to
42
+ * generate from.
43
+ *
44
+ * @examplePrompt Generate the program diagrams for this project
45
+ * @examplePrompt Auto-generate the space and department diagram sheets
46
+ * @examplePrompt Create the program layout sheets from the model
47
+ *
48
+ * # Example
49
+ * ```ts
50
+ * const { sheetIds } = await snaptrude.presentation.diagrams.generateProgram()
51
+ * ```
52
+ */
53
+ public abstract generateProgram(): PluginApiReturn<PluginPresentationDiagramsGenerateResult>
54
+
55
+ /**
56
+ * Generate the site diagrams (location, streetview, climate) for the
57
+ * current model, creating new layout sheets.
58
+ *
59
+ * Runs the same auto-generation as the Present-mode site-diagram flow:
60
+ * each requested type renders its diagram from the project's map terrain
61
+ * and creates a new sheet holding it. `options.types` selects which
62
+ * diagrams to generate (default: all three). Generation is tracked
63
+ * per-proposal — a type whose diagram already exists for the active
64
+ * proposal is **skipped, not duplicated** (the same semantics as the
65
+ * mount-time flow; existing site-diagram sheets are never replaced), so
66
+ * `sheetIds` contains only the sheets created by this call and can be
67
+ * empty when everything already exists. Requires Present mode to be open
68
+ * and the project to have a map terrain to generate from.
69
+ *
70
+ * @param options - Optional `types` — which site diagrams to generate
71
+ * (default: `["location", "streetview", "climate"]`).
72
+ * @returns A {@linkcode PluginPresentationDiagramsGenerateResult} with the
73
+ * `sheetIds` of the sheets created by this call (empty when all requested
74
+ * types were already generated).
75
+ * @throws If Present mode is not open or the project has no map terrain to
76
+ * generate from.
77
+ *
78
+ * @examplePrompt Generate the site diagrams for this project
79
+ * @examplePrompt Create the location, streetview and climate sheets
80
+ * @examplePrompt Add a climate diagram sheet to the presentation
81
+ *
82
+ * # Example
83
+ * ```ts
84
+ * const { sheetIds } = await snaptrude.presentation.diagrams.generateSite({
85
+ * types: ["location", "climate"],
86
+ * })
87
+ * ```
88
+ */
89
+ public abstract generateSite(options?: {
90
+ types?: PluginPresentationSiteDiagramType[]
91
+ }): PluginApiReturn<PluginPresentationDiagramsGenerateResult>
92
+
22
93
  /**
23
94
  * Place diagram images onto a sheet.
24
95
  *
@@ -82,3 +153,42 @@ export const PluginPresentationDiagramsPlaceResult = z.object({
82
153
  export type PluginPresentationDiagramsPlaceResult = z.infer<
83
154
  typeof PluginPresentationDiagramsPlaceResult
84
155
  >
156
+
157
+ /** A site diagram type — the three diagrams of the Present-mode site flow. */
158
+ export const PluginPresentationSiteDiagramType = z.enum([
159
+ "location",
160
+ "streetview",
161
+ "climate",
162
+ ])
163
+ export type PluginPresentationSiteDiagramType = z.infer<
164
+ typeof PluginPresentationSiteDiagramType
165
+ >
166
+
167
+ /**
168
+ * Arguments for {@linkcode PluginPresentationDiagramsApi.generateSite}.
169
+ *
170
+ * | Property | Type | Description |
171
+ * |---|---|---|
172
+ * | `types` | {@linkcode PluginPresentationSiteDiagramType}`[] \| undefined` | Which site diagrams to generate (default: all three) |
173
+ */
174
+ export const PluginPresentationDiagramsGenerateSiteArgs = z.object({
175
+ types: z.array(PluginPresentationSiteDiagramType).min(1).optional(),
176
+ })
177
+ export type PluginPresentationDiagramsGenerateSiteArgs = z.infer<
178
+ typeof PluginPresentationDiagramsGenerateSiteArgs
179
+ >
180
+
181
+ /**
182
+ * Result of {@linkcode PluginPresentationDiagramsApi.generateProgram} and
183
+ * {@linkcode PluginPresentationDiagramsApi.generateSite}.
184
+ *
185
+ * | Property | Type | Description |
186
+ * |---|---|---|
187
+ * | `sheetIds` | `string[]` | Ids of the sheets created by the generator |
188
+ */
189
+ export const PluginPresentationDiagramsGenerateResult = z.object({
190
+ sheetIds: z.array(z.string()),
191
+ })
192
+ export type PluginPresentationDiagramsGenerateResult = z.infer<
193
+ typeof PluginPresentationDiagramsGenerateResult
194
+ >
@@ -0,0 +1,108 @@
1
+ import * as z from "zod"
2
+
3
+ /**
4
+ * Presentation export — render the Present-mode layout sheets to a downloadable
5
+ * file (PDF / PNG / JPG) and hand the plugin the bytes as base64.
6
+ *
7
+ * This wraps the same pipeline the Present-mode **Export** dialog drives:
8
+ * each sheet is serialized to an SVG, then either composed into a PDF
9
+ * (svg2pdf/jspdf) or rasterized to a PNG/JPG. Nothing is written to disk
10
+ * host-side — the plugin receives the encoded bytes and decides what to do
11
+ * with them (save, upload, preview).
12
+ *
13
+ * Requires **Present mode to be open** (the documentation editor); the call
14
+ * throws `PRECONDITION_FAILED` when it is not.
15
+ *
16
+ * The result is always a uniform `{ files }` array (see
17
+ * {@linkcode PluginPresentationExportResult}):
18
+ * - `pdf` with `combine` (the default) → a single multi-page file.
19
+ * - `pdf` with `combine: false`, or any `png`/`jpg` → one file per sheet.
20
+ *
21
+ * Accessed via `snaptrude.presentation.export`.
22
+ *
23
+ * For a different export intent, see `core.io.export.model` (the 3D model as a
24
+ * GLB/OBJ/FBX/3DS file) and `program.spreadsheet.export` (the area-program /
25
+ * takeoff workbook as XLSX/PDF/CSV).
26
+ *
27
+ * The schemas and result types live here; the callable method is declared on
28
+ * {@linkcode PluginPresentationApi.export}.
29
+ */
30
+
31
+ /** Output file format: a vector `pdf`, or a rasterized `png` / `jpg`. */
32
+ export const PluginPresentationExportFormat = z.enum(["pdf", "png", "jpg"])
33
+ export type PluginPresentationExportFormat = z.infer<
34
+ typeof PluginPresentationExportFormat
35
+ >
36
+
37
+ /**
38
+ * Target pixel dimensions for a rasterized (`png`/`jpg`) export. Ignored for
39
+ * `pdf`, which stays vector and takes its size from the sheet.
40
+ *
41
+ * | Property | Type | Description |
42
+ * |---|---|---|
43
+ * | `width` | `number` | Output width in pixels |
44
+ * | `height` | `number` | Output height in pixels |
45
+ */
46
+ export const PluginPresentationExportResolution = z.object({
47
+ width: z.number().positive(),
48
+ height: z.number().positive(),
49
+ })
50
+ export type PluginPresentationExportResolution = z.infer<
51
+ typeof PluginPresentationExportResolution
52
+ >
53
+
54
+ /**
55
+ * Arguments for {@linkcode PluginPresentationApi.export}.
56
+ *
57
+ * | Property | Type | Description |
58
+ * |---|---|---|
59
+ * | `format` | `"pdf" \| "png" \| "jpg"` | Output format |
60
+ * | `sheetIds` | `string[] \| undefined` | Sheets to export (all sheets when omitted) |
61
+ * | `combine` | `boolean \| undefined` | PDF only: one multi-page file (default `true`) vs one file per sheet |
62
+ * | `resolution` | {@linkcode PluginPresentationExportResolution}` \| undefined` | Raster target size (`png`/`jpg` only) |
63
+ * | `fileName` | `string \| undefined` | Base file name (without extension) |
64
+ */
65
+ export const PluginPresentationExportArgs = z.object({
66
+ format: PluginPresentationExportFormat,
67
+ sheetIds: z.array(z.string()).optional(),
68
+ combine: z.boolean().optional(),
69
+ resolution: PluginPresentationExportResolution.optional(),
70
+ fileName: z.string().optional(),
71
+ })
72
+ export type PluginPresentationExportArgs = z.infer<
73
+ typeof PluginPresentationExportArgs
74
+ >
75
+
76
+ /**
77
+ * A single exported file.
78
+ *
79
+ * | Property | Type | Description |
80
+ * |---|---|---|
81
+ * | `fileName` | `string` | File name including extension |
82
+ * | `mimeType` | `string` | MIME type (`application/pdf`, `image/png`, `image/jpeg`) |
83
+ * | `dataBase64` | `string` | The file bytes, base64-encoded (no data-URL prefix) |
84
+ */
85
+ export const PluginPresentationExportFile = z.object({
86
+ fileName: z.string(),
87
+ mimeType: z.string(),
88
+ dataBase64: z.string(),
89
+ })
90
+ export type PluginPresentationExportFile = z.infer<
91
+ typeof PluginPresentationExportFile
92
+ >
93
+
94
+ /**
95
+ * Result of {@linkcode PluginPresentationApi.export} — always a `files` array.
96
+ * A combined PDF yields one entry; per-sheet exports yield one entry each, in
97
+ * sheet order.
98
+ *
99
+ * | Property | Type | Description |
100
+ * |---|---|---|
101
+ * | `files` | {@linkcode PluginPresentationExportFile}`[]` | The exported files |
102
+ */
103
+ export const PluginPresentationExportResult = z.object({
104
+ files: z.array(PluginPresentationExportFile),
105
+ })
106
+ export type PluginPresentationExportResult = z.infer<
107
+ typeof PluginPresentationExportResult
108
+ >