@tscircuit/cli 0.1.1590 → 0.1.1591

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
@@ -93628,7 +93628,7 @@ var import_perfect_cli = __toESM2(require_dist2(), 1);
93628
93628
  // lib/getVersion.ts
93629
93629
  import { createRequire as createRequire2 } from "node:module";
93630
93630
  // package.json
93631
- var version = "0.1.1588";
93631
+ var version = "0.1.1590";
93632
93632
  var package_default = {
93633
93633
  name: "@tscircuit/cli",
93634
93634
  version,
@@ -93672,7 +93672,7 @@ var package_default = {
93672
93672
  "circuit-json-to-readable-netlist": "^0.0.15",
93673
93673
  "circuit-json-to-spice": "^0.0.40",
93674
93674
  "circuit-json-to-step": "^0.0.36",
93675
- "circuit-json-to-tscircuit": "^0.0.35",
93675
+ "circuit-json-to-tscircuit": "^0.0.40",
93676
93676
  "circuit-json-trace-length-analysis": "github:tscircuit/circuit-json-trace-length-analysis#2b44792a40df0ca83b6bfb6ac95ed5e35e7168b8",
93677
93677
  commander: "^14.0.0",
93678
93678
  conf: "^13.1.0",
@@ -258547,9 +258547,6 @@ import fs46 from "node:fs/promises";
258547
258547
  import path49 from "node:path";
258548
258548
  import { KicadFootprintToCircuitJsonConverter } from "kicad-to-circuit-json";
258549
258549
 
258550
- // node_modules/circuit-json-to-tscircuit/dist/chunk-WC7XDXUV.js
258551
- import { su as su6 } from "@tscircuit/soup-util";
258552
-
258553
258550
  // node_modules/@tscircuit/mm/dist/index.js
258554
258551
  var unitToMm2 = {
258555
258552
  in: 25.4,
@@ -258575,7 +258572,9 @@ var mmStr = (n3) => {
258575
258572
  return `${mm3(n3)}mm`;
258576
258573
  };
258577
258574
 
258578
- // node_modules/circuit-json-to-tscircuit/dist/chunk-WC7XDXUV.js
258575
+ // node_modules/circuit-json-to-tscircuit/dist/chunk-UHPKLBYL.js
258576
+ import { su as su12 } from "@tscircuit/soup-util";
258577
+ import { su as su6 } from "@tscircuit/soup-util";
258579
258578
  import { su as su23 } from "@tscircuit/soup-util";
258580
258579
  import { su as su33 } from "@tscircuit/soup-util";
258581
258580
  import { su as su42 } from "@tscircuit/soup-util";
@@ -258586,7 +258585,7 @@ import { su as su8 } from "@tscircuit/soup-util";
258586
258585
  import { su as su9 } from "@tscircuit/soup-util";
258587
258586
  import { su as su10 } from "@tscircuit/soup-util";
258588
258587
  import { su as su11 } from "@tscircuit/soup-util";
258589
- import { su as su12 } from "@tscircuit/soup-util";
258588
+ import { su as su13 } from "@tscircuit/soup-util";
258590
258589
  var escapeJsxText = (value) => String(value ?? "").replace(/"/g, "\\\"");
258591
258590
  var formatMm = (value) => mmStr(value ?? 0);
258592
258591
  var formatOptionalMmAttr = (attrName, value) => {
@@ -259016,16 +259015,69 @@ var convertSmtPads = (circuitJson) => {
259016
259015
  const smtPads = su11(circuitJson).pcb_smtpad.list();
259017
259016
  const elementStrings = [];
259018
259017
  for (const smtPad of smtPads) {
259018
+ const commonAttrs = [];
259019
+ if (smtPad.port_hints !== undefined) {
259020
+ commonAttrs.push(`portHints={${JSON.stringify(smtPad.port_hints)}}`);
259021
+ }
259022
+ if ("x" in smtPad && smtPad.x !== undefined) {
259023
+ commonAttrs.push(`pcbX="${mmStr(smtPad.x)}"`);
259024
+ }
259025
+ if ("y" in smtPad && smtPad.y !== undefined) {
259026
+ commonAttrs.push(`pcbY="${mmStr(smtPad.y)}"`);
259027
+ }
259028
+ if (smtPad.layer !== undefined) {
259029
+ commonAttrs.push(`layer="${smtPad.layer}"`);
259030
+ }
259031
+ if (smtPad.is_covered_with_solder_mask !== undefined) {
259032
+ commonAttrs.push(`coveredWithSolderMask={${smtPad.is_covered_with_solder_mask}}`);
259033
+ }
259034
+ if (smtPad.soldermask_margin !== undefined) {
259035
+ commonAttrs.push(`solderMaskMargin="${mmStr(smtPad.soldermask_margin)}"`);
259036
+ }
259019
259037
  if (smtPad.shape === "circle") {
259020
- elementStrings.push(`<smtpad portHints={${JSON.stringify(smtPad.port_hints)}} pcbX="${mmStr(smtPad.x)}" pcbY="${mmStr(smtPad.y)}" radius="${mmStr(smtPad.radius)}" shape="circle" />`);
259038
+ elementStrings.push(`<smtpad ${commonAttrs.join(" ")} radius="${mmStr(smtPad.radius ?? 0)}" shape="circle" />`);
259021
259039
  } else if (smtPad.shape === "rect") {
259022
- elementStrings.push(`<smtpad portHints={${JSON.stringify(smtPad.port_hints)}} pcbX="${mmStr(smtPad.x)}" pcbY="${mmStr(smtPad.y)}" width="${mmStr(smtPad.width)}" height="${mmStr(smtPad.height)}" shape="rect" />`);
259040
+ if (smtPad.rect_border_radius !== undefined) {
259041
+ commonAttrs.push(`rectBorderRadius="${mmStr(smtPad.rect_border_radius)}"`);
259042
+ }
259043
+ if (smtPad.corner_radius !== undefined) {
259044
+ commonAttrs.push(`cornerRadius="${mmStr(smtPad.corner_radius)}"`);
259045
+ }
259046
+ if (smtPad.soldermask_margin_left !== undefined) {
259047
+ commonAttrs.push(`solderMaskMarginLeft="${mmStr(smtPad.soldermask_margin_left)}"`);
259048
+ }
259049
+ if (smtPad.soldermask_margin_top !== undefined) {
259050
+ commonAttrs.push(`solderMaskMarginTop="${mmStr(smtPad.soldermask_margin_top)}"`);
259051
+ }
259052
+ if (smtPad.soldermask_margin_right !== undefined) {
259053
+ commonAttrs.push(`solderMaskMarginRight="${mmStr(smtPad.soldermask_margin_right)}"`);
259054
+ }
259055
+ if (smtPad.soldermask_margin_bottom !== undefined) {
259056
+ commonAttrs.push(`solderMaskMarginBottom="${mmStr(smtPad.soldermask_margin_bottom)}"`);
259057
+ }
259058
+ elementStrings.push(`<smtpad ${commonAttrs.join(" ")} width="${mmStr(smtPad.width ?? 0)}" height="${mmStr(smtPad.height ?? 0)}" shape="rect" />`);
259023
259059
  } else if (smtPad.shape === "pill") {
259024
- elementStrings.push(`<smtpad portHints={${JSON.stringify(smtPad.port_hints)}} pcbX="${mmStr(smtPad.x)}" pcbY="${mmStr(smtPad.y)}" width="${mmStr(smtPad.width)}" height="${mmStr(smtPad.height)}" radius="${mmStr(smtPad.radius)}" shape="pill" />`);
259060
+ elementStrings.push(`<smtpad ${commonAttrs.join(" ")} width="${mmStr(smtPad.width ?? 0)}" height="${mmStr(smtPad.height ?? 0)}" radius="${mmStr(smtPad.radius ?? 0)}" shape="pill" />`);
259025
259061
  } else if (smtPad.shape === "polygon") {
259026
- elementStrings.push(`<smtpad portHints={${JSON.stringify(smtPad.port_hints)}} shape="polygon" points={${JSON.stringify(smtPad.points)}} />`);
259062
+ elementStrings.push(`<smtpad ${commonAttrs.join(" ")} shape="polygon" points={${JSON.stringify(smtPad.points)}} />`);
259027
259063
  } else if (smtPad.shape === "rotated_rect") {
259028
- elementStrings.push(`<smtpad portHints={${JSON.stringify(smtPad.port_hints)}} pcbX="${mmStr(smtPad.x)}" pcbY="${mmStr(smtPad.y)}" width="${mmStr(smtPad.width)}" height="${mmStr(smtPad.height)}" ccwRotation={${smtPad.ccw_rotation}} shape="rotated_rect" />`);
259064
+ const cornerRadius = smtPad.corner_radius ?? smtPad.rect_border_radius ?? undefined;
259065
+ if (cornerRadius !== undefined) {
259066
+ commonAttrs.push(`cornerRadius="${mmStr(cornerRadius)}"`);
259067
+ }
259068
+ if (smtPad.soldermask_margin_left !== undefined) {
259069
+ commonAttrs.push(`solderMaskMarginLeft="${mmStr(smtPad.soldermask_margin_left)}"`);
259070
+ }
259071
+ if (smtPad.soldermask_margin_top !== undefined) {
259072
+ commonAttrs.push(`solderMaskMarginTop="${mmStr(smtPad.soldermask_margin_top)}"`);
259073
+ }
259074
+ if (smtPad.soldermask_margin_right !== undefined) {
259075
+ commonAttrs.push(`solderMaskMarginRight="${mmStr(smtPad.soldermask_margin_right)}"`);
259076
+ }
259077
+ if (smtPad.soldermask_margin_bottom !== undefined) {
259078
+ commonAttrs.push(`solderMaskMarginBottom="${mmStr(smtPad.soldermask_margin_bottom)}"`);
259079
+ }
259080
+ elementStrings.push(`<smtpad ${commonAttrs.join(" ")} width="${mmStr(smtPad.width ?? 0)}" height="${mmStr(smtPad.height ?? 0)}"${formatPcbRotationAttr(smtPad.ccw_rotation)} shape="rotated_rect" />`);
259029
259081
  }
259030
259082
  }
259031
259083
  return elementStrings;
@@ -259055,17 +259107,65 @@ var generateFootprintTsx = (circuitJson) => {
259055
259107
  </footprint>
259056
259108
  `.trim();
259057
259109
  };
259110
+ var getBoardUsingTemplate = ({ circuitJson }) => {
259111
+ const pcbBoard = su12(circuitJson).pcb_board.list()[0];
259112
+ const boardProps2 = [];
259113
+ if (pcbBoard) {
259114
+ if (pcbBoard.width !== undefined) {
259115
+ boardProps2.push(`width="${mmStr(pcbBoard.width)}"`);
259116
+ }
259117
+ if (pcbBoard.height !== undefined) {
259118
+ boardProps2.push(`height="${mmStr(pcbBoard.height)}"`);
259119
+ }
259120
+ if (pcbBoard.outline && pcbBoard.outline.length > 0) {
259121
+ const points = pcbBoard.outline.map((p3) => `{ x: ${p3.x}, y: ${p3.y} }`).join(", ");
259122
+ boardProps2.push(`outline={[${points}]}`);
259123
+ }
259124
+ if (pcbBoard.thickness !== undefined) {
259125
+ boardProps2.push(`thickness="${mmStr(pcbBoard.thickness)}"`);
259126
+ }
259127
+ if (pcbBoard.num_layers !== undefined) {
259128
+ boardProps2.push(`layers={${pcbBoard.num_layers}}`);
259129
+ }
259130
+ if (pcbBoard.material !== undefined) {
259131
+ boardProps2.push(`material="${pcbBoard.material}"`);
259132
+ }
259133
+ if (pcbBoard.solder_mask_color !== undefined) {
259134
+ boardProps2.push(`solderMaskColor="${pcbBoard.solder_mask_color}"`);
259135
+ }
259136
+ if (pcbBoard.silkscreen_color !== undefined) {
259137
+ boardProps2.push(`silkscreenColor="${pcbBoard.silkscreen_color}"`);
259138
+ }
259139
+ if (pcbBoard.anchor_position !== undefined) {
259140
+ boardProps2.push(`boardAnchorPosition={{ x: ${pcbBoard.anchor_position.x}, y: ${pcbBoard.anchor_position.y} }}`);
259141
+ }
259142
+ if (pcbBoard.anchor_alignment !== undefined) {
259143
+ boardProps2.push(`boardAnchorAlignment="${pcbBoard.anchor_alignment}"`);
259144
+ }
259145
+ }
259146
+ const boardPropsStr = boardProps2.join(" ");
259147
+ const footprintTsx = generateFootprintTsx(circuitJson);
259148
+ const children = footprintTsx ? `<chip footprint={${footprintTsx}} />` : "";
259149
+ return `
259150
+ export default () => (
259151
+ <board${boardPropsStr ? ` ${boardPropsStr}` : ""}>
259152
+ ${children}
259153
+ </board>
259154
+ )
259155
+ `.replace(/\n\s*\n/g, `
259156
+ `).trim();
259157
+ };
259058
259158
  var escapeJsxText2 = (text) => text.replace(/\\/g, "\\\\").replace(/"/g, "\\\"");
259059
259159
  var generateSymbolTsx = (circuitJson) => {
259060
- const schematicArcs = su12(circuitJson).schematic_arc.list();
259061
- const schematicLines = su12(circuitJson).schematic_line.list();
259062
- const schematicPaths = su12(circuitJson).schematic_path.list();
259063
- const schematicTexts = su12(circuitJson).schematic_text.list();
259064
- const schematicCircles = su12(circuitJson).schematic_circle.list();
259065
- const schematicBoxes = su12(circuitJson).schematic_box.list();
259066
- const schematicRects = su12(circuitJson).schematic_rect.list();
259067
- const schematicTables = su12(circuitJson).schematic_table.list();
259068
- const schematicTableCells = su12(circuitJson).schematic_table_cell.list();
259160
+ const schematicArcs = su13(circuitJson).schematic_arc.list();
259161
+ const schematicLines = su13(circuitJson).schematic_line.list();
259162
+ const schematicPaths = su13(circuitJson).schematic_path.list();
259163
+ const schematicTexts = su13(circuitJson).schematic_text.list();
259164
+ const schematicCircles = su13(circuitJson).schematic_circle.list();
259165
+ const schematicBoxes = su13(circuitJson).schematic_box.list();
259166
+ const schematicRects = su13(circuitJson).schematic_rect.list();
259167
+ const schematicTables = su13(circuitJson).schematic_table.list();
259168
+ const schematicTableCells = su13(circuitJson).schematic_table_cell.list();
259069
259169
  const elementStrings = [];
259070
259170
  for (const arc2 of schematicArcs) {
259071
259171
  const center2 = arc2.center ?? { x: 0, y: 0 };
@@ -259287,6 +259387,10 @@ ${pinLabels ? `const pinLabels = ${JSON.stringify(pinLabels, null, " ")} as con
259287
259387
  `).trim();
259288
259388
  };
259289
259389
  var convertCircuitJsonToTscircuit = (circuitJson, opts) => {
259390
+ const hasBoard = circuitJson.some((el3) => el3.type === "pcb_board");
259391
+ if (hasBoard) {
259392
+ return getBoardUsingTemplate({ circuitJson });
259393
+ }
259290
259394
  return getComponentUsingTemplate({
259291
259395
  circuitJson,
259292
259396
  ...opts
@@ -264160,7 +264264,7 @@ import {
264160
264264
  } from "circuit-to-svg";
264161
264265
 
264162
264266
  // node_modules/dsn-converter/dist/index.js
264163
- import { su as su13 } from "@tscircuit/soup-util";
264267
+ import { su as su14 } from "@tscircuit/soup-util";
264164
264268
  import { getBoundsFromPoints as getBoundsFromPoints3 } from "@tscircuit/math-utils";
264165
264269
  import { applyToPoint as applyToPoint26, scale as scale7 } from "transformation-matrix";
264166
264270
  import { su as su24 } from "@tscircuit/soup-util";
@@ -264569,8 +264673,8 @@ function processComponentsAndPads(componentGroups, circuitElements, pcb) {
264569
264673
  const { pcb_component_id, pcb_smtpads } = group;
264570
264674
  if (pcb_smtpads.length === 0)
264571
264675
  continue;
264572
- const pcbComponent = su13(circuitElements).pcb_component.list().find((e4) => e4.pcb_component_id === pcb_component_id);
264573
- const sourceComponent = su13(circuitElements).source_component.list().find((e4) => e4.source_component_id === pcbComponent?.source_component_id);
264676
+ const pcbComponent = su14(circuitElements).pcb_component.list().find((e4) => e4.pcb_component_id === pcb_component_id);
264677
+ const sourceComponent = su14(circuitElements).source_component.list().find((e4) => e4.source_component_id === pcbComponent?.source_component_id);
264574
264678
  const footprintName = getFootprintName(sourceComponent, pcbComponent);
264575
264679
  const componentName = sourceComponent?.name || "Unknown";
264576
264680
  const circuitSpaceCoordinates = applyToPoint26(transformMmToUm, pcbComponent.center);
@@ -264605,8 +264709,8 @@ function processComponentsAndPads(componentGroups, circuitElements, pcb) {
264605
264709
  outlines: [],
264606
264710
  pins: componentGroup.pcb_smtpads.map((pad2) => {
264607
264711
  const pcbComponent = circuitElements.find((e4) => e4.type === "pcb_component" && e4.source_component_id === firstComponent.sourceComponent?.source_component_id);
264608
- const pcbPort = su13(circuitElements).pcb_port.list().find((e4) => e4.pcb_port_id === pad2.pcb_port_id);
264609
- const sourcePort = su13(circuitElements).source_port.list().find((e4) => e4.source_port_id === pcbPort?.source_port_id);
264712
+ const pcbPort = su14(circuitElements).pcb_port.list().find((e4) => e4.pcb_port_id === pad2.pcb_port_id);
264713
+ const sourcePort = su14(circuitElements).source_port.list().find((e4) => e4.source_port_id === pcbPort?.source_port_id);
264610
264714
  return createPinForImage({
264611
264715
  pad: pad2,
264612
264716
  pcbComponent,
@@ -267655,14 +267759,14 @@ var convertBomRowsToCsv = (bom_rows) => {
267655
267759
  // node_modules/circuit-json-to-pnp-csv/dist/index.js
267656
267760
  var import_papaparse2 = __toESM2(require_papaparse(), 1);
267657
267761
  import"circuit-json";
267658
- import { su as su15 } from "@tscircuit/soup-util";
267762
+ import { su as su16 } from "@tscircuit/soup-util";
267659
267763
  var fixedDecimals = 3;
267660
267764
  var convertCircuitJsonToPickAndPlaceRows = (circuitJson, opts = {}) => {
267661
267765
  opts.flip_y_axis ??= false;
267662
267766
  const rows = [];
267663
267767
  for (const element of circuitJson) {
267664
267768
  if (element.type === "pcb_component") {
267665
- const source_component = su15(circuitJson).source_component.get(element.source_component_id);
267769
+ const source_component = su16(circuitJson).source_component.get(element.source_component_id);
267666
267770
  rows.push({
267667
267771
  designator: source_component?.name ?? element.pcb_component_id,
267668
267772
  mid_x: element.center.x,
@@ -275872,7 +275976,7 @@ var cju8 = (circuitJsonInput, options = {}) => {
275872
275976
  return su25;
275873
275977
  };
275874
275978
  cju8.unparsed = cju8;
275875
- var su16 = cju8;
275979
+ var su17 = cju8;
275876
275980
  function createIdKey2(element) {
275877
275981
  const type = element.type;
275878
275982
  return `${type}:${element[`${type}_id`]}`;
@@ -278296,13 +278400,13 @@ var mapPortHints = (portHints2, portHintsMap) => {
278296
278400
  return portHints2.flatMap((hint) => portHintsMap[hint] ?? [hint]);
278297
278401
  };
278298
278402
  var generateFootprintTsx2 = (circuitJson, options = {}) => {
278299
- const holes = su16(circuitJson).pcb_hole.list();
278300
- const platedHoles = su16(circuitJson).pcb_plated_hole.list();
278301
- const smtPads = su16(circuitJson).pcb_smtpad.list();
278302
- const vias = su16(circuitJson).pcb_via.list();
278303
- const silkscreenPaths = su16(circuitJson).pcb_silkscreen_path.list();
278304
- const silkscreenTexts = su16(circuitJson).pcb_silkscreen_text.list();
278305
- const courtyardOutlines = su16(circuitJson).pcb_courtyard_outline.list();
278403
+ const holes = su17(circuitJson).pcb_hole.list();
278404
+ const platedHoles = su17(circuitJson).pcb_plated_hole.list();
278405
+ const smtPads = su17(circuitJson).pcb_smtpad.list();
278406
+ const vias = su17(circuitJson).pcb_via.list();
278407
+ const silkscreenPaths = su17(circuitJson).pcb_silkscreen_path.list();
278408
+ const silkscreenTexts = su17(circuitJson).pcb_silkscreen_text.list();
278409
+ const courtyardOutlines = su17(circuitJson).pcb_courtyard_outline.list();
278306
278410
  const elementStrings = [];
278307
278411
  for (const hole of holes) {
278308
278412
  if (hole.hole_shape === "circle") {
@@ -278547,14 +278651,14 @@ var convertBetterEasyToTsx = async ({
278547
278651
  cadModelBounds: cadPlacement?.bounds,
278548
278652
  showDesignator: true
278549
278653
  });
278550
- const [cadComponent] = su16(circuitJson).cad_component.list();
278654
+ const [cadComponent] = su17(circuitJson).cad_component.list();
278551
278655
  if (cadComponent) {
278552
278656
  cadComponent.position.x = 0;
278553
278657
  cadComponent.position.y = 0;
278554
278658
  }
278555
278659
  const rawPn = betterEasy.dataStr.head.c_para["Manufacturer Part"];
278556
278660
  const pn3 = rawPn ? normalizeManufacturerPartNumber(rawPn) : "unknown";
278557
- const sourcePorts = su16(circuitJson).source_port.list();
278661
+ const sourcePorts = su17(circuitJson).source_port.list();
278558
278662
  const pinLabels = {};
278559
278663
  const sortedPorts = sourcePorts.sort((a3, b3) => {
278560
278664
  const aNum = Number.parseInt(a3.name.replace("pin", ""));
package/dist/lib/index.js CHANGED
@@ -65811,7 +65811,7 @@ var getNodeHandler = (winterSpec, { port, middleware = [] }) => {
65811
65811
  }));
65812
65812
  };
65813
65813
  // package.json
65814
- var version = "0.1.1588";
65814
+ var version = "0.1.1590";
65815
65815
  var package_default = {
65816
65816
  name: "@tscircuit/cli",
65817
65817
  version,
@@ -65855,7 +65855,7 @@ var package_default = {
65855
65855
  "circuit-json-to-readable-netlist": "^0.0.15",
65856
65856
  "circuit-json-to-spice": "^0.0.40",
65857
65857
  "circuit-json-to-step": "^0.0.36",
65858
- "circuit-json-to-tscircuit": "^0.0.35",
65858
+ "circuit-json-to-tscircuit": "^0.0.40",
65859
65859
  "circuit-json-trace-length-analysis": "github:tscircuit/circuit-json-trace-length-analysis#2b44792a40df0ca83b6bfb6ac95ed5e35e7168b8",
65860
65860
  commander: "^14.0.0",
65861
65861
  conf: "^13.1.0",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tscircuit/cli",
3
- "version": "0.1.1590",
3
+ "version": "0.1.1591",
4
4
  "main": "dist/cli/main.js",
5
5
  "exports": {
6
6
  ".": "./dist/cli/main.js",
@@ -41,7 +41,7 @@
41
41
  "circuit-json-to-readable-netlist": "^0.0.15",
42
42
  "circuit-json-to-spice": "^0.0.40",
43
43
  "circuit-json-to-step": "^0.0.36",
44
- "circuit-json-to-tscircuit": "^0.0.35",
44
+ "circuit-json-to-tscircuit": "^0.0.40",
45
45
  "circuit-json-trace-length-analysis": "github:tscircuit/circuit-json-trace-length-analysis#2b44792a40df0ca83b6bfb6ac95ed5e35e7168b8",
46
46
  "commander": "^14.0.0",
47
47
  "conf": "^13.1.0",