@collabdt/plugin-kit 0.2.0 → 0.4.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
@@ -64,7 +64,7 @@ import type { MapToolProps, ToolbarToolProps } from '@collabdt/plugin-kit/types/
64
64
  | `@collabdt/plugin-kit/types/map` | `map.tools` | `maplibre-gl` types |
65
65
  | `@collabdt/plugin-kit/types/bim` | `bim.tools` | `@thatopen/components` types |
66
66
  | `@collabdt/plugin-kit/types/pointcloud` | `pointcloud.tools` | nothing external |
67
- | `@collabdt/plugin-kit/types/legend` | `map.legends` | nothing external |
67
+ | `@collabdt/plugin-kit/types/legend` | `viewer.legends` | nothing external |
68
68
 
69
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
70
 
@@ -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 ["data.pages", "viewer.tabs", "ui.dialogs", "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", "viewer.legends", "map.layers"];
6
6
  type PluginCapability = typeof VALID_CAPABILITIES[number];
7
7
  interface PluginManifest {
8
8
  slug: string;
@@ -30,6 +30,10 @@ interface ToolbarRegistration<P = Record<string, unknown>> {
30
30
  cursor?: string;
31
31
  stayActive?: boolean;
32
32
  }
33
+ interface MapLayerRegistration<P = unknown> {
34
+ id: string;
35
+ component: React.ComponentType<P>;
36
+ }
33
37
  interface DataPageColumn<Row> {
34
38
  key: string;
35
39
  labelKey: string;
@@ -38,6 +42,7 @@ interface DataPageColumn<Row> {
38
42
  interface DataPageRows<Row> {
39
43
  rows: Row[];
40
44
  isLoading?: boolean;
45
+ /** From the hook, not the registration, so it can close over `usePluginDialogs`. */
41
46
  onRowClick?: (row: Row) => void;
42
47
  }
43
48
  interface DataPageRegistration<Row = Record<string, unknown>> {
@@ -49,13 +54,15 @@ interface DataPageRegistration<Row = Record<string, unknown>> {
49
54
  searchKeys?: string[];
50
55
  emptyKey?: string;
51
56
  }
57
+ /** The viewers that host a tab or a legend. Core spells them exactly this way. */
58
+ type PluginViewerTarget = 'map' | 'bim' | 'pointcloud';
52
59
  interface ViewerTabRegistration {
53
60
  id: string;
54
61
  labelKey: string;
55
62
  icon: string;
56
63
  component: React.ComponentType;
57
- /** Viewer names as core spells them: 'map', 'bim', 'pointcloud'. Omit for all of them. */
58
- viewers?: string[];
64
+ /** Which viewers this tab appears in. Omit for all of them. */
65
+ viewers?: PluginViewerTarget[];
59
66
  }
60
67
  interface DialogRegistration<P = Record<string, unknown>> {
61
68
  id: string;
@@ -72,7 +79,8 @@ interface CapabilityRegistry<MapProps = unknown, BimProps = unknown, PointCloudP
72
79
  'map.tools': ToolbarRegistration<MapProps>;
73
80
  'bim.tools': ToolbarRegistration<BimProps>;
74
81
  'pointcloud.tools': ToolbarRegistration<PointCloudProps>;
75
- 'map.legends': Legend;
82
+ 'viewer.legends': Legend;
83
+ 'map.layers': MapLayerRegistration<MapProps>;
76
84
  }
77
85
  interface PluginContext<MapProps = unknown, BimProps = unknown, PointCloudProps = unknown, Legend = unknown> {
78
86
  pluginId: string;
@@ -80,4 +88,4 @@ interface PluginContext<MapProps = unknown, BimProps = unknown, PointCloudProps
80
88
  config: Record<string, unknown>;
81
89
  }
82
90
 
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 };
91
+ 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 PluginViewerTarget as g, type ToolbarToolProps as h, type ViewerTabRegistration as i };
@@ -7,7 +7,8 @@ var VALID_CAPABILITIES = [
7
7
  "map.tools",
8
8
  "bim.tools",
9
9
  "pointcloud.tools",
10
- "map.legends"
10
+ "viewer.legends",
11
+ "map.layers"
11
12
  ];
12
13
 
13
14
  export {
package/dist/index.js CHANGED
@@ -7,6 +7,7 @@ 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",
10
11
  "@collabdt/core/plugins-sdk/state",
11
12
  "@collabdt/core/plugins-sdk/ui",
12
13
  "@collabdt/core/plugins-sdk/components"
@@ -1,6 +1,6 @@
1
1
  /// <reference path="./sdkModules.d.ts" />
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';
2
+ import { C as CapabilityRegistry, P as PluginContext } from '../base-ClPlfxgA.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, g as PluginViewerTarget, T as ToolbarRegistration, h as ToolbarToolProps, V as VALID_CAPABILITIES, i as ViewerTabRegistration } from '../base-ClPlfxgA.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-EE4HWIP7.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, 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';
2
+ import { C as CapabilityRegistry, g as PluginViewerTarget, P as PluginContext } from '../base-ClPlfxgA.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, h as ToolbarToolProps, V as VALID_CAPABILITIES, i as ViewerTabRegistration } from '../base-ClPlfxgA.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
+ /** Which viewers this legend appears in. Omit for all of them. */
15
+ viewers?: PluginViewerTarget[];
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;
@@ -25,4 +27,4 @@ type LegendCapabilityRegistry = CapabilityRegistry<unknown, unknown, unknown, Le
25
27
  /** The `activate()` context for a plugin that contributes a map legend. */
26
28
  type LegendPluginContext = PluginContext<unknown, unknown, unknown, LegendRegistration>;
27
29
 
28
- export { CapabilityRegistry, type LegendCapabilityRegistry, type LegendPluginContext, type LegendRegistration, type LegendRow, PluginContext };
30
+ export { CapabilityRegistry, type LegendCapabilityRegistry, type LegendPluginContext, type LegendRegistration, type LegendRow, PluginContext, PluginViewerTarget };
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  PLUGIN_HOST_API,
3
3
  VALID_CAPABILITIES
4
- } from "../chunk-EE4HWIP7.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, 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';
2
+ import { C as CapabilityRegistry, P as PluginContext } from '../base-ClPlfxgA.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, g as PluginViewerTarget, T as ToolbarRegistration, h as ToolbarToolProps, V as VALID_CAPABILITIES, i as ViewerTabRegistration } from '../base-ClPlfxgA.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-EE4HWIP7.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, 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';
2
+ import { C as CapabilityRegistry, P as PluginContext } from '../base-ClPlfxgA.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, g as PluginViewerTarget, T as ToolbarRegistration, h as ToolbarToolProps, V as VALID_CAPABILITIES, i as ViewerTabRegistration } from '../base-ClPlfxgA.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-EE4HWIP7.js";
4
+ } from "../chunk-C7KO3OP7.js";
5
5
  export {
6
6
  PLUGIN_HOST_API,
7
7
  VALID_CAPABILITIES
@@ -1,170 +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
- 'data.pages',
19
- 'viewer.tabs',
20
- 'ui.dialogs',
21
- 'map.tools',
22
- 'bim.tools',
23
- 'pointcloud.tools',
24
- 'map.legends',
25
- ]
26
-
27
- export const PLUGIN_HOST_API: 1
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
-
46
- export function validateManifest(manifest: unknown): { valid: boolean; errors: string[] }
47
-
48
- // Generic because an ambient block cannot import `PluginEntry` from the kit's own entries,
49
- // and restating it would give a plugin two definitions. The call site behaves identically.
50
- export function resolvePluginEntry<E>(entry: E | (() => Promise<E>)): Promise<E>
51
- }
52
-
53
- declare module '@collabdt/core/plugins-sdk/config' {
54
- /** The plugin's config for this organization. Generic so a plugin can type its own shape. */
55
- export function usePluginConfig<
56
- T extends Record<string, unknown> = Record<string, unknown>,
57
- >(): T
58
- /** The calling plugin's id, from the scope its capability host established. */
59
- export function usePluginId(): string
60
- }
61
-
62
- declare module '@collabdt/core/plugins-sdk/messages' {
63
- export type PluginTranslator = (key: string, fallback?: string) => string
64
-
65
- /** A `t()` scoped to the calling plugin's own namespace. */
66
- export function usePluginTranslations(): PluginTranslator
67
-
68
- /** One piece of plugin text. All three parameters are required, matching core. */
69
- export function usePluginMessage(pluginId: string, key: string, fallback: string): string
70
-
71
- // Narrowed to a plain callable: typing next-intl's translator faithfully would drag
72
- // next-intl into a plugin's dependencies.
73
- export function useCoreTranslations(
74
- namespace: string,
75
- ): (key: string, values?: Record<string, unknown>) => string
76
- }
77
-
78
- declare module '@collabdt/core/plugins-sdk/store' {
79
- /** One stored document, as the owning plugin sees it. */
80
- export interface PluginDocument<T> {
81
- /** The plugin's own stable identifier for this document. */
82
- key: string
83
- data: T
84
- updatedAt: string | Date
85
- }
86
-
87
- export interface PluginStore<T> {
88
- items: PluginDocument<T>[]
89
- isLoading: boolean
90
- isError: unknown
91
- /** One document by key, or undefined. */
92
- get: (key: string) => PluginDocument<T> | undefined
93
- /** Create or replace a document. Keyed writes are upserts, not appends. */
94
- put: (key: string, data: T) => Promise<void>
95
- remove: (key: string) => Promise<void>
96
- }
97
-
98
- /** Storage scoped by organization, plugin and collection. `T` is your declaration, not a guarantee. */
99
- export function usePluginStore<T = unknown>(collection: string): PluginStore<T>
100
- }
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
-
126
- declare module '@collabdt/core/plugins-sdk/components' {
127
- // Shapes come from `./components`, a real module here, which is what lets core's
128
- // pluginKitComponents.test.ts compare these declarations against the real components.
129
- //
130
- // Inline `import('./components')` rather than a top-level import: an import declaration
131
- // inside an ambient module cannot use a relative specifier (TS2439), and skipLibCheck hides
132
- // that from everyone until a consumer turns it off.
133
-
134
- export type ButtonProps = import('./components').ButtonProps
135
- export const Button: import('./components').ButtonComponent
136
-
137
- export const Input: import('./components').InputComponent
138
-
139
- export type BadgeProps = import('./components').BadgeProps
140
- export const Badge: import('./components').BadgeComponent
141
-
142
- export type SeparatorProps = import('./components').SeparatorProps
143
- export const Separator: import('./components').SeparatorComponent
144
-
145
- export const Card: import('./components').CardComponent
146
- export const CardHeader: import('./components').CardComponent
147
- export const CardTitle: import('./components').CardComponent
148
- export const CardDescription: import('./components').CardComponent
149
- export const CardContent: import('./components').CardComponent
150
- export const CardFooter: import('./components').CardComponent
151
-
152
- export type DialogProps = import('./components').DialogProps
153
- export const Dialog: import('./components').DialogComponent
154
-
155
- export type DialogTriggerProps = import('./components').DialogTriggerProps
156
- export const DialogTrigger: import('./components').DialogTriggerComponent
157
- export const DialogClose: import('./components').DialogTriggerComponent
158
-
159
- export type DialogContentProps = import('./components').DialogContentProps
160
- export const DialogContent: import('./components').DialogContentComponent
161
-
162
- export const DialogHeader: import('./components').DialogSectionComponent
163
- export const DialogFooter: import('./components').DialogSectionComponent
164
-
165
- export type DialogTitleProps = import('./components').DialogTitleProps
166
- export const DialogTitle: import('./components').DialogTitleComponent
167
-
168
- export type DialogDescriptionProps = import('./components').DialogDescriptionProps
169
- export const DialogDescription: import('./components').DialogDescriptionComponent
170
- }
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
+ }
@@ -1,5 +1,5 @@
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';
1
+ import { C as CapabilityRegistry, P as PluginContext } from '../base-ClPlfxgA.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, g as PluginViewerTarget, T as ToolbarRegistration, h as ToolbarToolProps, V as VALID_CAPABILITIES, i as ViewerTabRegistration } from '../base-ClPlfxgA.js';
3
3
  import 'react';
