@tscircuit/core 0.0.553 → 0.0.555
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 +165 -72
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -4373,6 +4373,8 @@ var computeSchematicNetLabelCenter = ({
|
|
|
4373
4373
|
// lib/components/primitive-components/Trace/Trace_doInitialSchematicTraceRender.ts
|
|
4374
4374
|
import { MultilayerIjump } from "@tscircuit/infgrid-ijump-astar";
|
|
4375
4375
|
import "circuit-json";
|
|
4376
|
+
import { calculateElbow } from "calculate-elbow";
|
|
4377
|
+
import { doesLineIntersectLine as doesLineIntersectLine3 } from "@tscircuit/math-utils";
|
|
4376
4378
|
|
|
4377
4379
|
// lib/components/primitive-components/Trace/trace-utils/create-schematic-trace-crossing-segments.ts
|
|
4378
4380
|
import { distance as distance2, doesLineIntersectLine } from "@tscircuit/math-utils";
|
|
@@ -4856,6 +4858,71 @@ var Trace_doInitialSchematicTraceRender = (trace) => {
|
|
|
4856
4858
|
if (portsWithPosition.length < 2) {
|
|
4857
4859
|
return;
|
|
4858
4860
|
}
|
|
4861
|
+
const attemptElbowEdges = () => {
|
|
4862
|
+
const elbowEdges = [];
|
|
4863
|
+
for (let i = 0; i < portsWithPosition.length - 1; i++) {
|
|
4864
|
+
const start = portsWithPosition[i];
|
|
4865
|
+
const end = portsWithPosition[i + 1];
|
|
4866
|
+
const path = calculateElbow(
|
|
4867
|
+
{
|
|
4868
|
+
x: start.position.x,
|
|
4869
|
+
y: start.position.y,
|
|
4870
|
+
facingDirection: start.facingDirection
|
|
4871
|
+
},
|
|
4872
|
+
{
|
|
4873
|
+
x: end.position.x,
|
|
4874
|
+
y: end.position.y,
|
|
4875
|
+
facingDirection: end.facingDirection
|
|
4876
|
+
}
|
|
4877
|
+
);
|
|
4878
|
+
for (let j = 0; j < path.length - 1; j++) {
|
|
4879
|
+
elbowEdges.push({ from: path[j], to: path[j + 1] });
|
|
4880
|
+
}
|
|
4881
|
+
}
|
|
4882
|
+
const doesSegmentIntersectRect = (edge, rect) => {
|
|
4883
|
+
const halfW = rect.width / 2;
|
|
4884
|
+
const halfH = rect.height / 2;
|
|
4885
|
+
const left = rect.center.x - halfW;
|
|
4886
|
+
const right = rect.center.x + halfW;
|
|
4887
|
+
const top = rect.center.y - halfH;
|
|
4888
|
+
const bottom = rect.center.y + halfH;
|
|
4889
|
+
const inRect = (p) => p.x >= left && p.x <= right && p.y >= top && p.y <= bottom;
|
|
4890
|
+
if (inRect(edge.from) || inRect(edge.to)) return true;
|
|
4891
|
+
const rectEdges = [
|
|
4892
|
+
[
|
|
4893
|
+
{ x: left, y: top },
|
|
4894
|
+
{ x: right, y: top }
|
|
4895
|
+
],
|
|
4896
|
+
[
|
|
4897
|
+
{ x: right, y: top },
|
|
4898
|
+
{ x: right, y: bottom }
|
|
4899
|
+
],
|
|
4900
|
+
[
|
|
4901
|
+
{ x: right, y: bottom },
|
|
4902
|
+
{ x: left, y: bottom }
|
|
4903
|
+
],
|
|
4904
|
+
[
|
|
4905
|
+
{ x: left, y: bottom },
|
|
4906
|
+
{ x: left, y: top }
|
|
4907
|
+
]
|
|
4908
|
+
];
|
|
4909
|
+
return rectEdges.some(
|
|
4910
|
+
(r) => doesLineIntersectLine3([edge.from, edge.to], r, { lineThickness: 0 })
|
|
4911
|
+
);
|
|
4912
|
+
};
|
|
4913
|
+
for (const edge of elbowEdges) {
|
|
4914
|
+
for (const obstacle of obstacles) {
|
|
4915
|
+
if (doesSegmentIntersectRect(edge, obstacle)) {
|
|
4916
|
+
return null;
|
|
4917
|
+
}
|
|
4918
|
+
}
|
|
4919
|
+
}
|
|
4920
|
+
return elbowEdges;
|
|
4921
|
+
};
|
|
4922
|
+
let edges = attemptElbowEdges();
|
|
4923
|
+
if (edges && edges.length === 0) {
|
|
4924
|
+
edges = null;
|
|
4925
|
+
}
|
|
4859
4926
|
connection.pointsToConnect = portsWithPosition.map(({ position }) => ({
|
|
4860
4927
|
...position,
|
|
4861
4928
|
layer: "top"
|
|
@@ -4880,54 +4947,56 @@ var Trace_doInitialSchematicTraceRender = (trace) => {
|
|
|
4880
4947
|
Autorouter = DirectLineRouter;
|
|
4881
4948
|
skipOtherTraceInteraction = true;
|
|
4882
4949
|
}
|
|
4883
|
-
|
|
4884
|
-
|
|
4885
|
-
|
|
4886
|
-
|
|
4887
|
-
|
|
4888
|
-
|
|
4889
|
-
|
|
4890
|
-
|
|
4891
|
-
|
|
4892
|
-
|
|
4893
|
-
|
|
4894
|
-
|
|
4895
|
-
|
|
4896
|
-
|
|
4897
|
-
|
|
4898
|
-
|
|
4899
|
-
|
|
4900
|
-
|
|
4901
|
-
|
|
4902
|
-
|
|
4903
|
-
|
|
4904
|
-
|
|
4905
|
-
|
|
4906
|
-
|
|
4907
|
-
|
|
4908
|
-
|
|
4950
|
+
if (!edges) {
|
|
4951
|
+
const autorouter = new Autorouter({
|
|
4952
|
+
input: simpleRouteJsonInput,
|
|
4953
|
+
MAX_ITERATIONS: 100,
|
|
4954
|
+
OBSTACLE_MARGIN: 0.1,
|
|
4955
|
+
isRemovePathLoopsEnabled: true,
|
|
4956
|
+
isShortenPathWithShortcutsEnabled: true,
|
|
4957
|
+
marginsWithCosts: [
|
|
4958
|
+
{
|
|
4959
|
+
margin: 1,
|
|
4960
|
+
enterCost: 0,
|
|
4961
|
+
travelCostFactor: 1
|
|
4962
|
+
},
|
|
4963
|
+
{
|
|
4964
|
+
margin: 0.3,
|
|
4965
|
+
enterCost: 0,
|
|
4966
|
+
travelCostFactor: 1
|
|
4967
|
+
},
|
|
4968
|
+
{
|
|
4969
|
+
margin: 0.2,
|
|
4970
|
+
enterCost: 0,
|
|
4971
|
+
travelCostFactor: 2
|
|
4972
|
+
},
|
|
4973
|
+
{
|
|
4974
|
+
margin: 0.1,
|
|
4975
|
+
enterCost: 0,
|
|
4976
|
+
travelCostFactor: 3
|
|
4977
|
+
}
|
|
4978
|
+
]
|
|
4979
|
+
});
|
|
4980
|
+
let results = autorouter.solveAndMapToTraces();
|
|
4981
|
+
if (results.length === 0) {
|
|
4982
|
+
if (trace._isSymbolToChipConnection() || trace._isSymbolToSymbolConnection() || trace._isChipToChipConnection()) {
|
|
4983
|
+
trace._doInitialSchematicTraceRenderWithDisplayLabel();
|
|
4984
|
+
return;
|
|
4909
4985
|
}
|
|
4910
|
-
|
|
4911
|
-
|
|
4912
|
-
|
|
4913
|
-
|
|
4914
|
-
|
|
4915
|
-
|
|
4916
|
-
|
|
4986
|
+
const directLineRouter = new DirectLineRouter({
|
|
4987
|
+
input: simpleRouteJsonInput
|
|
4988
|
+
});
|
|
4989
|
+
results = directLineRouter.solveAndMapToTraces();
|
|
4990
|
+
skipOtherTraceInteraction = true;
|
|
4991
|
+
}
|
|
4992
|
+
const [{ route }] = results;
|
|
4993
|
+
edges = [];
|
|
4994
|
+
for (let i = 0; i < route.length - 1; i++) {
|
|
4995
|
+
edges.push({
|
|
4996
|
+
from: route[i],
|
|
4997
|
+
to: route[i + 1]
|
|
4998
|
+
});
|
|
4917
4999
|
}
|
|
4918
|
-
const directLineRouter = new DirectLineRouter({
|
|
4919
|
-
input: simpleRouteJsonInput
|
|
4920
|
-
});
|
|
4921
|
-
results = directLineRouter.solveAndMapToTraces();
|
|
4922
|
-
skipOtherTraceInteraction = true;
|
|
4923
|
-
}
|
|
4924
|
-
const [{ route }] = results;
|
|
4925
|
-
let edges = [];
|
|
4926
|
-
for (let i = 0; i < route.length - 1; i++) {
|
|
4927
|
-
edges.push({
|
|
4928
|
-
from: route[i],
|
|
4929
|
-
to: route[i + 1]
|
|
4930
|
-
});
|
|
4931
5000
|
}
|
|
4932
5001
|
const source_trace_id = trace.source_trace_id;
|
|
4933
5002
|
let junctions = [];
|
|
@@ -4945,6 +5014,9 @@ var Trace_doInitialSchematicTraceRender = (trace) => {
|
|
|
4945
5014
|
source_trace_id: trace.source_trace_id
|
|
4946
5015
|
});
|
|
4947
5016
|
}
|
|
5017
|
+
if (!edges || edges.length === 0) {
|
|
5018
|
+
return;
|
|
5019
|
+
}
|
|
4948
5020
|
const lastEdge = edges[edges.length - 1];
|
|
4949
5021
|
const lastEdgePort = portsWithPosition[portsWithPosition.length - 1];
|
|
4950
5022
|
const lastDominantDirection = getDominantDirection(lastEdge);
|
|
@@ -7300,14 +7372,19 @@ var normalizePinLabels = (inputPinLabels) => {
|
|
|
7300
7372
|
// lib/components/primitive-components/Group/Group_doInitialSchematicLayoutMatchAdapt.ts
|
|
7301
7373
|
import { corpusNoNetLabel } from "@tscircuit/schematic-corpus";
|
|
7302
7374
|
import { convertCircuitJsonToBpc } from "circuit-json-to-bpc";
|
|
7303
|
-
import {
|
|
7375
|
+
import {
|
|
7376
|
+
getGraphicsForBpcGraph,
|
|
7377
|
+
layoutSchematicGraphVariants
|
|
7378
|
+
} from "bpc-graph";
|
|
7304
7379
|
import Debug5 from "debug";
|
|
7380
|
+
import { buildSubtree } from "@tscircuit/circuit-json-util";
|
|
7305
7381
|
var debug4 = Debug5("Group_doInitialSchematicLayoutMatchAdapt");
|
|
7306
7382
|
function Group_doInitialSchematicLayoutMatchAdapt(group) {
|
|
7307
7383
|
const { db } = group.root;
|
|
7308
|
-
const subtreeCircuitJson =
|
|
7384
|
+
const subtreeCircuitJson = buildSubtree(db.toArray(), {
|
|
7385
|
+
source_group_id: group.source_group_id
|
|
7386
|
+
});
|
|
7309
7387
|
const bpcGraphBeforeGeneratedNetLabels = convertCircuitJsonToBpc(subtreeCircuitJson);
|
|
7310
|
-
console.log("Writing bpcGraphBeforeGeneratedNetLabels.svg");
|
|
7311
7388
|
if (debug4.enabled) {
|
|
7312
7389
|
global.debugGraphics?.push(
|
|
7313
7390
|
getGraphicsForBpcGraph(bpcGraphBeforeGeneratedNetLabels, {
|
|
@@ -7315,29 +7392,45 @@ function Group_doInitialSchematicLayoutMatchAdapt(group) {
|
|
|
7315
7392
|
})
|
|
7316
7393
|
);
|
|
7317
7394
|
}
|
|
7318
|
-
const
|
|
7395
|
+
const floatingGraph = convertCircuitJsonToBpc(
|
|
7319
7396
|
subtreeCircuitJson
|
|
7320
7397
|
// .concat(implicitNetLabels),
|
|
7321
7398
|
);
|
|
7322
|
-
const
|
|
7323
|
-
|
|
7324
|
-
|
|
7325
|
-
|
|
7326
|
-
|
|
7327
|
-
|
|
7328
|
-
|
|
7329
|
-
|
|
7330
|
-
|
|
7331
|
-
|
|
7332
|
-
|
|
7333
|
-
|
|
7334
|
-
|
|
7335
|
-
|
|
7336
|
-
|
|
7337
|
-
|
|
7338
|
-
|
|
7339
|
-
|
|
7340
|
-
|
|
7399
|
+
const floatingGraphNoNotConnected = {
|
|
7400
|
+
boxes: floatingGraph.boxes,
|
|
7401
|
+
pins: floatingGraph.pins.map((p) => ({
|
|
7402
|
+
...p,
|
|
7403
|
+
color: p.color.replace("not_connected", "normal")
|
|
7404
|
+
}))
|
|
7405
|
+
};
|
|
7406
|
+
const { result: laidOutBpcGraph } = layoutSchematicGraphVariants(
|
|
7407
|
+
[
|
|
7408
|
+
{ variantName: "default", floatingGraph },
|
|
7409
|
+
{
|
|
7410
|
+
variantName: "noNotConnected",
|
|
7411
|
+
floatingGraph: floatingGraphNoNotConnected
|
|
7412
|
+
}
|
|
7413
|
+
],
|
|
7414
|
+
{
|
|
7415
|
+
singletonKeys: ["vcc/2", "gnd/2"],
|
|
7416
|
+
centerPinColors: ["netlabel_center", "component_center"],
|
|
7417
|
+
floatingBoxIdsWithMutablePinOffsets: new Set(
|
|
7418
|
+
floatingGraph.boxes.filter((box) => {
|
|
7419
|
+
const boxPins = floatingGraph.pins.filter(
|
|
7420
|
+
(p) => p.boxId === box.boxId
|
|
7421
|
+
);
|
|
7422
|
+
const nonCenterBoxPins = boxPins.filter(
|
|
7423
|
+
(bp) => !bp.color.includes("center")
|
|
7424
|
+
);
|
|
7425
|
+
if (nonCenterBoxPins.length <= 2) {
|
|
7426
|
+
return true;
|
|
7427
|
+
}
|
|
7428
|
+
return false;
|
|
7429
|
+
}).map((b) => b.boxId)
|
|
7430
|
+
),
|
|
7431
|
+
corpus: corpusNoNetLabel
|
|
7432
|
+
}
|
|
7433
|
+
);
|
|
7341
7434
|
if (debug4.enabled) {
|
|
7342
7435
|
global.debugGraphics?.push(
|
|
7343
7436
|
getGraphicsForBpcGraph(laidOutBpcGraph, {
|
|
@@ -10695,7 +10788,7 @@ import { identity as identity5 } from "transformation-matrix";
|
|
|
10695
10788
|
var package_default = {
|
|
10696
10789
|
name: "@tscircuit/core",
|
|
10697
10790
|
type: "module",
|
|
10698
|
-
version: "0.0.
|
|
10791
|
+
version: "0.0.554",
|
|
10699
10792
|
types: "dist/index.d.ts",
|
|
10700
10793
|
main: "dist/index.js",
|
|
10701
10794
|
module: "dist/index.js",
|
|
@@ -10720,7 +10813,7 @@ var package_default = {
|
|
|
10720
10813
|
"@biomejs/biome": "^1.8.3",
|
|
10721
10814
|
"@tscircuit/capacity-autorouter": "^0.0.93",
|
|
10722
10815
|
"@tscircuit/checks": "^0.0.52",
|
|
10723
|
-
"@tscircuit/circuit-json-util": "^0.0.
|
|
10816
|
+
"@tscircuit/circuit-json-util": "^0.0.51",
|
|
10724
10817
|
"@tscircuit/footprinter": "^0.0.189",
|
|
10725
10818
|
"@tscircuit/import-snippet": "^0.0.4",
|
|
10726
10819
|
"@tscircuit/infgrid-ijump-astar": "^0.0.33",
|
|
@@ -10737,7 +10830,7 @@ var package_default = {
|
|
|
10737
10830
|
"@types/react": "^19.0.1",
|
|
10738
10831
|
"@types/react-dom": "^19.0.2",
|
|
10739
10832
|
"@types/react-reconciler": "^0.28.9",
|
|
10740
|
-
"bpc-graph": "^0.0.
|
|
10833
|
+
"bpc-graph": "^0.0.57",
|
|
10741
10834
|
"bun-match-svg": "0.0.12",
|
|
10742
10835
|
"calculate-elbow": "^0.0.5",
|
|
10743
10836
|
"chokidar-cli": "^3.0.0",
|
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.555",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"main": "dist/index.js",
|
|
7
7
|
"module": "dist/index.js",
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"@biomejs/biome": "^1.8.3",
|
|
27
27
|
"@tscircuit/capacity-autorouter": "^0.0.93",
|
|
28
28
|
"@tscircuit/checks": "^0.0.52",
|
|
29
|
-
"@tscircuit/circuit-json-util": "^0.0.
|
|
29
|
+
"@tscircuit/circuit-json-util": "^0.0.51",
|
|
30
30
|
"@tscircuit/footprinter": "^0.0.189",
|
|
31
31
|
"@tscircuit/import-snippet": "^0.0.4",
|
|
32
32
|
"@tscircuit/infgrid-ijump-astar": "^0.0.33",
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
"@types/react": "^19.0.1",
|
|
44
44
|
"@types/react-dom": "^19.0.2",
|
|
45
45
|
"@types/react-reconciler": "^0.28.9",
|
|
46
|
-
"bpc-graph": "^0.0.
|
|
46
|
+
"bpc-graph": "^0.0.57",
|
|
47
47
|
"bun-match-svg": "0.0.12",
|
|
48
48
|
"calculate-elbow": "^0.0.5",
|
|
49
49
|
"chokidar-cli": "^3.0.0",
|