@rulecad/cad 0.9.0 → 0.10.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.
Files changed (53) hide show
  1. package/AGENTS.md +21 -6
  2. package/CHANGELOG.md +320 -0
  3. package/EXAMPLES.md +22 -17
  4. package/README.md +192 -40
  5. package/bin/cad.mjs +465 -80
  6. package/lib/assembly.mjs +68 -33
  7. package/lib/cache-file.mjs +105 -0
  8. package/lib/code-text.mjs +28 -0
  9. package/lib/design-imports.mjs +127 -0
  10. package/lib/design.mjs +251 -55
  11. package/lib/designshapes.mjs +142 -0
  12. package/lib/edit.mjs +24 -2
  13. package/lib/estimates.mjs +51 -0
  14. package/lib/fasten.mjs +11 -5
  15. package/lib/fe-key.mjs +29 -0
  16. package/lib/fittings.mjs +20 -15
  17. package/lib/fixings.mjs +17 -4
  18. package/lib/framebuild.mjs +1 -1
  19. package/lib/framegen.mjs +9 -1
  20. package/lib/frames.mjs +6 -2
  21. package/lib/framesize.mjs +8 -81
  22. package/lib/host.mjs +7 -3
  23. package/lib/kit.mjs +5 -5
  24. package/lib/list.mjs +29 -21
  25. package/lib/loads.mjs +35 -23
  26. package/lib/measured.mjs +738 -98
  27. package/lib/motors.mjs +9 -29
  28. package/lib/names.mjs +15 -0
  29. package/lib/optimise.mjs +34 -25
  30. package/lib/order.mjs +4 -10
  31. package/lib/parts.mjs +3 -0
  32. package/lib/rules.mjs +2 -1
  33. package/lib/sandbox-hooks.mjs +109 -15
  34. package/lib/sandbox-lock.mjs +225 -0
  35. package/lib/sandbox-preload.mjs +2 -2
  36. package/lib/sandbox-run.mjs +22 -24
  37. package/lib/sandbox.mjs +173 -30
  38. package/lib/sheet.mjs +114 -3
  39. package/lib/versions.mjs +195 -32
  40. package/lib/workspace.mjs +3 -2
  41. package/package.json +11 -11
  42. package/schemas/assembly.schema.json +1 -1
  43. package/schemas/project.schema.json +6 -0
  44. package/templates/coupons/MEASURE.md +109 -0
  45. package/templates/coupons/assemblies/fixings-test.json +20 -0
  46. package/templates/coupons/assemblies/slot-test.json +11 -0
  47. package/templates/coupons/objects/fixings-coupon.js +88 -0
  48. package/templates/coupons/objects/fixings-coupon.json +26 -0
  49. package/templates/coupons/objects/holds-coupon.js +130 -0
  50. package/templates/coupons/objects/holds-coupon.json +42 -0
  51. package/templates/coupons/objects/slot-coupon.js +89 -0
  52. package/templates/coupons/objects/slot-coupon.json +29 -0
  53. package/templates/coupons/project.json +10 -0
package/lib/sheet.mjs CHANGED
@@ -44,10 +44,103 @@ function fileOf(name) {
44
44
  return file;
45
45
  }
46
46
 
47
+ // A workspace's copy of a kit set beside the kit's own, rule by rule. cad copies a kit set into rules/ the first time
48
+ // a design uses it and reads only the copy from then on, so a figure the kit corrects later would never reach it. A
49
+ // rule of the copy is the kit's to replace when the copy's is not "measured" (a figure taken from the maker's own part
50
+ // beats any published one) and was checked before the kit's was (a figure checked on the same day or later is the
51
+ // maker's own word, kept). The same figure with only more said of it in the kit's (a range added, say) is the kit's to
52
+ // take too. What the kit has and the copy lacks is new; what the copy has and the kit lacks is its own.
53
+ const day = (r) => {
54
+ const d = String(r?.checked ?? '');
55
+ return /^\d{4}-\d{2}-\d{2}$/.test(d) ? d : '';
56
+ };
57
+ const same = (a, b) => JSON.stringify(a) === JSON.stringify(b);
58
+ /**
59
+ * How a copy of a kit rule set stands against the kit's set.
60
+ * @param {{ rules?: Record<string, any> }} copy the workspace's copy
61
+ * @param {{ rules?: Record<string, any> }} kit the kit's set of the same name
62
+ * @returns {{ changed: string[], refreshed: string[], added: string[], measured: string[], newer: string[], own: string[] }}
63
+ * changed: a figure the kit has newer than the copy's (the kit's to take); refreshed: the same figure, its words or
64
+ * date newer in the kit, or more said of it there; added: the kit's rules the copy lacks; measured: the copy's
65
+ * measured figures that differ from the kit's; newer: the copy's figures that differ from the kit's and were checked
66
+ * on or after its date (or where neither says when); own: the copy's rules the kit has none of
67
+ */
68
+ export function kitDifference(copy, kit) {
69
+ const mine = copy?.rules && typeof copy.rules === 'object' ? copy.rules : {},
70
+ theirs = kit?.rules && typeof kit.rules === 'object' ? kit.rules : {},
71
+ out = { changed: [], refreshed: [], added: [], measured: [], newer: [], own: [] };
72
+ for (const [k, r] of Object.entries(theirs)) {
73
+ if (!(k in mine)) {
74
+ out.added.push(k);
75
+ continue;
76
+ }
77
+ const c = mine[k];
78
+ if (same(c, r)) continue;
79
+ const differs = !same(c?.value, r?.value);
80
+ if (c?.kind === 'measured') {
81
+ if (differs) out.measured.push(k);
82
+ } else if (day(r) && day(c) < day(r)) out[differs ? 'changed' : 'refreshed'].push(k);
83
+ else if (differs) out.newer.push(k);
84
+ else if (c && typeof c === 'object' && Object.entries(c).every(([f, x]) => same(x, r?.[f]))) out.refreshed.push(k); // (the kit's adds to the same figure: its range, say)
85
+ }
86
+ for (const k of Object.keys(mine)) if (!(k in theirs)) out.own.push(k);
87
+ return out;
88
+ }
89
+ /**
90
+ * The copy brought up to date with the kit's set: every rule in the kit's order, the kit's where kitDifference says
91
+ * it is the kit's to take (changed, refreshed or added), the copy's otherwise, then the copy's own rules. The set's
92
+ * other fields are the kit's, with any the copy alone has kept, and its "interface" both together.
93
+ * @param {Record<string, any>} copy
94
+ * @param {Record<string, any>} kit
95
+ * @returns {{ set: Record<string, any>, difference: ReturnType<typeof kitDifference> }}
96
+ */
97
+ export function updateFromKit(copy, kit) {
98
+ const difference = kitDifference(copy, kit),
99
+ take = new Set([...difference.changed, ...difference.refreshed, ...difference.added]),
100
+ rules = {};
101
+ for (const [k, r] of Object.entries(kit.rules || {})) rules[k] = take.has(k) ? r : copy.rules[k];
102
+ for (const k of difference.own) rules[k] = copy.rules[k];
103
+ const set = { ...copy, ...kit, rules };
104
+ if (copy.interface || kit.interface) set.interface = { ...copy.interface, ...kit.interface };
105
+ return { set, difference };
106
+ }
107
+ /**
108
+ * cad rules update's reading: the workspace's copy of a kit set and what bringing it up to date would make of it.
109
+ * Writes nothing. A name the kit has no set of is refused (that set is the workspace's alone); a workspace with no copy
110
+ * gets { file, copy: undefined }.
111
+ * @param {string} name a rule set's name, already held to plainName
112
+ * @returns {{ file: string, copy?: Record<string, any>, kit?: Record<string, any>, set?: Record<string, any>, difference?: ReturnType<typeof kitDifference>, fields?: string[] }}
113
+ * fields: the set's own fields (its _doc, its interface) the update changes
114
+ */
115
+ export function updateSet(name) {
116
+ const kitFile = path.join(RULE_DIRS.at(-1), `${name}.json`),
117
+ file = path.join(RULE_DIRS[0], `${name}.json`);
118
+ if (!fs.existsSync(kitFile))
119
+ throw new Error(
120
+ `the kit has no rule set "${name}", so there is nothing to update rules/${name}.json from: it is this workspace's own`,
121
+ );
122
+ if (RULE_DIRS.length < 2 || !fs.existsSync(file)) return { file };
123
+ const copy = readSet(file),
124
+ kit = readSet(kitFile);
125
+ if (!copy?.rules || typeof copy.rules !== 'object')
126
+ throw new Error(`rules/${name}.json has no "rules" to update: cad rules check ${name} says what is wrong with it`);
127
+ const { set, difference } = updateFromKit(copy, kit),
128
+ fields = [...new Set([...Object.keys(copy), ...Object.keys(set)])].filter(
129
+ (k) => k !== 'rules' && !same(copy[k], set[k]),
130
+ );
131
+ return { file, copy, kit, set, difference, fields };
132
+ }
133
+
134
+ // A figure as a note says it: a number or a word as it is, anything else as JSON
135
+ const said = (v) => (typeof v === 'number' || typeof v === 'string' ? String(v) : JSON.stringify(v));
136
+ const listed = (list) =>
137
+ list.length > 8 ? `${list.slice(0, 8).join(', ')} and ${list.length - 8} more (--json lists them)` : list.join(', ');
138
+
47
139
  // What a check notes and never fails on. An alias: a name the vocabulary shares across parts (screw_clearance, which a
