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.
package/dist/index.js CHANGED
@@ -6896,7 +6896,7 @@ var getPinLabelValues = (labels) => {
6896
6896
  if (typeof labels === "string") return [labels];
6897
6897
  return [...labels];
6898
6898
  };
6899
- var getDiodePortHintsMap = (pinLabels) => {
6899
+ var getPolarizedPortHintsMap = (pinLabels) => {
6900
6900
  const labelsByPin = Object.entries(pinLabels ?? {}).map(([pin, labels]) => ({
6901
6901
  pin,
6902
6902
  labels: getPinLabelValues(labels).map((label) => label.toLowerCase())
@@ -6927,7 +6927,7 @@ var generateTypescriptComponent = ({
6927
6927
  const cadComponent = circuitJson.find((item) => item.type === "cad_component");
6928
6928
  const footprintTsx = generateFootprintTsx(
6929
6929
  circuitJson,
6930
- componentType === "diode" ? { portHintsMap: getDiodePortHintsMap(safePinLabels) } : void 0
6930
+ componentType === "diode" || componentType === "led" ? { portHintsMap: getPolarizedPortHintsMap(safePinLabels) } : void 0
6931
6931
  );
6932
6932
  const simplifiedPinLabels = Object.fromEntries(
6933
6933
  Object.entries(safePinLabels).map(([pin, labels]) => {
@@ -6964,6 +6964,28 @@ ${cadModelLines}
6964
6964
  />
6965
6965
  )
6966
6966
  }
6967
+ `.trim();
6968
+ }
6969
+ if (componentType === "led") {
6970
+ return `
6971
+ import type { LedProps } from "@tscircuit/props"
6972
+
6973
+ export const ${componentName} = (props: LedProps) => {
6974
+ const { name = "LED1", ...restProps } = props
6975
+
6976
+ return (
6977
+ <led
6978
+ name={name}
6979
+ supplierPartNumbers={${JSON.stringify(supplierPartNumbers, null, " ")}}
6980
+ manufacturerPartNumber="${manufacturerPartNumber}"
6981
+ footprint={${footprintTsx}}
6982
+ ${objUrl || stepUrl ? `cadModel={{
6983
+ ${cadModelLines}
6984
+ }}` : ""}
6985
+ {...restProps}
6986
+ />
6987
+ )
6988
+ }
6967
6989
  `.trim();
6968
6990
  }
6969
6991
  return `
@@ -7017,7 +7039,39 @@ var isDiodeCategoryComponent = (betterEasy) => {
7017
7039
  ].some(categoryValueContainsDiode);
7018
7040
  };
7019
7041
 
7042
+ // lib/websafe/convert-to-typescript-component/category-value-contains-led.ts
7043
+ var categoryValueContainsLed = (value) => {
7044
+ if (typeof value === "string") {
7045
+ return /(^|[^a-z])leds?([^a-z]|$)/i.test(value) || /light[-\s]?emitting\s+diodes?/i.test(value);
7046
+ }
7047
+ if (Array.isArray(value)) {
7048
+ return value.some(categoryValueContainsLed);
7049
+ }
7050
+ if (value && typeof value === "object") {
7051
+ return Object.values(value).some(categoryValueContainsLed);
7052
+ }
7053
+ return false;
7054
+ };
7055
+
7056
+ // lib/websafe/convert-to-typescript-component/is-led-category-component.ts
7057
+ var isLedCategoryComponent = (betterEasy) => {
7058
+ const cPara = betterEasy.dataStr.head.c_para;
7059
+ return [
7060
+ betterEasy.tags,
7061
+ cPara.category,
7062
+ cPara.Category,
7063
+ cPara["LCSC Category"],
7064
+ cPara["JLCPCB Category"],
7065
+ betterEasy.category
7066
+ ].some(categoryValueContainsLed);
7067
+ };
7068
+
7020
7069
  // lib/websafe/convert-to-typescript-component/index.tsx
7070
+ var getGeneratedComponentType = (betterEasy) => {
7071
+ if (isLedCategoryComponent(betterEasy)) return "led";
7072
+ if (isDiodeCategoryComponent(betterEasy)) return "diode";
7073
+ return "chip";
7074
+ };
7021
7075
  var convertRawEasyToTsx = async ({ rawEasy }) => {
7022
7076
  const betterEasy = EasyEdaJsonSchema.parse(rawEasy);
7023
7077
  const result = await convertBetterEasyToTsx({
@@ -7082,7 +7136,7 @@ var convertBetterEasyToTsx = async ({
7082
7136
  stepUrl: modelStepUrl,
7083
7137
  circuitJson,
7084
7138
  supplierPartNumbers,
7085
- componentType: isDiodeCategoryComponent(betterEasy) ? "diode" : "chip"
7139
+ componentType: getGeneratedComponentType(betterEasy)
7086
7140
  });
7087
7141
  };
7088
7142
  var checkModelObjUrlValidity = async (url) => {