@geode/opengeodeweb-front 10.44.0-rc.7 → 10.44.0-rc.9

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 (32) hide show
  1. package/.build/server/utils/scripts.js +34 -23
  2. package/app/components/MissingFilesSelector.vue +30 -17
  3. package/app/components/ObjectSelector.vue +34 -23
  4. package/app/composables/hover_highlight.ts +13 -13
  5. package/app/composables/overlapping_picker_menu.ts +43 -0
  6. package/app/composables/project_manager_helpers/restore.ts +20 -11
  7. package/app/composables/use_overlapping_picker.ts +23 -37
  8. package/app/composables/virtual_tree_flatten.ts +66 -43
  9. package/app/stores/app_helpers/extension.ts +90 -51
  10. package/app/stores/infra.ts +26 -21
  11. package/app/utils/color_picker.ts +18 -15
  12. package/internal/database/database.ts +47 -32
  13. package/internal/stores/data_style/mesh/base_style.ts +74 -0
  14. package/internal/stores/data_style/mesh/index.ts +2 -57
  15. package/internal/stores/data_style/model/blocks/color.ts +58 -57
  16. package/internal/stores/data_style/model/blocks/polyhedron.ts +88 -44
  17. package/internal/stores/data_style/model/blocks/vertex.ts +88 -44
  18. package/internal/stores/data_style/model/color.ts +25 -26
  19. package/internal/stores/data_style/model/corners/index.ts +85 -78
  20. package/internal/stores/data_style/model/corners/vertex.ts +83 -39
  21. package/internal/stores/data_style/model/lines/color.ts +53 -40
  22. package/internal/stores/data_style/model/lines/edge.ts +88 -44
  23. package/internal/stores/data_style/model/lines/vertex.ts +88 -44
  24. package/internal/stores/data_style/model/surfaces/color.ts +68 -56
  25. package/internal/stores/data_style/model/surfaces/polygon.ts +80 -36
  26. package/internal/stores/data_style/model/surfaces/vertex.ts +80 -36
  27. package/internal/stores/data_style/model/visibility_dispatch.ts +49 -99
  28. package/internal/stores/hybrid_viewer/highlight.ts +70 -54
  29. package/internal/stores/hybrid_viewer/scene.ts +31 -25
  30. package/package.json +1 -1
  31. package/server/api/local/extensions/upload.put.ts +47 -20
  32. package/server/utils/scripts.ts +35 -30
@@ -40,33 +40,60 @@ function requiredQueryInt(event: H3Event, key: string): number {
40
40
  return parsed;
41
41
  }
42
42
 
43
+ interface UploadQuery {
44
+ projectName: string;
45
+ filename: string;
46
+ totalChunks: number;
47
+ chunkIndex: number;
48
+ }
49
+
50
+ function parseUploadQuery(event: H3Event): UploadQuery {
51
+ const projectName = requiredQueryString(event, "projectName");
52
+ const filename = requiredQueryString(event, "filename");
53
+ const totalChunks = requiredQueryInt(event, "total_chunks");
54
+ const chunkIndex = requiredQueryInt(event, "chunk_index");
55
+ if (chunkIndex >= totalChunks) {
56
+ throw createError({ statusCode: 400, message: "chunk_index must be less than total_chunks" });
57
+ }
58
+ return { projectName, filename, totalChunks, chunkIndex };
59
+ }
60
+
61
+ function requiredBodyStream(event: H3Event): ReadableStream<unknown> {
62
+ const webStream = getRequestWebStream(event);
63
+ if (!webStream) {
64
+ throw createError({ statusCode: 400, message: "No request body received" });
65
+ }
66
+ return webStream;
67
+ }
68
+
69
+ async function writeChunk(
70
+ webStream: ReadableStream<unknown>,
71
+ partPath: string,
72
+ chunkIndex: number,
73
+ ): Promise<void> {
74
+ const writeStream = fs.createWriteStream(partPath, { flags: chunkIndex === 0 ? "w" : "a" });
75
+ await pipeline(Readable.fromWeb(toNodeWebStream(webStream)), writeStream);
76
+ }
77
+
78
+ async function enforceSizeLimit(partPath: string): Promise<void> {
79
+ const { size } = await fs.promises.stat(partPath);
80
+ if (size > FILE_SIZE_LIMIT) {
81
+ await fs.promises.unlink(partPath);
82
+ throw createError({ statusCode: 400, message: "File too large" });
83
+ }
84
+ }
85
+
43
86
  // The file is sent as a raw (non-multipart) body, split into sequential chunks the client uploads in order (see OpenGeodeWeb-Front's upload_file.ts and OpenGeodeWeb-Back's upload_file route, which use the same protocol). Each chunk is appended to a `.part` file; the last one triggers the existing zip-metadata registration.
