@snaptrude/plugin-core 0.9.5 → 0.9.6

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@snaptrude/plugin-core",
3
- "version": "0.9.5",
3
+ "version": "0.9.6",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.js",
@@ -16,17 +16,6 @@
16
16
  "publishConfig": {
17
17
  "access": "public"
18
18
  },
19
- "scripts": {
20
- "check-types": "tsc --noEmit",
21
- "build": "tsup --clean",
22
- "dev": "tsup --watch",
23
- "clean-dist": "rm -rf dist",
24
- "test": "node --test test/*.test.mjs",
25
- "generate:manifest": "node scripts/generate-manifest.mjs",
26
- "generate:manifest:check": "node scripts/generate-manifest.mjs --check",
27
- "generate:manifest:all": "node scripts/generate-manifest.mjs --all",
28
- "generate:manifest:all:check": "node scripts/generate-manifest.mjs --all --check"
29
- },
30
19
  "devDependencies": {
31
20
  "ts-morph": "^28.0.0",
32
21
  "tsup": "^8.5.1",
@@ -37,5 +26,16 @@
37
26
  },
38
27
  "peerDependencies": {
39
28
  "zod": "^3.25.0 || ^4.0.0"
29
+ },
30
+ "scripts": {
31
+ "check-types": "tsc --noEmit",
32
+ "build": "tsup --clean",
33
+ "dev": "tsup --watch",
34
+ "clean-dist": "rm -rf dist",
35
+ "test": "node --test test/*.test.mjs",
36
+ "generate:manifest": "node scripts/generate-manifest.mjs",
37
+ "generate:manifest:check": "node scripts/generate-manifest.mjs --check",
38
+ "generate:manifest:all": "node scripts/generate-manifest.mjs --all",
39
+ "generate:manifest:all:check": "node scripts/generate-manifest.mjs --all --check"
40
40
  }
41
- }
41
+ }
@@ -62,6 +62,23 @@ export abstract class PluginCameraApi {
62
62
  view: PluginStandardView,
63
63
  ): PluginApiReturn<boolean>
64
64
 
65
+ /**
66
+ * Get the current camera mode. Paired with {@linkcode PluginCameraApi.setMode}.
67
+ *
68
+ * @returns `"2d"` when the editor is in plan view, `"3d"` otherwise.
69
+ *
70
+ * @examplePrompt Am I in 2D or 3D?
71
+ * @examplePrompt What view mode is the editor in?
72
+ *
73
+ * # Example
74
+ * ```ts
75
+ * if ((await snaptrude.core.camera.getMode()) === "2d") {
76
+ * await snaptrude.core.camera.setMode("3d")
77
+ * }
78
+ * ```
79
+ */
80
+ public abstract getMode(): PluginApiReturn<PluginCameraMode>
81
+
65
82
  /**
66
83
  * Toggle the modelling mode between `2d` (plan) and `3d`. Mirrors the canvas
67
84
  * 2D/3D toggle: `3d` enters the isometric perspective view, `2d` drops to the
@@ -1,15 +1,47 @@
1
1
  import * as z from "zod"
2
2
  import { PluginApiReturn } from "../../../types"
3
+ import { PUnitType } from "../units"
3
4
 
4
5
  /**
5
6
  * Project-level settings and info.
6
7
  *
7
- * Accessed via `snaptrude.core.project`. Currently exposes
8
+ * Accessed via `snaptrude.core.project`. Exposes
9
+ * {@linkcode PluginProjectApi.getInfo} (project identity) and
8
10
  * {@linkcode PluginProjectApi.settings} (snap + grid controls).
9
11
  */
