@collabdt/plugin-kit 0.1.0 → 0.2.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` | `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>
@@ -2,7 +2,7 @@ import * as React from 'react';
2
2
 
3
3
  /** Declare as `hostApi` in your manifest. The host refuses a plugin that declares another value. */
4
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"];
5
+ declare const VALID_CAPABILITIES: readonly ["data.pages", "viewer.tabs", "ui.dialogs", "map.tools", "bim.tools", "pointcloud.tools", "map.legends"];
6
6
  type PluginCapability = typeof VALID_CAPABILITIES[number];
7
7
  interface PluginManifest {
8
8
  slug: string;
@@ -30,7 +30,45 @@ interface ToolbarRegistration<P = Record<string, unknown>> {
30
30
  cursor?: string;
31
31
  stayActive?: boolean;
32
32
  }
33
+ interface DataPageColumn<Row> {
34
+ key: string;
35
+ labelKey: string;
36
+ render?: (row: Row) => React.ReactNode;
37
+ }
38
+ interface DataPageRows<Row> {
39
+ rows: Row[];
40
+ isLoading?: boolean;
41
+ onRowClick?: (row: Row) => void;
42
+ }
43
+ interface DataPageRegistration<Row = Record<string, unknown>> {
44
+ id: string;
45
+ titleKey: string;
46
+ icon: string;
47
+ useRows: () => DataPageRows<Row>;
48
+ columns: DataPageColumn<Row>[];
49
+ searchKeys?: string[];
50
+ emptyKey?: string;
51
+ }
52
+ interface ViewerTabRegistration {
53
+ id: string;
54
+ labelKey: string;
55
+ icon: string;
56
+ component: React.ComponentType;
57
+ /** Viewer names as core spells them: 'map', 'bim', 'pointcloud'. Omit for all of them. */
58
+ viewers?: string[];
59
+ }
60
+ interface DialogRegistration<P = Record<string, unknown>> {
61
+ id: string;
62
+ titleKey: string;
63
+ size?: 'sm' | 'md' | 'lg' | 'xl';
64
+ component: React.ComponentType<P & {
65
+ close: () => void;
66
+ }>;
67
+ }
33
68
  interface CapabilityRegistry<MapProps = unknown, BimProps = unknown, PointCloudProps = unknown, Legend = unknown> {
69
+ 'data.pages': DataPageRegistration;
70
+ 'viewer.tabs': ViewerTabRegistration;
71
+ 'ui.dialogs': DialogRegistration;
34
72
  'map.tools': ToolbarRegistration<MapProps>;
35
73
  'bim.tools': ToolbarRegistration<BimProps>;
36
74
  'pointcloud.tools': ToolbarRegistration<PointCloudProps>;
@@ -42,4 +80,4 @@ interface PluginContext<MapProps = unknown, BimProps = unknown, PointCloudProps
42
80
  config: Record<string, unknown>;
43
81
  }
44
82
 
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 };
83
+ export { type CapabilityRegistry as C, type DataPageColumn as D, PLUGIN_HOST_API as P, type ToolbarRegistration as T, VALID_CAPABILITIES as V, type DataPageRegistration as a, type DataPageRows as b, type DialogRegistration as c, type PluginCapability as d, type PluginContext as e, type PluginManifest as f, type ToolbarToolProps as g, type ViewerTabRegistration as h };
@@ -1,8 +1,9 @@
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",
package/dist/index.js CHANGED
@@ -7,6 +7,8 @@ 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/state",
11
+ "@collabdt/core/plugins-sdk/ui",
10
12
  "@collabdt/core/plugins-sdk/components"
11
13
  ];
12
14
  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, e as PluginContext } from '../base-yYCEWR1m.js';
3
+ export { D as DataPageColumn, a as DataPageRegistration, b as DataPageRows, c as DialogRegistration, P as PLUGIN_HOST_API, d as PluginCapability, f as PluginManifest, T as ToolbarRegistration, g as ToolbarToolProps, V as VALID_CAPABILITIES, h as ViewerTabRegistration } from '../base-yYCEWR1m.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-EE4HWIP7.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, e as PluginContext } from '../base-yYCEWR1m.js';
3
+ export { D as DataPageColumn, a as DataPageRegistration, b as DataPageRows, c as DialogRegistration, P as PLUGIN_HOST_API, d as PluginCapability, f as PluginManifest, T as ToolbarRegistration, g as ToolbarToolProps, V as VALID_CAPABILITIES, h as ViewerTabRegistration } from '../base-yYCEWR1m.js';
4
4
  import 'react';
5
5
 
