astra-abse/t113-s3
Allwinner T113-S3 / JLCPCB C5197687: native saved fanout, LCD top, storage right, 127 perimeter exits, 30 decoupling capacitors, connected GND planes; clean DRC and shorts, all 29 vias connected.
- Version
- 1.2.0
- License
- MIT
- Stars
- 0
scripts/patch-cli-bitmap.ts
import assert from "node:assert/strict";
import { readFile, writeFile } from "node:fs/promises";
import { createHash } from "node:crypto";
const file = "node_modules/@tscircuit/cli/dist/cli/main.js";
const version = JSON.parse(
await readFile("node_modules/@tscircuit/cli/package.json", "utf8"),
).version;
assert.equal(
version,
"0.1.2050",
"Review the bitmap compatibility patch when upgrading CLI",
);
let source = await readFile(file, "utf8");
const hash = (s: string) => createHash("sha256").update(s).digest("hex");
const original = hash(source);
const fixes = [
[
'if (!layerCanvas)\n return null;\n return layerCanvas.getContext("2d");',
'if (!layerCanvas || typeof layerCanvas.getContext !== "function")\n return null;\n return layerCanvas.getContext("2d");',
],
[
" rasterizeFill(parts) {\n if (parts.length === 0)\n return;\n const bounds = getBounds2(parts);",
" rasterizeFill(parts) {\n if (parts.length === 0)\n return;\n const boundedParts = parts.map(part => ({part, bounds: getBounds2([part])}));\n const bounds = getBounds2(parts);",
],
[
' for (const part of parts) {\n if (part.type === "circle") {',
' for (const {part, bounds: partBounds} of boundedParts) {\n if (point.x < partBounds.minX || point.x > partBounds.maxX || point.y < partBounds.minY || point.y > partBounds.maxY) continue;\n if (part.type === "circle") {',
],
] as const;
for (const [before, after] of fixes) {
if (source.includes(after)) continue;
assert.equal(
source.split(before).length,
2,
"Expected one exact upstream patch site",
);
source = source.replace(before, after);
}
await writeFile(file, source);
console.log(
`CLI bitmap canvas compatibility fix applied (${original.slice(0, 12)} -> ${hash(source).slice(0, 12)}); all short detection logic retained.`,
);