@collabdt/plugin-kit 0.1.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/LICENSE +662 -0
- package/README.md +131 -0
- package/dist/base-BljPi_dT.d.ts +45 -0
- package/dist/chunk-CVHASC2D.js +15 -0
- package/dist/index.d.ts +37 -0
- package/dist/index.js +191 -0
- package/dist/types/bim.d.ts +40 -0
- package/dist/types/bim.js +8 -0
- package/dist/types/components.d.ts +53 -0
- package/dist/types/components.js +0 -0
- package/dist/types/legend.d.ts +28 -0
- package/dist/types/legend.js +8 -0
- package/dist/types/map.d.ts +16 -0
- package/dist/types/map.js +8 -0
- package/dist/types/pointcloud.d.ts +16 -0
- package/dist/types/pointcloud.js +8 -0
- package/dist/types/sdkModules.d.ts +128 -0
- package/package.json +63 -0
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
// SPDX-License-Identifier: AGPL-3.0-or-later
|
|
2
|
+
// Copyright (C) 2025 Collab Digital Twins
|
|
3
|
+
|
|
4
|
+
// Types for the SDK modules a plugin imports at runtime but never installs: the specifier is
|
|
5
|
+
// marked external, and the browser resolves it through the host's import map. Shipping
|
|
6
|
+
// declarations for implementations this package does not contain is the point.
|
|
7
|
+
//
|
|
8
|
+
// Module and export names come from PLUGIN_RUNTIME_SHIMS in core; signatures are copied from
|
|
9
|
+
// core's sdk/. React's shims are absent because they have real published types.
|
|
10
|
+
//
|
|
11
|
+
// No top-level import or export, deliberately: that keeps this a global script, the only place
|
|
12
|
+
// TypeScript accepts an ambient declaration for a specifier it cannot resolve.
|
|
13
|
+
|
|
14
|
+
declare module '@collabdt/core/plugins-sdk' {
|
|
15
|
+
// Only the values the shim re-exports. The SDK's types live in the surface entries, so each
|
|
16
|
+
// shape has one definition and it is the one a plugin already imports.
|
|
17
|
+
export const VALID_CAPABILITIES: readonly [
|
|
18
|
+
'sidebar.items',
|
|
19
|
+
'viewer.panels',
|
|
20
|
+
'map.tools',
|
|
21
|
+
'bim.tools',
|
|
22
|
+
'pointcloud.tools',
|
|
23
|
+
'map.legends',
|
|
24
|
+
]
|
|
25
|
+
|
|
26
|
+
export const PLUGIN_HOST_API: 1
|
|
27
|
+
|
|
28
|
+
export function validateManifest(manifest: unknown): { valid: boolean; errors: string[] }
|
|
29
|
+
|
|
30
|
+
// Generic because an ambient block cannot import `PluginEntry` from the kit's own entries,
|
|
31
|
+
// and restating it would give a plugin two definitions. The call site behaves identically.
|
|
32
|
+
export function resolvePluginEntry<E>(entry: E | (() => Promise<E>)): Promise<E>
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
declare module '@collabdt/core/plugins-sdk/config' {
|
|
36
|
+
/** The plugin's config for this organization. Generic so a plugin can type its own shape. */
|
|
37
|
+
export function usePluginConfig<
|
|
38
|
+
T extends Record<string, unknown> = Record<string, unknown>,
|
|
39
|
+
>(): T
|
|
40
|
+
/** The calling plugin's id, from the scope its capability host established. */
|
|
41
|
+
export function usePluginId(): string
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
declare module '@collabdt/core/plugins-sdk/messages' {
|
|
45
|
+
export type PluginTranslator = (key: string, fallback?: string) => string
|
|
46
|
+
|
|
47
|
+
/** A `t()` scoped to the calling plugin's own namespace. */
|
|
48
|
+
export function usePluginTranslations(): PluginTranslator
|
|
49
|
+
|
|
50
|
+
/** One piece of plugin text. All three parameters are required, matching core. */
|
|
51
|
+
export function usePluginMessage(pluginId: string, key: string, fallback: string): string
|
|
52
|
+
|
|
53
|
+
// Narrowed to a plain callable: typing next-intl's translator faithfully would drag
|
|
54
|
+
// next-intl into a plugin's dependencies.
|
|
55
|
+
export function useCoreTranslations(
|
|
56
|
+
namespace: string,
|
|
57
|
+
): (key: string, values?: Record<string, unknown>) => string
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
declare module '@collabdt/core/plugins-sdk/store' {
|
|
61
|
+
/** One stored document, as the owning plugin sees it. */
|
|
62
|
+
export interface PluginDocument<T> {
|
|
63
|
+
/** The plugin's own stable identifier for this document. */
|
|
64
|
+
key: string
|
|
65
|
+
data: T
|
|
66
|
+
updatedAt: string | Date
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export interface PluginStore<T> {
|
|
70
|
+
items: PluginDocument<T>[]
|
|
71
|
+
isLoading: boolean
|
|
72
|
+
isError: unknown
|
|
73
|
+
/** One document by key, or undefined. */
|
|
74
|
+
get: (key: string) => PluginDocument<T> | undefined
|
|
75
|
+
/** Create or replace a document. Keyed writes are upserts, not appends. */
|
|
76
|
+
put: (key: string, data: T) => Promise<void>
|
|
77
|
+
remove: (key: string) => Promise<void>
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/** Storage scoped by organization, plugin and collection. `T` is your declaration, not a guarantee. */
|
|
81
|
+
export function usePluginStore<T = unknown>(collection: string): PluginStore<T>
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
declare module '@collabdt/core/plugins-sdk/components' {
|
|
85
|
+
// Shapes come from `./components`, a real module here, which is what lets core's
|
|
86
|
+
// pluginKitComponents.test.ts compare these declarations against the real components.
|
|
87
|
+
//
|
|
88
|
+
// Inline `import('./components')` rather than a top-level import: an import declaration
|
|
89
|
+
// inside an ambient module cannot use a relative specifier (TS2439), and skipLibCheck hides
|
|
90
|
+
// that from everyone until a consumer turns it off.
|
|
91
|
+
|
|
92
|
+
export type ButtonProps = import('./components').ButtonProps
|
|
93
|
+
export const Button: import('./components').ButtonComponent
|
|
94
|
+
|
|
95
|
+
export const Input: import('./components').InputComponent
|
|
96
|
+
|
|
97
|
+
export type BadgeProps = import('./components').BadgeProps
|
|
98
|
+
export const Badge: import('./components').BadgeComponent
|
|
99
|
+
|
|
100
|
+
export type SeparatorProps = import('./components').SeparatorProps
|
|
101
|
+
export const Separator: import('./components').SeparatorComponent
|
|
102
|
+
|
|
103
|
+
export const Card: import('./components').CardComponent
|
|
104
|
+
export const CardHeader: import('./components').CardComponent
|
|
105
|
+
export const CardTitle: import('./components').CardComponent
|
|
106
|
+
export const CardDescription: import('./components').CardComponent
|
|
107
|
+
export const CardContent: import('./components').CardComponent
|
|
108
|
+
export const CardFooter: import('./components').CardComponent
|
|
109
|
+
|
|
110
|
+
export type DialogProps = import('./components').DialogProps
|
|
111
|
+
export const Dialog: import('./components').DialogComponent
|
|
112
|
+
|
|
113
|
+
export type DialogTriggerProps = import('./components').DialogTriggerProps
|
|
114
|
+
export const DialogTrigger: import('./components').DialogTriggerComponent
|
|
115
|
+
export const DialogClose: import('./components').DialogTriggerComponent
|
|
116
|
+
|
|
117
|
+
export type DialogContentProps = import('./components').DialogContentProps
|
|
118
|
+
export const DialogContent: import('./components').DialogContentComponent
|
|
119
|
+
|
|
120
|
+
export const DialogHeader: import('./components').DialogSectionComponent
|
|
121
|
+
export const DialogFooter: import('./components').DialogSectionComponent
|
|
122
|
+
|
|
123
|
+
export type DialogTitleProps = import('./components').DialogTitleProps
|
|
124
|
+
export const DialogTitle: import('./components').DialogTitleComponent
|
|
125
|
+
|
|
126
|
+
export type DialogDescriptionProps = import('./components').DialogDescriptionProps
|
|
127
|
+
export const DialogDescription: import('./components').DialogDescriptionComponent
|
|
128
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +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
|
+
}
|