@tscircuit/cli 0.1.1809 → 0.1.1810

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/cli/main.js CHANGED
@@ -118521,7 +118521,7 @@ var package_default = {
118521
118521
  "@tscircuit/check-shorts": "https://jscdn.tscircuit.com/@tscircuit/check-shorts/0.0.12.tgz",
118522
118522
  "@tscircuit/circuit-json-placement-analysis": "^0.0.6",
118523
118523
  "@tscircuit/circuit-json-routing-analysis": "^0.0.6",
118524
- "@tscircuit/circuit-json-schematic-placement-analysis": "github:tscircuit/circuit-json-schematic-placement-analysis#b6d5fe675adc26a2fc988aa081e6fb51e6bf696a",
118524
+ "@tscircuit/circuit-json-schematic-placement-analysis": "github:tscircuit/circuit-json-schematic-placement-analysis#bb0b41d80c9714695b498e182c2a558f1e0ceb2d",
118525
118525
  "@tscircuit/eval": "^0.0.1016",
118526
118526
  "@tscircuit/fake-snippets": "^0.0.182",
118527
118527
  "@tscircuit/file-server": "^0.0.32",
@@ -283393,8 +283393,22 @@ import {
283393
283393
 
283394
283394
  // node_modules/@tscircuit/circuit-json-schematic-placement-analysis/lib/utils/placements.ts
283395
283395
  import { cju as cju7 } from "@tscircuit/circuit-json-util";
283396
+
283397
+ // node_modules/@tscircuit/circuit-json-schematic-placement-analysis/lib/utils/schematic-sheets.ts
283398
+ var getSchematicSheetNamesById = (circuitJson) => {
283399
+ const map = new Map;
283400
+ for (const element of circuitJson) {
283401
+ if (element.type === "schematic_sheet" && element.name) {
283402
+ map.set(element.schematic_sheet_id, element.name);
283403
+ }
283404
+ }
283405
+ return map;
283406
+ };
283407
+
283408
+ // node_modules/@tscircuit/circuit-json-schematic-placement-analysis/lib/utils/placements.ts
283396
283409
  var isSchematicBox = (el3) => el3.type === "schematic_box";
283397
283410
  var isSchematicComponent = (el3) => el3.type === "schematic_component";
283411
+ var getSchematicSheetId = (el3) => el3.schematic_sheet_id;
283398
283412
  var getSourceComponentName = (circuitJson, sourceComponentId) => {
283399
283413
  if (!sourceComponentId)
283400
283414
  return;
@@ -283413,37 +283427,69 @@ var getSourceComponentMetadata = (schematicBox, circuitJson) => {
283413
283427
  sourceComponentName: sourceComponent?.name
283414
283428
  };
283415
283429
  };
283416
- var schematicComponentToPlacement = (schematicComponent, circuitJson, schematicBox) => ({
283417
- lineItemType: "SchematicBoxPlacement",
283418
- positionAnchor: "center",
283419
- schX: schematicComponent.center.x,
283420
- schY: schematicComponent.center.y,
283421
- width: schematicBox?.width ?? schematicComponent.size.width,
283422
- height: schematicBox?.height ?? schematicComponent.size.height,
283423
- sourceComponentId: schematicComponent.source_component_id,
283424
- sourceComponentName: getSourceComponentName(circuitJson, schematicComponent.source_component_id),
283425
- schematicComponentId: schematicComponent.schematic_component_id,
283426
- schematicSymbolId: schematicBox?.schematic_symbol_id ?? schematicComponent.schematic_symbol_id,
283427
- subcircuitId: schematicComponent.subcircuit_id ?? schematicBox?.subcircuit_id
283428
- });
283429
- var schematicBoxToPlacement = (schematicBox, circuitJson) => ({
283430
- lineItemType: "SchematicBoxPlacement",
283431
- positionAnchor: "center",
283432
- schX: schematicBox.x,
283433
- schY: schematicBox.y,
283434
- width: schematicBox.width,
283435
- height: schematicBox.height,
283436
- ...getSourceComponentMetadata(schematicBox, circuitJson),
283437
- schematicComponentId: schematicBox.schematic_component_id,
283438
- schematicSymbolId: schematicBox.schematic_symbol_id,
283439
- subcircuitId: schematicBox.subcircuit_id
283440
- });
283430
+ var schematicComponentToPlacement = (schematicComponent, circuitJson, schematicSheetNameById, schematicBox) => {
283431
+ let schematicSheetId = getSchematicSheetId(schematicComponent);
283432
+ if (schematicSheetId === undefined && schematicBox) {
283433
+ schematicSheetId = getSchematicSheetId(schematicBox);
283434
+ }
283435
+ let schematicSheetName;
283436
+ if (schematicSheetId) {
283437
+ schematicSheetName = schematicSheetNameById.get(schematicSheetId);
283438
+ }
283439
+ const placement = {
283440
+ lineItemType: "SchematicBoxPlacement",
283441
+ positionAnchor: "center",
283442
+ schX: schematicComponent.center.x,
283443
+ schY: schematicComponent.center.y,
283444
+ width: schematicBox?.width ?? schematicComponent.size.width,
283445
+ height: schematicBox?.height ?? schematicComponent.size.height,
283446
+ sourceComponentId: schematicComponent.source_component_id,
283447
+ sourceComponentName: getSourceComponentName(circuitJson, schematicComponent.source_component_id),
283448
+ schematicComponentId: schematicComponent.schematic_component_id,
283449
+ schematicSymbolId: schematicBox?.schematic_symbol_id ?? schematicComponent.schematic_symbol_id,
283450
+ subcircuitId: schematicComponent.subcircuit_id ?? schematicBox?.subcircuit_id
283451
+ };
283452
+ if (schematicSheetId) {
283453
+ placement.schematicSheetId = schematicSheetId;
283454
+ }
283455
+ if (schematicSheetName) {
283456
+ placement.schematicSheetName = schematicSheetName;
283457
+ }
283458
+ return placement;
283459
+ };
283460
+ var schematicBoxToPlacement = (schematicBox, circuitJson, schematicSheetNameById) => {
283461
+ const schematicSheetId = getSchematicSheetId(schematicBox);
283462
+ let schematicSheetName;
283463
+ if (schematicSheetId) {
283464
+ schematicSheetName = schematicSheetNameById.get(schematicSheetId);
283465
+ }
283466
+ const placement = {
283467
+ lineItemType: "SchematicBoxPlacement",
283468
+ positionAnchor: "center",
283469
+ schX: schematicBox.x,
283470
+ schY: schematicBox.y,
283471
+ width: schematicBox.width,
283472
+ height: schematicBox.height,
283473
+ ...getSourceComponentMetadata(schematicBox, circuitJson),
283474
+ schematicComponentId: schematicBox.schematic_component_id,
283475
+ schematicSymbolId: schematicBox.schematic_symbol_id,
283476
+ subcircuitId: schematicBox.subcircuit_id
283477
+ };
283478
+ if (schematicSheetId) {
283479
+ placement.schematicSheetId = schematicSheetId;
283480
+ }
283481
+ if (schematicSheetName) {
283482
+ placement.schematicSheetName = schematicSheetName;
283483
+ }
283484
+ return placement;
283485
+ };
283441
283486
  var buildSolverContext = (circuitJson) => {
283442
283487
  const schematicBoxes = circuitJson.filter(isSchematicBox);
283488
+ const schematicSheetNameById = getSchematicSheetNamesById(circuitJson);
283443
283489
  const schematicComponentIds = new Set(circuitJson.filter(isSchematicComponent).map((sc2) => sc2.schematic_component_id));
283444
283490
  const componentPlacements = [
283445
- ...circuitJson.filter(isSchematicComponent).map((sc2) => schematicComponentToPlacement(sc2, circuitJson, schematicBoxes.find((sb3) => sb3.schematic_component_id === sc2.schematic_component_id))),
283446
- ...schematicBoxes.filter((sb3) => !sb3.schematic_component_id || !schematicComponentIds.has(sb3.schematic_component_id)).map((sb3) => schematicBoxToPlacement(sb3, circuitJson))
283491
+ ...circuitJson.filter(isSchematicComponent).map((sc2) => schematicComponentToPlacement(sc2, circuitJson, schematicSheetNameById, schematicBoxes.find((sb3) => sb3.schematic_component_id === sc2.schematic_component_id))),
283492
+ ...schematicBoxes.filter((sb3) => !sb3.schematic_component_id || !schematicComponentIds.has(sb3.schematic_component_id)).map((sb3) => schematicBoxToPlacement(sb3, circuitJson, schematicSheetNameById))
283447
283493
  ];
283448
283494
  return { circuitJson, componentPlacements };
283449
283495
  };
@@ -283712,6 +283758,8 @@ class SchematicBoxOverlapSolver extends BaseSolver7 {
283712
283758
  return `<OverlapCorrectionSuggestion ${attrs.join(" ")} />`;
283713
283759
  }
283714
283760
  getComponentOverlap(firstComponent, secondComponent) {
283761
+ if (firstComponent.schematicSheetId !== secondComponent.schematicSheetId)
283762
+ return null;
283715
283763
  const a3 = this.getCenteredRectBounds(firstComponent);
283716
283764
  const b3 = this.getCenteredRectBounds(secondComponent);
283717
283765
  const overlapWidth = Math.min(a3.right, b3.right) - Math.max(a3.left, b3.left);
@@ -284346,6 +284394,7 @@ class VerboseNetLabelSolver extends BaseSolver11 {
284346
284394
  VERBOSE_NET_LABEL_MESSAGE = "Create trace with schDisplayLabel";
284347
284395
  netLabels;
284348
284396
  tokenToInvolvedPin;
284397
+ schematicSheetNameById;
284349
284398
  currentIndex = 0;
284350
284399
  seen = new Set;
284351
284400
  constructor(params2) {
@@ -284354,6 +284403,7 @@ class VerboseNetLabelSolver extends BaseSolver11 {
284354
284403
  const { circuitJson } = params2.ctx;
284355
284404
  this.netLabels = circuitJson.filter((el3) => this.isSchematicNetLabel(el3));
284356
284405
  this.tokenToInvolvedPin = this.buildTokenToInvolvedPinMap(circuitJson);
284406
+ this.schematicSheetNameById = getSchematicSheetNamesById(circuitJson);
284357
284407
  this.solved = this.netLabels.length === 0;
284358
284408
  }
284359
284409
  _step() {
@@ -284363,13 +284413,20 @@ class VerboseNetLabelSolver extends BaseSolver11 {
284363
284413
  return;
284364
284414
  }
284365
284415
  this.solved = this.currentIndex >= this.netLabels.length;
284366
- if (!label.text.includes("/") || this.seen.has(label.text))
284416
+ const seenKey = `${label.schematic_sheet_id ?? ""}:${label.text}`;
284417
+ if (!label.text.includes("/") || this.seen.has(seenKey))
284367
284418
  return;
284368
- this.seen.add(label.text);
284419
+ this.seen.add(seenKey);
284420
+ let schematicSheetName;
284421
+ if (label.schematic_sheet_id) {
284422
+ schematicSheetName = this.schematicSheetNameById.get(label.schematic_sheet_id);
284423
+ }
284369
284424
  const issue = {
284370
284425
  lineItemType: "VerboseSchematicNetLabel",
284371
284426
  schematicNetLabelId: label.schematic_net_label_id,
284372
284427
  sourceNetId: label.source_net_id,
284428
+ schematicSheetId: label.schematic_sheet_id,
284429
+ schematicSheetName,
284373
284430
  text: label.text,
284374
284431
  involvedPins: this.getInvolvedPins(label.text, this.tokenToInvolvedPin),
284375
284432
  schX: label.center.x,
@@ -284383,6 +284440,7 @@ class VerboseNetLabelSolver extends BaseSolver11 {
284383
284440
  addAttr(attrs, "message", issue.message, { escape: false });
284384
284441
  addAttr(attrs, "text", issue.text);
284385
284442
  addAttr(attrs, "involvedPins", issue.involvedPins.join(","));
284443
+ addAttr(attrs, "schSheetName", issue.schematicSheetName);
284386
284444
  addAttr(attrs, "schX", issue.schX);
284387
284445
  addAttr(attrs, "schY", issue.schY);
284388
284446
  return `<VerboseSchematicNetLabel ${attrs.join(" ")} />`;
@@ -284482,8 +284540,9 @@ class DiodeResistorAlignmentSolver extends BaseSolver12 {
284482
284540
  return;
284483
284541
  const start = firstEdge.from;
284484
284542
  const end = lastEdge.to;
284485
- const startSourceCompId = this.findSourceComponentIdNearPoint(start);
284486
- const endSourceCompId = this.findSourceComponentIdNearPoint(end);
284543
+ const schematicSheetId = trace.schematic_sheet_id;
284544
+ const startSourceCompId = this.findSourceComponentIdNearPoint(start, schematicSheetId);
284545
+ const endSourceCompId = this.findSourceComponentIdNearPoint(end, schematicSheetId);
284487
284546
  if (!startSourceCompId || !endSourceCompId)
284488
284547
  return;
284489
284548
  const startFtype = this.sourceComponentFtypeById.get(startSourceCompId);
@@ -284498,8 +284557,8 @@ class DiodeResistorAlignmentSolver extends BaseSolver12 {
284498
284557
  const resistorBox = this.schematicBoxBySourceComponentId.get(resistorCompId);
284499
284558
  if (!diodeBox || !resistorBox)
284500
284559
  return;
284501
- const diodePort = this.findNearestPort(DIODE_FTYPES.has(startFtype) ? start : end);
284502
- const resistorPort = this.findNearestPort(startFtype === "simple_resistor" ? start : end);
284560
+ const diodePort = this.findNearestPort(DIODE_FTYPES.has(startFtype) ? start : end, schematicSheetId);
284561
+ const resistorPort = this.findNearestPort(startFtype === "simple_resistor" ? start : end, schematicSheetId);
284503
284562
  if (!diodePort?.center || !resistorPort?.center)
284504
284563
  return;
284505
284564
  const diodeName = diodeBox.sourceComponentName ?? diodeCompId;
@@ -284541,10 +284600,12 @@ class DiodeResistorAlignmentSolver extends BaseSolver12 {
284541
284600
  static dist(a3, b3) {
284542
284601
  return Math.sqrt((a3.x - b3.x) ** 2 + (a3.y - b3.y) ** 2);
284543
284602
  }
284544
- findNearestPort(point9) {
284603
+ findNearestPort(point9, schematicSheetId) {
284545
284604
  let nearest;
284546
284605
  let minDist = Infinity;
284547
284606
  for (const port of this.schematicPorts) {
284607
+ if (port.schematic_sheet_id !== schematicSheetId)
284608
+ continue;
284548
284609
  if (!port.center)
284549
284610
  continue;
284550
284611
  const d3 = DiodeResistorAlignmentSolver.dist(point9, port.center);
@@ -284555,8 +284616,8 @@ class DiodeResistorAlignmentSolver extends BaseSolver12 {
284555
284616
  }
284556
284617
  return nearest;
284557
284618
  }
284558
- findSourceComponentIdNearPoint(point9) {
284559
- const nearest = this.findNearestPort(point9);
284619
+ findSourceComponentIdNearPoint(point9, schematicSheetId) {
284620
+ const nearest = this.findNearestPort(point9, schematicSheetId);
284560
284621
  if (!nearest || !nearest.source_port_id)
284561
284622
  return;
284562
284623
  return this.sourceComponentIdBySourcePortId.get(nearest.source_port_id);
@@ -284651,6 +284712,8 @@ class ComponentNetLabelCollisionSolver extends BaseSolver13 {
284651
284712
  }
284652
284713
  }
284653
284714
  detectPair(compA, compB) {
284715
+ if (compA.schematicSheetId !== compB.schematicSheetId)
284716
+ return;
284654
284717
  this.rawCollisions.push(...this.detectLabelLabel(compA, compB));
284655
284718
  this.rawCollisions.push(...this.detectBoxLabel(compA, compB));
284656
284719
  this.rawCollisions.push(...this.detectBoxLabel(compB, compA));
@@ -284871,7 +284934,8 @@ class ComponentNetLabelCollisionSolver extends BaseSolver13 {
284871
284934
  portPositions.push({
284872
284935
  componentId: port.schematic_component_id,
284873
284936
  cx: port.center.x,
284874
- cy: port.center.y
284937
+ cy: port.center.y,
284938
+ schematicSheetId: port.schematic_sheet_id
284875
284939
  });
284876
284940
  }
284877
284941
  const result = new Map;
@@ -284882,7 +284946,7 @@ class ComponentNetLabelCollisionSolver extends BaseSolver13 {
284882
284946
  if (!label.anchor_position)
284883
284947
  continue;
284884
284948
  const { x: anchorX, y: anchorY } = label.anchor_position;
284885
- const matches = portPositions.filter((port) => Math.hypot(port.cx - anchorX, port.cy - anchorY) < MATCH_EPSILON);
284949
+ const matches = portPositions.filter((port) => port.schematicSheetId === label.schematic_sheet_id && Math.hypot(port.cx - anchorX, port.cy - anchorY) < MATCH_EPSILON);
284886
284950
  if (matches.length === 0)
284887
284951
  continue;
284888
284952
  const componentIds = new Set(matches.map((match) => match.componentId));
@@ -285003,6 +285067,7 @@ class SchematicPlacementAnalysis {
285003
285067
  addAttr(attrs, "schY", lineItem.schY);
285004
285068
  addAttr(attrs, "width", lineItem.width);
285005
285069
  addAttr(attrs, "height", lineItem.height);
285070
+ addAttr(attrs, "schSheetName", lineItem.schematicSheetName);
285006
285071
  return `<SchematicBoxPlacement ${attrs.join(" ")} />`;
285007
285072
  }
285008
285073
  schematicIssuesToString(issue) {
package/dist/lib/index.js CHANGED
@@ -65772,7 +65772,7 @@ var package_default = {
65772
65772
  "@tscircuit/check-shorts": "https://jscdn.tscircuit.com/@tscircuit/check-shorts/0.0.12.tgz",
65773
65773
  "@tscircuit/circuit-json-placement-analysis": "^0.0.6",
65774
65774
  "@tscircuit/circuit-json-routing-analysis": "^0.0.6",
65775
- "@tscircuit/circuit-json-schematic-placement-analysis": "github:tscircuit/circuit-json-schematic-placement-analysis#b6d5fe675adc26a2fc988aa081e6fb51e6bf696a",
65775
+ "@tscircuit/circuit-json-schematic-placement-analysis": "github:tscircuit/circuit-json-schematic-placement-analysis#bb0b41d80c9714695b498e182c2a558f1e0ceb2d",
65776
65776
  "@tscircuit/eval": "^0.0.1016",
65777
65777
  "@tscircuit/fake-snippets": "^0.0.182",
65778
65778
  "@tscircuit/file-server": "^0.0.32",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tscircuit/cli",
3
- "version": "0.1.1809",
3
+ "version": "0.1.1810",
4
4
  "main": "dist/cli/main.js",
5
5
  "exports": {
6
6
  ".": "./dist/cli/main.js",
@@ -12,7 +12,7 @@
12
12
  "@tscircuit/check-shorts": "https://jscdn.tscircuit.com/@tscircuit/check-shorts/0.0.12.tgz",
13
13
  "@tscircuit/circuit-json-placement-analysis": "^0.0.6",
14
14
  "@tscircuit/circuit-json-routing-analysis": "^0.0.6",
15
- "@tscircuit/circuit-json-schematic-placement-analysis": "github:tscircuit/circuit-json-schematic-placement-analysis#b6d5fe675adc26a2fc988aa081e6fb51e6bf696a",
15
+ "@tscircuit/circuit-json-schematic-placement-analysis": "github:tscircuit/circuit-json-schematic-placement-analysis#bb0b41d80c9714695b498e182c2a558f1e0ceb2d",
16
16
  "@tscircuit/eval": "^0.0.1016",
17
17
  "@tscircuit/fake-snippets": "^0.0.182",
18
18
  "@tscircuit/file-server": "^0.0.32",