easyeda 0.0.376 → 0.0.377

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/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { CommonComponentProps, ChipProps } from '@tscircuit/props';
1
+ import { CommonComponentProps, ChipProps, SupplierPartNumbers } from '@tscircuit/props';
2
2
  import { AnyCircuitElement } from 'circuit-json';
3
3
  import { z } from 'zod';
4
4
 
@@ -5379,6 +5379,35 @@ declare const convertRawEasyToTsx: ({ rawEasy, pinAttributes, }: {
5379
5379
  pinAttributes?: ChipProps["pinAttributes"];
5380
5380
  }) => Promise<string>;
5381
5381
 
5382
+ type GeneratedComponentType = "chip" | "diode" | "led" | "pushbutton" | "switch" | "capacitor" | "resistor" | "inductor" | "crystal" | "connector";
5383
+ type GenerateTypescriptComponentParams = {
5384
+ pinLabels: ChipProps["pinLabels"];
5385
+ pinAttributes?: ChipProps["pinAttributes"];
5386
+ componentName: string;
5387
+ objUrl?: string;
5388
+ stepUrl?: string;
5389
+ supplierPartNumbers: SupplierPartNumbers;
5390
+ manufacturerPartNumber: string;
5391
+ componentType?: GeneratedComponentType;
5392
+ isPolarizedCapacitor?: boolean;
5393
+ capacitance?: string;
5394
+ resistance?: string;
5395
+ inductance?: string;
5396
+ crystalFrequency?: string;
5397
+ crystalPinVariant?: "two_pin" | "four_pin";
5398
+ symbolTsx?: string;
5399
+ schPinArrangement?: ChipProps["schPinArrangement"];
5400
+ useSymbolPortsOnly?: boolean;
5401
+ inferPinAttributes?: boolean;
5402
+ } & ({
5403
+ circuitJson: AnyCircuitElement[];
5404
+ footprint?: string;
5405
+ } | {
5406
+ footprint: string;
5407
+ circuitJson?: AnyCircuitElement[];
5408
+ });
5409
+ declare const generateTypescriptComponent: ({ pinLabels, pinAttributes, componentName, objUrl, stepUrl, circuitJson, footprint, supplierPartNumbers, manufacturerPartNumber, componentType, isPolarizedCapacitor, capacitance, resistance, inductance, crystalFrequency, crystalPinVariant, symbolTsx, schPinArrangement, useSymbolPortsOnly, inferPinAttributes, }: GenerateTypescriptComponentParams) => string;
5410
+
5382
5411
  declare function normalizeManufacturerPartNumber(partNumber: string): string;
5383
5412
 
5384
5413
  declare const normalizePinLabels: (inputPinLabels: string[][]) => string[][];
@@ -5389,4 +5418,4 @@ declare const convertEasyEdaJsonToVariousFormats: ({ jlcpcbPartNumberOrFilepath,
5389
5418
  outputFormat: string;
5390
5419
  }) => Promise<void>;
5391
5420
 
