fluidcad 0.0.33 → 0.0.34
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/README.md +3 -2
- package/bin/commands/init.js +55 -0
- package/bin/commands/mcp.js +33 -0
- package/bin/commands/serve.js +77 -0
- package/bin/fluidcad.js +15 -107
- package/lib/dist/common/scene-object.d.ts +2 -1
- package/lib/dist/common/scene-object.js +3 -2
- package/lib/dist/core/2d/tarc.d.ts +20 -2
- package/lib/dist/core/2d/tarc.js +24 -0
- package/lib/dist/core/interfaces.d.ts +31 -2
- package/lib/dist/core/repeat.js +62 -46
- package/lib/dist/features/2d/arc.d.ts +8 -2
- package/lib/dist/features/2d/arc.js +94 -17
- package/lib/dist/features/2d/back.js +3 -2
- package/lib/dist/features/2d/sketch.d.ts +4 -0
- package/lib/dist/features/2d/sketch.js +21 -0
- package/lib/dist/features/2d/tarc-constrained.d.ts +2 -0
- package/lib/dist/features/2d/tarc-constrained.js +8 -0
- package/lib/dist/features/2d/tarc-radius-to-object.d.ts +16 -0
- package/lib/dist/features/2d/tarc-radius-to-object.js +58 -0
- package/lib/dist/features/2d/tarc-to-object.d.ts +18 -0
- package/lib/dist/features/2d/tarc-to-object.js +66 -0
- package/lib/dist/features/2d/tarc-to-point-tangent.d.ts +2 -0
- package/lib/dist/features/2d/tarc-to-point-tangent.js +3 -0
- package/lib/dist/features/2d/tarc-to-point.d.ts +2 -0
- package/lib/dist/features/2d/tarc-to-point.js +3 -0
- package/lib/dist/features/2d/tarc-with-tangent.d.ts +2 -0
- package/lib/dist/features/2d/tarc-with-tangent.js +3 -0
- package/lib/dist/features/2d/tarc.d.ts +2 -0
- package/lib/dist/features/2d/tarc.js +3 -0
- package/lib/dist/features/extrude-base.d.ts +9 -0
- package/lib/dist/features/extrude-base.js +22 -0
- package/lib/dist/features/extrude-to-face.js +1 -5
- package/lib/dist/features/extrude-two-distances.js +1 -2
- package/lib/dist/features/extrude.js +1 -2
- package/lib/dist/features/mirror-feature.d.ts +3 -2
- package/lib/dist/features/mirror-feature.js +1 -1
- package/lib/dist/features/repeat-circular.d.ts +3 -3
- package/lib/dist/features/repeat-circular.js +8 -1
- package/lib/dist/features/repeat-linear.d.ts +4 -2
- package/lib/dist/features/repeat-linear.js +10 -1
- package/lib/dist/features/repeat-matrix.d.ts +3 -1
- package/lib/dist/features/repeat-matrix.js +7 -2
- package/lib/dist/features/shell.d.ts +4 -1
- package/lib/dist/features/shell.js +14 -3
- package/lib/dist/helpers/clone-transform.d.ts +2 -1
- package/lib/dist/index.d.ts +7 -1
- package/lib/dist/index.js +3 -3
- package/lib/dist/math/lazy-matrix.d.ts +31 -0
- package/lib/dist/math/lazy-matrix.js +66 -0
- package/lib/dist/oc/constraints/constraint-solver-adaptor.d.ts +5 -0
- package/lib/dist/oc/constraints/constraint-solver-adaptor.js +16 -0
- package/lib/dist/oc/constraints/constraint-solver.d.ts +4 -0
- package/lib/dist/oc/constraints/curve/curve-constraint-solver.d.ts +4 -0
- package/lib/dist/oc/constraints/curve/curve-constraint-solver.js +3 -0
- package/lib/dist/oc/constraints/geometric/geometric-constraint-solver.d.ts +6 -1
- package/lib/dist/oc/constraints/geometric/geometric-constraint-solver.js +4 -0
- package/lib/dist/oc/constraints/geometric/tangent-arc-from-point-tangent.d.ts +8 -0
- package/lib/dist/oc/constraints/geometric/tangent-arc-from-point-tangent.js +111 -0
- package/lib/dist/oc/constraints/geometric/tangent-arc-radius-to-object.d.ts +8 -0
- package/lib/dist/oc/constraints/geometric/tangent-arc-radius-to-object.js +161 -0
- package/lib/dist/oc/mesh.d.ts +9 -4
- package/lib/dist/oc/mesh.js +14 -13
- package/lib/dist/oc/shell-ops.d.ts +2 -1
- package/lib/dist/oc/shell-ops.js +5 -2
- package/lib/dist/rendering/mesh-builder.d.ts +3 -0
- package/lib/dist/rendering/mesh-builder.js +8 -4
- package/lib/dist/rendering/render-edge.d.ts +2 -1
- package/lib/dist/rendering/render-edge.js +2 -2
- package/lib/dist/rendering/render-face.d.ts +2 -1
- package/lib/dist/rendering/render-face.js +2 -2
- package/lib/dist/rendering/render-solid.d.ts +2 -1
- package/lib/dist/rendering/render-solid.js +2 -2
- package/lib/dist/rendering/render-wire.d.ts +2 -1
- package/lib/dist/rendering/render-wire.js +2 -2
- package/lib/dist/rendering/render.d.ts +3 -0
- package/lib/dist/rendering/render.js +7 -2
- package/lib/dist/scene-manager.d.ts +4 -2
- package/lib/dist/scene-manager.js +12 -4
- package/lib/dist/tests/features/2d/arc.test.js +64 -0
- package/lib/dist/tests/features/2d/back.test.js +17 -1
- package/lib/dist/tests/features/2d/tarc.test.js +157 -0
- package/lib/dist/tests/features/repeat-user-repro.test.d.ts +1 -0
- package/lib/dist/tests/features/repeat-user-repro.test.js +60 -0
- package/lib/dist/tests/features/shell.test.js +36 -0
- package/lib/dist/tests/global-setup.js +2 -1
- package/lib/dist/tests/helpers/extract-blocks.d.ts +9 -0
- package/lib/dist/tests/helpers/extract-blocks.js +56 -0
- package/lib/dist/tests/llm-docs-examples.test.d.ts +1 -0
- package/lib/dist/tests/llm-docs-examples.test.js +62 -0
- package/lib/dist/tests/setup.js +2 -1
- package/lib/dist/tsconfig.tsbuildinfo +1 -1
- package/llm-docs/.coverage-allowlist.txt +9 -0
- package/llm-docs/api/arc.md +48 -0
- package/llm-docs/api/axis.md +42 -0
- package/llm-docs/api/bezier.md +42 -0
- package/llm-docs/api/booleans.md +44 -0
- package/llm-docs/api/chamfer.md +40 -0
- package/llm-docs/api/circle.md +36 -0
- package/llm-docs/api/color.md +34 -0
- package/llm-docs/api/connect.md +41 -0
- package/llm-docs/api/constraint-qualifiers.md +48 -0
- package/llm-docs/api/copy.md +63 -0
- package/llm-docs/api/cursor-lines.md +50 -0
- package/llm-docs/api/cursor-move.md +61 -0
- package/llm-docs/api/cut.md +55 -0
- package/llm-docs/api/draft.md +36 -0
- package/llm-docs/api/edge-filter.md +57 -0
- package/llm-docs/api/ellipse.md +34 -0
- package/llm-docs/api/extrude.md +74 -0
- package/llm-docs/api/face-filter.md +61 -0
- package/llm-docs/api/fillet.md +51 -0
- package/llm-docs/api/index.json +139 -0
- package/llm-docs/api/line.md +42 -0
- package/llm-docs/api/load.md +37 -0
- package/llm-docs/api/local.md +38 -0
- package/llm-docs/api/loft.md +37 -0
- package/llm-docs/api/mirror.md +44 -0
- package/llm-docs/api/offset.md +36 -0
- package/llm-docs/api/part.md +40 -0
- package/llm-docs/api/plane.md +44 -0
- package/llm-docs/api/polygon.md +37 -0
- package/llm-docs/api/primitive-solids.md +39 -0
- package/llm-docs/api/project-intersect.md +48 -0
- package/llm-docs/api/rect.md +48 -0
- package/llm-docs/api/remove.md +32 -0
- package/llm-docs/api/repeat.md +79 -0
- package/llm-docs/api/revolve.md +38 -0
- package/llm-docs/api/rib.md +40 -0
- package/llm-docs/api/rotate.md +37 -0
- package/llm-docs/api/select.md +41 -0
- package/llm-docs/api/shell.md +41 -0
- package/llm-docs/api/sketch.md +76 -0
- package/llm-docs/api/slot.md +36 -0
- package/llm-docs/api/split-trim.md +42 -0
- package/llm-docs/api/sweep.md +43 -0
- package/llm-docs/api/tarc.md +45 -0
- package/llm-docs/api/tcircle.md +38 -0
- package/llm-docs/api/tline.md +42 -0
- package/llm-docs/api/translate.md +40 -0
- package/llm-docs/api/types/aline.md +35 -0
- package/llm-docs/api/types/arc-angles.md +29 -0
- package/llm-docs/api/types/arc-points.md +48 -0
- package/llm-docs/api/types/axis-like.md +38 -0
- package/llm-docs/api/types/axis.md +21 -0
- package/llm-docs/api/types/boolean-operation.md +50 -0
- package/llm-docs/api/types/circular-repeat-options.md +31 -0
- package/llm-docs/api/types/common.md +32 -0
- package/llm-docs/api/types/cut.md +125 -0
- package/llm-docs/api/types/draft.md +21 -0
- package/llm-docs/api/types/extrudable-geometry.md +23 -0
- package/llm-docs/api/types/extrude.md +194 -0
- package/llm-docs/api/types/geometry.md +51 -0
- package/llm-docs/api/types/hline.md +35 -0
- package/llm-docs/api/types/linear-repeat-options.md +31 -0
- package/llm-docs/api/types/loft.md +154 -0
- package/llm-docs/api/types/mirror.md +35 -0
- package/llm-docs/api/types/offset.md +31 -0
- package/llm-docs/api/types/plane-like.md +35 -0
- package/llm-docs/api/types/plane-transform-options.md +29 -0
- package/llm-docs/api/types/plane.md +21 -0
- package/llm-docs/api/types/point-like.md +22 -0
- package/llm-docs/api/types/point2dlike.md +26 -0
- package/llm-docs/api/types/polygon.md +46 -0
- package/llm-docs/api/types/rect.md +128 -0
- package/llm-docs/api/types/revolve.md +102 -0
- package/llm-docs/api/types/rib.md +133 -0
- package/llm-docs/api/types/scene-object.md +33 -0
- package/llm-docs/api/types/select.md +21 -0
- package/llm-docs/api/types/shell.md +54 -0
- package/llm-docs/api/types/slot.md +43 -0
- package/llm-docs/api/types/sweep.md +189 -0
- package/llm-docs/api/types/tangent-arc-two-objects.md +46 -0
- package/llm-docs/api/types/transformable.md +93 -0
- package/llm-docs/api/types/trim.md +27 -0
- package/llm-docs/api/types/two-objects-tangent-line.md +46 -0
- package/llm-docs/api/types/vertex.md +17 -0
- package/llm-docs/api/types/vline.md +35 -0
- package/llm-docs/concepts/coordinate-system.md +45 -0
- package/llm-docs/concepts/history-and-rollback.md +40 -0
- package/llm-docs/concepts/last-selection.md +49 -0
- package/llm-docs/concepts/scene-graph.md +37 -0
- package/llm-docs/index.json +1750 -0
- package/mcp/dist/client.d.ts +64 -0
- package/mcp/dist/client.js +248 -0
- package/mcp/dist/discovery.d.ts +11 -0
- package/mcp/dist/discovery.js +78 -0
- package/mcp/dist/docs-index.d.ts +81 -0
- package/mcp/dist/docs-index.js +261 -0
- package/mcp/dist/resources.d.ts +4 -0
- package/mcp/dist/resources.js +115 -0
- package/mcp/dist/server.d.ts +12 -0
- package/mcp/dist/server.js +489 -0
- package/mcp/dist/tools/coordination.d.ts +9 -0
- package/mcp/dist/tools/coordination.js +46 -0
- package/mcp/dist/tools/docs.d.ts +66 -0
- package/mcp/dist/tools/docs.js +122 -0
- package/mcp/dist/tools/engine.d.ts +56 -0
- package/mcp/dist/tools/engine.js +145 -0
- package/mcp/dist/tools/inspection.d.ts +75 -0
- package/mcp/dist/tools/inspection.js +121 -0
- package/mcp/dist/tools/screenshot.d.ts +63 -0
- package/mcp/dist/tools/screenshot.js +263 -0
- package/mcp/dist/tools/source.d.ts +84 -0
- package/mcp/dist/tools/source.js +434 -0
- package/mcp/dist/tools/workspaces.d.ts +13 -0
- package/mcp/dist/tools/workspaces.js +33 -0
- package/mcp/dist/types.d.ts +18 -0
- package/mcp/dist/types.js +11 -0
- package/package.json +19 -5
- package/server/dist/code-editor.d.ts +36 -0
- package/server/dist/code-editor.js +8 -0
- package/server/dist/fluidcad-server.d.ts +50 -0
- package/server/dist/fluidcad-server.js +153 -1
- package/server/dist/global-registry.d.ts +30 -0
- package/server/dist/global-registry.js +126 -0
- package/server/dist/index.js +171 -26
- package/server/dist/instance-file.d.ts +31 -0
- package/server/dist/instance-file.js +73 -0
- package/server/dist/lint-fluid-js.d.ts +15 -0
- package/server/dist/lint-fluid-js.js +271 -0
- package/server/dist/routes/editor.d.ts +24 -0
- package/server/dist/routes/editor.js +44 -0
- package/server/dist/routes/export.d.ts +1 -1
- package/server/dist/routes/export.js +45 -8
- package/server/dist/routes/health.d.ts +7 -0
- package/server/dist/routes/health.js +14 -0
- package/server/dist/routes/lint.d.ts +10 -0
- package/server/dist/routes/lint.js +28 -0
- package/server/dist/routes/render.d.ts +33 -0
- package/server/dist/routes/render.js +34 -0
- package/server/dist/routes/scene.d.ts +5 -0
- package/server/dist/routes/scene.js +48 -0
- package/server/dist/routes/screenshot.js +68 -1
- package/server/dist/ws-protocol.d.ts +56 -2
- package/ui/dist/assets/{index-CFi9p7wR.js → index-BdqrMDRu.js} +21 -21
- package/ui/dist/index.html +1 -1
|
@@ -1,8 +1,13 @@
|
|
|
1
1
|
import { Router } from 'express';
|
|
2
|
+
const NAMED_VIEWS = new Set([
|
|
3
|
+
'front', 'back', 'left', 'right', 'top', 'bottom',
|
|
4
|
+
'iso-ftr', 'iso-fbr', 'iso-ftl', 'iso-fbl',
|
|
5
|
+
'iso-btr', 'iso-bbr', 'iso-btl', 'iso-bbl',
|
|
6
|
+
]);
|
|
2
7
|
export function createScreenshotRouter(requestScreenshot) {
|
|
3
8
|
const router = Router();
|
|
4
9
|
router.post('/screenshot', async (req, res) => {
|
|
5
|
-
const { width, height, showGrid, showAxes, transparent, autoCrop, fitToModel, margin } = req.body;
|
|
10
|
+
const { width, height, showGrid, showAxes, transparent, autoCrop, fitToModel, margin, view, multi, } = req.body;
|
|
6
11
|
const options = {};
|
|
7
12
|
if (width !== undefined) {
|
|
8
13
|
if (typeof width !== 'number' || width < 1 || width > 8192) {
|
|
@@ -60,6 +65,21 @@ export function createScreenshotRouter(requestScreenshot) {
|
|
|
60
65
|
}
|
|
61
66
|
options.margin = margin;
|
|
62
67
|
}
|
|
68
|
+
if (multi !== undefined) {
|
|
69
|
+
if (typeof multi !== 'boolean') {
|
|
70
|
+
res.status(400).json({ error: 'multi must be a boolean.' });
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
options.multi = multi;
|
|
74
|
+
}
|
|
75
|
+
if (view !== undefined) {
|
|
76
|
+
const validated = validateView(view);
|
|
77
|
+
if (typeof validated === 'string') {
|
|
78
|
+
res.status(400).json({ error: validated });
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
options.view = validated;
|
|
82
|
+
}
|
|
63
83
|
try {
|
|
64
84
|
const png = await requestScreenshot(options);
|
|
65
85
|
res.setHeader('Content-Type', 'image/png');
|
|
@@ -74,3 +94,50 @@ export function createScreenshotRouter(requestScreenshot) {
|
|
|
74
94
|
});
|
|
75
95
|
return router;
|
|
76
96
|
}
|
|
97
|
+
/** Validate the `view` payload. Returns the parsed view on success or an
|
|
98
|
+
* error-message string on failure. */
|
|
99
|
+
function validateView(raw) {
|
|
100
|
+
if (raw === null || typeof raw !== 'object') {
|
|
101
|
+
return 'view must be an object.';
|
|
102
|
+
}
|
|
103
|
+
const v = raw;
|
|
104
|
+
switch (v.kind) {
|
|
105
|
+
case 'current':
|
|
106
|
+
return { kind: 'current' };
|
|
107
|
+
case 'named': {
|
|
108
|
+
if (typeof v.name !== 'string' || !NAMED_VIEWS.has(v.name)) {
|
|
109
|
+
return `view.name must be one of: ${Array.from(NAMED_VIEWS).join(', ')}.`;
|
|
110
|
+
}
|
|
111
|
+
return { kind: 'named', name: v.name };
|
|
112
|
+
}
|
|
113
|
+
case 'orbit-from-current': {
|
|
114
|
+
if (typeof v.azimuthDeg !== 'number' || !Number.isFinite(v.azimuthDeg)) {
|
|
115
|
+
return 'view.azimuthDeg must be a finite number.';
|
|
116
|
+
}
|
|
117
|
+
if (typeof v.elevationDeg !== 'number' || !Number.isFinite(v.elevationDeg)) {
|
|
118
|
+
return 'view.elevationDeg must be a finite number.';
|
|
119
|
+
}
|
|
120
|
+
return { kind: 'orbit-from-current', azimuthDeg: v.azimuthDeg, elevationDeg: v.elevationDeg };
|
|
121
|
+
}
|
|
122
|
+
case 'look-from': {
|
|
123
|
+
if (!isVec3(v.eye)) {
|
|
124
|
+
return 'view.eye must be a 3-element array of finite numbers.';
|
|
125
|
+
}
|
|
126
|
+
if (v.target !== undefined && !isVec3(v.target)) {
|
|
127
|
+
return 'view.target must be a 3-element array of finite numbers when provided.';
|
|
128
|
+
}
|
|
129
|
+
return {
|
|
130
|
+
kind: 'look-from',
|
|
131
|
+
eye: v.eye,
|
|
132
|
+
target: v.target,
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
default:
|
|
136
|
+
return `view.kind must be one of: current, named, orbit-from-current, look-from.`;
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
function isVec3(value) {
|
|
140
|
+
return (Array.isArray(value) &&
|
|
141
|
+
value.length === 3 &&
|
|
142
|
+
value.every((n) => typeof n === 'number' && Number.isFinite(n)));
|
|
143
|
+
}
|
|
@@ -40,7 +40,16 @@ export type ExportSceneMessage = {
|
|
|
40
40
|
customAngularDeflectionDeg?: number;
|
|
41
41
|
};
|
|
42
42
|
};
|
|
43
|
-
|
|
43
|
+
/**
|
|
44
|
+
* Sent by the editor extension whenever its dirty-buffer set changes. Paths
|
|
45
|
+
* are absolute and normalized to the same scheme the server uses elsewhere.
|
|
46
|
+
* Replaces the cached set on the server — not incremental.
|
|
47
|
+
*/
|
|
48
|
+
export type EditorDirtyStateMessage = {
|
|
49
|
+
type: 'editor-dirty-state';
|
|
50
|
+
dirtyFiles: string[];
|
|
51
|
+
};
|
|
52
|
+
export type ExtensionMessage = ProcessFileMessage | LiveUpdateMessage | RollbackMessage | ImportFileMessage | HighlightShapeMessage | ClearHighlightMessage | ShowShapePropertiesMessage | ExportSceneMessage | EditorDirtyStateMessage;
|
|
44
53
|
export type ReadyMessage = {
|
|
45
54
|
type: 'ready';
|
|
46
55
|
port: number;
|
|
@@ -162,6 +171,21 @@ export type UIInitCompleteMessage = {
|
|
|
162
171
|
export type UIProcessingFileMessage = {
|
|
163
172
|
type: 'processing-file';
|
|
164
173
|
};
|
|
174
|
+
export type NamedView = 'front' | 'back' | 'left' | 'right' | 'top' | 'bottom' | 'iso-ftr' | 'iso-fbr' | 'iso-ftl' | 'iso-fbl' | 'iso-btr' | 'iso-bbr' | 'iso-btl' | 'iso-bbl';
|
|
175
|
+
export type ScreenshotView = {
|
|
176
|
+
kind: 'current';
|
|
177
|
+
} | {
|
|
178
|
+
kind: 'named';
|
|
179
|
+
name: NamedView;
|
|
180
|
+
} | {
|
|
181
|
+
kind: 'orbit-from-current';
|
|
182
|
+
azimuthDeg: number;
|
|
183
|
+
elevationDeg: number;
|
|
184
|
+
} | {
|
|
185
|
+
kind: 'look-from';
|
|
186
|
+
eye: [number, number, number];
|
|
187
|
+
target?: [number, number, number];
|
|
188
|
+
};
|
|
165
189
|
export type UITakeScreenshotMessage = {
|
|
166
190
|
type: 'take-screenshot';
|
|
167
191
|
requestId: string;
|
|
@@ -173,6 +197,36 @@ export type UITakeScreenshotMessage = {
|
|
|
173
197
|
transparent?: boolean;
|
|
174
198
|
autoCrop?: boolean;
|
|
175
199
|
margin?: number;
|
|
200
|
+
view?: ScreenshotView;
|
|
201
|
+
multi?: boolean;
|
|
176
202
|
};
|
|
177
203
|
};
|
|
178
|
-
|
|
204
|
+
/**
|
|
205
|
+
* Lifecycle ping for a render pass. Emitted at the start of every render and
|
|
206
|
+
* again on completion (state: 'end') or compile failure (state: 'error').
|
|
207
|
+
* Intermediate renders are cancelled at the server boundary, so only the
|
|
208
|
+
* latest `version` ever emits an `end`/`error`. Used by MCP coordination tools
|
|
209
|
+
* to wait deterministically instead of sleeping.
|
|
210
|
+
*/
|
|
211
|
+
export type UIRenderVersionMessage = {
|
|
212
|
+
type: 'render-version';
|
|
213
|
+
version: number;
|
|
214
|
+
state: 'start' | 'end' | 'error';
|
|
215
|
+
absPath?: string;
|
|
216
|
+
};
|
|
217
|
+
export type ServerToUIMessage = UIInitCompleteMessage | UIProcessingFileMessage | UISceneRenderedMessage | UIHighlightShapeMessage | UIClearHighlightMessage | UIShowShapePropertiesMessage | UITakeScreenshotMessage | UIRenderVersionMessage;
|
|
218
|
+
export type CameraStateMessage = {
|
|
219
|
+
type: 'camera-state';
|
|
220
|
+
position: [number, number, number];
|
|
221
|
+
target: [number, number, number];
|
|
222
|
+
up: [number, number, number];
|
|
223
|
+
projection: 'orthographic' | 'perspective';
|
|
224
|
+
};
|
|
225
|
+
export type ScreenshotResultMessage = {
|
|
226
|
+
type: 'screenshot-result';
|
|
227
|
+
requestId: string;
|
|
228
|
+
success: boolean;
|
|
229
|
+
data?: string;
|
|
230
|
+
error?: string;
|
|
231
|
+
};
|
|
232
|
+
export type UIToServerMessage = CameraStateMessage | ScreenshotResultMessage;
|