fluidcad 0.0.20 → 0.0.22

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 (48) hide show
  1. package/README.md +7 -2
  2. package/lib/dist/common/shape.d.ts +7 -0
  3. package/lib/dist/common/shape.js +7 -0
  4. package/lib/dist/core/copy.js +1 -1
  5. package/lib/dist/core/draft.d.ts +16 -0
  6. package/lib/dist/core/draft.js +29 -0
  7. package/lib/dist/core/index.d.ts +2 -3
  8. package/lib/dist/core/index.js +1 -1
  9. package/lib/dist/core/interfaces.d.ts +2 -0
  10. package/lib/dist/core/part.d.ts +2 -6
  11. package/lib/dist/core/part.js +12 -22
  12. package/lib/dist/features/2d/rect.d.ts +1 -0
  13. package/lib/dist/features/2d/rect.js +13 -9
  14. package/lib/dist/features/2d/sketch.d.ts +1 -0
  15. package/lib/dist/features/2d/sketch.js +21 -4
  16. package/lib/dist/features/copy-circular.js +1 -0
  17. package/lib/dist/features/copy-circular2d.js +1 -0
  18. package/lib/dist/features/copy-linear.js +4 -5
  19. package/lib/dist/features/copy-linear2d.js +4 -5
  20. package/lib/dist/features/draft.d.ts +15 -0
  21. package/lib/dist/features/draft.js +88 -0
  22. package/lib/dist/filters/edge/edge-filter.d.ts +0 -14
  23. package/lib/dist/filters/edge/edge-filter.js +2 -0
  24. package/lib/dist/filters/face/face-filter.d.ts +0 -14
  25. package/lib/dist/filters/face/face-filter.js +2 -0
  26. package/lib/dist/oc/draft-ops.d.ts +5 -0
  27. package/lib/dist/oc/draft-ops.js +51 -0
  28. package/lib/dist/oc/mesh.d.ts +2 -0
  29. package/lib/dist/oc/mesh.js +14 -6
  30. package/lib/dist/oc/wire-ops.js +4 -1
  31. package/lib/dist/rendering/mesh-transform.d.ts +3 -0
  32. package/lib/dist/rendering/mesh-transform.js +22 -0
  33. package/lib/dist/rendering/render-solid.js +3 -2
  34. package/lib/dist/rendering/render.js +25 -4
  35. package/lib/dist/tests/features/draft.test.d.ts +1 -0
  36. package/lib/dist/tests/features/draft.test.js +147 -0
  37. package/lib/dist/tests/features/part.test.js +69 -114
  38. package/lib/dist/tsconfig.tsbuildinfo +1 -1
  39. package/package.json +1 -1
  40. package/server/dist/fluidcad-server.d.ts +2 -0
  41. package/server/dist/fluidcad-server.js +10 -0
  42. package/server/dist/routes/actions.js +20 -0
  43. package/server/dist/vite-manager.js +7 -1
  44. package/ui/dist/assets/{index-Bz0YoaQD.js → index-C0JwQ8Bk.js} +15 -11
  45. package/ui/dist/assets/{index-BfcNNxXr.css → index-gPoNOiIs.css} +1 -1
  46. package/ui/dist/index.html +2 -2
  47. package/lib/dist/core/use.d.ts +0 -5
  48. package/lib/dist/core/use.js +0 -22
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fluidcad",
3
- "version": "0.0.20",
3
+ "version": "0.0.22",
4
4
  "description": "Parametric CAD modeling library using javascript",
5
5
  "author": "Marwan Aouida <contact@marwan.dev>",
6
6
  "homepage": "https://fluidcad.io",
@@ -10,10 +10,12 @@ export declare class FluidCadServer {
10
10
  private previousScenes;
11
11
  private renderingCache;
12
12
  private currentFileName;
13
+ private currentFilePath;
13
14
  init(workspacePath: string): Promise<void>;
14
15
  processFile(filePath: string, ignoreCache?: boolean): Promise<SceneRenderedData | null>;
15
16
  updateLiveCode(fileName: string, code: string): Promise<SceneRenderedData | null>;
16
17
  rollbackFromUI(index: number): Promise<SceneRenderedData | null>;
18
+ recomputeCurrentFile(): Promise<SceneRenderedData | null>;
17
19
  rollback(fileName: string, index: number): Promise<SceneRenderedData | null>;
18
20
  importFile(workspacePath: string, fileName: string, data: string): Promise<void>;
19
21
  getShapeProperties(shapeId: string): any;
@@ -9,6 +9,7 @@ export class FluidCadServer {
9
9
  previousScenes = new Map();
10
10
  renderingCache = new Map();
11
11
  currentFileName = '';
12
+ currentFilePath = '';
12
13
  async init(workspacePath) {
13
14
  await this.viteManager.init(workspacePath);
14
15
  const initFilePath = normalizePath(join(workspacePath, 'init.js'));
@@ -24,6 +25,7 @@ export class FluidCadServer {
24
25
  filePath = normalizePath(filePath);
25
26
  const normalizedFileName = filePath.replace('virtual:live-render:', '');
26
27
  this.currentFileName = normalizedFileName;
28
+ this.currentFilePath = filePath;
27
29
  if (!ignoreCache) {
28
30
  const fromCache = this.renderingCache.get(normalizedFileName);
29
31
  if (fromCache) {
@@ -88,6 +90,14 @@ export class FluidCadServer {
88
90
  async rollbackFromUI(index) {
89
91
  return this.rollback(this.currentFileName, index);
90
92
  }
93
+ async recomputeCurrentFile() {
94
+ if (!this.currentFilePath) {
95
+ return null;
96
+ }
97
+ this.previousScenes.delete(this.currentFileName);
98
+ this.renderingCache.delete(this.currentFileName);
99
+ return this.processFile(this.currentFilePath, true);
100
+ }
91
101
  async rollback(fileName, index) {
92
102
  if (!this.sceneManager) {
93
103
  return null;
@@ -67,6 +67,26 @@ export function createActionsRouter(fluidCadServer, sendToExtension, broadcastTo
67
67
  });
68
68
  res.json({ success: true });
69
69
  });
70
+ router.post('/recompute', async (_req, res) => {
71
+ const data = await fluidCadServer.recomputeCurrentFile();
72
+ if (!data) {
73
+ res.status(404).json({ error: 'No active scene' });
74
+ return;
75
+ }
76
+ sendToExtension({
77
+ type: 'scene-rendered',
78
+ absPath: data.absPath,
79
+ result: data.result,
80
+ rollbackStop: data.rollbackStop,
81
+ });
82
+ broadcastToUI({
83
+ type: 'scene-rendered',
84
+ result: data.result,
85
+ absPath: data.absPath,
86
+ breakpointHit: data.breakpointHit,
87
+ });
88
+ res.json({ success: true });
89
+ });
70
90
  router.post('/clear-breakpoints', (_req, res) => {
71
91
  sendToExtension({ type: 'clear-breakpoints' });
72
92
  res.json({ success: true });
@@ -103,7 +103,13 @@ export class ViteManager {
103
103
  this.buffers.set(id, code);
104
104
  }
105
105
  async loadModule(filePath) {
106
- return this.server.ssrLoadModule(filePath);
106
+ const mod = await this.server.ssrLoadModule(filePath);
107
+ for (const value of Object.values(mod)) {
108
+ if (typeof value === 'function') {
109
+ await value();
110
+ }
111
+ }
112
+ return mod;
107
113
  }
108
114
  invalidateModule() {
109
115
  for (const [id, mod] of this.server.moduleGraph.idToModuleMap) {