5392
- export { BBoxSchema, type BetterEasyEdaJson, DataStrSchema, EasyEdaJsonSchema, HeadSchema, LayerItemSchema, LcscSchema, ModelBoundsSchema, ObjectItemSchema, OwnerSchema, PackageDetailDataStrSchema, PackageDetailSchema, type RawEasyEdaJson, SzlcscSchema, convertEasyEdaJsonToCircuitJson, convertEasyEdaJsonToVariousFormats, convertRawEasyToTsx as convertRawEasyEdaToTs, fetchEasyEDAComponent, maybeNumber, normalizeManufacturerPartNumber, normalizePinLabels };
5421
+ export { BBoxSchema, type BetterEasyEdaJson, DataStrSchema, EasyEdaJsonSchema, type GenerateTypescriptComponentParams, type GeneratedComponentType, HeadSchema, LayerItemSchema, LcscSchema, ModelBoundsSchema, ObjectItemSchema, OwnerSchema, PackageDetailDataStrSchema, PackageDetailSchema, type RawEasyEdaJson, SzlcscSchema, convertEasyEdaJsonToCircuitJson, convertEasyEdaJsonToVariousFormats, convertRawEasyToTsx as convertRawEasyEdaToTs, fetchEasyEDAComponent, generateTypescriptComponent, maybeNumber, normalizeManufacturerPartNumber, normalizePinLabels };
package/dist/index.js CHANGED
@@ -17637,7 +17637,8 @@ var generateTypescriptComponent = ({
17637
17637
  componentName,
17638
17638
  objUrl,
17639
17639
  stepUrl,
17640
- circuitJson,
17640
+ circuitJson = [],
17641
+ footprint,
17641
17642
  supplierPartNumbers,
17642
17643
  manufacturerPartNumber,
17643
17644
  componentType = "chip",
@@ -17649,17 +17650,22 @@ var generateTypescriptComponent = ({
17649
17650
  crystalPinVariant,
17650
17651
  symbolTsx,
17651
17652
  schPinArrangement,
17652
- useSymbolPortsOnly = false
17653
+ useSymbolPortsOnly = false,
17654
+ inferPinAttributes: inferPinAttributes2 = true
17653
17655
  }) => {
17654
17656
  const safePinLabels = pinLabels ?? {};
17655
17657
  const polarizedPinMetadata = getPolarizedPinMetadata(safePinLabels);
17656
17658
  const polarizedPortHintsMap = polarizedPinMetadata?.portHintsMap;
17657
17659
  const polarizedPinLabels = polarizedPinMetadata?.pinLabels;
17658
17660
  const cadComponent = circuitJson.find((item) => item.type === "cad_component");
17659
- const footprintTsx = generateFootprintTsx(
17661
+ const footprintTsx = footprint !== void 0 ? JSON.stringify(footprint) : generateFootprintTsx(
17660
17662
  circuitJson,
17661
17663
  componentType === "diode" || componentType === "led" ? { portHintsMap: polarizedPortHintsMap } : void 0
17662
17664
  );
17665
+ const serializedManufacturerPartNumber = JSON.stringify(
17666
+ manufacturerPartNumber
17667
+ );
17668
+ const manufacturerPartNumberTsx = serializedManufacturerPartNumber.slice(1, -1) !== manufacturerPartNumber || manufacturerPartNumber.includes("&") ? `{${serializedManufacturerPartNumber}}` : serializedManufacturerPartNumber;
17663
17669
  const simplifiedPinLabels = Object.fromEntries(
17664
17670
  Object.entries(safePinLabels).map(([pin, labels]) => {
17665
17671
  if (Array.isArray(labels) && labels.length > 1 && labels[0] === pin) {
@@ -17669,7 +17675,7 @@ var generateTypescriptComponent = ({
17669
17675
  })
17670
17676
  );
17671
17677
  const pinLabelsString = Object.entries(simplifiedPinLabels).map(([pin, labels]) => ` ${pin}: ${JSON.stringify(labels)}`).join(",\n");
17672
- const inferredPinAttributes = componentType === "chip" ? inferPinAttributes(simplifiedPinLabels) : {};
17678
+ const inferredPinAttributes = componentType === "chip" && inferPinAttributes2 ? inferPinAttributes(simplifiedPinLabels) : {};
17673
17679
  const resolvedPinAttributes = { ...inferredPinAttributes, ...pinAttributes };
17674
17680
  const pinAttributesString = Object.entries(resolvedPinAttributes).map(([pin, attributes]) => {
17675
17681
  const attributesString = Object.entries(attributes).map(
@@ -17733,7 +17739,7 @@ ${polarizedPinLabelsBlock}${pinAttributesBlock}export const ${componentName} = (
17733
17739
  <diode
17734
17740
  name={name}
17735
17741
  ${polarizedPinLabelsProp}${symbolProp} supplierPartNumbers={${JSON.stringify(supplierPartNumbers, null, " ")}}
17736
- manufacturerPartNumber="${manufacturerPartNumber}"
17742
+ manufacturerPartNumber=${manufacturerPartNumberTsx}
17737
17743
  ${pinAttributesProp} footprint={${footprintTsx}}
17738
17744
  ${objUrl || stepUrl ? `cadModel={{
17739
17745
  ${cadModelLines}
@@ -17755,7 +17761,7 @@ ${polarizedPinLabelsBlock}${pinAttributesBlock}export const ${componentName} = (
17755
17761
  <led
17756
17762
  name={name}
17757
17763
  ${polarizedPinLabelsProp}${symbolProp} supplierPartNumbers={${JSON.stringify(supplierPartNumbers, null, " ")}}
17758
- manufacturerPartNumber="${manufacturerPartNumber}"
17764
+ manufacturerPartNumber=${manufacturerPartNumberTsx}
17759
17765
  ${pinAttributesProp} footprint={${footprintTsx}}
17760
17766
  ${objUrl || stepUrl ? `cadModel={{
17761
17767
  ${cadModelLines}
@@ -17782,7 +17788,7 @@ ${pinAttributesBlock}export const ${componentName} = (props: PushButtonProps<typ
17782
17788
  name={name}
17783
17789
  pinLabels={pinLabels}
17784
17790
  ${symbolProp} supplierPartNumbers={${JSON.stringify(supplierPartNumbers, null, " ")}}
17785
- manufacturerPartNumber="${manufacturerPartNumber}"
17791
+ manufacturerPartNumber=${manufacturerPartNumberTsx}
17786
17792
  ${pinAttributesProp} footprint={${footprintTsx}}
17787
17793
  ${objUrl || stepUrl ? `cadModel={{
17788
17794
  ${cadModelLines}
@@ -17809,7 +17815,7 @@ ${pinAttributesBlock}export const ${componentName} = (props: SwitchProps) => {
17809
17815
  name={name}
17810
17816
  pinLabels={pinLabels}
17811
17817
  ${symbolProp} supplierPartNumbers={${JSON.stringify(supplierPartNumbers, null, " ")}}
17812
- manufacturerPartNumber="${manufacturerPartNumber}"
17818
+ manufacturerPartNumber=${manufacturerPartNumberTsx}
17813
17819
  ${pinAttributesProp} footprint={${footprintTsx}}
17814
17820
  ${objUrl || stepUrl ? `cadModel={{
17815
17821
  ${cadModelLines}
@@ -17835,7 +17841,7 @@ ${capacitorPolarizedPinLabelsBlock}${pinAttributesBlock}export const ${component
17835
17841
  name={name}
17836
17842
  capacitance=${JSON.stringify(capacitance2)}
17837
17843
  ${capacitorPolarizedPinLabelsProp}${polarizedProp}${symbolProp} supplierPartNumbers={${JSON.stringify(supplierPartNumbers, null, " ")}}
17838
- manufacturerPartNumber="${manufacturerPartNumber}"
17844
+ manufacturerPartNumber=${manufacturerPartNumberTsx}
17839
17845
  ${pinAttributesProp} footprint={${footprintTsx}}
17840
17846
  ${objUrl || stepUrl ? `cadModel={{
17841
17847
  ${cadModelLines}
@@ -17861,7 +17867,7 @@ ${pinAttributesBlock}export const ${componentName} = (props: Omit<ResistorProps,
17861
17867
  name={name}
17862
17868
  resistance=${JSON.stringify(resistance2)}
17863
17869
  ${symbolProp} supplierPartNumbers={${JSON.stringify(supplierPartNumbers, null, " ")}}
17864
- manufacturerPartNumber="${manufacturerPartNumber}"
17870
+ manufacturerPartNumber=${manufacturerPartNumberTsx}
17865
17871
  ${pinAttributesProp} footprint={${footprintTsx}}
17866
17872
  ${objUrl || stepUrl ? `cadModel={{
17867
17873
  ${cadModelLines}
@@ -17884,7 +17890,7 @@ ${pinAttributesBlock}export const ${componentName} = (props: Omit<InductorProps,
17884
17890
  <inductor
17885
17891
  inductance=${JSON.stringify(inductance2)}
17886
17892
  supplierPartNumbers={${JSON.stringify(supplierPartNumbers, null, " ")}}
17887
- manufacturerPartNumber="${manufacturerPartNumber}"
17893
+ manufacturerPartNumber=${manufacturerPartNumberTsx}
17888
17894
  ${pinAttributesProp} footprint={${footprintTsx}}
17889
17895
  ${objUrl || stepUrl ? `cadModel={{
17890
17896
  ${cadModelLines}
@@ -17913,7 +17919,7 @@ ${pinAttributesBlock}export const ${componentName} = (props: ImportedCrystalProp
17913
17919
  frequency=${JSON.stringify(crystalFrequency)}
17914
17920
  pinVariant=${JSON.stringify(crystalPinVariant)}
17915
17921
  supplierPartNumbers={${JSON.stringify(supplierPartNumbers, null, " ")}}
17916
- manufacturerPartNumber="${manufacturerPartNumber}"
17922
+ manufacturerPartNumber=${manufacturerPartNumberTsx}
17917
17923
  ${pinAttributesProp} footprint={${footprintTsx}}
17918
17924
  ${objUrl || stepUrl ? `cadModel={{
17919
17925
  ${cadModelLines}
@@ -17937,7 +17943,7 @@ ${pinAttributesBlock}export const ${componentName} = (props: ConnectorProps) =>
17937
17943
  <connector
17938
17944
  pinLabels={pinLabels}
17939
17945
  supplierPartNumbers={${JSON.stringify(supplierPartNumbers, null, " ")}}
17940
- manufacturerPartNumber="${manufacturerPartNumber}"
17946
+ manufacturerPartNumber=${manufacturerPartNumberTsx}
17941
17947
  ${pinAttributesProp} footprint={${footprintTsx}}
17942
17948
  ${objUrl || stepUrl ? `cadModel={{
17943
17949
  ${cadModelLines}
@@ -17959,7 +17965,7 @@ ${pinAttributesBlock}export const ${componentName} = (props: ChipProps<typeof pi
17959
17965
  return (
17960
17966
  <chip
17961
17967
  ${useSymbolPortsOnly ? "" : " pinLabels={pinLabels}\n"}${pinAttributesProp}${symbolProp}${schPinArrangementProp} supplierPartNumbers={${JSON.stringify(supplierPartNumbers, null, " ")}}
17962
- manufacturerPartNumber="${manufacturerPartNumber}"
17968
+ manufacturerPartNumber=${manufacturerPartNumberTsx}
17963
17969
  footprint={${footprintTsx}}
17964
17970
  ${objUrl || stepUrl ? `cadModel={{
17965
17971
  ${cadModelLines}
@@ -18401,6 +18407,7 @@ export {
18401
18407
  convertEasyEdaJsonToVariousFormats,
18402
18408
  convertRawEasyToTsx as convertRawEasyEdaToTs,
18403
18409
  fetchEasyEDAComponent,
18410
+ generateTypescriptComponent,
18404
18411
  maybeNumber,
18405
18412
  normalizeManufacturerPartNumber,
18406
18413
  normalizePinLabels