@snaptrude/plugin-core 0.7.1 → 0.9.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 +29 -0
- package/api-manifest.full.json +7703 -0
- package/api-manifest.json +2946 -259
- 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 +245 -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 +331 -14
- package/dist/api/core/geom/create/index.d.ts.map +1 -1
- 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 +24 -0
- package/dist/api/core/index.d.ts.map +1 -1
- package/dist/api/core/io/export/index.d.ts +134 -0
- package/dist/api/core/io/export/index.d.ts.map +1 -0
- package/dist/api/core/io/import/index.d.ts +62 -1
- package/dist/api/core/io/import/index.d.ts.map +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/mode/index.d.ts +99 -0
- package/dist/api/core/mode/index.d.ts.map +1 -0
- 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/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/user.d.ts +44 -0
- package/dist/api/core/user.d.ts.map +1 -0
- 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/boolean/index.d.ts +4 -4
- package/dist/api/design/create/index.d.ts +253 -47
- 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/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/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 +35 -1
- 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 +178 -5
- package/dist/api/design/query/spaces.d.ts.map +1 -1
- package/dist/api/design/transform/index.d.ts +95 -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 +385 -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/buildableEnvelope.d.ts +4 -0
- package/dist/api/entity/buildableEnvelope.d.ts.map +1 -1
- package/dist/api/entity/referenceLine.d.ts +10 -2
- package/dist/api/entity/referenceLine.d.ts.map +1 -1
- package/dist/api/entity/space.d.ts +19 -19
- package/dist/api/entity/story.d.ts +148 -15
- 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 +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 +108 -0
- package/dist/api/presentation/export.d.ts.map +1 -0
- 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 +47 -0
- package/dist/api/presentation/index.d.ts.map +1 -1
- package/dist/api/presentation/placedViews.d.ts +370 -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 +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 +105 -8
- package/dist/api/program/site.d.ts.map +1 -1
- package/dist/api/program/spreadsheet.d.ts +365 -41
- package/dist/api/program/spreadsheet.d.ts.map +1 -1
- package/dist/api/workspace/index.d.ts +460 -0
- package/dist/api/workspace/index.d.ts.map +1 -0
- package/dist/handles.d.ts +64 -25
- package/dist/handles.d.ts.map +1 -1
- package/dist/index.cjs +3210 -1671
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +3008 -1666
- 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 +251 -0
- package/src/api/core/comment/index.ts +120 -2
- package/src/api/core/geom/create/index.ts +344 -1
- 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 +24 -0
- package/src/api/core/io/export/index.ts +126 -0
- package/src/api/core/io/import/index.ts +64 -0
- package/src/api/core/io/index.ts +5 -0
- package/src/api/core/mode/index.ts +96 -0
- package/src/api/core/proposals/index.ts +71 -11
- package/src/api/core/storeys/index.ts +279 -0
- package/src/api/core/tags.ts +27 -0
- package/src/api/core/user.ts +46 -0
- package/src/api/core/zoom/index.ts +4 -0
- package/src/api/design/create/index.ts +303 -36
- package/src/api/design/delete/index.ts +3 -0
- 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/geometry/index.ts +125 -3
- package/src/api/design/query/index.ts +37 -7
- 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 +101 -12
- package/src/api/design/types/index.ts +156 -0
- package/src/api/design/update/index.ts +467 -6
- package/src/api/design/visibility.ts +109 -0
- package/src/api/entity/buildableEnvelope.ts +4 -0
- package/src/api/entity/referenceLine.ts +8 -0
- package/src/api/entity/story.ts +161 -15
- package/src/api/index.ts +5 -0
- package/src/api/presentation/annotate.ts +360 -0
- package/src/api/presentation/diagrams.ts +53 -8
- package/src/api/presentation/export.ts +108 -0
- package/src/api/presentation/import.ts +6 -0
- package/src/api/presentation/index.ts +55 -0
- package/src/api/presentation/placedViews.ts +363 -0
- package/src/api/presentation/shapes.ts +274 -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 +106 -8
- package/src/api/program/spreadsheet.ts +376 -35
- package/src/api/workspace/index.ts +516 -0
- package/src/handles.ts +77 -13
- package/tsconfig.json +7 -2
|
@@ -136,30 +136,70 @@ export abstract class PluginCoreProposalsApi {
|
|
|
136
136
|
public abstract isActive(proposalId: string): PluginApiReturn<boolean>
|
|
137
137
|
|
|
138
138
|
/**
|
|
139
|
-
* Create a new design option (proposal)
|
|
139
|
+
* Create a new design option (proposal) — blank, or configured from a base
|
|
140
|
+
* proposal (the New Proposal modal's two paths).
|
|
140
141
|
*
|
|
141
142
|
* **Pro-gated** (creating proposals requires a Pro plan, matching the UI) and
|
|
142
|
-
* **not undoable**.
|
|
143
|
-
*
|
|
144
|
-
*
|
|
143
|
+
* **not undoable**. The name is capped at 24 characters.
|
|
144
|
+
*
|
|
145
|
+
* **Blank** (no `options`) — creates a bare proposal with a single empty
|
|
146
|
+
* default bucket; it does **not** carry forward the current proposal's
|
|
147
|
+
* layers, views, or targets, and the active proposal does **not** change.
|
|
148
|
+
*
|
|
149
|
+
* **Configured** (`options.baseProposalId`) — the modal's Configure path:
|
|
150
|
+
* carries the base proposal's buckets (layers) forward per `options.layers`,
|
|
151
|
+
* where each entry names a bucket of the base proposal and an action —
|
|
152
|
+
* `"share"` (the new proposal references the same live bucket) or
|
|
153
|
+
* `"duplicate"` (an independent copy of the bucket and its contents).
|
|
154
|
+
* Buckets not listed are left behind. Omitting `layers` carries **every**
|
|
155
|
+
* base bucket forward as a `"duplicate"` (the modal's default). The base
|
|
156
|
+
* proposal's views and area targets are copied either way, and the new
|
|
157
|
+
* proposal becomes the **active** one (implicit switch — blocked with
|
|
158
|
+
* `PROPOSAL_SWITCH_BLOCKED` while an in-canvas agent run is in flight, like
|
|
159
|
+
* {@linkcode PluginCoreProposalsApi.setActive}).
|
|
145
160
|
*
|
|
146
161
|
* @param name - Display name of the new proposal (capped at 24 chars).
|
|
162
|
+
* @param options - Optional configure path: `baseProposalId` (the proposal to
|
|
163
|
+
* carry forward from) and `layers` (per-bucket `"share"` / `"duplicate"`
|
|
164
|
+
* actions; omitted buckets are excluded, omitted `layers` duplicates all).
|
|
147
165
|
* @returns The new proposal's id (read the full record back with
|
|
148
166
|
* {@linkcode PluginCoreProposalsApi.get}).
|
|
149
|
-
* @throws If the caller is not on a Pro plan,
|
|
150
|
-
*
|
|
167
|
+
* @throws If the caller is not on a Pro plan, the name is empty/duplicate,
|
|
168
|
+
* `layers` is passed without `baseProposalId`, the base proposal or a
|
|
169
|
+
* listed bucket does not exist / does not belong to the base proposal, or
|
|
170
|
+
* (configured only) `PROPOSAL_SWITCH_BLOCKED` while a canvas-agent run is
|
|
171
|
+
* in flight.
|
|
151
172
|
*
|
|
152
173
|
* @examplePrompt Create a design option called Scheme B
|
|
153
174
|
* @examplePrompt Add a new proposal named Option 2
|
|
154
|
-
* @examplePrompt
|
|
175
|
+
* @examplePrompt Duplicate the current proposal as Scheme C
|
|
176
|
+
* @examplePrompt Create a design option based on Proposal 1 that shares its site layer
|
|
155
177
|
*
|
|
156
178
|
* # Example
|
|
157
179
|
* ```ts
|
|
180
|
+
* // blank design option
|
|
158
181
|
* const { id } = await snaptrude.core.proposals.create("Scheme B")
|
|
182
|
+
*
|
|
183
|
+
* // configured from the active proposal: duplicate every layer
|
|
184
|
+
* const base = await snaptrude.core.proposals.getActive()
|
|
185
|
+
* if (base) {
|
|
186
|
+
* const { id: dup } = await snaptrude.core.proposals.create("Scheme C", {
|
|
187
|
+
* baseProposalId: base.id,
|
|
188
|
+
* })
|
|
189
|
+
* // …or share one layer and leave the rest behind
|
|
190
|
+
* const { id: shared } = await snaptrude.core.proposals.create("Scheme D", {
|
|
191
|
+
* baseProposalId: base.id,
|
|
192
|
+
* layers: [{ bucketId: base.defaultBucketId, action: "share" }],
|
|
193
|
+
* })
|
|
194
|
+
* }
|
|
159
195
|
* ```
|
|
160
196
|
*/
|
|
161
197
|
public abstract create(
|
|
162
198
|
name: string,
|
|
199
|
+
options?: {
|
|
200
|
+
baseProposalId: string
|
|
201
|
+
layers?: { bucketId: string; action: "share" | "duplicate" }[]
|
|
202
|
+
},
|
|
163
203
|
): PluginApiReturn<PluginCoreProposalsCreateResult>
|
|
164
204
|
|
|
165
205
|
/**
|
|
@@ -383,15 +423,35 @@ export type PluginCoreProposalsIsActiveArgs = z.infer<
|
|
|
383
423
|
>
|
|
384
424
|
|
|
385
425
|
/**
|
|
386
|
-
* Arguments for {@linkcode PluginCoreProposalsApi.create}.
|
|
426
|
+
* Arguments for {@linkcode PluginCoreProposalsApi.create}. A bare `name` makes
|
|
427
|
+
* a blank proposal; `baseProposalId` switches to the configured (carry-forward)
|
|
428
|
+
* path. `layers` requires `baseProposalId` — each entry names a bucket of the
|
|
429
|
+
* base proposal; omitted buckets are excluded, and omitting `layers` entirely
|
|
430
|
+
* duplicates every base bucket.
|
|
387
431
|
*
|
|
388
432
|
* | Property | Type | Description |
|
|
389
433
|
* |---|---|---|
|
|
390
434
|
* | `name` | `string` | Display name of the new proposal (capped at 24 chars) |
|
|
435
|
+
* | `baseProposalId` | `string \| undefined` | Proposal to carry forward from (configured path) |
|
|
436
|
+
* | `layers` | `{ bucketId: string; action: "share" \| "duplicate" }[] \| undefined` | Per-bucket carry-forward actions (requires `baseProposalId`) |
|
|
391
437
|
*/
|
|
392
|
-
export const PluginCoreProposalsCreateArgs = z
|
|
393
|
-
|
|
394
|
-
|
|
438
|
+
export const PluginCoreProposalsCreateArgs = z
|
|
439
|
+
.object({
|
|
440
|
+
name: z.string(),
|
|
441
|
+
baseProposalId: z.string().optional(),
|
|
442
|
+
layers: z
|
|
443
|
+
.array(
|
|
444
|
+
z.object({
|
|
445
|
+
bucketId: z.string(),
|
|
446
|
+
action: z.enum(["share", "duplicate"]),
|
|
447
|
+
}),
|
|
448
|
+
)
|
|
449
|
+
.optional(),
|
|
450
|
+
})
|
|
451
|
+
.refine((v) => v.layers === undefined || v.baseProposalId !== undefined, {
|
|
452
|
+
message:
|
|
453
|
+
"layers requires baseProposalId — the layers describe how to carry the base proposal's buckets forward",
|
|
454
|
+
})
|
|
395
455
|
export type PluginCoreProposalsCreateArgs = z.infer<
|
|
396
456
|
typeof PluginCoreProposalsCreateArgs
|
|
397
457
|
>
|
|
@@ -0,0 +1,279 @@
|
|
|
1
|
+
import * as z from "zod"
|
|
2
|
+
import { PluginApiReturn } from "../../../types"
|
|
3
|
+
import { ComponentHandle } from "../../../handles"
|
|
4
|
+
import {
|
|
5
|
+
PluginStoryGetProperty,
|
|
6
|
+
PluginStoryGetResult,
|
|
7
|
+
PluginStoryGetAllResult,
|
|
8
|
+
PluginStoryCreateResult,
|
|
9
|
+
PluginStoryUpdateResult,
|
|
10
|
+
PluginStorySetActiveResult,
|
|
11
|
+
PluginStoryDeleteResult,
|
|
12
|
+
PluginStoryDuplicateResult,
|
|
13
|
+
} from "../../entity/story"
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Storey (floor) management.
|
|
17
|
+
*
|
|
18
|
+
* A storey represents a building floor in the Snaptrude project. Storeys are
|
|
19
|
+
* identified by their integer **storey value** (e.g. `1` for the ground floor,
|
|
20
|
+
* `2` for the first floor, `-1` for a basement).
|
|
21
|
+
*
|
|
22
|
+
* This is the canonical home for storey operations; it shares its implementation
|
|
23
|
+
* and schemas with the deprecated `entity.story` surface. All methods are **host
|
|
24
|
+
* API calls** that return Promises and support undo/redo via Snaptrude's command
|
|
25
|
+
* system (except {@linkcode PluginCoreStoreysApi.setActive}, a view change).
|
|
26
|
+
*
|
|
27
|
+
* Accessed via `snaptrude.core.storeys`.
|
|
28
|
+
*/
|
|
29
|
+
export abstract class PluginCoreStoreysApi {
|
|
30
|
+
constructor() {}
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Get properties of a storey by its storey number.
|
|
34
|
+
*
|
|
35
|
+
* Only the properties listed in `properties` are returned — unlisted
|
|
36
|
+
* properties will be `undefined` in the result.
|
|
37
|
+
*
|
|
38
|
+
* @param storyValue - Integer storey number
|
|
39
|
+
* (e.g. `1` for ground floor, `2` for first floor, `-1` for basement)
|
|
40
|
+
* @param properties - Array of property names to retrieve. See
|
|
41
|
+
* {@linkcode PluginStoryGetProperty} for available values.
|
|
42
|
+
* @returns A partial {@linkcode PluginStoryGetResult} containing only the requested properties
|
|
43
|
+
* @throws If the storey with the given value does not exist
|
|
44
|
+
*
|
|
45
|
+
* @examplePrompt What is the height of the ground floor?
|
|
46
|
+
* @examplePrompt How many rooms are on the second storey?
|
|
47
|
+
* @examplePrompt Get the total floor area of level 3
|
|
48
|
+
* @examplePrompt Is the first floor hidden in the viewport?
|
|
49
|
+
* @examplePrompt Show me the name and height of storey 2
|
|
50
|
+
*
|
|
51
|
+
* # Example
|
|
52
|
+
* ```ts
|
|
53
|
+
* const info = await snaptrude.core.storeys.get(1, ["height", "name", "spacesCount"])
|
|
54
|
+
* console.log(info.name, info.height, info.spacesCount)
|
|
55
|
+
* ```
|
|
56
|
+
*/
|
|
57
|
+
public abstract get(
|
|
58
|
+
storyValue: number,
|
|
59
|
+
properties: PluginStoryGetProperty[],
|
|
60
|
+
): PluginApiReturn<PluginStoryGetResult>
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* List all storeys in the current project.
|
|
64
|
+
*
|
|
65
|
+
* Returns basic identification data for every storey. Storeys are sorted
|
|
66
|
+
* from **top to bottom** (highest storey value first).
|
|
67
|
+
*
|
|
68
|
+
* @returns A {@linkcode PluginCoreStoreysListResult} with a `storeys` array,
|
|
69
|
+
* each entry containing `value`, `id`, and `name`
|
|
70
|
+
*
|
|
71
|
+
* @examplePrompt How many floors does this building have?
|
|
72
|
+
* @examplePrompt List all the storeys in the project
|
|
73
|
+
* @examplePrompt Show me every level with its name
|
|
74
|
+
* @examplePrompt Which storeys exist in this model?
|
|
75
|
+
*
|
|
76
|
+
* # Example
|
|
77
|
+
* ```ts
|
|
78
|
+
* const { storeys } = await snaptrude.core.storeys.list()
|
|
79
|
+
* for (const s of storeys) {
|
|
80
|
+
* console.log(`Storey ${s.value}: ${s.name} (id: ${s.id})`)
|
|
81
|
+
* }
|
|
82
|
+
* ```
|
|
83
|
+
*/
|
|
84
|
+
public abstract list(): PluginApiReturn<PluginCoreStoreysListResult>
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* Create a new storey (floor) in the project.
|
|
88
|
+
*
|
|
89
|
+
* The new storey is inserted at the position specified by `storyValue`. This
|
|
90
|
+
* operation is undoable.
|
|
91
|
+
*
|
|
92
|
+
* @param storyValue - Integer storey number
|
|
93
|
+
* to create (e.g. `3` to add a third floor)
|
|
94
|
+
* @param height - Optional height in Babylon
|
|
95
|
+
* units. If omitted, the project's default storey height is used.
|
|
96
|
+
* @returns A {@linkcode PluginStoryCreateResult} with `storyId` and `storyValue`
|
|
97
|
+
* @throws If a storey with the given value already exists or creation fails
|
|
98
|
+
*
|
|
99
|
+
* @examplePrompt Add a third floor to the building
|
|
100
|
+
* @examplePrompt Create a new storey above the second floor
|
|
101
|
+
* @examplePrompt Add a basement level to this project
|
|
102
|
+
* @examplePrompt Insert a new level with a custom floor height
|
|
103
|
+
*
|
|
104
|
+
* # Example
|
|
105
|
+
* ```ts
|
|
106
|
+
* // Create a new third floor with custom height
|
|
107
|
+
* const { storyId } = await snaptrude.core.storeys.create(3, 4.5)
|
|
108
|
+
* ```
|
|
109
|
+
*/
|
|
110
|
+
public abstract create(
|
|
111
|
+
storyValue: number,
|
|
112
|
+
height?: number,
|
|
113
|
+
): PluginApiReturn<PluginStoryCreateResult>
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* Update a storey's floor-to-floor `height` and/or `name`.
|
|
117
|
+
*
|
|
118
|
+
* **Height** is the same operation as editing the height in the Storeys panel:
|
|
119
|
+
* the walls, columns, and masses on the storey are **stretched** to the new
|
|
120
|
+
* height, every storey **above shifts up/down** by the delta so the stack stays
|
|
121
|
+
* contiguous, and coupled elements (staircases, parametric curtain walls,
|
|
122
|
+
* furniture offsets) are re-fitted. The whole height cascade is committed as
|
|
123
|
+
* **one undo step**. Height-locked elements are left untouched.
|
|
124
|
+
*
|
|
125
|
+
* **Name** is the same as renaming the storey in the Storeys panel: it is
|
|
126
|
+
* persisted immediately but, mirroring the panel, is **not** part of the height
|
|
127
|
+
* undo step.
|
|
128
|
+
*
|
|
129
|
+
* At least one of `height` or `options.name` must be supplied. Omitting the
|
|
130
|
+
* `height` argument (e.g. for a rename-only update) leaves the height untouched.
|
|
131
|
+
*
|
|
132
|
+
* @param storyValue - Integer storey number identifying the storey to update
|
|
133
|
+
* @param height - New floor-to-floor height in
|
|
134
|
+
* Babylon units. Omit to leave the height unchanged.
|
|
135
|
+
* @param options - `name` (new display name for the storey)
|
|
136
|
+
* @returns A {@linkcode PluginStoryUpdateResult} with the storey's
|
|
137
|
+
* `storyValue`, `height`, and `name` after the update
|
|
138
|
+
* @throws `PRECONDITION_FAILED` if no storey has the given value;
|
|
139
|
+
* `VALIDATION` if neither `height` nor `options.name` is supplied;
|
|
140
|
+
* `STORY_HEIGHT_REJECTED` if the engine rejects the height;
|
|
141
|
+
* `STORY_UPDATE_FAILED` if the storey cannot be re-read after the update
|
|
142
|
+
*
|
|
143
|
+
* @examplePrompt Change the ground floor height to 3.5 metres
|
|
144
|
+
* @examplePrompt Make the second storey taller
|
|
145
|
+
* @examplePrompt Rename the ground floor to "Lobby"
|
|
146
|
+
* @examplePrompt Set the floor-to-floor height of level 1
|
|
147
|
+
*
|
|
148
|
+
* # Example
|
|
149
|
+
* ```ts
|
|
150
|
+
* // Set ground floor height to 5 Babylon units — walls stretch and the
|
|
151
|
+
* // floors above move up to match, all in a single undo step.
|
|
152
|
+
* const result = await snaptrude.core.storeys.update(1, 5)
|
|
153
|
+
* // Rename only, leaving the height untouched.
|
|
154
|
+
* await snaptrude.core.storeys.update(1, undefined, { name: "Lobby" })
|
|
155
|
+
* ```
|
|
156
|
+
*/
|
|
157
|
+
public abstract update(
|
|
158
|
+
storyValue: number,
|
|
159
|
+
height?: number,
|
|
160
|
+
options?: { name?: string },
|
|
161
|
+
): PluginApiReturn<PluginStoryUpdateResult>
|
|
162
|
+
|
|
163
|
+
/**
|
|
164
|
+
* Make a storey the active storey — the same as clicking it in the storey/layer
|
|
165
|
+
* panel. Subsequent draws and creates target this storey, and in 2D the
|
|
166
|
+
* viewport switches to it. This is a view/navigation change: it is **not**
|
|
167
|
+
* undoable and commits nothing to the model.
|
|
168
|
+
*
|
|
169
|
+
* @param storyValue - Integer storey number to activate
|
|
170
|
+
* @returns A {@linkcode PluginStorySetActiveResult} echoing the now-active `storyValue`
|
|
171
|
+
* @throws `PRECONDITION_FAILED` if no storey has the given value
|
|
172
|
+
*
|
|
173
|
+
* @examplePrompt Switch to the second floor
|
|
174
|
+
* @examplePrompt Make the ground storey active
|
|
175
|
+
* @examplePrompt Go to the basement level
|
|
176
|
+
* @examplePrompt Set level 3 as the current storey
|
|
177
|
+
*
|
|
178
|
+
* # Example
|
|
179
|
+
* ```ts
|
|
180
|
+
* // Activate storey 2, then draw a wall — it lands on storey 2.
|
|
181
|
+
* await snaptrude.core.storeys.setActive(2)
|
|
182
|
+
* ```
|
|
183
|
+
*/
|
|
184
|
+
public abstract setActive(
|
|
185
|
+
storyValue: number,
|
|
186
|
+
): PluginApiReturn<PluginStorySetActiveResult>
|
|
187
|
+
|
|
188
|
+
/**
|
|
189
|
+
* Delete a storey and everything on it — the same as removing it from the
|
|
190
|
+
* storey panel. Every element placed on the storey (walls, floors, masses, …)
|
|
191
|
+
* is deleted with it, the remaining storeys are re-stacked, and the active
|
|
192
|
+
* storey falls back to an adjacent one. Committed as a single undo step.
|
|
193
|
+
*
|
|
194
|
+
* @param storyValue - Integer storey number to delete
|
|
195
|
+
* @returns A {@linkcode PluginStoryDeleteResult} with the deleted `storyValue`
|
|
196
|
+
* and the `newActiveStory` the editor fell back to
|
|
197
|
+
* @throws `PRECONDITION_FAILED` if no storey has the given value; or if plugin
|
|
198
|
+
* writes are disabled
|
|
199
|
+
*
|
|
200
|
+
* @examplePrompt Delete the top floor
|
|
201
|
+
* @examplePrompt Remove the basement level
|
|
202
|
+
* @examplePrompt Get rid of storey 3
|
|
203
|
+
* @examplePrompt Delete the second floor and everything on it
|
|
204
|
+
*
|
|
205
|
+
* # Example
|
|
206
|
+
* ```ts
|
|
207
|
+
* const { newActiveStory } = await snaptrude.core.storeys.delete(3)
|
|
208
|
+
* console.log(`Deleted storey 3; now on storey ${newActiveStory}`)
|
|
209
|
+
* ```
|
|
210
|
+
*/
|
|
211
|
+
public abstract delete(
|
|
212
|
+
storyValue: number,
|
|
213
|
+
): PluginApiReturn<PluginStoryDeleteResult>
|
|
214
|
+
|
|
215
|
+
/**
|
|
216
|
+
* Copy a storey into the adjacent level, up or down.
|
|
217
|
+
*
|
|
218
|
+
* By default the **whole storey** is copied: every eligible element on the
|
|
219
|
+
* active storey (walls, floors, roofs, masses, columns, beams, staircases,
|
|
220
|
+
* ceilings, parametric curtain walls, and furniture) is copied into the storey
|
|
221
|
+
* one level `"up"` or `"down"`. Pass `options.components` to copy only a subset
|
|
222
|
+
* instead. The target storey is **created automatically** if it does not yet
|
|
223
|
+
* exist, inheriting the source storey's height.
|
|
224
|
+
*
|
|
225
|
+
* Copies are **instanced** by default (`unique: false`) — they share geometry
|
|
226
|
+
* with the source, so later edits propagate. Set `unique: true` for independent
|
|
227
|
+
* geometry. Doors and windows are never copied on their own; they ride along
|
|
228
|
+
* with their host wall. Locked, throw-away, and unsupported elements are skipped
|
|
229
|
+
* and counted in `skipped`. The whole operation is a single undo step.
|
|
230
|
+
*
|
|
231
|
+
* @param direction - `"up"` to copy into the storey above, `"down"` for below
|
|
232
|
+
* @param options - `components` (restrict to a subset of the storey's elements;
|
|
233
|
+
* omit for the whole storey) and `unique` (default `false` = instanced copies;
|
|
234
|
+
* `true` = independent geometry)
|
|
235
|
+
* @returns A {@linkcode PluginStoryDuplicateResult} with the `sourceStory`, the
|
|
236
|
+
* `targetStories` the copies landed on, the `created` component handles, the
|
|
237
|
+
* `createdStoryValues` for any storeys generated to receive them, and the
|
|
238
|
+
* `skipped` count of ineligible elements
|
|
239
|
+
* @throws `NO_ACTIVE_STRUCTURE` if there is no active structure to copy into;
|
|
240
|
+
* `NO_ELIGIBLE_ELEMENTS` if nothing on the source storey (or in
|
|
241
|
+
* `options.components`) is copyable; `HANDLE_INVALID` for a stale or foreign
|
|
242
|
+
* supplied handle; or if plugin writes are disabled
|
|
243
|
+
*
|
|
244
|
+
* @examplePrompt Copy this floor to the storey above
|
|
245
|
+
* @examplePrompt Copy the ground floor down into a new basement
|
|
246
|
+
* @examplePrompt Repeat this level upwards with its own independent geometry
|
|
247
|
+
* @examplePrompt Copy just the selected walls onto the next floor up
|
|
248
|
+
*
|
|
249
|
+
* # Example
|
|
250
|
+
* ```ts
|
|
251
|
+
* // Copy the whole active storey one level up (instanced copies).
|
|
252
|
+
* const { targetStories, created, skipped } =
|
|
253
|
+
* await snaptrude.core.storeys.copy("up")
|
|
254
|
+
* console.log(`Copied ${created.length} elements onto storey ${targetStories}`)
|
|
255
|
+
* if (skipped) console.log(`${skipped} elements were skipped`)
|
|
256
|
+
* ```
|
|
257
|
+
*/
|
|
258
|
+
public abstract copy(
|
|
259
|
+
direction: "up" | "down",
|
|
260
|
+
options?: { components?: ComponentHandle[]; unique?: boolean },
|
|
261
|
+
): PluginApiReturn<PluginStoryDuplicateResult>
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
/**
|
|
265
|
+
* Result of {@linkcode PluginCoreStoreysApi.list} — the {@linkcode PluginStoryGetAllResult}
|
|
266
|
+
* shape with the array field renamed `stories` → `storeys`. Each entry shares the
|
|
267
|
+
* same element type: `{ value, id, name }`, sorted top to bottom.
|
|
268
|
+
*
|
|
269
|
+
* | Property | Type | Description |
|
|
270
|
+
* |---|---|---|
|
|
271
|
+
* | `storeys` | `Array<{ value, id, name }>` | All storeys, sorted top to bottom |
|
|
272
|
+
*/
|
|
273
|
+
export const PluginCoreStoreysListResult = z.object({
|
|
274
|
+
storeys: PluginStoryGetAllResult.shape.stories,
|
|
275
|
+
})
|
|
276
|
+
|
|
277
|
+
export type PluginCoreStoreysListResult = z.infer<
|
|
278
|
+
typeof PluginCoreStoreysListResult
|
|
279
|
+
>
|
package/src/api/core/tags.ts
CHANGED
|
@@ -131,11 +131,38 @@ export abstract class PluginCoreTagsApi {
|
|
|
131
131
|
* const { tags } = await snaptrude.core.tags.getTagsForComponent("cmp_42")
|
|
132
132
|
* for (const t of tags) console.log(t.categoryName, t.tagName)
|
|
133
133
|
* ```
|
|
134
|
+
*
|
|
135
|
+
* @deprecated Use `core.tags.listForComponent`
|
|
134
136
|
*/
|
|
135
137
|
public abstract getTagsForComponent(
|
|
136
138
|
componentId: ComponentHandle,
|
|
137
139
|
): PluginApiReturn<PluginCoreTagsGetTagsForComponentResult>
|
|
138
140
|
|
|
141
|
+
/**
|
|
142
|
+
* List the tags carried by a component.
|
|
143
|
+
*
|
|
144
|
+
* Returns one entry per category the component is tagged in, each carrying the
|
|
145
|
+
* category and tag names and the tag color. Canonical home of the read formerly
|
|
146
|
+
* at `getTagsForComponent` (now deprecated).
|
|
147
|
+
*
|
|
148
|
+
* @param componentId - The `Component.id` to read.
|
|
149
|
+
* @returns A {@linkcode PluginCoreTagsGetTagsForComponentResult} with a `tags`
|
|
150
|
+
* array (empty when the component has none or does not exist).
|
|
151
|
+
*
|
|
152
|
+
* @examplePrompt What tags does this space have?
|
|
153
|
+
* @examplePrompt List the tags on component cmp_42
|
|
154
|
+
* @examplePrompt Show the labels applied to this room
|
|
155
|
+
*
|
|
156
|
+
* # Example
|
|
157
|
+
* ```ts
|
|
158
|
+
* const { tags } = await snaptrude.core.tags.listForComponent("cmp_42")
|
|
159
|
+
* for (const t of tags) console.log(t.categoryName, t.tagName)
|
|
160
|
+
* ```
|
|
161
|
+
*/
|
|
162
|
+
public abstract listForComponent(
|
|
163
|
+
componentId: ComponentHandle,
|
|
164
|
+
): PluginApiReturn<PluginCoreTagsGetTagsForComponentResult>
|
|
165
|
+
|
|
139
166
|
/**
|
|
140
167
|
* List the components carrying a given tag or category.
|
|
141
168
|
*
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import * as z from "zod"
|
|
2
|
+
import { PluginApiReturn } from "../../types"
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* User locale.
|
|
6
|
+
*
|
|
7
|
+
* Read the viewer's timezone and language — for date/number formatting and
|
|
8
|
+
* localized labels. This is locale only: NO precise geolocation, no IP, no
|
|
9
|
+
* account identity. Accessed via `snaptrude.core.user`.
|
|
10
|
+
*/
|
|
11
|
+
export abstract class PluginUserApi {
|
|
12
|
+
constructor() {}
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Get the viewer's locale: IANA timezone and BCP-47 language tag, resolved
|
|
16
|
+
* from the browser (`Intl.DateTimeFormat().resolvedOptions().timeZone` and
|
|
17
|
+
* `navigator.language`). Locale only — no precise location.
|
|
18
|
+
*
|
|
19
|
+
* @returns `{ timezone, language }` — e.g. `{ timezone: "Asia/Kolkata", language: "en-US" }`.
|
|
20
|
+
*
|
|
21
|
+
* @examplePrompt What timezone is the user in?
|
|
22
|
+
* @examplePrompt Get the viewer's language for localized labels
|
|
23
|
+
* @examplePrompt Format the report date in the user's local timezone
|
|
24
|
+
* @examplePrompt Which locale should I use for this plugin's UI?
|
|
25
|
+
*
|
|
26
|
+
* # Example
|
|
27
|
+
* ```ts
|
|
28
|
+
* const { timezone, language } = await snaptrude.core.user.getLocale()
|
|
29
|
+
* ```
|
|
30
|
+
*/
|
|
31
|
+
public abstract getLocale(): PluginApiReturn<PluginUserLocale>
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* The viewer's locale.
|
|
36
|
+
*
|
|
37
|
+
* | Property | Type | Description |
|
|
38
|
+
* |---|---|---|
|
|
39
|
+
* | `timezone` | `string` | IANA timezone id (e.g. `"Asia/Kolkata"`) |
|
|
40
|
+
* | `language` | `string` | BCP-47 language tag (e.g. `"en-US"`) |
|
|
41
|
+
*/
|
|
42
|
+
export const PluginUserLocale = z.object({
|
|
43
|
+
timezone: z.string(),
|
|
44
|
+
language: z.string(),
|
|
45
|
+
})
|
|
46
|
+
export type PluginUserLocale = z.infer<typeof PluginUserLocale>
|
|
@@ -24,6 +24,8 @@ export abstract class PluginZoomApi {
|
|
|
24
24
|
* ```ts
|
|
25
25
|
* await snaptrude.core.zoom.extents()
|
|
26
26
|
* ```
|
|
27
|
+
*
|
|
28
|
+
* @deprecated Use `core.camera.zoomExtents`
|
|
27
29
|
*/
|
|
28
30
|
public abstract extents(): PluginApiReturn<boolean>
|
|
29
31
|
|
|
@@ -42,6 +44,8 @@ export abstract class PluginZoomApi {
|
|
|
42
44
|
* ```ts
|
|
43
45
|
* await snaptrude.core.zoom.selection()
|
|
44
46
|
* ```
|
|
47
|
+
*
|
|
48
|
+
* @deprecated Use `core.camera.zoomSelection`
|
|
45
49
|
*/
|
|
46
50
|
public abstract selection(): PluginApiReturn<boolean>
|
|
47
51
|
}
|