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/browser/index.js +57 -3
- package/dist/browser/index.js.map +1 -1
- package/dist/index.js +57 -3
- package/dist/index.js.map +1 -1
- package/dist/main.cjs +58 -4
- package/dist/main.cjs.map +1 -1
- package/package.json +1 -1
package/dist/main.cjs
CHANGED
|
@@ -997,7 +997,7 @@ var import_promises = __toESM(require("fs/promises"), 1);
|
|
|
997
997
|
var package_default = {
|
|
998
998
|
name: "easyeda",
|
|
999
999
|
type: "module",
|
|
1000
|
-
version: "0.0.
|
|
1000
|
+
version: "0.0.262",
|
|
1001
1001
|
files: [
|
|
1002
1002
|
"dist"
|
|
1003
1003
|
],
|
|
@@ -7799,7 +7799,7 @@ var getPinLabelValues = (labels) => {
|
|
|
7799
7799
|
if (typeof labels === "string") return [labels];
|
|
7800
7800
|
return [...labels];
|
|
7801
7801
|
};
|
|
7802
|
-
var
|
|
7802
|
+
var getPolarizedPortHintsMap = (pinLabels) => {
|
|
7803
7803
|
const labelsByPin = Object.entries(pinLabels ?? {}).map(([pin, labels]) => ({
|
|
7804
7804
|
pin,
|
|
7805
7805
|
labels: getPinLabelValues(labels).map((label) => label.toLowerCase())
|
|
@@ -7830,7 +7830,7 @@ var generateTypescriptComponent = ({
|
|
|
7830
7830
|
const cadComponent = circuitJson.find((item) => item.type === "cad_component");
|
|
7831
7831
|
const footprintTsx = generateFootprintTsx(
|
|
7832
7832
|
circuitJson,
|
|
7833
|
-
componentType === "diode" ? { portHintsMap:
|
|
7833
|
+
componentType === "diode" || componentType === "led" ? { portHintsMap: getPolarizedPortHintsMap(safePinLabels) } : void 0
|
|
7834
7834
|
);
|
|
7835
7835
|
const simplifiedPinLabels = Object.fromEntries(
|
|
7836
7836
|
Object.entries(safePinLabels).map(([pin, labels]) => {
|
|
@@ -7867,6 +7867,28 @@ ${cadModelLines}
|
|
|
7867
7867
|
/>
|
|
7868
7868
|
)
|
|
7869
7869
|
}
|
|
7870
|
+
`.trim();
|
|
7871
|
+
}
|
|
7872
|
+
if (componentType === "led") {
|
|
7873
|
+
return `
|
|
7874
|
+
import type { LedProps } from "@tscircuit/props"
|
|
7875
|
+
|
|
7876
|
+
export const ${componentName} = (props: LedProps) => {
|
|
7877
|
+
const { name = "LED1", ...restProps } = props
|
|
7878
|
+
|
|
7879
|
+
return (
|
|
7880
|
+
<led
|
|
7881
|
+
name={name}
|
|
7882
|
+
supplierPartNumbers={${JSON.stringify(supplierPartNumbers, null, " ")}}
|
|
7883
|
+
manufacturerPartNumber="${manufacturerPartNumber}"
|
|
7884
|
+
footprint={${footprintTsx}}
|
|
7885
|
+
${objUrl || stepUrl ? `cadModel={{
|
|
7886
|
+
${cadModelLines}
|
|
7887
|
+
}}` : ""}
|
|
7888
|
+
{...restProps}
|
|
7889
|
+
/>
|
|
7890
|
+
)
|
|
7891
|
+
}
|
|
7870
7892
|
`.trim();
|
|
7871
7893
|
}
|
|
7872
7894
|
return `
|
|
@@ -7920,7 +7942,39 @@ var isDiodeCategoryComponent = (betterEasy) => {
|
|
|
7920
7942
|
].some(categoryValueContainsDiode);
|
|
7921
7943
|
};
|
|
7922
7944
|
|
|
7945
|
+
// lib/websafe/convert-to-typescript-component/category-value-contains-led.ts
|
|
7946
|
+
var categoryValueContainsLed = (value) => {
|
|
7947
|
+
if (typeof value === "string") {
|
|
7948
|
+
return /(^|[^a-z])leds?([^a-z]|$)/i.test(value) || /light[-\s]?emitting\s+diodes?/i.test(value);
|
|
7949
|
+
}
|
|
7950
|
+
if (Array.isArray(value)) {
|
|
7951
|
+
return value.some(categoryValueContainsLed);
|
|
7952
|
+
}
|
|
7953
|
+
if (value && typeof value === "object") {
|
|
7954
|
+
return Object.values(value).some(categoryValueContainsLed);
|
|
7955
|
+
}
|
|
7956
|
+
return false;
|
|
7957
|
+
};
|
|
7958
|
+
|
|
7959
|
+
// lib/websafe/convert-to-typescript-component/is-led-category-component.ts
|
|
7960
|
+
var isLedCategoryComponent = (betterEasy) => {
|
|
7961
|
+
const cPara = betterEasy.dataStr.head.c_para;
|
|
7962
|
+
return [
|
|
7963
|
+
betterEasy.tags,
|
|
7964
|
+
cPara.category,
|
|
7965
|
+
cPara.Category,
|
|
7966
|
+
cPara["LCSC Category"],
|
|
7967
|
+
cPara["JLCPCB Category"],
|
|
7968
|
+
betterEasy.category
|
|
7969
|
+
].some(categoryValueContainsLed);
|
|
7970
|
+
};
|
|
7971
|
+
|
|
7923
7972
|
// lib/websafe/convert-to-typescript-component/index.tsx
|
|
7973
|
+
var getGeneratedComponentType = (betterEasy) => {
|
|
7974
|
+
if (isLedCategoryComponent(betterEasy)) return "led";
|
|
7975
|
+
if (isDiodeCategoryComponent(betterEasy)) return "diode";
|
|
7976
|
+
return "chip";
|
|
7977
|
+
};
|
|
7924
7978
|
var convertRawEasyToTsx = async ({ rawEasy }) => {
|
|
7925
7979
|
const betterEasy = EasyEdaJsonSchema.parse(rawEasy);
|
|
7926
7980
|
const result = await convertBetterEasyToTsx({
|
|
@@ -7985,7 +8039,7 @@ var convertBetterEasyToTsx = async ({
|
|
|
7985
8039
|
stepUrl: modelStepUrl,
|
|
7986
8040
|
circuitJson,
|
|
7987
8041
|
supplierPartNumbers,
|
|
7988
|
-
componentType:
|
|
8042
|
+
componentType: getGeneratedComponentType(betterEasy)
|
|
7989
8043
|
});
|
|
7990
8044
|
};
|
|
7991
8045
|
var checkModelObjUrlValidity = async (url) => {
|