@geode/opengeodeweb-front 10.44.0-rc.2 → 10.44.0-rc.4

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 (160) hide show
  1. package/.build/server/utils/cleanup.js +7 -2
  2. package/.build/server/utils/microservices.js +9 -81
  3. package/.build/server/utils/microservices_process.js +85 -0
  4. package/.build/server/utils/typed_handler.js +5 -1
  5. package/.build/server/utils/ws_client.js +7 -2
  6. package/.build/shared/utils/fetch_raw.js +2 -2
  7. package/.build/shared/utils/parse_boolean.js +2 -1
  8. package/app/components/ClippingPlanes.vue +22 -78
  9. package/app/components/DragAndDrop.vue +16 -79
  10. package/app/components/FileSelector.vue +9 -6
  11. package/app/components/HybridViewerTooltip.vue +8 -2
  12. package/app/components/MissingFilesSelector.vue +10 -6
  13. package/app/components/ObjectSelector.vue +6 -3
  14. package/app/components/Screenshot.vue +9 -2
  15. package/app/components/ThresholdCard.vue +205 -0
  16. package/app/components/ThresholdFilter.vue +81 -216
  17. package/app/components/ViewToolbar.vue +15 -231
  18. package/app/components/Viewer/EdgedCurve/SpecificEdgesColoring.vue +209 -0
  19. package/app/components/Viewer/EdgedCurve/SpecificEdgesOptions.vue +3 -191
  20. package/app/components/Viewer/Generic/Mesh/CellsColoring.vue +228 -0
  21. package/app/components/Viewer/Generic/Mesh/CellsOptions.vue +3 -210
  22. package/app/components/Viewer/Generic/Mesh/EdgesColoring.vue +211 -0
  23. package/app/components/Viewer/Generic/Mesh/EdgesOptions.vue +3 -192
  24. package/app/components/Viewer/Generic/Mesh/PolygonsColoring.vue +234 -0
  25. package/app/components/Viewer/Generic/Mesh/PolygonsOptions.vue +3 -215
  26. package/app/components/Viewer/Generic/Mesh/PolyhedraColoring.vue +221 -0
  27. package/app/components/Viewer/Generic/Mesh/PolyhedraOptions.vue +3 -203
  28. package/app/components/Viewer/Generic/Model/BlocksOptions.vue +7 -5
  29. package/app/components/Viewer/Generic/Model/ComponentPointsOptions.vue +2 -18
  30. package/app/components/Viewer/Generic/Model/CornerComponentOptions.vue +145 -0
  31. package/app/components/Viewer/Generic/Model/CornersOptions.vue +13 -292
  32. package/app/components/Viewer/Generic/Model/CornersTypeOptions.vue +173 -0
  33. package/app/components/Viewer/Generic/Model/LineComponentOptions.vue +218 -0
  34. package/app/components/Viewer/Generic/Model/LinesOptions.vue +13 -425
  35. package/app/components/Viewer/Generic/Model/LinesTypeOptions.vue +229 -0
  36. package/app/components/Viewer/Generic/Model/ModelEdgesCard.vue +12 -10
  37. package/app/components/Viewer/Generic/Model/ModelPointsCard.vue +12 -10
  38. package/app/components/Viewer/Generic/Model/SurfacesOptions.vue +9 -5
  39. package/app/components/Viewer/ObjectTree/Base/ComponentRelations.vue +4 -1
  40. package/app/components/Viewer/ObjectTree/Views/GlobalObjects.vue +6 -1
  41. package/app/components/Viewer/Options/AttributeRangeSelector.vue +11 -4
  42. package/app/components/Viewer/Options/AttributeSelector.vue +40 -136
  43. package/app/components/Viewer/Options/ColorPicker.vue +4 -1
  44. package/app/components/Viewer/Options/ColoringTypeSelector.vue +36 -74
  45. package/app/components/Viewer/Options/ColormapQuickPicker.vue +13 -7
  46. package/app/components/Viewer/Options/NoDataColorInfo.vue +56 -0
  47. package/app/components/Viewer/Solid/SpecificPolyhedraColoring.vue +217 -0
  48. package/app/components/Viewer/Solid/SpecificPolyhedraOptions.vue +4 -199
  49. package/app/components/Viewer/Surface/PolygonsColoring.vue +231 -0
  50. package/app/components/Viewer/Surface/PolygonsOptions.vue +3 -213
  51. package/app/components/csv-preview/CsvPreviewer.vue +4 -1
  52. package/app/composables/attribute_coloring_style.ts +8 -2
  53. package/app/composables/attribute_selector.ts +126 -0
  54. package/app/composables/clipping_slices.ts +166 -0
  55. package/app/composables/global_attribute_style.ts +4 -3
  56. package/app/composables/hover_highlight.ts +6 -5
  57. package/app/composables/project_manager.ts +5 -5
  58. package/app/composables/stepper_tree.ts +10 -2
  59. package/app/composables/tree_filter.ts +11 -2
  60. package/app/composables/tree_keyboard_nav.ts +4 -2
  61. package/app/composables/use_overlapping_picker.ts +5 -5
  62. package/app/composables/view_toolbar_options.ts +126 -0
  63. package/app/composables/view_toolbar_tool_options.ts +115 -0
  64. package/app/composables/view_toolbar_tools.ts +108 -0
  65. package/app/composables/virtual_tree.ts +20 -131
  66. package/app/composables/virtual_tree_flatten.ts +86 -0
  67. package/app/composables/virtual_tree_types.ts +81 -0
  68. package/app/stores/app.ts +8 -55
  69. package/app/stores/app_helpers/extension.ts +1 -1
  70. package/app/stores/app_helpers/registry.ts +69 -0
  71. package/app/stores/feedback.ts +2 -2
  72. package/app/stores/hybrid_viewer.ts +1 -1
  73. package/app/stores/menu.ts +1 -124
  74. package/app/stores/menu_helpers/menus_data.ts +127 -0
  75. package/app/stores/treeview.ts +17 -10
  76. package/app/stores/viewer.ts +17 -78
  77. package/app/stores/viewer_helpers/actions.ts +68 -0
  78. package/app/stores/viewer_helpers/request.ts +61 -0
  79. package/app/utils/clipping_planes.ts +4 -131
  80. package/app/utils/clipping_planes_scene.ts +131 -0
  81. package/app/utils/coloring_styles.ts +101 -0
  82. package/app/utils/default_styles/mesh_components.ts +168 -0
  83. package/app/utils/default_styles/meshes.ts +13 -153
  84. package/app/utils/default_styles/model_components.ts +170 -0
  85. package/app/utils/default_styles/models.ts +16 -153
  86. package/app/utils/drag_and_drop.ts +80 -0
  87. package/app/utils/extension.ts +1 -1
  88. package/app/utils/import_workflow.ts +6 -4
  89. package/app/utils/model_component_coloring.ts +46 -0
  90. package/app/utils/threshold.ts +33 -0
  91. package/app/utils/threshold_sources.ts +51 -0
  92. package/app/utils/upload_path.ts +15 -9
  93. package/internal/database/database.ts +4 -1
  94. package/internal/stores/data_style/mesh/cells/cell.ts +27 -150
  95. package/internal/stores/data_style/mesh/cells/cell_attribute.ts +74 -0
  96. package/internal/stores/data_style/mesh/cells/cell_config.ts +152 -0
  97. package/internal/stores/data_style/mesh/cells/vertex.ts +26 -157
  98. package/internal/stores/data_style/mesh/cells/vertex_attribute.ts +80 -0
  99. package/internal/stores/data_style/mesh/cells/vertex_config.ts +152 -0
  100. package/internal/stores/data_style/mesh/edges/edge.ts +27 -150
  101. package/internal/stores/data_style/mesh/edges/edge_attribute.ts +74 -0
  102. package/internal/stores/data_style/mesh/edges/edge_config.ts +152 -0
  103. package/internal/stores/data_style/mesh/edges/vertex.ts +26 -157
  104. package/internal/stores/data_style/mesh/edges/vertex_attribute.ts +80 -0
  105. package/internal/stores/data_style/mesh/edges/vertex_config.ts +152 -0
  106. package/internal/stores/data_style/mesh/points/vertex.ts +26 -157
  107. package/internal/stores/data_style/mesh/points/vertex_attribute.ts +80 -0
  108. package/internal/stores/data_style/mesh/points/vertex_config.ts +152 -0
  109. package/internal/stores/data_style/mesh/polygons/polygon.ts +27 -152
  110. package/internal/stores/data_style/mesh/polygons/polygon_attribute.ts +80 -0
  111. package/internal/stores/data_style/mesh/polygons/polygon_config.ts +148 -0
  112. package/internal/stores/data_style/mesh/polygons/vertex.ts +26 -157
  113. package/internal/stores/data_style/mesh/polygons/vertex_attribute.ts +80 -0
  114. package/internal/stores/data_style/mesh/polygons/vertex_config.ts +152 -0
  115. package/internal/stores/data_style/mesh/polyhedra/polyhedron.ts +27 -160
  116. package/internal/stores/data_style/mesh/polyhedra/polyhedron_attribute.ts +82 -0
  117. package/internal/stores/data_style/mesh/polyhedra/polyhedron_config.ts +157 -0
  118. package/internal/stores/data_style/mesh/polyhedra/vertex.ts +26 -157
  119. package/internal/stores/data_style/mesh/polyhedra/vertex_attribute.ts +80 -0
  120. package/internal/stores/data_style/mesh/polyhedra/vertex_config.ts +152 -0
  121. package/internal/stores/data_style/model/blocks/apply_coloring.ts +173 -0
  122. package/internal/stores/data_style/model/blocks/coloring_groups.ts +18 -0
  123. package/internal/stores/data_style/model/blocks/index.ts +12 -140
  124. package/internal/stores/data_style/model/blocks/polyhedron.ts +14 -10
  125. package/internal/stores/data_style/model/blocks/vertex.ts +14 -10
  126. package/internal/stores/data_style/model/common.ts +10 -119
  127. package/internal/stores/data_style/model/common_mutations.ts +184 -0
  128. package/internal/stores/data_style/model/corners/vertex.ts +14 -10
  129. package/internal/stores/data_style/model/lines/apply_coloring.ts +154 -0
  130. package/internal/stores/data_style/model/lines/coloring_groups.ts +18 -0
  131. package/internal/stores/data_style/model/lines/edge.ts +14 -10
  132. package/internal/stores/data_style/model/lines/index.ts +10 -134
  133. package/internal/stores/data_style/model/lines/vertex.ts +14 -10
  134. package/internal/stores/data_style/model/surfaces/apply_coloring.ts +186 -0
  135. package/internal/stores/data_style/model/surfaces/coloring_groups.ts +18 -0
  136. package/internal/stores/data_style/model/surfaces/index.ts +16 -160
  137. package/internal/stores/data_style/model/surfaces/polygon.ts +14 -10
  138. package/internal/stores/data_style/model/surfaces/vertex.ts +14 -10
  139. package/internal/stores/data_style/model/visibility.ts +3 -156
  140. package/internal/stores/data_style/model/visibility_dispatch.ts +160 -0
  141. package/internal/stores/data_style/state.ts +1 -181
  142. package/internal/stores/data_style/state_shared.ts +191 -0
  143. package/internal/stores/hybrid_viewer/brightness.ts +8 -2
  144. package/internal/stores/hybrid_viewer/camera.ts +7 -161
  145. package/internal/stores/hybrid_viewer/camera_animation.ts +4 -3
  146. package/internal/stores/hybrid_viewer/camera_helpers.ts +120 -0
  147. package/internal/stores/hybrid_viewer/camera_orientation.ts +60 -0
  148. package/internal/stores/hybrid_viewer/filters.ts +54 -11
  149. package/internal/stores/hybrid_viewer/highlight.ts +10 -9
  150. package/internal/stores/hybrid_viewer/ruler.ts +4 -3
  151. package/internal/utils/ws_client.ts +8 -1
  152. package/package.json +2 -2
  153. package/server/api/local/extensions/run.post.ts +6 -4
  154. package/server/utils/cleanup.ts +12 -2
  155. package/server/utils/microservices.ts +10 -102
  156. package/server/utils/microservices_process.ts +127 -0
  157. package/server/utils/typed_handler.ts +8 -1
  158. package/server/utils/ws_client.ts +15 -2
  159. package/shared/utils/fetch_raw.ts +2 -2
  160. package/shared/utils/parse_boolean.ts +4 -1
