@tscircuit/core 0.0.551 → 0.0.552
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 +66 -100
- package/package.json +5 -5
package/dist/index.js
CHANGED
|
@@ -6661,7 +6661,7 @@ var CapacityMeshAutorouter = class {
|
|
|
6661
6661
|
|
|
6662
6662
|
// lib/components/primitive-components/Group/Group.ts
|
|
6663
6663
|
import "circuit-json";
|
|
6664
|
-
import
|
|
6664
|
+
import Debug6 from "debug";
|
|
6665
6665
|
import "zod";
|
|
6666
6666
|
|
|
6667
6667
|
// lib/components/primitive-components/TraceHint.ts
|
|
@@ -7310,64 +7310,60 @@ import {
|
|
|
7310
7310
|
// lib/components/primitive-components/Group/Group_doInitialSchematicLayoutMatchAdapt.ts
|
|
7311
7311
|
import "@tscircuit/circuit-json-util";
|
|
7312
7312
|
import "circuit-json-to-connectivity-map";
|
|
7313
|
-
import
|
|
7314
|
-
import {
|
|
7313
|
+
import { corpusNoNetLabel } from "@tscircuit/schematic-corpus";
|
|
7314
|
+
import {
|
|
7315
|
+
convertCircuitJsonToBpc
|
|
7316
|
+
} from "circuit-json-to-bpc";
|
|
7315
7317
|
import {
|
|
7316
|
-
layoutSchematicGraph
|
|
7318
|
+
layoutSchematicGraph,
|
|
7319
|
+
getGraphicsForBpcGraph
|
|
7317
7320
|
} from "bpc-graph";
|
|
7321
|
+
import "graphics-debug";
|
|
7322
|
+
import "circuit-to-svg";
|
|
7323
|
+
import Debug5 from "debug";
|
|
7324
|
+
var debug4 = Debug5("Group_doInitialSchematicLayoutMatchAdapt");
|
|
7318
7325
|
function Group_doInitialSchematicLayoutMatchAdapt(group) {
|
|
7319
7326
|
const { db } = group.root;
|
|
7320
7327
|
const subtreeCircuitJson = structuredClone(db.toArray());
|
|
7321
|
-
const
|
|
7322
|
-
|
|
7323
|
-
)
|
|
7324
|
-
|
|
7325
|
-
|
|
7326
|
-
|
|
7327
|
-
|
|
7328
|
-
|
|
7329
|
-
};
|
|
7330
|
-
const generatedNetLabels = /* @__PURE__ */ new Map();
|
|
7331
|
-
for (const sp of subtreeCircuitJson.filter(
|
|
7332
|
-
(e) => e.type === "schematic_port"
|
|
7333
|
-
)) {
|
|
7334
|
-
const key = `${sp.center.x},${sp.center.y}`;
|
|
7335
|
-
if (existingLabels.has(key)) continue;
|
|
7336
|
-
const srcPort = db.source_port.get(sp.source_port_id);
|
|
7337
|
-
const srcNet = db.source_net.getWhere({
|
|
7338
|
-
subcircuit_connectivity_map_key: srcPort?.subcircuit_connectivity_map_key
|
|
7339
|
-
});
|
|
7340
|
-
if (!srcNet) {
|
|
7341
|
-
console.error(`No source net found for port: ${sp.source_port_id}`);
|
|
7342
|
-
continue;
|
|
7343
|
-
}
|
|
7344
|
-
const srcTrace = db.source_trace.getWhere({
|
|
7345
|
-
subcircuit_connectivity_map_key: srcPort?.subcircuit_connectivity_map_key
|
|
7346
|
-
});
|
|
7347
|
-
const schematic_net_label_id = `netlabel_for_${sp.schematic_port_id}`;
|
|
7348
|
-
const source_net = db.source_net.get(srcNet.source_net_id);
|
|
7349
|
-
const schematic_net_label = {
|
|
7350
|
-
type: "schematic_net_label",
|
|
7351
|
-
schematic_net_label_id,
|
|
7352
|
-
text: source_net.name,
|
|
7353
|
-
source_net_id: srcNet.source_net_id,
|
|
7354
|
-
source_trace_id: srcTrace?.source_trace_id,
|
|
7355
|
-
anchor_position: { ...sp.center },
|
|
7356
|
-
center: { ...sp.center },
|
|
7357
|
-
anchor_side: oppositeSideFromFacing[sp.facing_direction] ?? "right"
|
|
7358
|
-
};
|
|
7359
|
-
generatedNetLabels.set(schematic_net_label_id, {
|
|
7360
|
-
schematic_net_label,
|
|
7361
|
-
schematic_port: sp
|
|
7362
|
-
});
|
|
7363
|
-
subtreeCircuitJson.push(schematic_net_label);
|
|
7328
|
+
const bpcGraphBeforeGeneratedNetLabels = convertCircuitJsonToBpc(subtreeCircuitJson);
|
|
7329
|
+
console.log("Writing bpcGraphBeforeGeneratedNetLabels.svg");
|
|
7330
|
+
if (debug4.enabled) {
|
|
7331
|
+
global.debugGraphics?.push(
|
|
7332
|
+
getGraphicsForBpcGraph(bpcGraphBeforeGeneratedNetLabels, {
|
|
7333
|
+
title: "floatingBpcGraph"
|
|
7334
|
+
})
|
|
7335
|
+
);
|
|
7364
7336
|
}
|
|
7365
|
-
const targetBpcGraph = convertCircuitJsonToBpc(
|
|
7337
|
+
const targetBpcGraph = convertCircuitJsonToBpc(
|
|
7338
|
+
subtreeCircuitJson
|
|
7339
|
+
// .concat(implicitNetLabels),
|
|
7340
|
+
);
|
|
7366
7341
|
const laidOutBpcGraph = layoutSchematicGraph(targetBpcGraph, {
|
|
7367
7342
|
singletonKeys: ["vcc/2", "gnd/2"],
|
|
7368
7343
|
centerPinColors: ["netlabel_center", "component_center"],
|
|
7369
|
-
|
|
7344
|
+
floatingBoxIdsWithMutablePinOffsets: new Set(
|
|
7345
|
+
targetBpcGraph.boxes.filter((box) => {
|
|
7346
|
+
const boxPins = targetBpcGraph.pins.filter(
|
|
7347
|
+
(p) => p.boxId === box.boxId
|
|
7348
|
+
);
|
|
7349
|
+
const nonCenterBoxPins = boxPins.filter(
|
|
7350
|
+
(bp) => !bp.color.includes("center")
|
|
7351
|
+
);
|
|
7352
|
+
if (nonCenterBoxPins.length <= 2) {
|
|
7353
|
+
return true;
|
|
7354
|
+
}
|
|
7355
|
+
return false;
|
|
7356
|
+
}).map((b) => b.boxId)
|
|
7357
|
+
),
|
|
7358
|
+
corpus: corpusNoNetLabel
|
|
7370
7359
|
});
|
|
7360
|
+
if (debug4.enabled) {
|
|
7361
|
+
global.debugGraphics?.push(
|
|
7362
|
+
getGraphicsForBpcGraph(laidOutBpcGraph, {
|
|
7363
|
+
title: "laidOutBpcGraph"
|
|
7364
|
+
})
|
|
7365
|
+
);
|
|
7366
|
+
}
|
|
7371
7367
|
const groupOffset = group._getGlobalSchematicPositionBeforeLayout();
|
|
7372
7368
|
for (const box of laidOutBpcGraph.boxes) {
|
|
7373
7369
|
if (!box.center) continue;
|
|
@@ -7417,36 +7413,6 @@ function Group_doInitialSchematicLayoutMatchAdapt(group) {
|
|
|
7417
7413
|
};
|
|
7418
7414
|
continue;
|
|
7419
7415
|
}
|
|
7420
|
-
if (generatedNetLabels.has(box.boxId)) {
|
|
7421
|
-
const { schematic_net_label: generatedNetLabel, schematic_port } = generatedNetLabels.get(box.boxId);
|
|
7422
|
-
const pins = laidOutBpcGraph.pins.filter((p) => p.boxId === box.boxId);
|
|
7423
|
-
const center = pins.find((p) => p.color === "netlabel_center");
|
|
7424
|
-
const anchor = pins.find((p) => p.color !== "netlabel_center");
|
|
7425
|
-
const color = anchor.color;
|
|
7426
|
-
const symbolName = color === "vcc" ? "vcc" : color === "gnd" ? "gnd" : void 0;
|
|
7427
|
-
const anchorSide = color === "vcc" ? "bottom" : color === "gnd" ? "top" : oppositeSideFromFacing[schematic_port.facing_direction] ?? "right";
|
|
7428
|
-
const source_net = db.source_net.get(generatedNetLabel.source_net_id);
|
|
7429
|
-
const schematic_net_label2 = {
|
|
7430
|
-
type: "schematic_net_label",
|
|
7431
|
-
schematic_net_label_id: `netlabel_for_${box.boxId}`,
|
|
7432
|
-
text: source_net.name,
|
|
7433
|
-
// no text; just a placeholder box for Match-Adapt
|
|
7434
|
-
anchor_position: {
|
|
7435
|
-
x: box.center.x + groupOffset.x + center.offset.x,
|
|
7436
|
-
y: box.center.y + groupOffset.y + center.offset.y
|
|
7437
|
-
},
|
|
7438
|
-
center: {
|
|
7439
|
-
x: box.center.x + groupOffset.x + center.offset.x,
|
|
7440
|
-
y: box.center.y + groupOffset.y + center.offset.y
|
|
7441
|
-
},
|
|
7442
|
-
anchor_side: anchorSide,
|
|
7443
|
-
symbol_name: symbolName,
|
|
7444
|
-
source_net_id: generatedNetLabel.source_net_id,
|
|
7445
|
-
source_trace_id: generatedNetLabel.source_trace_id
|
|
7446
|
-
};
|
|
7447
|
-
db.schematic_net_label.insert(schematic_net_label2);
|
|
7448
|
-
continue;
|
|
7449
|
-
}
|
|
7450
7416
|
console.error(
|
|
7451
7417
|
`No schematic element found for box: ${box.boxId}. This is a bug in the matchAdapt binding with @tscircuit/core`
|
|
7452
7418
|
);
|
|
@@ -7947,20 +7913,20 @@ var Group = class extends NormalComponent {
|
|
|
7947
7913
|
return false;
|
|
7948
7914
|
}
|
|
7949
7915
|
_hasTracesToRoute() {
|
|
7950
|
-
const
|
|
7916
|
+
const debug5 = Debug6("tscircuit:core:_hasTracesToRoute");
|
|
7951
7917
|
const traces = this.selectAll("trace");
|
|
7952
|
-
|
|
7918
|
+
debug5(`[${this.getString()}] has ${traces.length} traces to route`);
|
|
7953
7919
|
return traces.length > 0;
|
|
7954
7920
|
}
|
|
7955
7921
|
async _runEffectMakeHttpAutoroutingRequest() {
|
|
7956
7922
|
const { db } = this.root;
|
|
7957
|
-
const
|
|
7923
|
+
const debug5 = Debug6("tscircuit:core:_runEffectMakeHttpAutoroutingRequest");
|
|
7958
7924
|
const props = this._parsedProps;
|
|
7959
7925
|
const autorouterConfig = this._getAutorouterConfig();
|
|
7960
7926
|
const serverUrl = autorouterConfig.serverUrl;
|
|
7961
7927
|
const serverMode = autorouterConfig.serverMode;
|
|
7962
7928
|
const fetchWithDebug = (url, options) => {
|
|
7963
|
-
|
|
7929
|
+
debug5("fetching", url);
|
|
7964
7930
|
if (options.headers) {
|
|
7965
7931
|
options.headers["Tscircuit-Core-Version"] = this.root?.getCoreVersion();
|
|
7966
7932
|
}
|
|
@@ -8076,8 +8042,8 @@ var Group = class extends NormalComponent {
|
|
|
8076
8042
|
async _runLocalAutorouting() {
|
|
8077
8043
|
const { db } = this.root;
|
|
8078
8044
|
const props = this._parsedProps;
|
|
8079
|
-
const
|
|
8080
|
-
|
|
8045
|
+
const debug5 = Debug6("tscircuit:core:_runLocalAutorouting");
|
|
8046
|
+
debug5(`[${this.getString()}] starting local autorouting`);
|
|
8081
8047
|
const autorouterConfig = this._getAutorouterConfig();
|
|
8082
8048
|
const { simpleRouteJson } = getSimpleRouteJsonFromCircuitJson({
|
|
8083
8049
|
db,
|
|
@@ -8102,11 +8068,11 @@ var Group = class extends NormalComponent {
|
|
|
8102
8068
|
const routingPromise = new Promise(
|
|
8103
8069
|
(resolve, reject) => {
|
|
8104
8070
|
autorouter.on("complete", (event) => {
|
|
8105
|
-
|
|
8071
|
+
debug5(`[${this.getString()}] local autorouting complete`);
|
|
8106
8072
|
resolve(event.traces);
|
|
8107
8073
|
});
|
|
8108
8074
|
autorouter.on("error", (event) => {
|
|
8109
|
-
|
|
8075
|
+
debug5(
|
|
8110
8076
|
`[${this.getString()}] local autorouting error: ${event.error.message}`
|
|
8111
8077
|
);
|
|
8112
8078
|
reject(event.error);
|
|
@@ -8163,30 +8129,30 @@ var Group = class extends NormalComponent {
|
|
|
8163
8129
|
}
|
|
8164
8130
|
}
|
|
8165
8131
|
doInitialPcbTraceRender() {
|
|
8166
|
-
const
|
|
8132
|
+
const debug5 = Debug6("tscircuit:core:doInitialPcbTraceRender");
|
|
8167
8133
|
if (!this.isSubcircuit) return;
|
|
8168
8134
|
if (this.root?.pcbDisabled) return;
|
|
8169
8135
|
if (this.getInheritedProperty("routingDisabled")) return;
|
|
8170
8136
|
if (this._shouldUseTraceByTraceRouting()) return;
|
|
8171
8137
|
if (!this._areChildSubcircuitsRouted()) {
|
|
8172
|
-
|
|
8138
|
+
debug5(
|
|
8173
8139
|
`[${this.getString()}] child subcircuits are not routed, skipping async autorouting until subcircuits routed`
|
|
8174
8140
|
);
|
|
8175
8141
|
return;
|
|
8176
8142
|
}
|
|
8177
|
-
|
|
8143
|
+
debug5(
|
|
8178
8144
|
`[${this.getString()}] no child subcircuits to wait for, initiating async routing`
|
|
8179
8145
|
);
|
|
8180
8146
|
if (!this._hasTracesToRoute()) return;
|
|
8181
8147
|
this._startAsyncAutorouting();
|
|
8182
8148
|
}
|
|
8183
8149
|
updatePcbTraceRender() {
|
|
8184
|
-
const
|
|
8185
|
-
|
|
8150
|
+
const debug5 = Debug6("tscircuit:core:updatePcbTraceRender");
|
|
8151
|
+
debug5(`[${this.getString()}] updating...`);
|
|
8186
8152
|
if (!this.isSubcircuit) return;
|
|
8187
8153
|
if (this._shouldRouteAsync() && this._hasTracesToRoute() && !this._hasStartedAsyncAutorouting) {
|
|
8188
8154
|
if (this._areChildSubcircuitsRouted()) {
|
|
8189
|
-
|
|
8155
|
+
debug5(
|
|
8190
8156
|
`[${this.getString()}] child subcircuits are now routed, starting async autorouting`
|
|
8191
8157
|
);
|
|
8192
8158
|
this._startAsyncAutorouting();
|
|
@@ -8197,14 +8163,14 @@ var Group = class extends NormalComponent {
|
|
|
8197
8163
|
if (this._shouldUseTraceByTraceRouting()) return;
|
|
8198
8164
|
const { db } = this.root;
|
|
8199
8165
|
if (this._asyncAutoroutingResult.output_simple_route_json) {
|
|
8200
|
-
|
|
8166
|
+
debug5(
|
|
8201
8167
|
`[${this.getString()}] updating PCB traces from simple route json (${this._asyncAutoroutingResult.output_simple_route_json.traces?.length} traces)`
|
|
8202
8168
|
);
|
|
8203
8169
|
this._updatePcbTraceRenderFromSimpleRouteJson();
|
|
8204
8170
|
return;
|
|
8205
8171
|
}
|
|
8206
8172
|
if (this._asyncAutoroutingResult.output_pcb_traces) {
|
|
8207
|
-
|
|
8173
|
+
debug5(
|
|
8208
8174
|
`[${this.getString()}] updating PCB traces from ${this._asyncAutoroutingResult.output_pcb_traces.length} traces`
|
|
8209
8175
|
);
|
|
8210
8176
|
this._updatePcbTraceRenderFromPcbTraces();
|
|
@@ -10748,7 +10714,7 @@ import { identity as identity5 } from "transformation-matrix";
|
|
|
10748
10714
|
var package_default = {
|
|
10749
10715
|
name: "@tscircuit/core",
|
|
10750
10716
|
type: "module",
|
|
10751
|
-
version: "0.0.
|
|
10717
|
+
version: "0.0.551",
|
|
10752
10718
|
types: "dist/index.d.ts",
|
|
10753
10719
|
main: "dist/index.js",
|
|
10754
10720
|
module: "dist/index.js",
|
|
@@ -10782,7 +10748,7 @@ var package_default = {
|
|
|
10782
10748
|
"@tscircuit/math-utils": "^0.0.18",
|
|
10783
10749
|
"@tscircuit/props": "^0.0.251",
|
|
10784
10750
|
"@tscircuit/schematic-autolayout": "^0.0.6",
|
|
10785
|
-
"@tscircuit/schematic-corpus": "^0.0.
|
|
10751
|
+
"@tscircuit/schematic-corpus": "^0.0.52",
|
|
10786
10752
|
"@tscircuit/schematic-match-adapt": "^0.0.16",
|
|
10787
10753
|
"@tscircuit/simple-3d-svg": "^0.0.6",
|
|
10788
10754
|
"@types/bun": "^1.2.16",
|
|
@@ -10790,18 +10756,18 @@ var package_default = {
|
|
|
10790
10756
|
"@types/react": "^19.0.1",
|
|
10791
10757
|
"@types/react-dom": "^19.0.2",
|
|
10792
10758
|
"@types/react-reconciler": "^0.28.9",
|
|
10793
|
-
"bpc-graph": "^0.0.
|
|
10759
|
+
"bpc-graph": "^0.0.53",
|
|
10794
10760
|
"bun-match-svg": "0.0.12",
|
|
10795
10761
|
"calculate-elbow": "^0.0.5",
|
|
10796
10762
|
"chokidar-cli": "^3.0.0",
|
|
10797
10763
|
"circuit-json": "^0.0.215",
|
|
10798
|
-
"circuit-json-to-bpc": "^0.0.
|
|
10764
|
+
"circuit-json-to-bpc": "^0.0.13",
|
|
10799
10765
|
"circuit-json-to-connectivity-map": "^0.0.22",
|
|
10800
10766
|
"circuit-json-to-simple-3d": "^0.0.2",
|
|
10801
10767
|
"circuit-to-svg": "^0.0.162",
|
|
10802
10768
|
concurrently: "^9.1.2",
|
|
10803
10769
|
debug: "^4.3.6",
|
|
10804
|
-
"graphics-debug": "^0.0.
|
|
10770
|
+
"graphics-debug": "^0.0.60",
|
|
10805
10771
|
howfat: "^0.3.8",
|
|
10806
10772
|
"live-server": "^1.2.2",
|
|
10807
10773
|
"looks-same": "^9.0.1",
|
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.552",
|
|
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.251",
|
|
37
37
|
"@tscircuit/schematic-autolayout": "^0.0.6",
|
|
38
|
-
"@tscircuit/schematic-corpus": "^0.0.
|
|
38
|
+
"@tscircuit/schematic-corpus": "^0.0.52",
|
|
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,18 +43,18 @@
|
|
|
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.53",
|
|
47
47
|
"bun-match-svg": "0.0.12",
|
|
48
48
|
"calculate-elbow": "^0.0.5",
|
|
49
49
|
"chokidar-cli": "^3.0.0",
|
|
50
50
|
"circuit-json": "^0.0.215",
|
|
51
|
-
"circuit-json-to-bpc": "^0.0.
|
|
51
|
+
"circuit-json-to-bpc": "^0.0.13",
|
|
52
52
|
"circuit-json-to-connectivity-map": "^0.0.22",
|
|
53
53
|
"circuit-json-to-simple-3d": "^0.0.2",
|
|
54
54
|
"circuit-to-svg": "^0.0.162",
|
|
55
55
|
"concurrently": "^9.1.2",
|
|
56
56
|
"debug": "^4.3.6",
|
|
57
|
-
"graphics-debug": "^0.0.
|
|
57
|
+
"graphics-debug": "^0.0.60",
|
|
58
58
|
"howfat": "^0.3.8",
|
|
59
59
|
"live-server": "^1.2.2",
|
|
60
60
|
"looks-same": "^9.0.1",
|