@tscircuit/cli 0.1.1319 → 0.1.1320

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
@@ -100574,7 +100574,7 @@ var import_perfect_cli = __toESM2(require_dist2(), 1);
100574
100574
  // lib/getVersion.ts
100575
100575
  import { createRequire as createRequire2 } from "node:module";
100576
100576
  // package.json
100577
- var version = "0.1.1318";
100577
+ var version = "0.1.1319";
100578
100578
  var package_default = {
100579
100579
  name: "@tscircuit/cli",
100580
100580
  version,
@@ -100588,7 +100588,7 @@ var package_default = {
100588
100588
  "@biomejs/biome": "^1.9.4",
100589
100589
  "@tscircuit/circuit-json-placement-analysis": "^0.0.6",
100590
100590
  "@tscircuit/circuit-json-routing-analysis": "^0.0.1",
100591
- "@tscircuit/circuit-json-schematic-placement-analysis": "github:tscircuit/circuit-json-schematic-placement-analysis#c7cfc20927dc5e24414a669e7bcfdecd83504f3e",
100591
+ "@tscircuit/circuit-json-schematic-placement-analysis": "github:tscircuit/circuit-json-schematic-placement-analysis#add7fd89b1edce7fda0471a173409b8118d2723c",
100592
100592
  "@tscircuit/fake-snippets": "^0.0.182",
100593
100593
  "@tscircuit/file-server": "^0.0.32",
100594
100594
  "@tscircuit/image-utils": "^0.0.3",
@@ -241231,10 +241231,10 @@ var registerCheckRouting = (program2) => {
241231
241231
  });
241232
241232
  };
241233
241233
 
241234
- // node_modules/@tscircuit/circuit-json-schematic-placement-analysis/lib/analyze-schematic-placement.ts
241234
+ // node_modules/@tscircuit/circuit-json-schematic-placement-analysis/lib/analyzers/analyze-schematic-placement.ts
241235
241235
  import { cju as cju7 } from "@tscircuit/circuit-json-util";
241236
241236
 
241237
- // node_modules/@tscircuit/circuit-json-schematic-placement-analysis/lib/capacitor-orientation.ts
241237
+ // node_modules/@tscircuit/circuit-json-schematic-placement-analysis/lib/analyzers/capacitor-orientation.ts
241238
241238
  var HORIZONTAL_CAPACITOR_SYMBOL_NAMES = new Set([
241239
241239
  "capacitor_left",
241240
241240
  "capacitor_right"
@@ -241260,8 +241260,162 @@ var generateCapacitorOrientationIssues = (componentPlacements, circuitJson) => {
241260
241260
  });
241261
241261
  };
241262
241262
 
