@tscircuit/cli 0.1.1813 → 0.1.1814

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
@@ -118529,7 +118529,7 @@ var package_default = {
118529
118529
  "@tscircuit/image-utils": "^0.0.8",
118530
118530
  "@tscircuit/krt-wasm": "^0.1.6",
118531
118531
  "@tscircuit/math-utils": "0.0.36",
118532
- "@tscircuit/props": "^0.0.592",
118532
+ "@tscircuit/props": "^0.0.612",
118533
118533
  "@tscircuit/runframe": "^0.0.2349",
118534
118534
  "@tscircuit/schematic-match-adapt": "^0.0.22",
118535
118535
  "@tscircuit/solver-utils": "0.0.16",
@@ -118543,14 +118543,14 @@ var package_default = {
118543
118543
  "@types/semver": "^7.5.8",
118544
118544
  "bun-match-svg": "^0.0.12",
118545
118545
  chokidar: "4.0.1",
118546
- "circuit-json": "^0.0.455",
118546
+ "circuit-json": "^0.0.464",
118547
118547
  "circuit-json-to-3d-png": "^0.0.6",
118548
118548
  "circuit-json-to-bom-csv": "^0.0.7",
118549
118549
  "circuit-json-to-connectivity-map": "^0.0.25",
118550
118550
  "circuit-json-to-footprinter": "^0.0.15",
118551
118551
  "circuit-json-to-gerber": "^0.0.83",
118552
118552
  "circuit-json-to-kicad": "0.0.157",
118553
- "circuit-json-to-pnp-csv": "^0.0.7",
118553
+ "circuit-json-to-pnp-csv": "^0.0.9",
118554
118554
  "circuit-json-to-readable-netlist": "^0.0.15",
118555
118555
  "circuit-json-to-spice": "^0.0.45",
118556
118556
  "circuit-json-to-step": "^0.0.38",
@@ -118595,7 +118595,7 @@ var package_default = {
118595
118595
  zod: "^3.23.8"
118596
118596
  },
118597
118597
  peerDependencies: {
118598
- "circuit-json": "^0.0.446",
118598
+ "circuit-json": "^0.0.464",
118599
118599
  tscircuit: "*"
118600
118600
  },
118601
118601
  bin: {
@@ -292605,15 +292605,141 @@ var registerDoctor = (program2) => {
292605
292605
  import fs61 from "node:fs";
292606
292606
  import path69 from "node:path";
292607
292607
  import { promisify as promisify3 } from "node:util";
292608
+
292609
+ // node_modules/circuit-json-to-bom-csv/dist/index.js
292610
+ var import_format_si_prefix = __toESM2(require_dist10(), 1);
292611
+ var import_papaparse = __toESM2(require_papaparse(), 1);
292612
+ var convertCircuitJsonToBomRows = async ({
292613
+ circuitJson,
292614
+ resolvePart
292615
+ }) => {
292616
+ const bom = [];
292617
+ for (const elm of circuitJson) {
292618
+ if (elm.type !== "pcb_component")
292619
+ continue;
292620
+ const source_component = circuitJson.find((e4) => e4.type === "source_component" && e4.source_component_id === elm.source_component_id);
292621
+ if (!source_component)
292622
+ continue;
292623
+ const part_info = await resolvePart?.({ pcb_component: elm, source_component }) ?? {};
292624
+ let comment2 = "";
292625
+ if (source_component.ftype === "simple_resistor")
292626
+ comment2 = si3(source_component.resistance);
292627
+ if (source_component.ftype === "simple_capacitor")
292628
+ comment2 = si3(source_component.capacitance);
292629
+ bom.push({
292630
+ designator: source_component.name ?? elm.pcb_component_id,
292631
+ comment: comment2,
292632
+ value: comment2,
292633
+ footprint: part_info.footprint || "",
292634
+ supplier_part_number_columns: part_info.supplier_part_number_columns ?? source_component.supplier_part_numbers ? convertSupplierPartNumbersIntoColumns(source_component.supplier_part_numbers) : undefined
292635
+ });
292636
+ }
292637
+ return bom;
292638
+ };
292639
+ function convertSupplierPartNumbersIntoColumns(supplier_part_numbers) {
292640
+ const supplier_part_number_columns = {};
292641
+ if (supplier_part_numbers?.jlcpcb) {
292642
+ supplier_part_number_columns["JLCPCB Part #"] = supplier_part_numbers.jlcpcb[0];
292643
+ }
292644
+ if (supplier_part_numbers?.lcsc) {
292645
+ supplier_part_number_columns["JLCPCB Part #"] = supplier_part_numbers.lcsc[0];
292646
+ }
292647
+ return supplier_part_number_columns;
292648
+ }
292649
+ function si3(v4) {
292650
+ if (v4 === null || v4 === undefined)
292651
+ return "";
292652
+ if (typeof v4 === "string")
292653
+ return v4;
292654
+ return import_format_si_prefix.formatSI(v4);
292655
+ }
292656
+ var convertBomRowsToCsv = (bom_rows) => {
292657
+ const csv_data = bom_rows.map((row) => {
292658
+ const supplier_part_number_columns = row.supplier_part_number_columns;
292659
+ const supplier_part_numbers = Object.values(supplier_part_number_columns || {}).join(", ");
292660
+ const extraColumns = Object.entries(row.extra_columns || {}).map(([key, value]) => `${key}: ${value}`).join(", ");
292661
+ return {
292662
+ Designator: row.designator,
292663
+ Comment: row.comment,
292664
+ Value: row.value,
292665
+ Footprint: row.footprint,
292666
+ ...supplier_part_number_columns
292667
+ };
292668
+ });
292669
+ const columnHeaders = [
292670
+ "Designator",
292671
+ "Comment",
292672
+ "Value",
292673
+ "Footprint"
292674
+ ];
292675
+ for (const row of csv_data) {
292676
+ for (const key in row) {
292677
+ if (!columnHeaders.includes(key)) {
292678
+ columnHeaders.push(key);
292679
+ }
292680
+ }
292681
+ }
292682
+ return import_papaparse.default.unparse(csv_data, { columns: columnHeaders });
292683
+ };
292684
+
292685
+ // lib/shared/export-snippet.ts
292686
+ init_dist();
292608
292687
  import { convertCircuitJsonToGltf as convertCircuitJsonToGltf4 } from "circuit-json-to-gltf";
292688
+
292689
+ // node_modules/circuit-json-to-pnp-csv/dist/index.js
292690
+ var import_papaparse2 = __toESM2(require_papaparse(), 1);
292691
+ import { su as su14 } from "@tscircuit/soup-util";
292692
+ import {
292693
+ getRotationBetweenPcbPin1Locations
292694
+ } from "circuit-json";
292695
+ var fixedDecimals = 3;
292696
+ var normalizeRotation = (rotation11) => (rotation11 % 360 + 360) % 360;
292697
+ var getPickAndPlaceRotation = (pcbComponent, supplier) => {
292698
+ if (!supplier || !pcbComponent.pin1_location)
292699
+ return pcbComponent.rotation;
292700
+ const supplierPin1Location = pcbComponent.supplier_pin1_location_map?.[supplier];
292701
+ if (!supplierPin1Location)
292702
+ return pcbComponent.rotation;
292703
+ const rotationAdjustment = getRotationBetweenPcbPin1Locations(supplierPin1Location, pcbComponent.pin1_location);
292704
+ if (rotationAdjustment === null)
292705
+ return pcbComponent.rotation;
292706
+ return normalizeRotation(pcbComponent.rotation + rotationAdjustment);
292707
+ };
292708
+ var convertCircuitJsonToPickAndPlaceRows = (circuitJson, opts = {}) => {
292709
+ const rows = [];
292710
+ for (const element of circuitJson) {
292711
+ if (element.type === "pcb_component") {
292712
+ const source_component = su14(circuitJson).source_component.get(element.source_component_id);
292713
+ if (!source_component)
292714
+ continue;
292715
+ rows.push({
292716
+ designator: source_component?.name ?? element.pcb_component_id,
292717
+ mid_x: element.center.x,
292718
+ mid_y: element.center.y * (opts.flip_y_axis ? -1 : 1),
292719
+ layer: element.layer,
292720
+ rotation: getPickAndPlaceRotation(element, opts.supplier)
292721
+ });
292722
+ }
292723
+ }
292724
+ return rows;
292725
+ };
292726
+ var convertCircuitJsonToPickAndPlaceCsv = (circuitJson, opts = {}) => import_papaparse2.default.unparse(convertCircuitJsonToPickAndPlaceRows(circuitJson, opts).map((row) => ({
292727
+ Designator: row.designator,
292728
+ "Mid X": row.mid_x.toFixed(fixedDecimals),
292729
+ "Mid Y": row.mid_y.toFixed(fixedDecimals),
292730
+ Layer: row.layer,
292731
+ Rotation: row.rotation
292732
+ })));
292733
+
292734
+ // lib/shared/export-snippet.ts
292609
292735
  import {
292736
+ convertCircuitJsonToAssemblySvg as convertCircuitJsonToAssemblySvg2,
292610
292737
  convertCircuitJsonToPcbSvg as convertCircuitJsonToPcbSvg6,
292611
- convertCircuitJsonToSchematicSvg as convertCircuitJsonToSchematicSvg4,
292612
- convertCircuitJsonToAssemblySvg as convertCircuitJsonToAssemblySvg2
292738
+ convertCircuitJsonToSchematicSvg as convertCircuitJsonToSchematicSvg4
292613
292739
  } from "circuit-to-svg";
292614
292740
 
292615
292741
  // node_modules/dsn-converter/dist/index.js
292616
- import { su as su14 } from "@tscircuit/soup-util";
292742
+ import { su as su16 } from "@tscircuit/soup-util";
292617
292743
  import { getBoundsFromPoints as getBoundsFromPoints6 } from "@tscircuit/math-utils";
292618
292744
  import { applyToPoint as applyToPoint31, scale as scale8 } from "transformation-matrix";
292619
292745
  import { su as su24 } from "@tscircuit/soup-util";
@@ -293022,8 +293148,8 @@ function processComponentsAndPads(componentGroups, circuitElements, pcb) {
293022
293148
  const { pcb_component_id, pcb_smtpads } = group;
293023
293149
  if (pcb_smtpads.length === 0)
293024
293150
  continue;
293025
- const pcbComponent = su14(circuitElements).pcb_component.list().find((e4) => e4.pcb_component_id === pcb_component_id);
293026
- const sourceComponent = su14(circuitElements).source_component.list().find((e4) => e4.source_component_id === pcbComponent?.source_component_id);
293151
+ const pcbComponent = su16(circuitElements).pcb_component.list().find((e4) => e4.pcb_component_id === pcb_component_id);
293152
+ const sourceComponent = su16(circuitElements).source_component.list().find((e4) => e4.source_component_id === pcbComponent?.source_component_id);
293027
293153
  const footprintName = getFootprintName(sourceComponent, pcbComponent);
293028
293154
  const componentName = sourceComponent?.name || "Unknown";
293029
293155
  const circuitSpaceCoordinates = applyToPoint31(transformMmToUm, pcbComponent.center);
@@ -293058,8 +293184,8 @@ function processComponentsAndPads(componentGroups, circuitElements, pcb) {
293058
293184
  outlines: [],
293059
293185
  pins: componentGroup.pcb_smtpads.map((pad2) => {
293060
293186
  const pcbComponent = circuitElements.find((e4) => e4.type === "pcb_component" && e4.source_component_id === firstComponent.sourceComponent?.source_component_id);
293061
- const pcbPort = su14(circuitElements).pcb_port.list().find((e4) => e4.pcb_port_id === pad2.pcb_port_id);
293062
- const sourcePort = su14(circuitElements).source_port.list().find((e4) => e4.source_port_id === pcbPort?.source_port_id);
293187
+ const pcbPort = su16(circuitElements).pcb_port.list().find((e4) => e4.pcb_port_id === pad2.pcb_port_id);
293188
+ const sourcePort = su16(circuitElements).source_port.list().find((e4) => e4.source_port_id === pcbPort?.source_port_id);
293063
293189
  return createPinForImage({
293064
293190
  pad: pad2,
293065
293191
  pcbComponent,
@@ -293920,115 +294046,6 @@ var debug102 = Debug10("dsn-converter:parse-dsn-to-dsn-json");
293920
294046
 
293921
294047
  // lib/shared/export-snippet.ts
293922
294048
  var import_jszip5 = __toESM2(require_lib4(), 1);
293923
- init_dist();
293924
-
293925
- // node_modules/circuit-json-to-bom-csv/dist/index.js
293926
- var import_format_si_prefix = __toESM2(require_dist10(), 1);
293927
- var import_papaparse = __toESM2(require_papaparse(), 1);
293928
- var convertCircuitJsonToBomRows = async ({
293929
- circuitJson,
293930
- resolvePart
293931
- }) => {
293932
- const bom = [];
293933
- for (const elm of circuitJson) {
293934
- if (elm.type !== "pcb_component")
293935
- continue;
293936
- const source_component = circuitJson.find((e4) => e4.type === "source_component" && e4.source_component_id === elm.source_component_id);
293937
- if (!source_component)
293938
- continue;
293939
- const part_info = await resolvePart?.({ pcb_component: elm, source_component }) ?? {};
293940
- let comment2 = "";
293941
- if (source_component.ftype === "simple_resistor")
293942
- comment2 = si3(source_component.resistance);
293943
- if (source_component.ftype === "simple_capacitor")
293944
- comment2 = si3(source_component.capacitance);
293945
- bom.push({
293946
- designator: source_component.name ?? elm.pcb_component_id,
293947
- comment: comment2,
293948
- value: comment2,
293949
- footprint: part_info.footprint || "",
293950
- supplier_part_number_columns: part_info.supplier_part_number_columns ?? source_component.supplier_part_numbers ? convertSupplierPartNumbersIntoColumns(source_component.supplier_part_numbers) : undefined
293951
- });
293952
- }
293953
- return bom;
293954
- };
293955
- function convertSupplierPartNumbersIntoColumns(supplier_part_numbers) {
293956
- const supplier_part_number_columns = {};
293957
- if (supplier_part_numbers?.jlcpcb) {
293958
- supplier_part_number_columns["JLCPCB Part #"] = supplier_part_numbers.jlcpcb[0];
293959
- }
293960
- if (supplier_part_numbers?.lcsc) {
293961
- supplier_part_number_columns["JLCPCB Part #"] = supplier_part_numbers.lcsc[0];
293962
- }
293963
- return supplier_part_number_columns;
293964
- }
293965
- function si3(v4) {
293966
- if (v4 === null || v4 === undefined)
293967
- return "";
293968
- if (typeof v4 === "string")
293969
- return v4;
293970
- return import_format_si_prefix.formatSI(v4);
293971
- }
293972
- var convertBomRowsToCsv = (bom_rows) => {
293973
- const csv_data = bom_rows.map((row) => {
293974
- const supplier_part_number_columns = row.supplier_part_number_columns;
293975
- const supplier_part_numbers = Object.values(supplier_part_number_columns || {}).join(", ");
293976
- const extraColumns = Object.entries(row.extra_columns || {}).map(([key, value]) => `${key}: ${value}`).join(", ");
293977
- return {
293978
- Designator: row.designator,
293979
- Comment: row.comment,
293980
- Value: row.value,
293981
- Footprint: row.footprint,
293982
- ...supplier_part_number_columns
293983
- };
293984
- });
293985
- const columnHeaders = [
293986
- "Designator",
293987
- "Comment",
293988
- "Value",
293989
- "Footprint"
293990
- ];
293991
- for (const row of csv_data) {
293992
- for (const key in row) {
293993
- if (!columnHeaders.includes(key)) {
293994
- columnHeaders.push(key);
293995
- }
293996
- }
293997
- }
293998
- return import_papaparse.default.unparse(csv_data, { columns: columnHeaders });
293999
- };
294000
-
294001
- // node_modules/circuit-json-to-pnp-csv/dist/index.js
294002
- var import_papaparse2 = __toESM2(require_papaparse(), 1);
294003
- import"circuit-json";
294004
- import { su as su16 } from "@tscircuit/soup-util";
294005
- var fixedDecimals = 3;
294006
- var convertCircuitJsonToPickAndPlaceRows = (circuitJson, opts = {}) => {
294007
- opts.flip_y_axis ??= false;
294008
- const rows = [];
294009
- for (const element of circuitJson) {
294010
- if (element.type === "pcb_component") {
294011
- const source_component = su16(circuitJson).source_component.get(element.source_component_id);
294012
- rows.push({
294013
- designator: source_component?.name ?? element.pcb_component_id,
294014
- mid_x: element.center.x,
294015
- mid_y: element.center.y * (opts.flip_y_axis ? -1 : 1),
294016
- layer: element.layer,
294017
- rotation: element.rotation
294018
- });
294019
- }
294020
- }
294021
- return rows;
294022
- };
294023
- var convertCircuitJsonToPickAndPlaceCsv = (circuitJson) => import_papaparse2.default.unparse(convertCircuitJsonToPickAndPlaceRows(circuitJson).map((row) => ({
294024
- Designator: row.designator,
294025
- "Mid X": row.mid_x.toFixed(fixedDecimals),
294026
- "Mid Y": row.mid_y.toFixed(fixedDecimals),
294027
- Layer: row.layer,
294028
- Rotation: row.rotation
294029
- })));
294030
-
294031
- // lib/shared/export-snippet.ts
294032
294049
  var writeFileAsync = promisify3(fs61.writeFile);
294033
294050
  var ALLOWED_EXPORT_FORMATS = [
294034
294051
  "json",
@@ -294128,10 +294145,15 @@ var exportSnippet = async ({
294128
294145
  return onExit(1);
294129
294146
  }
294130
294147
  } else {
294131
- const circuitData = await getOrGenerateCircuitJson({
294148
+ const isJlcpcbFabricationExport = format === "gerbers";
294149
+ const fabricationPlatformConfig = isJlcpcbFabricationExport ? getPlatformConfigWithCliDefaults(mergePlatformConfigs(platformConfig2, {
294150
+ enablePartOrientationAnalysis: true
294151
+ })) : platformConfig2;
294152
+ const generateCircuitData = isJlcpcbFabricationExport ? generateCircuitJson : getOrGenerateCircuitJson;
294153
+ const circuitData = await generateCircuitData({
294132
294154
  filePath,
294133
294155
  saveToFile: format === "circuit-json",
294134
- platformConfig: platformConfig2
294156
+ platformConfig: fabricationPlatformConfig
294135
294157
  }).catch((err2) => {
294136
294158
  onError(`Error generating circuit JSON: ${err2}`);
294137
294159
  return null;
@@ -294242,7 +294264,9 @@ var exportSnippet = async ({
294242
294264
  const bomRows = await convertCircuitJsonToBomRows({ circuitJson });
294243
294265
  const bomCsv = await convertBomRowsToCsv(bomRows);
294244
294266
  zip.file("bom.csv", bomCsv);
294245
- const pnpCsv = await convertCircuitJsonToPickAndPlaceCsv(circuitJson);
294267
+ const pnpCsv = await convertCircuitJsonToPickAndPlaceCsv(circuitJson, {
294268
+ supplier: "jlcpcb"
294269
+ });
294246
294270
  zip.file("pick_and_place.csv", pnpCsv);
294247
294271
  outputContent = await zip.generateAsync({ type: "nodebuffer" });
294248
294272
  break;
package/dist/lib/index.js CHANGED
@@ -65780,7 +65780,7 @@ var package_default = {
65780
65780
  "@tscircuit/image-utils": "^0.0.8",
65781
65781
  "@tscircuit/krt-wasm": "^0.1.6",
65782
65782
  "@tscircuit/math-utils": "0.0.36",
65783
- "@tscircuit/props": "^0.0.592",
65783
+ "@tscircuit/props": "^0.0.612",
65784
65784
  "@tscircuit/runframe": "^0.0.2349",
65785
65785
  "@tscircuit/schematic-match-adapt": "^0.0.22",
65786
65786
  "@tscircuit/solver-utils": "0.0.16",
@@ -65794,14 +65794,14 @@ var package_default = {
65794
65794
  "@types/semver": "^7.5.8",
65795
65795
  "bun-match-svg": "^0.0.12",
65796
65796
  chokidar: "4.0.1",
65797
- "circuit-json": "^0.0.455",
65797
+ "circuit-json": "^0.0.464",
65798
65798
  "circuit-json-to-3d-png": "^0.0.6",
65799
65799
  "circuit-json-to-bom-csv": "^0.0.7",
65800
65800
  "circuit-json-to-connectivity-map": "^0.0.25",
65801
65801
  "circuit-json-to-footprinter": "^0.0.15",
65802
65802
  "circuit-json-to-gerber": "^0.0.83",
65803
65803
  "circuit-json-to-kicad": "0.0.157",
65804
- "circuit-json-to-pnp-csv": "^0.0.7",
65804
+ "circuit-json-to-pnp-csv": "^0.0.9",
65805
65805
  "circuit-json-to-readable-netlist": "^0.0.15",
65806
65806
  "circuit-json-to-spice": "^0.0.45",
65807
65807
  "circuit-json-to-step": "^0.0.38",
@@ -65846,7 +65846,7 @@ var package_default = {
65846
65846
  zod: "^3.23.8"
65847
65847
  },
65848
65848
  peerDependencies: {
65849
- "circuit-json": "^0.0.446",
65849
+ "circuit-json": "^0.0.464",
65850
65850
  tscircuit: "*"
65851
65851
  },
65852
65852
  bin: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tscircuit/cli",
3
- "version": "0.1.1813",
3
+ "version": "0.1.1814",
4
4
  "main": "dist/cli/main.js",
5
5
  "exports": {
6
6
  ".": "./dist/cli/main.js",
@@ -20,7 +20,7 @@
20
20
  "@tscircuit/image-utils": "^0.0.8",
21
21
  "@tscircuit/krt-wasm": "^0.1.6",
22
22
  "@tscircuit/math-utils": "0.0.36",
23
- "@tscircuit/props": "^0.0.592",
23
+ "@tscircuit/props": "^0.0.612",
24
24
  "@tscircuit/runframe": "^0.0.2349",
25
25
  "@tscircuit/schematic-match-adapt": "^0.0.22",
26
26
  "@tscircuit/solver-utils": "0.0.16",
@@ -34,14 +34,14 @@
34
34
  "@types/semver": "^7.5.8",
35
35
  "bun-match-svg": "^0.0.12",
36
36
  "chokidar": "4.0.1",
37
- "circuit-json": "^0.0.455",
37
+ "circuit-json": "^0.0.464",
38
38
  "circuit-json-to-3d-png": "^0.0.6",
39
39
  "circuit-json-to-bom-csv": "^0.0.7",
40
40
  "circuit-json-to-connectivity-map": "^0.0.25",
41
41
  "circuit-json-to-footprinter": "^0.0.15",
42
42
  "circuit-json-to-gerber": "^0.0.83",
43
43
  "circuit-json-to-kicad": "0.0.157",
44
- "circuit-json-to-pnp-csv": "^0.0.7",
44
+ "circuit-json-to-pnp-csv": "^0.0.9",
45
45
  "circuit-json-to-readable-netlist": "^0.0.15",
46
46
  "circuit-json-to-spice": "^0.0.45",
47
47
  "circuit-json-to-step": "^0.0.38",
@@ -86,7 +86,7 @@
86
86
  "zod": "^3.23.8"
87
87
  },
88
88
  "peerDependencies": {
89
- "circuit-json": "^0.0.446",
89
+ "circuit-json": "^0.0.464",
90
90
  "tscircuit": "*"
91
91
  },
92
92
  "bin": {