10
12
  export abstract class PluginProjectApi {
11
13
  constructor() {}
12
14
 
15
+ /**
16
+ * Read identity and headline facts about the currently open project — id,
17
+ * display name, unit type, storey count, active storey, and site location
18
+ * when the project is geo-located.
19
+ *
20
+ * `activeStorey` and `storeyCount` are both scoped to the ACTIVE BUILDING, so
21
+ * they always describe the same building. In a multi-building project
22
+ * `storeyCount` is therefore NOT the total across every building — use
23
+ * `core.storeys.list()`, which spans all buildings, for that.
24
+ *
25
+ * @returns A {@linkcode PluginProjectInfo}. `name` is `null` only when the
26
+ * project genuinely has no title; `location` is `null` only when the project
27
+ * is not geo-located. Neither is used to signal a failure.
28
+ * @throws PRECONDITION_FAILED when no project is open.
29
+ * @throws OPERATION_FAILED when the project lookup or the site-location read
30
+ * fails. A failed read is never reported as `null`.
31
+ *
32
+ * @examplePrompt What is this project called?
33
+ * @examplePrompt Where is this project located?
34
+ * @examplePrompt Give me a summary of this project
35
+ * @examplePrompt How many storeys does this project have?
36
+ *
37
+ * # Example
38
+ * ```ts
39
+ * const info = await snaptrude.core.project.getInfo()
40
+ * console.log(info.name, info.units, info.storeyCount)
41
+ * ```
42
+ */
43
+ public abstract getInfo(): PluginApiReturn<PluginProjectInfo>
44
+
13
45
  /** Project settings — snaps and grid. See {@linkcode PluginProjectSettingsApi}. */
14
46
  public abstract settings: PluginProjectSettingsApi
15
47
  }
@@ -416,3 +448,32 @@ export const PluginToleranceArgs = z.object({
416
448
  })
417
449
 
418
450
  export type PluginToleranceArgs = z.infer<typeof PluginToleranceArgs>
451
+
452
+ /**
453
+ * Identity and headline facts about the currently open project.
454
+ *
455
+ * `location` is a read-only projection of {@linkcode PluginProgramSiteApi.getLocation}
456
+ * — `program.site.*` remains the full site surface (context, weather, polygons).
457
+ * It is mirrored here because "what and where is this project" is one question.
458
+ *
459
+ * | Property | Type | Description |
460
+ * |---|---|---|
461
+ * | `projectId` | `string` | The open project's id (floorkey) |
462
+ * | `name` | `string \| null` | Display name; `null` only when the project has no title (a failed lookup throws) |
463
+ * | `units` | {@linkcode PUnitType} | The project's unit type |
464
+ * | `activeStorey` | `number` | The active storey value, in the active building |
465
+ * | `storeyCount` | `number` | How many storeys the ACTIVE BUILDING has (not the project-wide total — `core.storeys.list()` spans all buildings) |
466
+ * | `location` | `{ latitude, longitude } \| null` | Site location; `null` only when not geo-located (a failed read throws) |
467
+ */
468
+ export const PluginProjectInfo = z.object({
469
+ projectId: z.string(),
470
+ name: z.string().nullable(),
471
+ units: PUnitType,
472
+ activeStorey: z.number(),
473
+ storeyCount: z.number(),
474
+ location: z
475
+ .object({ latitude: z.number(), longitude: z.number() })
476
+ .nullable(),
477
+ })
478
+
479
+ export type PluginProjectInfo = z.infer<typeof PluginProjectInfo>
@@ -160,6 +160,21 @@ export abstract class PluginCoreStoreysApi {
160
160
  options?: { name?: string },
161
161
  ): PluginApiReturn<PluginStoryUpdateResult>
162
162
 
163
+ /**
164
+ * Get the active storey's value. Paired with {@linkcode PluginCoreStoreysApi.setActive}.
165
+ *
166
+ * @returns The active storey value, in the same numbering `list` and `get` use.
167
+ *
168
+ * @examplePrompt Which storey am I on?
169
+ * @examplePrompt What is the current storey?
170
+ *
171
+ * # Example
172
+ * ```ts
173
+ * const storey = await snaptrude.core.storeys.getActive()
174
+ * ```
175
+ */
176
+ public abstract getActive(): PluginApiReturn<number>
177
+
163
178
  /**
164
179
  * Make a storey the active storey — the same as clicking it in the storey/layer
165
180
  * panel. Subsequent draws and creates target this storey, and in 2D the
@@ -2,6 +2,7 @@ import * as z from "zod"
2
2
  import { PluginApiReturn } from "../../../types"
3
3
  import { ComponentHandle } from "../../../handles"
4
4
  import { PluginDesignChangeResult } from "../lock"
5
+ import { PluginObjectCatalogGroup } from "../doors"
5
6
 
6
7
  /**
7
8
  * `snaptrude.design.furniture` — the placeable furniture **catalog** (a library of
@@ -92,9 +93,42 @@ export abstract class PluginDesignFurnitureApi {
92
93
  * const items = await snaptrude.design.furniture.listCatalog(undefined, first)
93
94
  * console.log(first, "→", items.length, "items")
94
95
  * ```
96
+ *
97
+ * @deprecated Use `design.furniture.listCatalogGroups` — the same name
98
+ * `design.doors` and `design.windows` use. Still supported.
95
99
  */
