@geode/opengeodeweb-front 12.2.0-rc.3 → 12.2.0-rc.5

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 (135) hide show
  1. package/.build/tests/browser/helpers/object_trees/common.js +3 -1
  2. package/.build/tests/browser/helpers/object_trees/model_tree_bar.js +41 -0
  3. package/.build/tests/browser/helpers/wait_for_action_settled.js +2 -2
  4. package/.build/tests/browser/suites/index.js +2 -0
  5. package/.build/tests/browser/suites/model/collections.js +1 -1
  6. package/.build/tests/browser/suites/object_tree/controls.js +2 -1
  7. package/.build/tests/browser/suites/object_tree/model_tree_bar.js +81 -0
  8. package/app/components/ClippingPlanes.vue +1 -1
  9. package/app/components/FactorFilterPanel.vue +1 -1
  10. package/app/components/Launcher.vue +3 -2
  11. package/app/components/ThresholdFilter.vue +1 -2
  12. package/app/components/Viewer/Basemap/CropOptions.vue +7 -8
  13. package/app/components/Viewer/Basemap/OpacityOptions.vue +7 -8
  14. package/app/components/Viewer/ContextMenu/CircularItems.vue +6 -43
  15. package/app/components/Viewer/ContextMenu/ContextMenu.vue +1 -6
  16. package/app/components/Viewer/ContextMenu/ContextMenuItem.vue +14 -16
  17. package/app/components/Viewer/EdgedCurve/PointsOptions.vue +5 -4
  18. package/app/components/Viewer/EdgedCurve/SpecificEdgesOptions.vue +10 -13
  19. package/app/components/Viewer/Generic/Mesh/CellsOptions.vue +8 -11
  20. package/app/components/Viewer/Generic/Mesh/EdgesOptions.vue +16 -13
  21. package/app/components/Viewer/Generic/Mesh/PointsOptions.vue +28 -31
  22. package/app/components/Viewer/Generic/Mesh/PolygonsOptions.vue +9 -11
  23. package/app/components/Viewer/Generic/Mesh/PolyhedraOptions.vue +8 -11
  24. package/app/components/Viewer/Generic/Model/BlocksOptions.vue +1 -1
  25. package/app/components/Viewer/Generic/Model/CornersOptions.vue +1 -1
  26. package/app/components/Viewer/Generic/Model/CornersTypeOptions.vue +1 -1
  27. package/app/components/Viewer/Generic/Model/EdgesOptions.vue +7 -8
  28. package/app/components/Viewer/Generic/Model/LinesOptions.vue +1 -1
  29. package/app/components/Viewer/Generic/Model/LinesTypeOptions.vue +1 -1
  30. package/app/components/Viewer/Generic/Model/ModelEdgesCard.vue +5 -7
  31. package/app/components/Viewer/Generic/Model/ModelPointsCard.vue +5 -7
  32. package/app/components/Viewer/Generic/Model/ModelStyleCard.vue +5 -7
  33. package/app/components/Viewer/Generic/Model/ModelStyleOptions.vue +7 -8
  34. package/app/components/Viewer/Generic/Model/PointsOptions.vue +7 -8
  35. package/app/components/Viewer/Generic/Model/SurfacesOptions.vue +1 -1
  36. package/app/components/Viewer/Grid/2D/CellsOptions.vue +6 -4
  37. package/app/components/Viewer/Grid/2D/EdgesOptions.vue +6 -4
  38. package/app/components/Viewer/Grid/2D/PointsOptions.vue +5 -4
  39. package/app/components/Viewer/Grid/3D/CellsOptions.vue +6 -4
  40. package/app/components/Viewer/Grid/3D/EdgesOptions.vue +6 -4
  41. package/app/components/Viewer/Grid/3D/FacetsOptions.vue +6 -4
  42. package/app/components/Viewer/Grid/3D/PointsOptions.vue +5 -4
  43. package/app/components/Viewer/Image/ImageOptions.vue +10 -13
  44. package/app/components/Viewer/ObjectTree/Base/CommonTreeView.vue +17 -1
  45. package/app/components/Viewer/ObjectTree/Base/ComponentRelations.vue +2 -2
  46. package/app/components/Viewer/ObjectTree/Base/Controls.vue +26 -2
  47. package/app/components/Viewer/ObjectTree/Base/StickyHeader.vue +4 -1
  48. package/app/components/Viewer/ObjectTree/Base/TreeRow.vue +6 -8
  49. package/app/components/Viewer/ObjectTree/Box.vue +30 -5
  50. package/app/components/Viewer/ObjectTree/Layout.vue +183 -54
  51. package/app/components/Viewer/ObjectTree/Views/GlobalObjects.vue +10 -15
  52. package/app/components/Viewer/ObjectTree/Views/ModelTree.vue +3 -0
  53. package/app/components/Viewer/PointSet/SpecificPointsOptions.vue +28 -31
  54. package/app/components/Viewer/Scene/BackgroundOptions.vue +4 -7
  55. package/app/components/Viewer/Scene/OrientationWidgetOptions.vue +4 -7
  56. package/app/components/Viewer/Scene/TextOptions.vue +4 -7
  57. package/app/components/Viewer/Solid/EdgesOptions.vue +6 -4
  58. package/app/components/Viewer/Solid/PointsOptions.vue +5 -4
  59. package/app/components/Viewer/Solid/PolygonsOptions.vue +6 -4
  60. package/app/components/Viewer/Solid/SpecificPolyhedraOptions.vue +8 -11
  61. package/app/components/Viewer/Surface/EdgesOptions.vue +6 -4
  62. package/app/components/Viewer/Surface/PointsOptions.vue +6 -4
  63. package/app/components/Viewer/Surface/PolygonsOptions.vue +8 -11
  64. package/app/components/Viewer/Surface/Triangulated/TrianglesOptions.vue +5 -4
  65. package/app/components/Viewer/TetrahedralSolid/TetrahedraOptions.vue +6 -4
  66. package/app/components/Viewer/TetrahedralSolid/TrianglesOptions.vue +6 -4
  67. package/app/composables/circular_menu.ts +45 -0
  68. package/app/composables/hover_highlight.ts +1 -1
  69. package/app/composables/model_menu_context.ts +7 -11
  70. package/app/composables/model_tree.ts +3 -3
  71. package/app/composables/model_tree_drag.ts +56 -0
  72. package/app/composables/project_manager_helpers/types.ts +2 -3
  73. package/app/composables/use_adaptive_styles.ts +15 -8
  74. package/app/composables/use_overlapping_picker.ts +7 -19
  75. package/app/composables/viewer_context_menu.ts +2 -1
  76. package/app/composables/virtual_tree.ts +7 -1
  77. package/app/stores/api.ts +6 -59
  78. package/app/stores/app.ts +21 -55
  79. package/app/stores/back.ts +86 -145
  80. package/app/stores/camera_manager.ts +12 -25
  81. package/app/stores/cloud.ts +21 -101
  82. package/app/stores/crs.ts +3 -2
  83. package/app/stores/data.ts +66 -409
  84. package/app/stores/data_style.ts +99 -93
  85. package/app/stores/feedback.ts +57 -53
  86. package/app/stores/infra.ts +61 -101
  87. package/app/stores/treeview.ts +39 -30
  88. package/app/stores/viewer.ts +9 -29
  89. package/app/stores/viewer_helpers/actions.ts +1 -23
  90. package/app/utils/backend_lifecycle.ts +155 -0
  91. package/app/utils/import_item.ts +5 -4
  92. package/app/utils/threshold_sources.ts +3 -2
  93. package/app/utils/treeview.ts +25 -1
  94. package/app/utils/viewer_object_type.ts +21 -0
  95. package/internal/database/base_database.ts +2 -1
  96. package/internal/database/database.ts +90 -7
  97. package/internal/database/queries.ts +45 -0
  98. package/internal/database/tables/camera_positions.ts +11 -1
  99. package/internal/database/tables/data.ts +20 -1
  100. package/internal/database/tables/data_style.ts +3 -1
  101. package/internal/database/tables/model_component_datastyle.ts +3 -1
  102. package/internal/database/tables/model_component_type_datastyle.ts +3 -1
  103. package/internal/database/tables/model_components.ts +12 -1
  104. package/internal/database/tables/model_components_relation.ts +11 -1
  105. package/internal/database/tables/scene_style.ts +3 -1
  106. package/internal/database/tables/treeview_config.ts +31 -0
  107. package/internal/stores/data/items.ts +110 -0
  108. package/internal/stores/data/model/collections.ts +107 -0
  109. package/internal/stores/data/model/components.ts +129 -0
  110. package/internal/stores/data/model/mesh_components.ts +134 -0
  111. package/internal/stores/data/model/relations.ts +76 -0
  112. package/internal/stores/data/model/types.ts +14 -0
  113. package/internal/stores/data/registration.ts +54 -0
  114. package/internal/stores/data/snapshot.ts +83 -0
  115. package/internal/stores/data/types.ts +26 -0
  116. package/internal/stores/data_style/model/common_mutations.ts +47 -77
  117. package/internal/stores/data_style/model/selection.ts +3 -10
  118. package/internal/stores/data_style/scene.ts +2 -2
  119. package/internal/stores/data_style/state.ts +10 -8
  120. package/internal/stores/data_style/state_shared.ts +10 -7
  121. package/internal/stores/hybrid_viewer/brightness.ts +36 -19
  122. package/internal/stores/hybrid_viewer/highlight.ts +9 -14
  123. package/internal/stores/hybrid_viewer/scene.ts +1 -1
  124. package/internal/stores/microservice.ts +192 -0
  125. package/package.json +1 -1
  126. package/tests/browser/helpers/data/helpers/attribute.ts +2 -1
  127. package/tests/browser/helpers/object_trees/common.ts +4 -0
  128. package/tests/browser/helpers/object_trees/model_tree_bar.ts +78 -0
  129. package/tests/browser/helpers/wait_for_action_settled.ts +2 -3
  130. package/tests/browser/suites/model/collections.ts +2 -1
  131. package/tests/browser/suites/object_tree/controls.ts +3 -0
  132. package/tests/browser/suites/object_tree/model_tree_bar.ts +125 -0
  133. package/app/stores/data_helpers/collections.ts +0 -122
  134. package/app/stores/data_helpers/mesh.ts +0 -167
  135. package/app/stores/data_helpers/relations.ts +0 -94
