@tscircuit/cli 0.1.2445 → 0.1.2447

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: 47848626 bytes
4
- sha256: cda0b18f259b0cc3ff95651b26fc51906e277d9f77b4ce6c120dde00fa5be8da
3
+ size: 47851146 bytes
4
+ sha256: b5c67a0ee7b703a49d9adbeb9337e02b558d6fe025241131a43b54f6d2a3e2a1
package/dist/lib/index.js CHANGED
@@ -74354,11 +74354,11 @@ import {
74354
74354
  } from "kicadts";
74355
74355
  import { TitleBlock, TitleBlockComment } from "kicadts";
74356
74356
  import {
74357
- EmbeddedFonts,
74357
+ EmbeddedFonts as EmbeddedFonts2,
74358
74358
  LibSymbols,
74359
74359
  SchematicSymbol as SchematicSymbol4,
74360
- SymbolPinNames,
74361
- SymbolPinNumbers,
74360
+ SymbolPinNames as SymbolPinNames2,
74361
+ SymbolPinNumbers as SymbolPinNumbers2,
74362
74362
  SymbolPower
74363
74363
  } from "kicadts";
74364
74364
  import { symbols as symbols3 } from "schematic-symbols";
@@ -74378,13 +74378,22 @@ import { SymbolRectangle } from "kicadts";
74378
74378
  import { SymbolText, TextEffects as TextEffects2, TextEffectsFont as TextEffectsFont2 } from "kicadts";
74379
74379
  import { SymbolProperty } from "kicadts";
74380
74380
  import { TextEffects as TextEffects3, TextEffectsFont as TextEffectsFont3 } from "kicadts";
74381
+ import {
74382
+ EmbeddedFonts,
74383
+ SymbolPinNames,
74384
+ SymbolPinNumbers,
74385
+ SymbolProperty as SymbolProperty2,
74386
+ TextEffects as TextEffects4,
74387
+ TextEffectsFont as TextEffectsFont4,
74388
+ TextEffectsJustify as TextEffectsJustify2
74389
+ } from "kicadts";
74381
74390
  import {
74382
74391
  SchematicSymbol as SchematicSymbol3,
74383
74392
  SymbolPin,
74384
74393
  SymbolPinName,
74385
74394
  SymbolPinNumber,
74386
- TextEffects as TextEffects4,
74387
- TextEffectsFont as TextEffectsFont4
74395
+ TextEffects as TextEffects5,
74396
+ TextEffectsFont as TextEffectsFont5
74388
74397
  } from "kicadts";
74389
74398
  import { applyToPoint as applyToPoint2, scale as createScaleMatrix2 } from "transformation-matrix";
74390
74399
  import { applyToPoint as applyToPoint3 } from "transformation-matrix";
@@ -74397,40 +74406,31 @@ import {
74397
74406
  Stroke as Stroke3,
74398
74407
  SymbolArcFill,
74399
74408
  SymbolRectangleFill,
74400
- TextEffects as TextEffects5,
74401
- TextEffectsFont as TextEffectsFont5,
74402
- TextEffectsJustify as TextEffectsJustify3,
74409
+ TextEffects as TextEffects6,
74410
+ TextEffectsFont as TextEffectsFont6,
74411
+ TextEffectsJustify as TextEffectsJustify4,
74403
74412
  Uuid,
74404
74413
  Xy as Xy2
74405
74414
  } from "kicadts";
74406
74415
  import { applyToPoint as applyToPoint5 } from "transformation-matrix";
74407
- import { Label, TextEffectsJustify as TextEffectsJustify2 } from "kicadts";
74416
+ import { Label, TextEffectsJustify as TextEffectsJustify3 } from "kicadts";
74408
74417
  import { applyToPoint as applyToPoint4 } from "transformation-matrix";
