@tscircuit/cli 0.1.2348 → 0.1.2350

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
@@ -1,4 +1,4 @@
1
1
  [diffend] Oversized file quarantined before diffing.
2
2
  name: package/dist/cli/main.js
3
- size: 46851561 bytes
4
- sha256: 1806ec974815c867031d068c0b7255678fcd64b5237107d21c088f7aeae9db22
3
+ size: 46855996 bytes
4
+ sha256: 3e89a23a4e2d130a6b63c7dd3df361ec747b0f26f45000391dc7d6b49afa65d7
package/dist/lib/index.js CHANGED
@@ -69121,7 +69121,7 @@ var getNodeHandler = (winterSpec, { port, middleware = [] }) => {
69121
69121
  }));
69122
69122
  };
69123
69123
  // package.json
69124
- var version = "0.1.2347";
69124
+ var version = "0.1.2349";
69125
69125
  var package_default = {
69126
69126
  name: "@tscircuit/cli",
69127
69127
  version,
@@ -69175,7 +69175,7 @@ var package_default = {
69175
69175
  "circuit-json-to-fdm-component-box": "^0.0.2",
69176
69176
  "circuit-json-to-footprinter": "^0.0.59",
69177
69177
  "circuit-json-to-gerber": "^0.0.112",
69178
- "circuit-json-to-kicad": "0.0.230",
69178
+ "circuit-json-to-kicad": "0.0.235",
69179
69179
  "circuit-json-to-pnp-csv": "^0.0.18",
69180
69180
  "circuit-json-to-readable-netlist": "^0.0.15",
69181
69181
  "circuit-json-to-spice": "^0.0.45",
@@ -69200,7 +69200,7 @@ var package_default = {
69200
69200
  jszip: "^3.10.1",
69201
69201
  "jwt-decode": "^4.0.0",
69202
69202
  "kicad-to-circuit-json": "^0.0.113",
69203
- kicadts: "^0.0.47",
69203
+ kicadts: "^0.0.58",
69204
69204
  kleur: "^4.1.5",
69205
69205
  ky: "^1.7.4",
69206
69206
  "make-vfs": "^1.0.15",
@@ -72666,6 +72666,7 @@ import { Segment, SegmentNet } from "kicadts";
72666
72666
  import { applyToPoint as applyToPoint24 } from "transformation-matrix";
72667
72667
  import { Via, ViaNet } from "kicadts";
72668
72668
  import { applyToPoint as applyToPoint25 } from "transformation-matrix";
72669
+ import { ViaTenting } from "kicadts";
72669
72670
  import { Footprint as Footprint4 } from "kicadts";
72670
72671
  import { applyToPoint as applyToPoint26 } from "transformation-matrix";
72671
72672
  import { GrLine } from "kicadts";
@@ -73758,6 +73759,9 @@ function addSymbolProperties({
73758
73759
  }));
73759
73760
  }
73760
73761
  }
