@tscircuit/core 0.0.551 → 0.0.553

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.
Files changed (2) hide show
  1. package/dist/index.js +62 -115
  2. 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 Debug5 from "debug";
6664
+ import Debug6 from "debug";
6665
6665
  import "zod";
6666
6666
 
6667
6667
  // lib/components/primitive-components/TraceHint.ts
@@ -7298,76 +7298,53 @@ var normalizePinLabels = (inputPinLabels) => {
7298
7298
  };
7299
7299
 
7300
7300
  // lib/components/primitive-components/Group/Group_doInitialSchematicLayoutMatchAdapt.ts
7301
- import "@tscircuit/schematic-match-adapt";
7302
- import "@tscircuit/schematic-match-adapt";
7303
-
7304
- // lib/utils/schematic/deriveSourceTraceIdFromMatchAdaptPath.ts
7305
- import {
7306
- getRefKey,
7307
- parseRefKey
7308
- } from "@tscircuit/schematic-match-adapt";
7309
-
7310
- // lib/components/primitive-components/Group/Group_doInitialSchematicLayoutMatchAdapt.ts
7311
- import "@tscircuit/circuit-json-util";
7312
- import "circuit-json-to-connectivity-map";
7313
- import corpus from "@tscircuit/schematic-corpus";
7301
+ import { corpusNoNetLabel } from "@tscircuit/schematic-corpus";
7314
7302
  import { convertCircuitJsonToBpc } from "circuit-json-to-bpc";
