fluidcad 0.0.7 → 0.0.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.
- package/bin/fluidcad.js +16 -0
- package/lib/dist/core/2d/arc.d.ts +15 -0
- package/lib/dist/core/2d/arc.js +10 -0
- package/lib/dist/core/2d/index.d.ts +0 -1
- package/lib/dist/core/2d/index.js +0 -1
- package/lib/dist/core/2d/tarc.d.ts +26 -2
- package/lib/dist/core/2d/tcircle.d.ts +26 -2
- package/lib/dist/core/2d/tline.d.ts +26 -6
- package/lib/dist/core/axis.d.ts +11 -4
- package/lib/dist/core/chamfer.d.ts +6 -6
- package/lib/dist/core/chamfer.js +12 -9
- package/lib/dist/core/cut.d.ts +27 -6
- package/lib/dist/core/extrude.d.ts +15 -3
- package/lib/dist/core/plane.d.ts +11 -4
- package/lib/dist/core/repeat.d.ts +16 -1
- package/lib/dist/core/repeat.js +39 -3
- package/lib/dist/core/sketch.d.ts +9 -3
- package/lib/dist/core/subtract.d.ts +5 -4
- package/lib/dist/core/subtract.js +9 -2
- package/lib/dist/features/2d/arc-three-points.d.ts +19 -0
- package/lib/dist/features/2d/arc-three-points.js +75 -0
- package/lib/dist/features/2d/constraints/geometry-qualifier.d.ts +16 -0
- package/lib/dist/features/2d/constraints/geometry-qualifier.js +16 -0
- package/lib/dist/features/2d/offset.js +10 -0
- package/lib/dist/features/2d/projection.js +9 -0
- package/lib/dist/features/2d/rect.js +19 -16
- package/lib/dist/features/chamfer.d.ts +4 -4
- package/lib/dist/features/chamfer.js +33 -15
- package/lib/dist/features/common2d.js +26 -8
- package/lib/dist/features/fuse2d.js +24 -6
- package/lib/dist/features/repeat-matrix.d.ts +14 -0
- package/lib/dist/features/repeat-matrix.js +41 -0
- package/lib/dist/features/select.d.ts +1 -0
- package/lib/dist/features/select.js +19 -0
- package/lib/dist/features/subtract2d.d.ts +14 -0
- package/lib/dist/features/subtract2d.js +80 -0
- package/lib/dist/filters/edge/belongs-to-face.d.ts +22 -0
- package/lib/dist/filters/edge/belongs-to-face.js +67 -0
- package/lib/dist/filters/edge/belongs-to-object.d.ts +18 -0
- package/lib/dist/filters/edge/belongs-to-object.js +37 -0
- package/lib/dist/filters/edge/edge-filter.d.ts +88 -3
- package/lib/dist/filters/edge/edge-filter.js +101 -4
- package/lib/dist/filters/edge/line-filter.d.ts +4 -1
- package/lib/dist/filters/edge/line-filter.js +14 -7
- package/lib/dist/filters/face/edge-count.d.ts +17 -0
- package/lib/dist/filters/face/edge-count.js +33 -0
- package/lib/dist/filters/face/face-filter.d.ts +93 -0
- package/lib/dist/filters/face/face-filter.js +112 -0
- package/lib/dist/filters/face/has-edge.d.ts +18 -0
- package/lib/dist/filters/face/has-edge.js +59 -0
- package/lib/dist/filters/face/has-object.d.ts +18 -0
- package/lib/dist/filters/face/has-object.js +37 -0
- package/lib/dist/filters/index.d.ts +6 -0
- package/lib/dist/filters/index.js +6 -0
- package/lib/dist/index.js +1 -1
- package/lib/dist/oc/edge-query.d.ts +2 -2
- package/lib/dist/oc/edge-query.js +13 -4
- package/lib/dist/tests/features/2d/arc.test.js +15 -1
- package/lib/dist/tests/features/select.test.js +249 -0
- package/lib/dist/tests/features/subtract2d.test.d.ts +1 -0
- package/lib/dist/tests/features/subtract2d.test.js +63 -0
- package/lib/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +3 -2
- package/server/dist/fluidcad-server.js +3 -2
- package/server/dist/index.js +2 -1
- package/server/dist/normalize-path.d.ts +6 -0
- package/server/dist/normalize-path.js +8 -0
- package/server/dist/vite-manager.js +3 -2
- package/lib/dist/core/2d/wire.d.ts +0 -11
- package/lib/dist/core/2d/wire.js +0 -29
- package/lib/dist/features/2d/wire.d.ts +0 -12
- package/lib/dist/features/2d/wire.js +0 -76
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "fluidcad",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.9",
|
|
4
4
|
"description": "Parametric CAD modeling library using javascript",
|
|
5
5
|
"author": "Marwan Aouida <contact@marwan.dev>",
|
|
6
6
|
"homepage": "https://fluidcad.io",
|
|
@@ -36,7 +36,8 @@
|
|
|
36
36
|
"./core": "./lib/dist/core/index.js",
|
|
37
37
|
"./filters": "./lib/dist/filters/index.js",
|
|
38
38
|
"./constraints": "./lib/dist/features/2d/constraints/geometry-qualifier.js",
|
|
39
|
-
"./server": "./server/dist/index.js"
|
|
39
|
+
"./server": "./server/dist/index.js",
|
|
40
|
+
"./math": "./lib/dist/math/index.js"
|
|
40
41
|
},
|
|
41
42
|
"scripts": {
|
|
42
43
|
"clean": "rm -rf lib/dist server/dist ui/dist lib/tsconfig.tsbuildinfo server/tsconfig.tsbuildinfo",
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { join } from 'path';
|
|
2
2
|
import { existsSync } from 'fs';
|
|
3
3
|
import { ViteManager } from "./vite-manager.js";
|
|
4
|
+
import { normalizePath } from "./normalize-path.js";
|
|
4
5
|
export class FluidCadServer {
|
|
5
6
|
viteManager = new ViteManager();
|
|
6
7
|
sceneManager;
|
|
@@ -9,7 +10,7 @@ export class FluidCadServer {
|
|
|
9
10
|
currentFileName = '';
|
|
10
11
|
async init(workspacePath) {
|
|
11
12
|
await this.viteManager.init(workspacePath);
|
|
12
|
-
const initFilePath = join(workspacePath, 'init.js');
|
|
13
|
+
const initFilePath = normalizePath(join(workspacePath, 'init.js'));
|
|
13
14
|
if (existsSync(initFilePath)) {
|
|
14
15
|
const { default: _sceneManager } = await this.viteManager.loadModule(initFilePath);
|
|
15
16
|
this.sceneManager = await _sceneManager;
|
|
@@ -19,7 +20,7 @@ export class FluidCadServer {
|
|
|
19
20
|
if (!this.sceneManager) {
|
|
20
21
|
return null;
|
|
21
22
|
}
|
|
22
|
-
const normalizedFileName = filePath.replace('virtual:live-render:', '');
|
|
23
|
+
const normalizedFileName = normalizePath(filePath.replace('virtual:live-render:', ''));
|
|
23
24
|
this.currentFileName = normalizedFileName;
|
|
24
25
|
if (!ignoreCache) {
|
|
25
26
|
const fromCache = this.renderingCache.get(normalizedFileName);
|
package/server/dist/index.js
CHANGED
|
@@ -8,8 +8,9 @@ import { createPropertiesRouter } from "./routes/properties.js";
|
|
|
8
8
|
import { createActionsRouter } from "./routes/actions.js";
|
|
9
9
|
import { createExportRouter } from "./routes/export.js";
|
|
10
10
|
import { createScreenshotRouter } from "./routes/screenshot.js";
|
|
11
|
+
import { normalizePath } from "./normalize-path.js";
|
|
11
12
|
const PORT = parseInt(process.env.FLUIDCAD_SERVER_PORT || '3100', 10);
|
|
12
|
-
const WORKSPACE_PATH = process.env.FLUIDCAD_WORKSPACE_PATH || '';
|
|
13
|
+
const WORKSPACE_PATH = normalizePath(process.env.FLUIDCAD_WORKSPACE_PATH || '');
|
|
13
14
|
const UI_DIST = path.resolve(import.meta.dirname, '../../ui/dist');
|
|
14
15
|
// ---------------------------------------------------------------------------
|
|
15
16
|
// IPC helpers — communication with extension host process
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { createServer } from 'vite';
|
|
2
2
|
import { dirname, resolve, isAbsolute } from 'path';
|
|
3
|
+
import { normalizePath } from "./normalize-path.js";
|
|
3
4
|
const BLOCKED_NODE_MODULES = new Set([
|
|
4
5
|
'fs',
|
|
5
6
|
'child_process',
|
|
@@ -42,7 +43,7 @@ export class ViteManager {
|
|
|
42
43
|
rootPath = '';
|
|
43
44
|
buffers = new Map();
|
|
44
45
|
async init(rootPath) {
|
|
45
|
-
this.rootPath = rootPath;
|
|
46
|
+
this.rootPath = normalizePath(rootPath);
|
|
46
47
|
const that = this;
|
|
47
48
|
this.server = await createServer({
|
|
48
49
|
root: rootPath,
|
|
@@ -66,7 +67,7 @@ export class ViteManager {
|
|
|
66
67
|
// Resolve relative imports from virtual modules against the real file path
|
|
67
68
|
if (importer && importer.startsWith('virtual:live-render:') && !isAbsolute(id)) {
|
|
68
69
|
const realImporter = importer.replace('virtual:live-render:', '');
|
|
69
|
-
return resolve(dirname(realImporter), id);
|
|
70
|
+
return normalizePath(resolve(dirname(realImporter), id));
|
|
70
71
|
}
|
|
71
72
|
},
|
|
72
73
|
transform(code, id) {
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { PlaneLike } from "../../math/plane.js";
|
|
2
|
-
import { IExtrudableGeometry, IGeometry, ISceneObject } from "../interfaces.js";
|
|
3
|
-
interface WireFunction {
|
|
4
|
-
/**
|
|
5
|
-
* Groups geometry segments into a closed wire for extrusion.
|
|
6
|
-
* @param args - The geometry segments to group, optionally ending with a target plane
|
|
7
|
-
*/
|
|
8
|
-
(...args: (IGeometry | PlaneLike | ISceneObject)[]): IExtrudableGeometry;
|
|
9
|
-
}
|
|
10
|
-
declare const _default: WireFunction;
|
|
11
|
-
export default _default;
|
package/lib/dist/core/2d/wire.js
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { GeometrySceneObject } from "../../features/2d/geometry.js";
|
|
2
|
-
import { WireObject } from "../../features/2d/wire.js";
|
|
3
|
-
import { registerBuilder } from "../../index.js";
|
|
4
|
-
import { isPlaneLike } from "../../math/plane.js";
|
|
5
|
-
import { SceneObject } from "../../common/scene-object.js";
|
|
6
|
-
import { resolvePlane } from "../../helpers/resolve.js";
|
|
7
|
-
function build(context) {
|
|
8
|
-
return function wire() {
|
|
9
|
-
let planeObj = null;
|
|
10
|
-
let argCount = arguments.length;
|
|
11
|
-
// Check if last argument is a plane
|
|
12
|
-
if (argCount > 0) {
|
|
13
|
-
const lastArg = arguments[argCount - 1];
|
|
14
|
-
if (isPlaneLike(lastArg) || (lastArg instanceof SceneObject && !(lastArg instanceof GeometrySceneObject))) {
|
|
15
|
-
planeObj = resolvePlane(lastArg, context);
|
|
16
|
-
argCount--;
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
// Collect target objects from arguments
|
|
20
|
-
let targetObjects = [];
|
|
21
|
-
for (let i = 0; i < argCount; i++) {
|
|
22
|
-
targetObjects.push(arguments[i]);
|
|
23
|
-
}
|
|
24
|
-
const path = new WireObject(targetObjects.length > 0 ? targetObjects : null, planeObj);
|
|
25
|
-
context.addSceneObject(path);
|
|
26
|
-
return path;
|
|
27
|
-
};
|
|
28
|
-
}
|
|
29
|
-
export default registerBuilder(build);
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { GeometrySceneObject } from "./geometry.js";
|
|
2
|
-
import { PlaneObjectBase } from "../plane-renderable-base.js";
|
|
3
|
-
import { ExtrudableGeometryBase } from "./extrudable-base.js";
|
|
4
|
-
export declare class WireObject extends ExtrudableGeometryBase {
|
|
5
|
-
private geometries;
|
|
6
|
-
constructor(geometries: GeometrySceneObject[] | null, targetPlane?: PlaneObjectBase);
|
|
7
|
-
build(): void;
|
|
8
|
-
compareTo(other: WireObject): boolean;
|
|
9
|
-
getType(): string;
|
|
10
|
-
getUniqueType(): string;
|
|
11
|
-
serialize(): {};
|
|
12
|
-
}
|
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
import { Edge } from "../../common/edge.js";
|
|
2
|
-
import { WireOps } from "../../oc/wire-ops.js";
|
|
3
|
-
import { ExtrudableGeometryBase } from "./extrudable-base.js";
|
|
4
|
-
import { Wire } from "../../common/wire.js";
|
|
5
|
-
export class WireObject extends ExtrudableGeometryBase {
|
|
6
|
-
geometries;
|
|
7
|
-
constructor(geometries, targetPlane = null) {
|
|
8
|
-
super(targetPlane);
|
|
9
|
-
this.geometries = geometries;
|
|
10
|
-
}
|
|
11
|
-
build() {
|
|
12
|
-
const sources = this.geometries ?? this.sketch.getPreviousSiblings(this);
|
|
13
|
-
const allEdges = [];
|
|
14
|
-
for (const obj of sources) {
|
|
15
|
-
const shapes = obj.getShapes();
|
|
16
|
-
for (const shape of shapes) {
|
|
17
|
-
if (shape instanceof Edge) {
|
|
18
|
-
allEdges.push(shape);
|
|
19
|
-
obj.removeShape(shape, this);
|
|
20
|
-
}
|
|
21
|
-
else if (shape instanceof Wire) {
|
|
22
|
-
const edges = shape.getEdges();
|
|
23
|
-
allEdges.push(...edges);
|
|
24
|
-
obj.removeShape(shape, this);
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
const groups = WireOps.groupConnectedEdges(allEdges);
|
|
29
|
-
for (const group of groups) {
|
|
30
|
-
const wire = WireOps.makeWireFromEdges(group);
|
|
31
|
-
this.addShape(wire);
|
|
32
|
-
}
|
|
33
|
-
if (this.targetPlane) {
|
|
34
|
-
this.targetPlane.removeShapes(this);
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
compareTo(other) {
|
|
38
|
-
if (!(other instanceof WireObject)) {
|
|
39
|
-
return false;
|
|
40
|
-
}
|
|
41
|
-
if (!super.compareTo(other)) {
|
|
42
|
-
return false;
|
|
43
|
-
}
|
|
44
|
-
if (this.targetPlane?.constructor !== other.targetPlane?.constructor) {
|
|
45
|
-
return false;
|
|
46
|
-
}
|
|
47
|
-
if (this.targetPlane && other.targetPlane && !this.targetPlane.compareTo(other.targetPlane)) {
|
|
48
|
-
return false;
|
|
49
|
-
}
|
|
50
|
-
const thisGeometries = this.geometries || [];
|
|
51
|
-
const otherGeometries = other.geometries || [];
|
|
52
|
-
if (thisGeometries.length !== otherGeometries.length) {
|
|
53
|
-
return false;
|
|
54
|
-
}
|
|
55
|
-
for (let i = 0; i < thisGeometries.length; i++) {
|
|
56
|
-
const thisGeo = thisGeometries[i];
|
|
57
|
-
const otherGeo = otherGeometries[i];
|
|
58
|
-
if (thisGeo.getUniqueType() !== otherGeo.getUniqueType()) {
|
|
59
|
-
return false;
|
|
60
|
-
}
|
|
61
|
-
if (!thisGeo.compareTo(otherGeo)) {
|
|
62
|
-
return false;
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
return true;
|
|
66
|
-
}
|
|
67
|
-
getType() {
|
|
68
|
-
return 'wire';
|
|
69
|
-
}
|
|
70
|
-
getUniqueType() {
|
|
71
|
-
return 'wire';
|
|
72
|
-
}
|
|
73
|
-
serialize() {
|
|
74
|
-
return {};
|
|
75
|
-
}
|
|
76
|
-
}
|