@collabdt/core 0.13.0 → 0.13.2
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/organizationConfig/src/organizationConfigContent.d.ts.map +1 -1
- package/dist/core/components/organizationConfig/src/organizationConfigContent.js +5 -11
- package/dist/core/components/organizationConfig/src/organizationConfigContent.js.map +1 -1
- package/dist/core/components/viewers/map/MapViewer.d.ts.map +1 -1
- package/dist/core/components/viewers/map/MapViewer.js +0 -4
- package/dist/core/components/viewers/map/MapViewer.js.map +1 -1
- package/dist/core/components/viewers/map/datasets/DatasetDetails.d.ts.map +1 -1
- package/dist/core/components/viewers/map/datasets/DatasetDetails.js +6 -4
- package/dist/core/components/viewers/map/datasets/DatasetDetails.js.map +1 -1
- package/dist/core/components/viewers/map/datasets/DatasetManager/index.d.ts.map +1 -1
- package/dist/core/components/viewers/map/datasets/DatasetManager/index.js +100 -53
- package/dist/core/components/viewers/map/datasets/DatasetManager/index.js.map +1 -1
- package/dist/core/components/viewers/map/datasets/DatasetManager/src/WmsDatasetControls.d.ts +8 -0
- package/dist/core/components/viewers/map/datasets/DatasetManager/src/WmsDatasetControls.d.ts.map +1 -0
- package/dist/core/components/viewers/map/datasets/DatasetManager/src/WmsDatasetControls.js +45 -0
- package/dist/core/components/viewers/map/datasets/DatasetManager/src/WmsDatasetControls.js.map +1 -0
- package/dist/core/components/viewers/map/datasets/index.d.ts.map +1 -1
- package/dist/core/components/viewers/map/datasets/index.js +4 -4
- package/dist/core/components/viewers/map/datasets/index.js.map +1 -1
- package/dist/core/components/viewers/map/datasets/src/wmsActiveTime.d.ts +5 -0
- package/dist/core/components/viewers/map/datasets/src/wmsActiveTime.d.ts.map +1 -0
- package/dist/core/components/viewers/map/datasets/src/wmsActiveTime.js +33 -0
- package/dist/core/components/viewers/map/datasets/src/wmsActiveTime.js.map +1 -0
- package/dist/core/components/viewers/map/src/MapLayers/src/OpenDataLayer/src/WmsTimeControl.d.ts +5 -4
- package/dist/core/components/viewers/map/src/MapLayers/src/OpenDataLayer/src/WmsTimeControl.d.ts.map +1 -1
- package/dist/core/components/viewers/map/src/MapLayers/src/OpenDataLayer/src/WmsTimeControl.js +55 -76
- package/dist/core/components/viewers/map/src/MapLayers/src/OpenDataLayer/src/WmsTimeControl.js.map +1 -1
- package/dist/core/components/viewers/map/src/MapLayers/src/OpenDataLayer/src/index.d.ts.map +1 -1
- package/dist/core/components/viewers/map/src/MapLayers/src/OpenDataLayer/src/index.js +7 -43
- package/dist/core/components/viewers/map/src/MapLayers/src/OpenDataLayer/src/index.js.map +1 -1
- package/dist/core/components/viewers/map/src/MapSidebar/src/LayersTab/index.d.ts.map +1 -1
- package/dist/core/components/viewers/map/src/MapSidebar/src/LayersTab/index.js +9 -4
- package/dist/core/components/viewers/map/src/MapSidebar/src/LayersTab/index.js.map +1 -1
- package/dist/core/components/viewers/shared/legends/PluginLegendSection.d.ts +16 -0
- package/dist/core/components/viewers/shared/legends/PluginLegendSection.d.ts.map +1 -0
- package/dist/core/components/viewers/shared/legends/PluginLegendSection.js +86 -0
- package/dist/core/components/viewers/shared/legends/PluginLegendSection.js.map +1 -0
- package/dist/core/components/viewers/shared/legends/ViewerLegendHost.d.ts +1 -1
- package/dist/core/components/viewers/shared/legends/ViewerLegendHost.d.ts.map +1 -1
- package/dist/core/components/viewers/shared/legends/ViewerLegendHost.js +10 -82
- package/dist/core/components/viewers/shared/legends/ViewerLegendHost.js.map +1 -1
- package/dist/core/components/viewers/shared/legends/usePluginLegends.d.ts +13 -0
- package/dist/core/components/viewers/shared/legends/usePluginLegends.d.ts.map +1 -0
- package/dist/core/components/viewers/shared/legends/usePluginLegends.js +57 -0
- package/dist/core/components/viewers/shared/legends/usePluginLegends.js.map +1 -0
- package/dist/core/components/viewers/viewerAccess.d.ts.map +1 -1
- package/dist/core/components/viewers/viewerAccess.js +2 -0
- package/dist/core/components/viewers/viewerAccess.js.map +1 -1
- package/dist/core/hooks/plugins/createPluginHooks.d.ts +2 -10
- package/dist/core/hooks/plugins/createPluginHooks.d.ts.map +1 -1
- package/dist/core/hooks/plugins/createPluginHooks.js +1 -2
- package/dist/core/hooks/plugins/createPluginHooks.js.map +1 -1
- package/dist/core/i18n/messages/en.json +2 -2
- package/dist/core/i18n/messages/es.json +2 -2
- package/dist/core/i18n/messages/fr.json +2 -2
- package/dist/core/plugins/host/pluginDatasetId.d.ts +3 -0
- package/dist/core/plugins/host/pluginDatasetId.d.ts.map +1 -0
- package/dist/core/plugins/host/pluginDatasetId.js +7 -0
- package/dist/core/plugins/host/pluginDatasetId.js.map +1 -0
- package/dist/core/plugins/host/pluginDatasets.d.ts +12 -0
- package/dist/core/plugins/host/pluginDatasets.d.ts.map +1 -0
- package/dist/core/plugins/host/pluginDatasets.js +81 -0
- package/dist/core/plugins/host/pluginDatasets.js.map +1 -0
- package/dist/core/plugins/host/runtimeShims.d.ts.map +1 -1
- package/dist/core/plugins/host/runtimeShims.js +2 -1
- package/dist/core/plugins/host/runtimeShims.js.map +1 -1
- package/dist/core/plugins/sdk/data.d.ts +2 -0
- package/dist/core/plugins/sdk/data.d.ts.map +1 -1
- package/dist/core/plugins/sdk/data.js +2 -0
- package/dist/core/plugins/sdk/data.js.map +1 -1
- package/dist/core/plugins/sdk/datasets.d.ts +12 -0
- package/dist/core/plugins/sdk/datasets.d.ts.map +1 -0
- package/dist/core/plugins/sdk/datasets.js +20 -0
- package/dist/core/plugins/sdk/datasets.js.map +1 -0
- package/dist/core/plugins/sdk/types.d.ts +47 -1
- package/dist/core/plugins/sdk/types.d.ts.map +1 -1
- package/dist/core/plugins/sdk/types.js +2 -1
- package/dist/core/plugins/sdk/types.js.map +1 -1
- package/dist/core/types/datasetTypes.d.ts +1 -0
- package/dist/core/types/datasetTypes.d.ts.map +1 -1
- package/dist/core/utils/appContent.d.ts +4 -7
- package/dist/core/utils/appContent.d.ts.map +1 -1
- package/dist/core/utils/appContent.js +8 -3
- package/dist/core/utils/appContent.js.map +1 -1
- package/package.json +1 -1
- package/dist/core/components/viewers/map/datasets/src/builtinLiveDatasets.d.ts +0 -4
- package/dist/core/components/viewers/map/datasets/src/builtinLiveDatasets.d.ts.map +0 -1
- package/dist/core/components/viewers/map/datasets/src/builtinLiveDatasets.js +0 -43
- package/dist/core/components/viewers/map/datasets/src/builtinLiveDatasets.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../../../../src/core/components/viewers/map/src/MapSidebar/src/LayersTab/index.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\n// import { useAppConfigContext } from '../../../../../../../store/AppConfig/context'\nimport {\n useOpenDataPortalsByCountrySubdivision,\n useOpenDataPortalsByGroup,\n useOpenDataPortalsByMunicipality,\n} from '../../../../../../../hooks/openDataPortals/openDataPortals'\nimport { DatasetsContext, MenusContext, useMapContext } from '../../../../../../../store'\nimport { DatasetGroup } from '../../../../../../../types/dbTypes'\nimport { ViewerSidebarPanel } from '../../../../../../ui/ViewerSidebar/Panel'\nimport { fetchLocalDatasets } from '../../../../datasets/src/localDatasets'\nimport { datasetVisibleForOrg, getOrgVisibility } from '../../../../datasets/src/orgVisibility'\nimport { useDatasetsForPortals } from '../../../../datasets/src/useDatasetsForPortals'\n\nimport { AppliedDatasetsSection } from './src/AppliedDatasetsSection'\nimport { AvailableDatasetsSection } from './src/AvailableDatasetsSection'\n\nimport type { Dataset } from '../../../../../../../types/datasetTypes'\nimport type { Organization } from '../../../../../../../types/dbTypes';\n\nconst BLOCKLIST_URLS = [\n '/2021_statistics_canada_boundaries/featureserver',\n '/limites_du_recensement_de_statistique_canada_(2021)/featureserver',\n]\nconst BLOCKLIST_NAMES = [\n '2021 statistics canada boundaries',\n 'limites du recensement de statistique canada (2021)',\n]\n\nfunction isBlocklisted(ds: Dataset) {\n const url = (ds.url || '').toLowerCase()\n const name = (ds.name || '').toLowerCase()\n return BLOCKLIST_URLS.some(u => url.includes(u)) || BLOCKLIST_NAMES.some(n => name.includes(n))\n}\n\nfunction sanitizeDatasets(list: Dataset[]) {\n const uniqueByName = new Map<string, Dataset>()\n for (const ds of list) {\n const name = ds.name?.toLowerCase() || ''\n if (!uniqueByName.has(name)) uniqueByName.set(name, ds)\n }\n const filtered = [...uniqueByName.values()].filter((ds) => {\n const name = ds.name?.toLowerCase() || ''\n const type = ds.type?.toLowerCase() || ''\n return !name.includes('basemap') && !type.includes('geocoding') && !isBlocklisted(ds)\n })\n return filtered.sort((a, b) => (a.name || '').localeCompare(b.name || ''))\n}\n\nexport function LayersTab({ martinBaseUrl, organization }: { martinBaseUrl?: string; organization?: Organization }) {\n const [searchQuery, setSearchQuery] = React.useState('')\n const [favourites, setFavourites] = React.useState<Dataset[]>([])\n\n const { state: mapState } = useMapContext()\n const { currentLocation } = mapState.map\n const org = organization\n const orgCountry = (org?.country || '').toUpperCase()\n\n const municipality = currentLocation?.municipality ?? org?.municipality ?? null\n const countrySubdivision = currentLocation?.countrySubdivision ?? org?.countrySubdivision ?? null\n\n const { state: datasetState, dispatch: datasetDispatch } = React.useContext(DatasetsContext)\n const { state: menusState } = React.useContext(MenusContext)\n const { rowsPerPage } = menusState.menus\n\n const orgVisibility = React.useMemo(() => getOrgVisibility(org?.id), [org?.id])\n\n const { openDataPortals: municipalPortals } = useOpenDataPortalsByMunicipality(municipality)\n const { openDataPortals: subdivisionPortals } = useOpenDataPortalsByCountrySubdivision(countrySubdivision)\n const { openDataPortals: nationalPortals } = useOpenDataPortalsByGroup(DatasetGroup.National)\n\n const matchesOrgCountry = React.useCallback(\n (portalCountry: string | null | undefined) => {\n if (!orgCountry) return true\n if (!portalCountry) return true\n return portalCountry.toUpperCase() === orgCountry\n },\n [orgCountry],\n )\n\n const filteredMunicipalPortals = React.useMemo(\n () => (Array.isArray(municipalPortals) ? municipalPortals.filter(p => matchesOrgCountry(p.country)) : []),\n [municipalPortals, matchesOrgCountry],\n )\n const filteredSubdivisionPortals = React.useMemo(\n () => (Array.isArray(subdivisionPortals)\n ? subdivisionPortals.filter(p => p.municipality == null && matchesOrgCountry(p.country))\n : []),\n [subdivisionPortals, matchesOrgCountry],\n )\n const filteredNationalPortals = React.useMemo(\n () => (Array.isArray(nationalPortals) ? nationalPortals.filter(p => matchesOrgCountry(p.country)) : []),\n [nationalPortals, matchesOrgCountry],\n )\n\n const municipal = useDatasetsForPortals(filteredMunicipalPortals, { rowsPerPage })\n const subdivision = useDatasetsForPortals(filteredSubdivisionPortals, { rowsPerPage })\n const national = useDatasetsForPortals(filteredNationalPortals, { rowsPerPage })\n\n React.useEffect(() => {\n const loadOrganizationalDatasets = async () => {\n try {\n const martinBaseUrlClean = (martinBaseUrl ?? '').replace(/\\/+$/, '')\n if (!martinBaseUrlClean) return\n\n const datasetsUrl = martinBaseUrlClean.includes('/tiles/index.json')\n ? martinBaseUrlClean\n : `${martinBaseUrlClean}/tiles/index.json`\n\n const localPortal = {\n id: -1,\n name: 'Organizational Datasets',\n apiUrl: datasetsUrl,\n dataManagementSystem: 'Other' as const,\n countrySubdivision: null,\n municipality: null,\n group: 'Organizational' as const,\n }\n\n const organizationalDatasets = await fetchLocalDatasets(localPortal as any)\n const visible = organizationalDatasets.filter(ds => datasetVisibleForOrg(ds, orgVisibility))\n if (visible.length > 0) {\n datasetDispatch({ type: 'SET_DATASETS', payload: { datasets: visible } })\n }\n }\n catch (error) {\n console.error('Failed to load organizational datasets:', error)\n }\n }\n void loadOrganizationalDatasets()\n }, [datasetDispatch, orgVisibility])\n\n const nationalDatasets = React.useMemo(\n () => sanitizeDatasets(national.datasets.filter(ds => datasetVisibleForOrg(ds, orgVisibility))),\n [national.datasets, orgVisibility],\n )\n const subdivisionDatasets = React.useMemo(\n () => sanitizeDatasets(subdivision.datasets.filter(ds => datasetVisibleForOrg(ds, orgVisibility))),\n [subdivision.datasets, orgVisibility],\n )\n const municipalDatasets = React.useMemo(\n () => sanitizeDatasets(municipal.datasets.filter(ds => datasetVisibleForOrg(ds, orgVisibility))),\n [municipal.datasets, orgVisibility],\n )\n const orgDatasets = React.useMemo(\n () => sanitizeDatasets((datasetState.datasets.datasets || []).filter(ds => datasetVisibleForOrg(ds, orgVisibility))),\n [datasetState.datasets.datasets, orgVisibility],\n )\n\n const allDatasets = React.useMemo(() => {\n const combined = [...nationalDatasets, ...subdivisionDatasets, ...municipalDatasets, ...orgDatasets]\n return sanitizeDatasets(combined)\n }, [nationalDatasets, subdivisionDatasets, municipalDatasets, orgDatasets])\n\n const liveDatasets = React.useMemo(\n () => allDatasets.filter(ds => ds.portal?.live === true),\n [allDatasets],\n )\n\n const toggleFavourite = React.useCallback((dataset: Dataset) => {\n setFavourites(prev => (\n prev.some(f => f.name === dataset.name)\n ? prev.filter(f => f.name !== dataset.name)\n : [...prev, dataset]\n ))\n }, [])\n\n const showMunicipal = Boolean(municipality)\n\n return (\n <ViewerSidebarPanel\n className=\"space-y-4\"\n search={{ value: searchQuery, onChange: setSearchQuery }}\n >\n <div className=\"flex-1 min-h-0 overflow-y-auto space-y-2 divide-y\">\n <div className=\"pb-2\">\n <AppliedDatasetsSection />\n </div>\n <div className=\"pt-2\">\n <AvailableDatasetsSection\n query={searchQuery}\n allDatasets={allDatasets}\n nationalDatasets={nationalDatasets}\n subdivisionDatasets={subdivisionDatasets}\n municipalDatasets={municipalDatasets}\n organizationalDatasets={orgDatasets}\n liveDatasets={liveDatasets}\n showMunicipal={showMunicipal}\n favourites={favourites}\n onFavouriteToggle={toggleFavourite}\n />\n </div>\n </div>\n </ViewerSidebarPanel>\n )\n}\n"],"mappings":";AAoLM,SAEI,KAFJ;AA/KN,YAAY,WAAW;AAGvB;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,iBAAiB,cAAc,qBAAqB;AAC7D,SAAS,oBAAoB;AAC7B,SAAS,0BAA0B;AACnC,SAAS,0BAA0B;AACnC,SAAS,sBAAsB,wBAAwB;AACvD,SAAS,6B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AC,SAAI,WAAU,qDACb;AAAA,4BAAC,SAAI,WAAU,QACb,8BAAC,0BAAuB,GAC1B;AAAA,QACA,oBAAC,SAAI,WAAU,QACb;AAAA,UAAC;AAAA;AAAA,YACC,OAAO;AAAA,YACP;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,YACA,wBAAwB;AAAA,YACxB;AAAA,YACA;AAAA,YACA;AAAA,YACA,mBAAmB;AAAA;AAAA,QACrB,GACF;AAAA,SACF;AAAA;AAAA,EACF;AAEJ;","names":["_a"]}
|
|
1
|
+
{"version":3,"sources":["../../../../../../../../../src/core/components/viewers/map/src/MapSidebar/src/LayersTab/index.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\n// import { useAppConfigContext } from '../../../../../../../store/AppConfig/context'\nimport {\n useOpenDataPortalsByCountrySubdivision,\n useOpenDataPortalsByGroup,\n useOpenDataPortalsByMunicipality,\n} from '../../../../../../../hooks/openDataPortals/openDataPortals'\nimport { usePluginDatasets } from '../../../../../../../plugins/host/pluginDatasets'\nimport { DatasetsContext, MenusContext, useMapContext } from '../../../../../../../store'\nimport { DatasetGroup } from '../../../../../../../types/dbTypes'\nimport { ViewerSidebarPanel } from '../../../../../../ui/ViewerSidebar/Panel'\nimport { fetchLocalDatasets } from '../../../../datasets/src/localDatasets'\nimport { datasetVisibleForOrg, getOrgVisibility } from '../../../../datasets/src/orgVisibility'\nimport { useDatasetsForPortals } from '../../../../datasets/src/useDatasetsForPortals'\n\nimport { AppliedDatasetsSection } from './src/AppliedDatasetsSection'\nimport { AvailableDatasetsSection } from './src/AvailableDatasetsSection'\n\nimport type { Dataset } from '../../../../../../../types/datasetTypes'\nimport type { Organization } from '../../../../../../../types/dbTypes';\n\nconst BLOCKLIST_URLS = [\n '/2021_statistics_canada_boundaries/featureserver',\n '/limites_du_recensement_de_statistique_canada_(2021)/featureserver',\n]\nconst BLOCKLIST_NAMES = [\n '2021 statistics canada boundaries',\n 'limites du recensement de statistique canada (2021)',\n]\n\nfunction isBlocklisted(ds: Dataset) {\n const url = (ds.url || '').toLowerCase()\n const name = (ds.name || '').toLowerCase()\n return BLOCKLIST_URLS.some(u => url.includes(u)) || BLOCKLIST_NAMES.some(n => name.includes(n))\n}\n\nfunction sanitizeDatasets(list: Dataset[]) {\n const uniqueByName = new Map<string, Dataset>()\n for (const ds of list) {\n const name = ds.name?.toLowerCase() || ''\n if (!uniqueByName.has(name)) uniqueByName.set(name, ds)\n }\n const filtered = [...uniqueByName.values()].filter((ds) => {\n const name = ds.name?.toLowerCase() || ''\n const type = ds.type?.toLowerCase() || ''\n return !name.includes('basemap') && !type.includes('geocoding') && !isBlocklisted(ds)\n })\n return filtered.sort((a, b) => (a.name || '').localeCompare(b.name || ''))\n}\n\nexport function LayersTab({ martinBaseUrl, organization }: { martinBaseUrl?: string; organization?: Organization }) {\n const [searchQuery, setSearchQuery] = React.useState('')\n const [favourites, setFavourites] = React.useState<Dataset[]>([])\n\n const { state: mapState } = useMapContext()\n const { currentLocation } = mapState.map\n const org = organization\n const orgCountry = (org?.country || '').toUpperCase()\n\n const municipality = currentLocation?.municipality ?? org?.municipality ?? null\n const countrySubdivision = currentLocation?.countrySubdivision ?? org?.countrySubdivision ?? null\n\n const { state: datasetState, dispatch: datasetDispatch } = React.useContext(DatasetsContext)\n const { state: menusState } = React.useContext(MenusContext)\n const { rowsPerPage } = menusState.menus\n\n const orgVisibility = React.useMemo(() => getOrgVisibility(org?.id), [org?.id])\n\n const { openDataPortals: municipalPortals } = useOpenDataPortalsByMunicipality(municipality)\n const { openDataPortals: subdivisionPortals } = useOpenDataPortalsByCountrySubdivision(countrySubdivision)\n const { openDataPortals: nationalPortals } = useOpenDataPortalsByGroup(DatasetGroup.National)\n\n const matchesOrgCountry = React.useCallback(\n (portalCountry: string | null | undefined) => {\n if (!orgCountry) return true\n if (!portalCountry) return true\n return portalCountry.toUpperCase() === orgCountry\n },\n [orgCountry],\n )\n\n const filteredMunicipalPortals = React.useMemo(\n () => (Array.isArray(municipalPortals) ? municipalPortals.filter(p => matchesOrgCountry(p.country)) : []),\n [municipalPortals, matchesOrgCountry],\n )\n const filteredSubdivisionPortals = React.useMemo(\n () => (Array.isArray(subdivisionPortals)\n ? subdivisionPortals.filter(p => p.municipality == null && matchesOrgCountry(p.country))\n : []),\n [subdivisionPortals, matchesOrgCountry],\n )\n const filteredNationalPortals = React.useMemo(\n () => (Array.isArray(nationalPortals) ? nationalPortals.filter(p => matchesOrgCountry(p.country)) : []),\n [nationalPortals, matchesOrgCountry],\n )\n\n const municipal = useDatasetsForPortals(filteredMunicipalPortals, { rowsPerPage })\n const subdivision = useDatasetsForPortals(filteredSubdivisionPortals, { rowsPerPage })\n const national = useDatasetsForPortals(filteredNationalPortals, { rowsPerPage })\n\n React.useEffect(() => {\n const loadOrganizationalDatasets = async () => {\n try {\n const martinBaseUrlClean = (martinBaseUrl ?? '').replace(/\\/+$/, '')\n if (!martinBaseUrlClean) return\n\n const datasetsUrl = martinBaseUrlClean.includes('/tiles/index.json')\n ? martinBaseUrlClean\n : `${martinBaseUrlClean}/tiles/index.json`\n\n const localPortal = {\n id: -1,\n name: 'Organizational Datasets',\n apiUrl: datasetsUrl,\n dataManagementSystem: 'Other' as const,\n countrySubdivision: null,\n municipality: null,\n group: 'Organizational' as const,\n }\n\n const organizationalDatasets = await fetchLocalDatasets(localPortal as any)\n const visible = organizationalDatasets.filter(ds => datasetVisibleForOrg(ds, orgVisibility))\n if (visible.length > 0) {\n datasetDispatch({ type: 'SET_DATASETS', payload: { datasets: visible } })\n }\n }\n catch (error) {\n console.error('Failed to load organizational datasets:', error)\n }\n }\n void loadOrganizationalDatasets()\n }, [datasetDispatch, orgVisibility])\n\n const nationalDatasets = React.useMemo(\n () => sanitizeDatasets(national.datasets.filter(ds => datasetVisibleForOrg(ds, orgVisibility))),\n [national.datasets, orgVisibility],\n )\n const subdivisionDatasets = React.useMemo(\n () => sanitizeDatasets(subdivision.datasets.filter(ds => datasetVisibleForOrg(ds, orgVisibility))),\n [subdivision.datasets, orgVisibility],\n )\n const municipalDatasets = React.useMemo(\n () => sanitizeDatasets(municipal.datasets.filter(ds => datasetVisibleForOrg(ds, orgVisibility))),\n [municipal.datasets, orgVisibility],\n )\n const pluginDatasets = usePluginDatasets(orgVisibility.currentOrgId)\n const orgDatasets = React.useMemo(\n () => sanitizeDatasets([...(datasetState.datasets.datasets || []), ...pluginDatasets.filter(ds => !ds.portal?.live)]\n .filter(ds => datasetVisibleForOrg(ds, orgVisibility))),\n [datasetState.datasets.datasets, pluginDatasets, orgVisibility],\n )\n\n const allDatasets = React.useMemo(() => {\n const combined = [...pluginDatasets, ...nationalDatasets, ...subdivisionDatasets, ...municipalDatasets, ...orgDatasets]\n return sanitizeDatasets(combined)\n }, [pluginDatasets, nationalDatasets, subdivisionDatasets, municipalDatasets, orgDatasets])\n\n const liveDatasets = React.useMemo(\n () => allDatasets.filter(ds => ds.portal?.live === true),\n [allDatasets],\n )\n\n const toggleFavourite = React.useCallback((dataset: Dataset) => {\n setFavourites(prev => (\n prev.some(f => f.name === dataset.name)\n ? prev.filter(f => f.name !== dataset.name)\n : [...prev, dataset]\n ))\n }, [])\n\n const showMunicipal = Boolean(municipality)\n\n return (\n <ViewerSidebarPanel\n className=\"space-y-4\"\n search={{ value: searchQuery, onChange: setSearchQuery }}\n >\n <div className=\"flex-1 min-h-0 overflow-y-auto space-y-2 divide-y\">\n <div className=\"pb-2\">\n <AppliedDatasetsSection />\n </div>\n <div className=\"pt-2\">\n <AvailableDatasetsSection\n query={searchQuery}\n allDatasets={allDatasets}\n nationalDatasets={nationalDatasets}\n subdivisionDatasets={subdivisionDatasets}\n municipalDatasets={municipalDatasets}\n organizationalDatasets={orgDatasets}\n liveDatasets={liveDatasets}\n showMunicipal={showMunicipal}\n favourites={favourites}\n onFavouriteToggle={toggleFavourite}\n />\n </div>\n </div>\n </ViewerSidebarPanel>\n )\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AAAA,MAAA,GAAG,WAAH,gBAAAA,IAAW,UAAS;AAAA,KAAI;AAAA,IACvD,CAAC,WAAW;AAAA,EACd;AAEA,QAAM,kBAAkB,MAAM,YAAY,CAAC,YAAqB;AAC9D,kBAAc,UACZ,KAAK,KAAK,OAAK,EAAE,SAAS,QAAQ,IAAI,IAClC,KAAK,OAAO,OAAK,EAAE,SAAS,QAAQ,IAAI,IACxC,CAAC,GAAG,MAAM,OAAO,CACtB;AAAA,EACH,GAAG,CAAC,CAAC;AAEL,QAAM,gBAAgB,QAAQ,YAAY;AAE1C,SACE;AAAA,IAAC;AAAA;AAAA,MACC,WAAU;AAAA,MACV,QAAQ,EAAE,OAAO,aAAa,UAAU,eAAe;AAAA,MAEvD,+BAAC,SAAI,WAAU,qDACb;AAAA,4BAAC,SAAI,WAAU,QACb,8BAAC,0BAAuB,GAC1B;AAAA,QACA,oBAAC,SAAI,WAAU,QACb;AAAA,UAAC;AAAA;AAAA,YACC,OAAO;AAAA,YACP;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,YACA,wBAAwB;AAAA,YACxB;AAAA,YACA;AAAA,YACA;AAAA,YACA,mBAAmB;AAAA;AAAA,QACrB,GACF;AAAA,SACF;AAAA;AAAA,EACF;AAEJ;","names":["_a"]}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import type { PluginContribution } from '../../../../plugins/host/provider';
|
|
3
|
+
export type LegendContribution = PluginContribution<'viewer.legends'>;
|
|
4
|
+
/** Identifies a legend across plugins, which may each reuse the same registration id. */
|
|
5
|
+
export declare const legendKey: (registration: LegendContribution) => string;
|
|
6
|
+
export interface PluginLegendSectionProps {
|
|
7
|
+
registration: LegendContribution;
|
|
8
|
+
config?: Record<string, unknown>;
|
|
9
|
+
onActiveChange?: (key: string, active: boolean) => void;
|
|
10
|
+
/** False runs the legend's hook for its `active` report only, drawing nothing. */
|
|
11
|
+
renderBody?: boolean;
|
|
12
|
+
/** Hides the title, for a legend nested under a row that already names it. */
|
|
13
|
+
showTitle?: boolean;
|
|
14
|
+
}
|
|
15
|
+
export declare function PluginLegendSection({ registration, config, ...rest }: PluginLegendSectionProps): React.JSX.Element;
|
|
16
|
+
//# sourceMappingURL=PluginLegendSection.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PluginLegendSection.d.ts","sourceRoot":"","sources":["../../../../../../src/core/components/viewers/shared/legends/PluginLegendSection.tsx"],"names":[],"mappings":"AAMA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAM9B,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,mCAAmC,CAAA;AAG3E,MAAM,MAAM,kBAAkB,GAAG,kBAAkB,CAAC,gBAAgB,CAAC,CAAA;AAErE,yFAAyF;AACzF,eAAO,MAAM,SAAS,GAAI,cAAc,kBAAkB,WAAkD,CAAA;AAE5G,MAAM,WAAW,wBAAwB;IACvC,YAAY,EAAE,kBAAkB,CAAA;IAChC,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IAChC,cAAc,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,KAAK,IAAI,CAAA;IACvD,kFAAkF;IAClF,UAAU,CAAC,EAAE,OAAO,CAAA;IACpB,8EAA8E;IAC9E,SAAS,CAAC,EAAE,OAAO,CAAA;CACpB;AAGD,wBAAgB,mBAAmB,CAAC,EAAE,YAAY,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,EAAE,wBAAwB,qBAM9F"}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
|
|
3
|
+
"use client";
|
|
4
|
+
var __defProp = Object.defineProperty;
|
|
5
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
8
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
9
|
+
var __spreadValues = (a, b) => {
|
|
10
|
+
for (var prop in b || (b = {}))
|
|
11
|
+
if (__hasOwnProp.call(b, prop))
|
|
12
|
+
__defNormalProp(a, prop, b[prop]);
|
|
13
|
+
if (__getOwnPropSymbols)
|
|
14
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
15
|
+
if (__propIsEnum.call(b, prop))
|
|
16
|
+
__defNormalProp(a, prop, b[prop]);
|
|
17
|
+
}
|
|
18
|
+
return a;
|
|
19
|
+
};
|
|
20
|
+
var __objRest = (source, exclude) => {
|
|
21
|
+
var target = {};
|
|
22
|
+
for (var prop in source)
|
|
23
|
+
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
24
|
+
target[prop] = source[prop];
|
|
25
|
+
if (source != null && __getOwnPropSymbols)
|
|
26
|
+
for (var prop of __getOwnPropSymbols(source)) {
|
|
27
|
+
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
|
|
28
|
+
target[prop] = source[prop];
|
|
29
|
+
}
|
|
30
|
+
return target;
|
|
31
|
+
};
|
|
32
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
33
|
+
import { useTranslations } from "next-intl";
|
|
34
|
+
import * as React from "react";
|
|
35
|
+
import { toast } from "sonner";
|
|
36
|
+
import { PluginScopeProvider } from "../../../../plugins/host/scope";
|
|
37
|
+
import { Switch } from "../../../ui/Switch";
|
|
38
|
+
const legendKey = (registration) => `${registration.pluginId}:${registration.id}`;
|
|
39
|
+
function PluginLegendSection(_a) {
|
|
40
|
+
var _b = _a, { registration, config } = _b, rest = __objRest(_b, ["registration", "config"]);
|
|
41
|
+
return /* @__PURE__ */ jsx(PluginScopeProvider, { pluginId: registration.pluginId, config, children: /* @__PURE__ */ jsx(LegendBody, __spreadValues({ registration }, rest)) });
|
|
42
|
+
}
|
|
43
|
+
function LegendBody({ registration, onActiveChange, renderBody = true, showTitle = true }) {
|
|
44
|
+
const t = useTranslations("MapLegend");
|
|
45
|
+
const { active, title, unavailable, rows, controls } = registration.useLegend();
|
|
46
|
+
const key = legendKey(registration);
|
|
47
|
+
React.useEffect(() => {
|
|
48
|
+
onActiveChange == null ? void 0 : onActiveChange(key, active);
|
|
49
|
+
}, [active, key, onActiveChange]);
|
|
50
|
+
const shownTitle = title != null ? title : registration.title;
|
|
51
|
+
React.useEffect(() => {
|
|
52
|
+
if (active && unavailable) toast.warning(t("feedUnavailableToast", { title: shownTitle }), { id: `legend-unavailable-${key}` });
|
|
53
|
+
}, [active, unavailable, key, shownTitle, t]);
|
|
54
|
+
if (!renderBody || !active) return null;
|
|
55
|
+
return /* @__PURE__ */ jsxs("div", { className: "px-3 py-2 border-t first:border-t-0", children: [
|
|
56
|
+
showTitle && /* @__PURE__ */ jsx("div", { className: "font-semibold text-xs mb-1", children: shownTitle }),
|
|
57
|
+
unavailable && /* @__PURE__ */ jsx("div", { className: "mb-1 rounded bg-red-100 text-red-800 px-2 py-1 text-[11px] font-medium", children: t("feedUnavailable") }),
|
|
58
|
+
/* @__PURE__ */ jsx("ul", { className: "space-y-1", children: rows.map((row) => /* @__PURE__ */ jsx(LegendRowItem, { row }, row.label)) }),
|
|
59
|
+
controls && /* @__PURE__ */ jsx("div", { className: "mt-2", children: controls })
|
|
60
|
+
] });
|
|
61
|
+
}
|
|
62
|
+
function LegendRowItem({ row }) {
|
|
63
|
+
const switchable = row.onVisibleChange !== void 0;
|
|
64
|
+
const visible = row.visible !== false;
|
|
65
|
+
return /* @__PURE__ */ jsxs("li", { className: `flex items-center gap-2 text-xs ${visible ? "" : "opacity-50"}`, children: [
|
|
66
|
+
/* @__PURE__ */ jsx("span", { "aria-hidden": "true", className: "inline-block h-3 w-3 rounded-sm shrink-0", style: { backgroundColor: row.color } }),
|
|
67
|
+
/* @__PURE__ */ jsx("span", { className: "flex-1", children: row.label }),
|
|
68
|
+
row.count !== void 0 && /* @__PURE__ */ jsx("span", { className: "tabular-nums opacity-70", children: row.count }),
|
|
69
|
+
switchable && /* @__PURE__ */ jsx(
|
|
70
|
+
Switch,
|
|
71
|
+
{
|
|
72
|
+
checked: visible,
|
|
73
|
+
onCheckedChange: (checked) => {
|
|
74
|
+
var _a;
|
|
75
|
+
return (_a = row.onVisibleChange) == null ? void 0 : _a.call(row, checked);
|
|
76
|
+
},
|
|
77
|
+
"aria-label": row.label
|
|
78
|
+
}
|
|
79
|
+
)
|
|
80
|
+
] });
|
|
81
|
+
}
|
|
82
|
+
export {
|
|
83
|
+
PluginLegendSection,
|
|
84
|
+
legendKey
|
|
85
|
+
};
|
|
86
|
+
//# sourceMappingURL=PluginLegendSection.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../../src/core/components/viewers/shared/legends/PluginLegendSection.tsx"],"sourcesContent":["'use client'\n\n// SPDX-License-Identifier: AGPL-3.0-or-later\n// Copyright (C) 2025 Collab Digital Twins\n\nimport { useTranslations } from 'next-intl'\nimport * as React from 'react'\nimport { toast } from 'sonner'\n\nimport { PluginScopeProvider } from '../../../../plugins/host/scope'\nimport { Switch } from '../../../ui/Switch'\n\nimport type { PluginContribution } from '../../../../plugins/host/provider'\nimport type { LegendRegistration, LegendRow } from '../../../../plugins/sdk/types'\n\nexport type LegendContribution = PluginContribution<'viewer.legends'>\n\n/** Identifies a legend across plugins, which may each reuse the same registration id. */\nexport const legendKey = (registration: LegendContribution) => `${registration.pluginId}:${registration.id}`\n\nexport interface PluginLegendSectionProps {\n registration: LegendContribution\n config?: Record<string, unknown>\n onActiveChange?: (key: string, active: boolean) => void\n /** False runs the legend's hook for its `active` report only, drawing nothing. */\n renderBody?: boolean\n /** Hides the title, for a legend nested under a row that already names it. */\n showTitle?: boolean\n}\n\n// The scope must be a parent: `useLegend` runs in LegendBody's own render.\nexport function PluginLegendSection({ registration, config, ...rest }: PluginLegendSectionProps) {\n return (\n <PluginScopeProvider pluginId={registration.pluginId} config={config}>\n <LegendBody registration={registration} {...rest} />\n </PluginScopeProvider>\n )\n}\n\nfunction LegendBody({ registration, onActiveChange, renderBody = true, showTitle = true }: PluginLegendSectionProps) {\n const t = useTranslations('MapLegend')\n const { active, title, unavailable, rows, controls } = (registration as LegendRegistration).useLegend()\n const key = legendKey(registration)\n\n React.useEffect(() => {\n onActiveChange?.(key, active)\n }, [active, key, onActiveChange])\n\n const shownTitle = title ?? registration.title\n React.useEffect(() => {\n if (active && unavailable) toast.warning(t('feedUnavailableToast', { title: shownTitle }), { id: `legend-unavailable-${key}` })\n }, [active, unavailable, key, shownTitle, t])\n\n if (!renderBody || !active) return null\n\n return (\n <div className=\"px-3 py-2 border-t first:border-t-0\">\n {showTitle && <div className=\"font-semibold text-xs mb-1\">{shownTitle}</div>}\n {unavailable && (\n <div className=\"mb-1 rounded bg-red-100 text-red-800 px-2 py-1 text-[11px] font-medium\">\n {t('feedUnavailable')}\n </div>\n )}\n <ul className=\"space-y-1\">\n {rows.map(row => <LegendRowItem key={row.label} row={row} />)}\n </ul>\n {controls && <div className=\"mt-2\">{controls}</div>}\n </div>\n )\n}\n\nfunction LegendRowItem({ row }: { row: LegendRow }) {\n const switchable = row.onVisibleChange !== undefined\n const visible = row.visible !== false\n\n return (\n <li className={`flex items-center gap-2 text-xs ${visible ? '' : 'opacity-50'}`}>\n <span aria-hidden=\"true\" className=\"inline-block h-3 w-3 rounded-sm shrink-0\" style={{ backgroundColor: row.color }} />\n <span className=\"flex-1\">{row.label}</span>\n {row.count !== undefined && <span className=\"tabular-nums opacity-70\">{row.count}</span>}\n {switchable && (\n <Switch\n checked={visible}\n onCheckedChange={checked => row.onVisibleChange?.(checked)}\n aria-label={row.label}\n />\n )}\n </li>\n )\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkCM,cAsBF,YAtBE;AA7BN,SAAS,uBAAuB;AAChC,YAAY,WAAW;AACvB,SAAS,aAAa;AAEtB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AAuB;AAClD,QAAM,aAAa,IAAI,oBAAoB;AAC3C,QAAM,UAAU,IAAI,YAAY;AAEhC,SACE,qBAAC,QAAG,WAAW,mCAAmC,UAAU,KAAK,YAAY,IAC3E;AAAA,wBAAC,UAAK,eAAY,QAAO,WAAU,4CAA2C,OAAO,EAAE,iBAAiB,IAAI,MAAM,GAAG;AAAA,IACrH,oBAAC,UAAK,WAAU,UAAU,cAAI,OAAM;AAAA,IACnC,IAAI,UAAU,UAAa,oBAAC,UAAK,WAAU,2BAA2B,cAAI,OAAM;AAAA,IAChF,cACC;AAAA,MAAC;AAAA;AAAA,QACC,SAAS;AAAA,QACT,iBAAiB,aAAQ;AAnFnC;AAmFsC,2BAAI,oBAAJ,6BAAsB;AAAA;AAAA,QAClD,cAAY,IAAI;AAAA;AAAA,IAClB;AAAA,KAEJ;AAEJ;","names":[]}
|
|
@@ -2,7 +2,7 @@ import * as React from 'react';
|
|
|
2
2
|
import type { ViewerNames } from '../../../../types/dbTypes';
|
|
3
3
|
/**
|
|
4
4
|
* One shared legend card per viewer, with a titled section per active `viewer.legends`
|
|
5
|
-
* registration.
|
|
5
|
+
* registration. The map stacks its legends in the applied-layers card instead.
|
|
6
6
|
*/
|
|
7
7
|
export declare function ViewerLegendHost({ viewer }: {
|
|
8
8
|
viewer: ViewerNames;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ViewerLegendHost.d.ts","sourceRoot":"","sources":["../../../../../../src/core/components/viewers/shared/legends/ViewerLegendHost.tsx"],"names":[],"mappings":"AAMA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;
|
|
1
|
+
{"version":3,"file":"ViewerLegendHost.d.ts","sourceRoot":"","sources":["../../../../../../src/core/components/viewers/shared/legends/ViewerLegendHost.tsx"],"names":[],"mappings":"AAMA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAO9B,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAA;AAE5D;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,EAAE,MAAM,EAAE,EAAE;IAAE,MAAM,EAAE,WAAW,CAAA;CAAE,qBA4BnE"}
|
|
@@ -1,67 +1,17 @@
|
|
|
1
1
|
'use client'
|
|
2
2
|
|
|
3
3
|
"use client";
|
|
4
|
-
var __defProp = Object.defineProperty;
|
|
5
|
-
var __defProps = Object.defineProperties;
|
|
6
|
-
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
7
|
-
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
8
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
|
-
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
10
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
11
|
-
var __spreadValues = (a, b) => {
|
|
12
|
-
for (var prop in b || (b = {}))
|
|
13
|
-
if (__hasOwnProp.call(b, prop))
|
|
14
|
-
__defNormalProp(a, prop, b[prop]);
|
|
15
|
-
if (__getOwnPropSymbols)
|
|
16
|
-
for (var prop of __getOwnPropSymbols(b)) {
|
|
17
|
-
if (__propIsEnum.call(b, prop))
|
|
18
|
-
__defNormalProp(a, prop, b[prop]);
|
|
19
|
-
}
|
|
20
|
-
return a;
|
|
21
|
-
};
|
|
22
|
-
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
23
|
-
var __objRest = (source, exclude) => {
|
|
24
|
-
var target = {};
|
|
25
|
-
for (var prop in source)
|
|
26
|
-
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
27
|
-
target[prop] = source[prop];
|
|
28
|
-
if (source != null && __getOwnPropSymbols)
|
|
29
|
-
for (var prop of __getOwnPropSymbols(source)) {
|
|
30
|
-
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
|
|
31
|
-
target[prop] = source[prop];
|
|
32
|
-
}
|
|
33
|
-
return target;
|
|
34
|
-
};
|
|
35
4
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
36
5
|
import { useTranslations } from "next-intl";
|
|
37
|
-
import * as React from "react";
|
|
38
|
-
import { usePluginConfigs, usePluginContributions } from "../../../../plugins/host/provider";
|
|
39
|
-
import { PluginScopeProvider } from "../../../../plugins/host/scope";
|
|
40
6
|
import { LegendCard } from "../../../ui/LegendCard";
|
|
7
|
+
import { legendKey, PluginLegendSection } from "./PluginLegendSection";
|
|
8
|
+
import { usePluginLegends } from "./usePluginLegends";
|
|
41
9
|
function ViewerLegendHost({ viewer }) {
|
|
42
|
-
const all = usePluginContributions("viewer.legends");
|
|
43
|
-
const configs = usePluginConfigs();
|
|
44
|
-
const registrations = React.useMemo(
|
|
45
|
-
() => all.filter((entry) => !entry.viewers || entry.viewers.includes(viewer)),
|
|
46
|
-
[all, viewer]
|
|
47
|
-
);
|
|
48
10
|
const t = useTranslations("MapLegend");
|
|
49
|
-
const
|
|
50
|
-
const
|
|
51
|
-
setActiveMap((prev) => prev[id] === active ? prev : __spreadProps(__spreadValues({}, prev), { [id]: active }));
|
|
52
|
-
}, []);
|
|
53
|
-
const activeCount = registrations.filter((r) => activeMap[r.id]).length;
|
|
11
|
+
const { registrations, configs, isActive, probes } = usePluginLegends(viewer);
|
|
12
|
+
const activeCount = registrations.filter(isActive).length;
|
|
54
13
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
55
|
-
|
|
56
|
-
ScopedLegendSection,
|
|
57
|
-
{
|
|
58
|
-
registration: r,
|
|
59
|
-
config: configs[r.pluginId],
|
|
60
|
-
onActiveChange: reportActive,
|
|
61
|
-
renderBody: false
|
|
62
|
-
},
|
|
63
|
-
`probe-${r.id}`
|
|
64
|
-
)) }),
|
|
14
|
+
probes,
|
|
65
15
|
activeCount > 0 && /* @__PURE__ */ jsx(
|
|
66
16
|
LegendCard,
|
|
67
17
|
{
|
|
@@ -69,40 +19,18 @@ function ViewerLegendHost({ viewer }) {
|
|
|
69
19
|
count: activeCount,
|
|
70
20
|
testId: "map-legend-card",
|
|
71
21
|
countTestId: "map-legend-count",
|
|
72
|
-
children: registrations.map((
|
|
73
|
-
|
|
22
|
+
children: registrations.map((registration) => /* @__PURE__ */ jsx(
|
|
23
|
+
PluginLegendSection,
|
|
74
24
|
{
|
|
75
|
-
registration
|
|
76
|
-
config: configs[
|
|
77
|
-
onActiveChange: reportActive,
|
|
78
|
-
renderBody: true
|
|
25
|
+
registration,
|
|
26
|
+
config: configs[registration.pluginId]
|
|
79
27
|
},
|
|
80
|
-
|
|
28
|
+
legendKey(registration)
|
|
81
29
|
))
|
|
82
30
|
}
|
|
83
31
|
)
|
|
84
32
|
] });
|
|
85
33
|
}
|
|
86
|
-
function ScopedLegendSection(_a) {
|
|
87
|
-
var _b = _a, { registration, config } = _b, rest = __objRest(_b, ["registration", "config"]);
|
|
88
|
-
return /* @__PURE__ */ jsx(PluginScopeProvider, { pluginId: registration.pluginId, config, children: /* @__PURE__ */ jsx(LegendSection, __spreadValues({ registration }, rest)) });
|
|
89
|
-
}
|
|
90
|
-
function LegendSection({ registration, onActiveChange, renderBody }) {
|
|
91
|
-
const t = useTranslations("MapLegend");
|
|
92
|
-
const { active, title, unavailable, rows } = registration.useLegend();
|
|
93
|
-
React.useEffect(() => {
|
|
94
|
-
onActiveChange(registration.id, active);
|
|
95
|
-
}, [active, registration.id, onActiveChange]);
|
|
96
|
-
if (!renderBody || !active) return null;
|
|
97
|
-
return /* @__PURE__ */ jsxs("div", { className: "px-3 py-2 border-t first:border-t-0", children: [
|
|
98
|
-
/* @__PURE__ */ jsx("div", { className: "font-semibold text-xs mb-1", children: title != null ? title : registration.title }),
|
|
99
|
-
unavailable ? /* @__PURE__ */ jsx("div", { className: "rounded bg-red-100 text-red-800 px-2 py-1 text-[11px] font-medium", children: t("feedUnavailable") }) : /* @__PURE__ */ jsx("ul", { className: "space-y-1", children: rows.map((row) => /* @__PURE__ */ jsxs("li", { className: "flex items-center gap-2 text-xs", children: [
|
|
100
|
-
/* @__PURE__ */ jsx("span", { "aria-hidden": "true", className: "inline-block h-3 w-3 rounded-sm shrink-0", style: { backgroundColor: row.color } }),
|
|
101
|
-
/* @__PURE__ */ jsx("span", { className: "flex-1", children: row.label }),
|
|
102
|
-
row.count !== void 0 && /* @__PURE__ */ jsx("span", { className: "tabular-nums opacity-70", children: row.count })
|
|
103
|
-
] }, row.label)) })
|
|
104
|
-
] });
|
|
105
|
-
}
|
|
106
34
|
export {
|
|
107
35
|
ViewerLegendHost
|
|
108
36
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../src/core/components/viewers/shared/legends/ViewerLegendHost.tsx"],"sourcesContent":["'use client'\n\n// SPDX-License-Identifier: AGPL-3.0-or-later\n// Copyright (C) 2025 Collab Digital Twins\n\nimport { useTranslations } from 'next-intl'\nimport * as React from 'react'\n\nimport {
|
|
1
|
+
{"version":3,"sources":["../../../../../../src/core/components/viewers/shared/legends/ViewerLegendHost.tsx"],"sourcesContent":["'use client'\n\n// SPDX-License-Identifier: AGPL-3.0-or-later\n// Copyright (C) 2025 Collab Digital Twins\n\nimport { useTranslations } from 'next-intl'\nimport * as React from 'react'\n\nimport { LegendCard } from '../../../ui/LegendCard'\n\nimport { legendKey, PluginLegendSection } from './PluginLegendSection'\nimport { usePluginLegends } from './usePluginLegends'\n\nimport type { ViewerNames } from '../../../../types/dbTypes'\n\n/**\n * One shared legend card per viewer, with a titled section per active `viewer.legends`\n * registration. The map stacks its legends in the applied-layers card instead.\n */\nexport function ViewerLegendHost({ viewer }: { viewer: ViewerNames }) {\n const t = useTranslations('MapLegend')\n const { registrations, configs, isActive, probes } = usePluginLegends(viewer)\n\n const activeCount = registrations.filter(isActive).length\n\n return (\n <>\n {probes}\n\n {activeCount > 0 && (\n <LegendCard\n title={activeCount === 1 ? t('title') : t('titlePlural')}\n count={activeCount}\n testId=\"map-legend-card\"\n countTestId=\"map-legend-count\"\n >\n {registrations.map(registration => (\n <PluginLegendSection\n key={legendKey(registration)}\n registration={registration}\n config={configs[registration.pluginId]}\n />\n ))}\n </LegendCard>\n )}\n </>\n )\n}\n"],"mappings":";AA0BI,mBAWQ,KAXR;AArBJ,SAAS,uBAAuB;AAGhC,SAAS,kBAAkB;AAE3B,SAAS,WAAW,2BAA2B;AAC/C,SAAS,wBAAwB;AAQ1B,SAAS,iBAAiB,EAAE,OAAO,GAA4B;AACpE,QAAM,IAAI,gBAAgB,WAAW;AACrC,QAAM,EAAE,eAAe,SAAS,UAAU,OAAO,IAAI,iBAAiB,MAAM;AAE5E,QAAM,cAAc,cAAc,OAAO,QAAQ,EAAE;AAEnD,SACE,iCACG;AAAA;AAAA,IAEA,cAAc,KACb;AAAA,MAAC;AAAA;AAAA,QACC,OAAO,gBAAgB,IAAI,EAAE,OAAO,IAAI,EAAE,aAAa;AAAA,QACvD,OAAO;AAAA,QACP,QAAO;AAAA,QACP,aAAY;AAAA,QAEX,wBAAc,IAAI,kBACjB;AAAA,UAAC;AAAA;AAAA,YAEC;AAAA,YACA,QAAQ,QAAQ,aAAa,QAAQ;AAAA;AAAA,UAFhC,UAAU,YAAY;AAAA,QAG7B,CACD;AAAA;AAAA,IACH;AAAA,KAEJ;AAEJ;","names":[]}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import type { LegendContribution } from './PluginLegendSection';
|
|
3
|
+
import type { ViewerNames } from '../../../../types/dbTypes';
|
|
4
|
+
export interface PluginLegends {
|
|
5
|
+
registrations: LegendContribution[];
|
|
6
|
+
configs: Record<string, Record<string, unknown>>;
|
|
7
|
+
isActive: (registration: LegendContribution) => boolean;
|
|
8
|
+
/** Render once: keeps every legend's hook running, and its `active` known, while no card shows it. */
|
|
9
|
+
probes: React.ReactNode;
|
|
10
|
+
}
|
|
11
|
+
/** The `viewer.legends` that belong in `viewer`, and which of them currently have something to say. */
|
|
12
|
+
export declare function usePluginLegends(viewer: ViewerNames): PluginLegends;
|
|
13
|
+
//# sourceMappingURL=usePluginLegends.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"usePluginLegends.d.ts","sourceRoot":"","sources":["../../../../../../src/core/components/viewers/shared/legends/usePluginLegends.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAM9B,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAA;AAC/D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAA;AAE5D,MAAM,WAAW,aAAa;IAC5B,aAAa,EAAE,kBAAkB,EAAE,CAAA;IACnC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAA;IAChD,QAAQ,EAAE,CAAC,YAAY,EAAE,kBAAkB,KAAK,OAAO,CAAA;IACvD,sGAAsG;IACtG,MAAM,EAAE,KAAK,CAAC,SAAS,CAAA;CACxB;AAED,uGAAuG;AACvG,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,WAAW,GAAG,aAAa,CAmCnE"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
|
|
3
|
+
"use client";
|
|
4
|
+
var __defProp = Object.defineProperty;
|
|
5
|
+
var __defProps = Object.defineProperties;
|
|
6
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
7
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
8
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
10
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
11
|
+
var __spreadValues = (a, b) => {
|
|
12
|
+
for (var prop in b || (b = {}))
|
|
13
|
+
if (__hasOwnProp.call(b, prop))
|
|
14
|
+
__defNormalProp(a, prop, b[prop]);
|
|
15
|
+
if (__getOwnPropSymbols)
|
|
16
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
17
|
+
if (__propIsEnum.call(b, prop))
|
|
18
|
+
__defNormalProp(a, prop, b[prop]);
|
|
19
|
+
}
|
|
20
|
+
return a;
|
|
21
|
+
};
|
|
22
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
23
|
+
import { jsx } from "react/jsx-runtime";
|
|
24
|
+
import * as React from "react";
|
|
25
|
+
import { usePluginConfigs, usePluginContributions } from "../../../../plugins/host/provider";
|
|
26
|
+
import { legendKey, PluginLegendSection } from "./PluginLegendSection";
|
|
27
|
+
function usePluginLegends(viewer) {
|
|
28
|
+
const all = usePluginContributions("viewer.legends");
|
|
29
|
+
const configs = usePluginConfigs();
|
|
30
|
+
const registrations = React.useMemo(
|
|
31
|
+
() => all.filter((entry) => !entry.viewers || entry.viewers.includes(viewer)),
|
|
32
|
+
[all, viewer]
|
|
33
|
+
);
|
|
34
|
+
const [activeMap, setActiveMap] = React.useState({});
|
|
35
|
+
const reportActive = React.useCallback((key, active) => {
|
|
36
|
+
setActiveMap((previous) => previous[key] === active ? previous : __spreadProps(__spreadValues({}, previous), { [key]: active }));
|
|
37
|
+
}, []);
|
|
38
|
+
const isActive = React.useCallback(
|
|
39
|
+
(registration) => Boolean(activeMap[legendKey(registration)]),
|
|
40
|
+
[activeMap]
|
|
41
|
+
);
|
|
42
|
+
const probes = /* @__PURE__ */ jsx("div", { className: "hidden", children: registrations.map((registration) => /* @__PURE__ */ jsx(
|
|
43
|
+
PluginLegendSection,
|
|
44
|
+
{
|
|
45
|
+
registration,
|
|
46
|
+
config: configs[registration.pluginId],
|
|
47
|
+
onActiveChange: reportActive,
|
|
48
|
+
renderBody: false
|
|
49
|
+
},
|
|
50
|
+
`probe-${legendKey(registration)}`
|
|
51
|
+
)) });
|
|
52
|
+
return { registrations, configs, isActive, probes };
|
|
53
|
+
}
|
|
54
|
+
export {
|
|
55
|
+
usePluginLegends
|
|
56
|
+
};
|
|
57
|
+
//# sourceMappingURL=usePluginLegends.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../../src/core/components/viewers/shared/legends/usePluginLegends.tsx"],"sourcesContent":["'use client'\n\n// SPDX-License-Identifier: AGPL-3.0-or-later\n// Copyright (C) 2025 Collab Digital Twins\n\nimport * as React from 'react'\n\nimport { usePluginConfigs, usePluginContributions } from '../../../../plugins/host/provider'\n\nimport { legendKey, PluginLegendSection } from './PluginLegendSection'\n\nimport type { LegendContribution } from './PluginLegendSection'\nimport type { ViewerNames } from '../../../../types/dbTypes'\n\nexport interface PluginLegends {\n registrations: LegendContribution[]\n configs: Record<string, Record<string, unknown>>\n isActive: (registration: LegendContribution) => boolean\n /** Render once: keeps every legend's hook running, and its `active` known, while no card shows it. */\n probes: React.ReactNode\n}\n\n/** The `viewer.legends` that belong in `viewer`, and which of them currently have something to say. */\nexport function usePluginLegends(viewer: ViewerNames): PluginLegends {\n const all = usePluginContributions('viewer.legends')\n const configs = usePluginConfigs()\n\n const registrations = React.useMemo(\n () => all.filter(entry => !entry.viewers || entry.viewers.includes(viewer)),\n [all, viewer],\n )\n\n const [activeMap, setActiveMap] = React.useState<Record<string, boolean>>({})\n\n const reportActive = React.useCallback((key: string, active: boolean) => {\n setActiveMap(previous => (previous[key] === active ? previous : { ...previous, [key]: active }))\n }, [])\n\n const isActive = React.useCallback(\n (registration: LegendContribution) => Boolean(activeMap[legendKey(registration)]),\n [activeMap],\n )\n\n const probes = (\n <div className=\"hidden\">\n {registrations.map(registration => (\n <PluginLegendSection\n key={`probe-${legendKey(registration)}`}\n registration={registration}\n config={configs[registration.pluginId]}\n onActiveChange={reportActive}\n renderBody={false}\n />\n ))}\n </div>\n )\n\n return { registrations, configs, isActive, probes }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AA8CQ;AAzCR,YAAY,WAAW;AAEvB,SAAS,kBAAkB,8BAA8B;AAEzD,SAAS,WAAW,2BAA2B;AAcxC,SAAS,iBAAiB,QAAoC;AACnE,QAAM,MAAM,uBAAuB,gBAAgB;AACnD,QAAM,UAAU,iBAAiB;AAEjC,QAAM,gBAAgB,MAAM;AAAA,IAC1B,MAAM,IAAI,OAAO,WAAS,CAAC,MAAM,WAAW,MAAM,QAAQ,SAAS,MAAM,CAAC;AAAA,IAC1E,CAAC,KAAK,MAAM;AAAA,EACd;AAEA,QAAM,CAAC,WAAW,YAAY,IAAI,MAAM,SAAkC,CAAC,CAAC;AAE5E,QAAM,eAAe,MAAM,YAAY,CAAC,KAAa,WAAoB;AACvE,iBAAa,cAAa,SAAS,GAAG,MAAM,SAAS,WAAW,iCAAK,WAAL,EAAe,CAAC,GAAG,GAAG,OAAO,EAAE;AAAA,EACjG,GAAG,CAAC,CAAC;AAEL,QAAM,WAAW,MAAM;AAAA,IACrB,CAAC,iBAAqC,QAAQ,UAAU,UAAU,YAAY,CAAC,CAAC;AAAA,IAChF,CAAC,SAAS;AAAA,EACZ;AAEA,QAAM,SACJ,oBAAC,SAAI,WAAU,UACZ,wBAAc,IAAI,kBACjB;AAAA,IAAC;AAAA;AAAA,MAEC;AAAA,MACA,QAAQ,QAAQ,aAAa,QAAQ;AAAA,MACrC,gBAAgB;AAAA,MAChB,YAAY;AAAA;AAAA,IAJP,SAAS,UAAU,YAAY,CAAC;AAAA,EAKvC,CACD,GACH;AAGF,SAAO,EAAE,eAAe,SAAS,UAAU,OAAO;AACpD;","names":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"viewerAccess.d.ts","sourceRoot":"","sources":["../../../../src/core/components/viewers/viewerAccess.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"viewerAccess.d.ts","sourceRoot":"","sources":["../../../../src/core/components/viewers/viewerAccess.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,YAAY,EAAE,SAAS,EAAe,MAAM,qBAAqB,CAAA;AAE/E;;;GAGG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,SAAS,EAAE,UAAU,EAAE,YAAY,CAAC,YAAY,CAAC,GAAG,OAAO,CAKlG"}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { parsePluginViewerKey } from "../../plugins/host/pluginViewerKey";
|
|
2
|
+
import { ALWAYS_AVAILABLE_VIEWERS } from "../../utils/appContent";
|
|
2
3
|
function isViewerAllowed(viewer, appContent) {
|
|
3
4
|
if (parsePluginViewerKey(viewer) !== null) return true;
|
|
5
|
+
if (ALWAYS_AVAILABLE_VIEWERS.includes(viewer)) return true;
|
|
4
6
|
return appContent.length === 0 || appContent.includes(viewer);
|
|
5
7
|
}
|
|
6
8
|
export {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/core/components/viewers/viewerAccess.ts"],"sourcesContent":["// SPDX-License-Identifier: AGPL-3.0-or-later\n// Copyright (C) 2025 Collab Digital Twins\n\nimport { parsePluginViewerKey } from '../../plugins/host/pluginViewerKey'\n\nimport type { Organization, ViewerKey, ViewerNames } from '../../types/dbTypes'\n\n/**\n * Whether this organization may show the requested viewer. `appContent` is a Prisma enum and\n * can never hold a plugin key, so a plugin page is gated by enablement instead.\n */\nexport function isViewerAllowed(viewer: ViewerKey, appContent: Organization['appContent']): boolean {\n if (parsePluginViewerKey(viewer) !== null) return true\n\n return appContent.length === 0 || appContent.includes(viewer as ViewerNames)\n}\n"],"mappings":"AAGA,SAAS,4BAA4B;
|
|
1
|
+
{"version":3,"sources":["../../../../src/core/components/viewers/viewerAccess.ts"],"sourcesContent":["// SPDX-License-Identifier: AGPL-3.0-or-later\n// Copyright (C) 2025 Collab Digital Twins\n\nimport { parsePluginViewerKey } from '../../plugins/host/pluginViewerKey'\nimport { ALWAYS_AVAILABLE_VIEWERS } from '../../utils/appContent'\n\nimport type { Organization, ViewerKey, ViewerNames } from '../../types/dbTypes'\n\n/**\n * Whether this organization may show the requested viewer. `appContent` is a Prisma enum and\n * can never hold a plugin key, so a plugin page is gated by enablement instead.\n */\nexport function isViewerAllowed(viewer: ViewerKey, appContent: Organization['appContent']): boolean {\n if (parsePluginViewerKey(viewer) !== null) return true\n if (ALWAYS_AVAILABLE_VIEWERS.includes(viewer as ViewerNames)) return true\n\n return appContent.length === 0 || appContent.includes(viewer as ViewerNames)\n}\n"],"mappings":"AAGA,SAAS,4BAA4B;AACrC,SAAS,gCAAgC;AAQlC,SAAS,gBAAgB,QAAmB,YAAiD;AAClG,MAAI,qBAAqB,MAAM,MAAM,KAAM,QAAO;AAClD,MAAI,yBAAyB,SAAS,MAAqB,EAAG,QAAO;AAErE,SAAO,WAAW,WAAW,KAAK,WAAW,SAAS,MAAqB;AAC7E;","names":[]}
|
|
@@ -1,16 +1,8 @@
|
|
|
1
1
|
import type { PluginInstallation, PluginRecord, PluginUserSetting } from '../../types/plugins';
|
|
2
2
|
import type { ApiAdapter } from '../ports/apiAdapter';
|
|
3
3
|
/**
|
|
4
|
-
* Enablement state for the plugins page.
|
|
5
|
-
*
|
|
6
|
-
* Both lists are small — bounded by the number of plugins a deployment has — so
|
|
7
|
-
* they are fetched whole and mutated by revalidation rather than by patching the
|
|
8
|
-
* cache. The page applies its own optimistic override on top, so the switch does
|
|
9
|
-
* not wait for the round trip.
|
|
10
|
-
*
|
|
11
|
-
* Writes are plain async functions, not `useSWRMutation`: every one of them is a
|
|
12
|
-
* per-plugin upsert triggered from a switch, and the mutation-hook-per-key shape
|
|
13
|
-
* the other domains use would mean one hook per plugin per control.
|
|
4
|
+
* Enablement state for the plugins page. Both lists are bounded by the plugin count, so they are
|
|
5
|
+
* fetched whole and revalidated; writes are plain async functions, not one `useSWRMutation` per plugin.
|
|
14
6
|
*/
|
|
15
7
|
export declare function createPluginHooks(adapter: ApiAdapter): {
|
|
16
8
|
usePluginInstallations: () => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createPluginHooks.d.ts","sourceRoot":"","sources":["../../../../src/core/hooks/plugins/createPluginHooks.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,kBAAkB,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAA;AAC9F,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAA;AAKrD
|
|
1
|
+
{"version":3,"file":"createPluginHooks.d.ts","sourceRoot":"","sources":["../../../../src/core/hooks/plugins/createPluginHooks.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,kBAAkB,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAA;AAC9F,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAA;AAKrD;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,UAAU;;;;;;;;;;;iCA4Cf,MAAM,cAAc,MAAM;;;;QAe1D,4EAA4E;yBACrD,MAAM,SAAS,OAAO;4BAKnB,MAAM;;;kCApCF,MAAM,SAAS,OAAO,CAAC,kBAAkB,CAAC;qCAIvC,MAAM;iCAIV,MAAM,SAAS,OAAO,CAAC,iBAAiB,CAAC;;EAoC3E"}
|
|
@@ -49,8 +49,7 @@ function createPluginHooks(adapter) {
|
|
|
49
49
|
records: data != null ? data : [],
|
|
50
50
|
isLoading,
|
|
51
51
|
isError: error,
|
|
52
|
-
// Arrow properties, not method shorthand: callers destructure these
|
|
53
|
-
// method shorthand would imply a `this` they do not have.
|
|
52
|
+
// Arrow properties, not method shorthand: callers destructure these and have no `this`.
|
|
54
53
|
/** Create or replace one document. `key` is the plugin's own identifier. */
|
|
55
54
|
put: async (recordKey, value) => {
|
|
56
55
|
const saved = await adapter.putPluginRecord(pluginId, collection, recordKey, value);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/core/hooks/plugins/createPluginHooks.ts"],"sourcesContent":["// SPDX-License-Identifier: AGPL-3.0-or-later\n// Copyright (C) 2025 Collab Digital Twins\n\nimport useSWR, { mutate } from 'swr'\n\nimport type { PluginInstallation, PluginRecord, PluginUserSetting } from '../../types/plugins'\nimport type { ApiAdapter } from '../ports/apiAdapter'\n\nconst INSTALLATIONS = ['pluginInstallations'] as const\nconst USER_SETTINGS = ['pluginUserSettings'] as const\n\n/**\n * Enablement state for the plugins page
|
|
1
|
+
{"version":3,"sources":["../../../../src/core/hooks/plugins/createPluginHooks.ts"],"sourcesContent":["// SPDX-License-Identifier: AGPL-3.0-or-later\n// Copyright (C) 2025 Collab Digital Twins\n\nimport useSWR, { mutate } from 'swr'\n\nimport type { PluginInstallation, PluginRecord, PluginUserSetting } from '../../types/plugins'\nimport type { ApiAdapter } from '../ports/apiAdapter'\n\nconst INSTALLATIONS = ['pluginInstallations'] as const\nconst USER_SETTINGS = ['pluginUserSettings'] as const\n\n/**\n * Enablement state for the plugins page. Both lists are bounded by the plugin count, so they are\n * fetched whole and revalidated; writes are plain async functions, not one `useSWRMutation` per plugin.\n */\nexport function createPluginHooks(adapter: ApiAdapter) {\n const usePluginInstallations = () => {\n const { data, error, isLoading } = useSWR<PluginInstallation[]>(\n INSTALLATIONS,\n () => adapter.listPluginInstallations(),\n )\n\n return {\n installations: data ?? [],\n isLoading,\n isError: error,\n }\n }\n\n const usePluginUserSettings = () => {\n const { data, error, isLoading } = useSWR<PluginUserSetting[]>(\n USER_SETTINGS,\n () => adapter.listPluginUserSettings(),\n )\n\n return {\n userSettings: data ?? [],\n isLoading,\n isError: error,\n }\n }\n\n // Not a hook: the plugins page hands these to its `PluginsActions` port and calls them from event handlers.\n const pluginActions = {\n async setInstallation(pluginId: string, patch: Partial<PluginInstallation>) {\n await adapter.upsertPluginInstallation(pluginId, patch)\n await mutate(INSTALLATIONS)\n },\n async removeInstallation(pluginId: string) {\n await adapter.deletePluginInstallation(pluginId)\n await mutate(INSTALLATIONS)\n },\n async setUserSetting(pluginId: string, patch: Partial<PluginUserSetting>) {\n await adapter.upsertPluginUserSetting(pluginId, patch)\n await mutate(USER_SETTINGS)\n },\n }\n\n // `pluginId` comes from the plugin scope at the call site, never from the plugin itself.\n const usePluginRecords = (pluginId: string, collection: string) => {\n const key = pluginId && collection ? ['pluginRecords', pluginId, collection] as const : null\n\n const { data, error, isLoading } = useSWR<PluginRecord[]>(\n key,\n () => adapter.listPluginRecords(pluginId, collection),\n )\n\n const revalidate = () => (key ? mutate(key) : Promise.resolve())\n\n return {\n records: data ?? [],\n isLoading,\n isError: error,\n // Arrow properties, not method shorthand: callers destructure these and have no `this`.\n /** Create or replace one document. `key` is the plugin's own identifier. */\n put: async (recordKey: string, value: unknown) => {\n const saved = await adapter.putPluginRecord(pluginId, collection, recordKey, value)\n await revalidate()\n return saved\n },\n remove: async (recordKey: string) => {\n await adapter.deletePluginRecord(pluginId, collection, recordKey)\n await revalidate()\n },\n }\n }\n\n return { usePluginInstallations, usePluginUserSettings, usePluginRecords, pluginActions }\n}\n"],"mappings":"AAGA,OAAO,UAAU,cAAc;AAK/B,MAAM,gBAAgB,CAAC,qBAAqB;AAC5C,MAAM,gBAAgB,CAAC,oBAAoB;AAMpC,SAAS,kBAAkB,SAAqB;AACrD,QAAM,yBAAyB,MAAM;AACnC,UAAM,EAAE,MAAM,OAAO,UAAU,IAAI;AAAA,MACjC;AAAA,MACA,MAAM,QAAQ,wBAAwB;AAAA,IACxC;AAEA,WAAO;AAAA,MACL,eAAe,sBAAQ,CAAC;AAAA,MACxB;AAAA,MACA,SAAS;AAAA,IACX;AAAA,EACF;AAEA,QAAM,wBAAwB,MAAM;AAClC,UAAM,EAAE,MAAM,OAAO,UAAU,IAAI;AAAA,MACjC;AAAA,MACA,MAAM,QAAQ,uBAAuB;AAAA,IACvC;AAEA,WAAO;AAAA,MACL,cAAc,sBAAQ,CAAC;AAAA,MACvB;AAAA,MACA,SAAS;AAAA,IACX;AAAA,EACF;AAGA,QAAM,gBAAgB;AAAA,IACpB,MAAM,gBAAgB,UAAkB,OAAoC;AAC1E,YAAM,QAAQ,yBAAyB,UAAU,KAAK;AACtD,YAAM,OAAO,aAAa;AAAA,IAC5B;AAAA,IACA,MAAM,mBAAmB,UAAkB;AACzC,YAAM,QAAQ,yBAAyB,QAAQ;AAC/C,YAAM,OAAO,aAAa;AAAA,IAC5B;AAAA,IACA,MAAM,eAAe,UAAkB,OAAmC;AACxE,YAAM,QAAQ,wBAAwB,UAAU,KAAK;AACrD,YAAM,OAAO,aAAa;AAAA,IAC5B;AAAA,EACF;AAGA,QAAM,mBAAmB,CAAC,UAAkB,eAAuB;AACjE,UAAM,MAAM,YAAY,aAAa,CAAC,iBAAiB,UAAU,UAAU,IAAa;AAExF,UAAM,EAAE,MAAM,OAAO,UAAU,IAAI;AAAA,MACjC;AAAA,MACA,MAAM,QAAQ,kBAAkB,UAAU,UAAU;AAAA,IACtD;AAEA,UAAM,aAAa,MAAO,MAAM,OAAO,GAAG,IAAI,QAAQ,QAAQ;AAE9D,WAAO;AAAA,MACL,SAAS,sBAAQ,CAAC;AAAA,MAClB;AAAA,MACA,SAAS;AAAA;AAAA;AAAA,MAGT,KAAK,OAAO,WAAmB,UAAmB;AAChD,cAAM,QAAQ,MAAM,QAAQ,gBAAgB,UAAU,YAAY,WAAW,KAAK;AAClF,cAAM,WAAW;AACjB,eAAO;AAAA,MACT;AAAA,MACA,QAAQ,OAAO,cAAsB;AACnC,cAAM,QAAQ,mBAAmB,UAAU,YAAY,SAAS;AAChE,cAAM,WAAW;AAAA,MACnB;AAAA,IACF;AAAA,EACF;AAEA,SAAO,EAAE,wBAAwB,uBAAuB,kBAAkB,cAAc;AAC1F;","names":[]}
|
|
@@ -447,7 +447,8 @@
|
|
|
447
447
|
"MapLegend": {
|
|
448
448
|
"title": "Legend",
|
|
449
449
|
"titlePlural": "Legends",
|
|
450
|
-
"feedUnavailable": "Feed unavailable"
|
|
450
|
+
"feedUnavailable": "Feed unavailable",
|
|
451
|
+
"feedUnavailableToast": "{title}: the live feed is unreachable right now, so the layer may be missing or out of date."
|
|
451
452
|
},
|
|
452
453
|
"Datasets": {
|
|
453
454
|
"failedFetchError": "Failed to fetch datasets.",
|
|
@@ -934,7 +935,6 @@
|
|
|
934
935
|
"featuresDescription": "Select which features to enable in your instance",
|
|
935
936
|
"viewers3DTitle": "3D Viewers",
|
|
936
937
|
"dataTitle": "Data",
|
|
937
|
-
"viewerMap": "Map",
|
|
938
938
|
"viewerBIM": "BIM",
|
|
939
939
|
"viewerPointCloud": "Point Cloud",
|
|
940
940
|
"dataSites": "Sites",
|
|
@@ -447,7 +447,8 @@
|
|
|
447
447
|
"MapLegend": {
|
|
448
448
|
"title": "Leyenda",
|
|
449
449
|
"titlePlural": "Leyendas",
|
|
450
|
-
"feedUnavailable": "Fuente no disponible"
|
|
450
|
+
"feedUnavailable": "Fuente no disponible",
|
|
451
|
+
"feedUnavailableToast": "{title}: la fuente en vivo no está disponible en este momento; la capa puede faltar o estar desactualizada."
|
|
451
452
|
},
|
|
452
453
|
"Datasets": {
|
|
453
454
|
"failedFetchError": "Error al obtener conjuntos de datos.",
|
|
@@ -934,7 +935,6 @@
|
|
|
934
935
|
"featuresDescription": "Seleccione las funcionalidades a habilitar en su instancia",
|
|
935
936
|
"viewers3DTitle": "Visores 3D",
|
|
936
937
|
"dataTitle": "Datos",
|
|
937
|
-
"viewerMap": "Mapa",
|
|
938
938
|
"viewerBIM": "BIM",
|
|
939
939
|
"viewerPointCloud": "Nube de puntos",
|
|
940
940
|
"dataSites": "Sitios",
|
|
@@ -447,7 +447,8 @@
|
|
|
447
447
|
"MapLegend": {
|
|
448
448
|
"title": "Légende",
|
|
449
449
|
"titlePlural": "Légendes",
|
|
450
|
-
"feedUnavailable": "Flux indisponible"
|
|
450
|
+
"feedUnavailable": "Flux indisponible",
|
|
451
|
+
"feedUnavailableToast": "{title} : le flux en direct est inaccessible pour le moment; la couche peut être absente ou périmée."
|
|
451
452
|
},
|
|
452
453
|
"Datasets": {
|
|
453
454
|
"failedFetchError": "Échec de la récupération des ensembles de données.",
|
|
@@ -934,7 +935,6 @@
|
|
|
934
935
|
"featuresDescription": "Sélectionnez les fonctionnalités à activer dans votre instance",
|
|
935
936
|
"viewers3DTitle": "Visionneuses 3D",
|
|
936
937
|
"dataTitle": "Données",
|
|
937
|
-
"viewerMap": "Carte",
|
|
938
938
|
"viewerBIM": "BIM",
|
|
939
939
|
"viewerPointCloud": "Nuage de points",
|
|
940
940
|
"dataSites": "Sites",
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pluginDatasetId.d.ts","sourceRoot":"","sources":["../../../../src/core/plugins/host/pluginDatasetId.ts"],"names":[],"mappings":"AAGA,mGAAmG;AACnG,wBAAgB,eAAe,CAAC,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAG,MAAM,CAEpE"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/core/plugins/host/pluginDatasetId.ts"],"sourcesContent":["// SPDX-License-Identifier: AGPL-3.0-or-later\n// Copyright (C) 2025 Collab Digital Twins\n\n/** The id a plugin dataset carries in the Datasets store, namespaced so no two plugins collide. */\nexport function pluginDatasetId(pluginId: string, id: string): string {\n return `plugin:${pluginId}:${id}`\n}\n"],"mappings":"AAIO,SAAS,gBAAgB,UAAkB,IAAoB;AACpE,SAAO,UAAU,QAAQ,IAAI,EAAE;AACjC;","names":[]}
|