@collabdt/core 0.5.4 → 0.7.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/dist/core/components/AppSidebarContent.d.ts.map +1 -1
- package/dist/core/components/AppSidebarContent.js +3 -2
- package/dist/core/components/AppSidebarContent.js.map +1 -1
- package/dist/core/components/viewers/plugins/src/PluginCard.d.ts.map +1 -1
- package/dist/core/components/viewers/plugins/src/PluginCard.js +33 -39
- package/dist/core/components/viewers/plugins/src/PluginCard.js.map +1 -1
- package/dist/core/plugins/hello-bim/manifest.json +2 -1
- package/dist/core/plugins/hello-bim/src/components/SpaceDialog.d.ts.map +1 -0
- package/dist/core/plugins/hello-bim/{components → src/components}/SpaceDialog.js +3 -3
- package/dist/core/plugins/hello-bim/src/components/SpaceDialog.js.map +1 -0
- package/dist/core/plugins/hello-bim/{components → src/components}/SpacesLegend.d.ts +1 -1
- package/dist/core/plugins/hello-bim/src/components/SpacesLegend.d.ts.map +1 -0
- package/dist/core/plugins/hello-bim/{components → src/components}/SpacesLegend.js +1 -1
- package/dist/core/plugins/hello-bim/src/components/SpacesLegend.js.map +1 -0
- package/dist/core/plugins/hello-bim/src/components/SpacesTab.d.ts.map +1 -0
- package/dist/core/plugins/hello-bim/{components → src/components}/SpacesTab.js +5 -5
- package/dist/core/plugins/hello-bim/src/components/SpacesTab.js.map +1 -0
- package/dist/core/plugins/hello-bim/{components → src/components}/SpacesTool.d.ts +1 -2
- package/dist/core/plugins/hello-bim/src/components/SpacesTool.d.ts.map +1 -0
- package/dist/core/plugins/hello-bim/{components → src/components}/SpacesTool.js +2 -2
- package/dist/core/plugins/hello-bim/src/components/SpacesTool.js.map +1 -0
- package/dist/core/plugins/hello-bim/src/components/icons.d.ts.map +1 -0
- package/dist/core/plugins/hello-bim/src/components/icons.js.map +1 -0
- package/dist/core/plugins/hello-bim/src/index.d.ts +10 -0
- package/dist/core/plugins/hello-bim/src/index.d.ts.map +1 -0
- package/dist/core/plugins/hello-bim/{index.js → src/index.js} +2 -3
- package/dist/core/plugins/hello-bim/src/index.js.map +1 -0
- package/dist/core/plugins/hello-bim/{spaces.d.ts → src/spaces.d.ts} +1 -1
- package/dist/core/plugins/hello-bim/src/spaces.d.ts.map +1 -0
- package/dist/core/plugins/hello-bim/{spaces.js → src/spaces.js} +4 -4
- package/dist/core/plugins/hello-bim/src/spaces.js.map +1 -0
- package/dist/core/plugins/hello-map/manifest.json +2 -1
- package/dist/core/plugins/hello-map/{components → src/components}/MapTool.d.ts +1 -2
- package/dist/core/plugins/hello-map/src/components/MapTool.d.ts.map +1 -0
- package/dist/core/plugins/hello-map/{components → src/components}/MapTool.js +3 -3
- package/dist/core/plugins/hello-map/src/components/MapTool.js.map +1 -0
- package/dist/core/plugins/hello-map/src/components/MarkerDialog.d.ts.map +1 -0
- package/dist/core/plugins/hello-map/{components → src/components}/MarkerDialog.js +2 -2
- package/dist/core/plugins/hello-map/src/components/MarkerDialog.js.map +1 -0
- package/dist/core/plugins/hello-map/{components → src/components}/MarkersLayer.d.ts +1 -1
- package/dist/core/plugins/hello-map/src/components/MarkersLayer.d.ts.map +1 -0
- package/dist/core/plugins/hello-map/{components → src/components}/MarkersLayer.js +1 -1
- package/dist/core/plugins/hello-map/src/components/MarkersLayer.js.map +1 -0
- package/dist/core/plugins/hello-map/{components → src/components}/MarkersLegend.d.ts +1 -1
- package/dist/core/plugins/hello-map/src/components/MarkersLegend.d.ts.map +1 -0
- package/dist/core/plugins/hello-map/{components → src/components}/MarkersLegend.js +1 -1
- package/dist/core/plugins/hello-map/src/components/MarkersLegend.js.map +1 -0
- package/dist/core/plugins/hello-map/{components → src/components}/MarkersPage.d.ts +1 -1
- package/dist/core/plugins/hello-map/src/components/MarkersPage.d.ts.map +1 -0
- package/dist/core/plugins/hello-map/{components → src/components}/MarkersPage.js +1 -1
- package/dist/core/plugins/hello-map/src/components/MarkersPage.js.map +1 -0
- package/dist/core/plugins/hello-map/src/components/MarkersTab.d.ts.map +1 -0
- package/dist/core/plugins/hello-map/{components → src/components}/MarkersTab.js +4 -4
- package/dist/core/plugins/hello-map/src/components/MarkersTab.js.map +1 -0
- package/dist/core/plugins/hello-map/src/index.d.ts +10 -0
- package/dist/core/plugins/hello-map/src/index.d.ts.map +1 -0
- package/dist/core/plugins/hello-map/{index.js → src/index.js} +2 -3
- package/dist/core/plugins/hello-map/src/index.js.map +1 -0
- package/dist/core/plugins/hello-map/src/markers.d.ts.map +1 -0
- package/dist/core/plugins/hello-map/{markers.js → src/markers.js} +3 -3
- package/dist/core/plugins/hello-map/src/markers.js.map +1 -0
- package/dist/core/plugins/host/PluginDataPageHost.js +1 -1
- package/dist/core/plugins/host/PluginDataPageHost.js.map +1 -1
- package/dist/core/plugins/host/context.d.ts.map +1 -1
- package/dist/core/plugins/host/context.js +16 -0
- package/dist/core/plugins/host/context.js.map +1 -1
- package/dist/core/plugins/host/pluginIcon.d.ts +5 -0
- package/dist/core/plugins/host/pluginIcon.d.ts.map +1 -0
- package/dist/core/plugins/host/pluginIcon.js +15 -0
- package/dist/core/plugins/host/pluginIcon.js.map +1 -0
- package/dist/core/plugins/host/runtimeShims.js.map +1 -1
- package/dist/core/plugins/host/usePluginDataPages.js +1 -1
- package/dist/core/plugins/host/usePluginDataPages.js.map +1 -1
- package/dist/core/plugins/host/usePluginToolbarTools.d.ts +0 -5
- package/dist/core/plugins/host/usePluginToolbarTools.d.ts.map +1 -1
- package/dist/core/plugins/host/usePluginToolbarTools.js +1 -12
- package/dist/core/plugins/host/usePluginToolbarTools.js.map +1 -1
- package/dist/core/plugins/host/usePluginViewerTabs.js +1 -1
- package/dist/core/plugins/host/usePluginViewerTabs.js.map +1 -1
- package/dist/core/plugins/installed.js +2 -2
- package/dist/core/plugins/installed.js.map +1 -1
- package/dist/core/plugins/manifests.js.map +1 -1
- package/dist/core/plugins/sdk/types.d.ts +11 -4
- package/dist/core/plugins/sdk/types.d.ts.map +1 -1
- package/dist/core/plugins/sdk/types.js.map +1 -1
- package/package.json +2 -1
- package/dist/core/plugins/hello-bim/components/SpaceDialog.d.ts.map +0 -1
- package/dist/core/plugins/hello-bim/components/SpaceDialog.js.map +0 -1
- package/dist/core/plugins/hello-bim/components/SpacesLegend.d.ts.map +0 -1
- package/dist/core/plugins/hello-bim/components/SpacesLegend.js.map +0 -1
- package/dist/core/plugins/hello-bim/components/SpacesTab.d.ts.map +0 -1
- package/dist/core/plugins/hello-bim/components/SpacesTab.js.map +0 -1
- package/dist/core/plugins/hello-bim/components/SpacesTool.d.ts.map +0 -1
- package/dist/core/plugins/hello-bim/components/SpacesTool.js.map +0 -1
- package/dist/core/plugins/hello-bim/components/icons.d.ts.map +0 -1
- package/dist/core/plugins/hello-bim/components/icons.js.map +0 -1
- package/dist/core/plugins/hello-bim/index.d.ts +0 -7
- package/dist/core/plugins/hello-bim/index.d.ts.map +0 -1
- package/dist/core/plugins/hello-bim/index.js.map +0 -1
- package/dist/core/plugins/hello-bim/spaces.d.ts.map +0 -1
- package/dist/core/plugins/hello-bim/spaces.js.map +0 -1
- package/dist/core/plugins/hello-map/components/MapTool.d.ts.map +0 -1
- package/dist/core/plugins/hello-map/components/MapTool.js.map +0 -1
- package/dist/core/plugins/hello-map/components/MarkerDialog.d.ts.map +0 -1
- package/dist/core/plugins/hello-map/components/MarkerDialog.js.map +0 -1
- package/dist/core/plugins/hello-map/components/MarkersLayer.d.ts.map +0 -1
- package/dist/core/plugins/hello-map/components/MarkersLayer.js.map +0 -1
- package/dist/core/plugins/hello-map/components/MarkersLegend.d.ts.map +0 -1
- package/dist/core/plugins/hello-map/components/MarkersLegend.js.map +0 -1
- package/dist/core/plugins/hello-map/components/MarkersPage.d.ts.map +0 -1
- package/dist/core/plugins/hello-map/components/MarkersPage.js.map +0 -1
- package/dist/core/plugins/hello-map/components/MarkersTab.d.ts.map +0 -1
- package/dist/core/plugins/hello-map/components/MarkersTab.js.map +0 -1
- package/dist/core/plugins/hello-map/index.d.ts +0 -7
- package/dist/core/plugins/hello-map/index.d.ts.map +0 -1
- package/dist/core/plugins/hello-map/index.js.map +0 -1
- package/dist/core/plugins/hello-map/markers.d.ts.map +0 -1
- package/dist/core/plugins/hello-map/markers.js.map +0 -1
- /package/dist/core/plugins/hello-bim/{components → src/components}/SpaceDialog.d.ts +0 -0
- /package/dist/core/plugins/hello-bim/{components → src/components}/SpacesTab.d.ts +0 -0
- /package/dist/core/plugins/hello-bim/{components → src/components}/icons.d.ts +0 -0
- /package/dist/core/plugins/hello-bim/{components → src/components}/icons.js +0 -0
- /package/dist/core/plugins/hello-map/{components → src/components}/MarkerDialog.d.ts +0 -0
- /package/dist/core/plugins/hello-map/{components → src/components}/MarkersTab.d.ts +0 -0
- /package/dist/core/plugins/hello-map/{markers.d.ts → src/markers.d.ts} +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../../src/core/plugins/hello-bim/src/components/icons.tsx"],"sourcesContent":["'use client'\r\n\r\n// SPDX-License-Identifier: AGPL-3.0-or-later\r\n// Copyright (C) 2025 Collab Digital Twins\r\n\r\nimport * as React from 'react'\r\n\r\n/**\r\n * Drawn here: `lucide-react` is unshimmed, so a plugin cannot import it. Icon *names* work in\r\n * registrations, where the host resolves them. Labels live on each button's aria-label.\r\n */\r\nexport function Glyph({ children }: { children: React.ReactNode }) {\r\n return (\r\n <svg\r\n viewBox=\"0 0 24 24\"\r\n className=\"h-4 w-4\"\r\n fill=\"none\"\r\n stroke=\"currentColor\"\r\n strokeWidth=\"2\"\r\n strokeLinecap=\"round\"\r\n strokeLinejoin=\"round\"\r\n aria-hidden=\"true\"\r\n >\r\n {children}\r\n </svg>\r\n )\r\n}\r\n\r\nexport function CheckIcon() {\r\n return <path d=\"M20 6 9 17l-5-5\" />\r\n}\r\n\r\nexport function XIcon() {\r\n return <><path d=\"M18 6 6 18\" /><path d=\"m6 6 12 12\" /></>\r\n}\r\n\r\n/** Smaller than the button glyphs — it sits inside a 24px swatch, not a 32px button. */\r\nexport function PlusIcon() {\r\n return (\r\n <svg\r\n viewBox=\"0 0 24 24\"\r\n className=\"h-3 w-3\"\r\n fill=\"none\"\r\n stroke=\"currentColor\"\r\n strokeWidth=\"2.5\"\r\n strokeLinecap=\"round\"\r\n aria-hidden=\"true\"\r\n >\r\n <path d=\"M5 12h14\" />\r\n <path d=\"M12 5v14\" />\r\n </svg>\r\n )\r\n}\r\n"],"mappings":";AAaI,SAoBK,UApBL,KAoBK,YApBL;AAFG,SAAS,MAAM,EAAE,SAAS,GAAkC;AACjE,SACE;AAAA,IAAC;AAAA;AAAA,MACC,SAAQ;AAAA,MACR,WAAU;AAAA,MACV,MAAK;AAAA,MACL,QAAO;AAAA,MACP,aAAY;AAAA,MACZ,eAAc;AAAA,MACd,gBAAe;AAAA,MACf,eAAY;AAAA,MAEX;AAAA;AAAA,EACH;AAEJ;AAEO,SAAS,YAAY;AAC1B,SAAO,oBAAC,UAAK,GAAE,mBAAkB;AACnC;AAEO,SAAS,QAAQ;AACtB,SAAO,iCAAE;AAAA,wBAAC,UAAK,GAAE,cAAa;AAAA,IAAE,oBAAC,UAAK,GAAE,cAAa;AAAA,KAAE;AACzD;AAGO,SAAS,WAAW;AACzB,SACE;AAAA,IAAC;AAAA;AAAA,MACC,SAAQ;AAAA,MACR,WAAU;AAAA,MACV,MAAK;AAAA,MACL,QAAO;AAAA,MACP,aAAY;AAAA,MACZ,eAAc;AAAA,MACd,eAAY;AAAA,MAEZ;AAAA,4BAAC,UAAK,GAAE,YAAW;AAAA,QACnB,oBAAC,UAAK,GAAE,YAAW;AAAA;AAAA;AAAA,EACrB;AAEJ;","names":[]}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { BimToolProps, PluginContext } from '@collabdt/plugin-kit/types/bim';
|
|
2
|
+
import type { LegendRegistration } from '@collabdt/plugin-kit/types/legend';
|
|
3
|
+
type Ctx = PluginContext<unknown, BimToolProps, unknown, LegendRegistration>;
|
|
4
|
+
/**
|
|
5
|
+
* Four surfaces over the model IfcSpaces, all reading one hook. The IFC is never written to:
|
|
6
|
+
* a renamed space is an annotation this plugin stores, and the dialog shows both names.
|
|
7
|
+
*/
|
|
8
|
+
export declare function activate(ctx: Ctx): void;
|
|
9
|
+
export {};
|
|
10
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/core/plugins/hello-bim/src/index.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,gCAAgC,CAAA;AACjF,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,mCAAmC,CAAA;AAE3E,KAAK,GAAG,GAAG,aAAa,CAAC,OAAO,EAAE,YAAY,EAAE,OAAO,EAAE,kBAAkB,CAAC,CAAA;AAE5E;;;GAGG;AACH,wBAAgB,QAAQ,CAAC,GAAG,EAAE,GAAG,GAAG,IAAI,CA+BvC"}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { ViewerNames } from "../sdk/types";
|
|
2
1
|
import { SpaceDialog } from "./components/SpaceDialog";
|
|
3
2
|
import { useSpacesLegend } from "./components/SpacesLegend";
|
|
4
3
|
import { SpacesTab } from "./components/SpacesTab";
|
|
@@ -16,13 +15,13 @@ function activate(ctx) {
|
|
|
16
15
|
labelKey: "tabTitle",
|
|
17
16
|
icon: "Boxes",
|
|
18
17
|
// BIM only: there are no IfcSpaces to annotate on the map or in a point cloud.
|
|
19
|
-
viewers: [
|
|
18
|
+
viewers: ["bim"],
|
|
20
19
|
component: SpacesTab
|
|
21
20
|
});
|
|
22
21
|
ctx.register("viewer.legends", {
|
|
23
22
|
id: "spaces",
|
|
24
23
|
title: "Spaces",
|
|
25
|
-
viewers: [
|
|
24
|
+
viewers: ["bim"],
|
|
26
25
|
useLegend: useSpacesLegend
|
|
27
26
|
});
|
|
28
27
|
ctx.register("ui.dialogs", {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../src/core/plugins/hello-bim/src/index.ts"],"sourcesContent":["// SPDX-License-Identifier: AGPL-3.0-or-later\r\n// Copyright (C) 2025 Collab Digital Twins\r\n\r\nimport { SpaceDialog } from './components/SpaceDialog'\r\nimport { useSpacesLegend } from './components/SpacesLegend'\r\nimport { SpacesTab } from './components/SpacesTab'\r\nimport { SpacesTool } from './components/SpacesTool'\r\n\r\nimport type { BimToolProps, PluginContext } from '@collabdt/plugin-kit/types/bim'\r\nimport type { LegendRegistration } from '@collabdt/plugin-kit/types/legend'\r\n\r\ntype Ctx = PluginContext<unknown, BimToolProps, unknown, LegendRegistration>\r\n\r\n/**\r\n * Four surfaces over the model IfcSpaces, all reading one hook. The IFC is never written to:\r\n * a renamed space is an annotation this plugin stores, and the dialog shows both names.\r\n */\r\nexport function activate(ctx: Ctx): void {\r\n ctx.register('bim.tools', {\r\n id: 'hello-bim',\r\n label: 'Spaces',\r\n icon: 'Boxes',\r\n component: SpacesTool,\r\n stayActive: true,\r\n })\r\n\r\n ctx.register('viewer.tabs', {\r\n id: 'spaces',\r\n labelKey: 'tabTitle',\r\n icon: 'Boxes',\r\n // BIM only: there are no IfcSpaces to annotate on the map or in a point cloud.\r\n viewers: ['bim'],\r\n component: SpacesTab,\r\n })\r\n\r\n ctx.register('viewer.legends', {\r\n id: 'spaces',\r\n title: 'Spaces',\r\n viewers: ['bim'],\r\n useLegend: useSpacesLegend,\r\n })\r\n\r\n ctx.register('ui.dialogs', {\r\n id: 'detail',\r\n titleKey: 'dialogTitle',\r\n size: 'md',\r\n component: SpaceDialog,\r\n })\r\n}\r\n"],"mappings":"AAGA,SAAS,mBAAmB;AAC5B,SAAS,uBAAuB;AAChC,SAAS,iBAAiB;AAC1B,SAAS,kBAAkB;AAWpB,SAAS,SAAS,KAAgB;AACvC,MAAI,SAAS,aAAa;AAAA,IACxB,IAAI;AAAA,IACJ,OAAO;AAAA,IACP,MAAM;AAAA,IACN,WAAW;AAAA,IACX,YAAY;AAAA,EACd,CAAC;AAED,MAAI,SAAS,eAAe;AAAA,IAC1B,IAAI;AAAA,IACJ,UAAU;AAAA,IACV,MAAM;AAAA;AAAA,IAEN,SAAS,CAAC,KAAK;AAAA,IACf,WAAW;AAAA,EACb,CAAC;AAED,MAAI,SAAS,kBAAkB;AAAA,IAC7B,IAAI;AAAA,IACJ,OAAO;AAAA,IACP,SAAS,CAAC,KAAK;AAAA,IACf,WAAW;AAAA,EACb,CAAC;AAED,MAAI,SAAS,cAAc;AAAA,IACzB,IAAI;AAAA,IACJ,UAAU;AAAA,IACV,MAAM;AAAA,IACN,WAAW;AAAA,EACb,CAAC;AACH;","names":[]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ModelIdMap } from '
|
|
1
|
+
import type { ModelIdMap } from '@collabdt/plugin-kit/types/bim';
|
|
2
2
|
/** What the plugin stores about one space. The IFC model itself is never written to. */
|
|
3
3
|
export interface SpaceAnnotation extends Record<string, unknown> {
|
|
4
4
|
/** Replaces the IFC name in this plugin's own surfaces. */
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"spaces.d.ts","sourceRoot":"","sources":["../../../../../src/core/plugins/hello-bim/src/spaces.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gCAAgC,CAAA;AAEhE,wFAAwF;AACxF,MAAM,WAAW,eAAgB,SAAQ,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IAC9D,2DAA2D;IAC3D,IAAI,EAAE,MAAM,CAAA;IACZ,MAAM,EAAE,MAAM,CAAA;CACf;AAED,MAAM,WAAW,KAAK;IACpB,6FAA6F;IAC7F,GAAG,EAAE,MAAM,CAAA;IACX,OAAO,EAAE,MAAM,CAAA;IACf,OAAO,EAAE,MAAM,CAAA;IACf,uCAAuC;IACvC,OAAO,EAAE,MAAM,CAAA;IACf,oEAAoE;IACpE,IAAI,EAAE,MAAM,CAAA;IACZ,MAAM,EAAE,MAAM,CAAA;IACd,6DAA6D;IAC7D,SAAS,EAAE,OAAO,CAAA;CACnB;AAED,wBAAgB,QAAQ,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,CAEjE;AAED,uEAAuE;AACvE,wBAAgB,YAAY,CAAC,MAAM,EAAE,KAAK,EAAE,GAAG,UAAU,CAMxD;AAED,MAAM,WAAW,eAAe;IAC9B,OAAO,EAAE,MAAM,CAAA;IACf,OAAO,EAAE,MAAM,CAAA;IACf,OAAO,EAAE,MAAM,CAAA;CAChB;AAKD,wBAAgB,iBAAiB,IAAI;IAAE,UAAU,EAAE,eAAe,EAAE,CAAC;IAAC,QAAQ,EAAE,OAAO,CAAA;CAAE,CAiDxF;AAgBD;;;GAGG;AACH,wBAAgB,SAAS;;;;;;kBAoET,MAAM,QAAQ,MAAM;qBAS1B,MAAM,UAAU,MAAM;iBAMhB,MAAM;EAiBrB;AAED;;;GAGG;AACH,wBAAgB,gBAAgB;;;EAuB/B;AAED,4DAA4D;AAC5D,wBAAgB,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAE/C"}
|
|
@@ -16,10 +16,10 @@ var __spreadValues = (a, b) => {
|
|
|
16
16
|
return a;
|
|
17
17
|
};
|
|
18
18
|
import * as React from "react";
|
|
19
|
-
import { stringToColour } from "
|
|
20
|
-
import { usePluginBimAppearance, useBimViewer } from "
|
|
21
|
-
import { usePluginState } from "
|
|
22
|
-
import { usePluginStore } from "
|
|
19
|
+
import { stringToColour } from "@collabdt/core/plugins-sdk";
|
|
20
|
+
import { usePluginBimAppearance, useBimViewer } from "@collabdt/core/plugins-sdk/bimViewer";
|
|
21
|
+
import { usePluginState } from "@collabdt/core/plugins-sdk/state";
|
|
22
|
+
import { usePluginStore } from "@collabdt/core/plugins-sdk/store";
|
|
23
23
|
function spaceKey(modelId, localId) {
|
|
24
24
|
return `${modelId}::${localId}`;
|
|
25
25
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../src/core/plugins/hello-bim/src/spaces.ts"],"sourcesContent":["'use client'\r\n\r\n// SPDX-License-Identifier: AGPL-3.0-or-later\r\n// Copyright (C) 2025 Collab Digital Twins\r\n\r\nimport * as React from 'react'\r\n\r\nimport { stringToColour } from '@collabdt/core/plugins-sdk'\r\nimport { usePluginBimAppearance, useBimViewer } from '@collabdt/core/plugins-sdk/bimViewer'\r\nimport { usePluginState } from '@collabdt/core/plugins-sdk/state'\r\nimport { usePluginStore } from '@collabdt/core/plugins-sdk/store'\r\n\r\nimport type { ModelIdMap } from '@collabdt/plugin-kit/types/bim'\r\n\r\n/** What the plugin stores about one space. The IFC model itself is never written to. */\r\nexport interface SpaceAnnotation extends Record<string, unknown> {\r\n /** Replaces the IFC name in this plugin's own surfaces. */\r\n name: string\r\n colour: string\r\n}\r\n\r\nexport interface Space {\r\n /** `<modelId>::<localId>` — stable for as long as the model is, and safe as a record key. */\r\n key: string\r\n modelId: string\r\n localId: number\r\n /** From the IFC, and never changed. */\r\n ifcName: string\r\n /** The annotation's name when there is one, otherwise the IFC's. */\r\n name: string\r\n colour: string\r\n /** Whether the plugin has stored anything for this space. */\r\n annotated: boolean\r\n}\r\n\r\nexport function spaceKey(modelId: string, localId: number): string {\r\n return `${modelId}::${localId}`\r\n}\r\n\r\n/** Sets, not arrays: `ModelIdMap` is `Record<string, Set<number>>`. */\r\nexport function toModelIdMap(spaces: Space[]): ModelIdMap {\r\n const items: ModelIdMap = {}\r\n for (const space of spaces) {\r\n (items[space.modelId] ??= new Set<number>()).add(space.localId)\r\n }\r\n return items\r\n}\r\n\r\nexport interface DiscoveredSpace {\r\n modelId: string\r\n localId: number\r\n ifcName: string\r\n}\r\n\r\n// Module scope, not plugin state: a state claim is an effect dep, so it cancels its own scan.\r\nconst scans = new Map<string, Promise<DiscoveredSpace[]>>()\r\n\r\nexport function useSpaceDiscovery(): { discovered: DiscoveredSpace[]; scanning: boolean } {\r\n const { components, modelIds, getItemsOfCategory, getProperties } = useBimViewer()\r\n const [discovered, setDiscovered] = usePluginState<DiscoveredSpace[]>('discovered', [])\r\n const [scannedFor, setScannedFor] = usePluginState<string | null>('scannedFor', null)\r\n\r\n const modelKey = modelIds.join('|')\r\n\r\n React.useEffect(() => {\r\n if (!components || modelKey === scannedFor) return\r\n\r\n if (modelIds.length === 0) {\r\n setDiscovered([])\r\n setScannedFor(modelKey)\r\n return\r\n }\r\n\r\n let cancelled = false\r\n\r\n const scan = scans.get(modelKey) ?? (async () => {\r\n const items = await getItemsOfCategory('IFCSPACE')\r\n const properties = await getProperties(items, ['Name', 'LongName'])\r\n\r\n return properties.map(entry => ({\r\n modelId: entry.modelId,\r\n localId: entry.localId,\r\n ifcName: readName(entry) ?? `Space ${entry.localId}`,\r\n }))\r\n })()\r\n\r\n scans.set(modelKey, scan)\r\n\r\n void scan\r\n .then((found) => {\r\n if (cancelled) return\r\n setDiscovered(found)\r\n // Only once there is a result, or a cancelled surface marks it looked-at.\r\n setScannedFor(modelKey)\r\n })\r\n .catch((error) => {\r\n console.error('[hello-bim] could not read the model\\'s spaces:', error)\r\n scans.delete(modelKey)\r\n })\r\n\r\n return () => {\r\n cancelled = true\r\n }\r\n }, [components, modelKey, modelIds, scannedFor, getItemsOfCategory, getProperties, setDiscovered, setScannedFor])\r\n\r\n return { discovered, scanning: components !== null && modelKey !== scannedFor }\r\n}\r\n\r\n/** IFC attributes arrive bare or wrapped in `{ value }`, depending on the model. */\r\nfunction readName(entry: Record<string, unknown>): string | null {\r\n for (const key of ['LongName', 'Name']) {\r\n const raw = entry[key]\r\n if (typeof raw === 'string' && raw.trim()) return raw.trim()\r\n\r\n if (raw && typeof raw === 'object' && 'value' in raw) {\r\n const value = (raw as { value: unknown }).value\r\n if (typeof value === 'string' && value.trim()) return value.trim()\r\n }\r\n }\r\n return null\r\n}\r\n\r\n/**\r\n * The spaces, plus the annotations this plugin stores against them. The IFC is read-only, so\r\n * a rename is an annotation, never a write to the model.\r\n */\r\nexport function useSpaces() {\r\n const { discovered, scanning } = useSpaceDiscovery()\r\n const store = usePluginStore<SpaceAnnotation>('spaces')\r\n const [selectedKey, setSelectedKey] = usePluginState<string | null>('selected', null)\r\n const [lastError, setLastError] = usePluginState<string | null>('lastError', null)\r\n\r\n const attempt = React.useCallback(\r\n async (action: () => Promise<void>) => {\r\n try {\r\n await action()\r\n setLastError(null)\r\n return true\r\n }\r\n catch (error) {\r\n const message = error instanceof Error ? error.message : String(error)\r\n console.error('[hello-bim] save failed:', error)\r\n setLastError(message)\r\n return false\r\n }\r\n },\r\n [setLastError],\r\n )\r\n\r\n const annotations = React.useMemo(\r\n () => new Map(store.items.map(item => [item.key, item.data])),\r\n [store.items],\r\n )\r\n\r\n const spaces = React.useMemo<Space[]>(\r\n () => discovered.map((found) => {\r\n const key = spaceKey(found.modelId, found.localId)\r\n const annotation = annotations.get(key)\r\n\r\n return {\r\n key,\r\n modelId: found.modelId,\r\n localId: found.localId,\r\n ifcName: found.ifcName,\r\n name: annotation?.name ?? found.ifcName,\r\n // Hashed, so an unpicked colour is stable per space rather than shuffling.\r\n colour: annotation?.colour ?? stringToColour(key),\r\n annotated: annotation !== undefined,\r\n }\r\n }),\r\n [discovered, annotations],\r\n )\r\n\r\n const byKey = React.useMemo(\r\n () => new Map(spaces.map(space => [space.key, space])),\r\n [spaces],\r\n )\r\n\r\n /** One edit path, so a field added to the annotation cannot be dropped by a rename. */\r\n const patch = React.useCallback(\r\n async (key: string, changes: Partial<SpaceAnnotation>) => {\r\n const current = byKey.get(key)\r\n if (!current) return\r\n\r\n await attempt(() => store.put(key, {\r\n name: current.name,\r\n colour: current.colour,\r\n ...changes,\r\n }))\r\n },\r\n [store, byKey, attempt],\r\n )\r\n\r\n const rename = React.useCallback(\r\n async (key: string, name: string) => {\r\n const trimmed = name.trim()\r\n if (!trimmed || trimmed === byKey.get(key)?.name) return\r\n await patch(key, { name: trimmed })\r\n },\r\n [patch, byKey],\r\n )\r\n\r\n const setColour = React.useCallback(\r\n (key: string, colour: string) => patch(key, { colour }),\r\n [patch],\r\n )\r\n\r\n /** Drops the annotation, so the space goes back to its IFC name and a hashed colour. */\r\n const reset = React.useCallback(\r\n async (key: string) => {\r\n if (!byKey.get(key)?.annotated) return\r\n await attempt(() => store.remove(key))\r\n },\r\n [store, byKey, attempt],\r\n )\r\n\r\n return {\r\n spaces,\r\n isLoading: store.isLoading || scanning,\r\n lastError,\r\n selected: selectedKey === null ? null : byKey.get(selectedKey) ?? null,\r\n select: setSelectedKey,\r\n rename,\r\n setColour,\r\n reset,\r\n }\r\n}\r\n\r\n/**\r\n * Whether the spaces are painted, applied from an effect so a recolour repaints at once.\r\n * The flag is plugin state, so the toolbar and the tab agree on it.\r\n */\r\nexport function useSpacePainting() {\r\n const { spaces } = useSpaces()\r\n const { setItemsVisible } = useBimViewer()\r\n const { setAppearance, clearAppearance } = usePluginBimAppearance()\r\n const [painted, setPainted] = usePluginState('painted', false)\r\n\r\n React.useEffect(() => {\r\n if (!painted) {\r\n clearAppearance()\r\n return\r\n }\r\n if (spaces.length === 0) return\r\n\r\n // IfcSpaces start hidden, so painting them without this colours nothing visible.\r\n void setItemsVisible(toModelIdMap(spaces), true)\r\n\r\n setAppearance(spaces.map(space => ({\r\n items: toModelIdMap([space]),\r\n appearance: { color: hexToInt(space.colour) },\r\n })))\r\n }, [painted, spaces, setAppearance, clearAppearance, setItemsVisible])\r\n\r\n return { painted, setPainted }\r\n}\r\n\r\n/** `#rrggbb` to the `0xRRGGBB` the appearance API takes. */\r\nexport function hexToInt(colour: string): number {\r\n return Number.parseInt(colour.replace('#', ''), 16)\r\n}\r\n"],"mappings":";;;;;;;;;;;;;;;;;AAKA,YAAY,WAAW;AAEvB,SAAS,sBAAsB;AAC/B,SAAS,wBAAwB,oBAAoB;AACrD,SAAS,sBAAsB;AAC/B,SAAS,sBAAsB;AAyBxB,SAAS,SAAS,SAAiB,SAAyB;AACjE,SAAO,GAAG,OAAO,KAAK,OAAO;AAC/B;AAGO,SAAS,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G,EAAE;AACpD;","names":["_a"]}
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
"hostApi": 1,
|
|
6
6
|
"description": "Records markers on the map and shows them everywhere: a toolbar readout, a map layer, a legend, a viewer sidebar tab, a data page and a dialog.",
|
|
7
7
|
"author": "Collab Digital Twins",
|
|
8
|
+
"icon": "MapPin",
|
|
8
9
|
"capabilities": [
|
|
9
10
|
"map.tools",
|
|
10
11
|
"map.layers",
|
|
@@ -126,4 +127,4 @@
|
|
|
126
127
|
"nameLabel": "Nombre"
|
|
127
128
|
}
|
|
128
129
|
}
|
|
129
|
-
}
|
|
130
|
+
}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import type { MapToolProps } from '
|
|
3
|
-
import type { ToolbarToolProps } from '../../sdk/types';
|
|
2
|
+
import type { MapToolProps, ToolbarToolProps } from '@collabdt/plugin-kit/types/map';
|
|
4
3
|
/**
|
|
5
4
|
* Where the map is, and a button to record it. The marker itself is drawn by `MarkersLayer`,
|
|
6
5
|
* because this panel unmounts as soon as the dropdown closes.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MapTool.d.ts","sourceRoot":"","sources":["../../../../../../src/core/plugins/hello-map/src/components/MapTool.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAQ9B,OAAO,KAAK,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAA;AAMpF;;;GAGG;AACH,wBAAgB,OAAO,CAAC,EAAE,GAAG,EAAE,EAAE,gBAAgB,GAAG,YAAY,qBA4E/D"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
3
3
|
import * as React from "react";
|
|
4
|
-
import { Button, Separator } from "
|
|
5
|
-
import { usePluginConfig } from "
|
|
6
|
-
import { usePluginTranslations } from "
|
|
4
|
+
import { Button, Separator } from "@collabdt/core/plugins-sdk/components";
|
|
5
|
+
import { usePluginConfig } from "@collabdt/core/plugins-sdk/config";
|
|
6
|
+
import { usePluginTranslations } from "@collabdt/core/plugins-sdk/messages";
|
|
7
7
|
import { useMarkers } from "../markers";
|
|
8
8
|
function MapTool({ map }) {
|
|
9
9
|
const t = usePluginTranslations();
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../../src/core/plugins/hello-map/src/components/MapTool.tsx"],"sourcesContent":["'use client'\r\n\r\n// SPDX-License-Identifier: AGPL-3.0-or-later\r\n// Copyright (C) 2025 Collab Digital Twins\r\n\r\nimport * as React from 'react'\r\n\r\nimport { Button, Separator } from '@collabdt/core/plugins-sdk/components'\r\nimport { usePluginConfig } from '@collabdt/core/plugins-sdk/config'\r\nimport { usePluginTranslations } from '@collabdt/core/plugins-sdk/messages'\n\r\nimport { useMarkers } from '../markers'\r\n\r\nimport type { MapToolProps, ToolbarToolProps } from '@collabdt/plugin-kit/types/map'\r\n\r\ninterface Config extends Record<string, unknown> {\r\n decimals?: number\r\n}\r\n\r\n/**\r\n * Where the map is, and a button to record it. The marker itself is drawn by `MarkersLayer`,\r\n * because this panel unmounts as soon as the dropdown closes.\r\n */\r\nexport function MapTool({ map }: ToolbarToolProps & MapToolProps) {\r\n const t = usePluginTranslations()\r\n const { decimals = 5 } = usePluginConfig<Config>()\r\n const { add, markers, lastError } = useMarkers()\r\n\r\n const [view, setView] = React.useState<{ lng: number; lat: number; zoom: number } | null>(null)\r\n const [saving, setSaving] = React.useState(false)\r\n\r\n React.useEffect(() => {\r\n if (!map) return\r\n\r\n const read = () => {\r\n const centre = map.getCenter()\r\n setView({ lng: centre.lng, lat: centre.lat, zoom: map.getZoom() })\r\n }\r\n\r\n read()\r\n map.on('move', read)\r\n return () => {\r\n map.off('move', read)\r\n }\r\n }, [map])\r\n\r\n const record = async () => {\r\n if (!view || saving) return\r\n\r\n setSaving(true)\r\n try {\r\n await add(view.lat, view.lng, view.zoom)\r\n } finally {\r\n setSaving(false)\r\n }\r\n }\r\n\r\n return (\r\n <div className=\"w-64 p-1\">\r\n <p className=\"px-2 py-1 text-sm font-medium\">{t('title', 'Hello Map')}</p>\r\n <Separator className=\"my-1\" />\r\n\r\n {view ? (\r\n <>\r\n <dl className=\"px-2 py-1 text-sm\">\r\n <Row label={t('latitude', 'Latitude')} value={view.lat.toFixed(decimals)} />\r\n <Row label={t('longitude', 'Longitude')} value={view.lng.toFixed(decimals)} />\r\n <Row label={t('zoom', 'Zoom')} value={view.zoom.toFixed(2)} />\r\n </dl>\r\n\r\n <Separator className=\"my-1\" />\r\n\r\n <Button\r\n size=\"sm\"\r\n variant=\"ghost\"\r\n className=\"w-full justify-start font-normal\"\r\n disabled={saving}\r\n onClick={() => { void record() }}\r\n >\r\n {saving ? t('recording', 'Recording…') : t('record', 'Record a marker here')}\r\n </Button>\r\n\r\n <p className=\"px-2 py-1 text-xs text-muted-foreground\">\r\n {t('markerCount', 'Markers: ')}{markers.length}\r\n </p>\r\n\r\n {lastError && (\r\n <p className=\"px-2 py-1 text-xs text-destructive\">\r\n {t('saveFailed', 'Could not save: ')}{lastError}\r\n </p>\r\n )}\r\n </>\r\n ) : (\r\n <p className=\"px-2 py-1 text-sm text-muted-foreground\">\r\n {t('waiting', 'Waiting for the map…')}\r\n </p>\r\n )}\r\n </div>\r\n )\r\n}\r\n\r\nfunction Row({ label, value }: { label: string; value: string }) {\r\n return (\r\n <div className=\"flex items-baseline justify-between gap-3 py-0.5\">\r\n <dt className=\"text-muted-foreground\">{label}</dt>\r\n <dd className=\"tabular-nums\">{value}</dd>\r\n </div>\r\n )\r\n}\r\n"],"mappings":";AA2DM,SAIE,UAJF,KAKI,YALJ;AAtDN,YAAY,WAAW;AAEvB,SAAS,QAAQ,iBAAiB;AAClC,SAAS,uBAAuB;AAChC,SAAS,6BAA6B;AAEtC,SAAS,kBAAkB;AAYpB,SAAS,QAAQ,EAAE,IAAI,GAAoC;AAChE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A,SAC9D;AAAA,MAEA,oBAAC,aAAU,WAAU,QAAO;AAAA,MAE5B;AAAA,QAAC;AAAA;AAAA,UACC,MAAK;AAAA,UACL,SAAQ;AAAA,UACR,WAAU;AAAA,UACV,UAAU;AAAA,UACV,SAAS,MAAM;AAAE,iBAAK,OAAO;AAAA,UAAE;AAAA,UAE9B,mBAAS,EAAE,aAAa,iBAAY,IAAI,EAAE,UAAU,sBAAsB;AAAA;AAAA,MAC7E;AAAA,MAEA,qBAAC,OAAE,WAAU,2CACV;AAAA,UAAE,eAAe,WAAW;AAAA,QAAG,QAAQ;AAAA,SAC1C;AAAA,MAEC,aACC,qBAAC,OAAE,WAAU,sCACV;AAAA,UAAE,cAAc,kBAAkB;AAAA,QAAG;AAAA,SACxC;AAAA,OAEJ,IAEA,oBAAC,OAAE,WAAU,2CACV,YAAE,WAAW,2BAAsB,GACtC;AAAA,KAEJ;AAEJ;AAEA,SAAS,IAAI,EAAE,OAAO,MAAM,GAAqC;AAC/D,SACE,qBAAC,SAAI,WAAU,oDACb;AAAA,wBAAC,QAAG,WAAU,yBAAyB,iBAAM;AAAA,IAC7C,oBAAC,QAAG,WAAU,gBAAgB,iBAAM;AAAA,KACtC;AAEJ;","names":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MarkerDialog.d.ts","sourceRoot":"","sources":["../../../../../../src/core/plugins/hello-map/src/components/MarkerDialog.tsx"],"names":[],"mappings":"AAUA,UAAU,KAAK;IACb,KAAK,EAAE,MAAM,IAAI,CAAA;IACjB,yFAAyF;IACzF,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB;AAED,8FAA8F;AAC9F,wBAAgB,YAAY,CAAC,EAAE,KAAK,EAAE,SAAS,EAAE,EAAE,KAAK,+BAwCvD"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
-
import { Button } from "
|
|
4
|
-
import { usePluginTranslations } from "
|
|
3
|
+
import { Button } from "@collabdt/core/plugins-sdk/components";
|
|
4
|
+
import { usePluginTranslations } from "@collabdt/core/plugins-sdk/messages";
|
|
5
5
|
import { useMarkers } from "../markers";
|
|
6
6
|
function MarkerDialog({ close, markerKey }) {
|
|
7
7
|
var _a;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../../src/core/plugins/hello-map/src/components/MarkerDialog.tsx"],"sourcesContent":["'use client'\r\n\r\n// SPDX-License-Identifier: AGPL-3.0-or-later\r\n// Copyright (C) 2025 Collab Digital Twins\r\n\r\nimport { Button } from '@collabdt/core/plugins-sdk/components'\r\nimport { usePluginTranslations } from '@collabdt/core/plugins-sdk/messages'\n\r\nimport { useMarkers } from '../markers'\r\n\r\ninterface Props {\r\n close: () => void\r\n /** Supplied by whichever surface opened this — the sidebar tab, or a row on the page. */\r\n markerKey?: string\r\n}\r\n\r\n/** One marker in full. Core owns the overlay and Escape; this outlives whatever opened it. */\r\nexport function MarkerDialog({ close, markerKey }: Props) {\r\n const t = usePluginTranslations()\r\n const { markers, selected } = useMarkers()\r\n\r\n const marker = markerKey\r\n ? markers.find(candidate => candidate.key === markerKey) ?? null\r\n : selected\r\n\r\n if (!marker) {\r\n return (\r\n <div className=\"flex flex-col gap-4\">\r\n <p className=\"text-sm text-muted-foreground\">\r\n {t('gone', 'That marker no longer exists.')}\r\n </p>\r\n <Button className=\"self-end\" onClick={close}>{t('close', 'Close')}</Button>\r\n </div>\r\n )\r\n }\r\n\r\n return (\r\n <div className=\"flex flex-col gap-4\">\r\n <div className=\"flex items-center gap-2\">\r\n <span\r\n aria-hidden=\"true\"\r\n className=\"inline-block h-4 w-4 rounded-full border border-white\"\r\n style={{ backgroundColor: marker.colour }}\r\n />\r\n <p className=\"font-medium\">{marker.name}</p>\r\n </div>\r\n\r\n <dl className=\"text-sm\">\r\n <Row label={t('columnLatitude', 'Latitude')} value={marker.latitude.toFixed(5)} />\r\n <Row label={t('columnLongitude', 'Longitude')} value={marker.longitude.toFixed(5)} />\r\n <Row label={t('zoom', 'Zoom')} value={marker.zoom.toFixed(2)} />\r\n <Row label={t('colour', 'Colour')} value={marker.colour} />\r\n </dl>\r\n\r\n <Button className=\"self-end\" onClick={close}>{t('close', 'Close')}</Button>\r\n </div>\r\n )\r\n}\r\n\r\nfunction Row({ label, value }: { label: string; value: string }) {\r\n return (\r\n <div className=\"flex items-baseline justify-between gap-3 py-0.5\">\r\n <dt className=\"text-muted-foreground\">{label}</dt>\r\n <dd className=\"tabular-nums\">{value}</dd>\r\n </div>\r\n )\r\n}\r\n"],"mappings":";AA2BM,SACE,KADF;AAtBN,SAAS,cAAc;AACvB,SAAS,6BAA6B;AAEtC,SAAS,kBAAkB;AASpB,SAAS,aAAa,EAAE,OAAO,UAAU,GAAU;AAjB1D;AAkBE,QAAM,IAAI,sBAAsB;AAChC,QAAM,EAAE,SAAS,SAAS,IAAI,WAAW;AAEzC,QAAM,SAAS,aACX,aAAQ,KAAK,eAAa,UAAU,QAAQ,SAAS,MAArD,YAA0D,OAC1D;AAEJ,MAAI,CAAC,QAAQ;AACX,WACE,qBAAC,SAAI,WAAU,uBACb;AAAA,0BAAC,OAAE,WAAU,iCACV,YAAE,QAAQ,+BAA+B,GAC5C;AAAA,MACA,oBAAC,UAAO,WAAU,YAAW,SAAS,OAAQ,YAAE,SAAS,OAAO,GAAE;AAAA,OACpE;AAAA,EAEJ;AAEA,SACE,qBAAC,SAAI,WAAU,uBACb;AAAA,yBAAC,SAAI,WAAU,2BACb;AAAA;AAAA,QAAC;AAAA;AAAA,UACC,eAAY;AAAA,UACZ,WAAU;AAAA,UACV,OAAO,EAAE,iBAAiB,OAAO,OAAO;AAAA;AAAA,MAC1C;AAAA,MACA,oBAAC,OAAE,WAAU,eAAe,iBAAO,MAAK;AAAA,OAC1C;AAAA,IAEA,qBAAC,QAAG,WAAU,WACZ;AAAA,0BAAC,OAAI,OAAO,EAAE,kBAAkB,UAAU,GAAG,OAAO,OAAO,SAAS,QAAQ,CAAC,GAAG;AAAA,MAChF,oBAAC,OAAI,OAAO,EAAE,mBAAmB,WAAW,GAAG,OAAO,OAAO,UAAU,QAAQ,CAAC,GAAG;AAAA,MACnF,oBAAC,OAAI,OAAO,EAAE,QAAQ,MAAM,GAAG,OAAO,OAAO,KAAK,QAAQ,CAAC,GAAG;AAAA,MAC9D,oBAAC,OAAI,OAAO,EAAE,UAAU,QAAQ,GAAG,OAAO,OAAO,QAAQ;AAAA,OAC3D;AAAA,IAEA,oBAAC,UAAO,WAAU,YAAW,SAAS,OAAQ,YAAE,SAAS,OAAO,GAAE;AAAA,KACpE;AAEJ;AAEA,SAAS,IAAI,EAAE,OAAO,MAAM,GAAqC;AAC/D,SACE,qBAAC,SAAI,WAAU,oDACb;AAAA,wBAAC,QAAG,WAAU,yBAAyB,iBAAM;AAAA,IAC7C,oBAAC,QAAG,WAAU,gBAAgB,iBAAM;AAAA,KACtC;AAEJ;","names":[]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import type { MapToolProps } from '
|
|
2
|
+
import type { MapToolProps } from '@collabdt/plugin-kit/types/map';
|
|
3
3
|
/**
|
|
4
4
|
* The markers and the open popup. A `map.layers` contribution, not part of the tool, whose
|
|
5
5
|
* panel unmounts. A GeoJSON source, because a plugin cannot import `maplibre-gl`.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MarkersLayer.d.ts","sourceRoot":"","sources":["../../../../../../src/core/plugins/hello-map/src/components/MarkersLayer.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAQ9B,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gCAAgC,CAAA;AAKlE;;;GAGG;AACH,wBAAgB,YAAY,CAAC,EAAE,GAAG,EAAE,EAAE,YAAY,qBAmEjD"}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
3
|
import * as React from "react";
|
|
4
4
|
import { createPortal } from "react-dom";
|
|
5
|
-
import { usePluginTranslations } from "
|
|
5
|
+
import { usePluginTranslations } from "@collabdt/core/plugins-sdk/messages";
|
|
6
6
|
import { useMarkers } from "../markers";
|
|
7
7
|
const SOURCE = "hello-map-markers";
|
|
8
8
|
const LAYER = "hello-map-markers";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../../src/core/plugins/hello-map/src/components/MarkersLayer.tsx"],"sourcesContent":["'use client'\r\n\r\n// SPDX-License-Identifier: AGPL-3.0-or-later\r\n// Copyright (C) 2025 Collab Digital Twins\r\n\r\nimport * as React from 'react'\r\nimport { createPortal } from 'react-dom'\r\n\r\nimport { usePluginTranslations } from '@collabdt/core/plugins-sdk/messages'\n\r\nimport { useMarkers } from '../markers'\r\n\r\nimport type { Marker } from '../markers'\r\nimport type { MapToolProps } from '@collabdt/plugin-kit/types/map'\r\n\r\nconst SOURCE = 'hello-map-markers'\r\nconst LAYER = 'hello-map-markers'\r\n\r\n/**\r\n * The markers and the open popup. A `map.layers` contribution, not part of the tool, whose\r\n * panel unmounts. A GeoJSON source, because a plugin cannot import `maplibre-gl`.\r\n */\r\nexport function MarkersLayer({ map }: MapToolProps) {\r\n const { markers, open } = useMarkers()\r\n\r\n const featuresRef = React.useRef<Marker[]>(markers)\r\n featuresRef.current = markers\r\n\r\n React.useEffect(() => {\r\n if (!map) return\r\n\r\n // Re-run on every style change: the basemap switcher drops every source and layer.\r\n const ensureLayer = () => {\r\n if (!map.getStyle() || map.getSource(SOURCE)) return\r\n\r\n map.addSource(SOURCE, { type: 'geojson', data: toFeatureCollection(featuresRef.current) })\r\n\r\n map.addLayer({\r\n id: LAYER,\r\n type: 'circle',\r\n source: SOURCE,\r\n paint: {\r\n // Read per feature, so recolouring one marker needs no layer change.\r\n 'circle-color': ['get', 'colour'],\r\n 'circle-radius': 7,\r\n 'circle-stroke-width': 2,\r\n 'circle-stroke-color': '#ffffff',\r\n },\r\n })\r\n }\r\n\r\n const openFeature = (event: { features?: Array<{ properties?: Record<string, unknown> }> }) => {\r\n const key = event.features?.[0]?.properties?.key\r\n if (typeof key === 'string') open(key)\r\n }\r\n\r\n const pointer = () => { map.getCanvas().style.cursor = 'pointer' }\r\n const clearPointer = () => { map.getCanvas().style.cursor = '' }\r\n\r\n if (map.isStyleLoaded()) ensureLayer()\r\n map.on('styledata', ensureLayer)\r\n map.on('click', LAYER, openFeature)\r\n map.on('mouseenter', LAYER, pointer)\r\n map.on('mouseleave', LAYER, clearPointer)\r\n\r\n return () => {\r\n map.off('styledata', ensureLayer)\r\n map.off('click', LAYER, openFeature)\r\n map.off('mouseenter', LAYER, pointer)\r\n map.off('mouseleave', LAYER, clearPointer)\r\n\r\n // Guarded: the style may be gone, and removing what is already gone throws.\r\n if (map.getLayer(LAYER)) map.removeLayer(LAYER)\r\n if (map.getSource(SOURCE)) map.removeSource(SOURCE)\r\n clearPointer()\r\n }\r\n }, [map, open])\r\n\r\n // setData, not a teardown: re-adding the layer would make the markers flicker.\r\n React.useEffect(() => {\r\n if (!map) return\r\n\r\n const source = map.getSource(SOURCE)\r\n if (source && 'setData' in source) {\r\n (source as { setData: (data: unknown) => void }).setData(toFeatureCollection(markers))\r\n }\r\n }, [map, markers])\r\n\r\n return <MarkerPopup map={map} />\r\n}\r\n\r\nfunction toFeatureCollection(markers: Marker[]) {\r\n return {\r\n type: 'FeatureCollection' as const,\r\n features: markers.map(marker => ({\r\n type: 'Feature' as const,\r\n geometry: { type: 'Point' as const, coordinates: [marker.longitude, marker.latitude] },\r\n // Only what the layer and the click handler read. Everything else stays in the store.\r\n properties: { key: marker.key, colour: marker.colour },\r\n })),\r\n }\r\n}\r\n\r\n/**\r\n * The popup for the open marker, portalled into the map's own container so it sits over the\r\n * canvas. Positioned with `map.project`, which is why it has to follow every move.\r\n */\r\nfunction MarkerPopup({ map }: MapToolProps) {\r\n const t = usePluginTranslations()\r\n const { openMarker, open } = useMarkers()\r\n const [, forceReposition] = React.useState(0)\r\n\r\n React.useEffect(() => {\r\n if (!map || !openMarker) return\r\n\r\n const reposition = () => forceReposition(tick => tick + 1)\r\n\r\n map.on('move', reposition)\r\n return () => {\r\n map.off('move', reposition)\r\n }\r\n }, [map, openMarker])\r\n\r\n if (!map || !openMarker) return null\r\n\r\n const { x, y } = map.project([openMarker.longitude, openMarker.latitude])\r\n\r\n return createPortal(\r\n <div\r\n className=\"absolute z-10 -translate-x-1/2 -translate-y-full pb-3\"\r\n style={{ left: x, top: y }}\r\n >\r\n <div className=\"rounded-md border bg-background px-3 py-2 shadow-lg\">\r\n <div className=\"flex items-start gap-2\">\r\n <span\r\n aria-hidden=\"true\"\r\n className=\"mt-1 inline-block h-3 w-3 shrink-0 rounded-full border border-white\"\r\n style={{ backgroundColor: openMarker.colour }}\r\n />\r\n <div className=\"text-xs\">\r\n <p className=\"font-medium\">{openMarker.name}</p>\r\n <p className=\"tabular-nums text-muted-foreground\">\r\n {openMarker.latitude.toFixed(5)}, {openMarker.longitude.toFixed(5)}\r\n </p>\r\n </div>\r\n <button\r\n type=\"button\"\r\n className=\"ml-2 text-muted-foreground hover:text-foreground\"\r\n aria-label={t('close', 'Close')}\r\n onClick={() => open(null)}\r\n >\r\n ×\r\n </button>\r\n </div>\r\n </div>\r\n </div>,\r\n map.getContainer(),\r\n )\r\n}\r\n"],"mappings":";AAwFS,cAqDG,YArDH;AAnFT,YAAY,WAAW;AACvB,SAAS,oBAAoB;AAE7B,SAAS,6BAA6B;AAEtC,SAAS,kBAAkB;AAK3B,MAAM,SAAS;AACf,MAAM,QAAQ;AAMP,SAAS,aAAa,EAAE,IAAI,GAAiB;AAClD,QAAM,EAAE,SAAS,KAAK,IAAI,WAAW;AAErC,QAAM,cAAc,MAAM,OAAiB,OAAO;AAClD,cAAY,UAAU;AAEtB,QAAM,UAAU,MAAM;AACpB,QAAI,CAAC,IAAK;AAGV,UAAM,cAAc,MAAM;AACxB,UAAI,CA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A;AAAA,cACC,eAAY;AAAA,cACZ,WAAU;AAAA,cACV,OAAO,EAAE,iBAAiB,WAAW,OAAO;AAAA;AAAA,UAC9C;AAAA,UACA,qBAAC,SAAI,WAAU,WACb;AAAA,gCAAC,OAAE,WAAU,eAAe,qBAAW,MAAK;AAAA,YAC5C,qBAAC,OAAE,WAAU,sCACV;AAAA,yBAAW,SAAS,QAAQ,CAAC;AAAA,cAAE;AAAA,cAAG,WAAW,UAAU,QAAQ,CAAC;AAAA,eACnE;AAAA,aACF;AAAA,UACA;AAAA,YAAC;AAAA;AAAA,cACC,MAAK;AAAA,cACL,WAAU;AAAA,cACV,cAAY,EAAE,SAAS,OAAO;AAAA,cAC9B,SAAS,MAAM,KAAK,IAAI;AAAA,cACzB;AAAA;AAAA,UAED;AAAA,WACF,GACF;AAAA;AAAA,IACF;AAAA,IACA,IAAI,aAAa;AAAA,EACnB;AACF;","names":[]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { LegendRow } from '
|
|
1
|
+
import type { LegendRow } from '@collabdt/plugin-kit/types/legend';
|
|
2
2
|
/**
|
|
3
3
|
* One row per marker, live as they are added, renamed and recoloured. Every marker gets a row;
|
|
4
4
|
* the host's card caps its body at 40vh and scrolls.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MarkersLegend.d.ts","sourceRoot":"","sources":["../../../../../../src/core/plugins/hello-map/src/components/MarkersLegend.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,mCAAmC,CAAA;AAElE;;;GAGG;AACH,wBAAgB,gBAAgB,IAAI;IAAE,MAAM,EAAE,OAAO,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,SAAS,EAAE,CAAA;CAAE,CAczF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../../src/core/plugins/hello-map/src/components/MarkersLegend.ts"],"sourcesContent":["'use client'\r\n\r\n// SPDX-License-Identifier: AGPL-3.0-or-later\r\n// Copyright (C) 2025 Collab Digital Twins\r\n\r\nimport { usePluginTranslations } from '@collabdt/core/plugins-sdk/messages'\n\r\nimport { useMarkers } from '../markers'\r\n\r\nimport type { LegendRow } from '@collabdt/plugin-kit/types/legend'\r\n\r\n/**\r\n * One row per marker, live as they are added, renamed and recoloured. Every marker gets a row;\r\n * the host's card caps its body at 40vh and scrolls.\r\n */\r\nexport function useMarkersLegend(): { active: boolean; title?: string; rows: LegendRow[] } {\r\n const t = usePluginTranslations()\r\n const { markers } = useMarkers()\r\n\r\n const rows: LegendRow[] = markers.map(marker => ({\r\n label: marker.name,\r\n color: marker.colour,\r\n }))\r\n\r\n return {\r\n active: rows.length > 0,\r\n title: t('legendTitle', 'Markers'),\r\n rows,\r\n }\r\n}\r\n"],"mappings":";AAKA,SAAS,6BAA6B;AAEtC,SAAS,kBAAkB;AAQpB,SAAS,mBAA2E;AACzF,QAAM,IAAI,sBAAsB;AAChC,QAAM,EAAE,QAAQ,IAAI,WAAW;AAE/B,QAAM,OAAoB,QAAQ,IAAI,aAAW;AAAA,IAC/C,OAAO,OAAO;AAAA,IACd,OAAO,OAAO;AAAA,EAChB,EAAE;AAEF,SAAO;AAAA,IACL,QAAQ,KAAK,SAAS;AAAA,IACtB,OAAO,EAAE,eAAe,SAAS;AAAA,IACjC;AAAA,EACF;AACF;","names":[]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { DataPageColumn, DataPageRows } from '../../sdk/types';
|
|
2
1
|
import type { Marker } from '../markers';
|
|
2
|
+
import type { DataPageColumn, DataPageRows } from '@collabdt/plugin-kit/types/ui';
|
|
3
3
|
/** Rows and the click handler both need hooks, so both come from here. */
|
|
4
4
|
export declare function useMarkerRows(): DataPageRows<Marker>;
|
|
5
5
|
export declare const markerColumns: DataPageColumn<Marker>[];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MarkersPage.d.ts","sourceRoot":"","sources":["../../../../../../src/core/plugins/hello-map/src/components/MarkersPage.tsx"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,YAAY,CAAA;AACxC,OAAO,KAAK,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAA;AAEjF,0EAA0E;AAC1E,wBAAgB,aAAa,IAAI,YAAY,CAAC,MAAM,CAAC,CAapD;AAGD,eAAO,MAAM,aAAa,EAAE,cAAc,CAAC,MAAM,CAAC,EAgBjD,CAAA"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx } from "react/jsx-runtime";
|
|
3
|
-
import { usePluginDialogs } from "
|
|
3
|
+
import { usePluginDialogs } from "@collabdt/core/plugins-sdk/ui";
|
|
4
4
|
import { useMarkers } from "../markers";
|
|
5
5
|
function useMarkerRows() {
|
|
6
6
|
const { markers, isLoading, select, open } = useMarkers();
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../../src/core/plugins/hello-map/src/components/MarkersPage.tsx"],"sourcesContent":["'use client'\r\n\r\n// SPDX-License-Identifier: AGPL-3.0-or-later\r\n// Copyright (C) 2025 Collab Digital Twins\r\n\r\nimport { usePluginDialogs } from '@collabdt/core/plugins-sdk/ui'\n\r\nimport { useMarkers } from '../markers'\r\n\r\nimport type { Marker } from '../markers'\r\nimport type { DataPageColumn, DataPageRows } from '@collabdt/plugin-kit/types/ui'\r\n\r\n/** Rows and the click handler both need hooks, so both come from here. */\r\nexport function useMarkerRows(): DataPageRows<Marker> {\r\n const { markers, isLoading, select, open } = useMarkers()\r\n const { open: openDialog } = usePluginDialogs()\r\n\r\n return {\r\n rows: markers,\r\n isLoading,\r\n onRowClick: (row) => {\r\n select(row.key)\r\n open(row.key)\r\n openDialog('detail', { markerKey: row.key })\r\n },\r\n }\r\n}\r\n\r\n// `labelKey` falls back to the literal, so this reads before any translation exists.\r\nexport const markerColumns: DataPageColumn<Marker>[] = [\r\n {\r\n key: 'colour',\r\n labelKey: 'colour',\r\n render: row => (\r\n <span\r\n aria-label={row.colour}\r\n className=\"inline-block h-3 w-3 rounded-full border border-white\"\r\n style={{ backgroundColor: row.colour }}\r\n />\r\n ),\r\n },\r\n { key: 'name', labelKey: 'columnName' },\r\n { key: 'latitude', labelKey: 'columnLatitude', render: row => row.latitude.toFixed(5) },\r\n { key: 'longitude', labelKey: 'columnLongitude', render: row => row.longitude.toFixed(5) },\r\n { key: 'zoom', labelKey: 'zoom', render: row => row.zoom.toFixed(2) },\r\n]\r\n"],"mappings":";AAkCM;AA7BN,SAAS,wBAAwB;AAEjC,SAAS,kBAAkB;AAMpB,SAAS,gBAAsC;AACpD,QAAM,EAAE,SAAS,WAAW,QAAQ,KAAK,IAAI,WAAW;AACxD,QAAM,EAAE,MAAM,WAAW,IAAI,iBAAiB;AAE9C,SAAO;AAAA,IACL,MAAM;AAAA,IACN;AAAA,IACA,YAAY,CAAC,QAAQ;AACnB,aAAO,IAAI,GAAG;AACd,WAAK,IAAI,GAAG;AACZ,iBAAW,UAAU,EAAE,WAAW,IAAI,IAAI,CAAC;AAAA,IAC7C;AAAA,EACF;AACF;AAGO,MAAM,gBAA0C;AAAA,EACrD;AAAA,IACE,KAAK;AAAA,IACL,UAAU;AAAA,IACV,QAAQ,SACN;AAAA,MAAC;AAAA;AAAA,QACC,cAAY,IAAI;AAAA,QAChB,WAAU;AAAA,QACV,OAAO,EAAE,iBAAiB,IAAI,OAAO;AAAA;AAAA,IACvC;AAAA,EAEJ;AAAA,EACA,EAAE,KAAK,QAAQ,UAAU,aAAa;AAAA,EACtC,EAAE,KAAK,YAAY,UAAU,kBAAkB,QAAQ,SAAO,IAAI,SAAS,QAAQ,CAAC,EAAE;AAAA,EACtF,EAAE,KAAK,aAAa,UAAU,mBAAmB,QAAQ,SAAO,IAAI,UAAU,QAAQ,CAAC,EAAE;AAAA,EACzF,EAAE,KAAK,QAAQ,UAAU,QAAQ,QAAQ,SAAO,IAAI,KAAK,QAAQ,CAAC,EAAE;AACtE;","names":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MarkersTab.d.ts","sourceRoot":"","sources":["../../../../../../src/core/plugins/hello-map/src/components/MarkersTab.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AA6I9B,2EAA2E;AAC3E,wBAAgB,UAAU,sBAoJzB"}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
3
3
|
import * as React from "react";
|
|
4
|
-
import { MAP_COLOUR_PALETTE } from "
|
|
5
|
-
import { Button, Input, Separator } from "
|
|
6
|
-
import { useMapViewer } from "
|
|
7
|
-
import { usePluginTranslations } from "
|
|
4
|
+
import { MAP_COLOUR_PALETTE } from "@collabdt/core/plugins-sdk";
|
|
5
|
+
import { Button, Input, Separator } from "@collabdt/core/plugins-sdk/components";
|
|
6
|
+
import { useMapViewer } from "@collabdt/core/plugins-sdk/mapViewer";
|
|
7
|
+
import { usePluginTranslations } from "@collabdt/core/plugins-sdk/messages";
|
|
8
8
|
import { useMarkers } from "../markers";
|
|
9
9
|
const SWATCHES = 8;
|
|
10
10
|
function NameField({
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../../src/core/plugins/hello-map/src/components/MarkersTab.tsx"],"sourcesContent":["'use client'\r\n\r\n// SPDX-License-Identifier: AGPL-3.0-or-later\r\n// Copyright (C) 2025 Collab Digital Twins\r\n\r\nimport * as React from 'react'\r\n\r\nimport { MAP_COLOUR_PALETTE } from '@collabdt/core/plugins-sdk'\r\nimport { Button, Input, Separator } from '@collabdt/core/plugins-sdk/components'\r\nimport { useMapViewer } from '@collabdt/core/plugins-sdk/mapViewer'\r\nimport { usePluginTranslations } from '@collabdt/core/plugins-sdk/messages'\n\r\nimport { useMarkers } from '../markers'\r\n\r\n/** How many palette entries to offer as swatches before the free colour input. */\r\nconst SWATCHES = 8\r\n\r\n/**\r\n * The name, saved only when confirmed. Not on blur: with a confirm button, blurring to reach\r\n * it would save first, and blurring elsewhere would commit an unconfirmed edit.\r\n */\r\nfunction NameField({\r\n name,\r\n label,\r\n saveLabel,\r\n revertLabel,\r\n onCommit,\r\n}: {\r\n name: string\r\n label: string\r\n saveLabel: string\r\n revertLabel: string\r\n onCommit: (name: string) => void\r\n}) {\r\n const [draft, setDraft] = React.useState(name)\r\n const inputId = React.useId()\r\n\r\n const trimmed = draft.trim()\r\n const canSave = trimmed.length > 0 && trimmed !== name\r\n\r\n const commit = () => {\r\n if (!canSave) return\r\n onCommit(trimmed)\r\n }\r\n\r\n return (\r\n <div className=\"flex flex-col gap-1\">\r\n <label className=\"text-xs font-medium\" htmlFor={inputId}>{label}</label>\r\n\r\n {/* Laid out like the app's other inline text edits (see the comment editor): the field\r\n takes the row, then a confirm and a revert, both h-8 w-8 icon buttons. */}\r\n <div className=\"flex items-center gap-1\">\r\n <Input\r\n id={inputId}\r\n value={draft}\r\n onChange={event => setDraft(event.target.value)}\r\n onKeyDown={(event) => {\r\n if (event.key === 'Enter') { event.preventDefault(); commit() }\r\n if (event.key === 'Escape') setDraft(name)\r\n }}\r\n className=\"h-8 flex-1\"\r\n />\r\n\r\n <Button\r\n size=\"icon\"\r\n className=\"h-8 w-8 shrink-0 p-0\"\r\n disabled={!canSave}\r\n aria-label={saveLabel}\r\n title={saveLabel}\r\n onClick={commit}\r\n >\r\n <CheckIcon />\r\n </Button>\r\n\r\n <Button\r\n size=\"icon\"\r\n variant=\"ghost\"\r\n className=\"h-8 w-8 shrink-0 p-0\"\r\n disabled={!canSave}\r\n aria-label={revertLabel}\r\n title={revertLabel}\r\n onClick={() => setDraft(name)}\r\n >\r\n <XIcon />\r\n </Button>\r\n </div>\r\n </div>\r\n )\r\n}\r\n\r\n// Drawn here: `lucide-react` is unshimmed, so a plugin cannot import it.\r\nfunction Glyph({ children }: { children: React.ReactNode }) {\r\n return (\r\n <svg\r\n viewBox=\"0 0 24 24\"\r\n className=\"h-4 w-4\"\r\n fill=\"none\"\r\n stroke=\"currentColor\"\r\n strokeWidth=\"2\"\r\n strokeLinecap=\"round\"\r\n strokeLinejoin=\"round\"\r\n aria-hidden=\"true\"\r\n >\r\n {children}\r\n </svg>\r\n )\r\n}\r\n\r\nfunction CheckIcon() {\r\n return <Glyph><path d=\"M20 6 9 17l-5-5\" /></Glyph>\r\n}\r\n\r\nfunction XIcon() {\r\n return <Glyph><path d=\"M18 6 6 18\" /><path d=\"m6 6 12 12\" /></Glyph>\r\n}\r\n\r\n/** Smaller than the button glyphs — it sits inside a 24px swatch, not a 32px button. */\r\nfunction PlusIcon() {\r\n return (\r\n <svg\r\n viewBox=\"0 0 24 24\"\r\n className=\"h-3 w-3\"\r\n fill=\"none\"\r\n stroke=\"currentColor\"\r\n strokeWidth=\"2.5\"\r\n strokeLinecap=\"round\"\r\n aria-hidden=\"true\"\r\n >\r\n <path d=\"M5 12h14\" />\r\n <path d=\"M12 5v14\" />\r\n </svg>\r\n )\r\n}\r\n\r\n/** Traces lucide's `map-pin-plus`, the same icon the toolbar registration names. */\r\nfunction MarkerPlusIcon() {\r\n return (\r\n <Glyph>\r\n <path d=\"M19.914 11.105A7.298 7.298 0 0 0 20 10a8 8 0 0 0-16 0c0 4.993 5.539 10.193 7.399 11.799a1 1 0 0 0 1.202 0 32 32 0 0 0 .824-.738\" />\r\n <circle cx=\"12\" cy=\"10\" r=\"3\" />\r\n <path d=\"M16 18h6\" />\r\n <path d=\"M19 15v6\" />\r\n </Glyph>\r\n )\r\n}\r\n\r\n/** The markers in the viewer sidebar, in the map and BIM viewers alike. */\r\nexport function MarkersTab() {\r\n const t = usePluginTranslations()\r\n const { map } = useMapViewer()\r\n const {\r\n markers, isLoading, lastError, selected,\r\n select, open, add, setColour, rename, remove,\r\n } = useMarkers()\r\n\r\n const addHere = async () => {\r\n if (!map) return\r\n const centre = map.getCenter()\r\n await add(centre.lat, centre.lng, map.getZoom())\r\n }\r\n\r\n /** Back to exactly the view the marker was recorded at, zoom included. */\r\n const flyTo = () => {\r\n if (!map || !selected) return\r\n\r\n map.flyTo({ center: [selected.longitude, selected.latitude], zoom: selected.zoom })\r\n open(selected.key)\r\n }\r\n\r\n if (isLoading && markers.length === 0) {\r\n return <p className=\"p-4 text-sm text-muted-foreground\">{t('loading', 'Loading…')}</p>\r\n }\r\n\r\n return (\r\n <div className=\"flex flex-col gap-3 p-4\">\r\n <Button\r\n size=\"sm\"\r\n variant=\"outline\"\r\n className=\"gap-2\"\r\n disabled={!map}\r\n onClick={() => { void addHere() }}\r\n >\r\n <MarkerPlusIcon />\r\n {t('addHere', 'Add a marker at the map centre')}\r\n </Button>\r\n\r\n {!map && (\r\n <p className=\"text-xs text-muted-foreground\">\r\n {t('mapOnly', 'Switch to the map to add a marker.')}\r\n </p>\r\n )}\r\n\r\n {lastError && (\r\n <p className=\"rounded-md bg-destructive/10 px-2 py-1 text-xs text-destructive\">\r\n {t('saveFailed', 'Could not save: ')}{lastError}\r\n </p>\r\n )}\r\n\r\n {markers.length === 0 ? (\r\n <p className=\"text-sm text-muted-foreground\">\r\n {t('empty', 'No markers yet. Record one from the map toolbar.')}\r\n </p>\r\n ) : (\r\n <ul className=\"flex flex-col gap-1\">\r\n {markers.map(marker => (\r\n <li key={marker.key}>\r\n <button\r\n type=\"button\"\r\n onClick={() => { select(marker.key); open(marker.key) }}\r\n className={`flex w-full items-center gap-2 rounded-md px-2 py-1 text-left text-sm ${\r\n selected?.key === marker.key ? 'bg-accent' : 'hover:bg-accent/50'\r\n }`}\r\n >\r\n <span\r\n aria-hidden=\"true\"\r\n className=\"inline-block h-3 w-3 shrink-0 rounded-full border border-white\"\r\n style={{ backgroundColor: marker.colour }}\r\n />\r\n <span className=\"flex-1 truncate\">{marker.name}</span>\r\n <span className=\"tabular-nums text-xs text-muted-foreground\">\r\n {marker.latitude.toFixed(2)}, {marker.longitude.toFixed(2)}\r\n </span>\r\n </button>\r\n </li>\r\n ))}\r\n </ul>\r\n )}\r\n\r\n {selected && (\r\n <>\r\n <Separator />\r\n\r\n <NameField\r\n key={selected.key}\r\n name={selected.name}\r\n label={t('nameLabel', 'Name')}\r\n saveLabel={t('saveName', 'Save name')}\r\n revertLabel={t('revertName', 'Discard the change')}\r\n onCommit={name => { void rename(selected.key, name) }}\r\n />\r\n\r\n <Button size=\"sm\" variant=\"outline\" disabled={!map} onClick={flyTo}>\r\n {t('flyTo', 'Fly to on the map')}\r\n </Button>\r\n\r\n <div className=\"flex flex-col gap-2\">\r\n <p className=\"text-xs font-medium\">{t('colour', 'Colour')}</p>\r\n\r\n <div className=\"flex flex-wrap items-center gap-1\">\r\n {MAP_COLOUR_PALETTE.slice(0, SWATCHES).map(colour => (\r\n <button\r\n key={colour}\r\n type=\"button\"\r\n aria-label={colour}\r\n aria-pressed={selected.colour === colour}\r\n onClick={() => { void setColour(selected.key, colour) }}\r\n className={`h-6 w-6 rounded-full border-2 ${\r\n selected.colour === colour ? 'border-foreground' : 'border-transparent'\r\n }`}\r\n style={{ backgroundColor: colour }}\r\n />\r\n ))}\r\n\r\n {/* Last in the row, set apart by a border and a margin: the palette is the\r\n default, not a limit. A plus rather than a swatch — a swatch of the current\r\n colour was indistinguishable from the presets beside it. The native input\r\n cannot be made round reliably across browsers, so it sits invisible on top. */}\r\n <label\r\n title={t('customColour', 'Pick any colour')}\r\n className=\"relative ml-1 flex h-6 w-6 shrink-0 cursor-pointer items-center justify-center rounded-full border border-input bg-background text-muted-foreground hover:text-foreground\"\r\n >\r\n <PlusIcon />\r\n <input\r\n type=\"color\"\r\n value={selected.colour}\r\n onChange={event => { void setColour(selected.key, event.target.value) }}\r\n className=\"absolute inset-0 h-full w-full cursor-pointer opacity-0\"\r\n />\r\n <span className=\"sr-only\">{t('customColour', 'Pick any colour')}</span>\r\n </label>\r\n </div>\r\n </div>\r\n\r\n <Button\r\n size=\"sm\"\r\n variant=\"ghost\"\r\n className=\"self-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AAAA,YAAC;AAAA;AAAA,cAEC,MAAK;AAAA,cACL,cAAY;AAAA,cACZ,gBAAc,SAAS,WAAW;AAAA,cAClC,SAAS,MAAM;AAAE,qBAAK,UAAU,SAAS,KAAK,MAAM;AAAA,cAAE;AAAA,cACtD,WAAW,iCACT,SAAS,WAAW,SAAS,sBAAsB,oBACrD;AAAA,cACA,OAAO,EAAE,iBAAiB,OAAO;AAAA;AAAA,YAR5B;AAAA,UASP,CACD;AAAA,UAMD;AAAA,YAAC;AAAA;AAAA,cACC,OAAO,EAAE,gBAAgB,iBAAiB;AAAA,cAC1C,WAAU;AAAA,cAEV;AAAA,oCAAC,YAAS;AAAA,gBACV;AAAA,kBAAC;AAAA;AAAA,oBACC,MAAK;AAAA,oBACL,OAAO,SAAS;AAAA,oBAChB,UAAU,WAAS;AAAE,2BAAK,UAAU,SAAS,KAAK,MAAM,OAAO,KAAK;AAAA,oBAAE;AAAA,oBACtE,WAAU;AAAA;AAAA,gBACZ;AAAA,gBACA,oBAAC,UAAK,WAAU,WAAW,YAAE,gBAAgB,iBAAiB,GAAE;AAAA;AAAA;AAAA,UAClE;AAAA,WACF;AAAA,SACF;AAAA,MAEA;AAAA,QAAC;AAAA;AAAA,UACC,MAAK;AAAA,UACL,SAAQ;AAAA,UACR,WAAU;AAAA,UACV,SAAS,MAAM;AAAE,iBAAK,OAAO,SAAS,GAAG;AAAA,UAAE;AAAA,UAE1C,YAAE,UAAU,QAAQ;AAAA;AAAA,MACvB;AAAA,OACF;AAAA,KAEJ;AAEJ;","names":[]}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { LegendRegistration } from '@collabdt/plugin-kit/types/legend';
|
|
2
|
+
import type { MapToolProps, PluginContext } from '@collabdt/plugin-kit/types/map';
|
|
3
|
+
type Ctx = PluginContext<MapToolProps, unknown, unknown, LegendRegistration>;
|
|
4
|
+
/**
|
|
5
|
+
* Six surfaces over one store and one selection, in React subtrees with no common ancestor.
|
|
6
|
+
* Without that shared state this would be six unrelated widgets in one bundle.
|
|
7
|
+
*/
|
|
8
|
+
export declare function activate(ctx: Ctx): void;
|
|
9
|
+
export {};
|
|
10
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/core/plugins/hello-map/src/index.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,mCAAmC,CAAA;AAC3E,OAAO,KAAK,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,gCAAgC,CAAA;AAEjF,KAAK,GAAG,GAAG,aAAa,CAAC,YAAY,EAAE,OAAO,EAAE,OAAO,EAAE,kBAAkB,CAAC,CAAA;AAE5E;;;GAGG;AACH,wBAAgB,QAAQ,CAAC,GAAG,EAAE,GAAG,GAAG,IAAI,CAgDvC"}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { ViewerNames } from "../sdk/types";
|
|
2
1
|
import { MapTool } from "./components/MapTool";
|
|
3
2
|
import { MarkerDialog } from "./components/MarkerDialog";
|
|
4
3
|
import { MarkersLayer } from "./components/MarkersLayer";
|
|
@@ -21,7 +20,7 @@ function activate(ctx) {
|
|
|
21
20
|
id: "markers",
|
|
22
21
|
title: "Markers",
|
|
23
22
|
// Map only: a list of map markers means nothing in BIM.
|
|
24
|
-
viewers: [
|
|
23
|
+
viewers: ["map"],
|
|
25
24
|
useLegend: useMarkersLegend
|
|
26
25
|
});
|
|
27
26
|
ctx.register("viewer.tabs", {
|
|
@@ -29,7 +28,7 @@ function activate(ctx) {
|
|
|
29
28
|
labelKey: "tabTitle",
|
|
30
29
|
icon: "MapPin",
|
|
31
30
|
// Recorded on the map, read in BIM; the point cloud has nothing to do with it.
|
|
32
|
-
viewers: [
|
|
31
|
+
viewers: ["map", "bim"],
|
|
33
32
|
component: MarkersTab
|
|
34
33
|
});
|
|
35
34
|
ctx.register("data.pages", {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../src/core/plugins/hello-map/src/index.ts"],"sourcesContent":["// SPDX-License-Identifier: AGPL-3.0-or-later\r\n// Copyright (C) 2025 Collab Digital Twins\r\n\r\nimport { MapTool } from './components/MapTool'\r\nimport { MarkerDialog } from './components/MarkerDialog'\r\nimport { MarkersLayer } from './components/MarkersLayer'\r\nimport { useMarkersLegend } from './components/MarkersLegend'\r\nimport { markerColumns, useMarkerRows } from './components/MarkersPage'\r\nimport { MarkersTab } from './components/MarkersTab'\r\n\r\nimport type { LegendRegistration } from '@collabdt/plugin-kit/types/legend'\r\nimport type { MapToolProps, PluginContext } from '@collabdt/plugin-kit/types/map'\r\n\r\ntype Ctx = PluginContext<MapToolProps, unknown, unknown, LegendRegistration>\r\n\r\n/**\r\n * Six surfaces over one store and one selection, in React subtrees with no common ancestor.\r\n * Without that shared state this would be six unrelated widgets in one bundle.\r\n */\r\nexport function activate(ctx: Ctx): void {\r\n ctx.register('map.tools', {\r\n id: 'hello-map',\r\n label: 'Hello Map',\r\n icon: 'MapPinPlus',\r\n component: MapTool,\r\n stayActive: true,\r\n })\r\n\r\n // Separate from the tool, whose panel unmounts when its dropdown closes.\r\n ctx.register('map.layers', {\r\n id: 'markers',\r\n component: MarkersLayer,\r\n })\r\n\r\n ctx.register('viewer.legends', {\r\n id: 'markers',\r\n title: 'Markers',\r\n // Map only: a list of map markers means nothing in BIM.\r\n viewers: ['map'],\r\n useLegend: useMarkersLegend,\r\n })\r\n\r\n ctx.register('viewer.tabs', {\r\n id: 'markers',\r\n labelKey: 'tabTitle',\r\n icon: 'MapPin',\r\n // Recorded on the map, read in BIM; the point cloud has nothing to do with it.\r\n viewers: ['map', 'bim'],\r\n component: MarkersTab,\r\n })\r\n\r\n ctx.register('data.pages', {\r\n id: 'markers',\r\n titleKey: 'pageTitle',\r\n icon: 'MapPinned',\r\n useRows: useMarkerRows,\r\n columns: markerColumns,\r\n emptyKey: 'empty',\r\n searchKeys: ['name'],\r\n })\r\n\r\n ctx.register('ui.dialogs', {\r\n id: 'detail',\r\n titleKey: 'dialogTitle',\r\n size: 'md',\r\n component: MarkerDialog,\r\n })\r\n}\r\n"],"mappings":"AAGA,SAAS,eAAe;AACxB,SAAS,oBAAoB;AAC7B,SAAS,oBAAoB;AAC7B,SAAS,wBAAwB;AACjC,SAAS,eAAe,qBAAqB;AAC7C,SAAS,kBAAkB;AAWpB,SAAS,SAAS,KAAgB;AACvC,MAAI,SAAS,aAAa;AAAA,IACxB,IAAI;AAAA,IACJ,OAAO;AAAA,IACP,MAAM;AAAA,IACN,WAAW;AAAA,IACX,YAAY;AAAA,EACd,CAAC;AAGD,MAAI,SAAS,cAAc;AAAA,IACzB,IAAI;AAAA,IACJ,WAAW;AAAA,EACb,CAAC;AAED,MAAI,SAAS,kBAAkB;AAAA,IAC7B,IAAI;AAAA,IACJ,OAAO;AAAA;AAAA,IAEP,SAAS,CAAC,KAAK;AAAA,IACf,WAAW;AAAA,EACb,CAAC;AAED,MAAI,SAAS,eAAe;AAAA,IAC1B,IAAI;AAAA,IACJ,UAAU;AAAA,IACV,MAAM;AAAA;AAAA,IAEN,SAAS,CAAC,OAAO,KAAK;AAAA,IACtB,WAAW;AAAA,EACb,CAAC;AAED,MAAI,SAAS,cAAc;AAAA,IACzB,IAAI;AAAA,IACJ,UAAU;AAAA,IACV,MAAM;AAAA,IACN,SAAS;AAAA,IACT,SAAS;AAAA,IACT,UAAU;AAAA,IACV,YAAY,CAAC,MAAM;AAAA,EACrB,CAAC;AAED,MAAI,SAAS,cAAc;AAAA,IACzB,IAAI;AAAA,IACJ,UAAU;AAAA,IACV,MAAM;AAAA,IACN,WAAW;AAAA,EACb,CAAC;AACH;","names":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"markers.d.ts","sourceRoot":"","sources":["../../../../../src/core/plugins/hello-map/src/markers.ts"],"names":[],"mappings":"AAWA,MAAM,WAAW,UAAW,SAAQ,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IACzD,IAAI,EAAE,MAAM,CAAA;IACZ,QAAQ,EAAE,MAAM,CAAA;IAChB,SAAS,EAAE,MAAM,CAAA;IACjB,kFAAkF;IAClF,IAAI,EAAE,MAAM,CAAA;IACZ,MAAM,EAAE,MAAM,CAAA;CACf;AAED,MAAM,WAAW,MAAO,SAAQ,UAAU;IACxC,GAAG,EAAE,MAAM,CAAA;CACZ;AAED,oGAAoG;AACpG,eAAO,MAAM,YAAY,KAAK,CAAA;AAY9B;;;GAGG;AACH,wBAAgB,UAAU;;;IAmGtB,0EAA0E;;;;;;oBA3DzD,MAAM,aAAa,MAAM,QAAQ,MAAM;qBA8BlD,MAAM,UAAU,MAAM;kBAKhB,MAAM,QAAQ,MAAM;kBAWpB,MAAM;EAwBrB"}
|
|
@@ -31,9 +31,9 @@ var __objRest = (source, exclude) => {
|
|
|
31
31
|
return target;
|
|
32
32
|
};
|
|
33
33
|
import * as React from "react";
|
|
34
|
-
import { stringToColour } from "
|
|
35
|
-
import { usePluginState } from "
|
|
36
|
-
import { usePluginStore } from "
|
|
34
|
+
import { stringToColour } from "@collabdt/core/plugins-sdk";
|
|
35
|
+
import { usePluginState } from "@collabdt/core/plugins-sdk/state";
|
|
36
|
+
import { usePluginStore } from "@collabdt/core/plugins-sdk/store";
|
|
37
37
|
const DEFAULT_ZOOM = 15;
|
|
38
38
|
function toData(_a) {
|
|
39
39
|
var _b = _a, { key: _key } = _b, data = __objRest(_b, ["key"]);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../src/core/plugins/hello-map/src/markers.ts"],"sourcesContent":["'use client'\r\n\r\n// SPDX-License-Identifier: AGPL-3.0-or-later\r\n// Copyright (C) 2025 Collab Digital Twins\r\n\r\nimport * as React from 'react'\r\n\r\nimport { stringToColour } from '@collabdt/core/plugins-sdk'\r\nimport { usePluginState } from '@collabdt/core/plugins-sdk/state'\r\nimport { usePluginStore } from '@collabdt/core/plugins-sdk/store'\r\n\r\nexport interface MarkerData extends Record<string, unknown> {\r\n name: string\r\n latitude: number\r\n longitude: number\r\n /** The zoom the marker was recorded at, so flying back restores the same view. */\r\n zoom: number\r\n colour: string\r\n}\r\n\r\nexport interface Marker extends MarkerData {\r\n key: string\r\n}\r\n\r\n/** Used when a record was written before `zoom` existed — `T` is a declaration, not a guarantee. */\r\nexport const DEFAULT_ZOOM = 15\r\n\r\n/** One edit path, so a field added to `MarkerData` cannot be dropped by a rename. */\r\nfunction toData({ key: _key, ...data }: Marker): MarkerData {\r\n return data\r\n}\r\n\r\n/** Unique without a counter to keep, so two quick clicks cannot collide. */\r\nfunction nextKey(): string {\r\n return `m-${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 7)}`\r\n}\r\n\r\n/**\r\n * Everything every surface reads. Markers are records, so they survive a reload; the selection\r\n * and the open popup are session state, so they do not belong in the database.\r\n */\r\nexport function useMarkers() {\r\n const store = usePluginStore<MarkerData>('markers')\r\n const [selectedKey, setSelectedKey] = usePluginState<string | null>('selected', null)\r\n const [openKey, setOpenKey] = usePluginState<string | null>('open', null)\r\n // Every write goes through `attempt`, or a rejected save looks like a dead button.\r\n const [lastError, setLastError] = usePluginState<string | null>('lastError', null)\r\n\r\n const attempt = React.useCallback(\r\n async (action: () => Promise<void>) => {\r\n try {\r\n await action()\r\n setLastError(null)\r\n return true\r\n }\r\n catch (error) {\r\n const message = error instanceof Error ? error.message : String(error)\r\n console.error('[hello-map] save failed:', error)\r\n setLastError(message)\r\n return false\r\n }\r\n },\r\n [setLastError],\r\n )\r\n\r\n const markers = React.useMemo<Marker[]>(\r\n () => store.items.map(item => ({\r\n key: item.key,\r\n ...item.data,\r\n // Records written before `zoom` existed have none, and flyTo would get NaN.\r\n zoom: typeof item.data.zoom === 'number' ? item.data.zoom : DEFAULT_ZOOM,\r\n })),\r\n [store.items],\r\n )\r\n\r\n const byKey = React.useMemo(\r\n () => new Map(markers.map(marker => [marker.key, marker])),\r\n [markers],\r\n )\r\n\r\n const add = React.useCallback(\r\n async (latitude: number, longitude: number, zoom: number) => {\r\n const key = nextKey()\r\n\r\n // A palette colour, so a page of markers stays readable and colourblind-safe.\r\n const saved = await attempt(() => store.put(key, {\r\n name: `Marker ${store.items.length + 1}`,\r\n latitude,\r\n longitude,\r\n zoom,\r\n colour: stringToColour(key),\r\n }))\r\n\r\n if (saved) setSelectedKey(key)\r\n return saved ? key : null\r\n },\r\n [store, setSelectedKey, attempt],\r\n )\r\n\r\n /** One edit path, so a field added to `MarkerData` cannot be dropped by a rename. */\r\n const patch = React.useCallback(\r\n async (key: string, changes: Partial<MarkerData>) => {\r\n const current = byKey.get(key)\r\n if (!current) return\r\n\r\n await attempt(() => store.put(key, { ...toData(current), ...changes }))\r\n },\r\n [store, byKey, attempt],\r\n )\r\n\r\n const setColour = React.useCallback(\r\n (key: string, colour: string) => patch(key, { colour }),\r\n [patch],\r\n )\r\n\r\n const rename = React.useCallback(\r\n async (key: string, name: string) => {\r\n const trimmed = name.trim()\r\n // An empty name would leave an unlabelled row and legend entry.\r\n if (!trimmed || trimmed === byKey.get(key)?.name) return\r\n\r\n await patch(key, { name: trimmed })\r\n },\r\n [patch, byKey],\r\n )\r\n\r\n const remove = React.useCallback(\r\n async (key: string) => {\r\n const removed = await attempt(() => store.remove(key))\r\n if (!removed) return\r\n\r\n setSelectedKey(current => (current === key ? null : current))\r\n setOpenKey(current => (current === key ? null : current))\r\n },\r\n [store, setSelectedKey, setOpenKey, attempt],\r\n )\r\n\r\n return {\r\n markers,\r\n isLoading: store.isLoading,\r\n /** The last write that failed, or null. Shown by the tool and the tab. */\r\n lastError,\r\n selected: selectedKey === null ? null : byKey.get(selectedKey) ?? null,\r\n openMarker: openKey === null ? null : byKey.get(openKey) ?? null,\r\n select: setSelectedKey,\r\n open: setOpenKey,\r\n add,\r\n setColour,\r\n rename,\r\n remove,\r\n }\r\n}\r\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAKA,YAAY,WAAW;AAEv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C,QAAS;AAEd,qBAAe,aAAY,YAAY,MAAM,OAAO,OAAQ;AAC5D,iBAAW,aAAY,YAAY,MAAM,OAAO,OAAQ;AAAA,IAC1D;AAAA,IACA,CAAC,OAAO,gBAAgB,YAAY,OAAO;AAAA,EAC7C;AAEA,SAAO;AAAA,IACL;AAAA,IACA,WAAW,MAAM;AAAA;AAAA,IAEjB;AAAA,IACA,UAAU,gBAAgB,OAAO,QAAO,WAAM,IAAI,WAAW,MAArB,YAA0B;AAAA,IAClE,YAAY,YAAY,OAAO,QAAO,WAAM,IAAI,OAAO,MAAjB,YAAsB;AAAA,IAC5D,QAAQ;AAAA,IACR,MAAM;AAAA,IACN;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF;","names":["_a"]}
|
|
@@ -29,10 +29,10 @@ import {
|
|
|
29
29
|
} from "../../components/ui/Breadcrumb";
|
|
30
30
|
import { Input } from "../../components/ui/Input";
|
|
31
31
|
import { usePluginMessageLookup } from "../sdk/messages";
|
|
32
|
+
import { resolvePluginIcon } from "./pluginIcon";
|
|
32
33
|
import { parsePluginViewerKey } from "./pluginViewerKey";
|
|
33
34
|
import { usePluginConfigs, usePluginContributions } from "./provider";
|
|
34
35
|
import { PluginScopeProvider } from "./scope";
|
|
35
|
-
import { resolvePluginIcon } from "./usePluginToolbarTools";
|
|
36
36
|
function PluginDataPageHost({ viewer }) {
|
|
37
37
|
const registrations = usePluginContributions("data.pages");
|
|
38
38
|
const target = parsePluginViewerKey(viewer);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/core/plugins/host/PluginDataPageHost.tsx"],"sourcesContent":["'use client'\r\n\r\n// SPDX-License-Identifier: AGPL-3.0-or-later\r\n// Copyright (C) 2025 Collab Digital Twins\r\n\r\nimport { useTranslations } from 'next-intl'\r\nimport * as React from 'react'\r\n\r\nimport {\r\n Breadcrumb,\r\n BreadcrumbItem,\r\n BreadcrumbList,\r\n BreadcrumbPage,\r\n} from '../../components/ui/Breadcrumb'\r\nimport { Input } from '../../components/ui/Input'\r\nimport { usePluginMessageLookup } from '../sdk/messages'\r\n\r\nimport { parsePluginViewerKey } from './pluginViewerKey'\r\nimport { usePluginConfigs, usePluginContributions } from './provider'\r\nimport { PluginScopeProvider } from './scope'\r\nimport { resolvePluginIcon } from './usePluginToolbarTools'\r\n\r\nimport type { ViewerKey } from '../../types/dbTypes'\r\nimport type { DataPageRegistration } from '../sdk/types'\r\n\r\ntype Row = Record<string, unknown>\r\ntype Registration = DataPageRegistration & { pluginId: string }\r\n\r\n/**\r\n * Renders the `data.pages` contribution the viewer key names. The frame mirrors\r\n * `PluginsManager`, so a plugin page is indistinguishable from a built-in one.\r\n */\r\nexport function PluginDataPageHost({ viewer }: { viewer: ViewerKey }) {\r\n const registrations = usePluginContributions('data.pages')\r\n const target = parsePluginViewerKey(viewer)\r\n\r\n const registration = target\r\n ? registrations.find(\r\n candidate => candidate.pluginId === target.pluginId && candidate.id === target.pageId,\r\n )\r\n : undefined\r\n\r\n // The key comes from the URL, so rendering nothing lets `Viewer` fall back.\r\n if (!registration) return null\r\n\r\n return <PluginDataPage key={viewer} registration={registration} />\r\n}\r\n\r\nfunction PluginDataPage({ registration }: { registration: Registration }) {\r\n const tData = useTranslations('DataMenu')\r\n const message = usePluginMessageLookup()\r\n const configs = usePluginConfigs()\r\n const [searchTerm, setSearchTerm] = React.useState('')\r\n\r\n const title = message(registration.pluginId, registration.titleKey, registration.titleKey)\r\n const Icon = resolvePluginIcon(registration.icon)\r\n\r\n return (\r\n <div className=\"sm:p-2 overflow-hidden bg-[#fafafa] h-full\">\r\n <div className=\"bg-background rounded-xl shadow h-full min-h-0\">\r\n <div className=\"flex flex-col h-full min-h-0\">\r\n\r\n <div className=\"flex flex-row gap-2 justify-start items-center px-3 py-4 relative\">\r\n <Breadcrumb className=\"px-3\">\r\n <BreadcrumbList>\r\n <BreadcrumbItem>\r\n <BreadcrumbPage>{title}</BreadcrumbPage>\r\n </BreadcrumbItem>\r\n </BreadcrumbList>\r\n </Breadcrumb>\r\n </div>\r\n\r\n <div className=\"flex flex-row justify-between items-center px-6 py-6\">\r\n <div className=\"flex items-center gap-2\">\r\n <Icon className=\"h-8 w-8\" />\r\n <h1 className=\"text-2xl text-foreground\">{title}</h1>\r\n </div>\r\n </div>\r\n\r\n <div className=\"flex flex-col sm:flex-row sm:justify-end items-stretch sm:items-center px-3 sm:px-6 py-4 gap-3 sm:gap-4\">\r\n <div className=\"w-full sm:w-96\">\r\n <Input\r\n placeholder={`${tData('searchPlaceholder')} ${title}...`}\r\n value={searchTerm}\r\n onChange={event => setSearchTerm(event.target.value)}\r\n aria-label={`${tData('searchPlaceholder')} ${title}`}\r\n />\r\n </div>\r\n </div>\r\n\r\n <div className=\"flex-1 min-h-0 overflow-y-auto px-3 sm:px-6 pb-8\">\r\n {/* The rows hook and the cell renderers are the plugin's, so they run inside its\r\n scope and can reach usePluginStore, usePluginState and the rest. */}\r\n <PluginScopeProvider\r\n pluginId={registration.pluginId}\r\n config={configs[registration.pluginId]}\r\n >\r\n <PluginDataTable\r\n key={`${registration.pluginId}:${registration.id}`}\r\n registration={registration}\r\n searchTerm={searchTerm}\r\n />\r\n </PluginScopeProvider>\r\n </div>\r\n\r\n </div>\r\n </div>\r\n </div>\r\n )\r\n}\r\n\r\ninterface TableProps {\r\n registration: Registration\r\n searchTerm: string\r\n}\r\n\r\nfunction PluginDataTable({ registration, searchTerm }: TableProps) {\r\n const t = useTranslations('PluginDataPage')\r\n const message = usePluginMessageLookup()\r\n const { rows, isLoading, onRowClick } = registration.useRows()\r\n\r\n const filtered = React.useMemo(\r\n () => filterRows(rows, registration.searchKeys, searchTerm),\r\n [rows, registration.searchKeys, searchTerm],\r\n )\r\n\r\n if (isLoading && rows.length === 0) return <Empty text={t('loading')} />\r\n\r\n if (filtered.length === 0) {\r\n if (searchTerm.trim()) return <Empty text={t('noResults', { query: searchTerm.trim() })} />\r\n\r\n const empty = registration.emptyKey\r\n ? message(registration.pluginId, registration.emptyKey, registration.emptyKey)\r\n : t('empty')\r\n\r\n return <Empty text={empty} />\r\n }\r\n\r\n return (\r\n <div className=\"overflow-x-auto\">\r\n <table className=\"w-full text-sm\">\r\n <thead>\r\n <tr className=\"border-b text-left text-muted-foreground\">\r\n {registration.columns.map(column => (\r\n <th key={column.key} scope=\"col\" className=\"px-3 py-2 font-medium\">\r\n {message(registration.pluginId, column.labelKey, column.labelKey)}\r\n </th>\r\n ))}\r\n </tr>\r\n </thead>\r\n <tbody>\r\n {filtered.map((row, index) => (\r\n <tr\r\n key={rowKey(row, index)}\r\n className={onRowClick ? 'border-b hover:bg-accent/50 cursor-pointer' : 'border-b'}\r\n // Interactive only when the plugin gave it something to do.\r\n {...(onRowClick\r\n ? {\r\n role: 'button' as const,\r\n tabIndex: 0,\r\n onClick: () => onRowClick(row),\r\n onKeyDown: (event: React.KeyboardEvent) => {\r\n if (event.key !== 'Enter' && event.key !== ' ') return\r\n event.preventDefault()\r\n onRowClick(row)\r\n },\r\n }\r\n : {})}\r\n >\r\n {registration.columns.map(column => (\r\n <td key={column.key} className=\"px-3 py-2\">\r\n {column.render ? column.render(row) : formatCell(row[column.key])}\r\n </td>\r\n ))}\r\n </tr>\r\n ))}\r\n </tbody>\r\n </table>\r\n </div>\r\n )\r\n}\r\n\r\n/** A plugin's own `key` when it supplied one, so a re-render does not remount every row. */\r\nfunction rowKey(row: Row, index: number): string {\r\n return typeof row.key === 'string' ? row.key : String(index)\r\n}\r\n\r\n// Non-primitives render empty rather than \"[object Object]\"; use a column `render` instead.\r\nfunction formatCell(value: unknown): string {\r\n if (typeof value === 'string') return value\r\n if (typeof value === 'number' || typeof value === 'boolean') return String(value)\r\n return ''\r\n}\r\n\r\nfunction filterRows(rows: Row[], searchKeys: string[] | undefined, searchTerm: string): Row[] {\r\n const query = searchTerm.trim().toLowerCase()\r\n if (!query) return rows\r\n\r\n return rows.filter((row) => {\r\n const keys = searchKeys ?? Object.keys(row)\r\n return keys.some(key => formatCell(row[key]).toLowerCase().includes(query))\r\n })\r\n}\r\n\r\nfunction Empty({ text }: { text: string }) {\r\n return <p className=\"py-12 text-center text-sm text-muted-foreground\">{text}</p>\r\n}\r\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AA6CS,cA4BG,YA5BH;AAxCT,SAAS,uBAAuB;AAChC,YAAY,WAAW;AAEvB;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,aAAa;AACtB,SAAS,8BAA8B;AAEvC,SAAS,4BAA4B;AACrC,SAAS,kBAAkB,8BAA8B;AACzD,SAAS,2BAA2B;AACpC,SAAS,yBAAyB;AAY3B,SAAS,mBAAmB,EAAE,OAAO,GAA0B;AACpE,QAAM,gBAAgB,uBAAuB,YAAY;AACzD,QAAM,SAAS,qBAAqB,MAAM;AAE1C,QAAM,eAAe,SACjB,cAAc;AAAA,IACd,eAAa,UAAU,aAAa,OAAO,YAAY,UAAU,OAAO,OAAO;AAAA,EACjF,IACE;AAGJ,MAAI,CAAC,aAAc,QAAO;AAE1B,SAAO,oBAAC,kBAA4B,gBAAR,MAAoC;AAClE;AAEA,SAAS,eAAe,EAAE,aAAa,GAAmC;AACxE,QAAM,QAAQ,gBAAgB,UAAU;AACxC,QAAM,UAAU,uBAAuB;AACvC,QAAM,UAAU,iBAAiB;AACjC,QAAM,CAAC,YAAY,aAAa,IAAI,MAAM,SAAS,EAAE;AAErD,QAAM,QAAQ,QAAQ,aAAa,UAAU,aAAa,UAAU,aAAa,QAAQ;AACzF,QAAM,OAAO,kBAAkB,aAAa,IAAI;AAEhD,SACE,oBAAC,SAAI,WAAU,8CACb,8BAAC,SAAI,WAAU,kDACb,+BAAC,SAAI,WAAU,gCAEb;AAAA,wBAAC,SAAI,WAAU,qEACb,8BAAC,cAAW,WAAU,QACpB,8BAAC,kBACC,8BAAC,kBACC,8BAAC,kBAAgB,iBAAM,GACzB,GACF,GACF,GACF;AAAA,IAEA,oBAAC,SAAI,WAAU,wD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AAW,MAAa,YAAkC,YAA2B;AAC5F,QAAM,QAAQ,WAAW,KAAK,EAAE,YAAY;AAC5C,MAAI,CAAC,MAAO,QAAO;AAEnB,SAAO,KAAK,OAAO,CAAC,QAAQ;AAC1B,UAAM,OAAO,kCAAc,OAAO,KAAK,GAAG;AAC1C,WAAO,KAAK,KAAK,SAAO,WAAW,IAAI,GAAG,CAAC,EAAE,YAAY,EAAE,SAAS,KAAK,CAAC;AAAA,EAC5E,CAAC;AACH;AAEA,SAAS,MAAM,EAAE,KAAK,GAAqB;AACzC,SAAO,oBAAC,OAAE,WAAU,mDAAmD,gBAAK;AAC9E;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../../../src/core/plugins/host/PluginDataPageHost.tsx"],"sourcesContent":["'use client'\r\n\r\n// SPDX-License-Identifier: AGPL-3.0-or-later\r\n// Copyright (C) 2025 Collab Digital Twins\r\n\r\nimport { useTranslations } from 'next-intl'\r\nimport * as React from 'react'\r\n\r\nimport {\r\n Breadcrumb,\r\n BreadcrumbItem,\r\n BreadcrumbList,\r\n BreadcrumbPage,\r\n} from '../../components/ui/Breadcrumb'\r\nimport { Input } from '../../components/ui/Input'\r\nimport { usePluginMessageLookup } from '../sdk/messages'\r\n\r\nimport { resolvePluginIcon } from './pluginIcon'\r\nimport { parsePluginViewerKey } from './pluginViewerKey'\r\nimport { usePluginConfigs, usePluginContributions } from './provider'\r\nimport { PluginScopeProvider } from './scope'\r\n\r\nimport type { ViewerKey } from '../../types/dbTypes'\r\nimport type { DataPageRegistration } from '../sdk/types'\r\n\r\ntype Row = Record<string, unknown>\r\ntype Registration = DataPageRegistration & { pluginId: string }\r\n\r\n/**\r\n * Renders the `data.pages` contribution the viewer key names. The frame mirrors\r\n * `PluginsManager`, so a plugin page is indistinguishable from a built-in one.\r\n */\r\nexport function PluginDataPageHost({ viewer }: { viewer: ViewerKey }) {\r\n const registrations = usePluginContributions('data.pages')\r\n const target = parsePluginViewerKey(viewer)\r\n\r\n const registration = target\r\n ? registrations.find(\r\n candidate => candidate.pluginId === target.pluginId && candidate.id === target.pageId,\r\n )\r\n : undefined\r\n\r\n // The key comes from the URL, so rendering nothing lets `Viewer` fall back.\r\n if (!registration) return null\r\n\r\n return <PluginDataPage key={viewer} registration={registration} />\r\n}\r\n\r\nfunction PluginDataPage({ registration }: { registration: Registration }) {\r\n const tData = useTranslations('DataMenu')\r\n const message = usePluginMessageLookup()\r\n const configs = usePluginConfigs()\r\n const [searchTerm, setSearchTerm] = React.useState('')\r\n\r\n const title = message(registration.pluginId, registration.titleKey, registration.titleKey)\r\n const Icon = resolvePluginIcon(registration.icon)\r\n\r\n return (\r\n <div className=\"sm:p-2 overflow-hidden bg-[#fafafa] h-full\">\r\n <div className=\"bg-background rounded-xl shadow h-full min-h-0\">\r\n <div className=\"flex flex-col h-full min-h-0\">\r\n\r\n <div className=\"flex flex-row gap-2 justify-start items-center px-3 py-4 relative\">\r\n <Breadcrumb className=\"px-3\">\r\n <BreadcrumbList>\r\n <BreadcrumbItem>\r\n <BreadcrumbPage>{title}</BreadcrumbPage>\r\n </BreadcrumbItem>\r\n </BreadcrumbList>\r\n </Breadcrumb>\r\n </div>\r\n\r\n <div className=\"flex flex-row justify-between items-center px-6 py-6\">\r\n <div className=\"flex items-center gap-2\">\r\n <Icon className=\"h-8 w-8\" />\r\n <h1 className=\"text-2xl text-foreground\">{title}</h1>\r\n </div>\r\n </div>\r\n\r\n <div className=\"flex flex-col sm:flex-row sm:justify-end items-stretch sm:items-center px-3 sm:px-6 py-4 gap-3 sm:gap-4\">\r\n <div className=\"w-full sm:w-96\">\r\n <Input\r\n placeholder={`${tData('searchPlaceholder')} ${title}...`}\r\n value={searchTerm}\r\n onChange={event => setSearchTerm(event.target.value)}\r\n aria-label={`${tData('searchPlaceholder')} ${title}`}\r\n />\r\n </div>\r\n </div>\r\n\r\n <div className=\"flex-1 min-h-0 overflow-y-auto px-3 sm:px-6 pb-8\">\r\n {/* The rows hook and the cell renderers are the plugin's, so they run inside its\r\n scope and can reach usePluginStore, usePluginState and the rest. */}\r\n <PluginScopeProvider\r\n pluginId={registration.pluginId}\r\n config={configs[registration.pluginId]}\r\n >\r\n <PluginDataTable\r\n key={`${registration.pluginId}:${registration.id}`}\r\n registration={registration}\r\n searchTerm={searchTerm}\r\n />\r\n </PluginScopeProvider>\r\n </div>\r\n\r\n </div>\r\n </div>\r\n </div>\r\n )\r\n}\r\n\r\ninterface TableProps {\r\n registration: Registration\r\n searchTerm: string\r\n}\r\n\r\nfunction PluginDataTable({ registration, searchTerm }: TableProps) {\r\n const t = useTranslations('PluginDataPage')\r\n const message = usePluginMessageLookup()\r\n const { rows, isLoading, onRowClick } = registration.useRows()\r\n\r\n const filtered = React.useMemo(\r\n () => filterRows(rows, registration.searchKeys, searchTerm),\r\n [rows, registration.searchKeys, searchTerm],\r\n )\r\n\r\n if (isLoading && rows.length === 0) return <Empty text={t('loading')} />\r\n\r\n if (filtered.length === 0) {\r\n if (searchTerm.trim()) return <Empty text={t('noResults', { query: searchTerm.trim() })} />\r\n\r\n const empty = registration.emptyKey\r\n ? message(registration.pluginId, registration.emptyKey, registration.emptyKey)\r\n : t('empty')\r\n\r\n return <Empty text={empty} />\r\n }\r\n\r\n return (\r\n <div className=\"overflow-x-auto\">\r\n <table className=\"w-full text-sm\">\r\n <thead>\r\n <tr className=\"border-b text-left text-muted-foreground\">\r\n {registration.columns.map(column => (\r\n <th key={column.key} scope=\"col\" className=\"px-3 py-2 font-medium\">\r\n {message(registration.pluginId, column.labelKey, column.labelKey)}\r\n </th>\r\n ))}\r\n </tr>\r\n </thead>\r\n <tbody>\r\n {filtered.map((row, index) => (\r\n <tr\r\n key={rowKey(row, index)}\r\n className={onRowClick ? 'border-b hover:bg-accent/50 cursor-pointer' : 'border-b'}\r\n // Interactive only when the plugin gave it something to do.\r\n {...(onRowClick\r\n ? {\r\n role: 'button' as const,\r\n tabIndex: 0,\r\n onClick: () => onRowClick(row),\r\n onKeyDown: (event: React.KeyboardEvent) => {\r\n if (event.key !== 'Enter' && event.key !== ' ') return\r\n event.preventDefault()\r\n onRowClick(row)\r\n },\r\n }\r\n : {})}\r\n >\r\n {registration.columns.map(column => (\r\n <td key={column.key} className=\"px-3 py-2\">\r\n {column.render ? column.render(row) : formatCell(row[column.key])}\r\n </td>\r\n ))}\r\n </tr>\r\n ))}\r\n </tbody>\r\n </table>\r\n </div>\r\n )\r\n}\r\n\r\n/** A plugin's own `key` when it supplied one, so a re-render does not remount every row. */\r\nfunction rowKey(row: Row, index: number): string {\r\n return typeof row.key === 'string' ? row.key : String(index)\r\n}\r\n\r\n// Non-primitives render empty rather than \"[object Object]\"; use a column `render` instead.\r\nfunction formatCell(value: unknown): string {\r\n if (typeof value === 'string') return value\r\n if (typeof value === 'number' || typeof value === 'boolean') return String(value)\r\n return ''\r\n}\r\n\r\nfunction filterRows(rows: Row[], searchKeys: string[] | undefined, searchTerm: string): Row[] {\r\n const query = searchTerm.trim().toLowerCase()\r\n if (!query) return rows\r\n\r\n return rows.filter((row) => {\r\n const keys = searchKeys ?? Object.keys(row)\r\n return keys.some(key => formatCell(row[key]).toLowerCase().includes(query))\r\n })\r\n}\r\n\r\nfunction Empty({ text }: { text: string }) {\r\n return <p className=\"py-12 text-center text-sm text-muted-foreground\">{text}</p>\r\n}\r\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AA6CS,cA4BG,YA5BH;AAxCT,SAAS,uBAAuB;AAChC,YAAY,WAAW;AAEvB;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,aAAa;AACtB,SAAS,8BAA8B;AAEvC,SAAS,yBAAyB;AAClC,SAAS,4BAA4B;AACrC,SAAS,kBAAkB,8BAA8B;AACzD,SAAS,2BAA2B;AAY7B,SAAS,mBAAmB,EAAE,OAAO,GAA0B;AACpE,QAAM,gBAAgB,uBAAuB,YAAY;AACzD,QAAM,SAAS,qBAAqB,MAAM;AAE1C,QAAM,eAAe,SACjB,cAAc;AAAA,IACd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,WAAW,GAAG;AAAA,QAC7B,WAAW,CAAC,UAA+B;AACzC,cAAI,MAAM,QAAQ,WAAW,MAAM,QAAQ,IAAK;AAChD,gBAAM,eAAe;AACrB,qBAAW,GAAG;AAAA,QAChB;AAAA,MACF,IACE,CAAC,IAfN;AAAA,QAiBE,uBAAa,QAAQ,IAAI,YACxB,oBAAC,QAAoB,WAAU,aAC5B,iBAAO,SAAS,OAAO,OAAO,GAAG,IAAI,WAAW,IAAI,OAAO,GAAG,CAAC,KADzD,OAAO,GAEhB,CACD;AAAA;AAAA,MApBI,OAAO,KAAK,KAAK;AAAA,IAqBxB,CACD,GACH;AAAA,KACF,GACF;AAEJ;AAGA,SAAS,OAAO,KAAU,OAAuB;AAC/C,SAAO,OAAO,IAAI,QAAQ,WAAW,IAAI,MAAM,OAAO,KAAK;AAC7D;AAGA,SAAS,WAAW,OAAwB;AAC1C,MAAI,OAAO,UAAU,SAAU,QAAO;AACtC,MAAI,OAAO,UAAU,YAAY,OAAO,UAAU,UAAW,QAAO,OAAO,KAAK;AAChF,SAAO;AACT;AAEA,SAAS,WAAW,MAAa,YAAkC,YAA2B;AAC5F,QAAM,QAAQ,WAAW,KAAK,EAAE,YAAY;AAC5C,MAAI,CAAC,MAAO,QAAO;AAEnB,SAAO,KAAK,OAAO,CAAC,QAAQ;AAC1B,UAAM,OAAO,kCAAc,OAAO,KAAK,GAAG;AAC1C,WAAO,KAAK,KAAK,SAAO,WAAW,IAAI,GAAG,CAAC,EAAE,YAAY,EAAE,SAAS,KAAK,CAAC;AAAA,EAC5E,CAAC;AACH;AAEA,SAAS,MAAM,EAAE,KAAK,GAAqB;AACzC,SAAO,oBAAC,OAAE,WAAU,mDAAmD,gBAAK;AAC9E;","names":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../../../src/core/plugins/host/context.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../../../src/core/plugins/host/context.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAA;AAChD,OAAO,KAAK,EACV,aAAa,EACb,gBAAgB,EAEjB,MAAM,cAAc,CAAA;AAErB,UAAU,oBAAoB;IAC5B,QAAQ,EAAE,MAAM,CAAA;IAChB,YAAY,EAAE,gBAAgB,EAAE,CAAA;IAChC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IAC/B,QAAQ,EAAE,cAAc,CAAA;CACzB;AAwBD,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,oBAAoB,GAAG,aAAa,CAsBhF"}
|
|
@@ -17,6 +17,21 @@ var __spreadValues = (a, b) => {
|
|
|
17
17
|
return a;
|
|
18
18
|
};
|
|
19
19
|
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
20
|
+
import { ViewerNames } from "../sdk/types";
|
|
21
|
+
const TARGETABLE_VIEWERS = /* @__PURE__ */ new Set([
|
|
22
|
+
ViewerNames.map,
|
|
23
|
+
ViewerNames.bim,
|
|
24
|
+
ViewerNames.pointcloud
|
|
25
|
+
]);
|
|
26
|
+
function warnOnUnknownViewers(pluginId, key, item) {
|
|
27
|
+
const { viewers } = item;
|
|
28
|
+
if (!Array.isArray(viewers)) return;
|
|
29
|
+
const unknown = viewers.filter((viewer) => !TARGETABLE_VIEWERS.has(viewer));
|
|
30
|
+
if (unknown.length === 0) return;
|
|
31
|
+
console.warn(
|
|
32
|
+
`Plugin "${pluginId}" targets unknown viewer(s) ${unknown.map((v) => JSON.stringify(v)).join(", ")} in its "${key}" contribution, so it renders nowhere. Valid viewers: ${[...TARGETABLE_VIEWERS].join(", ")}.`
|
|
33
|
+
);
|
|
34
|
+
}
|
|
20
35
|
function createPluginContext(options) {
|
|
21
36
|
const { pluginId, capabilities, config, registry } = options;
|
|
22
37
|
const declared = new Set(capabilities);
|
|
@@ -29,6 +44,7 @@ function createPluginContext(options) {
|
|
|
29
44
|
`Plugin "${pluginId}" did not declare capability "${key}" in its manifest`
|
|
30
45
|
);
|
|
31
46
|
}
|
|
47
|
+
warnOnUnknownViewers(pluginId, key, item);
|
|
32
48
|
registry.register(key, __spreadProps(__spreadValues({}, item), { pluginId }));
|
|
33
49
|
}
|
|
34
50
|
};
|