@snaptrude/plugin-core 0.3.0 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (266) hide show
  1. package/AGENTS.md +130 -48
  2. package/CHANGELOG.md +111 -0
  3. package/api-manifest.full.json +3999 -0
  4. package/api-manifest.json +3845 -0
  5. package/dist/api/core/buildings.d.ts +427 -0
  6. package/dist/api/core/buildings.d.ts.map +1 -0
  7. package/dist/api/core/comment/index.d.ts +230 -0
  8. package/dist/api/core/comment/index.d.ts.map +1 -0
  9. package/dist/api/core/geom/create/index.d.ts +247 -0
  10. package/dist/api/core/geom/create/index.d.ts.map +1 -0
  11. package/dist/api/core/geom/delete/index.d.ts +72 -0
  12. package/dist/api/core/geom/delete/index.d.ts.map +1 -0
  13. package/dist/api/core/geom/index.d.ts +24 -23
  14. package/dist/api/core/geom/index.d.ts.map +1 -1
  15. package/dist/api/core/geom/query/arc.d.ts +169 -0
  16. package/dist/api/core/geom/query/arc.d.ts.map +1 -0
  17. package/dist/api/core/geom/query/brep.d.ts +402 -0
  18. package/dist/api/core/geom/query/brep.d.ts.map +1 -0
  19. package/dist/api/core/geom/query/circle.d.ts +378 -0
  20. package/dist/api/core/geom/query/circle.d.ts.map +1 -0
  21. package/dist/api/core/geom/query/contour.d.ts +450 -0
  22. package/dist/api/core/geom/query/contour.d.ts.map +1 -0
  23. package/dist/api/core/geom/query/curve.d.ts +918 -0
  24. package/dist/api/core/geom/query/curve.d.ts.map +1 -0
  25. package/dist/api/core/geom/query/edge.d.ts +128 -0
  26. package/dist/api/core/geom/query/edge.d.ts.map +1 -0
  27. package/dist/api/core/geom/query/face.d.ts +363 -0
  28. package/dist/api/core/geom/query/face.d.ts.map +1 -0
  29. package/dist/api/core/geom/query/halfedge.d.ts +206 -0
  30. package/dist/api/core/geom/query/halfedge.d.ts.map +1 -0
  31. package/dist/api/core/geom/query/index.d.ts +61 -0
  32. package/dist/api/core/geom/query/index.d.ts.map +1 -0
  33. package/dist/api/core/geom/query/profile.d.ts +410 -0
  34. package/dist/api/core/geom/query/profile.d.ts.map +1 -0
  35. package/dist/api/core/geom/query/vertex.d.ts +187 -0
  36. package/dist/api/core/geom/query/vertex.d.ts.map +1 -0
  37. package/dist/api/core/geom/update/contour.d.ts +272 -0
  38. package/dist/api/core/geom/update/contour.d.ts.map +1 -0
  39. package/dist/api/core/geom/update/curve.d.ts +180 -0
  40. package/dist/api/core/geom/update/curve.d.ts.map +1 -0
  41. package/dist/api/core/geom/update/index.d.ts +27 -0
  42. package/dist/api/core/geom/update/index.d.ts.map +1 -0
  43. package/dist/api/core/geom/update/profile.d.ts +329 -0
  44. package/dist/api/core/geom/update/profile.d.ts.map +1 -0
  45. package/dist/api/core/groups.d.ts +485 -0
  46. package/dist/api/core/groups.d.ts.map +1 -0
  47. package/dist/api/core/history/index.d.ts +78 -0
  48. package/dist/api/core/history/index.d.ts.map +1 -0
  49. package/dist/api/core/index.d.ts +46 -1
  50. package/dist/api/core/index.d.ts.map +1 -1
  51. package/dist/api/core/layers.d.ts +402 -0
  52. package/dist/api/core/layers.d.ts.map +1 -0
  53. package/dist/api/core/math/quat.d.ts +111 -128
  54. package/dist/api/core/math/quat.d.ts.map +1 -1
  55. package/dist/api/core/math/vec3.d.ts +120 -102
  56. package/dist/api/core/math/vec3.d.ts.map +1 -1
  57. package/dist/api/core/project/index.d.ts +399 -0
  58. package/dist/api/core/project/index.d.ts.map +1 -0
  59. package/dist/api/core/tags.d.ts +755 -0
  60. package/dist/api/core/tags.d.ts.map +1 -0
  61. package/dist/api/core/units/index.d.ts +175 -0
  62. package/dist/api/core/units/index.d.ts.map +1 -0
  63. package/dist/api/core/zoom/index.d.ts +45 -0
  64. package/dist/api/core/zoom/index.d.ts.map +1 -0
  65. package/dist/api/design/boolean/index.d.ts +168 -0
  66. package/dist/api/design/boolean/index.d.ts.map +1 -0
  67. package/dist/api/design/create/index.d.ts +828 -0
  68. package/dist/api/design/create/index.d.ts.map +1 -0
  69. package/dist/api/design/delete/index.d.ts +63 -0
  70. package/dist/api/design/delete/index.d.ts.map +1 -0
  71. package/dist/api/design/doors/index.d.ts +268 -0
  72. package/dist/api/design/doors/index.d.ts.map +1 -0
  73. package/dist/api/design/edit/index.d.ts +49 -0
  74. package/dist/api/design/edit/index.d.ts.map +1 -0
  75. package/dist/api/design/erase/index.d.ts +160 -0
  76. package/dist/api/design/erase/index.d.ts.map +1 -0
  77. package/dist/api/design/furniture/index.d.ts +123 -0
  78. package/dist/api/design/furniture/index.d.ts.map +1 -0
  79. package/dist/api/design/index.d.ts +153 -0
  80. package/dist/api/design/index.d.ts.map +1 -0
  81. package/dist/api/design/lock.d.ts +41 -0
  82. package/dist/api/design/lock.d.ts.map +1 -0
  83. package/dist/api/design/materials/index.d.ts +297 -0
  84. package/dist/api/design/materials/index.d.ts.map +1 -0
  85. package/dist/api/design/query/geometry/index.d.ts +140 -0
  86. package/dist/api/design/query/geometry/index.d.ts.map +1 -0
  87. package/dist/api/design/query/index.d.ts +1011 -0
  88. package/dist/api/design/query/index.d.ts.map +1 -0
  89. package/dist/api/design/query/spaces.d.ts +221 -0
  90. package/dist/api/design/query/spaces.d.ts.map +1 -0
  91. package/dist/api/design/selection/index.d.ts +138 -0
  92. package/dist/api/design/selection/index.d.ts.map +1 -0
  93. package/dist/api/design/shared.d.ts +38 -0
  94. package/dist/api/design/shared.d.ts.map +1 -0
  95. package/dist/api/design/transform/index.d.ts +87 -0
  96. package/dist/api/design/transform/index.d.ts.map +1 -0
  97. package/dist/api/design/update/index.d.ts +178 -0
  98. package/dist/api/design/update/index.d.ts.map +1 -0
  99. package/dist/api/design/windows/index.d.ts +189 -0
  100. package/dist/api/design/windows/index.d.ts.map +1 -0
  101. package/dist/api/entity/buildableEnvelope.d.ts +261 -0
  102. package/dist/api/entity/buildableEnvelope.d.ts.map +1 -0
  103. package/dist/api/entity/department.d.ts +0 -98
  104. package/dist/api/entity/department.d.ts.map +1 -1
  105. package/dist/api/entity/index.d.ts +9 -9
  106. package/dist/api/entity/index.d.ts.map +1 -1
  107. package/dist/api/entity/referenceLine.d.ts +49 -106
  108. package/dist/api/entity/referenceLine.d.ts.map +1 -1
  109. package/dist/api/entity/space.d.ts +482 -249
  110. package/dist/api/entity/space.d.ts.map +1 -1
  111. package/dist/api/entity/story.d.ts +49 -39
  112. package/dist/api/entity/story.d.ts.map +1 -1
  113. package/dist/api/index.d.ts +17 -12
  114. package/dist/api/index.d.ts.map +1 -1
  115. package/dist/api/presentation/aiInspiration.d.ts +440 -0
  116. package/dist/api/presentation/aiInspiration.d.ts.map +1 -0
  117. package/dist/api/presentation/diagrams.d.ts +81 -0
  118. package/dist/api/presentation/diagrams.d.ts.map +1 -0
  119. package/dist/api/presentation/import.d.ts +113 -0
  120. package/dist/api/presentation/import.d.ts.map +1 -0
  121. package/dist/api/presentation/index.d.ts +46 -0
  122. package/dist/api/presentation/index.d.ts.map +1 -0
  123. package/dist/api/presentation/sheets.d.ts +176 -0
  124. package/dist/api/presentation/sheets.d.ts.map +1 -0
  125. package/dist/api/presentation/views.d.ts +296 -0
  126. package/dist/api/presentation/views.d.ts.map +1 -0
  127. package/dist/api/program/adjacency.d.ts +155 -0
  128. package/dist/api/program/adjacency.d.ts.map +1 -0
  129. package/dist/api/program/areas.d.ts +360 -0
  130. package/dist/api/program/areas.d.ts.map +1 -0
  131. package/dist/api/program/classification.d.ts +135 -0
  132. package/dist/api/program/classification.d.ts.map +1 -0
  133. package/dist/api/program/cores.d.ts +174 -0
  134. package/dist/api/program/cores.d.ts.map +1 -0
  135. package/dist/api/program/departments.d.ts +431 -0
  136. package/dist/api/program/departments.d.ts.map +1 -0
  137. package/dist/api/program/index.d.ts +69 -0
  138. package/dist/api/program/index.d.ts.map +1 -0
  139. package/dist/api/program/layout.d.ts +63 -0
  140. package/dist/api/program/layout.d.ts.map +1 -0
  141. package/dist/api/program/metrics.d.ts +108 -0
  142. package/dist/api/program/metrics.d.ts.map +1 -0
  143. package/dist/api/program/site.d.ts +367 -0
  144. package/dist/api/program/site.d.ts.map +1 -0
  145. package/dist/api/program/spreadsheet.d.ts +2041 -0
  146. package/dist/api/program/spreadsheet.d.ts.map +1 -0
  147. package/dist/handles.d.ts +138 -0
  148. package/dist/handles.d.ts.map +1 -0
  149. package/dist/host-utils.d.ts +7 -5
  150. package/dist/host-utils.d.ts.map +1 -1
  151. package/dist/index.cjs +4001 -904
  152. package/dist/index.cjs.map +1 -1
  153. package/dist/index.d.ts +1 -0
  154. package/dist/index.d.ts.map +1 -1
  155. package/dist/index.js +3392 -870
  156. package/dist/index.js.map +1 -1
  157. package/package.json +6 -2
  158. package/scripts/generate-manifest.mjs +193 -0
  159. package/scripts/generate-manifest.test.mjs +193 -0
  160. package/src/api/core/buildings.ts +485 -0
  161. package/src/api/core/comment/index.ts +258 -0
  162. package/src/api/core/geom/create/index.ts +293 -0
  163. package/src/api/core/geom/delete/index.ts +78 -0
  164. package/src/api/core/geom/index.ts +24 -23
  165. package/src/api/core/geom/query/arc.ts +169 -0
  166. package/src/api/core/geom/query/brep.ts +444 -0
  167. package/src/api/core/geom/query/circle.ts +404 -0
  168. package/src/api/core/geom/query/contour.ts +540 -0
  169. package/src/api/core/geom/query/curve.ts +1078 -0
  170. package/src/api/core/geom/query/edge.ts +130 -0
  171. package/src/api/core/geom/query/face.ts +403 -0
  172. package/src/api/core/geom/query/halfedge.ts +210 -0
  173. package/src/api/core/geom/query/index.ts +63 -0
  174. package/src/api/core/geom/query/profile.ts +473 -0
  175. package/src/api/core/geom/query/vertex.ts +205 -0
  176. package/src/api/core/geom/update/contour.ts +315 -0
  177. package/src/api/core/geom/update/curve.ts +209 -0
  178. package/src/api/core/geom/update/index.ts +29 -0
  179. package/src/api/core/geom/update/profile.ts +377 -0
  180. package/src/api/core/groups.ts +521 -0
  181. package/src/api/core/history/index.ts +84 -0
  182. package/src/api/core/index.ts +46 -1
  183. package/src/api/core/layers.ts +333 -0
  184. package/src/api/core/math/quat.ts +112 -235
  185. package/src/api/core/math/vec3.ts +124 -159
  186. package/src/api/core/project/index.ts +418 -0
  187. package/src/api/core/tags.ts +808 -0
  188. package/src/api/core/units/index.ts +164 -0
  189. package/src/api/core/zoom/index.ts +47 -0
  190. package/src/api/design/boolean/index.ts +179 -0
  191. package/src/api/design/create/index.ts +886 -0
  192. package/src/api/design/delete/index.ts +67 -0
  193. package/src/api/design/doors/index.ts +285 -0
  194. package/src/api/design/edit/index.ts +54 -0
  195. package/src/api/design/erase/index.ts +151 -0
  196. package/src/api/design/furniture/index.ts +130 -0
  197. package/src/api/design/index.ts +162 -0
  198. package/src/api/design/lock.ts +42 -0
  199. package/src/api/design/materials/index.ts +301 -0
  200. package/src/api/design/query/geometry/index.ts +166 -0
  201. package/src/api/design/query/index.ts +937 -0
  202. package/src/api/design/query/spaces.ts +132 -0
  203. package/src/api/design/selection/index.ts +144 -0
  204. package/src/api/design/shared.ts +40 -0
  205. package/src/api/design/transform/index.ts +93 -0
  206. package/src/api/design/update/index.ts +117 -0
  207. package/src/api/design/windows/index.ts +207 -0
  208. package/src/api/entity/buildableEnvelope.ts +318 -0
  209. package/src/api/entity/department.ts +0 -113
  210. package/src/api/entity/index.ts +9 -9
  211. package/src/api/entity/referenceLine.ts +50 -38
  212. package/src/api/entity/space.ts +285 -226
  213. package/src/api/entity/story.ts +53 -42
  214. package/src/api/index.ts +17 -12
  215. package/src/api/presentation/aiInspiration.ts +362 -0
  216. package/src/api/presentation/diagrams.ts +84 -0
  217. package/src/api/presentation/import.ts +112 -0
  218. package/src/api/presentation/index.ts +48 -0
  219. package/src/api/presentation/sheets.ts +198 -0
  220. package/src/api/presentation/views.ts +303 -0
  221. package/src/api/program/adjacency.ts +164 -0
  222. package/src/api/program/areas.ts +335 -0
  223. package/src/api/program/classification.ts +138 -0
  224. package/src/api/program/cores.ts +171 -0
  225. package/src/api/program/departments.ts +465 -0
  226. package/src/api/program/index.ts +71 -0
  227. package/src/api/program/layout.ts +68 -0
  228. package/src/api/program/metrics.ts +120 -0
  229. package/src/api/program/site.ts +326 -0
  230. package/src/api/program/spreadsheet.ts +2075 -0
  231. package/src/handles.ts +148 -0
  232. package/src/host-utils.ts +10 -6
  233. package/src/index.ts +1 -0
  234. package/dist/api/core/geom/arc.d.ts +0 -81
  235. package/dist/api/core/geom/arc.d.ts.map +0 -1
  236. package/dist/api/core/geom/curve.d.ts +0 -70
  237. package/dist/api/core/geom/curve.d.ts.map +0 -1
  238. package/dist/api/core/geom/line.d.ts +0 -56
  239. package/dist/api/core/geom/line.d.ts.map +0 -1
  240. package/dist/api/core/geom/profile.d.ts +0 -121
  241. package/dist/api/core/geom/profile.d.ts.map +0 -1
  242. package/dist/api/tools/copy.d.ts +0 -59
  243. package/dist/api/tools/copy.d.ts.map +0 -1
  244. package/dist/api/tools/index.d.ts +0 -33
  245. package/dist/api/tools/index.d.ts.map +0 -1
  246. package/dist/api/tools/material.d.ts +0 -51
  247. package/dist/api/tools/material.d.ts.map +0 -1
  248. package/dist/api/tools/offset.d.ts +0 -43
  249. package/dist/api/tools/offset.d.ts.map +0 -1
  250. package/dist/api/tools/selection.d.ts +0 -48
  251. package/dist/api/tools/selection.d.ts.map +0 -1
  252. package/dist/api/tools/transform.d.ts +0 -114
  253. package/dist/api/tools/transform.d.ts.map +0 -1
  254. package/dist/api/units/index.d.ts +0 -163
  255. package/dist/api/units/index.d.ts.map +0 -1
  256. package/src/api/core/geom/arc.ts +0 -70
  257. package/src/api/core/geom/curve.ts +0 -41
  258. package/src/api/core/geom/line.ts +0 -53
  259. package/src/api/core/geom/profile.ts +0 -94
  260. package/src/api/tools/copy.ts +0 -55
  261. package/src/api/tools/index.ts +0 -39
  262. package/src/api/tools/material.ts +0 -49
  263. package/src/api/tools/offset.ts +0 -43
  264. package/src/api/tools/selection.ts +0 -51
  265. package/src/api/tools/transform.ts +0 -117
  266. package/src/api/units/index.ts +0 -163
