imrishabh18/rp2040-motor-controller

A library of PCB component definitions covering MOSFETs, motor drivers, USB-PD control, sensors, current monitors, transistors, diodes, resistors, speakers, connectors, and mirrored bottom-side logos, with pin mappings, footprints, and 3D models.

Version
1.0.55
License
unset
Stars
5

scripts/patch-preview-renderer.ts

// Adapter for the renderer embedded in @tscircuit/runframe 0.0.3058.
// Its canvas drawer already splits full routes at vias and layer changes, and
// restricts complete runs to the requested copper layers. Filtering individual
// points first removes those boundaries and invents straight copper bridges.
const originalFilter = 'pso=(g,A)=>{const I=g.route.filter(o=>o.route_type==="wire"&&"layer"in o&&A.has(o.layer)?!0:o.route_type==="via"?A.has(o.from_layer)||A.has(o.to_layer):!1),e=I.filter(o=>o.route_type==="wire").length,t=I.some(o=>o.route_type==="via");return e<2&&!t?null:{...g,route:I}}';
const fixedFilter = 'pso=(g,A)=>g.route.some(o=>o.route_type==="wire"&&"layer"in o&&A.has(o.layer)||o.route_type==="via"&&(A.has(o.from_layer)||A.has(o.to_layer)))?g:null';

export function patchPreviewRenderer(standalone: string): string {
  if (standalone.split(originalFilter).length !== 2) {
    throw new Error("Runframe trace filter changed; review the preview renderer adapter before starting.");
  }
  return "// Motor controller preview: preserve complete multilayer trace routes.\n" +
    standalone.replace(originalFilter, fixedFilter);
}