@tscircuit/core 0.0.256 → 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.js +90 -75
- package/package.json +3 -2
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: () =>
|
|
47
|
+
Trace: () => Trace2,
|
|
48
48
|
TraceHint: () => TraceHint,
|
|
49
49
|
Transistor: () => Transistor,
|
|
50
50
|
Via: () => Via
|
|
@@ -4475,6 +4475,75 @@ function getTraceDisplayName({
|
|
|
4475
4475
|
return void 0;
|
|
4476
4476
|
}
|
|
4477
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
|
+
|
|
4478
4547
|
// lib/components/primitive-components/Trace/Trace.ts
|
|
4479
4548
|
var portToObjective = (port) => {
|
|
4480
4549
|
const portPosition = port._getGlobalPcbPositionAfterLayout();
|
|
@@ -4484,7 +4553,7 @@ var portToObjective = (port) => {
|
|
|
4484
4553
|
};
|
|
4485
4554
|
};
|
|
4486
4555
|
var SHOULD_USE_SINGLE_LAYER_ROUTING = false;
|
|
4487
|
-
var
|
|
4556
|
+
var Trace2 = class extends PrimitiveComponent {
|
|
4488
4557
|
source_trace_id = null;
|
|
4489
4558
|
pcb_trace_id = null;
|
|
4490
4559
|
schematic_trace_id = null;
|
|
@@ -5000,76 +5069,15 @@ searched component ${targetComponent.getString()}, which has ports: ${targetComp
|
|
|
5000
5069
|
const { allPortsFound, portsWithSelectors: connectedPorts } = this._findConnectedPorts();
|
|
5001
5070
|
const { netsWithSelectors } = this._findConnectedNets();
|
|
5002
5071
|
if (!allPortsFound) return;
|
|
5003
|
-
const obstacles = [];
|
|
5004
|
-
const connection = {
|
|
5005
|
-
name: this.source_trace_id,
|
|
5006
|
-
pointsToConnect: []
|
|
5007
|
-
};
|
|
5008
5072
|
if (this.props.schDisplayLabel && ("from" in this.props && "to" in this.props || "path" in this.props)) {
|
|
5009
5073
|
this._doInitialSchematicTraceRenderWithDisplayLabel();
|
|
5010
5074
|
return;
|
|
5011
5075
|
}
|
|
5012
|
-
|
|
5013
|
-
|
|
5014
|
-
|
|
5015
|
-
|
|
5016
|
-
|
|
5017
|
-
center: elm.center,
|
|
5018
|
-
width: elm.size.width,
|
|
5019
|
-
height: elm.size.height,
|
|
5020
|
-
connectedTo: []
|
|
5021
|
-
});
|
|
5022
|
-
}
|
|
5023
|
-
if (elm.type === "schematic_port") {
|
|
5024
|
-
obstacles.push({
|
|
5025
|
-
type: "rect",
|
|
5026
|
-
layers: ["top"],
|
|
5027
|
-
center: elm.center,
|
|
5028
|
-
width: 0.1,
|
|
5029
|
-
height: 0.1,
|
|
5030
|
-
connectedTo: []
|
|
5031
|
-
});
|
|
5032
|
-
}
|
|
5033
|
-
if (elm.type === "schematic_text") {
|
|
5034
|
-
obstacles.push({
|
|
5035
|
-
type: "rect",
|
|
5036
|
-
layers: ["top"],
|
|
5037
|
-
center: elm.position,
|
|
5038
|
-
width: (elm.text?.length ?? 0) * 0.1,
|
|
5039
|
-
height: 0.2,
|
|
5040
|
-
connectedTo: []
|
|
5041
|
-
});
|
|
5042
|
-
}
|
|
5043
|
-
if (elm.type === "schematic_box") {
|
|
5044
|
-
obstacles.push({
|
|
5045
|
-
type: "rect",
|
|
5046
|
-
layers: ["top"],
|
|
5047
|
-
center: { x: elm.x, y: elm.y },
|
|
5048
|
-
width: elm.width,
|
|
5049
|
-
height: elm.width,
|
|
5050
|
-
connectedTo: []
|
|
5051
|
-
});
|
|
5052
|
-
}
|
|
5053
|
-
if (elm.type === "schematic_net_label" && elm.symbol_name) {
|
|
5054
|
-
obstacles.push({
|
|
5055
|
-
type: "rect",
|
|
5056
|
-
layers: ["top"],
|
|
5057
|
-
center: elm.center,
|
|
5058
|
-
width: 0.25,
|
|
5059
|
-
height: 0.6,
|
|
5060
|
-
connectedTo: []
|
|
5061
|
-
});
|
|
5062
|
-
} else if (elm.type === "schematic_net_label") {
|
|
5063
|
-
obstacles.push({
|
|
5064
|
-
type: "rect",
|
|
5065
|
-
layers: ["top"],
|
|
5066
|
-
center: elm.center,
|
|
5067
|
-
width: (elm.text?.length ?? 0) * 0.1,
|
|
5068
|
-
height: 0.2,
|
|
5069
|
-
connectedTo: []
|
|
5070
|
-
});
|
|
5071
|
-
}
|
|
5072
|
-
}
|
|
5076
|
+
const connection = {
|
|
5077
|
+
name: this.source_trace_id,
|
|
5078
|
+
pointsToConnect: []
|
|
5079
|
+
};
|
|
5080
|
+
const obstacles = getSchematicObstaclesForTrace(this);
|
|
5073
5081
|
const portsWithPosition = connectedPorts.map(({ port }) => ({
|
|
5074
5082
|
port,
|
|
5075
5083
|
position: port._getGlobalSchematicPositionAfterLayout(),
|
|
@@ -5098,11 +5106,17 @@ searched component ${targetComponent.getString()}, which has ports: ${targetComp
|
|
|
5098
5106
|
layer: "top"
|
|
5099
5107
|
}));
|
|
5100
5108
|
const bounds = computeObstacleBounds(obstacles);
|
|
5109
|
+
const BOUNDS_MARGIN = 1;
|
|
5101
5110
|
const simpleRouteJsonInput = {
|
|
5102
5111
|
minTraceWidth: 0.1,
|
|
5103
5112
|
obstacles,
|
|
5104
5113
|
connections: [connection],
|
|
5105
|
-
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
|
+
},
|
|
5106
5120
|
layerCount: 1
|
|
5107
5121
|
};
|
|
5108
5122
|
let Autorouter = MultilayerIjump;
|
|
@@ -5112,7 +5126,8 @@ searched component ${targetComponent.getString()}, which has ports: ${targetComp
|
|
|
5112
5126
|
const autorouter = new Autorouter({
|
|
5113
5127
|
input: simpleRouteJsonInput,
|
|
5114
5128
|
OBSTACLE_MARGIN: 0.1,
|
|
5115
|
-
isRemovePathLoopsEnabled: true
|
|
5129
|
+
isRemovePathLoopsEnabled: true,
|
|
5130
|
+
isShortenPathWithShortcutsEnabled: false
|
|
5116
5131
|
});
|
|
5117
5132
|
const results = autorouter.solveAndMapToTraces();
|
|
5118
5133
|
if (results.length === 0) return;
|
|
@@ -5197,13 +5212,13 @@ var Capacitor = class extends NormalComponent {
|
|
|
5197
5212
|
doInitialCreateTracesFromProps() {
|
|
5198
5213
|
if (this.props.decouplingFor && this.props.decouplingTo) {
|
|
5199
5214
|
this.add(
|
|
5200
|
-
new
|
|
5215
|
+
new Trace2({
|
|
5201
5216
|
from: `${this.getSubcircuitSelector()} > port.1`,
|
|
5202
5217
|
to: this.props.decouplingFor
|
|
5203
5218
|
})
|
|
5204
5219
|
);
|
|
5205
5220
|
this.add(
|
|
5206
|
-
new
|
|
5221
|
+
new Trace2({
|
|
5207
5222
|
from: `${this.getSubcircuitSelector()} > port.2`,
|
|
5208
5223
|
to: this.props.decouplingTo
|
|
5209
5224
|
})
|
|
@@ -5421,13 +5436,13 @@ var Resistor = class extends NormalComponent {
|
|
|
5421
5436
|
doInitialCreateTracesFromProps() {
|
|
5422
5437
|
if (this.props.pullupFor && this.props.pullupTo) {
|
|
5423
5438
|
this.add(
|
|
5424
|
-
new
|
|
5439
|
+
new Trace2({
|
|
5425
5440
|
from: `${this.getSubcircuitSelector()} > port.1`,
|
|
5426
5441
|
to: this.props.pullupFor
|
|
5427
5442
|
})
|
|
5428
5443
|
);
|
|
5429
5444
|
this.add(
|
|
5430
|
-
new
|
|
5445
|
+
new Trace2({
|
|
5431
5446
|
from: `${this.getSubcircuitSelector()} > port.2`,
|
|
5432
5447
|
to: this.props.pullupTo
|
|
5433
5448
|
})
|
|
@@ -6493,7 +6508,7 @@ export {
|
|
|
6493
6508
|
SilkscreenText,
|
|
6494
6509
|
SmtPad,
|
|
6495
6510
|
Subcircuit,
|
|
6496
|
-
Trace,
|
|
6511
|
+
Trace2 as Trace,
|
|
6497
6512
|
TraceHint,
|
|
6498
6513
|
Transistor,
|
|
6499
6514
|
Via,
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tscircuit/core",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.0.
|
|
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.
|
|
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",
|