74409
74418
  import {
74410
74419
  SchematicSymbol as SchematicSymbol5,
74411
74420
  SymbolLibId,
74412
- SymbolProperty as SymbolProperty2,
74421
+ SymbolProperty as SymbolProperty3,
74413
74422
  SymbolPin as SymbolPin2,
74414
74423
  SymbolInstances,
74415
74424
  SymbolInstancesProject,
74416
74425
  SymbolInstancePath,
74417
- TextEffects as TextEffects6,
74418
- TextEffectsFont as TextEffectsFont6,
74419
- TextEffectsJustify as TextEffectsJustify4,
74426
+ TextEffects as TextEffects7,
74427
+ TextEffectsFont as TextEffectsFont7,
74428
+ TextEffectsJustify as TextEffectsJustify5,
74420
74429
  GlobalLabel
74421
74430
  } from "kicadts";
74422
74431
  import { applyToPoint as applyToPoint6 } from "transformation-matrix";
74423
74432
  import { symbols as symbols4 } from "schematic-symbols";
74424
74433
  import { NoConnect } from "kicadts";
74425
- import {
74426
- EmbeddedFonts as EmbeddedFonts2,
74427
- SymbolPinNames as SymbolPinNames2,
74428
- SymbolPinNumbers as SymbolPinNumbers2,
74429
- SymbolProperty as SymbolProperty3,
74430
- TextEffects as TextEffects7,
74431
- TextEffectsFont as TextEffectsFont7,
74432
- TextEffectsJustify as TextEffectsJustify5
74433
- } from "kicadts";
74434
74434
  import { formatSiUnit } from "format-si-unit";
74435
74435
  import {
74436
74436
  EmbeddedFonts as EmbeddedFonts3,
@@ -75698,6 +75698,146 @@ function addSymbolProperties({
75698
75698
  }));
75699
75699
  }
75700
75700
  }