96
100
  public abstract listCategories(): PluginApiReturn<string[]>
97
101
 
102
+ /**
103
+ * List the furniture catalog's groups. Matches
104
+ * {@linkcode PluginDesignDoorsApi.listCatalogGroups} and
105
+ * {@linkcode PluginDesignWindowsApi.listCatalogGroups}, so all three catalog
106
+ * surfaces are named alike.
107
+ *
108
+ * `source` is `"default"` for the built-in picker groups and `"team"` for the
109
+ * sub-types of THIS project's team library — exactly the split
110
+ * {@linkcode PluginDesignFurnitureApi.listCatalog}'s `source` filter uses, so
111
+ * every `"team"` group is guaranteed to match at least one team item here.
112
+ * For furniture the group token and its label are the same string (the
113
+ * category), so `dbType === label`; `design.doors`/`design.windows` have a
114
+ * distinct engine `dbType`.
115
+ *
116
+ * @returns The catalog groups as {@linkcode PluginObjectCatalogGroup}`[]`
117
+ * (`[]` when empty). Pass a group's `dbType` (=== `label`) to
118
+ * {@linkcode PluginDesignFurnitureApi.listCatalog}'s `category` filter to
119
+ * list its items.
120
+ *
121
+ * @examplePrompt What furniture groups are available?
122
+ * @examplePrompt List the furniture categories in this project
123
+ *
124
+ * # Example
125
+ * ```ts
126
+ * const groups = await snaptrude.design.furniture.listCatalogGroups()
127
+ * for (const g of groups) console.log(g.dbType, g.label, g.source)
128
+ * ```
129
+ */
130
+ public abstract listCatalogGroups(): PluginApiReturn<PluginObjectCatalogGroup[]>
131
+
98
132
  /**
99
133
  * List the placeable furniture catalog (team + general libraries),
100
134
  * optionally filtered by library `source` and/or `category`.
@@ -39,6 +39,26 @@ export abstract class PluginDesignVisibilityApi {
39
39
  components: ComponentHandle[],
40
40
  ): PluginApiReturn<PluginDesignChangeResult>
41
41
 
42
+ /**
43
+ * Reveal specific hidden components — the inverse of
44
+ * {@linkcode PluginDesignVisibilityApi.hide}. Use
45
+ * {@linkcode PluginDesignVisibilityApi.showAll} to reveal everything.
46
+ *
47
+ * @param components - The components to reveal.
48
+ * @returns A {@linkcode PluginDesignChangeResult} echoing the components shown.
49
+ *
50
+ * @examplePrompt Show these walls again
51
+ * @examplePrompt Unhide the selected furniture
52
+ *
53
+ * # Example
54
+ * ```ts
55
+ * await snaptrude.design.visibility.show([wall])
56
+ * ```
57
+ */
58
+ public abstract show(
59
+ components: ComponentHandle[],
60
+ ): PluginApiReturn<PluginDesignChangeResult>
61
+
42
62
  /**
43
63
  * Isolate entities — hide everything else so only the given entities remain
44
64
  * visible (the "Isolate" / solo action). Undoable. Reverse it with
@@ -94,6 +114,20 @@ export const PluginDesignVisibilityHideArgs = z.object({
94
114
  })
95
115
  export type PluginDesignVisibilityHideArgs = z.infer<typeof PluginDesignVisibilityHideArgs>
96
116
 
117
+ /**
118
+ * Arguments for {@linkcode PluginDesignVisibilityApi.show}.
119
+ *
120
+ * | Property | Type | Description |
121
+ * |---|---|---|
122
+ * | `components` | {@linkcode ComponentHandle}`[]` | Entities to reveal |
123
+ */
124
+ export const PluginDesignVisibilityShowArgs = z.object({
125
+ components: z.array(ComponentHandle),
126
+ })
127
+ export type PluginDesignVisibilityShowArgs = z.infer<
128
+ typeof PluginDesignVisibilityShowArgs
129
+ >
130
+
97
131
  /**
98
132
  * Arguments for {@linkcode PluginDesignVisibilityApi.isolate}.
99
133
  *