@rulecad/cad 0.7.92 → 0.8.0
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/AGENTS.md +4 -0
- package/CHANGELOG.md +76 -1
- package/EXAMPLES.md +8 -4
- package/README.md +64 -16
- package/bin/cad.mjs +28 -13
- package/lib/assembly.mjs +15 -11
- package/lib/design.mjs +122 -29
- package/lib/edit.mjs +4 -3
- package/lib/fasten.mjs +19 -6
- package/lib/fittings.mjs +8 -3
- package/lib/framebuild.mjs +5 -4
- package/lib/host.mjs +31 -2
- package/lib/layout.mjs +2 -1
- package/lib/motors.mjs +3 -1
- package/lib/names.mjs +39 -0
- package/lib/optimise.mjs +38 -11
- package/lib/order.mjs +1 -1
- package/lib/plates.mjs +2 -2
- package/lib/rules.mjs +25 -1
- package/lib/sandbox-hooks.mjs +92 -8
- package/lib/sandbox-preload.mjs +2 -2
- package/lib/sandbox-run.mjs +20 -4
- package/lib/sandbox.mjs +162 -14
- package/lib/schema.mjs +2 -1
- package/lib/targets.mjs +25 -7
- package/lib/versions.mjs +5 -3
- package/lib/workspace.mjs +21 -7
- package/package.json +11 -11
- package/schemas/object.schema.json +1 -1
- package/schemas/problem.schema.json +25 -7
- package/schemas/project.schema.json +1 -1
package/lib/sandbox.mjs
CHANGED
|
@@ -9,8 +9,12 @@
|
|
|
9
9
|
// the permission model doesn't cover the network, so a design written to get round them might still reach it, and
|
|
10
10
|
// read the workspace as it does. So: run only designs you trust, as with any code.
|
|
11
11
|
// It gets its values as data and sends back its parts' faces. A workspace that trusts its designs sets
|
|
12
|
-
// "sandbox": false in cad.config.json (or CAD_TRUST=1).
|
|
13
|
-
// with the board engine
|
|
12
|
+
// "sandbox": false in cad.config.json (or CAD_TRUST=1).
|
|
13
|
+
// Board designs (engine pcb) run here too, with the board engine: the sandbox may then also read @rulecad/pcb and what
|
|
14
|
+
// it loads (tscircuit's packages), the design gets v.pcb as it would in the tool's process (v.pcb.mount reads the
|
|
15
|
+
// workspace's thread sets, handed in as data), the runner builds the board's Circuit JSON, and the reply carries it
|
|
16
|
+
// (with the keyboard matrix and a cloned board's source) for the tool to check and make the board's solid and files
|
|
17
|
+
// from. The autorouter's results come back the same way as a lamina's stages, for the tool to keep.
|
|
14
18
|
import fs from 'node:fs';
|
|
15
19
|
import path from 'node:path';
|
|
16
20
|
import { spawn } from 'node:child_process';
|
|
@@ -33,7 +37,7 @@ export const sandboxed = () => !!flag && process.env.CAD_TRUST !== '1' && !(conf
|
|
|
33
37
|
|
|
34
38
|
// What the sandbox may read: the workspace, and the packages designs and the runner load (wherever npm put them), and
|
|
35
39
|
// what those load in turn (@rulecad/frames sizes a beam's operations through @rulecad/fixings)
|
|
36
|
-
function readable() {
|
|
40
|
+
function readable({ board = false, extra = [] } = {}) {
|
|
37
41
|
const real = (p) => { try { return fs.realpathSync(p); } catch { return null; } };
|
|
38
42
|
const pkgDir = (name, from) => { // the package's folder: from its entry up to its package.json (exports may hide that file)
|
|
39
43
|
try { let d = path.dirname(nodeModule.createRequire(from).resolve(name)); while (!fs.existsSync(path.join(d, 'package.json')) && path.dirname(d) !== d) d = path.dirname(d); return d; } catch { return null; }
|
|
@@ -42,8 +46,40 @@ function readable() {
|
|
|
42
46
|
// Every node_modules above the workspace and the tool (package lookups read their links), and where links lead
|
|
43
47
|
const up = (dir) => { const out = []; for (let d = dir; ; d = path.dirname(d)) { out.push(path.join(d, 'node_modules')); if (path.dirname(d) === d) return out; } };
|
|
44
48
|
const dirs = [WS, TOOL, ...[...up(WS), ...up(TOOL)].filter((d) => fs.existsSync(d)),
|
|
45
|
-
...['@jscad/modeling', '@rulecad/shapes', '@rulecad/flexures', '@rulecad/gears', '@rulecad/motors', '@rulecad/frames', '@rulecad/fixings', '@rulecad/rules/x1c.json', '@rulecad/fea', '@rulecad/variables', 'manifold-3d'].flatMap((n) => [pkgDir(n, fromWs), pkgDir(n, fromTool)])];
|
|
46
|
-
|
|
49
|
+
...['@jscad/modeling', '@rulecad/shapes', '@rulecad/flexures', '@rulecad/gears', '@rulecad/motors', '@rulecad/frames', '@rulecad/fixings', '@rulecad/rules/x1c.json', '@rulecad/fea', '@rulecad/variables', 'manifold-3d'].flatMap((n) => [pkgDir(n, fromWs), pkgDir(n, fromTool)]), ...extra];
|
|
50
|
+
const out = [...new Set(dirs.filter(Boolean).flatMap((d) => [d, real(d)]).filter(Boolean))];
|
|
51
|
+
// A board's engine loads tscircuit's packages and @rulecad's own (smooth, rules, fixings): what it depends on, and
|
|
52
|
+
// what they do in turn, wherever each really is. Most are in a node_modules listed above; a package linked in from
|
|
53
|
+
// elsewhere (a workspace of packages, as rulecad's own repository is) is added by its real folder.
|
|
54
|
+
if (board) out.push(...(engineDirs ||= engineFolders(out, real, pkgDir, fromTool))); // (found once a run: the packages don't move under it)
|
|
55
|
+
return out;
|
|
56
|
+
}
|
|
57
|
+
let engineDirs = null;
|
|
58
|
+
// A package's name as npm allows it: never a path ("/home/me/.ssh/key", "../..") that would lead the walk below anywhere
|
|
59
|
+
const PACKAGE_NAME = /^(@[a-z0-9][\w.~-]*\/)?[a-z0-9][\w.~-]*$/i;
|
|
60
|
+
// The real folders of @rulecad/pcb and every package it loads, but those inside a folder the sandbox already reads.
|
|
61
|
+
// The engine the runner loads is the tool's own (sandbox-run.mjs imports it from here), so the walk starts there, never
|
|
62
|
+
// at a copy in the workspace: a workspace's node_modules is the workspace's to write, and a package.json there naming
|
|
63
|
+
// "dependencies" that lead out of it (a link, a path) would have the sandbox read wherever they lead. Each dependency is
|
|
64
|
+
// a package name, and its folder one whose package.json has that name.
|
|
65
|
+
function engineFolders(out, real, pkgDir, from) {
|
|
66
|
+
const found = [], seen = new Set(), under = (d) => out.some((o) => d === o || d.startsWith(o + path.sep));
|
|
67
|
+
const named = (d, n) => { try { return JSON.parse(fs.readFileSync(path.join(d, 'package.json'), 'utf8')).name === n; } catch { return false; } };
|
|
68
|
+
// (the folder found, or the one above it of that name: by its entry, a package's dist/package.json may be found first,
|
|
69
|
+
// but never above the node_modules it is in)
|
|
70
|
+
const own = (d, n) => { for (; d && path.basename(d) !== 'node_modules' && path.dirname(d) !== d; d = path.dirname(d)) if (named(d, n)) return d; return null; };
|
|
71
|
+
const add = (d, n) => { d = d && own(d, n); if (!d || seen.has(d)) return; seen.add(d); if (!under(d)) found.push(d); walk(d); };
|
|
72
|
+
const find = (n, dir) => { // (findPackageJSON where Node has it: exports that hide a package's entry from require don't hide this)
|
|
73
|
+
const at = path.join(dir, 'package.json');
|
|
74
|
+
try { if (nodeModule.findPackageJSON) { const f = nodeModule.findPackageJSON(n, pathToFileURL(at)); if (f) return real(path.dirname(f)); } } catch { /* by its entry, below */ }
|
|
75
|
+
return real(pkgDir(n, at) || '');
|
|
76
|
+
};
|
|
77
|
+
function walk(dir) {
|
|
78
|
+
let j; try { j = JSON.parse(fs.readFileSync(path.join(dir, 'package.json'), 'utf8')); } catch { return; }
|
|
79
|
+
for (const n of Object.keys({ ...j.dependencies, ...j.optionalDependencies, ...j.peerDependencies })) if (PACKAGE_NAME.test(n)) add(find(n, dir), n);
|
|
80
|
+
}
|
|
81
|
+
add(real(pkgDir('@rulecad/pcb', from) || ''), '@rulecad/pcb');
|
|
82
|
+
return found;
|
|
47
83
|
}
|
|
48
84
|
|
|
49
85
|
// A read the permission model refused, said with what to do. Node names the first path it may not read; when that is
|
|
@@ -58,16 +94,123 @@ function refused(e) {
|
|
|
58
94
|
: `the design's sandbox was refused ${res}: a design may read only its workspace and the packages it uses. Keep what it needs inside the workspace, ${trust}`;
|
|
59
95
|
}
|
|
60
96
|
|
|
97
|
+
// The child's reply is untrusted input. The design shares the runner's process, so it can print anything on the
|
|
98
|
+
// stdout the reply is read from, and end the process before the runner prints the real one. So every field is checked
|
|
99
|
+
// before it is used (checkReply), and the only thing written from it is a stage of the cache: under a key of the form
|
|
100
|
+
// the stage cache makes (@rulecad/flexures cache.mjs: `${name}-${sha256 hex}`, a name such as "physics" or "flood
|
|
101
|
+
// probe"), as a file directly in the stages folder (stageFile). A reply that is not one the runner makes is refused
|
|
102
|
+
// whole, with nothing written.
|
|
103
|
+
|
|
104
|
+
/** The form of a stage's key, as the stage cache makes it: a stage's name, a dash and the 64 hex digits of a SHA-256. */
|
|
105
|
+
export const STAGE_KEY = /^[a-z][a-z0-9 _-]{0,39}-[0-9a-f]{64}$/;
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* The file a stage of the cache is kept in, or null when its key would put it anywhere but directly in `dir`.
|
|
109
|
+
* @param {string} dir the stages folder @param {unknown} key @returns {string | null}
|
|
110
|
+
*/
|
|
111
|
+
export function stageFile(dir, key) {
|
|
112
|
+
if (typeof key !== 'string' || !key) return null;
|
|
113
|
+
const file = path.resolve(dir, `${key}.json`), rel = path.relative(path.resolve(dir), file);
|
|
114
|
+
return rel && !path.isAbsolute(rel) && !rel.split(/[\\/]/).includes('..') && path.basename(rel) === rel ? file : null;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
const plain = (x) => x !== null && typeof x === 'object' && !Array.isArray(x) && Object.getPrototypeOf(x) === Object.prototype;
|
|
118
|
+
const point = (p) => Array.isArray(p) && p.length === 3 && p.every((n) => typeof n === 'number' && Number.isFinite(n));
|
|
119
|
+
const faceList = (x) => Array.isArray(x) && x.every((f) => Array.isArray(f) && f.every(point));
|
|
120
|
+
const PART = { name: 'string', role: 'string', label: 'string', filament: 'string', mirror: 'boolean' }, PART_FACES = ['solid', 'polygons', 'triangles'];
|
|
121
|
+
const REPLY = ['parts', 'read', 'mechanism', 'fixings', 'stages', 'board', 'mounted', 'routes'], ERROR = { message: 'string', code: 'string', line: 'number', syntax: 'boolean', resource: 'string' };
|
|
122
|
+
const fields = (o, kinds) => Object.entries(o).find(([k, x]) => !(k in kinds) || typeof x !== kinds[k]);
|
|
123
|
+
|
|
124
|
+
/** The form of a route's key, as @rulecad/pcb's route cache makes it: the 64 hex digits of a SHA-256. */
|
|
125
|
+
export const ROUTE_KEY = /^[0-9a-f]{64}$/;
|
|
126
|
+
// A key JSON.parse keeps as a plain field that Object.assign and the like would take as the object's prototype
|
|
127
|
+
const polluting = (x) => {
|
|
128
|
+
for (const stack = [x]; stack.length;) {
|
|
129
|
+
const o = stack.pop();
|
|
130
|
+
if (o === null || typeof o !== 'object') continue;
|
|
131
|
+
if (!Array.isArray(o) && Object.hasOwn(o, '__proto__')) return true;
|
|
132
|
+
for (const v of Array.isArray(o) ? o : Object.values(o)) if (v !== null && typeof v === 'object') stack.push(v);
|
|
133
|
+
}
|
|
134
|
+
return false;
|
|
135
|
+
};
|
|
136
|
+
// A board's reply: its Circuit JSON (a list of elements, each with its type), and the matrix and source the design gave
|
|
137
|
+
function checkBoard(b) {
|
|
138
|
+
if (!plain(b)) return 'its board is not an object';
|
|
139
|
+
const extra = Object.keys(b).find((k) => !['circuit', 'matrix', 'source'].includes(k));
|
|
140
|
+
if (extra) return `its board has a field "${extra}" the runner doesn't send`;
|
|
141
|
+
if (!Array.isArray(b.circuit) || !b.circuit.length || !b.circuit.every((e) => plain(e) && typeof e.type === 'string')) return 'its board\'s circuit is not a list of circuit elements';
|
|
142
|
+
if (b.matrix != null && !(plain(b.matrix) || Array.isArray(b.matrix))) return 'its board\'s matrix is not an object';
|
|
143
|
+
if (b.source != null && !plain(b.source)) return 'its board\'s source is not an object';
|
|
144
|
+
if (polluting(b)) return 'its board has a field named __proto__';
|
|
145
|
+
return null;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
/**
|
|
149
|
+
* What is wrong with a reply from the sandbox's runner, in a few words, or null when it is one the runner makes:
|
|
150
|
+
* `{ parts, read, mechanism?, fixings?, stages? }`, a board design's `{ parts: [], read, board: { circuit, matrix?,
|
|
151
|
+
* source? }, mounted?, fixings?, routes? }`, or `{ error }`.
|
|
152
|
+
* @param {unknown} r the child's stdout, parsed @returns {string | null}
|
|
153
|
+
*/
|
|
154
|
+
export function checkReply(r) {
|
|
155
|
+
if (!plain(r)) return 'it is not an object';
|
|
156
|
+
if ('error' in r) {
|
|
157
|
+
if (Object.keys(r).length !== 1 || !plain(r.error)) return 'its error is not one the runner makes';
|
|
158
|
+
const bad = fields(r.error, ERROR);
|
|
159
|
+
return bad ? `its error's ${bad[0]} is not one the runner makes` : typeof r.error.message !== 'string' ? 'its error has no message' : null;
|
|
160
|
+
}
|
|
161
|
+
const extra = Object.keys(r).find((k) => !REPLY.includes(k));
|
|
162
|
+
if (extra) return `it has a field "${extra}" the runner doesn't send`;
|
|
163
|
+
if (!Array.isArray(r.parts)) return 'it has no list of parts';
|
|
164
|
+
for (const p of r.parts) {
|
|
165
|
+
if (!plain(p)) return 'a part is not an object';
|
|
166
|
+
const bad = Object.entries(p).find(([k, x]) => !(PART_FACES.includes(k) ? faceList(x) : k in PART && typeof x === PART[k]));
|
|
167
|
+
if (bad) return `a part's ${bad[0]} is not one the runner makes`;
|
|
168
|
+
if (typeof p.name !== 'string' || PART_FACES.some((k) => !(k in p))) return 'a part has no name or no faces';
|
|
169
|
+
}
|
|
170
|
+
if (!Array.isArray(r.read) || !r.read.every((n) => typeof n === 'string')) return 'what it read is not a list of names';
|
|
171
|
+
if (r.mechanism != null && !plain(r.mechanism)) return 'its mechanism is not an object';
|
|
172
|
+
if (r.fixings != null && !(Array.isArray(r.fixings) && r.fixings.every(plain))) return 'its fixings are not a list of findings';
|
|
173
|
+
if (r.stages != null) {
|
|
174
|
+
if (!plain(r.stages)) return 'its stages are not an object';
|
|
175
|
+
const bad = Object.entries(r.stages).find(([k, text]) => !STAGE_KEY.test(k) || typeof text !== 'string');
|
|
176
|
+
if (bad) return STAGE_KEY.test(bad[0]) ? 'a stage is not text' : 'a stage\'s key is not one the stage cache makes';
|
|
177
|
+
}
|
|
178
|
+
if (r.board != null) { const bad = checkBoard(r.board); if (bad) return bad; if (r.parts.length) return 'a board\'s reply has parts of its own'; }
|
|
179
|
+
if (r.mounted != null && typeof r.mounted !== 'boolean') return 'its "mounted" is not true or false';
|
|
180
|
+
if (r.routes != null) {
|
|
181
|
+
if (r.board == null) return 'it has routes but no board';
|
|
182
|
+
if (!plain(r.routes)) return 'its routes are not an object';
|
|
183
|
+
const bad = Object.entries(r.routes).find(([k, text]) => !ROUTE_KEY.test(k) || typeof text !== 'string');
|
|
184
|
+
if (bad) return ROUTE_KEY.test(bad[0]) ? 'a route is not text' : 'a route\'s key is not one the route cache makes';
|
|
185
|
+
}
|
|
186
|
+
if (r.mechanism != null && polluting(r.mechanism)) return 'its mechanism has a field named __proto__';
|
|
187
|
+
return null;
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
/** Whether designs can be sandboxed here at all: Node has the permission model. */
|
|
191
|
+
export const canSandbox = () => !!flag;
|
|
192
|
+
|
|
61
193
|
/**
|
|
62
|
-
* Run a design's main(values) in the sandbox: { parts, read } as the build makes them
|
|
63
|
-
*
|
|
64
|
-
*
|
|
65
|
-
*
|
|
66
|
-
*
|
|
194
|
+
* Run a design's main(values) in the sandbox: { parts, read, mechanism, fixings } as the build makes them, and for a
|
|
195
|
+
* board design (board set) its { board: { circuit, matrix?, source? }, mounted } too, parts empty: the tool makes the
|
|
196
|
+
* board's solid from its circuit.
|
|
197
|
+
* The design shares the runner's process and can print anything, so every field of the reply is checked as untrusted
|
|
198
|
+
* input (checkReply), and only stage and route files of the caches are written from it.
|
|
199
|
+
* @param {object} request
|
|
200
|
+
* @param {{ js: string }} request.d the design
|
|
201
|
+
* @param {object} request.values @param {object} request.meta the .json's parts
|
|
202
|
+
* @param {'jscad' | 'manifold'} [request.engine] v.ops's booleans
|
|
203
|
+
* @param {string[]} [request.optional] names main may read that aren't among the values (the display's own inputs)
|
|
204
|
+
* @param {{ salt: string, get: (k: string) => string | undefined, put: (k: string, text: string) => void } | null} [request.stages] where a lamina's slow stages are kept: the child reads them from the cache (it may read the workspace) and hands back what it made, which is written here
|
|
205
|
+
* @param {{ frames?: object, fixings?: { sets?: object, printer?: object, material?: string | null } | null }} [request.bound] what the design's helpers are bound to: frames, the workspace's profile sets (lib/frames.mjs framesContext); fixings, what v.fixings is bound to (design.mjs fixingsContext), whose calls come back as fixings. A board's v.pcb.mount reads fixings.sets too
|
|
206
|
+
* @param {{ routes?: { dir: string, put: (k: string, text: string) => void } | null } | null} [request.board] set for a board design (engine pcb): routes, where the autorouter's results are kept (the child reads the folder; what it routes is handed back and put here)
|
|
207
|
+
* @param {string[]} [request.read] more folders the sandbox may read (a copy of a workspace held in memory)
|
|
208
|
+
* @returns {Promise<{ parts: object[], read: Set<string>, mechanism: object | null, fixings: object[] | null, board?: { circuit: object[], matrix?: object, source?: object }, mounted?: boolean }>}
|
|
67
209
|
*/
|
|
68
|
-
export function runSandboxed(d, values, meta, engine = 'jscad', optional = [], stages = null, bound = {}) {
|
|
210
|
+
export function runSandboxed({ d, values, meta, engine = 'jscad', optional = [], stages = null, bound = {}, board = null, read: more = [] }) {
|
|
69
211
|
const here = path.dirname(fileURLToPath(import.meta.url));
|
|
70
|
-
const
|
|
212
|
+
const routes = board?.routes?.dir ? [path.resolve(board.routes.dir)] : []; // (a route cache the user put outside the workspace, RULECAD_ROUTE_CACHE: read there, or every build routes again)
|
|
213
|
+
const args = [flag, ...readable({ board: !!board, extra: [...more, ...routes] }).map((p) => `--allow-fs-read=${p}`), ...(inThread ? [] : ['--allow-worker']), '--import', pathToFileURL(path.join(here, 'sandbox-preload.mjs')).href, path.join(here, 'sandbox-run.mjs')];
|
|
71
214
|
// (real paths: Node names an imported file by where it really is, so a workspace reached through a link still matches)
|
|
72
215
|
const js = fs.realpathSync(d.js), project = pathToFileURL(path.dirname(path.dirname(js)) + path.sep).href, stagesDir = paths.cache('stages');
|
|
73
216
|
// The child gets none of this process's environment but what Node needs to start: tokens and keys stay out of it
|
|
@@ -84,10 +227,15 @@ export function runSandboxed(d, values, meta, engine = 'jscad', optional = [], s
|
|
|
84
227
|
return reject(located(new Error(`the design's sandbox stopped: ${Buffer.concat(err).toString('utf8').trim().split('\n').slice(-3).join(' ') || 'no output'}`), d.js, 'design.sandbox'));
|
|
85
228
|
}
|
|
86
229
|
if (err.length) process.stderr.write(Buffer.concat(err)); // what the design printed
|
|
230
|
+
const wrong = checkReply(r) || (!board && r.board != null ? 'it has a board, and the design is not one' : board && r.board == null && !r.error ? 'a board design\'s reply has no board' : null); // (every field is untrusted: see checkReply)
|
|
231
|
+
if (wrong) return reject(located(new Error(`the design's reply was not one rulecad makes (${wrong}), so none of it was used and nothing it sent was written. A design gives back its shapes from main(v); one that writes to the process's output itself or ends the process is refused`), d.js, 'design.sandbox'));
|
|
87
232
|
if (r.error) return reject(located(Object.assign(new Error(refused(r.error)), { code: r.error.code, ...(r.error.line ? { line: r.error.line } : {}), ...(r.error.syntax ? { name: 'SyntaxError' } : {}) }), d.js, r.error.code || 'design.run'));
|
|
88
233
|
if (stages) for (const [k, text] of Object.entries(r.stages || {})) stages.put(k, text);
|
|
89
|
-
|
|
234
|
+
if (board?.routes) for (const [k, text] of Object.entries(r.routes || {})) board.routes.put(k, text);
|
|
235
|
+
resolve({ parts: r.parts.map(({ solid, ...p }) => ({ ...p, geometry: fromFaces(solid) })), read: new Set(r.read), mechanism: r.mechanism || null, fixings: r.fixings || null,
|
|
236
|
+
...(board ? { board: r.board, mounted: r.mounted === true } : {}) });
|
|
90
237
|
});
|
|
91
|
-
child.stdin.end(JSON.stringify({ js: `${pathToFileURL(js).href}?t=${fs.statSync(js).mtimeMs}`, values, meta, engine, optional, ...(stages ? { stages: { dir: stagesDir, salt: stages.salt } } : {}), bound
|
|
238
|
+
child.stdin.end(JSON.stringify({ js: `${pathToFileURL(js).href}?t=${fs.statSync(js).mtimeMs}`, values, meta, engine, optional, ...(stages ? { stages: { dir: stagesDir, salt: stages.salt } } : {}), bound,
|
|
239
|
+
...(board ? { board: { ...(board.routes ? { routes: path.resolve(board.routes.dir) } : {}) } } : {}) }));
|
|
92
240
|
});
|
|
93
241
|
}
|
package/lib/schema.mjs
CHANGED
|
@@ -37,7 +37,8 @@ export function validate(value, s, root = s, at = '') {
|
|
|
37
37
|
if (!types.some((t) => fits(value, t))) return [{ path: here, message: `should be ${types.join(' or ')}, not ${typeOf(value)}` }];
|
|
38
38
|
}
|
|
39
39
|
if (s.enum && !s.enum.includes(value)) out.push({ path: here, message: `should be one of ${s.enum.map((x) => JSON.stringify(x)).join(', ')} (got ${JSON.stringify(value)})` });
|
|
40
|
-
|
|
40
|
+
// (a pattern with a description says what it wants in words; one without, the pattern itself)
|
|
41
|
+
if (s.pattern && typeof value === 'string' && !new RegExp(s.pattern).test(value)) out.push({ path: here, message: `"${value}" isn't in the expected form: ${s.description || s.pattern}` });
|
|
41
42
|
if (typeOf(value) === 'object') {
|
|
42
43
|
for (const k of s.required || []) if (!(k in value)) out.push({ path: here, message: `needs "${k}"` });
|
|
43
44
|
const props = s.properties || {};
|
package/lib/targets.mjs
CHANGED
|
@@ -1,22 +1,40 @@
|
|
|
1
|
-
// Targets: optional extras the command hands work to, named in cad.config.json's "targets". A name is
|
|
2
|
-
// (gist) or a module path
|
|
1
|
+
// Targets: optional extras the command hands work to, named in cad.config.json's "targets". A name is either exactly one
|
|
2
|
+
// of the kit's own (OWN_TARGETS in workspace.mjs: today only "gist"), or a module path inside the workspace, so anyone
|
|
3
|
+
// can add their own (a smart mirror, a slicer, a printer). Every name but the kit's own is the workspace's code: it runs
|
|
4
|
+
// in the tool's process, so only once the workspace is trusted (cad trust), and never from outside the workspace. No
|
|
5
|
+
// path is ever made from a name to find one of the kit's own.
|
|
3
6
|
// show: export async function show({ title, ttl, mesh, card }) puts a model somewhere to look at.
|
|
4
7
|
// mesh: { polygons } (one solid) or { shapes, place } (each shape once, then a 3 × 4 transform per copy);
|
|
5
8
|
// card: { title, items } (short lines) to go with it
|
|
6
9
|
// shorten: export async function shorten(data, { desc }) stores a model link's data and returns an ID for #s=<id>
|
|
7
|
-
import fs from 'node:fs';
|
|
8
10
|
import path from 'node:path';
|
|
9
11
|
import { pathToFileURL } from 'node:url';
|
|
10
|
-
import { WS, config, needTrust } from './workspace.mjs';
|
|
12
|
+
import { WS, config, needTrust, isOwnTarget, OWN_TARGETS } from './workspace.mjs';
|
|
11
13
|
|
|
14
|
+
/** Whether cad.config.json names a target of this kind ("show", "shorten"). */
|
|
12
15
|
export const hasTarget = (kind) => !!config.targets?.[kind];
|
|
13
16
|
|
|
17
|
+
/**
|
|
18
|
+
* The function a target of this kind exports, loaded: one of the kit's own by its exact name, else the workspace's own
|
|
19
|
+
* module, once the workspace is trusted and only from inside it.
|
|
20
|
+
* @param {string} kind "show" or "shorten"
|
|
21
|
+
* @returns {Promise<Function>}
|
|
22
|
+
*/
|
|
14
23
|
export async function target(kind) {
|
|
15
24
|
const name = config.targets?.[kind];
|
|
16
25
|
if (!name) throw new Error(`no "${kind}" target: name one in cad.config.json ("targets": { "${kind}": … })`);
|
|
17
|
-
|
|
18
|
-
if (
|
|
19
|
-
|
|
26
|
+
let href;
|
|
27
|
+
if (isOwnTarget(name)) href = OWN_TARGETS[name];
|
|
28
|
+
else {
|
|
29
|
+
needTrust(); // (the workspace's own code, run in the tool's process: only once it is trusted)
|
|
30
|
+
if (typeof name !== 'string') throw new Error(`the ${kind} target in cad.config.json should be the name of a module file, not ${JSON.stringify(name)}`);
|
|
31
|
+
const file = path.resolve(WS, name), rel = path.relative(WS, file);
|
|
32
|
+
if (!rel || rel === '..' || rel.startsWith(`..${path.sep}`) || path.isAbsolute(rel)) {
|
|
33
|
+
throw Object.assign(new Error(`the ${kind} target ${name} (cad.config.json) is outside this workspace (${WS}), so it isn't run. Put the module in the workspace's folder and name it from there`), { code: 'workspace.outside' });
|
|
34
|
+
}
|
|
35
|
+
href = pathToFileURL(file).href;
|
|
36
|
+
}
|
|
37
|
+
const mod = await import(href);
|
|
20
38
|
if (typeof mod[kind] !== 'function') throw new Error(`target ${name} has no ${kind}()`);
|
|
21
39
|
return mod[kind];
|
|
22
40
|
}
|
package/lib/versions.mjs
CHANGED
|
@@ -11,6 +11,7 @@ import { fileURLToPath } from 'node:url';
|
|
|
11
11
|
import crypto from 'node:crypto';
|
|
12
12
|
import { resolve, loadRuleSet } from './rules.mjs';
|
|
13
13
|
import { WS, paths } from './workspace.mjs';
|
|
14
|
+
import { plainName, isPlainName } from './names.mjs';
|
|
14
15
|
import { readLayout, hasLayout } from './layout.mjs';
|
|
15
16
|
import { newer } from '@rulecad/versions';
|
|
16
17
|
|
|
@@ -57,10 +58,11 @@ export function materialise(d, version) {
|
|
|
57
58
|
const js = path.join(base, `${d.name}.js`), json = path.join(base, `${d.name}.json`);
|
|
58
59
|
fs.writeFileSync(js, show(rel(d.js)));
|
|
59
60
|
fs.writeFileSync(json, JSON.stringify(object, null, 2));
|
|
60
|
-
|
|
61
|
+
// (names from the release's own file, each written as a file here: plain names only, never ../)
|
|
62
|
+
for (const u of (object.uses || []).filter((x) => !x.includes('/'))) fs.writeFileSync(path.join(base, 'rules', `${plainName(u, 'rule set name', `${tag}'s ${d.name}.json, in its "uses"`)}.json`), show(`rules/${u}.json`)); // objects it reads are released on their own
|
|
61
63
|
// The layouts it could pick, as they were then (only files that existed in that release)
|
|
62
64
|
fs.mkdirSync(path.join(base, 'layouts'), { recursive: true });
|
|
63
|
-
for (const v of Object.values(object.variables || {})) if (v.type === 'layout') for (const n of v.choice || [v.value]) {
|
|
65
|
+
for (const v of Object.values(object.variables || {})) if (v.type === 'layout') for (const n of (v.choice || [v.value]).filter(isPlainName)) { // (another name is refused where the layout is read)
|
|
64
66
|
try { fs.writeFileSync(path.join(base, 'layouts', `${n}.json`), show(`projects/${d.project}/layouts/${n}.json`)); } catch {} // a built-in (grid)
|
|
65
67
|
}
|
|
66
68
|
return { ...d, js, json, rulesDir: path.join(base, 'rules'), layoutsDir: path.join(base, 'layouts'), version, tag };
|
|
@@ -84,7 +86,7 @@ const engineLibs = () => ENGINE_LIBS.map((n) => `${n}@${packageVersion(n, import
|
|
|
84
86
|
const engineHash = (code) => crypto.createHash('sha256').update(`${code.trimEnd()}\n${engineLibs()}`).digest('hex').slice(0, 16);
|
|
85
87
|
// The board engine's code: @rulecad/pcb's modules, and @rulecad/smooth's, which a board's build runs too (smoothing its
|
|
86
88
|
// tracks, finishing them): a change to either is a change to what a board builds, so it must miss the cache
|
|
87
|
-
const sources = (dir) => fs.readdirSync(dir).filter((f) => f.endsWith('.mjs') && f !== 'test.mjs').sort().map((f) => fs.readFileSync(path.join(dir, f), 'utf8')).join('\n');
|
|
89
|
+
const sources = (dir) => fs.readdirSync(dir).filter((f) => f.endsWith('.mjs') && f !== 'test.mjs' && !f.startsWith('.')).sort().map((f) => fs.readFileSync(path.join(dir, f), 'utf8')).join('\n');
|
|
88
90
|
export const engineId = () => {
|
|
89
91
|
const pcb = import.meta.resolve('@rulecad/pcb'), dir = path.dirname(fileURLToPath(pcb));
|
|
90
92
|
const smooth = path.dirname(createRequire(pcb).resolve('@rulecad/smooth'));
|
package/lib/workspace.mjs
CHANGED
|
@@ -10,6 +10,7 @@ import fs from 'node:fs';
|
|
|
10
10
|
import path from 'node:path';
|
|
11
11
|
import { host, readJson } from './host.mjs';
|
|
12
12
|
import { fileURLToPath } from 'node:url';
|
|
13
|
+
import { plainName } from './names.mjs';
|
|
13
14
|
|
|
14
15
|
export const TOOL = fileURLToPath(new URL('..', import.meta.url)).replace(/[\\/]$/, '');
|
|
15
16
|
|
|
@@ -37,28 +38,38 @@ export const RULE_DIRS = [...new Set([path.join(WS, 'rules'), path.dirname(fileU
|
|
|
37
38
|
|
|
38
39
|
export const paths = {
|
|
39
40
|
projects: path.join(WS, 'projects'),
|
|
40
|
-
project: (p) => path.join(WS, 'projects', p),
|
|
41
|
+
project: (p) => path.join(WS, 'projects', plainName(p, 'project name')), // (a name from a file or the command line: never ../)
|
|
41
42
|
cache: (...p) => path.join(WS, '.cache', ...p),
|
|
42
43
|
preview: (...p) => path.join(WS, '.preview', ...p),
|
|
43
44
|
exports: (...p) => path.join(WS, 'exports', ...p),
|
|
44
45
|
versions: (...p) => path.join(WS, '.versions', ...p),
|
|
45
46
|
};
|
|
46
47
|
|
|
47
|
-
// The printer a project's prints are checked against
|
|
48
|
+
// The printer a project's prints are checked against: project.json's "printer", else cad.config.json's. Either is a
|
|
49
|
+
// rule set's name, which becomes part of a path (rules/<printer>.json, and the kit's), so it must be a plain name.
|
|
48
50
|
export const printerOf = (project) => {
|
|
49
51
|
const f = project && path.join(paths.project(project), 'project.json');
|
|
50
|
-
|
|
52
|
+
const own = f && host.exists(f) && readJson(f).printer;
|
|
53
|
+
if (own) return plainName(own, '"printer" field', path.relative(WS, f));
|
|
54
|
+
return plainName(config.printer, '"printer" field', 'cad.config.json');
|
|
51
55
|
};
|
|
52
56
|
|
|
53
|
-
// Trust: a workspace that turns the design sandbox off ("sandbox": false)
|
|
54
|
-
//
|
|
57
|
+
// Trust: a workspace that turns the design sandbox off ("sandbox": false) or runs code of its own as a target (any
|
|
58
|
+
// name but one of the kit's own, below) runs that code outside the sandbox. (Board designs run in the sandbox, as
|
|
59
|
+
// every design does: they ask nothing.) A workspace cloned from elsewhere
|
|
55
60
|
// could do that on its first command, so it is asked once: cad trust records this folder, with what it asked for, in
|
|
56
61
|
// the user's own list (~/.config/rulecad/trusted.json, or $CAD_TRUSTED); asking for more later is asked again.
|
|
57
62
|
import os from 'node:os';
|
|
58
63
|
const TRUSTED = () => process.env.CAD_TRUSTED || path.join(os.homedir(), '.config', 'rulecad', 'trusted.json');
|
|
64
|
+
// The kit's own targets, by exact name. A target is the kit's own only if its name is a key here, never because of
|
|
65
|
+
// what its name looks like or because a file of that name happens to be in the kit: anything else in "targets" (a bare
|
|
66
|
+
// name, a path with / or \, a ../ name that reaches one of the kit's modules) is the workspace's code, and asked about.
|
|
67
|
+
export const OWN_TARGETS = Object.freeze(Object.assign(Object.create(null), { gist: new URL('./targets/gist.mjs', import.meta.url).href }));
|
|
68
|
+
/** Whether a target name in cad.config.json is one of the kit's own (exactly a key of OWN_TARGETS). */
|
|
69
|
+
export const isOwnTarget = (name) => typeof name === 'string' && Object.hasOwn(OWN_TARGETS, name);
|
|
59
70
|
/** What this workspace asks to run outside the sandbox: [] when nothing. */
|
|
60
71
|
export function asks(cfg = config) {
|
|
61
|
-
const own = Object.entries(cfg.targets || {}).filter(([, v]) =>
|
|
72
|
+
const own = Object.entries(cfg.targets || {}).filter(([, v]) => v && !isOwnTarget(v)).map(([k, v]) => `the ${k} target ${typeof v === 'string' ? v : JSON.stringify(v)}`);
|
|
62
73
|
return [...(cfg.sandbox === false ? ['designs run outside the sandbox'] : []), ...own].sort();
|
|
63
74
|
}
|
|
64
75
|
const trustList = () => { try { return JSON.parse(fs.readFileSync(TRUSTED(), 'utf8')); } catch { return {}; } };
|
|
@@ -66,7 +77,10 @@ const trustList = () => { try { return JSON.parse(fs.readFileSync(TRUSTED(), 'ut
|
|
|
66
77
|
export const trusted = (cfg = config) => { const a = asks(cfg); if (!a.length || process.env.CAD_TRUST === '1') return true; const t = trustList()[WS]; return !!t && a.every((x) => t.includes(x)); };
|
|
67
78
|
/** Trust this workspace for what it asks now. */
|
|
68
79
|
export function trust(cfg = config) { const list = trustList(); list[WS] = asks(cfg); fs.mkdirSync(path.dirname(TRUSTED()), { recursive: true }); fs.writeFileSync(TRUSTED(), JSON.stringify(list, null, 2) + '\n'); return list[WS]; }
|
|
69
|
-
/**
|
|
80
|
+
/**
|
|
81
|
+
* Throws, saying what it asks, where it asks it and how to allow it, when this workspace isn't trusted for what it asks.
|
|
82
|
+
* @param {object} [cfg]
|
|
83
|
+
*/
|
|
70
84
|
export function needTrust(cfg = config) {
|
|
71
85
|
if (trusted(cfg)) return;
|
|
72
86
|
throw Object.assign(new Error(`this workspace asks for ${asks(cfg).join(' and ')} (cad.config.json). If you trust it, run cad trust once; until then, it isn't done`), { code: 'workspace.untrusted' });
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rulecad/cad",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.8.0",
|
|
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": {
|
|
@@ -61,24 +61,24 @@
|
|
|
61
61
|
"@rulecad/variables": "^0.3.7",
|
|
62
62
|
"@rulecad/keyboard-layout": "^0.1.2",
|
|
63
63
|
"@rulecad/printcheck": "^0.3.3",
|
|
64
|
-
"@rulecad/fit": "^0.4.
|
|
65
|
-
"@rulecad/model-link": "^0.3.
|
|
64
|
+
"@rulecad/fit": "^0.4.1",
|
|
65
|
+
"@rulecad/model-link": "^0.3.3",
|
|
66
66
|
"@rulecad/versions": "^0.1.6",
|
|
67
67
|
"@rulecad/shapes": "^0.4.9",
|
|
68
|
-
"@rulecad/rules": "^0.3.
|
|
68
|
+
"@rulecad/rules": "^0.3.31",
|
|
69
69
|
"@jscad/modeling": "^2.12.0",
|
|
70
70
|
"three": "^0.186.1",
|
|
71
|
-
"@rulecad/fea": "^0.
|
|
72
|
-
"@rulecad/topopt": "^0.3.
|
|
73
|
-
"@rulecad/flexures": "^0.5.
|
|
74
|
-
"@rulecad/gears": "^0.3.
|
|
71
|
+
"@rulecad/fea": "^0.3.0",
|
|
72
|
+
"@rulecad/topopt": "^0.3.9",
|
|
73
|
+
"@rulecad/flexures": "^0.5.18",
|
|
74
|
+
"@rulecad/gears": "^0.3.5",
|
|
75
75
|
"@rulecad/motors": "^0.1.6",
|
|
76
|
-
"@rulecad/fixings": "^0.1.
|
|
76
|
+
"@rulecad/fixings": "^0.1.9",
|
|
77
77
|
"@rulecad/robots": "^0.1.4",
|
|
78
|
-
"@rulecad/frames": "^0.1.
|
|
78
|
+
"@rulecad/frames": "^0.1.14"
|
|
79
79
|
},
|
|
80
80
|
"peerDependencies": {
|
|
81
|
-
"@rulecad/pcb": "^0.
|
|
81
|
+
"@rulecad/pcb": "^0.6.0"
|
|
82
82
|
},
|
|
83
83
|
"peerDependenciesMeta": {
|
|
84
84
|
"@rulecad/pcb": {
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
"version": { "type": "string", "pattern": "^\\d+\\.\\d+\\.\\d+" },
|
|
14
14
|
"description": { "type": "string" },
|
|
15
15
|
"note": { "type": "string" },
|
|
16
|
-
"uses": { "type": "array", "items": { "type": "string" }, "description": "Rule sets (x1c, m3) and other objects (project/object, optionally @version). A screw's holes need none listed: v.fixings reads the thread's set, the printer and the material itself" },
|
|
16
|
+
"uses": { "type": "array", "items": { "type": "string", "pattern": "^[A-Za-z0-9][A-Za-z0-9_-]*(/[A-Za-z0-9][A-Za-z0-9_-]*(:[^/@]+)?(@[^/]+)?)?$", "description": "a rule set's plain name (letters, digits, - and _, as x1c), or another object as <project>/<object>, optionally with :<variant> and @<version> (keyboard/keycap@^1.0.0), never a path to a file" }, "description": "Rule sets (x1c, m3) and other objects (project/object, optionally :variant and @version), each name plain: letters, digits, - and _. A screw's holes need none listed: v.fixings reads the thread's set, the printer and the material itself" },
|
|
17
17
|
"material": { "type": "string" },
|
|
18
18
|
"orientation": { "type": "string", "description": "How it sits on the bed, and anything the printer or the person assembling it should know" },
|
|
19
19
|
"role": { "enum": ["part", "reference", "board"], "description": "reference: drawn faint and never printed (a switch, a tablet); board: a circuit board" },
|
|
@@ -64,6 +64,10 @@
|
|
|
64
64
|
"$ref": "#/$defs/expr",
|
|
65
65
|
"description": "A strain limit in place of stress, a share of the length (0.02 is 2%), such as \"pla.strength / pla.modulus / 2\": the stress limit is it times the material's modulus. Most use for a mechanism, whose hinges bend"
|
|
66
66
|
},
|
|
67
|
+
"robust": {
|
|
68
|
+
"type": "boolean",
|
|
69
|
+
"description": "Optimise the design as made a little thin and a little thick too (its eroded and dilated copies, Wang, Lazarov and Sigmund 2011). With a stress or strain limit: the lightest layout that keeps the limit on all three. A mechanism: the one whose worst copy moves its output furthest, and with a limit, kept to it on all three (da Silva, Beck and Sigmund 2019); its supports, input and output stay solid. About three times the solves. Refused with a volume alone"
|
|
70
|
+
},
|
|
67
71
|
"filter": {
|
|
68
72
|
"$ref": "#/$defs/expr",
|
|
69
73
|
"description": "Filter radius, mm: about the thinnest member (default a cell and a half, and never under two of the printer's lines)"
|
|
@@ -190,14 +194,28 @@
|
|
|
190
194
|
"description": "One section all along this axis: a part cut from a bar, an extrusion or a plate of the profile"
|
|
191
195
|
},
|
|
192
196
|
"mill": {
|
|
193
|
-
"
|
|
194
|
-
"
|
|
195
|
-
|
|
197
|
+
"description": "Milled from this side ('+z': the tool cuts down from above): no undercuts, so a cell is as solid as every cell between it and the tool. Or from several sides, a setup each (['+z', '-z']: turned over for the second): a cell is left where no side's tool reaches it. Or a variable holding the side or sides ('+z', '+z -z') or 'none' (not milled), so a variant can switch it. Not with overhang or cast. Rules: mill-3axis",
|
|
198
|
+
"oneOf": [
|
|
199
|
+
{ "type": "string", "pattern": "^([+-][xyz]|[A-Za-z_][A-Za-z0-9_]*)$" },
|
|
200
|
+
{ "type": "array", "items": { "type": "string", "pattern": "^[+-][xyz]$" }, "minItems": 1, "uniqueItems": true }
|
|
201
|
+
]
|
|
202
|
+
},
|
|
203
|
+
"tool": {
|
|
204
|
+
"$ref": "#/$defs/expr",
|
|
205
|
+
"description": "With mill: the tool's radius, mm (a flat end mill). No pocket narrower than the tool, and every inside corner seen from the tool rounded to at least its radius. At the grid's resolution: the tool's end is the cells whose centres are within its radius, so give at least a cell. Rules: mill-3axis (an inside corner's radius)"
|
|
206
|
+
},
|
|
207
|
+
"feature": {
|
|
208
|
+
"$ref": "#/$defs/expr",
|
|
209
|
+
"description": "The thinnest member made, mm: for a printer, its two lines (x1c.wall_min). Members narrower go as the part is optimised, and cad optimise reports any left. Where a cell is as wide or wider, every member already is and nothing changes; up to three cells across it is held by an opening filter; wider is refused by name with the cell size that would hold it. Rules: x1c (wall_min, line)"
|
|
210
|
+
},
|
|
211
|
+
"draft": {
|
|
212
|
+
"$ref": "#/$defs/expr",
|
|
213
|
+
"description": "With cast: the draft, degrees. The part narrows towards the side it is drawn off: a wall steps out a cell every whole number of layers in 1 / tan(draft), so at least this draft; refused by name when the grid is too shallow for one step. Rules: mould-injection"
|
|
196
214
|
},
|
|
197
215
|
"cast": {
|
|
198
|
-
"description": "Cast or moulded: in a mould drawn off one way ('+z'), or in two halves drawn off both ways along an axis from a parting plane. No undercuts from the draw
|
|
216
|
+
"description": "Cast or moulded: in a mould drawn off one way ('+z'), or in two halves drawn off both ways along an axis from a parting plane. No undercuts from the draw, and with draft the walls taper. Not with overhang or mill. Rules: mould-injection",
|
|
199
217
|
"oneOf": [
|
|
200
|
-
{ "type": "string", "pattern": "^[+-][xyz]$" },
|
|
218
|
+
{ "type": "string", "pattern": "^([+-][xyz]|[A-Za-z_][A-Za-z0-9_]*)$", "description": "The way it is drawn off, or a variable holding it (or 'none': not cast)" },
|
|
201
219
|
{
|
|
202
220
|
"type": "object",
|
|
203
221
|
"additionalProperties": false,
|
|
@@ -210,8 +228,8 @@
|
|
|
210
228
|
]
|
|
211
229
|
},
|
|
212
230
|
"voids": {
|
|
213
|
-
"enum": ["allowed", "refused"],
|
|
214
|
-
"description": "Enclosed voids in the result: allowed (the default)
|
|
231
|
+
"enum": ["allowed", "refused", "prevented"],
|
|
232
|
+
"description": "Enclosed voids in the result: allowed (the default); refused, for metal powder bed printing (powder left inside can't be got out) or a casting's trapped core: cad optimise then reports each as an error with its volume and where it is; or prevented: the optimiser keeps every void open to the outside as it goes (a virtual temperature, kept under a cap: an enclosed void runs hot), and any left are still reported as errors. Prevented is for the stiffest part that fills a volume, not a mechanism or a stress limit. Rules: dmls"
|
|
215
233
|
},
|
|
216
234
|
"output": {
|
|
217
235
|
"type": "object",
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
"title": { "type": "string", "description": "What the project is, in a few words, for its pages and lists" },
|
|
13
13
|
"description": { "type": "string", "description": "A sentence or two on what it is for" },
|
|
14
14
|
"material": { "type": "string", "description": "The plastic its parts print in unless a part says otherwise: PLA or PETG, or a rule set in rules/ that gives strength, modulus and density. Printed fittings are sized from it" },
|
|
15
|
-
"printer": { "type": "string", "description": "The printer rule set its prints are checked against (bed, overhang, layer), as x1c; left out, cad.config.json's printer" },
|
|
15
|
+
"printer": { "type": "string", "pattern": "^([A-Za-z0-9][A-Za-z0-9_-]*)?$", "description": "The printer rule set its prints are checked against (bed, overhang, layer), as x1c; left out, cad.config.json's printer. A plain name: letters, digits, - and _" },
|
|
16
16
|
"objects": { "type": "array", "items": { "type": "string", "pattern": "^[a-z][a-z0-9-]*$" }, "description": "Its objects, by name, as cad new <project>/<object> lists them" },
|
|
17
17
|
"filaments": {
|
|
18
18
|
"type": "object",
|