75701
+ var DEFAULT_TEXT_SIZE = 1.27;
75702
+ var DEFAULT_TEXT_THICKNESS = 0.15;
75703
+ var toNumber = (value, fallback) => {
75704
+ if (value === undefined)
75705
+ return fallback;
75706
+ const parsed = typeof value === "number" ? value : Number.parseFloat(value);
75707
+ if (Number.isNaN(parsed))
75708
+ return fallback;
75709
+ return parsed;
75710
+ };
75711
+ var createTextEffects2 = (effectsMeta, fallback) => {
75712
+ if (!effectsMeta)
75713
+ return fallback;
75714
+ const effects = new TextEffects4({
75715
+ font: fallback?.font,
75716
+ justify: fallback?.justify,
75717
+ hiddenText: fallback?.hiddenText ?? false
75718
+ });
75719
+ if (!effects.font) {
75720
+ const defaultFont = new TextEffectsFont4;
75721
+ defaultFont.size = { width: DEFAULT_TEXT_SIZE, height: DEFAULT_TEXT_SIZE };
75722
+ effects.font = defaultFont;
75723
+ }
75724
+ if (effectsMeta.font?.size) {
75725
+ effects.font.size = {
75726
+ width: toNumber(effectsMeta.font.size.x, DEFAULT_TEXT_SIZE),
75727
+ height: toNumber(effectsMeta.font.size.y, DEFAULT_TEXT_SIZE)
75728
+ };
75729
+ }
75730
+ if (effectsMeta.font?.thickness !== undefined) {
75731
+ effects.font.thickness = toNumber(effectsMeta.font.thickness, DEFAULT_TEXT_THICKNESS);
75732
+ }
75733
+ if (!effects.font.size) {
75734
+ effects.font.size = { width: DEFAULT_TEXT_SIZE, height: DEFAULT_TEXT_SIZE };
75735
+ }
75736
+ if (!effects.font.thickness && effectsMeta.font?.thickness !== undefined) {
75737
+ effects.font.thickness = DEFAULT_TEXT_THICKNESS;
75738
+ }
75739
+ const justify = createJustify(effectsMeta.justify);
75740
+ if (justify) {
75741
+ effects.justify = justify;
75742
+ }
75743
+ if (effectsMeta.hide !== undefined) {
75744
+ effects.hiddenText = effectsMeta.hide;
75745
+ }
75746
+ return effects;
75747
+ };
75748
+ var createJustify = (justifyInput) => {
75749
+ if (!justifyInput)
75750
+ return;
75751
+ const values = Array.isArray(justifyInput) ? justifyInput : [justifyInput];
75752
+ const options = {};
75753
+ for (const value of values) {
75754
+ if (value === "left" || value === "right") {
75755
+ options.horizontal = value;
75756
+ } else if (value === "top" || value === "bottom") {
75757
+ options.vertical = value;
75758
+ } else if (value === "mirror") {
75759
+ options.mirror = true;
75760
+ }
75761
+ }
75762
+ if (!options.horizontal && !options.vertical && !options.mirror) {
75763
+ return;
75764
+ }
75765
+ return new TextEffectsJustify2(options);
75766
+ };
75767
+ var applySymbolProperty = ({
75768
+ symbol,
75769
+ key,
75770
+ propertyMeta
75771
+ }) => {
75772
+ const existingProperty = symbol.properties.find((prop) => prop.key === key);
75773
+ const nextId = propertyMeta.id !== undefined ? toNumber(propertyMeta.id) : existingProperty?.id;
75774
+ const nextAt = propertyMeta.at ? [
75775
+ toNumber(propertyMeta.at.x, 0),
75776
+ toNumber(propertyMeta.at.y, 0),
75777
+ toNumber(propertyMeta.at.rotation, 0)
75778
+ ] : existingProperty?.at;
75779
+ const nextEffects = createTextEffects2(propertyMeta.effects, existingProperty?.effects);
75780
+ if (existingProperty) {
75781
+ existingProperty.value = propertyMeta.value;
75782
+ if (nextId !== undefined) {
75783
+ existingProperty.id = nextId;
75784
+ }
75785
+ if (nextAt) {
75786
+ existingProperty.at = nextAt;
75787
+ }
75788
+ if (nextEffects) {
75789
+ existingProperty.effects = nextEffects;
75790
+ }
75791
+ return;
75792
+ }
75793
+ symbol.properties.push(new SymbolProperty2({
75794
+ key,
75795
+ value: propertyMeta.value,
75796
+ id: nextId,
75797
+ at: nextAt,
75798
+ effects: nextEffects
75799
+ }));
75800
+ };
75801
+ function applyKicadSymbolMetadata(kicadSymbol, metadata) {
75802
+ applyKicadSymbolMetadataToSymbol(kicadSymbol.symbol, metadata);
75803
+ return kicadSymbol;
75804
+ }
75805
+ function applyKicadSymbolMetadataToSymbol(symbol, metadata) {
75806
+ if (metadata.excludeFromSim !== undefined) {
75807
+ symbol.excludeFromSim = metadata.excludeFromSim;
75808
+ }
75809
+ if (metadata.inBom !== undefined) {
75810
+ symbol.inBom = metadata.inBom;
75811
+ }
75812
+ if (metadata.onBoard !== undefined) {
75813
+ symbol.onBoard = metadata.onBoard;
75814
+ }
75815
+ if (metadata.embeddedFonts !== undefined) {
75816
+ symbol._sxEmbeddedFonts = new EmbeddedFonts(metadata.embeddedFonts);
75817
+ }
75818
+ if (metadata.pinNumbers?.hide !== undefined) {
75819
+ const pinNumbers = symbol.pinNumbers ?? new SymbolPinNumbers;
75820
+ pinNumbers.hide = metadata.pinNumbers.hide;
75821
+ symbol.pinNumbers = pinNumbers;
75822
+ }
75823
+ if (metadata.pinNames) {
75824
+ const pinNames = symbol.pinNames ?? new SymbolPinNames;
75825
+ if (metadata.pinNames.offset !== undefined) {
75826
+ pinNames.offset = toNumber(metadata.pinNames.offset, pinNames.offset);
75827
+ }
75828
+ if (metadata.pinNames.hide !== undefined) {
75829
+ pinNames.hide = metadata.pinNames.hide;
75830
+ }
75831
+ symbol.pinNames = pinNames;
75832
+ }
75833
+ if (metadata.properties) {
75834
+ for (const [key, propertyMeta] of Object.entries(metadata.properties)) {
75835
+ if (!propertyMeta)
75836
+ continue;
75837
+ applySymbolProperty({ symbol, key, propertyMeta });
75838
+ }
75839
+ }
75840
+ }
75701
75841
  function getPhysicalPinName(sourcePort) {
75702
75842
  return sourcePort && sourcePort.pin_number === undefined && /^[A-Z]+[1-9]\d*$/.test(sourcePort.name) ? sourcePort.name : undefined;
75703
75843
  }
