@rulecad/cad 0.1.0 → 0.1.1
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/design.mjs +2 -1
- package/lib/workspace.mjs +2 -2
- package/package.json +1 -1
package/lib/design.mjs
CHANGED
|
@@ -16,6 +16,7 @@
|
|
|
16
16
|
// Builds are cached in .cache/builds/, by everything they're made from (CAD_NO_CACHE=1 to skip).
|
|
17
17
|
import fs from 'node:fs';
|
|
18
18
|
import path from 'node:path';
|
|
19
|
+
import { pathToFileURL } from 'node:url';
|
|
19
20
|
import { createRequire } from 'node:module';
|
|
20
21
|
import crypto from 'node:crypto';
|
|
21
22
|
import { resolve, loadRuleSet } from './rules.mjs';
|
|
@@ -104,7 +105,7 @@ export async function build(d, set = {}, { mirror = false } = {}) {
|
|
|
104
105
|
return { object, values, entries, parts, polygons: parts.flatMap((p) => p.polygons), triangles: parts.flatMap((p) => p.triangles), cached: true, hash: key, ...(c.circuit ? { circuit: c.circuit, matrix: c.matrix } : {}) };
|
|
105
106
|
}
|
|
106
107
|
|
|
107
|
-
const mod = await import(`${d.js}?t=${fs.statSync(d.js).mtimeMs}`).catch((e) => { // a fresh copy after each edit
|
|
108
|
+
const mod = await import(`${pathToFileURL(d.js).href}?t=${fs.statSync(d.js).mtimeMs}`).catch((e) => { // a fresh copy after each edit
|
|
108
109
|
// Designs import JSCAD themselves, so it has to be installed where they are (it's the workspace's dependency)
|
|
109
110
|
if (e.code === 'ERR_MODULE_NOT_FOUND' && /@jscad\/modeling/.test(e.message)) throw new Error(`designs need JSCAD in the workspace: npm install @jscad/modeling (in ${WS})`);
|
|
110
111
|
if (/import statement outside a module/.test(e.message)) throw new Error(`designs are ES modules: set "type": "module" in ${path.join(WS, 'package.json')}`);
|
package/lib/workspace.mjs
CHANGED
|
@@ -10,7 +10,7 @@ import fs from 'node:fs';
|
|
|
10
10
|
import path from 'node:path';
|
|
11
11
|
import { fileURLToPath } from 'node:url';
|
|
12
12
|
|
|
13
|
-
export const TOOL =
|
|
13
|
+
export const TOOL = fileURLToPath(new URL('..', import.meta.url)).replace(/[\\/]$/, '');
|
|
14
14
|
|
|
15
15
|
function find() {
|
|
16
16
|
if (process.env.CAD_WORKSPACE) return path.resolve(process.env.CAD_WORKSPACE);
|
|
@@ -23,7 +23,7 @@ function find() {
|
|
|
23
23
|
export const WS = find();
|
|
24
24
|
export const config = (() => {
|
|
25
25
|
const f = path.join(WS, 'cad.config.json');
|
|
26
|
-
return { printer: 'x1c', viewUrl: 'https://jonibach.github.io/
|
|
26
|
+
return { printer: 'x1c', viewUrl: 'https://jonibach.github.io/rulecad/', targets: {}, ...(fs.existsSync(f) ? JSON.parse(fs.readFileSync(f, 'utf8')) : {}) };
|
|
27
27
|
})();
|
|
28
28
|
|
|
29
29
|
// Rule sets: the workspace's own first (your copies, with your measurements), then the published ones (@rulecad/rules).
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rulecad/cad",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"description": "The cad command: JSCAD designs from traceable rules, checked for printing and fit, versioned by what fits, shared as links and exported as Bambu 3MF.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|