@@ -0,0 +1,112 @@
1
+ import * as z from "zod"
2
+ import { PluginApiReturn } from "../../types"
3
+
4
+ /**
5
+ * Presentation import — bring external reference assets onto the Present canvas.
6
+ *
7
+ * `import.image` places a reference image and `import.pdf` places a PDF (each
8
+ * page vectorized to SVG) onto the current Present sheet, returning the created
9
+ * canvas shape ids. Requires Present mode to be open.
10
+ *
11
+ * The host engine takes a browser `File`, which a plugin worker cannot supply,
12
+ * so these accept a `url`/`dataUrl` that the host adapts into a `File`.
13
+ *
14
+ * Accessed via `snaptrude.presentation.import`.
15
+ */
16
+ export abstract class PluginPresentationImportApi {
17
+ constructor() {}
18
+
19
+ /**
20
+ * Import a reference image onto the current Present sheet.
21
+ *
22
+ * @param source - The asset to import: exactly one of `url` or `dataUrl`.
23
+ * @param options - Optional `position` — where to place the image on the
24
+ * sheet.
25
+ * @returns A {@linkcode PluginPresentationImportResult} with the created
26
+ * `shapeIds`.
27
+ * @throws If Present mode is not open or the source cannot be loaded.
28
+ *
29
+ * @examplePrompt Import this reference image onto the present canvas
30
+ * @examplePrompt Add a JPG to my presentation board
31
+ * @examplePrompt Drop this site photo onto the current sheet
32
+ * @examplePrompt Bring an inspiration image into Present mode
33
+ *
34
+ * # Example
35
+ * ```ts
36
+ * const { shapeIds } = await snaptrude.presentation.import.image(
37
+ * { url: "https://example.com/ref.png" },
38
+ * { position: { x: 200, y: 150 } },
39
+ * )
40
+ * ```
41
+ */
42
+ public abstract image(
43
+ source: { url?: string; dataUrl?: string },
44
+ options?: { position?: { x: number; y: number } },
45
+ ): PluginApiReturn<PluginPresentationImportResult>
46
+
47
+ /**
48
+ * Import a PDF onto the current Present sheet (one shape per page).
49
+ *
50
+ * Each page is converted to vector SVG and placed as a canvas shape.
51
+ *
52
+ * @param source - The asset to import: exactly one of `url` or `dataUrl`.
53
+ * @param options - Optional `position` — where to place the pages on the
54
+ * sheet.
55
+ * @returns A {@linkcode PluginPresentationImportResult} with one `shapeId` per
56
+ * page.
57
+ * @throws If Present mode is not open or the source cannot be loaded.
58
+ *
59
+ * @examplePrompt Import this PDF onto the present canvas
60
+ * @examplePrompt Add a multi-page PDF reference to my board
61
+ * @examplePrompt Bring a PDF floor plan into Present mode as vectors
62
+ * @examplePrompt Place each page of this PDF on the sheet
63
+ *
64
+ * # Example
65
+ * ```ts
66
+ * const { shapeIds } = await snaptrude.presentation.import.pdf({
67
+ * url: "https://example.com/plans.pdf",
68
+ * })
69
+ * ```
70
+ */
71
+ public abstract pdf(
72
+ source: { url?: string; dataUrl?: string },
73
+ options?: { position?: { x: number; y: number } },
74
+ ): PluginApiReturn<PluginPresentationImportResult>
75
+ }
76
+
77
+ /**
78
+ * Arguments for {@linkcode PluginPresentationImportApi.image} /
79
+ * {@linkcode PluginPresentationImportApi.pdf}. Provide exactly one source.
80
+ *
81
+ * | Property | Type | Description |
82
+ * |---|---|---|
83
+ * | `url` | `string \| undefined` | URL of the asset to import |
84
+ * | `dataUrl` | `string \| undefined` | Base64 data URL of the asset |
85
+ * | `position` | `{ x: number; y: number } \| undefined` | Where to place it on the sheet |
86
+ */
87
+ export const PluginPresentationImportArgs = z
88
+ .object({
89
+ url: z.string().optional(),
90
+ dataUrl: z.string().optional(),
91
+ position: z.object({ x: z.number(), y: z.number() }).optional(),
92
+ })
93
+ .refine((a) => Boolean(a.url) || Boolean(a.dataUrl), {
94
+ message: "Provide a url or a dataUrl",
95
+ })
96
+ export type PluginPresentationImportArgs = z.infer<
97
+ typeof PluginPresentationImportArgs
98
+ >
99
+
100
+ /**
101
+ * Result of an import.
102
+ *
103
+ * | Property | Type | Description |
104
+ * |---|---|---|
105
+ * | `shapeIds` | `string[]` | Ids of the created canvas shapes (one per page for PDFs) |
106
+ */
107
+ export const PluginPresentationImportResult = z.object({
108
+ shapeIds: z.array(z.string()),
109
+ })
110
+ export type PluginPresentationImportResult = z.infer<
111
+ typeof PluginPresentationImportResult
112
+ >
@@ -0,0 +1,48 @@
1
+ import { PluginPresentationViewsApi } from "./views"
2
+ import { PluginPresentationAIInspirationApi } from "./aiInspiration"
3
+ import { PluginPresentationSheetsApi } from "./sheets"
4
+ import { PluginPresentationDiagramsApi } from "./diagrams"
5
+ import { PluginPresentationImportApi } from "./import"
6
+
7
+ /**
8
+ * Presentation APIs — prepare and assemble presentations.
9
+ *
10
+ * Reads describe the artifacts a presentation is built from (saved views, layout
11
+ * sheets); writes assemble them (place views/diagrams on sheets, import
12
+ * references, capture/save views). Present-mode AI Inspiration also lives here.
13
+ *
14
+ * Several members require **Present mode to be open** (the documentation editor):
15
+ * sheets, diagram placement, and import.
16
+ *
17
+ * - {@linkcode PluginPresentationApi.views} — Saved 2D/3D views (list, get, capture, activate, create)
18
+ * - {@linkcode PluginPresentationApi.sheets} — Layout sheets (list, get, create, place views)
19
+ * - {@linkcode PluginPresentationApi.diagrams} — Place program/adjacency/site diagram images on sheets
20
+ * - {@linkcode PluginPresentationApi.import} — Import reference images/PDFs onto the canvas
21
+ * - {@linkcode PluginPresentationApi.aiInspiration} — Present-mode AI image/video generation
22
+ *
23
+ * Accessed via `snaptrude.presentation`.
24
+ */
25
+ export abstract class PluginPresentationApi {
26
+ /** Saved 2D/3D views. See {@linkcode PluginPresentationViewsApi}. */
27
+ public abstract views: PluginPresentationViewsApi
28
+ /** Layout sheets — list/get/create and place views (Present mode). See {@linkcode PluginPresentationSheetsApi}. */
29
+ public abstract sheets: PluginPresentationSheetsApi
30
+ /** Program/adjacency/site diagrams — place images on sheets. See {@linkcode PluginPresentationDiagramsApi}. */
31
+ public abstract diagrams: PluginPresentationDiagramsApi
32
+ /** Import reference images/PDFs onto the Present canvas. See {@linkcode PluginPresentationImportApi}. */
33
+ public abstract import: PluginPresentationImportApi
34
+ /**
35
+ * Present-mode AI Inspiration image/video generation. See
36
+ * {@linkcode PluginPresentationAIInspirationApi}. _(authored ahead — optional
37
+ * until the host lands; the host implementation today is a stub.)_
38
+ */
39
+ public aiInspiration?: PluginPresentationAIInspirationApi
40
+
41
+ constructor() {}
42
+ }
43
+
44
+ export * from "./views"
45
+ export * from "./sheets"
46
+ export * from "./diagrams"
47
+ export * from "./import"
48
+ export * from "./aiInspiration"
@@ -0,0 +1,198 @@
1
+ import * as z from "zod"
2
+ import { PluginApiReturn } from "../../types"
3
+
4
+ /**
5
+ * Presentation sheets — the layout sheets a presentation is assembled on.
6
+ *
7
+ * A **sheet** is a page in Present mode that views and diagrams are placed onto.
8
+ * These methods require **Present mode to be open** (the documentation editor) —
9
+ * reads return `[]`/`null` and writes throw when it is not.
10
+ *
11
+ * `list`/`get` are reads; `create` adds a sheet and `place` drops a saved view
12
+ * onto a sheet (returning the id of the created canvas shape).
13
+ *
14
+ * Accessed via `snaptrude.presentation.sheets`.
15
+ */
16
+ export abstract class PluginPresentationSheetsApi {
17
+ constructor() {}
18
+
19
+ /**
20
+ * List the layout sheets in the presentation.
21
+ *
22
+ * @returns A {@linkcode PluginPresentationSheetsListResult} with a `sheets`
23
+ * array (empty when Present mode is closed or there are no sheets).
24
+ *
25
+ * @examplePrompt List all the sheets
26
+ * @examplePrompt How many layout sheets are there?
27
+ * @examplePrompt Show me the presentation sheets
28
+ * @examplePrompt What sheets can I place views on?
29
+ *
30
+ * # Example
31
+ * ```ts
32
+ * const { sheets } = await snaptrude.presentation.sheets.list()
33
+ * ```
34
+ */
35
+ public abstract list(): PluginApiReturn<PluginPresentationSheetsListResult>
36
+
37
+ /**
38
+ * Get a single sheet by id.
39
+ *
40
+ * @param sheetId - The id of the sheet to read.
41
+ * @returns The matching {@linkcode PluginPresentationSheet}, or `null`.
42
+ *
43
+ * @examplePrompt Get the sheet with id sheet_1
44
+ * @examplePrompt Find the sheet called Cover
45
+ * @examplePrompt Look up a layout sheet by id
46
+ *
47
+ * # Example
48
+ * ```ts
49
+ * const sheet = await snaptrude.presentation.sheets.get("sheet_1")
50
+ * ```
51
+ */
52
+ public abstract get(
53
+ sheetId: string,
54
+ ): PluginApiReturn<PluginPresentationSheetsGetResult>
55
+
56
+ /**
57
+ * Create a new layout sheet.
58
+ *
59
+ * Requires Present mode to be open.
60
+ *
61
+ * @param name - Display name for the new sheet (optional).
62
+ * @returns The newly created {@linkcode PluginPresentationSheet}.
63
+ * @throws If Present mode is not open.
64
+ *
65
+ * @examplePrompt Create a new sheet called Cover
66
+ * @examplePrompt Add a layout sheet
67
+ * @examplePrompt Make a new presentation sheet named Floor Plans
68
+ *
69
+ * # Example
70
+ * ```ts
71
+ * const sheet = await snaptrude.presentation.sheets.create("Cover")
72
+ * ```
73
+ */
74
+ public abstract create(
75
+ name?: string,
76
+ ): PluginApiReturn<PluginPresentationSheet>
77
+
78
+ /**
79
+ * Place a saved view onto a sheet.
80
+ *
81
+ * Drops the given view onto the sheet at an optional position and returns the
82
+ * id of the created canvas shape. Requires Present mode to be open.
83
+ *
84
+ * @param sheetId - The id of the sheet to place onto.
85
+ * @param viewId - The id of the saved view to place.
86
+ * @param options - Optional `position` ({@linkcode PluginSheetPosition}) —
87
+ * where to place it (a default is used when omitted).
88
+ * @returns A {@linkcode PluginPresentationSheetsPlaceResult} with the created
89
+ * `shapeId`.
90
+ * @throws If Present mode is not open, or the sheet/view id is invalid.
91
+ *
92
+ * @examplePrompt Place the floor plan on Sheet 1
93
+ * @examplePrompt Add this 3D view to the cover sheet
94
+ * @examplePrompt Drop the site plan onto the layout sheet at 100, 200
95
+ * @examplePrompt Put the Ground Floor view on sheet_1
96
+ *
97
+ * # Example
98
+ * ```ts
99
+ * const { shapeId } = await snaptrude.presentation.sheets.place("sheet_1", "view_123")
100
+ * ```
101
+ */
102
+ public abstract place(
103
+ sheetId: string,
104
+ viewId: string,
105
+ options?: { position?: PluginSheetPosition },
106
+ ): PluginApiReturn<PluginPresentationSheetsPlaceResult>
107
+ }
108
+
109
+ /**
110
+ * A layout sheet in the presentation.
111
+ *
112
+ * | Property | Type | Description |
113
+ * |---|---|---|
114
+ * | `id` | `string` | Unique sheet id |
115
+ * | `name` | `string` | Display name |
116
+ */
117
+ export const PluginPresentationSheet = z.object({
118
+ id: z.string(),
119
+ name: z.string(),
120
+ })
121
+ export type PluginPresentationSheet = z.infer<typeof PluginPresentationSheet>
122
+
123
+ /**
124
+ * A position on a sheet/canvas (sheet coordinates).
125
+ *
126
+ * | Property | Type | Description |
127
+ * |---|---|---|
128
+ * | `x` | `number` | X coordinate |
129
+ * | `y` | `number` | Y coordinate |
130
+ */
131
+ export const PluginSheetPosition = z.object({
132
+ x: z.number(),
133
+ y: z.number(),
134
+ })
135
+ export type PluginSheetPosition = z.infer<typeof PluginSheetPosition>
136
+
137
+ /** Result of {@linkcode PluginPresentationSheetsApi.list}. */
138
+ export const PluginPresentationSheetsListResult = z.object({
139
+ sheets: z.array(PluginPresentationSheet),
140
+ })
141
+ export type PluginPresentationSheetsListResult = z.infer<
142
+ typeof PluginPresentationSheetsListResult
143
+ >
144
+
145
+ /** Arguments for {@linkcode PluginPresentationSheetsApi.get}. */
146
+ export const PluginPresentationSheetsGetArgs = z.object({
147
+ id: z.string(),
148
+ })
149
+ export type PluginPresentationSheetsGetArgs = z.infer<
150
+ typeof PluginPresentationSheetsGetArgs
151
+ >
152
+
153
+ /** Result of {@linkcode PluginPresentationSheetsApi.get} — the sheet, or `null`. */
154
+ export const PluginPresentationSheetsGetResult =
155
+ PluginPresentationSheet.nullable()
156
+ export type PluginPresentationSheetsGetResult = z.infer<
157
+ typeof PluginPresentationSheetsGetResult
158
+ >
159
+
160
+ /** Arguments for {@linkcode PluginPresentationSheetsApi.create}. */
161
+ export const PluginPresentationSheetsCreateArgs = z.object({
162
+ name: z.string().optional(),
163
+ })
164
+ export type PluginPresentationSheetsCreateArgs = z.infer<
165
+ typeof PluginPresentationSheetsCreateArgs
166
+ >
167
+
168
+ /**
169
+ * Arguments for {@linkcode PluginPresentationSheetsApi.place}.
170
+ *
171
+ * | Property | Type | Description |
172
+ * |---|---|---|
173
+ * | `sheetId` | `string` | The sheet to place onto |
174
+ * | `viewId` | `string` | The saved view to place |
175
+ * | `position` | {@linkcode PluginSheetPosition}` \| undefined` | Where to place it (a default is used when omitted) |
176
+ */
177
+ export const PluginPresentationSheetsPlaceArgs = z.object({
178
+ sheetId: z.string(),
179
+ viewId: z.string(),
180
+ position: PluginSheetPosition.optional(),
181
+ })
182
+ export type PluginPresentationSheetsPlaceArgs = z.infer<
183
+ typeof PluginPresentationSheetsPlaceArgs
184
+ >
185
+
186
+ /**
187
+ * Result of {@linkcode PluginPresentationSheetsApi.place}.
188
+ *
189
+ * | Property | Type | Description |
190
+ * |---|---|---|
191
+ * | `shapeId` | `string` | Id of the created canvas shape |
192
+ */
193
+ export const PluginPresentationSheetsPlaceResult = z.object({
194
+ shapeId: z.string(),
195
+ })
196
+ export type PluginPresentationSheetsPlaceResult = z.infer<
197
+ typeof PluginPresentationSheetsPlaceResult
198
+ >
@@ -0,0 +1,303 @@
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), and save the current camera as a new view.
10
+ *
11
+ * `list`/`get`/`getActive`/`capture` are reads; `setActive`/`create` are writes
12
+ * (a view is a camera bookmark — not geometry). Members typed optional (`?`) are
13
+ * authored ahead of the host: declared for plugins/codegen but not yet on the
14
+ * live discovery surface until the host lands them.
15
+ *
16
+ * Accessed via `snaptrude.presentation.views`.
17
+ */
18
+ export abstract class PluginPresentationViewsApi {
19
+ constructor() {}
20
+
21
+ /**
22
+ * List the saved views in the active project.
23
+ *
24
+ * @returns A {@linkcode PluginPresentationViewsListResult} with a `views` array
25
+ * of 2D and 3D views (empty when the project has none).
26
+ *
27
+ * @examplePrompt List all the saved views
28
+ * @examplePrompt What 2D and 3D views are in this project?
29
+ * @examplePrompt Which view is currently active?
30
+ * @examplePrompt Get the names of every presentation view
31
+ * @examplePrompt Show me the 3D views I can put on a sheet
32
+ *
33
+ * # Example
34
+ * ```ts
35
+ * const { views } = await snaptrude.presentation.views.list()
36
+ * const active = views.find((v) => v.isActive)
37
+ * const plans = views.filter((v) => v.type === "2d")
38
+ * ```
39
+ */
40
+ public abstract list(): PluginApiReturn<PluginPresentationViewsListResult>
41
+
42
+ /**
43
+ * Get a single saved view by id.
44
+ *
45
+ * @param viewId - The id of the view to read.
46
+ * @returns The matching {@linkcode PluginPresentationView}, or `null` if no view
47
+ * has that id.
48
+ *
49
+ * @examplePrompt Get the view with id view_12345
50
+ * @examplePrompt Find the saved view called Ground Floor Plan
51
+ * @examplePrompt Look up a presentation view by its id
52
+ *
53
+ * # Example
54
+ * ```ts
55
+ * const view = await snaptrude.presentation.views.get("view_123")
56
+ * ```
57
+ */
58
+ public abstract get(
59
+ viewId: string,
60
+ ): PluginApiReturn<PluginPresentationViewsGetResult>
61
+
62
+ /**
63
+ * Get the currently active view.
64
+ *
65
+ * @returns The active {@linkcode PluginPresentationView}, or `null` if none is
66
+ * active.
67
+ *
68
+ * @examplePrompt Which view is active right now?
69
+ * @examplePrompt Get the current view
70
+ * @examplePrompt What view am I looking at?
71
+ *
72
+ * # Example
73
+ * ```ts
74
+ * const active = await snaptrude.presentation.views.getActive()
75
+ * ```
76
+ */
77
+ public abstract getActive(): PluginApiReturn<PluginPresentationViewsGetResult>
78
+
79
+ /**
80
+ * Capture a screenshot of a view as a base64 image.
81
+ *
82
+ * Captures the **current** viewport by default; pass `viewId` to capture a
83
+ * specific saved view (which briefly applies that view to the scene). Use
84
+ * `format`/`resolution` to control the output.
85
+ *
86
+ * @param options - All optional: `viewId` (capture this saved view; omit for the
87
+ * current viewport), `format` (default `"png"`), `resolution` (e.g. `"1280x720"`).
88
+ * @returns A {@linkcode PluginPresentationViewsCaptureResult} with the base64
89
+ * `image` data URL.
90
+ * @throws If a given `viewId` does not exist.
91
+ *
92
+ * @examplePrompt Take a screenshot of the current view
93
+ * @examplePrompt Capture this view as a PNG
94
+ * @examplePrompt Render the Site Plan view to an image
95
+ * @examplePrompt Export a high-res image of what I'm looking at
96
+ *
97
+ * # Example
98
+ * ```ts
99
+ * const { image } = await snaptrude.presentation.views.capture({ format: "png" })
100
+ * ```
101
+ */
102
+ public abstract capture(options?: {
103
+ viewId?: string
104
+ format?: "png" | "jpeg"
105
+ resolution?: string
106
+ }): PluginApiReturn<PluginPresentationViewsCaptureResult>
107
+
108
+ /**
109
+ * Activate a saved view — move the camera to it and restore its scene state.
110
+ *
111
+ * Applies the view's camera, visibility, and storey state to the live scene.
112
+ * Paired with {@linkcode PluginPresentationViewsApi.getActive}.
113
+ *
114
+ * @param viewId - The id of the view to activate.
115
+ * @returns The id of the now-active view.
116
+ * @throws If no view has the given id.
117
+ *
118
+ * @examplePrompt Switch to the Ground Floor plan view
119
+ * @examplePrompt Make the 3D view active
120
+ * @examplePrompt Go to the view named Entrance
121
+ * @examplePrompt Load the site plan view
122
+ *
123
+ * # Example
124
+ * ```ts
125
+ * await snaptrude.presentation.views.setActive("view_123")
126
+ * ```
127
+ */
128
+ public abstract setActive(
129
+ viewId: string,
130
+ ): PluginApiReturn<PluginPresentationViewsSetActiveResult>
131
+
132
+ /**
133
+ * Save the current camera/scene state as a new named view.
134
+ *
135
+ * Creates a camera bookmark (not geometry) from where the camera is now.
136
+ *
137
+ * @param name - Name for the new view (a default is used when omitted).
138
+ * @param options - Optional `kind`: what kind of view to save (default `"view"`).
139
+ * @returns The newly created {@linkcode PluginPresentationView}.
140
+ * @throws If the view could not be saved.
141
+ *
142
+ * @examplePrompt Save the current view as Lobby Perspective
143
+ * @examplePrompt Create a new saved view from where I'm looking
144
+ * @examplePrompt Bookmark this camera angle
145
+ * @examplePrompt Save the current 2D plan as a view
146
+ *
147
+ * # Example
148
+ * ```ts
149
+ * const view = await snaptrude.presentation.views.create("Lobby")
150
+ * ```
151
+ */
152
+ public abstract create(
153
+ name?: string,
154
+ options?: { kind?: "view" | "sitePlan" },
155
+ ): PluginApiReturn<PluginPresentationViewsCreateResult>
156
+ }
157
+
158
+ /**
159
+ * The kind of a saved view: a 2D plan view or a 3D view.
160
+ */
161
+ export const PluginPresentationViewType = z.enum(["2d", "3d"])
162
+ export type PluginPresentationViewType = z.infer<
163
+ typeof PluginPresentationViewType
164
+ >
165
+
166
+ /**
167
+ * A saved presentation view.
168
+ *
169
+ * | Property | Type | Description |
170
+ * |---|---|---|
171
+ * | `id` | `string` | Unique view id |
172
+ * | `name` | `string` | Display name |
173
+ * | `type` | `"2d" \| "3d"` | Whether this is a 2D plan view or a 3D view |
174
+ * | `isActive` | `boolean` | Whether this view is the currently active view |
175
+ */
176
+ export const PluginPresentationView = z.object({
177
+ id: z.string(),
178
+ name: z.string(),
179
+ type: PluginPresentationViewType,
180
+ isActive: z.boolean(),
181
+ })
182
+ export type PluginPresentationView = z.infer<typeof PluginPresentationView>
183
+
184
+ /**
185
+ * Result of {@linkcode PluginPresentationViewsApi.list}.
186
+ *
187
+ * | Property | Type | Description |
188
+ * |---|---|---|
189
+ * | `views` | {@linkcode PluginPresentationView}`[]` | All saved views in the project |
190
+ */
191
+ export const PluginPresentationViewsListResult = z.object({
192
+ views: z.array(PluginPresentationView),
193
+ })
194
+ export type PluginPresentationViewsListResult = z.infer<
195
+ typeof PluginPresentationViewsListResult
196
+ >
197
+
198
+ /**
199
+ * Arguments for {@linkcode PluginPresentationViewsApi.get}.
200
+ *
201
+ * | Property | Type | Description |
202
+ * |---|---|---|
203
+ * | `id` | `string` | The id of the view to read |
204
+ */
205
+ export const PluginPresentationViewsGetArgs = z.object({
206
+ id: z.string(),
207
+ })
208
+ export type PluginPresentationViewsGetArgs = z.infer<
209
+ typeof PluginPresentationViewsGetArgs
210
+ >
211
+
212
+ /**
213
+ * Result of {@linkcode PluginPresentationViewsApi.get} and
214
+ * {@linkcode PluginPresentationViewsApi.getActive} — the view, or `null` when
215
+ * there is no match / no active view.
216
+ */
217
+ export const PluginPresentationViewsGetResult =
218
+ PluginPresentationView.nullable()
219
+ export type PluginPresentationViewsGetResult = z.infer<
220
+ typeof PluginPresentationViewsGetResult
221
+ >
222
+
223
+ /** Image format for {@linkcode PluginPresentationViewsApi.capture}. */
224
+ export const PluginPresentationImageFormat = z.enum(["png", "jpeg"])
225
+ export type PluginPresentationImageFormat = z.infer<
226
+ typeof PluginPresentationImageFormat
227
+ >
228
+
229
+ /**
230
+ * Arguments for {@linkcode PluginPresentationViewsApi.capture}. All optional.
231
+ *
232
+ * | Property | Type | Description |
233
+ * |---|---|---|
234
+ * | `viewId` | `string \| undefined` | Capture this saved view; omit to capture the current viewport |
235
+ * | `format` | `"png" \| "jpeg" \| undefined` | Output image format (default `"png"`) |
236
+ * | `resolution` | `string \| undefined` | Optional resolution hint (e.g. `"1280x720"`) |
237
+ */
238
+ export const PluginPresentationViewsCaptureArgs = z.object({
239
+ viewId: z.string().optional(),
240
+ format: PluginPresentationImageFormat.optional(),
241
+ resolution: z.string().optional(),
242
+ })
243
+ export type PluginPresentationViewsCaptureArgs = z.infer<
244
+ typeof PluginPresentationViewsCaptureArgs
245
+ >
246
+
247
+ /**
248
+ * Result of {@linkcode PluginPresentationViewsApi.capture}.
249
+ *
250
+ * | Property | Type | Description |
251
+ * |---|---|---|
252
+ * | `image` | `string` | The captured image as a base64 data URL |
253
+ */
254
+ export const PluginPresentationViewsCaptureResult = z.object({
255
+ image: z.string(),
256
+ })
257
+ export type PluginPresentationViewsCaptureResult = z.infer<
258
+ typeof PluginPresentationViewsCaptureResult
259
+ >
260
+
261
+ /**
262
+ * Arguments for {@linkcode PluginPresentationViewsApi.setActive}.
263
+ *
264
+ * | Property | Type | Description |
265
+ * |---|---|---|
266
+ * | `id` | `string` | The id of the view to activate |
267
+ */
268
+ export const PluginPresentationViewsSetActiveArgs = z.object({
269
+ id: z.string(),
270
+ })
271
+ export type PluginPresentationViewsSetActiveArgs = z.infer<
272
+ typeof PluginPresentationViewsSetActiveArgs
273
+ >
274
+
275
+ /** Result of {@linkcode PluginPresentationViewsApi.setActive} — the active view's id. */
276
+ export const PluginPresentationViewsSetActiveResult = z.object({
277
+ id: z.string(),
278
+ })
279
+ export type PluginPresentationViewsSetActiveResult = z.infer<
280
+ typeof PluginPresentationViewsSetActiveResult
281
+ >
282
+
283
+ /**
284
+ * Arguments for {@linkcode PluginPresentationViewsApi.create}. All optional.
285
+ *
286
+ * | Property | Type | Description |
287
+ * |---|---|---|
288
+ * | `name` | `string \| undefined` | Name for the new view (a default is used when omitted) |
289
+ * | `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. |
290
+ */
291
+ export const PluginPresentationViewsCreateArgs = z.object({
292
+ name: z.string().optional(),
293
+ kind: z.enum(["view", "sitePlan"]).optional(),
294
+ })
295
+ export type PluginPresentationViewsCreateArgs = z.infer<
296
+ typeof PluginPresentationViewsCreateArgs
297
+ >
298
+
299
+ /** Result of {@linkcode PluginPresentationViewsApi.create} — the saved view. */
300
+ export const PluginPresentationViewsCreateResult = PluginPresentationView
301
+ export type PluginPresentationViewsCreateResult = z.infer<
302
+ typeof PluginPresentationViewsCreateResult
303
+ >