@geode/opengeodeweb-front 10.43.2 → 10.44.0-rc.10

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 (254) hide show
  1. package/.build/server/utils/cleanup.js +7 -2
  2. package/.build/server/utils/microservices.js +9 -81
  3. package/.build/server/utils/microservices_process.js +85 -0
  4. package/.build/server/utils/scripts.js +34 -23
  5. package/.build/server/utils/typed_handler.js +5 -1
  6. package/.build/server/utils/ws_client.js +7 -2
  7. package/.build/shared/utils/fetch_raw.js +2 -2
  8. package/.build/shared/utils/parse_boolean.js +2 -1
  9. package/app/assets/geode_objects.ts +1 -0
  10. package/app/components/BasemapAttribution.vue +28 -0
  11. package/app/components/ClippingPlanes.vue +22 -78
  12. package/app/components/CrsSelector.vue +53 -46
  13. package/app/components/DragAndDrop.vue +16 -79
  14. package/app/components/FeedBack/Snackers.vue +27 -0
  15. package/app/components/FileSelector.vue +9 -6
  16. package/app/components/HybridViewerTooltip.vue +8 -2
  17. package/app/components/MissingFilesSelector.vue +40 -23
  18. package/app/components/ObjectSelector.vue +34 -20
  19. package/app/components/ProjectCrs.vue +37 -0
  20. package/app/components/Screenshot.vue +17 -59
  21. package/app/components/ThresholdCard.vue +205 -0
  22. package/app/components/ThresholdFilter.vue +81 -216
  23. package/app/components/ViewToolbar.vue +15 -231
  24. package/app/components/Viewer/Basemap/CropOptions.vue +50 -0
  25. package/app/components/Viewer/Basemap/OpacityOptions.vue +52 -0
  26. package/app/components/Viewer/ContextMenu/CircularItems.vue +1 -2
  27. package/app/components/Viewer/ContextMenu/ContextMenu.vue +11 -6
  28. package/app/components/Viewer/ContextMenu/ContextMenuItem.vue +10 -7
  29. package/app/components/Viewer/ContextMenu/InfoCard.vue +30 -0
  30. package/app/components/Viewer/EdgedCurve/SpecificEdgesColoring.vue +209 -0
  31. package/app/components/Viewer/EdgedCurve/SpecificEdgesOptions.vue +3 -191
  32. package/app/components/Viewer/Generic/Mesh/CellsColoring.vue +221 -0
  33. package/app/components/Viewer/Generic/Mesh/CellsOptions.vue +3 -210
  34. package/app/components/Viewer/Generic/Mesh/EdgesColoring.vue +211 -0
  35. package/app/components/Viewer/Generic/Mesh/EdgesOptions.vue +3 -192
  36. package/app/components/Viewer/Generic/Mesh/PointsOptions.vue +13 -0
  37. package/app/components/Viewer/Generic/Mesh/PolygonsColoring.vue +227 -0
  38. package/app/components/Viewer/Generic/Mesh/PolygonsOptions.vue +3 -215
  39. package/app/components/Viewer/Generic/Mesh/PolyhedraColoring.vue +221 -0
  40. package/app/components/Viewer/Generic/Mesh/PolyhedraOptions.vue +3 -203
  41. package/app/components/Viewer/Generic/Model/BlocksOptions.vue +14 -12
  42. package/app/components/Viewer/Generic/Model/ComponentPointsOptions.vue +2 -18
  43. package/app/components/Viewer/Generic/Model/CornerComponentOptions.vue +145 -0
  44. package/app/components/Viewer/Generic/Model/CornersOptions.vue +15 -294
  45. package/app/components/Viewer/Generic/Model/CornersTypeOptions.vue +173 -0
  46. package/app/components/Viewer/Generic/Model/LineComponentOptions.vue +218 -0
  47. package/app/components/Viewer/Generic/Model/LinesOptions.vue +15 -427
  48. package/app/components/Viewer/Generic/Model/LinesTypeOptions.vue +229 -0
  49. package/app/components/Viewer/Generic/Model/ModelCardTabs.vue +35 -0
  50. package/app/components/Viewer/Generic/Model/ModelEdgesCard.vue +34 -25
  51. package/app/components/Viewer/Generic/Model/ModelPointsCard.vue +34 -25
  52. package/app/components/Viewer/Generic/Model/ModelStyleCard.vue +17 -5
  53. package/app/components/Viewer/Generic/Model/SurfacesOptions.vue +16 -12
  54. package/app/components/Viewer/ObjectTree/Base/ComponentRelations.vue +4 -1
  55. package/app/components/Viewer/ObjectTree/Base/ItemLabel.vue +71 -1
  56. package/app/components/Viewer/ObjectTree/Views/GlobalObjects.vue +55 -10
  57. package/app/components/Viewer/Options/AttributeRangeSelector.vue +11 -4
  58. package/app/components/Viewer/Options/AttributeSelector.vue +40 -136
  59. package/app/components/Viewer/Options/ColorPicker.vue +4 -1
  60. package/app/components/Viewer/Options/ColoringTypeSelector.vue +48 -74
  61. package/app/components/Viewer/Options/ColormapQuickPicker.vue +13 -7
  62. package/app/components/Viewer/Options/NoDataColorInfo.vue +56 -0
  63. package/app/components/Viewer/Options/Sliders/Opacity.vue +22 -0
  64. package/app/components/Viewer/PointSet/SpecificPointsOptions.vue +13 -0
  65. package/app/components/Viewer/Scene/BackgroundOptions.vue +37 -0
  66. package/app/components/Viewer/Scene/OrientationWidgetOptions.vue +48 -0
  67. package/app/components/Viewer/Scene/TextOptions.vue +63 -0
  68. package/app/components/Viewer/Solid/SpecificPolyhedraColoring.vue +217 -0
  69. package/app/components/Viewer/Solid/SpecificPolyhedraOptions.vue +4 -199
  70. package/app/components/Viewer/Surface/PolygonsColoring.vue +224 -0
  71. package/app/components/Viewer/Surface/PolygonsOptions.vue +3 -213
  72. package/app/components/Viewer/Ui.vue +9 -0
  73. package/app/components/csv-preview/CsvPreviewer.vue +4 -1
  74. package/app/composables/attribute_coloring_style.ts +8 -2
  75. package/app/composables/attribute_selector.ts +126 -0
  76. package/app/composables/batch_style_model.ts +34 -0
  77. package/app/composables/clipping_slices.ts +166 -0
  78. package/app/composables/global_attribute_style.ts +4 -3
  79. package/app/composables/hover_highlight.ts +19 -18
  80. package/app/composables/live_data_item.ts +39 -0
  81. package/app/composables/model_tabs.ts +86 -0
  82. package/app/composables/overlapping_picker_menu.ts +43 -0
  83. package/app/composables/project_manager.ts +5 -81
  84. package/app/composables/project_manager_helpers/reset.ts +34 -0
  85. package/app/composables/project_manager_helpers/restore.ts +67 -0
  86. package/app/composables/project_manager_helpers/types.ts +24 -0
  87. package/app/composables/project_manager_helpers/viewer_session.ts +25 -0
  88. package/app/composables/stepper_tree.ts +10 -2
  89. package/app/composables/tree_filter.ts +11 -2
  90. package/app/composables/tree_keyboard_nav.ts +4 -2
  91. package/app/composables/use_overlapping_picker.ts +30 -42
  92. package/app/composables/view_toolbar_options.ts +126 -0
  93. package/app/composables/view_toolbar_tool_options.ts +115 -0
  94. package/app/composables/view_toolbar_tools.ts +108 -0
  95. package/app/composables/viewer_context_menu.ts +19 -1
  96. package/app/composables/virtual_tree.ts +20 -131
  97. package/app/composables/virtual_tree_flatten.ts +109 -0
  98. package/app/composables/virtual_tree_types.ts +81 -0
  99. package/app/stores/app.ts +8 -55
  100. package/app/stores/app_helpers/extension.ts +90 -51
  101. package/app/stores/app_helpers/registry.ts +69 -0
  102. package/app/stores/basemap.ts +52 -0
  103. package/app/stores/basemap_detail.ts +51 -0
  104. package/app/stores/basemap_helpers/builds.ts +158 -0
  105. package/app/stores/basemap_helpers/detail_layers.ts +72 -0
  106. package/app/stores/basemap_helpers/detail_map.ts +62 -0
  107. package/app/stores/basemap_helpers/detail_refresh.ts +134 -0
  108. package/app/stores/basemap_helpers/detail_view.ts +94 -0
  109. package/app/stores/basemap_helpers/extent.ts +40 -0
  110. package/app/stores/basemap_helpers/georeferenced.ts +50 -0
  111. package/app/stores/basemap_helpers/layers.ts +66 -0
  112. package/app/stores/basemap_helpers/settings.ts +87 -0
  113. package/app/stores/basemap_helpers/viewer.ts +114 -0
  114. package/app/stores/crs.ts +136 -0
  115. package/app/stores/data.ts +24 -1
  116. package/app/stores/data_style.ts +8 -0
  117. package/app/stores/feedback.ts +12 -2
  118. package/app/stores/hybrid_viewer.ts +1 -1
  119. package/app/stores/infra.ts +26 -21
  120. package/app/stores/menu.ts +8 -124
  121. package/app/stores/menu_helpers/basemap.ts +10 -0
  122. package/app/stores/menu_helpers/menus_data.ts +27 -0
  123. package/app/stores/menu_helpers/mesh/edged_curve.ts +12 -0
  124. package/app/stores/menu_helpers/mesh/grid.ts +24 -0
  125. package/app/stores/menu_helpers/mesh/point_set.ts +11 -0
  126. package/app/stores/menu_helpers/mesh/solid.ts +29 -0
  127. package/app/stores/menu_helpers/mesh/surface.ts +22 -0
  128. package/app/stores/menu_helpers/model.ts +25 -0
  129. package/app/stores/menu_helpers/scene.ts +10 -0
  130. package/app/stores/menu_helpers/types.ts +5 -0
  131. package/app/stores/treeview.ts +17 -10
  132. package/app/stores/viewer.ts +17 -79
  133. package/app/stores/viewer_helpers/actions.ts +68 -0
  134. package/app/stores/viewer_helpers/request.ts +61 -0
  135. package/app/utils/basemap_tree.ts +76 -0
  136. package/app/utils/clipping_planes.ts +4 -131
  137. package/app/utils/clipping_planes_scene.ts +131 -0
  138. package/app/utils/color_picker.ts +18 -15
  139. package/app/utils/coloring_styles.ts +101 -0
  140. package/app/utils/crs.ts +38 -0
  141. package/app/utils/default_styles/constants.ts +10 -0
  142. package/app/utils/default_styles/index.ts +17 -1
  143. package/app/utils/default_styles/mesh_components.ts +168 -0
  144. package/app/utils/default_styles/meshes.ts +13 -153
  145. package/app/utils/default_styles/model_components.ts +170 -0
  146. package/app/utils/default_styles/models.ts +16 -153
  147. package/app/utils/drag_and_drop.ts +80 -0
  148. package/app/utils/extension.ts +1 -1
  149. package/app/utils/import_workflow.ts +26 -11
  150. package/app/utils/model_component_coloring.ts +46 -0
  151. package/app/utils/threshold.ts +33 -0
  152. package/app/utils/threshold_sources.ts +51 -0
  153. package/app/utils/treeview.ts +12 -1
  154. package/app/utils/upload_path.ts +15 -9
  155. package/app/utils/visible_map_area.ts +129 -0
  156. package/internal/database/base_database.ts +2 -0
  157. package/internal/database/database.ts +47 -29
  158. package/internal/database/tables/scene_style.ts +6 -0
  159. package/internal/stores/data_style/mesh/base_style.ts +74 -0
  160. package/internal/stores/data_style/mesh/cells/cell.ts +27 -150
  161. package/internal/stores/data_style/mesh/cells/cell_attribute.ts +74 -0
  162. package/internal/stores/data_style/mesh/cells/cell_config.ts +152 -0
  163. package/internal/stores/data_style/mesh/cells/color.ts +3 -1
  164. package/internal/stores/data_style/mesh/cells/index.ts +17 -1
  165. package/internal/stores/data_style/mesh/cells/opacity.ts +54 -0
  166. package/internal/stores/data_style/mesh/cells/vertex.ts +26 -157
  167. package/internal/stores/data_style/mesh/cells/vertex_attribute.ts +80 -0
  168. package/internal/stores/data_style/mesh/cells/vertex_config.ts +152 -0
  169. package/internal/stores/data_style/mesh/edges/color.ts +3 -1
  170. package/internal/stores/data_style/mesh/edges/edge.ts +27 -150
  171. package/internal/stores/data_style/mesh/edges/edge_attribute.ts +74 -0
  172. package/internal/stores/data_style/mesh/edges/edge_config.ts +152 -0
  173. package/internal/stores/data_style/mesh/edges/index.ts +17 -1
  174. package/internal/stores/data_style/mesh/edges/opacity.ts +54 -0
  175. package/internal/stores/data_style/mesh/edges/vertex.ts +26 -157
  176. package/internal/stores/data_style/mesh/edges/vertex_attribute.ts +80 -0
  177. package/internal/stores/data_style/mesh/edges/vertex_config.ts +152 -0
  178. package/internal/stores/data_style/mesh/index.ts +2 -57
  179. package/internal/stores/data_style/mesh/points/color.ts +3 -1
  180. package/internal/stores/data_style/mesh/points/index.ts +17 -1
  181. package/internal/stores/data_style/mesh/points/opacity.ts +54 -0
  182. package/internal/stores/data_style/mesh/points/vertex.ts +26 -157
  183. package/internal/stores/data_style/mesh/points/vertex_attribute.ts +80 -0
  184. package/internal/stores/data_style/mesh/points/vertex_config.ts +152 -0
  185. package/internal/stores/data_style/mesh/polygons/color.ts +3 -1
  186. package/internal/stores/data_style/mesh/polygons/index.ts +17 -1
  187. package/internal/stores/data_style/mesh/polygons/opacity.ts +54 -0
  188. package/internal/stores/data_style/mesh/polygons/polygon.ts +27 -152
  189. package/internal/stores/data_style/mesh/polygons/polygon_attribute.ts +80 -0
  190. package/internal/stores/data_style/mesh/polygons/polygon_config.ts +148 -0
  191. package/internal/stores/data_style/mesh/polygons/vertex.ts +26 -157
  192. package/internal/stores/data_style/mesh/polygons/vertex_attribute.ts +80 -0
  193. package/internal/stores/data_style/mesh/polygons/vertex_config.ts +152 -0
  194. package/internal/stores/data_style/mesh/polyhedra/color.ts +3 -1
  195. package/internal/stores/data_style/mesh/polyhedra/index.ts +17 -1
  196. package/internal/stores/data_style/mesh/polyhedra/opacity.ts +54 -0
  197. package/internal/stores/data_style/mesh/polyhedra/polyhedron.ts +27 -160
  198. package/internal/stores/data_style/mesh/polyhedra/polyhedron_attribute.ts +82 -0
  199. package/internal/stores/data_style/mesh/polyhedra/polyhedron_config.ts +157 -0
  200. package/internal/stores/data_style/mesh/polyhedra/vertex.ts +26 -157
  201. package/internal/stores/data_style/mesh/polyhedra/vertex_attribute.ts +80 -0
  202. package/internal/stores/data_style/mesh/polyhedra/vertex_config.ts +152 -0
  203. package/internal/stores/data_style/model/blocks/apply_coloring.ts +173 -0
  204. package/internal/stores/data_style/model/blocks/color.ts +58 -57
  205. package/internal/stores/data_style/model/blocks/coloring_groups.ts +18 -0
  206. package/internal/stores/data_style/model/blocks/index.ts +12 -140
  207. package/internal/stores/data_style/model/blocks/polyhedron.ts +102 -54
  208. package/internal/stores/data_style/model/blocks/vertex.ts +102 -54
  209. package/internal/stores/data_style/model/color.ts +25 -26
  210. package/internal/stores/data_style/model/common.ts +10 -119
  211. package/internal/stores/data_style/model/common_mutations.ts +184 -0
  212. package/internal/stores/data_style/model/corners/index.ts +85 -78
  213. package/internal/stores/data_style/model/corners/vertex.ts +97 -49
  214. package/internal/stores/data_style/model/lines/apply_coloring.ts +154 -0
  215. package/internal/stores/data_style/model/lines/color.ts +53 -40
  216. package/internal/stores/data_style/model/lines/coloring_groups.ts +18 -0
  217. package/internal/stores/data_style/model/lines/edge.ts +102 -54
  218. package/internal/stores/data_style/model/lines/index.ts +10 -134
  219. package/internal/stores/data_style/model/lines/vertex.ts +102 -54
  220. package/internal/stores/data_style/model/surfaces/apply_coloring.ts +186 -0
  221. package/internal/stores/data_style/model/surfaces/color.ts +68 -56
  222. package/internal/stores/data_style/model/surfaces/coloring_groups.ts +18 -0
  223. package/internal/stores/data_style/model/surfaces/index.ts +16 -160
  224. package/internal/stores/data_style/model/surfaces/polygon.ts +94 -46
  225. package/internal/stores/data_style/model/surfaces/vertex.ts +94 -46
  226. package/internal/stores/data_style/model/visibility.ts +3 -156
  227. package/internal/stores/data_style/model/visibility_dispatch.ts +110 -0
  228. package/internal/stores/data_style/scene.ts +118 -0
  229. package/internal/stores/data_style/state.ts +5 -181
  230. package/internal/stores/data_style/state_shared.ts +199 -0
  231. package/internal/stores/data_style/types.ts +24 -1
  232. package/internal/stores/hybrid_viewer/brightness.ts +8 -2
  233. package/internal/stores/hybrid_viewer/camera.ts +7 -161
  234. package/internal/stores/hybrid_viewer/camera_animation.ts +4 -3
  235. package/internal/stores/hybrid_viewer/camera_helpers.ts +120 -0
  236. package/internal/stores/hybrid_viewer/camera_orientation.ts +60 -0
  237. package/internal/stores/hybrid_viewer/filters.ts +54 -11
  238. package/internal/stores/hybrid_viewer/highlight.ts +80 -63
  239. package/internal/stores/hybrid_viewer/ruler.ts +4 -3
  240. package/internal/stores/hybrid_viewer/scene.ts +34 -26
  241. package/internal/stores/hybrid_viewer/vtk_types.ts +2 -1
  242. package/internal/utils/ws_client.ts +8 -1
  243. package/package.json +5 -5
  244. package/server/api/local/extensions/run.post.ts +6 -4
  245. package/server/api/local/extensions/upload.put.ts +47 -20
  246. package/server/utils/cleanup.ts +12 -2
  247. package/server/utils/microservices.ts +10 -102
  248. package/server/utils/microservices_process.ts +127 -0
  249. package/server/utils/scripts.ts +35 -30
  250. package/server/utils/typed_handler.ts +8 -1
  251. package/server/utils/ws_client.ts +15 -2
  252. package/shared/utils/fetch_raw.ts +2 -2
  253. package/shared/utils/parse_boolean.ts +4 -1
  254. package/app/components/Viewer/Options/OptionsSection.vue +0 -76
