@collabdt/core 0.5.1 → 0.5.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (219) hide show
  1. package/dist/core/components/AppSidebarContent.d.ts +2 -3
  2. package/dist/core/components/AppSidebarContent.d.ts.map +1 -1
  3. package/dist/core/components/AppSidebarContent.js +10 -1
  4. package/dist/core/components/AppSidebarContent.js.map +1 -1
  5. package/dist/core/components/Toolbar.d.ts +2 -3
  6. package/dist/core/components/Toolbar.d.ts.map +1 -1
  7. package/dist/core/components/Toolbar.js.map +1 -1
  8. package/dist/core/components/ui/AppSidebar.d.ts +2 -2
  9. package/dist/core/components/ui/AppSidebar.d.ts.map +1 -1
  10. package/dist/core/components/ui/AppSidebar.js.map +1 -1
  11. package/dist/core/components/ui/Comments/CommentsSection.d.ts.map +1 -1
  12. package/dist/core/components/ui/Comments/CommentsSection.js +10 -9
  13. package/dist/core/components/ui/Comments/CommentsSection.js.map +1 -1
  14. package/dist/core/components/ui/Sensors/SensorsSection.d.ts.map +1 -1
  15. package/dist/core/components/ui/Sensors/SensorsSection.js +24 -23
  16. package/dist/core/components/ui/Sensors/SensorsSection.js.map +1 -1
  17. package/dist/core/components/ui/ViewerSidebar/Shell.js +1 -1
  18. package/dist/core/components/ui/ViewerSidebar/Shell.js.map +1 -1
  19. package/dist/core/components/ui/ViewerSidebar/TabStrip.d.ts +6 -5
  20. package/dist/core/components/ui/ViewerSidebar/TabStrip.d.ts.map +1 -1
  21. package/dist/core/components/ui/ViewerSidebar/TabStrip.js +6 -4
  22. package/dist/core/components/ui/ViewerSidebar/TabStrip.js.map +1 -1
  23. package/dist/core/components/ui/ViewerSidebar/sidebarTabs.d.ts +16 -9
  24. package/dist/core/components/ui/ViewerSidebar/sidebarTabs.d.ts.map +1 -1
  25. package/dist/core/components/ui/ViewerSidebar/sidebarTabs.js.map +1 -1
  26. package/dist/core/components/viewers/Viewer.d.ts.map +1 -1
  27. package/dist/core/components/viewers/Viewer.js +17 -8
  28. package/dist/core/components/viewers/Viewer.js.map +1 -1
  29. package/dist/core/components/viewers/bim/BimViewer.d.ts.map +1 -1
  30. package/dist/core/components/viewers/bim/BimViewer.js +6 -1
  31. package/dist/core/components/viewers/bim/BimViewer.js.map +1 -1
  32. package/dist/core/components/viewers/bim/src/BimSidebar/src/index.d.ts.map +1 -1
  33. package/dist/core/components/viewers/bim/src/BimSidebar/src/index.js +5 -1
  34. package/dist/core/components/viewers/bim/src/BimSidebar/src/index.js.map +1 -1
  35. package/dist/core/components/viewers/bim/src/ElementAppearance.d.ts +10 -1
  36. package/dist/core/components/viewers/bim/src/ElementAppearance.d.ts.map +1 -1
  37. package/dist/core/components/viewers/bim/src/ElementAppearance.js +36 -1
  38. package/dist/core/components/viewers/bim/src/ElementAppearance.js.map +1 -1
  39. package/dist/core/components/viewers/bim/src/ModelsSync.d.ts.map +1 -1
  40. package/dist/core/components/viewers/bim/src/ModelsSync.js +6 -5
  41. package/dist/core/components/viewers/bim/src/ModelsSync.js.map +1 -1
  42. package/dist/core/components/viewers/bim/src/lib/appearanceOverrides.d.ts +12 -1
  43. package/dist/core/components/viewers/bim/src/lib/appearanceOverrides.d.ts.map +1 -1
  44. package/dist/core/components/viewers/bim/src/lib/appearanceOverrides.js +18 -2
  45. package/dist/core/components/viewers/bim/src/lib/appearanceOverrides.js.map +1 -1
  46. package/dist/core/components/viewers/map/MapViewer.d.ts.map +1 -1
  47. package/dist/core/components/viewers/map/MapViewer.js +6 -3
  48. package/dist/core/components/viewers/map/MapViewer.js.map +1 -1
  49. package/dist/core/components/viewers/map/src/MapSidebar/index.d.ts.map +1 -1
  50. package/dist/core/components/viewers/map/src/MapSidebar/index.js +5 -1
  51. package/dist/core/components/viewers/map/src/MapSidebar/index.js.map +1 -1
  52. package/dist/core/components/viewers/map/utils/stringToColour.d.ts +3 -0
  53. package/dist/core/components/viewers/map/utils/stringToColour.d.ts.map +1 -1
  54. package/dist/core/components/viewers/map/utils/stringToColour.js +72 -70
  55. package/dist/core/components/viewers/map/utils/stringToColour.js.map +1 -1
  56. package/dist/core/components/viewers/plugins/src/PluginCard.d.ts.map +1 -1
  57. package/dist/core/components/viewers/plugins/src/PluginCard.js +8 -4
  58. package/dist/core/components/viewers/plugins/src/PluginCard.js.map +1 -1
  59. package/dist/core/components/viewers/pointcloud/src/PointCloudSidebar/index.d.ts.map +1 -1
  60. package/dist/core/components/viewers/pointcloud/src/PointCloudSidebar/index.js +5 -1
  61. package/dist/core/components/viewers/pointcloud/src/PointCloudSidebar/index.js.map +1 -1
  62. package/dist/core/components/viewers/shared/legends/ViewerLegendHost.d.ts +10 -0
  63. package/dist/core/components/viewers/shared/legends/ViewerLegendHost.d.ts.map +1 -0
  64. package/dist/core/components/viewers/{map/legends/MapLegendHost.js → shared/legends/ViewerLegendHost.js} +48 -8
  65. package/dist/core/components/viewers/shared/legends/ViewerLegendHost.js.map +1 -0
  66. package/dist/core/components/viewers/viewerAccess.d.ts +7 -0
  67. package/dist/core/components/viewers/viewerAccess.d.ts.map +1 -0
  68. package/dist/core/components/viewers/viewerAccess.js +9 -0
  69. package/dist/core/components/viewers/viewerAccess.js.map +1 -0
  70. package/dist/core/i18n/messages/en.json +5 -0
  71. package/dist/core/i18n/messages/es.json +5 -0
  72. package/dist/core/i18n/messages/fr.json +5 -0
  73. package/dist/core/plugins/hello-bim/components/SpaceDialog.d.ts +13 -0
  74. package/dist/core/plugins/hello-bim/components/SpaceDialog.d.ts.map +1 -0
  75. package/dist/core/plugins/hello-bim/components/SpaceDialog.js +80 -0
  76. package/dist/core/plugins/hello-bim/components/SpaceDialog.js.map +1 -0
  77. package/dist/core/plugins/hello-bim/components/SpacesLegend.d.ts +11 -0
  78. package/dist/core/plugins/hello-bim/components/SpacesLegend.d.ts.map +1 -0
  79. package/dist/core/plugins/hello-bim/components/SpacesLegend.js +16 -0
  80. package/dist/core/plugins/hello-bim/components/SpacesLegend.js.map +1 -0
  81. package/dist/core/plugins/hello-bim/components/SpacesTab.d.ts +4 -0
  82. package/dist/core/plugins/hello-bim/components/SpacesTab.d.ts.map +1 -0
  83. package/dist/core/plugins/hello-bim/components/SpacesTab.js +211 -0
  84. package/dist/core/plugins/hello-bim/components/SpacesTab.js.map +1 -0
  85. package/dist/core/plugins/hello-bim/components/SpacesTool.d.ts +8 -0
  86. package/dist/core/plugins/hello-bim/components/SpacesTool.d.ts.map +1 -0
  87. package/dist/core/plugins/hello-bim/components/SpacesTool.js +68 -0
  88. package/dist/core/plugins/hello-bim/components/SpacesTool.js.map +1 -0
  89. package/dist/core/plugins/hello-bim/components/icons.d.ts +13 -0
  90. package/dist/core/plugins/hello-bim/components/icons.d.ts.map +1 -0
  91. package/dist/core/plugins/hello-bim/components/icons.js +52 -0
  92. package/dist/core/plugins/hello-bim/components/icons.js.map +1 -0
  93. package/dist/core/plugins/hello-bim/index.d.ts +2 -6
  94. package/dist/core/plugins/hello-bim/index.d.ts.map +1 -1
  95. package/dist/core/plugins/hello-bim/index.js +27 -3
  96. package/dist/core/plugins/hello-bim/index.js.map +1 -1
  97. package/dist/core/plugins/hello-bim/manifest.json +97 -31
  98. package/dist/core/plugins/hello-bim/spaces.d.ts +57 -0
  99. package/dist/core/plugins/hello-bim/spaces.d.ts.map +1 -0
  100. package/dist/core/plugins/hello-bim/spaces.js +207 -0
  101. package/dist/core/plugins/hello-bim/spaces.js.map +1 -0
  102. package/dist/core/plugins/hello-map/components/MapTool.d.ts +9 -0
  103. package/dist/core/plugins/hello-map/components/MapTool.d.ts.map +1 -0
  104. package/dist/core/plugins/hello-map/components/{HelloMapTool.js → MapTool.js} +30 -11
  105. package/dist/core/plugins/hello-map/components/MapTool.js.map +1 -0
  106. package/dist/core/plugins/hello-map/components/MarkerDialog.d.ts +9 -0
  107. package/dist/core/plugins/hello-map/components/MarkerDialog.d.ts.map +1 -0
  108. package/dist/core/plugins/hello-map/components/MarkerDialog.js +47 -0
  109. package/dist/core/plugins/hello-map/components/MarkerDialog.js.map +1 -0
  110. package/dist/core/plugins/hello-map/components/MarkersLayer.d.ts +8 -0
  111. package/dist/core/plugins/hello-map/components/MarkersLayer.d.ts.map +1 -0
  112. package/dist/core/plugins/hello-map/components/MarkersLayer.js +133 -0
  113. package/dist/core/plugins/hello-map/components/MarkersLayer.js.map +1 -0
  114. package/dist/core/plugins/hello-map/components/MarkersLegend.d.ts +11 -0
  115. package/dist/core/plugins/hello-map/components/MarkersLegend.d.ts.map +1 -0
  116. package/dist/core/plugins/hello-map/components/MarkersLegend.js +20 -0
  117. package/dist/core/plugins/hello-map/components/MarkersLegend.js.map +1 -0
  118. package/dist/core/plugins/hello-map/components/MarkersPage.d.ts +6 -0
  119. package/dist/core/plugins/hello-map/components/MarkersPage.d.ts.map +1 -0
  120. package/dist/core/plugins/hello-map/components/MarkersPage.js +40 -0
  121. package/dist/core/plugins/hello-map/components/MarkersPage.js.map +1 -0
  122. package/dist/core/plugins/hello-map/components/MarkersTab.d.ts +4 -0
  123. package/dist/core/plugins/hello-map/components/MarkersTab.d.ts.map +1 -0
  124. package/dist/core/plugins/hello-map/components/MarkersTab.js +275 -0
  125. package/dist/core/plugins/hello-map/components/MarkersTab.js.map +1 -0
  126. package/dist/core/plugins/hello-map/index.d.ts +2 -5
  127. package/dist/core/plugins/hello-map/index.d.ts.map +1 -1
  128. package/dist/core/plugins/hello-map/index.js +43 -3
  129. package/dist/core/plugins/hello-map/index.js.map +1 -1
  130. package/dist/core/plugins/hello-map/manifest.json +85 -12
  131. package/dist/core/plugins/hello-map/markers.d.ts +32 -0
  132. package/dist/core/plugins/hello-map/markers.d.ts.map +1 -0
  133. package/dist/core/plugins/hello-map/markers.js +143 -0
  134. package/dist/core/plugins/hello-map/markers.js.map +1 -0
  135. package/dist/core/plugins/host/PluginDataPageHost.d.ts +10 -0
  136. package/dist/core/plugins/host/PluginDataPageHost.d.ts.map +1 -0
  137. package/dist/core/plugins/host/PluginDataPageHost.js +142 -0
  138. package/dist/core/plugins/host/PluginDataPageHost.js.map +1 -0
  139. package/dist/core/plugins/host/PluginDialogHost.d.ts +7 -0
  140. package/dist/core/plugins/host/PluginDialogHost.d.ts.map +1 -0
  141. package/dist/core/plugins/host/PluginDialogHost.js +80 -0
  142. package/dist/core/plugins/host/PluginDialogHost.js.map +1 -0
  143. package/dist/core/plugins/host/PluginMapLayerHost.d.ts +6 -0
  144. package/dist/core/plugins/host/PluginMapLayerHost.d.ts.map +1 -0
  145. package/dist/core/plugins/host/PluginMapLayerHost.js +26 -0
  146. package/dist/core/plugins/host/PluginMapLayerHost.js.map +1 -0
  147. package/dist/core/plugins/host/dialogs.d.ts +25 -0
  148. package/dist/core/plugins/host/dialogs.d.ts.map +1 -0
  149. package/dist/core/plugins/host/dialogs.js +50 -0
  150. package/dist/core/plugins/host/dialogs.js.map +1 -0
  151. package/dist/core/plugins/host/host.d.ts.map +1 -1
  152. package/dist/core/plugins/host/host.js +2 -0
  153. package/dist/core/plugins/host/host.js.map +1 -1
  154. package/dist/core/plugins/host/pluginState.d.ts +28 -0
  155. package/dist/core/plugins/host/pluginState.d.ts.map +1 -0
  156. package/dist/core/plugins/host/pluginState.js +49 -0
  157. package/dist/core/plugins/host/pluginState.js.map +1 -0
  158. package/dist/core/plugins/host/pluginViewerKey.d.ts +13 -0
  159. package/dist/core/plugins/host/pluginViewerKey.d.ts.map +1 -0
  160. package/dist/core/plugins/host/pluginViewerKey.js +18 -0
  161. package/dist/core/plugins/host/pluginViewerKey.js.map +1 -0
  162. package/dist/core/plugins/host/provider.d.ts.map +1 -1
  163. package/dist/core/plugins/host/provider.js +2 -1
  164. package/dist/core/plugins/host/provider.js.map +1 -1
  165. package/dist/core/plugins/host/runtimeShims.d.ts.map +1 -1
  166. package/dist/core/plugins/host/runtimeShims.js +23 -1
  167. package/dist/core/plugins/host/runtimeShims.js.map +1 -1
  168. package/dist/core/plugins/host/usePluginDataPages.d.ts +15 -0
  169. package/dist/core/plugins/host/usePluginDataPages.d.ts.map +1 -0
  170. package/dist/core/plugins/host/usePluginDataPages.js +22 -0
  171. package/dist/core/plugins/host/usePluginDataPages.js.map +1 -0
  172. package/dist/core/plugins/host/usePluginViewerTabs.d.ts +11 -0
  173. package/dist/core/plugins/host/usePluginViewerTabs.d.ts.map +1 -0
  174. package/dist/core/plugins/host/usePluginViewerTabs.js +41 -0
  175. package/dist/core/plugins/host/usePluginViewerTabs.js.map +1 -0
  176. package/dist/core/plugins/sdk/bimViewer.d.ts +29 -13
  177. package/dist/core/plugins/sdk/bimViewer.d.ts.map +1 -1
  178. package/dist/core/plugins/sdk/bimViewer.js +17 -1
  179. package/dist/core/plugins/sdk/bimViewer.js.map +1 -1
  180. package/dist/core/plugins/sdk/index.d.ts +1 -0
  181. package/dist/core/plugins/sdk/index.d.ts.map +1 -1
  182. package/dist/core/plugins/sdk/index.js +4 -1
  183. package/dist/core/plugins/sdk/index.js.map +1 -1
  184. package/dist/core/plugins/sdk/messages.d.ts +6 -0
  185. package/dist/core/plugins/sdk/messages.d.ts.map +1 -1
  186. package/dist/core/plugins/sdk/messages.js +11 -0
  187. package/dist/core/plugins/sdk/messages.js.map +1 -1
  188. package/dist/core/plugins/sdk/state.d.ts +6 -0
  189. package/dist/core/plugins/sdk/state.d.ts.map +1 -0
  190. package/dist/core/plugins/sdk/state.js +30 -0
  191. package/dist/core/plugins/sdk/state.js.map +1 -0
  192. package/dist/core/plugins/sdk/types.d.ts +55 -10
  193. package/dist/core/plugins/sdk/types.d.ts.map +1 -1
  194. package/dist/core/plugins/sdk/types.js +7 -3
  195. package/dist/core/plugins/sdk/types.js.map +1 -1
  196. package/dist/core/plugins/sdk/ui.d.ts +12 -0
  197. package/dist/core/plugins/sdk/ui.d.ts.map +1 -0
  198. package/dist/core/plugins/sdk/ui.js +16 -0
  199. package/dist/core/plugins/sdk/ui.js.map +1 -0
  200. package/dist/core/store/CombineProviders.d.ts.map +1 -1
  201. package/dist/core/store/CombineProviders.js +6 -2
  202. package/dist/core/store/CombineProviders.js.map +1 -1
  203. package/dist/core/store/Menus/reducer.d.ts +5 -3
  204. package/dist/core/store/Menus/reducer.d.ts.map +1 -1
  205. package/dist/core/store/Menus/reducer.js.map +1 -1
  206. package/dist/core/types/dbTypes.d.ts +5 -0
  207. package/dist/core/types/dbTypes.d.ts.map +1 -1
  208. package/dist/core/types/dbTypes.js.map +1 -1
  209. package/package.json +3 -1
  210. package/dist/core/components/viewers/map/legends/MapLegendHost.d.ts +0 -10
  211. package/dist/core/components/viewers/map/legends/MapLegendHost.d.ts.map +0 -1
  212. package/dist/core/components/viewers/map/legends/MapLegendHost.js.map +0 -1
  213. package/dist/core/plugins/hello-bim/components/HelloBimTool.d.ts +0 -18
  214. package/dist/core/plugins/hello-bim/components/HelloBimTool.d.ts.map +0 -1
  215. package/dist/core/plugins/hello-bim/components/HelloBimTool.js +0 -142
  216. package/dist/core/plugins/hello-bim/components/HelloBimTool.js.map +0 -1
  217. package/dist/core/plugins/hello-map/components/HelloMapTool.d.ts +0 -14
  218. package/dist/core/plugins/hello-map/components/HelloMapTool.d.ts.map +0 -1
  219. package/dist/core/plugins/hello-map/components/HelloMapTool.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/core/plugins/host/host.ts"],"sourcesContent":["// SPDX-License-Identifier: AGPL-3.0-or-later\r\n// Copyright (C) 2025 Collab Digital Twins\r\n\r\nimport { validateManifest } from '../sdk/types'\r\nimport { PLUGIN_HOST_API } from '../sdk/version'\r\n\r\nimport { createPluginContext } from './context'\r\nimport { PluginActivationError, PluginHostApiError, PluginManifestError } from './errors'\r\n\r\nimport type { PluginRegistry } from './registry'\r\nimport type { PluginManifest, PluginEntry, PluginContext } from '../sdk/types'\r\n\r\ntype PluginStatus = 'active' | 'inactive' | 'errored'\r\n\r\ninterface LoadedPlugin {\r\n manifest: PluginManifest\r\n entry: PluginEntry\r\n /** Null when the plugin was rejected before a context could be created. */\r\n context: PluginContext | null\r\n status: PluginStatus\r\n /** Set when status is 'errored', so the plugins page can show the reason. */\r\n error?: string\r\n}\r\n\r\nexport class PluginHost {\r\n private plugins: Map<string, LoadedPlugin> = new Map()\r\n\r\n constructor(private registry: PluginRegistry) {}\r\n\r\n /**\r\n * Validate, then activate. Rejection is recorded as an `errored` plugin rather than\r\n * thrown: the caller is loading a list, and one bad plugin must not stop the rest.\r\n */\r\n async loadPlugin(\r\n manifest: PluginManifest,\r\n entry: PluginEntry,\r\n config: Record<string, unknown>,\r\n ): Promise<void> {\r\n // Third-party input from here on, and `slug` becomes the map key and the\r\n // context's identity, so validate before anything else reads it.\r\n const { valid, errors } = validateManifest(manifest)\r\n const slug = typeof manifest?.slug === 'string' && manifest.slug ? manifest.slug : '<invalid>'\r\n\r\n if (!valid) {\r\n this.reject(slug, manifest, entry, new PluginManifestError(slug, errors))\r\n return\r\n }\r\n\r\n if (manifest.hostApi === undefined) {\r\n console.warn(\r\n `Plugin \"${slug}\" does not declare \"hostApi\" in its manifest. Assuming ${PLUGIN_HOST_API}; declare it so a future breaking change fails to load instead of failing to render.`,\r\n )\r\n } else if (manifest.hostApi !== PLUGIN_HOST_API) {\r\n this.reject(slug, manifest, entry, new PluginHostApiError(slug, manifest.hostApi, PLUGIN_HOST_API))\r\n return\r\n }\r\n\r\n const context = createPluginContext({\r\n pluginId: slug,\r\n capabilities: manifest.capabilities,\r\n config,\r\n registry: this.registry,\r\n })\r\n\r\n const loaded: LoadedPlugin = {\r\n manifest,\r\n entry,\r\n context,\r\n status: 'inactive',\r\n }\r\n\r\n try {\r\n await entry.activate(context)\r\n loaded.status = 'active'\r\n } catch (err) {\r\n loaded.status = 'errored'\r\n const error = new PluginActivationError(slug, err as Error)\r\n loaded.error = error.message\r\n console.error(error.message)\r\n // It may have registered before throwing; drop those so it is all-or-nothing.\r\n this.registry.deregisterAll(slug)\r\n }\r\n\r\n this.plugins.set(slug, loaded)\r\n }\r\n\r\n async unloadPlugin(slug: string): Promise<void> {\r\n const loaded = this.plugins.get(slug)\r\n if (!loaded) return\r\n\r\n try {\r\n if (loaded.entry.deactivate && loaded.context) {\r\n await loaded.entry.deactivate(loaded.context)\r\n }\r\n } catch (err) {\r\n console.error(`Plugin \"${slug}\" deactivate error:`, err)\r\n }\r\n\r\n this.registry.deregisterAll(slug)\r\n loaded.status = 'inactive'\r\n }\r\n\r\n getStatus(slug: string): PluginStatus | undefined {\r\n return this.plugins.get(slug)?.status\r\n }\r\n\r\n getError(slug: string): string | undefined {\r\n return this.plugins.get(slug)?.error\r\n }\r\n\r\n // Keyed off the map, not `manifest.slug`: a plugin rejected for an invalid manifest\r\n // may have no usable slug of its own.\r\n listPlugins(): Array<{ slug: string; status: PluginStatus; error?: string }> {\r\n return Array.from(this.plugins, ([slug, p]) => ({\r\n slug,\r\n status: p.status,\r\n ...(p.error ? { error: p.error } : {}),\r\n }))\r\n }\r\n\r\n private reject(\r\n slug: string,\r\n manifest: PluginManifest,\r\n entry: PluginEntry,\r\n error: Error,\r\n ): void {\r\n console.error(error.message)\r\n this.plugins.set(slug, {\r\n manifest,\r\n entry,\r\n context: null,\r\n status: 'errored',\r\n error: error.message,\r\n })\r\n }\r\n}\r\n"],"mappings":";;;;;;;;;;;;;;;;AAGA,SAAS,wBAAwB;AACjC,SAAS,uBAAuB;AAEhC,SAAS,2BAA2B;AACpC,SAAS,uBAAuB,oBAAoB,2BAA2B;AAiBxE,MAAM,WAAW;AAAA,EAGtB,YAAoB,UAA0B;AAA1B;AAFpB,SAAQ,UAAqC,oBAAI,IAAI;AAAA,EAEN;AAAA;AAAA;AAAA;AAAA;AAAA,EAM/C,MAAM,WACJ,UACA,OACA,QACe;AAGf,UAAM,EAAE,OAAO,OAAO,IAAI,iBAAiB,QAAQ;AACnD,UAAM,OAAO,QAAO,qCAAU,UAAS,YAAY,SAAS,OAAO,SAAS,OAAO;AAEnF,QAAI,CAAC,OAAO;AACV,WAAK,OAAO,MAAM,UAAU,OAAO,IAAI,oBAAoB,MAAM,MAAM,CAAC;AACxE;AAAA,IACF;AAEA,QAAI,SAAS,YAAY,QAAW;AAClC,cAAQ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,EACjC;AAAA;AAAA;AAAA,EAIA,cAA6E;AAC3E,WAAO,MAAM,KAAK,KAAK,SAAS,CAAC,CAAC,MAAM,CAAC,MAAO;AAAA,MAC9C;AAAA,MACA,QAAQ,EAAE;AAAA,OACN,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,IAAI,CAAC,EACpC;AAAA,EACJ;AAAA,EAEQ,OACN,MACA,UACA,OACA,OACM;AACN,YAAQ,MAAM,MAAM,OAAO;AAC3B,SAAK,QAAQ,IAAI,MAAM;AAAA,MACrB;AAAA,MACA;AAAA,MACA,SAAS;AAAA,MACT,QAAQ;AAAA,MACR,OAAO,MAAM;AAAA,IACf,CAAC;AAAA,EACH;AACF;","names":[]}
