@collabdt/core 0.4.0 → 0.4.1

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 (93) hide show
  1. package/dist/core/components/AppSidebarContent.d.ts.map +1 -1
  2. package/dist/core/components/AppSidebarContent.js +2 -7
  3. package/dist/core/components/AppSidebarContent.js.map +1 -1
  4. package/dist/core/components/ui/LegendCard.d.ts +8 -3
  5. package/dist/core/components/ui/LegendCard.d.ts.map +1 -1
  6. package/dist/core/components/ui/LegendCard.js +36 -18
  7. package/dist/core/components/ui/LegendCard.js.map +1 -1
  8. package/dist/core/components/ui/Sensors/SensorDetailDialog.d.ts.map +1 -1
  9. package/dist/core/components/ui/Sensors/SensorDetailDialog.js +56 -19
  10. package/dist/core/components/ui/Sensors/SensorDetailDialog.js.map +1 -1
  11. package/dist/core/components/ui/Sensors/SensorLegend.d.ts +6 -3
  12. package/dist/core/components/ui/Sensors/SensorLegend.d.ts.map +1 -1
  13. package/dist/core/components/ui/Sensors/SensorLegend.js +95 -27
  14. package/dist/core/components/ui/Sensors/SensorLegend.js.map +1 -1
  15. package/dist/core/components/ui/Sensors/SensorMultiSeriesChart.d.ts +10 -4
  16. package/dist/core/components/ui/Sensors/SensorMultiSeriesChart.d.ts.map +1 -1
  17. package/dist/core/components/ui/Sensors/SensorMultiSeriesChart.js +60 -9
  18. package/dist/core/components/ui/Sensors/SensorMultiSeriesChart.js.map +1 -1
  19. package/dist/core/components/ui/Sensors/SensorsSection.d.ts +1 -2
  20. package/dist/core/components/ui/Sensors/SensorsSection.d.ts.map +1 -1
  21. package/dist/core/components/ui/Sensors/SensorsSection.js +34 -4
  22. package/dist/core/components/ui/Sensors/SensorsSection.js.map +1 -1
  23. package/dist/core/components/ui/Sensors/buildingSensorColours.d.ts +49 -0
  24. package/dist/core/components/ui/Sensors/buildingSensorColours.d.ts.map +1 -0
  25. package/dist/core/components/ui/Sensors/buildingSensorColours.js +68 -0
  26. package/dist/core/components/ui/Sensors/buildingSensorColours.js.map +1 -0
  27. package/dist/core/components/ui/Sensors/sensorScope.js +1 -1
  28. package/dist/core/components/ui/Sensors/sensorScope.js.map +1 -1
  29. package/dist/core/components/ui/Sensors/sensorVisibility.d.ts +47 -0
  30. package/dist/core/components/ui/Sensors/sensorVisibility.d.ts.map +1 -0
  31. package/dist/core/components/ui/Sensors/sensorVisibility.js +29 -0
  32. package/dist/core/components/ui/Sensors/sensorVisibility.js.map +1 -0
  33. package/dist/core/components/ui/Sensors/useBuildingSensorColours.d.ts +30 -0
  34. package/dist/core/components/ui/Sensors/useBuildingSensorColours.d.ts.map +1 -0
  35. package/dist/core/components/ui/Sensors/useBuildingSensorColours.js +92 -0
  36. package/dist/core/components/ui/Sensors/useBuildingSensorColours.js.map +1 -0
  37. package/dist/core/components/ui/Sensors/useSensorSeriesMulti.d.ts +1 -1
  38. package/dist/core/components/ui/Sensors/useSensorSeriesMulti.d.ts.map +1 -1
  39. package/dist/core/components/ui/Sensors/useSensorSeriesMulti.js.map +1 -1
  40. package/dist/core/components/viewers/bim/src/tools/AddToBim/src/useSensorMarkers.d.ts.map +1 -1
  41. package/dist/core/components/viewers/bim/src/tools/AddToBim/src/useSensorMarkers.js +17 -17
  42. package/dist/core/components/viewers/bim/src/tools/AddToBim/src/useSensorMarkers.js.map +1 -1
  43. package/dist/core/components/viewers/map/src/MapFeaturePopoverMenu/src/DatabaseBuildingPopover/index.d.ts.map +1 -1
  44. package/dist/core/components/viewers/map/src/MapFeaturePopoverMenu/src/DatabaseBuildingPopover/index.js +27 -1
  45. package/dist/core/components/viewers/map/src/MapFeaturePopoverMenu/src/DatabaseBuildingPopover/index.js.map +1 -1
  46. package/dist/core/components/viewers/map/src/MapFeaturePopoverMenu/src/DatabaseBuildingPopover/src/BuildingSensorDetails.d.ts +36 -0
  47. package/dist/core/components/viewers/map/src/MapFeaturePopoverMenu/src/DatabaseBuildingPopover/src/BuildingSensorDetails.d.ts.map +1 -0
  48. package/dist/core/components/viewers/map/src/MapFeaturePopoverMenu/src/DatabaseBuildingPopover/src/BuildingSensorDetails.js +95 -0
  49. package/dist/core/components/viewers/map/src/MapFeaturePopoverMenu/src/DatabaseBuildingPopover/src/BuildingSensorDetails.js.map +1 -0
  50. package/dist/core/components/viewers/map/src/MapFeaturePopoverMenu/src/DatabaseBuildingPopover/src/BuildingsTools.d.ts.map +1 -1
  51. package/dist/core/components/viewers/map/src/MapFeaturePopoverMenu/src/DatabaseBuildingPopover/src/BuildingsTools.js +55 -42
  52. package/dist/core/components/viewers/map/src/MapFeaturePopoverMenu/src/DatabaseBuildingPopover/src/BuildingsTools.js.map +1 -1
  53. package/dist/core/components/viewers/map/src/MapLayers/src/BuildingLayers/buildingColourExpression.d.ts +32 -0
  54. package/dist/core/components/viewers/map/src/MapLayers/src/BuildingLayers/buildingColourExpression.d.ts.map +1 -0
  55. package/dist/core/components/viewers/map/src/MapLayers/src/BuildingLayers/buildingColourExpression.js +56 -0
  56. package/dist/core/components/viewers/map/src/MapLayers/src/BuildingLayers/buildingColourExpression.js.map +1 -0
  57. package/dist/core/components/viewers/map/src/MapLayers/src/BuildingLayers/index.d.ts.map +1 -1
  58. package/dist/core/components/viewers/map/src/MapLayers/src/BuildingLayers/index.js +61 -39
  59. package/dist/core/components/viewers/map/src/MapLayers/src/BuildingLayers/index.js.map +1 -1
  60. package/dist/core/components/viewers/map/src/MapLayers/src/BuildingLayers/src/BuildingSensorMarkers.d.ts +18 -0
  61. package/dist/core/components/viewers/map/src/MapLayers/src/BuildingLayers/src/BuildingSensorMarkers.d.ts.map +1 -0
  62. package/dist/core/components/viewers/map/src/MapLayers/src/BuildingLayers/src/BuildingSensorMarkers.js +61 -0
  63. package/dist/core/components/viewers/map/src/MapLayers/src/BuildingLayers/src/BuildingSensorMarkers.js.map +1 -0
  64. package/dist/core/components/viewers/map/src/MapLayers/src/SensorsLayer/index.d.ts.map +1 -1
  65. package/dist/core/components/viewers/map/src/MapLayers/src/SensorsLayer/index.js +36 -19
  66. package/dist/core/components/viewers/map/src/MapLayers/src/SensorsLayer/index.js.map +1 -1
  67. package/dist/core/components/viewers/map/src/MapLayers/src/SensorsLayer/sensorClusterColour.d.ts +22 -0
  68. package/dist/core/components/viewers/map/src/MapLayers/src/SensorsLayer/sensorClusterColour.d.ts.map +1 -0
  69. package/dist/core/components/viewers/map/src/MapLayers/src/SensorsLayer/sensorClusterColour.js +36 -0
  70. package/dist/core/components/viewers/map/src/MapLayers/src/SensorsLayer/sensorClusterColour.js.map +1 -0
  71. package/dist/core/components/viewers/map/src/MapLayers/src/mapLayersUtils.d.ts +5 -1
  72. package/dist/core/components/viewers/map/src/MapLayers/src/mapLayersUtils.d.ts.map +1 -1
  73. package/dist/core/components/viewers/map/src/MapLayers/src/mapLayersUtils.js +6 -2
  74. package/dist/core/components/viewers/map/src/MapLayers/src/mapLayersUtils.js.map +1 -1
  75. package/dist/core/i18n/messages/en.json +11 -1
  76. package/dist/core/i18n/messages/es.json +11 -1
  77. package/dist/core/i18n/messages/fr.json +11 -1
  78. package/dist/core/store/Menus/context.d.ts.map +1 -1
  79. package/dist/core/store/Menus/context.js +4 -2
  80. package/dist/core/store/Menus/context.js.map +1 -1
  81. package/dist/core/store/Menus/reducer.d.ts +15 -26
  82. package/dist/core/store/Menus/reducer.d.ts.map +1 -1
  83. package/dist/core/store/Menus/reducer.js +38 -4
  84. package/dist/core/store/Menus/reducer.js.map +1 -1
  85. package/dist/core/utils/appContent.d.ts +15 -0
  86. package/dist/core/utils/appContent.d.ts.map +1 -0
  87. package/dist/core/utils/appContent.js +24 -0
  88. package/dist/core/utils/appContent.js.map +1 -0
  89. package/dist/core/utils/colourUtils.d.ts +9 -0
  90. package/dist/core/utils/colourUtils.d.ts.map +1 -1
  91. package/dist/core/utils/colourUtils.js +16 -0
  92. package/dist/core/utils/colourUtils.js.map +1 -1
  93. package/package.json +1 -1