@@ -1,72 +1,14 @@
1
- import type { Ref } from "vue";
2
-
3
- // Same shape as Vue's MaybeRefOrGetter<T>, kept as a local alias for readability at call sites.
4
- type ReadonlyMaybeRefOrGetter<Value> = Value | Ref<Value> | (() => Value);
5
-
6
- type TreeItem = Record<string, unknown>;
7
-
8
- interface ItemPropsConfig {
9
- value: string;
10
- title: string;
11
- children: string;
12
- height: number;
13
- [key: string]: unknown;
14
- }
15
-
16
- interface SelectionConfig {
17
- selectable: boolean;
18
- strategy: string;
19
- [key: string]: unknown;
20
- }
21
-
22
- interface VirtualTreeProps {
23
- readonly items?: readonly TreeItem[];
24
- readonly opened?: readonly unknown[];
25
- readonly selected?: readonly unknown[];
26
- readonly active?: readonly unknown[];
27
- readonly itemProps?: Partial<ItemPropsConfig>;
28
- readonly selection?: Partial<SelectionConfig>;
29
- readonly search?: string;
30
- readonly customFilter?: (id: unknown, search: string, context: { raw: TreeItem }) => boolean;
31
- }
32
-
33
- interface DisplayItem {
34
- raw: TreeItem;
35
- id: unknown;
36
- depth: number;
37
- isOpen: boolean;
38
- isActive: boolean;
39
- isLeaf: boolean;
40
- }
41
-
42
- type EmitFn = (event: string, ...args: readonly unknown[]) => void;
43
-
44
- interface UseVirtualTreeReturn {
45
- actualItemProps: ComputedRef<ItemPropsConfig>;
46
- actualSelection: ComputedRef<SelectionConfig>;
47
- displayItems: ComputedRef<DisplayItem[]>;
48
- toggleOpen: (item: TreeItem) => void;
49
- toggleSelect: (item: TreeItem) => void;
50
- isSelected: (item: TreeItem) => boolean;
51
- getIndeterminate: (item: TreeItem) => boolean;
52
- }
53
-
54
- // Real runtime check (rather than an `as TreeItem[]` cast) for the duck-typed "children" field:
55
- // Item shapes vary across callers (treeview groups, model component/collection groups, ...), so
56
- // This only verifies it is actually an array, same as the assumption the old cast silently made.
57
- function isTreeItemArray(value: unknown): value is TreeItem[] {
58
- return Array.isArray(value);
59
- }
60
-
61
- // Extracted so we never call String() directly on a value typed as `unknown` (ids and titles can
62
- // Be anything at runtime): only stringify primitives that have a sane toString, and fall back to
63
- // "" for anything else instead of risking "[object Object]".
64
- function toDisplayString(value: unknown): string {
65
- if (typeof value === "string" || typeof value === "number" || typeof value === "boolean") {
66
- return String(value);
67
- }
68
- return "";
69
- }
1
+ import {
2
+ type EmitFn,
3
+ type ItemPropsConfig,
4
+ type ReadonlyMaybeRefOrGetter,
5
+ type SelectionConfig,
6
+ type TreeItem,
7
+ type UseVirtualTreeReturn,
8
+ type VirtualTreeProps,
9
+ isTreeItemArray,
10
+ } from "./virtual_tree_types";
11
+ import { flattenTree } from "./virtual_tree_flatten";
70
12
 