44
87
  export default defineRawEventHandler(
45
88
  schemas.api.local.extensions.upload,
46
89
  async (event: H3Event): Promise<LocalExtensionsUploadResponse> => {
47
- const projectName = requiredQueryString(event, "projectName");
48
- const filename = requiredQueryString(event, "filename");
49
- const totalChunks = requiredQueryInt(event, "total_chunks");
50
- const chunkIndex = requiredQueryInt(event, "chunk_index");
51
- if (chunkIndex >= totalChunks) {
52
- throw createError({ statusCode: 400, message: "chunk_index must be less than total_chunks" });
53
- }
54
-
55
- const webStream = getRequestWebStream(event);
56
- if (!webStream) {
57
- throw createError({ statusCode: 400, message: "No request body received" });
58
- }
90
+ const { projectName, filename, totalChunks, chunkIndex } = parseUploadQuery(event);
91
+ const webStream = requiredBodyStream(event);
59
92
 
60
93
  const targetPath = targetExtensionFilePath(projectName, filename);
61
94
  const partPath = `${targetPath}.part`;
62
- const writeStream = fs.createWriteStream(partPath, { flags: chunkIndex === 0 ? "w" : "a" });
63
- await pipeline(Readable.fromWeb(toNodeWebStream(webStream)), writeStream);
64
-
65
- const { size } = await fs.promises.stat(partPath);
66
- if (size > FILE_SIZE_LIMIT) {
67
- await fs.promises.unlink(partPath);
68
- throw createError({ statusCode: 400, message: "File too large" });
69
- }
95
+ await writeChunk(webStream, partPath, chunkIndex);
96
+ await enforceSizeLimit(partPath);
70
97
 
71
98
  if (chunkIndex < totalChunks - 1) {
72
99
  return { statusCode: CODE_200 };
@@ -43,6 +43,36 @@ interface NamedChildProcess extends child_process.ChildProcessByStdio<null, Read
43
43
  name?: string;
44
44
  }
45
45
 
46
+ function truncateLine(lineOutput: string): string {
47
+ const halfBuffer = MAX_ERROR_BUFFER_BYTES / 2;
48
+ return byteLength(lineOutput) > halfBuffer
49
+ ? `${lineOutput.slice(0, halfBuffer)}…[truncated]`
50
+ : lineOutput;
51
+ }
52
+
53
+ function trimOutputBuffer(output: string): string {
54
+ let trimmed = output;
55
+ while (byteLength(trimmed) > MAX_ERROR_BUFFER_BYTES) {
56
+ const newline = trimmed.indexOf("\n");
57
+ if (newline === -1) {
58
+ return "";
59
+ }
60
+ trimmed = trimmed.slice(newline + 1);
61
+ }
62
+ return trimmed;
63
+ }
64
+
65
+ function createOutputRecorder(): { record: (lineOutput: string) => void; read: () => string } {
66
+ let recentOutput = "";
67
+ function record(lineOutput: string): void {
68
+ recentOutput = trimOutputBuffer(`${recentOutput} ${truncateLine(lineOutput)}\n`);
69
+ }
70
+ function read(): string {
71
+ return recentOutput;
72
+ }
73
+ return { record, read };
74
+ }
75
+
46
76
  // oxlint-disable-next-line max-lines-per-function typescript/prefer-readonly-parameter-types eslint/require-await
47
77
  async function waitForReady(
48
78
  child: NamedChildProcess,
@@ -57,24 +87,8 @@ async function waitForReady(
57
87
  const readlineStderr = readline.createInterface({
58
88
  input: child.stderr,
59
89
  });
60
- let recentOutput = "";
61
- function recordOutput(lineOutput: string): void {
62
- const safeLine =
63
- byteLength(lineOutput) > MAX_ERROR_BUFFER_BYTES / 2
64
- ? `${lineOutput.slice(0, MAX_ERROR_BUFFER_BYTES / 2)}…[truncated]`
65
- : lineOutput;
66
- recentOutput = `${recentOutput} ${safeLine}\n`;
67
- while (byteLength(recentOutput) > MAX_ERROR_BUFFER_BYTES) {
68
- const newline = recentOutput.indexOf("\n");
69
- if (newline === -1) {
70
- recentOutput = "";
71
- break;
72
- }
73
- recentOutput = recentOutput.slice(newline + 1);
74
- }
75
- }
90
+ const recorder = createOutputRecorder();
76
91
  let onLine: ((line: string) => void) | undefined = undefined;
77
- let onErrLine: ((line: string) => void) | undefined = undefined;
78
92
  let onError: ((err: Error) => void) | undefined = undefined;
79
93
  let onClose: ((code: number | null) => void) | undefined = undefined;
80
94
  let onAbort: (() => void) | undefined = undefined;
@@ -82,9 +96,7 @@ async function waitForReady(
82
96
  function cleanup(): void {
83
97
  if (onLine) {
84
98
  readlineStdout.removeListener("line", onLine);
85
- }
86
- if (onErrLine) {
87
- readlineStderr.removeListener("line", onErrLine);
99
+ readlineStderr.removeListener("line", onLine);
88
100
  }
89
101
  if (onError) {
90
102
  child.removeListener("error", onError);
@@ -113,20 +125,12 @@ async function waitForReady(
113
125
 
114
126
  onLine = (lineOutput): void => {
115
127
  consola.info(`[${child.name}] ${lineOutput}`);
116
- recordOutput(lineOutput);
128
+ recorder.record(lineOutput);
117
129
  if (lineOutput.includes(expectedResponse)) {
118
130
  becomeReady();
119
131
  }
120
132
  };
121
133
 
122
- onErrLine = (line): void => {
123
- consola.info(`[${child.name}] ${line}`);
124
- recordOutput(line);
125
- if (line.includes(expectedResponse)) {
126
- becomeReady();
127
- }
128
- };
129
-
130
134
  onError = (err): void => {
131
135
  cleanup();
132
136
  reject(err);
@@ -135,6 +139,7 @@ async function waitForReady(
135
139
  onClose = (code): void => {
136
140
  consola.info(`[${child.name}] exited with code ${code}`);
137
141
  cleanup();
142
+ const recentOutput = recorder.read();
138
143
  reject(
139
144
  new Error(
140
145
  `[${child.name}] exited with code ${code} before becoming ready.${recentOutput ? `\nRecent output:\n${recentOutput}` : ""}`,
@@ -147,7 +152,7 @@ async function waitForReady(
147
152
  reject(new Error(`[${child.name}] timed out waiting for "${expectedResponse}"`));
148
153
  };
149
154
  readlineStdout.on("line", onLine);
150
- readlineStderr.on("line", onErrLine);
155
+ readlineStderr.on("line", onLine);
151
156
  child.once("error", onError);
152
157
  child.once("close", onClose);
153
158
  if (signal) {