@@ -36,6 +36,10 @@ interface MenusTypes {
36
36
  /** Monotonic counter bumped on every sensor focus dispatch so re-focusing re-zooms. */
37
37
  sensorFocusRequestId: number;
38
38
  pendingSensorAction: SensorActionRequest | null;
39
+ /** Legend card shown for this viewer. An absent entry means shown. */
40
+ sensorLegendVisible: Partial<Record<ViewerNames, boolean>>;
41
+ /** Sensor type the legend is pinned to, overriding the focused sensor's own type. */
42
+ sensorLegendTypeId: Partial<Record<ViewerNames, number | null>>;
39
43
  }
40
44
  export type MenusState = MenusTypes;
41
45
  export type MenusPayload = {
@@ -87,33 +91,18 @@ export type MenusPayload = {
87
91
  sensorId: number;
88
92
  };
89
93
  ['CLEAR_PENDING_SENSOR_ACTION']: undefined;
90
- };
91
- export type MenusActions = ActionMap<MenusPayload>[keyof ActionMap<MenusPayload>];
92
- export declare const MenusReducer: (state: MenusState, action: MenusActions) => {
93
- pendingSensorAction: {
94
- sensorId: number;
95
- action: string;
96
- requestId: number;
94
+ /** `visible` sets explicitly; omit it to flip. Not the `force` ("only show") shape used by
95
+ * the visibility toggles above, because the legend's close button needs an explicit hide. */
96
+ ['TOGGLE_SENSOR_LEGEND']: {
97
+ viewer: ViewerNames;
98
+ visible?: boolean;
99
+ };
100
+ ['SET_SENSOR_LEGEND_TYPE_ID']: {
101
+ viewer: ViewerNames;
102
+ sensorTypeId: number | null;
97
103
  };
98
- currentViewer: ViewerNames;
99
- rowsPerPage: number;
100
- selectedTab: SidebarTabType;
101
- commentsVisibleInViewer: ViewerNames[];
102
- currentCommentId: number | null;
103
- /** Comment double-clicked to zoom/focus. Drives the thick focus ring + camera move. */
104
- focusedCommentId: number | null;
105
- /** Monotonic counter bumped on every focus dispatch so re-focusing the same comment re-zooms. */
106
- focusRequestId: number;
107
- pendingCommentAction: CommentActionRequest | null;
108
- sensorsVisibleInViewer: ViewerNames[];
109
- visibleSensorTypes: Partial<Record<ViewerNames, number[]>>;
110
- visibleSensorTags: Partial<Record<ViewerNames, string[]>>;
111
- currentSensorId: number | null;
112
- currentSensorTypeId: number | null;
113
- /** Sensor double-clicked to zoom/focus. Drives the thick focus ring + camera move. */
114
- focusedSensorId: number | null;
115
- /** Monotonic counter bumped on every sensor focus dispatch so re-focusing re-zooms. */
116
- sensorFocusRequestId: number;
117
104
  };
105
+ export type MenusActions = ActionMap<MenusPayload>[keyof ActionMap<MenusPayload>];
106
+ export declare const MenusReducer: (state: MenusState, action: MenusActions) => MenusTypes;
118
107
  export {};
119
108
  //# sourceMappingURL=reducer.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"reducer.d.ts","sourceRoot":"","sources":["../../../../src/core/store/Menus/reducer.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAA;AACtD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AAE7C,MAAM,MAAM,cAAc,GAAG,MAAM,GAAG,QAAQ,GAAG,eAAe,GAAI,SAAS,GAAG,UAAU,CAAA;AAE1F,wFAAwF;AACxF,MAAM,MAAM,oBAAoB,GAAG;IACjC,SAAS,EAAE,MAAM,CAAA;IACjB,MAAM,EAAE,MAAM,GAAG,OAAO,CAAA;IACxB,oFAAoF;IACpF,SAAS,EAAE,MAAM,CAAA;CAClB,CAAA;AAED,6EAA6E;AAC7E,MAAM,MAAM,mBAAmB,GAAG;IAChC,QAAQ,EAAE,MAAM,CAAA;IAChB,MAAM,EAAE,MAAM,CAAA;IACd,oFAAoF;IACpF,SAAS,EAAE,MAAM,CAAA;CAClB,CAAA;AAED,UAAU,UAAU;IAClB,aAAa,EAAE,WAAW,CAAA;IAC1B,WAAW,EAAE,MAAM,CAAA;IACnB,WAAW,EAAE,cAAc,CAAA;IAC3B,uBAAuB,EAAE,WAAW,EAAE,CAAA;IACtC,gBAAgB,EAAE,MAAM,GAAG,IAAI,CAAA;IAC/B,uFAAuF;IACvF,gBAAgB,EAAE,MAAM,GAAG,IAAI,CAAA;IAC/B,iGAAiG;IACjG,cAAc,EAAE,MAAM,CAAA;IACtB,oBAAoB,EAAE,oBAAoB,GAAG,IAAI,CAAA;I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A;KAAE,CAAA;IACpE,CAAC,2BAA2B,CAAC,EAAE;QAAE,MAAM,EAAE,WAAW,CAAC;QAAC,YAAY,EAAE,MAAM,GAAG,IAAI,CAAA;KAAE,CAAA;CACpF,CAAA;AAED,MAAM,MAAM,YAAY,GACpB,SAAS,CAAC,YAAY,CAAC,CAAC,MAAM,SAAS,CAAC,YAAY,CAAC,CAAC,CAAA;AAE1D,eAAO,MAAM,YAAY,GAAI,OAAO,UAAU,EAAE,QAAQ,YAAY,eA6MnE,CAAA"}
@@ -18,7 +18,7 @@ var __spreadValues = (a, b) => {
18
18
  };
19
19
  var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
20
20
  const MenusReducer = (state, action) => {
21
- var _a, _b, _c, _d, _e, _f;
21
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
22
22
  switch (action.type) {
23
23
  case "SET_VIEWER":
24
24
  return __spreadProps(__spreadValues({}, state), {
@@ -80,12 +80,18 @@ const MenusReducer = (state, action) => {
80
80
  case "SET_FOCUSED_SENSOR_ID":
81
81
  return __spreadProps(__spreadValues({}, state), {
82
82
  focusedSensorId: action.payload.sensorId,
83
- sensorFocusRequestId: state.sensorFocusRequestId + 1
83
+ sensorFocusRequestId: state.sensorFocusRequestId + 1,
84
+ // Focusing a sensor hands the legend back to that sensor's own type, in this viewer
85
+ // only. Clearing on a null payload instead would undo the selection the legend dropdown
86
+ // just made, since it clears the focus right after pinning a type.
87
+ sensorLegendTypeId: action.payload.sensorId == null ? state.sensorLegendTypeId : __spreadProps(__spreadValues({}, state.sensorLegendTypeId), { [state.currentViewer]: null })
84
88
  });
85
89
  case "REQUEST_SENSOR_ACTION":
86
90
  return __spreadProps(__spreadValues({}, state), {
87
91
  pendingSensorAction: {
88
92
  sensorId: action.payload.sensorId,
93
+ // `as const`, or the literal widens to `string` and the reducer's inferred return
94
+ // type stops being assignable to MenusState.
89
95
  action: "edit",
90
96
  requestId: ((_d = (_c = state.pendingSensorAction) == null ? void 0 : _c.requestId) != null ? _d : 0) + 1
91
97
  }
@@ -105,6 +111,10 @@ const MenusReducer = (state, action) => {
105
111
  // Also hide all sensor types for this viewer
106
112
  visibleSensorTypes: __spreadProps(__spreadValues({}, state.visibleSensorTypes), {
107
113
  [sensorViewerToHide]: []
114
+ }),
115
+ // Nothing left for the legend to explain in this viewer.
116
+ sensorLegendTypeId: __spreadProps(__spreadValues({}, state.sensorLegendTypeId), {
117
+ [sensorViewerToHide]: null
108
118
  })
109
119
  });
110
120
  case "HIDE_ALL_SENSOR_TAGS_IN_VIEWER":
@@ -121,15 +131,22 @@ const MenusReducer = (state, action) => {
121
131
  const currentTypesForViewer = ((_e = state.visibleSensorTypes) == null ? void 0 : _e[toggleViewer]) || [];
122
132
  const isCurrentlyVisible = currentTypesForViewer.includes(sensorTypeId);
123
133
  if (force && isCurrentlyVisible) return state;
134
+ const turningOn = Boolean(force) || !isCurrentlyVisible;
124
135
  return __spreadProps(__spreadValues({}, state), {
125
136
  visibleSensorTypes: __spreadProps(__spreadValues({}, state.visibleSensorTypes), {
126
- [toggleViewer]: force || !isCurrentlyVisible ? [...currentTypesForViewer, sensorTypeId] : currentTypesForViewer.filter((t) => t !== sensorTypeId)
137
+ [toggleViewer]: turningOn ? [...currentTypesForViewer, sensorTypeId] : currentTypesForViewer.filter((t) => t !== sensorTypeId)
138
+ }),
139
+ // Switching a type on is also how you choose what the legend explains, so the ramp, the
140
+ // marker halos and the building colours appear immediately rather than waiting for a
141
+ // sensor to be focused. Switching it off releases the legend again.
142
+ sensorLegendTypeId: __spreadProps(__spreadValues({}, state.sensorLegendTypeId), {
143
+ [toggleViewer]: turningOn ? sensorTypeId : ((_f = state.sensorLegendTypeId) == null ? void 0 : _f[toggleViewer]) === sensorTypeId ? null : (_h = (_g = state.sensorLegendTypeId) == null ? void 0 : _g[toggleViewer]) != null ? _h : null
127
144
  })
128
145
  });
129
146
  case "TOGGLE_SENSOR_TAG_VISIBILITY":
130
147
  const { viewer: toggleTagViewer, sensorTag, force: forceTag } = action.payload;
131
148
  if (!toggleTagViewer || !sensorTag) return state;
132
- const currentTagsForViewer = ((_f = state.visibleSensorTags) == null ? void 0 : _f[toggleTagViewer]) || [];
149
+ const currentTagsForViewer = ((_i = state.visibleSensorTags) == null ? void 0 : _i[toggleTagViewer]) || [];
133
150
  const isTagCurrentlyVisible = currentTagsForViewer.includes(sensorTag);
134
151
  if (forceTag && isTagCurrentlyVisible) return state;
135
152
  return __spreadProps(__spreadValues({}, state), {
@@ -137,6 +154,23 @@ const MenusReducer = (state, action) => {
137
154
  [toggleTagViewer]: forceTag || !isTagCurrentlyVisible ? [...currentTagsForViewer, sensorTag] : currentTagsForViewer.filter((t) => t !== sensorTag)
138
155
  })
139
156
  });
157
+ case "TOGGLE_SENSOR_LEGEND":
158
+ const { viewer: legendViewer, visible } = action.payload;
159
+ if (!legendViewer) return state;
160
+ const legendCurrentlyVisible = ((_j = state.sensorLegendVisible) == null ? void 0 : _j[legendViewer]) !== false;
161
+ return __spreadProps(__spreadValues({}, state), {
162
+ sensorLegendVisible: __spreadProps(__spreadValues({}, state.sensorLegendVisible), {
163
+ [legendViewer]: visible != null ? visible : !legendCurrentlyVisible
164
+ })
165
+ });
166
+ case "SET_SENSOR_LEGEND_TYPE_ID":
167
+ const { viewer: legendTypeViewer, sensorTypeId: legendTypeId } = action.payload;
168
+ if (!legendTypeViewer) return state;
169
+ return __spreadProps(__spreadValues({}, state), {
170
+ sensorLegendTypeId: __spreadProps(__spreadValues({}, state.sensorLegendTypeId), {
171
+ [legendTypeViewer]: legendTypeId
172
+ })
173
+ });
140
174
  case "SHOW_ALL_SENSOR_IN_VIEWER":
141
175
  const showAllViewer = action.payload.viewer;
142
176
  if (!showAllViewer) return state;
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/core/store/Menus/reducer.ts"],"sourcesContent":["// SPDX-License-Identifier: AGPL-3.0-or-later\r\n// Copyright (C) 2025 Collab Digital Twins\r\n\r\nimport type { ViewerNames } from '../../types/dbTypes'\r\nimport type { ActionMap } from '../ActionMap'\r\n\r\nexport type SidebarTabType = 'file' | 'layers' | 'communication' | 'sensors' | 'settings'\r\n\r\n/** Request from a viewer marker to open a comment's editor/reply box in the sidebar. */\r\nexport type CommentActionRequest = {\r\n commentId: number\r\n action: 'edit' | 'reply'\r\n /** Monotonic id so the same request fires again even if the target is unchanged. */\r\n requestId: number\r\n}\r\n\r\n/** Request from a viewer marker to open a sensor's editor in the sidebar. */\r\nexport type SensorActionRequest = {\r\n sensorId: number\r\n action: 'edit'\r\n /** Monotonic id so the same request fires again even if the target is unchanged. */\r\n requestId: number\r\n}\r\n\r\ninterface MenusTypes {\r\n currentViewer: ViewerNames\r\n rowsPerPage: number\r\n selectedTab: SidebarTabType\r\n commentsVisibleInViewer: ViewerNames[]\r\n currentCommentId: number | null\r\n /** Comment double-clicked to zoom/focus. Drives the thick focus ring + camera move. */\r\n focusedCommentId: number | null\r\n /** Monotonic counter bumped on every focus dispatch so re-focusing the same comment re-zooms. */\r\n focusRequestId: number\r\n pendingCommentAction: CommentActionRequest | null\r\n sensorsVisibleInViewer: ViewerNames[]\r\n visibleSensorTypes: Partial<Record<ViewerNames, number[]>>\r\n visibleSensorTags: Partial<Record<ViewerNames, string[]>>\r\n currentSensorId: number | null\r\n currentSensorTypeId: number | null\r\n /** Sensor double-clicked to zoom/focus. Drives the thick focus ring + camera move. */\r\n focusedSensorId: number | null\r\n /** Monotonic counter bumped on every sensor focus dispatch so re-focusing re-zooms. */\r\n sensorFocusRequestId: number\r\n pendingSensorAction: SensorActionRequest | null\r\n}\r\n\r\nexport type MenusState = MenusTypes\r\n\r\nexport type MenusPayload = {\r\n ['SET_VIEWER']: Pick<MenusTypes, 'currentViewer'>\r\n ['SET_PAGINATION_ROWS_PER_PAGE']: Pick<MenusTypes, 'rowsPerPage'>\r\n ['SET_SIDEBAR_SELECTED_TAB']: Pick<MenusTypes, 'selectedTab'>\r\n ['SHOW_COMMENTS_IN_VIEWER']: {viewer: ViewerNames}\r\n ['HIDE_COMMENTS_IN_VIEWER']: {viewer: ViewerNames}\r\n ['SET_CURRENT_COMMENT_ID']: {commentId: number | null}\r\n ['SET_FOCUSED_COMMENT_ID']: {commentId: number | null}\r\n ['REQUEST_COMMENT_ACTION']: {commentId: number; action: 'edit' | 'reply'}\r\n ['CLEAR_PENDING_COMMENT_ACTION']: undefined\r\n ['TOGGLE_SENSOR_TYPE_VISIBILITY']: { viewer: ViewerNames; sensorTypeId: number; force?: boolean }\r\n ['TOGGLE_SENSOR_TAG_VISIBILITY']: { viewer: ViewerNames; sensorTag: string; force?: boolean }\r\n ['SHOW_ALL_SENSOR_IN_VIEWER']: {viewer: ViewerNames}\r\n ['HIDE_ALL_SENSORS_IN_VIEWER']: {viewer: ViewerNames}\r\n ['HIDE_ALL_SENSOR_TAGS_IN_VIEWER']: {viewer: ViewerNames}\r\n ['SET_CURRENT_SENSOR_ID']: Pick<MenusTypes, 'currentSensorId'>\r\n ['SET_CURRENT_SENSOR_TYPE_ID']: Pick<MenusTypes, 'currentSensorTypeId'>\r\n ['SET_FOCUSED_SENSOR_ID']: {sensorId: number | null}\r\n ['REQUEST_SENSOR_ACTION']: {sensorId: number}\r\n ['CLEAR_PENDING_SENSOR_ACTION']: undefined\r\n}\r\n\r\nexport type MenusActions\r\n = ActionMap<MenusPayload>[keyof ActionMap<MenusPayload>]\r\n\r\nexport const MenusReducer = (state: MenusState, action: MenusActions) => {\r\n switch (action.type) {\r\n case 'SET_VIEWER':\r\n return {\r\n ...state,\r\n currentViewer: action.payload.currentViewer,\r\n }\r\n case 'SET_PAGINATION_ROWS_PER_PAGE':\r\n return {\r\n ...state,\r\n rowsPerPage: action.payload.rowsPerPage,\r\n }\r\n case 'SET_SIDEBAR_SELECTED_TAB':\r\n return {\r\n ...state,\r\n selectedTab: action.payload.selectedTab,\r\n }\r\n case 'SHOW_COMMENTS_IN_VIEWER':\r\n const viewerToShow = action.payload.viewer\r\n if (!viewerToShow) return state\r\n const commentsCurrentlyVisible = state.commentsVisibleInViewer || []\r\n return {\r\n ...state,\r\n commentsVisibleInViewer: commentsCurrentlyVisible.includes(viewerToShow)\r\n ? commentsCurrentlyVisible\r\n : [...commentsCurrentlyVisible, viewerToShow],\r\n }\r\n case 'HIDE_COMMENTS_IN_VIEWER':\r\n const viewerToHide = action.payload.viewer\r\n if (!viewerToHide) return state\r\n return {\r\n ...state,\r\n commentsVisibleInViewer: (state.commentsVisibleInViewer || []).filter(\r\n v => v !== viewerToHide\r\n ),\r\n }\r\n case 'SET_CURRENT_COMMENT_ID':\r\n return {\r\n ...state,\r\n currentCommentId: action.payload.commentId,\r\n }\r\n case 'SET_FOCUSED_COMMENT_ID':\r\n return {\r\n ...state,\r\n focusedCommentId: action.payload.commentId,\r\n focusRequestId: state.focusRequestId + 1,\r\n }\r\n case 'REQUEST_COMMENT_ACTION':\r\n return {\r\n ...state,\r\n pendingCommentAction: {\r\n commentId: action.payload.commentId,\r\n action: action.payload.action,\r\n requestId: (state.pendingCommentAction?.requestId ?? 0) + 1,\r\n },\r\n }\r\n case 'CLEAR_PENDING_COMMENT_ACTION':\r\n if (state.pendingCommentAction === null) return state\r\n return {\r\n ...state,\r\n pendingCommentAction: null,\r\n }\r\n case 'SET_CURRENT_SENSOR_ID':\r\n return {\r\n ...state,\r\n currentSensorId: action.payload.currentSensorId,\r\n }\r\n case 'SET_CURRENT_SENSOR_TYPE_ID':\r\n return {\r\n ...state,\r\n currentSensorTypeId: action.payload.currentSensorTypeId,\r\n }\r\n case 'SET_FOCUSED_SENSOR_ID':\r\n return {\r\n ...state,\r\n focusedSensorId: action.payload.sensorId,\r\n sensorFocusRequestId: state.sensorFocusRequestId + 1,\r\n }\r\n case 'REQUEST_SENSOR_ACTION':\r\n return {\r\n ...state,\r\n pendingSensorAction: {\r\n sensorId: action.payload.sensorId,\r\n action: 'edit',\r\n requestId: (state.pendingSensorAction?.requestId ?? 0) + 1,\r\n },\r\n }\r\n case 'CLEAR_PENDING_SENSOR_ACTION':\r\n if (state.pendingSensorAction === null) return state\r\n return {\r\n ...state,\r\n pendingSensorAction: null,\r\n }\r\n case 'HIDE_ALL_SENSORS_IN_VIEWER':\r\n const sensorViewerToHide = action.payload.viewer\r\n if (!sensorViewerToHide) return state\r\n return {\r\n ...state,\r\n sensorsVisibleInViewer: (state.sensorsVisibleInViewer || []).filter(\r\n v => v !== sensorViewerToHide\r\n ),\r\n // Also hide all sensor types for this viewer\r\n visibleSensorTypes: {\r\n ...state.visibleSensorTypes,\r\n [sensorViewerToHide]: [],\r\n },\r\n }\r\n case 'HIDE_ALL_SENSOR_TAGS_IN_VIEWER':\r\n const tagViewerToHide = action.payload.viewer\r\n if (!tagViewerToHide) return state\r\n return {\r\n ...state,\r\n visibleSensorTags: {\r\n ...state.visibleSensorTags,\r\n [tagViewerToHide]: [],\r\n },\r\n }\r\n case 'TOGGLE_SENSOR_TYPE_VISIBILITY':\r\n const { viewer: toggleViewer, sensorTypeId, force } = action.payload\r\n if (!toggleViewer || !sensorTypeId) return state\r\n const currentTypesForViewer = state.visibleSensorTypes?.[toggleViewer] || []\r\n const isCurrentlyVisible = currentTypesForViewer.includes(sensorTypeId)\r\n // force=true → only show (idempotent); force=false/undefined → toggle\r\n if (force && isCurrentlyVisible) return state\r\n return {\r\n ...state,\r\n visibleSensorTypes: {\r\n ...state.visibleSensorTypes,\r\n [toggleViewer]: (force || !isCurrentlyVisible)\r\n ? [...currentTypesForViewer, sensorTypeId]\r\n : currentTypesForViewer.filter(t => t !== sensorTypeId),\r\n },\r\n }\r\n case 'TOGGLE_SENSOR_TAG_VISIBILITY':\r\n const { viewer: toggleTagViewer, sensorTag, force: forceTag } = action.payload\r\n if (!toggleTagViewer || !sensorTag) return state\r\n const currentTagsForViewer = state.visibleSensorTags?.[toggleTagViewer] || []\r\n const isTagCurrentlyVisible = currentTagsForViewer.includes(sensorTag)\r\n if (forceTag && isTagCurrentlyVisible) return state\r\n return {\r\n ...state,\r\n visibleSensorTags: {\r\n ...state.visibleSensorTags,\r\n [toggleTagViewer]: (forceTag || !isTagCurrentlyVisible)\r\n ? [...currentTagsForViewer, sensorTag]\r\n : currentTagsForViewer.filter(t => t !== sensorTag),\r\n },\r\n }\r\n\r\n case 'SHOW_ALL_SENSOR_IN_VIEWER':\r\n const showAllViewer = action.payload.viewer\r\n if (!showAllViewer) return state\r\n // This is called when opening the add sensor tool - we don't know all types yet\r\n // So we just ensure the viewer is in sensorsVisibleInViewer\r\n return state\r\n default:\r\n return state\r\n }\r\n}\r\n"],"mappings":";;;;;;;;;;;;;;;;;;;AA0EO,MAAM,eAAe,CAAC,OAAmB,WAAyB;AA1EzE;AA2EE,UAAQ,OAAO,MAAM;AAAA,IACnB,KAAK;AACH,aAAO,iCACF,QADE;AAAA,QAEL,eAAe,OAAO,QAAQ;AAAA,MAChC;AAAA,IACF,KAAK;AACH,aAAO,iCACF,QADE;AAAA,QAEL,aAAa,OAAO,QAAQ;AAAA,MAC9B;AAAA,IACF,KAAK;AACH,aAAO,iCACF,QADE;AAAA,QAEL,aAAa,OAAO,QAAQ;AAAA,MAC9B;AAAA,IACF,KAAK;AACH,YAAM,eAAe,OAAO,QAAQ;AACpC,UAAI,CAAC,aAAc,QAAO;AAC1B,YAAM,2BAA2B,MAAM,2BAA2B,CAAC;AACnE,aAAO,iCACJ,QADI;AAAA,QAEP,yBAAyB,yBAAyB,SAAS,YAAY,IACnE,2BACA,CAAC,GAAG,0BAA0B,YAAY;AAAA,MAC9C;AAAA,IACF,KAAK;AACH,YAAM,eAAe,OAAO,QAAQ;AACpC,UAAI,CAAC,aAAc,QAAO;AAC1B,aAAO,iCACJ,QADI;AAAA,QAEP,0BAA0B,MAAM,2BAA2B,CAAC,GAAG;AAAA,UAC7D,OAAK,MAAM;AAAA,QACb;AAAA,MACA;AAAA,IACF,KAAK;AACH,aAAO,iCACF,QADE;AAAA,QAEL,kBAAkB,OAAO,QAAQ;AAAA,MACnC;AAAA,IACF,KAAK;AACH,aAAO,iCACF,QADE;AAAA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,cAAe,QAAO;AAG3B,aAAO;AAAA,IACT;AACE,aAAO;AAAA,EACX;AACF;","names":[]}
1
+ {"version":3,"sources":["../../../../src/core/store/Menus/reducer.ts"],"sourcesContent":["// SPDX-License-Identifier: AGPL-3.0-or-later\r\n// Copyright (C) 2025 Collab Digital Twins\r\n\r\nimport type { ViewerNames } from '../../types/dbTypes'\r\nimport type { ActionMap } from '../ActionMap'\r\n\r\nexport type SidebarTabType = 'file' | 'layers' | 'communication' | 'sensors' | 'settings'\r\n\r\n/** Request from a viewer marker to open a comment's editor/reply box in the sidebar. */\r\nexport type CommentActionRequest = {\r\n commentId: number\r\n action: 'edit' | 'reply'\r\n /** Monotonic id so the same request fires again even if the target is unchanged. */\r\n requestId: number\r\n}\r\n\r\n/** Request from a viewer marker to open a sensor's editor in the sidebar. */\r\nexport type SensorActionRequest = {\r\n sensorId: number\r\n action: 'edit'\r\n /** Monotonic id so the same request fires again even if the target is unchanged. */\r\n requestId: number\r\n}\r\n\r\ninterface MenusTypes {\r\n currentViewer: ViewerNames\r\n rowsPerPage: number\r\n selectedTab: SidebarTabType\r\n commentsVisibleInViewer: ViewerNames[]\r\n currentCommentId: number | null\r\n /** Comment double-clicked to zoom/focus. Drives the thick focus ring + camera move. */\r\n focusedCommentId: number | null\r\n /** Monotonic counter bumped on every focus dispatch so re-focusing the same comment re-zooms. */\r\n focusRequestId: number\r\n pendingCommentAction: CommentActionRequest | null\r\n sensorsVisibleInViewer: ViewerNames[]\r\n visibleSensorTypes: Partial<Record<ViewerNames, number[]>>\r\n visibleSensorTags: Partial<Record<ViewerNames, string[]>>\r\n currentSensorId: number | null\r\n currentSensorTypeId: number | null\r\n /** Sensor double-clicked to zoom/focus. Drives the thick focus ring + camera move. */\r\n focusedSensorId: number | null\r\n /** Monotonic counter bumped on every sensor focus dispatch so re-focusing re-zooms. */\r\n sensorFocusRequestId: number\r\n pendingSensorAction: SensorActionRequest | null\r\n /** Legend card shown for this viewer. An absent entry means shown. */\r\n sensorLegendVisible: Partial<Record<ViewerNames, boolean>>\r\n /** Sensor type the legend is pinned to, overriding the focused sensor's own type. */\r\n sensorLegendTypeId: Partial<Record<ViewerNames, number | null>>\r\n}\r\n\r\nexport type MenusState = MenusTypes\r\n\r\nexport type MenusPayload = {\r\n ['SET_VIEWER']: Pick<MenusTypes, 'currentViewer'>\r\n ['SET_PAGINATION_ROWS_PER_PAGE']: Pick<MenusTypes, 'rowsPerPage'>\r\n ['SET_SIDEBAR_SELECTED_TAB']: Pick<MenusTypes, 'selectedTab'>\r\n ['SHOW_COMMENTS_IN_VIEWER']: {viewer: ViewerNames}\r\n ['HIDE_COMMENTS_IN_VIEWER']: {viewer: ViewerNames}\r\n ['SET_CURRENT_COMMENT_ID']: {commentId: number | null}\r\n ['SET_FOCUSED_COMMENT_ID']: {commentId: number | null}\r\n ['REQUEST_COMMENT_ACTION']: {commentId: number; action: 'edit' | 'reply'}\r\n ['CLEAR_PENDING_COMMENT_ACTION']: undefined\r\n ['TOGGLE_SENSOR_TYPE_VISIBILITY']: { viewer: ViewerNames; sensorTypeId: number; force?: boolean }\r\n ['TOGGLE_SENSOR_TAG_VISIBILITY']: { viewer: ViewerNames; sensorTag: string; force?: boolean }\r\n ['SHOW_ALL_SENSOR_IN_VIEWER']: {viewer: ViewerNames}\r\n ['HIDE_ALL_SENSORS_IN_VIEWER']: {viewer: ViewerNames}\r\n ['HIDE_ALL_SENSOR_TAGS_IN_VIEWER']: {viewer: ViewerNames}\r\n ['SET_CURRENT_SENSOR_ID']: Pick<MenusTypes, 'currentSensorId'>\r\n ['SET_CURRENT_SENSOR_TYPE_ID']: Pick<MenusTypes, 'currentSensorTypeId'>\r\n ['SET_FOCUSED_SENSOR_ID']: {sensorId: number | null}\r\n ['REQUEST_SENSOR_ACTION']: {sensorId: number}\r\n ['CLEAR_PENDING_SENSOR_ACTION']: undefined\r\n /** `visible` sets explicitly; omit it to flip. Not the `force` (\"only show\") shape used by\r\n * the visibility toggles above, because the legend's close button needs an explicit hide. */\r\n ['TOGGLE_SENSOR_LEGEND']: { viewer: ViewerNames; visible?: boolean }\r\n ['SET_SENSOR_LEGEND_TYPE_ID']: { viewer: ViewerNames; sensorTypeId: number | null }\r\n}\r\n\r\nexport type MenusActions\r\n = ActionMap<MenusPayload>[keyof ActionMap<MenusPayload>]\r\n\r\nexport const MenusReducer = (state: MenusState, action: MenusActions) => {\r\n switch (action.type) {\r\n case 'SET_VIEWER':\r\n return {\r\n ...state,\r\n currentViewer: action.payload.currentViewer,\r\n }\r\n case 'SET_PAGINATION_ROWS_PER_PAGE':\r\n return {\r\n ...state,\r\n rowsPerPage: action.payload.rowsPerPage,\r\n }\r\n case 'SET_SIDEBAR_SELECTED_TAB':\r\n return {\r\n ...state,\r\n selectedTab: action.payload.selectedTab,\r\n }\r\n case 'SHOW_COMMENTS_IN_VIEWER':\r\n const viewerToShow = action.payload.viewer\r\n if (!viewerToShow) return state\r\n const commentsCurrentlyVisible = state.commentsVisibleInViewer || []\r\n return {\r\n ...state,\r\n commentsVisibleInViewer: commentsCurrentlyVisible.includes(viewerToShow)\r\n ? commentsCurrentlyVisible\r\n : [...commentsCurrentlyVisible, viewerToShow],\r\n }\r\n case 'HIDE_COMMENTS_IN_VIEWER':\r\n const viewerToHide = action.payload.viewer\r\n if (!viewerToHide) return state\r\n return {\r\n ...state,\r\n commentsVisibleInViewer: (state.commentsVisibleInViewer || []).filter(\r\n v => v !== viewerToHide\r\n ),\r\n }\r\n case 'SET_CURRENT_COMMENT_ID':\r\n return {\r\n ...state,\r\n currentCommentId: action.payload.commentId,\r\n }\r\n case 'SET_FOCUSED_COMMENT_ID':\r\n return {\r\n ...state,\r\n focusedCommentId: action.payload.commentId,\r\n focusRequestId: state.focusRequestId + 1,\r\n }\r\n case 'REQUEST_COMMENT_ACTION':\r\n return {\r\n ...state,\r\n pendingCommentAction: {\r\n commentId: action.payload.commentId,\r\n action: action.payload.action,\r\n requestId: (state.pendingCommentAction?.requestId ?? 0) + 1,\r\n },\r\n }\r\n case 'CLEAR_PENDING_COMMENT_ACTION':\r\n if (state.pendingCommentAction === null) return state\r\n return {\r\n ...state,\r\n pendingCommentAction: null,\r\n }\r\n case 'SET_CURRENT_SENSOR_ID':\r\n return {\r\n ...state,\r\n currentSensorId: action.payload.currentSensorId,\r\n }\r\n case 'SET_CURRENT_SENSOR_TYPE_ID':\r\n return {\r\n ...state,\r\n currentSensorTypeId: action.payload.currentSensorTypeId,\r\n }\r\n case 'SET_FOCUSED_SENSOR_ID':\r\n return {\r\n ...state,\r\n focusedSensorId: action.payload.sensorId,\r\n sensorFocusRequestId: state.sensorFocusRequestId + 1,\r\n // Focusing a sensor hands the legend back to that sensor's own type, in this viewer\r\n // only. Clearing on a null payload instead would undo the selection the legend dropdown\r\n // just made, since it clears the focus right after pinning a type.\r\n sensorLegendTypeId: action.payload.sensorId == null\r\n ? state.sensorLegendTypeId\r\n : { ...state.sensorLegendTypeId, [state.currentViewer]: null },\r\n }\r\n case 'REQUEST_SENSOR_ACTION':\r\n return {\r\n ...state,\r\n pendingSensorAction: {\r\n sensorId: action.payload.sensorId,\r\n // `as const`, or the literal widens to `string` and the reducer's inferred return\r\n // type stops being assignable to MenusState.\r\n action: 'edit' as const,\r\n requestId: (state.pendingSensorAction?.requestId ?? 0) + 1,\r\n },\r\n }\r\n case 'CLEAR_PENDING_SENSOR_ACTION':\r\n if (state.pendingSensorAction === null) return state\r\n return {\r\n ...state,\r\n pendingSensorAction: null,\r\n }\r\n case 'HIDE_ALL_SENSORS_IN_VIEWER':\r\n const sensorViewerToHide = action.payload.viewer\r\n if (!sensorViewerToHide) return state\r\n return {\r\n ...state,\r\n sensorsVisibleInViewer: (state.sensorsVisibleInViewer || []).filter(\r\n v => v !== sensorViewerToHide\r\n ),\r\n // Also hide all sensor types for this viewer\r\n visibleSensorTypes: {\r\n ...state.visibleSensorTypes,\r\n [sensorViewerToHide]: [],\r\n },\r\n // Nothing left for the legend to explain in this viewer.\r\n sensorLegendTypeId: {\r\n ...state.sensorLegendTypeId,\r\n [sensorViewerToHide]: null,\r\n },\r\n }\r\n case 'HIDE_ALL_SENSOR_TAGS_IN_VIEWER':\r\n const tagViewerToHide = action.payload.viewer\r\n if (!tagViewerToHide) return state\r\n return {\r\n ...state,\r\n visibleSensorTags: {\r\n ...state.visibleSensorTags,\r\n [tagViewerToHide]: [],\r\n },\r\n }\r\n case 'TOGGLE_SENSOR_TYPE_VISIBILITY':\r\n const { viewer: toggleViewer, sensorTypeId, force } = action.payload\r\n if (!toggleViewer || !sensorTypeId) return state\r\n const currentTypesForViewer = state.visibleSensorTypes?.[toggleViewer] || []\r\n const isCurrentlyVisible = currentTypesForViewer.includes(sensorTypeId)\r\n // force=true → only show (idempotent); force=false/undefined → toggle\r\n if (force && isCurrentlyVisible) return state\r\n const turningOn = Boolean(force) || !isCurrentlyVisible\r\n return {\r\n ...state,\r\n visibleSensorTypes: {\r\n ...state.visibleSensorTypes,\r\n [toggleViewer]: turningOn\r\n ? [...currentTypesForViewer, sensorTypeId]\r\n : currentTypesForViewer.filter(t => t !== sensorTypeId),\r\n },\r\n // Switching a type on is also how you choose what the legend explains, so the ramp, the\r\n // marker halos and the building colours appear immediately rather than waiting for a\r\n // sensor to be focused. Switching it off releases the legend again.\r\n sensorLegendTypeId: {\r\n ...state.sensorLegendTypeId,\r\n [toggleViewer]: turningOn\r\n ? sensorTypeId\r\n : state.sensorLegendTypeId?.[toggleViewer] === sensorTypeId\r\n ? null\r\n : state.sensorLegendTypeId?.[toggleViewer] ?? null,\r\n },\r\n }\r\n case 'TOGGLE_SENSOR_TAG_VISIBILITY':\r\n const { viewer: toggleTagViewer, sensorTag, force: forceTag } = action.payload\r\n if (!toggleTagViewer || !sensorTag) return state\r\n const currentTagsForViewer = state.visibleSensorTags?.[toggleTagViewer] || []\r\n const isTagCurrentlyVisible = currentTagsForViewer.includes(sensorTag)\r\n if (forceTag && isTagCurrentlyVisible) return state\r\n return {\r\n ...state,\r\n visibleSensorTags: {\r\n ...state.visibleSensorTags,\r\n [toggleTagViewer]: (forceTag || !isTagCurrentlyVisible)\r\n ? [...currentTagsForViewer, sensorTag]\r\n : currentTagsForViewer.filter(t => t !== sensorTag),\r\n },\r\n }\r\n\r\n case 'TOGGLE_SENSOR_LEGEND':\r\n const { viewer: legendViewer, visible } = action.payload\r\n if (!legendViewer) return state\r\n const legendCurrentlyVisible = state.sensorLegendVisible?.[legendViewer] !== false\r\n return {\r\n ...state,\r\n sensorLegendVisible: {\r\n ...state.sensorLegendVisible,\r\n [legendViewer]: visible ?? !legendCurrentlyVisible,\r\n },\r\n }\r\n case 'SET_SENSOR_LEGEND_TYPE_ID':\r\n const { viewer: legendTypeViewer, sensorTypeId: legendTypeId } = action.payload\r\n if (!legendTypeViewer) return state\r\n return {\r\n ...state,\r\n sensorLegendTypeId: {\r\n ...state.sensorLegendTypeId,\r\n [legendTypeViewer]: legendTypeId,\r\n },\r\n }\r\n\r\n case 'SHOW_ALL_SENSOR_IN_VIEWER':\r\n const showAllViewer = action.payload.viewer\r\n if (!showAllViewer) return state\r\n // This is called when opening the add sensor tool - we don't know all types yet\r\n // So we just ensure the viewer is in sensorsVisibleInViewer\r\n return state\r\n default:\r\n return state\r\n }\r\n}\r\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAkFO,MAAM,eAAe,CAAC,OAAmB,WAAyB;AAlFzE;AAmFE,UAAQ,OAAO,MAAM;AAAA,IACnB,KAAK;AACH,aAAO,iCACF,QADE;AAAA,QAEL,eAAe,OAAO,QAAQ;AAAA,MAChC;AAAA,IACF,KAAK;AACH,aAAO,iCACF,QADE;AAAA,QAEL,aAAa,OAAO,QAAQ;AAAA,MAC9B;AAAA,IACF,KAAK;AACH,aAAO,iCACF,QADE;AAAA,QAEL,aAAa,OAAO,QAAQ;AAAA,MAC9B;AAAA,IACF,KAAK;AACH,YAAM,eAAe,OAAO,QAAQ;AACpC,UAAI,CAAC,aAAc,QAAO;AAC1B,YAAM,2BAA2B,MAAM,2BAA2B,CAAC;AACnE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,QADE;AAAA,QAEL,oBAAoB,iCACf,MAAM,qBADS;AAAA,UAElB,CAAC,gBAAgB,GAAG;AAAA,QACtB;AAAA,MACF;AAAA,IAEF,KAAK;AACH,YAAM,gBAAgB,OAAO,QAAQ;AACrC,UAAI,CAAC,cAAe,QAAO;AAG3B,aAAO;AAAA,IACT;AACE,aAAO;AAAA,EACX;AACF;","names":[]}
@@ -0,0 +1,15 @@
1
+ import { ViewerNames } from '../types/dbTypes';
2
+ import type { Organization } from '../types/dbTypes';
3
+ /**
4
+ * The viewers an organization has switched on.
5
+ *
6
+ * An empty `appContent` means "not configured", which grants everything rather than nothing, so
7
+ * an organization that never set the field keeps the full app. The map is always included.
8
+ *
9
+ * Shared so every entry point into a viewer agrees: the sidebar and the map popover's tool row
10
+ * were drifting, and a tool that navigates somewhere the sidebar hides is a dead end.
11
+ */
12
+ export declare function resolveAppContent(organization?: Organization | null): ViewerNames[];
13
+ /** Whether an organization can reach a viewer at all. */
14
+ export declare function hasAppContent(organization: Organization | null | undefined, viewer: ViewerNames): boolean;
15
+ //# sourceMappingURL=appContent.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"appContent.d.ts","sourceRoot":"","sources":["../../../src/core/utils/appContent.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AAE9C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAA;AAapD;;;;;;;;GAQG;AACH,wBAAgB,iBAAiB,CAAC,YAAY,CAAC,EAAE,YAAY,GAAG,IAAI,GAAG,WAAW,EAAE,CAInF;AAED,yDAAyD;AACzD,wBAAgB,aAAa,CAC3B,YAAY,EAAE,YAAY,GAAG,IAAI,GAAG,SAAS,EAC7C,MAAM,EAAE,WAAW,GAClB,OAAO,CAET"}
@@ -0,0 +1,24 @@
1
+ import { ViewerNames } from "../types/dbTypes";
2
+ const OPTIONAL_VIEWERS = [
3
+ ViewerNames.extensions,
4
+ ViewerNames.bim,
5
+ ViewerNames.pointcloud,
6
+ ViewerNames.sites,
7
+ ViewerNames.infrastructure,
8
+ ViewerNames.buildings,
9
+ ViewerNames.files
10
+ ];
11
+ function resolveAppContent(organization) {
12
+ var _a;
13
+ const configured = (_a = organization == null ? void 0 : organization.appContent) != null ? _a : [];
14
+ if (configured.length === 0) return [ViewerNames.map, ...OPTIONAL_VIEWERS];
15
+ return [ViewerNames.map, ...configured];
16
+ }
17
+ function hasAppContent(organization, viewer) {
18
+ return resolveAppContent(organization).includes(viewer);
19
+ }
20
+ export {
21
+ hasAppContent,
22
+ resolveAppContent
23
+ };
24
+ //# sourceMappingURL=appContent.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/core/utils/appContent.ts"],"sourcesContent":["// SPDX-License-Identifier: AGPL-3.0-or-later\r\n// Copyright (C) 2025 Collab Digital Twins\r\n\r\nimport { ViewerNames } from '../types/dbTypes'\r\n\r\nimport type { Organization } from '../types/dbTypes'\r\n\r\n/** Everything an organization can switch on. The map is always available and is not listed. */\r\nconst OPTIONAL_VIEWERS: ViewerNames[] = [\r\n ViewerNames.extensions,\r\n ViewerNames.bim,\r\n ViewerNames.pointcloud,\r\n ViewerNames.sites,\r\n ViewerNames.infrastructure,\r\n ViewerNames.buildings,\r\n ViewerNames.files,\r\n]\r\n\r\n/**\r\n * The viewers an organization has switched on.\r\n *\r\n * An empty `appContent` means \"not configured\", which grants everything rather than nothing, so\r\n * an organization that never set the field keeps the full app. The map is always included.\r\n *\r\n * Shared so every entry point into a viewer agrees: the sidebar and the map popover's tool row\r\n * were drifting, and a tool that navigates somewhere the sidebar hides is a dead end.\r\n */\r\nexport function resolveAppContent(organization?: Organization | null): ViewerNames[] {\r\n const configured = organization?.appContent ?? []\r\n if (configured.length === 0) return [ViewerNames.map, ...OPTIONAL_VIEWERS]\r\n return [ViewerNames.map, ...(configured as ViewerNames[])]\r\n}\r\n\r\n/** Whether an organization can reach a viewer at all. */\r\nexport function hasAppContent(\r\n organization: Organization | null | undefined,\r\n viewer: ViewerNames,\r\n): boolean {\r\n return resolveAppContent(organization).includes(viewer)\r\n}\r\n"],"mappings":"AAGA,SAAS,mBAAmB;AAK5B,MAAM,mBAAkC;AAAA,EACtC,YAAY;AAAA,EACZ,YAAY;AAAA,EACZ,YAAY;AAAA,EACZ,YAAY;AAAA,EACZ,YAAY;AAAA,EACZ,YAAY;AAAA,EACZ,YAAY;AACd;AAWO,SAAS,kBAAkB,cAAmD;AA3BrF;AA4BE,QAAM,cAAa,kDAAc,eAAd,YAA4B,CAAC;AAChD,MAAI,WAAW,WAAW,EAAG,QAAO,CAAC,YAAY,KAAK,GAAG,gBAAgB;AACzE,SAAO,CAAC,YAAY,KAAK,GAAI,UAA4B;AAC3D;AAGO,SAAS,cACd,cACA,QACS;AACT,SAAO,kBAAkB,YAAY,EAAE,SAAS,MAAM;AACxD;","names":[]}
@@ -16,6 +16,15 @@ export declare function toHex({ r, g, b }: Rgb): string;
16
16
  * them. Falls back to whichever endpoint parses when the other is malformed.
17
17
  */
18
18
  export declare function lerpHex(from: string, to: string, t: number): string;
19
+ /** WCAG relative luminance, 0 (black) to 1 (white). Returns null for an unparseable colour. */
20
+ export declare function relativeLuminance(colour: string): number | null;
21
+ /**
22
+ * Black or white, whichever reads better on the given background.
23
+ *
24
+ * Needed wherever a value ramp is used as a fill behind text: a ramp runs from dark to light by
25
+ * design, so no single fixed text colour stays legible across it.
26
+ */
27
+ export declare function readableTextColour(background: string): string;
19
28
  /** A hex colour as `rgba(...)` at the given alpha, for glows and washes. */
20
29
  export declare function withAlpha(colour: string, alpha: number): string;
21
30
  //# sourceMappingURL=colourUtils.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"colourUtils.d.ts","sourceRoot":"","sources":["../../../src/core/utils/colourUtils.ts"],"names":[],"mappings":"AAGA,yCAAyC;AACzC,MAAM,WAAW,GAAG;IAClB,CAAC,EAAE,MAAM,CAAA;IACT,CAAC,EAAE,MAAM,CAAA;IACT,CAAC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E,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAI/D"}
@@ -24,6 +24,20 @@ function lerpHex(from, to, t) {
24
24
  b: a.b + (b.b - a.b) * k
25
25
  });
26
26
  }
27
+ function relativeLuminance(colour) {
28
+ const rgb = parseHex(colour);
29
+ if (!rgb) return null;
30
+ const linear = (value) => {
31
+ const c = value / 255;
32
+ return c <= 0.03928 ? c / 12.92 : ((c + 0.055) / 1.055) ** 2.4;
33
+ };
34
+ return 0.2126 * linear(rgb.r) + 0.7152 * linear(rgb.g) + 0.0722 * linear(rgb.b);
35
+ }
36
+ function readableTextColour(background) {
37
+ const luminance = relativeLuminance(background);
38
+ if (luminance == null) return "#000000";
39
+ return luminance > 0.179 ? "#000000" : "#ffffff";
40
+ }
27
41
  function withAlpha(colour, alpha) {
28
42
  const rgb = parseHex(colour);
29
43
  if (!rgb) return colour;
@@ -32,6 +46,8 @@ function withAlpha(colour, alpha) {
32
46
  export {
33
47
  lerpHex,
34
48
  parseHex,
49
+ readableTextColour,
50
+ relativeLuminance,
35
51
  toHex,
36
52
  withAlpha
37
53
  };
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/core/utils/colourUtils.ts"],"sourcesContent":["// SPDX-License-Identifier: AGPL-3.0-or-later\r\n// Copyright (C) 2025 Collab Digital Twins\r\n\r\n/** An sRGB colour, 0-255 per channel. */\r\nexport interface Rgb {\r\n r: number\r\n g: number\r\n b: number\r\n}\r\n\r\nconst clamp01 = (n: number): number => (n < 0 ? 0 : n > 1 ? 1 : n)\r\n\r\n/** Parses `#abc` or `#aabbcc` (with or without the hash). Returns null for anything else. */\r\nexport function parseHex(colour: string): Rgb | null {\r\n const raw = colour.trim().replace(/^#/, '')\r\n const hex = raw.length === 3 ? raw.split('').map(c => c + c).join('') : raw\r\n if (!/^[0-9a-fA-F]{6}$/.test(hex)) return null\r\n return {\r\n r: parseInt(hex.slice(0, 2), 16),\r\n g: parseInt(hex.slice(2, 4), 16),\r\n b: parseInt(hex.slice(4, 6), 16),\r\n }\r\n}\r\n\r\nconst channel = (n: number): string => Math.round(n).toString(16).padStart(2, '0')\r\n\r\n/** `{r,g,b}` back to a `#rrggbb` string. */\r\nexport function toHex({ r, g, b }: Rgb): string {\r\n return `#${channel(r)}${channel(g)}${channel(b)}`\r\n}\r\n\r\n/**\r\n * Straight sRGB interpolation between two hex colours, `t` clamped to 0..1.\r\n *\r\n * sRGB rather than a perceptual space is deliberate: both endpoints are colours an operator\r\n * picked in a colour input, so the midpoint should be the one they would predict from mixing\r\n * them. Falls back to whichever endpoint parses when the other is malformed.\r\n */\r\nexport function lerpHex(from: string, to: string, t: number): string {\r\n const a = parseHex(from)\r\n const b = parseHex(to)\r\n if (!a || !b) return a ? from : to\r\n const k = clamp01(t)\r\n return toHex({\r\n r: a.r + (b.r - a.r) * k,\r\n g: a.g + (b.g - a.g) * k,\r\n b: a.b + (b.b - a.b) * k,\r\n })\r\n}\r\n\r\n/** A hex colour as `rgba(...)` at the given alpha, for glows and washes. */\r\nexport function withAlpha(colour: string, alpha: number): string {\r\n const rgb = parseHex(colour)\r\n if (!rgb) return colour\r\n return `rgba(${rgb.r}, ${rgb.g}, ${rgb.b}, ${clamp01(alpha)})`\r\n}\r\n"],"mappings":"AAUA,MAAM,UAAU,CAAC,MAAuB,IAAI,IAAI,IAAI,IAAI,IAAI,IAAI;AAGzD,SAAS,SAAS,QAA4B;AACnD,QAAM,MAAM,OAAO,KAAK,EAAE,QAAQ,MAAM,EAAE;AAC1C,QAAM,MAAM,IAAI,WAAW,IAAI,IAAI,MAAM,EAAE,EAAE,IAAI,OAAK,IAAI,CAAC,EAAE,KAAK,EAAE,IAAI;AACxE,MAAI,CAAC,mBAAmB,KAAK,GAAG,EAAG,QAAO;AAC1C,SAAO;AAAA,IACL,GAAG,SAAS,IAAI,MAAM,GAAG,CAAC,GAAG,EAAE;AAAA,IAC/B,GAAG,SAAS,IAAI,MAAM,GAAG,CAAC,GAAG,EAAE;AAAA,IAC/B,GAAG,SAAS,IAAI,MAAM,GAAG,CAAC,GAAG,EAAE;AAAA,EACjC;AACF;AAEA,MAAM,UAAU,CAAC,MAAsB,KAAK,MAAM,CAAC,EAAE,SAAS,EAAE,EAAE,SAAS,GAAG,GAAG;AAG1E,SAAS,MAAM,EAAE,GAAG,GAAG,EAAE,GAAgB;AAC9C,SAAO,IAAI,QAAQ,CAAC,CAAC,GAAG,QAAQ,CAAC,CAAC,GAAG,QAAQ,CAAC,CAAC;AACjD;AASO,SAAS,QAAQ,MAAc,IAAY,GAAmB;AACnE,QAAM,IAAI,SAAS,IAAI;AACvB,QAAM,IAAI,SAAS,EAAE;AACrB,MAAI,CAAC,KAAK,CAAC,EAAG,QAAO,IAAI,OAAO;AAChC,QAAM,IAAI,QAAQ,CAAC;AACnB,SAAO,MAAM;AAAA,IACX,GAAG,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK;AAAA,IACvB,GAAG,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK;AAAA,IACvB,GAAG,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK;AAAA,EACzB,CAAC;AACH;AAGO,SAAS,UAAU,QAAgB,OAAuB;AAC/D,QAAM,MAAM,SAAS,MAAM;AAC3B,MAAI,CAAC,IAAK,QAAO;AACjB,SAAO,QAAQ,IAAI,CAAC,KAAK,IAAI,CAAC,KAAK,IAAI,CAAC,KAAK,QAAQ,KAAK,CAAC;AAC7D;","names":[]}
1
+ {"version":3,"sources":["../../../src/core/utils/colourUtils.ts"],"sourcesContent":["// SPDX-License-Identifier: AGPL-3.0-or-later\r\n// Copyright (C) 2025 Collab Digital Twins\r\n\r\n/** An sRGB colour, 0-255 per channel. */\r\nexport interface Rgb {\r\n r: number\r\n g: number\r\n b: number\r\n}\r\n\r\nconst clamp01 = (n: number): number => (n < 0 ? 0 : n > 1 ? 1 : n)\r\n\r\n/** Parses `#abc` or `#aabbcc` (with or without the hash). Returns null for anything else. */\r\nexport function parseHex(colour: string): Rgb | null {\r\n const raw = colour.trim().replace(/^#/, '')\r\n const hex = raw.length === 3 ? raw.split('').map(c => c + c).join('') : raw\r\n if (!/^[0-9a-fA-F]{6}$/.test(hex)) return null\r\n return {\r\n r: parseInt(hex.slice(0, 2), 16),\r\n g: parseInt(hex.slice(2, 4), 16),\r\n b: parseInt(hex.slice(4, 6), 16),\r\n }\r\n}\r\n\r\nconst channel = (n: number): string => Math.round(n).toString(16).padStart(2, '0')\r\n\r\n/** `{r,g,b}` back to a `#rrggbb` string. */\r\nexport function toHex({ r, g, b }: Rgb): string {\r\n return `#${channel(r)}${channel(g)}${channel(b)}`\r\n}\r\n\r\n/**\r\n * Straight sRGB interpolation between two hex colours, `t` clamped to 0..1.\r\n *\r\n * sRGB rather than a perceptual space is deliberate: both endpoints are colours an operator\r\n * picked in a colour input, so the midpoint should be the one they would predict from mixing\r\n * them. Falls back to whichever endpoint parses when the other is malformed.\r\n */\r\nexport function lerpHex(from: string, to: string, t: number): string {\r\n const a = parseHex(from)\r\n const b = parseHex(to)\r\n if (!a || !b) return a ? from : to\r\n const k = clamp01(t)\r\n return toHex({\r\n r: a.r + (b.r - a.r) * k,\r\n g: a.g + (b.g - a.g) * k,\r\n b: a.b + (b.b - a.b) * k,\r\n })\r\n}\r\n\r\n/** WCAG relative luminance, 0 (black) to 1 (white). Returns null for an unparseable colour. */\r\nexport function relativeLuminance(colour: string): number | null {\r\n const rgb = parseHex(colour)\r\n if (!rgb) return null\r\n const linear = (value: number): number => {\r\n const c = value / 255\r\n return c <= 0.03928 ? c / 12.92 : ((c + 0.055) / 1.055) ** 2.4\r\n }\r\n return 0.2126 * linear(rgb.r) + 0.7152 * linear(rgb.g) + 0.0722 * linear(rgb.b)\r\n}\r\n\r\n/**\r\n * Black or white, whichever reads better on the given background.\r\n *\r\n * Needed wherever a value ramp is used as a fill behind text: a ramp runs from dark to light by\r\n * design, so no single fixed text colour stays legible across it.\r\n */\r\nexport function readableTextColour(background: string): string {\r\n const luminance = relativeLuminance(background)\r\n if (luminance == null) return '#000000'\r\n // 0.179 is the luminance at which white and black text have equal WCAG contrast.\r\n return luminance > 0.179 ? '#000000' : '#ffffff'\r\n}\r\n\r\n/** A hex colour as `rgba(...)` at the given alpha, for glows and washes. */\r\nexport function withAlpha(colour: string, alpha: number): string {\r\n const rgb = parseHex(colour)\r\n if (!rgb) return colour\r\n return `rgba(${rgb.r}, ${rgb.g}, ${rgb.b}, ${clamp01(alpha)})`\r\n}\r\n"],"mappings":"AAUA,MAAM,UAAU,CAAC,MAAuB,IAAI,IAAI,IAAI,IAAI,IAAI,IAAI;AAGzD,SAAS,SAAS,QAA4B;AACnD,QAAM,MAAM,OAAO,KAAK,EAAE,QAAQ,MAAM,EAAE;AAC1C,QAAM,MAAM,IAAI,WAAW,IAAI,IAAI,MAAM,EAAE,EAAE,IAAI,OAAK,IAAI,CAAC,EAAE,KAAK,EAAE,IAAI;AACxE,MAAI,CAAC,mBAAmB,KAAK,GAAG,EAAG,QAAO;AAC1C,SAAO;AAAA,IACL,GAAG,SAAS,IAAI,MAAM,GAAG,CAAC,GAAG,EAAE;AAAA,IAC/B,GAAG,SAAS,IAAI,MAAM,GAAG,CAAC,GAAG,EAAE;AAAA,IAC/B,GAAG,SAAS,IAAI,MAAM,GAAG,CAAC,GAAG,EAAE;AAAA,EACjC;AACF;AAEA,MAAM,UAAU,CAAC,MAAsB,KAAK,MAAM,CAAC,EAAE,SAAS,EAAE,EAAE,SAAS,GAAG,GAAG;AAG1E,SAAS,MAAM,EAAE,GAAG,GAAG,EAAE,GAAgB;AAC9C,SAAO,IAAI,QAAQ,CAAC,CAAC,GAAG,QAAQ,CAAC,CAAC,GAAG,QAAQ,CAAC,CAAC;AACjD;AASO,SAAS,QAAQ,MAAc,IAAY,GAAmB;AACnE,QAAM,IAAI,SAAS,IAAI;AACvB,QAAM,IAAI,SAAS,EAAE;AACrB,MAAI,CAAC,KAAK,CAAC,EAAG,QAAO,IAAI,OAAO;AAChC,QAAM,IAAI,QAAQ,CAAC;AACnB,SAAO,MAAM;AAAA,IACX,GAAG,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK;AAAA,IACvB,GAAG,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK;AAAA,IACvB,GAAG,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK;AAAA,EACzB,CAAC;AACH;AAGO,SAAS,kBAAkB,QAA+B;AAC/D,QAAM,MAAM,SAAS,MAAM;AAC3B,MAAI,CAAC,IAAK,QAAO;AACjB,QAAM,SAAS,CAAC,UAA0B;AACxC,UAAM,IAAI,QAAQ;AAClB,WAAO,KAAK,UAAU,IAAI,UAAU,IAAI,SAAS,UAAU;AAAA,EAC7D;AACA,SAAO,SAAS,OAAO,IAAI,CAAC,IAAI,SAAS,OAAO,IAAI,CAAC,IAAI,SAAS,OAAO,IAAI,CAAC;AAChF;AAQO,SAAS,mBAAmB,YAA4B;AAC7D,QAAM,YAAY,kBAAkB,UAAU;AAC9C,MAAI,aAAa,KAAM,QAAO;AAE9B,SAAO,YAAY,QAAQ,YAAY;AACzC;AAGO,SAAS,UAAU,QAAgB,OAAuB;AAC/D,QAAM,MAAM,SAAS,MAAM;AAC3B,MAAI,CAAC,IAAK,QAAO;AACjB,SAAO,QAAQ,IAAI,CAAC,KAAK,IAAI,CAAC,KAAK,IAAI,CAAC,KAAK,QAAQ,KAAK,CAAC;AAC7D;","names":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@collabdt/core",
3
- "version": "0.4.0",
3
+ "version": "0.4.1",
4
4
  "description": "CDT Core contains all the core technology for your CDT platform",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",