@snaptrude/plugin-core 0.8.0 → 0.9.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +35 -1
- package/api-manifest.full.json +1350 -89
- package/api-manifest.json +1146 -48
- package/dist/api/analysis/daylight.d.ts +603 -0
- package/dist/api/analysis/daylight.d.ts.map +1 -0
- package/dist/api/analysis/heatmaps.d.ts +438 -14
- package/dist/api/analysis/heatmaps.d.ts.map +1 -1
- package/dist/api/analysis/index.d.ts +15 -0
- package/dist/api/analysis/index.d.ts.map +1 -1
- package/dist/api/analysis/solar.d.ts +249 -0
- package/dist/api/analysis/solar.d.ts.map +1 -0
- package/dist/api/analysis/weather.d.ts +193 -0
- package/dist/api/analysis/weather.d.ts.map +1 -0
- package/dist/api/core/camera/index.d.ts +37 -0
- package/dist/api/core/camera/index.d.ts.map +1 -1
- package/dist/api/core/geom/create/index.d.ts +318 -1
- package/dist/api/core/geom/create/index.d.ts.map +1 -1
- package/dist/api/core/index.d.ts +9 -0
- package/dist/api/core/index.d.ts.map +1 -1
- package/dist/api/core/io/export/index.d.ts +3 -1
- package/dist/api/core/io/export/index.d.ts.map +1 -1
- package/dist/api/core/io/import/index.d.ts +61 -0
- package/dist/api/core/io/import/index.d.ts.map +1 -1
- package/dist/api/core/io/terrain/index.d.ts +132 -0
- package/dist/api/core/io/terrain/index.d.ts.map +1 -1
- package/dist/api/core/mode/index.d.ts +99 -0
- package/dist/api/core/mode/index.d.ts.map +1 -0
- package/dist/api/core/storeys/index.d.ts +251 -0
- package/dist/api/core/storeys/index.d.ts.map +1 -0
- package/dist/api/core/tags.d.ts +24 -0
- package/dist/api/core/tags.d.ts.map +1 -1
- package/dist/api/core/zoom/index.d.ts +4 -0
- package/dist/api/core/zoom/index.d.ts.map +1 -1
- package/dist/api/design/create/index.d.ts +115 -4
- package/dist/api/design/create/index.d.ts.map +1 -1
- package/dist/api/design/delete/index.d.ts +3 -0
- package/dist/api/design/delete/index.d.ts.map +1 -1
- package/dist/api/design/query/geometry/index.d.ts +112 -0
- package/dist/api/design/query/geometry/index.d.ts.map +1 -1
- package/dist/api/design/query/index.d.ts +4 -0
- package/dist/api/design/query/index.d.ts.map +1 -1
- package/dist/api/design/query/referenceLines.d.ts +45 -0
- package/dist/api/design/query/referenceLines.d.ts.map +1 -0
- package/dist/api/design/query/spaces.d.ts +173 -0
- package/dist/api/design/query/spaces.d.ts.map +1 -1
- package/dist/api/design/transform/index.d.ts +12 -0
- package/dist/api/design/transform/index.d.ts.map +1 -1
- package/dist/api/design/update/index.d.ts +51 -1
- package/dist/api/design/update/index.d.ts.map +1 -1
- package/dist/api/entity/buildableEnvelope.d.ts +4 -0
- package/dist/api/entity/buildableEnvelope.d.ts.map +1 -1
- package/dist/api/entity/referenceLine.d.ts +8 -0
- package/dist/api/entity/referenceLine.d.ts.map +1 -1
- package/dist/api/entity/story.d.ts +20 -0
- package/dist/api/entity/story.d.ts.map +1 -1
- package/dist/api/index.d.ts +5 -0
- package/dist/api/index.d.ts.map +1 -1
- package/dist/api/presentation/annotate.d.ts +23 -4
- package/dist/api/presentation/annotate.d.ts.map +1 -1
- package/dist/api/presentation/diagrams.d.ts +64 -2
- package/dist/api/presentation/diagrams.d.ts.map +1 -1
- package/dist/api/presentation/export.d.ts +4 -0
- package/dist/api/presentation/export.d.ts.map +1 -1
- package/dist/api/presentation/import.d.ts +6 -0
- package/dist/api/presentation/import.d.ts.map +1 -1
- package/dist/api/presentation/index.d.ts +20 -1
- package/dist/api/presentation/index.d.ts.map +1 -1
- package/dist/api/presentation/placedViews.d.ts +1139 -0
- package/dist/api/presentation/placedViews.d.ts.map +1 -0
- package/dist/api/presentation/shapes.d.ts +481 -0
- package/dist/api/presentation/shapes.d.ts.map +1 -0
- package/dist/api/presentation/sheets.d.ts +42 -0
- package/dist/api/presentation/sheets.d.ts.map +1 -1
- package/dist/api/presentation/slideshow.d.ts +125 -0
- package/dist/api/presentation/slideshow.d.ts.map +1 -0
- package/dist/api/presentation/tables.d.ts +81 -0
- package/dist/api/presentation/tables.d.ts.map +1 -0
- package/dist/api/program/site.d.ts +260 -2
- package/dist/api/program/site.d.ts.map +1 -1
- package/dist/api/program/spreadsheet.d.ts +260 -28
- package/dist/api/program/spreadsheet.d.ts.map +1 -1
- package/dist/api/workspace/index.d.ts +505 -0
- package/dist/api/workspace/index.d.ts.map +1 -0
- package/dist/index.cjs +2904 -1761
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +2762 -1761
- package/dist/index.js.map +1 -1
- package/package.json +3 -2
- package/scripts/generate-manifest.mjs +45 -0
- package/src/api/analysis/daylight.ts +470 -0
- package/src/api/analysis/heatmaps.ts +444 -17
- package/src/api/analysis/index.ts +15 -0
- package/src/api/analysis/solar.ts +237 -0
- package/src/api/analysis/weather.ts +179 -0
- package/src/api/core/camera/index.ts +39 -0
- package/src/api/core/geom/create/index.ts +344 -1
- package/src/api/core/index.ts +9 -0
- package/src/api/core/io/export/index.ts +3 -1
- package/src/api/core/io/import/index.ts +64 -0
- package/src/api/core/io/terrain/index.ts +143 -0
- package/src/api/core/mode/index.ts +96 -0
- package/src/api/core/storeys/index.ts +279 -0
- package/src/api/core/tags.ts +27 -0
- package/src/api/core/zoom/index.ts +4 -0
- package/src/api/design/create/index.ts +138 -1
- package/src/api/design/delete/index.ts +3 -0
- package/src/api/design/query/geometry/index.ts +125 -3
- package/src/api/design/query/index.ts +4 -0
- package/src/api/design/query/referenceLines.ts +52 -0
- package/src/api/design/query/spaces.ts +143 -0
- package/src/api/design/transform/index.ts +12 -0
- package/src/api/design/update/index.ts +66 -1
- package/src/api/entity/buildableEnvelope.ts +4 -0
- package/src/api/entity/referenceLine.ts +8 -0
- package/src/api/entity/story.ts +20 -0
- package/src/api/index.ts +5 -0
- package/src/api/presentation/annotate.ts +27 -2
- package/src/api/presentation/diagrams.ts +67 -2
- package/src/api/presentation/export.ts +4 -0
- package/src/api/presentation/import.ts +6 -0
- package/src/api/presentation/index.ts +20 -1
- package/src/api/presentation/placedViews.ts +1120 -0
- package/src/api/presentation/shapes.ts +274 -0
- package/src/api/presentation/sheets.ts +54 -0
- package/src/api/presentation/slideshow.ts +134 -0
- package/src/api/presentation/tables.ts +84 -0
- package/src/api/program/site.ts +205 -2
- package/src/api/program/spreadsheet.ts +251 -6
- package/src/api/workspace/index.ts +563 -0
|
@@ -0,0 +1,274 @@
|
|
|
1
|
+
import * as z from "zod"
|
|
2
|
+
import { PluginApiReturn } from "../../types"
|
|
3
|
+
import {
|
|
4
|
+
PluginAnnotateFill,
|
|
5
|
+
PluginAnnotateGeoKind,
|
|
6
|
+
PluginAnnotateTextColor,
|
|
7
|
+
PluginAnnotateTextSize,
|
|
8
|
+
} from "./annotate"
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Presentation shapes — a stable, plugin-owned shape lifecycle on Present-mode
|
|
12
|
+
* sheets.
|
|
13
|
+
*
|
|
14
|
+
* Where {@linkcode PluginPresentationAnnotateApi} is fire-and-forget (every call
|
|
15
|
+
* creates a new shape), this namespace keys each shape by a caller-chosen
|
|
16
|
+
* string, so rerunning an analysis **updates** its sheet output in place instead
|
|
17
|
+
* of duplicating it:
|
|
18
|
+
*
|
|
19
|
+
* - {@linkcode PluginPresentationShapesApi.upsert} — create or update the shape for a key
|
|
20
|
+
* - {@linkcode PluginPresentationShapesApi.remove} — delete the shape for a key
|
|
21
|
+
* - {@linkcode PluginPresentationShapesApi.removeAll} — delete every shape owned by the calling plugin
|
|
22
|
+
* - {@linkcode PluginPresentationShapesApi.list} — the calling plugin's shapes (key, shapeId, type)
|
|
23
|
+
*
|
|
24
|
+
* Shape ids are derived deterministically from the plugin id + key, so upserts
|
|
25
|
+
* converge across collaborators. Mutations require **Present mode to be open**
|
|
26
|
+
* (`list` is a never-throw read); each plugin sees and mutates only its own
|
|
27
|
+
* shapes.
|
|
28
|
+
*
|
|
29
|
+
* Accessed via `snaptrude.presentation.shapes`.
|
|
30
|
+
*/
|
|
31
|
+
export abstract class PluginPresentationShapesApi {
|
|
32
|
+
constructor() {}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Create or update the shape for a key.
|
|
36
|
+
*
|
|
37
|
+
* The `shape` spec is a discriminated union over the same four annotation
|
|
38
|
+
* kinds as `presentation.annotate` (`text`, `note`, `arrow`, `geo`), with the
|
|
39
|
+
* same option shapes. On first call for a key the shape is created on the
|
|
40
|
+
* target sheet (`options.sheetId`, default: the first sheet) and nested under
|
|
41
|
+
* the sheet frame; on later calls the existing shape is updated in place —
|
|
42
|
+
* same shape id, same sheet, one undo step. Positions/bounds are relative to
|
|
43
|
+
* the sheet's top-left, in canvas units. Requires Present mode to be open.
|
|
44
|
+
*
|
|
45
|
+
* @param key - Caller-chosen stable identifier for the shape (per plugin).
|
|
46
|
+
* @param shape - The desired shape ({@linkcode PluginPresentationShapeSpec}):
|
|
47
|
+
* `{ type: "text" | "note" | "arrow" | "geo", ... }` with the matching
|
|
48
|
+
* annotate options. Changing `type` for an existing key replaces the shape
|
|
49
|
+
* (same shape id).
|
|
50
|
+
* @param options - Optional `sheetId` — the sheet to create the shape on
|
|
51
|
+
* (defaults to the first sheet; ignored on update, the shape stays on its
|
|
52
|
+
* sheet).
|
|
53
|
+
* @returns A {@linkcode PluginPresentationShapesUpsertResult} — the stable
|
|
54
|
+
* `shapeId` and `created` (`true` on first upsert, `false` on update).
|
|
55
|
+
* @throws If Present mode is not open, the args are invalid, or the sheet id
|
|
56
|
+
* is unknown.
|
|
57
|
+
*
|
|
58
|
+
* @examplePrompt Update the analysis label on the sheet instead of adding another one
|
|
59
|
+
* @examplePrompt Rerun the daylight report and refresh its annotations
|
|
60
|
+
* @examplePrompt Keep one "FAR: 2.4" text on Sheet 1 that updates on each run
|
|
61
|
+
* @examplePrompt Draw a highlight rectangle the plugin can move on the next run
|
|
62
|
+
*
|
|
63
|
+
* # Example
|
|
64
|
+
* ```ts
|
|
65
|
+
* const { shapeId, created } = await snaptrude.presentation.shapes.upsert("far-label", {
|
|
66
|
+
* type: "text",
|
|
67
|
+
* text: "FAR: 2.4",
|
|
68
|
+
* position: { x: 40, y: 40 },
|
|
69
|
+
* color: "blue",
|
|
70
|
+
* })
|
|
71
|
+
* ```
|
|
72
|
+
*/
|
|
73
|
+
public abstract upsert(
|
|
74
|
+
key: string,
|
|
75
|
+
shape: PluginPresentationShapeSpec,
|
|
76
|
+
options?: { sheetId?: string },
|
|
77
|
+
): PluginApiReturn<PluginPresentationShapesUpsertResult>
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* Delete the shape for a key.
|
|
81
|
+
*
|
|
82
|
+
* Removes the calling plugin's shape registered under `key`, if it exists.
|
|
83
|
+
* Requires Present mode to be open.
|
|
84
|
+
*
|
|
85
|
+
* @param key - The key passed to {@linkcode PluginPresentationShapesApi.upsert}.
|
|
86
|
+
* @returns `true` if a shape was deleted, `false` if no shape exists for the
|
|
87
|
+
* key.
|
|
88
|
+
* @throws If Present mode is not open or the key is invalid.
|
|
89
|
+
*
|
|
90
|
+
* @examplePrompt Remove the FAR label from the sheet
|
|
91
|
+
* @examplePrompt Delete the highlight the plugin added earlier
|
|
92
|
+
* @examplePrompt Clear the "far-label" annotation
|
|
93
|
+
*
|
|
94
|
+
* # Example
|
|
95
|
+
* ```ts
|
|
96
|
+
* const removed = await snaptrude.presentation.shapes.remove("far-label")
|
|
97
|
+
* ```
|
|
98
|
+
*/
|
|
99
|
+
public abstract remove(key: string): PluginApiReturn<boolean>
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* Delete every shape owned by the calling plugin.
|
|
103
|
+
*
|
|
104
|
+
* Removes all shapes the calling plugin has upserted (across all sheets) in
|
|
105
|
+
* one undo step. Requires Present mode to be open.
|
|
106
|
+
*
|
|
107
|
+
* @returns The number of shapes deleted.
|
|
108
|
+
* @throws If Present mode is not open.
|
|
109
|
+
*
|
|
110
|
+
* @examplePrompt Clear all annotations my plugin added
|
|
111
|
+
* @examplePrompt Reset the sheet output before rerunning the analysis
|
|
112
|
+
* @examplePrompt Remove every plugin-drawn shape
|
|
113
|
+
*
|
|
114
|
+
* # Example
|
|
115
|
+
* ```ts
|
|
116
|
+
* const deleted = await snaptrude.presentation.shapes.removeAll()
|
|
117
|
+
* ```
|
|
118
|
+
*/
|
|
119
|
+
public abstract removeAll(): PluginApiReturn<number>
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* List the calling plugin's shapes.
|
|
123
|
+
*
|
|
124
|
+
* Returns one entry per live shape the calling plugin has upserted — its
|
|
125
|
+
* `key`, the underlying canvas `shapeId`, and the shape `type`. A never-throw
|
|
126
|
+
* read: returns an empty list when Present mode is closed.
|
|
127
|
+
*
|
|
128
|
+
* @returns A {@linkcode PluginPresentationShapesListResult} with the `shapes`
|
|
129
|
+
* array (empty when Present mode is closed).
|
|
130
|
+
*
|
|
131
|
+
* @examplePrompt Which annotations has my plugin placed on the sheets?
|
|
132
|
+
* @examplePrompt List the plugin's shapes before refreshing them
|
|
133
|
+
* @examplePrompt Check whether the FAR label already exists
|
|
134
|
+
*
|
|
135
|
+
* # Example
|
|
136
|
+
* ```ts
|
|
137
|
+
* const { shapes } = await snaptrude.presentation.shapes.list()
|
|
138
|
+
* const hasLabel = shapes.some((s) => s.key === "far-label")
|
|
139
|
+
* ```
|
|
140
|
+
*/
|
|
141
|
+
public abstract list(): PluginApiReturn<PluginPresentationShapesListResult>
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* Desired shape for {@linkcode PluginPresentationShapesApi.upsert} — a
|
|
146
|
+
* discriminated union over the four annotate kinds, with the same option shapes
|
|
147
|
+
* as the matching `presentation.annotate` call:
|
|
148
|
+
*
|
|
149
|
+
* | `type` | Payload | Mirrors |
|
|
150
|
+
* |---|---|---|
|
|
151
|
+
* | `"text"` | `text`, `position?`, `size?`, `color?` | `annotate.text` |
|
|
152
|
+
* | `"note"` | `text`, `position?`, `color?`, `size?` | `annotate.note` |
|
|
153
|
+
* | `"arrow"` | `start`, `end`, `color?`, `size?` | `annotate.arrow` |
|
|
154
|
+
* | `"geo"` | `kind`, `bounds`, `color?`, `fill?` | `annotate.shape` |
|
|
155
|
+
*
|
|
156
|
+
* Positions/bounds are relative to the sheet's top-left, in canvas units.
|
|
157
|
+
*/
|
|
158
|
+
export const PluginPresentationShapeSpec = z.discriminatedUnion("type", [
|
|
159
|
+
z.object({
|
|
160
|
+
type: z.literal("text"),
|
|
161
|
+
text: z.string(),
|
|
162
|
+
position: z.object({ x: z.number(), y: z.number() }).optional(),
|
|
163
|
+
size: PluginAnnotateTextSize.optional(),
|
|
164
|
+
color: PluginAnnotateTextColor.optional(),
|
|
165
|
+
}),
|
|
166
|
+
z.object({
|
|
167
|
+
type: z.literal("note"),
|
|
168
|
+
text: z.string(),
|
|
169
|
+
position: z.object({ x: z.number(), y: z.number() }).optional(),
|
|
170
|
+
color: PluginAnnotateTextColor.optional(),
|
|
171
|
+
size: PluginAnnotateTextSize.optional(),
|
|
172
|
+
}),
|
|
173
|
+
z.object({
|
|
174
|
+
type: z.literal("arrow"),
|
|
175
|
+
start: z.object({ x: z.number(), y: z.number() }),
|
|
176
|
+
end: z.object({ x: z.number(), y: z.number() }),
|
|
177
|
+
color: PluginAnnotateTextColor.optional(),
|
|
178
|
+
size: PluginAnnotateTextSize.optional(),
|
|
179
|
+
}),
|
|
180
|
+
z.object({
|
|
181
|
+
type: z.literal("geo"),
|
|
182
|
+
kind: PluginAnnotateGeoKind,
|
|
183
|
+
bounds: z.object({
|
|
184
|
+
x: z.number(),
|
|
185
|
+
y: z.number(),
|
|
186
|
+
w: z.number().positive(),
|
|
187
|
+
h: z.number().positive(),
|
|
188
|
+
}),
|
|
189
|
+
color: PluginAnnotateTextColor.optional(),
|
|
190
|
+
fill: PluginAnnotateFill.optional(),
|
|
191
|
+
}),
|
|
192
|
+
])
|
|
193
|
+
export type PluginPresentationShapeSpec = z.infer<
|
|
194
|
+
typeof PluginPresentationShapeSpec
|
|
195
|
+
>
|
|
196
|
+
|
|
197
|
+
/** The shape kind of a plugin-owned shape (the `type` discriminant of {@linkcode PluginPresentationShapeSpec}). */
|
|
198
|
+
export const PluginPresentationShapeType = z.enum([
|
|
199
|
+
"text",
|
|
200
|
+
"note",
|
|
201
|
+
"arrow",
|
|
202
|
+
"geo",
|
|
203
|
+
])
|
|
204
|
+
export type PluginPresentationShapeType = z.infer<
|
|
205
|
+
typeof PluginPresentationShapeType
|
|
206
|
+
>
|
|
207
|
+
|
|
208
|
+
/**
|
|
209
|
+
* Arguments for {@linkcode PluginPresentationShapesApi.upsert}.
|
|
210
|
+
*
|
|
211
|
+
* | Property | Type | Description |
|
|
212
|
+
* |---|---|---|
|
|
213
|
+
* | `key` | `string` | Caller-chosen stable identifier (non-empty) |
|
|
214
|
+
* | `shape` | {@linkcode PluginPresentationShapeSpec} | The desired shape |
|
|
215
|
+
* | `sheetId` | `string \| undefined` | Sheet to create on (default: first sheet; ignored on update) |
|
|
216
|
+
*/
|
|
217
|
+
export const PluginPresentationShapesUpsertArgs = z.object({
|
|
218
|
+
key: z.string().min(1),
|
|
219
|
+
shape: PluginPresentationShapeSpec,
|
|
220
|
+
sheetId: z.string().optional(),
|
|
221
|
+
})
|
|
222
|
+
export type PluginPresentationShapesUpsertArgs = z.infer<
|
|
223
|
+
typeof PluginPresentationShapesUpsertArgs
|
|
224
|
+
>
|
|
225
|
+
|
|
226
|
+
/**
|
|
227
|
+
* Result of {@linkcode PluginPresentationShapesApi.upsert}.
|
|
228
|
+
*
|
|
229
|
+
* | Property | Type | Description |
|
|
230
|
+
* |---|---|---|
|
|
231
|
+
* | `shapeId` | `string` | Stable id of the canvas shape for the key |
|
|
232
|
+
* | `created` | `boolean` | `true` if the shape was created, `false` if updated |
|
|
233
|
+
*/
|
|
234
|
+
export const PluginPresentationShapesUpsertResult = z.object({
|
|
235
|
+
shapeId: z.string(),
|
|
236
|
+
created: z.boolean(),
|
|
237
|
+
})
|
|
238
|
+
export type PluginPresentationShapesUpsertResult = z.infer<
|
|
239
|
+
typeof PluginPresentationShapesUpsertResult
|
|
240
|
+
>
|
|
241
|
+
|
|
242
|
+
/**
|
|
243
|
+
* Arguments for {@linkcode PluginPresentationShapesApi.remove}.
|
|
244
|
+
*
|
|
245
|
+
* | Property | Type | Description |
|
|
246
|
+
* |---|---|---|
|
|
247
|
+
* | `key` | `string` | The key the shape was upserted under (non-empty) |
|
|
248
|
+
*/
|
|
249
|
+
export const PluginPresentationShapesRemoveArgs = z.object({
|
|
250
|
+
key: z.string().min(1),
|
|
251
|
+
})
|
|
252
|
+
export type PluginPresentationShapesRemoveArgs = z.infer<
|
|
253
|
+
typeof PluginPresentationShapesRemoveArgs
|
|
254
|
+
>
|
|
255
|
+
|
|
256
|
+
/**
|
|
257
|
+
* Result of {@linkcode PluginPresentationShapesApi.list}.
|
|
258
|
+
*
|
|
259
|
+
* | Property | Type | Description |
|
|
260
|
+
* |---|---|---|
|
|
261
|
+
* | `shapes` | `{ key: string; shapeId: string; type: `{@linkcode PluginPresentationShapeType}` }[]` | One entry per live plugin-owned shape |
|
|
262
|
+
*/
|
|
263
|
+
export const PluginPresentationShapesListResult = z.object({
|
|
264
|
+
shapes: z.array(
|
|
265
|
+
z.object({
|
|
266
|
+
key: z.string(),
|
|
267
|
+
shapeId: z.string(),
|
|
268
|
+
type: PluginPresentationShapeType,
|
|
269
|
+
}),
|
|
270
|
+
),
|
|
271
|
+
})
|
|
272
|
+
export type PluginPresentationShapesListResult = z.infer<
|
|
273
|
+
typeof PluginPresentationShapesListResult
|
|
274
|
+
>
|
|
@@ -126,6 +126,34 @@ export abstract class PluginPresentationSheetsApi {
|
|
|
126
126
|
orientation?: PluginSheetOrientation,
|
|
127
127
|
): PluginApiReturn<PluginPresentationSheet>
|
|
128
128
|
|
|
129
|
+
/**
|
|
130
|
+
* Set a sheet's print margin.
|
|
131
|
+
*
|
|
132
|
+
* Applies one of the canonical margin presets — exactly what the sheet
|
|
133
|
+
* header's margin dropdown does. `margin` is unit-agnostic: `0 | 0.25 |
|
|
134
|
+
* 0.5 | 0.75 | 1`, displayed as None / 1/4″ / 1/2″ / 3/4″ / 1″ on imperial
|
|
135
|
+
* projects and None / 5mm / 10mm / 15mm / 20mm on metric ones. One undo
|
|
136
|
+
* step. Requires Present mode to be open.
|
|
137
|
+
*
|
|
138
|
+
* @param sheetId - The id of the sheet.
|
|
139
|
+
* @param margin - The margin preset ({@linkcode PluginSheetMargin}).
|
|
140
|
+
* @returns The updated {@linkcode PluginPresentationSheet}.
|
|
141
|
+
* @throws If Present mode is not open, or the sheet id is invalid.
|
|
142
|
+
*
|
|
143
|
+
* @examplePrompt Set the sheet margin to half an inch
|
|
144
|
+
* @examplePrompt Remove the margins on sheet_1
|
|
145
|
+
* @examplePrompt Give the cover sheet a 10mm margin
|
|
146
|
+
*
|
|
147
|
+
* # Example
|
|
148
|
+
* ```ts
|
|
149
|
+
* const sheet = await snaptrude.presentation.sheets.setMargin("sheet_1", 0.5)
|
|
150
|
+
* ```
|
|
151
|
+
*/
|
|
152
|
+
public abstract setMargin(
|
|
153
|
+
sheetId: string,
|
|
154
|
+
margin: PluginSheetMargin,
|
|
155
|
+
): PluginApiReturn<PluginPresentationSheet>
|
|
156
|
+
|
|
129
157
|
/**
|
|
130
158
|
* Place a saved view onto a sheet.
|
|
131
159
|
*
|
|
@@ -331,6 +359,21 @@ export type PluginSheetSize = z.infer<typeof PluginSheetSize>
|
|
|
331
359
|
export const PluginSheetOrientation = z.enum(["landscape", "portrait"])
|
|
332
360
|
export type PluginSheetOrientation = z.infer<typeof PluginSheetOrientation>
|
|
333
361
|
|
|
362
|
+
/**
|
|
363
|
+
* Canonical sheet margin presets — unit-agnostic values matching the sheet
|
|
364
|
+
* header's margin dropdown: `0` (None), `0.25`, `0.5`, `0.75`, `1`.
|
|
365
|
+
* Displayed as None / 1/4″ / 1/2″ / 3/4″ / 1″ on imperial projects and
|
|
366
|
+
* None / 5mm / 10mm / 15mm / 20mm on metric ones.
|
|
367
|
+
*/
|
|
368
|
+
export const PluginSheetMargin = z.union([
|
|
369
|
+
z.literal(0),
|
|
370
|
+
z.literal(0.25),
|
|
371
|
+
z.literal(0.5),
|
|
372
|
+
z.literal(0.75),
|
|
373
|
+
z.literal(1),
|
|
374
|
+
])
|
|
375
|
+
export type PluginSheetMargin = z.infer<typeof PluginSheetMargin>
|
|
376
|
+
|
|
334
377
|
/**
|
|
335
378
|
* A layout sheet in the presentation.
|
|
336
379
|
*
|
|
@@ -340,12 +383,14 @@ export type PluginSheetOrientation = z.infer<typeof PluginSheetOrientation>
|
|
|
340
383
|
* | `name` | `string` | Display name |
|
|
341
384
|
* | `size` | {@linkcode PluginSheetSize}` \| null` | Paper preset (`null` for a legacy sheet without one) |
|
|
342
385
|
* | `orientation` | {@linkcode PluginSheetOrientation}` \| null` | Orientation (`null` for a legacy sheet) |
|
|
386
|
+
* | `margin` | {@linkcode PluginSheetMargin}` \| null` | Margin preset (`null` when absent/unrecognized) |
|
|
343
387
|
*/
|
|
344
388
|
export const PluginPresentationSheet = z.object({
|
|
345
389
|
id: z.string(),
|
|
346
390
|
name: z.string(),
|
|
347
391
|
size: PluginSheetSize.nullable(),
|
|
348
392
|
orientation: PluginSheetOrientation.nullable(),
|
|
393
|
+
margin: PluginSheetMargin.nullable(),
|
|
349
394
|
})
|
|
350
395
|
export type PluginPresentationSheet = z.infer<typeof PluginPresentationSheet>
|
|
351
396
|
|
|
@@ -406,6 +451,15 @@ export type PluginPresentationSheetsSetSizeArgs = z.infer<
|
|
|
406
451
|
typeof PluginPresentationSheetsSetSizeArgs
|
|
407
452
|
>
|
|
408
453
|
|
|
454
|
+
/** Arguments for {@linkcode PluginPresentationSheetsApi.setMargin}. */
|
|
455
|
+
export const PluginPresentationSheetsSetMarginArgs = z.object({
|
|
456
|
+
sheetId: z.string(),
|
|
457
|
+
margin: PluginSheetMargin,
|
|
458
|
+
})
|
|
459
|
+
export type PluginPresentationSheetsSetMarginArgs = z.infer<
|
|
460
|
+
typeof PluginPresentationSheetsSetMarginArgs
|
|
461
|
+
>
|
|
462
|
+
|
|
409
463
|
/**
|
|
410
464
|
* Arguments for {@linkcode PluginPresentationSheetsApi.place}.
|
|
411
465
|
*
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import * as z from "zod"
|
|
2
|
+
import { PluginApiReturn } from "../../types"
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Presentation slideshow — run the Present-mode slideshow programmatically.
|
|
6
|
+
*
|
|
7
|
+
* The scriptable counterpart of the Present toolbar's slideshow: the
|
|
8
|
+
* slideshow plays **all** layout sheets in sheet order (hidden sheets are
|
|
9
|
+
* excluded) — `start` options only pick the slide it opens on. Slide
|
|
10
|
+
* navigation stays with the user (arrow keys / on-screen controls); there is
|
|
11
|
+
* intentionally no `next`/`prev`/`goTo`.
|
|
12
|
+
*
|
|
13
|
+
* **Fullscreen caveat:** browsers only grant fullscreen on a user gesture. A
|
|
14
|
+
* plugin-triggered `start` usually fails that check, in which case the
|
|
15
|
+
* slideshow catches the rejection and runs non-fullscreen (same slides, same
|
|
16
|
+
* controls, windowed).
|
|
17
|
+
*
|
|
18
|
+
* `start`/`stop` are write-gated; `getState` is a never-throw read. Requires
|
|
19
|
+
* Present mode to be open (except `getState`, which reports not-running).
|
|
20
|
+
*
|
|
21
|
+
* Accessed via `snaptrude.presentation.slideshow`.
|
|
22
|
+
*/
|
|
23
|
+
export abstract class PluginPresentationSlideshowApi {
|
|
24
|
+
constructor() {}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Start the slideshow.
|
|
28
|
+
*
|
|
29
|
+
* Launches the Present-mode slideshow over all layout sheets in sheet
|
|
30
|
+
* order. `options.startIndex` opens on that slide (clamped into range);
|
|
31
|
+
* otherwise `options.sheetIds` naming exactly one sheet opens on that
|
|
32
|
+
* sheet; otherwise it opens on the first slide. May run non-fullscreen —
|
|
33
|
+
* see the fullscreen caveat on
|
|
34
|
+
* {@linkcode PluginPresentationSlideshowApi}. Requires Present mode to be
|
|
35
|
+
* open with at least one sheet.
|
|
36
|
+
*
|
|
37
|
+
* @param options - Optional `sheetIds` (open on this sheet when exactly one
|
|
38
|
+
* id is given) and `startIndex` (0-based slide to open on; wins over
|
|
39
|
+
* `sheetIds`; clamped into range).
|
|
40
|
+
* @returns The {@linkcode PluginPresentationSlideshowState} after the
|
|
41
|
+
* launch (`running: true` and the opening `index`).
|
|
42
|
+
* @throws If Present mode is not open or there are no sheets to present.
|
|
43
|
+
*
|
|
44
|
+
* @examplePrompt Start the slideshow
|
|
45
|
+
* @examplePrompt Present the sheets from the beginning
|
|
46
|
+
* @examplePrompt Start the slideshow on sheet 3
|
|
47
|
+
* @examplePrompt Play the presentation starting at the cover sheet
|
|
48
|
+
*
|
|
49
|
+
* # Example
|
|
50
|
+
* ```ts
|
|
51
|
+
* const state = await snaptrude.presentation.slideshow.start({ startIndex: 2 })
|
|
52
|
+
* console.log(state.running, state.index) // true, 2
|
|
53
|
+
* ```
|
|
54
|
+
*/
|
|
55
|
+
public abstract start(options?: {
|
|
56
|
+
sheetIds?: string[]
|
|
57
|
+
startIndex?: number
|
|
58
|
+
}): PluginApiReturn<PluginPresentationSlideshowState>
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Stop the slideshow.
|
|
62
|
+
*
|
|
63
|
+
* Closes the running slideshow (exiting fullscreen if it entered it) and
|
|
64
|
+
* returns to the Present canvas. A no-op when no slideshow is running.
|
|
65
|
+
*
|
|
66
|
+
* @returns The {@linkcode PluginPresentationSlideshowState} after the stop
|
|
67
|
+
* (`running: false`).
|
|
68
|
+
* @throws If Present mode is not open.
|
|
69
|
+
*
|
|
70
|
+
* @examplePrompt Stop the slideshow
|
|
71
|
+
* @examplePrompt Exit the presentation
|
|
72
|
+
* @examplePrompt Close the slideshow and go back to the sheets
|
|
73
|
+
*
|
|
74
|
+
* # Example
|
|
75
|
+
* ```ts
|
|
76
|
+
* await snaptrude.presentation.slideshow.stop()
|
|
77
|
+
* ```
|
|
78
|
+
*/
|
|
79
|
+
public abstract stop(): PluginApiReturn<PluginPresentationSlideshowState>
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* Read the slideshow state.
|
|
83
|
+
*
|
|
84
|
+
* A never-throw read: reports whether a slideshow is running and, when it
|
|
85
|
+
* is, the current 0-based slide index (`index` is `null` when not
|
|
86
|
+
* running — including when Present mode is closed).
|
|
87
|
+
*
|
|
88
|
+
* @returns The current {@linkcode PluginPresentationSlideshowState}.
|
|
89
|
+
*
|
|
90
|
+
* @examplePrompt Is the slideshow running?
|
|
91
|
+
* @examplePrompt Which slide is the presentation on?
|
|
92
|
+
* @examplePrompt Check the slideshow state
|
|
93
|
+
*
|
|
94
|
+
* # Example
|
|
95
|
+
* ```ts
|
|
96
|
+
* const { running, index } = await snaptrude.presentation.slideshow.getState()
|
|
97
|
+
* ```
|
|
98
|
+
*/
|
|
99
|
+
public abstract getState(): PluginApiReturn<PluginPresentationSlideshowState>
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* Arguments for {@linkcode PluginPresentationSlideshowApi.start}.
|
|
104
|
+
*
|
|
105
|
+
* | Property | Type | Description |
|
|
106
|
+
* |---|---|---|
|
|
107
|
+
* | `sheetIds` | `string[] \| undefined` | Open on this sheet when exactly one id is given |
|
|
108
|
+
* | `startIndex` | `number \| undefined` | 0-based slide to open on (wins over `sheetIds`; clamped) |
|
|
109
|
+
*/
|
|
110
|
+
export const PluginPresentationSlideshowStartArgs = z.object({
|
|
111
|
+
sheetIds: z.array(z.string().min(1)).optional(),
|
|
112
|
+
startIndex: z.number().int().min(0).optional(),
|
|
113
|
+
})
|
|
114
|
+
export type PluginPresentationSlideshowStartArgs = z.infer<
|
|
115
|
+
typeof PluginPresentationSlideshowStartArgs
|
|
116
|
+
>
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* The slideshow state — result of {@linkcode PluginPresentationSlideshowApi.start},
|
|
120
|
+
* {@linkcode PluginPresentationSlideshowApi.stop}, and
|
|
121
|
+
* {@linkcode PluginPresentationSlideshowApi.getState}.
|
|
122
|
+
*
|
|
123
|
+
* | Property | Type | Description |
|
|
124
|
+
* |---|---|---|
|
|
125
|
+
* | `running` | `boolean` | Whether a slideshow is currently running |
|
|
126
|
+
* | `index` | `number \| null` | Current 0-based slide index (`null` when not running) |
|
|
127
|
+
*/
|
|
128
|
+
export const PluginPresentationSlideshowState = z.object({
|
|
129
|
+
running: z.boolean(),
|
|
130
|
+
index: z.number().int().nullable(),
|
|
131
|
+
})
|
|
132
|
+
export type PluginPresentationSlideshowState = z.infer<
|
|
133
|
+
typeof PluginPresentationSlideshowState
|
|
134
|
+
>
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import * as z from "zod"
|
|
2
|
+
import { PluginApiReturn } from "../../types"
|
|
3
|
+
import type { PluginCanvasShape } from "./placedViews"
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Presentation tables — place data tables on Present-mode sheets.
|
|
7
|
+
*
|
|
8
|
+
* The scriptable counterpart of the Present canvas's table paste (the flow
|
|
9
|
+
* that turns a Program-mode / Google Sheets / Excel paste into a table
|
|
10
|
+
* shape): {@linkcode PluginPresentationTablesApi.place} takes plain string
|
|
11
|
+
* rows and creates one table shape on a sheet. Requires Present mode to be
|
|
12
|
+
* open.
|
|
13
|
+
*
|
|
14
|
+
* Accessed via `snaptrude.presentation.tables`.
|
|
15
|
+
*/
|
|
16
|
+
export abstract class PluginPresentationTablesApi {
|
|
17
|
+
constructor() {}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Place a table on a sheet.
|
|
21
|
+
*
|
|
22
|
+
* Creates one table shape from `table.rows` — the same shape the Present
|
|
23
|
+
* canvas creates when a spreadsheet table is pasted — and returns the
|
|
24
|
+
* created shape as a canvas-shape record. Cells are plain strings; rows may
|
|
25
|
+
* be ragged (each row needs at least one cell), capped at 10000 cells
|
|
26
|
+
* total. `options.position` is sheet-local (relative to the sheet's
|
|
27
|
+
* top-left, in canvas units — the same convention as `annotate.*`); when
|
|
28
|
+
* omitted the table lands where the paste flow would auto-place it (the
|
|
29
|
+
* center of the current viewport). One undo step. Requires Present mode to
|
|
30
|
+
* be open.
|
|
31
|
+
*
|
|
32
|
+
* @param sheetId - The sheet to place the table on.
|
|
33
|
+
* @param table - The table content: `rows`, an array of string-cell rows.
|
|
34
|
+
* @param options - Optional `position` (`{ x, y }`, relative to the sheet's
|
|
35
|
+
* top-left — defaults to the paste flow's auto-placement).
|
|
36
|
+
* @returns The created table shape as a {@linkcode PluginCanvasShape}.
|
|
37
|
+
* @throws If Present mode is not open, the sheet id is invalid, or the
|
|
38
|
+
* table is empty / exceeds the 10000-cell cap.
|
|
39
|
+
*
|
|
40
|
+
* @examplePrompt Put the area schedule as a table on Sheet 1
|
|
41
|
+
* @examplePrompt Add a table of the room programs to the cover sheet
|
|
42
|
+
* @examplePrompt Paste this data as a table on the sheet
|
|
43
|
+
* @examplePrompt Place a two-column table of space names and areas
|
|
44
|
+
*
|
|
45
|
+
* # Example
|
|
46
|
+
* ```ts
|
|
47
|
+
* const shape = await snaptrude.presentation.tables.place("sheet_1", {
|
|
48
|
+
* rows: [
|
|
49
|
+
* ["Room", "Area"],
|
|
50
|
+
* ["Kitchen", "12.4 m²"],
|
|
51
|
+
* ["Living", "28.0 m²"],
|
|
52
|
+
* ],
|
|
53
|
+
* }, { position: { x: 40, y: 40 } })
|
|
54
|
+
* ```
|
|
55
|
+
*/
|
|
56
|
+
public abstract place(
|
|
57
|
+
sheetId: string,
|
|
58
|
+
table: { rows: string[][] },
|
|
59
|
+
options?: { position?: { x: number; y: number } },
|
|
60
|
+
): PluginApiReturn<PluginCanvasShape>
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Arguments for {@linkcode PluginPresentationTablesApi.place}.
|
|
65
|
+
*
|
|
66
|
+
* | Property | Type | Description |
|
|
67
|
+
* |---|---|---|
|
|
68
|
+
* | `sheetId` | `string` | The sheet to place the table on |
|
|
69
|
+
* | `rows` | `string[][]` | Table cells as string rows (non-empty; ≤ 10000 cells total) |
|
|
70
|
+
* | `position` | `{ x: number; y: number } \| undefined` | Sheet-local position (default: paste auto-placement) |
|
|
71
|
+
*/
|
|
72
|
+
export const PluginPresentationTablesPlaceArgs = z.object({
|
|
73
|
+
sheetId: z.string().min(1),
|
|
74
|
+
rows: z
|
|
75
|
+
.array(z.array(z.string()).min(1))
|
|
76
|
+
.min(1)
|
|
77
|
+
.refine((rows) => rows.reduce((n, r) => n + r.length, 0) <= 10000, {
|
|
78
|
+
message: "table exceeds the 10000-cell cap",
|
|
79
|
+
}),
|
|
80
|
+
position: z.object({ x: z.number(), y: z.number() }).optional(),
|
|
81
|
+
})
|
|
82
|
+
export type PluginPresentationTablesPlaceArgs = z.infer<
|
|
83
|
+
typeof PluginPresentationTablesPlaceArgs
|
|
84
|
+
>
|