@rulecad/cad 0.7.43 → 0.7.44
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/README.md +3 -0
- package/bin/cad.mjs +2 -2
- package/lib/links.mjs +15 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -93,6 +93,9 @@ fragment, which never reaches the web host, so the public page can open private
|
|
|
93
93
|
which version it holds (`keyboard/keycap@0.1.0`, or `+changes` if it isn't a release). The page is `@rulecad/viewer`: host your
|
|
94
94
|
own copy anywhere and name it in `viewUrl`.
|
|
95
95
|
|
|
96
|
+
- **Circuit boards:** a board's link also carries its fab zip, the same one `cad export` writes (Gerbers, drill files,
|
|
97
|
+
parts list, placement; plotted by KiCad where the board needs it). The page offers it as **Download for JLCPCB**. A
|
|
98
|
+
board whose zip can't be made here (one that needs KiCad, without it) goes without, and `cad link` says why.
|
|
96
99
|
- **Rules:** a link carries the model's values and the rules they use (value, source, kind, date checked) for the
|
|
97
100
|
page's Rules panel; estimates are marked there. A rule set with `"private": true` stays out of links, and
|
|
98
101
|
`--no-rules` leaves the list out altogether. Anyone with a link can read what it carries.
|
package/bin/cad.mjs
CHANGED
|
@@ -627,10 +627,10 @@ async function board(cmd, d, b, { title, version, tag }) {
|
|
|
627
627
|
// board and schematic beside it, and the matrix for firmware
|
|
628
628
|
const dir = paths.exports(d.project), { zip: zipOf } = await import('@rulecad/model-link');
|
|
629
629
|
fs.mkdirSync(dir, { recursive: true });
|
|
630
|
-
const fab = await pcb.fabFiles(b.circuit, d.name), zip = path.join(dir, `${name}-fab.zip`);
|
|
630
|
+
const fab = await pcb.fabFiles(b.circuit, d.name, { source: b.source }), zip = path.join(dir, `${name}-fab.zip`);
|
|
631
631
|
fs.writeFileSync(zip, await zipOf(Object.entries(fab)));
|
|
632
632
|
const written = [zip];
|
|
633
|
-
for (const [f, t] of Object.entries(await pcb.kicadFiles(b.circuit, name))) { fs.writeFileSync(path.join(dir, f), t); written.push(path.join(dir, f)); }
|
|
633
|
+
for (const [f, t] of Object.entries(await pcb.kicadFiles(b.circuit, name, { source: b.source }))) { fs.writeFileSync(path.join(dir, f), t); written.push(path.join(dir, f)); }
|
|
634
634
|
if (b.matrix) { const f = path.join(dir, `${name}-matrix.json`); fs.writeFileSync(f, JSON.stringify(b.matrix, null, 2) + '\n'); written.push(f); }
|
|
635
635
|
const done = [{ level: 'pass', text: `fab zip: ${Object.keys(fab).length} files (${Object.keys(fab).filter((f) => !/\.(csv|DRL)$/.test(f)).length} Gerber layers, 2 drill files, BOM, placement)` }];
|
|
636
636
|
if (opt('json')) return console.log(JSON.stringify({ object: `${d.project}/${d.name}`, version, files: written.map((f) => path.relative(WS, f)), findings: done }, null, 2));
|
package/lib/links.mjs
CHANGED
|
@@ -49,10 +49,24 @@ export async function objectModel(b, { title, version, src, set, filaments: fil
|
|
|
49
49
|
rules: b.entries.filter((e) => e.show).map((e) => [e.label || e.name, fmt(e.value), e.unit || '']),
|
|
50
50
|
...sheet([[b.object.name, b.entries]], { noRules }),
|
|
51
51
|
...(b.circuit ? { views: await (await pcbEngine()).views(b.circuit) } : {}), // boards: the 2D board and schematic
|
|
52
|
+
...(b.circuit ? await fabOf([[b.object.name, version, b]]) : {}), // and the zip to order it with
|
|
52
53
|
...fromParts(b.parts.map((p) => ({ name: p.name, role: p.role, label: p.label, slot: slotOf(fil, p.filament), triangles: triangles(p.triangles) }))),
|
|
53
54
|
};
|
|
54
55
|
}
|
|
55
56
|
|
|
57
|
+
// Each board's fab zip (cad export's: Gerbers, drill files, BOM, placement), for the page to offer as a download. A
|
|
58
|
+
// board whose files can't be made here (one that needs KiCad, without it) goes without, and says why
|
|
59
|
+
async function fabOf(boards) {
|
|
60
|
+
const pcb = await pcbEngine(), { zip } = await import('@rulecad/model-link'), fab = [];
|
|
61
|
+
for (const [name, version, b] of boards) {
|
|
62
|
+
try {
|
|
63
|
+
const files = await pcb.fabFiles(b.circuit, name, { source: b.source });
|
|
64
|
+
fab.push({ name: `${name}${version ? `@${version}` : ''}-fab.zip`.replace(/[^\w@.+-]/g, '-'), zip: Buffer.from(await zip(Object.entries(files))).toString('base64') });
|
|
65
|
+
} catch (e) { console.error(` ${name}: no fab zip in the link (${String(e.message || e).split('\n')[0]})`); }
|
|
66
|
+
}
|
|
67
|
+
return fab.length ? { fab } : {};
|
|
68
|
+
}
|
|
69
|
+
|
|
56
70
|
/** A built assembly as a model: each shape once and placed (nine keys cost one keycap), its boards' views, its joints. */
|
|
57
71
|
export async function assemblyModel(s, { title, versions, filaments: fil = {}, noRules = false, steps }) {
|
|
58
72
|
const placed = shapes(s.parts), list = placed.shapes.length ? placed.place.map(([i, ...m], n) => { const p = placed.shapes[i].part; return { shape: i, role: p.role, label: p.object || p.label, slot: slotOf(fil, p.filament), triangles: triangles(placed.shapes[i].triangles), matrix: m, name: s.parts[n].name }; }) : [];
|
|
@@ -78,7 +92,7 @@ export async function assemblyModel(s, { title, versions, filaments: fil = {}, n
|
|
|
78
92
|
if (!boards.length) return {};
|
|
79
93
|
const pcb = await pcbEngine(), views = [];
|
|
80
94
|
for (const o of boards) for (const [n, svg] of await pcb.views(o.built.circuit)) views.push([boards.length > 1 ? `${o.objName} ${n}` : n, svg]);
|
|
81
|
-
return { views };
|
|
95
|
+
return { views, ...(await fabOf(boards.map((o) => [o.objName, o.version || o.built.object?.version, o.built]))) };
|
|
82
96
|
})()),
|
|
83
97
|
...fromShapes(list),
|
|
84
98
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rulecad/cad",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.44",
|
|
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,7 +61,7 @@
|
|
|
61
61
|
"@rulecad/keyboard-layout": "^0.1.2",
|
|
62
62
|
"@rulecad/printcheck": "^0.3.0",
|
|
63
63
|
"@rulecad/fit": "^0.4.0",
|
|
64
|
-
"@rulecad/model-link": "^0.3.
|
|
64
|
+
"@rulecad/model-link": "^0.3.2",
|
|
65
65
|
"@rulecad/versions": "^0.1.0",
|
|
66
66
|
"@rulecad/shapes": "^0.4.4",
|
|
67
67
|
"@rulecad/rules": "^0.3.9",
|