@@ -1,9 +1,3 @@
1
- import { consola } from "consola";
2
-
3
- // Not auto-fixable (eslint's sort-imports core rule has no autofixer) and this file's import order doesn't match its syntax-kind-then-alphabetical requirement - left as-is rather than manually reordered across the codebase for a purely cosmetic rule.
4
- // oxlint-disable eslint/sort-imports, eslint/max-lines
5
- import { defineStore } from "pinia";
6
-
7
1
  import type { DataId, GeodeId } from "@geode/opengeodeweb-microservice/schema_types";
8
2
  import type {
9
3
  GeodeIdentified,
@@ -14,23 +8,21 @@ import type {
14
8
  GeodeObjectType,
15
9
  ViewerObjectType,
16
10
  } from "@geode/opengeodeweb-microservice/data_types";
11
+ import type {
12
+ OpenedView,
13
+ TreeviewConfigRecord,
14
+ } from "@ogw_internal/database/tables/treeview_config";
17
15
  import type { TreeGroup, TreeNode } from "@ogw_front/types/tree";
18
16
  import { ref, watch } from "vue";
19
- import { getTable } from "@ogw_internal/database/database";
17
+ import { consola } from "consola";
18
+ // Not auto-fixable (eslint's sort-imports core rule has no autofixer) and this file's import order doesn't match its syntax-kind-then-alphabetical requirement - left as-is rather than manually reordered across the codebase for a purely cosmetic rule.
19
+ // oxlint-disable eslint/sort-imports, eslint/max-lines
20
+ import { defineStore } from "pinia";
20
21
  import { nextModelTreeColor } from "@ogw_front/utils/treeview";
22
+ import { treeviewConfigDb } from "@ogw_internal/database/database";
21
23
 
22
24
  const PANEL_WIDTH = 300;
23
25
 
24
- interface OpenedView extends Partial<GeodeObjectTyped> {
25
- type: "object" | "component";
26
- id: string;
27
- title: string;
28
- scrollTop: number;
29
- opened: string[];
30
- // Ties a model tree to its row in the objects tree
31
- color?: string;
32
- }
33
-
34
26
  interface TreeviewChild extends TreeNode, GeodeIdentified, GeodeObjectTyped, ViewerObjectTyped {
35
27
  // Still being loaded in the viewer: shown with a spinner and not interactive yet
36
28
  loading?: boolean;
@@ -43,15 +35,6 @@ interface PendingImport extends TreeNode, GeodeObjectTyped {
43
35
 
44
36
  type TreeviewGroup = TreeGroup<TreeviewChild>;
45
37
 
46
- interface TreeviewConfigRecord {
47
- id: string;
48
- opened_views: OpenedView[];
49
- panelWidth: number;
50
- additionalPanelWidth: number;
51
- selectionIds: string[];
52
- rowHeights: number[];
53
- }
54
-
55
38
  interface TreeviewSnapshot {
56
39
  opened_views?: OpenedView[];
57
40
  panelWidth?: number;
@@ -117,11 +100,11 @@ export const useTreeviewStore = defineStore("treeview", () => {
117
100
  // Model hovered in the objects tree or on its model tree header: not saved
118
101
  const hoveredModelId = ref<string | undefined>(undefined);
119
102
 
120
- const treeview_config_db = getTable<TreeviewConfigRecord>("treeview_config");
103
+ const treeviewConfigTable = treeviewConfigDb();
121
104
 
122
105
  async function loadConfig(): Promise<void> {
123
106
  try {
124
- const config = await treeview_config_db.get("main");
107
+ const config = await treeviewConfigTable.get("main");
125
108
  if (config?.opened_views) {
126
109
  opened_views.value = withModelTreeColors(config.opened_views);
127
110
  }
@@ -156,7 +139,7 @@ export const useTreeviewStore = defineStore("treeview", () => {
156
139
 
157
140
  // Best-effort persistence: a failure is logged, not thrown.
158
141
  try {
159
- await treeview_config_db.put({
142
+ await treeviewConfigTable.put({
160
143
  id: "main",
161
144
  opened_views: clean_opened_views,
162
145
  panelWidth: panelWidth.value,
@@ -318,12 +301,35 @@ export const useTreeviewStore = defineStore("treeview", () => {
318
301
  });
319
302
  }
320
303
 
304
+ function setCollapsed(id: string, collapsed: boolean): void {
305
+ const existing = opened_views.value.find((view: ReadonlyOpenedView) => view.id === id);
306
+ if (existing) {
307
+ existing.collapsed = collapsed;
308
+ }
309
+ }
310
+
311
+ function toggleCollapsed(id: string): void {
312
+ const existing = opened_views.value.find((view: ReadonlyOpenedView) => view.id === id);
313
+ setCollapsed(id, existing?.collapsed !== true);
314
+ }
315
+
316
+ function setAllCollapsed(collapsed: boolean): void {
317
+ for (const view of opened_views.value) {
318
+ if (view.type === "component") {
319
+ view.collapsed = collapsed;
320
+ }
321
+ }
322
+ }
323
+
321
324
  function setHoveredModel(id: string | undefined): void {
322
325
  hoveredModelId.value = id;
323
326
  }
324
327
 
328
+ // The objects tree keeps its place, first: only the model trees move
325
329
  function moveView(from_index: number, to_index: number): void {
326
- if (from_index !== 0 && to_index !== 0) {
330
+ const moved = opened_views.value[from_index];
331
+ const target = opened_views.value[to_index];
332
+ if (moved && target && moved.id !== "main" && target.id !== "main") {
327
333
  const [element] = opened_views.value.splice(from_index, 1);
328
334
  if (element) {
329
335
  opened_views.value.splice(to_index, 0, element);
@@ -455,6 +461,9 @@ export const useTreeviewStore = defineStore("treeview", () => {
455
461
  displayAdditionalTree,
456
462
  closeView,
457
463
  toggleView,
464
+ setCollapsed,
465
+ toggleCollapsed,
466
+ setAllCollapsed,
458
467
  moveView,
459
468
  importStores,
460
469
  displayFileTree,
@@ -8,27 +8,22 @@ import opengeodeweb_viewer_schemas from "@geode/opengeodeweb-viewer/opengeodeweb
8
8
 
9
9
  // Local imports
10
10
  import { type ViewerRequestArgs, callViewer } from "./viewer_helpers/request.js";
11
- import {
12
- fetchViewerVersion,
13
- launchViewerMicroservice,
14
- pickWorldPosition,
15
- showRenderingWarnings,
16
- } from "./viewer_helpers/actions.js";
17
11
  import {
18
12
  getWebsocketApiPort,
19
13
  getWebsocketApiProtocol,
20
14
  isCloudMode,
21
15
  } from "@ogw_front/utils/stores.js";
16
+ import {
17
+ launchViewerMicroservice,
18
+ pickWorldPosition,
19
+ showRenderingWarnings,
20
+ } from "./viewer_helpers/actions.js";
21
+ import { useMicroserviceVersion, useRequestCounter } from "@ogw_internal/stores/microservice";
22
22
  import { Status } from "@ogw_front/utils/status";
23
23
  import { afterViewerReset } from "@ogw_front/composables/viewer_reset";
24
24
  import { useInfraStore } from "@ogw_front/stores/infra";
25
25
 
26
- import type {
27
- JsonRpcSchema,
28
- MicroserviceVersionSchema,
29
- RequestHandlers,
30
- ResponseOf,
31
- } from "@ogw_shared/utils/types.js";
26
+ import type { JsonRpcSchema, RequestHandlers, ResponseOf } from "@ogw_shared/utils/types.js";
32
27
  import type { RpcClient } from "@ogw_shared/utils/call_raw.js";
33
28
 
34
29
  interface ViewSize {
@@ -59,9 +54,8 @@ export const useViewerStore = defineStore(
59
54
  });
60
55
  // Pixel size of the remote rendering view, as sent to the server by RemoteView.resize()
61
56
  const view_size = ref<ViewSize>({ width: 0, height: 0 });
62
- const request_counter = ref(0);
57
+ const { request_counter, is_busy, start_request, stop_request } = useRequestCounter();
63
58
  const status = ref(Status.NOT_CONNECTED);
64
- const version = ref("0.0.0");
65
59
  // The viewer warnings are shown once, not again on each reconnection
66
60
  const rendering_warnings_shown = ref(false);
67
61
  const protocol = computed(() => getWebsocketApiProtocol());
@@ -74,13 +68,6 @@ export const useViewerStore = defineStore(
74
68
  viewer_url += "/ws";
75
69
  return viewer_url;
76
70
  });
77
- function start_request(): void {
78
- request_counter.value += 1;
79
- }
80
- function stop_request(): void {
81
- request_counter.value -= 1;
82
- }
83
- const is_busy = computed(() => request_counter.value > 0);
84
71
  function toggle_picking_mode(value: boolean): void {
85
72
  picking_mode.value = value;
86
73
  }
@@ -157,14 +144,7 @@ export const useViewerStore = defineStore(
157
144
  async function connect(): Promise<void> {
158
145
  await ws_connect();
159
146
  }
160
- async function get_version(
161
- schema: MicroserviceVersionSchema | undefined,
162
- ): Promise<{ microservice_version: string } | undefined> {
163
- const result = await fetchViewerVersion(request, schema, (microservice_version) => {
164
- version.value = microservice_version;
165
- });
166
- return result;
167
- }
147
+ const { version, get_version } = useMicroserviceVersion(request);
168
148
  return {
169
149
  default_local_port,
170
150
  client,
@@ -1,4 +1,3 @@
1
- import type { MicroserviceVersionSchema } from "@ogw_shared/utils/types.js";
2
1
  import type { Vector3 } from "@kitware/vtk.js/types";
3
2
  import type { ViewerRequest } from "./request.js";
4
3
  import { consola } from "consola";
@@ -46,27 +45,6 @@ async function launchViewerMicroservice(
46
45
  return result;
47
46
  }
48
47
 
49
- async function fetchViewerVersion(
50
- request: ViewerRequest,
51
- schema: MicroserviceVersionSchema | undefined,
52
- onVersion: (version: string) => void,
53
- ): Promise<{ microservice_version: string } | undefined> {
54
- if (!schema) {
55
- return undefined;
56
- }
57
- const result = await request(
58
- {
59
- schema,
60
- },
61
- {
62
- response_function: ({ microservice_version }) => {
63
- onVersion(microservice_version);
64
- },
65
- },
66
- );
67
- return result;
68
- }
69
-
70
48
  // Shows the viewer's warnings about its rendering setup, e.g. software rendering fallback.
71
49
  // Informational only: a failure is logged, never thrown, so it cannot break the connection.
72
50
  async function showRenderingWarnings(request: ViewerRequest): Promise<void> {
@@ -82,4 +60,4 @@ async function showRenderingWarnings(request: ViewerRequest): Promise<void> {
82
60
  }
83
61
  }
84
62
 
85
- export { fetchViewerVersion, launchViewerMicroservice, pickWorldPosition, showRenderingWarnings };
63
+ export { launchViewerMicroservice, pickWorldPosition, showRenderingWarnings };
@@ -0,0 +1,155 @@
1
+ // Creates the backend: launches the local microservices, or launches / reaches the cloud service,
2
+ // Then connects every registered microservice. It drives the stores from outside, so the stores
3
+ // Only hold their own state and no store imports another one to orchestrate it.
4
+ import { type Microservice, useInfraStore } from "@ogw_front/stores/infra";
5
+ import { clearCloudUrlParam, getCloudUrlParam } from "@ogw_front/utils/cloud";
6
+ import { Status } from "@ogw_front/utils/status";
7
+ import { api_fetch } from "@ogw_internal/utils/api_fetch";
8
+ import { appMode } from "@ogw_shared/app_mode";
9
+ import back_schemas from "@geode/opengeodeweb-back/opengeodeweb_back_typed_schemas.js";
10
+ import cloud_api_schemas from "@geode/cloud-api/cloud_api_typed_schemas.js";
11
+ import { registerRunningExtensions } from "@ogw_front/utils/extension";
12
+ import { setAppBaseUrl } from "@ogw_shared/scripts";
13
+ import { useAPIStore } from "@ogw_front/stores/api";
14
+ import { useAppStore } from "@ogw_front/stores/app";
15
+ import { useBackStore } from "@ogw_front/stores/back";
16
+ import { useCloudStore } from "@ogw_front/stores/cloud";
17
+
18
+ const CLOUD_PROJECT_FOLDER_PATH = "/project";
19
+
20
+ interface ElectronApi {
21
+ electronAPI: {
22
+ project_folder_path: (args: { projectFolderPath: string }) => void;
23
+ };
24
+ }
25
+
26
+ declare global {
27
+ // oxlint-disable-next-line no-var -- required for global augmentation
28
+ var electronAPI: ElectronApi["electronAPI"];
29
+ }
30
+
31
+ async function launchLocalServices(): Promise<void> {
32
+ const infraStore = useInfraStore();
33
+ const appStore = useAppStore();
34
+ await appStore.createProjectFolder();
35
+ if (infraStore.app_mode === appMode.DESKTOP) {
36
+ globalThis.electronAPI.project_folder_path({
37
+ projectFolderPath: appStore.projectFolderPath,
38
+ });
39
+ }
40
+ await setAppBaseUrl(appStore.base_url);
41
+ const launch_promises: Promise<unknown>[] = infraStore.microservices
42
+ .filter((store: Microservice) => store.launch)
43
+ .map(async (store: Microservice) => {
44
+ const result = await store.launch?.({ projectFolderPath: appStore.projectFolderPath });
45
+ return result;
46
+ });
47
+ launch_promises.push(registerRunningExtensions());
48
+ await Promise.all(launch_promises);
49
+ }
50
+
51
+ async function onCloudConnected(url: string): Promise<void> {
52
+ const appStore = useAppStore();
53
+ useCloudStore().set_connected(true);
54
+ useInfraStore().set_domain_name(url);
55
+ appStore.set_project_folder_path(CLOUD_PROJECT_FOLDER_PATH);
56
+ await setAppBaseUrl(appStore.base_url);
57
+ }
58
+
59
+ // `authToken` is the user's Firebase ID token, checked by the Cloud API
60
+ async function launchCloud(authToken: string): Promise<unknown> {
61
+ const cloudStore = useCloudStore();
62
+ cloudStore.set_connecting();
63
+ const { PROJECT, BRANCH } = useRuntimeConfig().public;
64
+ const result = await useAPIStore().request(
65
+ {
66
+ schema: cloud_api_schemas.cloud_api.cloud.run,
67
+ params: { project: PROJECT, branch: BRANCH },
68
+ headers: { Authorization: `Bearer ${authToken}` },
69
+ },
70
+ {
71
+ request_error_function: () => {
72
+ cloudStore.set_connected(false);
73
+ },
74
+ response_function: async ({ url }) => {
75
+ await onCloudConnected(url);
76
+ },
77
+ response_error_function: () => {
78
+ cloudStore.set_connected(false);
79
+ },
80
+ },
81
+ );
82
+ return result;
83
+ }
84
+
85
+ async function connectExistingCloud(host: string): Promise<void> {
86
+ const cloudStore = useCloudStore();
87
+ cloudStore.set_connecting();
88
+ const backStore = useBackStore();
89
+ // Probe the candidate host directly so domain_name is only updated once the service answers.
90
+ try {
91
+ await api_fetch(
92
+ {
93
+ $id: backStore.$id,
94
+ base_url: backStore.base_url_for(host),
95
+ start_request: () => {
96
+ backStore.start_request();
97
+ },
98
+ stop_request: () => {
99
+ backStore.stop_request();
100
+ },
101
+ },
102
+ { schema: back_schemas.opengeodeweb_back.ping, log_success: false },
103
+ );
104
+ } catch (error) {
105
+ cloudStore.set_connected(false);
106
+ throw error;
107
+ }
108
+ await onCloudConnected(host);
109
+ }
110
+
111
+ // Reuses the running service given by `?cloud_url=` when present, otherwise launches a new one.
112
+ // The param is single use: it is cleared whatever the outcome, so a retry launches a new service.
113
+ async function startCloud(authToken?: string): Promise<void> {
114
+ const existing_host = getCloudUrlParam();
115
+ if (existing_host === undefined) {
116
+ if (authToken === undefined) {
117
+ throw new Error("Launching a cloud service requires an authenticated user");
118
+ }
119
+ await launchCloud(authToken);
120
+ return;
121
+ }
122
+ try {
123
+ await connectExistingCloud(existing_host);
124
+ } finally {
125
+ clearCloudUrlParam();
126
+ }
127
+ }
128
+
129
+ async function createBackend(authToken?: string): Promise<void> {
130
+ const infraStore = useInfraStore();
131
+ if (infraStore.status === Status.CREATED) {
132
+ return;
133
+ }
134
+ await navigator.locks.request("infra.create_backend", async () => {
135
+ if (infraStore.status === Status.CREATED) {
136
+ return;
137
+ }
138
+ infraStore.set_status(Status.CREATING);
139
+ if (infraStore.app_mode === appMode.CLOUD) {
140
+ try {
141
+ await startCloud(authToken);
142
+ } catch (error) {
143
+ // Back to the "Load the app" button so the user is not stuck on the loading screen.
144
+ infraStore.set_status(Status.NOT_CREATED);
145
+ throw error;
146
+ }
147
+ } else {
148
+ await launchLocalServices();
149
+ }
150
+ infraStore.set_status(Status.CREATED);
151
+ await infraStore.create_connection();
152
+ });
153
+ }
154
+
155
+ export { connectExistingCloud, createBackend, launchCloud, startCloud };
@@ -1,6 +1,7 @@
1
1
  // Local imports
2
2
  import { type LegacyDataId, fromLegacyDataId } from "@ogw_front/utils/legacy_data_id";
3
3
  import { type NewDataItem, useDataStore } from "@ogw_front/stores/data";
4
+ import { isModel } from "@ogw_front/utils/viewer_object_type";
4
5
  import { useDataStyleStore } from "@ogw_front/stores/data_style";
5
6
  import { useFeedbackStore } from "@ogw_front/stores/feedback";
6
7
  import { useHybridViewerStore } from "@ogw_front/stores/hybrid_viewer";
@@ -10,7 +11,7 @@ import { useTreeviewStore } from "@ogw_front/stores/treeview";
10
11
  async function registerWhenViewable(item: NewDataItem, added: Promise<unknown>): Promise<unknown> {
11
12
  const dataStore = useDataStore();
12
13
  await added;
13
- if (!(await dataStore.isItemViewable(item))) {
14
+ if (!(await dataStore.fetchIsViewable(item.data_id))) {
14
15
  return undefined;
15
16
  }
16
17
  return dataStore.registerObject(item.data_id, item.name ?? item.data_id);
@@ -22,7 +23,7 @@ async function addToViewerWhenViewable(
22
23
  ): Promise<unknown> {
23
24
  const dataStore = useDataStore();
24
25
  await added;
25
- if (!(await dataStore.isItemViewable(item))) {
26
+ if (!(await dataStore.fetchIsViewable(item.data_id))) {
26
27
  return undefined;
27
28
  }
28
29
  return useHybridViewerStore().addItem(item.data_id);
@@ -30,7 +31,7 @@ async function addToViewerWhenViewable(
30
31
 
31
32
  async function applyStyleWhenReady(item: NewDataItem, ready: Promise<unknown>): Promise<unknown> {
32
33
  await ready;
33
- if (!(await useDataStore().isItemViewable(item))) {
34
+ if (!(await useDataStore().fetchIsViewable(item.data_id))) {
34
35
  return undefined;
35
36
  }
36
37
  return useDataStyleStore().applyDefaultStyle(item.data_id);
@@ -50,7 +51,7 @@ async function importDataItem(item: NewDataItem): Promise<string> {
50
51
  const registerTask = registerWhenViewable(item, addDataTask);
51
52
  let addDataComponentsTask: Promise<unknown> = Promise.resolve(undefined);
52
53
  let addDataRelationsTask: Promise<unknown> = Promise.resolve(undefined);
53
- if (item.viewer_object_type === "model") {
54
+ if (isModel(item)) {
54
55
  addDataComponentsTask = dataStore.addComponents(item);
55
56
  addDataRelationsTask = dataStore.addComponentRelations(item);
56
57
  }
@@ -3,6 +3,7 @@ import {
3
3
  MODEL_COMPONENT_ATTRIBUTE_SCHEMAS,
4
4
  MODEL_COMPONENT_KINDS,
5
5
  } from "@ogw_front/utils/attributes";
6
+ import { isImage, isMesh } from "@ogw_front/utils/viewer_object_type";
6
7
  import type { AttributeSource } from "@ogw_front/utils/threshold";
7
8
  import type { DataId } from "@geode/opengeodeweb-microservice/schema_types";
8
9
  import { attributeSchemas } from "@ogw_front/composables/attribute_coloring_style";
@@ -33,10 +34,10 @@ async function fetchSources(
33
34
  ): Promise<AttributeSource[]> {
34
35
  const item = await dataStore.item(dataId);
35
36
  // An image shows its own colors: it has no attribute to threshold
36
- if (item.viewer_object_type === "image") {
37
+ if (isImage(item)) {
37
38
  return [];
38
39
  }
39
- if (item.viewer_object_type === "mesh") {
40
+ if (isMesh(item)) {
40
41
  return ["vertex", MESH_ELEMENT_KINDS[item.geode_object_type]]
41
42
  .filter((kind): kind is string => kind !== undefined)
42
43
  .map((kind) => attributeSource(kind, "", { id: dataId }));
@@ -1,5 +1,7 @@
1
1
  import type { GeodeObjectTyped, ModelIdentified } from "@ogw_front/types/identifiers";
2
2
  import type { TreeGroup, TreeNode } from "@ogw_front/types/tree";
3
+ import type { DisplayItem } from "@ogw_front/composables/virtual_tree";
4
+ import { isBasemapId } from "@ogw_front/utils/basemap_tree";
3
5
 
4
6
  function compareSelections<Item>(
5
7
  current: readonly Item[],
@@ -86,7 +88,29 @@ function withPendingImports<Child extends TreeNode, Pending extends TreeNode & G
86
88
  return merged;
87
89
  }
88
90
 
89
- export { MODEL_TREE_COLORS, compareSelections, nextModelTreeColor, withPendingImports };
91
+ // In the objects tree, a data row follows its data. The basemap rows and the groups of data types
92
+ // Always show their toggle, except the group of horizon stacks, which open their own modal
93
+ function isObjectTreeRowViewable(
94
+ row: DisplayItem,
95
+ isDataViewable: (dataId: string) => boolean,
96
+ ): boolean {
97
+ const { id, title } = row.raw;
98
+ if (typeof id !== "string" || isBasemapId(id)) {
99
+ return true;
100
+ }
101
+ if (row.isLeaf) {
102
+ return isDataViewable(id);
103
+ }
104
+ return title !== "HorizonStack3D";
105
+ }
106
+
107
+ export {
108
+ MODEL_TREE_COLORS,
109
+ compareSelections,
110
+ isObjectTreeRowViewable,
111
+ nextModelTreeColor,
112
+ withPendingImports,
113
+ };
90
114
  export type {
91
115
  DataMenuPayload,
92
116
  GeodeObjectTypeMenuPayload,
@@ -0,0 +1,21 @@
1
+ import type { ViewerObjectTyped } from "@ogw_front/types/identifiers";
2
+
3
+ function isModel<Item extends Partial<ViewerObjectTyped>>(
4
+ item: Item,
5
+ ): item is Item & { viewer_object_type: "model" } {
6
+ return item.viewer_object_type === "model";
7
+ }
8
+
9
+ function isMesh<Item extends Partial<ViewerObjectTyped>>(
10
+ item: Item,
11
+ ): item is Item & { viewer_object_type: "mesh" } {
12
+ return item.viewer_object_type === "mesh";
13
+ }
14
+
15
+ function isImage<Item extends Partial<ViewerObjectTyped>>(
16
+ item: Item,
17
+ ): item is Item & { viewer_object_type: "image" } {
18
+ return item.viewer_object_type === "image";
19
+ }
20
+
21
+ export { isImage, isMesh, isModel };
@@ -7,6 +7,7 @@ import { modelComponentTypeDataStyleTable } from "./tables/model_component_type_
7
7
  import { modelComponentsRelationTable } from "./tables/model_components_relation";
8
8
  import { modelComponentsTable } from "./tables/model_components";
9
9
  import { sceneStyleTable } from "./tables/scene_style";
10
+ import { treeviewConfigTable } from "./tables/treeview_config";
10
11
 
11
12
  export class BaseDatabase extends Dexie {
12
13
  public static get initialStores(): Record<string, string> {
@@ -19,7 +20,7 @@ export class BaseDatabase extends Dexie {
19
20
  [modelComponentsRelationTable.name]: modelComponentsRelationTable.schema,
20
21
  [cameraPositionsTable.name]: cameraPositionsTable.schema,
21
22
  [sceneStyleTable.name]: sceneStyleTable.schema,
22
- treeview_config: "id",
23
+ [treeviewConfigTable.name]: treeviewConfigTable.schema,
23
24
  };
24
25
  }
25
26
 
@@ -1,6 +1,24 @@
1
- import { Dexie, type Table } from "dexie";
1
+ import { type CameraPositionRecord, cameraPositionsTable } from "./tables/camera_positions";
2
+ import { type DataItem, dataTable } from "./tables/data";
3
+ import { Dexie, type IndexableType, type Table } from "dexie";
4
+ import { type ModelComponentRecord, modelComponentsTable } from "./tables/model_components";
5
+ import {
6
+ type ModelComponentRelationRecord,
7
+ modelComponentsRelationTable,
8
+ } from "./tables/model_components_relation";
9
+ import type {
10
+ ModelComponentStyle,
11
+ ModelComponentTypeStyle,
12
+ ObjectStyle,
13
+ SceneStyle,
14
+ } from "@ogw_internal/stores/data_style/types";
15
+ import { type TreeviewConfigRecord, treeviewConfigTable } from "./tables/treeview_config";
2
16
  import { BaseDatabase } from "./base_database";
3
17
  import { ExtendedDatabase } from "./extended_database";
18
+ import { dataStyleTable } from "./tables/data_style";
19
+ import { modelComponentDataStyleTable } from "./tables/model_component_datastyle";
20
+ import { modelComponentTypeDataStyleTable } from "./tables/model_component_type_datastyle";
21
+ import { sceneStyleTable } from "./tables/scene_style";
4
22
 
5
23
  interface DatabaseContainer {
6
24
  instance: Dexie | undefined;
@@ -104,7 +122,7 @@ function currentInstance(): Dexie {
104
122
  return databaseContainer.instance;
105
123
  }
106
124
 
107
- function liveTable<TRow>(tableName: string): Table<TRow, string> {
125
+ function liveTable<TRow, TKey extends IndexableType>(tableName: string): Table<TRow, TKey> {
108
126
  const handler: ProxyHandler<object> = {
109
127
  get(_target, prop: string | symbol): unknown {
110
128
  const table = currentInstance().table(tableName);
@@ -121,7 +139,7 @@ function liveTable<TRow>(tableName: string): Table<TRow, string> {
121
139
  },
122
140
  };
123
141
  // oxlint-disable-next-line no-unsafe-type-assertion -- the proxy forwards every access to a Dexie Table.
124
- return new Proxy({}, handler) as Table<TRow, string>;
142
+ return new Proxy({}, handler) as Table<TRow, TKey>;
125
143
  }
126
144
 
127
145
  function isTableName(instance: Dexie, prop: string | symbol): prop is string {
@@ -149,9 +167,74 @@ const database = new Proxy<DatabaseTables>(
149
167
  },
150
168
  );
151
169
 
152
- // Callers cast to the row type they know a given table holds.
153
- function getTable<TRow>(tableName: string): Table<TRow, string> {
154
- return liveTable<TRow>(tableName);
170
+ // For the tables an extension registers at runtime, which the accessors below do not know.
171
+ // The caller gives the row type, and the key type when it is not a string.
172
+ function getTable<TRow, TKey extends IndexableType = string>(tableName: string): Table<TRow, TKey> {
173
+ return liveTable<TRow, TKey>(tableName);
155
174
  }
156
175
 
157
- export { Database, database, getTable };
176
+ // One accessor per table: its row and key types are written once, here
177
+ function dataDb(): Table<DataItem, string> {
178
+ return liveTable(dataTable.name);
179
+ }
180
+
181
+ function modelComponentsDb(): Table<ModelComponentRecord, string> {
182
+ return liveTable(modelComponentsTable.name);
183
+ }
184
+
185
+ function modelComponentsRelationDb(): Table<ModelComponentRelationRecord, string> {
186
+ return liveTable(modelComponentsRelationTable.name);
187
+ }
188
+
189
+ function dataStyleDb(): Table<ObjectStyle, string> {
190
+ return liveTable(dataStyleTable.name);
191
+ }
192
+
193
+ // Keyed by [id_model, id_component]
194
+ function componentDataStyleDb(): Table<ModelComponentStyle, [string, string]> {
195
+ return liveTable(modelComponentDataStyleTable.name);
196
+ }
197
+
198
+ // Keyed by [id_model, type]
199
+ function componentTypeDataStyleDb(): Table<ModelComponentTypeStyle, [string, string]> {
200
+ return liveTable(modelComponentTypeDataStyleTable.name);
201
+ }
202
+
203
+ function sceneStyleDb(): Table<SceneStyle, string> {
204
+ return liveTable(sceneStyleTable.name);
205
+ }
206
+
207
+ // Keyed by an auto-incremented number
208
+ function cameraPositionsDb(): Table<CameraPositionRecord, number> {
209
+ return liveTable(cameraPositionsTable.name);
210
+ }
211
+
212
+ function treeviewConfigDb(): Table<TreeviewConfigRecord, string> {
213
+ return liveTable(treeviewConfigTable.name);
214
+ }
215
+
216
+ // Runs `scope` in one read-write transaction over `tables`: its writes all apply, or none do.
217
+ // Only database calls may be awaited inside `scope`, or Dexie commits the transaction early.
218
+ async function writeTransaction<Result>(
219
+ tables: readonly Table[],
220
+ scope: () => Promise<Result>,
221
+ ): Promise<Result> {
222
+ const result = await currentInstance().transaction("rw", [...tables], scope);
223
+ return result;
224
+ }
225
+
226
+ export {
227
+ Database,
228
+ cameraPositionsDb,
229
+ componentDataStyleDb,
230
+ componentTypeDataStyleDb,
231
+ dataDb,
232
+ dataStyleDb,
233
+ database,
234
+ getTable,
235
+ modelComponentsDb,
236
+ modelComponentsRelationDb,
237
+ sceneStyleDb,
238
+ treeviewConfigDb,
239
+ writeTransaction,
240
+ };