241263
- // node_modules/@tscircuit/circuit-json-schematic-placement-analysis/lib/schematic-box-overlap.ts
241263
+ // node_modules/@tscircuit/circuit-json-schematic-placement-analysis/lib/analyzers/schematic-box-sizing.ts
241264
+ var SCHEMATIC_BOX_SIZING_MESSAGE = "Shrink schematic box width";
241265
+ var PIN_HEADER_SCHEMATIC_BOX_SIZING_MAX_ALLOWED_GAP = 0.1;
241266
+ var CHIP_SCHEMATIC_BOX_SIZING_MAX_ALLOWED_GAP = 1;
241267
+ var PIN_LABEL_EDGE_PADDING = 0.1;
241268
+ var PIN_NAME_CHARACTER_WIDTH = 0.095;
241269
+ var FALLBACK_CHARACTER_WIDTH = 0.13;
241270
+ var GAP_COMPARISON_EPSILON = 0.000000001;
241271
+ var isSchematicPort = (element) => element.type === "schematic_port";
241272
+ var isSourcePort = (element) => element.type === "source_port";
241273
+ var getSourceComponentWithFtype = (element) => {
241274
+ if (element.type !== "source_component" || !("source_component_id" in element) || typeof element.source_component_id !== "string") {
241275
+ return null;
241276
+ }
241277
+ return {
241278
+ type: "source_component",
241279
+ source_component_id: element.source_component_id,
241280
+ ftype: "ftype" in element && typeof element.ftype === "string" ? element.ftype : undefined
241281
+ };
241282
+ };
241283
+ var isHorizontalSide = (side) => side === "left" || side === "right";
241264
241284
  var getCenteredRectBounds = (box2) => {
241285
+ const halfWidth = box2.width / 2;
241286
+ return {
241287
+ left: box2.schX - halfWidth,
241288
+ right: box2.schX + halfWidth
241289
+ };
241290
+ };
241291
+ var isPinNameLabel = (label, sourcePort) => {
241292
+ if (!sourcePort)
241293
+ return false;
241294
+ return label === sourcePort.name || label === String(sourcePort.pin_number) || (sourcePort.port_hints ?? []).includes(label);
241295
+ };
241296
+ var estimateLabelWidth = (label, sourcePort) => {
241297
+ const characterWidth = isPinNameLabel(label, sourcePort) ? PIN_NAME_CHARACTER_WIDTH : FALLBACK_CHARACTER_WIDTH;
241298
+ return Array.from(label).length * characterWidth;
241299
+ };
241300
+ var getLabelColumn = (side, ports, sourcePortById) => {
241301
+ const labelWidths = ports.filter((port) => port.side_of_component === side).flatMap((port) => port.display_pin_label ? [
241302
+ estimateLabelWidth(port.display_pin_label, sourcePortById.get(port.source_port_id))
241303
+ ] : []);
241304
+ if (labelWidths.length === 0)
241305
+ return null;
241306
+ return {
241307
+ side,
241308
+ labelCount: labelWidths.length,
241309
+ maxLabelWidth: Math.max(...labelWidths)
241310
+ };
241311
+ };
241312
+ var getInnerLabelEdge = (bounds, labelColumn) => {
241313
+ if (labelColumn.side === "left") {
241314
+ return bounds.left + PIN_LABEL_EDGE_PADDING + labelColumn.maxLabelWidth;
241315
+ }
241316
+ return bounds.right - PIN_LABEL_EDGE_PADDING - labelColumn.maxLabelWidth;
241317
+ };
241318
+ var getSuggestedWidth = (input) => input.currentWidth - input.measuredInnerLabelHorizontalEmptySpace + input.maxAllowedInnerLabelHorizontalEmptySpace;
241319
+ var exceedsMaxAllowedGap = (measuredInnerLabelHorizontalEmptySpace, maxAllowedInnerLabelHorizontalEmptySpace) => measuredInnerLabelHorizontalEmptySpace - maxAllowedInnerLabelHorizontalEmptySpace > GAP_COMPARISON_EPSILON;
241320
+ var createPinHeaderIssue = (input) => ({
241321
+ lineItemType: "SchematicBoxTooWideForPinHeader",
241322
+ schematicBox: input.schematicBox,
241323
+ measuredInnerLabelHorizontalEmptySpace: input.measuredInnerLabelHorizontalEmptySpace,
241324
+ maxAllowedInnerLabelHorizontalEmptySpace: PIN_HEADER_SCHEMATIC_BOX_SIZING_MAX_ALLOWED_GAP,
241325
+ suggestedSchWidth: input.suggestedSchWidth,
241326
+ message: SCHEMATIC_BOX_SIZING_MESSAGE
241327
+ });
241328
+ var createChipIssue = (input) => ({
241329
+ lineItemType: "SchematicBoxTooWideForChip",
241330
+ schematicBox: input.schematicBox,
241331
+ measuredInnerLabelHorizontalEmptySpace: input.measuredInnerLabelHorizontalEmptySpace,
241332
+ maxAllowedInnerLabelHorizontalEmptySpace: CHIP_SCHEMATIC_BOX_SIZING_MAX_ALLOWED_GAP,
241333
+ suggestedSchWidth: input.suggestedSchWidth,
241334
+ message: SCHEMATIC_BOX_SIZING_MESSAGE
241335
+ });
241336
+ var generateSchematicBoxSizingCandidates = (componentPlacements, circuitJson) => {
241337
+ const placementBySchematicComponentId = new Map(componentPlacements.filter((placement) => placement.schematicComponentId).map((placement) => [placement.schematicComponentId, placement]));
241338
+ const sourcePortById = new Map(circuitJson.filter(isSourcePort).map((sourcePort) => [sourcePort.source_port_id, sourcePort]));
241339
+ const sourceComponentById = new Map(circuitJson.flatMap((element) => {
241340
+ const sourceComponent = getSourceComponentWithFtype(element);
241341
+ return sourceComponent ? [sourceComponent] : [];
241342
+ }).map((sourceComponent) => [
241343
+ sourceComponent.source_component_id,
241344
+ sourceComponent
241345
+ ]));
241346
+ const portsBySchematicComponentId = new Map;
241347
+ for (const port of circuitJson.filter(isSchematicPort)) {
241348
+ if (!port.schematic_component_id)
241349
+ continue;
241350
+ if (!isHorizontalSide(port.side_of_component))
241351
+ continue;
241352
+ const ports = portsBySchematicComponentId.get(port.schematic_component_id);
241353
+ if (ports) {
241354
+ ports.push(port);
241355
+ } else {
241356
+ portsBySchematicComponentId.set(port.schematic_component_id, [port]);
241357
+ }
241358
+ }
241359
+ const candidates = [];
241360
+ for (const [schematicComponentId, ports] of portsBySchematicComponentId) {
241361
+ const schematicBox = placementBySchematicComponentId.get(schematicComponentId);
241362
+ if (!schematicBox)
241363
+ continue;
241364
+ const bounds = getCenteredRectBounds(schematicBox);
241365
+ const leftLabelColumn = getLabelColumn("left", ports, sourcePortById);
241366
+ const rightLabelColumn = getLabelColumn("right", ports, sourcePortById);
241367
+ const sourceComponentFtype = schematicBox.sourceComponentId ? sourceComponentById.get(schematicBox.sourceComponentId)?.ftype : undefined;
241368
+ if (leftLabelColumn && rightLabelColumn) {
241369
+ const measuredInnerLabelHorizontalEmptySpace = getInnerLabelEdge(bounds, rightLabelColumn) - getInnerLabelEdge(bounds, leftLabelColumn);
241370
+ candidates.push({
241371
+ schematicBox,
241372
+ sourceComponentFtype,
241373
+ measuredInnerLabelHorizontalEmptySpace
241374
+ });
241375
+ continue;
241376
+ }
241377
+ if (leftLabelColumn && leftLabelColumn.labelCount >= 4) {
241378
+ const measuredInnerLabelHorizontalEmptySpace = bounds.right - getInnerLabelEdge(bounds, leftLabelColumn);
241379
+ candidates.push({
241380
+ schematicBox,
241381
+ sourceComponentFtype,
241382
+ measuredInnerLabelHorizontalEmptySpace
241383
+ });
241384
+ }
241385
+ if (rightLabelColumn && rightLabelColumn.labelCount >= 4) {
241386
+ const measuredInnerLabelHorizontalEmptySpace = getInnerLabelEdge(bounds, rightLabelColumn) - bounds.left;
241387
+ candidates.push({
241388
+ schematicBox,
241389
+ sourceComponentFtype,
241390
+ measuredInnerLabelHorizontalEmptySpace
241391
+ });
241392
+ }
241393
+ }
241394
+ return candidates;
241395
+ };
241396
+ var getSchematicBoxTooWideForPinHeaderIssues = (candidates) => candidates.filter((candidate) => candidate.sourceComponentFtype === "simple_pin_header").filter((candidate) => exceedsMaxAllowedGap(candidate.measuredInnerLabelHorizontalEmptySpace, PIN_HEADER_SCHEMATIC_BOX_SIZING_MAX_ALLOWED_GAP)).map((candidate) => createPinHeaderIssue({
241397
+ schematicBox: candidate.schematicBox,
241398
+ measuredInnerLabelHorizontalEmptySpace: candidate.measuredInnerLabelHorizontalEmptySpace,
241399
+ suggestedSchWidth: getSuggestedWidth({
241400
+ measuredInnerLabelHorizontalEmptySpace: candidate.measuredInnerLabelHorizontalEmptySpace,
241401
+ maxAllowedInnerLabelHorizontalEmptySpace: PIN_HEADER_SCHEMATIC_BOX_SIZING_MAX_ALLOWED_GAP,
241402
+ currentWidth: candidate.schematicBox.width
241403
+ })
241404
+ }));
241405
+ var getSchematicBoxTooWideForChipIssues = (candidates) => candidates.filter((candidate) => candidate.sourceComponentFtype === "simple_chip").filter((candidate) => exceedsMaxAllowedGap(candidate.measuredInnerLabelHorizontalEmptySpace, CHIP_SCHEMATIC_BOX_SIZING_MAX_ALLOWED_GAP)).map((candidate) => createChipIssue({
241406
+ schematicBox: candidate.schematicBox,
241407
+ measuredInnerLabelHorizontalEmptySpace: candidate.measuredInnerLabelHorizontalEmptySpace,
241408
+ suggestedSchWidth: getSuggestedWidth({
241409
+ measuredInnerLabelHorizontalEmptySpace: candidate.measuredInnerLabelHorizontalEmptySpace,
241410
+ maxAllowedInnerLabelHorizontalEmptySpace: CHIP_SCHEMATIC_BOX_SIZING_MAX_ALLOWED_GAP,
241411
+ currentWidth: candidate.schematicBox.width
241412
+ })
241413
+ }));
241414
+ var generateSchematicBoxTooWideForPinHeaderIssues = (componentPlacements, circuitJson) => getSchematicBoxTooWideForPinHeaderIssues(generateSchematicBoxSizingCandidates(componentPlacements, circuitJson));
241415
+ var generateSchematicBoxTooWideForChipIssues = (componentPlacements, circuitJson) => getSchematicBoxTooWideForChipIssues(generateSchematicBoxSizingCandidates(componentPlacements, circuitJson));
241416
+
241417
+ // node_modules/@tscircuit/circuit-json-schematic-placement-analysis/lib/analyzers/schematic-box-overlap.ts
241418
+ var getCenteredRectBounds2 = (box2) => {
241265
241419
  const halfWidth = box2.width / 2;
241266
241420
  const halfHeight = box2.height / 2;
241267
241421
  return {
@@ -241272,8 +241426,8 @@ var getCenteredRectBounds = (box2) => {
241272
241426
  };
241273
241427
  };
241274
241428
  var getComponentOverlap = (firstComponent, secondComponent) => {
241275
- const firstBounds = getCenteredRectBounds(firstComponent);
241276
- const secondBounds = getCenteredRectBounds(secondComponent);
241429
+ const firstBounds = getCenteredRectBounds2(firstComponent);
241430
+ const secondBounds = getCenteredRectBounds2(secondComponent);
241277
241431
  const left = Math.max(firstBounds.left, secondBounds.left);
241278
241432
  const right = Math.min(firstBounds.right, secondBounds.right);
241279
241433
  const top = Math.max(firstBounds.top, secondBounds.top);
@@ -241339,10 +241493,10 @@ var generateSchematicPlacementIssues = (componentPlacements) => {
241339
241493
  return issues;
241340
241494
  };
241341
241495
 
241342
- // node_modules/@tscircuit/circuit-json-schematic-placement-analysis/lib/verbose-net-label.ts
241496
+ // node_modules/@tscircuit/circuit-json-schematic-placement-analysis/lib/analyzers/verbose-net-label.ts
241343
241497
  var VERBOSE_NET_LABEL_MESSAGE = "Create trace with schDisplayLabel";
241344
241498
  var isSchematicNetLabel = (element) => element.type === "schematic_net_label";
241345
- var isSourcePort = (element) => element.type === "source_port";
241499
+ var isSourcePort2 = (element) => element.type === "source_port";
241346
241500
  var getSourceComponentWithName = (element) => {
241347
241501
  if (element.type !== "source_component" || !("source_component_id" in element) || !("name" in element) || typeof element.source_component_id !== "string" || typeof element.name !== "string") {
241348
241502
  return null;
@@ -241369,7 +241523,7 @@ var getLabelTokenToInvolvedPinMap = (circuitJson) => {
241369
241523
  sourceComponent
241370
241524
  ]));
241371
241525
  const tokenToInvolvedPin = new Map;
241372
- for (const sourcePort of circuitJson.filter(isSourcePort)) {
241526
+ for (const sourcePort of circuitJson.filter(isSourcePort2)) {
241373
241527
  if (!sourcePort.source_component_id)
241374
241528
  continue;
241375
241529
  const sourceComponent = sourceComponentById.get(sourcePort.source_component_id);
@@ -241413,7 +241567,7 @@ var generateVerboseNetLabelIssues = (circuitJson) => {
241413
241567
  return Array.from(issuesByText.values());
241414
241568
  };
241415
241569
 
241416
- // node_modules/@tscircuit/circuit-json-schematic-placement-analysis/lib/analyze-schematic-placement.ts
241570
+ // node_modules/@tscircuit/circuit-json-schematic-placement-analysis/lib/analyzers/analyze-schematic-placement.ts
241417
241571
  var fmtNumber5 = (value) => {
241418
241572
  if (Number.isInteger(value))
241419
241573
  return String(value);
@@ -241519,6 +241673,16 @@ var verboseSchematicNetLabelIssueToString = (issue) => {
241519
241673
  addAttr(attrs, "schY", issue.schY);
241520
241674
  return `<VerboseSchematicNetLabel ${attrs.join(" ")} />`;
241521
241675
  };
241676
+ var schematicBoxTooWideIssueToString = (issue) => {
241677
+ const attrs = [];
241678
+ addAttr(attrs, "message", issue.message, { escape: false });
241679
+ addAttr(attrs, "componentName", issue.schematicBox.sourceComponentName);
241680
+ addAttr(attrs, "currentSchWidth", issue.schematicBox.width);
241681
+ addAttr(attrs, "measuredInnerLabelHorizontalEmptySpace", issue.measuredInnerLabelHorizontalEmptySpace);
241682
+ addAttr(attrs, "maxAllowedInnerLabelHorizontalEmptySpace", issue.maxAllowedInnerLabelHorizontalEmptySpace);
241683
+ addAttr(attrs, "suggestedSchWidth", issue.suggestedSchWidth);
241684
+ return `<${issue.lineItemType} ${attrs.join(" ")} />`;
241685
+ };
241522
241686
  var correctionSuggestionToString = (suggestion) => {
241523
241687
  const attrs = [];
241524
241688
  addAttr(attrs, "target", suggestion.targetComponentName);
@@ -241562,6 +241726,9 @@ class SchematicPlacementAnalysis {
241562
241726
  return capacitorSymbolHorizontalIssueToString(issue);
241563
241727
  case "VerboseSchematicNetLabel":
241564
241728
  return verboseSchematicNetLabelIssueToString(issue);
241729
+ case "SchematicBoxTooWideForPinHeader":
241730
+ case "SchematicBoxTooWideForChip":
241731
+ return schematicBoxTooWideIssueToString(issue);
241565
241732
  default:
241566
241733
  return "";
241567
241734
  }
@@ -241582,7 +241749,9 @@ var analyzeSchematicPlacement = (circuitJson) => {
241582
241749
  const issues = [
241583
241750
  ...generateSchematicPlacementIssues(lineItems),
241584
241751
  ...generateCapacitorOrientationIssues(lineItems, circuitJson),
241585
- ...generateVerboseNetLabelIssues(circuitJson)
241752
+ ...generateVerboseNetLabelIssues(circuitJson),
241753
+ ...generateSchematicBoxTooWideForPinHeaderIssues(lineItems, circuitJson),
241754
+ ...generateSchematicBoxTooWideForChipIssues(lineItems, circuitJson)
241586
241755
  ];
241587
241756
  return new SchematicPlacementAnalysis([
241588
241757
  ...lineItems,
package/dist/lib/index.js CHANGED
@@ -65661,7 +65661,7 @@ var getNodeHandler = (winterSpec, { port, middleware = [] }) => {
65661
65661
  }));
65662
65662
  };
65663
65663
  // package.json
65664
- var version = "0.1.1318";
65664
+ var version = "0.1.1319";
65665
65665
  var package_default = {
65666
65666
  name: "@tscircuit/cli",
65667
65667
  version,
@@ -65675,7 +65675,7 @@ var package_default = {
65675
65675
  "@biomejs/biome": "^1.9.4",
65676
65676
  "@tscircuit/circuit-json-placement-analysis": "^0.0.6",
65677
65677
  "@tscircuit/circuit-json-routing-analysis": "^0.0.1",
65678
- "@tscircuit/circuit-json-schematic-placement-analysis": "github:tscircuit/circuit-json-schematic-placement-analysis#c7cfc20927dc5e24414a669e7bcfdecd83504f3e",
65678
+ "@tscircuit/circuit-json-schematic-placement-analysis": "github:tscircuit/circuit-json-schematic-placement-analysis#add7fd89b1edce7fda0471a173409b8118d2723c",
65679
65679
  "@tscircuit/fake-snippets": "^0.0.182",
65680
65680
  "@tscircuit/file-server": "^0.0.32",
65681
65681
  "@tscircuit/image-utils": "^0.0.3",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tscircuit/cli",
3
- "version": "0.1.1319",
3
+ "version": "0.1.1320",
4
4
  "main": "dist/cli/main.js",
5
5
  "exports": {
6
6
  ".": "./dist/cli/main.js",
@@ -11,7 +11,7 @@
11
11
  "@biomejs/biome": "^1.9.4",
12
12
  "@tscircuit/circuit-json-placement-analysis": "^0.0.6",
13
13
  "@tscircuit/circuit-json-routing-analysis": "^0.0.1",
14
- "@tscircuit/circuit-json-schematic-placement-analysis": "github:tscircuit/circuit-json-schematic-placement-analysis#c7cfc20927dc5e24414a669e7bcfdecd83504f3e",
14
+ "@tscircuit/circuit-json-schematic-placement-analysis": "github:tscircuit/circuit-json-schematic-placement-analysis#add7fd89b1edce7fda0471a173409b8118d2723c",
15
15
  "@tscircuit/fake-snippets": "^0.0.182",
16
16
  "@tscircuit/file-server": "^0.0.32",
17
17
  "@tscircuit/image-utils": "^0.0.3",