@tscircuit/core 0.0.255 → 0.0.257

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
@@ -16,6 +16,12 @@ type RenderPhaseStates = Record<RenderPhase, {
16
16
  initialized: boolean;
17
17
  dirty: boolean;
18
18
  }>;
19
+ type AsyncEffect = {
20
+ effectName: string;
21
+ promise: Promise<void>;
22
+ phase: RenderPhase;
23
+ complete: boolean;
24
+ };
19
25
  type RenderPhaseFunctions = {
20
26
  [T in RenderPhaseFn]?: () => void;
21
27
  };
@@ -9926,4 +9932,4 @@ declare module "react/jsx-runtime" {
9926
9932
  }
9927
9933
  }
9928
9934
 
9929
- export { 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, Renderable, Resistor, Resonator, RootCircuit, type RootCircuitEventName, SilkscreenCircle, SilkscreenLine, SilkscreenPath, SilkscreenRect, SilkscreenText, SmtPad, Subcircuit, Trace, TraceHint, Transistor, Via, applyEditEventsToManualEditsFile, createUseComponent, useCapacitor, useChip, useDiode, useLed, useRenderedCircuit, useResistor };
9935
+ 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 };
package/dist/index.js CHANGED
@@ -44,7 +44,7 @@ __export(components_exports, {
44
44
  SilkscreenText: () => SilkscreenText,
45
45
  SmtPad: () => SmtPad,
46
46
  Subcircuit: () => Subcircuit,
47
- Trace: () => Trace,
47
+ Trace: () => Trace2,
48
48
  TraceHint: () => TraceHint,
49
49
  Transistor: () => Transistor,
50
50
  Via: () => Via
@@ -1181,6 +1181,7 @@ var Net = class extends PrimitiveComponent {
1181
1181
  */
1182
1182
  doInitialPcbRouteNetIslands() {
1183
1183
  if (this.root?.pcbDisabled) return;
1184
+ if (this.getSubcircuit()._parsedProps.routingDisabled) return;
1184
1185
  const { db } = this.root;
1185
1186
  const { _parsedProps: props } = this;
1186
1187
  const traces = this._getAllDirectlyConnectedTraces().filter(
@@ -4474,6 +4475,75 @@ function getTraceDisplayName({
4474
4475
  return void 0;
4475
4476
  }
4476
4477
 
4478
+ // lib/components/primitive-components/Trace/get-obstacles-for-trace.ts
4479
+ import "@tscircuit/math-utils";
4480
+ var getSchematicObstaclesForTrace = (trace) => {
4481
+ const db = trace.root.db;
4482
+ const obstacles = [];
4483
+ for (const elm of db.toArray()) {
4484
+ if (elm.type === "schematic_component") {
4485
+ obstacles.push({
4486
+ type: "rect",
4487
+ layers: ["top"],
4488
+ center: elm.center,
4489
+ width: elm.size.width,
4490
+ height: elm.size.height,
4491
+ connectedTo: []
4492
+ });
4493
+ }
4494
+ if (elm.type === "schematic_port") {
4495
+ obstacles.push({
4496
+ type: "rect",
4497
+ layers: ["top"],
4498
+ center: elm.center,
4499
+ width: 0.1,
4500
+ height: 0.1,
4501
+ connectedTo: []
4502
+ });
4503
+ }
4504
+ if (elm.type === "schematic_text") {
4505
+ obstacles.push({
4506
+ type: "rect",
4507
+ layers: ["top"],
4508
+ center: elm.position,
4509
+ width: (elm.text?.length ?? 0) * 0.1,
4510
+ height: 0.2,
4511
+ connectedTo: []
4512
+ });
4513
+ }
4514
+ if (elm.type === "schematic_box") {
4515
+ obstacles.push({
4516
+ type: "rect",
4517
+ layers: ["top"],
4518
+ center: { x: elm.x, y: elm.y },
4519
+ width: elm.width,
4520
+ height: elm.height,
4521
+ connectedTo: []
4522
+ });
4523
+ }
4524
+ if (elm.type === "schematic_net_label" && elm.symbol_name) {
4525
+ obstacles.push({
4526
+ type: "rect",
4527
+ layers: ["top"],
4528
+ center: elm.center,
4529
+ width: 0.25,
4530
+ height: 0.6,
4531
+ connectedTo: []
4532
+ });
4533
+ } else if (elm.type === "schematic_net_label") {
4534
+ obstacles.push({
4535
+ type: "rect",
4536
+ layers: ["top"],
4537
+ center: elm.center,
4538
+ width: (elm.text?.length ?? 0) * 0.1,
4539
+ height: 0.2,
4540
+ connectedTo: []
4541
+ });
4542
+ }
4543
+ }
4544
+ return obstacles;
4545
+ };
4546
+
4477
4547
  // lib/components/primitive-components/Trace/Trace.ts
4478
4548
  var portToObjective = (port) => {
4479
4549
  const portPosition = port._getGlobalPcbPositionAfterLayout();
@@ -4483,7 +4553,7 @@ var portToObjective = (port) => {
4483
4553
  };
4484
4554
  };
4485
4555
  var SHOULD_USE_SINGLE_LAYER_ROUTING = false;
4486
- var Trace = class extends PrimitiveComponent {
4556
+ var Trace2 = class extends PrimitiveComponent {
4487
4557
  source_trace_id = null;
4488
4558
  pcb_trace_id = null;
4489
4559
  schematic_trace_id = null;
@@ -4999,76 +5069,15 @@ searched component ${targetComponent.getString()}, which has ports: ${targetComp
4999
5069
  const { allPortsFound, portsWithSelectors: connectedPorts } = this._findConnectedPorts();
5000
5070
  const { netsWithSelectors } = this._findConnectedNets();
5001
5071
  if (!allPortsFound) return;
5002
- const obstacles = [];
5003
- const connection = {
5004
- name: this.source_trace_id,
5005
- pointsToConnect: []
5006
- };
5007
5072
  if (this.props.schDisplayLabel && ("from" in this.props && "to" in this.props || "path" in this.props)) {
5008
5073
  this._doInitialSchematicTraceRenderWithDisplayLabel();
5009
5074
  return;
5010
5075
  }
5011
- for (const elm of db.toArray()) {
5012
- if (elm.type === "schematic_component") {
5013
- obstacles.push({
5014
- type: "rect",
5015
- layers: ["top"],
5016
- center: elm.center,
5017
- width: elm.size.width,
5018
- height: elm.size.height,
5019
- connectedTo: []
5020
- });
5021
- }
5022
- if (elm.type === "schematic_port") {
5023
- obstacles.push({
5024
- type: "rect",
5025
- layers: ["top"],
5026
- center: elm.center,
5027
- width: 0.1,
5028
- height: 0.1,
5029
- connectedTo: []
5030
- });
5031
- }
5032
- if (elm.type === "schematic_text") {
5033
- obstacles.push({
5034
- type: "rect",
5035
- layers: ["top"],
5036
- center: elm.position,
5037
- width: (elm.text?.length ?? 0) * 0.1,
5038
- height: 0.2,
5039
- connectedTo: []
5040
- });
5041
- }
5042
- if (elm.type === "schematic_box") {
5043
- obstacles.push({
5044
- type: "rect",
5045
- layers: ["top"],
5046
- center: { x: elm.x, y: elm.y },
5047
- width: elm.width,
5048
- height: elm.width,
5049
- connectedTo: []
5050
- });
5051
- }
5052
- if (elm.type === "schematic_net_label" && elm.symbol_name) {
5053
- obstacles.push({
5054
- type: "rect",
5055
- layers: ["top"],
5056
- center: elm.center,
5057
- width: 0.25,
5058
- height: 0.6,
5059
- connectedTo: []
5060
- });
5061
- } else if (elm.type === "schematic_net_label") {
5062
- obstacles.push({
5063
- type: "rect",
5064
- layers: ["top"],
5065
- center: elm.center,
5066
- width: (elm.text?.length ?? 0) * 0.1,
5067
- height: 0.2,
5068
- connectedTo: []
5069
- });
5070
- }
5071
- }
5076
+ const connection = {
5077
+ name: this.source_trace_id,
5078
+ pointsToConnect: []
5079
+ };
5080
+ const obstacles = getSchematicObstaclesForTrace(this);
5072
5081
  const portsWithPosition = connectedPorts.map(({ port }) => ({
5073
5082
  port,
5074
5083
  position: port._getGlobalSchematicPositionAfterLayout(),
@@ -5097,11 +5106,17 @@ searched component ${targetComponent.getString()}, which has ports: ${targetComp
5097
5106
  layer: "top"
5098
5107
  }));
5099
5108
  const bounds = computeObstacleBounds(obstacles);
5109
+ const BOUNDS_MARGIN = 1;
5100
5110
  const simpleRouteJsonInput = {
5101
5111
  minTraceWidth: 0.1,
5102
5112
  obstacles,
5103
5113
  connections: [connection],
5104
- bounds,
5114
+ bounds: {
5115
+ minX: bounds.minX - BOUNDS_MARGIN,
5116
+ maxX: bounds.maxX + BOUNDS_MARGIN,
5117
+ minY: bounds.minY - BOUNDS_MARGIN,
5118
+ maxY: bounds.maxY + BOUNDS_MARGIN
5119
+ },
5105
5120
  layerCount: 1
5106
5121
  };
5107
5122
  let Autorouter = MultilayerIjump;
@@ -5111,7 +5126,8 @@ searched component ${targetComponent.getString()}, which has ports: ${targetComp
5111
5126
  const autorouter = new Autorouter({
5112
5127
  input: simpleRouteJsonInput,
5113
5128
  OBSTACLE_MARGIN: 0.1,
5114
- isRemovePathLoopsEnabled: true
5129
+ isRemovePathLoopsEnabled: true,
5130
+ isShortenPathWithShortcutsEnabled: false
5115
5131
  });
5116
5132
  const results = autorouter.solveAndMapToTraces();
5117
5133
  if (results.length === 0) return;
@@ -5196,13 +5212,13 @@ var Capacitor = class extends NormalComponent {
5196
5212
  doInitialCreateTracesFromProps() {
5197
5213
  if (this.props.decouplingFor && this.props.decouplingTo) {
5198
5214
  this.add(
5199
- new Trace({
5215
+ new Trace2({
5200
5216
  from: `${this.getSubcircuitSelector()} > port.1`,
5201
5217
  to: this.props.decouplingFor
5202
5218
  })
5203
5219
  );
5204
5220
  this.add(
5205
- new Trace({
5221
+ new Trace2({
5206
5222
  from: `${this.getSubcircuitSelector()} > port.2`,
5207
5223
  to: this.props.decouplingTo
5208
5224
  })
@@ -5420,13 +5436,13 @@ var Resistor = class extends NormalComponent {
5420
5436
  doInitialCreateTracesFromProps() {
5421
5437
  if (this.props.pullupFor && this.props.pullupTo) {
5422
5438
  this.add(
5423
- new Trace({
5439
+ new Trace2({
5424
5440
  from: `${this.getSubcircuitSelector()} > port.1`,
5425
5441
  to: this.props.pullupFor
5426
5442
  })
5427
5443
  );
5428
5444
  this.add(
5429
- new Trace({
5445
+ new Trace2({
5430
5446
  from: `${this.getSubcircuitSelector()} > port.2`,
5431
5447
  to: this.props.pullupTo
5432
5448
  })
@@ -6492,12 +6508,13 @@ export {
6492
6508
  SilkscreenText,
6493
6509
  SmtPad,
6494
6510
  Subcircuit,
6495
- Trace,
6511
+ Trace2 as Trace,
6496
6512
  TraceHint,
6497
6513
  Transistor,
6498
6514
  Via,
6499
6515
  applyEditEventsToManualEditsFile,
6500
6516
  createUseComponent,
6517
+ orderedRenderPhases,
6501
6518
  useCapacitor,
6502
6519
  useChip,
6503
6520
  useDiode,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@tscircuit/core",
3
3
  "type": "module",
4
- "version": "0.0.255",
4
+ "version": "0.0.257",
5
5
  "types": "dist/index.d.ts",
6
6
  "main": "dist/index.js",
7
7
  "module": "dist/index.js",
@@ -29,6 +29,7 @@
29
29
  "bun-match-svg": "0.0.8",
30
30
  "circuit-to-svg": "^0.0.97",
31
31
  "debug": "^4.3.6",
32
+ "graphics-debug": "^0.0.4",
32
33
  "howfat": "^0.3.8",
33
34
  "looks-same": "^9.0.1",
34
35
  "pkg-pr-new": "^0.0.37",
@@ -41,7 +42,7 @@
41
42
  "dependencies": {
42
43
  "@lume/kiwi": "^0.4.3",
43
44
  "@tscircuit/footprinter": "^0.0.97",
44
- "@tscircuit/infgrid-ijump-astar": "^0.0.26",
45
+ "@tscircuit/infgrid-ijump-astar": "^0.0.27",
45
46
  "@tscircuit/math-utils": "^0.0.5",
46
47
  "@tscircuit/props": "^0.0.128",
47
48
  "@tscircuit/schematic-autolayout": "^0.0.6",