48
140
  // motor's mount reads) that a set gives to one of its own rules in "interface". A copy: a workspace's own copy of a
49
141
  // set the kit has (cad copies a set into rules/ the first time a design uses it), which is used as it is, even after
50
- // the kit's set gains figures: it is told which, so a design that wants one knows where it went.
142
+ // the kit's set gains figures or corrects one: it is told which (rules.new, rules.changed), and cad rules update takes
143
+ // them. A copy that is the kit's set word for word holds nothing of the workspace's own (rules.same).
51
144
  function notesOf(set, file) {
52
145
  const notes = [],
53
146
  kitDir = RULE_DIRS.at(-1),
@@ -69,12 +162,30 @@ function notesOf(set, file) {
69
162
  typeof set.rules === 'object'
70
163
  ) {
71
164
  const kit = readSet(kitFile),
72
- added = Object.keys(kit.rules || {}).filter((k) => !(k in set.rules));
165
+ { added, changed } = kitDifference(set, kit);
166
+ if (same(set, kit))
167
+ notes.push({
168
+ level: 'info',
169
+ code: 'rules.same',
170
+ text: `rules/${name}.json is the kit's ${name} as it is: nothing in it is yours yet. Unless you mean to put your own figures in it, you can delete it: the next design to use ${name} copies in the kit's as it is then`,
171
+ });
172
+ if (changed.length) {
173
+ const one = changed[0],
174
+ c = set.rules[one],
175
+ k = kit.rules[one];
176
+ notes.push({
177
+ level: 'info',
178
+ code: 'rules.changed',
179
+ text: `the kit's ${name} has a newer figure than your copy for ${one} (${said(c?.value)} here, ${said(k?.value)} in the kit's, checked ${k.checked})${changed.length > 1 ? ` and for ${listed(changed.slice(1))}` : ''}: cad rules update ${name} takes the kit's newer figures and keeps your measured ones`,
180
+ values: { count: changed.length },
181
+ refs: { rules: changed },
182
+ });
183
+ }
73
184
  if (added.length)
74
185
  notes.push({
75
186
  level: 'info',
76
187
  code: 'rules.new',
77
- text: `your copy is used as it is; the kit's ${name} now also has ${added.length > 8 ? `${added.slice(0, 8).join(', ')} and ${added.length - 8} more (--json lists them)` : added.join(', ')}: copy any you want into rules/${name}.json, or delete it to read the kit's own`,
188
+ text: `your copy is used as it is; the kit's ${name} now also has ${listed(added)}: copy any you want into rules/${name}.json, or cad rules update ${name} adds them all and keeps what is yours`,
78
189
  values: { count: added.length },
79
190
  refs: { rules: added },
80
191
  });
package/lib/versions.mjs CHANGED
@@ -12,7 +12,7 @@ import crypto from 'node:crypto';
12
12
  import { resolve, loadRuleSet } from './rules.mjs';
13
13
  import { WS, paths } from './workspace.mjs';
14
14
  import { readJson, readOwnText } from './host.mjs';
15
- import { plainName, isPlainName } from './names.mjs';
15
+ import { plainName, isPlainName, isWorkspacePath } from './names.mjs';
16
16
  import { readLayout, hasLayout } from './layout.mjs';
17
17
  import { newer } from '@rulecad/versions';
18
18
 
@@ -59,22 +59,145 @@ const layoutNames = (d, object) =>
59
59
  // A file's path in git's terms: relative to the workspace, forward slashes on every system (git show tag:path needs them)
60
60
  const rel = (f) => path.relative(WS, f).split(path.sep).join('/');
61
61
 
62
- // The files a design depends on, relative to the workspace (its git repo): its .js and .json, the rule sets and the layouts it uses.
62
+ // The files a design depends on, relative to the workspace (its git repo): its .js and .json, the rule sets and the
63
+ // layouts it uses, and, given its build (b), everything else the build read (design.mjs readsOf): the files its design
64
+ // imported, the rule sets v.fixings and v.frames read, and the files of the objects it reads through "uses". A release
65
+ // commits them all, so its tag holds every file it was built from.
63
66
  // (A board's engine is the tool's code, not the workspace's: its release records engineId() instead.)
64
- export function files(d, object) {
65
- return [
67
+ export function files(d, object, b) {
68
+ const own = [
66
69
  rel(d.js),
67
70
  rel(d.json),
68
71
  ...(object.uses || []).filter((u) => !u.includes('/')).map((u) => `rules/${u}.json`),
69
72
  ...layoutNames(d, object).map((n) => `projects/${d.project}/layouts/${n}.json`),
70
73
  ];
74
+ const r = b?.reads;
75
+ if (!r) return own;
76
+ // (only the workspace's own files: never a release's copy in .versions/, nor the cache)
77
+ const more = [...r.files, ...r.sets, ...r.also].filter((f) => isWorkspacePath(f) && !f.startsWith('.'));
78
+ return [...new Set([...own, ...more])];
79
+ }
80
+
81
+ // What a release records of its build's reads, in its tag's message (a line "reads: {…}"): the files its design
82
+ // imported, whether it called v.fixings and v.frames, and the files of the objects it reads. Its rule sets aren't
83
+ // listed: a release is rebuilt with every rule set its tag holds.
84
+ export const READS = 'reads: ';
85
+ export const readsLine = (b) =>
86
+ b?.reads
87
+ ? `${READS}${JSON.stringify({
88
+ files: b.reads.files.filter((f) => !f.startsWith('.')),
89
+ fixings: b.reads.fixings,
90
+ frames: b.reads.frames,
91
+ also: b.reads.also.filter((f) => !f.startsWith('.')),
92
+ })}`
93
+ : '';
94
+ // A tag's record of what its release read, or null for a release made before releases recorded it (or a line that is
95
+ // not one the tool writes: a tag comes with a cloned workspace, so its paths are taken only where they are plain paths
96
+ // inside the workspace)
97
+ function recorded(tag) {
98
+ let text;
99
+ try {
100
+ text = git('tag', '-l', '--format=%(contents)', tag);
101
+ } catch {
102
+ return null;
103
+ }
104
+ const line = text.split('\n').findLast((l) => l.startsWith(READS)); // (the tool's line comes after the message)
105
+ if (!line) return null;
106
+ let r;
107
+ try {
108
+ r = JSON.parse(line.slice(READS.length));
109
+ } catch {
110
+ return null;
111
+ }
112
+ const list = (x) => (Array.isArray(x) ? x.filter((f) => isWorkspacePath(f) && !f.startsWith('.')) : []);
113
+ return r && typeof r === 'object'
114
+ ? { files: list(r.files), fixings: r.fixings === true, frames: r.frames === true, also: list(r.also) }
115
+ : null;
116
+ }
117
+
118
+ // The files a .js imports by a path ('./box.js', '../shared/x.mjs'), as written in it: a release made before releases
119
+ // recorded what they read is rebuilt with these (and what they import in turn). Paths inside the workspace, from the
120
+ // file's own (`from`, a path inside the workspace).
121
+ const IMPORTED = /(?:\bfrom\s*|\bimport\s*\(?\s*)(['"])(\.\.?\/[^'"\n]+)\1/g;
122
+ const importedBy = (from, text) =>
123
+ [...String(text).matchAll(IMPORTED)]
124
+ .map((m) => path.posix.join(path.posix.dirname(from), m[2]))
125
+ .filter((f) => isWorkspacePath(f) && /\.(m?js|json)$/.test(f));
126
+
127
+ // A release's folder holds its files at the paths they have in the workspace (.versions/<project>/<object>@<version>/
128
+ // projects/<project>/objects/<object>.js, …/rules/x1c.json), so that what the design imports by a path is found there
129
+ // as it was, and what it imports from a package is found in the workspace's node_modules, above.
130
+ // put: a file of the release written there from its tag (false when the tag has no such file)
131
+ function treeOf(tag, base) {
132
+ const show = (f) => git('show', `${tag}:./${f}`); // (./: from the workspace, which may be below the repository's root)
133
+ const put = (f) => {
134
+ if (!isWorkspacePath(f)) return false;
135
+ const to = path.join(base, ...f.split('/'));
136
+ if (fs.existsSync(to)) return true;
137
+ let text;
138
+ try {
139
+ text = show(f);
140
+ } catch {
141
+ return false;
142
+ }
143
+ fs.mkdirSync(path.dirname(to), { recursive: true });
144
+ fs.writeFileSync(to, text);
145
+ return true;
146
+ };
147
+ // A design's file, and those it imports by a path, in turn (as written: what it imports as it runs is in the record)
148
+ const withImports = (f) => {
149
+ const seen = new Set();
150
+ for (let todo = [f]; todo.length && seen.size < 1000;) {
151
+ const x = todo.pop();
152
+ if (seen.has(x) || !put(x)) continue;
153
+ seen.add(x);
154
+ if (/\.m?js$/.test(x)) todo.push(...importedBy(x, fs.readFileSync(path.join(base, ...x.split('/')), 'utf8')));
155
+ }
156
+ seen.delete(f);
157
+ return [...seen].sort();
158
+ };
159
+ return { show, put, withImports };
160
+ }
161
+
162
+ // An object's files from a release's tag, into the release's folder: its .js and what that imports, its .json and the
163
+ // layouts it can pick. -> its .json, parsed, and the files its .js imports
164
+ function objectFrom(t, project, name, where) {
165
+ const json = `projects/${project}/objects/${name}.json`,
166
+ js = `projects/${project}/objects/${name}.js`;
167
+ let object;
168
+ try {
169
+ object = JSON.parse(t.show(json));
170
+ } catch {
171
+ throw new Error(`${where} has no ${project}/${name} that can be read (${json})`);
172
+ }
173
+ t.put(json);
174
+ if (!t.put(js)) throw new Error(`${where} has no ${js}`);
175
+ const imports = t.withImports(js);
176
+ for (const v of Object.values(object.variables || {}))
177
+ if (v.type === 'layout')
178
+ for (const n of (v.choice || [v.value]).filter(isPlainName)) t.put(`projects/${project}/layouts/${n}.json`); // (another name is refused where the layout is read; a built-in (grid) has no file)
179
+ return { object, imports };
180
+ }
181
+
182
+ // The rule sets a release holds, all of them, into its folder: what its "uses" names, and what v.fixings and v.frames
183
+ // read (thread, material, profile sets and the printer's, with rules/outlines/), as its tag has them
184
+ function rulesFrom(tag, t) {
185
+ let names = [];
186
+ try {
187
+ // (--full-tree: below the repository's root, ls-tree would list only what is under the same folder of the tree)
188
+ names = git('ls-tree', '-r', '--name-only', '--full-tree', `${tag}:./rules`).split('\n');
189
+ } catch {
190
+ // (no rules/ in the release)
191
+ }
192
+ for (const n of names) if (/^(outlines\/)?[^/]+\.json$/.test(n)) t.put(`rules/${n}`);
71
193
  }
72
194
 
73
195
  // A released version's files, written under .versions/ so its imports still find node_modules. -> a design to build
74
196
  export function materialise(d, version) {
75
197
  const tag = `${d.project}/${d.name}@${version}`;
198
+ let id;
76
199
  try {
77
- git('rev-parse', '--verify', `refs/tags/${tag}`);
200
+ id = git('rev-parse', '--verify', `refs/tags/${tag}`);
78
201
  } catch {
79
202
  throw new Error(
80
203
  `no release ${tag} (releases: ${
@@ -85,32 +208,70 @@ export function materialise(d, version) {
85
208
  );
86
209
  }
87
210
  const base = paths.versions(d.project, `${d.name}@${version}`);
88
- const show = (rel) => git('show', `${tag}:${rel}`);
89
- const object = JSON.parse(show(rel(d.json)));
90
- fs.mkdirSync(path.join(base, 'rules'), { recursive: true });
91
- const js = path.join(base, `${d.name}.js`),
92
- json = path.join(base, `${d.name}.json`);
93
- fs.writeFileSync(js, show(rel(d.js)));
94
- fs.writeFileSync(json, JSON.stringify(object, null, 2));
211
+ // A file already in the folder is used as it is (treeOf), so the folder is made afresh when it was written from
212
+ // another tag of the same name (one deleted and made again) or by an earlier version of the tool (another layout)
213
+ const stamp = path.join(base, '.tag');
214
+ if (fs.existsSync(base) && (!fs.existsSync(stamp) || fs.readFileSync(stamp, 'utf8') !== id))
215
+ fs.rmSync(base, { recursive: true, force: true });
216
+ fs.mkdirSync(base, { recursive: true });
217
+ fs.writeFileSync(stamp, id);
218
+ const t = treeOf(tag, base);
95
219
  // (names from the release's own file, each written as a file here: plain names only, never ../)
220
+ const object = JSON.parse(t.show(rel(d.json)));
96
221
  for (const u of (object.uses || []).filter((x) => !x.includes('/')))
97
- fs.writeFileSync(
98
- path.join(base, 'rules', `${plainName(u, 'rule set name', `${tag}'s ${d.name}.json, in its "uses"`)}.json`),
99
- show(`rules/${u}.json`),
100
- ); // objects it reads are released on their own
101
- // The layouts it could pick, as they were then (only files that existed in that release)
102
- fs.mkdirSync(path.join(base, 'layouts'), { recursive: true });
103
- for (const v of Object.values(object.variables || {}))
104
- if (v.type === 'layout')
105
- for (const n of (v.choice || [v.value]).filter(isPlainName)) {
106
- // (another name is refused where the layout is read)
107
- try {
108
- fs.writeFileSync(path.join(base, 'layouts', `${n}.json`), show(`projects/${d.project}/layouts/${n}.json`));
109
- } catch {
110
- // (a built-in layout (grid): nothing to write)
111
- }
112
- }
113
- return { ...d, js, json, rulesDir: path.join(base, 'rules'), layoutsDir: path.join(base, 'layouts'), version, tag };
222
+ plainName(u, 'rule set name', `${tag}'s ${d.name}.json, in its "uses"`);
223
+ const { imports } = objectFrom(t, d.project, d.name, tag);
224
+ rulesFrom(tag, t);
225
+ t.put(`projects/${d.project}/project.json`); // (the material v.fixings draws for, as it was)
226
+ // What the release read, as its tag records it; for one made before tags recorded it, the files its .js imports by
227
+ // a path, and v.fixings and v.frames where its code names them
228
+ let reads = recorded(tag);
229
+ if (reads) for (const f of [...reads.files, ...reads.also]) t.put(f);
230
+ else {
231
+ const code = [rel(d.js), ...imports]
232
+ .map((f) => fs.readFileSync(path.join(base, ...f.split('/')), 'utf8'))
233
+ .join('\n');
234
+ reads = { files: imports, fixings: /\bfixings\b/.test(code), frames: /\bframes\b/.test(code), also: [] };
235
+ }
236
+ const at = (f) => path.join(base, ...rel(f).split('/'));
237
+ return {
238
+ ...d,
239
+ js: at(d.js),
240
+ json: at(d.json),
241
+ rulesDir: path.join(base, 'rules'),
242
+ layoutsDir: path.join(base, 'projects', d.project, 'layouts'),
243
+ version,
244
+ tag,
245
+ tree: base,
246
+ reads,
247
+ };
248
+ }
249
+
250
+ /**
251
+ * Another object as a release has it (its files at the release's tag), for a release that reads it through "uses"
252
+ * without naming a version: rebuilt from the same tag as the release, so with the numbers it had then.
253
+ * @param {{ tag: string, tree: string, rulesDir: string, project: string }} d the release (materialise's)
254
+ * @param {string} project @param {string} name the object, plain names (design.mjs objectSets has checked them)
255
+ */
256
+ export function inRelease(d, project, name) {
257
+ const [plain, variant] = String(name).split(':');
258
+ plainName(project, 'project name');
259
+ plainName(plain, 'object name');
260
+ const t = treeOf(d.tag, d.tree);
261
+ objectFrom(t, project, plain, d.tag);
262
+ const at = (f) => path.join(d.tree, 'projects', project, f);
263
+ return {
264
+ project,
265
+ name: plain,
266
+ js: at(`objects/${plain}.js`),
267
+ json: at(`objects/${plain}.json`),
268
+ dir: paths.project(project),
269
+ rulesDir: d.rulesDir,
270
+ layoutsDir: at('layouts'),
271
+ tag: d.tag,
272
+ tree: d.tree,
273
+ ...(variant ? { variant } : {}),
274
+ };
114
275
  }
115
276
 
116
277
  // ---------- what changed: compare() is @rulecad/versions' (exported above) ----------
@@ -159,7 +320,7 @@ function taggedEngine(tag) {
159
320
  const m = git('tag', '-l', '--format=%(contents)', tag).match(/^engine: (\w+)$/m);
160
321
  if (m) return m[1];
161
322
  try {
162
- return engineHash(git('show', `${tag}:lib/pcb.mjs`));
323
+ return engineHash(git('show', `${tag}:./lib/pcb.mjs`));
163
324
  } catch {
164
325
  return '';
165
326
  } // (the engine once lived in the workspace)
@@ -167,7 +328,8 @@ function taggedEngine(tag) {
167
328
 
168
329
  // Resolve a design as it is on disk, or as materialised from a release.
169
330
  // refs: the numbers of objects it reads (design.mjs objectSets), which a snapshot can't build itself.
170
- export function snapshot(d, refs = {}) {
331
+ // reads: the text of each file it read besides its own (design.mjs readTexts), compared file by file by compare()
332
+ export function snapshot(d, refs = {}, reads = null) {
171
333
  const object = readJson(d.json); // (the workspace's own files only where they really are inside it: host.mjs)
172
334
  const sets = {
173
335
  ...(d.rulesDir
@@ -183,9 +345,10 @@ export function snapshot(d, refs = {}) {
183
345
  return {
184
346
  object,
185
347
  entries: resolve(object, { sets }).entries,
186
- js: readOwnText(d.js),
348
+ js: readOwnText(d.js).replace(/\r\n/g, '\n'), // (git keeps \n; a Windows checkout may write \r\n)
187
349
  layouts,
188
350
  ...(engine != null ? { engine } : {}),
351
+ ...(reads ? { reads } : {}),
189
352
  };
190
353
  }
191
354
 
package/lib/workspace.mjs CHANGED
@@ -189,8 +189,9 @@ export const paths = {
189
189
 
190
190
  // The printer a project's prints are checked against: project.json's "printer", else cad.config.json's. Either is a
191
191
  // rule set's name, which becomes part of a path (rules/<printer>.json, and the kit's), so it must be a plain name.
192
- export const printerOf = (project) => {
193
- const f = project && path.join(paths.project(project), 'project.json');
192
+ // dir: the project's folder as a release has it (lib/versions.mjs materialise), so it draws for the printer it named then.
193
+ export const printerOf = (project, dir = project && paths.project(project)) => {
194
+ const f = dir && path.join(dir, 'project.json');
194
195
  const own = f && host.exists(f) && readJson(f).printer;
195
196
  if (own) return plainName(own, '"printer" field', path.relative(WS, f));
196
197
  return plainName(config.printer, '"printer" field', 'cad.config.json');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rulecad/cad",
3
- "version": "0.9.0",
3
+ "version": "0.10.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": {
@@ -60,25 +60,25 @@
60
60
  "dependencies": {
61
61
  "@rulecad/variables": "^0.4.0",
62
62
  "@rulecad/keyboard-layout": "^0.2.0",
63
- "@rulecad/printcheck": "^0.4.0",
63
+ "@rulecad/printcheck": "^0.4.1",
64
64
  "@rulecad/fit": "^0.5.0",
65
65
  "@rulecad/model-link": "^0.4.0",
66
- "@rulecad/versions": "^0.2.0",
67
- "@rulecad/shapes": "^0.5.0",
68
- "@rulecad/rules": "^0.4.0",
66
+ "@rulecad/versions": "^0.3.0",
67
+ "@rulecad/shapes": "^0.6.0",
68
+ "@rulecad/rules": "^0.5.0",
69
69
  "@jscad/modeling": "^2.12.0",
70
70
  "three": "^0.186.1",
71
71
  "@rulecad/fea": "^0.4.0",
72
- "@rulecad/topopt": "^0.4.0",
73
- "@rulecad/flexures": "^0.6.0",
72
+ "@rulecad/topopt": "^0.4.1",
73
+ "@rulecad/flexures": "^0.7.0",
74
74
  "@rulecad/gears": "^0.4.0",
75
- "@rulecad/motors": "^0.2.0",
76
- "@rulecad/fixings": "^0.2.0",
75
+ "@rulecad/motors": "^0.2.1",
76
+ "@rulecad/fixings": "^0.3.0",
77
77
  "@rulecad/robots": "^0.2.0",
78
- "@rulecad/frames": "^0.2.0"
78
+ "@rulecad/frames": "^0.3.0"
79
79
  },
80
80
  "peerDependencies": {
81
- "@rulecad/pcb": "^0.7.0"
81
+ "@rulecad/pcb": "^0.7.1"
82
82
  },
83
83
  "peerDependenciesMeta": {
84
84
  "@rulecad/pcb": {
@@ -29,7 +29,7 @@
29
29
  "power": { "type": "object", "additionalProperties": false, "properties": { "margin": { "type": "number" } } },
30
30
  "wires": { "type": "array", "description": "Wires between anchors, their length measured through every pose", "items": { "type": "object", "required": ["from", "to"], "additionalProperties": false, "properties": { "id": { "type": "string" }, "from": { "type": "string" }, "to": { "type": "string" }, "via": { "type": "array", "items": { "anyOf": [{ "type": "string" }, { "type": "object", "required": ["along", "from", "to"], "additionalProperties": false, "description": "A run along a beam's slot: the wire follows the slot from one distance to another, held by printed cable clips at a pitch", "properties": { "along": { "type": "string", "description": "A beam's slotted face: rail.top" }, "from": { "$ref": "#/$defs/expr", "description": "mm from the beam's end a" }, "to": { "$ref": "#/$defs/expr" }, "pitch": { "$ref": "#/$defs/expr", "description": "The most between clips, mm (default 100)" }, "cable": { "$ref": "#/$defs/expr", "description": "The bundle the clips hold, mm (default 6)" } } }] }, "description": "Anchors, path joints or runs along a slot that the wire is routed by" }, "gauge": { "type": "string", "description": "awg22" }, "colour": { "type": "string" }, "conductors": { "type": "number" }, "connectors": { "type": "array", "items": { "type": "string" } }, "current": { "type": "number", "description": "A: else a motor's rated current at either end, or a signal's" }, "note": { "type": "string" } } } },
31
31
  "gravity": { "$ref": "#/$defs/vec3", "description": "Which way down is, for masses in loads (default [0, 0, -1])" },
32
- "frame": { "type": "object", "additionalProperties": false, "description": "The frame: what it is (a generator, kind with inside or outside, which expands into beams, joins and their ends before anything is built, as cad frame --expand writes out), and how its beams and joins are solved for frame.deflection, frame.stress, frame.buckling, frame.rack and frame.frequency, which beams could be printed (beam.printable), and how it is cut and heated for frame.square and frame.heat. Left out, it stands on its feet: the beam ends that carry a foot, a levelling foot, a castor plate or a stacking foot, or else the lowest beam ends, each held from moving (pinned)", "properties": {"kind": {"enum": ["box", "portal", "table", "gantry", "shelf"], "description": "A frame generated from a size: box (four posts and a ring of beams at the bottom and top), portal (two legs and a beam across: inside and outside are [width, height]; it lies in one plane and tips over on its feet alone, so it is refused until supports says its feet are held down, as z1.a and z2.a fixed), table (four legs and a ring at the top), gantry (a box without its top beams across, and a beam riding along the two top side beams on a sliding joint) or shelf (a box with rings between, shelves of them). Its beams are z1 .. (upright), x1 .. and y1 .. (along x and y, by ring from the bottom), g (a gantry's moving beam); its corner arrangement follows the join"}, "inside": {"type": "array", "minItems": 2, "maxItems": 3, "items": {"$ref": "#/$defs/expr"}, "description": "The clear volume the frame encloses, [width (x), depth (y), height (z)] in mm (a portal: [width, height]); the beams go round it. Give inside or outside"}, "outside": {"type": "array", "minItems": 2, "maxItems": 3, "items": {"$ref": "#/$defs/expr"}, "description": "The volume the whole frame must fit in, [width, depth, height] in mm (a portal: [width, height]); the beams go within it"}, "profile": {"type": "string", "description": "Every beam's profile, a square one (2020-misumi-hfs5, 3030-generic, 4040-item-8)"}, "join": {"description": "How the beams meet at each corner: a kind (blind, end-tap, bracket, gusset, hidden, anchor: the upright beams run through and the others butt against their faces, each shorter by the profile's width at each end; cube: every beam butts into a corner node, each as long as the inside), or { kind, fitting, screw } as a join takes them", "oneOf": [{"type": "string"},{"type": "object", "additionalProperties": false, "required": ["kind"], "properties": {"kind": {"type": "string"}, "fitting": {"type": "string"}, "screw": {"type": "string"}}}]}, "feet": {"description": "What stands under the upright beams' lower ends: foot, levelling or stacking (printed), a bought foot's set by name (fitting-motedis-foot-m6-d19), or a printed castor plate as { kind: castor, holes: [x, y], thread: M6, top } from the castor's drawing; left out, an end cap", "oneOf": [{"type": ["string", "null"]},{"type": "object", "additionalProperties": false, "required": ["kind", "holes", "thread"], "properties": {"kind": {"enum": ["castor"]}, "holes": {"type": "array", "minItems": 2, "maxItems": 2, "items": {"type": "number"}, "description": "The castor's bolt holes' spacing [x, y] in mm, from its maker's drawing"}, "thread": {"type": "string", "description": "Its bolts' thread, as M6"}, "top": {"type": "number", "description": "Its top plate's thickness in mm, for the bolts' length (3, an estimate, where left out)"}}}]}, "caps": {"type": ["string", "boolean"], "description": "The ends no join covers: printed end caps (true, the default), a bought end cap's set by name, or false for none (join.end then names them)"}, "braces": {"type": "array", "items": {"enum": ["front", "back", "left", "right"]}, "description": "The upright sides whose corners are stiffened against racking: each corner of that side keeps the join asked for and gains a printed corner bracket beside it, on drop-in nuts (where the join is a printed bracket already, that bracket is drawn braced instead; a bracket join not printed is refused with braces)"}, "panels": {"type": "object", "additionalProperties": false, "required": ["sheet", "thickness"], "description": "Panels closing the upright sides, each cut to its bay with its clips (a box, a shelf, a gantry's two sides)", "properties": {"sheet": {"type": "string", "description": "The sheet's material: acrylic, polycarbonate, aluminium, plywood, mdf"}, "thickness": {"$ref": "#/$defs/expr", "description": "mm"}, "sides": {"type": "array", "items": {"enum": ["front", "back", "left", "right"]}, "description": "Which sides (default every side that has a bay)"}}}, "shelves": {"type": "integer", "minimum": 1, "maximum": 20, "description": "A shelf: how many rings stand between the bottom and the top, spacing its height into equal clear bays (default 1)"}, "supports": {"type": "object", "description": "Where the frame is held, by beam end (\"z1.a\") or a place on a beam (\"x1.bottom@50%\"): pinned holds it from moving and lets it turn, fixed holds it from turning too, resting holds it from moving and from twisting about the beam's own length (a beam lying across a round bar, as the beam coupon does; for a beam along x, y or z). Given, these are the only supports, and at least one is named", "minProperties": 1, "additionalProperties": {"enum": ["pinned", "fixed", "resting"]}}, "limit": {"$ref": "#/$defs/expr", "description": "The sag allowed in every frame.deflection finding, in mm: at each load's point, each named point and along each guide whose rail gives no parallelism of its own (default: the task's accuracy, else the span of the beam it is on over 360)"}, "points": {"type": "array", "description": "Places on beams to report the sag at, beside each load's point and every guide (\"x1.top@50%\")", "items": {"type": "string"}}, "cut": {"type": "object", "additionalProperties": false, "description": "How the beams are cut in this workshop, where it differs from the profile's set and the kit's defaults: frame.square, frame.cut and the cut list read it", "properties": {"tolerance": {"$ref": "#/$defs/expr", "description": "How far a cut length may be from the length asked, either way, in mm (default: the profile's cut_tolerance, else 0.5)"}}}, "heat": {"type": "object", "additionalProperties": false, "description": "frame.heat: the temperatures the frame works at. The beams grow with the air in the enclosure; each printed fitting is held to its plastic's softening point", "properties": {"air": {"$ref": "#/$defs/expr", "description": "The air round the frame when it runs, in degrees C (inside its enclosure)"}, "built": {"$ref": "#/$defs/expr", "description": "The air it was built and squared in, in degrees C (default 20)"}, "heaters": {"type": "array", "description": "Hot things near the frame: what is within reach of one is taken at its temperature", "items": {"type": "object", "required": ["at", "temperature", "reach"], "additionalProperties": false, "properties": {"name": {"type": "string"}, "at": {"$ref": "#/$defs/vec3", "description": "Its middle, in the assembly's frame, mm"}, "temperature": {"$ref": "#/$defs/expr", "description": "Degrees C at its surface"}, "reach": {"$ref": "#/$defs/expr", "description": "How far from its middle a part is taken at that temperature, mm"}}}}}}, "printed": {"description": "beam.printable: each beam tried printed in this plastic (the kit's printable profile of its size, lying down or standing up), the frame solved again and held to its own limits: its sags, stress, buckling, creep and lowest mode; the beams that can be printed are listed, and printed together solved once more. A plastic's set by name (\"petg\"), or how it prints", "oneOf": [{"type": "string"},{"type": "object", "additionalProperties": false, "required": ["material"], "properties": {"material": {"type": "string", "description": "The plastic's set: pla, petg"}, "walls": {"type": "integer", "minimum": 1, "description": "Walls round every outline, in lines (3)"}, "infill": {"type": "number", "minimum": 0, "maximum": 1, "description": "The share of the inside the infill fills (0.4)"}, "pose": {"enum": ["lying", "standing"], "description": "Only this way up (both are tried where left out)"}}}]}, "size": {"type": "object", "additionalProperties": false, "description": "frame.size: each group of beams that must match given the lightest profile from a list that meets the frame's own limits (the sag at each load, point and guide, each beam's stress and buckling with frame.margin to spare, and the lowest mode against the task's moves), solved in every pose; a table of each group's profile, the limit that set it and its margin, and cad frame --size --write writes the profiles in", "properties": {"profiles": {"type": "array", "minItems": 1, "items": {"type": "string"}, "description": "The profiles to choose from, by set (default MISUMI's HFS5, HFS6 and HFS8 series from 2020 to 4080). One that is not square is tried lying as drawn and turned a quarter. A design is only tried where every join of a grouped beam still goes together (a blind join's screw and button head in the other beam's slot, an end-tap's cap head on its far face, a bought fitting on both profiles); the join checks of the written frame hold the rest"}, "groups": {"type": "object", "description": "Beams that must take one profile, by group name (\"rails\": [\"x1\", \"x2\"]); the rest are grouped by themselves: one profile, one direction, lengths within 0.5 mm", "additionalProperties": {"type": "array", "minItems": 1, "items": {"type": "string"}}}, "limits": {"type": "object", "additionalProperties": false, "description": "Limits in place of the frame checks' own", "properties": {"deflection": {"$ref": "#/$defs/expr", "description": "The sag allowed at every load, named point and guide, mm"}, "stress": {"$ref": "#/$defs/expr", "description": "How many times under its alloy's strength each beam stays (default frame.margin, 2)"}, "buckling": {"$ref": "#/$defs/expr", "description": "How many times its load the frame, and each grouped beam by Euler's load, must carry before it buckles (default frame.margin, 2)"}, "frequency": {"$ref": "#/$defs/expr", "description": "The lowest mode's floor, Hz (default twice what the task's moves shake it at; none without a task)"}, "rack": {"$ref": "#/$defs/expr", "description": "The sway allowed at the frame's top under frame.rack's side push alone, each way across, mm: racking as a limit (default frame.rack's own limit where the assembly gives frame.rack; none otherwise)"}}}, "by": {"enum": ["mass", "cost"], "description": "What is made least (mass: no profile set in the kit gives a price per metre yet)"}}}, "rack": {"type": "object", "additionalProperties": false, "description": "frame.rack: the side push at the frame's top and the sway allowed", "properties": {"load": {"$ref": "#/$defs/expr", "description": "The side push in N, shared among the top corners (default 20, an estimate)"}, "limit": {"$ref": "#/$defs/expr", "description": "The sway allowed at the top, in mm (default: the task's accuracy, else the height over 400)"}}}} },
32
+ "frame": { "type": "object", "additionalProperties": false, "description": "The frame: what it is (a generator, kind with inside or outside, which expands into beams, joins and their ends before anything is built, as cad frame --expand writes out), and how its beams and joins are solved for frame.deflection, frame.stress, frame.buckling, frame.rack and frame.frequency, which beams could be printed (beam.printable), and how it is cut and heated for frame.square and frame.heat. Left out, it stands on its feet: the beam ends that carry a foot, a levelling foot, a castor plate or a stacking foot, or else the lowest beam ends, each held from moving (pinned)", "properties": {"kind": {"enum": ["box", "portal", "table", "gantry", "shelf"], "description": "A frame generated from a size: box (four posts and a ring of beams at the bottom and top), portal (two legs and a beam across: inside and outside are [width, height]; it lies in one plane and tips over on its feet alone, so it is refused until supports says its feet are held down, as z1.a and z2.a fixed), table (four legs and a ring at the top), gantry (a box without its top beams across, and a beam riding along the two top side beams on a sliding joint) or shelf (a box with rings between, shelves of them). Its beams are z1 .. (upright), x1 .. and y1 .. (along x and y, by ring from the bottom), g (a gantry's moving beam); its corner arrangement follows the join"}, "inside": {"type": "array", "minItems": 2, "maxItems": 3, "items": {"$ref": "#/$defs/expr"}, "description": "The clear volume the frame encloses, [width (x), depth (y), height (z)] in mm (a portal: [width, height]); the beams go round it. Give inside or outside"}, "outside": {"type": "array", "minItems": 2, "maxItems": 3, "items": {"$ref": "#/$defs/expr"}, "description": "The volume the whole frame must fit in, its feet and end caps with it, [width, depth, height] in mm (a portal: [width, height]); the beams go within it, smaller by what the feet and caps add (refused on castors, whose height is not drawn)"}, "profile": {"type": "string", "description": "Every beam's profile, a square one (2020-misumi-hfs5, 3030-generic, 4040-item-8)"}, "join": {"description": "How the beams meet at each corner: a kind (blind, end-tap, bracket, gusset, hidden, anchor: the upright beams run through and the others butt against their faces, each shorter by the profile's width at each end; cube: every beam butts into a corner node, each as long as the inside), or { kind, fitting, screw, estimate } as a join takes them. blind and end-tap are built as they stand; bracket and gusset with their fitting, printed or bought, and hidden and anchor with a bought one; cube not yet", "oneOf": [{"type": "string"},{"type": "object", "additionalProperties": false, "required": ["kind"], "properties": {"kind": {"type": "string"}, "fitting": {"type": "string"}, "screw": {"type": "string"}, "estimate": {"type": "boolean", "description": "true: make the frame with a join the kit cannot build yet (cube; bracket, gusset, hidden or anchor with no fitting), its joins checked by their estimate. Without it those are refused, naming what is missing"}}}]}, "feet": {"description": "What stands under the upright beams' lower ends: foot, levelling or stacking (printed), a bought foot's set by name (fitting-motedis-foot-m6-d19), or a printed castor plate as { kind: castor, holes: [x, y], thread: M6, top } from the castor's drawing; left out, an end cap", "oneOf": [{"type": ["string", "null"]},{"type": "object", "additionalProperties": false, "required": ["kind", "holes", "thread"], "properties": {"kind": {"enum": ["castor"]}, "holes": {"type": "array", "minItems": 2, "maxItems": 2, "items": {"type": "number"}, "description": "The castor's bolt holes' spacing [x, y] in mm, from its maker's drawing"}, "thread": {"type": "string", "description": "Its bolts' thread, as M6"}, "top": {"type": "number", "description": "Its top plate's thickness in mm, for the bolts' length (3, an estimate, where left out)"}}}]}, "caps": {"type": ["string", "boolean"], "description": "The ends no join covers: printed end caps (true, the default), a bought end cap's set by name, or false for none (join.end then names them)"}, "braces": {"type": "array", "items": {"enum": ["front", "back", "left", "right"]}, "description": "The upright sides whose corners are stiffened against racking: each corner of that side keeps the join asked for and gains a printed corner bracket beside it, on drop-in nuts (where the join is a printed bracket already, that bracket is drawn braced instead; a bracket join not printed is refused with braces)"}, "panels": {"type": "object", "additionalProperties": false, "required": ["sheet", "thickness"], "description": "Panels closing the upright sides, each cut to its bay with its clips (a box, a shelf, a gantry's two sides)", "properties": {"sheet": {"type": "string", "description": "The sheet's material: acrylic, polycarbonate, aluminium, plywood, mdf"}, "thickness": {"$ref": "#/$defs/expr", "description": "mm"}, "sides": {"type": "array", "items": {"enum": ["front", "back", "left", "right"]}, "description": "Which sides (default every side that has a bay)"}}}, "shelves": {"type": "integer", "minimum": 1, "maximum": 20, "description": "A shelf: how many rings stand between the bottom and the top, spacing its height into equal clear bays (default 1)"}, "supports": {"type": "object", "description": "Where the frame is held, by beam end (\"z1.a\") or a place on a beam (\"x1.bottom@50%\"): pinned holds it from moving and lets it turn, fixed holds it from turning too, resting holds it from moving and from twisting about the beam's own length (a beam lying across a round bar, as the beam coupon does; for a beam along x, y or z). Given, these are the only supports, and at least one is named", "minProperties": 1, "additionalProperties": {"enum": ["pinned", "fixed", "resting"]}}, "limit": {"$ref": "#/$defs/expr", "description": "The sag allowed in every frame.deflection finding, in mm: at each load's point, each named point and along each guide whose rail gives no parallelism of its own (default: the task's accuracy, else the span of the beam it is on over 360)"}, "points": {"type": "array", "description": "Places on beams to report the sag at, beside each load's point and every guide (\"x1.top@50%\")", "items": {"type": "string"}}, "cut": {"type": "object", "additionalProperties": false, "description": "How the beams are cut in this workshop, where it differs from the profile's set and the kit's defaults: frame.square, frame.cut and the cut list read it", "properties": {"tolerance": {"$ref": "#/$defs/expr", "description": "How far a cut length may be from the length asked, either way, in mm (default: the profile's cut_tolerance, else 0.5)"}}}, "heat": {"type": "object", "additionalProperties": false, "description": "frame.heat: the temperatures the frame works at. The beams grow with the air in the enclosure; each printed fitting is held to its plastic's softening point", "properties": {"air": {"$ref": "#/$defs/expr", "description": "The air round the frame when it runs, in degrees C (inside its enclosure)"}, "built": {"$ref": "#/$defs/expr", "description": "The air it was built and squared in, in degrees C (default 20)"}, "heaters": {"type": "array", "description": "Hot things near the frame: what is within reach of one is taken at its temperature", "items": {"type": "object", "required": ["at", "temperature", "reach"], "additionalProperties": false, "properties": {"name": {"type": "string"}, "at": {"$ref": "#/$defs/vec3", "description": "Its middle, in the assembly's frame, mm"}, "temperature": {"$ref": "#/$defs/expr", "description": "Degrees C at its surface"}, "reach": {"$ref": "#/$defs/expr", "description": "How far from its middle a part is taken at that temperature, mm"}}}}}}, "printed": {"description": "beam.printable: each beam tried printed in this plastic (the kit's printable profile of its size, lying down or standing up), the frame solved again and held to its own limits: its sags, stress, buckling, creep and lowest mode; the beams that can be printed are listed, and printed together solved once more. A plastic's set by name (\"petg\"), or how it prints", "oneOf": [{"type": "string"},{"type": "object", "additionalProperties": false, "required": ["material"], "properties": {"material": {"type": "string", "description": "The plastic's set: pla, petg"}, "walls": {"type": "integer", "minimum": 1, "description": "Walls round every outline, in lines (3)"}, "infill": {"type": "number", "minimum": 0, "maximum": 1, "description": "The share of the inside the infill fills (0.4)"}, "pose": {"enum": ["lying", "standing"], "description": "Only this way up (both are tried where left out)"}}}]}, "size": {"type": "object", "additionalProperties": false, "description": "frame.size: each group of beams that must match given the lightest profile from a list that meets the frame's own limits (the sag at each load, point and guide, each beam's stress and buckling with frame.margin to spare, and the lowest mode against the task's moves), solved in every pose; a table of each group's profile, the limit that set it and its margin, and cad frame --size --write writes the profiles in", "properties": {"profiles": {"type": "array", "minItems": 1, "items": {"type": "string"}, "description": "The profiles to choose from, by set (default MISUMI's HFS5, HFS6 and HFS8 series from 2020 to 4080). One that is not square is tried lying as drawn and turned a quarter. A design is only tried where every join of a grouped beam still goes together (a blind join's screw and button head in the other beam's slot, an end-tap's cap head on its far face, a bought fitting on both profiles); the join checks of the written frame hold the rest"}, "groups": {"type": "object", "description": "Beams that must take one profile, by group name (\"rails\": [\"x1\", \"x2\"]); the rest are grouped by themselves: one profile, one direction, lengths within 0.5 mm", "additionalProperties": {"type": "array", "minItems": 1, "items": {"type": "string"}}}, "limits": {"type": "object", "additionalProperties": false, "description": "Limits in place of the frame checks' own", "properties": {"deflection": {"$ref": "#/$defs/expr", "description": "The sag allowed at every load, named point and guide, mm"}, "stress": {"$ref": "#/$defs/expr", "description": "How many times under its alloy's strength each beam stays (default frame.margin, 2)"}, "buckling": {"$ref": "#/$defs/expr", "description": "How many times its load the frame, and each grouped beam by Euler's load, must carry before it buckles (default frame.margin, 2)"}, "frequency": {"$ref": "#/$defs/expr", "description": "The lowest mode's floor, Hz (default twice what the task's moves shake it at; none without a task)"}, "rack": {"$ref": "#/$defs/expr", "description": "The sway allowed at the frame's top under frame.rack's side push alone, each way across, mm: racking as a limit (default frame.rack's own limit where the assembly gives frame.rack; none otherwise)"}}}, "by": {"enum": ["mass", "cost"], "description": "What is made least (mass: no profile set in the kit gives a price per metre yet)"}}}, "rack": {"type": "object", "additionalProperties": false, "description": "frame.rack: the side push at the frame's top and the sway allowed", "properties": {"load": {"$ref": "#/$defs/expr", "description": "The side push in N, shared among the top corners (default 20, an estimate)"}, "limit": {"$ref": "#/$defs/expr", "description": "The sway allowed at the top, in mm (default: the task's accuracy, else the height over 400)"}}}} },
33
33
  "loads": { "type": "array", "description": "What the assembly has to do: a torque (N m) or force (N) on a joint, or a mass (kg) carried at an anchor", "items": { "type": "object", "additionalProperties": false, "properties": { "joint": { "type": "string" }, "torque": { "$ref": "#/$defs/expr" }, "force": { "$ref": "#/$defs/expr" }, "mass": { "$ref": "#/$defs/expr" }, "at": { "$ref": "#/$defs/anchorRef" }, "note": { "type": "string" } } } },
34
34
  "poses": { "type": "object", "description": "Named sets of joint values ({ \"hinge\": 90 }), and of items' variables (\"action.travel\": 25: a flexure drawn bent in that pose, printed as drawn)", "additionalProperties": { "type": "object", "additionalProperties": { "$ref": "#/$defs/values" } } },
35
35
  "printInPlace": { "type": "array", "minItems": 2, "items": { "type": "string" }, "description": "Items printed together as one object printed in place (\"printInPlace\": true on it): they come off the bed together, so the assembly order never takes them apart from each other" },
@@ -14,6 +14,12 @@
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
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
+ "version": { "type": "string", "pattern": "^\\d+\\.\\d+\\.\\d+$", "description": "The project's latest release, as cad release <project> writes it (a git tag <project>@<version> holds it). Left to cad release" },
18
+ "release": {
19
+ "type": "object",
20
+ "description": "The version of each object in the project's latest release, by name, as cad release <project> writes it. Left to cad release",
21
+ "additionalProperties": { "type": "string", "pattern": "^\\d+\\.\\d+\\.\\d+$" }
22
+ },
17
23
  "filaments": {
18
24
  "type": "object",
19
25
  "description": "Its filaments, by name, for parts that print in more than one (a part's \"filament\": \"legend\"): each in its AMS slot",