4
4
 
5
5
  /** `CapabilityRegistry` for the surfaces that bind no viewer props. */
package/dist/types/ui.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  PLUGIN_HOST_API,
3
3
  VALID_CAPABILITIES
4
- } from "../chunk-EE4HWIP7.js";
4
+ } from "../chunk-C7KO3OP7.js";
5
5
  export {
6
6
  PLUGIN_HOST_API,
7
7
  VALID_CAPABILITIES
package/package.json CHANGED
@@ -1,63 +1,72 @@
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
- }
1
+ {
2
+ "name": "@collabdt/plugin-kit",
3
+ "version": "0.4.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/data": {
22
+ "types": "./dist/types/data.d.ts",
23
+ "default": "./dist/types/data.js"
24
+ },
25
+ "./types/map": {
26
+ "types": "./dist/types/map.d.ts",
27
+ "default": "./dist/types/map.js"
28
+ },
29
+ "./types/bim": {
30
+ "types": "./dist/types/bim.d.ts",
31
+ "default": "./dist/types/bim.js"
32
+ },
33
+ "./types/pointcloud": {
34
+ "types": "./dist/types/pointcloud.d.ts",
35
+ "default": "./dist/types/pointcloud.js"
36
+ },
37
+ "./types/legend": {
38
+ "types": "./dist/types/legend.d.ts",
39
+ "default": "./dist/types/legend.js"
40
+ },
41
+ "./types/ui": {
42
+ "types": "./dist/types/ui.d.ts",
43
+ "default": "./dist/types/ui.js"
44
+ }
45
+ },
46
+ "scripts": {
47
+ "build": "tsup && node scripts/shipAmbientTypes.mjs",
48
+ "prepublishOnly": "npm run build",
49
+ "test": "vitest run"
50
+ },
51
+ "peerDependencies": {
52
+ "@thatopen/components": ">=3.4",
53
+ "@types/react": ">=18",
54
+ "maplibre-gl": ">=5",
55
+ "tsup": ">=8"
56
+ },
57
+ "peerDependenciesMeta": {
58
+ "@thatopen/components": {
59
+ "optional": true
60
+ },
61
+ "maplibre-gl": {
62
+ "optional": true
63
+ }
64
+ },
65
+ "devDependencies": {
66
+ "@thatopen/components": "~3.4.0",
67
+ "maplibre-gl": "^5.24.0",
68
+ "tsup": "^8.5.0",
69
+ "typescript": "^5.9.3",
70
+ "vitest": "^4.1.8"
71
+ }
72
+ }