@geode/opengeodeweb-front 10.34.0-rc.9 → 10.34.0
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.
- package/{server → .build/server}/utils/app_config.js +10 -9
- package/{server → .build/server}/utils/cleanup.js +31 -17
- package/{server → .build/server}/utils/cloud.js +1 -4
- package/{server → .build/server}/utils/microservices.js +21 -9
- package/{server → .build/server}/utils/path.js +4 -4
- package/{server → .build/server}/utils/scripts.js +9 -9
- package/.build/server/utils/server_config.js +51 -0
- package/.build/server/utils/stream.js +6 -0
- package/{server → .build/server}/utils/ws_client.js +18 -3
- package/{shared → .build/shared}/scripts.js +10 -10
- package/.build/shared/utils/call_raw.js +31 -0
- package/{shared → .build/shared}/utils/call_schema.js +2 -2
- package/.build/shared/utils/fetch_raw.js +52 -0
- package/{shared → .build/shared}/utils/fetch_schema.js +2 -2
- package/{shared → .build/shared}/utils/file.js +3 -1
- package/{shared → .build/shared}/utils/response_handlers/load.js +10 -7
- package/{shared → .build/shared}/utils/validate_schema.js +1 -1
- package/app/components/ActionButton.vue +6 -6
- package/app/components/CameraManager/List.vue +5 -5
- package/app/components/CameraManager/Saver.vue +3 -5
- package/app/components/CameraManager.vue +6 -4
- package/app/components/CameraOrientation.vue +12 -12
- package/app/components/ClippingPlaneCard.vue +4 -2
- package/app/components/ClippingPlanes.vue +8 -8
- package/app/components/CrsSelector.vue +9 -10
- package/app/components/DeleteDialog.vue +4 -2
- package/app/components/DragAndDrop.vue +10 -12
- package/app/components/DragAndDropInternal/DragAndDropInline.vue +4 -2
- package/app/components/ExtensionSelector.vue +4 -4
- package/app/components/FeedBack/ErrorBanner.vue +3 -1
- package/app/components/FeedBack/Snackers.vue +4 -3
- package/app/components/FileSelector.vue +10 -8
- package/app/components/FileUploader.vue +11 -11
- package/app/components/GlassCard.vue +1 -1
- package/app/components/HybridRenderingView.vue +7 -5
- package/app/components/HybridViewerTooltip.vue +7 -7
- package/app/components/Launcher.vue +1 -1
- package/app/components/Loading/EcoMessages.vue +9 -3
- package/app/components/Loading.vue +2 -2
- package/app/components/MissingFilesSelector.vue +12 -10
- package/app/components/ObjectSelector.vue +10 -9
- package/app/components/PackagesVersions.vue +6 -5
- package/app/components/Recaptcha.vue +3 -3
- package/app/components/RemoteRenderingView.vue +6 -7
- package/app/components/Ruler.vue +3 -3
- package/app/components/Screenshot.vue +6 -6
- package/app/components/SearchBar.vue +4 -2
- package/app/components/ShrinkFilter.vue +7 -7
- package/app/components/Step.vue +6 -5
- package/app/components/Stepper.vue +4 -3
- package/app/components/ToolPanel.vue +6 -3
- package/app/components/ViewToolbar.vue +25 -28
- package/app/components/Viewer/ContextMenu/CenterButton.vue +7 -5
- package/app/components/Viewer/ContextMenu/CircularItems.vue +3 -3
- package/app/components/Viewer/ContextMenu/ContextMenu.vue +22 -19
- package/app/components/Viewer/ContextMenu/ContextMenuItem.vue +10 -8
- package/app/components/Viewer/ContextMenu/InfoCard.vue +11 -12
- package/app/components/Viewer/EdgedCurve/SpecificEdgesOptions.vue +13 -17
- package/app/components/Viewer/Generic/Mesh/CellsOptions.vue +11 -15
- package/app/components/Viewer/Generic/Mesh/EdgesOptions.vue +12 -16
- package/app/components/Viewer/Generic/Mesh/PointsOptions.vue +8 -12
- package/app/components/Viewer/Generic/Mesh/PolygonsOptions.vue +11 -15
- package/app/components/Viewer/Generic/Mesh/PolyhedraOptions.vue +11 -15
- package/app/components/Viewer/Generic/Model/BlocksOptions.vue +67 -38
- package/app/components/Viewer/Generic/Model/CornersOptions.vue +53 -23
- package/app/components/Viewer/Generic/Model/EdgesOptions.vue +1 -3
- package/app/components/Viewer/Generic/Model/LinesOptions.vue +67 -38
- package/app/components/Viewer/Generic/Model/ModelStyleCard.vue +31 -15
- package/app/components/Viewer/Generic/Model/ModelStyleOptions.vue +2 -3
- package/app/components/Viewer/Generic/Model/PointsOptions.vue +6 -6
- package/app/components/Viewer/Generic/Model/SurfacesOptions.vue +69 -38
- package/app/components/Viewer/ObjectTree/Base/CommonTreeView.vue +64 -46
- package/app/components/Viewer/ObjectTree/Base/Controls.vue +5 -5
- package/app/components/Viewer/ObjectTree/Base/ItemLabel.vue +13 -9
- package/app/components/Viewer/ObjectTree/Base/StickyHeader.vue +5 -5
- package/app/components/Viewer/ObjectTree/Base/TreeRow.vue +10 -10
- package/app/components/Viewer/ObjectTree/Box.vue +6 -4
- package/app/components/Viewer/ObjectTree/Layout.vue +23 -21
- package/app/components/Viewer/ObjectTree/Views/GlobalObjects.vue +14 -14
- package/app/components/Viewer/ObjectTree/Views/{ModelCollections.vue → ModelTree.vue} +59 -24
- package/app/components/Viewer/Options/AttributeColorBar.vue +4 -2
- package/app/components/Viewer/Options/AttributeRangeSelector.vue +4 -2
- package/app/components/Viewer/Options/AttributeSelector.vue +7 -9
- package/app/components/Viewer/Options/ColorMapList.vue +15 -13
- package/app/components/Viewer/Options/ColorMapPicker.vue +4 -4
- package/app/components/Viewer/Options/ColorPicker.vue +223 -41
- package/app/components/Viewer/Options/ColoringTypeSelector.vue +16 -16
- package/app/components/Viewer/Options/ColormapQuickPicker.vue +7 -5
- package/app/components/Viewer/Options/OptionsSection.vue +1 -1
- package/app/components/Viewer/Options/TextureItem.vue +8 -6
- package/app/components/Viewer/Options/TexturesSelector.vue +1 -1
- package/app/components/Viewer/OverlappingObjectsPicker.vue +8 -9
- package/app/components/Viewer/PointSet/SpecificPointsOptions.vue +2 -6
- package/app/components/Viewer/Solid/SpecificPolyhedraOptions.vue +12 -16
- package/app/components/Viewer/Surface/PolygonsOptions.vue +12 -16
- package/app/components/Viewer/Ui.vue +2 -2
- package/app/components/Wrapper.vue +1 -4
- package/app/components/ZScaling.vue +5 -3
- package/app/components/csv-preview/CsvPreviewer.vue +38 -37
- package/app/components/csv-preview/CsvSettings.vue +6 -4
- package/app/components/csv-preview/CsvTable.vue +1 -1
- package/app/composables/batch_style.ts +5 -6
- package/app/composables/clipping_planes_widget.ts +73 -181
- package/app/composables/clipping_planes_widget_entries.ts +189 -0
- package/app/composables/copy_to_clipboard.ts +7 -0
- package/app/composables/global_attribute_style.ts +163 -83
- package/app/composables/hover_highlight.ts +46 -14
- package/app/composables/model_collections.ts +26 -13
- package/app/composables/model_components.ts +26 -13
- package/app/composables/project_manager.ts +76 -19
- package/app/composables/responsive_middle_truncate.ts +13 -13
- package/app/composables/stepper_tree.ts +34 -11
- package/app/composables/tree_filter.ts +66 -44
- package/app/composables/tree_keyboard_nav.ts +25 -11
- package/app/composables/tree_scroll.ts +44 -14
- package/app/composables/use_adaptive_styles.ts +66 -23
- package/app/composables/use_overlapping_picker.ts +66 -16
- package/app/composables/use_quick_colormap.ts +16 -5
- package/app/composables/virtual_tree.ts +75 -43
- package/app/composables/vtk_implicit_plane_widget.d.ts +2 -0
- package/app/plugins/auto_store_register.ts +2 -7
- package/app/plugins/click_outside_ignore_snackbars.client.ts +39 -0
- package/app/stores/app.ts +57 -192
- package/app/stores/app_helpers/extension.ts +179 -0
- package/app/stores/back.ts +37 -21
- package/app/stores/camera_manager.ts +22 -20
- package/app/stores/cloud.ts +17 -13
- package/app/stores/data.ts +88 -47
- package/app/stores/data_helpers/collections.ts +36 -38
- package/app/stores/data_helpers/mesh.ts +45 -36
- package/app/stores/data_style.ts +50 -28
- package/app/stores/feedback.ts +6 -6
- package/app/stores/hybrid_viewer.ts +41 -52
- package/app/stores/infra.ts +39 -37
- package/app/stores/menu.ts +23 -14
- package/app/stores/treeview.ts +72 -42
- package/app/stores/viewer.ts +39 -27
- package/app/utils/attributes.ts +3 -3
- package/app/utils/clipping_planes.ts +111 -14
- package/app/utils/color_picker.ts +57 -0
- package/app/utils/colormap.ts +58 -35
- package/app/utils/default_styles/index.ts +2 -2
- package/app/utils/default_styles/meshes.ts +107 -13
- package/app/utils/default_styles/models.ts +83 -14
- package/app/utils/extension.ts +47 -20
- package/app/utils/import_workflow.ts +21 -13
- package/app/utils/name_cleaner.ts +1 -1
- package/app/utils/string.ts +1 -1
- package/app/utils/treeview.ts +2 -2
- package/internal/database/base_database.ts +7 -3
- package/internal/database/database.ts +36 -26
- package/internal/database/extended_database.ts +1 -1
- package/internal/stores/data_style/mesh/cells/cell.ts +70 -34
- package/internal/stores/data_style/mesh/cells/color.ts +12 -6
- package/internal/stores/data_style/mesh/cells/common.ts +18 -8
- package/internal/stores/data_style/mesh/cells/index.ts +122 -42
- package/internal/stores/data_style/mesh/cells/textures.ts +12 -6
- package/internal/stores/data_style/mesh/cells/vertex.ts +75 -34
- package/internal/stores/data_style/mesh/cells/visibility.ts +15 -4
- package/internal/stores/data_style/mesh/edges/color.ts +12 -6
- package/internal/stores/data_style/mesh/edges/common.ts +14 -6
- package/internal/stores/data_style/mesh/edges/edge.ts +71 -39
- package/internal/stores/data_style/mesh/edges/index.ts +117 -42
- package/internal/stores/data_style/mesh/edges/vertex.ts +76 -39
- package/internal/stores/data_style/mesh/edges/visibility.ts +15 -4
- package/internal/stores/data_style/mesh/edges/width.ts +12 -4
- package/internal/stores/data_style/mesh/index.ts +30 -11
- package/internal/stores/data_style/mesh/points/color.ts +12 -6
- package/internal/stores/data_style/mesh/points/common.ts +21 -8
- package/internal/stores/data_style/mesh/points/index.ts +101 -50
- package/internal/stores/data_style/mesh/points/size.ts +12 -4
- package/internal/stores/data_style/mesh/points/vertex.ts +75 -34
- package/internal/stores/data_style/mesh/points/visibility.ts +17 -7
- package/internal/stores/data_style/mesh/polygons/color.ts +12 -6
- package/internal/stores/data_style/mesh/polygons/common.ts +23 -6
- package/internal/stores/data_style/mesh/polygons/index.ts +130 -70
- package/internal/stores/data_style/mesh/polygons/polygon.ts +77 -43
- package/internal/stores/data_style/mesh/polygons/textures.ts +12 -6
- package/internal/stores/data_style/mesh/polygons/vertex.ts +79 -39
- package/internal/stores/data_style/mesh/polygons/visibility.ts +16 -6
- package/internal/stores/data_style/mesh/polyhedra/color.ts +12 -6
- package/internal/stores/data_style/mesh/polyhedra/common.ts +14 -6
- package/internal/stores/data_style/mesh/polyhedra/index.ts +115 -56
- package/internal/stores/data_style/mesh/polyhedra/polyhedron.ts +80 -39
- package/internal/stores/data_style/mesh/polyhedra/vertex.ts +79 -39
- package/internal/stores/data_style/mesh/polyhedra/visibility.ts +16 -6
- package/internal/stores/data_style/model/blocks/color.ts +43 -13
- package/internal/stores/data_style/model/blocks/common.ts +21 -6
- package/internal/stores/data_style/model/blocks/index.ts +89 -59
- package/internal/stores/data_style/model/blocks/polyhedron.ts +101 -44
- package/internal/stores/data_style/model/blocks/vertex.ts +107 -42
- package/internal/stores/data_style/model/blocks/visibility.ts +17 -4
- package/internal/stores/data_style/model/color.ts +171 -83
- package/internal/stores/data_style/model/common.ts +70 -21
- package/internal/stores/data_style/model/corners/color.ts +43 -11
- package/internal/stores/data_style/model/corners/common.ts +25 -6
- package/internal/stores/data_style/model/corners/index.ts +66 -41
- package/internal/stores/data_style/model/corners/vertex.ts +105 -74
- package/internal/stores/data_style/model/corners/visibility.ts +19 -4
- package/internal/stores/data_style/model/edges/common.ts +12 -4
- package/internal/stores/data_style/model/edges/index.ts +2 -1
- package/internal/stores/data_style/model/edges/visibility.ts +24 -7
- package/internal/stores/data_style/model/index.ts +24 -11
- package/internal/stores/data_style/model/lines/color.ts +41 -11
- package/internal/stores/data_style/model/lines/common.ts +17 -6
- package/internal/stores/data_style/model/lines/edge.ts +105 -42
- package/internal/stores/data_style/model/lines/index.ts +86 -59
- package/internal/stores/data_style/model/lines/vertex.ts +105 -42
- package/internal/stores/data_style/model/lines/visibility.ts +17 -4
- package/internal/stores/data_style/model/points/common.ts +8 -4
- package/internal/stores/data_style/model/points/index.ts +10 -3
- package/internal/stores/data_style/model/points/size.ts +12 -4
- package/internal/stores/data_style/model/points/visibility.ts +16 -6
- package/internal/stores/data_style/model/selection.ts +80 -58
- package/internal/stores/data_style/model/surfaces/color.ts +41 -11
- package/internal/stores/data_style/model/surfaces/common.ts +23 -6
- package/internal/stores/data_style/model/surfaces/index.ts +89 -59
- package/internal/stores/data_style/model/surfaces/polygon.ts +107 -67
- package/internal/stores/data_style/model/surfaces/vertex.ts +111 -67
- package/internal/stores/data_style/model/surfaces/visibility.ts +18 -5
- package/internal/stores/data_style/model/visibility.ts +82 -20
- package/internal/stores/data_style/state.ts +77 -65
- package/internal/stores/hybrid_viewer/brightness.ts +49 -31
- package/internal/stores/hybrid_viewer/camera.ts +191 -177
- package/internal/stores/hybrid_viewer/camera_animation.ts +11 -10
- package/internal/stores/hybrid_viewer/core.ts +64 -0
- package/internal/stores/hybrid_viewer/filters.ts +10 -16
- package/internal/stores/hybrid_viewer/highlight.ts +91 -130
- package/internal/stores/hybrid_viewer/ruler.ts +24 -15
- package/internal/stores/hybrid_viewer/scene.ts +96 -117
- package/internal/stores/hybrid_viewer/viewport.ts +74 -65
- package/internal/stores/hybrid_viewer/vtk_types.ts +13 -29
- package/internal/utils/api_fetch.ts +54 -23
- package/internal/utils/upload_file.ts +74 -53
- package/internal/utils/viewer_call.ts +22 -13
- package/internal/utils/ws_client.ts +24 -13
- package/nuxt.config.ts +58 -1
- package/package.json +20 -8
- package/server/api/cloud/extensions/run.post.ts +6 -10
- package/server/api/local/app/project_folder_path.post.ts +4 -4
- package/server/api/local/app/run_back.post.ts +5 -7
- package/server/api/local/app/run_viewer.post.ts +5 -7
- package/server/api/local/extensions/kill.post.ts +4 -3
- package/server/api/local/extensions/run.post.ts +7 -10
- package/server/api/local/extensions/upload.put.ts +44 -54
- package/server/api/microservice/app/get_is_app_ready.get.ts +4 -5
- package/server/api/microservice/app/set_app_base_url.post.ts +5 -6
- package/server/api/microservice/app/set_back_base_url.post.ts +5 -6
- package/server/api/microservice/app/set_is_app_ready.post.ts +5 -6
- package/server/api/microservice/app/set_viewer_base_url.post.ts +5 -6
- package/server/api/microservice/extensions/download.post.ts +5 -4
- package/server/api/serverless/run_cloud.post.ts +53 -11
- package/server/utils/app_config.ts +29 -22
- package/server/utils/cleanup.ts +60 -30
- package/server/utils/cloud.ts +9 -8
- package/server/utils/extension.ts +23 -9
- package/server/utils/microservices.ts +33 -24
- package/server/utils/path.ts +4 -4
- package/server/utils/scripts.ts +26 -23
- package/server/utils/server.ts +2 -2
- package/server/utils/server_config.ts +41 -27
- package/server/utils/stream.ts +6 -0
- package/server/utils/ws_client.ts +42 -8
- package/shared/scripts.ts +15 -10
- package/shared/utils/call_raw.ts +23 -16
- package/shared/utils/call_schema.ts +5 -8
- package/shared/utils/fetch_raw.ts +87 -47
- package/shared/utils/fetch_schema.ts +6 -9
- package/shared/utils/file.ts +8 -2
- package/shared/utils/response_handlers/load.ts +26 -11
- package/shared/utils/types.ts +9 -9
- package/shared/utils/validate_schema.ts +1 -1
- package/app/components/Viewer/ObjectTree/Views/ModelComponents.vue +0 -276
- package/server/types/vendor.d.ts +0 -64
- package/server/utils/server_config.js +0 -43
- package/shared/utils/call_raw.js +0 -30
- package/shared/utils/fetch_raw.js +0 -40
- /package/{opengeodeweb_front_schemas.js → .build/opengeodeweb_front_schemas.js} +0 -0
- /package/{server → .build/server}/utils/server.js +0 -0
- /package/{shared → .build/shared}/app_mode.js +0 -0
- /package/{shared → .build/shared}/utils/parse_boolean.js +0 -0
- /package/{shared → .build/shared}/utils/types.js +0 -0
|
@@ -1,11 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
import { liveQuery } from "dexie";
|
|
4
|
-
// oxlint-disable-next-line eslint/no-duplicate-imports
|
|
5
|
-
import type { Table } from "dexie";
|
|
1
|
+
import { type Table, liveQuery } from "dexie";
|
|
2
|
+
import type { Observable } from "rxjs";
|
|
6
3
|
import { database } from "@ogw_internal/database/database.js";
|
|
7
4
|
import { useObservable } from "@vueuse/rxjs";
|
|
8
|
-
import type { Observable } from "rxjs";
|
|
9
5
|
|
|
10
6
|
interface ModelComponentRecord {
|
|
11
7
|
id: string;
|
|
@@ -17,17 +13,17 @@ interface ModelComponentRecord {
|
|
|
17
13
|
}
|
|
18
14
|
|
|
19
15
|
interface FormattedComponent {
|
|
20
|
-
id: string;
|
|
21
|
-
title: string;
|
|
22
|
-
category: string;
|
|
23
|
-
viewer_id: number;
|
|
24
|
-
is_active: boolean;
|
|
16
|
+
readonly id: string;
|
|
17
|
+
readonly title: string;
|
|
18
|
+
readonly category: string;
|
|
19
|
+
readonly viewer_id: number;
|
|
20
|
+
readonly is_active: boolean;
|
|
25
21
|
}
|
|
26
22
|
|
|
27
23
|
interface FormattedComponentGroup {
|
|
28
24
|
id: string;
|
|
29
25
|
title: string;
|
|
30
|
-
children: FormattedComponent[];
|
|
26
|
+
readonly children: readonly FormattedComponent[];
|
|
31
27
|
}
|
|
32
28
|
|
|
33
29
|
function toFormattedComponent(meshComponent: ModelComponentRecord): FormattedComponent {
|
|
@@ -40,7 +36,20 @@ function toFormattedComponent(meshComponent: ModelComponentRecord): FormattedCom
|
|
|
40
36
|
};
|
|
41
37
|
}
|
|
42
38
|
|
|
43
|
-
|
|
39
|
+
// oxlint-disable-next-line eslint/max-lines-per-function
|
|
40
|
+
export function useDataMesh(): {
|
|
41
|
+
formatedMeshComponents: typeof formatedMeshComponents;
|
|
42
|
+
refFormatedMeshComponents: typeof refFormatedMeshComponents;
|
|
43
|
+
getMeshComponentsByType: typeof getMeshComponentsByType;
|
|
44
|
+
getAllMeshComponents: typeof getAllMeshComponents;
|
|
45
|
+
fetchAllMeshComponents: typeof fetchAllMeshComponents;
|
|
46
|
+
getMeshComponentGeodeIds: typeof getMeshComponentGeodeIds;
|
|
47
|
+
getCornersGeodeIds: typeof getCornersGeodeIds;
|
|
48
|
+
getLinesGeodeIds: typeof getLinesGeodeIds;
|
|
49
|
+
getSurfacesGeodeIds: typeof getSurfacesGeodeIds;
|
|
50
|
+
getBlocksGeodeIds: typeof getBlocksGeodeIds;
|
|
51
|
+
} {
|
|
52
|
+
// oxlint-disable-next-line no-unsafe-type-assertion -- database's table map is dynamically typed at runtime.
|
|
44
53
|
const model_components_db = database.model_components as unknown as Table<
|
|
45
54
|
ModelComponentRecord,
|
|
46
55
|
string
|
|
@@ -57,10 +66,8 @@ export function useDataMesh() {
|
|
|
57
66
|
|
|
58
67
|
const componentsByType: Record<string, ModelComponentRecord[]> = {};
|
|
59
68
|
for (const component_item of items) {
|
|
60
|
-
if (componentTitles[component_item.type]) {
|
|
61
|
-
|
|
62
|
-
componentsByType[component_item.type] = [];
|
|
63
|
-
}
|
|
69
|
+
if (componentTitles[component_item.type] !== undefined) {
|
|
70
|
+
componentsByType[component_item.type] ??= [];
|
|
64
71
|
componentsByType[component_item.type]?.push(component_item);
|
|
65
72
|
}
|
|
66
73
|
}
|
|
@@ -70,19 +77,19 @@ export function useDataMesh() {
|
|
|
70
77
|
.map((type) => ({
|
|
71
78
|
id: type,
|
|
72
79
|
title: componentTitles[type] ?? type,
|
|
73
|
-
children: (componentsByType[type] ?? []).map((item) =>
|
|
80
|
+
children: (componentsByType[type] ?? []).map((item: ModelComponentRecord) =>
|
|
81
|
+
toFormattedComponent(item),
|
|
82
|
+
),
|
|
74
83
|
}));
|
|
75
84
|
}
|
|
76
85
|
|
|
77
|
-
function refFormatedMeshComponents(modelId: string) {
|
|
78
|
-
// Dexie's liveQuery() returns Dexie's own minimal Observable shape, not an
|
|
79
|
-
// Actual rxjs Observable instance (useObservable's declared parameter type);
|
|
80
|
-
// The two are structurally close enough at runtime (vueuse only calls
|
|
81
|
-
// `.subscribe`) but not identical, hence the cast.
|
|
86
|
+
function refFormatedMeshComponents(modelId: string): Ref<FormattedComponentGroup[] | undefined> {
|
|
82
87
|
return useObservable(
|
|
83
|
-
liveQuery(() =>
|
|
84
|
-
|
|
85
|
-
|
|
88
|
+
liveQuery(async () => {
|
|
89
|
+
const components = await formatedMeshComponents(modelId);
|
|
90
|
+
return components;
|
|
91
|
+
// oxlint-disable-next-line no-unsafe-type-assertion
|
|
92
|
+
}) as unknown as Observable<FormattedComponentGroup[]>,
|
|
86
93
|
{
|
|
87
94
|
initialValue: undefined,
|
|
88
95
|
},
|
|
@@ -97,12 +104,12 @@ export function useDataMesh() {
|
|
|
97
104
|
.where("[id+type]")
|
|
98
105
|
.equals([modelId, type])
|
|
99
106
|
.toArray();
|
|
100
|
-
return components.map((item) => toFormattedComponent(item));
|
|
107
|
+
return components.map((item: ModelComponentRecord) => toFormattedComponent(item));
|
|
101
108
|
}
|
|
102
109
|
|
|
103
110
|
async function getAllMeshComponents(modelId: string): Promise<FormattedComponent[]> {
|
|
104
111
|
const items = await model_components_db.where("id").equals(modelId).toArray();
|
|
105
|
-
return items.map((item) => toFormattedComponent(item));
|
|
112
|
+
return items.map((item: ModelComponentRecord) => toFormattedComponent(item));
|
|
106
113
|
}
|
|
107
114
|
|
|
108
115
|
async function fetchAllMeshComponents(
|
|
@@ -111,9 +118,7 @@ export function useDataMesh() {
|
|
|
111
118
|
const components = await getAllMeshComponents(modelId);
|
|
112
119
|
const byType: Record<string, FormattedComponent[]> = {};
|
|
113
120
|
for (const component of components) {
|
|
114
|
-
|
|
115
|
-
byType[component.category] = [];
|
|
116
|
-
}
|
|
121
|
+
byType[component.category] ??= [];
|
|
117
122
|
byType[component.category]?.push(component);
|
|
118
123
|
}
|
|
119
124
|
return byType;
|
|
@@ -124,23 +129,27 @@ export function useDataMesh() {
|
|
|
124
129
|
.where("[id+type]")
|
|
125
130
|
.equals([modelId, type])
|
|
126
131
|
.toArray();
|
|
127
|
-
return components.map((component) => component.geode_id);
|
|
132
|
+
return components.map((component: ModelComponentRecord) => component.geode_id);
|
|
128
133
|
}
|
|
129
134
|
|
|
130
135
|
async function getCornersGeodeIds(modelId: string): Promise<string[]> {
|
|
131
|
-
|
|
136
|
+
const geodeIds = await getMeshComponentGeodeIds(modelId, "Corner");
|
|
137
|
+
return geodeIds;
|
|
132
138
|
}
|
|
133
139
|
|
|
134
140
|
async function getLinesGeodeIds(modelId: string): Promise<string[]> {
|
|
135
|
-
|
|
141
|
+
const geodeIds = await getMeshComponentGeodeIds(modelId, "Line");
|
|
142
|
+
return geodeIds;
|
|
136
143
|
}
|
|
137
144
|
|
|
138
145
|
async function getSurfacesGeodeIds(modelId: string): Promise<string[]> {
|
|
139
|
-
|
|
146
|
+
const geodeIds = await getMeshComponentGeodeIds(modelId, "Surface");
|
|
147
|
+
return geodeIds;
|
|
140
148
|
}
|
|
141
149
|
|
|
142
150
|
async function getBlocksGeodeIds(modelId: string): Promise<string[]> {
|
|
143
|
-
|
|
151
|
+
const geodeIds = await getMeshComponentGeodeIds(modelId, "Block");
|
|
152
|
+
return geodeIds;
|
|
144
153
|
}
|
|
145
154
|
|
|
146
155
|
return {
|
package/app/stores/data_style.ts
CHANGED
|
@@ -1,54 +1,63 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import type {
|
|
2
|
+
ModelComponentStyle,
|
|
3
|
+
ModelComponentTypeStyle,
|
|
4
|
+
ObjectStyle,
|
|
5
|
+
} from "@ogw_internal/stores/data_style/types";
|
|
6
|
+
import type { Table } from "dexie";
|
|
3
7
|
import { database } from "@ogw_internal/database/database.js";
|
|
4
8
|
import { getDefaultStyle } from "@ogw_front/utils/default_styles";
|
|
5
9
|
import { useDataStore } from "@ogw_front/stores/data";
|
|
6
10
|
import { useDataStyleState } from "@ogw_internal/stores/data_style/state";
|
|
7
11
|
import { useMeshStyle } from "@ogw_internal/stores/data_style/mesh/index";
|
|
8
12
|
import { useModelStyle } from "@ogw_internal/stores/data_style/model/index";
|
|
9
|
-
import type {
|
|
10
|
-
ModelComponentStyle,
|
|
11
|
-
ModelComponentTypeStyle,
|
|
12
|
-
ObjectStyle,
|
|
13
|
-
} from "@ogw_internal/stores/data_style/types";
|
|
14
13
|
|
|
15
14
|
interface DataStyleSnapshot {
|
|
16
|
-
styles: Record<string, ObjectStyle>;
|
|
17
|
-
componentStyles: Record<string, ModelComponentStyle>;
|
|
18
|
-
modelComponentTypeStyles: Record<string, ModelComponentTypeStyle>;
|
|
15
|
+
readonly styles: Record<string, ObjectStyle>;
|
|
16
|
+
readonly componentStyles: Record<string, ModelComponentStyle>;
|
|
17
|
+
readonly modelComponentTypeStyles: Record<string, ModelComponentTypeStyle>;
|
|
19
18
|
}
|
|
20
19
|
|
|
21
|
-
// The database's table map is dynamically assembled at runtime (see internal/database/database.ts), so
|
|
22
|
-
|
|
23
|
-
|
|
20
|
+
// The database's table map is dynamically assembled at runtime (see internal/database/database.ts), so its exported type is a loose `{}`; cast it to the shape it actually has at runtime rather than widening every call site.
|
|
21
|
+
type DatabaseTables = Record<string, Table<Record<string, unknown>, string> | undefined>;
|
|
22
|
+
|
|
23
|
+
// `noUncheckedIndexedAccess` sees these as possibly undefined even though they're always registered before this store is used; guard defensively rather than asserting.
|
|
24
|
+
function requireTable<TableValue>(table: TableValue | undefined, name: string): TableValue {
|
|
25
|
+
if (table === undefined) {
|
|
24
26
|
throw new Error(`Database table not initialized: ${name}`);
|
|
25
27
|
}
|
|
26
28
|
return table;
|
|
27
29
|
}
|
|
28
30
|
|
|
31
|
+
function isRecord(value: unknown): value is Record<string, unknown> {
|
|
32
|
+
return typeof value === "object" && value !== null;
|
|
33
|
+
}
|
|
34
|
+
|
|
29
35
|
// oxlint-disable-next-line max-lines-per-function
|
|
30
36
|
export const useDataStyleStore = defineStore("dataStyle", () => {
|
|
31
37
|
const dataStyleState = useDataStyleState();
|
|
32
38
|
const meshStyleStore = useMeshStyle();
|
|
33
39
|
const modelStyleStore = useModelStyle();
|
|
34
40
|
const dataStore = useDataStore();
|
|
35
|
-
|
|
41
|
+
// oxlint-disable-next-line no-unsafe-type-assertion -- the database Proxy is typed as `{}` at its export site; this cast documents its real runtime shape.
|
|
42
|
+
const typedDatabase = database as unknown as DatabaseTables;
|
|
43
|
+
const data_style_db = requireTable(typedDatabase.data_style, "data_style");
|
|
36
44
|
const model_component_type_datastyle_db = requireTable(
|
|
37
|
-
|
|
45
|
+
typedDatabase.model_component_type_datastyle,
|
|
38
46
|
"model_component_type_datastyle",
|
|
39
47
|
);
|
|
40
48
|
const component_datastyle_db = requireTable(
|
|
41
|
-
|
|
49
|
+
typedDatabase.model_component_datastyle,
|
|
42
50
|
"model_component_datastyle",
|
|
43
51
|
);
|
|
44
52
|
|
|
45
53
|
async function addDataStyle(id: string, geode_object: string): Promise<void> {
|
|
54
|
+
const defaultStyle = getDefaultStyle(geode_object);
|
|
46
55
|
await data_style_db.put(
|
|
47
|
-
structuredClone({ id, ...(
|
|
56
|
+
structuredClone({ id, ...(isRecord(defaultStyle) ? defaultStyle : {}) }),
|
|
48
57
|
);
|
|
49
58
|
}
|
|
50
59
|
|
|
51
|
-
async function setVisibility(id: string, visibility: boolean) {
|
|
60
|
+
async function setVisibility(id: string, visibility: boolean): Promise<unknown> {
|
|
52
61
|
const item = await dataStore.item(id);
|
|
53
62
|
if (!(await dataStore.isItemViewable(item))) {
|
|
54
63
|
return dataStyleState.mutateStyle(id, { visibility });
|
|
@@ -65,7 +74,7 @@ export const useDataStyleStore = defineStore("dataStyle", () => {
|
|
|
65
74
|
throw new Error("Unknown viewer_type");
|
|
66
75
|
}
|
|
67
76
|
|
|
68
|
-
async function applyDefaultStyle(id: string) {
|
|
77
|
+
async function applyDefaultStyle(id: string): Promise<unknown[]> {
|
|
69
78
|
const item = await dataStore.item(id);
|
|
70
79
|
if (!(await dataStore.isItemViewable(item))) {
|
|
71
80
|
throw new Error(`applyDefaultStyle called for non-viewable item: ${id}`);
|
|
@@ -90,6 +99,7 @@ export const useDataStyleStore = defineStore("dataStyle", () => {
|
|
|
90
99
|
};
|
|
91
100
|
}
|
|
92
101
|
|
|
102
|
+
// oxlint-disable-next-line prefer-readonly-parameter-types -- ObjectStyle (external type) has a mutable index signature and mutable nested StyleValues fields that can't be marked readonly from here.
|
|
93
103
|
async function importStores(snapshot: DataStyleSnapshot): Promise<void> {
|
|
94
104
|
const stylesSnapshot = snapshot.styles;
|
|
95
105
|
const componentStylesSnapshot = snapshot.componentStyles;
|
|
@@ -97,14 +107,24 @@ export const useDataStyleStore = defineStore("dataStyle", () => {
|
|
|
97
107
|
|
|
98
108
|
await dataStyleState.clear();
|
|
99
109
|
|
|
100
|
-
const style_promises = Object.entries(stylesSnapshot).map(
|
|
101
|
-
|
|
110
|
+
const style_promises = Object.entries(stylesSnapshot).map(
|
|
111
|
+
// oxlint-disable-next-line prefer-readonly-parameter-types -- same external ObjectStyle limitation as above.
|
|
112
|
+
async ([id, style]: readonly [string, ObjectStyle]) => {
|
|
113
|
+
const key = await data_style_db.put(structuredClone({ ...style, id }));
|
|
114
|
+
return key;
|
|
115
|
+
},
|
|
102
116
|
);
|
|
103
|
-
const component_style_promises = Object.values(componentStylesSnapshot).map(
|
|
104
|
-
|
|
117
|
+
const component_style_promises = Object.values(componentStylesSnapshot).map(
|
|
118
|
+
async (style: ModelComponentStyle) => {
|
|
119
|
+
const key = await component_datastyle_db.put(structuredClone(style));
|
|
120
|
+
return key;
|
|
121
|
+
},
|
|
105
122
|
);
|
|
106
123
|
const model_component_type_style_promises = Object.values(modelComponentTypeStylesSnapshot).map(
|
|
107
|
-
(style) =>
|
|
124
|
+
async (style: ModelComponentTypeStyle) => {
|
|
125
|
+
const key = await model_component_type_datastyle_db.put(structuredClone(style));
|
|
126
|
+
return key;
|
|
127
|
+
},
|
|
108
128
|
);
|
|
109
129
|
|
|
110
130
|
await Promise.all([
|
|
@@ -114,7 +134,7 @@ export const useDataStyleStore = defineStore("dataStyle", () => {
|
|
|
114
134
|
]);
|
|
115
135
|
}
|
|
116
136
|
|
|
117
|
-
function applyAllStylesFromState() {
|
|
137
|
+
async function applyAllStylesFromState(): Promise<void> {
|
|
118
138
|
const ids = Object.keys(dataStyleState.styles.value);
|
|
119
139
|
const promises = ids.map(async (id) => {
|
|
120
140
|
const meta = await dataStore.item(id);
|
|
@@ -123,12 +143,12 @@ export const useDataStyleStore = defineStore("dataStyle", () => {
|
|
|
123
143
|
}
|
|
124
144
|
const viewerType = meta.viewer_type;
|
|
125
145
|
if (viewerType === "mesh") {
|
|
126
|
-
|
|
146
|
+
await meshStyleStore.applyMeshStyle(id);
|
|
127
147
|
} else if (viewerType === "model") {
|
|
128
|
-
|
|
148
|
+
await modelStyleStore.applyModelStyle(id);
|
|
129
149
|
}
|
|
130
150
|
});
|
|
131
|
-
|
|
151
|
+
await Promise.all(promises);
|
|
132
152
|
}
|
|
133
153
|
|
|
134
154
|
return {
|
|
@@ -143,3 +163,5 @@ export const useDataStyleStore = defineStore("dataStyle", () => {
|
|
|
143
163
|
...modelStyleStore,
|
|
144
164
|
};
|
|
145
165
|
});
|
|
166
|
+
|
|
167
|
+
export type { DataStyleSnapshot };
|
package/app/stores/feedback.ts
CHANGED
|
@@ -21,9 +21,9 @@ export const useFeedbackStore = defineStore("feedback", {
|
|
|
21
21
|
feedbacks_timeout_miliseconds: DEFAULT_FEEDBACKS_TIMEOUT_SECONDS * MILLISECONDS_IN_SECOND,
|
|
22
22
|
}),
|
|
23
23
|
actions: {
|
|
24
|
-
|
|
24
|
+
add_error(code: number, route: string, name: string, description: string) {
|
|
25
25
|
const feedbackId = uuidv4();
|
|
26
|
-
|
|
26
|
+
this.feedbacks.push({
|
|
27
27
|
id: feedbackId,
|
|
28
28
|
type: "error",
|
|
29
29
|
code,
|
|
@@ -35,9 +35,9 @@ export const useFeedbackStore = defineStore("feedback", {
|
|
|
35
35
|
this.delete_feedback(feedbackId);
|
|
36
36
|
}, this.feedbacks_timeout_miliseconds);
|
|
37
37
|
},
|
|
38
|
-
|
|
38
|
+
add_success(description: string) {
|
|
39
39
|
const feedbackId = uuidv4();
|
|
40
|
-
|
|
40
|
+
this.feedbacks.push({
|
|
41
41
|
id: feedbackId,
|
|
42
42
|
type: "success",
|
|
43
43
|
description,
|
|
@@ -46,9 +46,9 @@ export const useFeedbackStore = defineStore("feedback", {
|
|
|
46
46
|
this.delete_feedback(feedbackId);
|
|
47
47
|
}, this.feedbacks_timeout_miliseconds);
|
|
48
48
|
},
|
|
49
|
-
|
|
49
|
+
add_warning(description: string) {
|
|
50
50
|
const feedbackId = uuidv4();
|
|
51
|
-
|
|
51
|
+
this.feedbacks.push({
|
|
52
52
|
id: feedbackId,
|
|
53
53
|
type: "warning",
|
|
54
54
|
description,
|
|
@@ -1,35 +1,30 @@
|
|
|
1
|
+
import {
|
|
2
|
+
type ViewStreamLike,
|
|
3
|
+
useHybridViewerViewport,
|
|
4
|
+
} from "@ogw_internal/stores/hybrid_viewer/viewport";
|
|
1
5
|
import {
|
|
2
6
|
applySnapshot,
|
|
3
7
|
getCameraOptions,
|
|
4
8
|
useHybridViewerCamera,
|
|
5
9
|
} from "@ogw_internal/stores/hybrid_viewer/camera";
|
|
6
10
|
import { BACKGROUND_COLOR } from "@ogw_internal/stores/hybrid_viewer/constants";
|
|
11
|
+
import type { CameraOptions } from "@ogw_internal/stores/hybrid_viewer/vtk_types";
|
|
7
12
|
import { useHybridViewerBrightness } from "@ogw_internal/stores/hybrid_viewer/brightness";
|
|
13
|
+
import { useHybridViewerCore } from "@ogw_internal/stores/hybrid_viewer/core";
|
|
8
14
|
import { useHybridViewerFilters } from "@ogw_internal/stores/hybrid_viewer/filters";
|
|
9
15
|
import { useHybridViewerHighlight } from "@ogw_internal/stores/hybrid_viewer/highlight";
|
|
10
16
|
import { useHybridViewerRuler } from "@ogw_internal/stores/hybrid_viewer/ruler";
|
|
11
17
|
import { useHybridViewerScene } from "@ogw_internal/stores/hybrid_viewer/scene";
|
|
12
|
-
import { useHybridViewerViewport } from "@ogw_internal/stores/hybrid_viewer/viewport";
|
|
13
18
|
import { newInstance as vtkGenericRenderWindow } from "@kitware/vtk.js/Rendering/Misc/GenericRenderWindow";
|
|
14
|
-
// oxlint-disable-next-line eslint/no-duplicate-imports
|
|
15
|
-
import type { vtkGenericRenderWindow as VtkGenericRenderWindow } from "@kitware/vtk.js/Rendering/Misc/GenericRenderWindow";
|
|
16
19
|
|
|
17
20
|
import { Status } from "@ogw_front/utils/status";
|
|
18
21
|
import { useViewerStore } from "@ogw_front/stores/viewer";
|
|
19
22
|
|
|
20
|
-
import viewer_schemas from "@geode/opengeodeweb-viewer/opengeodeweb_viewer_schemas.json";
|
|
21
|
-
|
|
22
|
-
interface GenericRenderWindowHolder {
|
|
23
|
-
value?: VtkGenericRenderWindow;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
23
|
// oxlint-disable max-lines-per-function, max-statements
|
|
27
24
|
export const useHybridViewerStore = defineStore("hybridViewer", () => {
|
|
28
25
|
const viewerStore = useViewerStore();
|
|
29
|
-
const genericRenderWindow
|
|
30
|
-
|
|
31
|
-
const is_moving = ref(false);
|
|
32
|
-
const is_picking = ref(false);
|
|
26
|
+
const { genericRenderWindow, status, is_moving, is_picking, remoteRender } =
|
|
27
|
+
useHybridViewerCore();
|
|
33
28
|
let imageStyle: CSSStyleDeclaration | undefined = undefined;
|
|
34
29
|
|
|
35
30
|
const brightnessStore = useHybridViewerBrightness();
|
|
@@ -46,11 +41,14 @@ export const useHybridViewerStore = defineStore("hybridViewer", () => {
|
|
|
46
41
|
if (!genericRenderWindow.value) {
|
|
47
42
|
return;
|
|
48
43
|
}
|
|
44
|
+
// oxlint-disable-next-line no-unsafe-assignment -- vtk.js has no types for getApiSpecificRenderWindow(); narrowed below.
|
|
49
45
|
const webGLRenderWindow = genericRenderWindow.value.getApiSpecificRenderWindow();
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
46
|
+
// oxlint-disable-next-line no-unsafe-type-assertion -- trusted vtk.js OpenGL render window API boundary.
|
|
47
|
+
const openGLRenderWindow = webGLRenderWindow as unknown as {
|
|
48
|
+
getCanvas: () => HTMLCanvasElement;
|
|
49
|
+
};
|
|
50
|
+
const canvas = openGLRenderWindow.getCanvas();
|
|
51
|
+
if (canvas.parentElement) {
|
|
54
52
|
canvas.parentElement.style.cursor = value ? "crosshair" : "default";
|
|
55
53
|
}
|
|
56
54
|
});
|
|
@@ -64,22 +62,34 @@ export const useHybridViewerStore = defineStore("hybridViewer", () => {
|
|
|
64
62
|
background: BACKGROUND_COLOR,
|
|
65
63
|
listenWindowResize: false,
|
|
66
64
|
});
|
|
67
|
-
const webGLRenderWindow =
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
65
|
+
const webGLRenderWindow =
|
|
66
|
+
// oxlint-disable-next-line no-unsafe-type-assertion -- trusted vtk.js OpenGL render window API boundary.
|
|
67
|
+
genericRenderWindow.value.getApiSpecificRenderWindow() as unknown as {
|
|
68
|
+
getReferenceByName: (name: string) => { style: CSSStyleDeclaration };
|
|
69
|
+
setBackgroundImage: (image: unknown) => void;
|
|
70
|
+
};
|
|
71
71
|
imageStyle = webGLRenderWindow.getReferenceByName("bgImage").style;
|
|
72
|
-
Object.assign(imageStyle, {
|
|
72
|
+
Object.assign(imageStyle, {
|
|
73
|
+
transition: "opacity 0.1s ease-in",
|
|
74
|
+
zIndex: 1,
|
|
75
|
+
});
|
|
73
76
|
await viewerStore.ws_connect();
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
+
// oxlint-disable-next-line no-unsafe-type-assertion -- trusted @kitware/vtk.js WebSocket client API boundary.
|
|
78
|
+
const clientApi = viewerStore.client as unknown as {
|
|
79
|
+
getImageStream: () => {
|
|
80
|
+
createViewStream: (id: string) => ViewStreamLike;
|
|
81
|
+
};
|
|
82
|
+
};
|
|
83
|
+
const imageStream = clientApi.getImageStream();
|
|
77
84
|
viewportStore.viewStream.value = imageStream.createViewStream("-1");
|
|
78
85
|
viewportStore.viewStream.value?.onImageReady((event: { image: unknown }) => {
|
|
79
86
|
if (is_moving.value) {
|
|
80
87
|
return;
|
|
81
88
|
}
|
|
82
|
-
|
|
89
|
+
// oxlint-disable no-unsafe-type-assertion -- image payload shape is guaranteed by the viewer's onImageReady contract.
|
|
90
|
+
const latestImage = event.image as typeof brightnessStore.latestImage.value;
|
|
91
|
+
// oxlint-enable no-unsafe-type-assertion
|
|
92
|
+
brightnessStore.latestImage.value = latestImage;
|
|
83
93
|
webGLRenderWindow.setBackgroundImage(event.image);
|
|
84
94
|
if (imageStyle) {
|
|
85
95
|
imageStyle.opacity = "1";
|
|
@@ -94,36 +104,15 @@ export const useHybridViewerStore = defineStore("hybridViewer", () => {
|
|
|
94
104
|
status.value = Status.CREATED;
|
|
95
105
|
}
|
|
96
106
|
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
if (renderPromise) {
|
|
102
|
-
renderPending = true;
|
|
103
|
-
return renderPromise;
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
renderPromise = (async () => {
|
|
107
|
-
try {
|
|
108
|
-
const schema = viewer_schemas.opengeodeweb_viewer.viewer.render;
|
|
109
|
-
await viewerStore.request({ schema });
|
|
110
|
-
} finally {
|
|
111
|
-
renderPromise = undefined;
|
|
112
|
-
if (renderPending) {
|
|
113
|
-
renderPending = false;
|
|
114
|
-
await remoteRender();
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
})();
|
|
118
|
-
return renderPromise;
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
function exportStores() {
|
|
107
|
+
function exportStores(): {
|
|
108
|
+
zScale: number;
|
|
109
|
+
camera_options: CameraOptions | Record<string, unknown>;
|
|
110
|
+
} {
|
|
122
111
|
const renderer = genericRenderWindow.value?.getRenderer();
|
|
123
112
|
const camera = renderer?.getActiveCamera();
|
|
124
113
|
return {
|
|
125
114
|
zScale: sceneStore.zScale.value,
|
|
126
|
-
camera_options: (camera ? getCameraOptions(camera) : undefined)
|
|
115
|
+
camera_options: (camera ? getCameraOptions(camera) : undefined) ?? cameraStore.camera_options,
|
|
127
116
|
};
|
|
128
117
|
}
|
|
129
118
|
|
package/app/stores/infra.ts
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import { Status } from "@ogw_front/utils/status";
|
|
2
2
|
import { appMode } from "@ogw_shared/app_mode";
|
|
3
|
-
import { registerRunningExtensions } from "@ogw_front/utils/extension";
|
|
4
3
|
import { setAppBaseUrl } from "@ogw_shared/scripts";
|
|
5
|
-
import { useAppStore } from "@ogw_front/stores/app";
|
|
6
4
|
import { useCloudStore } from "@ogw_front/stores/cloud";
|
|
7
5
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
6
|
+
interface ElectronApi {
|
|
7
|
+
electronAPI: {
|
|
8
|
+
project_folder_path: (args: { projectFolderPath: string }) => void;
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
declare global {
|
|
13
|
+
// oxlint-disable-next-line no-var -- required for global augmentation
|
|
14
|
+
var electronAPI: ElectronApi["electronAPI"];
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
export const useInfraStore = defineStore("infra", {
|
|
@@ -23,82 +23,84 @@ export const useInfraStore = defineStore("infra", {
|
|
|
23
23
|
}),
|
|
24
24
|
getters: {
|
|
25
25
|
microservices_connected(): boolean {
|
|
26
|
-
|
|
27
|
-
return this.microservices.every((store) => store.status === Status.CONNECTED);
|
|
26
|
+
return this.microservices.every((store: Microservice) => store.status === Status.CONNECTED);
|
|
28
27
|
},
|
|
29
28
|
microservices_busy(): boolean {
|
|
30
|
-
return this.microservices.some((store) => store.is_busy === true);
|
|
29
|
+
return this.microservices.some((store: Microservice) => store.is_busy === true);
|
|
31
30
|
},
|
|
32
31
|
},
|
|
33
32
|
actions: {
|
|
34
33
|
register_microservice(store: Microservice) {
|
|
35
34
|
const store_name = store.$id;
|
|
36
|
-
console.log("[INFRA] Registering microservice:", store_name);
|
|
37
35
|
|
|
38
|
-
if (
|
|
36
|
+
if (
|
|
37
|
+
!this.microservices.some((microservice: Microservice) => microservice.$id === store_name)
|
|
38
|
+
) {
|
|
39
39
|
this.microservices.push(store);
|
|
40
|
-
console.log("[INFRA] Microservice registered:", store_name);
|
|
41
40
|
}
|
|
42
41
|
},
|
|
43
42
|
unregister_microservice(microserviceId: string) {
|
|
44
|
-
console.log("[INFRA] Unregistering microservice:", microserviceId);
|
|
45
43
|
this.microservices = this.microservices.filter(
|
|
46
|
-
(microservice) => microservice.$id !== microserviceId,
|
|
44
|
+
(microservice: Microservice) => microservice.$id !== microserviceId,
|
|
47
45
|
);
|
|
48
|
-
console.log("[INFRA] Microservice unregistered:", microserviceId);
|
|
49
46
|
},
|
|
50
|
-
create_backend(email?: string) {
|
|
51
|
-
console.log("[INFRA] Starting create_backend - Mode:", this.app_mode);
|
|
52
|
-
console.log(
|
|
53
|
-
"[INFRA] Registered microservices:",
|
|
54
|
-
this.microservices.map((store) => store.$id),
|
|
55
|
-
);
|
|
47
|
+
async create_backend(email?: string) {
|
|
56
48
|
if (this.status === Status.CREATED) {
|
|
57
|
-
return;
|
|
49
|
+
return undefined;
|
|
58
50
|
}
|
|
59
|
-
|
|
51
|
+
await navigator.locks.request("infra.create_backend", async () => {
|
|
60
52
|
if (this.status === Status.CREATED) {
|
|
61
53
|
return;
|
|
62
54
|
}
|
|
63
55
|
this.status = Status.CREATING;
|
|
64
|
-
console.log("[INFRA] Lock granted for create_backend");
|
|
65
56
|
if (this.app_mode === appMode.CLOUD) {
|
|
66
57
|
const cloudStore = useCloudStore();
|
|
67
58
|
await cloudStore.launch(email ?? "");
|
|
68
59
|
} else {
|
|
60
|
+
const { useAppStore } = await import("@ogw_front/stores/app");
|
|
69
61
|
const appStore = useAppStore();
|
|
70
62
|
await appStore.createProjectFolder();
|
|
71
63
|
if (this.app_mode === appMode.DESKTOP) {
|
|
72
|
-
|
|
64
|
+
globalThis.electronAPI.project_folder_path({
|
|
73
65
|
projectFolderPath: appStore.projectFolderPath,
|
|
74
66
|
});
|
|
75
67
|
}
|
|
76
68
|
await setAppBaseUrl(appStore.base_url);
|
|
77
|
-
const microservices_with_launch = this.microservices.filter(
|
|
78
|
-
|
|
79
|
-
store.launch!({ projectFolderPath: appStore.projectFolderPath }),
|
|
69
|
+
const microservices_with_launch = this.microservices.filter(
|
|
70
|
+
(store: Microservice) => store.launch,
|
|
80
71
|
);
|
|
72
|
+
const launch_promises = microservices_with_launch.map(async (store: Microservice) => {
|
|
73
|
+
const result = await store.launch?.({
|
|
74
|
+
projectFolderPath: appStore.projectFolderPath,
|
|
75
|
+
});
|
|
76
|
+
return result;
|
|
77
|
+
});
|
|
78
|
+
const { registerRunningExtensions } = await import("@ogw_front/utils/extension");
|
|
81
79
|
launch_promises.push(registerRunningExtensions());
|
|
82
80
|
await Promise.all(launch_promises);
|
|
83
81
|
}
|
|
84
82
|
this.status = Status.CREATED;
|
|
85
|
-
console.log("[INFRA] Backend created successfully");
|
|
86
83
|
return this.create_connection();
|
|
87
84
|
});
|
|
85
|
+
return undefined;
|
|
88
86
|
},
|
|
89
87
|
async create_connection() {
|
|
90
|
-
console.log("[INFRA] Starting create_connection");
|
|
91
88
|
await Promise.all(
|
|
92
|
-
this.microservices.map(async (store) => {
|
|
93
|
-
console.log("[INFRA] Connecting to microservice:", store.$id);
|
|
89
|
+
this.microservices.map(async (store: Microservice) => {
|
|
94
90
|
await store.connect();
|
|
95
|
-
console.log("[INFRA] Microservice connected:", store.$id);
|
|
96
91
|
}),
|
|
97
92
|
);
|
|
98
|
-
console.log("[INFRA] All microservices connected");
|
|
99
93
|
},
|
|
100
94
|
},
|
|
101
95
|
share: {
|
|
102
96
|
omit: ["microservices"],
|
|
103
97
|
},
|
|
104
98
|
});
|
|
99
|
+
|
|
100
|
+
export interface Microservice {
|
|
101
|
+
$id: string;
|
|
102
|
+
status?: string;
|
|
103
|
+
is_busy?: boolean;
|
|
104
|
+
launch?: (params: Record<string, unknown>) => Promise<unknown>;
|
|
105
|
+
connect: () => Promise<void>;
|
|
106
|
+
}
|