@tscircuit/core 0.0.265 → 0.0.266
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/dist/index.d.ts +9 -1
- package/dist/index.js +60 -0
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -9879,6 +9879,14 @@ declare const applyEditEventsToManualEditsFile: ({ circuitJson, editEvents, manu
|
|
|
9879
9879
|
manualEditsFile: z.infer<typeof manual_edits_file>;
|
|
9880
9880
|
}) => z.infer<typeof manual_edits_file>;
|
|
9881
9881
|
|
|
9882
|
+
/**
|
|
9883
|
+
* This function can only be called in the PcbTraceRender phase or later
|
|
9884
|
+
*/
|
|
9885
|
+
declare const getSimpleRouteJsonFromCircuitJson: ({ circuitJson, minTraceWidth, }: {
|
|
9886
|
+
circuitJson: AnyCircuitElement[];
|
|
9887
|
+
minTraceWidth?: number;
|
|
9888
|
+
}) => SimpleRouteJson;
|
|
9889
|
+
|
|
9882
9890
|
interface TscircuitElements {
|
|
9883
9891
|
resistor: _tscircuit_props.ResistorProps;
|
|
9884
9892
|
capacitor: _tscircuit_props.CapacitorProps;
|
|
@@ -9941,4 +9949,4 @@ declare module "react/jsx-runtime" {
|
|
|
9941
9949
|
}
|
|
9942
9950
|
}
|
|
9943
9951
|
|
|
9944
|
-
export { type AsyncEffect, Battery, Board, Capacitor, Chip, Circuit, type ComponentWithPins, Constraint, Crystal, Diode, FabricationNotePath, FabricationNoteText, Footprint, Group, Hole, type IRenderable, Inductor, Jumper, Keepout, Led, Mosfet, Net, NetAlias, NormalComponent, PinHeader, type PinLabelSpec, PlatedHole, Port, Potentiometer, PowerSource, PrimitiveComponent, Project, PushButton, type RenderPhase, type RenderPhaseFn, type RenderPhaseFunctions, type RenderPhaseStates, Renderable, Resistor, Resonator, RootCircuit, type RootCircuitEventName, SilkscreenCircle, SilkscreenLine, SilkscreenPath, SilkscreenRect, SilkscreenText, SmtPad, Subcircuit, Trace, TraceHint, Transistor, Via, applyEditEventsToManualEditsFile, createUseComponent, orderedRenderPhases, useCapacitor, useChip, useDiode, useLed, useRenderedCircuit, useResistor };
|
|
9952
|
+
export { type AsyncEffect, Battery, Board, Capacitor, Chip, Circuit, type ComponentWithPins, Constraint, Crystal, Diode, FabricationNotePath, FabricationNoteText, Footprint, Group, Hole, type IRenderable, Inductor, Jumper, Keepout, Led, Mosfet, Net, NetAlias, NormalComponent, PinHeader, type PinLabelSpec, PlatedHole, Port, Potentiometer, PowerSource, PrimitiveComponent, Project, PushButton, type RenderPhase, type RenderPhaseFn, type RenderPhaseFunctions, type RenderPhaseStates, Renderable, Resistor, Resonator, RootCircuit, type RootCircuitEventName, SilkscreenCircle, SilkscreenLine, SilkscreenPath, SilkscreenRect, SilkscreenText, SmtPad, Subcircuit, Trace, TraceHint, Transistor, Via, applyEditEventsToManualEditsFile, createUseComponent, getSimpleRouteJsonFromCircuitJson, orderedRenderPhases, useCapacitor, useChip, useDiode, useLed, useRenderedCircuit, useResistor };
|
package/dist/index.js
CHANGED
|
@@ -6562,6 +6562,65 @@ var applyEditEventsToManualEditsFile = ({
|
|
|
6562
6562
|
return updatedManualEditsFile;
|
|
6563
6563
|
};
|
|
6564
6564
|
|
|
6565
|
+
// lib/utils/autorouting/getSimpleRouteJsonFromCircuitJson.ts
|
|
6566
|
+
import { getObstaclesFromSoup as getObstaclesFromSoup4 } from "@tscircuit/infgrid-ijump-astar";
|
|
6567
|
+
import { su as su3 } from "@tscircuit/soup-util";
|
|
6568
|
+
var getSimpleRouteJsonFromCircuitJson = ({
|
|
6569
|
+
circuitJson,
|
|
6570
|
+
minTraceWidth = 0.1
|
|
6571
|
+
}) => {
|
|
6572
|
+
const db = su3(circuitJson);
|
|
6573
|
+
const obstacles = getObstaclesFromSoup4([
|
|
6574
|
+
...db.pcb_component.list(),
|
|
6575
|
+
...db.pcb_smtpad.list(),
|
|
6576
|
+
...db.pcb_plated_hole.list()
|
|
6577
|
+
]);
|
|
6578
|
+
const allPoints = obstacles.flatMap((o) => [
|
|
6579
|
+
{
|
|
6580
|
+
x: o.center.x - o.width / 2,
|
|
6581
|
+
y: o.center.y - o.height / 2
|
|
6582
|
+
},
|
|
6583
|
+
{
|
|
6584
|
+
x: o.center.x + o.width / 2,
|
|
6585
|
+
y: o.center.y + o.height / 2
|
|
6586
|
+
}
|
|
6587
|
+
]);
|
|
6588
|
+
const bounds = {
|
|
6589
|
+
minX: Math.min(...allPoints.map((p) => p.x)) - 1,
|
|
6590
|
+
maxX: Math.max(...allPoints.map((p) => p.x)) + 1,
|
|
6591
|
+
minY: Math.min(...allPoints.map((p) => p.y)) - 1,
|
|
6592
|
+
maxY: Math.max(...allPoints.map((p) => p.y)) + 1
|
|
6593
|
+
};
|
|
6594
|
+
const connections = db.source_trace.list().map((trace) => {
|
|
6595
|
+
const connectedPorts = trace.connected_source_port_ids.map((id) => {
|
|
6596
|
+
const source_port = db.source_port.get(id);
|
|
6597
|
+
const pcb_port = db.pcb_port.getWhere({ source_port_id: id });
|
|
6598
|
+
return {
|
|
6599
|
+
...source_port,
|
|
6600
|
+
...pcb_port
|
|
6601
|
+
};
|
|
6602
|
+
});
|
|
6603
|
+
if (connectedPorts.length < 2) return null;
|
|
6604
|
+
return {
|
|
6605
|
+
name: trace.source_trace_id ?? "",
|
|
6606
|
+
pointsToConnect: connectedPorts.map((port) => {
|
|
6607
|
+
return {
|
|
6608
|
+
x: port.x,
|
|
6609
|
+
y: port.y,
|
|
6610
|
+
layer: port.layers?.[0] ?? "top"
|
|
6611
|
+
};
|
|
6612
|
+
})
|
|
6613
|
+
};
|
|
6614
|
+
}).filter((c) => c !== null);
|
|
6615
|
+
return {
|
|
6616
|
+
bounds,
|
|
6617
|
+
obstacles: [],
|
|
6618
|
+
connections,
|
|
6619
|
+
layerCount: 2,
|
|
6620
|
+
minTraceWidth
|
|
6621
|
+
};
|
|
6622
|
+
};
|
|
6623
|
+
|
|
6565
6624
|
// lib/index.ts
|
|
6566
6625
|
import { createElement } from "react";
|
|
6567
6626
|
|
|
@@ -6618,6 +6677,7 @@ export {
|
|
|
6618
6677
|
applyEditEventsToManualEditsFile,
|
|
6619
6678
|
createElement,
|
|
6620
6679
|
createUseComponent,
|
|
6680
|
+
getSimpleRouteJsonFromCircuitJson,
|
|
6621
6681
|
orderedRenderPhases,
|
|
6622
6682
|
useCapacitor,
|
|
6623
6683
|
useChip,
|