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/circuit-hash.ts

import { createHash } from "node:crypto";
import type { AnyCircuitElement } from "circuit-json";
function canonical(value: unknown): unknown {
  if (Array.isArray(value)) return value.map(canonical);
  if (value && typeof value === "object")
    return Object.fromEntries(
      Object.entries(value)
        .sort(([a], [b]) => a.localeCompare(b))
        .map(([k, v]) => [k, canonical(v)]),
    );
  return value;
}
/** Hash the entire electrical/physical/schematic artifact; filesystem metadata
 * differs between the local checkout and cloud build and has no circuit geometry.
 */
export function circuitHash(json: AnyCircuitElement[]) {
  return createHash("sha256")
    .update(
      JSON.stringify(
        canonical(json.filter((e) => e.type !== "source_project_metadata")),
      ),
    )
    .digest("hex");
}