71
13
  function useVirtualTree(
72
14
  propsIn: ReadonlyMaybeRefOrGetter<VirtualTreeProps>,
@@ -171,66 +113,6 @@ function useVirtualTree(
171
113
  emit("update:selected", [...newSelected]);
172
114
  }
173
115
 
174
- function flattenTree(itemsList: readonly TreeItem[], depth = 0): DisplayItem[] {
175
- const { search, customFilter } = props.value;
176
- const result: DisplayItem[] = [];
177
-
178
- for (const item of itemsList) {
179
- const id = item[actualItemProps.value.value];
180
- const children = getChildrenOf(item);
181
- const hasChildren = Boolean(children && children.length > 0);
182
-
183
- const isOpen = openedSet.value.has(id);
184
- const isActive = activeSet.value.has(id);
185
-
186
- if (search !== undefined && search !== "") {
187
- const lowerSearch = search.toLowerCase();
188
- const matches = customFilter
189
- ? customFilter(id, search, { raw: item })
190
- : toDisplayString(item[actualItemProps.value.title])
191
- .toLowerCase()
192
- .includes(lowerSearch) || toDisplayString(id).toLowerCase().includes(lowerSearch);
193
-
194
- if (hasChildren) {
195
- const subtree = flattenTree(children ?? [], depth + 1);
196
- if (subtree.length === 0 && !matches) {
197
- continue;
198
- }
199
-
200
- result.push({
201
- raw: item,
202
- id,
203
- depth,
204
- isOpen,
205
- isActive,
206
- isLeaf: false,
207
- });
208
- if (isOpen) {
209
- result.push(...subtree);
210
- }
211
- continue;
212
- }
213
- if (!matches) {
214
- continue;
215
- }
216
- }
217
-
218
- result.push({
219
- raw: item,
220
- id,
221
- depth,
222
- isOpen,
223
- isActive,
224
- isLeaf: !hasChildren,
225
- });
226
-
227
- if (isOpen && hasChildren) {
228
- result.push(...flattenTree(children ?? [], depth + 1));
229
- }
230
- }
231
- return result;
232
- }
233
-
234
116
  function collectNonLeafIds(itemsList: readonly TreeItem[]): unknown[] {
235
117
  const allIds: unknown[] = [];
236
118
  for (const item of itemsList) {
@@ -242,7 +124,8 @@ function useVirtualTree(
242
124
  return allIds;
243
125
  }
244
126
 
245
- const displayItems = computed(() => flattenTree(props.value.items ?? []));
127
+ const flattenContext = { props, actualItemProps, openedSet, activeSet, getChildrenOf };
128
+ const displayItems = computed(() => flattenTree(flattenContext, props.value.items ?? []));
246
129
 
247
130
  watch(
248
131
  () => props.value.search,
@@ -267,5 +150,11 @@ function useVirtualTree(
267
150
  };
268
151
  }
269
152
 
153
+ export type {
154
+ DisplayItem,
155
+ EmitFn,
156
+ ItemPropsConfig,
157
+ SelectionConfig,
158
+ TreeItem,
159
+ } from "./virtual_tree_types";
270
160
  export { useVirtualTree };
271
- export type { TreeItem, ItemPropsConfig, SelectionConfig, DisplayItem, EmitFn };
@@ -0,0 +1,109 @@
1
+ import type { ComputedRef, Ref } from "vue";
2
+ import {
3
+ type DisplayItem,
4
+ type ItemPropsConfig,
5
+ type TreeItem,
6
+ type VirtualTreeProps,
7
+ toDisplayString,
8
+ } from "./virtual_tree_types";
9
+
10
+ interface FlattenContext {
11
+ props: Ref<VirtualTreeProps>;
12
+ actualItemProps: ComputedRef<ItemPropsConfig>;
13
+ openedSet: ComputedRef<Set<unknown>>;
14
+ activeSet: ComputedRef<Set<unknown>>;
15
+ getChildrenOf: (item: TreeItem) => TreeItem[] | undefined;
16
+ }
17
+
18
+ function matchesSearch(ctx: FlattenContext, item: TreeItem, id: unknown, search: string): boolean {
19
+ const { customFilter } = ctx.props.value;
20
+ if (customFilter) {
21
+ return customFilter(id, search, { raw: item });
22
+ }
23
+ const lowerSearch = search.toLowerCase();
24
+ return (
25
+ toDisplayString(item[ctx.actualItemProps.value.title]).toLowerCase().includes(lowerSearch) ||
26
+ toDisplayString(id).toLowerCase().includes(lowerSearch)
27
+ );
28
+ }
29
+
30
+ function createDisplayItem(ctx: FlattenContext, item: TreeItem, depth: number): DisplayItem {
31
+ const id = item[ctx.actualItemProps.value.value];
32
+ return {
33
+ raw: item,
34
+ id,
35
+ depth,
36
+ isOpen: ctx.openedSet.value.has(id),
37
+ isActive: ctx.activeSet.value.has(id),
38
+ isLeaf: true,
39
+ };
40
+ }
41
+
42
+ type FlattenChildren = (children: readonly TreeItem[]) => DisplayItem[];
43
+
44
+ // A branch is kept when it matches or when one of its descendants does
45
+ function flattenSearchedBranch(
46
+ entry: DisplayItem,
47
+ subtree: readonly DisplayItem[],
48
+ matches: boolean,
49
+ ): DisplayItem[] {
50
+ if (subtree.length === 0 && !matches) {
51
+ return [];
52
+ }
53
+ const branch = { ...entry, isLeaf: false };
54
+ if (!branch.isOpen) {
55
+ return [branch];
56
+ }
57
+ return [branch, ...subtree];
58
+ }
59
+
60
+ function flattenOpenBranch(
61
+ entry: DisplayItem,
62
+ children: readonly TreeItem[],
63
+ flattenChildren: FlattenChildren,
64
+ ): DisplayItem[] {
65
+ const branch = { ...entry, isLeaf: false };
66
+ if (!branch.isOpen) {
67
+ return [branch];
68
+ }
69
+ return [branch, ...flattenChildren(children)];
70
+ }
71
+
72
+ function flattenNode(
73
+ ctx: FlattenContext,
74
+ item: TreeItem,
75
+ depth: number,
76
+ flattenChildren: FlattenChildren,
77
+ ): DisplayItem[] {
78
+ const { search } = ctx.props.value;
79
+ const entry = createDisplayItem(ctx, item, depth);
80
+ const children = ctx.getChildrenOf(item) ?? [];
81
+ const searching = search !== undefined && search !== "";
82
+
83
+ if (children.length === 0) {
84
+ if (searching && !matchesSearch(ctx, item, entry.id, search)) {
85
+ return [];
86
+ }
87
+ return [entry];
88
+ }
89
+ if (searching) {
90
+ const matches = matchesSearch(ctx, item, entry.id, search);
91
+ return flattenSearchedBranch(entry, flattenChildren(children), matches);
92
+ }
93
+ return flattenOpenBranch(entry, children, flattenChildren);
94
+ }
95
+
96
+ function flattenTree(ctx: FlattenContext, nodes: readonly TreeItem[], depth = 0): DisplayItem[] {
97
+ const result: DisplayItem[] = [];
98
+ function flattenChildren(children: readonly TreeItem[]): DisplayItem[] {
99
+ return flattenTree(ctx, children, depth + 1);
100
+ }
101
+
102
+ for (const item of nodes) {
103
+ result.push(...flattenNode(ctx, item, depth, flattenChildren));
104
+ }
105
+ return result;
106
+ }
107
+
108
+ export { flattenTree };
109
+ export type { FlattenContext };
@@ -0,0 +1,81 @@
1
+ import type { ComputedRef, Ref } from "vue";
2
+
3
+ // Same shape as Vue's MaybeRefOrGetter<T>, kept as a local alias for readability at call sites.
4
+ type ReadonlyMaybeRefOrGetter<Value> = Value | Ref<Value> | (() => Value);
5
+
6
+ type TreeItem = Record<string, unknown>;
7
+
8
+ interface ItemPropsConfig {
9
+ value: string;
10
+ title: string;
11
+ children: string;
12
+ height: number;
13
+ [key: string]: unknown;
14
+ }
15
+
16
+ interface SelectionConfig {
17
+ selectable: boolean;
18
+ strategy: string;
19
+ [key: string]: unknown;
20
+ }
21
+
22
+ interface VirtualTreeProps {
23
+ readonly items?: readonly TreeItem[];
24
+ readonly opened?: readonly unknown[];
25
+ readonly selected?: readonly unknown[];
26
+ readonly active?: readonly unknown[];
27
+ readonly itemProps?: Partial<ItemPropsConfig>;
28
+ readonly selection?: Partial<SelectionConfig>;
29
+ readonly search?: string;
30
+ readonly customFilter?: (id: unknown, search: string, context: { raw: TreeItem }) => boolean;
31
+ }
32
+
33
+ interface DisplayItem {
34
+ raw: TreeItem;
35
+ id: unknown;
36
+ depth: number;
37
+ isOpen: boolean;
38
+ isActive: boolean;
39
+ isLeaf: boolean;
40
+ }
41
+
42
+ type EmitFn = (event: string, ...args: readonly unknown[]) => void;
43
+
44
+ interface UseVirtualTreeReturn {
45
+ actualItemProps: ComputedRef<ItemPropsConfig>;
46
+ actualSelection: ComputedRef<SelectionConfig>;
47
+ displayItems: ComputedRef<DisplayItem[]>;
48
+ toggleOpen: (item: TreeItem) => void;
49
+ toggleSelect: (item: TreeItem) => void;
50
+ isSelected: (item: TreeItem) => boolean;
51
+ getIndeterminate: (item: TreeItem) => boolean;
52
+ }
53
+
54
+ // Real runtime check (rather than an `as TreeItem[]` cast) for the duck-typed "children" field:
55
+ // Item shapes vary across callers (treeview groups, model component/collection groups, ...), so
56
+ // This only verifies it is actually an array, same as the assumption the old cast silently made.
57
+ function isTreeItemArray(value: unknown): value is TreeItem[] {
58
+ return Array.isArray(value);
59
+ }
60
+
61
+ // Extracted so we never call String() directly on a value typed as `unknown` (ids and titles can
62
+ // Be anything at runtime): only stringify primitives that have a sane toString, and fall back to
63
+ // "" for anything else instead of risking "[object Object]".
64
+ function toDisplayString(value: unknown): string {
65
+ if (typeof value === "string" || typeof value === "number" || typeof value === "boolean") {
66
+ return String(value);
67
+ }
68
+ return "";
69
+ }
70
+
71
+ export { isTreeItemArray, toDisplayString };
72
+ export type {
73
+ DisplayItem,
74
+ EmitFn,
75
+ ItemPropsConfig,
76
+ ReadonlyMaybeRefOrGetter,
77
+ SelectionConfig,
78
+ TreeItem,
79
+ UseVirtualTreeReturn,
80
+ VirtualTreeProps,
81
+ };
package/app/stores/app.ts CHANGED
@@ -1,6 +1,9 @@
1
- import { consola } from "consola";
2
-
3
1
  // Local imports
2
+ import {
3
+ type RegisterableStore,
4
+ exportRegisteredStores,
5
+ importRegisteredStores,
6
+ } from "./app_helpers/registry.js";
4
7
  import { getRestApiPort, getRestApiProtocol, isCloudMode } from "@ogw_front/utils/stores.js";
5
8
  import { Status } from "@ogw_front/utils/status";
6
9
  import { api_fetch } from "@ogw_internal/utils/api_fetch.js";
@@ -27,16 +30,6 @@ declare module "pinia" {
27
30
  }
28
31
  }
29
32
 
30
- interface RegisterableStore {
31
- $id: string;
32
- $patch?: (partial: Record<string, unknown>) => void;
33
- exportStores?: (params?: Record<string, unknown>) => Promise<unknown>;
34
- importStores?: (snapshot: unknown) => Promise<void> | void;
35
- connect?: () => Promise<void>;
36
- kill?: () => Promise<void>;
37
- [key: string]: unknown;
38
- }
39
-
40
33
  // oxlint-disable-next-line max-lines-per-function, max-statements
41
34
  export const useAppStore = defineStore("app", () => {
42
35
  const stores: RegisterableStore[] = [];
@@ -85,52 +78,12 @@ export const useAppStore = defineStore("app", () => {
85
78
  async function exportStores(
86
79
  params: Record<string, unknown> = {},
87
80
  ): Promise<Record<string, unknown>> {
88
- const snapshot: Record<string, unknown> = {};
89
-
90
- await Promise.all(
91
- stores.map(async (store: RegisterableStore) => {
92
- if (!store.exportStores) {
93
- return;
94
- }
95
- const storeId = store.$id;
96
- try {
97
- snapshot[storeId] = await store.exportStores(params);
98
- } catch {
99
- // Ignore stores that fail to export; other stores still complete independently.
100
- }
101
- }),
102
- );
81
+ const snapshot = await exportRegisteredStores(stores, params);
103
82
  return snapshot;
104
83
  }
105
84
 
106
85
  async function importStores(snapshot: Record<string, unknown> | undefined): Promise<void> {
107
- if (!snapshot) {
108
- return;
109
- }
110
-
111
- const missingStoreIds: string[] = [];
112
-
113
- await Promise.all(
114
- stores.map(async (store: RegisterableStore) => {
115
- if (!store.importStores) {
116
- return;
117
- }
118
- const storeId = store.$id;
119
- if (snapshot[storeId] === undefined) {
120
- missingStoreIds.push(storeId);
121
- return;
122
- }
123
- try {
124
- await store.importStores(snapshot[storeId]);
125
- } catch {
126
- // Ignore stores that fail to import; other stores still complete independently.
127
- }
128
- }),
129
- );
130
-
131
- if (missingStoreIds.length > 0) {
132
- consola.warn(`Stores not found in snapshot: ${missingStoreIds.join(", ")}`);
133
- }
86
+ await importRegisteredStores(stores, snapshot);
134
87
  }
135
88
 
136
89
  const {
@@ -253,4 +206,4 @@ export const useAppStore = defineStore("app", () => {
253
206
  };
254
207
  });
255
208
 
256
- export type { RegisterableStore };
209
+ export type { RegisterableStore } from "./app_helpers/registry.js";
@@ -26,6 +26,85 @@ interface ExtensionData {
26
26
  enabled: boolean;
27
27
  }
28
28
 
29
+ async function transformBlobUrl(
30
+ path: string,
31
+ transformer: ((code: string) => string) | undefined,
32
+ ): Promise<string> {
33
+ if (!transformer || !path.startsWith("blob:")) {
34
+ return path;
35
+ }
36
+ const response = await fetch(path);
37
+ const code = await response.text();
38
+ const transformedCode = transformer(code);
39
+
40
+ const newBlob = new Blob([transformedCode], {
41
+ type: "application/javascript",
42
+ });
43
+ return URL.createObjectURL(newBlob);
44
+ }
45
+
46
+ async function importExtensionModule(
47
+ path: string,
48
+ transformer: ((code: string) => string) | undefined,
49
+ extensionPort: string,
50
+ serverPort?: string,
51
+ ): Promise<ExtensionModule> {
52
+ const finalURL = await transformBlobUrl(path, transformer);
53
+ // oxlint-disable-next-line no-inline-comments, no-unsafe-assignment
54
+ const extensionModule: ExtensionModule = await import(/* @vite-ignore */ finalURL);
55
+ const store = extensionModule.metadata.store();
56
+ store.$patch?.({
57
+ default_local_port: extensionPort,
58
+ ...(serverPort !== undefined && { nitro_port: serverPort }),
59
+ });
60
+
61
+ if (finalURL !== path && finalURL.startsWith("blob:")) {
62
+ URL.revokeObjectURL(finalURL);
63
+ }
64
+ return extensionModule;
65
+ }
66
+
67
+ function validateExtensionModule(
68
+ extensionModule: ExtensionModule,
69
+ api: unknown,
70
+ loaded: Map<string, ExtensionData>,
71
+ ): void {
72
+ if (!extensionModule.metadata?.id) {
73
+ throw new Error("Extension must have metadata.id");
74
+ }
75
+
76
+ const extensionId = extensionModule.metadata.id;
77
+
78
+ if (loaded.has(extensionId)) {
79
+ consola.warn(`[AppStore] Extension "${extensionId}" is already loaded`);
80
+ throw new Error(`Extension "${extensionId}" is already loaded.`);
81
+ }
82
+
83
+ if (api === undefined) {
84
+ throw new Error("Extension API not initialized");
85
+ }
86
+
87
+ if (typeof extensionModule.install !== "function") {
88
+ throw new TypeError("Extension must export an install function");
89
+ }
90
+ }
91
+
92
+ function createExtensionData(
93
+ extensionModule: ExtensionModule,
94
+ path: string,
95
+ backendPath: string | undefined,
96
+ ): ExtensionData {
97
+ return {
98
+ module: extensionModule,
99
+ id: extensionModule.metadata.id,
100
+ path,
101
+ backendPath,
102
+ loadedAt: new Date().toISOString(),
103
+ metadata: extensionModule.metadata,
104
+ enabled: true,
105
+ };
106
+ }
107
+
29
108
  // oxlint-disable-next-line max-lines-per-function, max-statements
30
109
  export function useAppExtensions(): {
31
110
  loadedExtensions: typeof loadedExtensions;
@@ -63,61 +142,21 @@ export function useAppExtensions(): {
63
142
  backendPath?: string,
64
143
  ): Promise<ExtensionModule> {
65
144
  try {
66
- let finalURL = path;
67
-
68
- if (codeTransformer.value && path.startsWith("blob:")) {
69
- const response = await fetch(path);
70
- const code = await response.text();
71
- const transformedCode = codeTransformer.value(code);
72
-
73
- const newBlob = new Blob([transformedCode], {
74
- type: "application/javascript",
75
- });
76
- finalURL = URL.createObjectURL(newBlob);
77
- }
78
- // oxlint-disable-next-line no-inline-comments, no-unsafe-assignment
79
- const extensionModule: ExtensionModule = await import(/* @vite-ignore */ finalURL);
80
- const store = extensionModule.metadata.store();
81
- store.$patch?.({
82
- default_local_port: extensionPort,
83
- ...(serverPort === undefined ? {} : { nitro_port: serverPort }),
84
- });
85
-
86
- if (finalURL !== path && finalURL.startsWith("blob:")) {
87
- URL.revokeObjectURL(finalURL);
88
- }
89
-
90
- if (!extensionModule.metadata?.id) {
91
- throw new Error("Extension must have metadata.id");
92
- }
93
-
145
+ const extensionModule = await importExtensionModule(
146
+ path,
147
+ codeTransformer.value,
148
+ extensionPort,
149
+ serverPort,
150
+ );
151
+ validateExtensionModule(extensionModule, extensionAPI.value, loadedExtensions.value);
94
152
  const extensionId = extensionModule.metadata.id;
95
153
 
96
- if (loadedExtensions.value.has(extensionId)) {
97
- consola.warn(`[AppStore] Extension "${extensionId}" is already loaded`);
98
- throw new Error(`Extension "${extensionId}" is already loaded.`);
99
- }
100
-
101
- if (extensionAPI.value === undefined) {
102
- throw new Error("Extension API not initialized");
103
- }
104
-
105
- if (typeof extensionModule.install !== "function") {
106
- throw new TypeError("Extension must export an install function");
107
- }
108
-
109
154
  await extensionModule.install(extensionAPI.value, backendPath);
110
155
 
111
- const extensionData: ExtensionData = {
112
- module: extensionModule,
113
- id: extensionId,
114
- path,
115
- backendPath,
116
- loadedAt: new Date().toISOString(),
117
- metadata: extensionModule.metadata,
118
- enabled: true,
119
- };
120
- loadedExtensions.value.set(extensionId, extensionData);
156
+ loadedExtensions.value.set(
157
+ extensionId,
158
+ createExtensionData(extensionModule, path, backendPath),
159
+ );
121
160
 
122
161
  consola.info(`[AppStore] Extension loaded successfully: ${extensionId}`);
123
162
  return extensionModule;
@@ -0,0 +1,69 @@
1
+ import { consola } from "consola";
2
+
3
+ interface RegisterableStore {
4
+ $id: string;
5
+ $patch?: (partial: Record<string, unknown>) => void;
6
+ exportStores?: (params?: Record<string, unknown>) => Promise<unknown>;
7
+ importStores?: (snapshot: unknown) => Promise<void> | void;
8
+ connect?: () => Promise<void>;
9
+ kill?: () => Promise<void>;
10
+ [key: string]: unknown;
11
+ }
12
+
13
+ async function exportRegisteredStores(
14
+ stores: readonly RegisterableStore[],
15
+ params: Record<string, unknown> = {},
16
+ ): Promise<Record<string, unknown>> {
17
+ const snapshot: Record<string, unknown> = {};
18
+
19
+ await Promise.all(
20
+ stores.map(async (store: RegisterableStore) => {
21
+ if (!store.exportStores) {
22
+ return;
23
+ }
24
+ const storeId = store.$id;
25
+ try {
26
+ snapshot[storeId] = await store.exportStores(params);
27
+ } catch {
28
+ // Ignore stores that fail to export; other stores still complete independently.
29
+ }
30
+ }),
31
+ );
32
+ return snapshot;
33
+ }
34
+
35
+ async function importRegisteredStores(
36
+ stores: readonly RegisterableStore[],
37
+ snapshot: Record<string, unknown> | undefined,
38
+ ): Promise<void> {
39
+ if (!snapshot) {
40
+ return;
41
+ }
42
+
43
+ const missingStoreIds: string[] = [];
44
+
45
+ await Promise.all(
46
+ stores.map(async (store: RegisterableStore) => {
47
+ if (!store.importStores) {
48
+ return;
49
+ }
50
+ const storeId = store.$id;
51
+ if (snapshot[storeId] === undefined) {
52
+ missingStoreIds.push(storeId);
53
+ return;
54
+ }
55
+ try {
56
+ await store.importStores(snapshot[storeId]);
57
+ } catch {
58
+ // Ignore stores that fail to import; other stores still complete independently.
59
+ }
60
+ }),
61
+ );
62
+
63
+ if (missingStoreIds.length > 0) {
64
+ consola.warn(`Stores not found in snapshot: ${missingStoreIds.join(", ")}`);
65
+ }
66
+ }
67
+
68
+ export { exportRegisteredStores, importRegisteredStores };
69
+ export type { RegisterableStore };