easyeda 0.0.262 → 0.0.263

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.
@@ -10644,7 +10644,7 @@ var getPinLabelValues = (labels) => {
10644
10644
  if (typeof labels === "string") return [labels];
10645
10645
  return [...labels];
10646
10646
  };
10647
- var getDiodePortHintsMap = (pinLabels) => {
10647
+ var getPolarizedPortHintsMap = (pinLabels) => {
10648
10648
  const labelsByPin = Object.entries(pinLabels ?? {}).map(([pin, labels]) => ({
10649
10649
  pin,
10650
10650
  labels: getPinLabelValues(labels).map((label) => label.toLowerCase())
@@ -10675,7 +10675,7 @@ var generateTypescriptComponent = ({
10675
10675
  const cadComponent = circuitJson.find((item) => item.type === "cad_component");
10676
10676
  const footprintTsx = generateFootprintTsx(
10677
10677
  circuitJson,
10678
- componentType === "diode" ? { portHintsMap: getDiodePortHintsMap(safePinLabels) } : void 0
10678
+ componentType === "diode" || componentType === "led" ? { portHintsMap: getPolarizedPortHintsMap(safePinLabels) } : void 0
10679
10679
  );
10680
10680
  const simplifiedPinLabels = Object.fromEntries(
10681
10681
  Object.entries(safePinLabels).map(([pin, labels]) => {
@@ -10712,6 +10712,28 @@ ${cadModelLines}
10712
10712
  />
10713
10713
  )
10714
10714
  }
10715
+ `.trim();
10716
+ }
10717
+ if (componentType === "led") {
10718
+ return `
10719
+ import type { LedProps } from "@tscircuit/props"
10720
+
10721
+ export const ${componentName} = (props: LedProps) => {
10722
+ const { name = "LED1", ...restProps } = props
10723
+
10724
+ return (
10725
+ <led
10726
+ name={name}
10727
+ supplierPartNumbers={${JSON.stringify(supplierPartNumbers, null, " ")}}
10728
+ manufacturerPartNumber="${manufacturerPartNumber}"
10729
+ footprint={${footprintTsx}}
10730
+ ${objUrl || stepUrl ? `cadModel={{
10731
+ ${cadModelLines}
10732
+ }}` : ""}
10733
+ {...restProps}
10734
+ />
10735
+ )
10736
+ }
10715
10737
  `.trim();
10716
10738
  }
10717
10739
  return `
@@ -10765,7 +10787,39 @@ var isDiodeCategoryComponent = (betterEasy) => {
10765
10787
  ].some(categoryValueContainsDiode);
10766
10788
  };
10767
10789
 
10790
+ // lib/websafe/convert-to-typescript-component/category-value-contains-led.ts
10791
+ var categoryValueContainsLed = (value) => {
10792
+ if (typeof value === "string") {
10793
+ return /(^|[^a-z])leds?([^a-z]|$)/i.test(value) || /light[-\s]?emitting\s+diodes?/i.test(value);
10794
+ }
10795
+ if (Array.isArray(value)) {
10796
+ return value.some(categoryValueContainsLed);
10797
+ }
10798
+ if (value && typeof value === "object") {
10799
+ return Object.values(value).some(categoryValueContainsLed);
10800
+ }
10801
+ return false;
10802
+ };
10803
+
10804
+ // lib/websafe/convert-to-typescript-component/is-led-category-component.ts
10805
+ var isLedCategoryComponent = (betterEasy) => {
10806
+ const cPara = betterEasy.dataStr.head.c_para;
10807
+ return [
10808
+ betterEasy.tags,
10809
+ cPara.category,
10810
+ cPara.Category,
10811
+ cPara["LCSC Category"],
10812
+ cPara["JLCPCB Category"],
10813
+ betterEasy.category
10814
+ ].some(categoryValueContainsLed);
10815
+ };
10816
+
10768
10817
  // lib/websafe/convert-to-typescript-component/index.tsx
10818
+ var getGeneratedComponentType = (betterEasy) => {
10819
+ if (isLedCategoryComponent(betterEasy)) return "led";
10820
+ if (isDiodeCategoryComponent(betterEasy)) return "diode";
10821
+ return "chip";
10822
+ };
10769
10823
  var convertRawEasyToTsx = async ({ rawEasy }) => {
10770
10824
  const betterEasy = EasyEdaJsonSchema.parse(rawEasy);
10771
10825
  const result = await convertBetterEasyToTsx({
@@ -10830,7 +10884,7 @@ var convertBetterEasyToTsx = async ({
10830
10884
  stepUrl: modelStepUrl,
10831
10885
  circuitJson,
10832
10886
  supplierPartNumbers,
10833
- componentType: isDiodeCategoryComponent(betterEasy) ? "diode" : "chip"
10887
+ componentType: getGeneratedComponentType(betterEasy)
10834
10888
  });
10835
10889
  };
10836
10890
  var checkModelObjUrlValidity = async (url) => {