@rulecad/cad 0.7.97 → 0.9.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 (86) hide show
  1. package/AGENTS.md +26 -10
  2. package/CHANGELOG.md +442 -2
  3. package/EXAMPLES.md +48 -42
  4. package/README.md +226 -73
  5. package/TUTORIAL.md +2 -2
  6. package/bin/cad.mjs +2253 -514
  7. package/lib/animate.mjs +173 -49
  8. package/lib/assembly.mjs +1854 -437
  9. package/lib/beams.mjs +256 -52
  10. package/lib/belts.mjs +66 -15
  11. package/lib/board-work.mjs +12 -0
  12. package/lib/bought.mjs +309 -53
  13. package/lib/buildpage.mjs +179 -29
  14. package/lib/carried.mjs +201 -0
  15. package/lib/clone.mjs +194 -42
  16. package/lib/design.mjs +734 -113
  17. package/lib/drive.mjs +187 -63
  18. package/lib/edit.mjs +900 -191
  19. package/lib/errors.mjs +16 -3
  20. package/lib/explain.mjs +62 -13
  21. package/lib/fasten.mjs +2710 -502
  22. package/lib/fittings.mjs +715 -121
  23. package/lib/fixings.mjs +21 -9
  24. package/lib/framebuild.mjs +792 -176
  25. package/lib/framecheck.mjs +1901 -368
  26. package/lib/framegen.mjs +100 -22
  27. package/lib/frameheat.mjs +225 -42
  28. package/lib/frameprint.mjs +513 -108
  29. package/lib/frames.mjs +81 -17
  30. package/lib/framesize.mjs +792 -120
  31. package/lib/frametip.mjs +235 -0
  32. package/lib/gait.mjs +135 -23
  33. package/lib/grip.mjs +62 -13
  34. package/lib/guides.mjs +1403 -230
  35. package/lib/host.mjs +149 -18
  36. package/lib/inplace.mjs +171 -36
  37. package/lib/jigs.mjs +360 -78
  38. package/lib/joins.mjs +697 -118
  39. package/lib/jsonedit.mjs +88 -26
  40. package/lib/kept.mjs +84 -0
  41. package/lib/kit.mjs +438 -68
  42. package/lib/layout.mjs +3 -1
  43. package/lib/links.mjs +149 -42
  44. package/lib/list.mjs +326 -64
  45. package/lib/live-guard.mjs +68 -0
  46. package/lib/live-shape.mjs +96 -24
  47. package/lib/live.mjs +189 -59
  48. package/lib/loads.mjs +579 -130
  49. package/lib/machine.mjs +372 -74
  50. package/lib/magnets.mjs +162 -44
  51. package/lib/measured.mjs +417 -94
  52. package/lib/mesh.mjs +526 -119
  53. package/lib/meshcmd.mjs +215 -60
  54. package/lib/motors.mjs +1022 -212
  55. package/lib/motorsvg.mjs +114 -32
  56. package/lib/names.mjs +41 -0
  57. package/lib/optimise.mjs +979 -283
  58. package/lib/order.mjs +519 -112
  59. package/lib/panels.mjs +482 -94
  60. package/lib/parts.mjs +78 -23
  61. package/lib/pins.mjs +163 -44
  62. package/lib/plates.mjs +224 -36
  63. package/lib/player.mjs +37 -9
  64. package/lib/power.mjs +64 -13
  65. package/lib/preview.mjs +83 -16
  66. package/lib/profilemeasure.mjs +572 -129
  67. package/lib/rules.mjs +38 -4
  68. package/lib/sandbox-hooks.mjs +154 -12
  69. package/lib/sandbox-preload.mjs +2 -2
  70. package/lib/sandbox-run.mjs +127 -12
  71. package/lib/sandbox.mjs +632 -35
  72. package/lib/schema.mjs +43 -11
  73. package/lib/seats.mjs +227 -49
  74. package/lib/services.mjs +261 -52
  75. package/lib/sheet.mjs +851 -178
  76. package/lib/slotnuts.mjs +213 -34
  77. package/lib/targets/gist.mjs +4 -1
  78. package/lib/targets.mjs +42 -6
  79. package/lib/task.mjs +376 -79
  80. package/lib/versions.mjs +113 -28
  81. package/lib/wires.mjs +228 -45
  82. package/lib/workspace.mjs +216 -17
  83. package/package.json +19 -19
  84. package/schemas/assembly.schema.json +2 -2
  85. package/schemas/object.schema.json +1 -1
  86. package/schemas/project.schema.json +1 -1
