@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.
- package/.build/server/utils/cleanup.js +7 -2
- package/.build/server/utils/microservices.js +9 -81
- package/.build/server/utils/microservices_process.js +85 -0
- package/.build/server/utils/scripts.js +34 -23
- package/.build/server/utils/typed_handler.js +5 -1
- package/.build/server/utils/ws_client.js +7 -2
- package/.build/shared/utils/fetch_raw.js +2 -2
- package/.build/shared/utils/parse_boolean.js +2 -1
- package/app/assets/geode_objects.ts +1 -0
- package/app/components/BasemapAttribution.vue +28 -0
- package/app/components/ClippingPlanes.vue +22 -78
- package/app/components/CrsSelector.vue +53 -46
- package/app/components/DragAndDrop.vue +16 -79
- package/app/components/FeedBack/Snackers.vue +27 -0
- package/app/components/FileSelector.vue +9 -6
- package/app/components/HybridViewerTooltip.vue +8 -2
- package/app/components/MissingFilesSelector.vue +40 -23
- package/app/components/ObjectSelector.vue +34 -20
- package/app/components/ProjectCrs.vue +37 -0
- package/app/components/Screenshot.vue +17 -59
- package/app/components/ThresholdCard.vue +205 -0
- package/app/components/ThresholdFilter.vue +81 -216
- package/app/components/ViewToolbar.vue +15 -231
- package/app/components/Viewer/Basemap/CropOptions.vue +50 -0
- package/app/components/Viewer/Basemap/OpacityOptions.vue +52 -0
- package/app/components/Viewer/ContextMenu/CircularItems.vue +1 -2
- package/app/components/Viewer/ContextMenu/ContextMenu.vue +11 -6
- package/app/components/Viewer/ContextMenu/ContextMenuItem.vue +10 -7
- package/app/components/Viewer/ContextMenu/InfoCard.vue +30 -0
- package/app/components/Viewer/EdgedCurve/SpecificEdgesColoring.vue +209 -0
- package/app/components/Viewer/EdgedCurve/SpecificEdgesOptions.vue +3 -191
- package/app/components/Viewer/Generic/Mesh/CellsColoring.vue +221 -0
- package/app/components/Viewer/Generic/Mesh/CellsOptions.vue +3 -210
- package/app/components/Viewer/Generic/Mesh/EdgesColoring.vue +211 -0
- package/app/components/Viewer/Generic/Mesh/EdgesOptions.vue +3 -192
- package/app/components/Viewer/Generic/Mesh/PointsOptions.vue +13 -0
- package/app/components/Viewer/Generic/Mesh/PolygonsColoring.vue +227 -0
- package/app/components/Viewer/Generic/Mesh/PolygonsOptions.vue +3 -215
- package/app/components/Viewer/Generic/Mesh/PolyhedraColoring.vue +221 -0
- package/app/components/Viewer/Generic/Mesh/PolyhedraOptions.vue +3 -203
- package/app/components/Viewer/Generic/Model/BlocksOptions.vue +14 -12
- package/app/components/Viewer/Generic/Model/ComponentPointsOptions.vue +2 -18
- package/app/components/Viewer/Generic/Model/CornerComponentOptions.vue +145 -0
- package/app/components/Viewer/Generic/Model/CornersOptions.vue +15 -294
- package/app/components/Viewer/Generic/Model/CornersTypeOptions.vue +173 -0
- package/app/components/Viewer/Generic/Model/LineComponentOptions.vue +218 -0
- package/app/components/Viewer/Generic/Model/LinesOptions.vue +15 -427
- package/app/components/Viewer/Generic/Model/LinesTypeOptions.vue +229 -0
- package/app/components/Viewer/Generic/Model/ModelCardTabs.vue +35 -0
- package/app/components/Viewer/Generic/Model/ModelEdgesCard.vue +34 -25
- package/app/components/Viewer/Generic/Model/ModelPointsCard.vue +34 -25
- package/app/components/Viewer/Generic/Model/ModelStyleCard.vue +17 -5
- package/app/components/Viewer/Generic/Model/SurfacesOptions.vue +16 -12
- package/app/components/Viewer/ObjectTree/Base/ComponentRelations.vue +4 -1
- package/app/components/Viewer/ObjectTree/Base/ItemLabel.vue +71 -1
- package/app/components/Viewer/ObjectTree/Views/GlobalObjects.vue +55 -10
- package/app/components/Viewer/Options/AttributeRangeSelector.vue +11 -4
- package/app/components/Viewer/Options/AttributeSelector.vue +40 -136
- package/app/components/Viewer/Options/ColorPicker.vue +4 -1
- package/app/components/Viewer/Options/ColoringTypeSelector.vue +48 -74
- package/app/components/Viewer/Options/ColormapQuickPicker.vue +13 -7
- package/app/components/Viewer/Options/NoDataColorInfo.vue +56 -0
- package/app/components/Viewer/Options/Sliders/Opacity.vue +22 -0
- package/app/components/Viewer/PointSet/SpecificPointsOptions.vue +13 -0
- package/app/components/Viewer/Scene/BackgroundOptions.vue +37 -0
- package/app/components/Viewer/Scene/OrientationWidgetOptions.vue +48 -0
- package/app/components/Viewer/Scene/TextOptions.vue +63 -0
- package/app/components/Viewer/Solid/SpecificPolyhedraColoring.vue +217 -0
- package/app/components/Viewer/Solid/SpecificPolyhedraOptions.vue +4 -199
- package/app/components/Viewer/Surface/PolygonsColoring.vue +224 -0
- package/app/components/Viewer/Surface/PolygonsOptions.vue +3 -213
- package/app/components/Viewer/Ui.vue +9 -0
- package/app/components/csv-preview/CsvPreviewer.vue +4 -1
- package/app/composables/attribute_coloring_style.ts +8 -2
- package/app/composables/attribute_selector.ts +126 -0
- package/app/composables/batch_style_model.ts +34 -0
- package/app/composables/clipping_slices.ts +166 -0
- package/app/composables/global_attribute_style.ts +4 -3
- package/app/composables/hover_highlight.ts +19 -18
- package/app/composables/live_data_item.ts +39 -0
- package/app/composables/model_tabs.ts +86 -0
- package/app/composables/overlapping_picker_menu.ts +43 -0
- package/app/composables/project_manager.ts +5 -81
- package/app/composables/project_manager_helpers/reset.ts +34 -0
- package/app/composables/project_manager_helpers/restore.ts +67 -0
- package/app/composables/project_manager_helpers/types.ts +24 -0
- package/app/composables/project_manager_helpers/viewer_session.ts +25 -0
- package/app/composables/stepper_tree.ts +10 -2
- package/app/composables/tree_filter.ts +11 -2
- package/app/composables/tree_keyboard_nav.ts +4 -2
- package/app/composables/use_overlapping_picker.ts +30 -42
- package/app/composables/view_toolbar_options.ts +126 -0
- package/app/composables/view_toolbar_tool_options.ts +115 -0
- package/app/composables/view_toolbar_tools.ts +108 -0
- package/app/composables/viewer_context_menu.ts +19 -1
- package/app/composables/virtual_tree.ts +20 -131
- package/app/composables/virtual_tree_flatten.ts +109 -0
- package/app/composables/virtual_tree_types.ts +81 -0
- package/app/stores/app.ts +8 -55
- package/app/stores/app_helpers/extension.ts +90 -51
- package/app/stores/app_helpers/registry.ts +69 -0
- package/app/stores/basemap.ts +52 -0
- package/app/stores/basemap_detail.ts +51 -0
- package/app/stores/basemap_helpers/builds.ts +158 -0
- package/app/stores/basemap_helpers/detail_layers.ts +72 -0
- package/app/stores/basemap_helpers/detail_map.ts +62 -0
- package/app/stores/basemap_helpers/detail_refresh.ts +134 -0
- package/app/stores/basemap_helpers/detail_view.ts +94 -0
- package/app/stores/basemap_helpers/extent.ts +40 -0
- package/app/stores/basemap_helpers/georeferenced.ts +50 -0
- package/app/stores/basemap_helpers/layers.ts +66 -0
- package/app/stores/basemap_helpers/settings.ts +87 -0
- package/app/stores/basemap_helpers/viewer.ts +114 -0
- package/app/stores/crs.ts +136 -0
- package/app/stores/data.ts +24 -1
- package/app/stores/data_style.ts +8 -0
- package/app/stores/feedback.ts +12 -2
- package/app/stores/hybrid_viewer.ts +1 -1
- package/app/stores/infra.ts +26 -21
- package/app/stores/menu.ts +8 -124
- package/app/stores/menu_helpers/basemap.ts +10 -0
- package/app/stores/menu_helpers/menus_data.ts +27 -0
- package/app/stores/menu_helpers/mesh/edged_curve.ts +12 -0
- package/app/stores/menu_helpers/mesh/grid.ts +24 -0
- package/app/stores/menu_helpers/mesh/point_set.ts +11 -0
- package/app/stores/menu_helpers/mesh/solid.ts +29 -0
- package/app/stores/menu_helpers/mesh/surface.ts +22 -0
- package/app/stores/menu_helpers/model.ts +25 -0
- package/app/stores/menu_helpers/scene.ts +10 -0
- package/app/stores/menu_helpers/types.ts +5 -0
- package/app/stores/treeview.ts +17 -10
- package/app/stores/viewer.ts +17 -79
- package/app/stores/viewer_helpers/actions.ts +68 -0
- package/app/stores/viewer_helpers/request.ts +61 -0
- package/app/utils/basemap_tree.ts +76 -0
- package/app/utils/clipping_planes.ts +4 -131
- package/app/utils/clipping_planes_scene.ts +131 -0
- package/app/utils/color_picker.ts +18 -15
- package/app/utils/coloring_styles.ts +101 -0
- package/app/utils/crs.ts +38 -0
- package/app/utils/default_styles/constants.ts +10 -0
- package/app/utils/default_styles/index.ts +17 -1
- package/app/utils/default_styles/mesh_components.ts +168 -0
- package/app/utils/default_styles/meshes.ts +13 -153
- package/app/utils/default_styles/model_components.ts +170 -0
- package/app/utils/default_styles/models.ts +16 -153
- package/app/utils/drag_and_drop.ts +80 -0
- package/app/utils/extension.ts +1 -1
- package/app/utils/import_workflow.ts +26 -11
- package/app/utils/model_component_coloring.ts +46 -0
- package/app/utils/threshold.ts +33 -0
- package/app/utils/threshold_sources.ts +51 -0
- package/app/utils/treeview.ts +12 -1
- package/app/utils/upload_path.ts +15 -9
- package/app/utils/visible_map_area.ts +129 -0
- package/internal/database/base_database.ts +2 -0
- package/internal/database/database.ts +47 -29
- package/internal/database/tables/scene_style.ts +6 -0
- package/internal/stores/data_style/mesh/base_style.ts +74 -0
- package/internal/stores/data_style/mesh/cells/cell.ts +27 -150
- package/internal/stores/data_style/mesh/cells/cell_attribute.ts +74 -0
- package/internal/stores/data_style/mesh/cells/cell_config.ts +152 -0
- package/internal/stores/data_style/mesh/cells/color.ts +3 -1
- package/internal/stores/data_style/mesh/cells/index.ts +17 -1
- package/internal/stores/data_style/mesh/cells/opacity.ts +54 -0
- package/internal/stores/data_style/mesh/cells/vertex.ts +26 -157
- package/internal/stores/data_style/mesh/cells/vertex_attribute.ts +80 -0
- package/internal/stores/data_style/mesh/cells/vertex_config.ts +152 -0
- package/internal/stores/data_style/mesh/edges/color.ts +3 -1
- package/internal/stores/data_style/mesh/edges/edge.ts +27 -150
- package/internal/stores/data_style/mesh/edges/edge_attribute.ts +74 -0
- package/internal/stores/data_style/mesh/edges/edge_config.ts +152 -0
- package/internal/stores/data_style/mesh/edges/index.ts +17 -1
- package/internal/stores/data_style/mesh/edges/opacity.ts +54 -0
- package/internal/stores/data_style/mesh/edges/vertex.ts +26 -157
- package/internal/stores/data_style/mesh/edges/vertex_attribute.ts +80 -0
- package/internal/stores/data_style/mesh/edges/vertex_config.ts +152 -0
- package/internal/stores/data_style/mesh/index.ts +2 -57
- package/internal/stores/data_style/mesh/points/color.ts +3 -1
- package/internal/stores/data_style/mesh/points/index.ts +17 -1
- package/internal/stores/data_style/mesh/points/opacity.ts +54 -0
- package/internal/stores/data_style/mesh/points/vertex.ts +26 -157
- package/internal/stores/data_style/mesh/points/vertex_attribute.ts +80 -0
- package/internal/stores/data_style/mesh/points/vertex_config.ts +152 -0
- package/internal/stores/data_style/mesh/polygons/color.ts +3 -1
- package/internal/stores/data_style/mesh/polygons/index.ts +17 -1
- package/internal/stores/data_style/mesh/polygons/opacity.ts +54 -0
- package/internal/stores/data_style/mesh/polygons/polygon.ts +27 -152
- package/internal/stores/data_style/mesh/polygons/polygon_attribute.ts +80 -0
- package/internal/stores/data_style/mesh/polygons/polygon_config.ts +148 -0
- package/internal/stores/data_style/mesh/polygons/vertex.ts +26 -157
- package/internal/stores/data_style/mesh/polygons/vertex_attribute.ts +80 -0
- package/internal/stores/data_style/mesh/polygons/vertex_config.ts +152 -0
- package/internal/stores/data_style/mesh/polyhedra/color.ts +3 -1
- package/internal/stores/data_style/mesh/polyhedra/index.ts +17 -1
- package/internal/stores/data_style/mesh/polyhedra/opacity.ts +54 -0
- package/internal/stores/data_style/mesh/polyhedra/polyhedron.ts +27 -160
- package/internal/stores/data_style/mesh/polyhedra/polyhedron_attribute.ts +82 -0
- package/internal/stores/data_style/mesh/polyhedra/polyhedron_config.ts +157 -0
- package/internal/stores/data_style/mesh/polyhedra/vertex.ts +26 -157
- package/internal/stores/data_style/mesh/polyhedra/vertex_attribute.ts +80 -0
- package/internal/stores/data_style/mesh/polyhedra/vertex_config.ts +152 -0
- package/internal/stores/data_style/model/blocks/apply_coloring.ts +173 -0
- package/internal/stores/data_style/model/blocks/color.ts +58 -57
- package/internal/stores/data_style/model/blocks/coloring_groups.ts +18 -0
- package/internal/stores/data_style/model/blocks/index.ts +12 -140
- package/internal/stores/data_style/model/blocks/polyhedron.ts +102 -54
- package/internal/stores/data_style/model/blocks/vertex.ts +102 -54
- package/internal/stores/data_style/model/color.ts +25 -26
- package/internal/stores/data_style/model/common.ts +10 -119
- package/internal/stores/data_style/model/common_mutations.ts +184 -0
- package/internal/stores/data_style/model/corners/index.ts +85 -78
- package/internal/stores/data_style/model/corners/vertex.ts +97 -49
- package/internal/stores/data_style/model/lines/apply_coloring.ts +154 -0
- package/internal/stores/data_style/model/lines/color.ts +53 -40
- package/internal/stores/data_style/model/lines/coloring_groups.ts +18 -0
- package/internal/stores/data_style/model/lines/edge.ts +102 -54
- package/internal/stores/data_style/model/lines/index.ts +10 -134
- package/internal/stores/data_style/model/lines/vertex.ts +102 -54
- package/internal/stores/data_style/model/surfaces/apply_coloring.ts +186 -0
- package/internal/stores/data_style/model/surfaces/color.ts +68 -56
- package/internal/stores/data_style/model/surfaces/coloring_groups.ts +18 -0
- package/internal/stores/data_style/model/surfaces/index.ts +16 -160
- package/internal/stores/data_style/model/surfaces/polygon.ts +94 -46
- package/internal/stores/data_style/model/surfaces/vertex.ts +94 -46
- package/internal/stores/data_style/model/visibility.ts +3 -156
- package/internal/stores/data_style/model/visibility_dispatch.ts +110 -0
- package/internal/stores/data_style/scene.ts +118 -0
- package/internal/stores/data_style/state.ts +5 -181
- package/internal/stores/data_style/state_shared.ts +199 -0
- package/internal/stores/data_style/types.ts +24 -1
- package/internal/stores/hybrid_viewer/brightness.ts +8 -2
- package/internal/stores/hybrid_viewer/camera.ts +7 -161
- package/internal/stores/hybrid_viewer/camera_animation.ts +4 -3
- package/internal/stores/hybrid_viewer/camera_helpers.ts +120 -0
- package/internal/stores/hybrid_viewer/camera_orientation.ts +60 -0
- package/internal/stores/hybrid_viewer/filters.ts +54 -11
- package/internal/stores/hybrid_viewer/highlight.ts +80 -63
- package/internal/stores/hybrid_viewer/ruler.ts +4 -3
- package/internal/stores/hybrid_viewer/scene.ts +34 -26
- package/internal/stores/hybrid_viewer/vtk_types.ts +2 -1
- package/internal/utils/ws_client.ts +8 -1
- package/package.json +5 -5
- package/server/api/local/extensions/run.post.ts +6 -4
- package/server/api/local/extensions/upload.put.ts +47 -20
- package/server/utils/cleanup.ts +12 -2
- package/server/utils/microservices.ts +10 -102
- package/server/utils/microservices_process.ts +127 -0
- package/server/utils/scripts.ts +35 -30
- package/server/utils/typed_handler.ts +8 -1
- package/server/utils/ws_client.ts +15 -2
- package/shared/utils/fetch_raw.ts +2 -2
- package/shared/utils/parse_boolean.ts +4 -1
- package/app/components/Viewer/Options/OptionsSection.vue +0 -76
|
@@ -28,6 +28,10 @@ async function deleteFolderRecursive(folderPath) {
|
|
|
28
28
|
function isErrorWithMessage(error) {
|
|
29
29
|
return typeof error === "object" && error !== null && "message" in error && typeof error.message === "string";
|
|
30
30
|
}
|
|
31
|
+
function describeError(error) {
|
|
32
|
+
if (isErrorWithMessage(error)) return error.message;
|
|
33
|
+
return String(error);
|
|
34
|
+
}
|
|
31
35
|
async function killHttpMicroservice(microservice) {
|
|
32
36
|
consola.debug("killHttpMicroservice", { ...microservice });
|
|
33
37
|
const failMessage = `Failed to kill ${microservice.name}`;
|
|
@@ -36,7 +40,7 @@ async function killHttpMicroservice(microservice) {
|
|
|
36
40
|
try {
|
|
37
41
|
await fetch(microservice.url, { method: microservice.method });
|
|
38
42
|
} catch (error) {
|
|
39
|
-
const message =
|
|
43
|
+
const message = describeError(error);
|
|
40
44
|
consola.info(`Expected error during kill of ${microservice.name}:`, message);
|
|
41
45
|
}
|
|
42
46
|
}
|
|
@@ -109,7 +113,8 @@ async function cleanupBackend(projectFolderPath) {
|
|
|
109
113
|
}
|
|
110
114
|
function getMicroserviceByName(microservices, name) {
|
|
111
115
|
const found = microservices.find((microservice) => microservice.name === name);
|
|
112
|
-
|
|
116
|
+
if (found === void 0) return;
|
|
117
|
+
return { ...found };
|
|
113
118
|
}
|
|
114
119
|
//#endregion
|
|
115
120
|
export { cleanupBackend, deleteFolderRecursive, getMicroserviceByName, killMicroservice, microservicesMetadatasPath, projectMicroservices };
|
|
@@ -1,67 +1,13 @@
|
|
|
1
1
|
import { microservicesMetadatasPath, projectMicroservices } from "./cleanup.js";
|
|
2
2
|
import { addNginxLocation, addSupervisorProgram } from "./cloud.js";
|
|
3
|
-
import { getAvailablePort
|
|
3
|
+
import { getAvailablePort } from "./scripts.js";
|
|
4
4
|
import { executablePath } from "./path.js";
|
|
5
|
-
import
|
|
5
|
+
import { DEFAULT_RUN_ARGS, backArgs, isPortInUseError, runScript, waitUntilListening } from "./microservices_process.js";
|
|
6
6
|
import { consola } from "consola";
|
|
7
7
|
import fs from "node:fs";
|
|
8
8
|
import child_process from "node:child_process";
|
|
9
9
|
import back_schemas from "@geode/opengeodeweb-back/opengeodeweb_back_schemas.json" with { type: "json" };
|
|
10
10
|
//#region server/utils/microservices.ts
|
|
11
|
-
const MILLISECONDS_PER_SECOND = 1e3;
|
|
12
|
-
const DEFAULT_TIMEOUT_SECONDS = 120;
|
|
13
|
-
const MAX_PORT_RETRIES = 1;
|
|
14
|
-
const DEFAULT_RUN_ARGS = { projectFolderPath: "" };
|
|
15
|
-
const LISTENING_LOG_PATTERN = /^Listening on https?:\/\/.+:\d+\/?\s*$/mu;
|
|
16
|
-
async function runScript(execPath, execName, args, expectedResponse, timeoutSeconds = DEFAULT_TIMEOUT_SECONDS) {
|
|
17
|
-
const command = executablePath(execPath, execName);
|
|
18
|
-
consola.debug("runScript", command, args);
|
|
19
|
-
const child = child_process.spawn(command, args, { stdio: [
|
|
20
|
-
"ignore",
|
|
21
|
-
"pipe",
|
|
22
|
-
"pipe"
|
|
23
|
-
] });
|
|
24
|
-
child.name = command.replace(/^.*[\\/]/u, "");
|
|
25
|
-
child.on("spawn", () => {
|
|
26
|
-
consola.info(`[${child.name}] spawned, pid=${child.pid}`);
|
|
27
|
-
});
|
|
28
|
-
const controller = new AbortController();
|
|
29
|
-
const timer = setTimeout(() => {
|
|
30
|
-
controller.abort();
|
|
31
|
-
}, timeoutSeconds * MILLISECONDS_PER_SECOND);
|
|
32
|
-
if (typeof timer.unref === "function") timer.unref();
|
|
33
|
-
try {
|
|
34
|
-
const result = await waitForReady(child, expectedResponse, controller.signal);
|
|
35
|
-
clearTimeout(timer);
|
|
36
|
-
return result;
|
|
37
|
-
} catch (error) {
|
|
38
|
-
clearTimeout(timer);
|
|
39
|
-
child.kill();
|
|
40
|
-
throw error;
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
function isPortInUseError(error) {
|
|
44
|
-
return /EADDRINUSE|address already in use|port already in use/iu.test(String(error));
|
|
45
|
-
}
|
|
46
|
-
function backArgs(args, port) {
|
|
47
|
-
const { projectFolderPath } = args;
|
|
48
|
-
if (!projectFolderPath) throw new Error("projectFolderPath is required");
|
|
49
|
-
const uploadFolderPath = args.uploadFolderPath !== void 0 && args.uploadFolderPath !== "" ? args.uploadFolderPath : path.join(projectFolderPath, "uploads");
|
|
50
|
-
const executableArgs = [
|
|
51
|
-
"--port",
|
|
52
|
-
String(port),
|
|
53
|
-
"--project_folder_path",
|
|
54
|
-
projectFolderPath,
|
|
55
|
-
"--upload_folder_path",
|
|
56
|
-
uploadFolderPath,
|
|
57
|
-
"--allowed_origins",
|
|
58
|
-
"http://localhost:*",
|
|
59
|
-
"--timeout",
|
|
60
|
-
"0"
|
|
61
|
-
];
|
|
62
|
-
if (process.env.NODE_ENV === void 0 || process.env.NODE_ENV === "development") executableArgs.push("--debug");
|
|
63
|
-
return executableArgs;
|
|
64
|
-
}
|
|
65
11
|
async function runBack(execName, execPath, args = DEFAULT_RUN_ARGS, attempts = 0) {
|
|
66
12
|
let port = void 0;
|
|
67
13
|
try {
|
|
@@ -75,7 +21,7 @@ async function runBack(execName, execPath, args = DEFAULT_RUN_ARGS, attempts = 0
|
|
|
75
21
|
consola.error("runBack error", error);
|
|
76
22
|
throw error;
|
|
77
23
|
}
|
|
78
|
-
if (attempts <=
|
|
24
|
+
if (attempts <= 1) {
|
|
79
25
|
consola.info("Retrying runBack on conflicting port", port);
|
|
80
26
|
return await runBack(execName, execPath, args, attempts + 1);
|
|
81
27
|
}
|
|
@@ -104,7 +50,7 @@ async function runViewer(execName, execPath, args = DEFAULT_RUN_ARGS, attempts =
|
|
|
104
50
|
consola.error("runViewer error", error);
|
|
105
51
|
throw error;
|
|
106
52
|
}
|
|
107
|
-
if (attempts <=
|
|
53
|
+
if (attempts <= 1) {
|
|
108
54
|
consola.info("Retrying runViewer on conflicting port", port);
|
|
109
55
|
return await runViewer(execName, execPath, args, attempts + 1);
|
|
110
56
|
}
|
|
@@ -126,48 +72,30 @@ async function runExtension(extensionId, execName, execPath, args = DEFAULT_RUN_
|
|
|
126
72
|
consola.error("runExtension error", error);
|
|
127
73
|
throw error;
|
|
128
74
|
}
|
|
129
|
-
if (attempts <=
|
|
75
|
+
if (attempts <= 1) {
|
|
130
76
|
consola.info("Retrying runExtension on conflicting port", port);
|
|
131
77
|
return await runExtension(extensionId, execName, execPath, args, attempts + 1);
|
|
132
78
|
}
|
|
133
79
|
}
|
|
134
80
|
throw new Error(`runExtension failed to run ${extensionId}`);
|
|
135
81
|
}
|
|
136
|
-
async function waitUntilListening(child) {
|
|
137
|
-
child.stderr.on("data", (data) => {
|
|
138
|
-
consola.info(`[${child.spawnfile}] STDERR:`, data.toString().trim());
|
|
139
|
-
});
|
|
140
|
-
child.on("close", (code) => {
|
|
141
|
-
consola.info(`[${child.spawnfile}] exited with code ${code}`);
|
|
142
|
-
});
|
|
143
|
-
for await (const chunk of child.stdout) {
|
|
144
|
-
const output = String(chunk);
|
|
145
|
-
consola.info(`[${child.spawnfile}] STDOUT:`, output.trim());
|
|
146
|
-
if (LISTENING_LOG_PATTERN.test(output)) {
|
|
147
|
-
child.stdout.on("data", (data) => {
|
|
148
|
-
consola.info(`[${child.spawnfile}] STDOUT:`, data.toString().trim());
|
|
149
|
-
});
|
|
150
|
-
return;
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
throw new Error(`${child.spawnfile} exited before becoming ready`);
|
|
154
|
-
}
|
|
155
82
|
async function runExtensionServer(entryPath, attempts = 0) {
|
|
156
83
|
let port = void 0;
|
|
157
84
|
try {
|
|
158
85
|
port = await getAvailablePort();
|
|
159
86
|
consola.info("runExtensionServer", entryPath, port);
|
|
160
|
-
|
|
87
|
+
const child = child_process.spawn("node", [entryPath], { env: {
|
|
161
88
|
...process.env,
|
|
162
89
|
PORT: String(port)
|
|
163
|
-
} })
|
|
90
|
+
} });
|
|
91
|
+
await waitUntilListening(child);
|
|
164
92
|
return port;
|
|
165
93
|
} catch (error) {
|
|
166
94
|
if (!isPortInUseError(error)) {
|
|
167
95
|
consola.error("runExtensionServer error", error);
|
|
168
96
|
throw error;
|
|
169
97
|
}
|
|
170
|
-
if (attempts <=
|
|
98
|
+
if (attempts <= 1) {
|
|
171
99
|
consola.warn("Retrying runExtensionServer on conflicting port", port);
|
|
172
100
|
return await runExtensionServer(entryPath, attempts + 1);
|
|
173
101
|
}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { waitForReady } from "./scripts.js";
|
|
2
|
+
import { executablePath } from "./path.js";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
import { consola } from "consola";
|
|
5
|
+
import child_process from "node:child_process";
|
|
6
|
+
//#region server/utils/microservices_process.ts
|
|
7
|
+
const MILLISECONDS_PER_SECOND = 1e3;
|
|
8
|
+
const DEFAULT_TIMEOUT_SECONDS = 120;
|
|
9
|
+
const MAX_PORT_RETRIES = 1;
|
|
10
|
+
const DEFAULT_RUN_ARGS = { projectFolderPath: "" };
|
|
11
|
+
const LISTENING_LOG_PATTERN = /^Listening on https?:\/\/.+:\d+\/?\s*$/mu;
|
|
12
|
+
async function runScript(execPath, execName, args, expectedResponse, timeoutSeconds = DEFAULT_TIMEOUT_SECONDS) {
|
|
13
|
+
const command = executablePath(execPath, execName);
|
|
14
|
+
consola.debug("runScript", command, args);
|
|
15
|
+
const child = child_process.spawn(command, args, { stdio: [
|
|
16
|
+
"ignore",
|
|
17
|
+
"pipe",
|
|
18
|
+
"pipe"
|
|
19
|
+
] });
|
|
20
|
+
child.name = command.replace(/^.*[\\/]/u, "");
|
|
21
|
+
child.on("spawn", () => {
|
|
22
|
+
consola.info(`[${child.name}] spawned, pid=${child.pid}`);
|
|
23
|
+
});
|
|
24
|
+
const controller = new AbortController();
|
|
25
|
+
const timer = setTimeout(() => {
|
|
26
|
+
controller.abort();
|
|
27
|
+
}, timeoutSeconds * MILLISECONDS_PER_SECOND);
|
|
28
|
+
if (typeof timer.unref === "function") timer.unref();
|
|
29
|
+
try {
|
|
30
|
+
const result = await waitForReady(child, expectedResponse, controller.signal);
|
|
31
|
+
clearTimeout(timer);
|
|
32
|
+
return result;
|
|
33
|
+
} catch (error) {
|
|
34
|
+
clearTimeout(timer);
|
|
35
|
+
child.kill();
|
|
36
|
+
throw error;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
function isPortInUseError(error) {
|
|
40
|
+
return /EADDRINUSE|address already in use|port already in use/iu.test(String(error));
|
|
41
|
+
}
|
|
42
|
+
function resolveUploadFolderPath(projectFolderPath, uploadFolderPath) {
|
|
43
|
+
if (uploadFolderPath !== void 0 && uploadFolderPath !== "") return uploadFolderPath;
|
|
44
|
+
return path.join(projectFolderPath, "uploads");
|
|
45
|
+
}
|
|
46
|
+
function backArgs(args, port) {
|
|
47
|
+
const { projectFolderPath } = args;
|
|
48
|
+
if (!projectFolderPath) throw new Error("projectFolderPath is required");
|
|
49
|
+
const uploadFolderPath = resolveUploadFolderPath(projectFolderPath, args.uploadFolderPath);
|
|
50
|
+
const executableArgs = [
|
|
51
|
+
"--port",
|
|
52
|
+
String(port),
|
|
53
|
+
"--project_folder_path",
|
|
54
|
+
projectFolderPath,
|
|
55
|
+
"--upload_folder_path",
|
|
56
|
+
uploadFolderPath,
|
|
57
|
+
"--allowed_origins",
|
|
58
|
+
"http://localhost:*",
|
|
59
|
+
"--timeout",
|
|
60
|
+
"0"
|
|
61
|
+
];
|
|
62
|
+
if (process.env.NODE_ENV === void 0 || process.env.NODE_ENV === "development") executableArgs.push("--debug");
|
|
63
|
+
return executableArgs;
|
|
64
|
+
}
|
|
65
|
+
async function waitUntilListening(child) {
|
|
66
|
+
child.stderr.on("data", (data) => {
|
|
67
|
+
consola.info(`[${child.spawnfile}] STDERR:`, data.toString().trim());
|
|
68
|
+
});
|
|
69
|
+
child.on("close", (code) => {
|
|
70
|
+
consola.info(`[${child.spawnfile}] exited with code ${code}`);
|
|
71
|
+
});
|
|
72
|
+
for await (const chunk of child.stdout) {
|
|
73
|
+
const output = String(chunk);
|
|
74
|
+
consola.info(`[${child.spawnfile}] STDOUT:`, output.trim());
|
|
75
|
+
if (LISTENING_LOG_PATTERN.test(output)) {
|
|
76
|
+
child.stdout.on("data", (data) => {
|
|
77
|
+
consola.info(`[${child.spawnfile}] STDOUT:`, data.toString().trim());
|
|
78
|
+
});
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
throw new Error(`${child.spawnfile} exited before becoming ready`);
|
|
83
|
+
}
|
|
84
|
+
//#endregion
|
|
85
|
+
export { DEFAULT_RUN_ARGS, MAX_PORT_RETRIES, backArgs, isPortInUseError, runScript, waitUntilListening };
|
|
@@ -25,31 +25,46 @@ const encoder = new TextEncoder();
|
|
|
25
25
|
function byteLength(str) {
|
|
26
26
|
return encoder.encode(str).byteLength;
|
|
27
27
|
}
|
|
28
|
+
function truncateLine(lineOutput) {
|
|
29
|
+
const halfBuffer = MAX_ERROR_BUFFER_BYTES / 2;
|
|
30
|
+
return byteLength(lineOutput) > halfBuffer ? `${lineOutput.slice(0, halfBuffer)}…[truncated]` : lineOutput;
|
|
31
|
+
}
|
|
32
|
+
function trimOutputBuffer(output) {
|
|
33
|
+
let trimmed = output;
|
|
34
|
+
while (byteLength(trimmed) > MAX_ERROR_BUFFER_BYTES) {
|
|
35
|
+
const newline = trimmed.indexOf("\n");
|
|
36
|
+
if (newline === -1) return "";
|
|
37
|
+
trimmed = trimmed.slice(newline + 1);
|
|
38
|
+
}
|
|
39
|
+
return trimmed;
|
|
40
|
+
}
|
|
41
|
+
function createOutputRecorder() {
|
|
42
|
+
let recentOutput = "";
|
|
43
|
+
function record(lineOutput) {
|
|
44
|
+
recentOutput = trimOutputBuffer(`${recentOutput} ${truncateLine(lineOutput)}\n`);
|
|
45
|
+
}
|
|
46
|
+
function read() {
|
|
47
|
+
return recentOutput;
|
|
48
|
+
}
|
|
49
|
+
return {
|
|
50
|
+
record,
|
|
51
|
+
read
|
|
52
|
+
};
|
|
53
|
+
}
|
|
28
54
|
async function waitForReady(child, expectedResponse, signal) {
|
|
29
55
|
return new Promise((resolve, reject) => {
|
|
30
56
|
const readlineStdout = readline.createInterface({ input: child.stdout });
|
|
31
57
|
const readlineStderr = readline.createInterface({ input: child.stderr });
|
|
32
|
-
|
|
33
|
-
function recordOutput(lineOutput) {
|
|
34
|
-
const safeLine = byteLength(lineOutput) > MAX_ERROR_BUFFER_BYTES / 2 ? `${lineOutput.slice(0, MAX_ERROR_BUFFER_BYTES / 2)}…[truncated]` : lineOutput;
|
|
35
|
-
recentOutput = `${recentOutput} ${safeLine}\n`;
|
|
36
|
-
while (byteLength(recentOutput) > MAX_ERROR_BUFFER_BYTES) {
|
|
37
|
-
const newline = recentOutput.indexOf("\n");
|
|
38
|
-
if (newline === -1) {
|
|
39
|
-
recentOutput = "";
|
|
40
|
-
break;
|
|
41
|
-
}
|
|
42
|
-
recentOutput = recentOutput.slice(newline + 1);
|
|
43
|
-
}
|
|
44
|
-
}
|
|
58
|
+
const recorder = createOutputRecorder();
|
|
45
59
|
let onLine = void 0;
|
|
46
|
-
let onErrLine = void 0;
|
|
47
60
|
let onError = void 0;
|
|
48
61
|
let onClose = void 0;
|
|
49
62
|
let onAbort = void 0;
|
|
50
63
|
function cleanup() {
|
|
51
|
-
if (onLine)
|
|
52
|
-
|
|
64
|
+
if (onLine) {
|
|
65
|
+
readlineStdout.removeListener("line", onLine);
|
|
66
|
+
readlineStderr.removeListener("line", onLine);
|
|
67
|
+
}
|
|
53
68
|
if (onError) child.removeListener("error", onError);
|
|
54
69
|
if (onClose) child.removeListener("close", onClose);
|
|
55
70
|
if (signal && onAbort) signal.removeEventListener("abort", onAbort);
|
|
@@ -69,14 +84,9 @@ async function waitForReady(child, expectedResponse, signal) {
|
|
|
69
84
|
}
|
|
70
85
|
onLine = (lineOutput) => {
|
|
71
86
|
consola.info(`[${child.name}] ${lineOutput}`);
|
|
72
|
-
|
|
87
|
+
recorder.record(lineOutput);
|
|
73
88
|
if (lineOutput.includes(expectedResponse)) becomeReady();
|
|
74
89
|
};
|
|
75
|
-
onErrLine = (line) => {
|
|
76
|
-
consola.info(`[${child.name}] ${line}`);
|
|
77
|
-
recordOutput(line);
|
|
78
|
-
if (line.includes(expectedResponse)) becomeReady();
|
|
79
|
-
};
|
|
80
90
|
onError = (err) => {
|
|
81
91
|
cleanup();
|
|
82
92
|
reject(err);
|
|
@@ -84,6 +94,7 @@ async function waitForReady(child, expectedResponse, signal) {
|
|
|
84
94
|
onClose = (code) => {
|
|
85
95
|
consola.info(`[${child.name}] exited with code ${code}`);
|
|
86
96
|
cleanup();
|
|
97
|
+
const recentOutput = recorder.read();
|
|
87
98
|
reject(/* @__PURE__ */ new Error(`[${child.name}] exited with code ${code} before becoming ready.${recentOutput ? `\nRecent output:\n${recentOutput}` : ""}`));
|
|
88
99
|
};
|
|
89
100
|
onAbort = () => {
|
|
@@ -91,7 +102,7 @@ async function waitForReady(child, expectedResponse, signal) {
|
|
|
91
102
|
reject(/* @__PURE__ */ new Error(`[${child.name}] timed out waiting for "${expectedResponse}"`));
|
|
92
103
|
};
|
|
93
104
|
readlineStdout.on("line", onLine);
|
|
94
|
-
readlineStderr.on("line",
|
|
105
|
+
readlineStderr.on("line", onLine);
|
|
95
106
|
child.once("error", onError);
|
|
96
107
|
child.once("close", onClose);
|
|
97
108
|
if (signal) signal.addEventListener("abort", onAbort, { once: true });
|
|
@@ -5,6 +5,10 @@ import { createError, defineEventHandler, getQuery, isError, readBody, setRespon
|
|
|
5
5
|
//#region server/utils/typed_handler.ts
|
|
6
6
|
const BAD_REQUEST = 400;
|
|
7
7
|
const INTERNAL_SERVER_ERROR = 500;
|
|
8
|
+
function describeError(error) {
|
|
9
|
+
if (error instanceof Error) return error.message;
|
|
10
|
+
return String(error);
|
|
11
|
+
}
|
|
8
12
|
function toErrorResponse(error) {
|
|
9
13
|
if (isError(error)) return {
|
|
10
14
|
code: error.statusCode,
|
|
@@ -14,7 +18,7 @@ function toErrorResponse(error) {
|
|
|
14
18
|
return {
|
|
15
19
|
code: INTERNAL_SERVER_ERROR,
|
|
16
20
|
name: "Internal Server Error",
|
|
17
|
-
description:
|
|
21
|
+
description: describeError(error)
|
|
18
22
|
};
|
|
19
23
|
}
|
|
20
24
|
function sendError(event, schema, error) {
|
|
@@ -11,7 +11,12 @@ function isWsRpcMessage(value) {
|
|
|
11
11
|
}
|
|
12
12
|
function rawDataToBlob(raw) {
|
|
13
13
|
if (raw instanceof ArrayBuffer) return new Blob([raw]);
|
|
14
|
-
return new Blob([Uint8Array.from(
|
|
14
|
+
if (Array.isArray(raw)) return new Blob([Uint8Array.from(Buffer.concat(raw))]);
|
|
15
|
+
return new Blob([Uint8Array.from(raw)]);
|
|
16
|
+
}
|
|
17
|
+
function findPendingCall(pending, id) {
|
|
18
|
+
if (id === void 0) return;
|
|
19
|
+
return pending.get(id);
|
|
15
20
|
}
|
|
16
21
|
function createServerWsRpcClient(baseUrl) {
|
|
17
22
|
const socket = new WebSocket(baseUrl);
|
|
@@ -46,7 +51,7 @@ function createServerWsRpcClient(baseUrl) {
|
|
|
46
51
|
return;
|
|
47
52
|
}
|
|
48
53
|
if (typeof message.id === "string" && message.id.startsWith("publish:")) return;
|
|
49
|
-
const entry =
|
|
54
|
+
const entry = findPendingCall(pending, message.id);
|
|
50
55
|
if (!entry || message.id === void 0) return;
|
|
51
56
|
pending.delete(message.id);
|
|
52
57
|
if (message.error) entry.reject(new Error(message.error.message ?? "wslink RPC error"));
|
|
@@ -17,8 +17,8 @@ async function performFetch({ route, method, params, baseURL, headers, max_retry
|
|
|
17
17
|
baseURL,
|
|
18
18
|
method,
|
|
19
19
|
headers,
|
|
20
|
-
...hasBody(params)
|
|
21
|
-
...max_retry
|
|
20
|
+
...hasBody(params) && { body: params },
|
|
21
|
+
...max_retry !== void 0 && { retry: max_retry },
|
|
22
22
|
async onRequestError({ error }) {
|
|
23
23
|
if (request_error_function) await request_error_function(error);
|
|
24
24
|
},
|
|
@@ -14,7 +14,8 @@ const FALSY_VALUES = /* @__PURE__ */ new Set([
|
|
|
14
14
|
"no"
|
|
15
15
|
]);
|
|
16
16
|
function parseBoolean(value) {
|
|
17
|
-
|
|
17
|
+
let normalized = value;
|
|
18
|
+
if (typeof value === "string") normalized = value.trim().toLowerCase();
|
|
18
19
|
if (TRUTHY_VALUES.has(normalized)) return true;
|
|
19
20
|
if (FALSY_VALUES.has(normalized)) return false;
|
|
20
21
|
throw new Error(`Cannot parse boolean from: ${value}`);
|
|
@@ -13,6 +13,7 @@ import PointSet3D from "@ogw_front/assets/img/geode_objects/PointSet3D.svg";
|
|
|
13
13
|
import PolygonalSurface2D from "@ogw_front/assets/img/geode_objects/PolygonalSurface2D.svg";
|
|
14
14
|
import PolygonalSurface3D from "@ogw_front/assets/img/geode_objects/PolygonalSurface3D.svg";
|
|
15
15
|
import PolyhedralSolid3D from "@ogw_front/assets/img/geode_objects/PolyhedralSolid3D.svg";
|
|
16
|
+
// oxlint-disable-next-line import/max-dependencies -- one icon import per geode object.
|
|
16
17
|
import RasterImage2D from "@ogw_front/assets/img/geode_objects/RasterImage2D.svg";
|
|
17
18
|
import RasterImage3D from "@ogw_front/assets/img/geode_objects/RasterImage3D.svg";
|
|
18
19
|
import RegularGrid2D from "@ogw_front/assets/img/geode_objects/RegularGrid2D.svg";
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { useBasemapStore } from "@ogw_front/stores/basemap";
|
|
3
|
+
|
|
4
|
+
const basemapStore = useBasemapStore();
|
|
5
|
+
// A hidden basemap stays built: its attribution goes with its maps
|
|
6
|
+
</script>
|
|
7
|
+
|
|
8
|
+
<template>
|
|
9
|
+
<span
|
|
10
|
+
v-if="basemapStore.attribution && basemapStore.maps.length > 0"
|
|
11
|
+
data-testid="basemapAttribution"
|
|
12
|
+
class="basemap-attribution text-caption text-medium-emphasis px-1"
|
|
13
|
+
>
|
|
14
|
+
{{ basemapStore.attribution }}
|
|
15
|
+
</span>
|
|
16
|
+
</template>
|
|
17
|
+
|
|
18
|
+
<style scoped>
|
|
19
|
+
.basemap-attribution {
|
|
20
|
+
position: absolute;
|
|
21
|
+
left: 8px;
|
|
22
|
+
bottom: 4px;
|
|
23
|
+
z-index: 1;
|
|
24
|
+
background: rgba(var(--v-theme-surface), 0.6);
|
|
25
|
+
border-radius: 4px;
|
|
26
|
+
pointer-events: none;
|
|
27
|
+
}
|
|
28
|
+
</style>
|
|
@@ -1,16 +1,11 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
2
|
import { DEBOUNCE_DELAY, DEFAULT_NORMALS } from "@ogw_front/utils/clipping_planes";
|
|
3
|
-
import {
|
|
4
|
-
DEFAULT_SLICE_AXIS,
|
|
5
|
-
SLICE_AXES,
|
|
6
|
-
type SliceAxis,
|
|
7
|
-
areAllGrids,
|
|
8
|
-
} from "@ogw_front/utils/slice";
|
|
9
3
|
import type { ClippingPlane } from "@ogw_front/composables/clipping_planes_widget_entries";
|
|
10
4
|
import ClippingPlaneCard from "@ogw_front/components/ClippingPlaneCard.vue";
|
|
11
5
|
import SliceCard from "@ogw_front/components/SliceCard.vue";
|
|
12
6
|
import ToolPanel from "@ogw_front/components/ToolPanel.vue";
|
|
13
7
|
import { useClippingPlanesWidget } from "@ogw_front/composables/clipping_planes_widget";
|
|
8
|
+
import { useClippingSlices } from "@ogw_front/composables/clipping_slices";
|
|
14
9
|
import { useDataStore } from "@ogw_front/stores/data";
|
|
15
10
|
import { useDebounceFn } from "@vueuse/core";
|
|
16
11
|
import { useHybridViewerStore } from "@ogw_front/stores/hybrid_viewer";
|
|
@@ -33,16 +28,12 @@ function newItemId(): number {
|
|
|
33
28
|
}
|
|
34
29
|
const planes = ref<ClippingPlane[]>([{ id: newItemId(), origin: undefined, normal: [1, 0, 0] }]);
|
|
35
30
|
const allItems = dataStore.refRegisteredItems();
|
|
36
|
-
const
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
targetAllVisible.value ? allItems.value.map((item) => item.id) : selectedDatasetIds.value,
|
|
43
|
-
);
|
|
44
|
-
const isAllGrid = computed<boolean>(() => areAllGrids(allItems.value, targetIds.value));
|
|
45
|
-
const isSliceActive = computed<boolean>(() => isAllGrid.value && sliceEnabled.value);
|
|
31
|
+
const targetIds = computed<string[]>(() => {
|
|
32
|
+
if (targetAllVisible.value) {
|
|
33
|
+
return allItems.value.map((item) => item.id);
|
|
34
|
+
}
|
|
35
|
+
return selectedDatasetIds.value;
|
|
36
|
+
});
|
|
46
37
|
const availableDatasets = computed<{ title: string; value: string }[]>(() =>
|
|
47
38
|
allItems.value.map((item) => ({
|
|
48
39
|
title: item.name || item.id,
|
|
@@ -51,8 +42,6 @@ const availableDatasets = computed<{ title: string; value: string }[]>(() =>
|
|
|
51
42
|
);
|
|
52
43
|
const widgetContainer = useTemplateRef("widgetContainer");
|
|
53
44
|
let debouncedApply: ((...args: unknown[]) => void) | undefined = undefined;
|
|
54
|
-
let areSlicesApplied = false;
|
|
55
|
-
let pendingSlices: Promise<void> = Promise.resolve();
|
|
56
45
|
|
|
57
46
|
const {
|
|
58
47
|
getSceneCenter,
|
|
@@ -76,6 +65,19 @@ function getUntargetedIds(): string[] {
|
|
|
76
65
|
return allItems.value.map((item) => item.id).filter((id) => !targetIds.value.includes(id));
|
|
77
66
|
}
|
|
78
67
|
|
|
68
|
+
const {
|
|
69
|
+
sliceEnabled,
|
|
70
|
+
slices,
|
|
71
|
+
sliceMaxIndices,
|
|
72
|
+
isAllGrid,
|
|
73
|
+
isSliceActive,
|
|
74
|
+
applySlices,
|
|
75
|
+
addSlice,
|
|
76
|
+
removeSlice,
|
|
77
|
+
resetSlices,
|
|
78
|
+
removeSlices,
|
|
79
|
+
} = useClippingSlices({ allItems, targetIds, getUntargetedIds, newItemId, hybridViewerStore });
|
|
80
|
+
|
|
79
81
|
async function applyClippingPlanes(): Promise<void> {
|
|
80
82
|
if (allItems.value.length === 0) {
|
|
81
83
|
return;
|
|
@@ -97,45 +99,6 @@ async function applyClippingPlanes(): Promise<void> {
|
|
|
97
99
|
}
|
|
98
100
|
}
|
|
99
101
|
|
|
100
|
-
async function sendSlices(): Promise<void> {
|
|
101
|
-
if (!isAllGrid.value && !areSlicesApplied) {
|
|
102
|
-
return;
|
|
103
|
-
}
|
|
104
|
-
const isActive = isSliceActive.value;
|
|
105
|
-
const untargetedIds = getUntargetedIds();
|
|
106
|
-
if (targetIds.value.length > 0) {
|
|
107
|
-
const maxIndices = await hybridViewerStore.setSlice(
|
|
108
|
-
targetIds.value,
|
|
109
|
-
isActive ? slices.value.map(({ axis, index }) => ({ axis, index })) : [],
|
|
110
|
-
);
|
|
111
|
-
if (isAllGrid.value) {
|
|
112
|
-
sliceMaxIndices.value = maxIndices;
|
|
113
|
-
}
|
|
114
|
-
if (isActive) {
|
|
115
|
-
for (const slice of slices.value) {
|
|
116
|
-
slice.index = Math.min(slice.index, maxIndices[slice.axis]);
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
if (areSlicesApplied && untargetedIds.length > 0) {
|
|
121
|
-
await hybridViewerStore.setSlice(untargetedIds, []);
|
|
122
|
-
}
|
|
123
|
-
areSlicesApplied = isActive;
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
function queueSliceTask(task: () => Promise<void>): Promise<void> {
|
|
127
|
-
const previous = pendingSlices;
|
|
128
|
-
pendingSlices = (async (): Promise<void> => {
|
|
129
|
-
await Promise.allSettled([previous]);
|
|
130
|
-
await task();
|
|
131
|
-
})();
|
|
132
|
-
return pendingSlices;
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
function applySlices(): Promise<void> {
|
|
136
|
-
return queueSliceTask(sendSlices);
|
|
137
|
-
}
|
|
138
|
-
|
|
139
102
|
async function applyAll(): Promise<void> {
|
|
140
103
|
await applyClippingPlanes();
|
|
141
104
|
await applySlices();
|
|
@@ -156,19 +119,6 @@ function removePlane(index: number): void {
|
|
|
156
119
|
planes.value.splice(index, 1);
|
|
157
120
|
}
|
|
158
121
|
|
|
159
|
-
function addSlice(): void {
|
|
160
|
-
const lastSlice = slices.value.at(-1);
|
|
161
|
-
slices.value.push({
|
|
162
|
-
id: newItemId(),
|
|
163
|
-
axis: lastSlice ? SLICE_AXES[lastSlice.axis].next : DEFAULT_SLICE_AXIS,
|
|
164
|
-
index: 0,
|
|
165
|
-
});
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
function removeSlice(index: number): void {
|
|
169
|
-
slices.value.splice(index, 1);
|
|
170
|
-
}
|
|
171
|
-
|
|
172
122
|
function flipNormal(plane: { normal: number[] }): void {
|
|
173
123
|
plane.normal = plane.normal.map((component) => -component);
|
|
174
124
|
syncWidgets();
|
|
@@ -178,8 +128,7 @@ function flipNormal(plane: { normal: number[] }): void {
|
|
|
178
128
|
async function resetClippingPlanes(): Promise<void> {
|
|
179
129
|
setFromWidget(true);
|
|
180
130
|
planes.value = [{ id: newItemId(), origin: undefined, normal: [1, 0, 0] }];
|
|
181
|
-
|
|
182
|
-
slices.value = [{ id: newItemId(), axis: DEFAULT_SLICE_AXIS, index: 0 }];
|
|
131
|
+
resetSlices();
|
|
183
132
|
updateWidgetPlacement({ isReset: true });
|
|
184
133
|
setFromWidget(false);
|
|
185
134
|
await applyAll();
|
|
@@ -188,12 +137,7 @@ async function resetClippingPlanes(): Promise<void> {
|
|
|
188
137
|
async function removeClippingPlanes(): Promise<void> {
|
|
189
138
|
const allIds = allItems.value.map((item) => item.id);
|
|
190
139
|
await hybridViewerStore.setClippingPlanes(allIds, []);
|
|
191
|
-
await
|
|
192
|
-
if (areSlicesApplied) {
|
|
193
|
-
await hybridViewerStore.setSlice(allIds, []);
|
|
194
|
-
areSlicesApplied = false;
|
|
195
|
-
}
|
|
196
|
-
});
|
|
140
|
+
await removeSlices(allIds);
|
|
197
141
|
}
|
|
198
142
|
|
|
199
143
|
watch(widgetContainer, (container) => {
|