@collabdt/core 0.16.0 → 0.18.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/core/components/AppSidebarContent.d.ts +2 -2
- package/dist/core/components/AppSidebarContent.d.ts.map +1 -1
- package/dist/core/components/AppSidebarContent.js +5 -4
- package/dist/core/components/AppSidebarContent.js.map +1 -1
- package/dist/core/components/Logo.d.ts +2 -0
- package/dist/core/components/Logo.d.ts.map +1 -1
- package/dist/core/components/Logo.js +8 -14
- package/dist/core/components/Logo.js.map +1 -1
- package/dist/core/components/Toolbar.d.ts +2 -2
- package/dist/core/components/Toolbar.d.ts.map +1 -1
- package/dist/core/components/Toolbar.js +4 -4
- package/dist/core/components/Toolbar.js.map +1 -1
- package/dist/core/components/authentication/AuthPage.d.ts +2 -2
- package/dist/core/components/authentication/AuthPage.d.ts.map +1 -1
- package/dist/core/components/authentication/AuthPage.js +6 -36
- package/dist/core/components/authentication/AuthPage.js.map +1 -1
- package/dist/core/components/authentication/Signin.d.ts +2 -2
- package/dist/core/components/authentication/Signin.d.ts.map +1 -1
- package/dist/core/components/authentication/Signin.js +2 -2
- package/dist/core/components/authentication/Signin.js.map +1 -1
- package/dist/core/components/settings/index.d.ts +2 -2
- package/dist/core/components/settings/index.d.ts.map +1 -1
- package/dist/core/components/settings/index.js +2 -2
- package/dist/core/components/settings/index.js.map +1 -1
- package/dist/core/components/settings/src/OrganizationSettingsPanel.d.ts +2 -2
- package/dist/core/components/settings/src/OrganizationSettingsPanel.d.ts.map +1 -1
- package/dist/core/components/settings/src/OrganizationSettingsPanel.js +3 -3
- package/dist/core/components/settings/src/OrganizationSettingsPanel.js.map +1 -1
- package/dist/core/components/settings/src/SettingsContent.d.ts +2 -2
- package/dist/core/components/settings/src/SettingsContent.d.ts.map +1 -1
- package/dist/core/components/settings/src/SettingsContent.js +2 -2
- package/dist/core/components/settings/src/SettingsContent.js.map +1 -1
- package/dist/core/components/ui/AppSidebar.d.ts +3 -1
- package/dist/core/components/ui/AppSidebar.d.ts.map +1 -1
- package/dist/core/components/ui/AppSidebar.js +2 -2
- package/dist/core/components/ui/AppSidebar.js.map +1 -1
- package/dist/core/components/ui/NavUser.d.ts +3 -1
- package/dist/core/components/ui/NavUser.d.ts.map +1 -1
- package/dist/core/components/ui/NavUser.js +15 -11
- package/dist/core/components/ui/NavUser.js.map +1 -1
- package/dist/core/components/ui/Sidebar.d.ts +1 -1
- package/dist/core/components/ui/Sidebar.d.ts.map +1 -1
- package/dist/core/components/ui/Sidebar.js +3 -3
- package/dist/core/components/ui/Sidebar.js.map +1 -1
- package/dist/core/components/ui/ViewerSidebar/index.d.ts +2 -2
- package/dist/core/components/ui/ViewerSidebar/index.d.ts.map +1 -1
- package/dist/core/components/ui/ViewerSidebar/index.js +2 -2
- package/dist/core/components/ui/ViewerSidebar/index.js.map +1 -1
- package/dist/core/components/usage/SortHeader.d.ts +18 -0
- package/dist/core/components/usage/SortHeader.d.ts.map +1 -0
- package/dist/core/components/usage/SortHeader.js +25 -0
- package/dist/core/components/usage/SortHeader.js.map +1 -0
- package/dist/core/components/usage/StatCard.d.ts +9 -0
- package/dist/core/components/usage/StatCard.d.ts.map +1 -0
- package/dist/core/components/usage/StatCard.js +18 -0
- package/dist/core/components/usage/StatCard.js.map +1 -0
- package/dist/core/components/usage/UsagePanels.d.ts +15 -0
- package/dist/core/components/usage/UsagePanels.d.ts.map +1 -0
- package/dist/core/components/usage/UsagePanels.js +43 -0
- package/dist/core/components/usage/UsagePanels.js.map +1 -0
- package/dist/core/components/usage/UserUsageTable.d.ts +14 -0
- package/dist/core/components/usage/UserUsageTable.d.ts.map +1 -0
- package/dist/core/components/usage/UserUsageTable.js +64 -0
- package/dist/core/components/usage/UserUsageTable.js.map +1 -0
- package/dist/core/components/usage/VolumeOverview.d.ts +5 -0
- package/dist/core/components/usage/VolumeOverview.d.ts.map +1 -0
- package/dist/core/components/usage/VolumeOverview.js +81 -0
- package/dist/core/components/usage/VolumeOverview.js.map +1 -0
- package/dist/core/components/usage/usagePalette.d.ts +21 -0
- package/dist/core/components/usage/usagePalette.d.ts.map +1 -0
- package/dist/core/components/usage/usagePalette.js +10 -0
- package/dist/core/components/usage/usagePalette.js.map +1 -0
- package/dist/core/components/viewers/Data/siteDetails/AssociatedBuildings.js.map +1 -1
- package/dist/core/components/viewers/Viewer.d.ts +2 -2
- package/dist/core/components/viewers/Viewer.d.ts.map +1 -1
- package/dist/core/components/viewers/Viewer.js +3 -3
- package/dist/core/components/viewers/Viewer.js.map +1 -1
- package/dist/core/components/viewers/map/datasets/RowActions.js +9 -9
- package/dist/core/components/viewers/map/datasets/RowActions.js.map +1 -1
- package/dist/core/components/viewers/map/datasets/src/orgFileDatasets.d.ts +4 -0
- package/dist/core/components/viewers/map/datasets/src/orgFileDatasets.d.ts.map +1 -0
- package/dist/core/components/viewers/map/datasets/src/{minioDatasets.js → orgFileDatasets.js} +5 -5
- package/dist/core/components/viewers/map/datasets/src/orgFileDatasets.js.map +1 -0
- package/dist/core/components/viewers/map/datasets/src/useOrganizationalDatasets.d.ts +1 -1
- package/dist/core/components/viewers/map/datasets/src/useOrganizationalDatasets.js +4 -4
- package/dist/core/components/viewers/map/datasets/src/useOrganizationalDatasets.js.map +1 -1
- package/dist/core/components/viewers/map/src/MapLayers/src/SiteLayer/siteGeometry.d.ts +3 -3
- package/dist/core/components/viewers/map/src/MapLayers/src/SiteLayer/siteGeometry.d.ts.map +1 -1
- package/dist/core/components/viewers/map/src/MapLayers/src/SiteLayer/siteGeometry.js.map +1 -1
- package/dist/core/components/viewers/map/src/MapLayers/src/SiteLayer/useShowSitesOnMap.d.ts +1 -1
- package/dist/core/components/viewers/map/src/MapLayers/src/SiteLayer/useShowSitesOnMap.js.map +1 -1
- package/dist/core/components/viewers/map/src/MapSidebar/index.d.ts +2 -2
- package/dist/core/components/viewers/map/src/MapSidebar/index.d.ts.map +1 -1
- package/dist/core/components/viewers/map/src/MapSidebar/index.js +1 -1
- package/dist/core/components/viewers/map/src/MapSidebar/index.js.map +1 -1
- package/dist/core/components/viewers/map/src/tools/AddTools/AddDataset/DatasetAdder.d.ts +1 -1
- package/dist/core/components/viewers/map/src/tools/AddTools/AddDataset/DatasetAdder.js +1 -1
- package/dist/core/components/viewers/map/src/tools/AddTools/AddDataset/DatasetAdder.js.map +1 -1
- package/dist/core/components/viewers/map/src/tools/AddTools/AddFile/utils/uploadToPresignedURLS.js.map +1 -1
- package/dist/core/components/viewers/map/src/tools/AddTools/AddSite/persistSite.d.ts +3 -3
- package/dist/core/components/viewers/map/src/tools/AddTools/AddSite/persistSite.js.map +1 -1
- package/dist/core/components/viewers/map/src/tools/mapTools.d.ts +1 -1
- package/dist/core/components/viewers/map/src/tools/mapTools.d.ts.map +1 -1
- package/dist/core/components/viewers/map/src/tools/mapTools.js.map +1 -1
- package/dist/core/hooks/ports/apiAdapter.d.ts +3 -0
- package/dist/core/hooks/ports/apiAdapter.d.ts.map +1 -1
- package/dist/core/hooks/provider.d.ts +2 -0
- package/dist/core/hooks/provider.d.ts.map +1 -1
- package/dist/core/hooks/provider.js +3 -1
- package/dist/core/hooks/provider.js.map +1 -1
- package/dist/core/hooks/usage/createUsageHooks.d.ts +15 -0
- package/dist/core/hooks/usage/createUsageHooks.d.ts.map +1 -0
- package/dist/core/hooks/usage/createUsageHooks.js +16 -0
- package/dist/core/hooks/usage/createUsageHooks.js.map +1 -0
- package/dist/core/hooks/usage/usage.d.ts +11 -0
- package/dist/core/hooks/usage/usage.d.ts.map +1 -0
- package/dist/core/hooks/usage/usage.js +11 -0
- package/dist/core/hooks/usage/usage.js.map +1 -0
- package/dist/core/hooks/useFirstLoadableImage.d.ts +3 -0
- package/dist/core/hooks/useFirstLoadableImage.d.ts.map +1 -0
- package/dist/core/hooks/useFirstLoadableImage.js +46 -0
- package/dist/core/hooks/useFirstLoadableImage.js.map +1 -0
- package/dist/core/i18n/messages/en.json +31 -0
- package/dist/core/i18n/messages/es.json +31 -0
- package/dist/core/i18n/messages/fr.json +31 -0
- package/dist/core/plugins/sdk/types.d.ts +2 -0
- package/dist/core/plugins/sdk/types.d.ts.map +1 -1
- package/dist/core/plugins/sdk/types.js.map +1 -1
- package/dist/core/store/AppConfig/context.d.ts +1 -1
- package/dist/core/store/AppConfig/context.d.ts.map +1 -1
- package/dist/core/store/AppConfig/context.js.map +1 -1
- package/dist/core/store/MapSites/reducer.d.ts +2 -2
- package/dist/core/store/MapSites/reducer.d.ts.map +1 -1
- package/dist/core/store/MapSites/reducer.js.map +1 -1
- package/dist/core/types/usage.d.ts +36 -0
- package/dist/core/types/usage.d.ts.map +1 -0
- package/dist/core/types/usage.js +1 -0
- package/dist/core/types/usage.js.map +1 -0
- package/dist/core/utils/csv.d.ts +7 -0
- package/dist/core/utils/csv.d.ts.map +1 -0
- package/dist/core/utils/csv.js +23 -0
- package/dist/core/utils/csv.js.map +1 -0
- package/dist/core/utils/orgLogo.d.ts +6 -0
- package/dist/core/utils/orgLogo.d.ts.map +1 -0
- package/dist/core/utils/orgLogo.js +15 -0
- package/dist/core/utils/orgLogo.js.map +1 -0
- package/dist/core/utils/usageCsv.d.ts +3 -0
- package/dist/core/utils/usageCsv.d.ts.map +1 -0
- package/dist/core/utils/usageCsv.js +14 -0
- package/dist/core/utils/usageCsv.js.map +1 -0
- package/dist/core/utils/usageFormat.d.ts +6 -0
- package/dist/core/utils/usageFormat.d.ts.map +1 -0
- package/dist/core/utils/usageFormat.js +34 -0
- package/dist/core/utils/usageFormat.js.map +1 -0
- package/package.json +1 -1
- package/dist/core/components/viewers/map/datasets/src/minioDatasets.d.ts +0 -4
- package/dist/core/components/viewers/map/datasets/src/minioDatasets.d.ts.map +0 -1
- package/dist/core/components/viewers/map/datasets/src/minioDatasets.js.map +0 -1
|
@@ -9,10 +9,10 @@ export interface PersistedSite {
|
|
|
9
9
|
/**
|
|
10
10
|
* Persist a freshly drawn site:
|
|
11
11
|
* 1. create the DB Site (via the injected `createSite` hook trigger),
|
|
12
|
-
* 2. upload the polygon GeoJSON to
|
|
13
|
-
* 3. create a File row attached to the site that references the
|
|
12
|
+
* 2. upload the polygon GeoJSON to object storage (presigned PUT),
|
|
13
|
+
* 3. create a File row attached to the site that references the stored object.
|
|
14
14
|
*
|
|
15
|
-
* The polygon geometry lives in
|
|
15
|
+
* The polygon geometry lives in object storage (there is no geometry column on Site);
|
|
16
16
|
* the File row links it to the site via `attachedFilesSiteId` + the geometry tag.
|
|
17
17
|
*/
|
|
18
18
|
export declare const persistDrawnSite: (params: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../../../../src/core/components/viewers/map/src/tools/AddTools/AddSite/persistSite.ts"],"sourcesContent":["// SPDX-License-Identifier: AGPL-3.0-or-later\n// Copyright (C) 2025 Collab Digital Twins\n\nimport { ringToFeatureCollection, type Ring } from '../../../MapLayers/src/SiteLayer/siteGeometry'\nimport { uploadToPresignedUrl } from '../AddFile/utils/uploadToPresignedURLS'\n\n/** Tag stored on the File row so the site's boundary geojson can be found later. */\nexport const SITE_GEOMETRY_TAG = 'site-geometry'\n\nexport interface PersistedSite {\n siteId: number\n assetId: string\n fileId?: number\n}\n\n/**\n * Persist a freshly drawn site:\n * 1. create the DB Site (via the injected `createSite` hook trigger),\n * 2. upload the polygon GeoJSON to
|
|
1
|
+
{"version":3,"sources":["../../../../../../../../../src/core/components/viewers/map/src/tools/AddTools/AddSite/persistSite.ts"],"sourcesContent":["// SPDX-License-Identifier: AGPL-3.0-or-later\n// Copyright (C) 2025 Collab Digital Twins\n\nimport { ringToFeatureCollection, type Ring } from '../../../MapLayers/src/SiteLayer/siteGeometry'\nimport { uploadToPresignedUrl } from '../AddFile/utils/uploadToPresignedURLS'\n\n/** Tag stored on the File row so the site's boundary geojson can be found later. */\nexport const SITE_GEOMETRY_TAG = 'site-geometry'\n\nexport interface PersistedSite {\n siteId: number\n assetId: string\n fileId?: number\n}\n\n/**\n * Persist a freshly drawn site:\n * 1. create the DB Site (via the injected `createSite` hook trigger),\n * 2. upload the polygon GeoJSON to object storage (presigned PUT),\n * 3. create a File row attached to the site that references the stored object.\n *\n * The polygon geometry lives in object storage (there is no geometry column on Site);\n * the File row links it to the site via `attachedFilesSiteId` + the geometry tag.\n */\nexport const persistDrawnSite = async (params: {\n name: string\n ring: Ring\n centroid: [number, number]\n createSite: (arg: any) => Promise<any>\n}): Promise<PersistedSite> => {\n const { name, ring, centroid, createSite } = params\n\n const site = await createSite({\n siteName: name,\n siteLongitude: centroid[0],\n siteLatitude: centroid[1],\n })\n const siteId = site?.id\n if (!siteId) throw new Error('Site creation did not return an id')\n\n const assetId = `${crypto.randomUUID()}.geojson`\n const fc = ringToFeatureCollection(ring, name)\n const file = new File([JSON.stringify(fc)], `${name || 'site'}.geojson`, {\n type: 'application/geo+json',\n })\n\n const presRes = await fetch(`/api/presigned-url-upload?asset=${encodeURIComponent(assetId)}`)\n if (!presRes.ok) throw new Error('Failed to get an upload URL')\n const { presignedUrl } = await presRes.json()\n await uploadToPresignedUrl(presignedUrl, file)\n\n const fileRes = await fetch(`/api/files/site/${siteId}`, {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify({\n type: 'map-file',\n name: `${name || 'site'}.geojson`,\n assetId,\n mimeType: 'application/geo+json',\n extension: 'geojson',\n sizeBytes: file.size,\n tag: SITE_GEOMETRY_TAG,\n isVisible: false,\n }),\n })\n // The DB link is required: without it the boundary is orphaned in object storage and\n // can never be re-shown. Treat failure as fatal so the caller can retry.\n if (!fileRes.ok) throw new Error('Failed to attach the geometry file to the site')\n const data = await fileRes.json().catch(() => null)\n const fileId: number | undefined = data?.newFile?.id\n\n return { siteId, assetId, fileId }\n}\n"],"mappings":"AAGA,SAAS,+BAA0C;AACnD,SAAS,4BAA4B;AAG9B,MAAM,oBAAoB;AAiB1B,MAAM,mBAAmB,OAAO,WAKT;AA7B9B;AA8BE,QAAM,EAAE,MAAM,MAAM,UAAU,WAAW,IAAI;AAE7C,Q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= 'map-dimensions' | 'map-media' | 'map-compare' | 'map-database' | 'map-add' | 'map-add-comment' | 'map-add-dataset' | 'map-add-site' | 'map-add-building' | 'map-add-sensor' | 'map-add-file' | 'map-measure' | 'map-share' | 'map-compare-buildings' | 'open-building-page' | 'open-bim-viewer' | 'map-edit-footprint';
|
|
4
4
|
type MapToolsConfig = {
|
|
5
5
|
martinBaseUrl?: string;
|
|
6
|
-
|
|
6
|
+
storageBaseUrl?: string;
|
|
7
7
|
organization?: Organization;
|
|
8
8
|
geocodeEarthApiKey?: string;
|
|
9
9
|
geocoderUrl?: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mapTools.d.ts","sourceRoot":"","sources":["../../../../../../../src/core/components/viewers/map/src/tools/mapTools.ts"],"names":[],"mappings":"AAiBA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAA;AAChE,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,4BAA4B,CAAA;AAOtD,MAAM,MAAM,kBAAkB,GAC9B,gBAAgB,GAChB,WAAW,GACX,aAAa,GACb,cAAc,GACd,SAAS,GACT,iBAAiB,GACjB,iBAAiB,GACjB,cAAc,GACd,kBAAkB,GAClB,gBAAgB,GAChB,cAAc,GACd,aAAa,GACb,WAAW,GACX,uBAAuB,GACvB,oBAAoB,GACpB,iBAAiB,GACjB,oBAAoB,CAAA;AAEpB,KAAK,cAAc,GAAG;IACpB,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB,
|
|
1
|
+
{"version":3,"file":"mapTools.d.ts","sourceRoot":"","sources":["../../../../../../../src/core/components/viewers/map/src/tools/mapTools.ts"],"names":[],"mappings":"AAiBA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAA;AAChE,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,4BAA4B,CAAA;AAOtD,MAAM,MAAM,kBAAkB,GAC9B,gBAAgB,GAChB,WAAW,GACX,aAAa,GACb,cAAc,GACd,SAAS,GACT,iBAAiB,GACjB,iBAAiB,GACjB,cAAc,GACd,kBAAkB,GAClB,gBAAgB,GAChB,cAAc,GACd,aAAa,GACb,WAAW,GACX,uBAAuB,GACvB,oBAAoB,GACpB,iBAAiB,GACjB,oBAAoB,CAAA;AAEpB,KAAK,cAAc,GAAG;IACpB,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,YAAY,CAAC,EAAE,YAAY,CAAA;IAC3B,kBAAkB,CAAC,EAAE,MAAM,CAAA;IAC3B,WAAW,CAAC,EAAE,MAAM,CAAA;CACrB,CAAA;AAGD,wBAAgB,kBAAkB,CAAC,MAAM,CAAC,EAAE,cAAc,GAAG,IAAI,EAAE,CA2ClE;AAED,gGAAgG;AAChG,eAAO,MAAM,eAAe,2BAAqB,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../../src/core/components/viewers/map/src/tools/mapTools.ts"],"sourcesContent":["// SPDX-License-Identifier: AGPL-3.0-or-later\n// Copyright (C) 2025 Collab Digital Twins\n\nimport * as LR from 'lucide-react'\nimport { useTranslations } from 'next-intl'\nimport * as React from 'react'\n\nimport { usePluginToolbarTools } from '../../../../../plugins/host/usePluginToolbarTools'\nimport { useMapViewer } from '../../../../../plugins/sdk/mapViewer'\n// Utilities\nimport Compare from '../compare'\n\nimport AddToMap from './AddTools/AddToMap'\nimport DatasetMapTool from './DatasetMapTool'\nimport { MeasureMapTool } from './measureMapTool'\nimport { ShareMapTool } from './shareMapTool'\n\nimport type { Organization } from '../../../../../types/dbTypes'\nimport type { Tool } from '../../../../../types/tools'\n\n// Icons\n\n// Custom toolbar buttons\n\n\nexport type MapToolbarToolType =\n'map-dimensions' |\n'map-media' |\n'map-compare' |\n'map-database' |\n'map-add' |\n'map-add-comment' |\n'map-add-dataset' |\n'map-add-site' |\n'map-add-building' |\n'map-add-sensor' |\n'map-add-file' |\n'map-measure' |\n'map-share' |\n'map-compare-buildings' |\n'open-building-page' |\n'open-bim-viewer' |\n'map-edit-footprint'\n\ntype MapToolsConfig = {\n martinBaseUrl?: string\n
|
|
1
|
+
{"version":3,"sources":["../../../../../../../src/core/components/viewers/map/src/tools/mapTools.ts"],"sourcesContent":["// SPDX-License-Identifier: AGPL-3.0-or-later\n// Copyright (C) 2025 Collab Digital Twins\n\nimport * as LR from 'lucide-react'\nimport { useTranslations } from 'next-intl'\nimport * as React from 'react'\n\nimport { usePluginToolbarTools } from '../../../../../plugins/host/usePluginToolbarTools'\nimport { useMapViewer } from '../../../../../plugins/sdk/mapViewer'\n// Utilities\nimport Compare from '../compare'\n\nimport AddToMap from './AddTools/AddToMap'\nimport DatasetMapTool from './DatasetMapTool'\nimport { MeasureMapTool } from './measureMapTool'\nimport { ShareMapTool } from './shareMapTool'\n\nimport type { Organization } from '../../../../../types/dbTypes'\nimport type { Tool } from '../../../../../types/tools'\n\n// Icons\n\n// Custom toolbar buttons\n\n\nexport type MapToolbarToolType =\n'map-dimensions' |\n'map-media' |\n'map-compare' |\n'map-database' |\n'map-add' |\n'map-add-comment' |\n'map-add-dataset' |\n'map-add-site' |\n'map-add-building' |\n'map-add-sensor' |\n'map-add-file' |\n'map-measure' |\n'map-share' |\n'map-compare-buildings' |\n'open-building-page' |\n'open-bim-viewer' |\n'map-edit-footprint'\n\ntype MapToolsConfig = {\n martinBaseUrl?: string\n storageBaseUrl?: string\n organization?: Organization\n geocodeEarthApiKey?: string\n geocoderUrl?: string\n}\n\n// Export toolbar configuration\nexport function useMapToolbarTools(config?: MapToolsConfig): Tool[] {\n // Translation\n const t = useTranslations('mapToolbarTools')\n\n const extraProps = (config ?? {}) as unknown as Record<string, unknown>\n\n // Map plugin tools get the MapLibre handle as `MapToolProps`, alongside the\n // same config core tools receive. Imported from `sdk/mapViewer`, not the\n // `sdk/viewer` barrel, so the BIM engine stays out of this eager bundle.\n // Memoized: a fresh object every render would recompute the tool list each time.\n const viewer = useMapViewer()\n const pluginProps = React.useMemo(\n () => ({ ...extraProps, ...viewer }),\n [extraProps, viewer],\n )\n const pluginTools = usePluginToolbarTools('map.tools', pluginProps)\n\n return [\n { id: 'map-compare', title: t('compareTitle'), url: '/', icon: LR.Columns3, component: Compare },\n { id: 'map-database', title: t('datasetsTitle'), url: '/', icon: LR.Database, component: DatasetMapTool, extraProps },\n {\n id: 'map-add',\n title: t('addTitle'),\n icon: LR.Plus,\n component: AddToMap,\n extraProps,\n },\n {\n id: 'map-measure',\n title: t('measureTitle'),\n icon: LR.Ruler,\n cursor: 'crosshair',\n stayActive: true,\n component: MeasureMapTool,\n },\n { id: 'map-share',\n title: t('shareTitle'),\n icon: LR.Share2,\n component: ShareMapTool,\n },\n // Plugin-contributed tools come last, after everything core ships.\n ...pluginTools,\n ]\n}\n\n/** @deprecated Renamed to useMapToolbarTools; it is a hook and must be called during render. */\nexport const mapToolbarTools = useMapToolbarTools\n"],"mappings":";;;;;;;;;;;;;;;;AAGA,YAAY,QAAQ;AACpB,SAAS,uBAAuB;AAChC,YAAY,WAAW;AAEvB,SAAS,6BAA6B;AACtC,SAAS,oBAAoB;AAE7B,OAAO,aAAa;AAEpB,OAAO,cAAc;AACrB,OAAO,oBAAoB;AAC3B,SAAS,sBAAsB;AAC/B,SAAS,oBAAoB;AAsCtB,SAAS,mBAAmB,QAAiC;AAElE,QAAM,IAAI,gBAAgB,iBAAiB;AAE3C,QAAM,aAAc,0BAAU,CAAC;AAM/B,QAAM,SAAS,aAAa;AAC5B,QAAM,cAAc,MAAM;AAAA,IACxB,MAAO,kCAAK,aAAe;AAAA,IAC3B,CAAC,YAAY,MAAM;AAAA,EACrB;AACA,QAAM,cAAc,sBAAsB,aAAa,WAAW;AAElE,SAAO;AAAA,IACL,EAAE,IAAI,eAAe,OAAO,EAAE,cAAc,GAAG,KAAK,KAAK,MAAM,GAAG,UAAU,WAAW,QAAQ;AAAA,IAC/F,EAAE,IAAI,gBAAgB,OAAO,EAAE,eAAe,GAAG,KAAK,KAAK,MAAM,GAAG,UAAU,WAAW,gBAAgB,WAAW;AAAA,IACpH;AAAA,MACE,IAAI;AAAA,MACJ,OAAO,EAAE,UAAU;AAAA,MACnB,MAAM,GAAG;AAAA,MACT,WAAW;AAAA,MACX;AAAA,IACF;AAAA,IACA;AAAA,MACE,IAAI;AAAA,MACJ,OAAO,EAAE,cAAc;AAAA,MACvB,MAAM,GAAG;AAAA,MACT,QAAQ;AAAA,MACR,YAAY;AAAA,MACZ,WAAW;AAAA,IACb;AAAA,IACA;AAAA,MAAE,IAAI;AAAA,MACJ,OAAO,EAAE,YAAY;AAAA,MACrB,MAAM,GAAG;AAAA,MACT,WAAW;AAAA,IACb;AAAA;AAAA,IAEA,GAAG;AAAA,EACL;AACF;AAGO,MAAM,kBAAkB;","names":[]}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { Building, DbFile, Site, OpenDataPortal, DatasetGroup, User, Role, Organization, Comment, Sensor, Infrastructure, SensorType } from '../../../core/types/dbTypes';
|
|
2
2
|
import type { PluginInstallation, PluginRecord, PluginUserSetting } from '../../../core/types/plugins';
|
|
3
|
+
import type { UserUsageReport, VolumeReport } from '../../../core/types/usage';
|
|
3
4
|
export interface ApiAdapter {
|
|
4
5
|
getBuildings(): Promise<Building[]>;
|
|
5
6
|
getBuilding(id: number): Promise<Building | null>;
|
|
@@ -61,6 +62,8 @@ export interface ApiAdapter {
|
|
|
61
62
|
updateOrganization(id: string, patch: Partial<Organization>): Promise<Organization>;
|
|
62
63
|
getOrganizationByName(name: string): Promise<Organization | null>;
|
|
63
64
|
getOrganizationRoles(orgId: string): Promise<Role[]>;
|
|
65
|
+
getMyUsage(): Promise<VolumeReport>;
|
|
66
|
+
getOrganizationUsage(): Promise<UserUsageReport>;
|
|
64
67
|
getComments(): Promise<Comment[]>;
|
|
65
68
|
getCommentsByBuilding(buildingId: number): Promise<Comment[]>;
|
|
66
69
|
getComment(id: number): Promise<Comment>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"apiAdapter.d.ts","sourceRoot":"","sources":["../../../../src/core/hooks/ports/apiAdapter.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,cAAc,EAAE,YAAY,EAAE,IAAI,EAAE,IAAI,EAAE,YAAY,EAAE,OAAO,EAAE,MAAM,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAA;AAC9K,OAAO,KAAK,EAAE,kBAAkB,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAA;
|
|
1
|
+
{"version":3,"file":"apiAdapter.d.ts","sourceRoot":"","sources":["../../../../src/core/hooks/ports/apiAdapter.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,cAAc,EAAE,YAAY,EAAE,IAAI,EAAE,IAAI,EAAE,YAAY,EAAE,OAAO,EAAE,MAAM,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAA;AAC9K,OAAO,KAAK,EAAE,kBAAkB,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAA;AACtG,OAAO,KAAK,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAA;AA0B9E,MAAM,WAAW,UAAU;IAEvB,YAAY,IAAI,OAAO,CAAC,QAAQ,EAAE,CAAC,CAAA;IACnC,WAAW,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,QAAQ,GAAG,IAAI,CAAC,CAAA;IACjD,iBAAiB,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,QAAQ,EAAE,CAAC,CAAA;IACrD,uBAAuB,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,QAAQ,EAAE,CAAC,CAAA;IAC/D,iBAAiB,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC,CAAA;IACtC,cAAc,CAAC,EAAE,EAAE,MAAM,EAAE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AC,QAAQ,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAGrF,kBAAkB,IAAI,OAAO,CAAC,cAAc,EAAE,CAAC,CAAC;IAChD,iBAAiB,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,GAAG,IAAI,CAAC,CAAC;IAC9D,oBAAoB,CAAC,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,CAAC,cAAc,CAAC,GAAG,OAAO,CAAC,cAAc,CAAC,CAAC;IAC1F,oBAAoB,CAAC,KAAK,EAAE,OAAO,CAAC,cAAc,CAAC,GAAG,OAAO,CAAC,cAAc,CAAC,CAAC;IAC9E,oBAAoB,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,CAAC,CAAC;CAE7D"}
|
|
@@ -9,6 +9,7 @@ import { createPluginHooks } from "./plugins/createPluginHooks";
|
|
|
9
9
|
import { createSensorHooks } from "./sensors/createSensorHooks";
|
|
10
10
|
import { createSensorTypeHooks } from "./sensorTypes/createSensorTypeHooks";
|
|
11
11
|
import { createSiteHooks } from "./sites/createSiteHooks";
|
|
12
|
+
import { createUsageHooks } from "./usage/createUsageHooks";
|
|
12
13
|
import { createUserHooks } from "./users/createUserHooks";
|
|
13
14
|
import type { ApiAdapter } from "./ports/apiAdapter";
|
|
14
15
|
export type HooksBag = {
|
|
@@ -23,6 +24,7 @@ export type HooksBag = {
|
|
|
23
24
|
sensor: ReturnType<typeof createSensorHooks>;
|
|
24
25
|
sensorType: ReturnType<typeof createSensorTypeHooks>;
|
|
25
26
|
plugin: ReturnType<typeof createPluginHooks>;
|
|
27
|
+
usage: ReturnType<typeof createUsageHooks>;
|
|
26
28
|
};
|
|
27
29
|
export declare const HooksCtx: React.Context<HooksBag>;
|
|
28
30
|
export declare function CoreHooksProvider({ adapter, children }: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"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ACzC,cAAc,EAAE,UAAU,CAAC,OAAO,yBAAyB,CAAC,CAAC;IAC7D,IAAI,EAAE,UAAU,CAAC,OAAO,eAAe,CAAC,CAAC;IACzC,YAAY,EAAE,UAAU,CAAC,OAAO,uBAAuB,CAAC,CAAC;IACzD,OAAO,EAAE,UAAU,CAAC,OAAO,kBAAkB,CAAC,CAAC;IAC/C,MAAM,EAAE,UAAU,CAAC,OAAO,iBAAiB,CAAC,CAAC;IAC7C,UAAU,EAAE,UAAU,CAAC,OAAO,qBAAqB,CAAC,CAAC;IACrD,MAAM,EAAE,UAAU,CAAC,OAAO,iBAAiB,CAAC,CAAC;IAC7C,KAAK,EAAE,UAAU,CAAC,OAAO,gBAAgB,CAAC,CAAC;CAC5C,CAAC;AACF,eAAO,MAAM,QAAQ,yBAAuC,CAAC;AAE7D,wBAAgB,iBAAiB,CAAC,EAAE,OAAO,EAAE,QAAQ,EAAE,EAAC;IAAE,OAAO,EAAE,UAAU,CAAC;IAAC,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAA;CAAE,qBAiBzG;AAED,wBAAgB,YAAY,aAI3B"}
|
|
@@ -13,6 +13,7 @@ import { createPluginHooks } from "./plugins/createPluginHooks";
|
|
|
13
13
|
import { createSensorHooks } from "./sensors/createSensorHooks";
|
|
14
14
|
import { createSensorTypeHooks } from "./sensorTypes/createSensorTypeHooks";
|
|
15
15
|
import { createSiteHooks } from "./sites/createSiteHooks";
|
|
16
|
+
import { createUsageHooks } from "./usage/createUsageHooks";
|
|
16
17
|
import { createUserHooks } from "./users/createUserHooks";
|
|
17
18
|
const HooksCtx = createContext(null);
|
|
18
19
|
function CoreHooksProvider({ adapter, children }) {
|
|
@@ -27,7 +28,8 @@ function CoreHooksProvider({ adapter, children }) {
|
|
|
27
28
|
comment: createCommentHooks(adapter),
|
|
28
29
|
sensor: createSensorHooks(adapter),
|
|
29
30
|
sensorType: createSensorTypeHooks(adapter),
|
|
30
|
-
plugin: createPluginHooks(adapter)
|
|
31
|
+
plugin: createPluginHooks(adapter),
|
|
32
|
+
usage: createUsageHooks(adapter)
|
|
31
33
|
}), [adapter]);
|
|
32
34
|
return /* @__PURE__ */ jsx(HooksCtx.Provider, { value: hooks, children });
|
|
33
35
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/core/hooks/provider.tsx"],"sourcesContent":["\"use client\";\n\n// SPDX-License-Identifier: AGPL-3.0-or-later\n// Copyright (C) 2025 Collab Digital Twins\n\nimport React, { createContext, useContext, useMemo } from \"react\";\n\nimport { createBuildingHooks } from \"./buildings/createBuildingHooks\";\nimport { createCommentHooks } from \"./comments/createCommentHooks\";\nimport { createFileHooks } from \"./files/createFileHooks\";\nimport { createInfrastructureHooks } from './infrastructures/createInfrastructureHooks';\nimport { createOpenDataPortalHooks } from \"./openDataPortals/createOpenDataPortalHooks\";\nimport { createOrganizationHooks } from \"./organizations/createOrganizationHooks\";\nimport { createPluginHooks } from \"./plugins/createPluginHooks\";\nimport { createSensorHooks } from \"./sensors/createSensorHooks\";\nimport { createSensorTypeHooks } from \"./sensorTypes/createSensorTypeHooks\";\nimport { createSiteHooks } from \"./sites/createSiteHooks\";\nimport { createUserHooks } from \"./users/createUserHooks\";\n\nimport type { ApiAdapter } from \"./ports/apiAdapter\";\n\n// CoreHooksProvider takes an ApiAdapter (the object that knows how to fetch data) and\n// creates all the app's data-fetching hooks from it. Mount it once at the root so every\n// page has access. Inside any component, call useCoreHooks() to get the hooks, or import\n// from the per-domain convenience wrappers (e.g. useGetBuildings from hooks/buildings/buildings.ts).\n\nexport type HooksBag = {\n building: ReturnType<typeof createBuildingHooks>;\n file: ReturnType<typeof createFileHooks>;\n openData: ReturnType<typeof createOpenDataPortalHooks>;\n site: ReturnType<typeof createSiteHooks>;\n infrastructure: ReturnType<typeof createInfrastructureHooks>;\n user: ReturnType<typeof createUserHooks>;\n organization: ReturnType<typeof createOrganizationHooks>;\n comment: ReturnType<typeof createCommentHooks>;\n sensor: ReturnType<typeof createSensorHooks>;\n sensorType: ReturnType<typeof createSensorTypeHooks>;\n plugin: ReturnType<typeof createPluginHooks>;\n};\nexport const HooksCtx = createContext<HooksBag | null>(null);\n\nexport function CoreHooksProvider({ adapter, children }:{ adapter: ApiAdapter; children: React.ReactNode }) {\n // Build the bound hook set exactly once per adapter instance\n const hooks = useMemo<HooksBag>(() => ({\n building: createBuildingHooks(adapter),\n file: createFileHooks(adapter),\n openData: createOpenDataPortalHooks(adapter),\n site: createSiteHooks(adapter),\n infrastructure: createInfrastructureHooks(adapter),\n user: createUserHooks(adapter),\n organization: createOrganizationHooks(adapter),\n comment: createCommentHooks(adapter),\n sensor: createSensorHooks(adapter),\n sensorType: createSensorTypeHooks(adapter),\n plugin: createPluginHooks(adapter),\n }), [adapter]);\n return <HooksCtx.Provider value={hooks}>{children}</HooksCtx.Provider>;\n}\n\nexport function useCoreHooks() {\n const ctx = useContext(HooksCtx);\n if (!ctx) throw new Error(\"useCoreHooks must be used inside <CoreHooksProvider>\");\n return ctx;\n}"],"mappings":";
|
|
1
|
+
{"version":3,"sources":["../../../src/core/hooks/provider.tsx"],"sourcesContent":["\"use client\";\n\n// SPDX-License-Identifier: AGPL-3.0-or-later\n// Copyright (C) 2025 Collab Digital Twins\n\nimport React, { createContext, useContext, useMemo } from \"react\";\n\nimport { createBuildingHooks } from \"./buildings/createBuildingHooks\";\nimport { createCommentHooks } from \"./comments/createCommentHooks\";\nimport { createFileHooks } from \"./files/createFileHooks\";\nimport { createInfrastructureHooks } from './infrastructures/createInfrastructureHooks';\nimport { createOpenDataPortalHooks } from \"./openDataPortals/createOpenDataPortalHooks\";\nimport { createOrganizationHooks } from \"./organizations/createOrganizationHooks\";\nimport { createPluginHooks } from \"./plugins/createPluginHooks\";\nimport { createSensorHooks } from \"./sensors/createSensorHooks\";\nimport { createSensorTypeHooks } from \"./sensorTypes/createSensorTypeHooks\";\nimport { createSiteHooks } from \"./sites/createSiteHooks\";\nimport { createUsageHooks } from \"./usage/createUsageHooks\";\nimport { createUserHooks } from \"./users/createUserHooks\";\n\nimport type { ApiAdapter } from \"./ports/apiAdapter\";\n\n// CoreHooksProvider takes an ApiAdapter (the object that knows how to fetch data) and\n// creates all the app's data-fetching hooks from it. Mount it once at the root so every\n// page has access. Inside any component, call useCoreHooks() to get the hooks, or import\n// from the per-domain convenience wrappers (e.g. useGetBuildings from hooks/buildings/buildings.ts).\n\nexport type HooksBag = {\n building: ReturnType<typeof createBuildingHooks>;\n file: ReturnType<typeof createFileHooks>;\n openData: ReturnType<typeof createOpenDataPortalHooks>;\n site: ReturnType<typeof createSiteHooks>;\n infrastructure: ReturnType<typeof createInfrastructureHooks>;\n user: ReturnType<typeof createUserHooks>;\n organization: ReturnType<typeof createOrganizationHooks>;\n comment: ReturnType<typeof createCommentHooks>;\n sensor: ReturnType<typeof createSensorHooks>;\n sensorType: ReturnType<typeof createSensorTypeHooks>;\n plugin: ReturnType<typeof createPluginHooks>;\n usage: ReturnType<typeof createUsageHooks>;\n};\nexport const HooksCtx = createContext<HooksBag | null>(null);\n\nexport function CoreHooksProvider({ adapter, children }:{ adapter: ApiAdapter; children: React.ReactNode }) {\n // Build the bound hook set exactly once per adapter instance\n const hooks = useMemo<HooksBag>(() => ({\n building: createBuildingHooks(adapter),\n file: createFileHooks(adapter),\n openData: createOpenDataPortalHooks(adapter),\n site: createSiteHooks(adapter),\n infrastructure: createInfrastructureHooks(adapter),\n user: createUserHooks(adapter),\n organization: createOrganizationHooks(adapter),\n comment: createCommentHooks(adapter),\n sensor: createSensorHooks(adapter),\n sensorType: createSensorTypeHooks(adapter),\n plugin: createPluginHooks(adapter),\n usage: createUsageHooks(adapter),\n }), [adapter]);\n return <HooksCtx.Provider value={hooks}>{children}</HooksCtx.Provider>;\n}\n\nexport function useCoreHooks() {\n const ctx = useContext(HooksCtx);\n if (!ctx) throw new Error(\"useCoreHooks must be used inside <CoreHooksProvider>\");\n return ctx;\n}"],"mappings":";AA2DS;AAtDT,SAAgB,eAAe,YAAY,eAAe;AAE1D,SAAS,2BAA2B;AACpC,SAAS,0BAA0B;AACnC,SAAS,uBAAuB;AAChC,SAAS,iCAAiC;AAC1C,SAAS,iCAAiC;AAC1C,SAAS,+BAA+B;AACxC,SAAS,yBAAyB;AAClC,SAAS,yBAAyB;AAClC,SAAS,6BAA6B;AACtC,SAAS,uBAAuB;AAChC,SAAS,wBAAwB;AACjC,SAAS,uBAAuB;AAuBzB,MAAM,WAAW,cAA+B,IAAI;AAEpD,SAAS,kBAAkB,EAAE,SAAS,SAAS,GAAsD;AAE1G,QAAM,QAAQ,QAAkB,OAAO;AAAA,IACrC,UAAU,oBAAoB,OAAO;AAAA,IACrC,MAAM,gBAAgB,OAAO;AAAA,IAC7B,UAAU,0BAA0B,OAAO;AAAA,IAC3C,MAAM,gBAAgB,OAAO;AAAA,IAC7B,gBAAgB,0BAA0B,OAAO;AAAA,IACjD,MAAM,gBAAgB,OAAO;AAAA,IAC7B,cAAc,wBAAwB,OAAO;AAAA,IAC7C,SAAS,mBAAmB,OAAO;AAAA,IACnC,QAAQ,kBAAkB,OAAO;AAAA,IACjC,YAAY,sBAAsB,OAAO;AAAA,IACzC,QAAQ,kBAAkB,OAAO;AAAA,IACjC,OAAO,iBAAiB,OAAO;AAAA,EACjC,IAAI,CAAC,OAAO,CAAC;AACb,SAAO,oBAAC,SAAS,UAAT,EAAkB,OAAO,OAAQ,UAAS;AACpD;AAEO,SAAS,eAAe;AAC7B,QAAM,MAAM,WAAW,QAAQ;AAC/B,MAAI,CAAC,IAAK,OAAM,IAAI,MAAM,sDAAsD;AAChF,SAAO;AACT;","names":[]}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { UserUsageReport, VolumeReport } from '../../types/usage';
|
|
2
|
+
import type { ApiAdapter } from '../ports/apiAdapter';
|
|
3
|
+
export declare function createUsageHooks(adapter: ApiAdapter): {
|
|
4
|
+
useMyUsage: () => {
|
|
5
|
+
report: VolumeReport;
|
|
6
|
+
isLoading: boolean;
|
|
7
|
+
isError: unknown;
|
|
8
|
+
};
|
|
9
|
+
useOrganizationUsage: () => {
|
|
10
|
+
report: UserUsageReport;
|
|
11
|
+
isLoading: boolean;
|
|
12
|
+
isError: unknown;
|
|
13
|
+
};
|
|
14
|
+
};
|
|
15
|
+
//# sourceMappingURL=createUsageHooks.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createUsageHooks.d.ts","sourceRoot":"","sources":["../../../../src/core/hooks/usage/createUsageHooks.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AACtE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAA;AAErD,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,UAAU;;;;iBAGY,OAAO;;;;;iBAKP,OAAO;;EAItE"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import useSWR from "swr";
|
|
2
|
+
function createUsageHooks(adapter) {
|
|
3
|
+
const useMyUsage = () => {
|
|
4
|
+
const { data, error, isLoading } = useSWR(["usage", "me"], () => adapter.getMyUsage());
|
|
5
|
+
return { report: data != null ? data : null, isLoading, isError: error };
|
|
6
|
+
};
|
|
7
|
+
const useOrganizationUsage = () => {
|
|
8
|
+
const { data, error, isLoading } = useSWR(["usage", "organization"], () => adapter.getOrganizationUsage());
|
|
9
|
+
return { report: data != null ? data : null, isLoading, isError: error };
|
|
10
|
+
};
|
|
11
|
+
return { useMyUsage, useOrganizationUsage };
|
|
12
|
+
}
|
|
13
|
+
export {
|
|
14
|
+
createUsageHooks
|
|
15
|
+
};
|
|
16
|
+
//# sourceMappingURL=createUsageHooks.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/core/hooks/usage/createUsageHooks.ts"],"sourcesContent":["// SPDX-License-Identifier: AGPL-3.0-or-later\n// Copyright (C) 2025 Collab Digital Twins\n\nimport useSWR from 'swr'\n\nimport type { UserUsageReport, VolumeReport } from '../../types/usage'\nimport type { ApiAdapter } from '../ports/apiAdapter'\n\nexport function createUsageHooks(adapter: ApiAdapter) {\n const useMyUsage = () => {\n const { data, error, isLoading } = useSWR<VolumeReport>(['usage', 'me'], () => adapter.getMyUsage())\n return { report: data ?? null, isLoading, isError: error as unknown }\n }\n\n const useOrganizationUsage = () => {\n const { data, error, isLoading } = useSWR<UserUsageReport>(['usage', 'organization'], () => adapter.getOrganizationUsage())\n return { report: data ?? null, isLoading, isError: error as unknown }\n }\n\n return { useMyUsage, useOrganizationUsage }\n}\n"],"mappings":"AAGA,OAAO,YAAY;AAKZ,SAAS,iBAAiB,SAAqB;AACpD,QAAM,aAAa,MAAM;AACvB,UAAM,EAAE,MAAM,OAAO,UAAU,IAAI,OAAqB,CAAC,SAAS,IAAI,GAAG,MAAM,QAAQ,WAAW,CAAC;AACnG,WAAO,EAAE,QAAQ,sBAAQ,MAAM,WAAW,SAAS,MAAiB;AAAA,EACtE;AAEA,QAAM,uBAAuB,MAAM;AACjC,UAAM,EAAE,MAAM,OAAO,UAAU,IAAI,OAAwB,CAAC,SAAS,cAAc,GAAG,MAAM,QAAQ,qBAAqB,CAAC;AAC1H,WAAO,EAAE,QAAQ,sBAAQ,MAAM,WAAW,SAAS,MAAiB;AAAA,EACtE;AAEA,SAAO,EAAE,YAAY,qBAAqB;AAC5C;","names":[]}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export declare const useMyUsage: () => {
|
|
2
|
+
report: import("../../types/usage").VolumeReport;
|
|
3
|
+
isLoading: boolean;
|
|
4
|
+
isError: unknown;
|
|
5
|
+
};
|
|
6
|
+
export declare const useOrganizationUsage: () => {
|
|
7
|
+
report: import("../../types/usage").UserUsageReport;
|
|
8
|
+
isLoading: boolean;
|
|
9
|
+
isError: unknown;
|
|
10
|
+
};
|
|
11
|
+
//# sourceMappingURL=usage.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"usage.d.ts","sourceRoot":"","sources":["../../../../src/core/hooks/usage/usage.ts"],"names":[],"mappings":"AAOA,eAAO,MAAM,UAAU;;;;CAA0C,CAAC;AAClE,eAAO,MAAM,oBAAoB;;;;CAAoD,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
"use client";
|
|
4
|
+
import { useCoreHooks } from "../provider";
|
|
5
|
+
const useMyUsage = () => useCoreHooks().usage.useMyUsage();
|
|
6
|
+
const useOrganizationUsage = () => useCoreHooks().usage.useOrganizationUsage();
|
|
7
|
+
export {
|
|
8
|
+
useMyUsage,
|
|
9
|
+
useOrganizationUsage
|
|
10
|
+
};
|
|
11
|
+
//# sourceMappingURL=usage.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/core/hooks/usage/usage.ts"],"sourcesContent":["\"use client\";\n\n// SPDX-License-Identifier: AGPL-3.0-or-later\n// Copyright (C) 2025 Collab Digital Twins\n\nimport { useCoreHooks } from \"../provider\";\n\nexport const useMyUsage = () => useCoreHooks().usage.useMyUsage();\nexport const useOrganizationUsage = () => useCoreHooks().usage.useOrganizationUsage();\n"],"mappings":";AAKA,SAAS,oBAAoB;AAEtB,MAAM,aAAa,MAAM,aAAa,EAAE,MAAM,WAAW;AACzD,MAAM,uBAAuB,MAAM,aAAa,EAAE,MAAM,qBAAqB;","names":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useFirstLoadableImage.d.ts","sourceRoot":"","sources":["../../../src/core/hooks/useFirstLoadableImage.ts"],"names":[],"mappings":"AAcA,8EAA8E;AAC9E,wBAAgB,qBAAqB,CAAC,UAAU,EAAE,SAAS,CAAC,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC,EAAE,GAAG,MAAM,GAAG,IAAI,CAsCvG"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
|
|
3
|
+
"use client";
|
|
4
|
+
import { useEffect, useState } from "react";
|
|
5
|
+
const SEPARATOR = "\n";
|
|
6
|
+
function isUsable(image, src) {
|
|
7
|
+
return image.naturalWidth > 0 || src.toLowerCase().endsWith(".svg");
|
|
8
|
+
}
|
|
9
|
+
function useFirstLoadableImage(candidates) {
|
|
10
|
+
const candidatesKey = candidates.filter(Boolean).join(SEPARATOR);
|
|
11
|
+
const [loaded, setLoaded] = useState(null);
|
|
12
|
+
useEffect(() => {
|
|
13
|
+
setLoaded(null);
|
|
14
|
+
const sources = candidatesKey ? candidatesKey.split(SEPARATOR) : [];
|
|
15
|
+
let cancelled = false;
|
|
16
|
+
let probe = null;
|
|
17
|
+
const probeFrom = (index) => {
|
|
18
|
+
if (cancelled || index >= sources.length) return;
|
|
19
|
+
const src = sources[index];
|
|
20
|
+
const image = new Image();
|
|
21
|
+
probe = image;
|
|
22
|
+
image.onload = () => {
|
|
23
|
+
if (cancelled) return;
|
|
24
|
+
if (isUsable(image, src)) setLoaded(src);
|
|
25
|
+
else probeFrom(index + 1);
|
|
26
|
+
};
|
|
27
|
+
image.onerror = () => {
|
|
28
|
+
if (!cancelled) probeFrom(index + 1);
|
|
29
|
+
};
|
|
30
|
+
image.src = src;
|
|
31
|
+
};
|
|
32
|
+
probeFrom(0);
|
|
33
|
+
return () => {
|
|
34
|
+
cancelled = true;
|
|
35
|
+
if (probe) {
|
|
36
|
+
probe.onload = null;
|
|
37
|
+
probe.onerror = null;
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
}, [candidatesKey]);
|
|
41
|
+
return loaded;
|
|
42
|
+
}
|
|
43
|
+
export {
|
|
44
|
+
useFirstLoadableImage
|
|
45
|
+
};
|
|
46
|
+
//# sourceMappingURL=useFirstLoadableImage.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/core/hooks/useFirstLoadableImage.ts"],"sourcesContent":["'use client'\n\n// SPDX-License-Identifier: AGPL-3.0-or-later\n// Copyright (C) 2025 Collab Digital Twins\n\nimport { useEffect, useState } from 'react'\n\nconst SEPARATOR = '\\n'\n\nfunction isUsable(image: HTMLImageElement, src: string): boolean {\n // An SVG with no intrinsic size reports naturalWidth 0 yet renders fine.\n return image.naturalWidth > 0 || src.toLowerCase().endsWith('.svg')\n}\n\n/** First candidate URL that loads, or null while probing and when none do. */\nexport function useFirstLoadableImage(candidates: readonly (string | null | undefined)[]): string | null {\n const candidatesKey = candidates.filter(Boolean).join(SEPARATOR)\n const [loaded, setLoaded] = useState<string | null>(null)\n\n // A detached Image() avoids the SSR race where a rendered <img> errors before React attaches onError.\n useEffect(() => {\n setLoaded(null)\n const sources = candidatesKey ? candidatesKey.split(SEPARATOR) : []\n let cancelled = false\n let probe: HTMLImageElement | null = null\n\n const probeFrom = (index: number) => {\n if (cancelled || index >= sources.length) return\n const src = sources[index]\n const image = new Image()\n probe = image\n image.onload = () => {\n if (cancelled) return\n if (isUsable(image, src)) setLoaded(src)\n else probeFrom(index + 1)\n }\n image.onerror = () => {\n if (!cancelled) probeFrom(index + 1)\n }\n image.src = src\n }\n\n probeFrom(0)\n return () => {\n cancelled = true\n if (probe) {\n probe.onload = null\n probe.onerror = null\n }\n }\n }, [candidatesKey])\n\n return loaded\n}\n"],"mappings":";AAKA,SAAS,WAAW,gBAAgB;AAEpC,MAAM,YAAY;AAElB,SAAS,SAAS,OAAyB,KAAsB;AAE/D,SAAO,MAAM,eAAe,KAAK,IAAI,YAAY,EAAE,SAAS,MAAM;AACpE;AAGO,SAAS,sBAAsB,YAAmE;AACvG,QAAM,gBAAgB,WAAW,OAAO,OAAO,EAAE,KAAK,SAAS;AAC/D,QAAM,CAAC,QAAQ,SAAS,IAAI,SAAwB,IAAI;AAGxD,YAAU,MAAM;AACd,cAAU,IAAI;AACd,UAAM,UAAU,gBAAgB,cAAc,MAAM,SAAS,IAAI,CAAC;AAClE,QAAI,YAAY;AAChB,QAAI,QAAiC;AAErC,UAAM,YAAY,CAAC,UAAkB;AACnC,UAAI,aAAa,SAAS,QAAQ,OAAQ;AAC1C,YAAM,MAAM,QAAQ,KAAK;AACzB,YAAM,QAAQ,IAAI,MAAM;AACxB,cAAQ;AACR,YAAM,SAAS,MAAM;AACnB,YAAI,UAAW;AACf,YAAI,SAAS,OAAO,GAAG,EAAG,WAAU,GAAG;AAAA,YAClC,WAAU,QAAQ,CAAC;AAAA,MAC1B;AACA,YAAM,UAAU,MAAM;AACpB,YAAI,CAAC,UAAW,WAAU,QAAQ,CAAC;AAAA,MACrC;AACA,YAAM,MAAM;AAAA,IACd;AAEA,cAAU,CAAC;AACX,WAAO,MAAM;AACX,kBAAY;AACZ,UAAI,OAAO;AACT,cAAM,SAAS;AACf,cAAM,UAAU;AAAA,MAClB;AAAA,IACF;AAAA,EACF,GAAG,CAAC,aAAa,CAAC;AAElB,SAAO;AACT;","names":[]}
|
|
@@ -2386,5 +2386,36 @@
|
|
|
2386
2386
|
"moreStyle": "More style",
|
|
2387
2387
|
"moreEntries": "+{count, number} more",
|
|
2388
2388
|
"lessStyle": "Less style"
|
|
2389
|
+
},
|
|
2390
|
+
"UsageReport": {
|
|
2391
|
+
"loading": "Loading usage…",
|
|
2392
|
+
"loadFailed": "Could not load the usage report.",
|
|
2393
|
+
"exportCsv": "Export CSV",
|
|
2394
|
+
"stats": {
|
|
2395
|
+
"stored": "Stored",
|
|
2396
|
+
"files": "Files",
|
|
2397
|
+
"latestMonth": "Uploaded this month",
|
|
2398
|
+
"unsized": "{count, plural, one {# file has} other {# files have}} no recorded size"
|
|
2399
|
+
},
|
|
2400
|
+
"chart": {
|
|
2401
|
+
"title": "Uploads per month",
|
|
2402
|
+
"description": "Size of the files uploaded each month that are still stored.",
|
|
2403
|
+
"uploaded": "Uploaded"
|
|
2404
|
+
},
|
|
2405
|
+
"byType": {
|
|
2406
|
+
"title": "By file type",
|
|
2407
|
+
"files": "{count, plural, one {# file} other {# files}}"
|
|
2408
|
+
},
|
|
2409
|
+
"table": {
|
|
2410
|
+
"title": "Per user",
|
|
2411
|
+
"user": "User",
|
|
2412
|
+
"organization": "Organization",
|
|
2413
|
+
"stored": "Stored",
|
|
2414
|
+
"files": "Files",
|
|
2415
|
+
"lastUpload": "Last upload",
|
|
2416
|
+
"unattributed": "Unattributed (uploaded before tracking)",
|
|
2417
|
+
"deletedUser": "Unknown user",
|
|
2418
|
+
"empty": "No uploads match."
|
|
2419
|
+
}
|
|
2389
2420
|
}
|
|
2390
2421
|
}
|
|
@@ -2383,5 +2383,36 @@
|
|
|
2383
2383
|
"moreStyle": "Más estilo",
|
|
2384
2384
|
"moreEntries": "+{count, number} más",
|
|
2385
2385
|
"lessStyle": "Menos estilo"
|
|
2386
|
+
},
|
|
2387
|
+
"UsageReport": {
|
|
2388
|
+
"loading": "Cargando el uso…",
|
|
2389
|
+
"loadFailed": "No se pudo cargar el informe de uso.",
|
|
2390
|
+
"exportCsv": "Exportar CSV",
|
|
2391
|
+
"stats": {
|
|
2392
|
+
"stored": "Almacenado",
|
|
2393
|
+
"files": "Archivos",
|
|
2394
|
+
"latestMonth": "Subido este mes",
|
|
2395
|
+
"unsized": "{count, plural, one {# archivo no tiene} other {# archivos no tienen}} tamaño registrado"
|
|
2396
|
+
},
|
|
2397
|
+
"chart": {
|
|
2398
|
+
"title": "Subidas por mes",
|
|
2399
|
+
"description": "Tamaño de los archivos subidos cada mes que siguen almacenados.",
|
|
2400
|
+
"uploaded": "Subido"
|
|
2401
|
+
},
|
|
2402
|
+
"byType": {
|
|
2403
|
+
"title": "Por tipo de archivo",
|
|
2404
|
+
"files": "{count, plural, one {# archivo} other {# archivos}}"
|
|
2405
|
+
},
|
|
2406
|
+
"table": {
|
|
2407
|
+
"title": "Por usuario",
|
|
2408
|
+
"user": "Usuario",
|
|
2409
|
+
"organization": "Organización",
|
|
2410
|
+
"stored": "Almacenado",
|
|
2411
|
+
"files": "Archivos",
|
|
2412
|
+
"lastUpload": "Última subida",
|
|
2413
|
+
"unattributed": "Sin atribuir (subido antes del seguimiento)",
|
|
2414
|
+
"deletedUser": "Usuario desconocido",
|
|
2415
|
+
"empty": "Ninguna subida coincide."
|
|
2416
|
+
}
|
|
2386
2417
|
}
|
|
2387
2418
|
}
|
|
@@ -2383,5 +2383,36 @@
|
|
|
2383
2383
|
"moreStyle": "Plus de style",
|
|
2384
2384
|
"moreEntries": "+{count, number} de plus",
|
|
2385
2385
|
"lessStyle": "Moins de style"
|
|
2386
|
+
},
|
|
2387
|
+
"UsageReport": {
|
|
2388
|
+
"loading": "Chargement de l’utilisation…",
|
|
2389
|
+
"loadFailed": "Impossible de charger le rapport d’utilisation.",
|
|
2390
|
+
"exportCsv": "Exporter en CSV",
|
|
2391
|
+
"stats": {
|
|
2392
|
+
"stored": "Stocké",
|
|
2393
|
+
"files": "Fichiers",
|
|
2394
|
+
"latestMonth": "Téléversé ce mois-ci",
|
|
2395
|
+
"unsized": "{count, plural, one {# fichier n’a} other {# fichiers n’ont}} pas de taille enregistrée"
|
|
2396
|
+
},
|
|
2397
|
+
"chart": {
|
|
2398
|
+
"title": "Téléversements par mois",
|
|
2399
|
+
"description": "Taille des fichiers téléversés chaque mois et toujours stockés.",
|
|
2400
|
+
"uploaded": "Téléversé"
|
|
2401
|
+
},
|
|
2402
|
+
"byType": {
|
|
2403
|
+
"title": "Par type de fichier",
|
|
2404
|
+
"files": "{count, plural, one {# fichier} other {# fichiers}}"
|
|
2405
|
+
},
|
|
2406
|
+
"table": {
|
|
2407
|
+
"title": "Par utilisateur",
|
|
2408
|
+
"user": "Utilisateur",
|
|
2409
|
+
"organization": "Organisation",
|
|
2410
|
+
"stored": "Stocké",
|
|
2411
|
+
"files": "Fichiers",
|
|
2412
|
+
"lastUpload": "Dernier téléversement",
|
|
2413
|
+
"unattributed": "Non attribué (téléversé avant le suivi)",
|
|
2414
|
+
"deletedUser": "Utilisateur inconnu",
|
|
2415
|
+
"empty": "Aucun téléversement ne correspond."
|
|
2416
|
+
}
|
|
2386
2417
|
}
|
|
2387
2418
|
}
|
|
@@ -20,6 +20,8 @@ export interface PluginManifest {
|
|
|
20
20
|
author?: string;
|
|
21
21
|
/** A lucide icon name shown beside the plugin's name. Unset or unknown shows a puzzle piece. */
|
|
22
22
|
icon?: string;
|
|
23
|
+
/** Free-form grouping such as `live-data`. Informational only; the platform never checks it. */
|
|
24
|
+
category?: string;
|
|
23
25
|
capabilities: PluginCapability[];
|
|
24
26
|
requiredPermissions?: string[];
|
|
25
27
|
configSchema?: Record<string, unknown>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/core/plugins/sdk/types.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAC/C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAE/C,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAA;AAEjD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAA;AAEtD;;;GAGG;AACH,MAAM,MAAM,kBAAkB,GAAG,GAAG,WAAW,CAAC,GAAG,GAAG,WAAW,CAAC,GAAG,EAAE,CAAA;AACvE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAA;AAM/C,eAAO,MAAM,kBAAkB,gIASrB,CAAA;AAEV,MAAM,MAAM,gBAAgB,GAAG,OAAO,kBAAkB,CAAC,MAAM,CAAC,CAAA;AAIhE,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,MAAM,CAAA;IACZ,OAAO,EAAE,MAAM,CAAA;IACf,kGAAkG;IAClG,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,gGAAgG;IAChG,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,YAAY,EAAE,gBAAgB,EAAE,CAAA;IAChC,mBAAmB,CAAC,EAAE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}
|
|
@@ -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\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, remove or hide 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":[]}
|
|
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 /** Free-form grouping such as `live-data`. Informational only; the platform never checks it. */\n category?: 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, remove or hide 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;AA6BO,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":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../../../src/core/store/AppConfig/context.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAM/B,OAAO,KAAK,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAElE,MAAM,MAAM,aAAa,GAAG;IAC1B,
|
|
1
|
+
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../../../src/core/store/AppConfig/context.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAM/B,OAAO,KAAK,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAElE,MAAM,MAAM,aAAa,GAAG;IAC1B,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,gBAAgB,CAAC,EAAE,MAAM,CAAA;IACzB,gBAAgB,CAAC,EAAE,MAAM,CAAA;IACzB,kBAAkB,CAAC,EAAE,MAAM,CAAA;IAC3B,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,WAAW,CAAC,EAAE,MAAM,CAAA;CACrB,CAAA;AAED,KAAK,gBAAgB,GAAG;IACtB,SAAS,EAAE,cAAc,CAAA;IACzB,aAAa,EAAE,aAAa,CAAA;CAC7B,CAAA;AAoBD,eAAO,MAAM,gBAAgB;WACpB,gBAAgB;cACb,KAAK,CAAC,QAAQ,CAAC,gBAAgB,CAAC;EAI1C,CAAA;AAEF,eAAO,MAAM,iBAAiB,EAAE,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,iBAAiB,CAAC;IAAE,aAAa,CAAC,EAAE,aAAa,CAAA;CAAE,CAAC,CAQlG,CAAA;AAED,eAAO,MAAM,mBAAmB;WAjBvB,gBAAgB;cACb,KAAK,CAAC,QAAQ,CAAC,gBAAgB,CAAC;CAgB+B,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/core/store/AppConfig/context.tsx"],"sourcesContent":["\"use client\"\n\n// SPDX-License-Identifier: AGPL-3.0-or-later\n// Copyright (C) 2025 Collab Digital Twins\n\nimport * as React from \"react\";\n\nimport { detectTimeZone } from '../../utils/timeUtils'\n\nimport { AppConfigReducer } from './reducer'\n\nimport type { AppConfigActions, AppConfigState } from './reducer';\n\nexport type RuntimeConfig = {\n
|
|
1
|
+
{"version":3,"sources":["../../../../src/core/store/AppConfig/context.tsx"],"sourcesContent":["\"use client\"\n\n// SPDX-License-Identifier: AGPL-3.0-or-later\n// Copyright (C) 2025 Collab Digital Twins\n\nimport * as React from \"react\";\n\nimport { detectTimeZone } from '../../utils/timeUtils'\n\nimport { AppConfigReducer } from './reducer'\n\nimport type { AppConfigActions, AppConfigState } from './reducer';\n\nexport type RuntimeConfig = {\n storageUrl?: string\n martinUrl?: string\n recaptchaSiteKey?: string\n pointcloudApiUrl?: string\n geocodeEarthApiKey?: string\n geocoderUrl?: string\n photonUrl?: string\n nominatimUrl?: string\n maptilerKey?: string\n}\n\ntype InitialStateType = {\n appConfig: AppConfigState\n runtimeConfig: RuntimeConfig\n}\n\nconst initialState: InitialStateType = {\n appConfig: {\n organization: null,\n user: null,\n displayTimeZone: detectTimeZone(),\n displayTimeZoneUserSet: false,\n },\n runtimeConfig: {},\n}\n\nconst reducer = (\n { appConfig, runtimeConfig }: InitialStateType,\n action: AppConfigActions,\n): InitialStateType => ({\n appConfig: AppConfigReducer(appConfig, action),\n runtimeConfig,\n})\n\nexport const AppConfigContext = React.createContext<{\n state: InitialStateType\n dispatch: React.Dispatch<AppConfigActions>\n}>({\n state: initialState,\n dispatch: () => null,\n})\n\nexport const AppConfigProvider: React.FC<React.PropsWithChildren<{ runtimeConfig?: RuntimeConfig }>> = ({ children, runtimeConfig = {} }) => {\n const [state, dispatch] = React.useReducer(reducer, { ...initialState, runtimeConfig })\n const value = React.useMemo(() => ({ state, dispatch }), [state])\n return (\n <AppConfigContext.Provider value={value}>\n {children}\n </AppConfigContext.Provider>\n )\n}\n\nexport const useAppConfigContext = () => React.useContext(AppConfigContext)"],"mappings":";;;;;;;;;;;;;;;;;;;;AA4DI;AAvDJ,YAAY,WAAW;AAEvB,SAAS,sBAAsB;AAE/B,SAAS,wBAAwB;AAqBjC,MAAM,eAAiC;AAAA,EACrC,WAAW;AAAA,IACT,cAAc;AAAA,IACd,MAAM;AAAA,IACN,iBAAiB,eAAe;AAAA,IAChC,wBAAwB;AAAA,EAC1B;AAAA,EACA,eAAe,CAAC;AAClB;AAEA,MAAM,UAAU,CACd,EAAE,WAAW,cAAc,GAC3B,YACsB;AAAA,EACtB,WAAW,iBAAiB,WAAW,MAAM;AAAA,EAC7C;AACF;AAEO,MAAM,mBAAmB,MAAM,cAGnC;AAAA,EACD,OAAO;AAAA,EACP,UAAU,MAAM;AAClB,CAAC;AAEM,MAAM,oBAA0F,CAAC,EAAE,UAAU,gBAAgB,CAAC,EAAE,MAAM;AAC3I,QAAM,CAAC,OAAO,QAAQ,IAAI,MAAM,WAAW,SAAS,iCAAK,eAAL,EAAmB,cAAc,EAAC;AACtF,QAAM,QAAQ,MAAM,QAAQ,OAAO,EAAE,OAAO,SAAS,IAAI,CAAC,KAAK,CAAC;AAChE,SACE,oBAAC,iBAAiB,UAAjB,EAA0B,OACxB,UACH;AAEJ;AAEO,MAAM,sBAAsB,MAAM,MAAM,WAAW,gBAAgB;","names":[]}
|