@collabdt/core 0.13.2 → 0.14.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/core/components/ConfirmDialog.d.ts +3 -3
- package/dist/core/components/ConfirmDialog.d.ts.map +1 -1
- package/dist/core/components/ConfirmDialog.js +1 -1
- package/dist/core/components/ConfirmDialog.js.map +1 -1
- package/dist/core/components/ui/FilesManager/src/FileItemComponent.d.ts.map +1 -1
- package/dist/core/components/ui/FilesManager/src/FileItemComponent.js +13 -0
- package/dist/core/components/ui/FilesManager/src/FileItemComponent.js.map +1 -1
- package/dist/core/components/ui/FilesManager/src/useFileActions.d.ts +2 -1
- package/dist/core/components/ui/FilesManager/src/useFileActions.d.ts.map +1 -1
- package/dist/core/components/ui/FilesManager/src/useFileActions.js +4 -1
- package/dist/core/components/ui/FilesManager/src/useFileActions.js.map +1 -1
- package/dist/core/components/ui/chart.js +3 -3
- package/dist/core/components/ui/chart.js.map +1 -1
- package/dist/core/components/viewers/Viewer.d.ts.map +1 -1
- package/dist/core/components/viewers/Viewer.js +15 -3
- package/dist/core/components/viewers/Viewer.js.map +1 -1
- package/dist/core/components/viewers/bim/BimViewer.d.ts.map +1 -1
- package/dist/core/components/viewers/bim/BimViewer.js +2 -1
- package/dist/core/components/viewers/bim/BimViewer.js.map +1 -1
- package/dist/core/components/viewers/bim/src/BimLoadingState/index.d.ts.map +1 -1
- package/dist/core/components/viewers/bim/src/BimLoadingState/index.js +1 -6
- package/dist/core/components/viewers/bim/src/BimLoadingState/index.js.map +1 -1
- package/dist/core/components/viewers/bim/src/BimMeasurements/BimMeasurementManager.d.ts.map +1 -1
- package/dist/core/components/viewers/bim/src/BimMeasurements/BimMeasurementManager.js +1 -6
- package/dist/core/components/viewers/bim/src/BimMeasurements/BimMeasurementManager.js.map +1 -1
- package/dist/core/components/viewers/bim/src/BimSidebar/src/FileTab/src/BimSection.d.ts.map +1 -1
- package/dist/core/components/viewers/bim/src/BimSidebar/src/FileTab/src/BimSection.js +5 -2
- package/dist/core/components/viewers/bim/src/BimSidebar/src/FileTab/src/BimSection.js.map +1 -1
- package/dist/core/components/viewers/bim/src/BimSidebar/src/LayersTab/src/FloorplanSection.d.ts.map +1 -1
- package/dist/core/components/viewers/bim/src/BimSidebar/src/LayersTab/src/FloorplanSection.js +24 -15
- package/dist/core/components/viewers/bim/src/BimSidebar/src/LayersTab/src/FloorplanSection.js.map +1 -1
- package/dist/core/components/viewers/bim/src/CameraNavigation.d.ts.map +1 -1
- package/dist/core/components/viewers/bim/src/CameraNavigation.js +2 -7
- package/dist/core/components/viewers/bim/src/CameraNavigation.js.map +1 -1
- package/dist/core/components/viewers/bim/src/FloorplanTool/index.d.ts +37 -129
- package/dist/core/components/viewers/bim/src/FloorplanTool/index.d.ts.map +1 -1
- package/dist/core/components/viewers/bim/src/FloorplanTool/index.js +193 -395
- package/dist/core/components/viewers/bim/src/FloorplanTool/index.js.map +1 -1
- package/dist/core/components/viewers/bim/src/FloorplanTool/src/FloorplanRenderer.d.ts +1 -12
- package/dist/core/components/viewers/bim/src/FloorplanTool/src/FloorplanRenderer.d.ts.map +1 -1
- package/dist/core/components/viewers/bim/src/FloorplanTool/src/FloorplanRenderer.js +3 -5
- package/dist/core/components/viewers/bim/src/FloorplanTool/src/FloorplanRenderer.js.map +1 -1
- package/dist/core/components/viewers/bim/src/FloorplanTool/src/PlanCutFill.d.ts +15 -0
- package/dist/core/components/viewers/bim/src/FloorplanTool/src/PlanCutFill.d.ts.map +1 -0
- package/dist/core/components/viewers/bim/src/FloorplanTool/src/PlanCutFill.js +61 -0
- package/dist/core/components/viewers/bim/src/FloorplanTool/src/PlanCutFill.js.map +1 -0
- package/dist/core/components/viewers/bim/src/FloorplanTool/src/PlanShapeEditor.d.ts +37 -0
- package/dist/core/components/viewers/bim/src/FloorplanTool/src/PlanShapeEditor.d.ts.map +1 -0
- package/dist/core/components/viewers/bim/src/FloorplanTool/src/PlanShapeEditor.js +264 -0
- package/dist/core/components/viewers/bim/src/FloorplanTool/src/PlanShapeEditor.js.map +1 -0
- package/dist/core/components/viewers/bim/src/FloorplanTool/src/PlanSketch.d.ts +56 -0
- package/dist/core/components/viewers/bim/src/FloorplanTool/src/PlanSketch.d.ts.map +1 -0
- package/dist/core/components/viewers/bim/src/FloorplanTool/src/PlanSketch.js +337 -0
- package/dist/core/components/viewers/bim/src/FloorplanTool/src/PlanSketch.js.map +1 -0
- package/dist/core/components/viewers/bim/src/FloorplanTool/src/PluginPlanOverlay.d.ts +51 -0
- package/dist/core/components/viewers/bim/src/FloorplanTool/src/PluginPlanOverlay.d.ts.map +1 -0
- package/dist/core/components/viewers/bim/src/FloorplanTool/src/PluginPlanOverlay.js +238 -0
- package/dist/core/components/viewers/bim/src/FloorplanTool/src/PluginPlanOverlay.js.map +1 -0
- package/dist/core/components/viewers/bim/src/FloorplanTool/src/StoreyProjector.d.ts +1 -6
- package/dist/core/components/viewers/bim/src/FloorplanTool/src/StoreyProjector.d.ts.map +1 -1
- package/dist/core/components/viewers/bim/src/FloorplanTool/src/StoreyProjector.js +9 -18
- package/dist/core/components/viewers/bim/src/FloorplanTool/src/StoreyProjector.js.map +1 -1
- package/dist/core/components/viewers/bim/src/FloorplanTool/src/footprintOutline.d.ts +6 -0
- package/dist/core/components/viewers/bim/src/FloorplanTool/src/footprintOutline.d.ts.map +1 -0
- package/dist/core/components/viewers/bim/src/FloorplanTool/src/footprintOutline.js +91 -0
- package/dist/core/components/viewers/bim/src/FloorplanTool/src/footprintOutline.js.map +1 -0
- package/dist/core/components/viewers/bim/src/FloorplanTool/src/planPointer.d.ts +38 -0
- package/dist/core/components/viewers/bim/src/FloorplanTool/src/planPointer.d.ts.map +1 -0
- package/dist/core/components/viewers/bim/src/FloorplanTool/src/planPointer.js +77 -0
- package/dist/core/components/viewers/bim/src/FloorplanTool/src/planPointer.js.map +1 -0
- package/dist/core/components/viewers/bim/src/FloorplanTool/src/planScene.d.ts +15 -0
- package/dist/core/components/viewers/bim/src/FloorplanTool/src/planScene.d.ts.map +1 -0
- package/dist/core/components/viewers/bim/src/FloorplanTool/src/planScene.js +34 -0
- package/dist/core/components/viewers/bim/src/FloorplanTool/src/planScene.js.map +1 -0
- package/dist/core/components/viewers/bim/src/FloorplanTool/src/shapeEditing.d.ts +17 -0
- package/dist/core/components/viewers/bim/src/FloorplanTool/src/shapeEditing.d.ts.map +1 -0
- package/dist/core/components/viewers/bim/src/FloorplanTool/src/shapeEditing.js +75 -0
- package/dist/core/components/viewers/bim/src/FloorplanTool/src/shapeEditing.js.map +1 -0
- package/dist/core/components/viewers/bim/src/FloorplanTool/src/spaceFootprints.d.ts +16 -0
- package/dist/core/components/viewers/bim/src/FloorplanTool/src/spaceFootprints.d.ts.map +1 -0
- package/dist/core/components/viewers/bim/src/FloorplanTool/src/spaceFootprints.js +41 -0
- package/dist/core/components/viewers/bim/src/FloorplanTool/src/spaceFootprints.js.map +1 -0
- package/dist/core/components/viewers/bim/src/FloorplanTool/src/types.d.ts +5 -5
- package/dist/core/components/viewers/bim/src/FloorplanTool/src/types.d.ts.map +1 -1
- package/dist/core/components/viewers/bim/src/FloorplanTool/src/types.js +12 -1
- package/dist/core/components/viewers/bim/src/FloorplanTool/src/types.js.map +1 -1
- package/dist/core/components/viewers/bim/src/FloorplanTool/src/utils.d.ts +14 -6
- package/dist/core/components/viewers/bim/src/FloorplanTool/src/utils.d.ts.map +1 -1
- package/dist/core/components/viewers/bim/src/FloorplanTool/src/utils.js +76 -12
- package/dist/core/components/viewers/bim/src/FloorplanTool/src/utils.js.map +1 -1
- package/dist/core/components/viewers/bim/src/LoadModels.d.ts +3 -1
- package/dist/core/components/viewers/bim/src/LoadModels.d.ts.map +1 -1
- package/dist/core/components/viewers/bim/src/LoadModels.js +10 -14
- package/dist/core/components/viewers/bim/src/LoadModels.js.map +1 -1
- package/dist/core/components/viewers/bim/src/Placement/ModelTurnConfirm.d.ts +7 -0
- package/dist/core/components/viewers/bim/src/Placement/ModelTurnConfirm.d.ts.map +1 -0
- package/dist/core/components/viewers/bim/src/Placement/ModelTurnConfirm.js +78 -0
- package/dist/core/components/viewers/bim/src/Placement/ModelTurnConfirm.js.map +1 -0
- package/dist/core/components/viewers/bim/src/Placement/PlacementEditorHost.d.ts.map +1 -1
- package/dist/core/components/viewers/bim/src/Placement/PlacementEditorHost.js +18 -14
- package/dist/core/components/viewers/bim/src/Placement/PlacementEditorHost.js.map +1 -1
- package/dist/core/components/viewers/bim/src/Placement/targets/useModelTarget.d.ts.map +1 -1
- package/dist/core/components/viewers/bim/src/Placement/targets/useModelTarget.js +19 -0
- package/dist/core/components/viewers/bim/src/Placement/targets/useModelTarget.js.map +1 -1
- package/dist/core/components/viewers/bim/src/SimpleBimViewer.d.ts +1 -1
- package/dist/core/components/viewers/bim/src/SimpleBimViewer.d.ts.map +1 -1
- package/dist/core/components/viewers/bim/src/SimpleBimViewer.js +22 -3
- package/dist/core/components/viewers/bim/src/SimpleBimViewer.js.map +1 -1
- package/dist/core/components/viewers/bim/src/lib/CameraController.d.ts +7 -17
- package/dist/core/components/viewers/bim/src/lib/CameraController.d.ts.map +1 -1
- package/dist/core/components/viewers/bim/src/lib/CameraController.js +26 -14
- package/dist/core/components/viewers/bim/src/lib/CameraController.js.map +1 -1
- package/dist/core/components/viewers/bim/src/lib/ChromeController.d.ts +7 -8
- package/dist/core/components/viewers/bim/src/lib/ChromeController.d.ts.map +1 -1
- package/dist/core/components/viewers/bim/src/lib/ChromeController.js +22 -3
- package/dist/core/components/viewers/bim/src/lib/ChromeController.js.map +1 -1
- package/dist/core/components/viewers/bim/src/lib/TrueNorthPopover.d.ts +4 -12
- package/dist/core/components/viewers/bim/src/lib/TrueNorthPopover.d.ts.map +1 -1
- package/dist/core/components/viewers/bim/src/lib/TrueNorthPopover.js +2 -2
- package/dist/core/components/viewers/bim/src/lib/TrueNorthPopover.js.map +1 -1
- package/dist/core/components/viewers/bim/src/lib/applyModelPlacement.d.ts +3 -2
- package/dist/core/components/viewers/bim/src/lib/applyModelPlacement.d.ts.map +1 -1
- package/dist/core/components/viewers/bim/src/lib/applyModelPlacement.js +6 -2
- package/dist/core/components/viewers/bim/src/lib/applyModelPlacement.js.map +1 -1
- package/dist/core/components/viewers/bim/src/lib/createBimWorld.d.ts.map +1 -1
- package/dist/core/components/viewers/bim/src/lib/createBimWorld.js +2 -0
- package/dist/core/components/viewers/bim/src/lib/createBimWorld.js.map +1 -1
- package/dist/core/components/viewers/bim/src/lib/drawingProjection.d.ts +3 -25
- package/dist/core/components/viewers/bim/src/lib/drawingProjection.d.ts.map +1 -1
- package/dist/core/components/viewers/bim/src/lib/drawingProjection.js +2 -35
- package/dist/core/components/viewers/bim/src/lib/drawingProjection.js.map +1 -1
- package/dist/core/components/viewers/bim/src/lib/modelPlacementWatchers.d.ts +38 -0
- package/dist/core/components/viewers/bim/src/lib/modelPlacementWatchers.d.ts.map +1 -0
- package/dist/core/components/viewers/bim/src/lib/modelPlacementWatchers.js +58 -0
- package/dist/core/components/viewers/bim/src/lib/modelPlacementWatchers.js.map +1 -0
- package/dist/core/components/viewers/bim/src/lib/pickModelEdge.d.ts +14 -0
- package/dist/core/components/viewers/bim/src/lib/pickModelEdge.d.ts.map +1 -0
- package/dist/core/components/viewers/bim/src/lib/pickModelEdge.js +126 -0
- package/dist/core/components/viewers/bim/src/lib/pickModelEdge.js.map +1 -0
- package/dist/core/components/viewers/bim/src/lib/placedClipEdges.d.ts +19 -0
- package/dist/core/components/viewers/bim/src/lib/placedClipEdges.d.ts.map +1 -0
- package/dist/core/components/viewers/bim/src/lib/placedClipEdges.js +41 -0
- package/dist/core/components/viewers/bim/src/lib/placedClipEdges.js.map +1 -0
- package/dist/core/components/viewers/bim/src/lib/spaceOverlay.d.ts +10 -34
- package/dist/core/components/viewers/bim/src/lib/spaceOverlay.d.ts.map +1 -1
- package/dist/core/components/viewers/bim/src/lib/spaceOverlay.js +83 -53
- package/dist/core/components/viewers/bim/src/lib/spaceOverlay.js.map +1 -1
- package/dist/core/components/viewers/bim/src/lib/useProjectNorth.d.ts +8 -0
- package/dist/core/components/viewers/bim/src/lib/useProjectNorth.d.ts.map +1 -0
- package/dist/core/components/viewers/bim/src/lib/useProjectNorth.js +81 -0
- package/dist/core/components/viewers/bim/src/lib/useProjectNorth.js.map +1 -0
- package/dist/core/components/viewers/bim/src/tools/AddToBim/src/FileMarkerUtils.d.ts.map +1 -1
- package/dist/core/components/viewers/bim/src/tools/AddToBim/src/FileMarkerUtils.js +1 -0
- package/dist/core/components/viewers/bim/src/tools/AddToBim/src/FileMarkerUtils.js.map +1 -1
- package/dist/core/components/viewers/bim/src/tools/bimToolbar.d.ts.map +1 -1
- package/dist/core/components/viewers/bim/src/tools/bimToolbar.js +2 -14
- package/dist/core/components/viewers/bim/src/tools/bimToolbar.js.map +1 -1
- package/dist/core/components/viewers/plugins/PluginsManager.d.ts.map +1 -1
- package/dist/core/components/viewers/plugins/PluginsManager.js +7 -4
- package/dist/core/components/viewers/plugins/PluginsManager.js.map +1 -1
- package/dist/core/components/viewers/plugins/src/InstallHereButton.d.ts +9 -0
- package/dist/core/components/viewers/plugins/src/InstallHereButton.d.ts.map +1 -0
- package/dist/core/components/viewers/plugins/src/InstallHereButton.js +33 -0
- package/dist/core/components/viewers/plugins/src/InstallHereButton.js.map +1 -0
- package/dist/core/components/viewers/plugins/src/RegistryDetails.js +11 -6
- package/dist/core/components/viewers/plugins/src/RegistryDetails.js.map +1 -1
- package/dist/core/components/viewers/plugins/src/useRegistryPlugins.d.ts.map +1 -1
- package/dist/core/components/viewers/plugins/src/useRegistryPlugins.js +20 -7
- package/dist/core/components/viewers/plugins/src/useRegistryPlugins.js.map +1 -1
- package/dist/core/components/viewers/plugins/types.d.ts +11 -1
- package/dist/core/components/viewers/plugins/types.d.ts.map +1 -1
- package/dist/core/components/viewers/shared/placement/objectTarget.d.ts +2 -1
- package/dist/core/components/viewers/shared/placement/objectTarget.d.ts.map +1 -1
- package/dist/core/components/viewers/shared/placement/objectTarget.js +6 -3
- package/dist/core/components/viewers/shared/placement/objectTarget.js.map +1 -1
- package/dist/core/components/viewers/shared/placement/placementCore.d.ts +1 -0
- package/dist/core/components/viewers/shared/placement/placementCore.d.ts.map +1 -1
- package/dist/core/components/viewers/shared/placement/placementCore.js +12 -1
- package/dist/core/components/viewers/shared/placement/placementCore.js.map +1 -1
- package/dist/core/components/viewers/shared/placement/placementTarget.d.ts +2 -0
- package/dist/core/components/viewers/shared/placement/placementTarget.d.ts.map +1 -1
- package/dist/core/components/viewers/shared/placement/placementTarget.js.map +1 -1
- package/dist/core/components/viewers/shared/placement/projectNorth.d.ts +22 -0
- package/dist/core/components/viewers/shared/placement/projectNorth.d.ts.map +1 -0
- package/dist/core/components/viewers/shared/placement/projectNorth.js +39 -0
- package/dist/core/components/viewers/shared/placement/projectNorth.js.map +1 -0
- package/dist/core/hooks/plugins/createPluginHooks.d.ts +1 -0
- package/dist/core/hooks/plugins/createPluginHooks.d.ts.map +1 -1
- package/dist/core/hooks/plugins/createPluginHooks.js +5 -4
- package/dist/core/hooks/plugins/createPluginHooks.js.map +1 -1
- package/dist/core/hooks/useUndoRedoShortcuts.d.ts.map +1 -1
- package/dist/core/hooks/useUndoRedoShortcuts.js +1 -6
- package/dist/core/hooks/useUndoRedoShortcuts.js.map +1 -1
- package/dist/core/i18n/messages/en.json +16 -4
- package/dist/core/i18n/messages/es.json +16 -4
- package/dist/core/i18n/messages/fr.json +16 -4
- package/dist/core/plugins/host/PluginDataPageHost.d.ts.map +1 -1
- package/dist/core/plugins/host/PluginDataPageHost.js +30 -25
- package/dist/core/plugins/host/PluginDataPageHost.js.map +1 -1
- package/dist/core/plugins/host/pluginDatasetLookup.d.ts +6 -0
- package/dist/core/plugins/host/pluginDatasetLookup.d.ts.map +1 -0
- package/dist/core/plugins/host/pluginDatasetLookup.js +9 -0
- package/dist/core/plugins/host/pluginDatasetLookup.js.map +1 -0
- package/dist/core/plugins/host/pluginDatasets.d.ts +0 -8
- package/dist/core/plugins/host/pluginDatasets.d.ts.map +1 -1
- package/dist/core/plugins/host/pluginDatasets.js +1 -65
- package/dist/core/plugins/host/pluginDatasets.js.map +1 -1
- package/dist/core/plugins/host/provider.d.ts.map +1 -1
- package/dist/core/plugins/host/provider.js +12 -1
- package/dist/core/plugins/host/provider.js.map +1 -1
- package/dist/core/plugins/host/runtimeMessages.d.ts +13 -0
- package/dist/core/plugins/host/runtimeMessages.d.ts.map +1 -0
- package/dist/core/plugins/host/runtimeMessages.js +21 -0
- package/dist/core/plugins/host/runtimeMessages.js.map +1 -0
- package/dist/core/plugins/host/runtimeShims.d.ts +2 -0
- package/dist/core/plugins/host/runtimeShims.d.ts.map +1 -1
- package/dist/core/plugins/host/runtimeShims.js +28 -1
- package/dist/core/plugins/host/runtimeShims.js.map +1 -1
- package/dist/core/plugins/host/toPluginDataset.d.ts +10 -0
- package/dist/core/plugins/host/toPluginDataset.d.ts.map +1 -0
- package/dist/core/plugins/host/toPluginDataset.js +68 -0
- package/dist/core/plugins/host/toPluginDataset.js.map +1 -0
- package/dist/core/plugins/host/usePluginToolbarTools.d.ts.map +1 -1
- package/dist/core/plugins/host/usePluginToolbarTools.js +6 -2
- package/dist/core/plugins/host/usePluginToolbarTools.js.map +1 -1
- package/dist/core/plugins/sdk/bimViewer.d.ts +25 -5
- package/dist/core/plugins/sdk/bimViewer.d.ts.map +1 -1
- package/dist/core/plugins/sdk/bimViewer.js +66 -10
- package/dist/core/plugins/sdk/bimViewer.js.map +1 -1
- package/dist/core/plugins/sdk/charts.d.ts +4 -0
- package/dist/core/plugins/sdk/charts.d.ts.map +1 -0
- package/dist/core/plugins/sdk/charts.js +46 -0
- package/dist/core/plugins/sdk/charts.js.map +1 -0
- package/dist/core/plugins/sdk/components.d.ts +1 -0
- package/dist/core/plugins/sdk/components.d.ts.map +1 -1
- package/dist/core/plugins/sdk/components.js +2 -0
- package/dist/core/plugins/sdk/components.js.map +1 -1
- package/dist/core/plugins/sdk/datasets.d.ts +6 -2
- package/dist/core/plugins/sdk/datasets.d.ts.map +1 -1
- package/dist/core/plugins/sdk/datasets.js +15 -2
- package/dist/core/plugins/sdk/datasets.js.map +1 -1
- package/dist/core/plugins/sdk/floorplan.d.ts +64 -0
- package/dist/core/plugins/sdk/floorplan.d.ts.map +1 -0
- package/dist/core/plugins/sdk/floorplan.js +102 -0
- package/dist/core/plugins/sdk/floorplan.js.map +1 -0
- package/dist/core/plugins/sdk/messages.d.ts.map +1 -1
- package/dist/core/plugins/sdk/messages.js +31 -15
- package/dist/core/plugins/sdk/messages.js.map +1 -1
- package/dist/core/plugins/sdk/types.d.ts +13 -2
- package/dist/core/plugins/sdk/types.d.ts.map +1 -1
- package/dist/core/plugins/sdk/types.js.map +1 -1
- package/dist/core/plugins/sdk/ui.d.ts +6 -0
- package/dist/core/plugins/sdk/ui.d.ts.map +1 -1
- package/dist/core/plugins/sdk/ui.js +13 -0
- package/dist/core/plugins/sdk/ui.js.map +1 -1
- package/dist/core/types/global.d.ts +1 -1
- package/dist/core/types/global.d.ts.map +1 -1
- package/dist/core/types/global.js.map +1 -1
- package/dist/core/utils/utils.d.ts +2 -0
- package/dist/core/utils/utils.d.ts.map +1 -1
- package/dist/core/utils/utils.js +4 -0
- package/dist/core/utils/utils.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
|
|
3
|
+
"use client";
|
|
4
|
+
var __defProp = Object.defineProperty;
|
|
5
|
+
var __defProps = Object.defineProperties;
|
|
6
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
7
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
8
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
10
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
11
|
+
var __spreadValues = (a, b) => {
|
|
12
|
+
for (var prop in b || (b = {}))
|
|
13
|
+
if (__hasOwnProp.call(b, prop))
|
|
14
|
+
__defNormalProp(a, prop, b[prop]);
|
|
15
|
+
if (__getOwnPropSymbols)
|
|
16
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
17
|
+
if (__propIsEnum.call(b, prop))
|
|
18
|
+
__defNormalProp(a, prop, b[prop]);
|
|
19
|
+
}
|
|
20
|
+
return a;
|
|
21
|
+
};
|
|
22
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
23
|
+
import * as React from "react";
|
|
24
|
+
import { FloorplanTool } from "../../components/viewers/bim/src/FloorplanTool";
|
|
25
|
+
import { readPlanFootprints } from "../../components/viewers/bim/src/FloorplanTool/src/spaceFootprints";
|
|
26
|
+
const EMPTY_SNAPSHOT = { storeys: [], active: null, isDrawing: false, isEditingShape: false, hasLines: false };
|
|
27
|
+
function findTool(components) {
|
|
28
|
+
var _a;
|
|
29
|
+
return (_a = components == null ? void 0 : components.list.get(FloorplanTool.uuid)) != null ? _a : null;
|
|
30
|
+
}
|
|
31
|
+
function toStorey(entry) {
|
|
32
|
+
return { id: entry.id, name: entry.name, elevation: entry.elevation, modelId: entry.modelId };
|
|
33
|
+
}
|
|
34
|
+
function snapshot(tool) {
|
|
35
|
+
var _a;
|
|
36
|
+
if (!tool) return EMPTY_SNAPSHOT;
|
|
37
|
+
const active = tool.activeDrawing;
|
|
38
|
+
return {
|
|
39
|
+
storeys: tool.drawings.map(toStorey),
|
|
40
|
+
active: active ? toStorey(active) : null,
|
|
41
|
+
isDrawing: tool.sketch.isActive,
|
|
42
|
+
isEditingShape: tool.editor.isActive,
|
|
43
|
+
hasLines: (_a = active == null ? void 0 : active.projected) != null ? _a : false
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
function useFloorplanSource(components) {
|
|
47
|
+
const tool = findTool(components);
|
|
48
|
+
const [state, setState] = React.useState(() => snapshot(tool));
|
|
49
|
+
React.useEffect(() => {
|
|
50
|
+
const update = () => setState(snapshot(tool));
|
|
51
|
+
update();
|
|
52
|
+
if (!tool) return;
|
|
53
|
+
tool.onDrawingsChanged.add(update);
|
|
54
|
+
tool.onActiveDrawingChanged.add(update);
|
|
55
|
+
tool.sketch.onActiveChanged.add(update);
|
|
56
|
+
tool.editor.onActiveChanged.add(update);
|
|
57
|
+
tool.onLayersChanged.add(update);
|
|
58
|
+
return () => {
|
|
59
|
+
tool.onDrawingsChanged.remove(update);
|
|
60
|
+
tool.onActiveDrawingChanged.remove(update);
|
|
61
|
+
tool.sketch.onActiveChanged.remove(update);
|
|
62
|
+
tool.editor.onActiveChanged.remove(update);
|
|
63
|
+
tool.onLayersChanged.remove(update);
|
|
64
|
+
};
|
|
65
|
+
}, [tool]);
|
|
66
|
+
return React.useMemo(() => ({ tool, components, state }), [tool, components, state]);
|
|
67
|
+
}
|
|
68
|
+
function bindPluginFloorplan(source, pluginId) {
|
|
69
|
+
const { tool, components, state } = source;
|
|
70
|
+
return __spreadProps(__spreadValues({
|
|
71
|
+
available: tool !== null
|
|
72
|
+
}, state), {
|
|
73
|
+
activate: async (storeyId) => {
|
|
74
|
+
await (tool == null ? void 0 : tool.activate(storeyId));
|
|
75
|
+
},
|
|
76
|
+
deactivate: async () => {
|
|
77
|
+
await (tool == null ? void 0 : tool.deactivate());
|
|
78
|
+
},
|
|
79
|
+
generateLines: async () => {
|
|
80
|
+
const id = tool == null ? void 0 : tool.activeDrawingId;
|
|
81
|
+
if (id) await tool.generateLines(id);
|
|
82
|
+
},
|
|
83
|
+
frame: async (points) => {
|
|
84
|
+
await (tool == null ? void 0 : tool.framePoints(points));
|
|
85
|
+
},
|
|
86
|
+
drawShape: async (kind) => tool ? tool.sketch.start(kind) : null,
|
|
87
|
+
editShape: async (points) => tool ? tool.editor.start(points) : null,
|
|
88
|
+
finishEditingShape: () => tool == null ? void 0 : tool.editor.commit(),
|
|
89
|
+
cancelDrawing: () => {
|
|
90
|
+
tool == null ? void 0 : tool.sketch.cancel();
|
|
91
|
+
tool == null ? void 0 : tool.editor.cancel();
|
|
92
|
+
},
|
|
93
|
+
setOverlay: (shapes, options) => tool == null ? void 0 : tool.overlay.set(pluginId, shapes, options),
|
|
94
|
+
clearOverlay: () => tool == null ? void 0 : tool.overlay.clear(pluginId),
|
|
95
|
+
getSpaceFootprints: async (items) => components ? readPlanFootprints(components, items) : []
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
export {
|
|
99
|
+
bindPluginFloorplan,
|
|
100
|
+
useFloorplanSource
|
|
101
|
+
};
|
|
102
|
+
//# sourceMappingURL=floorplan.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/core/plugins/sdk/floorplan.ts"],"sourcesContent":["'use client'\n\n// SPDX-License-Identifier: AGPL-3.0-or-later\n// Copyright (C) 2025 Collab Digital Twins\n\nimport * as React from 'react'\n\nimport { FloorplanTool } from '../../components/viewers/bim/src/FloorplanTool'\nimport { readPlanFootprints } from '../../components/viewers/bim/src/FloorplanTool/src/spaceFootprints'\n\nimport type { PlanOverlayOptions, PlanOverlayShape, PlanPoint, SketchKind } from '../../components/viewers/bim/src/FloorplanTool'\nimport type { PlanFootprint } from '../../components/viewers/bim/src/FloorplanTool/src/spaceFootprints'\nimport type { ModelIdMap } from '../../components/viewers/bim/src/lib/bimTree'\nimport type * as OBC from '@thatopen/components'\n\nexport interface FloorplanStorey {\n /** Stable for the session: `${modelId}::${storeyName}`. */\n id: string\n name: string\n /** World height of the storey, in metres. */\n elevation: number\n modelId: string\n}\n\n/** The BIM floorplan as a plugin sees it. Coordinates are world metres on the horizontal plane. */\nexport interface PluginFloorplan {\n /** False in a viewer without floorplans; every method is then a no-op. */\n available: boolean\n storeys: FloorplanStorey[]\n active: FloorplanStorey | null\n isDrawing: boolean\n /** True while `editShape` is waiting for the user to finish reshaping an outline. */\n isEditingShape: boolean\n /** True once the open storey's vector lines exist; sketches snap to their corners. */\n hasLines: boolean\n activate: (storeyId: string) => Promise<void>\n deactivate: () => Promise<void>\n /** Projects the open storey's vector lines. Slow on large models, so it is a separate step. */\n generateLines: () => Promise<void>\n /** Fits the open plan's view to an outline, such as a space's, with some margin around it. */\n frame: (points: readonly PlanPoint[]) => Promise<void>\n /** Resolves with the drawn outline, or null when cancelled or no plan is open. */\n drawShape: (kind: SketchKind) => Promise<PlanPoint[] | null>\n /**\n * Lets the user drag the outline's corners and edges; Ctrl+click adds a corner, Delete removes one.\n * Resolves with the new outline on Enter or `finishEditingShape`, or null when cancelled.\n */\n editShape: (points: readonly PlanPoint[]) => Promise<PlanPoint[] | null>\n finishEditingShape: () => void\n /** Cancels a drawing or a shape edit in progress. */\n cancelDrawing: () => void\n /** Replaces this plugin's shapes on the open plan. They follow whichever storey is open. */\n setOverlay: (shapes: readonly PlanOverlayShape[], options?: PlanOverlayOptions) => void\n clearOverlay: () => void\n /** Floor outlines of elements such as IFCSPACEs, for drawing them with `setOverlay`. */\n getSpaceFootprints: (items: ModelIdMap) => Promise<PlanFootprint[]>\n}\n\ninterface FloorplanSnapshot {\n storeys: FloorplanStorey[]\n active: FloorplanStorey | null\n isDrawing: boolean\n isEditingShape: boolean\n hasLines: boolean\n}\n\nconst EMPTY_SNAPSHOT: FloorplanSnapshot = { storeys: [], active: null, isDrawing: false, isEditingShape: false, hasLines: false }\n\n// `list.get`, not `components.get`: the latter would create the tool in a viewer that has none.\nfunction findTool(components: OBC.Components | null): FloorplanTool | null {\n return (components?.list.get(FloorplanTool.uuid) as FloorplanTool | undefined) ?? null\n}\n\nfunction toStorey(entry: { id: string; name: string; elevation: number; modelId: string }): FloorplanStorey {\n return { id: entry.id, name: entry.name, elevation: entry.elevation, modelId: entry.modelId }\n}\n\nfunction snapshot(tool: FloorplanTool | null): FloorplanSnapshot {\n if (!tool) return EMPTY_SNAPSHOT\n const active = tool.activeDrawing\n return {\n storeys: tool.drawings.map(toStorey),\n active: active ? toStorey(active) : null,\n isDrawing: tool.sketch.isActive,\n isEditingShape: tool.editor.isActive,\n hasLines: active?.projected ?? false,\n }\n}\n\n/** Live floorplan state plus the tool, for binding to a plugin with {@link bindPluginFloorplan}. */\nexport function useFloorplanSource(components: OBC.Components | null) {\n const tool = findTool(components)\n const [state, setState] = React.useState<FloorplanSnapshot>(() => snapshot(tool))\n\n React.useEffect(() => {\n const update = () => setState(snapshot(tool))\n update()\n if (!tool) return\n tool.onDrawingsChanged.add(update)\n tool.onActiveDrawingChanged.add(update)\n tool.sketch.onActiveChanged.add(update)\n tool.editor.onActiveChanged.add(update)\n tool.onLayersChanged.add(update)\n return () => {\n tool.onDrawingsChanged.remove(update)\n tool.onActiveDrawingChanged.remove(update)\n tool.sketch.onActiveChanged.remove(update)\n tool.editor.onActiveChanged.remove(update)\n tool.onLayersChanged.remove(update)\n }\n }, [tool])\n\n return React.useMemo(() => ({ tool, components, state }), [tool, components, state])\n}\n\nexport type FloorplanSource = ReturnType<typeof useFloorplanSource>\n\n/** The floorplan surface for one plugin; overlays are kept per `pluginId`. */\nexport function bindPluginFloorplan(source: FloorplanSource, pluginId: string): PluginFloorplan {\n const { tool, components, state } = source\n return {\n available: tool !== null,\n ...state,\n activate: async (storeyId) => { await tool?.activate(storeyId) },\n deactivate: async () => { await tool?.deactivate() },\n generateLines: async () => {\n const id = tool?.activeDrawingId\n if (id) await tool.generateLines(id)\n },\n frame: async (points) => { await tool?.framePoints(points) },\n drawShape: async kind => (tool ? tool.sketch.start(kind) : null),\n editShape: async points => (tool ? tool.editor.start(points) : null),\n finishEditingShape: () => tool?.editor.commit(),\n cancelDrawing: () => {\n tool?.sketch.cancel()\n tool?.editor.cancel()\n },\n setOverlay: (shapes, options) => tool?.overlay.set(pluginId, shapes, options),\n clearOverlay: () => tool?.overlay.clear(pluginId),\n getSpaceFootprints: async items => (components ? readPlanFootprints(components, items) : []),\n }\n}\n\nexport type { PlanFootprint, PlanOverlayOptions, PlanOverlayShape, PlanPoint, SketchKind }\n"],"mappings":";;;;;;;;;;;;;;;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"messages.d.ts","sourceRoot":"","sources":["../../../../src/core/plugins/sdk/messages.ts"],"names":[],"mappings":"AAaA;;;;;;;GAOG;AAEH,kFAAkF;AAClF,iBAAS,mBAAmB,CAC1B,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,EAC7C,QAAQ,EAAE,MAAM,EAChB,GAAG,EAAE,MAAM,GACV,MAAM,GAAG,SAAS,CAKpB;AA6BD;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAGxF;AAED,MAAM,MAAM,gBAAgB,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,KAAK,MAAM,CAAA;AAEzE;;;;GAIG;AACH,wBAAgB,qBAAqB,IAAI,gBAAgB,CAQxD;AAED,MAAM,MAAM,mBAAmB,GAAG,CAAC,QAAQ,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,KAAK,MAAM,CAAA;AAE7F;;;GAGG;AACH,wBAAgB,sBAAsB,IAAI,mBAAmB,CAM5D;AAED,mGAAmG;AACnG,wBAAgB,mBAAmB,CAAC,SAAS,EAAE,MAAM,+DAEpD;AAED,OAAO,EAAE,mBAAmB,IAAI,qBAAqB,EAAE,CAAA"}
|
|
@@ -1,50 +1,66 @@
|
|
|
1
1
|
'use client'
|
|
2
2
|
|
|
3
3
|
"use client";
|
|
4
|
-
import { useMessages, useTranslations } from "next-intl";
|
|
4
|
+
import { useLocale, useMessages, useTranslations } from "next-intl";
|
|
5
5
|
import * as React from "react";
|
|
6
|
+
import { RuntimePluginMessagesContext } from "../host/runtimeMessages";
|
|
6
7
|
import { usePluginId } from "../host/scope";
|
|
7
8
|
function lookupPluginMessage(messages, pluginId, key) {
|
|
8
9
|
const plugins = messages == null ? void 0 : messages.plugins;
|
|
9
10
|
if (typeof plugins !== "object" || plugins === null) return void 0;
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
return readKey(plugins[pluginId], key);
|
|
12
|
+
}
|
|
13
|
+
function readKey(strings, key) {
|
|
14
|
+
let node = strings;
|
|
13
15
|
for (const part of key.split(".")) {
|
|
14
16
|
if (typeof node !== "object" || node === null) return void 0;
|
|
15
17
|
node = node[part];
|
|
16
18
|
}
|
|
17
19
|
return typeof node === "string" && node.length > 0 ? node : void 0;
|
|
18
20
|
}
|
|
19
|
-
function
|
|
21
|
+
function usePluginMessageReader() {
|
|
20
22
|
const messages = useMessages();
|
|
21
|
-
|
|
22
|
-
|
|
23
|
+
const runtime = React.useContext(RuntimePluginMessagesContext);
|
|
24
|
+
const locale = useLocale().toLowerCase();
|
|
25
|
+
return React.useCallback(
|
|
26
|
+
(pluginId, key) => {
|
|
23
27
|
var _a;
|
|
24
|
-
return (_a = lookupPluginMessage(messages, pluginId, key)) != null ? _a :
|
|
28
|
+
return (_a = lookupPluginMessage(messages, pluginId, key)) != null ? _a : readRuntimeMessage(runtime, pluginId, locale, key);
|
|
25
29
|
},
|
|
26
|
-
[messages,
|
|
30
|
+
[messages, runtime, locale]
|
|
27
31
|
);
|
|
28
32
|
}
|
|
33
|
+
function readRuntimeMessage(runtime, pluginId, locale, key) {
|
|
34
|
+
var _a;
|
|
35
|
+
const own = runtime[pluginId];
|
|
36
|
+
return own ? (_a = readKey(own[locale], key)) != null ? _a : readKey(own.en, key) : void 0;
|
|
37
|
+
}
|
|
38
|
+
function usePluginMessage(pluginId, key, fallback) {
|
|
39
|
+
const read = usePluginMessageReader();
|
|
40
|
+
return React.useMemo(() => {
|
|
41
|
+
var _a;
|
|
42
|
+
return (_a = read(pluginId, key)) != null ? _a : fallback;
|
|
43
|
+
}, [read, pluginId, key, fallback]);
|
|
44
|
+
}
|
|
29
45
|
function usePluginTranslations() {
|
|
30
46
|
const pluginId = usePluginId();
|
|
31
|
-
const
|
|
47
|
+
const read = usePluginMessageReader();
|
|
32
48
|
return React.useCallback(
|
|
33
49
|
(key, fallback) => {
|
|
34
50
|
var _a, _b;
|
|
35
|
-
return (_b = (_a =
|
|
51
|
+
return (_b = (_a = read(pluginId, key)) != null ? _a : fallback) != null ? _b : `plugins.${pluginId}.${key}`;
|
|
36
52
|
},
|
|
37
|
-
[
|
|
53
|
+
[read, pluginId]
|
|
38
54
|
);
|
|
39
55
|
}
|
|
40
56
|
function usePluginMessageLookup() {
|
|
41
|
-
const
|
|
57
|
+
const read = usePluginMessageReader();
|
|
42
58
|
return React.useCallback(
|
|
43
59
|
(pluginId, key, fallback) => {
|
|
44
60
|
var _a;
|
|
45
|
-
return (_a =
|
|
61
|
+
return (_a = read(pluginId, key)) != null ? _a : fallback;
|
|
46
62
|
},
|
|
47
|
-
[
|
|
63
|
+
[read]
|
|
48
64
|
);
|
|
49
65
|
}
|
|
50
66
|
function useCoreTranslations(namespace) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/core/plugins/sdk/messages.ts"],"sourcesContent":["'use client'\n\n// SPDX-License-Identifier: AGPL-3.0-or-later\n// Copyright (C) 2025 Collab Digital Twins\n\nimport { useMessages, useTranslations } from 'next-intl'\nimport * as React from 'react'\n\nimport { usePluginId } from '../host/scope'\n\n/**\n * Translations for plugin-supplied text.\n *\n * A plugin's catalog is merged under `plugins.<pluginId>`, giving the locale\n * fallbacks for free. What this module adds is the last one: a plugin may ship no\n * catalog, or one missing the key, and the manifest's own string is shown rather\n * than `plugins.foo.name`. An untranslated plugin stays usable.\n */\n\n/** Reads `plugins.<pluginId>.<key>` out of the merged catalog, if it is there. */\nfunction lookupPluginMessage(\n messages: Record<string, unknown> | undefined,\n pluginId: string,\n key: string,\n): string | undefined {\n const plugins = messages?.plugins\n if (typeof plugins !== 'object' || plugins === null) return undefined\n\n
|
|
1
|
+
{"version":3,"sources":["../../../../src/core/plugins/sdk/messages.ts"],"sourcesContent":["'use client'\n\n// SPDX-License-Identifier: AGPL-3.0-or-later\n// Copyright (C) 2025 Collab Digital Twins\n\nimport { useLocale, useMessages, useTranslations } from 'next-intl'\nimport * as React from 'react'\n\nimport { RuntimePluginMessagesContext } from '../host/runtimeMessages'\nimport { usePluginId } from '../host/scope'\n\nimport type { RuntimePluginMessages } from '../host/runtimeMessages'\n\n/**\n * Translations for plugin-supplied text.\n *\n * A plugin's catalog is merged under `plugins.<pluginId>`, giving the locale\n * fallbacks for free. What this module adds is the last one: a plugin may ship no\n * catalog, or one missing the key, and the manifest's own string is shown rather\n * than `plugins.foo.name`. An untranslated plugin stays usable.\n */\n\n/** Reads `plugins.<pluginId>.<key>` out of the merged catalog, if it is there. */\nfunction lookupPluginMessage(\n messages: Record<string, unknown> | undefined,\n pluginId: string,\n key: string,\n): string | undefined {\n const plugins = messages?.plugins\n if (typeof plugins !== 'object' || plugins === null) return undefined\n\n return readKey((plugins as Record<string, unknown>)[pluginId], key)\n}\n\n// Dotted keys address nested groups, e.g. 'spaces.title'.\nfunction readKey(strings: unknown, key: string): string | undefined {\n let node: unknown = strings\n for (const part of key.split('.')) {\n if (typeof node !== 'object' || node === null) return undefined\n node = (node as Record<string, unknown>)[part]\n }\n return typeof node === 'string' && node.length > 0 ? node : undefined\n}\n\n// The catalog first, then a runtime-loaded manifest in the active locale, then its English.\nfunction usePluginMessageReader() {\n const messages = useMessages() as Record<string, unknown> | undefined\n const runtime = React.useContext(RuntimePluginMessagesContext)\n const locale = useLocale().toLowerCase()\n\n return React.useCallback(\n (pluginId: string, key: string) => lookupPluginMessage(messages, pluginId, key) ?? readRuntimeMessage(runtime, pluginId, locale, key),\n [messages, runtime, locale],\n )\n}\n\nfunction readRuntimeMessage(runtime: RuntimePluginMessages, pluginId: string, locale: string, key: string): string | undefined {\n const own = runtime[pluginId]\n return own ? readKey(own[locale], key) ?? readKey(own.en, key) : undefined\n}\n\n/**\n * One piece of plugin-supplied text, with the manifest string as the fallback.\n * For anything core renders on a plugin's behalf — its name, description, a\n * contributed tool's label.\n */\nexport function usePluginMessage(pluginId: string, key: string, fallback: string): string {\n const read = usePluginMessageReader()\n return React.useMemo(() => read(pluginId, key) ?? fallback, [read, pluginId, key, fallback])\n}\n\nexport type PluginTranslator = (key: string, fallback?: string) => string\n\n/**\n * A `t()` scoped to the calling plugin's namespace. Only valid inside a plugin\n * subtree, so a plugin cannot read another's strings. Without a `fallback`, a\n * missing key renders as `plugins.<pluginId>.<key>` rather than throwing.\n */\nexport function usePluginTranslations(): PluginTranslator {\n const pluginId = usePluginId()\n const read = usePluginMessageReader()\n\n return React.useCallback(\n (key: string, fallback?: string) => read(pluginId, key) ?? fallback ?? `plugins.${pluginId}.${key}`,\n [read, pluginId],\n )\n}\n\nexport type PluginMessageLookup = (pluginId: string, key: string, fallback: string) => string\n\n/**\n * Text for several plugins at once, for a host rendering a list of contributions — a hook\n * cannot be called per row. Host-side only; a plugin has `usePluginTranslations`.\n */\nexport function usePluginMessageLookup(): PluginMessageLookup {\n const read = usePluginMessageReader()\n return React.useCallback(\n (pluginId: string, key: string, fallback: string) => read(pluginId, key) ?? fallback,\n [read],\n )\n}\n\n/** Core's own strings, kept a separate call so plugin and core text differ at the point of use. */\nexport function useCoreTranslations(namespace: string) {\n return useTranslations(namespace)\n}\n\nexport { lookupPluginMessage as __lookupPluginMessage }\n"],"mappings":";AAKA,SAAS,WAAW,aAAa,uBAAuB;AACxD,YAAY,WAAW;AAEvB,SAAS,oCAAoC;AAC7C,SAAS,mBAAmB;AAc5B,SAAS,oBACP,UACA,UACA,KACoB;AACpB,QAAM,UAAU,qCAAU;AAC1B,MAAI,OAAO,YAAY,YAAY,YAAY,KAAM,QAAO;AAE5D,SAAO,QAAS,QAAoC,QAAQ,GAAG,GAAG;AACpE;AAGA,SAAS,QAAQ,SAAkB,KAAiC;AAClE,MAAI,OAAgB;AACpB,aAAW,QAAQ,IAAI,MAAM,GAAG,GAAG;AACjC,QAAI,OAAO,SAAS,YAAY,SAAS,KAAM,QAAO;AACtD,WAAQ,K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AAA,IAC5E,CAAC,IAAI;AAAA,EACP;AACF;AAGO,SAAS,oBAAoB,WAAmB;AACrD,SAAO,gBAAgB,SAAS;AAClC;","names":[]}
|
|
@@ -50,16 +50,27 @@ export interface DataPageRows<Row> {
|
|
|
50
50
|
/** From the hook, not the registration, so it can close over `usePluginDialogs`. */
|
|
51
51
|
onRowClick?: (row: Row) => void;
|
|
52
52
|
}
|
|
53
|
-
|
|
53
|
+
interface DataPageBase {
|
|
54
54
|
id: string;
|
|
55
55
|
titleKey: string;
|
|
56
56
|
icon: string | React.ComponentType<LucideProps>;
|
|
57
|
+
}
|
|
58
|
+
/** Core renders a searchable table from the plugin's rows and columns. */
|
|
59
|
+
export interface DataPageTable<Row = Record<string, unknown>> extends DataPageBase {
|
|
57
60
|
useRows: () => DataPageRows<Row>;
|
|
58
61
|
columns: DataPageColumn<Row>[];
|
|
59
62
|
/** Column keys the search box filters on. Omit to search every column. */
|
|
60
63
|
searchKeys?: string[];
|
|
61
64
|
emptyKey?: string;
|
|
65
|
+
component?: never;
|
|
66
|
+
}
|
|
67
|
+
/** Core keeps the page frame and title; the plugin renders everything below them. */
|
|
68
|
+
export interface DataPageCustom extends DataPageBase {
|
|
69
|
+
component: React.ComponentType;
|
|
70
|
+
useRows?: never;
|
|
71
|
+
columns?: never;
|
|
62
72
|
}
|
|
73
|
+
export type DataPageRegistration<Row = Record<string, unknown>> = DataPageTable<Row> | DataPageCustom;
|
|
63
74
|
/** Every toolbar component receives the toolbar entry core built for it. */
|
|
64
75
|
export interface ToolbarToolProps {
|
|
65
76
|
tool: unknown;
|
|
@@ -131,7 +142,7 @@ export type PluginDatasetSource = {
|
|
|
131
142
|
};
|
|
132
143
|
/**
|
|
133
144
|
* A dataset listed in the Datasets menu: under Live Data when `live`, otherwise under
|
|
134
|
-
* Organizational.
|
|
145
|
+
* Organizational. `usePluginDataset(id)` reports whether it is applied and can apply or remove it.
|
|
135
146
|
*/
|
|
136
147
|
export interface DatasetRegistration {
|
|
137
148
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AY,EAAE,oBAAoB,CAAA;IAClC,cAAc,EAAE,mBAAmB,CAAA;CACpC;AAcD,MAAM,WAAW,aAAa;IAC5B,QAAQ,EAAE,MAAM,CAAA;IAChB,QAAQ,CAAC,CAAC,SAAS,MAAM,kBAAkB,EAAE,GAAG,EAAE,CAAC,EAAE,IAAI,EAAE,kBAAkB,CAAC,CAAC,CAAC,GAAG,IAAI,CAAA;IACvF,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CAChC;AAID,MAAM,WAAW,WAAW;IAE1B,QAAQ,CAAC,GAAG,EAAE,GAAG,GAAG,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;IACxC,UAAU,CAAC,CAAC,GAAG,EAAE,GAAG,GAAG,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;CAC5C;AAED;;;;GAIG;AACH,MAAM,WAAW,YAAY;IAC3B,QAAQ,EAAE,cAAc,CAAA;IACxB,KAAK,EAAE,WAAW,GAAG,CAAC,MAAM,OAAO,CAAC,WAAW,CAAC,CAAC,CAAA;CAClD;AAED,kEAAkE;AAClE,wBAAsB,kBAAkB,CACtC,KAAK,EAAE,YAAY,CAAC,OAAO,CAAC,GAC3B,OAAO,CAAC,WAAW,CAAC,CAEtB;AAED,sFAAsF;AACtF,MAAM,MAAM,YAAY,GAAG,YAAY,EAAE,GAAG,CAAC,MAAM,OAAO,CAAC,YAAY,EAAE,CAAC,CAAC,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/core/plugins/sdk/types.ts"],"sourcesContent":["// SPDX-License-Identifier: AGPL-3.0-or-later\n// Copyright (C) 2025 Collab Digital Twins\n\n// Type-only: keeps the viewer modules' runtime deps (@thatopen, three, maplibre)\n// out of the host's module graph.\nimport type { BimToolProps } from './bimViewer'\nimport type { MapToolProps } from './mapViewer'\n// A value, not just a type: a `viewer.tabs` contribution names the viewers it belongs in.\nexport { ViewerNames } from '../../types/dbTypes'\n\nimport type { ViewerNames } from '../../types/dbTypes'\n\n/**\n * The viewers that can host a tab or a legend, spelled as plain strings. Derived from\n * `ViewerNames` so the two cannot drift, and the form `@collabdt/plugin-kit` publishes.\n */\nexport type PluginViewerTarget = `${ViewerNames.map | ViewerNames.bim}`\nimport type { LucideProps } from 'lucide-react'\n\n// --- Capability definitions ---\n\n// Only capabilities core actually renders. One with no consumer registers fine,\n// shows nothing, and leaves nothing to debug.\nexport const VALID_CAPABILITIES = [\n 'data.pages',\n 'viewer.tabs',\n 'ui.dialogs',\n 'map.tools',\n 'bim.tools',\n 'viewer.legends',\n 'map.layers',\n 'map.datasets',\n] as const\n\nexport type PluginCapability = typeof VALID_CAPABILITIES[number]\n\n// --- Manifest ---\n\nexport interface PluginManifest {\n slug: string\n name: string\n version: string\n /** The `PLUGIN_HOST_API` this plugin was built against. Omitted is warned about, not rejected. */\n hostApi?: number\n description?: string\n author?: string\n /** A lucide icon name shown beside the plugin's name. Unset or unknown shows a puzzle piece. */\n icon?: string\n capabilities: PluginCapability[]\n requiredPermissions?: string[]\n configSchema?: Record<string, unknown>\n /**\n * Strings keyed by locale then message key, e.g. `{ en: { title: 'Hello' } }`.\n * Core folds them under `plugins.<slug>`, so `t('title')` resolves and no plugin\n * can collide with another. Values may nest, addressed as `t('spaces.title')`.\n */\n messages?: Record<string, Record<string, unknown>>\n}\n\nexport function validateManifest(manifest: unknown): { valid: boolean; errors: string[] } {\n const errors: string[] = []\n\n if (typeof manifest !== 'object' || manifest === null) {\n return { valid: false, errors: ['manifest must be an object'] }\n }\n\n const m = manifest as Record<string, unknown>\n\n if (!m.slug || typeof m.slug !== 'string') errors.push('slug is required')\n if (!m.name || typeof m.name !== 'string') errors.push('name is required')\n if (!m.version || typeof m.version !== 'string') errors.push('version is required')\n\n if (m.hostApi !== undefined && !Number.isInteger(m.hostApi)) {\n errors.push('hostApi must be an integer when present')\n }\n\n if (!Array.isArray(m.capabilities) || m.capabilities.length === 0) {\n errors.push('at least one capability is required')\n } else {\n for (const cap of m.capabilities) {\n if (!VALID_CAPABILITIES.includes(cap as PluginCapability)) {\n errors.push(`invalid capability: \"${cap}\"`)\n }\n }\n }\n\n return { valid: errors.length === 0, errors }\n}\n\n// --- Registration shapes (one per capability) ---\n\nexport interface DataPageColumn<Row> {\n key: string\n /** Resolved in the plugin's own namespace, falling back to the literal string. */\n labelKey: string\n render?: (row: Row) => React.ReactNode\n}\n\n/**\n * A full page in the Datasets nav, rendered by core. The plugin declares rows and columns; a\n * row click opens one of its own `ui.dialogs` rather than a detail view of its own.\n */\nexport interface DataPageRows<Row> {\n rows: Row[]\n isLoading?: boolean\n /** From the hook, not the registration, so it can close over `usePluginDialogs`. */\n onRowClick?: (row: Row) => void\n}\n\nexport interface DataPageRegistration<Row = Record<string, unknown>> {\n id: string\n titleKey: string\n icon: string | React.ComponentType<LucideProps>\n useRows: () => DataPageRows<Row>\n columns: DataPageColumn<Row>[]\n /** Column keys the search box filters on. Omit to search every column. */\n searchKeys?: string[]\n emptyKey?: string\n}\n\n/** Every toolbar component receives the toolbar entry core built for it. */\nexport interface ToolbarToolProps {\n tool: unknown\n}\n\n/**\n * A toolbar contribution. `P` is the viewer surface the hosting toolbar passes as\n * props, bound per capability by `CapabilityRegistry` — so a BIM component\n * registered under `map.tools` is a compile error.\n */\nexport interface ToolbarRegistration<P = Record<string, unknown>> {\n id: string\n label: string\n icon: string | React.ComponentType<LucideProps>\n component: React.ComponentType<ToolbarToolProps & P>\n cursor?: string\n stayActive?: boolean\n}\n\nexport interface ViewerTabRegistration {\n id: string\n labelKey: string\n icon: string | React.ComponentType<LucideProps>\n component: React.ComponentType\n /** Which viewers this tab appears in. Omit for all of them. */\n viewers?: Array<PluginViewerTarget | ViewerNames>\n}\n\n/**\n * A modal core owns. Registered here, opened by id from any of the plugin's surfaces via\n * `usePluginDialogs()`, so it outlives whichever one opened it.\n */\nexport interface DialogRegistration<P = Record<string, unknown>> {\n id: string\n titleKey: string\n size?: 'sm' | 'md' | 'lg' | 'xl'\n component: React.ComponentType<P & { close: () => void }>\n}\n\n/**\n * Something drawn on the map, mounted for as long as the map. Separate from `map.tools`,\n * whose panel unmounts when its dropdown closes and would take the layer with it.\n */\nexport interface MapLayerRegistration {\n id: string\n component: React.ComponentType<MapToolProps>\n}\n\n/** The least of a GeoJSON FeatureCollection core needs, so a typed `geojson` one satisfies it. */\nexport interface PluginFeatureCollection {\n type: 'FeatureCollection'\n features: Array<{\n type: 'Feature'\n id?: string | number\n geometry: { type: string; coordinates?: unknown; geometries?: unknown } | null\n properties: Record<string, unknown> | null\n }>\n}\n\n/** How core draws a plugin dataset. Absent, the plugin draws it from its own `map.layers`. */\nexport type PluginDatasetSource =\n | { type: 'wms'; baseUrl: string; layers: string; timeEnabled?: boolean }\n | { type: 'geojson'; getFeatures: () => Promise<PluginFeatureCollection> }\n\n/**\n * A dataset listed in the Datasets menu: under Live Data when `live`, otherwise under\n * Organizational. Applying it is the user's choice; `usePluginDataset(id)` reports it.\n */\nexport interface DatasetRegistration {\n id: string\n name: string\n description?: string\n publisher?: string\n /** A link to the dataset's documentation, shown in its details. */\n information?: string\n live?: boolean\n source?: PluginDatasetSource\n}\n\nexport interface LegendRow {\n label: string\n color: string\n count?: number\n /** With `onVisibleChange`, the row gets a switch; false dims it. */\n visible?: boolean\n onVisibleChange?: (visible: boolean) => void\n}\n\nexport interface LegendRegistration {\n id: string\n title: string\n /** Which viewers this legend appears in. Omit for all of them. */\n viewers?: Array<PluginViewerTarget | ViewerNames>\n /** A `map.datasets` id of the same plugin: the map nests this legend under that applied dataset. */\n dataset?: string\n // Called by the legend host on each render; active:false omits the section.\n useLegend: () => {\n active: boolean\n // Overrides registration.title when set, e.g. a city-scoped label.\n title?: string\n unavailable?: boolean\n rows: LegendRow[]\n /** The plugin's own inputs under the rows, such as a date slider filtering what is drawn. */\n controls?: React.ReactNode\n }\n}\n\n// --- Capability → registration type map ---\n// A new contribution point needs one entry here, its type above, and a consumer\n// calling `registry.getAll('your.key')`. No host changes.\n\nexport interface CapabilityRegistry {\n 'data.pages': DataPageRegistration\n 'viewer.tabs': ViewerTabRegistration\n 'ui.dialogs': DialogRegistration\n 'map.tools': ToolbarRegistration<MapToolProps>\n 'bim.tools': ToolbarRegistration<BimToolProps>\n 'viewer.legends': LegendRegistration\n 'map.layers': MapLayerRegistration\n 'map.datasets': DatasetRegistration\n}\n\n// Errors if VALID_CAPABILITIES and keyof CapabilityRegistry drift apart.\ntype _CapabilityParity =\n PluginCapability extends keyof CapabilityRegistry\n ? keyof CapabilityRegistry extends PluginCapability\n ? true\n : never\n : never\nconst _capabilityParity: _CapabilityParity = true\nvoid _capabilityParity\n\n// --- Plugin Context ---\n\nexport interface PluginContext {\n pluginId: string\n register<K extends keyof CapabilityRegistry>(key: K, item: CapabilityRegistry[K]): void\n config: Record<string, unknown>\n}\n\n// --- Plugin entry point type ---\n\nexport interface PluginEntry {\n // `any`: each plugin binds only the slots it uses, so no one context type fits them all.\n activate(ctx: any): void | Promise<void>\n deactivate?(ctx: any): void | Promise<void>\n}\n\n/**\n * One loadable plugin: its manifest plus its module, or a thunk returning it.\n * Prefer the thunk when compiled in — a static import pulls the plugin's\n * components into every route that reaches `installed.ts`.\n */\nexport interface PluginSource {\n manifest: PluginManifest\n entry: PluginEntry | (() => Promise<PluginEntry>)\n}\n\n/** Resolves either form of `PluginSource.entry` to the module. */\nexport async function resolvePluginEntry(\n entry: PluginSource['entry'],\n): Promise<PluginEntry> {\n return typeof entry === 'function' ? entry() : entry\n}\n\n/** An array for compiled-in plugins; a thunk when the list itself must be fetched. */\nexport type PluginsInput = PluginSource[] | (() => Promise<PluginSource[]>)\n"],"mappings":"AAQA,SAAS,mBAAmB;AAerB,MAAM,qBAAqB;AAAA,EAChC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AA2BO,SAAS,iBAAiB,UAAyD;AACxF,QAAM,SAAmB,CAAC;AAE1B,MAAI,OAAO,aAAa,YAAY,aAAa,MAAM;AACrD,WAAO,EAAE,OAAO,OAAO,QAAQ,CAAC,4BAA4B,EAAE;AAAA,EAChE;AAEA,QAAM,IAAI;AAEV,MAAI,CAAC,EAAE,QAAQ,OAAO,EAAE,SAAS,SAAU,QAAO,KAAK,kBAAkB;AACzE,MAAI,CAAC,EAAE,QAAQ,OAAO,EAAE,SAAS,SAAU,QAAO,KAAK,kBAAkB;AACzE,MAAI,CAAC,EAAE,WAAW,OAAO,EAAE,YAAY,SAAU,QAAO,KAAK,qBAAqB;AAElF,MAAI,EAAE,YAAY,UAAa,CAAC,OAAO,UAAU,EAAE,OAAO,GAAG;AAC3D,WAAO,KAAK,yCAAyC;AAAA,EACvD;AAEA,MAAI,CAAC,MAAM,QAAQ,EAAE,YAAY,KAAK,EAAE,aAAa,WAAW,GAAG;AACjE,WAAO,KAAK,qCAAqC;AAAA,EACnD,OAAO;AACL,eAAW,OAAO,EAAE,cAAc;AAChC,UAAI,CAAC,mBAAmB,SAAS,GAAuB,GAAG;AACzD,eAAO,KAAK,wBAAwB,GAAG,GAAG;AAAA,MAC5C;AAAA,IACF;AAAA,EACF;AAEA,SAAO,EAAE,OAAO,OAAO,WAAW,GAAG,OAAO;AAC9C;AAkKA,MAAM,oBAAuC;AAC7C,KAAK;AA6BL,eAAsB,mBACpB,OACsB;AACtB,SAAO,OAAO,UAAU,aAAa,MAAM,IAAI;AACjD;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../../../src/core/plugins/sdk/types.ts"],"sourcesContent":["// SPDX-License-Identifier: AGPL-3.0-or-later\n// Copyright (C) 2025 Collab Digital Twins\n\n// Type-only: keeps the viewer modules' runtime deps (@thatopen, three, maplibre)\n// out of the host's module graph.\nimport type { BimToolProps } from './bimViewer'\nimport type { MapToolProps } from './mapViewer'\n// A value, not just a type: a `viewer.tabs` contribution names the viewers it belongs in.\nexport { ViewerNames } from '../../types/dbTypes'\n\nimport type { ViewerNames } from '../../types/dbTypes'\n\n/**\n * The viewers that can host a tab or a legend, spelled as plain strings. Derived from\n * `ViewerNames` so the two cannot drift, and the form `@collabdt/plugin-kit` publishes.\n */\nexport type PluginViewerTarget = `${ViewerNames.map | ViewerNames.bim}`\nimport type { LucideProps } from 'lucide-react'\n\n// --- Capability definitions ---\n\n// Only capabilities core actually renders. One with no consumer registers fine,\n// shows nothing, and leaves nothing to debug.\nexport const VALID_CAPABILITIES = [\n 'data.pages',\n 'viewer.tabs',\n 'ui.dialogs',\n 'map.tools',\n 'bim.tools',\n 'viewer.legends',\n 'map.layers',\n 'map.datasets',\n] as const\n\nexport type PluginCapability = typeof VALID_CAPABILITIES[number]\n\n// --- Manifest ---\n\nexport interface PluginManifest {\n slug: string\n name: string\n version: string\n /** The `PLUGIN_HOST_API` this plugin was built against. Omitted is warned about, not rejected. */\n hostApi?: number\n description?: string\n author?: string\n /** A lucide icon name shown beside the plugin's name. Unset or unknown shows a puzzle piece. */\n icon?: string\n capabilities: PluginCapability[]\n requiredPermissions?: string[]\n configSchema?: Record<string, unknown>\n /**\n * Strings keyed by locale then message key, e.g. `{ en: { title: 'Hello' } }`.\n * Core folds them under `plugins.<slug>`, so `t('title')` resolves and no plugin\n * can collide with another. Values may nest, addressed as `t('spaces.title')`.\n */\n messages?: Record<string, Record<string, unknown>>\n}\n\nexport function validateManifest(manifest: unknown): { valid: boolean; errors: string[] } {\n const errors: string[] = []\n\n if (typeof manifest !== 'object' || manifest === null) {\n return { valid: false, errors: ['manifest must be an object'] }\n }\n\n const m = manifest as Record<string, unknown>\n\n if (!m.slug || typeof m.slug !== 'string') errors.push('slug is required')\n if (!m.name || typeof m.name !== 'string') errors.push('name is required')\n if (!m.version || typeof m.version !== 'string') errors.push('version is required')\n\n if (m.hostApi !== undefined && !Number.isInteger(m.hostApi)) {\n errors.push('hostApi must be an integer when present')\n }\n\n if (!Array.isArray(m.capabilities) || m.capabilities.length === 0) {\n errors.push('at least one capability is required')\n } else {\n for (const cap of m.capabilities) {\n if (!VALID_CAPABILITIES.includes(cap as PluginCapability)) {\n errors.push(`invalid capability: \"${cap}\"`)\n }\n }\n }\n\n return { valid: errors.length === 0, errors }\n}\n\n// --- Registration shapes (one per capability) ---\n\nexport interface DataPageColumn<Row> {\n key: string\n /** Resolved in the plugin's own namespace, falling back to the literal string. */\n labelKey: string\n render?: (row: Row) => React.ReactNode\n}\n\n/**\n * A full page in the Datasets nav, rendered by core. The plugin declares rows and columns; a\n * row click opens one of its own `ui.dialogs` rather than a detail view of its own.\n */\nexport interface DataPageRows<Row> {\n rows: Row[]\n isLoading?: boolean\n /** From the hook, not the registration, so it can close over `usePluginDialogs`. */\n onRowClick?: (row: Row) => void\n}\n\ninterface DataPageBase {\n id: string\n titleKey: string\n icon: string | React.ComponentType<LucideProps>\n}\n\n/** Core renders a searchable table from the plugin's rows and columns. */\nexport interface DataPageTable<Row = Record<string, unknown>> extends DataPageBase {\n useRows: () => DataPageRows<Row>\n columns: DataPageColumn<Row>[]\n /** Column keys the search box filters on. Omit to search every column. */\n searchKeys?: string[]\n emptyKey?: string\n component?: never\n}\n\n/** Core keeps the page frame and title; the plugin renders everything below them. */\nexport interface DataPageCustom extends DataPageBase {\n component: React.ComponentType\n useRows?: never\n columns?: never\n}\n\nexport type DataPageRegistration<Row = Record<string, unknown>> = DataPageTable<Row> | DataPageCustom\n\n/** Every toolbar component receives the toolbar entry core built for it. */\nexport interface ToolbarToolProps {\n tool: unknown\n}\n\n/**\n * A toolbar contribution. `P` is the viewer surface the hosting toolbar passes as\n * props, bound per capability by `CapabilityRegistry` — so a BIM component\n * registered under `map.tools` is a compile error.\n */\nexport interface ToolbarRegistration<P = Record<string, unknown>> {\n id: string\n label: string\n icon: string | React.ComponentType<LucideProps>\n component: React.ComponentType<ToolbarToolProps & P>\n cursor?: string\n stayActive?: boolean\n}\n\nexport interface ViewerTabRegistration {\n id: string\n labelKey: string\n icon: string | React.ComponentType<LucideProps>\n component: React.ComponentType\n /** Which viewers this tab appears in. Omit for all of them. */\n viewers?: Array<PluginViewerTarget | ViewerNames>\n}\n\n/**\n * A modal core owns. Registered here, opened by id from any of the plugin's surfaces via\n * `usePluginDialogs()`, so it outlives whichever one opened it.\n */\nexport interface DialogRegistration<P = Record<string, unknown>> {\n id: string\n titleKey: string\n size?: 'sm' | 'md' | 'lg' | 'xl'\n component: React.ComponentType<P & { close: () => void }>\n}\n\n/**\n * Something drawn on the map, mounted for as long as the map. Separate from `map.tools`,\n * whose panel unmounts when its dropdown closes and would take the layer with it.\n */\nexport interface MapLayerRegistration {\n id: string\n component: React.ComponentType<MapToolProps>\n}\n\n/** The least of a GeoJSON FeatureCollection core needs, so a typed `geojson` one satisfies it. */\nexport interface PluginFeatureCollection {\n type: 'FeatureCollection'\n features: Array<{\n type: 'Feature'\n id?: string | number\n geometry: { type: string; coordinates?: unknown; geometries?: unknown } | null\n properties: Record<string, unknown> | null\n }>\n}\n\n/** How core draws a plugin dataset. Absent, the plugin draws it from its own `map.layers`. */\nexport type PluginDatasetSource =\n | { type: 'wms'; baseUrl: string; layers: string; timeEnabled?: boolean }\n | { type: 'geojson'; getFeatures: () => Promise<PluginFeatureCollection> }\n\n/**\n * A dataset listed in the Datasets menu: under Live Data when `live`, otherwise under\n * Organizational. `usePluginDataset(id)` reports whether it is applied and can apply or remove it.\n */\nexport interface DatasetRegistration {\n id: string\n name: string\n description?: string\n publisher?: string\n /** A link to the dataset's documentation, shown in its details. */\n information?: string\n live?: boolean\n source?: PluginDatasetSource\n}\n\nexport interface LegendRow {\n label: string\n color: string\n count?: number\n /** With `onVisibleChange`, the row gets a switch; false dims it. */\n visible?: boolean\n onVisibleChange?: (visible: boolean) => void\n}\n\nexport interface LegendRegistration {\n id: string\n title: string\n /** Which viewers this legend appears in. Omit for all of them. */\n viewers?: Array<PluginViewerTarget | ViewerNames>\n /** A `map.datasets` id of the same plugin: the map nests this legend under that applied dataset. */\n dataset?: string\n // Called by the legend host on each render; active:false omits the section.\n useLegend: () => {\n active: boolean\n // Overrides registration.title when set, e.g. a city-scoped label.\n title?: string\n unavailable?: boolean\n rows: LegendRow[]\n /** The plugin's own inputs under the rows, such as a date slider filtering what is drawn. */\n controls?: React.ReactNode\n }\n}\n\n// --- Capability → registration type map ---\n// A new contribution point needs one entry here, its type above, and a consumer\n// calling `registry.getAll('your.key')`. No host changes.\n\nexport interface CapabilityRegistry {\n 'data.pages': DataPageRegistration\n 'viewer.tabs': ViewerTabRegistration\n 'ui.dialogs': DialogRegistration\n 'map.tools': ToolbarRegistration<MapToolProps>\n 'bim.tools': ToolbarRegistration<BimToolProps>\n 'viewer.legends': LegendRegistration\n 'map.layers': MapLayerRegistration\n 'map.datasets': DatasetRegistration\n}\n\n// Errors if VALID_CAPABILITIES and keyof CapabilityRegistry drift apart.\ntype _CapabilityParity =\n PluginCapability extends keyof CapabilityRegistry\n ? keyof CapabilityRegistry extends PluginCapability\n ? true\n : never\n : never\nconst _capabilityParity: _CapabilityParity = true\nvoid _capabilityParity\n\n// --- Plugin Context ---\n\nexport interface PluginContext {\n pluginId: string\n register<K extends keyof CapabilityRegistry>(key: K, item: CapabilityRegistry[K]): void\n config: Record<string, unknown>\n}\n\n// --- Plugin entry point type ---\n\nexport interface PluginEntry {\n // `any`: each plugin binds only the slots it uses, so no one context type fits them all.\n activate(ctx: any): void | Promise<void>\n deactivate?(ctx: any): void | Promise<void>\n}\n\n/**\n * One loadable plugin: its manifest plus its module, or a thunk returning it.\n * Prefer the thunk when compiled in — a static import pulls the plugin's\n * components into every route that reaches `installed.ts`.\n */\nexport interface PluginSource {\n manifest: PluginManifest\n entry: PluginEntry | (() => Promise<PluginEntry>)\n}\n\n/** Resolves either form of `PluginSource.entry` to the module. */\nexport async function resolvePluginEntry(\n entry: PluginSource['entry'],\n): Promise<PluginEntry> {\n return typeof entry === 'function' ? entry() : entry\n}\n\n/** An array for compiled-in plugins; a thunk when the list itself must be fetched. */\nexport type PluginsInput = PluginSource[] | (() => Promise<PluginSource[]>)\n"],"mappings":"AAQA,SAAS,mBAAmB;AAerB,MAAM,qBAAqB;AAAA,EAChC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AA2BO,SAAS,iBAAiB,UAAyD;AACxF,QAAM,SAAmB,CAAC;AAE1B,MAAI,OAAO,aAAa,YAAY,aAAa,MAAM;AACrD,WAAO,EAAE,OAAO,OAAO,QAAQ,CAAC,4BAA4B,EAAE;AAAA,EAChE;AAEA,QAAM,IAAI;AAEV,MAAI,CAAC,EAAE,QAAQ,OAAO,EAAE,SAAS,SAAU,QAAO,KAAK,kBAAkB;AACzE,MAAI,CAAC,EAAE,QAAQ,OAAO,EAAE,SAAS,SAAU,QAAO,KAAK,kBAAkB;AACzE,MAAI,CAAC,EAAE,WAAW,OAAO,EAAE,YAAY,SAAU,QAAO,KAAK,qBAAqB;AAElF,MAAI,EAAE,YAAY,UAAa,CAAC,OAAO,UAAU,EAAE,OAAO,GAAG;AAC3D,WAAO,KAAK,yCAAyC;AAAA,EACvD;AAEA,MAAI,CAAC,MAAM,QAAQ,EAAE,YAAY,KAAK,EAAE,aAAa,WAAW,GAAG;AACjE,WAAO,KAAK,qCAAqC;AAAA,EACnD,OAAO;AACL,eAAW,OAAO,EAAE,cAAc;AAChC,UAAI,CAAC,mBAAmB,SAAS,GAAuB,GAAG;AACzD,eAAO,KAAK,wBAAwB,GAAG,GAAG;AAAA,MAC5C;AAAA,IACF;AAAA,EACF;AAEA,SAAO,EAAE,OAAO,OAAO,WAAW,GAAG,OAAO;AAC9C;AAgLA,MAAM,oBAAuC;AAC7C,KAAK;AA6BL,eAAsB,mBACpB,OACsB;AACtB,SAAO,OAAO,UAAU,aAAa,MAAM,IAAI;AACjD;","names":[]}
|
|
@@ -9,4 +9,10 @@ export interface PluginDialogs {
|
|
|
9
9
|
* scope, so a plugin can only address its own.
|
|
10
10
|
*/
|
|
11
11
|
export declare function usePluginDialogs(): PluginDialogs;
|
|
12
|
+
/** The host's toasts, so a plugin's confirmations look like core's own. */
|
|
13
|
+
export declare const toast: {
|
|
14
|
+
success: (message: string) => void;
|
|
15
|
+
error: (message: string) => void;
|
|
16
|
+
info: (message: string) => void;
|
|
17
|
+
};
|
|
12
18
|
//# sourceMappingURL=ui.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ui.d.ts","sourceRoot":"","sources":["../../../../src/core/plugins/sdk/ui.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ui.d.ts","sourceRoot":"","sources":["../../../../src/core/plugins/sdk/ui.ts"],"names":[],"mappings":"AAWA,MAAM,WAAW,aAAa;IAC5B,6FAA6F;IAC7F,IAAI,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,IAAI,CAAA;IACjE,qFAAqF;IACrF,KAAK,EAAE,CAAC,QAAQ,CAAC,EAAE,MAAM,KAAK,IAAI,CAAA;CACnC;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,IAAI,aAAa,CAQhD;AAED,2EAA2E;AAC3E,eAAO,MAAM,KAAK;uBACG,MAAM;qBACR,MAAM;oBACP,MAAM;CACvB,CAAA"}
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
"use client";
|
|
4
4
|
import * as React from "react";
|
|
5
|
+
import { toast as sonner } from "sonner";
|
|
5
6
|
import { usePluginDialogControls } from "../host/dialogs";
|
|
6
7
|
import { usePluginId } from "../host/scope";
|
|
7
8
|
function usePluginDialogs() {
|
|
@@ -12,7 +13,19 @@ function usePluginDialogs() {
|
|
|
12
13
|
close: (dialogId) => controls.close(pluginId, dialogId)
|
|
13
14
|
}), [controls, pluginId]);
|
|
14
15
|
}
|
|
16
|
+
const toast = {
|
|
17
|
+
success: (message) => {
|
|
18
|
+
sonner.success(message);
|
|
19
|
+
},
|
|
20
|
+
error: (message) => {
|
|
21
|
+
sonner.error(message);
|
|
22
|
+
},
|
|
23
|
+
info: (message) => {
|
|
24
|
+
sonner.info(message);
|
|
25
|
+
}
|
|
26
|
+
};
|
|
15
27
|
export {
|
|
28
|
+
toast,
|
|
16
29
|
usePluginDialogs
|
|
17
30
|
};
|
|
18
31
|
//# sourceMappingURL=ui.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/core/plugins/sdk/ui.ts"],"sourcesContent":["'use client'\n\n// SPDX-License-Identifier: AGPL-3.0-or-later\n// Copyright (C) 2025 Collab Digital Twins\n\nimport * as React from 'react'\n\nimport { usePluginDialogControls } from '../host/dialogs'\nimport { usePluginId } from '../host/scope'\n\nexport interface PluginDialogs {\n /** Opens one of this plugin's registered dialogs. `props` reaches the component as props. */\n open: (dialogId: string, props?: Record<string, unknown>) => void\n /** Closes the topmost instance of `dialogId`, or of any of this plugin's dialogs. */\n close: (dialogId?: string) => void\n}\n\n/**\n * Opens and closes this plugin's dialogs from any of its surfaces. The id comes from the\n * scope, so a plugin can only address its own.\n */\nexport function usePluginDialogs(): PluginDialogs {\n const pluginId = usePluginId()\n const controls = usePluginDialogControls()\n\n return React.useMemo(() => ({\n open: (dialogId, props) => controls.open(pluginId, dialogId, props),\n close: dialogId => controls.close(pluginId, dialogId),\n }), [controls, pluginId])\n}\n"],"mappings":";AAKA,YAAY,WAAW;
|
|
1
|
+
{"version":3,"sources":["../../../../src/core/plugins/sdk/ui.ts"],"sourcesContent":["'use client'\n\n// SPDX-License-Identifier: AGPL-3.0-or-later\n// Copyright (C) 2025 Collab Digital Twins\n\nimport * as React from 'react'\nimport { toast as sonner } from 'sonner'\n\nimport { usePluginDialogControls } from '../host/dialogs'\nimport { usePluginId } from '../host/scope'\n\nexport interface PluginDialogs {\n /** Opens one of this plugin's registered dialogs. `props` reaches the component as props. */\n open: (dialogId: string, props?: Record<string, unknown>) => void\n /** Closes the topmost instance of `dialogId`, or of any of this plugin's dialogs. */\n close: (dialogId?: string) => void\n}\n\n/**\n * Opens and closes this plugin's dialogs from any of its surfaces. The id comes from the\n * scope, so a plugin can only address its own.\n */\nexport function usePluginDialogs(): PluginDialogs {\n const pluginId = usePluginId()\n const controls = usePluginDialogControls()\n\n return React.useMemo(() => ({\n open: (dialogId, props) => controls.open(pluginId, dialogId, props),\n close: dialogId => controls.close(pluginId, dialogId),\n }), [controls, pluginId])\n}\n\n/** The host's toasts, so a plugin's confirmations look like core's own. */\nexport const toast = {\n success: (message: string) => { sonner.success(message) },\n error: (message: string) => { sonner.error(message) },\n info: (message: string) => { sonner.info(message) },\n}\n"],"mappings":";AAKA,YAAY,WAAW;AACvB,SAAS,SAAS,cAAc;AAEhC,SAAS,+BAA+B;AACxC,SAAS,mBAAmB;AAarB,SAAS,mBAAkC;AAChD,QAAM,WAAW,YAAY;AAC7B,QAAM,WAAW,wBAAwB;AAEzC,SAAO,MAAM,QAAQ,OAAO;AAAA,IAC1B,MAAM,CAAC,UAAU,UAAU,SAAS,KAAK,UAAU,UAAU,KAAK;AAAA,IAClE,OAAO,cAAY,SAAS,MAAM,UAAU,QAAQ;AAAA,EACtD,IAAI,CAAC,UAAU,QAAQ,CAAC;AAC1B;AAGO,MAAM,QAAQ;AAAA,EACnB,SAAS,CAAC,YAAoB;AAAE,WAAO,QAAQ,OAAO;AAAA,EAAE;AAAA,EACxD,OAAO,CAAC,YAAoB;AAAE,WAAO,MAAM,OAAO;AAAA,EAAE;AAAA,EACpD,MAAM,CAAC,YAAoB;AAAE,WAAO,KAAK,OAAO;AAAA,EAAE;AACpD;","names":[]}
|
|
@@ -44,5 +44,5 @@ export declare enum RoleNames {
|
|
|
44
44
|
user = "User",
|
|
45
45
|
viewer = "Viewer"
|
|
46
46
|
}
|
|
47
|
-
export type FileAction = 'download' | 'view' | 'ghost' | 'move' | 'edit' | 'info' | 'delete';
|
|
47
|
+
export type FileAction = 'download' | 'view' | 'ghost' | 'move' | 'projectNorth' | 'edit' | 'info' | 'delete';
|
|
48
48
|
//# sourceMappingURL=global.d.ts.map
|
|
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W;CAClB;AAED,MAAM,MAAM,UAAU,GAAG,UAAU,GAAG,MAAM,GAAG,OAAO,GAAG,MAAM,GAAG,cAAc,GAAG,MAAM,GAAG,MAAM,GAAG,QAAQ,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/core/types/global.ts"],"sourcesContent":["// SPDX-License-Identifier: AGPL-3.0-or-later\n// Copyright (C) 2025 Collab Digital Twins\n\nimport { Coordinates } from 'maplibre-gl'\n\nimport { Location } from './map'\n\nimport type { ViewerNames } from './dbTypes'\nimport type { CurrentLocation, LngLat} from './map';\nimport type * as THREE from 'three'\n\nexport interface Identified {\n // _id?: string; // Mongo db id\n id: string // id = crypto.randomUUID(); Random id vs id generated by parameters\n name?: string\n}\n\nexport interface Created extends Identified {\n createdBy?: string\n createdDate?: string\n createdTime?: string\n}\n\nexport type Theme = 'light' | 'dark'\n\nexport interface Modified extends Created {\n modifiedDate?: string\n modifiedBy?: string // User uId\n}\nexport interface SearchParams extends Partial<CurrentLocation> {\n viewer: ViewerNames\n modelId?: string\n buildingId?: string\n}\n\nexport type CursorType = '' | 'pointer' | 'grab' | 'grabbing' | 'crosshair' | 'copy'\n\nexport interface Position extends Partial<LngLat>, Partial<THREE.Vector3> {\n elevation?: number\n}\n\nexport type FilterState = {\n id: number\n field: string\n fieldType: 'boolean' | 'string' | 'number' | 'date' | 'enum' | null\n operator: 'isTrue' | 'isFalse' | 'contains' | 'equals' | 'startsWith' | 'endsWith' | 'greaterThan' | 'lessThan' | 'between' | 'before' | 'after' | 'inList' | null\n value: boolean | string | number | Date | string[] | null\n secondValue: number | Date | null\n}\n\nexport enum DataTypes {\n building = 'building',\n site = 'site',\n infrastructure = 'infrastructure',\n file = 'file',\n user = 'user',\n}\n\n// Temporary Role names\nexport enum RoleNames {\n admin = 'Admin',\n user = 'User',\n viewer = 'Viewer',\n}\n\nexport type FileAction = 'download' | 'view' | 'ghost' | 'move' | 'edit' | 'info' | 'delete'\n\n"],"mappings":"AAkDO,IAAK,YAAL,kBAAKA,eAAL;AACL,EAAAA,WAAA,cAAW;AACX,EAAAA,WAAA,UAAO;AACP,EAAAA,WAAA,oBAAiB;AACjB,EAAAA,WAAA,UAAO;AACP,EAAAA,WAAA,UAAO;AALG,SAAAA;AAAA,GAAA;AASL,IAAK,YAAL,kBAAKC,eAAL;AACL,EAAAA,WAAA,WAAQ;AACR,EAAAA,WAAA,UAAO;AACP,EAAAA,WAAA,YAAS;AAHC,SAAAA;AAAA,GAAA;","names":["DataTypes","RoleNames"]}
|
|
1
|
+
{"version":3,"sources":["../../../src/core/types/global.ts"],"sourcesContent":["// SPDX-License-Identifier: AGPL-3.0-or-later\n// Copyright (C) 2025 Collab Digital Twins\n\nimport { Coordinates } from 'maplibre-gl'\n\nimport { Location } from './map'\n\nimport type { ViewerNames } from './dbTypes'\nimport type { CurrentLocation, LngLat} from './map';\nimport type * as THREE from 'three'\n\nexport interface Identified {\n // _id?: string; // Mongo db id\n id: string // id = crypto.randomUUID(); Random id vs id generated by parameters\n name?: string\n}\n\nexport interface Created extends Identified {\n createdBy?: string\n createdDate?: string\n createdTime?: string\n}\n\nexport type Theme = 'light' | 'dark'\n\nexport interface Modified extends Created {\n modifiedDate?: string\n modifiedBy?: string // User uId\n}\nexport interface SearchParams extends Partial<CurrentLocation> {\n viewer: ViewerNames\n modelId?: string\n buildingId?: string\n}\n\nexport type CursorType = '' | 'pointer' | 'grab' | 'grabbing' | 'crosshair' | 'copy'\n\nexport interface Position extends Partial<LngLat>, Partial<THREE.Vector3> {\n elevation?: number\n}\n\nexport type FilterState = {\n id: number\n field: string\n fieldType: 'boolean' | 'string' | 'number' | 'date' | 'enum' | null\n operator: 'isTrue' | 'isFalse' | 'contains' | 'equals' | 'startsWith' | 'endsWith' | 'greaterThan' | 'lessThan' | 'between' | 'before' | 'after' | 'inList' | null\n value: boolean | string | number | Date | string[] | null\n secondValue: number | Date | null\n}\n\nexport enum DataTypes {\n building = 'building',\n site = 'site',\n infrastructure = 'infrastructure',\n file = 'file',\n user = 'user',\n}\n\n// Temporary Role names\nexport enum RoleNames {\n admin = 'Admin',\n user = 'User',\n viewer = 'Viewer',\n}\n\nexport type FileAction = 'download' | 'view' | 'ghost' | 'move' | 'projectNorth' | 'edit' | 'info' | 'delete'\n\n"],"mappings":"AAkDO,IAAK,YAAL,kBAAKA,eAAL;AACL,EAAAA,WAAA,cAAW;AACX,EAAAA,WAAA,UAAO;AACP,EAAAA,WAAA,oBAAiB;AACjB,EAAAA,WAAA,UAAO;AACP,EAAAA,WAAA,UAAO;AALG,SAAAA;AAAA,GAAA;AASL,IAAK,YAAL,kBAAKC,eAAL;AACL,EAAAA,WAAA,WAAQ;AACR,EAAAA,WAAA,UAAO;AACP,EAAAA,WAAA,YAAS;AAHC,SAAAA;AAAA,GAAA;","names":["DataTypes","RoleNames"]}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { type ClassValue } from 'clsx';
|
|
2
2
|
import type { Language } from '../types/dbTypes';
|
|
3
|
+
/** True when a keystroke is aimed at a text field rather than the page. */
|
|
4
|
+
export declare function isEditableTarget(target: EventTarget | null): boolean;
|
|
3
5
|
export declare function cn(...inputs: ClassValue[]): string;
|
|
4
6
|
/**
|
|
5
7
|
* Stringify a value of unknown shape for display, search or export.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/core/utils/utils.ts"],"names":[],"mappings":"AAGA,OAAO,EAAQ,KAAK,UAAU,EAAE,MAAM,MAAM,CAAA;AAG5C,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAA;AAEhD,wBAAgB,EAAE,CAAC,GAAG,MAAM,EAAE,UAAU,EAAE,UAEzC;AAED;;;;;;;GAOG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CActD;AAED,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,IAAI,GAAG,MAAM,CAInD;AAED,wBAAsB,cAAc,CAClC,SAAS,EAAE,QAAQ,GAAE,GAAG,QAAQ,EAAE,EAClC,gBAAgB,CAAC,EAAE,CAAC,MAAM,EAAE,QAAQ,GAAE,GAAG,QAAQ,EAAE,KAAK,IAAI,EAC5D,MAAM,CAAC,EAAE;IAAE,OAAO,EAAE,MAAM,IAAI,CAAA;CAAE,iBAiBjC"}
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/core/utils/utils.ts"],"names":[],"mappings":"AAGA,OAAO,EAAQ,KAAK,UAAU,EAAE,MAAM,MAAM,CAAA;AAG5C,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAA;AAEhD,2EAA2E;AAC3E,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,WAAW,GAAG,IAAI,GAAG,OAAO,CAEpE;AAED,wBAAgB,EAAE,CAAC,GAAG,MAAM,EAAE,UAAU,EAAE,UAEzC;AAED;;;;;;;GAOG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CActD;AAED,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,IAAI,GAAG,MAAM,CAInD;AAED,wBAAsB,cAAc,CAClC,SAAS,EAAE,QAAQ,GAAE,GAAG,QAAQ,EAAE,EAClC,gBAAgB,CAAC,EAAE,CAAC,MAAM,EAAE,QAAQ,GAAE,GAAG,QAAQ,EAAE,KAAK,IAAI,EAC5D,MAAM,CAAC,EAAE;IAAE,OAAO,EAAE,MAAM,IAAI,CAAA;CAAE,iBAiBjC"}
|
package/dist/core/utils/utils.js
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import { clsx } from "clsx";
|
|
2
2
|
import { twMerge } from "tailwind-merge";
|
|
3
|
+
function isEditableTarget(target) {
|
|
4
|
+
return target instanceof HTMLElement && (target.isContentEditable || /^(INPUT|TEXTAREA|SELECT)$/.test(target.tagName));
|
|
5
|
+
}
|
|
3
6
|
function cn(...inputs) {
|
|
4
7
|
return twMerge(clsx(inputs));
|
|
5
8
|
}
|
|
@@ -34,6 +37,7 @@ async function switchLanguage(newLocale, setCurrentLocale, router) {
|
|
|
34
37
|
export {
|
|
35
38
|
cn,
|
|
36
39
|
getFileExtension,
|
|
40
|
+
isEditableTarget,
|
|
37
41
|
switchLanguage,
|
|
38
42
|
toDisplayString
|
|
39
43
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/core/utils/utils.ts"],"sourcesContent":["// SPDX-License-Identifier: AGPL-3.0-or-later\n// Copyright (C) 2025 Collab Digital Twins\n\nimport { clsx, type ClassValue } from 'clsx'\nimport { twMerge } from 'tailwind-merge'\n\nimport type { Language } from '../types/dbTypes'\n\nexport function cn(...inputs: ClassValue[]) {\n return twMerge(clsx(inputs))\n}\n\n/**\n * Stringify a value of unknown shape for display, search or export.\n *\n * Plain `String(value)` renders objects and arrays as '[object Object]', which\n * shows up in data tables and CSV exports whenever a dataset column, sensor\n * reading or dynamic property holds structured data. JSON is a readable\n * fallback for those; everything else stringifies as usual.\n */\nexport function toDisplayString(value: unknown): string {\n if (value === null || value === undefined) return ''\n if (typeof value === 'object') {\n try {\n return JSON.stringify(value) ?? ''\n }\n catch {\n // Circular structures cannot be serialized.\n return ''\n }\n }\n // Objects are handled above, so this only sees primitives.\n // eslint-disable-next-line @typescript-eslint/no-base-to-string\n return String(value)\n}\n\nexport function getFileExtension(file: File): string {\n const parts = file.name.split('.')\n if (parts.length <= 1) return ''\n return parts.pop()!.toLowerCase()\n}\n\nexport async function switchLanguage(\n newLocale: Language |`${Language}`,\n setCurrentLocale?: (locale: Language |`${Language}`) => void,\n router?: { refresh: () => void }\n) {\n // Set cookie that expires in 1 year\n const expires = new Date();\n expires.setFullYear(expires.getFullYear() + 1);\n\n document.cookie = `NEXT_LOCALE=${newLocale}; expires=${expires.toUTCString()}; path=/; SameSite=Lax`;\n\n // Update local state immediately for UI feedback\n if (setCurrentLocale) {\n setCurrentLocale(newLocale);\n }\n\n // Use router.refresh() to reload server components with new locale\n if (router) {\n router.refresh();\n }\n}\n"],"mappings":"AAGA,SAAS,YAA6B;AACtC,SAAS,eAAe;
|
|
1
|
+
{"version":3,"sources":["../../../src/core/utils/utils.ts"],"sourcesContent":["// SPDX-License-Identifier: AGPL-3.0-or-later\n// Copyright (C) 2025 Collab Digital Twins\n\nimport { clsx, type ClassValue } from 'clsx'\nimport { twMerge } from 'tailwind-merge'\n\nimport type { Language } from '../types/dbTypes'\n\n/** True when a keystroke is aimed at a text field rather than the page. */\nexport function isEditableTarget(target: EventTarget | null): boolean {\n return target instanceof HTMLElement && (target.isContentEditable || /^(INPUT|TEXTAREA|SELECT)$/.test(target.tagName))\n}\n\nexport function cn(...inputs: ClassValue[]) {\n return twMerge(clsx(inputs))\n}\n\n/**\n * Stringify a value of unknown shape for display, search or export.\n *\n * Plain `String(value)` renders objects and arrays as '[object Object]', which\n * shows up in data tables and CSV exports whenever a dataset column, sensor\n * reading or dynamic property holds structured data. JSON is a readable\n * fallback for those; everything else stringifies as usual.\n */\nexport function toDisplayString(value: unknown): string {\n if (value === null || value === undefined) return ''\n if (typeof value === 'object') {\n try {\n return JSON.stringify(value) ?? ''\n }\n catch {\n // Circular structures cannot be serialized.\n return ''\n }\n }\n // Objects are handled above, so this only sees primitives.\n // eslint-disable-next-line @typescript-eslint/no-base-to-string\n return String(value)\n}\n\nexport function getFileExtension(file: File): string {\n const parts = file.name.split('.')\n if (parts.length <= 1) return ''\n return parts.pop()!.toLowerCase()\n}\n\nexport async function switchLanguage(\n newLocale: Language |`${Language}`,\n setCurrentLocale?: (locale: Language |`${Language}`) => void,\n router?: { refresh: () => void }\n) {\n // Set cookie that expires in 1 year\n const expires = new Date();\n expires.setFullYear(expires.getFullYear() + 1);\n\n document.cookie = `NEXT_LOCALE=${newLocale}; expires=${expires.toUTCString()}; path=/; SameSite=Lax`;\n\n // Update local state immediately for UI feedback\n if (setCurrentLocale) {\n setCurrentLocale(newLocale);\n }\n\n // Use router.refresh() to reload server components with new locale\n if (router) {\n router.refresh();\n }\n}\n"],"mappings":"AAGA,SAAS,YAA6B;AACtC,SAAS,eAAe;AAKjB,SAAS,iBAAiB,QAAqC;AACpE,SAAO,kBAAkB,gBAAgB,OAAO,qBAAqB,4BAA4B,KAAK,OAAO,OAAO;AACtH;AAEO,SAAS,MAAM,QAAsB;AAC1C,SAAO,QAAQ,KAAK,MAAM,CAAC;AAC7B;AAUO,SAAS,gBAAgB,OAAwB;AAzBxD;AA0BE,MAAI,UAAU,QAAQ,UAAU,OAAW,QAAO;AAClD,MAAI,OAAO,UAAU,UAAU;AAC7B,QAAI;AACF,cAAO,UAAK,UAAU,KAAK,MAApB,YAAyB;AAAA,IAClC,SACM;AAEJ,aAAO;AAAA,IACT;AAAA,EACF;AAGA,SAAO,OAAO,KAAK;AACrB;AAEO,SAAS,iBAAiB,MAAoB;AACnD,QAAM,QAAQ,KAAK,KAAK,MAAM,GAAG;AACjC,MAAI,MAAM,UAAU,EAAG,QAAO;AAC9B,SAAO,MAAM,IAAI,EAAG,YAAY;AAClC;AAEA,eAAsB,eACpB,WACA,kBACA,QACA;AAEA,QAAM,UAAU,oBAAI,KAAK;AACzB,UAAQ,YAAY,QAAQ,YAAY,IAAI,CAAC;AAE7C,WAAS,SAAS,eAAe,SAAS,aAAa,QAAQ,YAAY,CAAC;AAG5E,MAAI,kBAAkB;AACpB,qBAAiB,SAAS;AAAA,EAC5B;AAGA,MAAI,QAAQ;AACV,WAAO,QAAQ;AAAA,EACjB;AACF;","names":[]}
|