@tscircuit/core 0.0.264 → 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 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
@@ -781,37 +781,44 @@ var PrimitiveComponent = class extends Renderable {
781
781
  _getSchematicSymbolName() {
782
782
  const { _parsedProps: props } = this;
783
783
  const base_symbol_name = this.config.schematicSymbolName;
784
+ let normalizedRotation = props.schRotation;
785
+ if (normalizedRotation === void 0) {
786
+ normalizedRotation = 0;
787
+ }
788
+ normalizedRotation = normalizedRotation % 360;
789
+ if (normalizedRotation < 0) {
790
+ normalizedRotation += 360;
791
+ }
792
+ if (props.schRotation !== void 0 && normalizedRotation % 90 !== 0) {
793
+ throw new Error(
794
+ `Schematic rotation ${props.schRotation} is not supported for ${this.componentName}`
795
+ );
796
+ }
784
797
  const symbol_name_horz = `${base_symbol_name}_horz`;
785
798
  const symbol_name_vert = `${base_symbol_name}_vert`;
786
799
  const symbol_name_up = `${base_symbol_name}_up`;
787
800
  const symbol_name_down = `${base_symbol_name}_down`;
788
801
  const symbol_name_left = `${base_symbol_name}_left`;
789
802
  const symbol_name_right = `${base_symbol_name}_right`;
790
- if (props.schRotation !== void 0 && props.schRotation !== 0 && props.schRotation !== 90 && props.schRotation !== 180 && props.schRotation !== 270) {
791
- throw new Error(
792
- `Schematic rotation ${props.schRotation} is not supported for ${this.componentName}`
793
- );
794
- }
795
- if (symbol_name_right in symbols && (props.schRotation === void 0 || props.schRotation === 0)) {
803
+ if (symbol_name_right in symbols && normalizedRotation === 0) {
796
804
  return symbol_name_right;
797
805
  }
798
- if (symbol_name_up in symbols && props.schRotation === 90) {
806
+ if (symbol_name_up in symbols && normalizedRotation === 90) {
799
807
  return symbol_name_up;
800
808
  }
801
- if (symbol_name_left in symbols && props.schRotation === 180) {
809
+ if (symbol_name_left in symbols && normalizedRotation === 180) {
802
810
  return symbol_name_left;
803
811
  }
804
- if (symbol_name_down in symbols && props.schRotation === 270) {
812
+ if (symbol_name_down in symbols && normalizedRotation === 270) {
805
813
  return symbol_name_down;
806
814
  }
807
815
  if (symbol_name_horz in symbols) {
808
- if (props.schRotation === 0 || props.schRotation === void 0)
809
- return symbol_name_horz;
810
- if (props.schRotation === 180) return symbol_name_horz;
816
+ if (normalizedRotation === 0) return symbol_name_horz;
817
+ if (normalizedRotation === 180) return symbol_name_horz;
811
818
  }
812
819
  if (symbol_name_vert in symbols) {
813
- if (props.schRotation === 90) return symbol_name_vert;
814
- if (props.schRotation === 270) return symbol_name_vert;
820
+ if (normalizedRotation === 90) return symbol_name_vert;
821
+ if (normalizedRotation === 270) return symbol_name_vert;
815
822
  }
816
823
  if (base_symbol_name in symbols) return base_symbol_name;
817
824
  return void 0;
@@ -6555,6 +6562,65 @@ var applyEditEventsToManualEditsFile = ({
6555
6562
  return updatedManualEditsFile;
6556
6563
  };
6557
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
+
6558
6624
  // lib/index.ts
6559
6625
  import { createElement } from "react";
6560
6626
 
@@ -6611,6 +6677,7 @@ export {
6611
6677
  applyEditEventsToManualEditsFile,
6612
6678
  createElement,
6613
6679
  createUseComponent,
6680
+ getSimpleRouteJsonFromCircuitJson,
6614
6681
  orderedRenderPhases,
6615
6682
  useCapacitor,
6616
6683
  useChip,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@tscircuit/core",
3
3
  "type": "module",
4
- "version": "0.0.264",
4
+ "version": "0.0.266",
5
5
  "types": "dist/index.d.ts",
6
6
  "main": "dist/index.js",
7
7
  "module": "dist/index.js",