@collabdt/core 0.13.1 → 0.13.3
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/dist/core/components/viewers/map/MapViewer.d.ts.map +1 -1
- package/dist/core/components/viewers/map/MapViewer.js +0 -4
- package/dist/core/components/viewers/map/MapViewer.js.map +1 -1
- package/dist/core/components/viewers/map/datasets/DatasetDetails.d.ts.map +1 -1
- package/dist/core/components/viewers/map/datasets/DatasetDetails.js +6 -4
- package/dist/core/components/viewers/map/datasets/DatasetDetails.js.map +1 -1
- package/dist/core/components/viewers/map/datasets/DatasetManager/index.d.ts.map +1 -1
- package/dist/core/components/viewers/map/datasets/DatasetManager/index.js +100 -53
- package/dist/core/components/viewers/map/datasets/DatasetManager/index.js.map +1 -1
- package/dist/core/components/viewers/map/datasets/DatasetManager/src/WmsDatasetControls.d.ts +8 -0
- package/dist/core/components/viewers/map/datasets/DatasetManager/src/WmsDatasetControls.d.ts.map +1 -0
- package/dist/core/components/viewers/map/datasets/DatasetManager/src/WmsDatasetControls.js +45 -0
- package/dist/core/components/viewers/map/datasets/DatasetManager/src/WmsDatasetControls.js.map +1 -0
- package/dist/core/components/viewers/map/datasets/index.d.ts.map +1 -1
- package/dist/core/components/viewers/map/datasets/index.js +4 -4
- package/dist/core/components/viewers/map/datasets/index.js.map +1 -1
- package/dist/core/components/viewers/map/datasets/src/wmsActiveTime.d.ts +5 -0
- package/dist/core/components/viewers/map/datasets/src/wmsActiveTime.d.ts.map +1 -0
- package/dist/core/components/viewers/map/datasets/src/wmsActiveTime.js +33 -0
- package/dist/core/components/viewers/map/datasets/src/wmsActiveTime.js.map +1 -0
- package/dist/core/components/viewers/map/src/MapLayers/src/OpenDataLayer/src/WmsTimeControl.d.ts +5 -4
- package/dist/core/components/viewers/map/src/MapLayers/src/OpenDataLayer/src/WmsTimeControl.d.ts.map +1 -1
- package/dist/core/components/viewers/map/src/MapLayers/src/OpenDataLayer/src/WmsTimeControl.js +55 -76
- package/dist/core/components/viewers/map/src/MapLayers/src/OpenDataLayer/src/WmsTimeControl.js.map +1 -1
- package/dist/core/components/viewers/map/src/MapLayers/src/OpenDataLayer/src/index.d.ts.map +1 -1
- package/dist/core/components/viewers/map/src/MapLayers/src/OpenDataLayer/src/index.js +7 -43
- package/dist/core/components/viewers/map/src/MapLayers/src/OpenDataLayer/src/index.js.map +1 -1
- package/dist/core/components/viewers/map/src/MapSidebar/src/LayersTab/index.d.ts.map +1 -1
- package/dist/core/components/viewers/map/src/MapSidebar/src/LayersTab/index.js +9 -4
- package/dist/core/components/viewers/map/src/MapSidebar/src/LayersTab/index.js.map +1 -1
- package/dist/core/components/viewers/shared/legends/PluginLegendSection.d.ts +16 -0
- package/dist/core/components/viewers/shared/legends/PluginLegendSection.d.ts.map +1 -0
- package/dist/core/components/viewers/shared/legends/PluginLegendSection.js +86 -0
- package/dist/core/components/viewers/shared/legends/PluginLegendSection.js.map +1 -0
- package/dist/core/components/viewers/shared/legends/ViewerLegendHost.d.ts +1 -1
- package/dist/core/components/viewers/shared/legends/ViewerLegendHost.d.ts.map +1 -1
- package/dist/core/components/viewers/shared/legends/ViewerLegendHost.js +10 -82
- package/dist/core/components/viewers/shared/legends/ViewerLegendHost.js.map +1 -1
- package/dist/core/components/viewers/shared/legends/usePluginLegends.d.ts +13 -0
- package/dist/core/components/viewers/shared/legends/usePluginLegends.d.ts.map +1 -0
- package/dist/core/components/viewers/shared/legends/usePluginLegends.js +57 -0
- package/dist/core/components/viewers/shared/legends/usePluginLegends.js.map +1 -0
- package/dist/core/i18n/messages/en.json +2 -1
- package/dist/core/i18n/messages/es.json +2 -1
- package/dist/core/i18n/messages/fr.json +2 -1
- package/dist/core/plugins/host/pluginDatasetId.d.ts +3 -0
- package/dist/core/plugins/host/pluginDatasetId.d.ts.map +1 -0
- package/dist/core/plugins/host/pluginDatasetId.js +7 -0
- package/dist/core/plugins/host/pluginDatasetId.js.map +1 -0
- package/dist/core/plugins/host/pluginDatasetLookup.d.ts +6 -0
- package/dist/core/plugins/host/pluginDatasetLookup.d.ts.map +1 -0
- package/dist/core/plugins/host/pluginDatasetLookup.js +9 -0
- package/dist/core/plugins/host/pluginDatasetLookup.js.map +1 -0
- package/dist/core/plugins/host/pluginDatasets.d.ts +4 -0
- package/dist/core/plugins/host/pluginDatasets.d.ts.map +1 -0
- package/dist/core/plugins/host/pluginDatasets.js +17 -0
- package/dist/core/plugins/host/pluginDatasets.js.map +1 -0
- package/dist/core/plugins/host/provider.d.ts.map +1 -1
- package/dist/core/plugins/host/provider.js +7 -1
- package/dist/core/plugins/host/provider.js.map +1 -1
- package/dist/core/plugins/host/runtimeShims.d.ts.map +1 -1
- package/dist/core/plugins/host/runtimeShims.js +2 -1
- package/dist/core/plugins/host/runtimeShims.js.map +1 -1
- package/dist/core/plugins/host/toPluginDataset.d.ts +10 -0
- package/dist/core/plugins/host/toPluginDataset.d.ts.map +1 -0
- package/dist/core/plugins/host/toPluginDataset.js +68 -0
- package/dist/core/plugins/host/toPluginDataset.js.map +1 -0
- package/dist/core/plugins/sdk/data.d.ts +2 -0
- package/dist/core/plugins/sdk/data.d.ts.map +1 -1
- package/dist/core/plugins/sdk/data.js +2 -0
- package/dist/core/plugins/sdk/data.js.map +1 -1
- package/dist/core/plugins/sdk/datasets.d.ts +16 -0
- package/dist/core/plugins/sdk/datasets.d.ts.map +1 -0
- package/dist/core/plugins/sdk/datasets.js +33 -0
- package/dist/core/plugins/sdk/datasets.js.map +1 -0
- package/dist/core/plugins/sdk/types.d.ts +47 -1
- package/dist/core/plugins/sdk/types.d.ts.map +1 -1
- package/dist/core/plugins/sdk/types.js +2 -1
- package/dist/core/plugins/sdk/types.js.map +1 -1
- package/dist/core/types/datasetTypes.d.ts +1 -0
- package/dist/core/types/datasetTypes.d.ts.map +1 -1
- package/package.json +1 -1
- package/dist/core/components/viewers/map/datasets/src/builtinLiveDatasets.d.ts +0 -4
- package/dist/core/components/viewers/map/datasets/src/builtinLiveDatasets.d.ts.map +0 -1
- package/dist/core/components/viewers/map/datasets/src/builtinLiveDatasets.js +0 -43
- package/dist/core/components/viewers/map/datasets/src/builtinLiveDatasets.js.map +0 -1
|
@@ -1,67 +1,17 @@
|
|
|
1
1
|
'use client'
|
|
2
2
|
|
|
3
3
|
"use client";
|
|
4
|
-
var __defProp = Object.defineProperty;
|
|
5
|
-
var __defProps = Object.defineProperties;
|
|
6
|
-
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
7
|
-
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
8
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
|
-
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
10
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
11
|
-
var __spreadValues = (a, b) => {
|
|
12
|
-
for (var prop in b || (b = {}))
|
|
13
|
-
if (__hasOwnProp.call(b, prop))
|
|
14
|
-
__defNormalProp(a, prop, b[prop]);
|
|
15
|
-
if (__getOwnPropSymbols)
|
|
16
|
-
for (var prop of __getOwnPropSymbols(b)) {
|
|
17
|
-
if (__propIsEnum.call(b, prop))
|
|
18
|
-
__defNormalProp(a, prop, b[prop]);
|
|
19
|
-
}
|
|
20
|
-
return a;
|
|
21
|
-
};
|
|
22
|
-
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
23
|
-
var __objRest = (source, exclude) => {
|
|
24
|
-
var target = {};
|
|
25
|
-
for (var prop in source)
|
|
26
|
-
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
27
|
-
target[prop] = source[prop];
|
|
28
|
-
if (source != null && __getOwnPropSymbols)
|
|
29
|
-
for (var prop of __getOwnPropSymbols(source)) {
|
|
30
|
-
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
|
|
31
|
-
target[prop] = source[prop];
|
|
32
|
-
}
|
|
33
|
-
return target;
|
|
34
|
-
};
|
|
35
4
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
36
5
|
import { useTranslations } from "next-intl";
|
|
37
|
-
import * as React from "react";
|
|
38
|
-
import { usePluginConfigs, usePluginContributions } from "../../../../plugins/host/provider";
|
|
39
|
-
import { PluginScopeProvider } from "../../../../plugins/host/scope";
|
|
40
6
|
import { LegendCard } from "../../../ui/LegendCard";
|
|
7
|
+
import { legendKey, PluginLegendSection } from "./PluginLegendSection";
|
|
8
|
+
import { usePluginLegends } from "./usePluginLegends";
|
|
41
9
|
function ViewerLegendHost({ viewer }) {
|
|
42
|
-
const all = usePluginContributions("viewer.legends");
|
|
43
|
-
const configs = usePluginConfigs();
|
|
44
|
-
const registrations = React.useMemo(
|
|
45
|
-
() => all.filter((entry) => !entry.viewers || entry.viewers.includes(viewer)),
|
|
46
|
-
[all, viewer]
|
|
47
|
-
);
|
|
48
10
|
const t = useTranslations("MapLegend");
|
|
49
|
-
const
|
|
50
|
-
const
|
|
51
|
-
setActiveMap((prev) => prev[id] === active ? prev : __spreadProps(__spreadValues({}, prev), { [id]: active }));
|
|
52
|
-
}, []);
|
|
53
|
-
const activeCount = registrations.filter((r) => activeMap[r.id]).length;
|
|
11
|
+
const { registrations, configs, isActive, probes } = usePluginLegends(viewer);
|
|
12
|
+
const activeCount = registrations.filter(isActive).length;
|
|
54
13
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
55
|
-
|
|
56
|
-
ScopedLegendSection,
|
|
57
|
-
{
|
|
58
|
-
registration: r,
|
|
59
|
-
config: configs[r.pluginId],
|
|
60
|
-
onActiveChange: reportActive,
|
|
61
|
-
renderBody: false
|
|
62
|
-
},
|
|
63
|
-
`probe-${r.id}`
|
|
64
|
-
)) }),
|
|
14
|
+
probes,
|
|
65
15
|
activeCount > 0 && /* @__PURE__ */ jsx(
|
|
66
16
|
LegendCard,
|
|
67
17
|
{
|
|
@@ -69,40 +19,18 @@ function ViewerLegendHost({ viewer }) {
|
|
|
69
19
|
count: activeCount,
|
|
70
20
|
testId: "map-legend-card",
|
|
71
21
|
countTestId: "map-legend-count",
|
|
72
|
-
children: registrations.map((
|
|
73
|
-
|
|
22
|
+
children: registrations.map((registration) => /* @__PURE__ */ jsx(
|
|
23
|
+
PluginLegendSection,
|
|
74
24
|
{
|
|
75
|
-
registration
|
|
76
|
-
config: configs[
|
|
77
|
-
onActiveChange: reportActive,
|
|
78
|
-
renderBody: true
|
|
25
|
+
registration,
|
|
26
|
+
config: configs[registration.pluginId]
|
|
79
27
|
},
|
|
80
|
-
|
|
28
|
+
legendKey(registration)
|
|
81
29
|
))
|
|
82
30
|
}
|
|
83
31
|
)
|
|
84
32
|
] });
|
|
85
33
|
}
|
|
86
|
-
function ScopedLegendSection(_a) {
|
|
87
|
-
var _b = _a, { registration, config } = _b, rest = __objRest(_b, ["registration", "config"]);
|
|
88
|
-
return /* @__PURE__ */ jsx(PluginScopeProvider, { pluginId: registration.pluginId, config, children: /* @__PURE__ */ jsx(LegendSection, __spreadValues({ registration }, rest)) });
|
|
89
|
-
}
|
|
90
|
-
function LegendSection({ registration, onActiveChange, renderBody }) {
|
|
91
|
-
const t = useTranslations("MapLegend");
|
|
92
|
-
const { active, title, unavailable, rows } = registration.useLegend();
|
|
93
|
-
React.useEffect(() => {
|
|
94
|
-
onActiveChange(registration.id, active);
|
|
95
|
-
}, [active, registration.id, onActiveChange]);
|
|
96
|
-
if (!renderBody || !active) return null;
|
|
97
|
-
return /* @__PURE__ */ jsxs("div", { className: "px-3 py-2 border-t first:border-t-0", children: [
|
|
98
|
-
/* @__PURE__ */ jsx("div", { className: "font-semibold text-xs mb-1", children: title != null ? title : registration.title }),
|
|
99
|
-
unavailable ? /* @__PURE__ */ jsx("div", { className: "rounded bg-red-100 text-red-800 px-2 py-1 text-[11px] font-medium", children: t("feedUnavailable") }) : /* @__PURE__ */ jsx("ul", { className: "space-y-1", children: rows.map((row) => /* @__PURE__ */ jsxs("li", { className: "flex items-center gap-2 text-xs", children: [
|
|
100
|
-
/* @__PURE__ */ jsx("span", { "aria-hidden": "true", className: "inline-block h-3 w-3 rounded-sm shrink-0", style: { backgroundColor: row.color } }),
|
|
101
|
-
/* @__PURE__ */ jsx("span", { className: "flex-1", children: row.label }),
|
|
102
|
-
row.count !== void 0 && /* @__PURE__ */ jsx("span", { className: "tabular-nums opacity-70", children: row.count })
|
|
103
|
-
] }, row.label)) })
|
|
104
|
-
] });
|
|
105
|
-
}
|
|
106
34
|
export {
|
|
107
35
|
ViewerLegendHost
|
|
108
36
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../src/core/components/viewers/shared/legends/ViewerLegendHost.tsx"],"sourcesContent":["'use client'\n\n// SPDX-License-Identifier: AGPL-3.0-or-later\n// Copyright (C) 2025 Collab Digital Twins\n\nimport { useTranslations } from 'next-intl'\nimport * as React from 'react'\n\nimport {
|
|
1
|
+
{"version":3,"sources":["../../../../../../src/core/components/viewers/shared/legends/ViewerLegendHost.tsx"],"sourcesContent":["'use client'\n\n// SPDX-License-Identifier: AGPL-3.0-or-later\n// Copyright (C) 2025 Collab Digital Twins\n\nimport { useTranslations } from 'next-intl'\nimport * as React from 'react'\n\nimport { LegendCard } from '../../../ui/LegendCard'\n\nimport { legendKey, PluginLegendSection } from './PluginLegendSection'\nimport { usePluginLegends } from './usePluginLegends'\n\nimport type { ViewerNames } from '../../../../types/dbTypes'\n\n/**\n * One shared legend card per viewer, with a titled section per active `viewer.legends`\n * registration. The map stacks its legends in the applied-layers card instead.\n */\nexport function ViewerLegendHost({ viewer }: { viewer: ViewerNames }) {\n const t = useTranslations('MapLegend')\n const { registrations, configs, isActive, probes } = usePluginLegends(viewer)\n\n const activeCount = registrations.filter(isActive).length\n\n return (\n <>\n {probes}\n\n {activeCount > 0 && (\n <LegendCard\n title={activeCount === 1 ? t('title') : t('titlePlural')}\n count={activeCount}\n testId=\"map-legend-card\"\n countTestId=\"map-legend-count\"\n >\n {registrations.map(registration => (\n <PluginLegendSection\n key={legendKey(registration)}\n registration={registration}\n config={configs[registration.pluginId]}\n />\n ))}\n </LegendCard>\n )}\n </>\n )\n}\n"],"mappings":";AA0BI,mBAWQ,KAXR;AArBJ,SAAS,uBAAuB;AAGhC,SAAS,kBAAkB;AAE3B,SAAS,WAAW,2BAA2B;AAC/C,SAAS,wBAAwB;AAQ1B,SAAS,iBAAiB,EAAE,OAAO,GAA4B;AACpE,QAAM,IAAI,gBAAgB,WAAW;AACrC,QAAM,EAAE,eAAe,SAAS,UAAU,OAAO,IAAI,iBAAiB,MAAM;AAE5E,QAAM,cAAc,cAAc,OAAO,QAAQ,EAAE;AAEnD,SACE,iCACG;AAAA;AAAA,IAEA,cAAc,KACb;AAAA,MAAC;AAAA;AAAA,QACC,OAAO,gBAAgB,IAAI,EAAE,OAAO,IAAI,EAAE,aAAa;AAAA,QACvD,OAAO;AAAA,QACP,QAAO;AAAA,QACP,aAAY;AAAA,QAEX,wBAAc,IAAI,kBACjB;AAAA,UAAC;AAAA;AAAA,YAEC;AAAA,YACA,QAAQ,QAAQ,aAAa,QAAQ;AAAA;AAAA,UAFhC,UAAU,YAAY;AAAA,QAG7B,CACD;AAAA;AAAA,IACH;AAAA,KAEJ;AAEJ;","names":[]}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import type { LegendContribution } from './PluginLegendSection';
|
|
3
|
+
import type { ViewerNames } from '../../../../types/dbTypes';
|
|
4
|
+
export interface PluginLegends {
|
|
5
|
+
registrations: LegendContribution[];
|
|
6
|
+
configs: Record<string, Record<string, unknown>>;
|
|
7
|
+
isActive: (registration: LegendContribution) => boolean;
|
|
8
|
+
/** Render once: keeps every legend's hook running, and its `active` known, while no card shows it. */
|
|
9
|
+
probes: React.ReactNode;
|
|
10
|
+
}
|
|
11
|
+
/** The `viewer.legends` that belong in `viewer`, and which of them currently have something to say. */
|
|
12
|
+
export declare function usePluginLegends(viewer: ViewerNames): PluginLegends;
|
|
13
|
+
//# sourceMappingURL=usePluginLegends.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"usePluginLegends.d.ts","sourceRoot":"","sources":["../../../../../../src/core/components/viewers/shared/legends/usePluginLegends.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAM9B,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAA;AAC/D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAA;AAE5D,MAAM,WAAW,aAAa;IAC5B,aAAa,EAAE,kBAAkB,EAAE,CAAA;IACnC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAA;IAChD,QAAQ,EAAE,CAAC,YAAY,EAAE,kBAAkB,KAAK,OAAO,CAAA;IACvD,sGAAsG;IACtG,MAAM,EAAE,KAAK,CAAC,SAAS,CAAA;CACxB;AAED,uGAAuG;AACvG,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,WAAW,GAAG,aAAa,CAmCnE"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
|
|
3
|
+
"use client";
|
|
4
|
+
var __defProp = Object.defineProperty;
|
|
5
|
+
var __defProps = Object.defineProperties;
|
|
6
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
7
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
8
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
10
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
11
|
+
var __spreadValues = (a, b) => {
|
|
12
|
+
for (var prop in b || (b = {}))
|
|
13
|
+
if (__hasOwnProp.call(b, prop))
|
|
14
|
+
__defNormalProp(a, prop, b[prop]);
|
|
15
|
+
if (__getOwnPropSymbols)
|
|
16
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
17
|
+
if (__propIsEnum.call(b, prop))
|
|
18
|
+
__defNormalProp(a, prop, b[prop]);
|
|
19
|
+
}
|
|
20
|
+
return a;
|
|
21
|
+
};
|
|
22
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
23
|
+
import { jsx } from "react/jsx-runtime";
|
|
24
|
+
import * as React from "react";
|
|
25
|
+
import { usePluginConfigs, usePluginContributions } from "../../../../plugins/host/provider";
|
|
26
|
+
import { legendKey, PluginLegendSection } from "./PluginLegendSection";
|
|
27
|
+
function usePluginLegends(viewer) {
|
|
28
|
+
const all = usePluginContributions("viewer.legends");
|
|
29
|
+
const configs = usePluginConfigs();
|
|
30
|
+
const registrations = React.useMemo(
|
|
31
|
+
() => all.filter((entry) => !entry.viewers || entry.viewers.includes(viewer)),
|
|
32
|
+
[all, viewer]
|
|
33
|
+
);
|
|
34
|
+
const [activeMap, setActiveMap] = React.useState({});
|
|
35
|
+
const reportActive = React.useCallback((key, active) => {
|
|
36
|
+
setActiveMap((previous) => previous[key] === active ? previous : __spreadProps(__spreadValues({}, previous), { [key]: active }));
|
|
37
|
+
}, []);
|
|
38
|
+
const isActive = React.useCallback(
|
|
39
|
+
(registration) => Boolean(activeMap[legendKey(registration)]),
|
|
40
|
+
[activeMap]
|
|
41
|
+
);
|
|
42
|
+
const probes = /* @__PURE__ */ jsx("div", { className: "hidden", children: registrations.map((registration) => /* @__PURE__ */ jsx(
|
|
43
|
+
PluginLegendSection,
|
|
44
|
+
{
|
|
45
|
+
registration,
|
|
46
|
+
config: configs[registration.pluginId],
|
|
47
|
+
onActiveChange: reportActive,
|
|
48
|
+
renderBody: false
|
|
49
|
+
},
|
|
50
|
+
`probe-${legendKey(registration)}`
|
|
51
|
+
)) });
|
|
52
|
+
return { registrations, configs, isActive, probes };
|
|
53
|
+
}
|
|
54
|
+
export {
|
|
55
|
+
usePluginLegends
|
|
56
|
+
};
|
|
57
|
+
//# sourceMappingURL=usePluginLegends.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../../src/core/components/viewers/shared/legends/usePluginLegends.tsx"],"sourcesContent":["'use client'\n\n// SPDX-License-Identifier: AGPL-3.0-or-later\n// Copyright (C) 2025 Collab Digital Twins\n\nimport * as React from 'react'\n\nimport { usePluginConfigs, usePluginContributions } from '../../../../plugins/host/provider'\n\nimport { legendKey, PluginLegendSection } from './PluginLegendSection'\n\nimport type { LegendContribution } from './PluginLegendSection'\nimport type { ViewerNames } from '../../../../types/dbTypes'\n\nexport interface PluginLegends {\n registrations: LegendContribution[]\n configs: Record<string, Record<string, unknown>>\n isActive: (registration: LegendContribution) => boolean\n /** Render once: keeps every legend's hook running, and its `active` known, while no card shows it. */\n probes: React.ReactNode\n}\n\n/** The `viewer.legends` that belong in `viewer`, and which of them currently have something to say. */\nexport function usePluginLegends(viewer: ViewerNames): PluginLegends {\n const all = usePluginContributions('viewer.legends')\n const configs = usePluginConfigs()\n\n const registrations = React.useMemo(\n () => all.filter(entry => !entry.viewers || entry.viewers.includes(viewer)),\n [all, viewer],\n )\n\n const [activeMap, setActiveMap] = React.useState<Record<string, boolean>>({})\n\n const reportActive = React.useCallback((key: string, active: boolean) => {\n setActiveMap(previous => (previous[key] === active ? previous : { ...previous, [key]: active }))\n }, [])\n\n const isActive = React.useCallback(\n (registration: LegendContribution) => Boolean(activeMap[legendKey(registration)]),\n [activeMap],\n )\n\n const probes = (\n <div className=\"hidden\">\n {registrations.map(registration => (\n <PluginLegendSection\n key={`probe-${legendKey(registration)}`}\n registration={registration}\n config={configs[registration.pluginId]}\n onActiveChange={reportActive}\n renderBody={false}\n />\n ))}\n </div>\n )\n\n return { registrations, configs, isActive, probes }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AA8CQ;AAzCR,YAAY,WAAW;AAEvB,SAAS,kBAAkB,8BAA8B;AAEzD,SAAS,WAAW,2BAA2B;AAcxC,SAAS,iBAAiB,QAAoC;AACnE,QAAM,MAAM,uBAAuB,gBAAgB;AACnD,QAAM,UAAU,iBAAiB;AAEjC,QAAM,gBAAgB,MAAM;AAAA,IAC1B,MAAM,IAAI,OAAO,WAAS,CAAC,MAAM,WAAW,MAAM,QAAQ,SAAS,MAAM,CAAC;AAAA,IAC1E,CAAC,KAAK,MAAM;AAAA,EACd;AAEA,QAAM,CAAC,WAAW,YAAY,IAAI,MAAM,SAAkC,CAAC,CAAC;AAE5E,QAAM,eAAe,MAAM,YAAY,CAAC,KAAa,WAAoB;AACvE,iBAAa,cAAa,SAAS,GAAG,MAAM,SAAS,WAAW,iCAAK,WAAL,EAAe,CAAC,GAAG,GAAG,OAAO,EAAE;AAAA,EACjG,GAAG,CAAC,CAAC;AAEL,QAAM,WAAW,MAAM;AAAA,IACrB,CAAC,iBAAqC,QAAQ,UAAU,UAAU,YAAY,CAAC,CAAC;AAAA,IAChF,CAAC,SAAS;AAAA,EACZ;AAEA,QAAM,SACJ,oBAAC,SAAI,WAAU,UACZ,wBAAc,IAAI,kBACjB;AAAA,IAAC;AAAA;AAAA,MAEC;AAAA,MACA,QAAQ,QAAQ,aAAa,QAAQ;AAAA,MACrC,gBAAgB;AAAA,MAChB,YAAY;AAAA;AAAA,IAJP,SAAS,UAAU,YAAY,CAAC;AAAA,EAKvC,CACD,GACH;AAGF,SAAO,EAAE,eAAe,SAAS,UAAU,OAAO;AACpD;","names":[]}
|
|
@@ -447,7 +447,8 @@
|
|
|
447
447
|
"MapLegend": {
|
|
448
448
|
"title": "Legend",
|
|
449
449
|
"titlePlural": "Legends",
|
|
450
|
-
"feedUnavailable": "Feed unavailable"
|
|
450
|
+
"feedUnavailable": "Feed unavailable",
|
|
451
|
+
"feedUnavailableToast": "{title}: the live feed is unreachable right now, so the layer may be missing or out of date."
|
|
451
452
|
},
|
|
452
453
|
"Datasets": {
|
|
453
454
|
"failedFetchError": "Failed to fetch datasets.",
|
|
@@ -447,7 +447,8 @@
|
|
|
447
447
|
"MapLegend": {
|
|
448
448
|
"title": "Leyenda",
|
|
449
449
|
"titlePlural": "Leyendas",
|
|
450
|
-
"feedUnavailable": "Fuente no disponible"
|
|
450
|
+
"feedUnavailable": "Fuente no disponible",
|
|
451
|
+
"feedUnavailableToast": "{title}: la fuente en vivo no está disponible en este momento; la capa puede faltar o estar desactualizada."
|
|
451
452
|
},
|
|
452
453
|
"Datasets": {
|
|
453
454
|
"failedFetchError": "Error al obtener conjuntos de datos.",
|
|
@@ -447,7 +447,8 @@
|
|
|
447
447
|
"MapLegend": {
|
|
448
448
|
"title": "Légende",
|
|
449
449
|
"titlePlural": "Légendes",
|
|
450
|
-
"feedUnavailable": "Flux indisponible"
|
|
450
|
+
"feedUnavailable": "Flux indisponible",
|
|
451
|
+
"feedUnavailableToast": "{title} : le flux en direct est inaccessible pour le moment; la couche peut être absente ou périmée."
|
|
451
452
|
},
|
|
452
453
|
"Datasets": {
|
|
453
454
|
"failedFetchError": "Échec de la récupération des ensembles de données.",
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pluginDatasetId.d.ts","sourceRoot":"","sources":["../../../../src/core/plugins/host/pluginDatasetId.ts"],"names":[],"mappings":"AAGA,mGAAmG;AACnG,wBAAgB,eAAe,CAAC,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAG,MAAM,CAEpE"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/core/plugins/host/pluginDatasetId.ts"],"sourcesContent":["// SPDX-License-Identifier: AGPL-3.0-or-later\n// Copyright (C) 2025 Collab Digital Twins\n\n/** The id a plugin dataset carries in the Datasets store, namespaced so no two plugins collide. */\nexport function pluginDatasetId(pluginId: string, id: string): string {\n return `plugin:${pluginId}:${id}`\n}\n"],"mappings":"AAIO,SAAS,gBAAgB,UAAkB,IAAoB;AACpE,SAAO,UAAU,QAAQ,IAAI,EAAE;AACjC;","names":[]}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import type { Dataset } from '../../types/datasetTypes';
|
|
3
|
+
export type PluginDatasetLookup = (pluginId: string, id: string) => Dataset | undefined;
|
|
4
|
+
/** How the SDK finds a plugin's own dataset without importing the host, which would close a cycle through `installed.ts`. */
|
|
5
|
+
export declare const PluginDatasetLookupContext: React.Context<PluginDatasetLookup>;
|
|
6
|
+
//# sourceMappingURL=pluginDatasetLookup.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pluginDatasetLookup.d.ts","sourceRoot":"","sources":["../../../../src/core/plugins/host/pluginDatasetLookup.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAE9B,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,0BAA0B,CAAA;AAEvD,MAAM,MAAM,mBAAmB,GAAG,CAAC,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,KAAK,OAAO,GAAG,SAAS,CAAA;AAEvF,6HAA6H;AAC7H,eAAO,MAAM,0BAA0B,oCAA4D,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/core/plugins/host/pluginDatasetLookup.ts"],"sourcesContent":["'use client'\n\n// SPDX-License-Identifier: AGPL-3.0-or-later\n// Copyright (C) 2025 Collab Digital Twins\n\nimport * as React from 'react'\n\nimport type { Dataset } from '../../types/datasetTypes'\n\nexport type PluginDatasetLookup = (pluginId: string, id: string) => Dataset | undefined\n\n/** How the SDK finds a plugin's own dataset without importing the host, which would close a cycle through `installed.ts`. */\nexport const PluginDatasetLookupContext = React.createContext<PluginDatasetLookup>(() => undefined)\n"],"mappings":";AAKA,YAAY,WAAW;AAOhB,MAAM,6BAA6B,MAAM,cAAmC,MAAM,MAAS;","names":[]}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { Dataset } from '../../types/datasetTypes';
|
|
2
|
+
/** Every enabled plugin's datasets, for the lists in the Datasets menu and the Layers tab. */
|
|
3
|
+
export declare function usePluginDatasets(organization?: number): Dataset[];
|
|
4
|
+
//# sourceMappingURL=pluginDatasets.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pluginDatasets.d.ts","sourceRoot":"","sources":["../../../../src/core/plugins/host/pluginDatasets.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,0BAA0B,CAAA;AAEvD,8FAA8F;AAC9F,wBAAgB,iBAAiB,CAAC,YAAY,CAAC,EAAE,MAAM,GAAG,OAAO,EAAE,CAOlE"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
|
|
3
|
+
"use client";
|
|
4
|
+
import * as React from "react";
|
|
5
|
+
import { usePluginContributions } from "./provider";
|
|
6
|
+
import { toPluginDataset } from "./toPluginDataset";
|
|
7
|
+
function usePluginDatasets(organization) {
|
|
8
|
+
const registrations = usePluginContributions("map.datasets");
|
|
9
|
+
return React.useMemo(
|
|
10
|
+
() => registrations.map((registration) => toPluginDataset(registration, organization)),
|
|
11
|
+
[registrations, organization]
|
|
12
|
+
);
|
|
13
|
+
}
|
|
14
|
+
export {
|
|
15
|
+
usePluginDatasets
|
|
16
|
+
};
|
|
17
|
+
//# sourceMappingURL=pluginDatasets.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/core/plugins/host/pluginDatasets.ts"],"sourcesContent":["'use client'\n\n// SPDX-License-Identifier: AGPL-3.0-or-later\n// Copyright (C) 2025 Collab Digital Twins\n\nimport * as React from 'react'\n\nimport { usePluginContributions } from './provider'\nimport { toPluginDataset } from './toPluginDataset'\n\nimport type { Dataset } from '../../types/datasetTypes'\n\n/** Every enabled plugin's datasets, for the lists in the Datasets menu and the Layers tab. */\nexport function usePluginDatasets(organization?: number): Dataset[] {\n const registrations = usePluginContributions('map.datasets')\n\n return React.useMemo(\n () => registrations.map(registration => toPluginDataset(registration, organization)),\n [registrations, organization],\n )\n}\n"],"mappings":";AAKA,YAAY,WAAW;AAEvB,SAAS,8BAA8B;AACvC,SAAS,uBAAuB;AAKzB,SAAS,kBAAkB,cAAkC;AAClE,QAAM,gBAAgB,uBAAuB,cAAc;AAE3D,SAAO,MAAM;AAAA,IACX,MAAM,cAAc,IAAI,kBAAgB,gBAAgB,cAAc,YAAY,CAAC;AAAA,IACnF,CAAC,eAAe,YAAY;AAAA,EAC9B;AACF;","names":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"provider.d.ts","sourceRoot":"","sources":["../../../../src/core/plugins/host/provider.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAO9B,OAAO,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAA;
|
|
1
|
+
{"version":3,"file":"provider.d.ts","sourceRoot":"","sources":["../../../../src/core/plugins/host/provider.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAO9B,OAAO,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAA;AAEnC,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAA;AAI3C,OAAO,KAAK,EAAE,kBAAkB,EAAgB,YAAY,EAAE,MAAM,cAAc,CAAA;AAWlF,MAAM,WAAW,uBAAuB;IACtC,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAA;IACzB;;;;OAIG;IACH,OAAO,CAAC,EAAE,YAAY,CAAA;IACtB;;;;OAIG;IACH,YAAY,CAAC,EAAE,MAAM,EAAE,CAAA;IACvB,mFAAmF;IACnF,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAA;CAClD;AAED,wBAAgB,kBAAkB,CAAC,EACjC,QAAQ,EACR,OAA2B,EAC3B,YAAY,EACZ,OAAO,GACR,EAAE,uBAAuB,qBAiHzB;AAED,wBAAgB,iBAAiB,IAAI,cAAc,CAMlD;AAED,wBAAgB,eAAe,IAAI,OAAO,CAGzC;AAED,sFAAsF;AACtF,wBAAgB,aAAa,IAAI,UAAU,GAAG,IAAI,CAEjD;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,IAAI,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAE1E;AAID,MAAM,MAAM,kBAAkB,CAAC,CAAC,SAAS,MAAM,kBAAkB,IAC/D,kBAAkB,CAAC,CAAC,CAAC,GAAG;IAAE,QAAQ,EAAE,MAAM,CAAA;CAAE,CAAA;AAE9C;;;;;GAKG;AACH,wBAAgB,sBAAsB,CAAC,CAAC,SAAS,MAAM,kBAAkB,EACvE,GAAG,EAAE,CAAC,GACL,kBAAkB,CAAC,CAAC,CAAC,EAAE,CAgBzB"}
|
|
@@ -7,7 +7,9 @@ import { INSTALLED_PLUGINS } from "../installed";
|
|
|
7
7
|
import { resolvePluginEntry } from "../sdk/types";
|
|
8
8
|
import { PluginDialogProvider } from "./dialogs";
|
|
9
9
|
import { PluginHost } from "./host";
|
|
10
|
+
import { PluginDatasetLookupContext } from "./pluginDatasetLookup";
|
|
10
11
|
import { PluginRegistry } from "./registry";
|
|
12
|
+
import { toPluginDataset } from "./toPluginDataset";
|
|
11
13
|
const PluginHostContext = React.createContext(null);
|
|
12
14
|
function PluginHostProvider({
|
|
13
15
|
children,
|
|
@@ -84,7 +86,11 @@ function PluginHostProvider({
|
|
|
84
86
|
() => ({ registry, host, ready, configs: resolvedConfigs }),
|
|
85
87
|
[registry, host, ready, resolvedConfigs]
|
|
86
88
|
);
|
|
87
|
-
|
|
89
|
+
const findDataset = React.useCallback((pluginId, id) => {
|
|
90
|
+
const registration = registry.getAll("map.datasets").find((candidate) => candidate.pluginId === pluginId && candidate.id === id);
|
|
91
|
+
return registration && toPluginDataset(registration);
|
|
92
|
+
}, [registry]);
|
|
93
|
+
return /* @__PURE__ */ jsx(PluginHostContext.Provider, { value, children: /* @__PURE__ */ jsx(PluginDatasetLookupContext.Provider, { value: findDataset, children: /* @__PURE__ */ jsx(PluginDialogProvider, { children }) }) });
|
|
88
94
|
}
|
|
89
95
|
function usePluginRegistry() {
|
|
90
96
|
const context = React.useContext(PluginHostContext);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/core/plugins/host/provider.tsx"],"sourcesContent":["'use client'\n\n// SPDX-License-Identifier: AGPL-3.0-or-later\n// Copyright (C) 2025 Collab Digital Twins\n\nimport * as React from 'react'\n\nimport { INSTALLED_PLUGINS } from '../installed'\n\nimport { resolvePluginEntry } from '../sdk/types'\n\nimport { PluginDialogProvider } from './dialogs'\nimport { PluginHost } from './host'\nimport { PluginRegistry } from './registry'\n\n\nimport type { CapabilityRegistry, PluginSource, PluginsInput } from '../sdk/types'\n\ninterface PluginHostContextValue {\n registry: PluginRegistry\n host: PluginHost\n ready: boolean\n configs: Record<string, Record<string, unknown>>\n}\n\nconst PluginHostContext = React.createContext<PluginHostContextValue | null>(null)\n\nexport interface PluginHostProviderProps {\n children: React.ReactNode\n /**\n * The plugins to load. Defaults to the set compiled into core. Pass a stable\n * reference — a module-scope array or a `useCallback` thunk — since a fresh\n * literal re-resolves the list on every render.\n */\n plugins?: PluginsInput\n /**\n * Slugs to activate. `undefined` activates everything, for consumers that do not\n * manage enablement. An array is authoritative: anything unlisted stays inactive,\n * and removing a slug deactivates that plugin in place, without a reload.\n */\n enabledSlugs?: string[]\n /** Per-plugin configuration, keyed by slug. Reaches the plugin as `ctx.config`. */\n configs?: Record<string, Record<string, unknown>>\n}\n\nexport function PluginHostProvider({\n children,\n plugins = INSTALLED_PLUGINS,\n enabledSlugs,\n configs,\n}: PluginHostProviderProps) {\n const registry = React.useMemo(() => new PluginRegistry(), [])\n const host = React.useMemo(() => new PluginHost(registry), [registry])\n\n const [sources, setSources] = React.useState<PluginSource[] | null>(null)\n const [ready, setReady] = React.useState(false)\n\n // Both normalized to an identity derived from their content: the props arrive as\n // fresh literals from a fetch, and using them as effect deps directly would reload\n // every plugin on every render. The JSON round-trip also drops anything\n // non-serializable, which is correct — config originates as JSON.\n const enabledKey = React.useMemo(\n () => (enabledSlugs ? [...enabledSlugs].sort().join('\\u0000') : null),\n [enabledSlugs],\n )\n const enabled = React.useMemo(\n () => (enabledKey === null ? null : new Set(enabledKey.split('\\u0000'))),\n [enabledKey],\n )\n\n const configsKey = React.useMemo(() => (configs ? JSON.stringify(configs) : ''), [configs])\n const resolvedConfigs = React.useMemo<Record<string, Record<string, unknown>>>(\n () => (configsKey ? JSON.parse(configsKey) : {}),\n [configsKey],\n )\n\n // Resolve the list first: for runtime-loaded plugins that is a fetch plus a\n // dynamic import per bundle, so it cannot happen during render.\n React.useEffect(() => {\n let cancelled = false\n\n async function resolve() {\n try {\n const resolved = typeof plugins === 'function' ? await plugins() : plugins\n if (!cancelled) setSources(resolved)\n } catch (err) {\n // A plugin source that cannot be resolved must not take down the app.\n console.error('Failed to resolve the plugin list:', err)\n if (!cancelled) setSources([])\n }\n }\n\n void resolve()\n return () => {\n cancelled = true\n }\n }, [plugins])\n\n // Reconcile: activate what should be running, deactivate what should not.\n // Runs again whenever enablement or config changes, so the plugins page can\n // toggle a plugin without a page reload.\n React.useEffect(() => {\n if (!sources) return\n let cancelled = false\n\n async function sync() {\n for (const { manifest, entry } of sources ?? []) {\n if (cancelled) return\n\n const slug = manifest?.slug\n if (typeof slug !== 'string' || !slug) {\n // Let the host reject it, so the failure is recorded. The entry is never\n // resolved: no point fetching a chunk for a plugin that cannot activate.\n await host.loadPlugin(manifest, { activate: () => {} }, {})\n continue\n }\n\n const shouldRun = enabled === null || enabled.has(slug)\n const isRunning = host.getStatus(slug) === 'active'\n\n if (shouldRun && !isRunning) {\n // Resolving the entry is what downloads a compiled-in plugin's chunk, so it\n // happens here rather than at module scope.\n try {\n await host.loadPlugin(manifest, await resolvePluginEntry(entry), resolvedConfigs[slug] ?? {})\n } catch (error) {\n // A chunk that fails to load must not stop the plugins after it.\n console.error(`Failed to load plugin \"${slug}\":`, error)\n }\n } else if (!shouldRun && isRunning) {\n await host.unloadPlugin(slug)\n }\n }\n\n if (!cancelled) setReady(true)\n }\n\n void sync()\n return () => {\n cancelled = true\n }\n }, [sources, host, enabled, resolvedConfigs])\n\n const value = React.useMemo(\n () => ({ registry, host, ready, configs: resolvedConfigs }),\n [registry, host, ready, resolvedConfigs],\n )\n\n return (\n <PluginHostContext.Provider value={value}>\n <PluginDialogProvider>\n {children}\n </PluginDialogProvider>\n </PluginHostContext.Provider>\n )\n}\n\nexport function usePluginRegistry(): PluginRegistry {\n const context = React.useContext(PluginHostContext)\n if (!context) {\n throw new Error('usePluginRegistry must be used within PluginHostProvider')\n }\n return context.registry\n}\n\nexport function usePluginsReady(): boolean {\n const context = React.useContext(PluginHostContext)\n return context?.ready ?? false\n}\n\n/** The host itself. Only the plugins page needs this; capability consumers do not. */\nexport function usePluginHost(): PluginHost | null {\n return React.useContext(PluginHostContext)?.host ?? null\n}\n\n/**\n * Every plugin's configuration, keyed by slug, for capability hosts to pass into\n * `PluginScopeProvider`. Plugins use `usePluginConfig()` from the SDK instead — a plugin\n * component importing this module puts `installed.ts` and the host in a cycle.\n */\nexport function usePluginConfigs(): Record<string, Record<string, unknown>> {\n return React.useContext(PluginHostContext)?.configs ?? EMPTY_CONFIGS\n}\n\nconst EMPTY_CONFIGS: Record<string, Record<string, unknown>> = {}\n\nexport type PluginContribution<K extends keyof CapabilityRegistry> =\n CapabilityRegistry[K] & { pluginId: string }\n\n/**\n * Read a capability's contributions and re-render when they change — the one way a host\n * component should consume the registry. `registry.getAll()` during render only works\n * when plugins load before first paint; a runtime-loaded plugin registers after the\n * consumer rendered, with nothing to tell it to look again.\n */\nexport function usePluginContributions<K extends keyof CapabilityRegistry>(\n key: K,\n): PluginContribution<K>[] {\n const registry = usePluginRegistry()\n\n const subscribe = React.useCallback(\n (onStoreChange: () => void) => registry.subscribe(onStoreChange),\n [registry],\n )\n\n // Copy-on-write in the registry makes this a stable reference between changes, which is\n // what lets useSyncExternalStore skip consumers of untouched capabilities.\n const getSnapshot = React.useCallback(\n () => registry.getAll(key) as unknown as PluginContribution<K>[],\n [registry, key],\n )\n\n return React.useSyncExternalStore(subscribe, getSnapshot, getSnapshot)\n}\n"],"mappings":";AAsJM;AAjJN,YAAY,WAAW;AAEvB,SAAS,yBAAyB;AAElC,SAAS,0BAA0B;AAEnC,SAAS,4BAA4B;AACrC,SAAS,kBAAkB;AAC3B,SAAS,sBAAsB;AAY/B,MAAM,oBAAoB,MAAM,cAA6C,IAAI;AAoB1E,SAAS,mBAAmB;AAAA,EACjC;AAAA,EACA,UAAU;AAAA,EACV;AAAA,EACA;AACF,GAA4B;AAC1B,QAAM,WAAW,MAAM,QAAQ,MAAM,IAAI,eAAe,GAAG,CAAC,CAAC;AAC7D,QAAM,OAAO,MAAM,QAAQ,MAAM,IAAI,WAAW,QAAQ,GAAG,CAAC,QAAQ,CAAC;AAErE,QAAM,CAAC,SAAS,UAAU,IAAI,MAAM,SAAgC,IAAI;AACxE,QAAM,CAAC,OAAO,QAAQ,IAAI,MAAM,SAAS,KAAK;AAM9C,QAAM,aAAa,MAAM;AAAA,IACvB,MAAO,eAAe,CAAC,GAAG,YAAY,EAAE,KAAK,EAAE,KAAK,IAAQ,IAAI;AAAA,IAChE,CAAC,YAAY;AAAA,EACf;AACA,QAAM,UAAU,MAAM;AAAA,IACpB,MAAO,eAAe,OAAO,OAAO,IAAI,IAAI,WAAW,MAAM,IAAQ,CAAC;AAAA,IACtE,CAAC,UAAU;AAAA,EACb;AAEA,QAAM,aAAa,MAAM,QAAQ,MAAO,UAAU,KAAK,UAAU,OAAO,IAAI,IAAK,CAAC,OAAO,CAAC;AAC1F,QAAM,kBAAkB,MAAM;AAAA,IAC5B,MAAO,aAAa,KAAK,MAAM,UAAU,IAAI,CAAC;AAAA,IAC9C,CAAC,U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MAAM;AACX,kBAAY;AAAA,IACd;AAAA,EACF,GAAG,CAAC,SAAS,MAAM,SAAS,eAAe,CAAC;AAE5C,QAAM,QAAQ,MAAM;AAAA,IAClB,OAAO,EAAE,UAAU,MAAM,OAAO,SAAS,gBAAgB;AAAA,IACzD,CAAC,UAAU,MAAM,OAAO,eAAe;AAAA,EACzC;AAEA,SACE,oBAAC,kBAAkB,UAAlB,EAA2B,OAC1B,8BAAC,wBACE,UACH,GACF;AAEJ;AAEO,SAAS,oBAAoC;AAClD,QAAM,UAAU,MAAM,WAAW,iBAAiB;AAClD,MAAI,CAAC,SAAS;AACZ,UAAM,IAAI,MAAM,0DAA0D;AAAA,EAC5E;AACA,SAAO,QAAQ;AACjB;AAEO,SAAS,kBAA2B;AArK3C;AAsKE,QAAM,UAAU,MAAM,WAAW,iBAAiB;AAClD,UAAO,wCAAS,UAAT,YAAkB;AAC3B;AAGO,SAAS,gBAAmC;AA3KnD;AA4KE,UAAO,iBAAM,WAAW,iBAAiB,MAAlC,mBAAqC,SAArC,YAA6C;AACtD;AAOO,SAAS,mBAA4D;AApL5E;AAqLE,UAAO,iBAAM,WAAW,iBAAiB,MAAlC,mBAAqC,YAArC,YAAgD;AACzD;AAEA,MAAM,gBAAyD,CAAC;AAWzD,SAAS,uBACd,KACyB;AACzB,QAAM,WAAW,kBAAkB;AAEnC,QAAM,YAAY,MAAM;AAAA,IACtB,CAAC,kBAA8B,SAAS,UAAU,aAAa;AAAA,IAC/D,CAAC,QAAQ;AAAA,EACX;AAIA,QAAM,cAAc,MAAM;AAAA,IACxB,MAAM,SAAS,OAAO,GAAG;AAAA,IACzB,CAAC,UAAU,GAAG;AAAA,EAChB;AAEA,SAAO,MAAM,qBAAqB,WAAW,aAAa,WAAW;AACvE;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../../../src/core/plugins/host/provider.tsx"],"sourcesContent":["'use client'\n\n// SPDX-License-Identifier: AGPL-3.0-or-later\n// Copyright (C) 2025 Collab Digital Twins\n\nimport * as React from 'react'\n\nimport { INSTALLED_PLUGINS } from '../installed'\n\nimport { resolvePluginEntry } from '../sdk/types'\n\nimport { PluginDialogProvider } from './dialogs'\nimport { PluginHost } from './host'\nimport { PluginDatasetLookupContext, type PluginDatasetLookup } from './pluginDatasetLookup'\nimport { PluginRegistry } from './registry'\nimport { toPluginDataset } from './toPluginDataset'\n\n\nimport type { CapabilityRegistry, PluginSource, PluginsInput } from '../sdk/types'\n\ninterface PluginHostContextValue {\n registry: PluginRegistry\n host: PluginHost\n ready: boolean\n configs: Record<string, Record<string, unknown>>\n}\n\nconst PluginHostContext = React.createContext<PluginHostContextValue | null>(null)\n\nexport interface PluginHostProviderProps {\n children: React.ReactNode\n /**\n * The plugins to load. Defaults to the set compiled into core. Pass a stable\n * reference — a module-scope array or a `useCallback` thunk — since a fresh\n * literal re-resolves the list on every render.\n */\n plugins?: PluginsInput\n /**\n * Slugs to activate. `undefined` activates everything, for consumers that do not\n * manage enablement. An array is authoritative: anything unlisted stays inactive,\n * and removing a slug deactivates that plugin in place, without a reload.\n */\n enabledSlugs?: string[]\n /** Per-plugin configuration, keyed by slug. Reaches the plugin as `ctx.config`. */\n configs?: Record<string, Record<string, unknown>>\n}\n\nexport function PluginHostProvider({\n children,\n plugins = INSTALLED_PLUGINS,\n enabledSlugs,\n configs,\n}: PluginHostProviderProps) {\n const registry = React.useMemo(() => new PluginRegistry(), [])\n const host = React.useMemo(() => new PluginHost(registry), [registry])\n\n const [sources, setSources] = React.useState<PluginSource[] | null>(null)\n const [ready, setReady] = React.useState(false)\n\n // Both normalized to an identity derived from their content: the props arrive as\n // fresh literals from a fetch, and using them as effect deps directly would reload\n // every plugin on every render. The JSON round-trip also drops anything\n // non-serializable, which is correct — config originates as JSON.\n const enabledKey = React.useMemo(\n () => (enabledSlugs ? [...enabledSlugs].sort().join('\\u0000') : null),\n [enabledSlugs],\n )\n const enabled = React.useMemo(\n () => (enabledKey === null ? null : new Set(enabledKey.split('\\u0000'))),\n [enabledKey],\n )\n\n const configsKey = React.useMemo(() => (configs ? JSON.stringify(configs) : ''), [configs])\n const resolvedConfigs = React.useMemo<Record<string, Record<string, unknown>>>(\n () => (configsKey ? JSON.parse(configsKey) : {}),\n [configsKey],\n )\n\n // Resolve the list first: for runtime-loaded plugins that is a fetch plus a\n // dynamic import per bundle, so it cannot happen during render.\n React.useEffect(() => {\n let cancelled = false\n\n async function resolve() {\n try {\n const resolved = typeof plugins === 'function' ? await plugins() : plugins\n if (!cancelled) setSources(resolved)\n } catch (err) {\n // A plugin source that cannot be resolved must not take down the app.\n console.error('Failed to resolve the plugin list:', err)\n if (!cancelled) setSources([])\n }\n }\n\n void resolve()\n return () => {\n cancelled = true\n }\n }, [plugins])\n\n // Reconcile: activate what should be running, deactivate what should not.\n // Runs again whenever enablement or config changes, so the plugins page can\n // toggle a plugin without a page reload.\n React.useEffect(() => {\n if (!sources) return\n let cancelled = false\n\n async function sync() {\n for (const { manifest, entry } of sources ?? []) {\n if (cancelled) return\n\n const slug = manifest?.slug\n if (typeof slug !== 'string' || !slug) {\n // Let the host reject it, so the failure is recorded. The entry is never\n // resolved: no point fetching a chunk for a plugin that cannot activate.\n await host.loadPlugin(manifest, { activate: () => {} }, {})\n continue\n }\n\n const shouldRun = enabled === null || enabled.has(slug)\n const isRunning = host.getStatus(slug) === 'active'\n\n if (shouldRun && !isRunning) {\n // Resolving the entry is what downloads a compiled-in plugin's chunk, so it\n // happens here rather than at module scope.\n try {\n await host.loadPlugin(manifest, await resolvePluginEntry(entry), resolvedConfigs[slug] ?? {})\n } catch (error) {\n // A chunk that fails to load must not stop the plugins after it.\n console.error(`Failed to load plugin \"${slug}\":`, error)\n }\n } else if (!shouldRun && isRunning) {\n await host.unloadPlugin(slug)\n }\n }\n\n if (!cancelled) setReady(true)\n }\n\n void sync()\n return () => {\n cancelled = true\n }\n }, [sources, host, enabled, resolvedConfigs])\n\n const value = React.useMemo(\n () => ({ registry, host, ready, configs: resolvedConfigs }),\n [registry, host, ready, resolvedConfigs],\n )\n\n const findDataset = React.useCallback<PluginDatasetLookup>((pluginId, id) => {\n const registration = (registry.getAll('map.datasets') as unknown as PluginContribution<'map.datasets'>[])\n .find(candidate => candidate.pluginId === pluginId && candidate.id === id)\n return registration && toPluginDataset(registration)\n }, [registry])\n\n return (\n <PluginHostContext.Provider value={value}>\n <PluginDatasetLookupContext.Provider value={findDataset}>\n <PluginDialogProvider>\n {children}\n </PluginDialogProvider>\n </PluginDatasetLookupContext.Provider>\n </PluginHostContext.Provider>\n )\n}\n\nexport function usePluginRegistry(): PluginRegistry {\n const context = React.useContext(PluginHostContext)\n if (!context) {\n throw new Error('usePluginRegistry must be used within PluginHostProvider')\n }\n return context.registry\n}\n\nexport function usePluginsReady(): boolean {\n const context = React.useContext(PluginHostContext)\n return context?.ready ?? false\n}\n\n/** The host itself. Only the plugins page needs this; capability consumers do not. */\nexport function usePluginHost(): PluginHost | null {\n return React.useContext(PluginHostContext)?.host ?? null\n}\n\n/**\n * Every plugin's configuration, keyed by slug, for capability hosts to pass into\n * `PluginScopeProvider`. Plugins use `usePluginConfig()` from the SDK instead — a plugin\n * component importing this module puts `installed.ts` and the host in a cycle.\n */\nexport function usePluginConfigs(): Record<string, Record<string, unknown>> {\n return React.useContext(PluginHostContext)?.configs ?? EMPTY_CONFIGS\n}\n\nconst EMPTY_CONFIGS: Record<string, Record<string, unknown>> = {}\n\nexport type PluginContribution<K extends keyof CapabilityRegistry> =\n CapabilityRegistry[K] & { pluginId: string }\n\n/**\n * Read a capability's contributions and re-render when they change — the one way a host\n * component should consume the registry. `registry.getAll()` during render only works\n * when plugins load before first paint; a runtime-loaded plugin registers after the\n * consumer rendered, with nothing to tell it to look again.\n */\nexport function usePluginContributions<K extends keyof CapabilityRegistry>(\n key: K,\n): PluginContribution<K>[] {\n const registry = usePluginRegistry()\n\n const subscribe = React.useCallback(\n (onStoreChange: () => void) => registry.subscribe(onStoreChange),\n [registry],\n )\n\n // Copy-on-write in the registry makes this a stable reference between changes, which is\n // what lets useSyncExternalStore skip consumers of untouched capabilities.\n const getSnapshot = React.useCallback(\n () => registry.getAll(key) as unknown as PluginContribution<K>[],\n [registry, key],\n )\n\n return React.useSyncExternalStore(subscribe, getSnapshot, getSnapshot)\n}\n"],"mappings":";AA+JQ;AA1JR,YAAY,WAAW;AAEvB,SAAS,yBAAyB;AAElC,SAAS,0BAA0B;AAEnC,SAAS,4BAA4B;AACrC,SAAS,kBAAkB;AAC3B,SAAS,kCAA4D;AACrE,SAAS,sBAAsB;AAC/B,SAAS,uBAAuB;AAYhC,MAAM,oBAAoB,MAAM,cAA6C,IAAI;AAoB1E,SAAS,mBAAmB;AAAA,EACjC;AAAA,EACA,UAAU;AAAA,EACV;AAAA,EACA;AACF,GAA4B;AAC1B,QAAM,WAAW,MAAM,QAAQ,MAAM,IAAI,eAAe,GAAG,CAAC,CAAC;AAC7D,QAAM,OAAO,MAAM,QAAQ,MAAM,IAAI,WAAW,QAAQ,GAAG,CAAC,QAAQ,CAAC;AAErE,QAAM,CAAC,SAAS,UAAU,IAAI,MAAM,SAAgC,IAAI;AACxE,QAAM,CAAC,OAAO,QAAQ,IAAI,MAAM,SAAS,KAAK;AAM9C,QAAM,aAAa,MAAM;AAAA,IACvB,MAAO,eAAe,CAAC,GAAG,YAAY,EAAE,KAAK,EAAE,KAAK,IAAQ,IAAI;AAAA,IAChE,CAAC,YAAY;AAAA,EACf;AACA,QAAM,UAAU,MAAM;AAAA,IACpB,MAAO,eAAe,OAAO,OAAO,IAAI,IAAI,WAAW,MAAM,IAAQ,CAAC;AAAA,IACtE,CAAC,UAAU;AAAA,EACb;AAEA,QAAM,aAAa,MAAM,QAAQ,MAAO,UAAU,KAAK,UAAU,OAAO,IAAI,IAAK,CAAC,OAAO,CAAC;AAC1F,QAAM,kBAAkB,MAAM;AAAA,IAC5B,MAAO,aAAa,KAAK,MAAM,UAAU,IAAI,CAAC;AAAA,IAC9C,CAAC,UAAU;AAAA,EACb;AAIA,QAAM,UAAU,MA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,IACzB,CAAC,UAAU,GAAG;AAAA,EAChB;AAEA,SAAO,MAAM,qBAAqB,WAAW,aAAa,WAAW;AACvE;","names":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runtimeShims.d.ts","sourceRoot":"","sources":["../../../../src/core/plugins/host/runtimeShims.ts"],"names":[],"mappings":"AAGA,2FAA2F;AAC3F,MAAM,WAAW,WAAW;IAC1B,gDAAgD;IAChD,IAAI,EAAE,MAAM,CAAA;IACZ,0EAA0E;IAC1E,MAAM,EAAE,MAAM,CAAA;IACd,4CAA4C;IAC5C,SAAS,EAAE,MAAM,CAAA;IACjB,6EAA6E;IAC7E,OAAO,EAAE,MAAM,EAAE,CAAA;CAClB;AAUD,eAAO,MAAM,oBAAoB,EAAE,SAAS,WAAW,
|
|
1
|
+
{"version":3,"file":"runtimeShims.d.ts","sourceRoot":"","sources":["../../../../src/core/plugins/host/runtimeShims.ts"],"names":[],"mappings":"AAGA,2FAA2F;AAC3F,MAAM,WAAW,WAAW;IAC1B,gDAAgD;IAChD,IAAI,EAAE,MAAM,CAAA;IACZ,0EAA0E;IAC1E,MAAM,EAAE,MAAM,CAAA;IACd,4CAA4C;IAC5C,SAAS,EAAE,MAAM,CAAA;IACjB,6EAA6E;IAC7E,OAAO,EAAE,MAAM,EAAE,CAAA;CAClB;AAUD,eAAO,MAAM,oBAAoB,EAAE,SAAS,WAAW,EAmGtD,CAAA;AAED,8EAA8E;AAC9E,eAAO,MAAM,gBAAgB,EAAE,SAAS,MAAM,EAE7C,CAAA"}
|
|
@@ -119,7 +119,8 @@ const PLUGIN_RUNTIME_SHIMS = [
|
|
|
119
119
|
"useDeleteComments",
|
|
120
120
|
// Re-exported by the module, so a plugin reaching for data finds both here too.
|
|
121
121
|
"usePluginConfig",
|
|
122
|
-
"usePluginPermissions"
|
|
122
|
+
"usePluginPermissions",
|
|
123
|
+
"usePluginDataset"
|
|
123
124
|
]
|
|
124
125
|
},
|
|
125
126
|
{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/core/plugins/host/runtimeShims.ts"],"sourcesContent":["// SPDX-License-Identifier: AGPL-3.0-or-later\n// Copyright (C) 2025 Collab Digital Twins\n\n/** One bare specifier a runtime-loaded plugin may import, and the shim the host serves. */\nexport interface RuntimeShim {\n /** Filename served under `/plugin-runtime/`. */\n file: string\n /** Key on `globalThis.__CDT_RUNTIME__` that the host bridge populates. */\n bridge: string\n /** The bare specifier the plugin writes. */\n specifier: string\n /** Re-exported by name, because an import map cannot rewrite a namespace. */\n exports: string[]\n}\n\n// Part of the host contract, so it lives beside `PLUGIN_HOST_API` rather than in the\n// app. Three consumers derive from it — the app's shim generator, the published import\n// map, and `@collabdt/plugin-kit`'s build preset — and when they disagree a plugin\n// either bundles a second copy of a singleton or dies on an unmapped specifier.\n//\n// Absent on purpose: `@thatopen/components`, `three`, `maplibre-gl`, `lucide-react`. A\n// plugin gets viewer instances as props and names icons by string, so it never imports\n// those at runtime — which is what stops a second copy of three.js loading.\nexport const PLUGIN_RUNTIME_SHIMS: readonly RuntimeShim[] = [\n {\n file: 'react.js',\n bridge: 'react',\n specifier: 'react',\n exports: [\n 'Children', 'Component', 'Fragment', 'Profiler', 'PureComponent',\n 'StrictMode', 'Suspense', 'cloneElement', 'createContext',\n 'createElement', 'createRef', 'forwardRef', 'isValidElement', 'lazy',\n 'memo', 'startTransition', 'useCallback', 'useContext', 'useDebugValue',\n 'useDeferredValue', 'useEffect', 'useId', 'useImperativeHandle',\n 'useInsertionEffect', 'useLayoutEffect', 'useMemo', 'useReducer',\n 'useRef', 'useState', 'useSyncExternalStore', 'useTransition', 'version',\n ],\n },\n {\n file: 'react-dom.js',\n bridge: 'reactDom',\n specifier: 'react-dom',\n exports: ['createPortal', 'flushSync', 'version'],\n },\n {\n file: 'jsx-runtime.js',\n bridge: 'jsxRuntime',\n specifier: 'react/jsx-runtime',\n exports: ['Fragment', 'jsx', 'jsxs'],\n },\n {\n file: 'sdk.js',\n bridge: 'sdk',\n specifier: '@collabdt/core/plugins-sdk',\n exports: [\n 'VALID_CAPABILITIES', 'validateManifest', 'PLUGIN_HOST_API', 'resolvePluginEntry',\n // A value, not just a type: a `viewer.tabs` contribution names the viewers it belongs in.\n 'ViewerNames',\n // So a plugin colouring something on the map uses the platform's palette.\n 'MAP_COLOUR_PALETTE', 'stringToColour',\n ],\n },\n {\n file: 'sdk-config.js',\n bridge: 'sdkConfig',\n specifier: '@collabdt/core/plugins-sdk/config',\n exports: ['usePluginConfig', 'usePluginId'],\n },\n {\n file: 'sdk-messages.js',\n bridge: 'sdkMessages',\n specifier: '@collabdt/core/plugins-sdk/messages',\n exports: ['usePluginMessage', 'usePluginTranslations', 'useCoreTranslations'],\n },\n {\n file: 'sdk-store.js',\n bridge: 'sdkStore',\n specifier: '@collabdt/core/plugins-sdk/store',\n exports: ['usePluginStore'],\n },\n {\n file: 'sdk-data.js',\n bridge: 'sdkData',\n specifier: '@collabdt/core/plugins-sdk/data',\n exports: [\n 'useBuildings', 'useBuilding', 'useBuildingsByOsm', 'useBuildingOsmIds',\n 'useSites', 'useSite',\n 'useInfrastructures', 'useInfrastructure',\n 'useOrganization', 'useOrganizationByName',\n 'useFiles', 'useFile', 'useFilesByBuildingId', 'useFilesBySiteId', 'useDownloadFile',\n 'useSensors', 'useSensor', 'useSensorsByBuilding', 'useSensorsByAuthor', 'useCreateSensor',\n 'useSensorTypes', 'useSensorType',\n 'useComments', 'useComment', 'useCommentsByBuilding', 'useCommentsByAuthor',\n 'useCreateComment', 'useDeleteComments',\n // Re-exported by the module, so a plugin reaching for data finds both here too.\n 'usePluginConfig', 'usePluginPermissions',\n ],\n },\n {\n file: 'sdk-state.js',\n bridge: 'sdkState',\n specifier: '@collabdt/core/plugins-sdk/state',\n exports: ['usePluginState'],\n },\n {\n file: 'sdk-ui.js',\n bridge: 'sdkUi',\n specifier: '@collabdt/core/plugins-sdk/ui',\n exports: ['usePluginDialogs'],\n },\n {\n file: 'sdk-components.js',\n bridge: 'sdkComponents',\n specifier: '@collabdt/core/plugins-sdk/components',\n exports: [\n 'Badge', 'Button', 'Input', 'Separator',\n 'Card', 'CardContent', 'CardDescription', 'CardFooter', 'CardHeader', 'CardTitle',\n 'Dialog', 'DialogClose', 'DialogContent', 'DialogDescription',\n 'DialogFooter', 'DialogHeader', 'DialogTitle', 'DialogTrigger',\n ],\n },\n]\n\n/** Just the specifiers, which is what a bundler's `external` option wants. */\nexport const PLUGIN_EXTERNALS: readonly string[] = PLUGIN_RUNTIME_SHIMS.map(\n shim => shim.specifier,\n)\n"],"mappings":"AAuBO,MAAM,uBAA+C;AAAA,EAC1D;AAAA,IACE,MAAM;AAAA,IACN,QAAQ;AAAA,IACR,WAAW;AAAA,IACX,SAAS;AAAA,MACP;AAAA,MAAY;AAAA,MAAa;AAAA,MAAY;AAAA,MAAY;AAAA,MACjD;AAAA,MAAc;AAAA,MAAY;AAAA,MAAgB;AAAA,MAC1C;AAAA,MAAiB;AAAA,MAAa;AAAA,MAAc;AAAA,MAAkB;AAAA,MAC9D;AAAA,MAAQ;AAAA,MAAmB;AAAA,MAAe;AAAA,MAAc;AAAA,MACxD;AAAA,MAAoB;AAAA,MAAa;AAAA,MAAS;AAAA,MAC1C;AAAA,MAAsB;AAAA,MAAmB;AAAA,MAAW;AAAA,MACpD;AAAA,MAAU;AAAA,MAAY;AAAA,MAAwB;AAAA,MAAiB;AAAA,IACjE;AAAA,EACF;AAAA,EACA;AAAA,IACE,MAAM;AAAA,IACN,QAAQ;AAAA,IACR,WAAW;AAAA,IACX,SAAS,CAAC,gBAAgB,aAAa,SAAS;AAAA,EAClD;AAAA,EACA;AAAA,IACE,MAAM;AAAA,IACN,QAAQ;AAAA,IACR,WAAW;AAAA,IACX,SAAS,CAAC,YAAY,OAAO,MAAM;AAAA,EACrC;AAAA,EACA;AAAA,IACE,MAAM;AAAA,IACN,QAAQ;AAAA,IACR,WAAW;AAAA,IACX,SAAS;AAAA,MACP;AAAA,MAAsB;AAAA,MAAoB;AAAA,MAAmB;AAAA;AAAA,MAE7D;AAAA;AAAA,MAEA;AAAA,MAAsB;AAAA,IACxB;AAAA,EACF;AAAA,EACA;AAAA,IACE,MAAM;AAAA,IACN,QAAQ;AAAA,IACR,WAAW;AAAA,IACX,SAAS,CAAC,mBAAmB,aAAa;AAAA,EAC5C;AAAA,EACA;AAAA,IACE,MAAM;AAAA,IACN,QAAQ;AAAA,IACR,WAAW;AAAA,IACX,SAAS,CAAC,oBAAoB,yBAAyB,qBAAqB;AAAA,EAC9E;AAAA,EACA;AAAA,IACE,MAAM;AAAA,IACN,QAAQ;AAAA,IACR,WAAW;AAAA,IACX,SAAS,CAAC,gBAAgB;AAAA,EAC5B;AAAA,EACA;AAAA,IACE,MAAM;AAAA,IACN,QAAQ;AAAA,IACR,WAAW;AAAA,IACX,SAAS;AAAA,MACP;AAAA,MAAgB;AAAA,MAAe;AAAA,MAAqB;AAAA,MACpD;AAAA,MAAY;AAAA,MACZ;AAAA,MAAsB;AAAA,MACtB;AAAA,MAAmB;AAAA,MACnB;AAAA,MAAY;AAAA,MAAW;AAAA,MAAwB;AAAA,MAAoB;AAAA,MACnE;AAAA,MAAc;AAAA,MAAa;AAAA,MAAwB;AAAA,MAAsB;AAAA,MACzE;AAAA,MAAkB;AAAA,MAClB;AAAA,MAAe;AAAA,MAAc;AAAA,MAAyB;AAAA,MACtD;AAAA,MAAoB;AAAA;AAAA,MAEpB;AAAA,MAAmB;AAAA,
|
|
1
|
+
{"version":3,"sources":["../../../../src/core/plugins/host/runtimeShims.ts"],"sourcesContent":["// SPDX-License-Identifier: AGPL-3.0-or-later\n// Copyright (C) 2025 Collab Digital Twins\n\n/** One bare specifier a runtime-loaded plugin may import, and the shim the host serves. */\nexport interface RuntimeShim {\n /** Filename served under `/plugin-runtime/`. */\n file: string\n /** Key on `globalThis.__CDT_RUNTIME__` that the host bridge populates. */\n bridge: string\n /** The bare specifier the plugin writes. */\n specifier: string\n /** Re-exported by name, because an import map cannot rewrite a namespace. */\n exports: string[]\n}\n\n// Part of the host contract, so it lives beside `PLUGIN_HOST_API` rather than in the\n// app. Three consumers derive from it — the app's shim generator, the published import\n// map, and `@collabdt/plugin-kit`'s build preset — and when they disagree a plugin\n// either bundles a second copy of a singleton or dies on an unmapped specifier.\n//\n// Absent on purpose: `@thatopen/components`, `three`, `maplibre-gl`, `lucide-react`. A\n// plugin gets viewer instances as props and names icons by string, so it never imports\n// those at runtime — which is what stops a second copy of three.js loading.\nexport const PLUGIN_RUNTIME_SHIMS: readonly RuntimeShim[] = [\n {\n file: 'react.js',\n bridge: 'react',\n specifier: 'react',\n exports: [\n 'Children', 'Component', 'Fragment', 'Profiler', 'PureComponent',\n 'StrictMode', 'Suspense', 'cloneElement', 'createContext',\n 'createElement', 'createRef', 'forwardRef', 'isValidElement', 'lazy',\n 'memo', 'startTransition', 'useCallback', 'useContext', 'useDebugValue',\n 'useDeferredValue', 'useEffect', 'useId', 'useImperativeHandle',\n 'useInsertionEffect', 'useLayoutEffect', 'useMemo', 'useReducer',\n 'useRef', 'useState', 'useSyncExternalStore', 'useTransition', 'version',\n ],\n },\n {\n file: 'react-dom.js',\n bridge: 'reactDom',\n specifier: 'react-dom',\n exports: ['createPortal', 'flushSync', 'version'],\n },\n {\n file: 'jsx-runtime.js',\n bridge: 'jsxRuntime',\n specifier: 'react/jsx-runtime',\n exports: ['Fragment', 'jsx', 'jsxs'],\n },\n {\n file: 'sdk.js',\n bridge: 'sdk',\n specifier: '@collabdt/core/plugins-sdk',\n exports: [\n 'VALID_CAPABILITIES', 'validateManifest', 'PLUGIN_HOST_API', 'resolvePluginEntry',\n // A value, not just a type: a `viewer.tabs` contribution names the viewers it belongs in.\n 'ViewerNames',\n // So a plugin colouring something on the map uses the platform's palette.\n 'MAP_COLOUR_PALETTE', 'stringToColour',\n ],\n },\n {\n file: 'sdk-config.js',\n bridge: 'sdkConfig',\n specifier: '@collabdt/core/plugins-sdk/config',\n exports: ['usePluginConfig', 'usePluginId'],\n },\n {\n file: 'sdk-messages.js',\n bridge: 'sdkMessages',\n specifier: '@collabdt/core/plugins-sdk/messages',\n exports: ['usePluginMessage', 'usePluginTranslations', 'useCoreTranslations'],\n },\n {\n file: 'sdk-store.js',\n bridge: 'sdkStore',\n specifier: '@collabdt/core/plugins-sdk/store',\n exports: ['usePluginStore'],\n },\n {\n file: 'sdk-data.js',\n bridge: 'sdkData',\n specifier: '@collabdt/core/plugins-sdk/data',\n exports: [\n 'useBuildings', 'useBuilding', 'useBuildingsByOsm', 'useBuildingOsmIds',\n 'useSites', 'useSite',\n 'useInfrastructures', 'useInfrastructure',\n 'useOrganization', 'useOrganizationByName',\n 'useFiles', 'useFile', 'useFilesByBuildingId', 'useFilesBySiteId', 'useDownloadFile',\n 'useSensors', 'useSensor', 'useSensorsByBuilding', 'useSensorsByAuthor', 'useCreateSensor',\n 'useSensorTypes', 'useSensorType',\n 'useComments', 'useComment', 'useCommentsByBuilding', 'useCommentsByAuthor',\n 'useCreateComment', 'useDeleteComments',\n // Re-exported by the module, so a plugin reaching for data finds both here too.\n 'usePluginConfig', 'usePluginPermissions',\n 'usePluginDataset',\n ],\n },\n {\n file: 'sdk-state.js',\n bridge: 'sdkState',\n specifier: '@collabdt/core/plugins-sdk/state',\n exports: ['usePluginState'],\n },\n {\n file: 'sdk-ui.js',\n bridge: 'sdkUi',\n specifier: '@collabdt/core/plugins-sdk/ui',\n exports: ['usePluginDialogs'],\n },\n {\n file: 'sdk-components.js',\n bridge: 'sdkComponents',\n specifier: '@collabdt/core/plugins-sdk/components',\n exports: [\n 'Badge', 'Button', 'Input', 'Separator',\n 'Card', 'CardContent', 'CardDescription', 'CardFooter', 'CardHeader', 'CardTitle',\n 'Dialog', 'DialogClose', 'DialogContent', 'DialogDescription',\n 'DialogFooter', 'DialogHeader', 'DialogTitle', 'DialogTrigger',\n ],\n },\n]\n\n/** Just the specifiers, which is what a bundler's `external` option wants. */\nexport const PLUGIN_EXTERNALS: readonly string[] = PLUGIN_RU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@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { PluginContribution } from './provider';
|
|
2
|
+
import type { Dataset } from '../../types/datasetTypes';
|
|
3
|
+
type DatasetContribution = PluginContribution<'map.datasets'>;
|
|
4
|
+
/**
|
|
5
|
+
* A `map.datasets` contribution as the Datasets menu lists it. A live one goes under Live
|
|
6
|
+
* Data; any other is organizational, stamped with the viewer's own organization.
|
|
7
|
+
*/
|
|
8
|
+
export declare function toPluginDataset(registration: DatasetContribution, organization?: number): Dataset;
|
|
9
|
+
export {};
|
|
10
|
+
//# sourceMappingURL=toPluginDataset.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"toPluginDataset.d.ts","sourceRoot":"","sources":["../../../../src/core/plugins/host/toPluginDataset.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAA;AACpD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,0BAA0B,CAAA;AAMvD,KAAK,mBAAmB,GAAG,kBAAkB,CAAC,cAAc,CAAC,CAAA;AA8B7D;;;GAGG;AACH,wBAAgB,eAAe,CAAC,YAAY,EAAE,mBAAmB,EAAE,YAAY,CAAC,EAAE,MAAM,GAAG,OAAO,CAoBjG"}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
3
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
4
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
5
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
6
|
+
var __spreadValues = (a, b) => {
|
|
7
|
+
for (var prop in b || (b = {}))
|
|
8
|
+
if (__hasOwnProp.call(b, prop))
|
|
9
|
+
__defNormalProp(a, prop, b[prop]);
|
|
10
|
+
if (__getOwnPropSymbols)
|
|
11
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
12
|
+
if (__propIsEnum.call(b, prop))
|
|
13
|
+
__defNormalProp(a, prop, b[prop]);
|
|
14
|
+
}
|
|
15
|
+
return a;
|
|
16
|
+
};
|
|
17
|
+
import { buildWmsTileUrl } from "../../components/viewers/map/datasets/src/urlSources";
|
|
18
|
+
import { layerColorByName } from "../../components/viewers/map/utils/stringToColour";
|
|
19
|
+
import { DatasetGroup } from "../../types/dbTypes";
|
|
20
|
+
import { pluginDatasetId } from "./pluginDatasetId";
|
|
21
|
+
const noFeatures = async () => ({ type: "FeatureCollection", features: [] });
|
|
22
|
+
function drawnBy(registration) {
|
|
23
|
+
const { source, pluginId } = registration;
|
|
24
|
+
if ((source == null ? void 0 : source.type) === "wms") {
|
|
25
|
+
const { baseUrl, layers, timeEnabled } = source;
|
|
26
|
+
return {
|
|
27
|
+
datasetType: "WMS",
|
|
28
|
+
type: "WMS",
|
|
29
|
+
url: buildWmsTileUrl(baseUrl, layers),
|
|
30
|
+
timeEnabled,
|
|
31
|
+
wms: { baseUrl, layers },
|
|
32
|
+
clickable: false,
|
|
33
|
+
getFeatures: noFeatures
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
if ((source == null ? void 0 : source.type) === "geojson") {
|
|
37
|
+
return {
|
|
38
|
+
datasetType: "GeoJSON",
|
|
39
|
+
type: "GeoJSON",
|
|
40
|
+
clickable: true,
|
|
41
|
+
getFeatures: async () => await source.getFeatures()
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
return { datasetType: "GeoJSON", type: "Plugin", clickable: false, drawnByPlugin: pluginId, getFeatures: noFeatures };
|
|
45
|
+
}
|
|
46
|
+
function toPluginDataset(registration, organization) {
|
|
47
|
+
const { pluginId, id, name, description, publisher, information, live = false } = registration;
|
|
48
|
+
const group = live ? DatasetGroup.National : DatasetGroup.Organizational;
|
|
49
|
+
return __spreadValues({
|
|
50
|
+
id: pluginDatasetId(pluginId, id),
|
|
51
|
+
name,
|
|
52
|
+
description,
|
|
53
|
+
publisher,
|
|
54
|
+
information,
|
|
55
|
+
organization: live ? void 0 : organization,
|
|
56
|
+
dataManagementSystem: "other",
|
|
57
|
+
countrySubdivision: "",
|
|
58
|
+
municipality: "",
|
|
59
|
+
group,
|
|
60
|
+
layerColor: layerColorByName(name),
|
|
61
|
+
portal: { id: -1, name: publisher != null ? publisher : name, group, dataManagementSystem: "Other", live },
|
|
62
|
+
getFields: async () => []
|
|
63
|
+
}, drawnBy(registration));
|
|
64
|
+
}
|
|
65
|
+
export {
|
|
66
|
+
toPluginDataset
|
|
67
|
+
};
|
|
68
|
+
//# sourceMappingURL=toPluginDataset.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/core/plugins/host/toPluginDataset.ts"],"sourcesContent":["// SPDX-License-Identifier: AGPL-3.0-or-later\n// Copyright (C) 2025 Collab Digital Twins\n\nimport { buildWmsTileUrl } from '../../components/viewers/map/datasets/src/urlSources'\nimport { layerColorByName } from '../../components/viewers/map/utils/stringToColour'\nimport { DatasetGroup } from '../../types/dbTypes'\n\nimport { pluginDatasetId } from './pluginDatasetId'\n\nimport type { PluginContribution } from './provider'\nimport type { Dataset } from '../../types/datasetTypes'\nimport type { AllGeoJSON } from '@turf/turf'\n\nconst noFeatures = async (): Promise<AllGeoJSON> =>\n ({ type: 'FeatureCollection', features: [] }) as AllGeoJSON\n\ntype DatasetContribution = PluginContribution<'map.datasets'>\n\nfunction drawnBy(registration: DatasetContribution): Pick<Dataset, 'datasetType' | 'type' | 'url' | 'timeEnabled' | 'wms' | 'getFeatures' | 'drawnByPlugin' | 'clickable'> {\n const { source, pluginId } = registration\n\n if (source?.type === 'wms') {\n const { baseUrl, layers, timeEnabled } = source\n return {\n datasetType: 'WMS',\n type: 'WMS',\n url: buildWmsTileUrl(baseUrl, layers),\n timeEnabled,\n wms: { baseUrl, layers },\n clickable: false,\n getFeatures: noFeatures,\n }\n }\n\n if (source?.type === 'geojson') {\n return {\n datasetType: 'GeoJSON',\n type: 'GeoJSON',\n clickable: true,\n getFeatures: async () => (await source.getFeatures()) as AllGeoJSON,\n }\n }\n\n return { datasetType: 'GeoJSON', type: 'Plugin', clickable: false, drawnByPlugin: pluginId, getFeatures: noFeatures }\n}\n\n/**\n * A `map.datasets` contribution as the Datasets menu lists it. A live one goes under Live\n * Data; any other is organizational, stamped with the viewer's own organization.\n */\nexport function toPluginDataset(registration: DatasetContribution, organization?: number): Dataset {\n const { pluginId, id, name, description, publisher, information, live = false } = registration\n const group = live ? DatasetGroup.National : DatasetGroup.Organizational\n\n return {\n id: pluginDatasetId(pluginId, id),\n name,\n description,\n publisher,\n information,\n organization: live ? undefined : organization,\n dataManagementSystem: 'other',\n countrySubdivision: '',\n municipality: '',\n group,\n layerColor: layerColorByName(name),\n portal: { id: -1, name: publisher ?? name, group, dataManagementSystem: 'Other', live },\n getFields: async () => [],\n ...drawnBy(registration),\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAGA,SAAS,uBAAuB;AAChC,SAAS,wBAAwB;AACjC,SAAS,oBAAoB;AAE7B,SAAS,uBAAuB;AAMhC,MAAM,aAAa,aAChB,EAAE,MAAM,qBAAqB,UAAU,CAAC,EAAE;AAI7C,SAAS,QAAQ,cAA0J;AACzK,QAAM,EAAE,QAAQ,SAAS,IAAI;AAE7B,OAAI,iCAAQ,UAAS,OAAO;AAC1B,UAAM,EAAE,SAAS,QAAQ,YAAY,IAAI;AACzC,WAAO;AAAA,MACL,aAAa;AAAA,MACb,MAAM;AAAA,MACN,KAAK,gBAAgB,SAAS,MAAM;AAAA,MACpC;AAAA,MACA,KAAK,EAAE,SAAS,OAAO;AAAA,MACvB,WAAW;AAAA,MACX,aAAa;AAAA,IACf;AAAA,EACF;AAEA,OAAI,iCAAQ,UAAS,WAAW;AAC9B,WAAO;AAAA,MACL,aAAa;AAAA,MACb,MAAM;AAAA,MACN,WAAW;AAAA,MACX,aAAa,YAAa,MAAM,OAAO,YAAY;AAAA,IACrD;AAAA,EACF;AAEA,SAAO,EAAE,aAAa,WAAW,MAAM,UAAU,WAAW,OAAO,eAAe,UAAU,aAAa,WAAW;AACtH;AAMO,SAAS,gBAAgB,cAAmC,cAAgC;AACjG,QAAM,EAAE,UAAU,IAAI,MAAM,aAAa,WAAW,aAAa,OAAO,MAAM,IAAI;AAClF,QAAM,QAAQ,OAAO,aAAa,WAAW,aAAa;AAE1D,SAAO;AAAA,IACL,IAAI,gBAAgB,UAAU,EAAE;AAAA,IAChC;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,cAAc,OAAO,SAAY;AAAA,IACjC,sBAAsB;AAAA,IACtB,oBAAoB;AAAA,IACpB,cAAc;AAAA,IACd;AAAA,IACA,YAAY,iBAAiB,IAAI;AAAA,IACjC,QAAQ,EAAE,IAAI,IAAI,MAAM,gCAAa,MAAM,OAAO,sBAAsB,SAAS,KAAK;AAAA,IACtF,WAAW,YAAY,CAAC;AAAA,KACrB,QAAQ,YAAY;AAE3B;","names":[]}
|
|
@@ -19,4 +19,6 @@ export { useComments, useComment, useCommentsByBuilding, useCommentsByAuthor, us
|
|
|
19
19
|
/** The plugin's config for this organization, shaped by the manifest's `configSchema`. */
|
|
20
20
|
export { usePluginConfig } from './config';
|
|
21
21
|
export { usePluginPermissions } from './permissions';
|
|
22
|
+
export { usePluginDataset } from './datasets';
|
|
23
|
+
export type { PluginDatasetState } from './datasets';
|
|
22
24
|
//# sourceMappingURL=data.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"data.d.ts","sourceRoot":"","sources":["../../../../src/core/plugins/sdk/data.ts"],"names":[],"mappings":"AAKA;;;;;;;;;GASG;AAGH,OAAO,EACL,YAAY,EACZ,WAAW,EACX,iBAAiB,EACjB,iBAAiB,GAClB,MAAM,iCAAiC,CAAA;AACxC,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAA;AAC3D,OAAO,EA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