@snaptrude/plugin-core 0.7.1 → 0.8.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.
- package/CHANGELOG.md +14 -0
- package/api-manifest.full.json +6442 -0
- package/api-manifest.json +2029 -128
- package/dist/api/core/camera/index.d.ts +208 -0
- package/dist/api/core/camera/index.d.ts.map +1 -0
- package/dist/api/core/comment/index.d.ts +105 -2
- package/dist/api/core/comment/index.d.ts.map +1 -1
- package/dist/api/core/geom/create/index.d.ts +13 -13
- package/dist/api/core/geom/delete/index.d.ts +8 -2
- package/dist/api/core/geom/delete/index.d.ts.map +1 -1
- package/dist/api/core/geom/query/arc.d.ts +5 -5
- package/dist/api/core/geom/query/brep.d.ts +18 -18
- package/dist/api/core/geom/query/circle.d.ts +18 -18
- package/dist/api/core/geom/query/contour.d.ts +20 -20
- package/dist/api/core/geom/query/curve.d.ts +49 -49
- package/dist/api/core/geom/query/edge.d.ts +5 -5
- package/dist/api/core/geom/query/face.d.ts +16 -16
- package/dist/api/core/geom/query/halfedge.d.ts +8 -8
- package/dist/api/core/geom/query/profile.d.ts +19 -19
- package/dist/api/core/geom/query/vertex.d.ts +8 -8
- package/dist/api/core/geom/update/contour.d.ts +14 -14
- package/dist/api/core/geom/update/curve.d.ts +7 -7
- package/dist/api/core/geom/update/profile.d.ts +16 -16
- package/dist/api/core/handles/index.d.ts +210 -0
- package/dist/api/core/handles/index.d.ts.map +1 -0
- package/dist/api/core/index.d.ts +15 -0
- package/dist/api/core/index.d.ts.map +1 -1
- package/dist/api/core/io/export/index.d.ts +132 -0
- package/dist/api/core/io/export/index.d.ts.map +1 -0
- package/dist/api/core/io/import/index.d.ts +1 -1
- package/dist/api/core/io/index.d.ts +5 -0
- package/dist/api/core/io/index.d.ts.map +1 -1
- package/dist/api/core/layers.d.ts +7 -7
- package/dist/api/core/proposals/index.d.ts +65 -9
- package/dist/api/core/proposals/index.d.ts.map +1 -1
- package/dist/api/core/user.d.ts +44 -0
- package/dist/api/core/user.d.ts.map +1 -0
- package/dist/api/design/boolean/index.d.ts +4 -4
- package/dist/api/design/create/index.d.ts +139 -44
- package/dist/api/design/create/index.d.ts.map +1 -1
- package/dist/api/design/doors/index.d.ts +36 -0
- package/dist/api/design/doors/index.d.ts.map +1 -1
- package/dist/api/design/edit/index.d.ts +1 -1
- package/dist/api/design/erase/index.d.ts +2 -2
- package/dist/api/design/furniture/index.d.ts +114 -3
- package/dist/api/design/furniture/index.d.ts.map +1 -1
- package/dist/api/design/index.d.ts +10 -0
- package/dist/api/design/index.d.ts.map +1 -1
- package/dist/api/design/materials/index.d.ts +111 -14
- package/dist/api/design/materials/index.d.ts.map +1 -1
- package/dist/api/design/query/index.d.ts +31 -1
- package/dist/api/design/query/index.d.ts.map +1 -1
- package/dist/api/design/query/spaces.d.ts +5 -5
- package/dist/api/design/transform/index.d.ts +83 -14
- package/dist/api/design/transform/index.d.ts.map +1 -1
- package/dist/api/design/types/index.d.ts +181 -0
- package/dist/api/design/types/index.d.ts.map +1 -0
- package/dist/api/design/update/index.d.ts +335 -2
- package/dist/api/design/update/index.d.ts.map +1 -1
- package/dist/api/design/visibility.d.ts +98 -0
- package/dist/api/design/visibility.d.ts.map +1 -0
- package/dist/api/entity/referenceLine.d.ts +2 -2
- package/dist/api/entity/space.d.ts +19 -19
- package/dist/api/entity/story.d.ts +128 -15
- package/dist/api/entity/story.d.ts.map +1 -1
- package/dist/api/presentation/annotate.d.ts +448 -0
- package/dist/api/presentation/annotate.d.ts.map +1 -0
- package/dist/api/presentation/diagrams.d.ts +49 -8
- package/dist/api/presentation/diagrams.d.ts.map +1 -1
- package/dist/api/presentation/export.d.ts +104 -0
- package/dist/api/presentation/export.d.ts.map +1 -0
- package/dist/api/presentation/index.d.ts +38 -0
- package/dist/api/presentation/index.d.ts.map +1 -1
- package/dist/api/presentation/sheets.d.ts +410 -13
- package/dist/api/presentation/sheets.d.ts.map +1 -1
- package/dist/api/presentation/views.d.ts +165 -10
- package/dist/api/presentation/views.d.ts.map +1 -1
- package/dist/api/program/areas.d.ts +63 -3
- package/dist/api/program/areas.d.ts.map +1 -1
- package/dist/api/program/cores.d.ts +3 -99
- package/dist/api/program/cores.d.ts.map +1 -1
- package/dist/api/program/index.d.ts +2 -2
- package/dist/api/program/index.d.ts.map +1 -1
- package/dist/api/program/layout.d.ts +172 -12
- package/dist/api/program/layout.d.ts.map +1 -1
- package/dist/api/program/site.d.ts +11 -8
- package/dist/api/program/site.d.ts.map +1 -1
- package/dist/api/program/spreadsheet.d.ts +105 -13
- package/dist/api/program/spreadsheet.d.ts.map +1 -1
- package/dist/handles.d.ts +64 -25
- package/dist/handles.d.ts.map +1 -1
- package/dist/index.cjs +2316 -1644
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +2224 -1639
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/api/core/camera/index.ts +212 -0
- package/src/api/core/comment/index.ts +120 -2
- package/src/api/core/geom/delete/index.ts +6 -0
- package/src/api/core/handles/index.ts +233 -0
- package/src/api/core/index.ts +15 -0
- package/src/api/core/io/export/index.ts +124 -0
- package/src/api/core/io/index.ts +5 -0
- package/src/api/core/proposals/index.ts +71 -11
- package/src/api/core/user.ts +46 -0
- package/src/api/design/create/index.ts +166 -36
- package/src/api/design/doors/index.ts +40 -0
- package/src/api/design/furniture/index.ts +127 -3
- package/src/api/design/index.ts +10 -0
- package/src/api/design/materials/index.ts +157 -30
- package/src/api/design/query/index.ts +33 -7
- package/src/api/design/transform/index.ts +89 -12
- package/src/api/design/types/index.ts +156 -0
- package/src/api/design/update/index.ts +402 -6
- package/src/api/design/visibility.ts +109 -0
- package/src/api/entity/story.ts +141 -15
- package/src/api/presentation/annotate.ts +360 -0
- package/src/api/presentation/diagrams.ts +53 -8
- package/src/api/presentation/export.ts +104 -0
- package/src/api/presentation/index.ts +46 -0
- package/src/api/presentation/sheets.ts +346 -13
- package/src/api/presentation/views.ts +164 -12
- package/src/api/program/areas.ts +57 -6
- package/src/api/program/cores.ts +3 -91
- package/src/api/program/index.ts +2 -2
- package/src/api/program/layout.ts +182 -12
- package/src/api/program/site.ts +11 -8
- package/src/api/program/spreadsheet.ts +125 -29
- package/src/handles.ts +77 -13
- package/tsconfig.json +7 -2
|
@@ -0,0 +1,104 @@
|
|
|
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
|
+
* The schemas and result types live here; the callable method is declared on
|
|
24
|
+
* {@linkcode PluginPresentationApi.export}.
|
|
25
|
+
*/
|
|
26
|
+
|
|
27
|
+
/** Output file format: a vector `pdf`, or a rasterized `png` / `jpg`. */
|
|
28
|
+
export const PluginPresentationExportFormat = z.enum(["pdf", "png", "jpg"])
|
|
29
|
+
export type PluginPresentationExportFormat = z.infer<
|
|
30
|
+
typeof PluginPresentationExportFormat
|
|
31
|
+
>
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Target pixel dimensions for a rasterized (`png`/`jpg`) export. Ignored for
|
|
35
|
+
* `pdf`, which stays vector and takes its size from the sheet.
|
|
36
|
+
*
|
|
37
|
+
* | Property | Type | Description |
|
|
38
|
+
* |---|---|---|
|
|
39
|
+
* | `width` | `number` | Output width in pixels |
|
|
40
|
+
* | `height` | `number` | Output height in pixels |
|
|
41
|
+
*/
|
|
42
|
+
export const PluginPresentationExportResolution = z.object({
|
|
43
|
+
width: z.number().positive(),
|
|
44
|
+
height: z.number().positive(),
|
|
45
|
+
})
|
|
46
|
+
export type PluginPresentationExportResolution = z.infer<
|
|
47
|
+
typeof PluginPresentationExportResolution
|
|
48
|
+
>
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Arguments for {@linkcode PluginPresentationApi.export}.
|
|
52
|
+
*
|
|
53
|
+
* | Property | Type | Description |
|
|
54
|
+
* |---|---|---|
|
|
55
|
+
* | `format` | `"pdf" \| "png" \| "jpg"` | Output format |
|
|
56
|
+
* | `sheetIds` | `string[] \| undefined` | Sheets to export (all sheets when omitted) |
|
|
57
|
+
* | `combine` | `boolean \| undefined` | PDF only: one multi-page file (default `true`) vs one file per sheet |
|
|
58
|
+
* | `resolution` | {@linkcode PluginPresentationExportResolution}` \| undefined` | Raster target size (`png`/`jpg` only) |
|
|
59
|
+
* | `fileName` | `string \| undefined` | Base file name (without extension) |
|
|
60
|
+
*/
|
|
61
|
+
export const PluginPresentationExportArgs = z.object({
|
|
62
|
+
format: PluginPresentationExportFormat,
|
|
63
|
+
sheetIds: z.array(z.string()).optional(),
|
|
64
|
+
combine: z.boolean().optional(),
|
|
65
|
+
resolution: PluginPresentationExportResolution.optional(),
|
|
66
|
+
fileName: z.string().optional(),
|
|
67
|
+
})
|
|
68
|
+
export type PluginPresentationExportArgs = z.infer<
|
|
69
|
+
typeof PluginPresentationExportArgs
|
|
70
|
+
>
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* A single exported file.
|
|
74
|
+
*
|
|
75
|
+
* | Property | Type | Description |
|
|
76
|
+
* |---|---|---|
|
|
77
|
+
* | `fileName` | `string` | File name including extension |
|
|
78
|
+
* | `mimeType` | `string` | MIME type (`application/pdf`, `image/png`, `image/jpeg`) |
|
|
79
|
+
* | `dataBase64` | `string` | The file bytes, base64-encoded (no data-URL prefix) |
|
|
80
|
+
*/
|
|
81
|
+
export const PluginPresentationExportFile = z.object({
|
|
82
|
+
fileName: z.string(),
|
|
83
|
+
mimeType: z.string(),
|
|
84
|
+
dataBase64: z.string(),
|
|
85
|
+
})
|
|
86
|
+
export type PluginPresentationExportFile = z.infer<
|
|
87
|
+
typeof PluginPresentationExportFile
|
|
88
|
+
>
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* Result of {@linkcode PluginPresentationApi.export} — always a `files` array.
|
|
92
|
+
* A combined PDF yields one entry; per-sheet exports yield one entry each, in
|
|
93
|
+
* sheet order.
|
|
94
|
+
*
|
|
95
|
+
* | Property | Type | Description |
|
|
96
|
+
* |---|---|---|
|
|
97
|
+
* | `files` | {@linkcode PluginPresentationExportFile}`[]` | The exported files |
|
|
98
|
+
*/
|
|
99
|
+
export const PluginPresentationExportResult = z.object({
|
|
100
|
+
files: z.array(PluginPresentationExportFile),
|
|
101
|
+
})
|
|
102
|
+
export type PluginPresentationExportResult = z.infer<
|
|
103
|
+
typeof PluginPresentationExportResult
|
|
104
|
+
>
|
|
@@ -1,8 +1,15 @@
|
|
|
1
|
+
import { PluginApiReturn } from "../../types"
|
|
1
2
|
import { PluginPresentationViewsApi } from "./views"
|
|
2
3
|
import { PluginPresentationAIInspirationApi } from "./aiInspiration"
|
|
3
4
|
import { PluginPresentationSheetsApi } from "./sheets"
|
|
4
5
|
import { PluginPresentationDiagramsApi } from "./diagrams"
|
|
6
|
+
import { PluginPresentationAnnotateApi } from "./annotate"
|
|
5
7
|
import { PluginPresentationImportApi } from "./import"
|
|
8
|
+
import {
|
|
9
|
+
PluginPresentationExportResult,
|
|
10
|
+
type PluginPresentationExportFormat,
|
|
11
|
+
type PluginPresentationExportResolution,
|
|
12
|
+
} from "./export"
|
|
6
13
|
|
|
7
14
|
/**
|
|
8
15
|
* Presentation APIs — prepare and assemble presentations.
|
|
@@ -29,6 +36,8 @@ export abstract class PluginPresentationApi {
|
|
|
29
36
|
public abstract sheets: PluginPresentationSheetsApi
|
|
30
37
|
/** Program/adjacency/site diagrams — place images on sheets. See {@linkcode PluginPresentationDiagramsApi}. */
|
|
31
38
|
public abstract diagrams: PluginPresentationDiagramsApi
|
|
39
|
+
/** Annotations on Present-mode sheets — text/arrows/notes/geo shapes. See {@linkcode PluginPresentationAnnotateApi}. */
|
|
40
|
+
public abstract annotate: PluginPresentationAnnotateApi
|
|
32
41
|
/** Import reference images/PDFs onto the Present canvas. See {@linkcode PluginPresentationImportApi}. */
|
|
33
42
|
public abstract import: PluginPresentationImportApi
|
|
34
43
|
/**
|
|
@@ -37,11 +46,48 @@ export abstract class PluginPresentationApi {
|
|
|
37
46
|
*/
|
|
38
47
|
public abstract aiInspiration: PluginPresentationAIInspirationApi
|
|
39
48
|
|
|
49
|
+
/**
|
|
50
|
+
* Export the presentation's layout sheets to a downloadable file (PDF / PNG /
|
|
51
|
+
* JPG) and return the encoded bytes as base64. Wraps the Present-mode Export
|
|
52
|
+
* dialog pipeline headlessly. Requires Present mode to be open.
|
|
53
|
+
*
|
|
54
|
+
* @param format - Output format: `"pdf"`, `"png"`, or `"jpg"`.
|
|
55
|
+
* @param options - Optional `sheetIds` (all sheets when omitted), `combine`
|
|
56
|
+
* (PDF only — one multi-page file vs one per sheet, default `true`),
|
|
57
|
+
* `resolution` (raster target size for `png`/`jpg`), and `fileName`.
|
|
58
|
+
* @returns A {@linkcode PluginPresentationExportResult} — always a `files`
|
|
59
|
+
* array (one entry for a combined PDF, one per sheet otherwise).
|
|
60
|
+
* @throws If Present mode is not open, a `sheetId` is unknown, or a sheet
|
|
61
|
+
* fails to serialize/encode.
|
|
62
|
+
*
|
|
63
|
+
* @examplePrompt Export the presentation as a PDF
|
|
64
|
+
* @examplePrompt Download all sheets as a single PDF
|
|
65
|
+
* @examplePrompt Export sheet 1 as a PNG
|
|
66
|
+
* @examplePrompt Save the presentation sheets as JPG images
|
|
67
|
+
* @examplePrompt Export these sheets to PDF at high resolution
|
|
68
|
+
*
|
|
69
|
+
* # Example
|
|
70
|
+
* ```ts
|
|
71
|
+
* const { files } = await snaptrude.presentation.export("pdf")
|
|
72
|
+
* ```
|
|
73
|
+
*/
|
|
74
|
+
public abstract export(
|
|
75
|
+
format: PluginPresentationExportFormat,
|
|
76
|
+
options?: {
|
|
77
|
+
sheetIds?: string[]
|
|
78
|
+
combine?: boolean
|
|
79
|
+
resolution?: PluginPresentationExportResolution
|
|
80
|
+
fileName?: string
|
|
81
|
+
},
|
|
82
|
+
): PluginApiReturn<PluginPresentationExportResult>
|
|
83
|
+
|
|
40
84
|
constructor() {}
|
|
41
85
|
}
|
|
42
86
|
|
|
43
87
|
export * from "./views"
|
|
44
88
|
export * from "./sheets"
|
|
45
89
|
export * from "./diagrams"
|
|
90
|
+
export * from "./annotate"
|
|
46
91
|
export * from "./import"
|
|
47
92
|
export * from "./aiInspiration"
|
|
93
|
+
export * from "./export"
|
|
@@ -8,8 +8,11 @@ import { PluginApiReturn } from "../../types"
|
|
|
8
8
|
* These methods require **Present mode to be open** (the documentation editor) —
|
|
9
9
|
* reads return `[]`/`null` and writes throw when it is not.
|
|
10
10
|
*
|
|
11
|
-
* `list`/`get` are reads;
|
|
12
|
-
*
|
|
11
|
+
* `list`/`get` are reads; the rest mutate and require Present mode to be open:
|
|
12
|
+
* `create` adds a sheet, `place` drops a saved view onto a sheet as a live
|
|
13
|
+
* linked view shape, `rename` relabels a sheet, `delete` removes one, `reorder`
|
|
14
|
+
* moves one in the sheet order, `setActive` navigates to one, and
|
|
15
|
+
* `updatePlacedView` re-renders placed views to the current model.
|
|
13
16
|
*
|
|
14
17
|
* Accessed via `snaptrude.presentation.sheets`.
|
|
15
18
|
*/
|
|
@@ -56,56 +59,278 @@ export abstract class PluginPresentationSheetsApi {
|
|
|
56
59
|
/**
|
|
57
60
|
* Create a new layout sheet.
|
|
58
61
|
*
|
|
62
|
+
* Optionally sets the paper size and orientation — the same presets as the
|
|
63
|
+
* sheet header's size dropdown (ANSI A–E, Arch A–E1, ISO A4–A0). When `size`
|
|
64
|
+
* is omitted the sheet inherits the editor session's last-used size
|
|
65
|
+
* (initially ANSI B) in landscape, so pass `size` explicitly whenever the
|
|
66
|
+
* output format matters.
|
|
67
|
+
*
|
|
59
68
|
* Requires Present mode to be open.
|
|
60
69
|
*
|
|
61
70
|
* @param name - Display name for the new sheet (optional).
|
|
71
|
+
* @param options - Optional `size` ({@linkcode PluginSheetSize} paper preset)
|
|
72
|
+
* and `orientation` ({@linkcode PluginSheetOrientation}; `"landscape"` when
|
|
73
|
+
* omitted).
|
|
62
74
|
* @returns The newly created {@linkcode PluginPresentationSheet}.
|
|
63
75
|
* @throws If Present mode is not open.
|
|
64
76
|
*
|
|
65
77
|
* @examplePrompt Create a new sheet called Cover
|
|
66
|
-
* @examplePrompt Add
|
|
67
|
-
* @examplePrompt Make a new presentation sheet named Floor Plans
|
|
78
|
+
* @examplePrompt Add an A3 landscape layout sheet
|
|
79
|
+
* @examplePrompt Make a new ANSI D presentation sheet named Floor Plans
|
|
80
|
+
* @examplePrompt Create a portrait A4 sheet
|
|
68
81
|
*
|
|
69
82
|
* # Example
|
|
70
83
|
* ```ts
|
|
71
|
-
* const sheet = await snaptrude.presentation.sheets.create("Cover"
|
|
84
|
+
* const sheet = await snaptrude.presentation.sheets.create("Cover", {
|
|
85
|
+
* size: "ISO_A3",
|
|
86
|
+
* orientation: "landscape",
|
|
87
|
+
* })
|
|
72
88
|
* ```
|
|
73
89
|
*/
|
|
74
90
|
public abstract create(
|
|
75
91
|
name?: string,
|
|
92
|
+
options?: { size?: PluginSheetSize; orientation?: PluginSheetOrientation },
|
|
93
|
+
): PluginApiReturn<PluginPresentationSheet>
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* Set a sheet's paper size and/or orientation.
|
|
97
|
+
*
|
|
98
|
+
* Applies one of the standard paper presets — exactly what the sheet header's
|
|
99
|
+
* size dropdown and orientation toggle do. Content that no longer fits inside
|
|
100
|
+
* the resized sheet is moved out onto the canvas (matching the native
|
|
101
|
+
* behavior). Undoable. Does not change the user's remembered default size for
|
|
102
|
+
* new sheets.
|
|
103
|
+
*
|
|
104
|
+
* Requires Present mode to be open.
|
|
105
|
+
*
|
|
106
|
+
* @param sheetId - The id of the sheet to resize.
|
|
107
|
+
* @param size - The paper preset ({@linkcode PluginSheetSize}).
|
|
108
|
+
* @param orientation - Optional {@linkcode PluginSheetOrientation}; keeps the
|
|
109
|
+
* sheet's current orientation when omitted.
|
|
110
|
+
* @returns The updated {@linkcode PluginPresentationSheet}.
|
|
111
|
+
* @throws If Present mode is not open, or the sheet id is invalid.
|
|
112
|
+
*
|
|
113
|
+
* @examplePrompt Resize sheet_1 to A1
|
|
114
|
+
* @examplePrompt Make the cover sheet ANSI B portrait
|
|
115
|
+
* @examplePrompt Change this sheet to Arch D landscape
|
|
116
|
+
* @examplePrompt Set the sheet size to A3
|
|
117
|
+
*
|
|
118
|
+
* # Example
|
|
119
|
+
* ```ts
|
|
120
|
+
* const sheet = await snaptrude.presentation.sheets.setSize("sheet_1", "ISO_A1", "portrait")
|
|
121
|
+
* ```
|
|
122
|
+
*/
|
|
123
|
+
public abstract setSize(
|
|
124
|
+
sheetId: string,
|
|
125
|
+
size: PluginSheetSize,
|
|
126
|
+
orientation?: PluginSheetOrientation,
|
|
76
127
|
): PluginApiReturn<PluginPresentationSheet>
|
|
77
128
|
|
|
78
129
|
/**
|
|
79
130
|
* Place a saved view onto a sheet.
|
|
80
131
|
*
|
|
81
|
-
* Drops the given view onto the sheet
|
|
82
|
-
*
|
|
132
|
+
* Drops the given view onto the sheet through the **native view drop** — the
|
|
133
|
+
* placed shape is a live linked view (the same shape the Present views panel's
|
|
134
|
+
* drag-drop creates), re-rendered from the current model, so
|
|
135
|
+
* {@linkcode PluginPresentationSheetsApi.updatePlacedView} refreshes it later.
|
|
136
|
+
* 2D and site-plan views are placed at an architectural scale: the closest
|
|
137
|
+
* standard scale by default (the native auto-fit), or the explicit `scale`
|
|
138
|
+
* when given — one of the standard values the placed view's Scale dropdown
|
|
139
|
+
* offers for the project's unit system (metric `10, 20, 50, 100, 150, 200,
|
|
140
|
+
* 250, 500, 1000`; imperial e.g. `48` for 1/4″ = 1′, `96` for 1/8″ = 1′,
|
|
141
|
+
* `120` for 1″ = 10′). 3D views have no scale — passing `scale` for one
|
|
142
|
+
* throws. Requires Present mode to be open.
|
|
83
143
|
*
|
|
84
144
|
* @param sheetId - The id of the sheet to place onto.
|
|
85
145
|
* @param viewId - The id of the saved view to place.
|
|
86
146
|
* @param options - Optional `position` ({@linkcode PluginSheetPosition}) —
|
|
87
|
-
* where to place it (
|
|
147
|
+
* where to place it (sheet centre when omitted) — and `scale` — a standard
|
|
148
|
+
* scale value for the project's unit system (2D/site-plan views only;
|
|
149
|
+
* auto-fit when omitted).
|
|
88
150
|
* @returns A {@linkcode PluginPresentationSheetsPlaceResult} with the created
|
|
89
151
|
* `shapeId`.
|
|
90
|
-
* @throws If Present mode is not open,
|
|
152
|
+
* @throws If Present mode is not open, the sheet/view id is invalid, `scale`
|
|
153
|
+
* is not a standard value for the project's unit system, or `scale` is
|
|
154
|
+
* passed for a 3D view.
|
|
91
155
|
*
|
|
92
156
|
* @examplePrompt Place the floor plan on Sheet 1
|
|
93
157
|
* @examplePrompt Add this 3D view to the cover sheet
|
|
94
158
|
* @examplePrompt Drop the site plan onto the layout sheet at 100, 200
|
|
95
|
-
* @examplePrompt Put the Ground Floor view on sheet_1
|
|
159
|
+
* @examplePrompt Put the Ground Floor view on sheet_1 at 1:100 scale
|
|
160
|
+
* @examplePrompt Place the plan on the cover sheet at quarter-inch scale
|
|
96
161
|
*
|
|
97
162
|
* # Example
|
|
98
163
|
* ```ts
|
|
99
|
-
* const { shapeId } = await snaptrude.presentation.sheets.place("sheet_1", "view_123"
|
|
164
|
+
* const { shapeId } = await snaptrude.presentation.sheets.place("sheet_1", "view_123", {
|
|
165
|
+
* scale: 100, // 1:100 (metric project)
|
|
166
|
+
* })
|
|
100
167
|
* ```
|
|
101
168
|
*/
|
|
102
169
|
public abstract place(
|
|
103
170
|
sheetId: string,
|
|
104
171
|
viewId: string,
|
|
105
|
-
options?: { position?: PluginSheetPosition },
|
|
172
|
+
options?: { position?: PluginSheetPosition; scale?: number },
|
|
106
173
|
): PluginApiReturn<PluginPresentationSheetsPlaceResult>
|
|
174
|
+
|
|
175
|
+
/**
|
|
176
|
+
* Rename a layout sheet.
|
|
177
|
+
*
|
|
178
|
+
* Sets the sheet's display name — the same label the sheets panel shows and
|
|
179
|
+
* that `list`/`get` read back. Requires Present mode to be open.
|
|
180
|
+
*
|
|
181
|
+
* @param sheetId - The id of the sheet to rename.
|
|
182
|
+
* @param name - The new display name (non-empty after trimming).
|
|
183
|
+
* @returns The updated {@linkcode PluginPresentationSheet}.
|
|
184
|
+
* @throws If Present mode is not open, or the sheet id is invalid.
|
|
185
|
+
*
|
|
186
|
+
* @examplePrompt Rename sheet_1 to Cover
|
|
187
|
+
* @examplePrompt Call the first sheet Ground Floor
|
|
188
|
+
* @examplePrompt Change this sheet's name to Site Plan
|
|
189
|
+
*
|
|
190
|
+
* # Example
|
|
191
|
+
* ```ts
|
|
192
|
+
* const sheet = await snaptrude.presentation.sheets.rename("sheet_1", "Cover")
|
|
193
|
+
* ```
|
|
194
|
+
*/
|
|
195
|
+
public abstract rename(
|
|
196
|
+
sheetId: string,
|
|
197
|
+
name: string,
|
|
198
|
+
): PluginApiReturn<PluginPresentationSheet>
|
|
199
|
+
|
|
200
|
+
/**
|
|
201
|
+
* Delete a layout sheet.
|
|
202
|
+
*
|
|
203
|
+
* Removes the sheet (and its placed content) from the presentation and
|
|
204
|
+
* renumbers the remaining sheets. Requires Present mode to be open. Auto-diagram
|
|
205
|
+
* sheets cannot be deleted through the API — remove those from the Present UI.
|
|
206
|
+
*
|
|
207
|
+
* @param sheetId - The id of the sheet to delete.
|
|
208
|
+
* @returns The id of the deleted sheet
|
|
209
|
+
* (a {@linkcode PluginPresentationSheetsDeleteResult}).
|
|
210
|
+
* @throws If Present mode is not open, the sheet id is invalid, or the sheet is
|
|
211
|
+
* an auto-diagram sheet.
|
|
212
|
+
*
|
|
213
|
+
* @examplePrompt Delete sheet_2
|
|
214
|
+
* @examplePrompt Remove the Cover sheet
|
|
215
|
+
* @examplePrompt Get rid of the last layout sheet
|
|
216
|
+
*
|
|
217
|
+
* # Example
|
|
218
|
+
* ```ts
|
|
219
|
+
* const { id } = await snaptrude.presentation.sheets.delete("sheet_2")
|
|
220
|
+
* ```
|
|
221
|
+
*/
|
|
222
|
+
public abstract delete(
|
|
223
|
+
sheetId: string,
|
|
224
|
+
): PluginApiReturn<PluginPresentationSheetsDeleteResult>
|
|
225
|
+
|
|
226
|
+
/**
|
|
227
|
+
* Move a sheet to a new position in the sheet order.
|
|
228
|
+
*
|
|
229
|
+
* Reorders the sheet to the given zero-based `index` (as the sheets panel does
|
|
230
|
+
* when a sheet is dragged) and renumbers the rest. `index` is clamped to the
|
|
231
|
+
* valid range. Requires Present mode to be open.
|
|
232
|
+
*
|
|
233
|
+
* @param sheetId - The id of the sheet to move.
|
|
234
|
+
* @param index - Zero-based target position in the sheet order.
|
|
235
|
+
* @returns The sheets in their new order
|
|
236
|
+
* (a {@linkcode PluginPresentationSheetsListResult}).
|
|
237
|
+
* @throws If Present mode is not open, or the sheet id is invalid.
|
|
238
|
+
*
|
|
239
|
+
* @examplePrompt Move sheet_3 to the front
|
|
240
|
+
* @examplePrompt Make the Cover sheet the first sheet
|
|
241
|
+
* @examplePrompt Reorder this sheet to position 2
|
|
242
|
+
*
|
|
243
|
+
* # Example
|
|
244
|
+
* ```ts
|
|
245
|
+
* const { sheets } = await snaptrude.presentation.sheets.reorder("sheet_3", 0)
|
|
246
|
+
* ```
|
|
247
|
+
*/
|
|
248
|
+
public abstract reorder(
|
|
249
|
+
sheetId: string,
|
|
250
|
+
index: number,
|
|
251
|
+
): PluginApiReturn<PluginPresentationSheetsListResult>
|
|
252
|
+
|
|
253
|
+
/**
|
|
254
|
+
* Make a sheet the active sheet.
|
|
255
|
+
*
|
|
256
|
+
* Selects the sheet in the sheets panel and navigates the Present canvas to it
|
|
257
|
+
* (the same as clicking it in the panel). Requires Present mode to be open.
|
|
258
|
+
*
|
|
259
|
+
* @param sheetId - The id of the sheet to activate.
|
|
260
|
+
* @returns The now-active {@linkcode PluginPresentationSheet}.
|
|
261
|
+
* @throws If Present mode is not open, or the sheet id is invalid.
|
|
262
|
+
*
|
|
263
|
+
* @examplePrompt Go to sheet_1
|
|
264
|
+
* @examplePrompt Open the Cover sheet
|
|
265
|
+
* @examplePrompt Switch to the Site Plan sheet
|
|
266
|
+
*
|
|
267
|
+
* # Example
|
|
268
|
+
* ```ts
|
|
269
|
+
* await snaptrude.presentation.sheets.setActive("sheet_1")
|
|
270
|
+
* ```
|
|
271
|
+
*/
|
|
272
|
+
public abstract setActive(
|
|
273
|
+
sheetId: string,
|
|
274
|
+
): PluginApiReturn<PluginPresentationSheet>
|
|
275
|
+
|
|
276
|
+
/**
|
|
277
|
+
* Refresh placed views to the current model state.
|
|
278
|
+
*
|
|
279
|
+
* Re-renders the presentation's placed **views** — the live linked view shapes —
|
|
280
|
+
* from the current model (the "Update views" action). Views placed with
|
|
281
|
+
* {@linkcode PluginPresentationSheetsApi.place} are live view shapes too, so
|
|
282
|
+
* they refresh along with panel-dropped ones. Pass `sheetId` to refresh only
|
|
283
|
+
* the views on that sheet, or omit it to refresh every placed view. Requires
|
|
284
|
+
* Present mode to be open.
|
|
285
|
+
*
|
|
286
|
+
* @param options - Optional `sheetId` — restrict the refresh to one sheet's
|
|
287
|
+
* placed views (all placed views when omitted).
|
|
288
|
+
* @returns The ids of the placed view shapes submitted for refresh
|
|
289
|
+
* (a {@linkcode PluginPresentationSheetsUpdatePlacedViewResult}).
|
|
290
|
+
* @throws If Present mode is not open, or `sheetId` is given but invalid.
|
|
291
|
+
*
|
|
292
|
+
* @examplePrompt Update all the placed views to the latest model
|
|
293
|
+
* @examplePrompt Refresh the views on sheet_1
|
|
294
|
+
* @examplePrompt Re-render the placed views after my edits
|
|
295
|
+
*
|
|
296
|
+
* # Example
|
|
297
|
+
* ```ts
|
|
298
|
+
* const { shapeIds } = await snaptrude.presentation.sheets.updatePlacedView()
|
|
299
|
+
* ```
|
|
300
|
+
*/
|
|
301
|
+
public abstract updatePlacedView(options?: {
|
|
302
|
+
sheetId?: string
|
|
303
|
+
}): PluginApiReturn<PluginPresentationSheetsUpdatePlacedViewResult>
|
|
107
304
|
}
|
|
108
305
|
|
|
306
|
+
/**
|
|
307
|
+
* Standard paper-size presets for layout sheets — identical to the sheet
|
|
308
|
+
* header's size dropdown in Present mode.
|
|
309
|
+
*/
|
|
310
|
+
export const PluginSheetSize = z.enum([
|
|
311
|
+
"ANSI_A",
|
|
312
|
+
"ANSI_B",
|
|
313
|
+
"ANSI_C",
|
|
314
|
+
"ANSI_D",
|
|
315
|
+
"ANSI_E",
|
|
316
|
+
"ARCH_A",
|
|
317
|
+
"ARCH_B",
|
|
318
|
+
"ARCH_C",
|
|
319
|
+
"ARCH_D",
|
|
320
|
+
"ARCH_E",
|
|
321
|
+
"ARCH_E1",
|
|
322
|
+
"ISO_A4",
|
|
323
|
+
"ISO_A3",
|
|
324
|
+
"ISO_A2",
|
|
325
|
+
"ISO_A1",
|
|
326
|
+
"ISO_A0",
|
|
327
|
+
])
|
|
328
|
+
export type PluginSheetSize = z.infer<typeof PluginSheetSize>
|
|
329
|
+
|
|
330
|
+
/** Sheet orientation. */
|
|
331
|
+
export const PluginSheetOrientation = z.enum(["landscape", "portrait"])
|
|
332
|
+
export type PluginSheetOrientation = z.infer<typeof PluginSheetOrientation>
|
|
333
|
+
|
|
109
334
|
/**
|
|
110
335
|
* A layout sheet in the presentation.
|
|
111
336
|
*
|
|
@@ -113,10 +338,14 @@ export abstract class PluginPresentationSheetsApi {
|
|
|
113
338
|
* |---|---|---|
|
|
114
339
|
* | `id` | `string` | Unique sheet id |
|
|
115
340
|
* | `name` | `string` | Display name |
|
|
341
|
+
* | `size` | {@linkcode PluginSheetSize}` \| null` | Paper preset (`null` for a legacy sheet without one) |
|
|
342
|
+
* | `orientation` | {@linkcode PluginSheetOrientation}` \| null` | Orientation (`null` for a legacy sheet) |
|
|
116
343
|
*/
|
|
117
344
|
export const PluginPresentationSheet = z.object({
|
|
118
345
|
id: z.string(),
|
|
119
346
|
name: z.string(),
|
|
347
|
+
size: PluginSheetSize.nullable(),
|
|
348
|
+
orientation: PluginSheetOrientation.nullable(),
|
|
120
349
|
})
|
|
121
350
|
export type PluginPresentationSheet = z.infer<typeof PluginPresentationSheet>
|
|
122
351
|
|
|
@@ -160,11 +389,23 @@ export type PluginPresentationSheetsGetResult = z.infer<
|
|
|
160
389
|
/** Arguments for {@linkcode PluginPresentationSheetsApi.create}. */
|
|
161
390
|
export const PluginPresentationSheetsCreateArgs = z.object({
|
|
162
391
|
name: z.string().optional(),
|
|
392
|
+
size: PluginSheetSize.optional(),
|
|
393
|
+
orientation: PluginSheetOrientation.optional(),
|
|
163
394
|
})
|
|
164
395
|
export type PluginPresentationSheetsCreateArgs = z.infer<
|
|
165
396
|
typeof PluginPresentationSheetsCreateArgs
|
|
166
397
|
>
|
|
167
398
|
|
|
399
|
+
/** Arguments for {@linkcode PluginPresentationSheetsApi.setSize}. */
|
|
400
|
+
export const PluginPresentationSheetsSetSizeArgs = z.object({
|
|
401
|
+
sheetId: z.string(),
|
|
402
|
+
size: PluginSheetSize,
|
|
403
|
+
orientation: PluginSheetOrientation.optional(),
|
|
404
|
+
})
|
|
405
|
+
export type PluginPresentationSheetsSetSizeArgs = z.infer<
|
|
406
|
+
typeof PluginPresentationSheetsSetSizeArgs
|
|
407
|
+
>
|
|
408
|
+
|
|
168
409
|
/**
|
|
169
410
|
* Arguments for {@linkcode PluginPresentationSheetsApi.place}.
|
|
170
411
|
*
|
|
@@ -172,12 +413,14 @@ export type PluginPresentationSheetsCreateArgs = z.infer<
|
|
|
172
413
|
* |---|---|---|
|
|
173
414
|
* | `sheetId` | `string` | The sheet to place onto |
|
|
174
415
|
* | `viewId` | `string` | The saved view to place |
|
|
175
|
-
* | `position` | {@linkcode PluginSheetPosition}` \| undefined` | Where to place it (
|
|
416
|
+
* | `position` | {@linkcode PluginSheetPosition}` \| undefined` | Where to place it (sheet centre when omitted) |
|
|
417
|
+
* | `scale` | `number \| undefined` | Standard scale value for the project's unit system (2D/site-plan views only; auto-fit to the closest standard scale when omitted) |
|
|
176
418
|
*/
|
|
177
419
|
export const PluginPresentationSheetsPlaceArgs = z.object({
|
|
178
420
|
sheetId: z.string(),
|
|
179
421
|
viewId: z.string(),
|
|
180
422
|
position: PluginSheetPosition.optional(),
|
|
423
|
+
scale: z.number().positive().optional(),
|
|
181
424
|
})
|
|
182
425
|
export type PluginPresentationSheetsPlaceArgs = z.infer<
|
|
183
426
|
typeof PluginPresentationSheetsPlaceArgs
|
|
@@ -196,3 +439,93 @@ export const PluginPresentationSheetsPlaceResult = z.object({
|
|
|
196
439
|
export type PluginPresentationSheetsPlaceResult = z.infer<
|
|
197
440
|
typeof PluginPresentationSheetsPlaceResult
|
|
198
441
|
>
|
|
442
|
+
|
|
443
|
+
/**
|
|
444
|
+
* Arguments for {@linkcode PluginPresentationSheetsApi.rename}.
|
|
445
|
+
*
|
|
446
|
+
* | Property | Type | Description |
|
|
447
|
+
* |---|---|---|
|
|
448
|
+
* | `sheetId` | `string` | The sheet to rename |
|
|
449
|
+
* | `name` | `string` | New display name (non-empty after trimming) |
|
|
450
|
+
*/
|
|
451
|
+
export const PluginPresentationSheetsRenameArgs = z.object({
|
|
452
|
+
sheetId: z.string(),
|
|
453
|
+
name: z.string().trim().min(1),
|
|
454
|
+
})
|
|
455
|
+
export type PluginPresentationSheetsRenameArgs = z.infer<
|
|
456
|
+
typeof PluginPresentationSheetsRenameArgs
|
|
457
|
+
>
|
|
458
|
+
|
|
459
|
+
/** Arguments for {@linkcode PluginPresentationSheetsApi.delete}. */
|
|
460
|
+
export const PluginPresentationSheetsDeleteArgs = z.object({
|
|
461
|
+
sheetId: z.string(),
|
|
462
|
+
})
|
|
463
|
+
export type PluginPresentationSheetsDeleteArgs = z.infer<
|
|
464
|
+
typeof PluginPresentationSheetsDeleteArgs
|
|
465
|
+
>
|
|
466
|
+
|
|
467
|
+
/**
|
|
468
|
+
* Result of {@linkcode PluginPresentationSheetsApi.delete}.
|
|
469
|
+
*
|
|
470
|
+
* | Property | Type | Description |
|
|
471
|
+
* |---|---|---|
|
|
472
|
+
* | `id` | `string` | Id of the deleted sheet |
|
|
473
|
+
*/
|
|
474
|
+
export const PluginPresentationSheetsDeleteResult = z.object({
|
|
475
|
+
id: z.string(),
|
|
476
|
+
})
|
|
477
|
+
export type PluginPresentationSheetsDeleteResult = z.infer<
|
|
478
|
+
typeof PluginPresentationSheetsDeleteResult
|
|
479
|
+
>
|
|
480
|
+
|
|
481
|
+
/**
|
|
482
|
+
* Arguments for {@linkcode PluginPresentationSheetsApi.reorder}.
|
|
483
|
+
*
|
|
484
|
+
* | Property | Type | Description |
|
|
485
|
+
* |---|---|---|
|
|
486
|
+
* | `sheetId` | `string` | The sheet to move |
|
|
487
|
+
* | `index` | `number` | Zero-based target position (clamped to range) |
|
|
488
|
+
*/
|
|
489
|
+
export const PluginPresentationSheetsReorderArgs = z.object({
|
|
490
|
+
sheetId: z.string(),
|
|
491
|
+
index: z.number().int().min(0),
|
|
492
|
+
})
|
|
493
|
+
export type PluginPresentationSheetsReorderArgs = z.infer<
|
|
494
|
+
typeof PluginPresentationSheetsReorderArgs
|
|
495
|
+
>
|
|
496
|
+
|
|
497
|
+
/** Arguments for {@linkcode PluginPresentationSheetsApi.setActive}. */
|
|
498
|
+
export const PluginPresentationSheetsSetActiveArgs = z.object({
|
|
499
|
+
sheetId: z.string(),
|
|
500
|
+
})
|
|
501
|
+
export type PluginPresentationSheetsSetActiveArgs = z.infer<
|
|
502
|
+
typeof PluginPresentationSheetsSetActiveArgs
|
|
503
|
+
>
|
|
504
|
+
|
|
505
|
+
/**
|
|
506
|
+
* Arguments for {@linkcode PluginPresentationSheetsApi.updatePlacedView}.
|
|
507
|
+
*
|
|
508
|
+
* | Property | Type | Description |
|
|
509
|
+
* |---|---|---|
|
|
510
|
+
* | `sheetId` | `string`? | Restrict the refresh to one sheet's placed views |
|
|
511
|
+
*/
|
|
512
|
+
export const PluginPresentationSheetsUpdatePlacedViewArgs = z.object({
|
|
513
|
+
sheetId: z.string().optional(),
|
|
514
|
+
})
|
|
515
|
+
export type PluginPresentationSheetsUpdatePlacedViewArgs = z.infer<
|
|
516
|
+
typeof PluginPresentationSheetsUpdatePlacedViewArgs
|
|
517
|
+
>
|
|
518
|
+
|
|
519
|
+
/**
|
|
520
|
+
* Result of {@linkcode PluginPresentationSheetsApi.updatePlacedView}.
|
|
521
|
+
*
|
|
522
|
+
* | Property | Type | Description |
|
|
523
|
+
* |---|---|---|
|
|
524
|
+
* | `shapeIds` | `string[]` | Ids of the placed view shapes submitted for refresh |
|
|
525
|
+
*/
|
|
526
|
+
export const PluginPresentationSheetsUpdatePlacedViewResult = z.object({
|
|
527
|
+
shapeIds: z.array(z.string()),
|
|
528
|
+
})
|
|
529
|
+
export type PluginPresentationSheetsUpdatePlacedViewResult = z.infer<
|
|
530
|
+
typeof PluginPresentationSheetsUpdatePlacedViewResult
|
|
531
|
+
>
|