package/lib/clone.mjs CHANGED
@@ -10,7 +10,8 @@ import { pcbEngine } from './design.mjs';
10
10
 
11
11
  const today = () => new Date().toISOString().slice(0, 10);
12
12
  // Licences that ask boards made from the source to stay under them (or forbid that use): said when cloning
13
- export const reciprocal = (s) => /CERN-OHL-S|CERN Open Hardware Licence Version 2 - Strongly|GPL|share-?alike|\bSA\b/i.test(String(s || ''));
13
+ export const reciprocal = (s) =>
14
+ /CERN-OHL-S|CERN Open Hardware Licence Version 2 - Strongly|GPL|share-?alike|\bSA\b/i.test(String(s || ''));
14
15
  export const limiting = (s) => /\b(NC|ND)\b|non-?commercial|no-?deriv/i.test(String(s || ''));
15
16
 
16
17
  // A GitHub file link (github.com/<owner>/<repo>/blob/<ref>/<path>) -> { owner, repo, ref, file }, else null
@@ -30,37 +31,118 @@ async function getJSON(url) {
30
31
  async function fetchBoard(ref, o) {
31
32
  const gh = githubFile(ref);
32
33
  if (!gh) {
33
- if (!fs.existsSync(ref)) throw new Error(`no file ${ref}: give a .kicad_pcb file, or a GitHub link to one (https://github.com/<owner>/<repo>/blob/<branch>/<path>.kicad_pcb)`);
34
- return { text: fs.readFileSync(ref, 'utf8'), source: o.source || path.basename(ref), licence: o.licence || null, dir: path.dirname(path.resolve(ref)) };
34
+ if (!fs.existsSync(ref))
35
+ throw new Error(
36
+ `no file ${ref}: give a .kicad_pcb file, or a GitHub link to one (https://github.com/<owner>/<repo>/blob/<branch>/<path>.kicad_pcb)`,
37
+ );
38
+ return {
39
+ text: fs.readFileSync(ref, 'utf8'),
40
+ source: o.source || path.basename(ref),
41
+ licence: o.licence || null,
42
+ dir: path.dirname(path.resolve(ref)),
43
+ };
35
44
  }
36
45
  const base = `https://api.github.com/repos/${gh.owner}/${gh.repo}`;
37
46
  const commit = (await getJSON(`${base}/commits/${encodeURIComponent(gh.ref)}`)).sha;
38
- const raw = await fetch(`https://raw.githubusercontent.com/${gh.owner}/${gh.repo}/${commit}/${gh.file.split('/').map(encodeURIComponent).join('/')}`);
47
+ const raw = await fetch(
48
+ `https://raw.githubusercontent.com/${gh.owner}/${gh.repo}/${commit}/${gh.file.split('/').map(encodeURIComponent).join('/')}`,
49
+ );
39
50
  if (!raw.ok) throw new Error(`couldn't download ${gh.file} at ${commit.slice(0, 7)} (${raw.status})`);
40
51
  let licence = o.licence || null;
41
52
  if (!licence) {
42
53
  const l = await getJSON(`${base}/license?ref=${commit}`).catch(() => null);
43
- const first = l?.content ? Buffer.from(l.content, 'base64').toString('utf8').split('\n').map((s) => s.trim()).find(Boolean) : null;
54
+ const first = l?.content
55
+ ? Buffer.from(l.content, 'base64')
56
+ .toString('utf8')
57
+ .split('\n')
58
+ .map((s) => s.trim())
59
+ .find(Boolean)
60
+ : null;
44
61
  licence = l?.license?.spdx_id && l.license.spdx_id !== 'NOASSERTION' ? l.license.spdx_id : first;
45
62
  }
46
- return { text: await raw.text(), source: `https://github.com/${gh.owner}/${gh.repo}/blob/${commit}/${gh.file}`, licence, commit, github: { ...gh, commit } };
63
+ return {
64
+ text: await raw.text(),
65
+ source: `https://github.com/${gh.owner}/${gh.repo}/blob/${commit}/${gh.file}`,
66
+ licence,
67
+ commit,
68
+ github: { ...gh, commit },
69
+ };
47
70
  }
48
71
 
49
72
  // ---- the parts' 3D models ----
50
73
  // KiCad's own library, by the version its path variable names (6 and later name it; older boards say KISYS3DMOD)
51
74
  const KICAD = { 6: '6.0.11', 7: '7.0.11', 8: '8.0.8' };
52
- const KICAD_LICENCE = 'CC-BY-SA-4.0 with the KiCad libraries exception (designs using the models aren\'t bound by it)';
53
- const fetchText = async (url) => { const r = await fetch(url); if (!r.ok) throw new Error(`${r.status} for ${url}`); return r.text(); };
75
+ const KICAD_LICENCE = "CC-BY-SA-4.0 with the KiCad libraries exception (designs using the models aren't bound by it)";
76
+ const fetchText = async (url) => {
77
+ const r = await fetch(url);
78
+ if (!r.ok) throw new Error(`${r.status} for ${url}`);
79
+ return r.text();
80
+ };
81
+
82
+ // Whether file is in the folder dir, or a folder in it (by its name, and by where a link in the way leads)
83
+ function inside(dir, file) {
84
+ const within = (d, f) => {
85
+ const rel = nodePath.relative(d, f);
86
+ return rel !== '' && rel !== '..' && !rel.startsWith(`..${nodePath.sep}`) && !nodePath.isAbsolute(rel);
87
+ };
88
+ if (!within(dir, file)) return false;
89
+ try {
90
+ return within(fs.realpathSync(dir), fs.realpathSync(file));
91
+ } catch {
92
+ return true; // (no such file yet: reading it finds nothing, and says so)
93
+ }
94
+ }
95
+
96
+ // base + rest, refused if the address it makes leads out of base. (A web address reads "%2e%2e" and a backslash as
97
+ // ".." and "/", so a path the checks on its words pass can still climb to another repository, or out of KiCad's
98
+ // library, and be copied in under a licence that isn't its own.)
99
+ function under(base, rest, what) {
100
+ const url = base + rest;
101
+ if (!new URL(url).pathname.startsWith(new URL(base).pathname))
102
+ throw new Error(`its path leaves ${what}, so cad clone doesn't follow it`);
103
+ return url;
104
+ }
54
105
 
55
- // Where a model's file comes from: { url, licence } (or { file } for a board read from a file), or null
56
- async function modelSource(path, got) {
106
+ /**
107
+ * Where a model's file comes from: { url, licence } (or { file } for a board read from a file), or null. A path that
108
+ * leads out of the board's folder, its repository or KiCad's library is refused.
109
+ * @param {string} path the model's path as the board gives it
110
+ * @param {{ dir?: string, github?: { owner: string, repo: string, commit: string, file: string }, licence?: string }} got where the board came from
111
+ * @returns {Promise<{ url?: string, file?: string, dir?: string, licence?: string | null, kicad?: boolean } | null>}
112
+ */
113
+ export async function modelSource(path, got) {
57
114
  const kicad = path.match(/^\$\{(?:KICAD(\d+)_3DMODEL_DIR|KISYS3DMOD)\}\/(.+)$/);
58
- if (kicad) return { url: `https://gitlab.com/kicad/libraries/kicad-packages3D/-/raw/${KICAD[kicad[1]] ?? KICAD[6]}/${kicad[2]}`, licence: KICAD_LICENCE, kicad: true };
115
+ if (kicad)
116
+ return {
117
+ url: under(
118
+ `https://gitlab.com/kicad/libraries/kicad-packages3D/-/raw/${KICAD[kicad[1]] ?? KICAD[6]}/`,
119
+ kicad[2],
120
+ "KiCad's model library",
121
+ ),
122
+ licence: KICAD_LICENCE,
123
+ kicad: true,
124
+ };
59
125
  const own = path.match(/^\$\{KIPRJMOD\}\/(.+)$/);
60
126
  if (!own) return null;
61
- if (!got.github) return got.dir ? { file: nodePath.resolve(got.dir, own[1]) } : null;
127
+ // A board's own models are in its folder: a path that climbs out of it (../, or one from the top of the disc) is
128
+ // refused, so a board from elsewhere can't have cad clone copy a file of this computer into the workspace. (From
129
+ // GitHub, the path may lead anywhere in the board's repository, which is fetched from GitHub, never from this disc.)
130
+ if (!got.github) {
131
+ if (!got.dir) return null;
132
+ const file = nodePath.resolve(got.dir, own[1]);
133
+ if (!inside(got.dir, file)) throw new Error(`its path leaves the board's folder, so cad clone doesn't follow it`);
134
+ return { file, dir: got.dir };
135
+ }
62
136
  // In the source's repository, next to its board; a path into a submodule goes on in the submodule's repository
63
- const { owner, repo, commit, file } = got.github, parts = nodePath.posix.normalize(nodePath.posix.join(nodePath.posix.dirname(file), own[1])).split('/');
137
+ const { owner, repo, commit, file } = got.github,
138
+ parts = nodePath.posix.normalize(nodePath.posix.join(nodePath.posix.dirname(file), own[1])).split('/');
139
+ if (parts[0] === '..' || parts[0] === '')
140
+ throw new Error(`its path leaves the board's repository, so cad clone doesn't follow it`);
141
+ const inRepo = under(
142
+ `https://raw.githubusercontent.com/${owner}/${repo}/${commit}/`,
143
+ parts.join('/'),
144
+ "the board's repository",
145
+ );
64
146
  const api = (o, r, x) => getJSON(`https://api.github.com/repos/${o}/${r}/${x}`);
65
147
  const top = await api(owner, repo, `contents/${encodeURIComponent(parts[0])}?ref=${commit}`).catch(() => null);
66
148
  const licenceOf = async (o, r) => (await api(o, r, 'license').catch(() => null))?.license?.spdx_id;
@@ -68,37 +150,76 @@ async function modelSource(path, got) {
68
150
  const m = top.submodule_git_url.match(/github\.com[:/]([\w.-]+)\/([\w.-]+?)(?:\.git)?$/);
69
151
  if (!m) return null;
70
152
  const lic = await licenceOf(m[1], m[2]);
71
- return { url: `https://raw.githubusercontent.com/${m[1]}/${m[2]}/${top.sha}/${parts.slice(1).join('/')}`, licence: lic && lic !== 'NOASSERTION' ? lic : null };
153
+ return {
154
+ url: under(
155
+ `https://raw.githubusercontent.com/${m[1]}/${m[2]}/${top.sha}/`,
156
+ parts.slice(1).join('/'),
157
+ "the board's repository",
158
+ ),
159
+ licence: lic && lic !== 'NOASSERTION' ? lic : null,
160
+ };
72
161
  }
73
- return { url: `https://raw.githubusercontent.com/${owner}/${repo}/${commit}/${parts.join('/')}`, licence: got.licence };
162
+ return {
163
+ url: inRepo,
164
+ licence: got.licence,
165
+ };
74
166
  }
75
167
 
76
168
  // Each model the circuit's parts name, fetched once into the workspace's models/ (a mesh, where its licence lets it be
77
169
  // shared and it comes as VRML) or kept as its size (a STEP file, or a shape with no licence): circuit.models[path]
78
170
  async function fetchModels(circuit, got, { wrlMesh, stepBounds }, notes) {
79
- const out = {}, paths = [...new Set(circuit.parts.filter((p) => p.model).map((p) => p.model.path))];
171
+ const out = {},
172
+ paths = [...new Set(circuit.parts.filter((p) => p.model).map((p) => p.model.path))];
80
173
  for (const path of paths) {
81
174
  try {
82
175
  const src = await modelSource(path, got);
83
- if (!src) { notes.push(`no 3D model for ${path}: its path isn't one cad clone can follow`); continue; }
84
- const name = path.split('/').pop().replace(/\.(step|stp|wrl)$/i, ''), dir = src.kicad ? `kicad/${path.split('/').slice(-2, -1)[0]}` : 'source';
85
- const read = (ext) => (src.file ? fs.promises.readFile(src.file.replace(/\.[^.]+$/, ext), 'utf8') : fetchText(src.url.replace(/\.[^./]+$/, ext)));
86
- if (src.licence || src.file) { // VRML where there is one (KiCad's library has both): a mesh
176
+ if (!src) {
177
+ notes.push(`no 3D model for ${path}: its path isn't one cad clone can follow`);
178
+ continue;
179
+ }
180
+ const name = path
181
+ .split('/')
182
+ .pop()
183
+ .replace(/\.(step|stp|wrl)$/i, ''),
184
+ dir = src.kicad ? `kicad/${path.split('/').slice(-2, -1)[0]}` : 'source';
185
+ const read = async (ext) => {
186
+ if (!src.file) return fetchText(src.url.replace(/\.[^./]+$/, ext));
187
+ const f = src.file.replace(/\.[^.]+$/, ext);
188
+ // (and where a link in the board's folder leads: it must stay in the folder too)
189
+ if (!inside(src.dir, f)) throw new Error(`its path leaves the board's folder, so cad clone doesn't follow it`);
190
+ return fs.promises.readFile(f, 'utf8');
191
+ };
192
+ if (src.licence || src.file) {
193
+ // VRML where there is one (KiCad's library has both): a mesh
87
194
  const wrl = /\.wrl$/i.test(path) || src.kicad ? await read('.wrl').catch(() => null) : null;
88
195
  if (wrl) {
89
196
  const triangles = wrlMesh(wrl).map((t) => t.map((v) => v.map((n) => Math.round(n * 1e3) / 1e3)));
90
197
  const file = `models/${dir}/${name}.json`;
91
198
  fs.mkdirSync(nodePath.join(WS, nodePath.dirname(file)), { recursive: true });
92
- fs.writeFileSync(nodePath.join(WS, file), JSON.stringify({ source: src.url || src.file, licence: src.licence, triangles }));
199
+ fs.writeFileSync(
200
+ nodePath.join(WS, file),
201
+ JSON.stringify({ source: src.url || src.file, licence: src.licence, triangles }),
202
+ );
93
203
  out[path] = { mesh: file, licence: src.licence };
94
204
  continue;
95
205
  }
96
206
  }
97
207
  const step = await read(nodePath.extname(path) || '.step').catch(() => read('.step'));
98
208
  const box = stepBounds(step);
99
- if (!box) { notes.push(`no 3D model for ${name}: its file has no points to measure`); continue; }
100
- out[path] = { box, ...(src.licence ? { licence: src.licence } : {}), size_only: src.licence ? 'a STEP model: drawn as the box round it' : 'no licence: only its size is used, drawn as a box' };
101
- } catch (e) { notes.push(`no 3D model for ${path.split('/').pop()}: ${e.message}`); }
209
+ if (!box) {
210
+ notes.push(`no 3D model for ${name}: its file has no points to measure`);
211
+ continue;
212
+ }
213
+ out[path] = {
214
+ box,
215
+ ...(src.licence ? { licence: src.licence } : {}),
216
+ size_only: src.licence
217
+ ? 'a STEP model: drawn as the box round it'
218
+ : 'no licence: only its size is used, drawn as a box',
219
+ };
220
+ } catch (e) {
221
+ notes.push(`no 3D model for ${path.split('/').pop()}: ${e.message}`);
222
+ }
102
223
  }
103
224
  return out;
104
225
  }
@@ -108,43 +229,74 @@ async function fetchModels(circuit, got, { wrlMesh, stepBounds }, notes) {
108
229
  * can't carry yet, and what the licence asks. o: { source, licence, force }.
109
230
  */
110
231
  export async function cloneBoard(ref, name, o = {}) {
111
- if (!ref || !/^[a-z][a-z0-9_]*$/.test(name || '')) throw new Error('usage: cad clone <board.kicad_pcb | GitHub link> <name> [--source <link>] [--licence <licence>] [--force] (name: lower case, digits and _)');
232
+ if (!ref || !/^[a-z][a-z0-9_]*$/.test(name || ''))
233
+ throw new Error(
234
+ 'usage: cad clone <board.kicad_pcb | GitHub link> <name> [--source <link>] [--licence <licence>] [--force] (name: lower case, digits and _)',
235
+ );
112
236
  const to = path.join(WS, 'rules', `${name}.json`);
113
237
  if (fs.existsSync(to) && !o.force) throw new Error(`rules/${name}.json already exists (--force to replace it)`);
114
238
  const { fromKicadPcb, clone, learnPlacement, wrlMesh, stepBounds } = await pcbEngine();
115
239
  if (!learnPlacement) throw new Error('cad clone needs @rulecad/pcb 0.3.8 or later: npm install @rulecad/pcb@latest');
116
240
  const got = await fetchBoard(ref, o);
117
241
  const circuit = fromKicadPcb(got.text);
118
- circuit.source = { ...circuit.source, from: got.source, ...(got.commit ? { commit: got.commit } : {}), read: today() };
242
+ circuit.source = {
243
+ ...circuit.source,
244
+ from: got.source,
245
+ ...(got.commit ? { commit: got.commit } : {}),
246
+ read: today(),
247
+ };
119
248
  circuit.placement = learnPlacement(circuit); // which small parts stay by which pins: edit max to be stricter or freer
120
249
  const modelNotes = [];
121
250
  if (!o.noModels && wrlMesh) circuit.models = await fetchModels(circuit, got, { wrlMesh, stepBounds }, modelNotes);
122
- const extra = { kind: 'derived', source: got.source, ...(got.licence ? { licence: got.licence } : {}), checked: today() };
251
+ const extra = {
252
+ kind: 'derived',
253
+ source: got.source,
254
+ ...(got.licence ? { licence: got.licence } : {}),
255
+ checked: today(),
256
+ };
123
257
  const rule = (value, unit, text) => ({ value, ...(unit ? { unit } : {}), rule: text, ...extra });
124
258
  const rules = {
125
- width: rule(circuit.width, 'mm', 'The source board\'s width, across its outline'),
126
- height: rule(circuit.height, 'mm', 'The source board\'s height, across its outline'),
127
- layers: rule(circuit.layers, null, `Copper layers on the source board (${circuit.copper.join(', ')})`)
259
+ width: rule(circuit.width, 'mm', "The source board's width, across its outline"),
260
+ height: rule(circuit.height, 'mm', "The source board's height, across its outline"),
261
+ layers: rule(circuit.layers, null, `Copper layers on the source board (${circuit.copper.join(', ')})`),
128
262
  };
129
- if (circuit.thickness) rules.thickness = rule(circuit.thickness, 'mm', 'The source board\'s thickness');
263
+ if (circuit.thickness) rules.thickness = rule(circuit.thickness, 'mm', "The source board's thickness");
130
264
  const doc = `Cloned from ${got.source} by cad clone: the circuit of a published board (its parts, pads, nets, planes and outline), for @rulecad/pcb's clone() to redraw by rules.${got.licence ? ` Licence: ${got.licence}.` : ' Licence unknown: find it before sharing anything made from this.'}${reciprocal(got.licence) ? ' Boards made from it must be shared under the same licence, with their design files.' : ''}`;
131
265
  fs.mkdirSync(path.dirname(to), { recursive: true });
132
- fs.writeFileSync(to, `${JSON.stringify({ _doc: doc, name, ...(got.licence ? { licence: got.licence } : {}), rules, circuit }, null, 1)}\n`);
266
+ fs.writeFileSync(
267
+ to,
268
+ `${JSON.stringify({ _doc: doc, name, ...(got.licence ? { licence: got.licence } : {}), rules, circuit }, null, 1)}\n`,
269
+ );
133
270
 
134
- const nets = Object.keys(circuit.nets).length, planes = Object.keys(circuit.planes);
135
- console.log(`made ${path.relative(process.cwd(), to)}: ${circuit.parts.length} parts, ${nets} nets, ${circuit.width} × ${circuit.height} mm, ${circuit.layers} copper layers${planes.length ? `, planes ${planes.join(' ')}` : ''}`);
271
+ const nets = Object.keys(circuit.nets).length,
272
+ planes = Object.keys(circuit.planes);
273
+ console.log(
274
+ `made ${path.relative(process.cwd(), to)}: ${circuit.parts.length} parts, ${nets} nets, ${circuit.width} × ${circuit.height} mm, ${circuit.layers} copper layers${planes.length ? `, planes ${planes.join(' ')}` : ''}`,
275
+ );
136
276
  console.log(` from ${got.source}`);
137
- console.log(` placement: ${circuit.placement.length} small parts kept near the pins they serve (circuit.placement: edit max to change how near)`);
277
+ console.log(
278
+ ` placement: ${circuit.placement.length} small parts kept near the pins they serve (circuit.placement: edit max to change how near)`,
279
+ );
138
280
  if (circuit.models) {
139
- const all = Object.values(circuit.models), boxes = all.filter((m) => m.box).length;
140
- console.log(` 3D models: ${all.length - boxes} as meshes (in models/), ${boxes} as boxes the size of the part${all.some((m) => /no licence/.test(m.size_only || '')) ? ' (some have no licence: only their size is used)' : ''}`);
281
+ const all = Object.values(circuit.models),
282
+ boxes = all.filter((m) => m.box).length;
283
+ console.log(
284
+ ` 3D models: ${all.length - boxes} as meshes (in models/), ${boxes} as boxes the size of the part${all.some((m) => /no licence/.test(m.size_only || '')) ? ' (some have no licence: only their size is used)' : ''}`,
285
+ );
141
286
  }
142
287
  for (const n of modelNotes) console.log(` note: ${n}`);
143
- if (!circuit.outline) console.log(' note: the outline isn\'t one closed shape: designs get its bounds');
288
+ if (!circuit.outline) console.log(" note: the outline isn't one closed shape: designs get its bounds");
144
289
  for (const n of clone(circuit).notes) console.log(` note: ${n}`);
145
- if (!got.licence) console.log(' ! no licence given (--licence): find the source\'s licence before sharing anything made from it');
146
- else if (limiting(got.licence)) console.log(` ! licence "${got.licence}" limits what you may make from this: read it before using the circuit`);
147
- else if (reciprocal(got.licence)) console.log(` ! licence "${got.licence}" is reciprocal: boards made from this must be shared under it too, with their design files. Keep this rule set apart from rules under other licences`);
148
- console.log(` use it in a board: clone(v.${name}.circuit) from @rulecad/pcb gives the parts and nets, each where the source put it`);
290
+ if (!got.licence)
291
+ console.log(" ! no licence given (--licence): find the source's licence before sharing anything made from it");
292
+ else if (limiting(got.licence))
293
+ console.log(` ! licence "${got.licence}" limits what you may make from this: read it before using the circuit`);
294
+ else if (reciprocal(got.licence))
295
+ console.log(
296
+ ` ! licence "${got.licence}" is reciprocal: boards made from this must be shared under it too, with their design files. Keep this rule set apart from rules under other licences`,
297
+ );
298
+ console.log(
299
+ ` use it in a board: clone(v.${name}.circuit) from @rulecad/pcb gives the parts and nets, each where the source put it`,
300
+ );
149
301
  return { to, circuit };
150
302
  }