fluidcad 0.0.28 → 0.0.30
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/lib/dist/common/profiler.d.ts +12 -0
- package/lib/dist/common/profiler.js +35 -0
- package/lib/dist/common/scene-object.d.ts +3 -0
- package/lib/dist/common/scene-object.js +3 -0
- package/lib/dist/common/shape-history-tracker.d.ts +9 -1
- package/lib/dist/common/shape-history-tracker.js +37 -23
- package/lib/dist/core/2d/aline.d.ts +13 -13
- package/lib/dist/core/2d/aline.js +20 -11
- package/lib/dist/core/2d/arc.d.ts +6 -6
- package/lib/dist/core/2d/arc.js +19 -15
- package/lib/dist/core/2d/back.d.ts +12 -0
- package/lib/dist/core/2d/back.js +11 -0
- package/lib/dist/core/2d/circle.d.ts +2 -2
- package/lib/dist/core/2d/circle.js +14 -10
- package/lib/dist/core/2d/ellipse.d.ts +35 -0
- package/lib/dist/core/2d/ellipse.js +65 -0
- package/lib/dist/core/2d/hline.d.ts +20 -13
- package/lib/dist/core/2d/hline.js +33 -15
- package/lib/dist/core/2d/index.d.ts +2 -0
- package/lib/dist/core/2d/index.js +2 -0
- package/lib/dist/core/2d/intersect.d.ts +2 -2
- package/lib/dist/core/2d/intersect.js +7 -3
- package/lib/dist/core/2d/line.d.ts +2 -2
- package/lib/dist/core/2d/line.js +14 -10
- package/lib/dist/core/2d/offset.d.ts +4 -4
- package/lib/dist/core/2d/offset.js +9 -5
- package/lib/dist/core/2d/polygon.d.ts +4 -4
- package/lib/dist/core/2d/polygon.js +24 -20
- package/lib/dist/core/2d/project.d.ts +2 -2
- package/lib/dist/core/2d/project.js +7 -3
- package/lib/dist/core/2d/rect.d.ts +2 -2
- package/lib/dist/core/2d/rect.js +22 -21
- package/lib/dist/core/2d/slot.d.ts +6 -6
- package/lib/dist/core/2d/slot.js +29 -32
- package/lib/dist/core/2d/vline.d.ts +20 -13
- package/lib/dist/core/2d/vline.js +29 -15
- package/lib/dist/core/interfaces.d.ts +62 -0
- package/lib/dist/core/mirror.d.ts +7 -7
- package/lib/dist/core/mirror.js +17 -11
- package/lib/dist/core/part.d.ts +3 -1
- package/lib/dist/core/part.js +1 -1
- package/lib/dist/core/rotate.d.ts +5 -5
- package/lib/dist/core/rotate.js +4 -1
- package/lib/dist/core/sketch.d.ts +3 -1
- package/lib/dist/core/sketch.js +1 -1
- package/lib/dist/core/translate.d.ts +9 -9
- package/lib/dist/features/2d/aline.d.ts +8 -5
- package/lib/dist/features/2d/aline.js +70 -18
- package/lib/dist/features/2d/back.d.ts +14 -0
- package/lib/dist/features/2d/back.js +35 -0
- package/lib/dist/features/2d/ellipse.d.ts +23 -0
- package/lib/dist/features/2d/ellipse.js +75 -0
- package/lib/dist/features/2d/hline.d.ts +9 -4
- package/lib/dist/features/2d/hline.js +65 -14
- package/lib/dist/features/2d/offset.d.ts +3 -0
- package/lib/dist/features/2d/offset.js +27 -3
- package/lib/dist/features/2d/sketch.d.ts +1 -0
- package/lib/dist/features/2d/sketch.js +15 -0
- package/lib/dist/features/2d/vline.d.ts +9 -4
- package/lib/dist/features/2d/vline.js +67 -15
- package/lib/dist/features/common.js +2 -1
- package/lib/dist/features/extrude-base.d.ts +19 -1
- package/lib/dist/features/extrude-base.js +75 -12
- package/lib/dist/features/extrude-two-distances.js +32 -27
- package/lib/dist/features/extrude.d.ts +39 -0
- package/lib/dist/features/extrude.js +196 -156
- package/lib/dist/features/fuse.js +2 -1
- package/lib/dist/features/lazy-scene-object.d.ts +1 -0
- package/lib/dist/features/lazy-scene-object.js +3 -0
- package/lib/dist/features/lazy-vertex.d.ts +1 -0
- package/lib/dist/features/lazy-vertex.js +3 -0
- package/lib/dist/features/loft.js +11 -8
- package/lib/dist/features/mirror-shape.d.ts +2 -0
- package/lib/dist/features/mirror-shape.js +16 -0
- package/lib/dist/features/mirror-shape2d.d.ts +2 -0
- package/lib/dist/features/mirror-shape2d.js +22 -1
- package/lib/dist/features/revolve.d.ts +31 -0
- package/lib/dist/features/revolve.js +178 -95
- package/lib/dist/features/rotate.d.ts +2 -0
- package/lib/dist/features/rotate.js +16 -0
- package/lib/dist/features/rotate2d.d.ts +2 -0
- package/lib/dist/features/rotate2d.js +16 -0
- package/lib/dist/features/select.js +2 -1
- package/lib/dist/features/simple-extruder.d.ts +3 -1
- package/lib/dist/features/simple-extruder.js +13 -9
- package/lib/dist/features/subtract.d.ts +2 -2
- package/lib/dist/features/subtract.js +3 -3
- package/lib/dist/features/sweep.d.ts +14 -0
- package/lib/dist/features/sweep.js +93 -80
- package/lib/dist/features/translate.d.ts +2 -0
- package/lib/dist/features/translate.js +23 -2
- package/lib/dist/filters/edge/edge-filter.d.ts +6 -0
- package/lib/dist/filters/edge/edge-filter.js +11 -0
- package/lib/dist/filters/face/face-filter.d.ts +6 -0
- package/lib/dist/filters/face/face-filter.js +11 -0
- package/lib/dist/filters/filter-base.d.ts +7 -1
- package/lib/dist/filters/filter-base.js +8 -0
- package/lib/dist/filters/filter-builder-base.js +11 -0
- package/lib/dist/filters/from-object.d.ts +14 -0
- package/lib/dist/filters/from-object.js +40 -0
- package/lib/dist/helpers/scene-helpers.d.ts +2 -0
- package/lib/dist/helpers/scene-helpers.js +68 -48
- package/lib/dist/oc/color-transfer.js +6 -0
- package/lib/dist/oc/edge-ops.d.ts +1 -0
- package/lib/dist/oc/edge-ops.js +17 -0
- package/lib/dist/oc/extrude-ops.d.ts +18 -1
- package/lib/dist/oc/extrude-ops.js +34 -1
- package/lib/dist/oc/geometry.d.ts +1 -0
- package/lib/dist/oc/geometry.js +27 -0
- package/lib/dist/oc/mesh.js +11 -9
- package/lib/dist/oc/ray-intersect.d.ts +16 -0
- package/lib/dist/oc/ray-intersect.js +91 -0
- package/lib/dist/oc/thin-face-maker.d.ts +0 -1
- package/lib/dist/oc/thin-face-maker.js +2 -20
- package/lib/dist/rendering/render.d.ts +2 -1
- package/lib/dist/rendering/render.js +72 -33
- package/lib/dist/rendering/scene.d.ts +4 -0
- package/lib/dist/tests/features/2d/back.test.d.ts +1 -0
- package/lib/dist/tests/features/2d/back.test.js +60 -0
- package/lib/dist/tests/features/2d/circle.test.js +1 -1
- package/lib/dist/tests/features/2d/constrained.test.js +4 -4
- package/lib/dist/tests/features/2d/ellipse.test.d.ts +1 -0
- package/lib/dist/tests/features/2d/ellipse.test.js +100 -0
- package/lib/dist/tests/features/2d/line.test.js +89 -3
- package/lib/dist/tests/features/2d/offset.test.js +1 -1
- package/lib/dist/tests/features/2d/polygon.test.js +2 -2
- package/lib/dist/tests/features/2d/rect.test.js +1 -1
- package/lib/dist/tests/features/2d/slot-from-edge.test.js +1 -1
- package/lib/dist/tests/features/2d/slot.test.js +1 -1
- package/lib/dist/tests/features/mirror.test.js +58 -0
- package/lib/dist/tests/features/mirror2d.test.js +63 -0
- package/lib/dist/tests/features/rotate.test.js +62 -0
- package/lib/dist/tests/features/rotate2d.test.js +47 -0
- package/lib/dist/tests/features/thin-revolve.test.js +37 -1
- package/lib/dist/tests/features/translate.test.js +63 -0
- package/lib/dist/tests/perf/record-fusion-history.bench.test.d.ts +1 -0
- package/lib/dist/tests/perf/record-fusion-history.bench.test.js +77 -0
- package/lib/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/server/dist/index.js +77 -45
- package/server/dist/ws-protocol.d.ts +11 -0
- package/ui/dist/assets/{index-BrW_x4uc.js → index-6Ep4GPxf.js} +131 -77
- package/ui/dist/assets/index-DRKfe6N9.css +2 -0
- package/ui/dist/index.html +2 -2
- package/ui/dist/assets/index-gPoNOiIs.css +0 -2
package/package.json
CHANGED
package/server/dist/index.js
CHANGED
|
@@ -10,6 +10,7 @@ import { createExportRouter } from "./routes/export.js";
|
|
|
10
10
|
import { createScreenshotRouter } from "./routes/screenshot.js";
|
|
11
11
|
import { createPreferencesRouter } from "./routes/preferences.js";
|
|
12
12
|
import { normalizePath } from "./normalize-path.js";
|
|
13
|
+
import { extractSourceLocation } from '../../lib/dist/index.js';
|
|
13
14
|
const PORT = parseInt(process.env.FLUIDCAD_SERVER_PORT || '3100', 10);
|
|
14
15
|
const WORKSPACE_PATH = normalizePath(process.env.FLUIDCAD_WORKSPACE_PATH || '');
|
|
15
16
|
const UI_DIST = path.resolve(import.meta.dirname, '../../ui/dist');
|
|
@@ -142,6 +143,62 @@ wss.on('connection', (ws) => {
|
|
|
142
143
|
// ---------------------------------------------------------------------------
|
|
143
144
|
let currentFile = null;
|
|
144
145
|
let renderVersion = 0;
|
|
146
|
+
const lastSceneByFile = new Map();
|
|
147
|
+
function emitSuccess(absPath, result, rollbackStop, breakpointHit) {
|
|
148
|
+
lastSceneByFile.set(absPath, { result, rollbackStop });
|
|
149
|
+
sendToExtension({
|
|
150
|
+
type: 'scene-rendered',
|
|
151
|
+
absPath,
|
|
152
|
+
result,
|
|
153
|
+
rollbackStop,
|
|
154
|
+
});
|
|
155
|
+
broadcastToUI({
|
|
156
|
+
type: 'scene-rendered',
|
|
157
|
+
result,
|
|
158
|
+
absPath,
|
|
159
|
+
rollbackStop,
|
|
160
|
+
breakpointHit,
|
|
161
|
+
});
|
|
162
|
+
}
|
|
163
|
+
function buildCompileError(filePath, err) {
|
|
164
|
+
const message = err?.message || String(err);
|
|
165
|
+
const stack = typeof err?.stack === 'string' ? err.stack : '';
|
|
166
|
+
let sourceLocation = stack ? extractSourceLocation(stack) : null;
|
|
167
|
+
const normalized = normalizePath(filePath).replace('virtual:live-render:', '');
|
|
168
|
+
if (sourceLocation) {
|
|
169
|
+
sourceLocation = {
|
|
170
|
+
filePath: sourceLocation.filePath.replace('virtual:live-render:', ''),
|
|
171
|
+
line: sourceLocation.line,
|
|
172
|
+
column: sourceLocation.column,
|
|
173
|
+
};
|
|
174
|
+
}
|
|
175
|
+
return {
|
|
176
|
+
message,
|
|
177
|
+
filePath: normalized,
|
|
178
|
+
sourceLocation: sourceLocation ?? undefined,
|
|
179
|
+
};
|
|
180
|
+
}
|
|
181
|
+
function emitCompileError(filePath, err) {
|
|
182
|
+
const compileError = buildCompileError(filePath, err);
|
|
183
|
+
const key = compileError.filePath ?? normalizePath(filePath).replace('virtual:live-render:', '');
|
|
184
|
+
const prev = lastSceneByFile.get(key);
|
|
185
|
+
const result = prev?.result ?? [];
|
|
186
|
+
const rollbackStop = prev?.rollbackStop ?? -1;
|
|
187
|
+
sendToExtension({
|
|
188
|
+
type: 'scene-rendered',
|
|
189
|
+
absPath: key,
|
|
190
|
+
result,
|
|
191
|
+
rollbackStop,
|
|
192
|
+
compileError,
|
|
193
|
+
});
|
|
194
|
+
broadcastToUI({
|
|
195
|
+
type: 'scene-rendered',
|
|
196
|
+
result,
|
|
197
|
+
absPath: key,
|
|
198
|
+
rollbackStop,
|
|
199
|
+
compileError,
|
|
200
|
+
});
|
|
201
|
+
}
|
|
145
202
|
async function handleExtensionMessage(msg) {
|
|
146
203
|
try {
|
|
147
204
|
switch (msg.type) {
|
|
@@ -149,23 +206,20 @@ async function handleExtensionMessage(msg) {
|
|
|
149
206
|
const myVersion = ++renderVersion;
|
|
150
207
|
broadcastToUI({ type: 'processing-file' });
|
|
151
208
|
currentFile = msg.filePath;
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
209
|
+
try {
|
|
210
|
+
const data = await fluidCadServer.processFile(msg.filePath);
|
|
211
|
+
if (myVersion !== renderVersion) {
|
|
212
|
+
return;
|
|
213
|
+
}
|
|
214
|
+
if (data) {
|
|
215
|
+
emitSuccess(data.absPath, data.result, data.rollbackStop, data.breakpointHit);
|
|
216
|
+
}
|
|
155
217
|
}
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
rollbackStop: data.rollbackStop,
|
|
162
|
-
});
|
|
163
|
-
broadcastToUI({
|
|
164
|
-
type: 'scene-rendered',
|
|
165
|
-
result: data.result,
|
|
166
|
-
absPath: data.absPath,
|
|
167
|
-
breakpointHit: data.breakpointHit,
|
|
168
|
-
});
|
|
218
|
+
catch (err) {
|
|
219
|
+
if (myVersion !== renderVersion) {
|
|
220
|
+
return;
|
|
221
|
+
}
|
|
222
|
+
emitCompileError(msg.filePath, err);
|
|
169
223
|
}
|
|
170
224
|
break;
|
|
171
225
|
}
|
|
@@ -181,25 +235,14 @@ async function handleExtensionMessage(msg) {
|
|
|
181
235
|
return;
|
|
182
236
|
}
|
|
183
237
|
if (data) {
|
|
184
|
-
|
|
185
|
-
type: 'scene-rendered',
|
|
186
|
-
absPath: data.absPath,
|
|
187
|
-
result: data.result,
|
|
188
|
-
rollbackStop: data.rollbackStop,
|
|
189
|
-
});
|
|
190
|
-
broadcastToUI({
|
|
191
|
-
type: 'scene-rendered',
|
|
192
|
-
result: data.result,
|
|
193
|
-
absPath: data.absPath,
|
|
194
|
-
breakpointHit: data.breakpointHit,
|
|
195
|
-
});
|
|
238
|
+
emitSuccess(data.absPath, data.result, data.rollbackStop, data.breakpointHit);
|
|
196
239
|
}
|
|
197
240
|
}
|
|
198
|
-
catch {
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
241
|
+
catch (err) {
|
|
242
|
+
if (myVersion !== renderVersion) {
|
|
243
|
+
return;
|
|
244
|
+
}
|
|
245
|
+
emitCompileError(msg.fileName, err);
|
|
203
246
|
}
|
|
204
247
|
break;
|
|
205
248
|
}
|
|
@@ -210,18 +253,7 @@ async function handleExtensionMessage(msg) {
|
|
|
210
253
|
return;
|
|
211
254
|
}
|
|
212
255
|
if (data) {
|
|
213
|
-
|
|
214
|
-
type: 'scene-rendered',
|
|
215
|
-
absPath: data.absPath,
|
|
216
|
-
result: data.result,
|
|
217
|
-
rollbackStop: data.rollbackStop,
|
|
218
|
-
});
|
|
219
|
-
broadcastToUI({
|
|
220
|
-
type: 'scene-rendered',
|
|
221
|
-
result: data.result,
|
|
222
|
-
absPath: data.absPath,
|
|
223
|
-
rollbackStop: data.rollbackStop,
|
|
224
|
-
});
|
|
256
|
+
emitSuccess(data.absPath, data.result, data.rollbackStop);
|
|
225
257
|
}
|
|
226
258
|
break;
|
|
227
259
|
}
|
|
@@ -51,11 +51,21 @@ export type InitCompleteMessage = {
|
|
|
51
51
|
success: boolean;
|
|
52
52
|
error?: string;
|
|
53
53
|
};
|
|
54
|
+
export type CompileError = {
|
|
55
|
+
message: string;
|
|
56
|
+
filePath?: string;
|
|
57
|
+
sourceLocation?: {
|
|
58
|
+
filePath: string;
|
|
59
|
+
line: number;
|
|
60
|
+
column: number;
|
|
61
|
+
};
|
|
62
|
+
};
|
|
54
63
|
export type SceneRenderedMessage = {
|
|
55
64
|
type: 'scene-rendered';
|
|
56
65
|
absPath: string;
|
|
57
66
|
result: any[];
|
|
58
67
|
rollbackStop: number;
|
|
68
|
+
compileError?: CompileError;
|
|
59
69
|
};
|
|
60
70
|
export type ErrorMessage = {
|
|
61
71
|
type: 'error';
|
|
@@ -131,6 +141,7 @@ export type UISceneRenderedMessage = {
|
|
|
131
141
|
absPath: string;
|
|
132
142
|
rollbackStop?: number;
|
|
133
143
|
breakpointHit?: boolean;
|
|
144
|
+
compileError?: CompileError;
|
|
134
145
|
};
|
|
135
146
|
export type UIHighlightShapeMessage = {
|
|
136
147
|
type: 'highlight-shape';
|