6
6
  interface LegendRow {
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  PLUGIN_HOST_API,
3
3
  VALID_CAPABILITIES
4
- } from "../chunk-CVHASC2D.js";
4
+ } from "../chunk-EE4HWIP7.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, e as PluginContext } from '../base-yYCEWR1m.js';
3
+ export { D as DataPageColumn, a as DataPageRegistration, b as DataPageRows, c as DialogRegistration, P as PLUGIN_HOST_API, d as PluginCapability, f as PluginManifest, T as ToolbarRegistration, g as ToolbarToolProps, V as VALID_CAPABILITIES, h as ViewerTabRegistration } from '../base-yYCEWR1m.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-EE4HWIP7.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, e as PluginContext } from '../base-yYCEWR1m.js';
3
+ export { D as DataPageColumn, a as DataPageRegistration, b as DataPageRows, c as DialogRegistration, P as PLUGIN_HOST_API, d as PluginCapability, f as PluginManifest, T as ToolbarRegistration, g as ToolbarToolProps, V as VALID_CAPABILITIES, h as ViewerTabRegistration } from '../base-yYCEWR1m.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-EE4HWIP7.js";
5
5
  export {
6
6
  PLUGIN_HOST_API,
7
7
  VALID_CAPABILITIES
@@ -15,8 +15,9 @@ declare module '@collabdt/core/plugins-sdk' {
15
15
  // Only the values the shim re-exports. The SDK's types live in the surface entries, so each
16
16
  // shape has one definition and it is the one a plugin already imports.
17
17
  export const VALID_CAPABILITIES: readonly [
18
- 'sidebar.items',
19
- 'viewer.panels',
18
+ 'data.pages',
19
+ 'viewer.tabs',
20
+ 'ui.dialogs',
20
21
  'map.tools',
21
22
  'bim.tools',
22
23
  'pointcloud.tools',
@@ -25,6 +26,23 @@ declare module '@collabdt/core/plugins-sdk' {
25
26
 
26
27
  export const PLUGIN_HOST_API: 1
27
28
 
29
+ // A value, not just a type: a `viewer.tabs` contribution names the viewers it belongs in.
30
+ // Restated rather than imported, because an ambient block cannot reach the kit's entries.
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
+
28
46
  export function validateManifest(manifest: unknown): { valid: boolean; errors: string[] }
29
47
 
30
48
  // Generic because an ambient block cannot import `PluginEntry` from the kit's own entries,
@@ -81,6 +99,30 @@ declare module '@collabdt/core/plugins-sdk/store' {
81
99
  export function usePluginStore<T = unknown>(collection: string): PluginStore<T>
82
100
  }
83
101
 
102
+ declare module '@collabdt/core/plugins-sdk/state' {
103
+ /**
104
+ * Shared state for one plugin's surfaces, in memory and scoped to the calling plugin. A map
105
+ * tool and a sidebar tab using the same key see the same value; another plugin never does.
106
+ * Gone when the plugin is disabled or the tab closes — `usePluginStore` is the persisted one.
107
+ */
108
+ export function usePluginState<T>(
109
+ key: string,
110
+ initial: T,
111
+ ): [T, (next: T | ((previous: T) => T)) => void]
112
+ }
113
+
114
+ declare module '@collabdt/core/plugins-sdk/ui' {
115
+ export interface PluginDialogs {
116
+ /** Opens one of this plugin's registered dialogs. `props` reaches the component as props. */
117
+ open: (dialogId: string, props?: Record<string, unknown>) => void
118
+ /** Closes the topmost instance of `dialogId`, or of any of this plugin's dialogs. */
119
+ close: (dialogId?: string) => void
120
+ }
121
+
122
+ /** Opens and closes this plugin's `ui.dialogs` contributions from any of its surfaces. */
123
+ export function usePluginDialogs(): PluginDialogs
124
+ }
125
+
84
126
  declare module '@collabdt/core/plugins-sdk/components' {
85
127
  // Shapes come from `./components`, a real module here, which is what lets core's
86
128
  // pluginKitComponents.test.ts compare these declarations against the real components.
@@ -0,0 +1,10 @@
1
+ import { C as CapabilityRegistry, e as PluginContext } from '../base-yYCEWR1m.js';
2
+ export { D as DataPageColumn, a as DataPageRegistration, b as DataPageRows, c as DialogRegistration, P as PLUGIN_HOST_API, d as PluginCapability, f as PluginManifest, T as ToolbarRegistration, g as ToolbarToolProps, V as VALID_CAPABILITIES, h as ViewerTabRegistration } from '../base-yYCEWR1m.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-EE4HWIP7.js";
5
+ export {
6
+ PLUGIN_HOST_API,
7
+ VALID_CAPABILITIES
8
+ };
package/package.json CHANGED
@@ -1,63 +1,63 @@
1
- {
2
- "name": "@collabdt/plugin-kit",
3
- "version": "0.1.0",
4
- "description": "Build preset and types for authoring CDT plugins.",
5
- "license": "AGPL-3.0-or-later",
6
- "type": "module",
7
- "files": [
8
- "dist"
9
- ],
10
- "main": "./dist/index.js",
11
- "types": "./dist/index.d.ts",
12
- "exports": {
13
- ".": {
14
- "types": "./dist/index.d.ts",
15
- "default": "./dist/index.js"
16
- },
17
- "./types/components": {
18
- "types": "./dist/types/components.d.ts",
19
- "default": "./dist/types/components.js"
20
- },
21
- "./types/map": {
22
- "types": "./dist/types/map.d.ts",
23
- "default": "./dist/types/map.js"
24
- },
25
- "./types/bim": {
26
- "types": "./dist/types/bim.d.ts",
27
- "default": "./dist/types/bim.js"
28
- },
29
- "./types/pointcloud": {
30
- "types": "./dist/types/pointcloud.d.ts",
31
- "default": "./dist/types/pointcloud.js"
32
- },
33
- "./types/legend": {
34
- "types": "./dist/types/legend.d.ts",
35
- "default": "./dist/types/legend.js"
36
- }
37
- },
38
- "scripts": {
39
- "build": "tsup && node scripts/shipAmbientTypes.mjs",
40
- "test": "vitest run"
41
- },
42
- "peerDependencies": {
43
- "@thatopen/components": ">=3.4",
44
- "@types/react": ">=18",
45
- "maplibre-gl": ">=5",
46
- "tsup": ">=8"
47
- },
48
- "peerDependenciesMeta": {
49
- "@thatopen/components": {
50
- "optional": true
51
- },
52
- "maplibre-gl": {
53
- "optional": true
54
- }
55
- },
56
- "devDependencies": {
57
- "@thatopen/components": "~3.4.0",
58
- "maplibre-gl": "^5.24.0",
59
- "tsup": "^8.5.0",
60
- "typescript": "^5.9.3",
61
- "vitest": "^4.1.8"
62
- }
63
- }
1
+ {
2
+ "name": "@collabdt/plugin-kit",
3
+ "version": "0.2.0",
4
+ "description": "Build preset and types for authoring CDT plugins.",
5
+ "license": "AGPL-3.0-or-later",
6
+ "type": "module",
7
+ "files": [
8
+ "dist"
9
+ ],
10
+ "main": "./dist/index.js",
11
+ "types": "./dist/index.d.ts",
12
+ "exports": {
13
+ ".": {
14
+ "types": "./dist/index.d.ts",
15
+ "default": "./dist/index.js"
16
+ },
17
+ "./types/components": {
18
+ "types": "./dist/types/components.d.ts",
19
+ "default": "./dist/types/components.js"
20
+ },
21
+ "./types/map": {
22
+ "types": "./dist/types/map.d.ts",
23
+ "default": "./dist/types/map.js"
24
+ },
25
+ "./types/bim": {
26
+ "types": "./dist/types/bim.d.ts",
27
+ "default": "./dist/types/bim.js"
28
+ },
29
+ "./types/pointcloud": {
30
+ "types": "./dist/types/pointcloud.d.ts",
31
+ "default": "./dist/types/pointcloud.js"
32
+ },
33
+ "./types/legend": {
34
+ "types": "./dist/types/legend.d.ts",
35
+ "default": "./dist/types/legend.js"
36
+ }
37
+ },
38
+ "scripts": {
39
+ "build": "tsup && node scripts/shipAmbientTypes.mjs",
40
+ "test": "vitest run"
41
+ },
42
+ "peerDependencies": {
43
+ "@thatopen/components": ">=3.4",
44
+ "@types/react": ">=18",
45
+ "maplibre-gl": ">=5",
46
+ "tsup": ">=8"
47
+ },
48
+ "peerDependenciesMeta": {
49
+ "@thatopen/components": {
50
+ "optional": true
51
+ },
52
+ "maplibre-gl": {
53
+ "optional": true
54
+ }
55
+ },
56
+ "devDependencies": {
57
+ "@thatopen/components": "~3.4.0",
58
+ "maplibre-gl": "^5.24.0",
59
+ "tsup": "^8.5.0",
60
+ "typescript": "^5.9.3",
61
+ "vitest": "^4.1.8"
62
+ }
63
+ }