@@ -75922,14 +76062,14 @@ function createPinSubsymbol({
75922
76062
  angle
75923
76063
  ];
75924
76064
  pin.length = isChip ? CHIP_PIN_LENGTH : CUSTOM_SYMBOL_PIN_LENGTH;
75925
- const nameFont = new TextEffectsFont4;
76065
+ const nameFont = new TextEffectsFont5;
75926
76066
  nameFont.size = { height: 1.27, width: 1.27 };
75927
- const nameEffects = new TextEffects4({ font: nameFont });
76067
+ const nameEffects = new TextEffects5({ font: nameFont });
75928
76068
  const pinName = port.labels?.[0] || "~";
75929
76069
  pin._sxName = new SymbolPinName({ value: pinName, effects: nameEffects });
75930
- const numFont = new TextEffectsFont4;
76070
+ const numFont = new TextEffectsFont5;
75931
76071
  numFont.size = { height: 1.27, width: 1.27 };
75932
- const numEffects = new TextEffects4({ font: numFont });
76072
+ const numEffects = new TextEffects5({ font: numFont });
75933
76073
  const pinNum = port.pinNumber?.toString() ?? circuitPinNumbers.get(i) ?? `${i + 1}`;
75934
76074
  const schematicPort = schematicPorts.find((candidate) => {
75935
76075
  if (candidate.schematic_component_id !== schematicComponent?.schematic_component_id) {
@@ -76082,10 +76222,14 @@ var AddLibrarySymbolsStage = class extends ConverterStage {
76082
76222
  referencePrefix: getReferencePrefixForComponent(sourceComp),
76083
76223
  symbolScale: this.ctx.kicadSchematicScaleFactor
76084
76224
  };
76085
- return this.createLibrarySymbol({
76225
+ const symbol = this.createLibrarySymbol({
76086
76226
  libId: libraryId,
76087
76227
  ...librarySymbolOptions
76088
76228
  });
76229
+ if (schematicComponent.metadata?.kicad_symbol) {
76230
+ applyKicadSymbolMetadataToSymbol(symbol, schematicComponent.metadata.kicad_symbol);
76231
+ }
76232
+ return symbol;
76089
76233
  }
76090
76234
  getLibraryIdForSymbolDefinition(libId, librarySymbol) {
76091
76235
  const definition = librarySymbol.getString();
@@ -76195,10 +76339,10 @@ var AddLibrarySymbolsStage = class extends ConverterStage {
76195
76339
  inBom: true,
76196
76340
  onBoard: true
76197
76341
  });
76198
- const pinNumbers = new SymbolPinNumbers;
76342
+ const pinNumbers = new SymbolPinNumbers2;
76199
76343
  pinNumbers.hide = !isChip;
76200
76344
  symbol._sxPinNumbers = pinNumbers;
76201
- const pinNames = new SymbolPinNames;
76345
+ const pinNames = new SymbolPinNames2;
76202
76346
  pinNames.offset = isChip ? 1.27 : 0;
76203
76347
  if (hidePinNames)
76204
76348
  pinNames.hide = true;
@@ -76229,7 +76373,7 @@ var AddLibrarySymbolsStage = class extends ConverterStage {
76229
76373
  c2kMatSch: this.ctx.c2kMatSch
76230
76374
  });
76231
76375
  symbol.subSymbols.push(pinSymbol);
76232
- symbol._sxEmbeddedFonts = new EmbeddedFonts(false);
76376
+ symbol._sxEmbeddedFonts = new EmbeddedFonts2(false);
76233
76377
  return symbol;
76234
76378
  }
76235
76379
  getDescription(sourceComp) {
@@ -76323,7 +76467,7 @@ function createInlineTraceLabel({
76323
76467
  }
76324
76468
  const { x, y } = applyToPoint4(transform, text.position);
76325
76469
  const effects = createTextEffects(fontSize, false);
76326
- effects.justify = new TextEffectsJustify2({
76470
+ effects.justify = new TextEffectsJustify3({
76327
76471
  horizontal: getTextJustificationFromAnchor(text.anchor)?.horizontal,
76328
76472
  vertical: "bottom"
76329
76473
  });
@@ -76492,15 +76636,15 @@ var AddSchematicGraphicsStage = class extends ConverterStage {
76492
76636
  x: (text.position?.x ?? 0) + (isInlineTraceText || preserveText ? 0 : DEFAULT_SECTION_TEXT_PADDING_X_MM),
76493
76637
  y: sourceY
76494
76638
  });
76495
- const font = new TextEffectsFont5;
76639
+ const font = new TextEffectsFont6;
76496
76640
  const fontSize = preserveText ? Math.max(0.01, text.font_size * (this.ctx.kicadSchematicScaleFactor ?? 1)) : DEFAULT_SECTION_TEXT_SIZE_MM;
76497
76641
  font.size = { height: fontSize, width: fontSize };
76498
76642
  font.color = preserveText ? parseColor(text.color) ?? DEFAULT_SECTION_TEXT_COLOR : DEFAULT_SECTION_TEXT_COLOR;
76499
76643
  const justify = isInlineTraceText || preserveText ? getTextJustificationFromAnchor(text.anchor) : undefined;
76500
- const effects = new TextEffects5({
76644
+ const effects = new TextEffects6({
76501
76645
  font,
76502
76646
  hiddenText: false,
76503
- justify: justify ? new TextEffectsJustify3(justify) : undefined
76647
+ justify: justify ? new TextEffectsJustify4(justify) : undefined
76504
76648
  });
76505
76649
  const schematicText = new SchematicText({
76506
76650
  value: text.text || "",
@@ -76601,35 +76745,35 @@ var AddSchematicNetLabelsStage = class extends ConverterStage {
76601
76745
  symbol._sxLibId = symLibId;
76602
76746
  const isUpSymbol = symbolName.includes("_up") || symbolName.toLowerCase().includes("vcc");
76603
76747
  const referenceOffset = isUpSymbol ? -4 : 4;
76604
- const referenceProperty = new SymbolProperty2({
76748
+ const referenceProperty = new SymbolProperty3({
76605
76749
  key: "Reference",
76606
76750
  value: reference,
76607
76751
  id: 0,
76608
76752
  at: [x, y + referenceOffset, 0],
76609
76753
  effects: this.createTextEffects(1.27, true)
76610
76754
  });
76611
- const valueProperty = new SymbolProperty2({
76755
+ const valueProperty = new SymbolProperty3({
76612
76756
  key: "Value",
76613
76757
  value: labelText,
76614
76758
  id: 1,
76615
76759
  at: [x, y + referenceOffset, 0],
76616
76760
  effects: this.createTextEffects(1.27, false)
76617
76761
  });
76618
- const footprintProperty = new SymbolProperty2({
76762
+ const footprintProperty = new SymbolProperty3({
76619
76763
  key: "Footprint",
76620
76764
  value: "",
76621
76765
  id: 2,
76622
76766
  at: [x - 1.778, y, 90],
76623
76767
  effects: this.createTextEffects(1.27, true)
76624
76768
  });
76625
- const datasheetProperty = new SymbolProperty2({
76769
+ const datasheetProperty = new SymbolProperty3({
76626
76770
  key: "Datasheet",
76627
76771
  value: "~",
76628
76772
  id: 3,
76629
76773
  at: [x, y, 0],
76630
76774
  effects: this.createTextEffects(1.27, true)
76631
76775
  });
76632
- const descriptionProperty = new SymbolProperty2({
76776
+ const descriptionProperty = new SymbolProperty3({
76633
76777
  key: "Description",
76634
76778
  value: `Power/Net symbol: ${labelText}`,
76635
76779
  id: 4,
@@ -76686,7 +76830,7 @@ var AddSchematicNetLabelsStage = class extends ConverterStage {
76686
76830
  const orientation = orientationMap[anchorSide] || orientationMap["left"];
76687
76831
  const effects = this.createTextEffects(1.27, false);
76688
76832
  if (Object.keys(orientation.justify).length > 0) {
76689
- effects.justify = new TextEffectsJustify4(orientation.justify);
76833
+ effects.justify = new TextEffectsJustify5(orientation.justify);
76690
76834
  }
76691
76835
  const globalLabel = new GlobalLabel({
76692
76836
  value: labelText,
@@ -76699,9 +76843,9 @@ var AddSchematicNetLabelsStage = class extends ConverterStage {
76699
76843
  return globalLabel;
76700
76844
  }
76701
76845
  createTextEffects(size, hide = false) {
76702
- const font = new TextEffectsFont6;
76846
+ const font = new TextEffectsFont7;
76703
76847
  font.size = { height: size, width: size };
76704
- return new TextEffects6({
76848
+ return new TextEffects7({
76705
76849
  font,
76706
76850
  hiddenText: hide
76707
76851
  });
@@ -76737,144 +76881,6 @@ var AddSchematicNoConnectsStage = class extends ConverterStage {
76737
76881
  return this.ctx.kicadSch;
76738
76882
  }
76739
76883
  };
76740
- var DEFAULT_TEXT_SIZE = 1.27;
76741
- var DEFAULT_TEXT_THICKNESS = 0.15;
76742
- var toNumber = (value, fallback) => {
76743
- if (value === undefined)
76744
- return fallback;
76745
- const parsed = typeof value === "number" ? value : Number.parseFloat(value);
76746
- if (Number.isNaN(parsed))
76747
- return fallback;
76748
- return parsed;
76749
- };
76750
- var createTextEffects2 = (effectsMeta, fallback) => {
76751
- if (!effectsMeta)
76752
- return fallback;
76753
- const effects = new TextEffects7({
76754
- font: fallback?.font,
76755
- justify: fallback?.justify,
76756
- hiddenText: fallback?.hiddenText ?? false
76757
- });
76758
- if (!effects.font) {
76759
- const defaultFont = new TextEffectsFont7;
76760
- defaultFont.size = { width: DEFAULT_TEXT_SIZE, height: DEFAULT_TEXT_SIZE };
76761
- effects.font = defaultFont;
76762
- }
76763
- if (effectsMeta.font?.size) {
76764
- effects.font.size = {
76765
- width: toNumber(effectsMeta.font.size.x, DEFAULT_TEXT_SIZE),
76766
- height: toNumber(effectsMeta.font.size.y, DEFAULT_TEXT_SIZE)
76767
- };
76768
- }
76769
- if (effectsMeta.font?.thickness !== undefined) {
76770
- effects.font.thickness = toNumber(effectsMeta.font.thickness, DEFAULT_TEXT_THICKNESS);
76771
- }
76772
- if (!effects.font.size) {
76773
- effects.font.size = { width: DEFAULT_TEXT_SIZE, height: DEFAULT_TEXT_SIZE };
76774
- }
76775
- if (!effects.font.thickness && effectsMeta.font?.thickness !== undefined) {
76776
- effects.font.thickness = DEFAULT_TEXT_THICKNESS;
76777
- }
76778
- const justify = createJustify(effectsMeta.justify);
76779
- if (justify) {
76780
- effects.justify = justify;
76781
- }
76782
- if (effectsMeta.hide !== undefined) {
76783
- effects.hiddenText = effectsMeta.hide;
76784
- }
76785
- return effects;
76786
- };
76787
- var createJustify = (justifyInput) => {
76788
- if (!justifyInput)
76789
- return;
76790
- const values = Array.isArray(justifyInput) ? justifyInput : [justifyInput];
76791
- const options = {};
76792
- for (const value of values) {
76793
- if (value === "left" || value === "right") {
76794
- options.horizontal = value;
76795
- } else if (value === "top" || value === "bottom") {
76796
- options.vertical = value;
76797
- } else if (value === "mirror") {
76798
- options.mirror = true;
76799
- }
76800
- }
76801
- if (!options.horizontal && !options.vertical && !options.mirror) {
76802
- return;
76803
- }
76804
- return new TextEffectsJustify5(options);
76805
- };
76806
- var applySymbolProperty = ({
76807
- symbol,
76808
- key,
76809
- propertyMeta
76810
- }) => {
76811
- const existingProperty = symbol.properties.find((prop) => prop.key === key);
76812
- const nextId = propertyMeta.id !== undefined ? toNumber(propertyMeta.id) : existingProperty?.id;
76813
- const nextAt = propertyMeta.at ? [
76814
- toNumber(propertyMeta.at.x, 0),
76815
- toNumber(propertyMeta.at.y, 0),
76816
- toNumber(propertyMeta.at.rotation, 0)
76817
- ] : existingProperty?.at;
76818
- const nextEffects = createTextEffects2(propertyMeta.effects, existingProperty?.effects);
76819
- if (existingProperty) {
76820
- existingProperty.value = propertyMeta.value;
76821
- if (nextId !== undefined) {
76822
- existingProperty.id = nextId;
76823
- }
76824
- if (nextAt) {
76825
- existingProperty.at = nextAt;
76826
- }
76827
- if (nextEffects) {
76828
- existingProperty.effects = nextEffects;
76829
- }
76830
- return;
76831
- }
76832
- symbol.properties.push(new SymbolProperty3({
76833
- key,
76834
- value: propertyMeta.value,
76835
- id: nextId,
76836
- at: nextAt,
76837
- effects: nextEffects
76838
- }));
76839
- };
76840
- function applyKicadSymbolMetadata(kicadSymbol, metadata) {
76841
- const { symbol } = kicadSymbol;
76842
- if (metadata.excludeFromSim !== undefined) {
76843
- symbol.excludeFromSim = metadata.excludeFromSim;
76844
- }
76845
- if (metadata.inBom !== undefined) {
76846
- symbol.inBom = metadata.inBom;
76847
- }
76848
- if (metadata.onBoard !== undefined) {
76849
- symbol.onBoard = metadata.onBoard;
76850
- }
76851
- if (metadata.embeddedFonts !== undefined) {
76852
- symbol._sxEmbeddedFonts = new EmbeddedFonts2(metadata.embeddedFonts);
76853
- }
76854
- if (metadata.pinNumbers?.hide !== undefined) {
76855
- const pinNumbers = symbol.pinNumbers ?? new SymbolPinNumbers2;
76856
- pinNumbers.hide = metadata.pinNumbers.hide;
76857
- symbol.pinNumbers = pinNumbers;
76858
- }
76859
- if (metadata.pinNames) {
76860
- const pinNames = symbol.pinNames ?? new SymbolPinNames2;
76861
- if (metadata.pinNames.offset !== undefined) {
76862
- pinNames.offset = toNumber(metadata.pinNames.offset, pinNames.offset);
76863
- }
76864
- if (metadata.pinNames.hide !== undefined) {
76865
- pinNames.hide = metadata.pinNames.hide;
76866
- }
76867
- symbol.pinNames = pinNames;
76868
- }
76869
- if (metadata.properties) {
76870
- for (const [key, propertyMeta] of Object.entries(metadata.properties)) {
76871
- if (!propertyMeta)
76872
- continue;
76873
- applySymbolProperty({ symbol, key, propertyMeta });
76874
- }
76875
- }
76876
- return kicadSymbol;
76877
- }
76878
76884
  var DEFAULT_PROPERTY_FONT_SIZE = 1.27;
76879
76885
  var AddSchematicSymbolsStage = class extends ConverterStage {
76880
76886
  _step() {
@@ -76930,7 +76936,7 @@ var AddSchematicSymbolsStage = class extends ConverterStage {
76930
76936
  reference,
76931
76937
  value
76932
76938
  });
76933
- const symbolMetadata = schematicSymbol?.metadata?.kicad_symbol;
76939
+ const symbolMetadata = schematicSymbol ? schematicSymbol.metadata?.kicad_symbol : schematicComponent.metadata?.kicad_symbol;
76934
76940
  let customReferenceText;
76935
76941
  if (schematicSymbolId && sourceComponent.name) {
76936
76942
  customReferenceText = db.schematic_text.list().find((text) => text.schematic_symbol_id === schematicSymbolId && text.text === sourceComponent.name);
@@ -81789,9 +81795,9 @@ function updateBuiltinKicadSymbolFootprint(kicadSymbol, options) {
81789
81795
  }
81790
81796
  return { symbolName: kicadSymbol.symbolName, symbol };
81791
81797
  }
81792
- var addedSymbolNames = /* @__PURE__ */ new Set;
81798
+ var addedSymbolDefinitions = /* @__PURE__ */ new Set;
81793
81799
  function classifyKicadSymbols(ctx) {
81794
- addedSymbolNames.clear();
81800
+ addedSymbolDefinitions.clear();
81795
81801
  for (const extractedKicadComponent of ctx.extractedKicadComponents) {
81796
81802
  classifySymbolsForComponent({
81797
81803
  ctx,
@@ -81823,10 +81829,11 @@ function classifySymbolsForComponent({
81823
81829
  for (const kicadSymbol of kicadSymbols) {
81824
81830
  if (!kicadSymbol.isBuiltin) {
81825
81831
  const symbolName = kicadSymbol.symbolName;
81826
- if (addedSymbolNames.has(symbolName)) {
81832
+ const symbolDefinitionKey = JSON.stringify([symbolName, metadata]);
81833
+ if (addedSymbolDefinitions.has(symbolDefinitionKey)) {
81827
81834
  continue;
81828
81835
  }
81829
- addedSymbolNames.add(symbolName);
81836
+ addedSymbolDefinitions.add(symbolDefinitionKey);
81830
81837
  if (hasCustomFootprint) {
81831
81838
  updateKicadSymbolFootprint({
81832
81839
  kicadSymbol,
@@ -81872,19 +81879,36 @@ function addUserSymbol({
81872
81879
  ctx,
81873
81880
  kicadSymbol
81874
81881
  }) {
81875
- const alreadyExistsByName = ctx.userKicadSymbols.some((s) => s.symbolName === kicadSymbol.symbolName);
81876
- if (alreadyExistsByName) {
81877
- return;
81878
- }
81879
- ctx.userKicadSymbols.push(kicadSymbol);
81882
+ addSymbolDefinition({ symbols: ctx.userKicadSymbols, kicadSymbol });
81880
81883
  }
81881
81884
  function addBuiltinSymbol({
81882
81885
  ctx,
81883
81886
  kicadSymbol
81884
81887
  }) {
81885
- const alreadyExists = ctx.builtinKicadSymbols.some((s) => s.symbolName === kicadSymbol.symbolName);
81886
- if (!alreadyExists) {
81887
- ctx.builtinKicadSymbols.push(kicadSymbol);
81888
+ addSymbolDefinition({ symbols: ctx.builtinKicadSymbols, kicadSymbol });
81889
+ }
81890
+ function addSymbolDefinition({
81891
+ symbols: symbols5,
81892
+ kicadSymbol
81893
+ }) {
81894
+ let symbolVariant = kicadSymbol;
81895
+ let suffix = 2;
81896
+ while (true) {
81897
+ const existingSymbol = symbols5.find((symbol) => symbol.symbolName === symbolVariant.symbolName);
81898
+ if (!existingSymbol) {
81899
+ symbols5.push(symbolVariant);
81900
+ return;
81901
+ }
81902
+ if (existingSymbol.symbol.getString() === symbolVariant.symbol.getString()) {
81903
+ return;
81904
+ }
81905
+ symbolVariant = {
81906
+ ...renameKicadSymbol({
81907
+ kicadSymbol: symbolVariant,
81908
+ newKicadSymbolName: `${kicadSymbol.symbolName}_${suffix++}`
81909
+ }),
81910
+ isBuiltin: kicadSymbol.isBuiltin
81911
+ };
81888
81912
  }
81889
81913
  }
81890
81914
  function generateSymLibTable(params2) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tscircuit/cli",
3
- "version": "0.1.2445",
3
+ "version": "0.1.2447",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/tscircuit/cli"
@@ -43,8 +43,8 @@
43
43
  "circuit-json-to-bom-csv": "^0.0.26",
44
44
  "circuit-json-to-fdm-component-box": "^0.0.2",
45
45
  "circuit-json-to-footprinter": "^0.0.59",
46
- "circuit-json-to-gerber": "^0.0.120",
47
- "circuit-json-to-kicad": "0.0.269",
46
+ "circuit-json-to-gerber": "^0.0.122",
47
+ "circuit-json-to-kicad": "0.0.270",
48
48
  "circuit-json-to-readable-netlist": "^0.0.15",
49
49
  "circuit-json-to-step": "^0.0.63",
50
50
  "circuit-json-to-tscircuit": "^0.0.50",