73762
+ function getPhysicalPinName(sourcePort) {
73763
+ return sourcePort && sourcePort.pin_number === undefined && /^[A-Z]+[1-9]\d*$/.test(sourcePort.name) ? sourcePort.name : undefined;
73764
+ }
73761
73765
  function calculatePinPosition({
73762
73766
  port,
73763
73767
  center,
@@ -73956,8 +73960,10 @@ function createPinSubsymbol({
73956
73960
  numFont.size = { height: 1.27, width: 1.27 };
73957
73961
  const numEffects = new TextEffects4({ font: numFont });
73958
73962
  const pinNum = port.pinNumber?.toString() ?? circuitPinNumbers.get(i) ?? `${i + 1}`;
73963
+ const schematicPort = schematicPorts.find((candidate) => candidate.schematic_component_id === schematicComponent?.schematic_component_id && String(candidate.pin_number) === pinNum);
73964
+ const sourcePort = sourcePorts.find((candidate) => candidate.source_port_id === schematicPort?.source_port_id);
73959
73965
  pin._sxNumber = new SymbolPinNumber({
73960
- value: pinNum,
73966
+ value: getPhysicalPinName(sourcePort) ?? pinNum,
73961
73967
  effects: numEffects
73962
73968
  });
73963
73969
  pinSymbol.pins.push(pin);
@@ -73966,11 +73972,14 @@ function createPinSubsymbol({
73966
73972
  }
73967
73973
  var AddLibrarySymbolsStage = class extends ConverterStage {
73968
73974
  processedSymbolNames = /* @__PURE__ */ new Set;
73975
+ pinNumberingsByLibId = /* @__PURE__ */ new Map;
73969
73976
  _step() {
73970
73977
  const { kicadSch, db } = this.ctx;
73971
73978
  const libSymbols = new LibSymbols;
73972
73979
  const librarySymbols = [];
73973
73980
  this.processedSymbolNames = /* @__PURE__ */ new Set;
73981
+ this.pinNumberingsByLibId = /* @__PURE__ */ new Map;
73982
+ this.ctx.schematicComponentLibraryIds = /* @__PURE__ */ new Map;
73974
73983
  const schematicComponents = db.schematic_component.list();
73975
73984
  for (const schematicComponent of schematicComponents) {
73976
73985
  const libSymbol = this.createLibrarySymbolForComponent(schematicComponent);
@@ -74066,8 +74075,7 @@ var AddLibrarySymbolsStage = class extends ConverterStage {
74066
74075
  if (!symbolData)
74067
74076
  return null;
74068
74077
  const footprintName = getKicadCompatibleComponentName(sourceComp, cadComponent);
74069
- return this.createLibrarySymbol({
74070
- libId: libraryId,
74078
+ const librarySymbolOptions = {
74071
74079
  symbolData,
74072
74080
  isChip,
74073
74081
  schematicComponent,
@@ -74077,8 +74085,31 @@ var AddLibrarySymbolsStage = class extends ConverterStage {
74077
74085
  footprintRef: footprintName ? `tscircuit:${footprintName}` : "",
74078
74086
  referencePrefix: getReferencePrefixForComponent(sourceComp),
74079
74087
  symbolScale: this.ctx.kicadSchematicScaleFactor
74088
+ };
74089
+ const librarySymbol = this.createLibrarySymbol({
74090
+ libId: libraryId,
74091
+ ...librarySymbolOptions
74092
+ });
74093
+ const pinNumberingLibId = this.getLibraryIdForPinNumbering(libraryId, librarySymbol);
74094
+ if (pinNumberingLibId === libraryId)
74095
+ return librarySymbol;
74096
+ this.ctx.schematicComponentLibraryIds.set(schematicComponent.schematic_component_id, pinNumberingLibId);
74097
+ return this.createLibrarySymbol({
74098
+ libId: pinNumberingLibId,
74099
+ ...librarySymbolOptions
74080
74100
  });
74081
74101
  }
74102
+ getLibraryIdForPinNumbering(libId, librarySymbol) {
74103
+ const pinNumbering = librarySymbol.subSymbols.flatMap((subSymbol) => subSymbol.pins.map((pin) => pin.numberString)).join(",");
74104
+ const numberings = this.pinNumberingsByLibId.get(libId) ?? [];
74105
+ this.pinNumberingsByLibId.set(libId, numberings);
74106
+ let index = numberings.indexOf(pinNumbering);
74107
+ if (index === -1) {
74108
+ numberings.push(pinNumbering);
74109
+ index = numberings.length - 1;
74110
+ }
74111
+ return index === 0 ? libId : `${libId}_${index + 1}`;
74112
+ }
74082
74113
  createLibrarySymbolFromSchematicSymbol(schematicComponent, sourceComp, symbolContext) {
74083
74114
  const { cadComponent, schematicSymbol, schematicSymbolId, libraryId } = symbolContext;
74084
74115
  if (!schematicSymbol || !schematicSymbolId) {
@@ -74096,6 +74127,12 @@ var AddLibrarySymbolsStage = class extends ConverterStage {
74096
74127
  schematicComponentCenter: schematicComponent.center,
74097
74128
  schematicComponentSize: schematicComponent.size
74098
74129
  });
74130
+ if (sourceComp.name) {
74131
+ const referenceTextIndex = symbolData.texts.findIndex((text) => text.text === sourceComp.name);
74132
+ if (referenceTextIndex !== -1) {
74133
+ symbolData.texts.splice(referenceTextIndex, 1);
74134
+ }
74135
+ }
74099
74136
  const footprintName = getKicadCompatibleComponentName(sourceComp, cadComponent);
74100
74137
  return this.createLibrarySymbol({
74101
74138
  libId: libraryId,
@@ -74643,6 +74680,7 @@ var AddSchematicNetLabelsStage = class extends ConverterStage {
74643
74680
  return this.ctx.kicadSch;
74644
74681
  }
74645
74682
  };
74683
+ var DEFAULT_PROPERTY_FONT_SIZE = 1.27;
74646
74684
  var AddSchematicSymbolsStage = class extends ConverterStage {
74647
74685
  _step() {
74648
74686
  const { kicadSch, db } = this.ctx;
@@ -74686,7 +74724,7 @@ var AddSchematicSymbolsStage = class extends ConverterStage {
74686
74724
  uuid,
74687
74725
  fieldsAutoplaced: false
74688
74726
  });
74689
- const symLibId = new SymbolLibId2(libraryId);
74727
+ const symLibId = new SymbolLibId2(this.ctx.schematicComponentLibraryIds?.get(schematicComponent.schematic_component_id) ?? libraryId);
74690
74728
  symbol._sxLibId = symLibId;
74691
74729
  const { reference, value, description } = this.getComponentMetadata(sourceComponent);
74692
74730
  const hasManufacturerValueForValuePlacement = (sourceComponent.ftype === "simple_chip" || sourceComponent.ftype === "simple_connector") && Boolean(sourceComponent.manufacturer_part_number);
@@ -74698,16 +74736,30 @@ var AddSchematicSymbolsStage = class extends ConverterStage {
74698
74736
  value
74699
74737
  });
74700
74738
  const symbolMetadata = schematicSymbol?.metadata?.kicad_symbol;
74739
+ let customReferenceText;
74740
+ if (schematicSymbolId && sourceComponent.name) {
74741
+ customReferenceText = db.schematic_text.list().find((text) => text.schematic_symbol_id === schematicSymbolId && text.text === sourceComponent.name);
74742
+ }
74743
+ const customReferencePosition = this.getTextPosition(customReferenceText);
74744
+ const referencePosition = customReferencePosition?.position ?? refTextPos;
74745
+ let referenceFontSize = DEFAULT_PROPERTY_FONT_SIZE;
74746
+ if (customReferenceText) {
74747
+ referenceFontSize = customReferenceText.font_size * this.ctx.kicadSchematicScaleFactor;
74748
+ }
74701
74749
  const refMeta = symbolMetadata?.properties?.Reference;
74702
74750
  const hideGeneratedCustomReference = Boolean(schematicSymbolId) || usesComponentLevelSymbolPrimitives;
74703
74751
  const referenceProperty = new SymbolProperty3({
74704
74752
  key: "Reference",
74705
74753
  value: refMeta?.value ?? reference,
74706
74754
  id: 0,
74707
- at: [refTextPos.x, refTextPos.y, 0],
74708
- effects: this.createTextEffects(Number(refMeta?.effects?.font?.size?.x ?? 1.27), {
74709
- hide: refMeta?.effects?.hide ?? hideGeneratedCustomReference,
74710
- justify: refJustify
74755
+ at: [
74756
+ referencePosition.x,
74757
+ referencePosition.y,
74758
+ customReferenceText?.rotation ?? 0
74759
+ ],
74760
+ effects: this.createTextEffects(Number(refMeta?.effects?.font?.size?.x ?? referenceFontSize), {
74761
+ hide: refMeta?.effects?.hide ?? (hideGeneratedCustomReference && !customReferenceText),
74762
+ justify: customReferencePosition?.justify ?? refJustify
74711
74763
  })
74712
74764
  });
74713
74765
  const hideValue = Boolean(schematicSymbolId) || usesComponentLevelSymbolPrimitives || sourceComponent.ftype === "simple_chip" && !hasManufacturerValueForValuePlacement || sourceComponent.ftype === "simple_diode" && !schematicComponent.symbol_display_value || sourceComponent.ftype === "simple_pin_header" || sourceComponent.ftype === "simple_test_point";
@@ -74717,7 +74769,7 @@ var AddSchematicSymbolsStage = class extends ConverterStage {
74717
74769
  value: valMeta?.value ?? value,
74718
74770
  id: 1,
74719
74771
  at: [valTextPos.x, valTextPos.y, 0],
74720
- effects: this.createTextEffects(Number(valMeta?.effects?.font?.size?.x ?? 1.27), { hide: valMeta?.effects?.hide ?? hideValue, justify: valJustify })
74772
+ effects: this.createTextEffects(Number(valMeta?.effects?.font?.size?.x ?? DEFAULT_PROPERTY_FONT_SIZE), { hide: valMeta?.effects?.hide ?? hideValue, justify: valJustify })
74721
74773
  });
74722
74774
  const fpMeta = symbolMetadata?.properties?.Footprint;
74723
74775
  const footprintProperty = new SymbolProperty3({
@@ -74725,7 +74777,7 @@ var AddSchematicSymbolsStage = class extends ConverterStage {
74725
74777
  value: fpMeta?.value ?? "",
74726
74778
  id: 2,
74727
74779
  at: [x - 1.778, y, 90],
74728
- effects: this.createTextEffects(1.27, {
74780
+ effects: this.createTextEffects(DEFAULT_PROPERTY_FONT_SIZE, {
74729
74781
  hide: fpMeta?.effects?.hide ?? true
74730
74782
  })
74731
74783
  });
@@ -74735,7 +74787,7 @@ var AddSchematicSymbolsStage = class extends ConverterStage {
74735
74787
  value: dsMeta?.value ?? "~",
74736
74788
  id: 3,
74737
74789
  at: [x, y, 0],
74738
- effects: this.createTextEffects(1.27, {
74790
+ effects: this.createTextEffects(DEFAULT_PROPERTY_FONT_SIZE, {
74739
74791
  hide: dsMeta?.effects?.hide ?? true
74740
74792
  })
74741
74793
  });
@@ -74745,7 +74797,7 @@ var AddSchematicSymbolsStage = class extends ConverterStage {
74745
74797
  value: descMeta?.value ?? description,
74746
74798
  id: 4,
74747
74799
  at: [x, y, 0],
74748
- effects: this.createTextEffects(1.27, {
74800
+ effects: this.createTextEffects(DEFAULT_PROPERTY_FONT_SIZE, {
74749
74801
  hide: descMeta?.effects?.hide ?? true
74750
74802
  })
74751
74803
  });
@@ -74757,7 +74809,7 @@ var AddSchematicSymbolsStage = class extends ConverterStage {
74757
74809
  value: kwMeta.value,
74758
74810
  id: 5,
74759
74811
  at: [x, y, 0],
74760
- effects: this.createTextEffects(1.27, {
74812
+ effects: this.createTextEffects(DEFAULT_PROPERTY_FONT_SIZE, {
74761
74813
  hide: kwMeta.effects?.hide ?? true
74762
74814
  })
74763
74815
  });
@@ -74770,7 +74822,7 @@ var AddSchematicSymbolsStage = class extends ConverterStage {
74770
74822
  value: fpFilterMeta.value,
74771
74823
  id: 6,
74772
74824
  at: [x, y, 0],
74773
- effects: this.createTextEffects(1.27, {
74825
+ effects: this.createTextEffects(DEFAULT_PROPERTY_FONT_SIZE, {
74774
74826
  hide: fpFilterMeta.effects?.hide ?? true
74775
74827
  })
74776
74828
  });
@@ -74820,7 +74872,7 @@ var AddSchematicSymbolsStage = class extends ConverterStage {
74820
74872
  if (!port)
74821
74873
  continue;
74822
74874
  const pin = new SymbolPin3;
74823
- pin.numberString = `${port.pin_number || i + 1}`;
74875
+ pin.numberString = getPhysicalPinName(port.source_port_id ? db.source_port.get(port.source_port_id) : undefined) ?? `${port.pin_number || i + 1}`;
74824
74876
  pin.uuid = crypto.randomUUID();
74825
74877
  symbol.pins.push(pin);
74826
74878
  }
@@ -75876,7 +75928,7 @@ var ExtractFootprintsStage = class extends ConverterStage {
75876
75928
  customFootprintNames.add(footprintName);
75877
75929
  const pcbComp = this.ctx.circuitJson.find((el) => el.type === "pcb_component" && el.source_component_id === cadComponent.source_component_id);
75878
75930
  if (pcbComp && pcbComp.type === "pcb_component" && pcbComp.metadata?.kicad_footprint?.footprintName) {
75879
- customFootprintNames.add(pcbComp.metadata.kicad_footprint.footprintName);
75931
+ customFootprintNames.add(pcbComp.metadata.kicad_footprint.footprintName.split(":").pop());
75880
75932
  }
75881
75933
  }
75882
75934
  }
@@ -76944,7 +76996,7 @@ function convertSmdPads({
76944
76996
  const sourcePort = pcbPort?.source_port_id ? ctx.db.source_port?.get(pcbPort.source_port_id) : undefined;
76945
76997
  const pinHint = pcbPad.port_hints?.find((h) => /^pin[A-Za-z0-9_]+$/i.test(h));
76946
76998
  const gridHint = pcbPad.port_hints?.find((h) => /^[A-Za-z]?\d+[A-Za-z0-9_]*$/.test(h));
76947
- const resolvedPadNumber = sourcePort?.pin_number != null ? String(sourcePort.pin_number) : pinHint ? pinHint.replace(/^pin/i, "") : gridHint ?? String(padNumber);
76999
+ const resolvedPadNumber = getPhysicalPinName(sourcePort) ?? (sourcePort?.pin_number != null ? String(sourcePort.pin_number) : pinHint ? pinHint.replace(/^pin/i, "") : gridHint ?? String(padNumber));
76948
77000
  const pad = createSmdPadFromCircuitJson({
76949
77001
  pcbPad,
76950
77002
  componentCenter,
@@ -77077,7 +77129,7 @@ function convertPlatedHoles({
77077
77129
  const sourcePort = pcbPort?.source_port_id ? ctx.db.source_port?.get(pcbPort.source_port_id) : undefined;
77078
77130
  const pinHint = platedHole.port_hints?.find((h) => /^pin[A-Za-z0-9_]+$/i.test(h));
77079
77131
  const gridHint = platedHole.port_hints?.find((h) => /^[A-Za-z]?\d+[A-Za-z0-9_]*$/.test(h));
77080
- const resolvedPadNumber = sourcePort?.pin_number != null ? String(sourcePort.pin_number) : pinHint ? pinHint.replace(/^pin/i, "") : gridHint ?? String(padNumber);
77132
+ const resolvedPadNumber = getPhysicalPinName(sourcePort) ?? (sourcePort?.pin_number != null ? String(sourcePort.pin_number) : pinHint ? pinHint.replace(/^pin/i, "") : gridHint ?? String(padNumber));
77081
77133
  const pad = createThruHolePadFromCircuitJson({
77082
77134
  platedHole,
77083
77135
  componentCenter,
@@ -77574,6 +77626,26 @@ var AddTracesStage = class extends ConverterStage {
77574
77626
  return this.ctx.kicadPcb;
77575
77627
  }
77576
77628
  };
77629
+ var toKicadTentingValue = (tented) => tented === undefined ? "none" : tented ? "yes" : "no";
77630
+ var KicadViaTenting = class extends ViaTenting {
77631
+ constructor(front, back) {
77632
+ super();
77633
+ this.front = front;
77634
+ this.back = back;
77635
+ }
77636
+ front;
77637
+ back;
77638
+ getString() {
77639
+ return `(tenting (front ${this.front}) (back ${this.back}))`;
77640
+ }
77641
+ };
77642
+ var createViaTenting = (via) => {
77643
+ const top = via.tented_on_top ?? via.is_tented;
77644
+ const bottom = via.tented_on_bottom ?? via.is_tented;
77645
+ if (top === undefined && bottom === undefined)
77646
+ return;
77647
+ return new KicadViaTenting(toKicadTentingValue(top), toKicadTentingValue(bottom));
77648
+ };
77577
77649
  var AddViasStage = class extends ConverterStage {
77578
77650
  viasProcessed = 0;
77579
77651
  pcbVias = [];
@@ -77593,7 +77665,9 @@ var AddViasStage = class extends ConverterStage {
77593
77665
  to_layer: point.to_layer,
77594
77666
  pcb_trace_id: trace.pcb_trace_id,
77595
77667
  subcircuit_connectivity_map_key: trace.subcircuit_connectivity_map_key,
77596
- connection_name: trace.connection_name
77668
+ connection_name: trace.connection_name,
77669
+ tented_on_top: point.tented_on_top,
77670
+ tented_on_bottom: point.tented_on_bottom
77597
77671
  })).filter((via) => {
77598
77672
  const viaKey = this.getViaDedupeKey(via);
77599
77673
  if (seenViaKeys.has(viaKey)) {
@@ -77701,7 +77775,8 @@ var AddViasStage = class extends ConverterStage {
77701
77775
  drill: viaDrill,
77702
77776
  layers: viaLayers,
77703
77777
  net: new ViaNet(netInfo?.id ?? 0),
77704
- uuid: generateDeterministicUuid(viaData)
77778
+ uuid: generateDeterministicUuid(viaData),
77779
+ tenting: createViaTenting(via)
77705
77780
  });
77706
77781
  const vias = kicadPcb.vias;
77707
77782
  vias.push(kicadVia);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tscircuit/cli",
3
- "version": "0.1.2348",
3
+ "version": "0.1.2350",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/tscircuit/cli"
@@ -51,7 +51,7 @@
51
51
  "circuit-json-to-fdm-component-box": "^0.0.2",
52
52
  "circuit-json-to-footprinter": "^0.0.59",
53
53
  "circuit-json-to-gerber": "^0.0.112",
54
- "circuit-json-to-kicad": "0.0.230",
54
+ "circuit-json-to-kicad": "0.0.235",
55
55
  "circuit-json-to-pnp-csv": "^0.0.18",
56
56
  "circuit-json-to-readable-netlist": "^0.0.15",
57
57
  "circuit-json-to-spice": "^0.0.45",
@@ -76,7 +76,7 @@
76
76
  "jszip": "^3.10.1",
77
77
  "jwt-decode": "^4.0.0",
78
78
  "kicad-to-circuit-json": "^0.0.113",
79
- "kicadts": "^0.0.47",
79
+ "kicadts": "^0.0.58",
80
80
  "kleur": "^4.1.5",
81
81
  "ky": "^1.7.4",
82
82
  "make-vfs": "^1.0.15",