7315
- import {
7316
- layoutSchematicGraph
7317
- } from "bpc-graph";
7303
+ import { layoutSchematicGraph, getGraphicsForBpcGraph } from "bpc-graph";
7304
+ import Debug5 from "debug";
7305
+ var debug4 = Debug5("Group_doInitialSchematicLayoutMatchAdapt");
7318
7306
  function Group_doInitialSchematicLayoutMatchAdapt(group) {
7319
7307
  const { db } = group.root;
7320
7308
  const subtreeCircuitJson = structuredClone(db.toArray());
7321
- const existingLabels = new Set(
7322
- subtreeCircuitJson.filter((e) => e.type === "schematic_net_label").map((e) => `${e.anchor_position?.x},${e.anchor_position?.y}`)
7323
- );
7324
- const oppositeSideFromFacing = {
7325
- left: "right",
7326
- right: "left",
7327
- top: "bottom",
7328
- bottom: "top"
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);
7309
+ const bpcGraphBeforeGeneratedNetLabels = convertCircuitJsonToBpc(subtreeCircuitJson);
7310
+ console.log("Writing bpcGraphBeforeGeneratedNetLabels.svg");
7311
+ if (debug4.enabled) {
7312
+ global.debugGraphics?.push(
7313
+ getGraphicsForBpcGraph(bpcGraphBeforeGeneratedNetLabels, {
7314
+ title: "floatingBpcGraph"
7315
+ })
7316
+ );
7364
7317
  }
7365
- const targetBpcGraph = convertCircuitJsonToBpc(subtreeCircuitJson);
7318
+ const targetBpcGraph = convertCircuitJsonToBpc(
7319
+ subtreeCircuitJson
7320
+ // .concat(implicitNetLabels),
7321
+ );
7366
7322
  const laidOutBpcGraph = layoutSchematicGraph(targetBpcGraph, {
7367
7323
  singletonKeys: ["vcc/2", "gnd/2"],
7368
7324
  centerPinColors: ["netlabel_center", "component_center"],
7369
- corpus
7325
+ floatingBoxIdsWithMutablePinOffsets: new Set(
7326
+ targetBpcGraph.boxes.filter((box) => {
7327
+ const boxPins = targetBpcGraph.pins.filter(
7328
+ (p) => p.boxId === box.boxId
7329
+ );
7330
+ const nonCenterBoxPins = boxPins.filter(
7331
+ (bp) => !bp.color.includes("center")
7332
+ );
7333
+ if (nonCenterBoxPins.length <= 2) {
7334
+ return true;
7335
+ }
7336
+ return false;
7337
+ }).map((b) => b.boxId)
7338
+ ),
7339
+ corpus: corpusNoNetLabel
7370
7340
  });
7341
+ if (debug4.enabled) {
7342
+ global.debugGraphics?.push(
7343
+ getGraphicsForBpcGraph(laidOutBpcGraph, {
7344
+ title: "laidOutBpcGraph"
7345
+ })
7346
+ );
7347
+ }
7371
7348
  const groupOffset = group._getGlobalSchematicPositionBeforeLayout();
7372
7349
  for (const box of laidOutBpcGraph.boxes) {
7373
7350
  if (!box.center) continue;
@@ -7417,36 +7394,6 @@ function Group_doInitialSchematicLayoutMatchAdapt(group) {
7417
7394
  };
7418
7395
  continue;
7419
7396
  }
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
7397
  console.error(
7451
7398
  `No schematic element found for box: ${box.boxId}. This is a bug in the matchAdapt binding with @tscircuit/core`
7452
7399
  );
@@ -7454,12 +7401,12 @@ function Group_doInitialSchematicLayoutMatchAdapt(group) {
7454
7401
  }
7455
7402
 
7456
7403
  // lib/components/primitive-components/Group/Group_doInitialSourceAddConnectivityMapKey.ts
7457
- import { ConnectivityMap as ConnectivityMap3 } from "circuit-json-to-connectivity-map";
7404
+ import { ConnectivityMap as ConnectivityMap2 } from "circuit-json-to-connectivity-map";
7458
7405
  function Group_doInitialSourceAddConnectivityMapKey(group) {
7459
7406
  if (!group.isSubcircuit) return;
7460
7407
  const { db } = group.root;
7461
7408
  const traces = group.selectAll("trace");
7462
- const connMap = new ConnectivityMap3({});
7409
+ const connMap = new ConnectivityMap2({});
7463
7410
  connMap.addConnections(
7464
7411
  traces.map((t) => {
7465
7412
  const source_trace = db.source_trace.get(
@@ -7947,20 +7894,20 @@ var Group = class extends NormalComponent {
7947
7894
  return false;
7948
7895
  }
7949
7896
  _hasTracesToRoute() {
7950
- const debug4 = Debug5("tscircuit:core:_hasTracesToRoute");
7897
+ const debug5 = Debug6("tscircuit:core:_hasTracesToRoute");
7951
7898
  const traces = this.selectAll("trace");
7952
- debug4(`[${this.getString()}] has ${traces.length} traces to route`);
7899
+ debug5(`[${this.getString()}] has ${traces.length} traces to route`);
7953
7900
  return traces.length > 0;
7954
7901
  }
7955
7902
  async _runEffectMakeHttpAutoroutingRequest() {
7956
7903
  const { db } = this.root;
7957
- const debug4 = Debug5("tscircuit:core:_runEffectMakeHttpAutoroutingRequest");
7904
+ const debug5 = Debug6("tscircuit:core:_runEffectMakeHttpAutoroutingRequest");
7958
7905
  const props = this._parsedProps;
7959
7906
  const autorouterConfig = this._getAutorouterConfig();
7960
7907
  const serverUrl = autorouterConfig.serverUrl;
7961
7908
  const serverMode = autorouterConfig.serverMode;
7962
7909
  const fetchWithDebug = (url, options) => {
7963
- debug4("fetching", url);
7910
+ debug5("fetching", url);
7964
7911
  if (options.headers) {
7965
7912
  options.headers["Tscircuit-Core-Version"] = this.root?.getCoreVersion();
7966
7913
  }
@@ -8076,8 +8023,8 @@ var Group = class extends NormalComponent {
8076
8023
  async _runLocalAutorouting() {
8077
8024
  const { db } = this.root;
8078
8025
  const props = this._parsedProps;
8079
- const debug4 = Debug5("tscircuit:core:_runLocalAutorouting");
8080
- debug4(`[${this.getString()}] starting local autorouting`);
8026
+ const debug5 = Debug6("tscircuit:core:_runLocalAutorouting");
8027
+ debug5(`[${this.getString()}] starting local autorouting`);
8081
8028
  const autorouterConfig = this._getAutorouterConfig();
8082
8029
  const { simpleRouteJson } = getSimpleRouteJsonFromCircuitJson({
8083
8030
  db,
@@ -8102,11 +8049,11 @@ var Group = class extends NormalComponent {
8102
8049
  const routingPromise = new Promise(
8103
8050
  (resolve, reject) => {
8104
8051
  autorouter.on("complete", (event) => {
8105
- debug4(`[${this.getString()}] local autorouting complete`);
8052
+ debug5(`[${this.getString()}] local autorouting complete`);
8106
8053
  resolve(event.traces);
8107
8054
  });
8108
8055
  autorouter.on("error", (event) => {
8109
- debug4(
8056
+ debug5(
8110
8057
  `[${this.getString()}] local autorouting error: ${event.error.message}`
8111
8058
  );
8112
8059
  reject(event.error);
@@ -8163,30 +8110,30 @@ var Group = class extends NormalComponent {
8163
8110
  }
8164
8111
  }
8165
8112
  doInitialPcbTraceRender() {
8166
- const debug4 = Debug5("tscircuit:core:doInitialPcbTraceRender");
8113
+ const debug5 = Debug6("tscircuit:core:doInitialPcbTraceRender");
8167
8114
  if (!this.isSubcircuit) return;
8168
8115
  if (this.root?.pcbDisabled) return;
8169
8116
  if (this.getInheritedProperty("routingDisabled")) return;
8170
8117
  if (this._shouldUseTraceByTraceRouting()) return;
8171
8118
  if (!this._areChildSubcircuitsRouted()) {
8172
- debug4(
8119
+ debug5(
8173
8120
  `[${this.getString()}] child subcircuits are not routed, skipping async autorouting until subcircuits routed`
8174
8121
  );
8175
8122
  return;
8176
8123
  }
8177
- debug4(
8124
+ debug5(
8178
8125
  `[${this.getString()}] no child subcircuits to wait for, initiating async routing`
8179
8126
  );
8180
8127
  if (!this._hasTracesToRoute()) return;
8181
8128
  this._startAsyncAutorouting();
8182
8129
  }
8183
8130
  updatePcbTraceRender() {
8184
- const debug4 = Debug5("tscircuit:core:updatePcbTraceRender");
8185
- debug4(`[${this.getString()}] updating...`);
8131
+ const debug5 = Debug6("tscircuit:core:updatePcbTraceRender");
8132
+ debug5(`[${this.getString()}] updating...`);
8186
8133
  if (!this.isSubcircuit) return;
8187
8134
  if (this._shouldRouteAsync() && this._hasTracesToRoute() && !this._hasStartedAsyncAutorouting) {
8188
8135
  if (this._areChildSubcircuitsRouted()) {
8189
- debug4(
8136
+ debug5(
8190
8137
  `[${this.getString()}] child subcircuits are now routed, starting async autorouting`
8191
8138
  );
8192
8139
  this._startAsyncAutorouting();
@@ -8197,14 +8144,14 @@ var Group = class extends NormalComponent {
8197
8144
  if (this._shouldUseTraceByTraceRouting()) return;
8198
8145
  const { db } = this.root;
8199
8146
  if (this._asyncAutoroutingResult.output_simple_route_json) {
8200
- debug4(
8147
+ debug5(
8201
8148
  `[${this.getString()}] updating PCB traces from simple route json (${this._asyncAutoroutingResult.output_simple_route_json.traces?.length} traces)`
8202
8149
  );
8203
8150
  this._updatePcbTraceRenderFromSimpleRouteJson();
8204
8151
  return;
8205
8152
  }
8206
8153
  if (this._asyncAutoroutingResult.output_pcb_traces) {
8207
- debug4(
8154
+ debug5(
8208
8155
  `[${this.getString()}] updating PCB traces from ${this._asyncAutoroutingResult.output_pcb_traces.length} traces`
8209
8156
  );
8210
8157
  this._updatePcbTraceRenderFromPcbTraces();
@@ -10748,7 +10695,7 @@ import { identity as identity5 } from "transformation-matrix";
10748
10695
  var package_default = {
10749
10696
  name: "@tscircuit/core",
10750
10697
  type: "module",
10751
- version: "0.0.550",
10698
+ version: "0.0.552",
10752
10699
  types: "dist/index.d.ts",
10753
10700
  main: "dist/index.js",
10754
10701
  module: "dist/index.js",
@@ -10782,7 +10729,7 @@ var package_default = {
10782
10729
  "@tscircuit/math-utils": "^0.0.18",
10783
10730
  "@tscircuit/props": "^0.0.251",
10784
10731
  "@tscircuit/schematic-autolayout": "^0.0.6",
10785
- "@tscircuit/schematic-corpus": "^0.0.50",
10732
+ "@tscircuit/schematic-corpus": "^0.0.52",
10786
10733
  "@tscircuit/schematic-match-adapt": "^0.0.16",
10787
10734
  "@tscircuit/simple-3d-svg": "^0.0.6",
10788
10735
  "@types/bun": "^1.2.16",
@@ -10790,18 +10737,18 @@ var package_default = {
10790
10737
  "@types/react": "^19.0.1",
10791
10738
  "@types/react-dom": "^19.0.2",
10792
10739
  "@types/react-reconciler": "^0.28.9",
10793
- "bpc-graph": "^0.0.50",
10740
+ "bpc-graph": "^0.0.53",
10794
10741
  "bun-match-svg": "0.0.12",
10795
10742
  "calculate-elbow": "^0.0.5",
10796
10743
  "chokidar-cli": "^3.0.0",
10797
10744
  "circuit-json": "^0.0.215",
10798
- "circuit-json-to-bpc": "^0.0.7",
10745
+ "circuit-json-to-bpc": "^0.0.13",
10799
10746
  "circuit-json-to-connectivity-map": "^0.0.22",
10800
10747
  "circuit-json-to-simple-3d": "^0.0.2",
10801
10748
  "circuit-to-svg": "^0.0.162",
10802
10749
  concurrently: "^9.1.2",
10803
10750
  debug: "^4.3.6",
10804
- "graphics-debug": "^0.0.57",
10751
+ "graphics-debug": "^0.0.60",
10805
10752
  howfat: "^0.3.8",
10806
10753
  "live-server": "^1.2.2",
10807
10754
  "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.551",
4
+ "version": "0.0.553",
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.50",
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.50",
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.7",
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",
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",