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.
Files changed (237) hide show
  1. package/README.md +3 -2
  2. package/bin/commands/init.js +55 -0
  3. package/bin/commands/mcp.js +33 -0
  4. package/bin/commands/serve.js +77 -0
  5. package/bin/fluidcad.js +15 -107
  6. package/lib/dist/common/scene-object.d.ts +2 -1
  7. package/lib/dist/common/scene-object.js +3 -2
  8. package/lib/dist/core/2d/tarc.d.ts +20 -2
  9. package/lib/dist/core/2d/tarc.js +24 -0
  10. package/lib/dist/core/interfaces.d.ts +31 -2
  11. package/lib/dist/core/repeat.js +62 -46
  12. package/lib/dist/features/2d/arc.d.ts +8 -2
  13. package/lib/dist/features/2d/arc.js +94 -17
  14. package/lib/dist/features/2d/back.js +3 -2
  15. package/lib/dist/features/2d/sketch.d.ts +4 -0
  16. package/lib/dist/features/2d/sketch.js +21 -0
  17. package/lib/dist/features/2d/tarc-constrained.d.ts +2 -0
  18. package/lib/dist/features/2d/tarc-constrained.js +8 -0
  19. package/lib/dist/features/2d/tarc-radius-to-object.d.ts +16 -0
  20. package/lib/dist/features/2d/tarc-radius-to-object.js +58 -0
  21. package/lib/dist/features/2d/tarc-to-object.d.ts +18 -0
  22. package/lib/dist/features/2d/tarc-to-object.js +66 -0
  23. package/lib/dist/features/2d/tarc-to-point-tangent.d.ts +2 -0
  24. package/lib/dist/features/2d/tarc-to-point-tangent.js +3 -0
  25. package/lib/dist/features/2d/tarc-to-point.d.ts +2 -0
  26. package/lib/dist/features/2d/tarc-to-point.js +3 -0
  27. package/lib/dist/features/2d/tarc-with-tangent.d.ts +2 -0
  28. package/lib/dist/features/2d/tarc-with-tangent.js +3 -0
  29. package/lib/dist/features/2d/tarc.d.ts +2 -0
  30. package/lib/dist/features/2d/tarc.js +3 -0
  31. package/lib/dist/features/extrude-base.d.ts +9 -0
  32. package/lib/dist/features/extrude-base.js +22 -0
  33. package/lib/dist/features/extrude-to-face.js +1 -5
  34. package/lib/dist/features/extrude-two-distances.js +1 -2
  35. package/lib/dist/features/extrude.js +1 -2
  36. package/lib/dist/features/mirror-feature.d.ts +3 -2
  37. package/lib/dist/features/mirror-feature.js +1 -1
  38. package/lib/dist/features/repeat-circular.d.ts +3 -3
  39. package/lib/dist/features/repeat-circular.js +8 -1
  40. package/lib/dist/features/repeat-linear.d.ts +4 -2
  41. package/lib/dist/features/repeat-linear.js +10 -1
  42. package/lib/dist/features/repeat-matrix.d.ts +3 -1
  43. package/lib/dist/features/repeat-matrix.js +7 -2
  44. package/lib/dist/features/shell.d.ts +4 -1
  45. package/lib/dist/features/shell.js +14 -3
  46. package/lib/dist/helpers/clone-transform.d.ts +2 -1
  47. package/lib/dist/index.d.ts +7 -1
  48. package/lib/dist/index.js +3 -3
  49. package/lib/dist/math/lazy-matrix.d.ts +31 -0
  50. package/lib/dist/math/lazy-matrix.js +66 -0
  51. package/lib/dist/oc/constraints/constraint-solver-adaptor.d.ts +5 -0
  52. package/lib/dist/oc/constraints/constraint-solver-adaptor.js +16 -0
  53. package/lib/dist/oc/constraints/constraint-solver.d.ts +4 -0
  54. package/lib/dist/oc/constraints/curve/curve-constraint-solver.d.ts +4 -0
  55. package/lib/dist/oc/constraints/curve/curve-constraint-solver.js +3 -0
  56. package/lib/dist/oc/constraints/geometric/geometric-constraint-solver.d.ts +6 -1
  57. package/lib/dist/oc/constraints/geometric/geometric-constraint-solver.js +4 -0
  58. package/lib/dist/oc/constraints/geometric/tangent-arc-from-point-tangent.d.ts +8 -0
  59. package/lib/dist/oc/constraints/geometric/tangent-arc-from-point-tangent.js +111 -0
  60. package/lib/dist/oc/constraints/geometric/tangent-arc-radius-to-object.d.ts +8 -0
  61. package/lib/dist/oc/constraints/geometric/tangent-arc-radius-to-object.js +161 -0
  62. package/lib/dist/oc/mesh.d.ts +9 -4
  63. package/lib/dist/oc/mesh.js +14 -13
  64. package/lib/dist/oc/shell-ops.d.ts +2 -1
  65. package/lib/dist/oc/shell-ops.js +5 -2
  66. package/lib/dist/rendering/mesh-builder.d.ts +3 -0
  67. package/lib/dist/rendering/mesh-builder.js +8 -4
  68. package/lib/dist/rendering/render-edge.d.ts +2 -1
  69. package/lib/dist/rendering/render-edge.js +2 -2
  70. package/lib/dist/rendering/render-face.d.ts +2 -1
  71. package/lib/dist/rendering/render-face.js +2 -2
  72. package/lib/dist/rendering/render-solid.d.ts +2 -1
  73. package/lib/dist/rendering/render-solid.js +2 -2
  74. package/lib/dist/rendering/render-wire.d.ts +2 -1
  75. package/lib/dist/rendering/render-wire.js +2 -2
  76. package/lib/dist/rendering/render.d.ts +3 -0
  77. package/lib/dist/rendering/render.js +7 -2
  78. package/lib/dist/scene-manager.d.ts +4 -2
  79. package/lib/dist/scene-manager.js +12 -4
  80. package/lib/dist/tests/features/2d/arc.test.js +64 -0
  81. package/lib/dist/tests/features/2d/back.test.js +17 -1
  82. package/lib/dist/tests/features/2d/tarc.test.js +157 -0
  83. package/lib/dist/tests/features/repeat-user-repro.test.d.ts +1 -0
  84. package/lib/dist/tests/features/repeat-user-repro.test.js +60 -0
  85. package/lib/dist/tests/features/shell.test.js +36 -0
  86. package/lib/dist/tests/global-setup.js +2 -1
  87. package/lib/dist/tests/helpers/extract-blocks.d.ts +9 -0
  88. package/lib/dist/tests/helpers/extract-blocks.js +56 -0
  89. package/lib/dist/tests/llm-docs-examples.test.d.ts +1 -0
  90. package/lib/dist/tests/llm-docs-examples.test.js +62 -0
  91. package/lib/dist/tests/setup.js +2 -1
  92. package/lib/dist/tsconfig.tsbuildinfo +1 -1
  93. package/llm-docs/.coverage-allowlist.txt +9 -0
  94. package/llm-docs/api/arc.md +48 -0
  95. package/llm-docs/api/axis.md +42 -0
  96. package/llm-docs/api/bezier.md +42 -0
  97. package/llm-docs/api/booleans.md +44 -0
  98. package/llm-docs/api/chamfer.md +40 -0
  99. package/llm-docs/api/circle.md +36 -0
  100. package/llm-docs/api/color.md +34 -0
  101. package/llm-docs/api/connect.md +41 -0
  102. package/llm-docs/api/constraint-qualifiers.md +48 -0
  103. package/llm-docs/api/copy.md +63 -0
  104. package/llm-docs/api/cursor-lines.md +50 -0
  105. package/llm-docs/api/cursor-move.md +61 -0
  106. package/llm-docs/api/cut.md +55 -0
  107. package/llm-docs/api/draft.md +36 -0
  108. package/llm-docs/api/edge-filter.md +57 -0
  109. package/llm-docs/api/ellipse.md +34 -0
  110. package/llm-docs/api/extrude.md +74 -0
  111. package/llm-docs/api/face-filter.md +61 -0
  112. package/llm-docs/api/fillet.md +51 -0
  113. package/llm-docs/api/index.json +139 -0
  114. package/llm-docs/api/line.md +42 -0
  115. package/llm-docs/api/load.md +37 -0
  116. package/llm-docs/api/local.md +38 -0
  117. package/llm-docs/api/loft.md +37 -0
  118. package/llm-docs/api/mirror.md +44 -0
  119. package/llm-docs/api/offset.md +36 -0
  120. package/llm-docs/api/part.md +40 -0
  121. package/llm-docs/api/plane.md +44 -0
  122. package/llm-docs/api/polygon.md +37 -0
  123. package/llm-docs/api/primitive-solids.md +39 -0
  124. package/llm-docs/api/project-intersect.md +48 -0
  125. package/llm-docs/api/rect.md +48 -0
  126. package/llm-docs/api/remove.md +32 -0
  127. package/llm-docs/api/repeat.md +79 -0
  128. package/llm-docs/api/revolve.md +38 -0
  129. package/llm-docs/api/rib.md +40 -0
  130. package/llm-docs/api/rotate.md +37 -0
  131. package/llm-docs/api/select.md +41 -0
  132. package/llm-docs/api/shell.md +41 -0
  133. package/llm-docs/api/sketch.md +76 -0
  134. package/llm-docs/api/slot.md +36 -0
  135. package/llm-docs/api/split-trim.md +42 -0
  136. package/llm-docs/api/sweep.md +43 -0
  137. package/llm-docs/api/tarc.md +45 -0
  138. package/llm-docs/api/tcircle.md +38 -0
  139. package/llm-docs/api/tline.md +42 -0
  140. package/llm-docs/api/translate.md +40 -0
  141. package/llm-docs/api/types/aline.md +35 -0
  142. package/llm-docs/api/types/arc-angles.md +29 -0
  143. package/llm-docs/api/types/arc-points.md +48 -0
  144. package/llm-docs/api/types/axis-like.md +38 -0
  145. package/llm-docs/api/types/axis.md +21 -0
  146. package/llm-docs/api/types/boolean-operation.md +50 -0
  147. package/llm-docs/api/types/circular-repeat-options.md +31 -0
  148. package/llm-docs/api/types/common.md +32 -0
  149. package/llm-docs/api/types/cut.md +125 -0
  150. package/llm-docs/api/types/draft.md +21 -0
  151. package/llm-docs/api/types/extrudable-geometry.md +23 -0
  152. package/llm-docs/api/types/extrude.md +194 -0
  153. package/llm-docs/api/types/geometry.md +51 -0
  154. package/llm-docs/api/types/hline.md +35 -0
  155. package/llm-docs/api/types/linear-repeat-options.md +31 -0
  156. package/llm-docs/api/types/loft.md +154 -0
  157. package/llm-docs/api/types/mirror.md +35 -0
  158. package/llm-docs/api/types/offset.md +31 -0
  159. package/llm-docs/api/types/plane-like.md +35 -0
  160. package/llm-docs/api/types/plane-transform-options.md +29 -0
  161. package/llm-docs/api/types/plane.md +21 -0
  162. package/llm-docs/api/types/point-like.md +22 -0
  163. package/llm-docs/api/types/point2dlike.md +26 -0
  164. package/llm-docs/api/types/polygon.md +46 -0
  165. package/llm-docs/api/types/rect.md +128 -0
  166. package/llm-docs/api/types/revolve.md +102 -0
  167. package/llm-docs/api/types/rib.md +133 -0
  168. package/llm-docs/api/types/scene-object.md +33 -0
  169. package/llm-docs/api/types/select.md +21 -0
  170. package/llm-docs/api/types/shell.md +54 -0
  171. package/llm-docs/api/types/slot.md +43 -0
  172. package/llm-docs/api/types/sweep.md +189 -0
  173. package/llm-docs/api/types/tangent-arc-two-objects.md +46 -0
  174. package/llm-docs/api/types/transformable.md +93 -0
  175. package/llm-docs/api/types/trim.md +27 -0
  176. package/llm-docs/api/types/two-objects-tangent-line.md +46 -0
  177. package/llm-docs/api/types/vertex.md +17 -0
  178. package/llm-docs/api/types/vline.md +35 -0
  179. package/llm-docs/concepts/coordinate-system.md +45 -0
  180. package/llm-docs/concepts/history-and-rollback.md +40 -0
  181. package/llm-docs/concepts/last-selection.md +49 -0
  182. package/llm-docs/concepts/scene-graph.md +37 -0
  183. package/llm-docs/index.json +1750 -0
  184. package/mcp/dist/client.d.ts +64 -0
  185. package/mcp/dist/client.js +248 -0
  186. package/mcp/dist/discovery.d.ts +11 -0
  187. package/mcp/dist/discovery.js +78 -0
  188. package/mcp/dist/docs-index.d.ts +81 -0
  189. package/mcp/dist/docs-index.js +261 -0
  190. package/mcp/dist/resources.d.ts +4 -0
  191. package/mcp/dist/resources.js +115 -0
  192. package/mcp/dist/server.d.ts +12 -0
  193. package/mcp/dist/server.js +489 -0
  194. package/mcp/dist/tools/coordination.d.ts +9 -0
  195. package/mcp/dist/tools/coordination.js +46 -0
  196. package/mcp/dist/tools/docs.d.ts +66 -0
  197. package/mcp/dist/tools/docs.js +122 -0
  198. package/mcp/dist/tools/engine.d.ts +56 -0
  199. package/mcp/dist/tools/engine.js +145 -0
  200. package/mcp/dist/tools/inspection.d.ts +75 -0
  201. package/mcp/dist/tools/inspection.js +121 -0
  202. package/mcp/dist/tools/screenshot.d.ts +63 -0
  203. package/mcp/dist/tools/screenshot.js +263 -0
  204. package/mcp/dist/tools/source.d.ts +84 -0
  205. package/mcp/dist/tools/source.js +434 -0
  206. package/mcp/dist/tools/workspaces.d.ts +13 -0
  207. package/mcp/dist/tools/workspaces.js +33 -0
  208. package/mcp/dist/types.d.ts +18 -0
  209. package/mcp/dist/types.js +11 -0
  210. package/package.json +19 -5
  211. package/server/dist/code-editor.d.ts +36 -0
  212. package/server/dist/code-editor.js +8 -0
  213. package/server/dist/fluidcad-server.d.ts +50 -0
  214. package/server/dist/fluidcad-server.js +153 -1
  215. package/server/dist/global-registry.d.ts +30 -0
  216. package/server/dist/global-registry.js +126 -0
  217. package/server/dist/index.js +171 -26
  218. package/server/dist/instance-file.d.ts +31 -0
  219. package/server/dist/instance-file.js +73 -0
  220. package/server/dist/lint-fluid-js.d.ts +15 -0
  221. package/server/dist/lint-fluid-js.js +271 -0
  222. package/server/dist/routes/editor.d.ts +24 -0
  223. package/server/dist/routes/editor.js +44 -0
  224. package/server/dist/routes/export.d.ts +1 -1
  225. package/server/dist/routes/export.js +45 -8
  226. package/server/dist/routes/health.d.ts +7 -0
  227. package/server/dist/routes/health.js +14 -0
  228. package/server/dist/routes/lint.d.ts +10 -0
  229. package/server/dist/routes/lint.js +28 -0
  230. package/server/dist/routes/render.d.ts +33 -0
  231. package/server/dist/routes/render.js +34 -0
  232. package/server/dist/routes/scene.d.ts +5 -0
  233. package/server/dist/routes/scene.js +48 -0
  234. package/server/dist/routes/screenshot.js +68 -1
  235. package/server/dist/ws-protocol.d.ts +56 -2
  236. package/ui/dist/assets/{index-CFi9p7wR.js → index-BdqrMDRu.js} +21 -21
  237. 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
- export type ExtensionMessage = ProcessFileMessage | LiveUpdateMessage | RollbackMessage | ImportFileMessage | HighlightShapeMessage | ClearHighlightMessage | ShowShapePropertiesMessage | ExportSceneMessage;
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
- export type ServerToUIMessage = UIInitCompleteMessage | UIProcessingFileMessage | UISceneRenderedMessage | UIHighlightShapeMessage | UIClearHighlightMessage | UIShowShapePropertiesMessage | UITakeScreenshotMessage;
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;