@tscircuit/core 0.0.132 → 0.0.133
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 +110 -88
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1543,9 +1543,10 @@ var Port = class extends PrimitiveComponent {
|
|
|
1543
1543
|
console.warn(`Could not find parent symbol for ${this}`);
|
|
1544
1544
|
return { x: 0, y: 0 };
|
|
1545
1545
|
}
|
|
1546
|
+
const offsetY = -0.045;
|
|
1546
1547
|
const transform = compose3(
|
|
1547
1548
|
this.parent.computeSchematicGlobalTransform(),
|
|
1548
|
-
translate3(-symbol.center.x, -symbol.center.y)
|
|
1549
|
+
translate3(-symbol.center.x, -symbol.center.y + offsetY)
|
|
1549
1550
|
);
|
|
1550
1551
|
return applyToPoint4(transform, this.schematicSymbolPortDef);
|
|
1551
1552
|
}
|
|
@@ -2554,11 +2555,49 @@ var stringProxy = new Proxy(
|
|
|
2554
2555
|
var FTYPE = stringProxy;
|
|
2555
2556
|
|
|
2556
2557
|
// lib/components/primitive-components/Trace.ts
|
|
2557
|
-
import { traceProps } from "@tscircuit/props";
|
|
2558
2558
|
import {
|
|
2559
2559
|
MultilayerIjump,
|
|
2560
2560
|
getObstaclesFromSoup
|
|
2561
2561
|
} from "@tscircuit/infgrid-ijump-astar";
|
|
2562
|
+
import { traceProps } from "@tscircuit/props";
|
|
2563
|
+
import { getFullConnectivityMapFromCircuitJson } from "circuit-json-to-connectivity-map";
|
|
2564
|
+
|
|
2565
|
+
// lib/utils/autorouting/DirectLineRouter.ts
|
|
2566
|
+
var DirectLineRouter = class {
|
|
2567
|
+
input;
|
|
2568
|
+
constructor({ input }) {
|
|
2569
|
+
this.input = input;
|
|
2570
|
+
}
|
|
2571
|
+
solveAndMapToTraces() {
|
|
2572
|
+
const traces = [];
|
|
2573
|
+
for (const connection of this.input.connections) {
|
|
2574
|
+
if (connection.pointsToConnect.length !== 2) continue;
|
|
2575
|
+
const [start, end] = connection.pointsToConnect;
|
|
2576
|
+
const trace = {
|
|
2577
|
+
type: "pcb_trace",
|
|
2578
|
+
pcb_trace_id: "",
|
|
2579
|
+
route: [
|
|
2580
|
+
{
|
|
2581
|
+
route_type: "wire",
|
|
2582
|
+
x: start.x,
|
|
2583
|
+
y: start.y,
|
|
2584
|
+
layer: "top",
|
|
2585
|
+
width: 0.1
|
|
2586
|
+
},
|
|
2587
|
+
{
|
|
2588
|
+
route_type: "wire",
|
|
2589
|
+
x: end.x,
|
|
2590
|
+
y: end.y,
|
|
2591
|
+
layer: "top",
|
|
2592
|
+
width: 0.1
|
|
2593
|
+
}
|
|
2594
|
+
]
|
|
2595
|
+
};
|
|
2596
|
+
traces.push(trace);
|
|
2597
|
+
}
|
|
2598
|
+
return traces;
|
|
2599
|
+
}
|
|
2600
|
+
};
|
|
2562
2601
|
|
|
2563
2602
|
// lib/utils/autorouting/computeObstacleBounds.ts
|
|
2564
2603
|
var computeObstacleBounds = (obstacles) => {
|
|
@@ -2569,22 +2608,6 @@ var computeObstacleBounds = (obstacles) => {
|
|
|
2569
2608
|
return { minX, maxX, minY, maxY };
|
|
2570
2609
|
};
|
|
2571
2610
|
|
|
2572
|
-
// lib/utils/projectPointInDirection.ts
|
|
2573
|
-
var projectPointInDirection = (point, direction, distance) => {
|
|
2574
|
-
switch (direction) {
|
|
2575
|
-
case "up":
|
|
2576
|
-
return { x: point.x, y: point.y - distance };
|
|
2577
|
-
case "down":
|
|
2578
|
-
return { x: point.x, y: point.y + distance };
|
|
2579
|
-
case "left":
|
|
2580
|
-
return { x: point.x - distance, y: point.y };
|
|
2581
|
-
case "right":
|
|
2582
|
-
return { x: point.x + distance, y: point.y };
|
|
2583
|
-
default:
|
|
2584
|
-
throw new Error(`Unknown direction "${direction}"`);
|
|
2585
|
-
}
|
|
2586
|
-
};
|
|
2587
|
-
|
|
2588
2611
|
// lib/utils/autorouting/findPossibleTraceLayerCombinations.ts
|
|
2589
2612
|
var LAYER_SELECTION_PREFERENCE = ["top", "bottom", "inner1", "inner2"];
|
|
2590
2613
|
var findPossibleTraceLayerCombinations = (hints, layer_path = []) => {
|
|
@@ -2718,8 +2741,37 @@ function getClosest(point, candidates) {
|
|
|
2718
2741
|
return closest;
|
|
2719
2742
|
}
|
|
2720
2743
|
|
|
2721
|
-
// lib/
|
|
2722
|
-
|
|
2744
|
+
// lib/utils/projectPointInDirection.ts
|
|
2745
|
+
var projectPointInDirection = (point, direction, distance) => {
|
|
2746
|
+
switch (direction) {
|
|
2747
|
+
case "up":
|
|
2748
|
+
return { x: point.x, y: point.y + distance };
|
|
2749
|
+
case "down":
|
|
2750
|
+
return { x: point.x, y: point.y - distance };
|
|
2751
|
+
case "left":
|
|
2752
|
+
return { x: point.x + distance, y: point.y };
|
|
2753
|
+
case "right":
|
|
2754
|
+
return { x: point.x - distance, y: point.y };
|
|
2755
|
+
default:
|
|
2756
|
+
throw new Error(`Unknown direction "${direction}"`);
|
|
2757
|
+
}
|
|
2758
|
+
};
|
|
2759
|
+
|
|
2760
|
+
// lib/utils/projectPointInOppositeDirection.ts
|
|
2761
|
+
var projectPointInOppositeDirection = (point, direction, distance) => {
|
|
2762
|
+
switch (direction) {
|
|
2763
|
+
case "up":
|
|
2764
|
+
return { x: point.x, y: point.y + distance };
|
|
2765
|
+
case "down":
|
|
2766
|
+
return { x: point.x, y: point.y - distance };
|
|
2767
|
+
case "left":
|
|
2768
|
+
return { x: point.x + distance, y: point.y };
|
|
2769
|
+
case "right":
|
|
2770
|
+
return { x: point.x - distance, y: point.y };
|
|
2771
|
+
default:
|
|
2772
|
+
throw new Error(`Unknown direction "${direction}"`);
|
|
2773
|
+
}
|
|
2774
|
+
};
|
|
2723
2775
|
|
|
2724
2776
|
// lib/utils/try-now.ts
|
|
2725
2777
|
function tryNow(fn) {
|
|
@@ -2731,46 +2783,7 @@ function tryNow(fn) {
|
|
|
2731
2783
|
}
|
|
2732
2784
|
|
|
2733
2785
|
// lib/components/primitive-components/Trace.ts
|
|
2734
|
-
import
|
|
2735
|
-
|
|
2736
|
-
// lib/utils/autorouting/DirectLineRouter.ts
|
|
2737
|
-
var DirectLineRouter = class {
|
|
2738
|
-
input;
|
|
2739
|
-
constructor({ input }) {
|
|
2740
|
-
this.input = input;
|
|
2741
|
-
}
|
|
2742
|
-
solveAndMapToTraces() {
|
|
2743
|
-
const traces = [];
|
|
2744
|
-
for (const connection of this.input.connections) {
|
|
2745
|
-
if (connection.pointsToConnect.length !== 2) continue;
|
|
2746
|
-
const [start, end] = connection.pointsToConnect;
|
|
2747
|
-
const trace = {
|
|
2748
|
-
type: "pcb_trace",
|
|
2749
|
-
pcb_trace_id: "",
|
|
2750
|
-
route: [
|
|
2751
|
-
{
|
|
2752
|
-
route_type: "wire",
|
|
2753
|
-
x: start.x,
|
|
2754
|
-
y: start.y,
|
|
2755
|
-
layer: "top",
|
|
2756
|
-
width: 0.1
|
|
2757
|
-
},
|
|
2758
|
-
{
|
|
2759
|
-
route_type: "wire",
|
|
2760
|
-
x: end.x,
|
|
2761
|
-
y: end.y,
|
|
2762
|
-
layer: "top",
|
|
2763
|
-
width: 0.1
|
|
2764
|
-
}
|
|
2765
|
-
]
|
|
2766
|
-
};
|
|
2767
|
-
traces.push(trace);
|
|
2768
|
-
}
|
|
2769
|
-
return traces;
|
|
2770
|
-
}
|
|
2771
|
-
};
|
|
2772
|
-
|
|
2773
|
-
// lib/components/primitive-components/Trace.ts
|
|
2786
|
+
import "zod";
|
|
2774
2787
|
var portToObjective = (port) => {
|
|
2775
2788
|
const portPosition = port._getGlobalPcbPositionAfterLayout();
|
|
2776
2789
|
return {
|
|
@@ -3204,17 +3217,19 @@ searched component ${targetComponent.getString()}, which has ports: ${targetComp
|
|
|
3204
3217
|
});
|
|
3205
3218
|
}
|
|
3206
3219
|
}
|
|
3207
|
-
|
|
3208
|
-
|
|
3209
|
-
|
|
3210
|
-
|
|
3211
|
-
|
|
3212
|
-
|
|
3213
|
-
|
|
3214
|
-
|
|
3215
|
-
layer: "top"
|
|
3216
|
-
});
|
|
3220
|
+
const portsWithPosition = ports.map(({ port }) => ({
|
|
3221
|
+
port,
|
|
3222
|
+
position: port._getGlobalSchematicPositionAfterLayout(),
|
|
3223
|
+
schematic_port_id: port.schematic_port_id ?? void 0,
|
|
3224
|
+
facingDirection: port.facingDirection
|
|
3225
|
+
}));
|
|
3226
|
+
if (portsWithPosition.length < 2) {
|
|
3227
|
+
return;
|
|
3217
3228
|
}
|
|
3229
|
+
connection.pointsToConnect = portsWithPosition.map(({ position }) => ({
|
|
3230
|
+
...position,
|
|
3231
|
+
layer: "top"
|
|
3232
|
+
}));
|
|
3218
3233
|
const bounds = computeObstacleBounds(obstacles);
|
|
3219
3234
|
const simpleRouteJsonInput = {
|
|
3220
3235
|
minTraceWidth: 0.1,
|
|
@@ -3223,19 +3238,6 @@ searched component ${targetComponent.getString()}, which has ports: ${targetComp
|
|
|
3223
3238
|
bounds,
|
|
3224
3239
|
layerCount: 1
|
|
3225
3240
|
};
|
|
3226
|
-
if (this.getSubcircuit().props._schDebugObjectsEnabled) {
|
|
3227
|
-
for (const obstacle of obstacles) {
|
|
3228
|
-
db.schematic_debug_object.insert({
|
|
3229
|
-
shape: "rect",
|
|
3230
|
-
center: obstacle.center,
|
|
3231
|
-
size: {
|
|
3232
|
-
width: obstacle.width,
|
|
3233
|
-
height: obstacle.height
|
|
3234
|
-
},
|
|
3235
|
-
label: "obstacle"
|
|
3236
|
-
});
|
|
3237
|
-
}
|
|
3238
|
-
}
|
|
3239
3241
|
let Autorouter = MultilayerIjump;
|
|
3240
3242
|
if (this.getSubcircuit().props._schDirectLineRoutingEnabled) {
|
|
3241
3243
|
Autorouter = DirectLineRouter;
|
|
@@ -3250,14 +3252,34 @@ searched component ${targetComponent.getString()}, which has ports: ${targetComp
|
|
|
3250
3252
|
const { route } = result;
|
|
3251
3253
|
const edges = [];
|
|
3252
3254
|
for (let i = 0; i < route.length - 1; i++) {
|
|
3253
|
-
const from = route[i];
|
|
3254
|
-
const to = route[i + 1];
|
|
3255
3255
|
edges.push({
|
|
3256
|
-
from,
|
|
3257
|
-
to
|
|
3258
|
-
// TODO to_schematic_port_id and from_schematic_port_id
|
|
3256
|
+
from: route[i],
|
|
3257
|
+
to: route[i + 1]
|
|
3259
3258
|
});
|
|
3260
3259
|
}
|
|
3260
|
+
const STUB_LENGTH = 0.15;
|
|
3261
|
+
edges.unshift({
|
|
3262
|
+
from: {
|
|
3263
|
+
...projectPointInDirection(
|
|
3264
|
+
route[0],
|
|
3265
|
+
portsWithPosition[0].facingDirection,
|
|
3266
|
+
STUB_LENGTH
|
|
3267
|
+
)
|
|
3268
|
+
},
|
|
3269
|
+
to: route[0],
|
|
3270
|
+
from_schematic_port_id: portsWithPosition[0].schematic_port_id
|
|
3271
|
+
});
|
|
3272
|
+
edges.push({
|
|
3273
|
+
from: route[route.length - 1],
|
|
3274
|
+
to: {
|
|
3275
|
+
...projectPointInOppositeDirection(
|
|
3276
|
+
route[route.length - 1],
|
|
3277
|
+
portsWithPosition[1].facingDirection,
|
|
3278
|
+
STUB_LENGTH
|
|
3279
|
+
)
|
|
3280
|
+
},
|
|
3281
|
+
from_schematic_port_id: portsWithPosition[1].schematic_port_id
|
|
3282
|
+
});
|
|
3261
3283
|
const trace = db.schematic_trace.insert({
|
|
3262
3284
|
source_trace_id: this.source_trace_id,
|
|
3263
3285
|
edges
|