1
+ {"version":3,"sources":["../../../../src/core/plugins/host/host.ts"],"sourcesContent":["// SPDX-License-Identifier: AGPL-3.0-or-later\r\n// Copyright (C) 2025 Collab Digital Twins\r\n\r\nimport { validateManifest } from '../sdk/types'\r\nimport { PLUGIN_HOST_API } from '../sdk/version'\r\n\r\nimport { createPluginContext } from './context'\r\nimport { PluginActivationError, PluginHostApiError, PluginManifestError } from './errors'\r\nimport { pluginStateStore } from './pluginState'\r\n\r\nimport type { PluginRegistry } from './registry'\r\nimport type { PluginManifest, PluginEntry, PluginContext } from '../sdk/types'\r\n\r\ntype PluginStatus = 'active' | 'inactive' | 'errored'\r\n\r\ninterface LoadedPlugin {\r\n manifest: PluginManifest\r\n entry: PluginEntry\r\n /** Null when the plugin was rejected before a context could be created. */\r\n context: PluginContext | null\r\n status: PluginStatus\r\n /** Set when status is 'errored', so the plugins page can show the reason. */\r\n error?: string\r\n}\r\n\r\nexport class PluginHost {\r\n private plugins: Map<string, LoadedPlugin> = new Map()\r\n\r\n constructor(private registry: PluginRegistry) {}\r\n\r\n /**\r\n * Validate, then activate. Rejection is recorded as an `errored` plugin rather than\r\n * thrown: the caller is loading a list, and one bad plugin must not stop the rest.\r\n */\r\n async loadPlugin(\r\n manifest: PluginManifest,\r\n entry: PluginEntry,\r\n config: Record<string, unknown>,\r\n ): Promise<void> {\r\n // Third-party input from here on, and `slug` becomes the map key and the\r\n // context's identity, so validate before anything else reads it.\r\n const { valid, errors } = validateManifest(manifest)\r\n const slug = typeof manifest?.slug === 'string' && manifest.slug ? manifest.slug : '<invalid>'\r\n\r\n if (!valid) {\r\n this.reject(slug, manifest, entry, new PluginManifestError(slug, errors))\r\n return\r\n }\r\n\r\n if (manifest.hostApi === undefined) {\r\n console.warn(\r\n `Plugin \"${slug}\" does not declare \"hostApi\" in its manifest. Assuming ${PLUGIN_HOST_API}; declare it so a future breaking change fails to load instead of failing to render.`,\r\n )\r\n } else if (manifest.hostApi !== PLUGIN_HOST_API) {\r\n this.reject(slug, manifest, entry, new PluginHostApiError(slug, manifest.hostApi, PLUGIN_HOST_API))\r\n return\r\n }\r\n\r\n const context = createPluginContext({\r\n pluginId: slug,\r\n capabilities: manifest.capabilities,\r\n config,\r\n registry: this.registry,\r\n })\r\n\r\n const loaded: LoadedPlugin = {\r\n manifest,\r\n entry,\r\n context,\r\n status: 'inactive',\r\n }\r\n\r\n try {\r\n await entry.activate(context)\r\n loaded.status = 'active'\r\n } catch (err) {\r\n loaded.status = 'errored'\r\n const error = new PluginActivationError(slug, err as Error)\r\n loaded.error = error.message\r\n console.error(error.message)\r\n // It may have registered before throwing; drop those so it is all-or-nothing.\r\n this.registry.deregisterAll(slug)\r\n }\r\n\r\n this.plugins.set(slug, loaded)\r\n }\r\n\r\n async unloadPlugin(slug: string): Promise<void> {\r\n const loaded = this.plugins.get(slug)\r\n if (!loaded) return\r\n\r\n try {\r\n if (loaded.entry.deactivate && loaded.context) {\r\n await loaded.entry.deactivate(loaded.context)\r\n }\r\n } catch (err) {\r\n console.error(`Plugin \"${slug}\" deactivate error:`, err)\r\n }\r\n\r\n this.registry.deregisterAll(slug)\r\n pluginStateStore.clear(slug)\r\n loaded.status = 'inactive'\r\n }\r\n\r\n getStatus(slug: string): PluginStatus | undefined {\r\n return this.plugins.get(slug)?.status\r\n }\r\n\r\n getError(slug: string): string | undefined {\r\n return this.plugins.get(slug)?.error\r\n }\r\n\r\n // Keyed off the map, not `manifest.slug`: a plugin rejected for an invalid manifest\r\n // may have no usable slug of its own.\r\n listPlugins(): Array<{ slug: string; status: PluginStatus; error?: string }> {\r\n return Array.from(this.plugins, ([slug, p]) => ({\r\n slug,\r\n status: p.status,\r\n ...(p.error ? { error: p.error } : {}),\r\n }))\r\n }\r\n\r\n private reject(\r\n slug: string,\r\n manifest: PluginManifest,\r\n entry: PluginEntry,\r\n error: Error,\r\n ): void {\r\n console.error(error.message)\r\n this.plugins.set(slug, {\r\n manifest,\r\n entry,\r\n context: null,\r\n status: 'errored',\r\n error: error.message,\r\n })\r\n }\r\n}\r\n"],"mappings":";;;;;;;;;;;;;;;;AAGA,SAAS,wBAAwB;AACjC,SAAS,uBAAuB;AAEhC,SAAS,2BAA2B;AACpC,SAAS,uBAAuB,oBAAoB,2BAA2B;AAC/E,SAAS,wBAAwB;AAiB1B,MAAM,WAAW;AAAA,EAGtB,YAAoB,UAA0B;AAA1B;AAFpB,SAAQ,UAAqC,oBAAI,IAAI;AAAA,EAEN;AAAA;AAAA;AAAA;AAAA;AAAA,EAM/C,MAAM,WACJ,UACA,OACA,QACe;AAGf,UAAM,EAAE,OAAO,OAAO,IAAI,iBAAiB,QAAQ;AACnD,UAAM,OAAO,QAAO,qCAAU,UAAS,YAAY,SAAS,OAAO,SAAS,OAAO;AAEnF,QAAI,CAAC,OAAO;AACV,WAAK,OAAO,MAAM,UAAU,OAAO,IAAI,oBAAoB,MAAM,MAAM,CAAC;AACxE;AAAA,IACF;AAEA,QAAI,SAAS,YAAY,QAAW;AAClC,cAAQ;AAAA,QACN,WAAW,IAAI,0DAA0D,eAAe;AAAA,MAC1F;AAAA,IACF,WAAW,SAAS,YAAY,iBAAiB;AAC/C,WAAK,OAAO,MAAM,UAAU,OAAO,IAAI,mBAAmB,MAAM,SAAS,SAAS,eAAe,CAAC;AAClG;AAAA,I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E,QAAQ,EAAE,OAAO,EAAE,MAAM,IAAI,CAAC,EACpC;AAAA,EACJ;AAAA,EAEQ,OACN,MACA,UACA,OACA,OACM;AACN,YAAQ,MAAM,MAAM,OAAO;AAC3B,SAAK,QAAQ,IAAI,MAAM;AAAA,MACrB;AAAA,MACA;AAAA,MACA,SAAS;AAAA,MACT,QAAQ;AAAA,MACR,OAAO,MAAM;AAAA,IACf,CAAC;AAAA,EACH;AACF;","names":[]}
@@ -0,0 +1,28 @@
1
+ type Listener = () => void;
2
+ /**
3
+ * Ephemeral per-plugin state, keyed by plugin and then by the plugin's own key.
4
+ *
5
+ * A plugin's surfaces render in unrelated React subtrees — a map tool, a viewer sidebar tab,
6
+ * a dialog and a data page have no common ancestor below the host — so they cannot share
7
+ * state through context or props. `usePluginStore` is the persisted alternative and costs a
8
+ * server round trip per write, which is wrong for a selection.
9
+ *
10
+ * Module scope rather than a provider, for the same reason: a provider would have to sit
11
+ * above every surface, and the surfaces do not share one.
12
+ */
13
+ declare class PluginStateStore {
14
+ private values;
15
+ private listeners;
16
+ private static scopedKey;
17
+ get<T>(pluginId: string, key: string, initial: T): T;
18
+ set<T>(pluginId: string, key: string, value: T): void;
19
+ subscribe(pluginId: string, key: string, listener: Listener): () => void;
20
+ /**
21
+ * Drops everything one plugin holds. Called when it is disabled or unloaded, so a plugin
22
+ * re-enabled in the same session starts clean rather than resuming a stale selection.
23
+ */
24
+ clear(pluginId: string): void;
25
+ }
26
+ export declare const pluginStateStore: PluginStateStore;
27
+ export {};
28
+ //# sourceMappingURL=pluginState.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pluginState.d.ts","sourceRoot":"","sources":["../../../../src/core/plugins/host/pluginState.ts"],"names":[],"mappings":"AAGA,KAAK,QAAQ,GAAG,MAAM,IAAI,CAAA;AAE1B;;;;;;;;;;GAUG;AACH,cAAM,gBAAgB;IACpB,OAAO,CAAC,MAAM,CAAkC;IAChD,OAAO,CAAC,SAAS,CAAwC;IAEzD,OAAO,CAAC,MAAM,CAAC,SAAS;IAIxB,GAAG,CAAC,CAAC,EAAE,QAAQ,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,GAAG,CAAC;IAKpD,GAAG,CAAC,CAAC,EAAE,QAAQ,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,GAAG,IAAI;IAQrD,SAAS,CAAC,QAAQ,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ,GAAG,MAAM,IAAI;IAaxE;;;OAGG;IACH,KAAK,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI;CAU9B;AAED,eAAO,MAAM,gBAAgB,kBAAyB,CAAA"}
@@ -0,0 +1,49 @@
1
+ class PluginStateStore {
2
+ constructor() {
3
+ this.values = /* @__PURE__ */ new Map();
4
+ this.listeners = /* @__PURE__ */ new Map();
5
+ }
6
+ static scopedKey(pluginId, key) {
7
+ return `${pluginId}\0${key}`;
8
+ }
9
+ get(pluginId, key, initial) {
10
+ const scoped = PluginStateStore.scopedKey(pluginId, key);
11
+ return this.values.has(scoped) ? this.values.get(scoped) : initial;
12
+ }
13
+ set(pluginId, key, value) {
14
+ var _a;
15
+ const scoped = PluginStateStore.scopedKey(pluginId, key);
16
+ if (Object.is(this.values.get(scoped), value)) return;
17
+ this.values.set(scoped, value);
18
+ for (const listener of (_a = this.listeners.get(scoped)) != null ? _a : []) listener();
19
+ }
20
+ subscribe(pluginId, key, listener) {
21
+ var _a;
22
+ const scoped = PluginStateStore.scopedKey(pluginId, key);
23
+ const forKey = (_a = this.listeners.get(scoped)) != null ? _a : /* @__PURE__ */ new Set();
24
+ forKey.add(listener);
25
+ this.listeners.set(scoped, forKey);
26
+ return () => {
27
+ forKey.delete(listener);
28
+ if (forKey.size === 0) this.listeners.delete(scoped);
29
+ };
30
+ }
31
+ /**
32
+ * Drops everything one plugin holds. Called when it is disabled or unloaded, so a plugin
33
+ * re-enabled in the same session starts clean rather than resuming a stale selection.
34
+ */
35
+ clear(pluginId) {
36
+ var _a;
37
+ const prefix = `${pluginId}\0`;
38
+ for (const scoped of [...this.values.keys()]) {
39
+ if (!scoped.startsWith(prefix)) continue;
40
+ this.values.delete(scoped);
41
+ for (const listener of (_a = this.listeners.get(scoped)) != null ? _a : []) listener();
42
+ }
43
+ }
44
+ }
45
+ const pluginStateStore = new PluginStateStore();
46
+ export {
47
+ pluginStateStore
48
+ };
49
+ //# sourceMappingURL=pluginState.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/core/plugins/host/pluginState.ts"],"sourcesContent":["// SPDX-License-Identifier: AGPL-3.0-or-later\n// Copyright (C) 2025 Collab Digital Twins\n\ntype Listener = () => void\n\n/**\n * Ephemeral per-plugin state, keyed by plugin and then by the plugin's own key.\n *\n * A plugin's surfaces render in unrelated React subtrees — a map tool, a viewer sidebar tab,\n * a dialog and a data page have no common ancestor below the host — so they cannot share\n * state through context or props. `usePluginStore` is the persisted alternative and costs a\n * server round trip per write, which is wrong for a selection.\n *\n * Module scope rather than a provider, for the same reason: a provider would have to sit\n * above every surface, and the surfaces do not share one.\n */\nclass PluginStateStore {\n private values: Map<string, unknown> = new Map()\n private listeners: Map<string, Set<Listener>> = new Map()\n\n private static scopedKey(pluginId: string, key: string): string {\n return `${pluginId}\u0000${key}`\n }\n\n get<T>(pluginId: string, key: string, initial: T): T {\n const scoped = PluginStateStore.scopedKey(pluginId, key)\n return this.values.has(scoped) ? (this.values.get(scoped) as T) : initial\n }\n\n set<T>(pluginId: string, key: string, value: T): void {\n const scoped = PluginStateStore.scopedKey(pluginId, key)\n if (Object.is(this.values.get(scoped), value)) return\n\n this.values.set(scoped, value)\n for (const listener of this.listeners.get(scoped) ?? []) listener()\n }\n\n subscribe(pluginId: string, key: string, listener: Listener): () => void {\n const scoped = PluginStateStore.scopedKey(pluginId, key)\n const forKey = this.listeners.get(scoped) ?? new Set<Listener>()\n\n forKey.add(listener)\n this.listeners.set(scoped, forKey)\n\n return () => {\n forKey.delete(listener)\n if (forKey.size === 0) this.listeners.delete(scoped)\n }\n }\n\n /**\n * Drops everything one plugin holds. Called when it is disabled or unloaded, so a plugin\n * re-enabled in the same session starts clean rather than resuming a stale selection.\n */\n clear(pluginId: string): void {\n const prefix = `${pluginId}\u0000`\n\n for (const scoped of [...this.values.keys()]) {\n if (!scoped.startsWith(prefix)) continue\n\n this.values.delete(scoped)\n for (const listener of this.listeners.get(scoped) ?? []) listener()\n }\n }\n}\n\nexport const pluginStateStore = new PluginStateStore()\n"],"mappings":"AAgBA,MAAM,iBAAiB;AAAA,EAAvB;AACE,SAAQ,SAA+B,oBAAI,IAAI;AAC/C,SAAQ,YAAwC,oBAAI,IAAI;AAAA;AAAA,EAExD,OAAe,UAAU,UAAkB,KAAqB;AAC9D,WAAO,GAAG,QAAQ,KAAI,GAAG;AAAA,EAC3B;AAAA,EAEA,IAAO,UAAkB,KAAa,SAAe;AACnD,UAAM,SAAS,iBAAiB,UAAU,UAAU,GAAG;AACvD,WAAO,KAAK,OAAO,IAAI,MAAM,IAAK,KAAK,OAAO,IAAI,MAAM,IAAU;AAAA,EACpE;AAAA,EAEA,IAAO,UAAkB,KAAa,OAAgB;AA7BxD;AA8BI,UAAM,SAAS,iBAAiB,UAAU,UAAU,GAAG;AACvD,QAAI,OAAO,GAAG,KAAK,OAAO,IAAI,MAAM,GAAG,KAAK,EAAG;AAE/C,SAAK,OAAO,IAAI,QAAQ,KAAK;AAC7B,eAAW,aAAY,UAAK,UAAU,IAAI,MAAM,MAAzB,YAA8B,CAAC,EAAG,UAAS;AAAA,EACpE;AAAA,EAEA,UAAU,UAAkB,KAAa,UAAgC;AArC3E;AAsCI,UAAM,SAAS,iBAAiB,UAAU,UAAU,GAAG;AACvD,UAAM,UAAS,UAAK,UAAU,IAAI,MAAM,MAAzB,YAA8B,oBAAI,IAAc;AAE/D,WAAO,IAAI,QAAQ;AACnB,SAAK,UAAU,IAAI,QAAQ,MAAM;AAEjC,WAAO,MAAM;AACX,aAAO,OAAO,QAAQ;AACtB,UAAI,OAAO,SAAS,EAAG,MAAK,UAAU,OAAO,MAAM;AAAA,IACrD;AAAA,EACF;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,MAAM,UAAwB;AAtDhC;AAuDI,UAAM,SAAS,GAAG,QAAQ;AAE1B,eAAW,UAAU,CAAC,GAAG,KAAK,OAAO,KAAK,CAAC,GAAG;AAC5C,UAAI,CAAC,OAAO,WAAW,MAAM,EAAG;AAEhC,WAAK,OAAO,OAAO,MAAM;AACzB,iBAAW,aAAY,UAAK,UAAU,IAAI,MAAM,MAAzB,YAA8B,CAAC,EAAG,UAAS;AAAA,IACpE;AAAA,EACF;AACF;AAEO,MAAM,mBAAmB,IAAI,iBAAiB;","names":[]}
@@ -0,0 +1,13 @@
1
+ import type { ViewerKey } from '../../types/dbTypes';
2
+ export interface PluginViewerTarget {
3
+ pluginId: string;
4
+ pageId: string;
5
+ }
6
+ /**
7
+ * The `viewer` value that routes to one plugin's data page. Namespaced the same way toolbar
8
+ * tool ids already are, so a plugin page and a built-in one can never collide.
9
+ */
10
+ export declare function pluginViewerKey(pluginId: string, pageId: string): ViewerKey;
11
+ /** Null, not a throw, for a built-in or malformed key: this value comes from the URL. */
12
+ export declare function parsePluginViewerKey(key: string | null | undefined): PluginViewerTarget | null;
13
+ //# sourceMappingURL=pluginViewerKey.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pluginViewerKey.d.ts","sourceRoot":"","sources":["../../../../src/core/plugins/host/pluginViewerKey.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAA;AAIpD,MAAM,WAAW,kBAAkB;IACjC,QAAQ,EAAE,MAAM,CAAA;IAChB,MAAM,EAAE,MAAM,CAAA;CACf;AAED;;;GAGG;AACH,wBAAgB,eAAe,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,SAAS,CAE3E;AAED,yFAAyF;AACzF,wBAAgB,oBAAoB,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,kBAAkB,GAAG,IAAI,CAY9F"}
@@ -0,0 +1,18 @@
1
+ const PREFIX = "plugin:";
2
+ function pluginViewerKey(pluginId, pageId) {
3
+ return `${PREFIX}${pluginId}:${pageId}`;
4
+ }
5
+ function parsePluginViewerKey(key) {
6
+ if (typeof key !== "string" || !key.startsWith(PREFIX)) return null;
7
+ const separator = key.indexOf(":", PREFIX.length);
8
+ if (separator === -1) return null;
9
+ const pluginId = key.slice(PREFIX.length, separator);
10
+ const pageId = key.slice(separator + 1);
11
+ if (!pluginId || !pageId) return null;
12
+ return { pluginId, pageId };
13
+ }
14
+ export {
15
+ parsePluginViewerKey,
16
+ pluginViewerKey
17
+ };
18
+ //# sourceMappingURL=pluginViewerKey.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/core/plugins/host/pluginViewerKey.ts"],"sourcesContent":["// SPDX-License-Identifier: AGPL-3.0-or-later\r\n// Copyright (C) 2025 Collab Digital Twins\r\n\r\nimport type { ViewerKey } from '../../types/dbTypes'\r\n\r\nconst PREFIX = 'plugin:'\r\n\r\nexport interface PluginViewerTarget {\r\n pluginId: string\r\n pageId: string\r\n}\r\n\r\n/**\r\n * The `viewer` value that routes to one plugin's data page. Namespaced the same way toolbar\r\n * tool ids already are, so a plugin page and a built-in one can never collide.\r\n */\r\nexport function pluginViewerKey(pluginId: string, pageId: string): ViewerKey {\r\n return `${PREFIX}${pluginId}:${pageId}`\r\n}\r\n\r\n/** Null, not a throw, for a built-in or malformed key: this value comes from the URL. */\r\nexport function parsePluginViewerKey(key: string | null | undefined): PluginViewerTarget | null {\r\n if (typeof key !== 'string' || !key.startsWith(PREFIX)) return null\r\n\r\n const separator = key.indexOf(':', PREFIX.length)\r\n if (separator === -1) return null\r\n\r\n const pluginId = key.slice(PREFIX.length, separator)\r\n const pageId = key.slice(separator + 1)\r\n\r\n if (!pluginId || !pageId) return null\r\n\r\n return { pluginId, pageId }\r\n}\r\n"],"mappings":"AAKA,MAAM,SAAS;AAWR,SAAS,gBAAgB,UAAkB,QAA2B;AAC3E,SAAO,GAAG,MAAM,GAAG,QAAQ,IAAI,MAAM;AACvC;AAGO,SAAS,qBAAqB,KAA2D;AAC9F,MAAI,OAAO,QAAQ,YAAY,CAAC,IAAI,WAAW,MAAM,EAAG,QAAO;AAE/D,QAAM,YAAY,IAAI,QAAQ,KAAK,OAAO,MAAM;AAChD,MAAI,cAAc,GAAI,QAAO;AAE7B,QAAM,WAAW,IAAI,MAAM,OAAO,QAAQ,SAAS;AACnD,QAAM,SAAS,IAAI,MAAM,YAAY,CAAC;AAEtC,MAAI,CAAC,YAAY,CAAC,OAAQ,QAAO;AAEjC,SAAO,EAAE,UAAU,OAAO;AAC5B;","names":[]}
@@ -1 +1 @@
1
- {"version":3,"file":"provider.d.ts","sourceRoot":"","sources":["../../../../src/core/plugins/host/provider.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAM9B,OAAO,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAA;AACnC,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAA;AAG3C,OAAO,KAAK,EAAE,kBAAkB,EAAgB,YAAY,EAAE,MAAM,cAAc,CAAA;AAWlF,MAAM,WAAW,uBAAuB;IACtC,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAA;IACzB;;;;OAIG;IACH,OAAO,CAAC,EAAE,YAAY,CAAA;IACtB;;;;OAIG;IACH,YAAY,CAAC,EAAE,MAAM,EAAE,CAAA;IACvB,mFAAmF;IACnF,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAA;CAClD;AAED,wBAAgB,kBAAkB,CAAC,EACjC,QAAQ,EACR,OAA2B,EAC3B,YAAY,EACZ,OAA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ACZ,OAAO,GACR,EAAE,uBAAuB,qBAyGzB;AAED,wBAAgB,iBAAiB,IAAI,cAAc,CAMlD;AAED,wBAAgB,eAAe,IAAI,OAAO,CAGzC;AAED,sFAAsF;AACtF,wBAAgB,aAAa,IAAI,UAAU,GAAG,IAAI,CAEjD;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,IAAI,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAE1E;AAID,MAAM,MAAM,kBAAkB,CAAC,CAAC,SAAS,MAAM,kBAAkB,IAC/D,kBAAkB,CAAC,CAAC,CAAC,GAAG;IAAE,QAAQ,EAAE,MAAM,CAAA;CAAE,CAAA;AAE9C;;;;;GAKG;AACH,wBAAgB,sBAAsB,CAAC,CAAC,SAAS,MAAM,kBAAkB,EACvE,GAAG,EAAE,CAAC,GACL,kBAAkB,CAAC,CAAC,CAAC,EAAE,CAgBzB"}
@@ -3,6 +3,7 @@ import { jsx } from "react/jsx-runtime";
3
3
  import * as React from "react";
4
4
  import { INSTALLED_PLUGINS } from "../installed";
5
5
  import { resolvePluginEntry } from "../sdk/types";
6
+ import { PluginDialogProvider } from "./dialogs";
6
7
  import { PluginHost } from "./host";
7
8
  import { PluginRegistry } from "./registry";
8
9
  const PluginHostContext = React.createContext(null);
@@ -81,7 +82,7 @@ function PluginHostProvider({
81
82
  () => ({ registry, host, ready, configs: resolvedConfigs }),
82
83
  [registry, host, ready, resolvedConfigs]
83
84
  );
84
- return /* @__PURE__ */ jsx(PluginHostContext.Provider, { value, children });
85
+ return /* @__PURE__ */ jsx(PluginHostContext.Provider, { value, children: /* @__PURE__ */ jsx(PluginDialogProvider, { children }) });
85
86
  }
86
87
  function usePluginRegistry() {
87
88
  const context = React.useContext(PluginHostContext);
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/core/plugins/host/provider.tsx"],"sourcesContent":["'use client'\r\n\r\n// SPDX-License-Identifier: AGPL-3.0-or-later\r\n// Copyright (C) 2025 Collab Digital Twins\r\n\r\nimport * as React from 'react'\r\n\r\nimport { INSTALLED_PLUGINS } from '../installed'\r\n\r\nimport { resolvePluginEntry } from '../sdk/types'\r\n\r\nimport { PluginHost } from './host'\r\nimport { PluginRegistry } from './registry'\r\n\r\n\r\nimport type { CapabilityRegistry, PluginSource, PluginsInput } from '../sdk/types'\r\n\r\ninterface PluginHostContextValue {\r\n registry: PluginRegistry\r\n host: PluginHost\r\n ready: boolean\r\n configs: Record<string, Record<string, unknown>>\r\n}\r\n\r\nconst PluginHostContext = React.createContext<PluginHostContextValue | null>(null)\r\n\r\nexport interface PluginHostProviderProps {\r\n children: React.ReactNode\r\n /**\r\n * The plugins to load. Defaults to the set compiled into core. Pass a stable\r\n * reference — a module-scope array or a `useCallback` thunk — since a fresh\r\n * literal re-resolves the list on every render.\r\n */\r\n plugins?: PluginsInput\r\n /**\r\n * Slugs to activate. `undefined` activates everything, for consumers that do not\r\n * manage enablement. An array is authoritative: anything unlisted stays inactive,\r\n * and removing a slug deactivates that plugin in place, without a reload.\r\n */\r\n enabledSlugs?: string[]\r\n /** Per-plugin configuration, keyed by slug. Reaches the plugin as `ctx.config`. */\r\n configs?: Record<string, Record<string, unknown>>\r\n}\r\n\r\nexport function PluginHostProvider({\r\n children,\r\n plugins = INSTALLED_PLUGINS,\r\n enabledSlugs,\r\n configs,\r\n}: PluginHostProviderProps) {\r\n const registry = React.useMemo(() => new PluginRegistry(), [])\r\n const host = React.useMemo(() => new PluginHost(registry), [registry])\r\n\r\n const [sources, setSources] = React.useState<PluginSource[] | null>(null)\r\n const [ready, setReady] = React.useState(false)\r\n\r\n // Both normalized to an identity derived from their content: the props arrive as\r\n // fresh literals from a fetch, and using them as effect deps directly would reload\r\n // every plugin on every render. The JSON round-trip also drops anything\r\n // non-serializable, which is correct — config originates as JSON.\r\n const enabledKey = React.useMemo(\r\n () => (enabledSlugs ? [...enabledSlugs].sort().join('\\u0000') : null),\r\n [enabledSlugs],\r\n )\r\n const enabled = React.useMemo(\r\n () => (enabledKey === null ? null : new Set(enabledKey.split('\\u0000'))),\r\n [enabledKey],\r\n )\r\n\r\n const configsKey = React.useMemo(() => (configs ? JSON.stringify(configs) : ''), [configs])\r\n const resolvedConfigs = React.useMemo<Record<string, Record<string, unknown>>>(\r\n () => (configsKey ? JSON.parse(configsKey) : {}),\r\n [configsKey],\r\n )\r\n\r\n // Resolve the list first: for runtime-loaded plugins that is a fetch plus a\r\n // dynamic import per bundle, so it cannot happen during render.\r\n React.useEffect(() => {\r\n let cancelled = false\r\n\r\n async function resolve() {\r\n try {\r\n const resolved = typeof plugins === 'function' ? await plugins() : plugins\r\n if (!cancelled) setSources(resolved)\r\n } catch (err) {\r\n // A plugin source that cannot be resolved must not take down the app.\r\n console.error('Failed to resolve the plugin list:', err)\r\n if (!cancelled) setSources([])\r\n }\r\n }\r\n\r\n void resolve()\r\n return () => {\r\n cancelled = true\r\n }\r\n }, [plugins])\r\n\r\n // Reconcile: activate what should be running, deactivate what should not.\r\n // Runs again whenever enablement or config changes, so the plugins page can\r\n // toggle a plugin without a page reload.\r\n React.useEffect(() => {\r\n if (!sources) return\r\n let cancelled = false\r\n\r\n async function sync() {\r\n for (const { manifest, entry } of sources ?? []) {\r\n if (cancelled) return\r\n\r\n const slug = manifest?.slug\r\n if (typeof slug !== 'string' || !slug) {\r\n // Let the host reject it, so the failure is recorded. The entry is never\r\n // resolved: no point fetching a chunk for a plugin that cannot activate.\r\n await host.loadPlugin(manifest, { activate: () => {} }, {})\r\n continue\r\n }\r\n\r\n const shouldRun = enabled === null || enabled.has(slug)\r\n const isRunning = host.getStatus(slug) === 'active'\r\n\r\n if (shouldRun && !isRunning) {\r\n // Resolving the entry is what downloads a compiled-in plugin's chunk, so it\r\n // happens here rather than at module scope.\r\n try {\r\n await host.loadPlugin(manifest, await resolvePluginEntry(entry), resolvedConfigs[slug] ?? {})\r\n } catch (error) {\r\n // A chunk that fails to load must not stop the plugins after it.\r\n console.error(`Failed to load plugin \"${slug}\":`, error)\r\n }\r\n } else if (!shouldRun && isRunning) {\r\n await host.unloadPlugin(slug)\r\n }\r\n }\r\n\r\n if (!cancelled) setReady(true)\r\n }\r\n\r\n void sync()\r\n return () => {\r\n cancelled = true\r\n }\r\n }, [sources, host, enabled, resolvedConfigs])\r\n\r\n const value = React.useMemo(\r\n () => ({ registry, host, ready, configs: resolvedConfigs }),\r\n [registry, host, ready, resolvedConfigs],\r\n )\r\n\r\n return (\r\n <PluginHostContext.Provider value={value}>\r\n {children}\r\n </PluginHostContext.Provider>\r\n )\r\n}\r\n\r\nexport function usePluginRegistry(): PluginRegistry {\r\n const context = React.useContext(PluginHostContext)\r\n if (!context) {\r\n throw new Error('usePluginRegistry must be used within PluginHostProvider')\r\n }\r\n return context.registry\r\n}\r\n\r\nexport function usePluginsReady(): boolean {\r\n const context = React.useContext(PluginHostContext)\r\n return context?.ready ?? false\r\n}\r\n\r\n/** The host itself. Only the plugins page needs this; capability consumers do not. */\r\nexport function usePluginHost(): PluginHost | null {\r\n return React.useContext(PluginHostContext)?.host ?? null\r\n}\r\n\r\n/**\r\n * Every plugin's configuration, keyed by slug, for capability hosts to pass into\r\n * `PluginScopeProvider`. Plugins use `usePluginConfig()` from the SDK instead — a plugin\r\n * component importing this module puts `installed.ts` and the host in a cycle.\r\n */\r\nexport function usePluginConfigs(): Record<string, Record<string, unknown>> {\r\n return React.useContext(PluginHostContext)?.configs ?? EMPTY_CONFIGS\r\n}\r\n\r\nconst EMPTY_CONFIGS: Record<string, Record<string, unknown>> = {}\r\n\r\nexport type PluginContribution<K extends keyof CapabilityRegistry> =\r\n CapabilityRegistry[K] & { pluginId: string }\r\n\r\n/**\r\n * Read a capability's contributions and re-render when they change — the one way a host\r\n * component should consume the registry. `registry.getAll()` during render only works\r\n * when plugins load before first paint; a runtime-loaded plugin registers after the\r\n * consumer rendered, with nothing to tell it to look again.\r\n */\r\nexport function usePluginContributions<K extends keyof CapabilityRegistry>(\r\n key: K,\r\n): PluginContribution<K>[] {\r\n const registry = usePluginRegistry()\r\n\r\n const subscribe = React.useCallback(\r\n (onStoreChange: () => void) => registry.subscribe(onStoreChange),\r\n [registry],\r\n )\r\n\r\n // Copy-on-write in the registry makes this a stable reference between changes, which is\r\n // what lets useSyncExternalStore skip consumers of untouched capabilities.\r\n const getSnapshot = React.useCallback(\r\n () => registry.getAll(key) as unknown as PluginContribution<K>[],\r\n [registry, key],\r\n )\r\n\r\n return React.useSyncExternalStore(subscribe, getSnapshot, getSnapshot)\r\n}\r\n"],"mappings":";AAoJI;AA/IJ,YAAY,WAAW;AAEvB,SAAS,yBAAyB;AAElC,SAAS,0BAA0B;AAEnC,SAAS,kBAAkB;AAC3B,SAAS,sBAAsB;AAY/B,MAAM,oBAAoB,MAAM,cAA6C,IAAI;AAoB1E,SAAS,mBAAmB;AAAA,EACjC;AAAA,EACA,UAAU;AAAA,EACV;AAAA,EACA;AACF,GAA4B;AAC1B,QAAM,WAAW,MAAM,QAAQ,MAAM,IAAI,eAAe,GAAG,CAAC,CAAC;AAC7D,QAAM,OAAO,MAAM,QAAQ,MAAM,IAAI,WAAW,QAAQ,GAAG,CAAC,QAAQ,CAAC;AAErE,QAAM,CAAC,SAAS,UAAU,IAAI,MAAM,SAAgC,IAAI;AACxE,QAAM,CAAC,OAAO,QAAQ,IAAI,MAAM,SAAS,KAAK;AAM9C,QAAM,aAAa,MAAM;AAAA,IACvB,MAAO,eAAe,CAAC,GAAG,YAAY,EAAE,KAAK,EAAE,KAAK,IAAQ,IAAI;AAAA,IAChE,CAAC,YAAY;AAAA,EACf;AACA,QAAM,UAAU,MAAM;AAAA,IACpB,MAAO,eAAe,OAAO,OAAO,IAAI,IAAI,WAAW,MAAM,IAAQ,CAAC;AAAA,IACtE,CAAC,UAAU;AAAA,EACb;AAEA,QAAM,aAAa,MAAM,QAAQ,MAAO,UAAU,KAAK,UAAU,OAAO,IAAI,IAAK,CAAC,OAAO,CAAC;AAC1F,QAAM,kBAAkB,MAAM;AAAA,IAC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ier: AGPL-3.0-or-later\r\n// Copyright (C) 2025 Collab Digital Twins\r\n\r\nimport * as React from 'react'\r\n\r\nimport { INSTALLED_PLUGINS } from '../installed'\r\n\r\nimport { resolvePluginEntry } from '../sdk/types'\r\n\r\nimport { PluginDialogProvider } from './dialogs'\r\nimport { PluginHost } from './host'\r\nimport { PluginRegistry } from './registry'\r\n\r\n\r\nimport type { CapabilityRegistry, PluginSource, PluginsInput } from '../sdk/types'\r\n\r\ninterface PluginHostContextValue {\r\n registry: PluginRegistry\r\n host: PluginHost\r\n ready: boolean\r\n configs: Record<string, Record<string, unknown>>\r\n}\r\n\r\nconst PluginHostContext = React.createContext<PluginHostContextValue | null>(null)\r\n\r\nexport interface PluginHostProviderProps {\r\n children: React.ReactNode\r\n /**\r\n * The plugins to load. Defaults to the set compiled into core. Pass a stable\r\n * reference — a module-scope array or a `useCallback` thunk — since a fresh\r\n * literal re-resolves the list on every render.\r\n */\r\n plugins?: PluginsInput\r\n /**\r\n * Slugs to activate. `undefined` activates everything, for consumers that do not\r\n * manage enablement. An array is authoritative: anything unlisted stays inactive,\r\n * and removing a slug deactivates that plugin in place, without a reload.\r\n */\r\n enabledSlugs?: string[]\r\n /** Per-plugin configuration, keyed by slug. Reaches the plugin as `ctx.config`. */\r\n configs?: Record<string, Record<string, unknown>>\r\n}\r\n\r\nexport function PluginHostProvider({\r\n children,\r\n plugins = INSTALLED_PLUGINS,\r\n enabledSlugs,\r\n configs,\r\n}: PluginHostProviderProps) {\r\n const registry = React.useMemo(() => new PluginRegistry(), [])\r\n const host = React.useMemo(() => new PluginHost(registry), [registry])\r\n\r\n const [sources, setSources] = React.useState<PluginSource[] | null>(null)\r\n const [ready, setReady] = React.useState(false)\r\n\r\n // Both normalized to an identity derived from their content: the props arrive as\r\n // fresh literals from a fetch, and using them as effect deps directly would reload\r\n // every plugin on every render. The JSON round-trip also drops anything\r\n // non-serializable, which is correct — config originates as JSON.\r\n const enabledKey = React.useMemo(\r\n () => (enabledSlugs ? [...enabledSlugs].sort().join('\\u0000') : null),\r\n [enabledSlugs],\r\n )\r\n const enabled = React.useMemo(\r\n () => (enabledKey === null ? null : new Set(enabledKey.split('\\u0000'))),\r\n [enabledKey],\r\n )\r\n\r\n const configsKey = React.useMemo(() => (configs ? JSON.stringify(configs) : ''), [configs])\r\n const resolvedConfigs = React.useMemo<Record<string, Record<string, unknown>>>(\r\n () => (configsKey ? JSON.parse(configsKey) : {}),\r\n [configsKey],\r\n )\r\n\r\n // Resolve the list first: for runtime-loaded plugins that is a fetch plus a\r\n // dynamic import per bundle, so it cannot happen during render.\r\n React.useEffect(() => {\r\n let cancelled = false\r\n\r\n async function resolve() {\r\n try {\r\n const resolved = typeof plugins === 'function' ? await plugins() : plugins\r\n if (!cancelled) setSources(resolved)\r\n } catch (err) {\r\n // A plugin source that cannot be resolved must not take down the app.\r\n console.error('Failed to resolve the plugin list:', err)\r\n if (!cancelled) setSources([])\r\n }\r\n }\r\n\r\n void resolve()\r\n return () => {\r\n cancelled = true\r\n }\r\n }, [plugins])\r\n\r\n // Reconcile: activate what should be running, deactivate what should not.\r\n // Runs again whenever enablement or config changes, so the plugins page can\r\n // toggle a plugin without a page reload.\r\n React.useEffect(() => {\r\n if (!sources) return\r\n let cancelled = false\r\n\r\n async function sync() {\r\n for (const { manifest, entry } of sources ?? []) {\r\n if (cancelled) return\r\n\r\n const slug = manifest?.slug\r\n if (typeof slug !== 'string' || !slug) {\r\n // Let the host reject it, so the failure is recorded. The entry is never\r\n // resolved: no point fetching a chunk for a plugin that cannot activate.\r\n await host.loadPlugin(manifest, { activate: () => {} }, {})\r\n continue\r\n }\r\n\r\n const shouldRun = enabled === null || enabled.has(slug)\r\n const isRunning = host.getStatus(slug) === 'active'\r\n\r\n if (shouldRun && !isRunning) {\r\n // Resolving the entry is what downloads a compiled-in plugin's chunk, so it\r\n // happens here rather than at module scope.\r\n try {\r\n await host.loadPlugin(manifest, await resolvePluginEntry(entry), resolvedConfigs[slug] ?? {})\r\n } catch (error) {\r\n // A chunk that fails to load must not stop the plugins after it.\r\n console.error(`Failed to load plugin \"${slug}\":`, error)\r\n }\r\n } else if (!shouldRun && isRunning) {\r\n await host.unloadPlugin(slug)\r\n }\r\n }\r\n\r\n if (!cancelled) setReady(true)\r\n }\r\n\r\n void sync()\r\n return () => {\r\n cancelled = true\r\n }\r\n }, [sources, host, enabled, resolvedConfigs])\r\n\r\n const value = React.useMemo(\r\n () => ({ registry, host, ready, configs: resolvedConfigs }),\r\n [registry, host, ready, resolvedConfigs],\r\n )\r\n\r\n return (\r\n <PluginHostContext.Provider value={value}>\r\n <PluginDialogProvider>\r\n {children}\r\n </PluginDialogProvider>\r\n </PluginHostContext.Provider>\r\n )\r\n}\r\n\r\nexport function usePluginRegistry(): PluginRegistry {\r\n const context = React.useContext(PluginHostContext)\r\n if (!context) {\r\n throw new Error('usePluginRegistry must be used within PluginHostProvider')\r\n }\r\n return context.registry\r\n}\r\n\r\nexport function usePluginsReady(): boolean {\r\n const context = React.useContext(PluginHostContext)\r\n return context?.ready ?? false\r\n}\r\n\r\n/** The host itself. Only the plugins page needs this; capability consumers do not. */\r\nexport function usePluginHost(): PluginHost | null {\r\n return React.useContext(PluginHostContext)?.host ?? null\r\n}\r\n\r\n/**\r\n * Every plugin's configuration, keyed by slug, for capability hosts to pass into\r\n * `PluginScopeProvider`. Plugins use `usePluginConfig()` from the SDK instead — a plugin\r\n * component importing this module puts `installed.ts` and the host in a cycle.\r\n */\r\nexport function usePluginConfigs(): Record<string, Record<string, unknown>> {\r\n return React.useContext(PluginHostContext)?.configs ?? EMPTY_CONFIGS\r\n}\r\n\r\nconst EMPTY_CONFIGS: Record<string, Record<string, unknown>> = {}\r\n\r\nexport type PluginContribution<K extends keyof CapabilityRegistry> =\r\n CapabilityRegistry[K] & { pluginId: string }\r\n\r\n/**\r\n * Read a capability's contributions and re-render when they change — the one way a host\r\n * component should consume the registry. `registry.getAll()` during render only works\r\n * when plugins load before first paint; a runtime-loaded plugin registers after the\r\n * consumer rendered, with nothing to tell it to look again.\r\n */\r\nexport function usePluginContributions<K extends keyof CapabilityRegistry>(\r\n key: K,\r\n): PluginContribution<K>[] {\r\n const registry = usePluginRegistry()\r\n\r\n const subscribe = React.useCallback(\r\n (onStoreChange: () => void) => registry.subscribe(onStoreChange),\r\n [registry],\r\n )\r\n\r\n // Copy-on-write in the registry makes this a stable reference between changes, which is\r\n // what lets useSyncExternalStore skip consumers of untouched capabilities.\r\n const getSnapshot = React.useCallback(\r\n () => registry.getAll(key) as unknown as PluginContribution<K>[],\r\n [registry, key],\r\n )\r\n\r\n return React.useSyncExternalStore(subscribe, getSnapshot, getSnapshot)\r\n}\r\n"],"mappings":";AAsJM;AAjJN,YAAY,WAAW;AAEvB,SAAS,yBAAyB;AAElC,SAAS,0BAA0B;AAEnC,SAAS,4BAA4B;AACrC,SAAS,kBAAkB;AAC3B,SAAS,sBAAsB;AAY/B,MAAM,oBAAoB,MAAM,cAA6C,IAAI;AAoB1E,SAAS,mBAAmB;AAAA,EACjC;AAAA,EACA,UAAU;AAAA,EACV;AAAA,EACA;AACF,GAA4B;AAC1B,QAAM,WAAW,MAAM,QAAQ,MAAM,IAAI,eAAe,GAAG,CAAC,CAAC;AAC7D,QAAM,OAAO,MAAM,QAAQ,MAAM,IAAI,WAAW,QAAQ,GAAG,CAAC,QAAQ,CAAC;AAErE,QAAM,CAAC,SAAS,UAAU,IAAI,MAAM,SAAgC,IAAI;AACxE,QAAM,CAAC,OAAO,QAAQ,IAAI,MAAM,SAAS,KAAK;AAM9C,QAAM,aAAa,MAAM;AAAA,IACvB,MAAO,eAAe,CAAC,GAAG,YAAY,EAAE,KAAK,EAAE,KAAK,IAAQ,IAAI;AAAA,IAChE,CAAC,YAAY;AAAA,EACf;AACA,QAAM,UAAU,MAAM;AAAA,IACpB,MAAO,eAAe,OAAO,OAAO,IAAI,IAAI,WAAW,MAAM,IAAQ,CAAC;AAAA,IACtE,CAAC,UAAU;AAAA,EACb;AAEA,QAAM,aAAa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AAM,qBAAqB,WAAW,aAAa,WAAW;AACvE;","names":[]}
@@ -1 +1 @@
1
- {"version":3,"file":"runtimeShims.d.ts","sourceRoot":"","sources":["../../../../src/core/plugins/host/runtimeShims.ts"],"names":[],"mappings":"AAGA,2FAA2F;AAC3F,MAAM,WAAW,WAAW;IAC1B,gDAAgD;IAChD,IAAI,EAAE,MAAM,CAAA;IACZ,0EAA0E;IAC1E,MAAM,EAAE,MAAM,CAAA;IACd,4CAA4C;IAC5C,SAAS,EAAE,MAAM,CAAA;IACjB,6EAA6E;IAC7E,OAAO,EAAE,MAAM,EAAE,CAAA;CAClB;AAUD,eAAO,MAAM,oBAAoB,EAAE,SAAS,WAAW,EA8DtD,CAAA;AAED,8EAA8E;AAC9E,eAAO,MAAM,gBAAgB,EAAE,SAAS,MAAM,EAE7C,CAAA"}
1
+ {"version":3,"file":"runtimeShims.d.ts","sourceRoot":"","sources":["../../../../src/core/plugins/host/runtimeShims.ts"],"names":[],"mappings":"AAGA,2FAA2F;AAC3F,MAAM,WAAW,WAAW;IAC1B,gDAAgD;IAChD,IAAI,EAAE,MAAM,CAAA;IACZ,0EAA0E;IAC1E,MAAM,EAAE,MAAM,CAAA;IACd,4CAA4C;IAC5C,SAAS,EAAE,MAAM,CAAA;IACjB,6EAA6E;IAC7E,OAAO,EAAE,MAAM,EAAE,CAAA;CAClB;AAUD,eAAO,MAAM,oBAAoB,EAAE,SAAS,WAAW,EAgFtD,CAAA;AAED,8EAA8E;AAC9E,eAAO,MAAM,gBAAgB,EAAE,SAAS,MAAM,EAE7C,CAAA"}
@@ -54,7 +54,17 @@ const PLUGIN_RUNTIME_SHIMS = [
54
54
  file: "sdk.js",
55
55
  bridge: "sdk",
56
56
  specifier: "@collabdt/core/plugins-sdk",
57
- exports: ["VALID_CAPABILITIES", "validateManifest", "PLUGIN_HOST_API", "resolvePluginEntry"]
57
+ exports: [
58
+ "VALID_CAPABILITIES",
59
+ "validateManifest",
60
+ "PLUGIN_HOST_API",
61
+ "resolvePluginEntry",
62
+ // A value, not just a type: a `viewer.tabs` contribution names the viewers it belongs in.
63
+ "ViewerNames",
64
+ // So a plugin colouring something on the map uses the platform's palette.
65
+ "MAP_COLOUR_PALETTE",
66
+ "stringToColour"
67
+ ]
58
68
  },
59
69
  {
60
70
  file: "sdk-config.js",
@@ -74,6 +84,18 @@ const PLUGIN_RUNTIME_SHIMS = [
74
84
  specifier: "@collabdt/core/plugins-sdk/store",
75
85
  exports: ["usePluginStore"]
76
86
  },
87
+ {
88
+ file: "sdk-state.js",
89
+ bridge: "sdkState",
90
+ specifier: "@collabdt/core/plugins-sdk/state",
91
+ exports: ["usePluginState"]
92
+ },
93
+ {
94
+ file: "sdk-ui.js",
95
+ bridge: "sdkUi",
96
+ specifier: "@collabdt/core/plugins-sdk/ui",
97
+ exports: ["usePluginDialogs"]
98
+ },
77
99
  {
78
100
  file: "sdk-components.js",
79
101
  bridge: "sdkComponents",
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/core/plugins/host/runtimeShims.ts"],"sourcesContent":["// SPDX-License-Identifier: AGPL-3.0-or-later\r\n// Copyright (C) 2025 Collab Digital Twins\r\n\r\n/** One bare specifier a runtime-loaded plugin may import, and the shim the host serves. */\r\nexport interface RuntimeShim {\r\n /** Filename served under `/plugin-runtime/`. */\r\n file: string\r\n /** Key on `globalThis.__CDT_RUNTIME__` that the host bridge populates. */\r\n bridge: string\r\n /** The bare specifier the plugin writes. */\r\n specifier: string\r\n /** Re-exported by name, because an import map cannot rewrite a namespace. */\r\n exports: string[]\r\n}\r\n\r\n// Part of the host contract, so it lives beside `PLUGIN_HOST_API` rather than in the\r\n// app. Three consumers derive from it — the app's shim generator, the published import\r\n// map, and `@collabdt/plugin-kit`'s build preset — and when they disagree a plugin\r\n// either bundles a second copy of a singleton or dies on an unmapped specifier.\r\n//\r\n// Absent on purpose: `@thatopen/components`, `three`, `maplibre-gl`, `lucide-react`. A\r\n// plugin gets viewer instances as props and names icons by string, so it never imports\r\n// those at runtime — which is what stops a second copy of three.js loading.\r\nexport const PLUGIN_RUNTIME_SHIMS: readonly RuntimeShim[] = [\r\n {\r\n file: 'react.js',\r\n bridge: 'react',\r\n specifier: 'react',\r\n exports: [\r\n 'Children', 'Component', 'Fragment', 'Profiler', 'PureComponent',\r\n 'StrictMode', 'Suspense', 'cloneElement', 'createContext',\r\n 'createElement', 'createRef', 'forwardRef', 'isValidElement', 'lazy',\r\n 'memo', 'startTransition', 'useCallback', 'useContext', 'useDebugValue',\r\n 'useDeferredValue', 'useEffect', 'useId', 'useImperativeHandle',\r\n 'useInsertionEffect', 'useLayoutEffect', 'useMemo', 'useReducer',\r\n 'useRef', 'useState', 'useSyncExternalStore', 'useTransition', 'version',\r\n ],\r\n },\r\n {\r\n file: 'react-dom.js',\r\n bridge: 'reactDom',\r\n specifier: 'react-dom',\r\n exports: ['createPortal', 'flushSync', 'version'],\r\n },\r\n {\r\n file: 'jsx-runtime.js',\r\n bridge: 'jsxRuntime',\r\n specifier: 'react/jsx-runtime',\r\n exports: ['Fragment', 'jsx', 'jsxs'],\r\n },\r\n {\r\n file: 'sdk.js',\r\n bridge: 'sdk',\r\n specifier: '@collabdt/core/plugins-sdk',\r\n exports: ['VALID_CAPABILITIES', 'validateManifest', 'PLUGIN_HOST_API', 'resolvePluginEntry'],\r\n },\r\n {\r\n file: 'sdk-config.js',\r\n bridge: 'sdkConfig',\r\n specifier: '@collabdt/core/plugins-sdk/config',\r\n exports: ['usePluginConfig', 'usePluginId'],\r\n },\r\n {\r\n file: 'sdk-messages.js',\r\n bridge: 'sdkMessages',\r\n specifier: '@collabdt/core/plugins-sdk/messages',\r\n exports: ['usePluginMessage', 'usePluginTranslations', 'useCoreTranslations'],\r\n },\r\n {\r\n file: 'sdk-store.js',\r\n bridge: 'sdkStore',\r\n specifier: '@collabdt/core/plugins-sdk/store',\r\n exports: ['usePluginStore'],\r\n },\r\n {\r\n file: 'sdk-components.js',\r\n bridge: 'sdkComponents',\r\n specifier: '@collabdt/core/plugins-sdk/components',\r\n exports: [\r\n 'Badge', 'Button', 'Input', 'Separator',\r\n 'Card', 'CardContent', 'CardDescription', 'CardFooter', 'CardHeader', 'CardTitle',\r\n 'Dialog', 'DialogClose', 'DialogContent', 'DialogDescription',\r\n 'DialogFooter', 'DialogHeader', 'DialogTitle', 'DialogTrigger',\r\n ],\r\n },\r\n]\r\n\r\n/** Just the specifiers, which is what a bundler's `external` option wants. */\r\nexport const PLUGIN_EXTERNALS: readonly string[] = PLUGIN_RUNTIME_SHIMS.map(\r\n shim => shim.specifier,\r\n)\r\n"],"mappings":"AAuBO,MAAM,uBAA+C;AAAA,EAC1D;AAAA,IACE,MAAM;AAAA,IACN,QAAQ;AAAA,IACR,WAAW;AAAA,IACX,SAAS;AAAA,MACP;AAAA,MAAY;AAAA,MAAa;AAAA,MAAY;AAAA,MAAY;AAAA,MACjD;AAAA,MAAc;AAAA,MAAY;AAAA,MAAgB;AAAA,MAC1C;AAAA,MAAiB;AAAA,MAAa;AAAA,MAAc;AAAA,MAAkB;AAAA,MAC9D;AAAA,MAAQ;AAAA,MAAmB;AAAA,MAAe;AAAA,MAAc;AAAA,MACxD;AAAA,MAAoB;AAAA,MAAa;AAAA,MAAS;AAAA,MAC1C;AAAA,MAAsB;AAAA,MAAmB;AAAA,MAAW;AAAA,MACpD;AAAA,MAAU;AAAA,MAAY;AAAA,MAAwB;AAAA,MAAiB;AAAA,IACjE;AAAA,EACF;AAAA,EACA;AAAA,IACE,MAAM;AAAA,IACN,QAAQ;AAAA,IACR,WAAW;AAAA,IACX,SAAS,CAAC,gBAAgB,aAAa,SAAS;AAAA,EAClD;AAAA,EACA;AAAA,IACE,MAAM;AAAA,IACN,QAAQ;AAAA,IACR,WAAW;AAAA,IACX,SAAS,CAAC,YAAY,OAAO,MAAM;AAAA,EACrC;AAAA,EACA;AAAA,IACE,MAAM;AAAA,IACN,QAAQ;AAAA,IACR,WAAW;AAAA,IACX,SAAS,CAAC,sBAAsB,oBAAoB,mBAAmB,oBAAoB;AAAA,EAC7F;AAAA,EACA;AAAA,IACE,MAAM;AAAA,IACN,QAAQ;AAAA,IACR,WAAW;AAAA,IACX,SAAS,CAAC,mBAAmB,aAAa;AAAA,EAC5C;AAAA,EACA;AAAA,IACE,MAAM;AAAA,IACN,QAAQ;AAAA,IACR,WAAW;AAAA,IACX,SAAS,CAAC,oBAAoB,yBAAyB,qBAAqB;AAAA,EAC9E;AAAA,EACA;AAAA,IACE,MAAM;AAAA,IACN,QAAQ;AAAA,IACR,WAAW;AAAA,IACX,SAAS,CAAC,gBAAgB;AAAA,EAC5B;AAAA,EACA;AAAA,IACE,MAAM;AAAA,IACN,QAAQ;AAAA,IACR,WAAW;AAAA,IACX,SAAS;AAAA,MACP;AAAA,MAAS;AAAA,MAAU;AAAA,MAAS;AAAA,MAC5B;AAAA,MAAQ;AAAA,MAAe;AAAA,MAAmB;AAAA,MAAc;AAAA,MAAc;AAAA,MACtE;AAAA,MAAU;AAAA,MAAe;AAAA,MAAiB;AAAA,MAC1C;AAAA,MAAgB;AAAA,MAAgB;AAAA,MAAe;AAAA,IACjD;AAAA,EACF;AACF;AAGO,MAAM,mBAAsC,qBAAqB;AAAA,EACtE,UAAQ,KAAK;AACf;","names":[]}
1
+ {"version":3,"sources":["../../../../src/core/plugins/host/runtimeShims.ts"],"sourcesContent":["// SPDX-License-Identifier: AGPL-3.0-or-later\r\n// Copyright (C) 2025 Collab Digital Twins\r\n\r\n/** One bare specifier a runtime-loaded plugin may import, and the shim the host serves. */\r\nexport interface RuntimeShim {\r\n /** Filename served under `/plugin-runtime/`. */\r\n file: string\r\n /** Key on `globalThis.__CDT_RUNTIME__` that the host bridge populates. */\r\n bridge: string\r\n /** The bare specifier the plugin writes. */\r\n specifier: string\r\n /** Re-exported by name, because an import map cannot rewrite a namespace. */\r\n exports: string[]\r\n}\r\n\r\n// Part of the host contract, so it lives beside `PLUGIN_HOST_API` rather than in the\r\n// app. Three consumers derive from it — the app's shim generator, the published import\r\n// map, and `@collabdt/plugin-kit`'s build preset — and when they disagree a plugin\r\n// either bundles a second copy of a singleton or dies on an unmapped specifier.\r\n//\r\n// Absent on purpose: `@thatopen/components`, `three`, `maplibre-gl`, `lucide-react`. A\r\n// plugin gets viewer instances as props and names icons by string, so it never imports\r\n// those at runtime — which is what stops a second copy of three.js loading.\r\nexport const PLUGIN_RUNTIME_SHIMS: readonly RuntimeShim[] = [\r\n {\r\n file: 'react.js',\r\n bridge: 'react',\r\n specifier: 'react',\r\n exports: [\r\n 'Children', 'Component', 'Fragment', 'Profiler', 'PureComponent',\r\n 'StrictMode', 'Suspense', 'cloneElement', 'createContext',\r\n 'createElement', 'createRef', 'forwardRef', 'isValidElement', 'lazy',\r\n 'memo', 'startTransition', 'useCallback', 'useContext', 'useDebugValue',\r\n 'useDeferredValue', 'useEffect', 'useId', 'useImperativeHandle',\r\n 'useInsertionEffect', 'useLayoutEffect', 'useMemo', 'useReducer',\r\n 'useRef', 'useState', 'useSyncExternalStore', 'useTransition', 'version',\r\n ],\r\n },\r\n {\r\n file: 'react-dom.js',\r\n bridge: 'reactDom',\r\n specifier: 'react-dom',\r\n exports: ['createPortal', 'flushSync', 'version'],\r\n },\r\n {\r\n file: 'jsx-runtime.js',\r\n bridge: 'jsxRuntime',\r\n specifier: 'react/jsx-runtime',\r\n exports: ['Fragment', 'jsx', 'jsxs'],\r\n },\r\n {\r\n file: 'sdk.js',\r\n bridge: 'sdk',\r\n specifier: '@collabdt/core/plugins-sdk',\r\n exports: [\r\n 'VALID_CAPABILITIES', 'validateManifest', 'PLUGIN_HOST_API', 'resolvePluginEntry',\r\n // A value, not just a type: a `viewer.tabs` contribution names the viewers it belongs in.\r\n 'ViewerNames',\r\n // So a plugin colouring something on the map uses the platform's palette.\r\n 'MAP_COLOUR_PALETTE', 'stringToColour',\r\n ],\r\n },\r\n {\r\n file: 'sdk-config.js',\r\n bridge: 'sdkConfig',\r\n specifier: '@collabdt/core/plugins-sdk/config',\r\n exports: ['usePluginConfig', 'usePluginId'],\r\n },\r\n {\r\n file: 'sdk-messages.js',\r\n bridge: 'sdkMessages',\r\n specifier: '@collabdt/core/plugins-sdk/messages',\r\n exports: ['usePluginMessage', 'usePluginTranslations', 'useCoreTranslations'],\r\n },\r\n {\r\n file: 'sdk-store.js',\r\n bridge: 'sdkStore',\r\n specifier: '@collabdt/core/plugins-sdk/store',\r\n exports: ['usePluginStore'],\r\n },\r\n {\r\n file: 'sdk-state.js',\r\n bridge: 'sdkState',\r\n specifier: '@collabdt/core/plugins-sdk/state',\r\n exports: ['usePluginState'],\r\n },\r\n {\r\n file: 'sdk-ui.js',\r\n bridge: 'sdkUi',\r\n specifier: '@collabdt/core/plugins-sdk/ui',\r\n exports: ['usePluginDialogs'],\r\n },\r\n {\r\n file: 'sdk-components.js',\r\n bridge: 'sdkComponents',\r\n specifier: '@collabdt/core/plugins-sdk/components',\r\n exports: [\r\n 'Badge', 'Button', 'Input', 'Separator',\r\n 'Card', 'CardContent', 'CardDescription', 'CardFooter', 'CardHeader', 'CardTitle',\r\n 'Dialog', 'DialogClose', 'DialogContent', 'DialogDescription',\r\n 'DialogFooter', 'DialogHeader', 'DialogTitle', 'DialogTrigger',\r\n ],\r\n },\r\n]\r\n\r\n/** Just the specifiers, which is what a bundler's `external` option wants. */\r\nexport const PLUGIN_EXTERNALS: readonly string[] = PLUGIN_RUNTIME_SHIMS.map(\r\n shim => shim.specifier,\r\n)\r\n"],"mappings":"AAuBO,MAAM,uBAA+C;AAAA,EAC1D;AAAA,IACE,MAAM;AAAA,IACN,QAAQ;AAAA,IACR,WAAW;AAAA,IACX,SAAS;AAAA,MACP;AAAA,MAAY;AAAA,MAAa;AAAA,MAAY;AAAA,MAAY;AAAA,MACjD;AAAA,MAAc;AAAA,MAAY;AAAA,MAAgB;AAAA,MAC1C;AAAA,MAAiB;AAAA,MAAa;AAAA,MAAc;AAAA,MAAkB;AAAA,MAC9D;AAAA,MAAQ;AAAA,MAAmB;AAAA,MAAe;AAAA,MAAc;AA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ACR,WAAW;AAAA,IACX,SAAS;AAAA,MACP;AAAA,MAAS;AAAA,MAAU;AAAA,MAAS;AAAA,MAC5B;AAAA,MAAQ;AAAA,MAAe;AAAA,MAAmB;AAAA,MAAc;AAAA,MAAc;AAAA,MACtE;AAAA,MAAU;AAAA,MAAe;AAAA,MAAiB;AAAA,MAC1C;AAAA,MAAgB;AAAA,MAAgB;AAAA,MAAe;AAAA,IACjD;AAAA,EACF;AACF;AAGO,MAAM,mBAAsC,qBAAqB;AAAA,EACtE,UAAQ,KAAK;AACf;","names":[]}
@@ -0,0 +1,15 @@
1
+ import * as React from 'react';
2
+ import type { ViewerKey } from '../../types/dbTypes';
3
+ import type { LucideProps } from 'lucide-react';
4
+ export interface PluginNavItem {
5
+ /** The `viewer` key this item switches to. */
6
+ id: ViewerKey;
7
+ title: string;
8
+ icon: React.ComponentType<LucideProps>;
9
+ }
10
+ /**
11
+ * The `data.pages` contributions as nav items. They sit in Datasets beside Buildings, so a
12
+ * contributed page reads as part of the platform.
13
+ */
14
+ export declare function usePluginDataPages(): PluginNavItem[];
15
+ //# sourceMappingURL=usePluginDataPages.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"usePluginDataPages.d.ts","sourceRoot":"","sources":["../../../../src/core/plugins/host/usePluginDataPages.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAQ9B,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAA;AACpD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAA;AAE/C,MAAM,WAAW,aAAa;IAC5B,8CAA8C;IAC9C,EAAE,EAAE,SAAS,CAAA;IACb,KAAK,EAAE,MAAM,CAAA;IACb,IAAI,EAAE,KAAK,CAAC,aAAa,CAAC,WAAW,CAAC,CAAA;CACvC;AAED;;;GAGG;AACH,wBAAgB,kBAAkB,IAAI,aAAa,EAAE,CAYpD"}
@@ -0,0 +1,22 @@
1
+ "use client";
2
+ import * as React from "react";
3
+ import { usePluginMessageLookup } from "../sdk/messages";
4
+ import { pluginViewerKey } from "./pluginViewerKey";
5
+ import { usePluginContributions } from "./provider";
6
+ import { resolvePluginIcon } from "./usePluginToolbarTools";
7
+ function usePluginDataPages() {
8
+ const registrations = usePluginContributions("data.pages");
9
+ const message = usePluginMessageLookup();
10
+ return React.useMemo(
11
+ () => registrations.map((registration) => ({
12
+ id: pluginViewerKey(registration.pluginId, registration.id),
13
+ title: message(registration.pluginId, registration.titleKey, registration.titleKey),
14
+ icon: resolvePluginIcon(registration.icon)
15
+ })),
16
+ [registrations, message]
17
+ );
18
+ }
19
+ export {
20
+ usePluginDataPages
21
+ };
22
+ //# sourceMappingURL=usePluginDataPages.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/core/plugins/host/usePluginDataPages.ts"],"sourcesContent":["'use client'\r\n\r\n// SPDX-License-Identifier: AGPL-3.0-or-later\r\n// Copyright (C) 2025 Collab Digital Twins\r\n\r\nimport * as React from 'react'\r\n\r\nimport { usePluginMessageLookup } from '../sdk/messages'\r\n\r\nimport { pluginViewerKey } from './pluginViewerKey'\r\nimport { usePluginContributions } from './provider'\r\nimport { resolvePluginIcon } from './usePluginToolbarTools'\r\n\r\nimport type { ViewerKey } from '../../types/dbTypes'\r\nimport type { LucideProps } from 'lucide-react'\r\n\r\nexport interface PluginNavItem {\r\n /** The `viewer` key this item switches to. */\r\n id: ViewerKey\r\n title: string\r\n icon: React.ComponentType<LucideProps>\r\n}\r\n\r\n/**\r\n * The `data.pages` contributions as nav items. They sit in Datasets beside Buildings, so a\r\n * contributed page reads as part of the platform.\r\n */\r\nexport function usePluginDataPages(): PluginNavItem[] {\r\n const registrations = usePluginContributions('data.pages')\r\n const message = usePluginMessageLookup()\r\n\r\n return React.useMemo(\r\n () => registrations.map(registration => ({\r\n id: pluginViewerKey(registration.pluginId, registration.id),\r\n title: message(registration.pluginId, registration.titleKey, registration.titleKey),\r\n icon: resolvePluginIcon(registration.icon),\r\n })),\r\n [registrations, message],\r\n )\r\n}\r\n"],"mappings":";AAKA,YAAY,WAAW;AAEvB,SAAS,8BAA8B;AAEvC,SAAS,uBAAuB;AAChC,SAAS,8BAA8B;AACvC,SAAS,yBAAyB;AAgB3B,SAAS,qBAAsC;AACpD,QAAM,gBAAgB,uBAAuB,YAAY;AACzD,QAAM,UAAU,uBAAuB;AAEvC,SAAO,MAAM;AAAA,IACX,MAAM,cAAc,IAAI,mBAAiB;AAAA,MACvC,IAAI,gBAAgB,aAAa,UAAU,aAAa,EAAE;AAAA,MAC1D,OAAO,QAAQ,aAAa,UAAU,aAAa,UAAU,aAAa,QAAQ;AAAA,MAClF,MAAM,kBAAkB,aAAa,IAAI;AAAA,IAC3C,EAAE;AAAA,IACF,CAAC,eAAe,OAAO;AAAA,EACzB;AACF;","names":[]}
@@ -0,0 +1,11 @@
1
+ import type { ViewerSidebarTab } from '../../components/ui/ViewerSidebar/sidebarTabs';
2
+ import type { SidebarTabKey } from '../../store/Menus/reducer';
3
+ import type { ViewerNames } from '../../types/dbTypes';
4
+ /** Namespaced so a plugin tab can never collide with a built-in one, or with another plugin's. */
5
+ export declare function pluginTabId(pluginId: string, tabId: string): SidebarTabKey;
6
+ /**
7
+ * The `viewer.tabs` contributions for this viewer; no `viewers` means every viewer. The panel
8
+ * is wrapped in the plugin scope, which is what lets the component inside reach the SDK hooks.
9
+ */
10
+ export declare function usePluginViewerTabs(viewer: ViewerNames): ViewerSidebarTab[];
11
+ //# sourceMappingURL=usePluginViewerTabs.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"usePluginViewerTabs.d.ts","sourceRoot":"","sources":["../../../../src/core/plugins/host/usePluginViewerTabs.tsx"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,+CAA+C,CAAA;AACrF,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAA;AAC9D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAA;AAEtD,kGAAkG;AAClG,wBAAgB,WAAW,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,aAAa,CAE1E;AAED;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,WAAW,GAAG,gBAAgB,EAAE,CA6B3E"}
@@ -0,0 +1,41 @@
1
+ "use client";
2
+ import { jsx } from "react/jsx-runtime";
3
+ import * as React from "react";
4
+ import { usePluginMessageLookup } from "../sdk/messages";
5
+ import { usePluginConfigs, usePluginContributions } from "./provider";
6
+ import { PluginScopeProvider } from "./scope";
7
+ import { resolvePluginIcon } from "./usePluginToolbarTools";
8
+ function pluginTabId(pluginId, tabId) {
9
+ return `plugin:${pluginId}:${tabId}`;
10
+ }
11
+ function usePluginViewerTabs(viewer) {
12
+ const registrations = usePluginContributions("viewer.tabs");
13
+ const configs = usePluginConfigs();
14
+ const message = usePluginMessageLookup();
15
+ return React.useMemo(
16
+ () => registrations.filter((registration) => !registration.viewers || registration.viewers.includes(viewer)).map((registration) => {
17
+ const Panel = registration.component;
18
+ return {
19
+ id: pluginTabId(registration.pluginId, registration.id),
20
+ meta: {
21
+ icon: resolvePluginIcon(registration.icon),
22
+ label: message(registration.pluginId, registration.labelKey, registration.labelKey)
23
+ },
24
+ content: /* @__PURE__ */ jsx(
25
+ PluginScopeProvider,
26
+ {
27
+ pluginId: registration.pluginId,
28
+ config: configs[registration.pluginId],
29
+ children: /* @__PURE__ */ jsx(Panel, {})
30
+ }
31
+ )
32
+ };
33
+ }),
34
+ [registrations, viewer, configs, message]
35
+ );
36
+ }
37
+ export {
38
+ pluginTabId,
39
+ usePluginViewerTabs
40
+ };
41
+ //# sourceMappingURL=usePluginViewerTabs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/core/plugins/host/usePluginViewerTabs.tsx"],"sourcesContent":["'use client'\r\n\r\n// SPDX-License-Identifier: AGPL-3.0-or-later\r\n// Copyright (C) 2025 Collab Digital Twins\r\n\r\nimport * as React from 'react'\r\n\r\nimport { usePluginMessageLookup } from '../sdk/messages'\r\n\r\nimport { usePluginConfigs, usePluginContributions } from './provider'\r\nimport { PluginScopeProvider } from './scope'\r\nimport { resolvePluginIcon } from './usePluginToolbarTools'\r\n\r\nimport type { ViewerSidebarTab } from '../../components/ui/ViewerSidebar/sidebarTabs'\r\nimport type { SidebarTabKey } from '../../store/Menus/reducer'\r\nimport type { ViewerNames } from '../../types/dbTypes'\r\n\r\n/** Namespaced so a plugin tab can never collide with a built-in one, or with another plugin's. */\r\nexport function pluginTabId(pluginId: string, tabId: string): SidebarTabKey {\r\n return `plugin:${pluginId}:${tabId}`\r\n}\r\n\r\n/**\r\n * The `viewer.tabs` contributions for this viewer; no `viewers` means every viewer. The panel\r\n * is wrapped in the plugin scope, which is what lets the component inside reach the SDK hooks.\r\n */\r\nexport function usePluginViewerTabs(viewer: ViewerNames): ViewerSidebarTab[] {\r\n const registrations = usePluginContributions('viewer.tabs')\r\n const configs = usePluginConfigs()\r\n const message = usePluginMessageLookup()\r\n\r\n return React.useMemo(\r\n () => registrations\r\n .filter(registration => !registration.viewers || registration.viewers.includes(viewer))\r\n .map((registration) => {\r\n const Panel = registration.component\r\n\r\n return {\r\n id: pluginTabId(registration.pluginId, registration.id),\r\n meta: {\r\n icon: resolvePluginIcon(registration.icon),\r\n label: message(registration.pluginId, registration.labelKey, registration.labelKey),\r\n },\r\n content: (\r\n <PluginScopeProvider\r\n pluginId={registration.pluginId}\r\n config={configs[registration.pluginId]}\r\n >\r\n <Panel />\r\n </PluginScopeProvider>\r\n ),\r\n }\r\n }),\r\n [registrations, viewer, configs, message],\r\n )\r\n}\r\n"],"mappings":";AAgDc;AA3Cd,YAAY,WAAW;AAEvB,SAAS,8BAA8B;AAEvC,SAAS,kBAAkB,8BAA8B;AACzD,SAAS,2BAA2B;AACpC,SAAS,yBAAyB;AAO3B,SAAS,YAAY,UAAkB,OAA8B;AAC1E,SAAO,UAAU,QAAQ,IAAI,KAAK;AACpC;AAMO,SAAS,oBAAoB,QAAyC;AAC3E,QAAM,gBAAgB,uBAAuB,aAAa;AAC1D,QAAM,UAAU,iBAAiB;AACjC,QAAM,UAAU,uBAAuB;AAEvC,SAAO,MAAM;AAAA,IACX,MAAM,cACH,OAAO,kBAAgB,CAAC,aAAa,WAAW,aAAa,QAAQ,SAAS,MAAM,CAAC,EACrF,IAAI,CAAC,iBAAiB;AACrB,YAAM,QAAQ,aAAa;AAE3B,aAAO;AAAA,QACL,IAAI,YAAY,aAAa,UAAU,aAAa,EAAE;AAAA,QACtD,MAAM;AAAA,UACJ,MAAM,kBAAkB,aAAa,IAAI;AAAA,UACzC,OAAO,QAAQ,aAAa,UAAU,aAAa,UAAU,aAAa,QAAQ;AAAA,QACpF;AAAA,QACA,SACE;AAAA,UAAC;AAAA;AAAA,YACC,UAAU,aAAa;AAAA,YACvB,QAAQ,QAAQ,aAAa,QAAQ;AAAA,YAErC,8BAAC,SAAM;AAAA;AAAA,QACT;AAAA,MAEJ;AAAA,IACF,CAAC;AAAA,IACH,CAAC,eAAe,QAAQ,SAAS,OAAO;AAAA,EAC1C;AACF;","names":[]}
@@ -2,12 +2,8 @@ import type { BimItemProperties } from '../../components/viewers/bim/src/lib/bim
2
2
  import type { ModelIdMap } from '../../components/viewers/bim/src/lib/bimTree';
3
3
  import type * as OBC from '@thatopen/components';
4
4
  /**
5
- * The BIM viewer, as a plugin sees it.
6
- *
7
- * Has a runtime dependency on `@thatopen/components` and three, so it stays out of
8
- * the `plugins-sdk` barrel and out of anything the map route imports. Core reaches
9
- * it only from inside the BIM viewer's own lazy chunk; plugins import
10
- * `@collabdt/core/plugins-sdk/bimViewer`.
5
+ * The BIM viewer, as a plugin sees it. Kept out of the `plugins-sdk` barrel: it depends on
6
+ * `@thatopen/components` and three at runtime.
11
7
  */
12
8
  export interface BimToolProps {
13
9
  components: OBC.Components | null;
@@ -35,14 +31,34 @@ export interface BimToolProps {
35
31
  getProperties: (items: ModelIdMap, attributes?: string[]) => Promise<BimItemProperties[]>;
36
32
  }
37
33
  /**
38
- * Thin façade over the same `lib/bim*` helpers the core sidebar and toolbars use, so
39
- * a plugin cannot drift from core behaviour.
40
- *
41
- * No colour or opacity overrides, on purpose: raw per-element painting spends one of
42
- * the model's ~65 500 Fragments material slots per element per call and exhausts
43
- * them. Core buckets those through `ElementAppearance`; plugins use `select` and
44
- * `isolate` to draw attention.
34
+ * Thin façade over the `lib/bim*` helpers core itself uses. Colour lives in
35
+ * {@link usePluginBimAppearance}, which knows the calling plugin; this cannot.
45
36
  */
46
37
  export declare function useBimViewer(): BimToolProps;
38
+ export interface BimAppearance {
39
+ /** `0xRRGGBB`. Omit to keep each element's own colour. */
40
+ color?: number;
41
+ /** `0`–`1`. Omit to leave elements opaque. */
42
+ opacity?: number;
43
+ }
44
+ /** One appearance and the elements wearing it. */
45
+ export interface BimAppearanceGroup {
46
+ items: ModelIdMap;
47
+ appearance: BimAppearance;
48
+ }
49
+ export interface PluginBimAppearance {
50
+ /**
51
+ * Every group in one call, replacing this plugin's previous paint. Calling it per group
52
+ * would replace that same entry each time and leave only the last. An empty list clears.
53
+ */
54
+ setAppearance: (groups: readonly BimAppearanceGroup[]) => void;
55
+ /** Gives this plugin's elements back their own colours. */
56
+ clearAppearance: () => void;
57
+ }
58
+ /**
59
+ * Colour and opacity, bucketed into one `highlight()` per appearance — per element would
60
+ * exhaust the model's ~65 500 material slots. Scoped to this plugin, outside the sidebar's undo.
61
+ */
62
+ export declare function usePluginBimAppearance(): PluginBimAppearance;
47
63
  export type { ModelIdMap, BimItemProperties };
48
64
  //# sourceMappingURL=bimViewer.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"bimViewer.d.ts","sourceRoot":"","sources":["../../../../src/core/plugins/sdk/bimViewer.ts"],"names":[],"mappings":"AAqBA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,iDAAiD,CAAA;AACxF,OAAO,KAAK,EAAE,UAAU,EAAE,M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,YAAY,IAAI,YAAY,CAoC3C;AAED,MAAM,WAAW,aAAa;IAC5B,0DAA0D;IAC1D,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,8CAA8C;IAC9C,OAAO,CAAC,EAAE,MAAM,CAAA;CACjB;AAED,kDAAkD;AAClD,MAAM,WAAW,kBAAkB;IACjC,KAAK,EAAE,UAAU,CAAA;IACjB,UAAU,EAAE,aAAa,CAAA;CAC1B;AAED,MAAM,WAAW,mBAAmB;IAClC;;;OAGG;IACH,aAAa,EAAE,CAAC,MAAM,EAAE,SAAS,kBAAkB,EAAE,KAAK,IAAI,CAAA;IAC9D,2DAA2D;IAC3D,eAAe,EAAE,MAAM,IAAI,CAAA;CAC5B;AAED;;;GAGG;AACH,wBAAgB,sBAAsB,IAAI,mBAAmB,CAa5D;AAED,YAAY,EAAE,UAAU,EAAE,iBAAiB,EAAE,CAAA"}
@@ -1,5 +1,6 @@
1
1
  "use client";
2
2
  import * as React from "react";
3
+ import { ElementAppearance } from "../../components/viewers/bim/src/ElementAppearance";
3
4
  import { fitToSelection } from "../../components/viewers/bim/src/lib/bimCamera";
4
5
  import {
5
6
  clearSelection,
@@ -13,6 +14,7 @@ import {
13
14
  getItemsOfCategory
14
15
  } from "../../components/viewers/bim/src/lib/bimQueries";
15
16
  import { BimContext } from "../../store/BIM/context";
17
+ import { usePluginId } from "../host/scope";
16
18
  function useBimViewer() {
17
19
  const { state } = React.useContext(BimContext);
18
20
  const { bimComponents, world, fragments, modelIds, selection } = state.bim;
@@ -44,7 +46,21 @@ function useBimViewer() {
44
46
  getProperties: async (items, attributes) => bimComponents ? getItemProperties(bimComponents, items, attributes) : []
45
47
  }), [bimComponents, world, fragments, modelIds, selection]);
46
48
  }
49
+ function usePluginBimAppearance() {
50
+ const pluginId = usePluginId();
51
+ const { state } = React.useContext(BimContext);
52
+ const { bimComponents } = state.bim;
53
+ return React.useMemo(() => ({
54
+ setAppearance: (groups) => {
55
+ bimComponents == null ? void 0 : bimComponents.get(ElementAppearance).setElementAppearance(pluginId, groups);
56
+ },
57
+ clearAppearance: () => {
58
+ bimComponents == null ? void 0 : bimComponents.get(ElementAppearance).clearElementAppearance(pluginId);
59
+ }
60
+ }), [bimComponents, pluginId]);
61
+ }
47
62
  export {
48
- useBimViewer
63
+ useBimViewer,
64
+ usePluginBimAppearance
49
65
  };
50
66
  //# sourceMappingURL=bimViewer.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/core/plugins/sdk/bimViewer.ts"],"sourcesContent":["'use client'\r\n\r\n// SPDX-License-Identifier: AGPL-3.0-or-later\r\n// Copyright (C) 2025 Collab Digital Twins\r\n\r\nimport * as React from 'react'\r\n\r\nimport { fitToSelection } from '../../components/viewers/bim/src/lib/bimCamera'\r\nimport {\r\n clearSelection,\r\n isolateItems,\r\n selectItems,\r\n setItemsVisible,\r\n showAllItems,\r\n} from '../../components/viewers/bim/src/lib/bimItemActions'\r\nimport {\r\n getItemProperties,\r\n getItemsOfCategory,\r\n} from '../../components/viewers/bim/src/lib/bimQueries'\r\nimport { BimContext } from '../../store/BIM/context'\r\n\r\nimport type { BimItemProperties } from '../../components/viewers/bim/src/lib/bimQueries'\r\nimport type { ModelIdMap } from '../../components/viewers/bim/src/lib/bimTree'\r\nimport type * as OBC from '@thatopen/components'\r\n\r\n/**\r\n * The BIM viewer, as a plugin sees it.\r\n *\r\n * Has a runtime dependency on `@thatopen/components` and three, so it stays out of\r\n * the `plugins-sdk` barrel and out of anything the map route imports. Core reaches\r\n * it only from inside the BIM viewer's own lazy chunk; plugins import\r\n * `@collabdt/core/plugins-sdk/bimViewer`.\r\n */\r\n\r\nexport interface BimToolProps {\r\n components: OBC.Components | null\r\n world: OBC.World | null\r\n fragments: OBC.FragmentsManager | null\r\n /** Ids of every loaded model, in load order. */\r\n modelIds: string[]\r\n\r\n /** The live selection, keyed by model id. Updates as the user clicks in the viewport. */\r\n selection: ModelIdMap\r\n\r\n // Properties, not methods: standalone closures with no `this`, so a plugin can\r\n // destructure them out of the props without an unbound-`this` hazard.\r\n select: (items: ModelIdMap) => Promise<void>\r\n clearSelection: () => void\r\n /** Frame the camera on whatever is currently selected. */\r\n fitToSelection: () => Promise<void>\r\n\r\n /** Hides everything except `items`, across every loaded model. */\r\n isolate: (items: ModelIdMap) => Promise<void>\r\n setItemsVisible: (items: ModelIdMap, visible: boolean) => Promise<void>\r\n /** The escape hatch from `isolate`: makes everything visible again. */\r\n showAll: () => Promise<void>\r\n\r\n /**\r\n * Every element of one IFC class, e.g. `getItemsOfCategory('IFCSPACE')`. Spaces\r\n * start hidden, being volumetric, so showing them needs `setItemsVisible` too.\r\n */\r\n getItemsOfCategory: (category: string) => Promise<ModelIdMap>\r\n /** Attributes for the given elements. Omit `attributes` for the default set. */\r\n getProperties: (items: ModelIdMap, attributes?: string[]) => Promise<BimItemProperties[]>\r\n}\r\n\r\n/**\r\n * Thin façade over the same `lib/bim*` helpers the core sidebar and toolbars use, so\r\n * a plugin cannot drift from core behaviour.\r\n *\r\n * No colour or opacity overrides, on purpose: raw per-element painting spends one of\r\n * the model's ~65 500 Fragments material slots per element per call and exhausts\r\n * them. Core buckets those through `ElementAppearance`; plugins use `select` and\r\n * `isolate` to draw attention.\r\n */\r\nexport function useBimViewer(): BimToolProps {\r\n const { state } = React.useContext(BimContext)\r\n const { bimComponents, world, fragments, modelIds, selection } = state.bim\r\n\r\n return React.useMemo<BimToolProps>(() => ({\r\n components: bimComponents,\r\n world,\r\n fragments,\r\n modelIds,\r\n selection,\r\n\r\n select: async (items: ModelIdMap) => {\r\n if (bimComponents) await selectItems(bimComponents, items)\r\n },\r\n clearSelection: () => {\r\n if (bimComponents) clearSelection(bimComponents)\r\n },\r\n fitToSelection: async () => {\r\n if (bimComponents) await fitToSelection(bimComponents)\r\n },\r\n\r\n isolate: async (items: ModelIdMap) => {\r\n if (bimComponents) await isolateItems(bimComponents, items)\r\n },\r\n setItemsVisible: async (items: ModelIdMap, visible: boolean) => {\r\n if (bimComponents) await setItemsVisible(bimComponents, items, visible)\r\n },\r\n showAll: async () => {\r\n if (bimComponents) await showAllItems(bimComponents)\r\n },\r\n\r\n getItemsOfCategory: async (category: string) =>\r\n bimComponents ? getItemsOfCategory(bimComponents, category) : {},\r\n getProperties: async (items: ModelIdMap, attributes?: string[]) =>\r\n bimComponents ? getItemProperties(bimComponents, items, attributes) : [],\r\n }), [bimComponents, world, fragments, modelIds, selection])\r\n}\r\n\r\nexport type { ModelIdMap, BimItemProperties }\r\n"],"mappings":";AAKA,YAAY,WAAW;AAEvB,SAAS,sBAAsB;AAC/B;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP;AAAA,EACE;AAAA,EACA;AAAA,OACK;AACP,SAAS,kBAAkB;AAwDpB,SAAS,eAA6B;AAC3C,QAAM,EAAE,MAAM,IAAI,MAAM,WAAW,UAAU;AAC7C,QAAM,EAAE,eAAe,OAAO,WAAW,UAAU,UAAU,IAAI,MAAM;AAEvE,SAAO,MAAM,QAAsB,OAAO;AAAA,IACxC,YAAY;AAAA,IACZ;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IAEA,QAAQ,OAAO,UAAsB;AACnC,UAAI,cAAe,OAAM,YAAY,eAAe,KAAK;AAAA,IAC3D;AAAA,IACA,gBAAgB,MAAM;AACpB,UAAI,cAAe,gBAAe,aAAa;AAAA,IACjD;AAAA,IACA,gBAAgB,YAAY;AAC1B,UAAI,cAAe,OAAM,eAAe,aAAa;AAAA,IACvD;AAAA,IAEA,SAAS,OAAO,UAAsB;AACpC,UAAI,cAAe,OAAM,aAAa,eAAe,KAAK;AAAA,IAC5D;AAAA,IACA,iBAAiB,OAAO,OAAmB,YAAqB;AAC9D,UAAI,cAAe,OAAM,gBAAgB,eAAe,OAAO,OAAO;AAAA,IACxE;AAAA,IACA,SAAS,YAAY;AACnB,UAAI,cAAe,OAAM,aAAa,aAAa;AAAA,IACrD;AAAA,IAEA,oBAAoB,OAAO,aACzB,gBAAgB,mBAAmB,eAAe,QAAQ,IAAI,CAAC;AAAA,IACjE,eAAe,OAAO,OAAmB,eACvC,gBAAgB,kBAAkB,eAAe,OAAO,UAAU,IAAI,CAAC;AAAA,EAC3E,IAAI,CAAC,eAAe,OAAO,WAAW,UAAU,SAAS,CAAC;AAC5D;","names":[]}
1
+ {"version":3,"sources":["../../../../src/core/plugins/sdk/bimViewer.ts"],"sourcesContent":["'use client'\r\n\r\n// SPDX-License-Identifier: AGPL-3.0-or-later\r\n// Copyright (C) 2025 Collab Digital Twins\r\n\r\nimport * as React from 'react'\r\n\r\nimport { ElementAppearance } from '../../components/viewers/bim/src/ElementAppearance'\r\nimport { fitToSelection } from '../../components/viewers/bim/src/lib/bimCamera'\r\nimport {\r\n clearSelection,\r\n isolateItems,\r\n selectItems,\r\n setItemsVisible,\r\n showAllItems,\r\n} from '../../components/viewers/bim/src/lib/bimItemActions'\r\nimport {\r\n getItemProperties,\r\n getItemsOfCategory,\r\n} from '../../components/viewers/bim/src/lib/bimQueries'\r\nimport { BimContext } from '../../store/BIM/context'\r\nimport { usePluginId } from '../host/scope'\r\n\r\nimport type { BimItemProperties } from '../../components/viewers/bim/src/lib/bimQueries'\r\nimport type { ModelIdMap } from '../../components/viewers/bim/src/lib/bimTree'\r\nimport type * as OBC from '@thatopen/components'\r\n\r\n/**\r\n * The BIM viewer, as a plugin sees it. Kept out of the `plugins-sdk` barrel: it depends on\r\n * `@thatopen/components` and three at runtime.\r\n */\r\nexport interface BimToolProps {\r\n components: OBC.Components | null\r\n world: OBC.World | null\r\n fragments: OBC.FragmentsManager | null\r\n /** Ids of every loaded model, in load order. */\r\n modelIds: string[]\r\n\r\n /** The live selection, keyed by model id. Updates as the user clicks in the viewport. */\r\n selection: ModelIdMap\r\n\r\n // Properties, not methods, so a plugin can destructure them safely.\r\n select: (items: ModelIdMap) => Promise<void>\r\n clearSelection: () => void\r\n /** Frame the camera on whatever is currently selected. */\r\n fitToSelection: () => Promise<void>\r\n\r\n /** Hides everything except `items`, across every loaded model. */\r\n isolate: (items: ModelIdMap) => Promise<void>\r\n setItemsVisible: (items: ModelIdMap, visible: boolean) => Promise<void>\r\n /** The escape hatch from `isolate`: makes everything visible again. */\r\n showAll: () => Promise<void>\r\n\r\n /**\r\n * Every element of one IFC class, e.g. `getItemsOfCategory('IFCSPACE')`. Spaces\r\n * start hidden, being volumetric, so showing them needs `setItemsVisible` too.\r\n */\r\n getItemsOfCategory: (category: string) => Promise<ModelIdMap>\r\n /** Attributes for the given elements. Omit `attributes` for the default set. */\r\n getProperties: (items: ModelIdMap, attributes?: string[]) => Promise<BimItemProperties[]>\r\n}\r\n\r\n/**\r\n * Thin façade over the `lib/bim*` helpers core itself uses. Colour lives in\r\n * {@link usePluginBimAppearance}, which knows the calling plugin; this cannot.\r\n */\r\nexport function useBimViewer(): BimToolProps {\r\n const { state } = React.useContext(BimContext)\r\n const { bimComponents, world, fragments, modelIds, selection } = state.bim\r\n\r\n return React.useMemo<BimToolProps>(() => ({\r\n components: bimComponents,\r\n world,\r\n fragments,\r\n modelIds,\r\n selection,\r\n\r\n select: async (items: ModelIdMap) => {\r\n if (bimComponents) await selectItems(bimComponents, items)\r\n },\r\n clearSelection: () => {\r\n if (bimComponents) clearSelection(bimComponents)\r\n },\r\n fitToSelection: async () => {\r\n if (bimComponents) await fitToSelection(bimComponents)\r\n },\r\n\r\n isolate: async (items: ModelIdMap) => {\r\n if (bimComponents) await isolateItems(bimComponents, items)\r\n },\r\n setItemsVisible: async (items: ModelIdMap, visible: boolean) => {\r\n if (bimComponents) await setItemsVisible(bimComponents, items, visible)\r\n },\r\n showAll: async () => {\r\n if (bimComponents) await showAllItems(bimComponents)\r\n },\r\n\r\n getItemsOfCategory: async (category: string) =>\r\n bimComponents ? getItemsOfCategory(bimComponents, category) : {},\r\n getProperties: async (items: ModelIdMap, attributes?: string[]) =>\r\n bimComponents ? getItemProperties(bimComponents, items, attributes) : [],\r\n }), [bimComponents, world, fragments, modelIds, selection])\r\n}\r\n\r\nexport interface BimAppearance {\r\n /** `0xRRGGBB`. Omit to keep each element's own colour. */\r\n color?: number\r\n /** `0`–`1`. Omit to leave elements opaque. */\r\n opacity?: number\r\n}\r\n\r\n/** One appearance and the elements wearing it. */\r\nexport interface BimAppearanceGroup {\r\n items: ModelIdMap\r\n appearance: BimAppearance\r\n}\r\n\r\nexport interface PluginBimAppearance {\r\n /**\r\n * Every group in one call, replacing this plugin's previous paint. Calling it per group\r\n * would replace that same entry each time and leave only the last. An empty list clears.\r\n */\r\n setAppearance: (groups: readonly BimAppearanceGroup[]) => void\r\n /** Gives this plugin's elements back their own colours. */\r\n clearAppearance: () => void\r\n}\r\n\r\n/**\r\n * Colour and opacity, bucketed into one `highlight()` per appearance — per element would\r\n * exhaust the model's ~65 500 material slots. Scoped to this plugin, outside the sidebar's undo.\r\n */\r\nexport function usePluginBimAppearance(): PluginBimAppearance {\r\n const pluginId = usePluginId()\r\n const { state } = React.useContext(BimContext)\r\n const { bimComponents } = state.bim\r\n\r\n return React.useMemo<PluginBimAppearance>(() => ({\r\n setAppearance: (groups: readonly BimAppearanceGroup[]) => {\r\n bimComponents?.get(ElementAppearance).setElementAppearance(pluginId, groups)\r\n },\r\n clearAppearance: () => {\r\n bimComponents?.get(ElementAppearance).clearElementAppearance(pluginId)\r\n },\r\n }), [bimComponents, pluginId])\r\n}\r\n\r\nexport type { ModelIdMap, BimItemProperties }\r\n"],"mappings":";AAKA,YAAY,WAAW;AAEvB,SAAS,yBAAyB;AAClC,SAAS,sBAAsB;AAC/B;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP;AAAA,EACE;AAAA,EACA;AAAA,OACK;AACP,SAAS,kBAAkB;AAC3B,SAAS,mBAAmB;AA6CrB,SAAS,eAA6B;AAC3C,QAAM,EAAE,MAAM,IAAI,MAAM,WAAW,UAAU;AAC7C,QAAM,EAAE,eAAe,OAAO,WAAW,UAAU,UAAU,IAAI,MAAM;AAEvE,SA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from './version';
3
3
  export * from './components';
4
+ export { MAP_COLOUR_PALETTE, stringToColour } from '../../components/viewers/map/utils/stringToColour';
4
5
  export { PLUGIN_RUNTIME_SHIMS, PLUGIN_EXTERNALS } from '../host/runtimeShims';
5
6
  export type { RuntimeShim } from '../host/runtimeShims';
6
7
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/core/plugins/sdk/index.ts"],"names":[],"mappings":"AAGA,cAAc,SAAS,CAAA;AACvB,cAAc,WAAW,CAAA;AACzB,cAAc,cAAc,CAAA;AAI5B,OAAO,EAAE,oBAAoB,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAA;AAC7E,YAAY,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/core/plugins/sdk/index.ts"],"names":[],"mappings":"AAGA,cAAc,SAAS,CAAA;AACvB,cAAc,WAAW,CAAA;AACzB,cAAc,cAAc,CAAA;AAG5B,OAAO,EAAE,kBAAkB,EAAE,cAAc,EAAE,MAAM,mDAAmD,CAAA;AAItG,OAAO,EAAE,oBAAoB,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAA;AAC7E,YAAY,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAA"}