@collabdt/plugin-kit 0.12.0 → 0.14.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -8,6 +8,25 @@ repository root.
8
8
 
9
9
  ## [Unreleased]
10
10
 
11
+ ## [0.14.0] - 2026-11-23
12
+
13
+ ### Added
14
+ - `@collabdt/core/plugins-sdk/tour` as an external, with its declarations (`GuidedTour`, `useTour`,
15
+ `browserTourStore`, `findSidebarPageLink`, `setToolbarPanel`, `TourBody`, `splitTerm`). The types are also
16
+ exported from `@collabdt/plugin-kit/types/tour`. Using it requires a platform running `@collabdt/core` with
17
+ the same addition.
18
+ Steps also take `items`, `shortcut` and `skip`, and `onEnter` may return a cleanup; `GuidedTour` takes `startAt`,
19
+ `onFinish` and `onStepChange`.
20
+
21
+ ## [0.13.0] - 2026-10-23
22
+
23
+ ### Added
24
+ - `category` on `PluginManifest`: an optional free-form grouping such as `live-data`, informational only.
25
+ - `hide()` on `PluginDatasetState` in the `@collabdt/core/plugins-sdk/data` declarations. It needs a platform
26
+ running `@collabdt/core` with the same addition.
27
+
28
+ ## [0.12.0] - 2026-10-13
29
+
11
30
  ### Added
12
31
  - `PluginUser` and `usePluginUser()` in the `@collabdt/core/plugins-sdk/data` declarations: the signed-in user's
13
32
  `id` and `name`, or `null` while the session loads or when signed out.
