@tscircuit/core 0.0.265 → 0.0.267
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 +66 -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,71 @@ 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
|
+
import { getFullConnectivityMapFromCircuitJson as getFullConnectivityMapFromCircuitJson2 } from "circuit-json-to-connectivity-map";
|
|
6569
|
+
var getSimpleRouteJsonFromCircuitJson = ({
|
|
6570
|
+
circuitJson,
|
|
6571
|
+
minTraceWidth = 0.1
|
|
6572
|
+
}) => {
|
|
6573
|
+
const db = su3(circuitJson);
|
|
6574
|
+
const connMap = getFullConnectivityMapFromCircuitJson2(circuitJson);
|
|
6575
|
+
const obstacles = getObstaclesFromSoup4(
|
|
6576
|
+
[
|
|
6577
|
+
...db.pcb_component.list(),
|
|
6578
|
+
...db.pcb_smtpad.list(),
|
|
6579
|
+
...db.pcb_plated_hole.list()
|
|
6580
|
+
],
|
|
6581
|
+
connMap
|
|
6582
|
+
);
|
|
6583
|
+
const allPoints = obstacles.flatMap((o) => [
|
|
6584
|
+
{
|
|
6585
|
+
x: o.center.x - o.width / 2,
|
|
6586
|
+
y: o.center.y - o.height / 2
|
|
6587
|
+
},
|
|
6588
|
+
{
|
|
6589
|
+
x: o.center.x + o.width / 2,
|
|
6590
|
+
y: o.center.y + o.height / 2
|
|
6591
|
+
}
|
|
6592
|
+
]);
|
|
6593
|
+
const bounds = {
|
|
6594
|
+
minX: Math.min(...allPoints.map((p) => p.x)) - 1,
|
|
6595
|
+
maxX: Math.max(...allPoints.map((p) => p.x)) + 1,
|
|
6596
|
+
minY: Math.min(...allPoints.map((p) => p.y)) - 1,
|
|
6597
|
+
maxY: Math.max(...allPoints.map((p) => p.y)) + 1
|
|
6598
|
+
};
|
|
6599
|
+
const connections = db.source_trace.list().map((trace) => {
|
|
6600
|
+
const connectedPorts = trace.connected_source_port_ids.map((id) => {
|
|
6601
|
+
const source_port = db.source_port.get(id);
|
|
6602
|
+
const pcb_port = db.pcb_port.getWhere({ source_port_id: id });
|
|
6603
|
+
return {
|
|
6604
|
+
...source_port,
|
|
6605
|
+
...pcb_port
|
|
6606
|
+
};
|
|
6607
|
+
});
|
|
6608
|
+
if (connectedPorts.length < 2) return null;
|
|
6609
|
+
return {
|
|
6610
|
+
name: connMap.getNetConnectedToId(trace.source_trace_id) ?? trace.source_trace_id ?? "",
|
|
6611
|
+
source_trace_id: trace.source_trace_id,
|
|
6612
|
+
pointsToConnect: connectedPorts.map((port) => {
|
|
6613
|
+
return {
|
|
6614
|
+
x: port.x,
|
|
6615
|
+
y: port.y,
|
|
6616
|
+
layer: port.layers?.[0] ?? "top"
|
|
6617
|
+
};
|
|
6618
|
+
})
|
|
6619
|
+
};
|
|
6620
|
+
}).filter((c) => c !== null);
|
|
6621
|
+
return {
|
|
6622
|
+
bounds,
|
|
6623
|
+
obstacles,
|
|
6624
|
+
connections,
|
|
6625
|
+
layerCount: 2,
|
|
6626
|
+
minTraceWidth
|
|
6627
|
+
};
|
|
6628
|
+
};
|
|
6629
|
+
|
|
6565
6630
|
// lib/index.ts
|
|
6566
6631
|
import { createElement } from "react";
|
|
6567
6632
|
|
|
@@ -6618,6 +6683,7 @@ export {
|
|
|
6618
6683
|
applyEditEventsToManualEditsFile,
|
|
6619
6684
|
createElement,
|
|
6620
6685
|
createUseComponent,
|
|
6686
|
+
getSimpleRouteJsonFromCircuitJson,
|
|
6621
6687
|
orderedRenderPhases,
|
|
6622
6688
|
useCapacitor,
|
|
6623
6689
|
useChip,
|