@collabdt/plugin-kit 0.1.0 → 0.3.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/README.md CHANGED
@@ -1,131 +1,131 @@
1
- <div align="center">
2
- <br />
3
- <img src="https://github.com/collabdt/docs/raw/main/static/img/cdt-logo.svg" alt="Collab Digital Twins Logo" height="72" />
4
- <br /><br />
5
-
6
- <h1>@collabdt/plugin-kit</h1>
7
-
8
- <p><strong>Build preset and SDK types for CDT platform plugins</strong></p>
9
-
10
- <p>
11
- <a href="https://docs.collabdt.org/docs/plugins/overview">Plugin Docs</a> ·
12
- <a href="https://docs.collabdt.org/docs/plugins/all-capabilities">Capabilities</a> ·
13
- <a href="https://www.npmjs.com/package/create-cdt-plugin">create-cdt-plugin</a> ·
14
- <a href="https://collabdt.org">Website</a>
15
- </p>
16
-
17
- <br />
18
-
19
- <a href="https://www.npmjs.com/package/@collabdt/plugin-kit"><img src="https://img.shields.io/npm/v/@collabdt/plugin-kit?style=flat-square&color=orange&label=%40collabdt%2Fplugin-kit" alt="npm version" /></a>
20
- <img src="https://img.shields.io/badge/license-AGPL%203.0-orange?style=flat-square" alt="License" />
21
- <img src="https://img.shields.io/badge/dependencies-zero-orange?style=flat-square" alt="Zero runtime dependencies" />
22
-
23
- <br /><br />
24
-
25
- <img src="https://img.shields.io/badge/TypeScript-3178c6?style=flat-square&logo=typescript&logoColor=white" alt="TypeScript" />
26
- <img src="https://img.shields.io/badge/tsup-black?style=flat-square" alt="tsup" />
27
- <img src="https://img.shields.io/badge/Node-22%2B-339933?style=flat-square&logo=node.js&logoColor=white" alt="Node 22+" />
28
-
29
- <br /><br />
30
- <hr />
31
- <br />
32
- </div>
33
-
34
- ## What is this?
35
-
36
- The build half of the plugin toolchain for the [CDT platform](https://collabdt.org). It gives a plugin author two things and no runtime dependencies:
37
-
38
- - **`pluginPreset()`** — the [tsup](https://tsup.egoist.dev) configuration a plugin needs, plus a post-build guard that fails if the plugin imports anything the platform cannot resolve.
39
- - **Per-surface SDK types** — the shapes a plugin's component receives, without installing `@collabdt/core`.
40
-
41
- Most people never install this directly. [`create-cdt-plugin`](https://www.npmjs.com/package/create-cdt-plugin) scaffolds a plugin that already depends on it and is already configured.
42
-
43
- ---
44
-
45
- ## Usage
46
-
47
- The whole build configuration:
48
-
49
- ```ts
50
- // tsup.config.ts
51
- import { pluginPreset } from '@collabdt/plugin-kit'
52
-
53
- export default pluginPreset()
54
- ```
55
-
56
- That emits a single ESM `dist/index.js`, marks the platform's shared modules external, and then checks the emitted bundle. Types come from the entry matching your surface:
57
-
58
- ```ts
59
- import type { MapToolProps, ToolbarToolProps } from '@collabdt/plugin-kit/types/map'
60
- ```
61
-
62
- | Entry | For | Names |
63
- |---|---|---|
64
- | `@collabdt/plugin-kit/types/map` | `map.tools` | `maplibre-gl` types |
65
- | `@collabdt/plugin-kit/types/bim` | `bim.tools` | `@thatopen/components` types |
66
- | `@collabdt/plugin-kit/types/pointcloud` | `pointcloud.tools` | nothing external |
67
- | `@collabdt/plugin-kit/types/legend` | `map.legends` | nothing external |
68
-
69
- Split per surface on purpose. A single combined entry would make a map plugin's typecheck fail on unresolved `@thatopen/components` references it has no reason to install, so only the map and BIM surfaces need a type-only dependency at all.
70
-
71
- Your `tsconfig.json` needs `"moduleResolution": "bundler"`, since these are reached through `exports` subpaths. It needs no `paths` mapping: importing from a surface entry pulls in ambient declarations for `@collabdt/core/plugins-sdk*`, which is what lets a plugin typecheck the SDK's real exports without installing core.
72
-
73
- ---
74
-
75
- ## Why the guard exists
76
-
77
- Marking the platform's modules external is only half the contract. The other half is importing nothing else, and getting that wrong does not fail loudly:
78
-
79
- - **Bundle too much** and the plugin ships a second copy of React or three.js. A second React breaks hooks outright; a second three.js crashes the BIM viewer. Both are runtime crashes in someone else's browser, attributed to the plugin rather than to the duplicate.
80
- - **Bundle too little** and a bare specifier survives into the bundle with no import map entry, dying at load with a message that blames the plugin rather than the missing shim.
81
-
82
- The guard turns both into a build failure at the moment the import is written. It reads esbuild's metafile rather than scanning the bundle text, because a string literal containing `from 'three'` would fool a regex, and it makes two separate checks:
83
-
84
- 1. **External imports** catch a specifier the platform publishes no shim for.
85
- 2. **Bundled packages** catch a forbidden library that was *inlined*. esbuild only marks an import external if it is on the external list, so an author who has `three` installed and imports it gets a bundle with three.js baked in and no external import to inspect. Check 1 alone would report that bundle clean, which is why it is not the only check.
86
-
87
- A plugin may import `react`, `react-dom`, `react/jsx-runtime`, and `@collabdt/core/plugins-sdk` with its `/config`, `/messages`, `/store` and `/components` entries. Nothing else. Viewer instances arrive as props and icons are named by string, so `three`, `@thatopen/components`, `maplibre-gl` and `lucide-react` are never needed at runtime.
88
-
89
- ---
90
-
91
- ## What the preset refuses
92
-
93
- `pluginPreset()` takes overrides, but rejects the ones that would quietly break delivery or switch the guard off:
94
-
95
- | Override | Why it is refused |
96
- |---|---|
97
- | `entry`, `outDir` | The platform serves `dist/index.js` from `src/index.ts` and nothing else. |
98
- | `splitting: true` | A code-split chunk beside `index.js` would not resolve. |
99
- | `format` other than ESM | The browser imports the bundle directly and resolves its bare specifiers through the platform's import map. |
100
- | `external` | It is what the guard checks against. A plugin cannot widen the allowlist. |
101
- | `onSuccess` | It is what runs the guard. Call `assertBundleImports()` from your own step instead. |
102
-
103
- Refusing loudly matters more than it sounds: each of these would otherwise produce a build that passes and a plugin that fails later, somewhere less obvious.
104
-
105
- ---
106
-
107
- ## Also exported
108
-
109
- For a stricter or more forgiving check of your own: `assertBundleImports`, `checkImports`, `checkBundled`, `collectExternalImports`, `collectBundledPackages`, `canVerifyBundled`, `PLUGIN_EXTERNALS`, `KNOWN_FORBIDDEN`, `PLUGIN_METAFILE`, `PLUGIN_OUT_FILE`.
110
-
111
- ---
112
-
113
- ## Requirements
114
-
115
- Node 22 or newer, and `tsup` 8 or newer as a peer. `@types/react` is a required peer; `maplibre-gl` and `@thatopen/components` are optional peers, needed only for the surface that names them and only as types.
116
-
117
- This package has **no runtime dependencies**. Scaffolding a legend plugin should not install three.js to read a config object, which is also why the allowlist is a literal here rather than an import from `@collabdt/core`. A test in core fails if the two ever disagree.
118
-
119
- ---
120
-
121
- ## Licensing
122
-
123
- Free and open source under the **GNU Affero General Public License, version 3.0** ([full text](LICENSE) · [summary](https://www.gnu.org/licenses/agpl-3.0.en.html)). For commercial licensing, contact **[info@collabdt.org](mailto:info@collabdt.org)**.
124
-
125
- > Copyright © 2025 Collab Digital Twins. Distributed under AGPL-3.0.
126
-
127
- ---
128
-
129
- <div align="center">
130
- <sub>Stewarded by a Canadian not-for-profit organization for long-term public benefit.</sub>
131
- </div>
1
+ <div align="center">
2
+ <br />
3
+ <img src="https://github.com/collabdt/docs/raw/main/static/img/cdt-logo.svg" alt="Collab Digital Twins Logo" height="72" />
4
+ <br /><br />
5
+
6
+ <h1>@collabdt/plugin-kit</h1>
7
+
8
+ <p><strong>Build preset and SDK types for CDT platform plugins</strong></p>
9
+
10
+ <p>
11
+ <a href="https://docs.collabdt.org/docs/plugins/overview">Plugin Docs</a> ·
12
+ <a href="https://docs.collabdt.org/docs/plugins/all-capabilities">Capabilities</a> ·
13
+ <a href="https://www.npmjs.com/package/create-cdt-plugin">create-cdt-plugin</a> ·
14
+ <a href="https://collabdt.org">Website</a>
15
+ </p>
16
+
17
+ <br />
18
+
19
+ <a href="https://www.npmjs.com/package/@collabdt/plugin-kit"><img src="https://img.shields.io/npm/v/@collabdt/plugin-kit?style=flat-square&color=orange&label=%40collabdt%2Fplugin-kit" alt="npm version" /></a>
20
+ <img src="https://img.shields.io/badge/license-AGPL%203.0-orange?style=flat-square" alt="License" />
21
+ <img src="https://img.shields.io/badge/dependencies-zero-orange?style=flat-square" alt="Zero runtime dependencies" />
22
+
23
+ <br /><br />
24
+
25
+ <img src="https://img.shields.io/badge/TypeScript-3178c6?style=flat-square&logo=typescript&logoColor=white" alt="TypeScript" />
26
+ <img src="https://img.shields.io/badge/tsup-black?style=flat-square" alt="tsup" />
27
+ <img src="https://img.shields.io/badge/Node-22%2B-339933?style=flat-square&logo=node.js&logoColor=white" alt="Node 22+" />
28
+
29
+ <br /><br />
30
+ <hr />
31
+ <br />
32
+ </div>
33
+
34
+ ## What is this?
35
+
36
+ The build half of the plugin toolchain for the [CDT platform](https://collabdt.org). It gives a plugin author two things and no runtime dependencies:
37
+
38
+ - **`pluginPreset()`** — the [tsup](https://tsup.egoist.dev) configuration a plugin needs, plus a post-build guard that fails if the plugin imports anything the platform cannot resolve.
39
+ - **Per-surface SDK types** — the shapes a plugin's component receives, without installing `@collabdt/core`.
40
+
41
+ Most people never install this directly. [`create-cdt-plugin`](https://www.npmjs.com/package/create-cdt-plugin) scaffolds a plugin that already depends on it and is already configured.
42
+
43
+ ---
44
+
45
+ ## Usage
46
+
47
+ The whole build configuration:
48
+
49
+ ```ts
50
+ // tsup.config.ts
51
+ import { pluginPreset } from '@collabdt/plugin-kit'
52
+
53
+ export default pluginPreset()
54
+ ```
55
+
56
+ That emits a single ESM `dist/index.js`, marks the platform's shared modules external, and then checks the emitted bundle. Types come from the entry matching your surface:
57
+
58
+ ```ts
59
+ import type { MapToolProps, ToolbarToolProps } from '@collabdt/plugin-kit/types/map'
60
+ ```
61
+
62
+ | Entry | For | Names |
63
+ |---|---|---|
64
+ | `@collabdt/plugin-kit/types/map` | `map.tools` | `maplibre-gl` types |
65
+ | `@collabdt/plugin-kit/types/bim` | `bim.tools` | `@thatopen/components` types |
66
+ | `@collabdt/plugin-kit/types/pointcloud` | `pointcloud.tools` | nothing external |
67
+ | `@collabdt/plugin-kit/types/legend` | `viewer.legends` | nothing external |
68
+
69
+ Split per surface on purpose. A single combined entry would make a map plugin's typecheck fail on unresolved `@thatopen/components` references it has no reason to install, so only the map and BIM surfaces need a type-only dependency at all.
70
+
71
+ Your `tsconfig.json` needs `"moduleResolution": "bundler"`, since these are reached through `exports` subpaths. It needs no `paths` mapping: importing from a surface entry pulls in ambient declarations for `@collabdt/core/plugins-sdk*`, which is what lets a plugin typecheck the SDK's real exports without installing core.
72
+
73
+ ---
74
+
75
+ ## Why the guard exists
76
+
77
+ Marking the platform's modules external is only half the contract. The other half is importing nothing else, and getting that wrong does not fail loudly:
78
+
79
+ - **Bundle too much** and the plugin ships a second copy of React or three.js. A second React breaks hooks outright; a second three.js crashes the BIM viewer. Both are runtime crashes in someone else's browser, attributed to the plugin rather than to the duplicate.
80
+ - **Bundle too little** and a bare specifier survives into the bundle with no import map entry, dying at load with a message that blames the plugin rather than the missing shim.
81
+
82
+ The guard turns both into a build failure at the moment the import is written. It reads esbuild's metafile rather than scanning the bundle text, because a string literal containing `from 'three'` would fool a regex, and it makes two separate checks:
83
+
84
+ 1. **External imports** catch a specifier the platform publishes no shim for.
85
+ 2. **Bundled packages** catch a forbidden library that was *inlined*. esbuild only marks an import external if it is on the external list, so an author who has `three` installed and imports it gets a bundle with three.js baked in and no external import to inspect. Check 1 alone would report that bundle clean, which is why it is not the only check.
86
+
87
+ A plugin may import `react`, `react-dom`, `react/jsx-runtime`, and `@collabdt/core/plugins-sdk` with its `/config`, `/messages`, `/store` and `/components` entries. Nothing else. Viewer instances arrive as props and icons are named by string, so `three`, `@thatopen/components`, `maplibre-gl` and `lucide-react` are never needed at runtime.
88
+
89
+ ---
90
+
91
+ ## What the preset refuses
92
+
93
+ `pluginPreset()` takes overrides, but rejects the ones that would quietly break delivery or switch the guard off:
94
+
95
+ | Override | Why it is refused |
96
+ |---|---|
97
+ | `entry`, `outDir` | The platform serves `dist/index.js` from `src/index.ts` and nothing else. |
98
+ | `splitting: true` | A code-split chunk beside `index.js` would not resolve. |
99
+ | `format` other than ESM | The browser imports the bundle directly and resolves its bare specifiers through the platform's import map. |
100
+ | `external` | It is what the guard checks against. A plugin cannot widen the allowlist. |
101
+ | `onSuccess` | It is what runs the guard. Call `assertBundleImports()` from your own step instead. |
102
+
103
+ Refusing loudly matters more than it sounds: each of these would otherwise produce a build that passes and a plugin that fails later, somewhere less obvious.
104
+
105
+ ---
106
+
107
+ ## Also exported
108
+
109
+ For a stricter or more forgiving check of your own: `assertBundleImports`, `checkImports`, `checkBundled`, `collectExternalImports`, `collectBundledPackages`, `canVerifyBundled`, `PLUGIN_EXTERNALS`, `KNOWN_FORBIDDEN`, `PLUGIN_METAFILE`, `PLUGIN_OUT_FILE`.
110
+
111
+ ---
112
+
113
+ ## Requirements
114
+
115
+ Node 22 or newer, and `tsup` 8 or newer as a peer. `@types/react` is a required peer; `maplibre-gl` and `@thatopen/components` are optional peers, needed only for the surface that names them and only as types.
116
+
117
+ This package has **no runtime dependencies**. Scaffolding a legend plugin should not install three.js to read a config object, which is also why the allowlist is a literal here rather than an import from `@collabdt/core`. A test in core fails if the two ever disagree.
118
+
119
+ ---
120
+
121
+ ## Licensing
122
+
123
+ Free and open source under the **GNU Affero General Public License, version 3.0** ([full text](LICENSE) · [summary](https://www.gnu.org/licenses/agpl-3.0.en.html)). For commercial licensing, contact **[info@collabdt.org](mailto:info@collabdt.org)**.
124
+
125
+ > Copyright © 2025 Collab Digital Twins. Distributed under AGPL-3.0.
126
+
127
+ ---
128
+
129
+ <div align="center">
130
+ <sub>Stewarded by a Canadian not-for-profit organization for long-term public benefit.</sub>
131
+ </div>
@@ -0,0 +1,89 @@
1
+ import * as React from 'react';
2
+
3
+ /** Declare as `hostApi` in your manifest. The host refuses a plugin that declares another value. */
4
+ declare const PLUGIN_HOST_API = 1;
5
+ declare const VALID_CAPABILITIES: readonly ["data.pages", "viewer.tabs", "ui.dialogs", "map.tools", "bim.tools", "pointcloud.tools", "viewer.legends", "map.layers"];
6
+ type PluginCapability = typeof VALID_CAPABILITIES[number];
7
+ interface PluginManifest {
8
+ slug: string;
9
+ name: string;
10
+ version: string;
11
+ /** Omitting this is allowed but warned about, which defers a version mismatch to render time. */
12
+ hostApi?: number;
13
+ description?: string;
14
+ author?: string;
15
+ capabilities: PluginCapability[];
16
+ requiredPermissions?: string[];
17
+ configSchema?: Record<string, unknown>;
18
+ /** Strings by locale then key, folded into the app's tree under `plugins.<slug>`. May nest. */
19
+ messages?: Record<string, Record<string, unknown>>;
20
+ }
21
+ /** Every toolbar component receives the toolbar entry core built for it. */
22
+ interface ToolbarToolProps {
23
+ tool: unknown;
24
+ }
25
+ interface ToolbarRegistration<P = Record<string, unknown>> {
26
+ id: string;
27
+ label: string;
28
+ icon: string;
29
+ component: React.ComponentType<ToolbarToolProps & P>;
30
+ cursor?: string;
31
+ stayActive?: boolean;
32
+ }
33
+ interface MapLayerRegistration<P = unknown> {
34
+ id: string;
35
+ component: React.ComponentType<P>;
36
+ }
37
+ interface DataPageColumn<Row> {
38
+ key: string;
39
+ labelKey: string;
40
+ render?: (row: Row) => React.ReactNode;
41
+ }
42
+ interface DataPageRows<Row> {
43
+ rows: Row[];
44
+ isLoading?: boolean;
45
+ /** From the hook, not the registration, so it can close over `usePluginDialogs`. */
46
+ onRowClick?: (row: Row) => void;
47
+ }
48
+ interface DataPageRegistration<Row = Record<string, unknown>> {
49
+ id: string;
50
+ titleKey: string;
51
+ icon: string;
52
+ useRows: () => DataPageRows<Row>;
53
+ columns: DataPageColumn<Row>[];
54
+ searchKeys?: string[];
55
+ emptyKey?: string;
56
+ }
57
+ interface ViewerTabRegistration {
58
+ id: string;
59
+ labelKey: string;
60
+ icon: string;
61
+ component: React.ComponentType;
62
+ /** Viewer names as core spells them: 'map', 'bim', 'pointcloud'. Omit for all of them. */
63
+ viewers?: string[];
64
+ }
65
+ interface DialogRegistration<P = Record<string, unknown>> {
66
+ id: string;
67
+ titleKey: string;
68
+ size?: 'sm' | 'md' | 'lg' | 'xl';
69
+ component: React.ComponentType<P & {
70
+ close: () => void;
71
+ }>;
72
+ }
73
+ interface CapabilityRegistry<MapProps = unknown, BimProps = unknown, PointCloudProps = unknown, Legend = unknown> {
74
+ 'data.pages': DataPageRegistration;
75
+ 'viewer.tabs': ViewerTabRegistration;
76
+ 'ui.dialogs': DialogRegistration;
77
+ 'map.tools': ToolbarRegistration<MapProps>;
78
+ 'bim.tools': ToolbarRegistration<BimProps>;
79
+ 'pointcloud.tools': ToolbarRegistration<PointCloudProps>;
80
+ 'viewer.legends': Legend;
81
+ 'map.layers': MapLayerRegistration<MapProps>;
82
+ }
83
+ interface PluginContext<MapProps = unknown, BimProps = unknown, PointCloudProps = unknown, Legend = unknown> {
84
+ pluginId: string;
85
+ register<K extends keyof CapabilityRegistry>(key: K, item: CapabilityRegistry<MapProps, BimProps, PointCloudProps, Legend>[K]): void;
86
+ config: Record<string, unknown>;
87
+ }
88
+
89
+ export { type CapabilityRegistry as C, type DataPageColumn as D, type MapLayerRegistration as M, type PluginContext as P, type ToolbarRegistration as T, VALID_CAPABILITIES as V, type DataPageRegistration as a, type DataPageRows as b, type DialogRegistration as c, PLUGIN_HOST_API as d, type PluginCapability as e, type PluginManifest as f, type ToolbarToolProps as g, type ViewerTabRegistration as h };
@@ -1,12 +1,14 @@
1
1
  // src/types/base.ts
2
2
  var PLUGIN_HOST_API = 1;
3
3
  var VALID_CAPABILITIES = [
4
- "sidebar.items",
5
- "viewer.panels",
4
+ "data.pages",
5
+ "viewer.tabs",
6
+ "ui.dialogs",
6
7
  "map.tools",
7
8
  "bim.tools",
8
9
  "pointcloud.tools",
9
- "map.legends"
10
+ "viewer.legends",
11
+ "map.layers"
10
12
  ];
11
13
 
12
14
  export {
package/dist/index.js CHANGED
@@ -7,6 +7,9 @@ var PLUGIN_EXTERNALS = [
7
7
  "@collabdt/core/plugins-sdk/config",
8
8
  "@collabdt/core/plugins-sdk/messages",
9
9
  "@collabdt/core/plugins-sdk/store",
10
+ "@collabdt/core/plugins-sdk/data",
11
+ "@collabdt/core/plugins-sdk/state",
12
+ "@collabdt/core/plugins-sdk/ui",
10
13
  "@collabdt/core/plugins-sdk/components"
11
14
  ];
12
15
  var KNOWN_FORBIDDEN = [
@@ -1,6 +1,6 @@
1
1
  /// <reference path="./sdkModules.d.ts" />
2
- import { C as CapabilityRegistry, P as PluginContext } from '../base-BljPi_dT.js';
3
- export { a as PLUGIN_HOST_API, b as PluginCapability, c as PluginManifest, T as ToolbarRegistration, d as ToolbarToolProps, V as VALID_CAPABILITIES } from '../base-BljPi_dT.js';
2
+ import { C as CapabilityRegistry, P as PluginContext } from '../base-B4YIm9v6.js';
3
+ export { D as DataPageColumn, a as DataPageRegistration, b as DataPageRows, c as DialogRegistration, M as MapLayerRegistration, d as PLUGIN_HOST_API, e as PluginCapability, f as PluginManifest, T as ToolbarRegistration, g as ToolbarToolProps, V as VALID_CAPABILITIES, h as ViewerTabRegistration } from '../base-B4YIm9v6.js';
4
4
  import * as OBC from '@thatopen/components';
5
5
  import 'react';
6
6
 
package/dist/types/bim.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  PLUGIN_HOST_API,
3
3
  VALID_CAPABILITIES
4
- } from "../chunk-CVHASC2D.js";
4
+ } from "../chunk-C7KO3OP7.js";
5
5
  export {
6
6
  PLUGIN_HOST_API,
7
7
  VALID_CAPABILITIES
@@ -0,0 +1,225 @@
1
+ /** Mirrors core's `ViewerNames`, as the union the records carry. */
2
+ type PluginViewerName = 'auth' | 'map' | 'bim' | 'pointcloud' | 'buildings' | 'sites' | 'files' | 'land' | 'infrastructure' | 'extensions' | 'settings' | 'users';
3
+ interface PluginBuilding {
4
+ id: number;
5
+ buildingName?: string;
6
+ buildingAddress?: string;
7
+ buildingMunicipality?: string;
8
+ buildingCountrySubdivision?: string;
9
+ buildingPostalCode?: string;
10
+ buildingLongitude?: number;
11
+ buildingLatitude?: number;
12
+ buildingElevation?: number;
13
+ rotation?: number;
14
+ buildingType: string[];
15
+ buildingStoreyNum?: number;
16
+ buildingTotalSqft?: number;
17
+ buildingNotes?: string;
18
+ buildingWebsite?: string;
19
+ buildingZoning?: string;
20
+ featureId?: string | null;
21
+ buildingParentSiteId?: number | null;
22
+ }
23
+ interface PluginSite {
24
+ id: number;
25
+ siteName?: string;
26
+ siteAddress?: string;
27
+ siteMunicipality?: string;
28
+ siteCity?: string;
29
+ siteCountrySubdivision?: string;
30
+ sitePostalCode?: string;
31
+ siteLongitude?: number;
32
+ siteLatitude?: number;
33
+ siteNotes?: string;
34
+ siteWebsite?: string;
35
+ siteOrganizationId: number;
36
+ }
37
+ interface PluginInfrastructure {
38
+ id: number;
39
+ featureId?: string;
40
+ infrastructureName?: string;
41
+ infrastructureType?: string;
42
+ infrastructureState?: string;
43
+ infrastructureStatus?: string;
44
+ infrastructureAddress?: string;
45
+ infrastructureMunicipality?: string;
46
+ infrastructureCountrySubdivision?: string;
47
+ infrastructureDescription?: string;
48
+ }
49
+ interface PluginOrganization {
50
+ id: number;
51
+ name: string;
52
+ title?: string | null;
53
+ description?: string | null;
54
+ countrySubdivision?: string | null;
55
+ municipality?: string | null;
56
+ lat?: number | null;
57
+ long?: number | null;
58
+ zoom?: number | null;
59
+ country?: string | null;
60
+ }
61
+ interface PluginFile {
62
+ id: number;
63
+ name: string;
64
+ type: string;
65
+ url?: string | null;
66
+ assetId: string;
67
+ mimeType?: string | null;
68
+ extension?: string | null;
69
+ sizeBytes?: number | null;
70
+ uploadedAt: string;
71
+ description?: string | null;
72
+ tag?: string | null;
73
+ x?: number | null;
74
+ y?: number | null;
75
+ z?: number | null;
76
+ lat?: number | null;
77
+ lng?: number | null;
78
+ elevation?: number | null;
79
+ isVisible?: boolean;
80
+ fileOrganizationId: number;
81
+ }
82
+ interface PluginSensor {
83
+ id: number;
84
+ name: string;
85
+ data: string;
86
+ dataFormat: 'Csv' | 'Json';
87
+ updateFrequency: number;
88
+ longitude?: number | null;
89
+ latitude?: number | null;
90
+ elevation?: number | null;
91
+ visible: boolean;
92
+ viewer: PluginViewerName;
93
+ x?: number | null;
94
+ y?: number | null;
95
+ z?: number | null;
96
+ createdAt: Date;
97
+ updatedAt: Date;
98
+ url?: string | null;
99
+ tags: string[];
100
+ maxThreshold?: number | null;
101
+ minThreshold?: number | null;
102
+ typeId?: number | null;
103
+ organizationId: number;
104
+ buildingId?: number | null;
105
+ authorId: number;
106
+ }
107
+ interface PluginSensorType {
108
+ id: number;
109
+ name: string;
110
+ icon: string;
111
+ minValue: number;
112
+ maxValue: number;
113
+ minColour: string;
114
+ midColour: string;
115
+ maxColour: string;
116
+ }
117
+ interface PluginComment {
118
+ id: number;
119
+ authorId: number;
120
+ organizationId: number;
121
+ text: string;
122
+ longitude?: number | null;
123
+ latitude?: number | null;
124
+ elevation?: number | null;
125
+ visible: boolean;
126
+ viewer: PluginViewerName;
127
+ x?: number | null;
128
+ y?: number | null;
129
+ z?: number | null;
130
+ createdAt: Date;
131
+ updatedAt: Date;
132
+ replyToId?: number | null;
133
+ buildingId?: number | null;
134
+ image?: string | null;
135
+ }
136
+ /** Every read hook resolves to one of these, keyed by the name it uses for the payload. */
137
+ interface PluginQuery {
138
+ isLoading: boolean;
139
+ /** Whatever the fetch threw. Truthy means the read failed. */
140
+ isError: unknown;
141
+ }
142
+ interface PluginBuildingsQuery extends PluginQuery {
143
+ buildings: PluginBuilding[];
144
+ }
145
+ interface PluginBuildingQuery extends PluginQuery {
146
+ building: PluginBuilding | null;
147
+ }
148
+ interface PluginBuildingOsmIdsQuery extends PluginQuery {
149
+ osmIds: number[];
150
+ }
151
+ interface PluginSitesQuery extends PluginQuery {
152
+ sites: PluginSite[];
153
+ }
154
+ interface PluginSiteQuery extends PluginQuery {
155
+ site: PluginSite | null;
156
+ }
157
+ interface PluginInfrastructuresQuery extends PluginQuery {
158
+ infrastructures: PluginInfrastructure[];
159
+ }
160
+ interface PluginInfrastructureQuery extends PluginQuery {
161
+ infrastructure: PluginInfrastructure | null;
162
+ }
163
+ interface PluginOrganizationQuery extends PluginQuery {
164
+ organization: PluginOrganization | null;
165
+ }
166
+ interface PluginFilesQuery extends PluginQuery {
167
+ files: PluginFile[];
168
+ }
169
+ interface PluginFileQuery extends PluginQuery {
170
+ file: PluginFile | null;
171
+ }
172
+ interface PluginSensorsQuery extends PluginQuery {
173
+ sensors: PluginSensor[];
174
+ }
175
+ interface PluginSensorQuery extends PluginQuery {
176
+ sensor: PluginSensor | null;
177
+ }
178
+ interface PluginSensorTypesQuery extends PluginQuery {
179
+ sensorTypes: PluginSensorType[];
180
+ }
181
+ interface PluginSensorTypeQuery extends PluginQuery {
182
+ sensorType: PluginSensorType | null;
183
+ }
184
+ interface PluginCommentsQuery extends PluginQuery {
185
+ comments: PluginComment[];
186
+ }
187
+ interface PluginCommentQuery extends PluginQuery {
188
+ comment: PluginComment | null;
189
+ }
190
+ /** Rejects on failure, so wrap the call rather than reading an error flag after it. */
191
+ type PluginTrigger<Arg, Result> = (arg: Arg) => Promise<Result | undefined>;
192
+ interface PluginCreateSensor {
193
+ createSensor: PluginTrigger<{
194
+ sensorData: Partial<PluginSensor>;
195
+ }, PluginSensor>;
196
+ isMutating: boolean;
197
+ }
198
+ interface PluginCreateComment {
199
+ createComment: PluginTrigger<{
200
+ commentData: Partial<PluginComment>;
201
+ }, PluginComment>;
202
+ isMutating: boolean;
203
+ }
204
+ interface PluginDeleteComments {
205
+ deleteComments: PluginTrigger<{
206
+ ids: number[];
207
+ }, unknown>;
208
+ isDeleting: boolean;
209
+ }
210
+ interface PluginDownloadFile {
211
+ downloadFile: (file: PluginFile, fileName?: string) => Promise<void>;
212
+ isDownloading: boolean;
213
+ downloadError: Error | null;
214
+ }
215
+ /** The signed-in user's CASL ability, narrowed to the two checks a plugin makes. */
216
+ interface PluginAbility {
217
+ can(action: string, subject: string): boolean;
218
+ cannot(action: string, subject: string): boolean;
219
+ }
220
+ interface PluginPermissions {
221
+ ability: PluginAbility;
222
+ isLoading: boolean;
223
+ }
224
+
225
+ export type { PluginAbility, PluginBuilding, PluginBuildingOsmIdsQuery, PluginBuildingQuery, PluginBuildingsQuery, PluginComment, PluginCommentQuery, PluginCommentsQuery, PluginCreateComment, PluginCreateSensor, PluginDeleteComments, PluginDownloadFile, PluginFile, PluginFileQuery, PluginFilesQuery, PluginInfrastructure, PluginInfrastructureQuery, PluginInfrastructuresQuery, PluginOrganization, PluginOrganizationQuery, PluginPermissions, PluginQuery, PluginSensor, PluginSensorQuery, PluginSensorType, PluginSensorTypeQuery, PluginSensorTypesQuery, PluginSensorsQuery, PluginSite, PluginSiteQuery, PluginSitesQuery, PluginTrigger, PluginViewerName };
File without changes
@@ -1,6 +1,6 @@
1
1
  /// <reference path="./sdkModules.d.ts" />
2
- import { C as CapabilityRegistry, P as PluginContext } from '../base-BljPi_dT.js';
3
- export { a as PLUGIN_HOST_API, b as PluginCapability, c as PluginManifest, T as ToolbarRegistration, d as ToolbarToolProps, V as VALID_CAPABILITIES } from '../base-BljPi_dT.js';
2
+ import { C as CapabilityRegistry, P as PluginContext } from '../base-B4YIm9v6.js';
3
+ export { D as DataPageColumn, a as DataPageRegistration, b as DataPageRows, c as DialogRegistration, M as MapLayerRegistration, d as PLUGIN_HOST_API, e as PluginCapability, f as PluginManifest, T as ToolbarRegistration, g as ToolbarToolProps, V as VALID_CAPABILITIES, h as ViewerTabRegistration } from '../base-B4YIm9v6.js';
4
4
  import 'react';
5
5
 
6
6
  interface LegendRow {
@@ -11,6 +11,8 @@ interface LegendRow {
11
11
  interface LegendRegistration {
12
12
  id: string;
13
13
  title: string;
14
+ /** Viewer names as core spells them: 'map', 'bim', 'pointcloud'. Omit for all of them. */
15
+ viewers?: string[];
14
16
  useLegend: () => {
15
17
  /** False omits the section entirely, which is what a legend with nothing to say should do. */
16
18
  active: boolean;
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  PLUGIN_HOST_API,
3
3
  VALID_CAPABILITIES
4
- } from "../chunk-CVHASC2D.js";
4
+ } from "../chunk-C7KO3OP7.js";
5
5
  export {
6
6
  PLUGIN_HOST_API,
7
7
  VALID_CAPABILITIES
@@ -1,6 +1,6 @@
1
1
  /// <reference path="./sdkModules.d.ts" />
2
- import { C as CapabilityRegistry, P as PluginContext } from '../base-BljPi_dT.js';
3
- export { a as PLUGIN_HOST_API, b as PluginCapability, c as PluginManifest, T as ToolbarRegistration, d as ToolbarToolProps, V as VALID_CAPABILITIES } from '../base-BljPi_dT.js';
2
+ import { C as CapabilityRegistry, P as PluginContext } from '../base-B4YIm9v6.js';
3
+ export { D as DataPageColumn, a as DataPageRegistration, b as DataPageRows, c as DialogRegistration, M as MapLayerRegistration, d as PLUGIN_HOST_API, e as PluginCapability, f as PluginManifest, T as ToolbarRegistration, g as ToolbarToolProps, V as VALID_CAPABILITIES, h as ViewerTabRegistration } from '../base-B4YIm9v6.js';
4
4
  import { Map } from 'maplibre-gl';
5
5
  import 'react';
6
6
 
package/dist/types/map.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  PLUGIN_HOST_API,
3
3
  VALID_CAPABILITIES
4
- } from "../chunk-CVHASC2D.js";
4
+ } from "../chunk-C7KO3OP7.js";
5
5
  export {
6
6
  PLUGIN_HOST_API,
7
7
  VALID_CAPABILITIES
@@ -1,6 +1,6 @@
1
1
  /// <reference path="./sdkModules.d.ts" />
2
- import { C as CapabilityRegistry, P as PluginContext } from '../base-BljPi_dT.js';
3
- export { a as PLUGIN_HOST_API, b as PluginCapability, c as PluginManifest, T as ToolbarRegistration, d as ToolbarToolProps, V as VALID_CAPABILITIES } from '../base-BljPi_dT.js';
2
+ import { C as CapabilityRegistry, P as PluginContext } from '../base-B4YIm9v6.js';
3
+ export { D as DataPageColumn, a as DataPageRegistration, b as DataPageRows, c as DialogRegistration, M as MapLayerRegistration, d as PLUGIN_HOST_API, e as PluginCapability, f as PluginManifest, T as ToolbarRegistration, g as ToolbarToolProps, V as VALID_CAPABILITIES, h as ViewerTabRegistration } from '../base-B4YIm9v6.js';
4
4
  import 'react';
5
5
 
6
6
  interface PointCloudToolProps {
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  PLUGIN_HOST_API,
3
3
  VALID_CAPABILITIES
4
- } from "../chunk-CVHASC2D.js";
4
+ } from "../chunk-C7KO3OP7.js";
5
5
  export {
6
6
  PLUGIN_HOST_API,
7
7
  VALID_CAPABILITIES
@@ -1,128 +1,239 @@
1
- // SPDX-License-Identifier: AGPL-3.0-or-later
2
- // Copyright (C) 2025 Collab Digital Twins
3
-
4
- // Types for the SDK modules a plugin imports at runtime but never installs: the specifier is
5
- // marked external, and the browser resolves it through the host's import map. Shipping
6
- // declarations for implementations this package does not contain is the point.
7
- //
8
- // Module and export names come from PLUGIN_RUNTIME_SHIMS in core; signatures are copied from
9
- // core's sdk/. React's shims are absent because they have real published types.
10
- //
11
- // No top-level import or export, deliberately: that keeps this a global script, the only place
12
- // TypeScript accepts an ambient declaration for a specifier it cannot resolve.
13
-
14
- declare module '@collabdt/core/plugins-sdk' {
15
- // Only the values the shim re-exports. The SDK's types live in the surface entries, so each
16
- // shape has one definition and it is the one a plugin already imports.
17
- export const VALID_CAPABILITIES: readonly [
18
- 'sidebar.items',
19
- 'viewer.panels',
20
- 'map.tools',
21
- 'bim.tools',
22
- 'pointcloud.tools',
23
- 'map.legends',
24
- ]
25
-
26
- export const PLUGIN_HOST_API: 1
27
-
28
- export function validateManifest(manifest: unknown): { valid: boolean; errors: string[] }
29
-
30
- // Generic because an ambient block cannot import `PluginEntry` from the kit's own entries,
31
- // and restating it would give a plugin two definitions. The call site behaves identically.
32
- export function resolvePluginEntry<E>(entry: E | (() => Promise<E>)): Promise<E>
33
- }
34
-
35
- declare module '@collabdt/core/plugins-sdk/config' {
36
- /** The plugin's config for this organization. Generic so a plugin can type its own shape. */
37
- export function usePluginConfig<
38
- T extends Record<string, unknown> = Record<string, unknown>,
39
- >(): T
40
- /** The calling plugin's id, from the scope its capability host established. */
41
- export function usePluginId(): string
42
- }
43
-
44
- declare module '@collabdt/core/plugins-sdk/messages' {
45
- export type PluginTranslator = (key: string, fallback?: string) => string
46
-
47
- /** A `t()` scoped to the calling plugin's own namespace. */
48
- export function usePluginTranslations(): PluginTranslator
49
-
50
- /** One piece of plugin text. All three parameters are required, matching core. */
51
- export function usePluginMessage(pluginId: string, key: string, fallback: string): string
52
-
53
- // Narrowed to a plain callable: typing next-intl's translator faithfully would drag
54
- // next-intl into a plugin's dependencies.
55
- export function useCoreTranslations(
56
- namespace: string,
57
- ): (key: string, values?: Record<string, unknown>) => string
58
- }
59
-
60
- declare module '@collabdt/core/plugins-sdk/store' {
61
- /** One stored document, as the owning plugin sees it. */
62
- export interface PluginDocument<T> {
63
- /** The plugin's own stable identifier for this document. */
64
- key: string
65
- data: T
66
- updatedAt: string | Date
67
- }
68
-
69
- export interface PluginStore<T> {
70
- items: PluginDocument<T>[]
71
- isLoading: boolean
72
- isError: unknown
73
- /** One document by key, or undefined. */
74
- get: (key: string) => PluginDocument<T> | undefined
75
- /** Create or replace a document. Keyed writes are upserts, not appends. */
76
- put: (key: string, data: T) => Promise<void>
77
- remove: (key: string) => Promise<void>
78
- }
79
-
80
- /** Storage scoped by organization, plugin and collection. `T` is your declaration, not a guarantee. */
81
- export function usePluginStore<T = unknown>(collection: string): PluginStore<T>
82
- }
83
-
84
- declare module '@collabdt/core/plugins-sdk/components' {
85
- // Shapes come from `./components`, a real module here, which is what lets core's
86
- // pluginKitComponents.test.ts compare these declarations against the real components.
87
- //
88
- // Inline `import('./components')` rather than a top-level import: an import declaration
89
- // inside an ambient module cannot use a relative specifier (TS2439), and skipLibCheck hides
90
- // that from everyone until a consumer turns it off.
91
-
92
- export type ButtonProps = import('./components').ButtonProps
93
- export const Button: import('./components').ButtonComponent
94
-
95
- export const Input: import('./components').InputComponent
96
-
97
- export type BadgeProps = import('./components').BadgeProps
98
- export const Badge: import('./components').BadgeComponent
99
-
100
- export type SeparatorProps = import('./components').SeparatorProps
101
- export const Separator: import('./components').SeparatorComponent
102
-
103
- export const Card: import('./components').CardComponent
104
- export const CardHeader: import('./components').CardComponent
105
- export const CardTitle: import('./components').CardComponent
106
- export const CardDescription: import('./components').CardComponent
107
- export const CardContent: import('./components').CardComponent
108
- export const CardFooter: import('./components').CardComponent
109
-
110
- export type DialogProps = import('./components').DialogProps
111
- export const Dialog: import('./components').DialogComponent
112
-
113
- export type DialogTriggerProps = import('./components').DialogTriggerProps
114
- export const DialogTrigger: import('./components').DialogTriggerComponent
115
- export const DialogClose: import('./components').DialogTriggerComponent
116
-
117
- export type DialogContentProps = import('./components').DialogContentProps
118
- export const DialogContent: import('./components').DialogContentComponent
119
-
120
- export const DialogHeader: import('./components').DialogSectionComponent
121
- export const DialogFooter: import('./components').DialogSectionComponent
122
-
123
- export type DialogTitleProps = import('./components').DialogTitleProps
124
- export const DialogTitle: import('./components').DialogTitleComponent
125
-
126
- export type DialogDescriptionProps = import('./components').DialogDescriptionProps
127
- export const DialogDescription: import('./components').DialogDescriptionComponent
128
- }
1
+ // SPDX-License-Identifier: AGPL-3.0-or-later
2
+ // Copyright (C) 2025 Collab Digital Twins
3
+
4
+ // Types for the SDK modules a plugin imports at runtime but never installs: the specifier is
5
+ // marked external, and the browser resolves it through the host's import map. Shipping
6
+ // declarations for implementations this package does not contain is the point.
7
+ //
8
+ // Module and export names come from PLUGIN_RUNTIME_SHIMS in core; signatures are copied from
9
+ // core's sdk/. React's shims are absent because they have real published types.
10
+ //
11
+ // No top-level import or export, deliberately: that keeps this a global script, the only place
12
+ // TypeScript accepts an ambient declaration for a specifier it cannot resolve.
13
+
14
+ declare module '@collabdt/core/plugins-sdk' {
15
+ // Only the values the shim re-exports. The SDK's types live in the surface entries, so each
16
+ // shape has one definition and it is the one a plugin already imports.
17
+ export const VALID_CAPABILITIES: readonly [
18
+ 'data.pages',
19
+ 'viewer.tabs',
20
+ 'ui.dialogs',
21
+ 'map.tools',
22
+ 'bim.tools',
23
+ 'pointcloud.tools',
24
+ 'viewer.legends',
25
+ 'map.layers',
26
+ ]
27
+
28
+ export const PLUGIN_HOST_API: 1
29
+
30
+ // A value, not just a type: a `viewer.tabs` contribution names its viewers.
31
+ export const ViewerNames: {
32
+ auth: 'auth'
33
+ map: 'map'
34
+ bim: 'bim'
35
+ pointcloud: 'pointcloud'
36
+ buildings: 'buildings'
37
+ sites: 'sites'
38
+ files: 'files'
39
+ land: 'land'
40
+ infrastructure: 'infrastructure'
41
+ extensions: 'extensions'
42
+ settings: 'settings'
43
+ users: 'users'
44
+ }
45
+
46
+ /** Map-friendly, colourblind-accessible colours. Use these rather than inventing a set. */
47
+ export const MAP_COLOUR_PALETTE: readonly string[]
48
+
49
+ /** A stable colour from `MAP_COLOUR_PALETTE`, chosen by hashing the string. */
50
+ export function stringToColour(str: string, variant?: 'min' | 'max'): string
51
+
52
+ export function validateManifest(manifest: unknown): { valid: boolean; errors: string[] }
53
+
54
+ // Generic because an ambient block cannot import `PluginEntry` from the kit's own entries,
55
+ // and restating it would give a plugin two definitions. The call site behaves identically.
56
+ export function resolvePluginEntry<E>(entry: E | (() => Promise<E>)): Promise<E>
57
+ }
58
+
59
+ declare module '@collabdt/core/plugins-sdk/config' {
60
+ /** The plugin's config for this organization. Generic so a plugin can type its own shape. */
61
+ export function usePluginConfig<
62
+ T extends Record<string, unknown> = Record<string, unknown>,
63
+ >(): T
64
+ /** The calling plugin's id, from the scope its capability host established. */
65
+ export function usePluginId(): string
66
+ }
67
+
68
+ declare module '@collabdt/core/plugins-sdk/messages' {
69
+ export type PluginTranslator = (key: string, fallback?: string) => string
70
+
71
+ /** A `t()` scoped to the calling plugin's own namespace. */
72
+ export function usePluginTranslations(): PluginTranslator
73
+
74
+ /** One piece of plugin text. All three parameters are required, matching core. */
75
+ export function usePluginMessage(pluginId: string, key: string, fallback: string): string
76
+
77
+ // Narrowed to a plain callable: typing next-intl's translator faithfully would drag
78
+ // next-intl into a plugin's dependencies.
79
+ export function useCoreTranslations(
80
+ namespace: string,
81
+ ): (key: string, values?: Record<string, unknown>) => string
82
+ }
83
+
84
+ declare module '@collabdt/core/plugins-sdk/store' {
85
+ /** One stored document, as the owning plugin sees it. */
86
+ export interface PluginDocument<T> {
87
+ /** The plugin's own stable identifier for this document. */
88
+ key: string
89
+ data: T
90
+ updatedAt: string | Date
91
+ }
92
+
93
+ export interface PluginStore<T> {
94
+ items: PluginDocument<T>[]
95
+ isLoading: boolean
96
+ isError: unknown
97
+ /** One document by key, or undefined. */
98
+ get: (key: string) => PluginDocument<T> | undefined
99
+ /** Create or replace a document. Keyed writes are upserts, not appends. */
100
+ put: (key: string, data: T) => Promise<void>
101
+ remove: (key: string) => Promise<void>
102
+ }
103
+
104
+ /** Storage scoped by organization, plugin and collection. `T` is your declaration, not a guarantee. */
105
+ export function usePluginStore<T = unknown>(collection: string): PluginStore<T>
106
+ }
107
+
108
+ declare module '@collabdt/core/plugins-sdk/data' {
109
+ // Shapes come from `./data`, inline rather than imported at the top: an ambient module cannot carry a relative import (TS2439).
110
+
111
+ export type PluginBuilding = import('./data').PluginBuilding
112
+ export type PluginSite = import('./data').PluginSite
113
+ export type PluginInfrastructure = import('./data').PluginInfrastructure
114
+ export type PluginOrganization = import('./data').PluginOrganization
115
+ export type PluginFile = import('./data').PluginFile
116
+ export type PluginSensor = import('./data').PluginSensor
117
+ export type PluginSensorType = import('./data').PluginSensorType
118
+ export type PluginComment = import('./data').PluginComment
119
+ export type PluginAbility = import('./data').PluginAbility
120
+ export type PluginPermissions = import('./data').PluginPermissions
121
+
122
+ export function useBuildings(): import('./data').PluginBuildingsQuery
123
+ export function useBuilding(id: number | null): import('./data').PluginBuildingQuery
124
+ export function useBuildingsByOsm(osmId: number | null): import('./data').PluginBuildingsQuery
125
+ export function useBuildingOsmIds(): import('./data').PluginBuildingOsmIdsQuery
126
+
127
+ export function useSites(): import('./data').PluginSitesQuery
128
+ export function useSite(siteId: string): import('./data').PluginSiteQuery
129
+
130
+ export function useInfrastructures(): import('./data').PluginInfrastructuresQuery
131
+ export function useInfrastructure(
132
+ infrastructureId: number,
133
+ ): import('./data').PluginInfrastructureQuery
134
+
135
+ export function useOrganization(id: string | null): import('./data').PluginOrganizationQuery
136
+ export function useOrganizationByName(
137
+ name: string | null,
138
+ ): import('./data').PluginOrganizationQuery
139
+
140
+ export function useFiles(): import('./data').PluginFilesQuery
141
+ export function useFile(id: number | null): import('./data').PluginFileQuery
142
+ export function useFilesByBuildingId(
143
+ buildingId: number,
144
+ tag?: string,
145
+ ): import('./data').PluginFilesQuery
146
+ export function useFilesBySiteId(siteId: number, tag?: string): import('./data').PluginFilesQuery
147
+ export function useDownloadFile(): import('./data').PluginDownloadFile
148
+
149
+ export function useSensors(): import('./data').PluginSensorsQuery
150
+ export function useSensor(id: number | null): import('./data').PluginSensorQuery
151
+ export function useSensorsByBuilding(buildingId: number | null): import('./data').PluginSensorsQuery
152
+ export function useSensorsByAuthor(authorId: number | null): import('./data').PluginSensorsQuery
153
+ export function useCreateSensor(): import('./data').PluginCreateSensor
154
+
155
+ export function useSensorTypes(): import('./data').PluginSensorTypesQuery
156
+ export function useSensorType(id: number): import('./data').PluginSensorTypeQuery
157
+
158
+ export function useComments(): import('./data').PluginCommentsQuery
159
+ export function useComment(id: number | null): import('./data').PluginCommentQuery
160
+ export function useCommentsByBuilding(buildingId: number | null): import('./data').PluginCommentsQuery
161
+ export function useCommentsByAuthor(authorId: number | null): import('./data').PluginCommentsQuery
162
+ export function useCreateComment(): import('./data').PluginCreateComment
163
+ export function useDeleteComments(): import('./data').PluginDeleteComments
164
+
165
+ /** Re-exported by core's data module, so a plugin finds both here as well as at their own specifiers. */
166
+ export function usePluginConfig<
167
+ T extends Record<string, unknown> = Record<string, unknown>,
168
+ >(): T
169
+ export function usePluginPermissions(): import('./data').PluginPermissions
170
+ }
171
+
172
+ declare module '@collabdt/core/plugins-sdk/state' {
173
+ /**
174
+ * Shared state for one plugin's surfaces: in memory, scoped to the plugin, gone when it is
175
+ * disabled. `usePluginStore` is the persisted counterpart.
176
+ */
177
+ export function usePluginState<T>(
178
+ key: string,
179
+ initial: T,
180
+ ): [T, (next: T | ((previous: T) => T)) => void]
181
+ }
182
+
183
+ declare module '@collabdt/core/plugins-sdk/ui' {
184
+ export interface PluginDialogs {
185
+ /** Opens one of this plugin's registered dialogs. `props` reaches the component as props. */
186
+ open: (dialogId: string, props?: Record<string, unknown>) => void
187
+ /** Closes the topmost instance of `dialogId`, or of any of this plugin's dialogs. */
188
+ close: (dialogId?: string) => void
189
+ }
190
+
191
+ /** Opens and closes this plugin's `ui.dialogs` contributions from any of its surfaces. */
192
+ export function usePluginDialogs(): PluginDialogs
193
+ }
194
+
195
+ declare module '@collabdt/core/plugins-sdk/components' {
196
+ // Shapes come from `./components`, a real module here, which is what lets core's
197
+ // pluginKitComponents.test.ts compare these declarations against the real components.
198
+ //
199
+ // Inline `import('./components')` rather than a top-level import: an import declaration
200
+ // inside an ambient module cannot use a relative specifier (TS2439), and skipLibCheck hides
201
+ // that from everyone until a consumer turns it off.
202
+
203
+ export type ButtonProps = import('./components').ButtonProps
204
+ export const Button: import('./components').ButtonComponent
205
+
206
+ export const Input: import('./components').InputComponent
207
+
208
+ export type BadgeProps = import('./components').BadgeProps
209
+ export const Badge: import('./components').BadgeComponent
210
+
211
+ export type SeparatorProps = import('./components').SeparatorProps
212
+ export const Separator: import('./components').SeparatorComponent
213
+
214
+ export const Card: import('./components').CardComponent
215
+ export const CardHeader: import('./components').CardComponent
216
+ export const CardTitle: import('./components').CardComponent
217
+ export const CardDescription: import('./components').CardComponent
218
+ export const CardContent: import('./components').CardComponent
219
+ export const CardFooter: import('./components').CardComponent
220
+
221
+ export type DialogProps = import('./components').DialogProps
222
+ export const Dialog: import('./components').DialogComponent
223
+
224
+ export type DialogTriggerProps = import('./components').DialogTriggerProps
225
+ export const DialogTrigger: import('./components').DialogTriggerComponent
226
+ export const DialogClose: import('./components').DialogTriggerComponent
227
+
228
+ export type DialogContentProps = import('./components').DialogContentProps
229
+ export const DialogContent: import('./components').DialogContentComponent
230
+
231
+ export const DialogHeader: import('./components').DialogSectionComponent
232
+ export const DialogFooter: import('./components').DialogSectionComponent
233
+
234
+ export type DialogTitleProps = import('./components').DialogTitleProps
235
+ export const DialogTitle: import('./components').DialogTitleComponent
236
+
237
+ export type DialogDescriptionProps = import('./components').DialogDescriptionProps
238
+ export const DialogDescription: import('./components').DialogDescriptionComponent
239
+ }
@@ -0,0 +1,10 @@
1
+ import { C as CapabilityRegistry, P as PluginContext } from '../base-B4YIm9v6.js';
2
+ export { D as DataPageColumn, a as DataPageRegistration, b as DataPageRows, c as DialogRegistration, M as MapLayerRegistration, d as PLUGIN_HOST_API, e as PluginCapability, f as PluginManifest, T as ToolbarRegistration, g as ToolbarToolProps, V as VALID_CAPABILITIES, h as ViewerTabRegistration } from '../base-B4YIm9v6.js';
3
+ import 'react';
4
+
5
+ /** `CapabilityRegistry` for the surfaces that bind no viewer props. */
6
+ type UiCapabilityRegistry = CapabilityRegistry;
7
+ /** The `activate()` context for a plugin contributing pages, tabs or dialogs. */
8
+ type UiPluginContext = PluginContext;
9
+
10
+ export { CapabilityRegistry, PluginContext, type UiCapabilityRegistry, type UiPluginContext };
@@ -0,0 +1,8 @@
1
+ import {
2
+ PLUGIN_HOST_API,
3
+ VALID_CAPABILITIES
4
+ } from "../chunk-C7KO3OP7.js";
5
+ export {
6
+ PLUGIN_HOST_API,
7
+ VALID_CAPABILITIES
8
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@collabdt/plugin-kit",
3
- "version": "0.1.0",
3
+ "version": "0.3.0",
4
4
  "description": "Build preset and types for authoring CDT plugins.",
5
5
  "license": "AGPL-3.0-or-later",
6
6
  "type": "module",
@@ -18,6 +18,10 @@
18
18
  "types": "./dist/types/components.d.ts",
19
19
  "default": "./dist/types/components.js"
20
20
  },
21
+ "./types/data": {
22
+ "types": "./dist/types/data.d.ts",
23
+ "default": "./dist/types/data.js"
24
+ },
21
25
  "./types/map": {
22
26
  "types": "./dist/types/map.d.ts",
23
27
  "default": "./dist/types/map.js"
@@ -33,10 +37,15 @@
33
37
  "./types/legend": {
34
38
  "types": "./dist/types/legend.d.ts",
35
39
  "default": "./dist/types/legend.js"
40
+ },
41
+ "./types/ui": {
42
+ "types": "./dist/types/ui.d.ts",
43
+ "default": "./dist/types/ui.js"
36
44
  }
37
45
  },
38
46
  "scripts": {
39
47
  "build": "tsup && node scripts/shipAmbientTypes.mjs",
48
+ "prepublishOnly": "npm run build",
40
49
  "test": "vitest run"
41
50
  },
42
51
  "peerDependencies": {
@@ -1,45 +0,0 @@
1
- import * as React from 'react';
2
-
3
- /** Declare as `hostApi` in your manifest. The host refuses a plugin that declares another value. */
4
- declare const PLUGIN_HOST_API = 1;
5
- declare const VALID_CAPABILITIES: readonly ["sidebar.items", "viewer.panels", "map.tools", "bim.tools", "pointcloud.tools", "map.legends"];
6
- type PluginCapability = typeof VALID_CAPABILITIES[number];
7
- interface PluginManifest {
8
- slug: string;
9
- name: string;
10
- version: string;
11
- /** Omitting this is allowed but warned about, which defers a version mismatch to render time. */
12
- hostApi?: number;
13
- description?: string;
14
- author?: string;
15
- capabilities: PluginCapability[];
16
- requiredPermissions?: string[];
17
- configSchema?: Record<string, unknown>;
18
- /** Strings by locale then key, folded into the app's tree under `plugins.<slug>`. May nest. */
19
- messages?: Record<string, Record<string, unknown>>;
20
- }
21
- /** Every toolbar component receives the toolbar entry core built for it. */
22
- interface ToolbarToolProps {
23
- tool: unknown;
24
- }
25
- interface ToolbarRegistration<P = Record<string, unknown>> {
26
- id: string;
27
- label: string;
28
- icon: string;
29
- component: React.ComponentType<ToolbarToolProps & P>;
30
- cursor?: string;
31
- stayActive?: boolean;
32
- }
33
- interface CapabilityRegistry<MapProps = unknown, BimProps = unknown, PointCloudProps = unknown, Legend = unknown> {
34
- 'map.tools': ToolbarRegistration<MapProps>;
35
- 'bim.tools': ToolbarRegistration<BimProps>;
36
- 'pointcloud.tools': ToolbarRegistration<PointCloudProps>;
37
- 'map.legends': Legend;
38
- }
39
- interface PluginContext<MapProps = unknown, BimProps = unknown, PointCloudProps = unknown, Legend = unknown> {
40
- pluginId: string;
41
- register<K extends keyof CapabilityRegistry>(key: K, item: CapabilityRegistry<MapProps, BimProps, PointCloudProps, Legend>[K]): void;
42
- config: Record<string, unknown>;
43
- }
44
-
45
- export { type CapabilityRegistry as C, type PluginContext as P, type ToolbarRegistration as T, VALID_CAPABILITIES as V, PLUGIN_HOST_API as a, type PluginCapability as b, type PluginManifest as c, type ToolbarToolProps as d };