@@ -14,6 +14,8 @@ interface PluginManifest {
14
14
  author?: string;
15
15
  /** A lucide icon name shown beside the plugin's name. Unset or unknown shows a puzzle piece. */
16
16
  icon?: string;
17
+ /** Free-form grouping such as `live-data`. Informational only; the platform never checks it. */
18
+ category?: string;
17
19
  capabilities: PluginCapability[];
18
20
  requiredPermissions?: string[];
19
21
  configSchema?: Record<string, unknown>;
@@ -64,7 +66,7 @@ type PluginDatasetSource = {
64
66
  };
65
67
  /**
66
68
  * A dataset listed in the Datasets menu: under Live Data when `live`, otherwise under
67
- * Organizational. `usePluginDataset(id)` reports whether it is applied and can apply or remove it.
69
+ * Organizational. `usePluginDataset(id)` reports whether it is applied and can apply, remove or hide it.
68
70
  */
69
71
  interface DatasetRegistration {
70
72
  id: string;
package/dist/index.js CHANGED
@@ -11,6 +11,7 @@ var PLUGIN_EXTERNALS = [
11
11
  "@collabdt/core/plugins-sdk/state",
12
12
  "@collabdt/core/plugins-sdk/ui",
13
13
  "@collabdt/core/plugins-sdk/components",
14
+ "@collabdt/core/plugins-sdk/tour",
14
15
  "@collabdt/core/plugins-sdk/charts"
15
16
  ];
16
17
  var KNOWN_FORBIDDEN = [
@@ -1,6 +1,6 @@
1
1
  /// <reference path="./sdkModules.d.ts" />
2
- import { C as CapabilityRegistry, P as PluginContext } from '../base-DqrDbWmp.js';
3
- export { D as DataPageColumn, a as DataPageCustom, b as DataPageRegistration, c as DataPageRows, d as DataPageTable, e as DatasetRegistration, f as DialogRegistration, M as MapLayerRegistration, g as PLUGIN_HOST_API, h as PluginCapability, i as PluginDatasetSource, j as PluginFeatureCollection, k as PluginManifest, l as PluginNode, m as PluginViewerTarget, T as ToolbarRegistration, n as ToolbarToolProps, V as VALID_CAPABILITIES, o as ViewerTabRegistration } from '../base-DqrDbWmp.js';
2
+ import { C as CapabilityRegistry, P as PluginContext } from '../base-BgaJzKVd.js';
3
+ export { D as DataPageColumn, a as DataPageCustom, b as DataPageRegistration, c as DataPageRows, d as DataPageTable, e as DatasetRegistration, f as DialogRegistration, M as MapLayerRegistration, g as PLUGIN_HOST_API, h as PluginCapability, i as PluginDatasetSource, j as PluginFeatureCollection, k as PluginManifest, l as PluginNode, m as PluginViewerTarget, T as ToolbarRegistration, n as ToolbarToolProps, V as VALID_CAPABILITIES, o as ViewerTabRegistration } from '../base-BgaJzKVd.js';
4
4
  import * as OBC from '@thatopen/components';
5
5
  import 'react';
6
6
 
@@ -1,6 +1,6 @@
1
1
  /// <reference path="./sdkModules.d.ts" />
2
- import { C as CapabilityRegistry, m as PluginViewerTarget, l as PluginNode, P as PluginContext } from '../base-DqrDbWmp.js';
3
- export { D as DataPageColumn, a as DataPageCustom, b as DataPageRegistration, c as DataPageRows, d as DataPageTable, e as DatasetRegistration, f as DialogRegistration, M as MapLayerRegistration, g as PLUGIN_HOST_API, h as PluginCapability, i as PluginDatasetSource, j as PluginFeatureCollection, k as PluginManifest, T as ToolbarRegistration, n as ToolbarToolProps, V as VALID_CAPABILITIES, o as ViewerTabRegistration } from '../base-DqrDbWmp.js';
2
+ import { C as CapabilityRegistry, m as PluginViewerTarget, l as PluginNode, P as PluginContext } from '../base-BgaJzKVd.js';
3
+ export { D as DataPageColumn, a as DataPageCustom, b as DataPageRegistration, c as DataPageRows, d as DataPageTable, e as DatasetRegistration, f as DialogRegistration, M as MapLayerRegistration, g as PLUGIN_HOST_API, h as PluginCapability, i as PluginDatasetSource, j as PluginFeatureCollection, k as PluginManifest, T as ToolbarRegistration, n as ToolbarToolProps, V as VALID_CAPABILITIES, o as ViewerTabRegistration } from '../base-BgaJzKVd.js';
4
4
  import 'react';
5
5
 
6
6
  interface LegendRow {
@@ -1,6 +1,6 @@
1
1
  /// <reference path="./sdkModules.d.ts" />
2
- import { C as CapabilityRegistry, P as PluginContext } from '../base-DqrDbWmp.js';
3
- export { D as DataPageColumn, a as DataPageCustom, b as DataPageRegistration, c as DataPageRows, d as DataPageTable, e as DatasetRegistration, f as DialogRegistration, M as MapLayerRegistration, g as PLUGIN_HOST_API, h as PluginCapability, i as PluginDatasetSource, j as PluginFeatureCollection, k as PluginManifest, l as PluginNode, m as PluginViewerTarget, T as ToolbarRegistration, n as ToolbarToolProps, V as VALID_CAPABILITIES, o as ViewerTabRegistration } from '../base-DqrDbWmp.js';
2
+ import { C as CapabilityRegistry, P as PluginContext } from '../base-BgaJzKVd.js';
3
+ export { D as DataPageColumn, a as DataPageCustom, b as DataPageRegistration, c as DataPageRows, d as DataPageTable, e as DatasetRegistration, f as DialogRegistration, M as MapLayerRegistration, g as PLUGIN_HOST_API, h as PluginCapability, i as PluginDatasetSource, j as PluginFeatureCollection, k as PluginManifest, l as PluginNode, m as PluginViewerTarget, T as ToolbarRegistration, n as ToolbarToolProps, V as VALID_CAPABILITIES, o as ViewerTabRegistration } from '../base-BgaJzKVd.js';
4
4
  import { Map } from 'maplibre-gl';
5
5
  import 'react';
6
6
 
@@ -1,288 +1,314 @@
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
- 'viewer.legends',
24
- 'map.layers',
25
- 'map.datasets',
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
- buildings: 'buildings'
36
- sites: 'sites'
37
- files: 'files'
38
- land: 'land'
39
- infrastructure: 'infrastructure'
40
- plugins: 'plugins'
41
- settings: 'settings'
42
- users: 'users'
43
- }
44
-
45
- /** Map-friendly, colourblind-accessible colours. Use these rather than inventing a set. */
46
- export const MAP_COLOUR_PALETTE: readonly string[]
47
-
48
- /** A stable colour from `MAP_COLOUR_PALETTE`, chosen by hashing the string. */
49
- export function stringToColour(str: string, variant?: 'min' | 'max'): string
50
-
51
- export function validateManifest(manifest: unknown): { valid: boolean; errors: string[] }
52
-
53
- // Generic because an ambient block cannot import `PluginEntry` from the kit's own entries,
54
- // and restating it would give a plugin two definitions. The call site behaves identically.
55
- export function resolvePluginEntry<E>(entry: E | (() => Promise<E>)): Promise<E>
56
- }
57
-
58
- declare module '@collabdt/core/plugins-sdk/config' {
59
- /** The plugin's config for this organization. Generic so a plugin can type its own shape. */
60
- export function usePluginConfig<
61
- T extends Record<string, unknown> = Record<string, unknown>,
62
- >(): T
63
- /** The calling plugin's id, from the scope its capability host established. */
64
- export function usePluginId(): string
65
- }
66
-
67
- declare module '@collabdt/core/plugins-sdk/messages' {
68
- export type PluginTranslator = (key: string, fallback?: string) => string
69
-
70
- /** A `t()` scoped to the calling plugin's own namespace. */
71
- export function usePluginTranslations(): PluginTranslator
72
-
73
- /** One piece of plugin text. All three parameters are required, matching core. */
74
- export function usePluginMessage(pluginId: string, key: string, fallback: string): string
75
-
76
- // Narrowed to a plain callable: typing next-intl's translator faithfully would drag
77
- // next-intl into a plugin's dependencies.
78
- export function useCoreTranslations(
79
- namespace: string,
80
- ): (key: string, values?: Record<string, unknown>) => string
81
- }
82
-
83
- declare module '@collabdt/core/plugins-sdk/store' {
84
- /** One stored document, as the owning plugin sees it. */
85
- export interface PluginDocument<T> {
86
- /** The plugin's own stable identifier for this document. */
87
- key: string
88
- data: T
89
- updatedAt: string | Date
90
- }
91
-
92
- export interface PluginStore<T> {
93
- items: PluginDocument<T>[]
94
- isLoading: boolean
95
- isError: unknown
96
- /** One document by key, or undefined. */
97
- get: (key: string) => PluginDocument<T> | undefined
98
- /** Create or replace a document. Keyed writes are upserts, not appends. */
99
- put: (key: string, data: T) => Promise<void>
100
- remove: (key: string) => Promise<void>
101
- }
102
-
103
- /** Storage scoped by organization, plugin and collection. `T` is your declaration, not a guarantee. */
104
- export function usePluginStore<T = unknown>(collection: string): PluginStore<T>
105
- }
106
-
107
- declare module '@collabdt/core/plugins-sdk/data' {
108
- // Shapes come from `./data`, inline rather than imported at the top: an ambient module cannot carry a relative import (TS2439).
109
-
110
- export type PluginBuilding = import('./data').PluginBuilding
111
- export type PluginSite = import('./data').PluginSite
112
- export type PluginInfrastructure = import('./data').PluginInfrastructure
113
- export type PluginOrganization = import('./data').PluginOrganization
114
- export type PluginFile = import('./data').PluginFile
115
- export type PluginSensor = import('./data').PluginSensor
116
- export type PluginSensorType = import('./data').PluginSensorType
117
- export type PluginComment = import('./data').PluginComment
118
- export type PluginAbility = import('./data').PluginAbility
119
- export type PluginPermissions = import('./data').PluginPermissions
120
- export type PluginUser = import('./data').PluginUser
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
- export function usePluginUser(): import('./data').PluginUser | null
171
-
172
- export interface PluginDatasetState {
173
- /** The user added it from the Datasets menu. */
174
- applied: boolean
175
- /** Applied and not hidden with its eye toggle: draw it only when this is true. */
176
- visible: boolean
177
- /** What ticking it in the Datasets menu does: adds it to the map, or shows it again if hidden. */
178
- apply: () => void
179
- /** What unticking it in the Datasets menu does: takes it off the map. */
180
- remove: () => void
181
- }
182
-
183
- /** Whether one of this plugin's `map.datasets`, by its registration id, is on the map, and the menu's actions for it. */
184
- export function usePluginDataset(id: string): PluginDatasetState
185
- }
186
-
187
- declare module '@collabdt/core/plugins-sdk/state' {
188
- /**
189
- * Shared state for one plugin's surfaces: in memory, scoped to the plugin, gone when it is
190
- * disabled. `usePluginStore` is the persisted counterpart.
191
- */
192
- export function usePluginState<T>(
193
- key: string,
194
- initial: T,
195
- ): [T, (next: T | ((previous: T) => T)) => void]
196
- }
197
-
198
- declare module '@collabdt/core/plugins-sdk/ui' {
199
- export interface PluginDialogs {
200
- /** Opens one of this plugin's registered dialogs. `props` reaches the component as props. */
201
- open: (dialogId: string, props?: Record<string, unknown>) => void
202
- /** Closes the topmost instance of `dialogId`, or of any of this plugin's dialogs. */
203
- close: (dialogId?: string) => void
204
- }
205
-
206
- /** Opens and closes this plugin's `ui.dialogs` contributions from any of its surfaces. */
207
- export function usePluginDialogs(): PluginDialogs
208
-
209
- /** The host's toasts, so a plugin's confirmations look like core's own. */
210
- export const toast: {
211
- success: (message: string) => void
212
- error: (message: string) => void
213
- info: (message: string) => void
214
- }
215
- }
216
-
217
- declare module '@collabdt/core/plugins-sdk/components' {
218
- // Shapes come from `./components`, a real module here, which is what lets core's
219
- // pluginKitComponents.test.ts compare these declarations against the real components.
220
- //
221
- // Inline `import('./components')` rather than a top-level import: an import declaration
222
- // inside an ambient module cannot use a relative specifier (TS2439), and skipLibCheck hides
223
- // that from everyone until a consumer turns it off.
224
-
225
- export type ButtonProps = import('./components').ButtonProps
226
- export const Button: import('./components').ButtonComponent
227
-
228
- export const Input: import('./components').InputComponent
229
-
230
- export type BadgeProps = import('./components').BadgeProps
231
- export const Badge: import('./components').BadgeComponent
232
-
233
- export type SeparatorProps = import('./components').SeparatorProps
234
- export const Separator: import('./components').SeparatorComponent
235
-
236
- export type ConfirmDialogProps = import('./components').ConfirmDialogProps
237
- export const ConfirmDialog: import('./components').ConfirmDialogComponent
238
-
239
- export const Card: import('./components').CardComponent
240
- export const CardHeader: import('./components').CardComponent
241
- export const CardTitle: import('./components').CardComponent
242
- export const CardDescription: import('./components').CardComponent
243
- export const CardContent: import('./components').CardComponent
244
- export const CardFooter: import('./components').CardComponent
245
-
246
- export type DialogProps = import('./components').DialogProps
247
- export const Dialog: import('./components').DialogComponent
248
-
249
- export type DialogTriggerProps = import('./components').DialogTriggerProps
250
- export const DialogTrigger: import('./components').DialogTriggerComponent
251
- export const DialogClose: import('./components').DialogTriggerComponent
252
-
253
- export type DialogContentProps = import('./components').DialogContentProps
254
- export const DialogContent: import('./components').DialogContentComponent
255
-
256
- export const DialogHeader: import('./components').DialogSectionComponent
257
- export const DialogFooter: import('./components').DialogSectionComponent
258
-
259
- export type DialogTitleProps = import('./components').DialogTitleProps
260
- export const DialogTitle: import('./components').DialogTitleComponent
261
-
262
- export type DialogDescriptionProps = import('./components').DialogDescriptionProps
263
- export const DialogDescription: import('./components').DialogDescriptionComponent
264
- }
265
-
266
- declare module '@collabdt/core/plugins-sdk/charts' {
267
- // Loaded on first import, so the host's Recharts never reaches a page that draws no plugin chart.
268
- export type ChartConfig = import('./charts').ChartConfig
269
- export const ChartContainer: import('./charts').ChartContainerComponent
270
- export const ChartTooltip: import('./charts').RechartsComponent
271
- export const ChartTooltipContent: import('./charts').RechartsComponent
272
- export const ChartLegend: import('./charts').RechartsComponent
273
- export const ChartLegendContent: import('./charts').RechartsComponent
274
-
275
- export const Area: import('./charts').RechartsComponent
276
- export const AreaChart: import('./charts').RechartsComponent
277
- export const Bar: import('./charts').RechartsComponent
278
- export const BarChart: import('./charts').RechartsComponent
279
- export const CartesianGrid: import('./charts').RechartsComponent
280
- export const Cell: import('./charts').RechartsComponent
281
- export const Line: import('./charts').RechartsComponent
282
- export const LineChart: import('./charts').RechartsComponent
283
- export const Pie: import('./charts').RechartsComponent
284
- export const PieChart: import('./charts').RechartsComponent
285
- export const ResponsiveContainer: import('./charts').RechartsComponent
286
- export const XAxis: import('./charts').RechartsComponent
287
- export const YAxis: import('./charts').RechartsComponent
288
- }
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
+ 'viewer.legends',
24
+ 'map.layers',
25
+ 'map.datasets',
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
+ buildings: 'buildings'
36
+ sites: 'sites'
37
+ files: 'files'
38
+ land: 'land'
39
+ infrastructure: 'infrastructure'
40
+ plugins: 'plugins'
41
+ settings: 'settings'
42
+ users: 'users'
43
+ }
44
+
45
+ /** Map-friendly, colourblind-accessible colours. Use these rather than inventing a set. */
46
+ export const MAP_COLOUR_PALETTE: readonly string[]
47
+
48
+ /** A stable colour from `MAP_COLOUR_PALETTE`, chosen by hashing the string. */
49
+ export function stringToColour(str: string, variant?: 'min' | 'max'): string
50
+
51
+ export function validateManifest(manifest: unknown): { valid: boolean; errors: string[] }
52
+
53
+ // Generic because an ambient block cannot import `PluginEntry` from the kit's own entries,
54
+ // and restating it would give a plugin two definitions. The call site behaves identically.
55
+ export function resolvePluginEntry<E>(entry: E | (() => Promise<E>)): Promise<E>
56
+ }
57
+
58
+ declare module '@collabdt/core/plugins-sdk/config' {
59
+ /** The plugin's config for this organization. Generic so a plugin can type its own shape. */
60
+ export function usePluginConfig<
61
+ T extends Record<string, unknown> = Record<string, unknown>,
62
+ >(): T
63
+ /** The calling plugin's id, from the scope its capability host established. */
64
+ export function usePluginId(): string
65
+ }
66
+
67
+ declare module '@collabdt/core/plugins-sdk/messages' {
68
+ export type PluginTranslator = (key: string, fallback?: string) => string
69
+
70
+ /** A `t()` scoped to the calling plugin's own namespace. */
71
+ export function usePluginTranslations(): PluginTranslator
72
+
73
+ /** One piece of plugin text. All three parameters are required, matching core. */
74
+ export function usePluginMessage(pluginId: string, key: string, fallback: string): string
75
+
76
+ // Narrowed to a plain callable: typing next-intl's translator faithfully would drag
77
+ // next-intl into a plugin's dependencies.
78
+ export function useCoreTranslations(
79
+ namespace: string,
80
+ ): (key: string, values?: Record<string, unknown>) => string
81
+ }
82
+
83
+ declare module '@collabdt/core/plugins-sdk/store' {
84
+ /** One stored document, as the owning plugin sees it. */
85
+ export interface PluginDocument<T> {
86
+ /** The plugin's own stable identifier for this document. */
87
+ key: string
88
+ data: T
89
+ updatedAt: string | Date
90
+ }
91
+
92
+ export interface PluginStore<T> {
93
+ items: PluginDocument<T>[]
94
+ isLoading: boolean
95
+ isError: unknown
96
+ /** One document by key, or undefined. */
97
+ get: (key: string) => PluginDocument<T> | undefined
98
+ /** Create or replace a document. Keyed writes are upserts, not appends. */
99
+ put: (key: string, data: T) => Promise<void>
100
+ remove: (key: string) => Promise<void>
101
+ }
102
+
103
+ /** Storage scoped by organization, plugin and collection. `T` is your declaration, not a guarantee. */
104
+ export function usePluginStore<T = unknown>(collection: string): PluginStore<T>
105
+ }
106
+
107
+ declare module '@collabdt/core/plugins-sdk/data' {
108
+ // Shapes come from `./data`, inline rather than imported at the top: an ambient module cannot carry a relative import (TS2439).
109
+
110
+ export type PluginBuilding = import('./data').PluginBuilding
111
+ export type PluginSite = import('./data').PluginSite
112
+ export type PluginInfrastructure = import('./data').PluginInfrastructure
113
+ export type PluginOrganization = import('./data').PluginOrganization
114
+ export type PluginFile = import('./data').PluginFile
115
+ export type PluginSensor = import('./data').PluginSensor
116
+ export type PluginSensorType = import('./data').PluginSensorType
117
+ export type PluginComment = import('./data').PluginComment
118
+ export type PluginAbility = import('./data').PluginAbility
119
+ export type PluginPermissions = import('./data').PluginPermissions
120
+ export type PluginUser = import('./data').PluginUser
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
+ export function usePluginUser(): import('./data').PluginUser | null
171
+
172
+ export interface PluginDatasetState {
173
+ /** The user added it from the Datasets menu. */
174
+ applied: boolean
175
+ /** Applied and not hidden with its eye toggle: draw it only when this is true. */
176
+ visible: boolean
177
+ /** What ticking it in the Datasets menu does: adds it to the map, or shows it again if hidden. */
178
+ apply: () => void
179
+ /** What unticking it in the Datasets menu does: takes it off the map. */
180
+ remove: () => void
181
+ /** What its eye toggle in the applied list does: keeps it applied but stops drawing it. */
182
+ hide: () => void
183
+ }
184
+
185
+ /** Whether one of this plugin's `map.datasets`, by its registration id, is on the map, and the menu's actions for it. */
186
+ export function usePluginDataset(id: string): PluginDatasetState
187
+ }
188
+
189
+ declare module '@collabdt/core/plugins-sdk/state' {
190
+ /**
191
+ * Shared state for one plugin's surfaces: in memory, scoped to the plugin, gone when it is
192
+ * disabled. `usePluginStore` is the persisted counterpart.
193
+ */
194
+ export function usePluginState<T>(
195
+ key: string,
196
+ initial: T,
197
+ ): [T, (next: T | ((previous: T) => T)) => void]
198
+ }
199
+
200
+ declare module '@collabdt/core/plugins-sdk/ui' {
201
+ export interface PluginDialogs {
202
+ /** Opens one of this plugin's registered dialogs. `props` reaches the component as props. */
203
+ open: (dialogId: string, props?: Record<string, unknown>) => void
204
+ /** Closes the topmost instance of `dialogId`, or of any of this plugin's dialogs. */
205
+ close: (dialogId?: string) => void
206
+ }
207
+
208
+ /** Opens and closes this plugin's `ui.dialogs` contributions from any of its surfaces. */
209
+ export function usePluginDialogs(): PluginDialogs
210
+
211
+ /** The host's toasts, so a plugin's confirmations look like core's own. */
212
+ export const toast: {
213
+ success: (message: string) => void
214
+ error: (message: string) => void
215
+ info: (message: string) => void
216
+ }
217
+ }
218
+
219
+ declare module '@collabdt/core/plugins-sdk/components' {
220
+ // Shapes come from `./components`, a real module here, which is what lets core's
221
+ // pluginKitComponents.test.ts compare these declarations against the real components.
222
+ //
223
+ // Inline `import('./components')` rather than a top-level import: an import declaration
224
+ // inside an ambient module cannot use a relative specifier (TS2439), and skipLibCheck hides
225
+ // that from everyone until a consumer turns it off.
226
+
227
+ export type ButtonProps = import('./components').ButtonProps
228
+ export const Button: import('./components').ButtonComponent
229
+
230
+ export const Input: import('./components').InputComponent
231
+
232
+ export type BadgeProps = import('./components').BadgeProps
233
+ export const Badge: import('./components').BadgeComponent
234
+
235
+ export type SeparatorProps = import('./components').SeparatorProps
236
+ export const Separator: import('./components').SeparatorComponent
237
+
238
+ export type ConfirmDialogProps = import('./components').ConfirmDialogProps
239
+ export const ConfirmDialog: import('./components').ConfirmDialogComponent
240
+
241
+ export const Card: import('./components').CardComponent
242
+ export const CardHeader: import('./components').CardComponent
243
+ export const CardTitle: import('./components').CardComponent
244
+ export const CardDescription: import('./components').CardComponent
245
+ export const CardContent: import('./components').CardComponent
246
+ export const CardFooter: import('./components').CardComponent
247
+
248
+ export type DialogProps = import('./components').DialogProps
249
+ export const Dialog: import('./components').DialogComponent
250
+
251
+ export type DialogTriggerProps = import('./components').DialogTriggerProps
252
+ export const DialogTrigger: import('./components').DialogTriggerComponent
253
+ export const DialogClose: import('./components').DialogTriggerComponent
254
+
255
+ export type DialogContentProps = import('./components').DialogContentProps
256
+ export const DialogContent: import('./components').DialogContentComponent
257
+
258
+ export const DialogHeader: import('./components').DialogSectionComponent
259
+ export const DialogFooter: import('./components').DialogSectionComponent
260
+
261
+ export type DialogTitleProps = import('./components').DialogTitleProps
262
+ export const DialogTitle: import('./components').DialogTitleComponent
263
+
264
+ export type DialogDescriptionProps = import('./components').DialogDescriptionProps
265
+ export const DialogDescription: import('./components').DialogDescriptionComponent
266
+ }
267
+
268
+ declare module '@collabdt/core/plugins-sdk/charts' {
269
+ // Loaded on first import, so the host's Recharts never reaches a page that draws no plugin chart.
270
+ export type ChartConfig = import('./charts').ChartConfig
271
+ export const ChartContainer: import('./charts').ChartContainerComponent
272
+ export const ChartTooltip: import('./charts').RechartsComponent
273
+ export const ChartTooltipContent: import('./charts').RechartsComponent
274
+ export const ChartLegend: import('./charts').RechartsComponent
275
+ export const ChartLegendContent: import('./charts').RechartsComponent
276
+
277
+ export const Area: import('./charts').RechartsComponent
278
+ export const AreaChart: import('./charts').RechartsComponent
279
+ export const Bar: import('./charts').RechartsComponent
280
+ export const BarChart: import('./charts').RechartsComponent
281
+ export const CartesianGrid: import('./charts').RechartsComponent
282
+ export const Cell: import('./charts').RechartsComponent
283
+ export const Line: import('./charts').RechartsComponent
284
+ export const LineChart: import('./charts').RechartsComponent
285
+ export const Pie: import('./charts').RechartsComponent
286
+ export const PieChart: import('./charts').RechartsComponent
287
+ export const ResponsiveContainer: import('./charts').RechartsComponent
288
+ export const XAxis: import('./charts').RechartsComponent
289
+ export const YAxis: import('./charts').RechartsComponent
290
+ }
291
+
292
+ declare module '@collabdt/core/plugins-sdk/tour' {
293
+ export type TourTarget = import('./tour').TourTarget
294
+ export type TourItem = import('./tour').TourItem
295
+ export type TourStep = import('./tour').TourStep
296
+ export type GuidedTourLabels = import('./tour').GuidedTourLabels
297
+ export type GuidedTourProps = import('./tour').GuidedTourProps
298
+ export type TourStore = import('./tour').TourStore
299
+ export type BrowserTourStoreOptions = import('./tour').BrowserTourStoreOptions
300
+
301
+ /** A step-by-step guide that spotlights parts of the page while leaving it usable underneath. */
302
+ export const GuidedTour: import('./tour').GuidedTourComponent
303
+ export const TourBody: import('./tour').TourBodyComponent
304
+ export function splitTerm(line: string): [string | null, string]
305
+
306
+ /** Whether a tour is showing: open until hidden or finished, then closed for as long as `store` remembers. */
307
+ export function useTour(tourId: string, store?: TourStore): { open: boolean; start: () => void; hide: () => void }
308
+ export function browserTourStore(options: BrowserTourStoreOptions, backing?: import('./tour').FlagStorage | null): TourStore
309
+
310
+ /** The app sidebar's button for a page, matched on its title. */
311
+ export function findSidebarPageLink(title: string, lookup?: Pick<Document, 'querySelectorAll'>): HTMLElement | null
312
+ /** Opens or closes the toolbar dropdown holding `element` through the toggle that controls it. */
313
+ export function setToolbarPanel(element: Element | null, open: boolean, lookup?: Pick<Document, 'querySelectorAll' | 'getElementById'>): void
314
+ }
@@ -0,0 +1,79 @@
1
+ import * as React from 'react';
2
+
3
+ /** A `data-tour` anchor id, a function finding the element, or `null` to centre the card. */
4
+ type TourTarget = string | (() => Element | null | undefined) | null;
5
+ /** A row under a step's body; with `onSelect` it is a button, e.g. one that starts a tour of the part it names. */
6
+ interface TourItem {
7
+ id: string;
8
+ term: string;
9
+ description: string;
10
+ icon?: React.ComponentType<{
11
+ className?: string;
12
+ }>;
13
+ onSelect?: () => void;
14
+ }
15
+ interface TourStep {
16
+ id: string;
17
+ target: TourTarget;
18
+ title: string;
19
+ /** A string splits on newlines; `term — description` lines become a definition list. */
20
+ body: React.ReactNode;
21
+ items?: TourItem[];
22
+ /** Runs when the step opens, to open a panel the target needs; a returned function runs when the step closes. */
23
+ onEnter?: () => void | (() => void);
24
+ /** Points an arrow at the target and ends the tour when the target is clicked. */
25
+ invite?: boolean;
26
+ /** Whether to scroll the target into view; `false` for targets that fill the page, like a map. */
27
+ scroll?: boolean;
28
+ /** A small button at the top of the card, e.g. one that skips to the tour of the page the viewer is on. */
29
+ shortcut?: {
30
+ label: string;
31
+ onSelect: () => void;
32
+ };
33
+ /** Checked when Next or Back would reach the step; `true` passes over it, e.g. a hint for a state the page is not in. */
34
+ skip?: () => boolean;
35
+ }
36
+ interface GuidedTourLabels {
37
+ next: string;
38
+ back: string;
39
+ finish: string;
40
+ hide: string;
41
+ missing: string;
42
+ progress: (step: number, total: number) => string;
43
+ }
44
+ interface GuidedTourProps {
45
+ steps: TourStep[];
46
+ /** Called when the viewer hides, escapes or finishes the tour. */
47
+ onHide: () => void;
48
+ /** Called by Finish on the last step instead of `onHide`, e.g. to return to the tour this one branched from. */
49
+ onFinish?: () => void;
50
+ /** Called with the id of each step as it opens, e.g. to reopen on it if the tour remounts. */
51
+ onStepChange?: (stepId: string) => void;
52
+ /** The id of the step to open on; the first step when absent or unknown. */
53
+ startAt?: string;
54
+ /** Elements the card must not cover, such as the panel a step points into. */
55
+ avoid?: () => Element[];
56
+ /** Shown at the start of the card's header, e.g. a logo. */
57
+ header?: React.ReactNode;
58
+ labels?: Partial<GuidedTourLabels>;
59
+ /** Scopes CSS variable overrides (`--tour-accent`, …) to this tour. */
60
+ className?: string;
61
+ }
62
+ type GuidedTourComponent = (props: GuidedTourProps) => React.ReactNode;
63
+ type TourBodyComponent = (props: {
64
+ body: React.ReactNode;
65
+ }) => React.ReactNode;
66
+ /** Remembers which tours a viewer has finished or hidden, so they do not reopen. */
67
+ interface TourStore {
68
+ isDone: (tourId: string) => boolean;
69
+ markDone: (tourId: string) => void;
70
+ }
71
+ type FlagStorage = Pick<Storage, 'getItem' | 'setItem'>;
72
+ interface BrowserTourStoreOptions {
73
+ /** `session` brings the tour back in a new browser session; `local` keeps it closed on this device. */
74
+ storage?: 'session' | 'local';
75
+ /** Prefixes the storage key, so two plugins' tours with the same id stay apart. */
76
+ namespace: string;
77
+ }
78
+
79
+ export type { BrowserTourStoreOptions, FlagStorage, GuidedTourComponent, GuidedTourLabels, GuidedTourProps, TourBodyComponent, TourItem, TourStep, TourStore, TourTarget };
File without changes
@@ -1,5 +1,5 @@
1
- import { C as CapabilityRegistry, P as PluginContext } from '../base-DqrDbWmp.js';
2
- export { D as DataPageColumn, a as DataPageCustom, b as DataPageRegistration, c as DataPageRows, d as DataPageTable, e as DatasetRegistration, f as DialogRegistration, M as MapLayerRegistration, g as PLUGIN_HOST_API, h as PluginCapability, i as PluginDatasetSource, j as PluginFeatureCollection, k as PluginManifest, l as PluginNode, m as PluginViewerTarget, T as ToolbarRegistration, n as ToolbarToolProps, V as VALID_CAPABILITIES, o as ViewerTabRegistration } from '../base-DqrDbWmp.js';
1
+ import { C as CapabilityRegistry, P as PluginContext } from '../base-BgaJzKVd.js';
2
+ export { D as DataPageColumn, a as DataPageCustom, b as DataPageRegistration, c as DataPageRows, d as DataPageTable, e as DatasetRegistration, f as DialogRegistration, M as MapLayerRegistration, g as PLUGIN_HOST_API, h as PluginCapability, i as PluginDatasetSource, j as PluginFeatureCollection, k as PluginManifest, l as PluginNode, m as PluginViewerTarget, T as ToolbarRegistration, n as ToolbarToolProps, V as VALID_CAPABILITIES, o as ViewerTabRegistration } from '../base-BgaJzKVd.js';
3
3
  import 'react';
4
4
 
5
5
  /** `CapabilityRegistry` for the surfaces that bind no viewer props. */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@collabdt/plugin-kit",
3
- "version": "0.12.0",
3
+ "version": "0.14.0",
4
4
  "description": "Build preset and types for authoring CDT plugins.",
5
5
  "license": "AGPL-3.0-or-later",
6
6
  "type": "module",
@@ -42,6 +42,10 @@
42
42
  "./types/ui": {
43
43
  "types": "./dist/types/ui.d.ts",
44
44
  "default": "./dist/types/ui.js"
45
+ },
46
+ "./types/tour": {
47
+ "types": "./dist/types/tour.d.ts",
48
+ "default": "./dist/types/tour.js"
45
49
  }
46
50
  },
47
51
  "scripts": {