@rulecad/pcb 0.7.0 → 0.7.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -3,6 +3,18 @@
3
3
  What changed in each release, for someone upgrading a workspace. A **drilled size** here is a dimension the fab
4
4
  makes (a hole's diameter in the drill file). Each release says whether any drilled or printed size moved, and why.
5
5
 
6
+ ## 0.7.1: routes are kept whole, and never written through a link
7
+
8
+ ### Fixed
9
+
10
+ - A route the autorouter found was written into the route cache (`RULECAD_ROUTE_CACHE`, a workspace's `.cache/routes`
11
+ when cad builds a trusted board) in place: a run stopped part way through left the file cut short, and a file there
12
+ that was a link to a file elsewhere, as a workspace cloned from someone else may carry, had that file overwritten. A
13
+ route is now written to a new file beside its place and then renamed over it: the file is whole or not there, and a
14
+ link in its place is replaced, never written through.
15
+
16
+ For someone upgrading: nothing to do. No printed size moves.
17
+
6
18
  ## 0.7.0: unused names removed and ignored failures explained; a hole that breaks through a round or rounded board's edge fails; KiCad footprints with oval, slotted or turned pads import; back text mirrored; simple mistakes refused; needs Node 24 or later, as two of the libraries it draws with do; on a shaped board, rectangular pads and slotted holes are checked against the edge by their whole shape
7
19
 
8
20
  ### Changed
package/circuit.mjs CHANGED
@@ -2542,12 +2542,17 @@ async function routeCache(input) {
2542
2542
  return null;
2543
2543
  }
2544
2544
  },
2545
+ // (written whole, to a new file beside it that is then renamed over it: a run stopped part way leaves no file cut
2546
+ // short, and a file there that is a link, one a workspace cloned from someone else may carry in its .cache/routes,
2547
+ // is replaced, never written through)
2545
2548
  write: (traces) => {
2549
+ const temp = path.join(dir, `.${key}.${process.pid}-${crypto.randomBytes(6).toString('hex')}.tmp`);
2546
2550
  try {
2547
2551
  fs.mkdirSync(dir, { recursive: true });
2548
- fs.writeFileSync(file, JSON.stringify(traces));
2552
+ fs.writeFileSync(temp, JSON.stringify(traces), { flag: 'wx' });
2553
+ fs.renameSync(temp, file);
2549
2554
  } catch {
2550
- // (a cache that can't be written is only slower)
2555
+ fs.rmSync(temp, { force: true }); // (a cache that can't be written is only slower)
2551
2556
  }
2552
2557
  },
2553
2558
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rulecad/pcb",
3
- "version": "0.7.0",
3
+ "version": "0.7.1",
4
4
  "description": "Circuit boards from rules: parts from rule sets or any standard footprint, quarter-turn rotation, nets and autorouting; keyboards with every matrix track drawn by rule. Gerbers, KiCad files and a JLCPCB BOM. Circuit JSON written directly: no React.",
5
5
  "type": "module",
6
6
  "exports": "./pcb.mjs",
@@ -38,8 +38,8 @@
38
38
  "dependencies": {
39
39
  "@flatten-js/core": "1.6.14",
40
40
  "@jscad/modeling": "^2.12.0",
41
- "@rulecad/fixings": "^0.2.0",
42
- "@rulecad/rules": "^0.4.0",
41
+ "@rulecad/fixings": "^0.3.0",
42
+ "@rulecad/rules": "^0.5.0",
43
43
  "@resvg/resvg-js": "2.6.2",
44
44
  "@rulecad/smooth": "^0.3.0",
45
45
  "@tscircuit/capacity-autorouter": "0.0.982",