@tscircuit/core 0.0.540 → 0.0.542
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 +32 -55
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -7272,12 +7272,10 @@ import {
|
|
|
7272
7272
|
// lib/components/primitive-components/Group/Group_doInitialSchematicLayoutMatchAdapt.ts
|
|
7273
7273
|
import "@tscircuit/circuit-json-util";
|
|
7274
7274
|
import "circuit-json-to-connectivity-map";
|
|
7275
|
-
import corpus from "@tscircuit/schematic-corpus
|
|
7275
|
+
import corpus from "@tscircuit/schematic-corpus";
|
|
7276
7276
|
import { convertCircuitJsonToBpc } from "circuit-json-to-bpc";
|
|
7277
7277
|
import {
|
|
7278
|
-
|
|
7279
|
-
netAdaptBpcGraph,
|
|
7280
|
-
getBpcGraphWlDistance
|
|
7278
|
+
layoutSchematicGraph
|
|
7281
7279
|
} from "bpc-graph";
|
|
7282
7280
|
function Group_doInitialSchematicLayoutMatchAdapt(group) {
|
|
7283
7281
|
const { db } = group.root;
|
|
@@ -7327,42 +7325,20 @@ function Group_doInitialSchematicLayoutMatchAdapt(group) {
|
|
|
7327
7325
|
subtreeCircuitJson.push(schematic_net_label);
|
|
7328
7326
|
}
|
|
7329
7327
|
const targetBpcGraph = convertCircuitJsonToBpc(subtreeCircuitJson);
|
|
7330
|
-
|
|
7331
|
-
|
|
7332
|
-
|
|
7333
|
-
box.center = void 0;
|
|
7334
|
-
}
|
|
7335
|
-
}
|
|
7336
|
-
let bestMatch = {
|
|
7337
|
-
boxes: [],
|
|
7338
|
-
pins: []
|
|
7339
|
-
};
|
|
7340
|
-
let bestWlDistance = Infinity;
|
|
7341
|
-
let winningBpcGraphName = "empty";
|
|
7342
|
-
for (const [candidateBpcGraphName, candidateBpcGraph] of Object.entries(
|
|
7328
|
+
const laidOutBpcGraph = layoutSchematicGraph(targetBpcGraph, {
|
|
7329
|
+
singletonKeys: ["vcc/2", "gnd/2"],
|
|
7330
|
+
centerPinColors: ["netlabel_center", "component_center"],
|
|
7343
7331
|
corpus
|
|
7344
|
-
)
|
|
7345
|
-
|
|
7346
|
-
|
|
7347
|
-
|
|
7348
|
-
);
|
|
7349
|
-
console.log(candidateBpcGraphName, wlDistance);
|
|
7350
|
-
if (wlDistance < bestWlDistance) {
|
|
7351
|
-
bestMatch = candidateBpcGraph;
|
|
7352
|
-
winningBpcGraphName = candidateBpcGraphName;
|
|
7353
|
-
bestWlDistance = wlDistance;
|
|
7354
|
-
if (wlDistance === 0) break;
|
|
7355
|
-
}
|
|
7356
|
-
}
|
|
7357
|
-
console.log(`Winning BPC graph: ${winningBpcGraphName}`);
|
|
7358
|
-
const { adaptedBpcGraph } = netAdaptBpcGraph(
|
|
7359
|
-
bestMatch,
|
|
7360
|
-
targetBpcGraph
|
|
7361
|
-
);
|
|
7362
|
-
const adaptedBpcGraphWithPositions = assignFloatingBoxPositions(adaptedBpcGraph);
|
|
7363
|
-
for (const box of adaptedBpcGraphWithPositions.boxes) {
|
|
7332
|
+
});
|
|
7333
|
+
const groupOffset = group._getGlobalSchematicPositionBeforeLayout();
|
|
7334
|
+
for (const box of laidOutBpcGraph.boxes) {
|
|
7335
|
+
if (!box.center) continue;
|
|
7364
7336
|
const schematic_component2 = db.schematic_component.get(box.boxId);
|
|
7365
7337
|
if (schematic_component2) {
|
|
7338
|
+
const newCenter = {
|
|
7339
|
+
x: box.center.x + groupOffset.x,
|
|
7340
|
+
y: box.center.y + groupOffset.y
|
|
7341
|
+
};
|
|
7366
7342
|
const ports = db.schematic_port.list({
|
|
7367
7343
|
schematic_component_id: schematic_component2.schematic_component_id
|
|
7368
7344
|
});
|
|
@@ -7370,8 +7346,8 @@ function Group_doInitialSchematicLayoutMatchAdapt(group) {
|
|
|
7370
7346
|
schematic_component_id: schematic_component2.schematic_component_id
|
|
7371
7347
|
});
|
|
7372
7348
|
const positionDelta = {
|
|
7373
|
-
x:
|
|
7374
|
-
y:
|
|
7349
|
+
x: newCenter.x - schematic_component2.center.x,
|
|
7350
|
+
y: newCenter.y - schematic_component2.center.y
|
|
7375
7351
|
};
|
|
7376
7352
|
for (const port of ports) {
|
|
7377
7353
|
port.center.x += positionDelta.x;
|
|
@@ -7381,30 +7357,31 @@ function Group_doInitialSchematicLayoutMatchAdapt(group) {
|
|
|
7381
7357
|
text.position.x += positionDelta.x;
|
|
7382
7358
|
text.position.y += positionDelta.y;
|
|
7383
7359
|
}
|
|
7384
|
-
schematic_component2.center
|
|
7385
|
-
schematic_component2.center.y += positionDelta.y;
|
|
7360
|
+
schematic_component2.center = newCenter;
|
|
7386
7361
|
continue;
|
|
7387
7362
|
}
|
|
7388
7363
|
const schematic_net_label = db.schematic_net_label.get(box.boxId);
|
|
7389
7364
|
if (schematic_net_label) {
|
|
7390
|
-
const pin =
|
|
7365
|
+
const pin = laidOutBpcGraph.pins.find(
|
|
7391
7366
|
(p) => p.boxId === box.boxId && p.color === "netlabel_center"
|
|
7392
7367
|
);
|
|
7393
7368
|
if (!pin) {
|
|
7394
7369
|
throw new Error(`No pin found for net label: ${box.boxId}`);
|
|
7395
7370
|
}
|
|
7396
|
-
|
|
7371
|
+
const finalCenter = {
|
|
7372
|
+
x: box.center.x + groupOffset.x,
|
|
7373
|
+
y: box.center.y + groupOffset.y
|
|
7374
|
+
};
|
|
7375
|
+
schematic_net_label.center = finalCenter;
|
|
7397
7376
|
schematic_net_label.anchor_position = {
|
|
7398
|
-
x:
|
|
7399
|
-
y:
|
|
7377
|
+
x: finalCenter.x + pin.offset.x,
|
|
7378
|
+
y: finalCenter.y + pin.offset.y
|
|
7400
7379
|
};
|
|
7401
7380
|
continue;
|
|
7402
7381
|
}
|
|
7403
7382
|
if (generatedNetLabels.has(box.boxId)) {
|
|
7404
7383
|
const { schematic_net_label: generatedNetLabel, schematic_port } = generatedNetLabels.get(box.boxId);
|
|
7405
|
-
const pins =
|
|
7406
|
-
(p) => p.boxId === box.boxId
|
|
7407
|
-
);
|
|
7384
|
+
const pins = laidOutBpcGraph.pins.filter((p) => p.boxId === box.boxId);
|
|
7408
7385
|
const center = pins.find((p) => p.color === "netlabel_center");
|
|
7409
7386
|
const anchor = pins.find((p) => p.color !== "netlabel_center");
|
|
7410
7387
|
const color = anchor.color;
|
|
@@ -7417,12 +7394,12 @@ function Group_doInitialSchematicLayoutMatchAdapt(group) {
|
|
|
7417
7394
|
text: source_net.name,
|
|
7418
7395
|
// no text; just a placeholder box for Match-Adapt
|
|
7419
7396
|
anchor_position: {
|
|
7420
|
-
x: box.center.x + center.offset.x,
|
|
7421
|
-
y: box.center.y + center.offset.y
|
|
7397
|
+
x: box.center.x + groupOffset.x + center.offset.x,
|
|
7398
|
+
y: box.center.y + groupOffset.y + center.offset.y
|
|
7422
7399
|
},
|
|
7423
7400
|
center: {
|
|
7424
|
-
x: box.center.x + center.offset.x,
|
|
7425
|
-
y: box.center.y + center.offset.y
|
|
7401
|
+
x: box.center.x + groupOffset.x + center.offset.x,
|
|
7402
|
+
y: box.center.y + groupOffset.y + center.offset.y
|
|
7426
7403
|
},
|
|
7427
7404
|
anchor_side: anchorSide,
|
|
7428
7405
|
symbol_name: symbolName,
|
|
@@ -10701,7 +10678,7 @@ import { identity as identity4 } from "transformation-matrix";
|
|
|
10701
10678
|
var package_default = {
|
|
10702
10679
|
name: "@tscircuit/core",
|
|
10703
10680
|
type: "module",
|
|
10704
|
-
version: "0.0.
|
|
10681
|
+
version: "0.0.541",
|
|
10705
10682
|
types: "dist/index.d.ts",
|
|
10706
10683
|
main: "dist/index.js",
|
|
10707
10684
|
module: "dist/index.js",
|
|
@@ -10735,7 +10712,7 @@ var package_default = {
|
|
|
10735
10712
|
"@tscircuit/math-utils": "^0.0.18",
|
|
10736
10713
|
"@tscircuit/props": "^0.0.248",
|
|
10737
10714
|
"@tscircuit/schematic-autolayout": "^0.0.6",
|
|
10738
|
-
"@tscircuit/schematic-corpus": "^0.0.
|
|
10715
|
+
"@tscircuit/schematic-corpus": "^0.0.33",
|
|
10739
10716
|
"@tscircuit/schematic-match-adapt": "^0.0.16",
|
|
10740
10717
|
"@tscircuit/simple-3d-svg": "^0.0.6",
|
|
10741
10718
|
"@types/bun": "^1.2.16",
|
|
@@ -10743,7 +10720,7 @@ var package_default = {
|
|
|
10743
10720
|
"@types/react": "^19.0.1",
|
|
10744
10721
|
"@types/react-dom": "^19.0.2",
|
|
10745
10722
|
"@types/react-reconciler": "^0.28.9",
|
|
10746
|
-
"bpc-graph": "^0.0.
|
|
10723
|
+
"bpc-graph": "^0.0.46",
|
|
10747
10724
|
"bun-match-svg": "0.0.11",
|
|
10748
10725
|
"calculate-elbow": "^0.0.5",
|
|
10749
10726
|
"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.542",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"main": "dist/index.js",
|
|
7
7
|
"module": "dist/index.js",
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
"@tscircuit/math-utils": "^0.0.18",
|
|
36
36
|
"@tscircuit/props": "^0.0.248",
|
|
37
37
|
"@tscircuit/schematic-autolayout": "^0.0.6",
|
|
38
|
-
"@tscircuit/schematic-corpus": "^0.0.
|
|
38
|
+
"@tscircuit/schematic-corpus": "^0.0.33",
|
|
39
39
|
"@tscircuit/schematic-match-adapt": "^0.0.16",
|
|
40
40
|
"@tscircuit/simple-3d-svg": "^0.0.6",
|
|
41
41
|
"@types/bun": "^1.2.16",
|
|
@@ -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.46",
|
|
47
47
|
"bun-match-svg": "0.0.11",
|
|
48
48
|
"calculate-elbow": "^0.0.5",
|
|
49
49
|
"chokidar-cli": "^3.0.0",
|