@@ -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 = isErrorWithMessage(error) ? error.message : String(error);
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
- return found === void 0 ? void 0 : { ...found };
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, waitForReady } from "./scripts.js";
3
+ import { getAvailablePort } from "./scripts.js";
4
4
  import { executablePath } from "./path.js";
5
- import path from "node:path";
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 <= MAX_PORT_RETRIES) {
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 <= MAX_PORT_RETRIES) {
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 <= MAX_PORT_RETRIES) {
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
- await waitUntilListening(child_process.spawn("node", [entryPath], { env: {
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 <= MAX_PORT_RETRIES) {
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 };
@@ -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: error instanceof Error ? error.message : String(error)
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(Array.isArray(raw) ? Buffer.concat(raw) : raw)]);
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 = message.id === void 0 ? void 0 : pending.get(message.id);
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) ? { body: params } : {},
21
- ...max_retry === void 0 ? {} : { retry: 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
- const normalized = typeof value === "string" ? value.trim().toLowerCase() : value;
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}`);
@@ -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 sliceEnabled = ref<boolean>(false);
37
- const slices = ref<{ id: number; axis: SliceAxis; index: number }[]>([
38
- { id: newItemId(), axis: DEFAULT_SLICE_AXIS, index: 0 },
39
- ]);
40
- const sliceMaxIndices = ref<[number, number, number]>([0, 0, 0]);
41
- const targetIds = computed<string[]>(() =>
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
- sliceEnabled.value = false;
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 queueSliceTask(async () => {
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) => {
@@ -1,4 +1,5 @@
1
1
  <script setup lang="ts">
2
+ import { filesFromEntry, isFileAccepted } from "@ogw_front/utils/drag_and_drop";
2
3
  import DragAndDropInline from "./DragAndDropInternal/DragAndDropInline.vue";
3
4
  import DragAndDropOverlay from "./DragAndDropInternal/DragAndDropOverlay.vue";
4
5
  import type { UploadFile } from "@ogw_front/utils/upload_path";
@@ -38,11 +39,12 @@ const {
38
39
  // oxlint-disable-next-line vue/max-props
39
40
  } = defineProps<Props>();
40
41
 
41
- const displayed_texts = computed<DragAndDropTexts>(() =>
42
- directory
43
- ? { ...texts, idle: "Click or drag and drop a folder", drop: "Drop the folder here" }
44
- : texts,
45
- );
42
+ const displayed_texts = computed<DragAndDropTexts>(() => {
43
+ if (directory) {
44
+ return { ...texts, idle: "Click or drag and drop a folder", drop: "Drop the folder here" };
45
+ }
46
+ return texts;
47
+ });
46
48
 
47
49
  const emit = defineEmits<{
48
50
  "files-selected": [files: UploadFile[]];
@@ -55,50 +57,11 @@ const isInternalDrag = ref(false);
55
57
  const dragCounter = ref(0);
56
58
  const fileInput = ref<HTMLInputElement | undefined>(undefined);
57
59
 
58
- const WILDCARD_SUFFIX_LENGTH = 2;
59
-
60
- function isFileAccepted(file: File, acceptValue: string | string[] | undefined): boolean {
61
- const fileName = (file.name || "").toLowerCase();
62
- const fileType = (file.type || "").toLowerCase();
63
- const isVext = fileName.endsWith(".vext");
64
-
65
- if (!acceptValue) {
66
- return !isVext;
67
- }
68
- let rules: string[] = [];
69
- if (Array.isArray(acceptValue)) {
70
- rules = acceptValue;
71
- } else if (typeof acceptValue === "string") {
72
- rules = acceptValue.split(",");
60
+ function getErrorMessage(error: unknown): string {
61
+ if (error instanceof Error) {
62
+ return error.message;
73
63
  }
74
- rules = rules.map((rule) => String(rule).trim()).filter(Boolean);
75
- if (rules.length === 0) {
76
- return !isVext;
77
- }
78
-
79
- return rules.some((rule) => {
80
- let cleanRule = rule.toLowerCase();
81
- if (!cleanRule) {
82
- return !isVext;
83
- }
84
- if (cleanRule === "*" || cleanRule === "*.*") {
85
- return !isVext;
86
- }
87
- if (cleanRule.startsWith("*.")) {
88
- cleanRule = cleanRule.slice(1);
89
- }
90
- if (cleanRule.startsWith(".")) {
91
- return fileName.endsWith(cleanRule);
92
- }
93
- if (cleanRule.includes("/")) {
94
- if (cleanRule.endsWith("/*")) {
95
- const typeGroup = cleanRule.slice(0, -WILDCARD_SUFFIX_LENGTH);
96
- return fileType.startsWith(typeGroup);
97
- }
98
- return fileType === cleanRule;
99
- }
100
- return fileName.endsWith(`.${cleanRule}`);
101
- });
64
+ return String(error);
102
65
  }
103
66
 
104
67
  function triggerFileDialog(): void {
@@ -126,41 +89,16 @@ function onDragOver(event: DragEvent): void {
126
89
  }
127
90
  }
128
91
 
129
- async function readAllEntries(reader: FileSystemDirectoryReader): Promise<FileSystemEntry[]> {
130
- // oxlint-disable-next-line promise/avoid-new
131
- const batch = await new Promise<FileSystemEntry[]>((resolve, reject) => {
132
- reader.readEntries(resolve, reject);
133
- });
134
- if (batch.length === 0) {
135
- return [];
136
- }
137
- return [...batch, ...(await readAllEntries(reader))];
138
- }
139
-
140
- async function filesFromEntry(entry: FileSystemEntry, path: string): Promise<UploadFile[]> {
141
- if (entry.isFile) {
142
- // oxlint-disable-next-line promise/avoid-new
143
- const file = await new Promise<File>((resolve, reject) => {
144
- // oxlint-disable-next-line no-unsafe-type-assertion -- isFile guarantees a FileSystemFileEntry
145
- (entry as FileSystemFileEntry).file(resolve, reject);
146
- });
147
- return [Object.assign(file, { relativePath: path })];
148
- }
149
- // oxlint-disable-next-line no-unsafe-type-assertion -- not a file, so a FileSystemDirectoryEntry
150
- const children = await readAllEntries((entry as FileSystemDirectoryEntry).createReader());
151
- const nested = await Promise.all(
152
- children.map((child) => filesFromEntry(child, `${path}/${child.name}`)),
153
- );
154
- return nested.flat();
155
- }
156
-
157
92
  async function emitDroppedEntries(entries: FileSystemEntry[]): Promise<void> {
158
93
  try {
159
94
  const groups = await Promise.all(
160
95
  entries.map(async (entry) => {
161
96
  const files = await filesFromEntry(entry, entry.name);
162
97
  // Files inside a dropped folder are all needed: never filtered out.
163
- return entry.isDirectory ? files : files.filter((file) => isFileAccepted(file, accept));
98
+ if (entry.isDirectory) {
99
+ return files;
100
+ }
101
+ return files.filter((file) => isFileAccepted(file, accept));
164
102
  }),
165
103
  );
166
104
  const files = groups.flat();
@@ -168,8 +106,7 @@ async function emitDroppedEntries(entries: FileSystemEntry[]): Promise<void> {
168
106
  emit("files-selected", files);
169
107
  }
170
108
  } catch (error) {
171
- const message = error instanceof Error ? error.message : String(error);
172
- emit("folder-read-error", message);
109
+ emit("folder-read-error", getErrorMessage(error));
173
110
  }
174
111
  }
175
112
 
@@ -55,12 +55,15 @@ const toggle_loading = useToggle(loading);
55
55
 
56
56
  function files_uploaded_event(value: unknown[]): void {
57
57
  if (value.length > 0) {
58
- emit(
59
- "update_values",
60
- timeSeries
61
- ? { files: value, autoUpload: false, time_series: time_series.value }
62
- : { files: value, autoUpload: false },
63
- );
58
+ if (timeSeries) {
59
+ emit("update_values", {
60
+ files: value,
61
+ autoUpload: false,
62
+ time_series: time_series.value,
63
+ });
64
+ } else {
65
+ emit("update_values", { files: value, autoUpload: false });
66
+ }
64
67
  emit("increment_step");
65
68
  }
66
69
  }
@@ -92,7 +92,10 @@ function capitalize(val: string): string {
92
92
 
93
93
  const fieldTypeLabel = computed<string>(() => {
94
94
  const fieldType = hybridViewerStore.hoverData?.fieldType;
95
- return typeof fieldType === "string" ? capitalize(fieldType.toLowerCase()) : "";
95
+ if (typeof fieldType !== "string") {
96
+ return "";
97
+ }
98
+ return capitalize(fieldType.toLowerCase());
96
99
  });
97
100
 
98
101
  const coordinates = computed<number[] | undefined>(() => {
@@ -114,7 +117,10 @@ function formatAttributeValue(val: unknown): string {
114
117
  return `[ ${formattedValues.join(", ")} ]`;
115
118
  }
116
119
  if (typeof val === "number") {
117
- return Number.isInteger(val) ? String(val) : Number(val).toFixed(4);
120
+ if (Number.isInteger(val)) {
121
+ return String(val);
122
+ }
123
+ return Number(val).toFixed(4);
118
124
  }
119
125
  return val;
120
126
  }