@collabdt/core 0.5.1 → 0.5.4

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 +61 -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
@@ -0,0 +1,143 @@
1
+ "use client";
2
+ var __defProp = Object.defineProperty;
3
+ var __defProps = Object.defineProperties;
4
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
5
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
8
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
9
+ var __spreadValues = (a, b) => {
10
+ for (var prop in b || (b = {}))
11
+ if (__hasOwnProp.call(b, prop))
12
+ __defNormalProp(a, prop, b[prop]);
13
+ if (__getOwnPropSymbols)
14
+ for (var prop of __getOwnPropSymbols(b)) {
15
+ if (__propIsEnum.call(b, prop))
16
+ __defNormalProp(a, prop, b[prop]);
17
+ }
18
+ return a;
19
+ };
20
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
21
+ var __objRest = (source, exclude) => {
22
+ var target = {};
23
+ for (var prop in source)
24
+ if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
25
+ target[prop] = source[prop];
26
+ if (source != null && __getOwnPropSymbols)
27
+ for (var prop of __getOwnPropSymbols(source)) {
28
+ if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
29
+ target[prop] = source[prop];
30
+ }
31
+ return target;
32
+ };
33
+ import * as React from "react";
34
+ import { stringToColour } from "../sdk";
35
+ import { usePluginState } from "../sdk/state";
36
+ import { usePluginStore } from "../sdk/store";
37
+ const DEFAULT_ZOOM = 15;
38
+ function toData(_a) {
39
+ var _b = _a, { key: _key } = _b, data = __objRest(_b, ["key"]);
40
+ return data;
41
+ }
42
+ function nextKey() {
43
+ return `m-${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 7)}`;
44
+ }
45
+ function useMarkers() {
46
+ var _a, _b;
47
+ const store = usePluginStore("markers");
48
+ const [selectedKey, setSelectedKey] = usePluginState("selected", null);
49
+ const [openKey, setOpenKey] = usePluginState("open", null);
50
+ const [lastError, setLastError] = usePluginState("lastError", null);
51
+ const attempt = React.useCallback(
52
+ async (action) => {
53
+ try {
54
+ await action();
55
+ setLastError(null);
56
+ return true;
57
+ } catch (error) {
58
+ const message = error instanceof Error ? error.message : String(error);
59
+ console.error("[hello-map] save failed:", error);
60
+ setLastError(message);
61
+ return false;
62
+ }
63
+ },
64
+ [setLastError]
65
+ );
66
+ const markers = React.useMemo(
67
+ () => store.items.map((item) => __spreadProps(__spreadValues({
68
+ key: item.key
69
+ }, item.data), {
70
+ // Records written before `zoom` existed have none, and flyTo would get NaN.
71
+ zoom: typeof item.data.zoom === "number" ? item.data.zoom : DEFAULT_ZOOM
72
+ })),
73
+ [store.items]
74
+ );
75
+ const byKey = React.useMemo(
76
+ () => new Map(markers.map((marker) => [marker.key, marker])),
77
+ [markers]
78
+ );
79
+ const add = React.useCallback(
80
+ async (latitude, longitude, zoom) => {
81
+ const key = nextKey();
82
+ const saved = await attempt(() => store.put(key, {
83
+ name: `Marker ${store.items.length + 1}`,
84
+ latitude,
85
+ longitude,
86
+ zoom,
87
+ colour: stringToColour(key)
88
+ }));
89
+ if (saved) setSelectedKey(key);
90
+ return saved ? key : null;
91
+ },
92
+ [store, setSelectedKey, attempt]
93
+ );
94
+ const patch = React.useCallback(
95
+ async (key, changes) => {
96
+ const current = byKey.get(key);
97
+ if (!current) return;
98
+ await attempt(() => store.put(key, __spreadValues(__spreadValues({}, toData(current)), changes)));
99
+ },
100
+ [store, byKey, attempt]
101
+ );
102
+ const setColour = React.useCallback(
103
+ (key, colour) => patch(key, { colour }),
104
+ [patch]
105
+ );
106
+ const rename = React.useCallback(
107
+ async (key, name) => {
108
+ var _a2;
109
+ const trimmed = name.trim();
110
+ if (!trimmed || trimmed === ((_a2 = byKey.get(key)) == null ? void 0 : _a2.name)) return;
111
+ await patch(key, { name: trimmed });
112
+ },
113
+ [patch, byKey]
114
+ );
115
+ const remove = React.useCallback(
116
+ async (key) => {
117
+ const removed = await attempt(() => store.remove(key));
118
+ if (!removed) return;
119
+ setSelectedKey((current) => current === key ? null : current);
120
+ setOpenKey((current) => current === key ? null : current);
121
+ },
122
+ [store, setSelectedKey, setOpenKey, attempt]
123
+ );
124
+ return {
125
+ markers,
126
+ isLoading: store.isLoading,
127
+ /** The last write that failed, or null. Shown by the tool and the tab. */
128
+ lastError,
129
+ selected: selectedKey === null ? null : (_a = byKey.get(selectedKey)) != null ? _a : null,
130
+ openMarker: openKey === null ? null : (_b = byKey.get(openKey)) != null ? _b : null,
131
+ select: setSelectedKey,
132
+ open: setOpenKey,
133
+ add,
134
+ setColour,
135
+ rename,
136
+ remove
137
+ };
138
+ }
139
+ export {
140
+ DEFAULT_ZOOM,
141
+ useMarkers
142
+ };
143
+ //# sourceMappingURL=markers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/core/plugins/hello-map/markers.ts"],"sourcesContent":["'use client'\r\n\r\n// SPDX-License-Identifier: AGPL-3.0-or-later\r\n// Copyright (C) 2025 Collab Digital Twins\r\n\r\nimport * as React from 'react'\r\n\r\nimport { stringToColour } from '../sdk'\r\nimport { usePluginState } from '../sdk/state'\r\nimport { usePluginStore } from '../sdk/store'\r\n\r\nexport interface MarkerData extends Record<string, unknown> {\r\n name: string\r\n latitude: number\r\n longitude: number\r\n /** The zoom the marker was recorded at, so flying back restores the same view. */\r\n zoom: number\r\n colour: string\r\n}\r\n\r\nexport interface Marker extends MarkerData {\r\n key: string\r\n}\r\n\r\n/** Used when a record was written before `zoom` existed — `T` is a declaration, not a guarantee. */\r\nexport const DEFAULT_ZOOM = 15\r\n\r\n/** One edit path, so a field added to `MarkerData` cannot be dropped by a rename. */\r\nfunction toData({ key: _key, ...data }: Marker): MarkerData {\r\n return data\r\n}\r\n\r\n/** Unique without a counter to keep, so two quick clicks cannot collide. */\r\nfunction nextKey(): string {\r\n return `m-${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 7)}`\r\n}\r\n\r\n/**\r\n * Everything every surface reads. Markers are records, so they survive a reload; the selection\r\n * and the open popup are session state, so they do not belong in the database.\r\n */\r\nexport function useMarkers() {\r\n const store = usePluginStore<MarkerData>('markers')\r\n const [selectedKey, setSelectedKey] = usePluginState<string | null>('selected', null)\r\n const [openKey, setOpenKey] = usePluginState<string | null>('open', null)\r\n // Every write goes through `attempt`, or a rejected save looks like a dead button.\r\n const [lastError, setLastError] = usePluginState<string | null>('lastError', null)\r\n\r\n const attempt = React.useCallback(\r\n async (action: () => Promise<void>) => {\r\n try {\r\n await action()\r\n setLastError(null)\r\n return true\r\n }\r\n catch (error) {\r\n const message = error instanceof Error ? error.message : String(error)\r\n console.error('[hello-map] save failed:', error)\r\n setLastError(message)\r\n return false\r\n }\r\n },\r\n [setLastError],\r\n )\r\n\r\n const markers = React.useMemo<Marker[]>(\r\n () => store.items.map(item => ({\r\n key: item.key,\r\n ...item.data,\r\n // Records written before `zoom` existed have none, and flyTo would get NaN.\r\n zoom: typeof item.data.zoom === 'number' ? item.data.zoom : DEFAULT_ZOOM,\r\n })),\r\n [store.items],\r\n )\r\n\r\n const byKey = React.useMemo(\r\n () => new Map(markers.map(marker => [marker.key, marker])),\r\n [markers],\r\n )\r\n\r\n const add = React.useCallback(\r\n async (latitude: number, longitude: number, zoom: number) => {\r\n const key = nextKey()\r\n\r\n // A palette colour, so a page of markers stays readable and colourblind-safe.\r\n const saved = await attempt(() => store.put(key, {\r\n name: `Marker ${store.items.length + 1}`,\r\n latitude,\r\n longitude,\r\n zoom,\r\n colour: stringToColour(key),\r\n }))\r\n\r\n if (saved) setSelectedKey(key)\r\n return saved ? key : null\r\n },\r\n [store, setSelectedKey, attempt],\r\n )\r\n\r\n /** One edit path, so a field added to `MarkerData` cannot be dropped by a rename. */\r\n const patch = React.useCallback(\r\n async (key: string, changes: Partial<MarkerData>) => {\r\n const current = byKey.get(key)\r\n if (!current) return\r\n\r\n await attempt(() => store.put(key, { ...toData(current), ...changes }))\r\n },\r\n [store, byKey, attempt],\r\n )\r\n\r\n const setColour = React.useCallback(\r\n (key: string, colour: string) => patch(key, { colour }),\r\n [patch],\r\n )\r\n\r\n const rename = React.useCallback(\r\n async (key: string, name: string) => {\r\n const trimmed = name.trim()\r\n // An empty name would leave an unlabelled row and legend entry.\r\n if (!trimmed || trimmed === byKey.get(key)?.name) return\r\n\r\n await patch(key, { name: trimmed })\r\n },\r\n [patch, byKey],\r\n )\r\n\r\n const remove = React.useCallback(\r\n async (key: string) => {\r\n const removed = await attempt(() => store.remove(key))\r\n if (!removed) return\r\n\r\n setSelectedKey(current => (current === key ? null : current))\r\n setOpenKey(current => (current === key ? null : current))\r\n },\r\n [store, setSelectedKey, setOpenKey, attempt],\r\n )\r\n\r\n return {\r\n markers,\r\n isLoading: store.isLoading,\r\n /** The last write that failed, or null. Shown by the tool and the tab. */\r\n lastError,\r\n selected: selectedKey === null ? null : byKey.get(selectedKey) ?? null,\r\n openMarker: openKey === null ? null : byKey.get(openKey) ?? null,\r\n select: setSelectedKey,\r\n open: setOpenKey,\r\n add,\r\n setColour,\r\n rename,\r\n remove,\r\n }\r\n}\r\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAKA,YAAY,WAAW;AAEvB,SAAS,sBAAsB;AAC/B,SAAS,sBAAsB;AAC/B,SAAS,sBAAsB;AAgBxB,MAAM,eAAe;AAG5B,SAAS,OAAO,IAA4C;AAA5C,eAAE,OAAK,KA5BvB,IA4BgB,IAAgB,iBAAhB,IAAgB,CAAd;AAChB,SAAO;AACT;AAGA,SAAS,UAAkB;AACzB,SAAO,KAAK,KAAK,IAAI,EAAE,SAAS,EAAE,CAAC,IAAI,KAAK,OAAO,EAAE,SAAS,EAAE,EAAE,MAAM,GAAG,CAAC,CAAC;AAC/E;AAMO,SAAS,aAAa;AAzC7B;AA0CE,QAAM,QAAQ,eAA2B,SAAS;AAClD,QAAM,CAAC,aAAa,cAAc,IAAI,eAA8B,YAAY,IAAI;AACpF,QAAM,CAAC,SAAS,UAAU,IAAI,eAA8B,QAAQ,IAAI;AAExE,QAAM,CAAC,WAAW,YAAY,IAAI,eAA8B,aAAa,IAAI;AAEjF,QAAM,UAAU,MAAM;AAAA,IACpB,OAAO,WAAgC;AACrC,UAAI;AACF,cAAM,OAAO;AACb,qBAAa,IAAI;AACjB,eAAO;AAAA,MACT,SACO,OAAO;AACZ,cAAM,UAAU,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK;AACrE,gBAAQ,MAAM,4BAA4B,KAAK;AAC/C,qBAAa,OAAO;AACpB,eAAO;AAAA,MACT;AAAA,IACF;AAAA,IACA,CAAC,YAAY;AAAA,EACf;AAEA,QAAM,UAAU,MAAM;AAAA,IACpB,MAAM,MAAM,MAAM,IAAI,UAAS;AAAA,MAC7B,KAAK,KAAK;AAAA,OACP,KAAK,OAFqB;AAAA;AAAA,MA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AAElD,YAAM,MAAM,KAAK,EAAE,MAAM,QAAQ,CAAC;AAAA,IACpC;AAAA,IACA,CAAC,OAAO,KAAK;AAAA,EACf;AAEA,QAAM,SAAS,MAAM;AAAA,IACnB,OAAO,QAAgB;AACrB,YAAM,UAAU,MAAM,QAAQ,MAAM,MAAM,OAAO,GAAG,CAAC;AACrD,UAAI,CAAC,QAAS;AAEd,qBAAe,aAAY,YAAY,MAAM,OAAO,OAAQ;AAC5D,iBAAW,aAAY,YAAY,MAAM,OAAO,OAAQ;AAAA,IAC1D;AAAA,IACA,CAAC,OAAO,gBAAgB,YAAY,OAAO;AAAA,EAC7C;AAEA,SAAO;AAAA,IACL;AAAA,IACA,WAAW,MAAM;AAAA;AAAA,IAEjB;AAAA,IACA,UAAU,gBAAgB,OAAO,QAAO,WAAM,IAAI,WAAW,MAArB,YAA0B;AAAA,IAClE,YAAY,YAAY,OAAO,QAAO,WAAM,IAAI,OAAO,MAAjB,YAAsB;AAAA,IAC5D,QAAQ;AAAA,IACR,MAAM;AAAA,IACN;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF;","names":["_a"]}
@@ -0,0 +1,10 @@
1
+ import * as React from 'react';
2
+ import type { ViewerKey } from '../../types/dbTypes';
3
+ /**
4
+ * Renders the `data.pages` contribution the viewer key names. The frame mirrors
5
+ * `PluginsManager`, so a plugin page is indistinguishable from a built-in one.
6
+ */
7
+ export declare function PluginDataPageHost({ viewer }: {
8
+ viewer: ViewerKey;
9
+ }): React.JSX.Element;
10
+ //# sourceMappingURL=PluginDataPageHost.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PluginDataPageHost.d.ts","sourceRoot":"","sources":["../../../../src/core/plugins/host/PluginDataPageHost.tsx"],"names":[],"mappings":"AAMA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAgB9B,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAA;AAMpD;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,EAAE,MAAM,EAAE,EAAE;IAAE,MAAM,EAAE,SAAS,CAAA;CAAE,qBAcnE"}
@@ -0,0 +1,142 @@
1
+ "use client";
2
+ var __defProp = Object.defineProperty;
3
+ var __defProps = Object.defineProperties;
4
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
5
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
8
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
9
+ var __spreadValues = (a, b) => {
10
+ for (var prop in b || (b = {}))
11
+ if (__hasOwnProp.call(b, prop))
12
+ __defNormalProp(a, prop, b[prop]);
13
+ if (__getOwnPropSymbols)
14
+ for (var prop of __getOwnPropSymbols(b)) {
15
+ if (__propIsEnum.call(b, prop))
16
+ __defNormalProp(a, prop, b[prop]);
17
+ }
18
+ return a;
19
+ };
20
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
21
+ import { jsx, jsxs } from "react/jsx-runtime";
22
+ import { useTranslations } from "next-intl";
23
+ import * as React from "react";
24
+ import {
25
+ Breadcrumb,
26
+ BreadcrumbItem,
27
+ BreadcrumbList,
28
+ BreadcrumbPage
29
+ } from "../../components/ui/Breadcrumb";
30
+ import { Input } from "../../components/ui/Input";
31
+ import { usePluginMessageLookup } from "../sdk/messages";
32
+ import { parsePluginViewerKey } from "./pluginViewerKey";
33
+ import { usePluginConfigs, usePluginContributions } from "./provider";
34
+ import { PluginScopeProvider } from "./scope";
35
+ import { resolvePluginIcon } from "./usePluginToolbarTools";
36
+ function PluginDataPageHost({ viewer }) {
37
+ const registrations = usePluginContributions("data.pages");
38
+ const target = parsePluginViewerKey(viewer);
39
+ const registration = target ? registrations.find(
40
+ (candidate) => candidate.pluginId === target.pluginId && candidate.id === target.pageId
41
+ ) : void 0;
42
+ if (!registration) return null;
43
+ return /* @__PURE__ */ jsx(PluginDataPage, { registration }, viewer);
44
+ }
45
+ function PluginDataPage({ registration }) {
46
+ const tData = useTranslations("DataMenu");
47
+ const message = usePluginMessageLookup();
48
+ const configs = usePluginConfigs();
49
+ const [searchTerm, setSearchTerm] = React.useState("");
50
+ const title = message(registration.pluginId, registration.titleKey, registration.titleKey);
51
+ const Icon = resolvePluginIcon(registration.icon);
52
+ return /* @__PURE__ */ jsx("div", { className: "sm:p-2 overflow-hidden bg-[#fafafa] h-full", children: /* @__PURE__ */ jsx("div", { className: "bg-background rounded-xl shadow h-full min-h-0", children: /* @__PURE__ */ jsxs("div", { className: "flex flex-col h-full min-h-0", children: [
53
+ /* @__PURE__ */ jsx("div", { className: "flex flex-row gap-2 justify-start items-center px-3 py-4 relative", children: /* @__PURE__ */ jsx(Breadcrumb, { className: "px-3", children: /* @__PURE__ */ jsx(BreadcrumbList, { children: /* @__PURE__ */ jsx(BreadcrumbItem, { children: /* @__PURE__ */ jsx(BreadcrumbPage, { children: title }) }) }) }) }),
54
+ /* @__PURE__ */ jsx("div", { className: "flex flex-row justify-between items-center px-6 py-6", children: /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
55
+ /* @__PURE__ */ jsx(Icon, { className: "h-8 w-8" }),
56
+ /* @__PURE__ */ jsx("h1", { className: "text-2xl text-foreground", children: title })
57
+ ] }) }),
58
+ /* @__PURE__ */ jsx("div", { className: "flex flex-col sm:flex-row sm:justify-end items-stretch sm:items-center px-3 sm:px-6 py-4 gap-3 sm:gap-4", children: /* @__PURE__ */ jsx("div", { className: "w-full sm:w-96", children: /* @__PURE__ */ jsx(
59
+ Input,
60
+ {
61
+ placeholder: `${tData("searchPlaceholder")} ${title}...`,
62
+ value: searchTerm,
63
+ onChange: (event) => setSearchTerm(event.target.value),
64
+ "aria-label": `${tData("searchPlaceholder")} ${title}`
65
+ }
66
+ ) }) }),
67
+ /* @__PURE__ */ jsx("div", { className: "flex-1 min-h-0 overflow-y-auto px-3 sm:px-6 pb-8", children: /* @__PURE__ */ jsx(
68
+ PluginScopeProvider,
69
+ {
70
+ pluginId: registration.pluginId,
71
+ config: configs[registration.pluginId],
72
+ children: /* @__PURE__ */ jsx(
73
+ PluginDataTable,
74
+ {
75
+ registration,
76
+ searchTerm
77
+ },
78
+ `${registration.pluginId}:${registration.id}`
79
+ )
80
+ }
81
+ ) })
82
+ ] }) }) });
83
+ }
84
+ function PluginDataTable({ registration, searchTerm }) {
85
+ const t = useTranslations("PluginDataPage");
86
+ const message = usePluginMessageLookup();
87
+ const { rows, isLoading, onRowClick } = registration.useRows();
88
+ const filtered = React.useMemo(
89
+ () => filterRows(rows, registration.searchKeys, searchTerm),
90
+ [rows, registration.searchKeys, searchTerm]
91
+ );
92
+ if (isLoading && rows.length === 0) return /* @__PURE__ */ jsx(Empty, { text: t("loading") });
93
+ if (filtered.length === 0) {
94
+ if (searchTerm.trim()) return /* @__PURE__ */ jsx(Empty, { text: t("noResults", { query: searchTerm.trim() }) });
95
+ const empty = registration.emptyKey ? message(registration.pluginId, registration.emptyKey, registration.emptyKey) : t("empty");
96
+ return /* @__PURE__ */ jsx(Empty, { text: empty });
97
+ }
98
+ return /* @__PURE__ */ jsx("div", { className: "overflow-x-auto", children: /* @__PURE__ */ jsxs("table", { className: "w-full text-sm", children: [
99
+ /* @__PURE__ */ jsx("thead", { children: /* @__PURE__ */ jsx("tr", { className: "border-b text-left text-muted-foreground", children: registration.columns.map((column) => /* @__PURE__ */ jsx("th", { scope: "col", className: "px-3 py-2 font-medium", children: message(registration.pluginId, column.labelKey, column.labelKey) }, column.key)) }) }),
100
+ /* @__PURE__ */ jsx("tbody", { children: filtered.map((row, index) => /* @__PURE__ */ jsx(
101
+ "tr",
102
+ __spreadProps(__spreadValues({
103
+ className: onRowClick ? "border-b hover:bg-accent/50 cursor-pointer" : "border-b"
104
+ }, onRowClick ? {
105
+ role: "button",
106
+ tabIndex: 0,
107
+ onClick: () => onRowClick(row),
108
+ onKeyDown: (event) => {
109
+ if (event.key !== "Enter" && event.key !== " ") return;
110
+ event.preventDefault();
111
+ onRowClick(row);
112
+ }
113
+ } : {}), {
114
+ children: registration.columns.map((column) => /* @__PURE__ */ jsx("td", { className: "px-3 py-2", children: column.render ? column.render(row) : formatCell(row[column.key]) }, column.key))
115
+ }),
116
+ rowKey(row, index)
117
+ )) })
118
+ ] }) });
119
+ }
120
+ function rowKey(row, index) {
121
+ return typeof row.key === "string" ? row.key : String(index);
122
+ }
123
+ function formatCell(value) {
124
+ if (typeof value === "string") return value;
125
+ if (typeof value === "number" || typeof value === "boolean") return String(value);
126
+ return "";
127
+ }
128
+ function filterRows(rows, searchKeys, searchTerm) {
129
+ const query = searchTerm.trim().toLowerCase();
130
+ if (!query) return rows;
131
+ return rows.filter((row) => {
132
+ const keys = searchKeys != null ? searchKeys : Object.keys(row);
133
+ return keys.some((key) => formatCell(row[key]).toLowerCase().includes(query));
134
+ });
135
+ }
136
+ function Empty({ text }) {
137
+ return /* @__PURE__ */ jsx("p", { className: "py-12 text-center text-sm text-muted-foreground", children: text });
138
+ }
139
+ export {
140
+ PluginDataPageHost
141
+ };
142
+ //# sourceMappingURL=PluginDataPageHost.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/core/plugins/host/PluginDataPageHost.tsx"],"sourcesContent":["'use client'\r\n\r\n// SPDX-License-Identifier: AGPL-3.0-or-later\r\n// Copyright (C) 2025 Collab Digital Twins\r\n\r\nimport { useTranslations } from 'next-intl'\r\nimport * as React from 'react'\r\n\r\nimport {\r\n Breadcrumb,\r\n BreadcrumbItem,\r\n BreadcrumbList,\r\n BreadcrumbPage,\r\n} from '../../components/ui/Breadcrumb'\r\nimport { Input } from '../../components/ui/Input'\r\nimport { usePluginMessageLookup } from '../sdk/messages'\r\n\r\nimport { parsePluginViewerKey } from './pluginViewerKey'\r\nimport { usePluginConfigs, usePluginContributions } from './provider'\r\nimport { PluginScopeProvider } from './scope'\r\nimport { resolvePluginIcon } from './usePluginToolbarTools'\r\n\r\nimport type { ViewerKey } from '../../types/dbTypes'\r\nimport type { DataPageRegistration } from '../sdk/types'\r\n\r\ntype Row = Record<string, unknown>\r\ntype Registration = DataPageRegistration & { pluginId: string }\r\n\r\n/**\r\n * Renders the `data.pages` contribution the viewer key names. The frame mirrors\r\n * `PluginsManager`, so a plugin page is indistinguishable from a built-in one.\r\n */\r\nexport function PluginDataPageHost({ viewer }: { viewer: ViewerKey }) {\r\n const registrations = usePluginContributions('data.pages')\r\n const target = parsePluginViewerKey(viewer)\r\n\r\n const registration = target\r\n ? registrations.find(\r\n candidate => candidate.pluginId === target.pluginId && candidate.id === target.pageId,\r\n )\r\n : undefined\r\n\r\n // The key comes from the URL, so rendering nothing lets `Viewer` fall back.\r\n if (!registration) return null\r\n\r\n return <PluginDataPage key={viewer} registration={registration} />\r\n}\r\n\r\nfunction PluginDataPage({ registration }: { registration: Registration }) {\r\n const tData = useTranslations('DataMenu')\r\n const message = usePluginMessageLookup()\r\n const configs = usePluginConfigs()\r\n const [searchTerm, setSearchTerm] = React.useState('')\r\n\r\n const title = message(registration.pluginId, registration.titleKey, registration.titleKey)\r\n const Icon = resolvePluginIcon(registration.icon)\r\n\r\n return (\r\n <div className=\"sm:p-2 overflow-hidden bg-[#fafafa] h-full\">\r\n <div className=\"bg-background rounded-xl shadow h-full min-h-0\">\r\n <div className=\"flex flex-col h-full min-h-0\">\r\n\r\n <div className=\"flex flex-row gap-2 justify-start items-center px-3 py-4 relative\">\r\n <Breadcrumb className=\"px-3\">\r\n <BreadcrumbList>\r\n <BreadcrumbItem>\r\n <BreadcrumbPage>{title}</BreadcrumbPage>\r\n </BreadcrumbItem>\r\n </BreadcrumbList>\r\n </Breadcrumb>\r\n </div>\r\n\r\n <div className=\"flex flex-row justify-between items-center px-6 py-6\">\r\n <div className=\"flex items-center gap-2\">\r\n <Icon className=\"h-8 w-8\" />\r\n <h1 className=\"text-2xl text-foreground\">{title}</h1>\r\n </div>\r\n </div>\r\n\r\n <div className=\"flex flex-col sm:flex-row sm:justify-end items-stretch sm:items-center px-3 sm:px-6 py-4 gap-3 sm:gap-4\">\r\n <div className=\"w-full sm:w-96\">\r\n <Input\r\n placeholder={`${tData('searchPlaceholder')} ${title}...`}\r\n value={searchTerm}\r\n onChange={event => setSearchTerm(event.target.value)}\r\n aria-label={`${tData('searchPlaceholder')} ${title}`}\r\n />\r\n </div>\r\n </div>\r\n\r\n <div className=\"flex-1 min-h-0 overflow-y-auto px-3 sm:px-6 pb-8\">\r\n {/* The rows hook and the cell renderers are the plugin's, so they run inside its\r\n scope and can reach usePluginStore, usePluginState and the rest. */}\r\n <PluginScopeProvider\r\n pluginId={registration.pluginId}\r\n config={configs[registration.pluginId]}\r\n >\r\n <PluginDataTable\r\n key={`${registration.pluginId}:${registration.id}`}\r\n registration={registration}\r\n searchTerm={searchTerm}\r\n />\r\n </PluginScopeProvider>\r\n </div>\r\n\r\n </div>\r\n </div>\r\n </div>\r\n )\r\n}\r\n\r\ninterface TableProps {\r\n registration: Registration\r\n searchTerm: string\r\n}\r\n\r\nfunction PluginDataTable({ registration, searchTerm }: TableProps) {\r\n const t = useTranslations('PluginDataPage')\r\n const message = usePluginMessageLookup()\r\n const { rows, isLoading, onRowClick } = registration.useRows()\r\n\r\n const filtered = React.useMemo(\r\n () => filterRows(rows, registration.searchKeys, searchTerm),\r\n [rows, registration.searchKeys, searchTerm],\r\n )\r\n\r\n if (isLoading && rows.length === 0) return <Empty text={t('loading')} />\r\n\r\n if (filtered.length === 0) {\r\n if (searchTerm.trim()) return <Empty text={t('noResults', { query: searchTerm.trim() })} />\r\n\r\n const empty = registration.emptyKey\r\n ? message(registration.pluginId, registration.emptyKey, registration.emptyKey)\r\n : t('empty')\r\n\r\n return <Empty text={empty} />\r\n }\r\n\r\n return (\r\n <div className=\"overflow-x-auto\">\r\n <table className=\"w-full text-sm\">\r\n <thead>\r\n <tr className=\"border-b text-left text-muted-foreground\">\r\n {registration.columns.map(column => (\r\n <th key={column.key} scope=\"col\" className=\"px-3 py-2 font-medium\">\r\n {message(registration.pluginId, column.labelKey, column.labelKey)}\r\n </th>\r\n ))}\r\n </tr>\r\n </thead>\r\n <tbody>\r\n {filtered.map((row, index) => (\r\n <tr\r\n key={rowKey(row, index)}\r\n className={onRowClick ? 'border-b hover:bg-accent/50 cursor-pointer' : 'border-b'}\r\n // Interactive only when the plugin gave it something to do.\r\n {...(onRowClick\r\n ? {\r\n role: 'button' as const,\r\n tabIndex: 0,\r\n onClick: () => onRowClick(row),\r\n onKeyDown: (event: React.KeyboardEvent) => {\r\n if (event.key !== 'Enter' && event.key !== ' ') return\r\n event.preventDefault()\r\n onRowClick(row)\r\n },\r\n }\r\n : {})}\r\n >\r\n {registration.columns.map(column => (\r\n <td key={column.key} className=\"px-3 py-2\">\r\n {column.render ? column.render(row) : formatCell(row[column.key])}\r\n </td>\r\n ))}\r\n </tr>\r\n ))}\r\n </tbody>\r\n </table>\r\n </div>\r\n )\r\n}\r\n\r\n/** A plugin's own `key` when it supplied one, so a re-render does not remount every row. */\r\nfunction rowKey(row: Row, index: number): string {\r\n return typeof row.key === 'string' ? row.key : String(index)\r\n}\r\n\r\n// Non-primitives render empty rather than \"[object Object]\"; use a column `render` instead.\r\nfunction formatCell(value: unknown): string {\r\n if (typeof value === 'string') return value\r\n if (typeof value === 'number' || typeof value === 'boolean') return String(value)\r\n return ''\r\n}\r\n\r\nfunction filterRows(rows: Row[], searchKeys: string[] | undefined, searchTerm: string): Row[] {\r\n const query = searchTerm.trim().toLowerCase()\r\n if (!query) return rows\r\n\r\n return rows.filter((row) => {\r\n const keys = searchKeys ?? Object.keys(row)\r\n return keys.some(key => formatCell(row[key]).toLowerCase().includes(query))\r\n })\r\n}\r\n\r\nfunction Empty({ text }: { text: string }) {\r\n return <p className=\"py-12 text-center text-sm text-muted-foreground\">{text}</p>\r\n}\r\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AA6CS,cA4BG,YA5BH;AAxCT,SAAS,uBA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AO,KAAK,KAAK,SAAO,WAAW,IAAI,GAAG,CAAC,EAAE,YAAY,EAAE,SAAS,KAAK,CAAC;AAAA,EAC5E,CAAC;AACH;AAEA,SAAS,MAAM,EAAE,KAAK,GAAqB;AACzC,SAAO,oBAAC,OAAE,WAAU,mDAAmD,gBAAK;AAC9E;","names":[]}
@@ -0,0 +1,7 @@
1
+ import * as React from 'react';
2
+ /**
3
+ * Renders whatever plugin dialogs are open. Mounted once, by `AppProvider`, inside
4
+ * `PluginHostProvider` — never by a plugin, and never more than once.
5
+ */
6
+ export declare function PluginDialogHost(): React.JSX.Element;
7
+ //# sourceMappingURL=PluginDialogHost.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PluginDialogHost.d.ts","sourceRoot":"","sources":["../../../../src/core/plugins/host/PluginDialogHost.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAwB9B;;;GAGG;AACH,wBAAgB,gBAAgB,sBA0B/B"}
@@ -0,0 +1,80 @@
1
+ "use client";
2
+ var __defProp = Object.defineProperty;
3
+ var __defProps = Object.defineProperties;
4
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
5
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
8
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
9
+ var __spreadValues = (a, b) => {
10
+ for (var prop in b || (b = {}))
11
+ if (__hasOwnProp.call(b, prop))
12
+ __defNormalProp(a, prop, b[prop]);
13
+ if (__getOwnPropSymbols)
14
+ for (var prop of __getOwnPropSymbols(b)) {
15
+ if (__propIsEnum.call(b, prop))
16
+ __defNormalProp(a, prop, b[prop]);
17
+ }
18
+ return a;
19
+ };
20
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
21
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
22
+ import {
23
+ Dialog,
24
+ DialogContent,
25
+ DialogHeader,
26
+ DialogTitle
27
+ } from "../../components/ui/Dialog";
28
+ import { usePluginMessage } from "../sdk/messages";
29
+ import { usePluginDialogControls, usePluginDialogStack } from "./dialogs";
30
+ import { usePluginConfigs, usePluginContributions } from "./provider";
31
+ import { PluginScopeProvider } from "./scope";
32
+ const SIZE_CLASS = {
33
+ sm: "sm:max-w-sm",
34
+ md: "sm:max-w-lg",
35
+ lg: "sm:max-w-3xl",
36
+ xl: "sm:max-w-5xl"
37
+ };
38
+ function PluginDialogHost() {
39
+ const stack = usePluginDialogStack();
40
+ const registrations = usePluginContributions("ui.dialogs");
41
+ const { close } = usePluginDialogControls();
42
+ return /* @__PURE__ */ jsx(Fragment, { children: stack.map((entry) => {
43
+ const registration = registrations.find(
44
+ (candidate) => candidate.pluginId === entry.pluginId && candidate.id === entry.dialogId
45
+ );
46
+ if (!registration) return null;
47
+ return /* @__PURE__ */ jsx(
48
+ PluginDialogFrame,
49
+ {
50
+ entry,
51
+ registration,
52
+ onClose: () => close(entry.pluginId, entry.dialogId)
53
+ },
54
+ entry.instanceId
55
+ );
56
+ }) });
57
+ }
58
+ function PluginDialogFrame({ entry, registration, onClose }) {
59
+ var _a;
60
+ const title = usePluginMessage(entry.pluginId, registration.titleKey, registration.titleKey);
61
+ const configs = usePluginConfigs();
62
+ const Body = registration.component;
63
+ return /* @__PURE__ */ jsx(Dialog, { open: true, onOpenChange: (next) => {
64
+ if (!next) onClose();
65
+ }, children: /* @__PURE__ */ jsxs(
66
+ DialogContent,
67
+ {
68
+ className: SIZE_CLASS[(_a = registration.size) != null ? _a : "md"],
69
+ "aria-describedby": void 0,
70
+ children: [
71
+ /* @__PURE__ */ jsx(DialogHeader, { children: /* @__PURE__ */ jsx(DialogTitle, { children: title }) }),
72
+ /* @__PURE__ */ jsx(PluginScopeProvider, { pluginId: entry.pluginId, config: configs[entry.pluginId], children: /* @__PURE__ */ jsx(Body, __spreadProps(__spreadValues({}, entry.props), { close: onClose })) })
73
+ ]
74
+ }
75
+ ) });
76
+ }
77
+ export {
78
+ PluginDialogHost
79
+ };
80
+ //# sourceMappingURL=PluginDialogHost.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/core/plugins/host/PluginDialogHost.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 {\r\n Dialog,\r\n DialogContent,\r\n DialogHeader,\r\n DialogTitle,\r\n} from '../../components/ui/Dialog'\r\nimport { usePluginMessage } from '../sdk/messages'\r\n\r\nimport { usePluginDialogControls, usePluginDialogStack } from './dialogs'\r\nimport { usePluginConfigs, usePluginContributions } from './provider'\r\nimport { PluginScopeProvider } from './scope'\r\n\r\nimport type { OpenDialog } from './dialogs'\r\nimport type { DialogRegistration } from '../sdk/types'\r\n\r\nconst SIZE_CLASS: Record<NonNullable<DialogRegistration['size']>, string> = {\r\n sm: 'sm:max-w-sm',\r\n md: 'sm:max-w-lg',\r\n lg: 'sm:max-w-3xl',\r\n xl: 'sm:max-w-5xl',\r\n}\r\n\r\n/**\r\n * Renders whatever plugin dialogs are open. Mounted once, by `AppProvider`, inside\r\n * `PluginHostProvider` — never by a plugin, and never more than once.\r\n */\r\nexport function PluginDialogHost() {\r\n const stack = usePluginDialogStack()\r\n const registrations = usePluginContributions('ui.dialogs')\r\n const { close } = usePluginDialogControls()\r\n\r\n return (\r\n <>\r\n {stack.map((entry) => {\r\n const registration = registrations.find(\r\n candidate => candidate.pluginId === entry.pluginId && candidate.id === entry.dialogId,\r\n )\r\n\r\n // Its plugin may have been disabled mid-flight, leaving nothing to render.\r\n if (!registration) return null\r\n\r\n return (\r\n <PluginDialogFrame\r\n key={entry.instanceId}\r\n entry={entry}\r\n registration={registration}\r\n onClose={() => close(entry.pluginId, entry.dialogId)}\r\n />\r\n )\r\n })}\r\n </>\r\n )\r\n}\r\n\r\ninterface FrameProps {\r\n entry: OpenDialog\r\n registration: DialogRegistration & { pluginId: string }\r\n onClose: () => void\r\n}\r\n\r\nfunction PluginDialogFrame({ entry, registration, onClose }: FrameProps) {\r\n const title = usePluginMessage(entry.pluginId, registration.titleKey, registration.titleKey)\r\n const configs = usePluginConfigs()\r\n const Body = registration.component as React.ComponentType<Record<string, unknown>>\r\n\r\n return (\r\n <Dialog open onOpenChange={(next) => { if (!next) onClose() }}>\r\n {/* No description: the body is the plugin's, so core has nothing to say about it.\r\n Passing undefined is how Radix is told that is deliberate rather than an omission. */}\r\n <DialogContent\r\n className={SIZE_CLASS[registration.size ?? 'md']}\r\n aria-describedby={undefined}\r\n >\r\n <DialogHeader>\r\n <DialogTitle>{title}</DialogTitle>\r\n </DialogHeader>\r\n\r\n <PluginScopeProvider pluginId={entry.pluginId} config={configs[entry.pluginId]}>\r\n <Body {...entry.props} close={onClose} />\r\n </PluginScopeProvider>\r\n </DialogContent>\r\n </Dialog>\r\n )\r\n}\r\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAuCI,mBAUM,KA2BJ,YArCF;AAhCJ;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,wBAAwB;AAEjC,SAAS,yBAAyB,4BAA4B;AAC9D,SAAS,kBAAkB,8BAA8B;AACzD,SAAS,2BAA2B;AAKpC,MAAM,aAAsE;AAAA,EAC1E,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AACN;AAMO,SAAS,mBAAmB;AACjC,QAAM,QAAQ,qBAAqB;AACnC,QAAM,gBAAgB,uBAAuB,YAAY;AACzD,QAAM,EAAE,MAAM,IAAI,wBAAwB;AAE1C,SACE,gCACG,gBAAM,IAAI,CAAC,UAAU;AACpB,UAAM,eAAe,cAAc;AAAA,MACjC,eAAa,UAAU,aAAa,MAAM,YAAY,UAAU,OAAO,MAAM;AAAA,IAC/E;AAGA,QAAI,CAAC,aAAc,QAAO;AAE1B,WACE;AAAA,MAAC;AAAA;AAAA,QAEC;AAAA,QACA;AAAA,QACA,SAAS,MAAM,MAAM,MAAM,UAAU,MAAM,QAAQ;AAAA;AAAA,MAH9C,MAAM;AAAA,IAIb;AAAA,EAEJ,CAAC,GACH;AAEJ;AAQA,SAAS,kBAAkB,EAAE,OAAO,cAAc,QAAQ,GAAe;AAnEzE;AAoEE,QAAM,QAAQ,iBAAiB,MAAM,UAAU,aAAa,UAAU,aAAa,QAAQ;AAC3F,QAAM,UAAU,iBAAiB;AACjC,QAAM,OAAO,aAAa;AAE1B,SACE,oBAAC,UAAO,MAAI,MAAC,cAAc,CAAC,SAAS;AAAE,QAAI,CAAC,KAAM,SAAQ;AAAA,EAAE,GAG1D;AAAA,IAAC;AAAA;AAAA,MACC,WAAW,YAAW,kBAAa,SAAb,YAAqB,IAAI;AAAA,MAC/C,oBAAkB;AAAA,MAElB;AAAA,4BAAC,gBACC,8BAAC,eAAa,iBAAM,GACtB;AAAA,QAEA,oBAAC,uBAAoB,UAAU,MAAM,UAAU,QAAQ,QAAQ,MAAM,QAAQ,GAC3E,8BAAC,uCAAS,MAAM,QAAf,EAAsB,OAAO,UAAS,GACzC;AAAA;AAAA;AAAA,EACF,GACF;AAEJ;","names":[]}
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Mounts every `map.layers` contribution for as long as the map exists — a toolbar panel
3
+ * unmounts when its dropdown closes and would take its layers with it.
4
+ */
5
+ export declare function PluginMapLayerHost(): import("react").JSX.Element;
6
+ //# sourceMappingURL=PluginMapLayerHost.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PluginMapLayerHost.d.ts","sourceRoot":"","sources":["../../../../src/core/plugins/host/PluginMapLayerHost.tsx"],"names":[],"mappings":"AAUA;;;GAGG;AACH,wBAAgB,kBAAkB,gCAsBjC"}
@@ -0,0 +1,26 @@
1
+ "use client";
2
+ import { Fragment, jsx } from "react/jsx-runtime";
3
+ import { useMapViewer } from "../sdk/mapViewer";
4
+ import { usePluginConfigs, usePluginContributions } from "./provider";
5
+ import { PluginScopeProvider } from "./scope";
6
+ function PluginMapLayerHost() {
7
+ const registrations = usePluginContributions("map.layers");
8
+ const configs = usePluginConfigs();
9
+ const { map } = useMapViewer();
10
+ return /* @__PURE__ */ jsx(Fragment, { children: registrations.map((registration) => {
11
+ const Layer = registration.component;
12
+ return /* @__PURE__ */ jsx(
13
+ PluginScopeProvider,
14
+ {
15
+ pluginId: registration.pluginId,
16
+ config: configs[registration.pluginId],
17
+ children: /* @__PURE__ */ jsx(Layer, { map })
18
+ },
19
+ `${registration.pluginId}:${registration.id}`
20
+ );
21
+ }) });
22
+ }
23
+ export {
24
+ PluginMapLayerHost
25
+ };
26
+ //# sourceMappingURL=PluginMapLayerHost.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/core/plugins/host/PluginMapLayerHost.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 { useMapViewer } from '../sdk/mapViewer'\r\n\r\nimport { usePluginConfigs, usePluginContributions } from './provider'\r\nimport { PluginScopeProvider } from './scope'\r\n\r\n/**\r\n * Mounts every `map.layers` contribution for as long as the map exists — a toolbar panel\r\n * unmounts when its dropdown closes and would take its layers with it.\r\n */\r\nexport function PluginMapLayerHost() {\r\n const registrations = usePluginContributions('map.layers')\r\n const configs = usePluginConfigs()\r\n const { map } = useMapViewer()\r\n\r\n return (\r\n <>\r\n {registrations.map((registration) => {\r\n const Layer = registration.component\r\n\r\n return (\r\n <PluginScopeProvider\r\n key={`${registration.pluginId}:${registration.id}`}\r\n pluginId={registration.pluginId}\r\n config={configs[registration.pluginId]}\r\n >\r\n <Layer map={map} />\r\n </PluginScopeProvider>\r\n )\r\n })}\r\n </>\r\n )\r\n}\r\n"],"mappings":";AAoBI,mBAUQ,WAVR;AAfJ,SAAS,oBAAoB;AAE7B,SAAS,kBAAkB,8BAA8B;AACzD,SAAS,2BAA2B;AAM7B,SAAS,qBAAqB;AACnC,QAAM,gBAAgB,uBAAuB,YAAY;AACzD,QAAM,UAAU,iBAAiB;AACjC,QAAM,EAAE,IAAI,IAAI,aAAa;AAE7B,SACE,gCACG,wBAAc,IAAI,CAAC,iBAAiB;AACnC,UAAM,QAAQ,aAAa;AAE3B,WACE;AAAA,MAAC;AAAA;AAAA,QAEC,UAAU,aAAa;AAAA,QACvB,QAAQ,QAAQ,aAAa,QAAQ;AAAA,QAErC,8BAAC,SAAM,KAAU;AAAA;AAAA,MAJZ,GAAG,aAAa,QAAQ,IAAI,aAAa,EAAE;AAAA,IAKlD;AAAA,EAEJ,CAAC,GACH;AAEJ;","names":[]}
@@ -0,0 +1,25 @@
1
+ import * as React from 'react';
2
+ export interface OpenDialog {
3
+ pluginId: string;
4
+ dialogId: string;
5
+ props: Record<string, unknown>;
6
+ /** Monotonic, so opening the same dialog twice stacks rather than replacing. */
7
+ instanceId: number;
8
+ }
9
+ interface DialogControls {
10
+ open: (pluginId: string, dialogId: string, props?: Record<string, unknown>) => void;
11
+ close: (pluginId: string, dialogId?: string) => void;
12
+ closePlugin: (pluginId: string) => void;
13
+ }
14
+ /**
15
+ * Holds every open plugin dialog, above all of a plugin's surfaces so one outlives whatever
16
+ * opened it. State only: the provider renders this, so importing it back would cycle.
17
+ */
18
+ export declare function PluginDialogProvider({ children }: {
19
+ children: React.ReactNode;
20
+ }): React.JSX.Element;
21
+ /** Throws outside the provider rather than silently doing nothing when a plugin opens a dialog. */
22
+ export declare function usePluginDialogControls(): DialogControls;
23
+ export declare function usePluginDialogStack(): OpenDialog[];
24
+ export {};
25
+ //# sourceMappingURL=dialogs.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dialogs.d.ts","sourceRoot":"","sources":["../../../../src/core/plugins/host/dialogs.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAE9B,MAAM,WAAW,UAAU;IACzB,QAAQ,EAAE,MAAM,CAAA;IAChB,QAAQ,EAAE,MAAM,CAAA;IAChB,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IAC9B,gFAAgF;IAChF,UAAU,EAAE,MAAM,CAAA;CACnB;AAED,UAAU,cAAc;IACtB,IAAI,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,IAAI,CAAA;IACnF,KAAK,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,KAAK,IAAI,CAAA;IACpD,WAAW,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,IAAI,CAAA;CACxC;AAKD;;;GAGG;AACH,wBAAgB,oBAAoB,CAAC,EAAE,QAAQ,EAAE,EAAE;IAAE,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAA;CAAE,qBAyC/E;AAED,mGAAmG;AACnG,wBAAgB,uBAAuB,IAAI,cAAc,CAUxD;AAED,wBAAgB,oBAAoB,IAAI,UAAU,EAAE,CAEnD"}
@@ -0,0 +1,50 @@
1
+ "use client";
2
+ import { jsx } from "react/jsx-runtime";
3
+ import * as React from "react";
4
+ const DialogStackContext = React.createContext([]);
5
+ const DialogControlsContext = React.createContext(null);
6
+ function PluginDialogProvider({ children }) {
7
+ const [stack, setStack] = React.useState([]);
8
+ const nextInstance = React.useRef(0);
9
+ const controls = React.useMemo(() => ({
10
+ open: (pluginId, dialogId, props = {}) => {
11
+ nextInstance.current += 1;
12
+ const instanceId = nextInstance.current;
13
+ setStack((previous) => [...previous, { pluginId, dialogId, props, instanceId }]);
14
+ },
15
+ // Topmost match only, so stacking the same dialog twice does not lose both.
16
+ close: (pluginId, dialogId) => {
17
+ setStack((previous) => {
18
+ const matches = (entry) => entry.pluginId === pluginId && (dialogId === void 0 || entry.dialogId === dialogId);
19
+ for (let index = previous.length - 1; index >= 0; index -= 1) {
20
+ if (matches(previous[index])) {
21
+ return [...previous.slice(0, index), ...previous.slice(index + 1)];
22
+ }
23
+ }
24
+ return previous;
25
+ });
26
+ },
27
+ closePlugin: (pluginId) => {
28
+ setStack((previous) => previous.some((entry) => entry.pluginId === pluginId) ? previous.filter((entry) => entry.pluginId !== pluginId) : previous);
29
+ }
30
+ }), []);
31
+ return /* @__PURE__ */ jsx(DialogControlsContext.Provider, { value: controls, children: /* @__PURE__ */ jsx(DialogStackContext.Provider, { value: stack, children }) });
32
+ }
33
+ function usePluginDialogControls() {
34
+ const controls = React.useContext(DialogControlsContext);
35
+ if (controls === null) {
36
+ throw new Error(
37
+ "Plugin dialogs are only available inside PluginHostProvider, which owns the dialog stack."
38
+ );
39
+ }
40
+ return controls;
41
+ }
42
+ function usePluginDialogStack() {
43
+ return React.useContext(DialogStackContext);
44
+ }
45
+ export {
46
+ PluginDialogProvider,
47
+ usePluginDialogControls,
48
+ usePluginDialogStack
49
+ };
50
+ //# sourceMappingURL=dialogs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/core/plugins/host/dialogs.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\nexport interface OpenDialog {\r\n pluginId: string\r\n dialogId: string\r\n props: Record<string, unknown>\r\n /** Monotonic, so opening the same dialog twice stacks rather than replacing. */\r\n instanceId: number\r\n}\r\n\r\ninterface DialogControls {\r\n open: (pluginId: string, dialogId: string, props?: Record<string, unknown>) => void\r\n close: (pluginId: string, dialogId?: string) => void\r\n closePlugin: (pluginId: string) => void\r\n}\r\n\r\nconst DialogStackContext = React.createContext<OpenDialog[]>([])\r\nconst DialogControlsContext = React.createContext<DialogControls | null>(null)\r\n\r\n/**\r\n * Holds every open plugin dialog, above all of a plugin's surfaces so one outlives whatever\r\n * opened it. State only: the provider renders this, so importing it back would cycle.\r\n */\r\nexport function PluginDialogProvider({ children }: { children: React.ReactNode }) {\r\n const [stack, setStack] = React.useState<OpenDialog[]>([])\r\n const nextInstance = React.useRef(0)\r\n\r\n const controls = React.useMemo<DialogControls>(() => ({\r\n open: (pluginId, dialogId, props = {}) => {\r\n nextInstance.current += 1\r\n const instanceId = nextInstance.current\r\n setStack(previous => [...previous, { pluginId, dialogId, props, instanceId }])\r\n },\r\n // Topmost match only, so stacking the same dialog twice does not lose both.\r\n close: (pluginId, dialogId) => {\r\n setStack((previous) => {\r\n const matches = (entry: OpenDialog) =>\r\n entry.pluginId === pluginId && (dialogId === undefined || entry.dialogId === dialogId)\r\n\r\n for (let index = previous.length - 1; index >= 0; index -= 1) {\r\n if (matches(previous[index])) {\r\n return [...previous.slice(0, index), ...previous.slice(index + 1)]\r\n }\r\n }\r\n\r\n return previous\r\n })\r\n },\r\n closePlugin: (pluginId) => {\r\n setStack(previous => (\r\n previous.some(entry => entry.pluginId === pluginId)\r\n ? previous.filter(entry => entry.pluginId !== pluginId)\r\n : previous\r\n ))\r\n },\r\n }), [])\r\n\r\n return (\r\n <DialogControlsContext.Provider value={controls}>\r\n <DialogStackContext.Provider value={stack}>\r\n {children}\r\n </DialogStackContext.Provider>\r\n </DialogControlsContext.Provider>\r\n )\r\n}\r\n\r\n/** Throws outside the provider rather than silently doing nothing when a plugin opens a dialog. */\r\nexport function usePluginDialogControls(): DialogControls {\r\n const controls = React.useContext(DialogControlsContext)\r\n\r\n if (controls === null) {\r\n throw new Error(\r\n 'Plugin dialogs are only available inside PluginHostProvider, which owns the dialog stack.',\r\n )\r\n }\r\n\r\n return controls\r\n}\r\n\r\nexport function usePluginDialogStack(): OpenDialog[] {\r\n return React.useContext(DialogStackContext)\r\n}\r\n"],"mappings":";AAgEM;AA3DN,YAAY,WAAW;AAgBvB,MAAM,qBAAqB,MAAM,cAA4B,CAAC,CAAC;AAC/D,MAAM,wB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;AACT;AAEO,SAAS,uBAAqC;AACnD,SAAO,MAAM,WAAW,kBAAkB;AAC5C;","names":[]}
@@ -1 +1 @@
1
- {"version":3,"file":"host.d.ts","sourceRoot":"","sources":["../../../../src/core/plugins/host/host.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAA;AAChD,OAAO,KAAK,EAAE,cAAc,EAAE,WAAW,EAAiB,MAAM,cAAc,CAAA;AAE9E,KAAK,YAAY,GAAG,QAAQ,GAAG,UAAU,GAAG,SAAS,CAAA;AAYrD,qBAAa,UAAU;IAGT,OAAO,CAAC,QAAQ;IAF5B,OAAO,CAAC,OAAO,CAAuC;gBAElC,QAAQ,EAAE,cAAc;IAE5C;;;OAGG;IACG,UAAU,CACd,QAAQ,EAAE,cAAc,EACxB,KAAK,EAAE,WAAW,EAClB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC9B,OAAO,CAAC,IAAI,CAAC;IAiDV,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAgB/C,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,YAAY,GAAG,SAAS;IAIjD,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS;IAM1C,WAAW,IAAI,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,YAAY,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IAQ5E,OAAO,CAAC,MAAM;CAef"}
1
+ {"version":3,"file":"host.d.ts","sourceRoot":"","sources":["../../../../src/core/plugins/host/host.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAA;AAChD,OAAO,KAAK,EAAE,cAAc,EAAE,WAAW,EAAiB,MAAM,cAAc,CAAA;AAE9E,KAAK,YAAY,GAAG,QAAQ,GAAG,UAAU,GAAG,SAAS,CAAA;AAYrD,qBAAa,UAAU;IAGT,OAAO,CAAC,QAAQ;IAF5B,OAAO,CAAC,OAAO,CAAuC;gBAElC,QAAQ,EAAE,cAAc;IAE5C;;;OAGG;IACG,UAAU,CACd,QAAQ,EAAE,cAAc,EACxB,KAAK,EAAE,WAAW,EAClB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC9B,OAAO,CAAC,IAAI,CAAC;IAiDV,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAiB/C,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,YAAY,GAAG,SAAS;IAIjD,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS;IAM1C,WAAW,IAAI,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,YAAY,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IAQ5E,OAAO,CAAC,MAAM;CAef"}
@@ -18,6 +18,7 @@ import { validateManifest } from "../sdk/types";
18
18
  import { PLUGIN_HOST_API } from "../sdk/version";
19
19
  import { createPluginContext } from "./context";
20
20
  import { PluginActivationError, PluginHostApiError, PluginManifestError } from "./errors";
21
+ import { pluginStateStore } from "./pluginState";
21
22
  class PluginHost {
22
23
  constructor(registry) {
23
24
  this.registry = registry;
@@ -77,6 +78,7 @@ class PluginHost {
77
78
  console.error(`Plugin "${slug}" deactivate error:`, err);
78
79
  }
79
80
  this.registry.deregisterAll(slug);
81
+ pluginStateStore.clear(slug);
80
82
  loaded.status = "inactive";
81
83
  }
82
84
  getStatus(slug) {