easyeda 0.0.288 → 0.0.290
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 +90 -4
- package/dist/browser/index.js.map +1 -1
- package/dist/index.js +90 -4
- package/dist/index.js.map +1 -1
- package/dist/main.cjs +91 -5
- package/dist/main.cjs.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -7755,6 +7755,9 @@ var generateTypescriptComponent = ({
|
|
|
7755
7755
|
supplierPartNumbers,
|
|
7756
7756
|
manufacturerPartNumber,
|
|
7757
7757
|
componentType = "chip",
|
|
7758
|
+
inductance: inductance2,
|
|
7759
|
+
crystalFrequency,
|
|
7760
|
+
crystalPinVariant,
|
|
7758
7761
|
symbolTsx
|
|
7759
7762
|
}) => {
|
|
7760
7763
|
const safePinLabels = pinLabels ?? {};
|
|
@@ -7889,6 +7892,58 @@ ${cadModelLines}
|
|
|
7889
7892
|
/>
|
|
7890
7893
|
)
|
|
7891
7894
|
}
|
|
7895
|
+
`.trim();
|
|
7896
|
+
}
|
|
7897
|
+
if (componentType === "inductor") {
|
|
7898
|
+
if (!inductance2) {
|
|
7899
|
+
throw new Error("Inductance is required for inductor components");
|
|
7900
|
+
}
|
|
7901
|
+
return `
|
|
7902
|
+
import type { InductorProps } from "@tscircuit/props"
|
|
7903
|
+
|
|
7904
|
+
export const ${componentName} = (props: Omit<InductorProps, "inductance">) => {
|
|
7905
|
+
return (
|
|
7906
|
+
<inductor
|
|
7907
|
+
inductance=${JSON.stringify(inductance2)}
|
|
7908
|
+
supplierPartNumbers={${JSON.stringify(supplierPartNumbers, null, " ")}}
|
|
7909
|
+
manufacturerPartNumber="${manufacturerPartNumber}"
|
|
7910
|
+
footprint={${footprintTsx}}
|
|
7911
|
+
${objUrl || stepUrl ? `cadModel={{
|
|
7912
|
+
${cadModelLines}
|
|
7913
|
+
}}` : ""}
|
|
7914
|
+
{...props}
|
|
7915
|
+
/>
|
|
7916
|
+
)
|
|
7917
|
+
}
|
|
7918
|
+
`.trim();
|
|
7919
|
+
}
|
|
7920
|
+
if (componentType === "crystal") {
|
|
7921
|
+
if (!crystalFrequency || !crystalPinVariant) {
|
|
7922
|
+
throw new Error("Crystal frequency and pin variant are required");
|
|
7923
|
+
}
|
|
7924
|
+
return `
|
|
7925
|
+
import type { CrystalProps } from "@tscircuit/props"
|
|
7926
|
+
|
|
7927
|
+
type ImportedCrystalProps = Omit<CrystalProps, "frequency" | "pinVariant">
|
|
7928
|
+
|
|
7929
|
+
export const ${componentName} = (props: ImportedCrystalProps) => {
|
|
7930
|
+
const { name = "X1", ...restProps } = props
|
|
7931
|
+
|
|
7932
|
+
return (
|
|
7933
|
+
<crystal
|
|
7934
|
+
name={name}
|
|
7935
|
+
frequency=${JSON.stringify(crystalFrequency)}
|
|
7936
|
+
pinVariant=${JSON.stringify(crystalPinVariant)}
|
|
7937
|
+
supplierPartNumbers={${JSON.stringify(supplierPartNumbers, null, " ")}}
|
|
7938
|
+
manufacturerPartNumber="${manufacturerPartNumber}"
|
|
7939
|
+
footprint={${footprintTsx}}
|
|
7940
|
+
${objUrl || stepUrl ? `cadModel={{
|
|
7941
|
+
${cadModelLines}
|
|
7942
|
+
}}` : ""}
|
|
7943
|
+
{...restProps}
|
|
7944
|
+
/>
|
|
7945
|
+
)
|
|
7946
|
+
}
|
|
7892
7947
|
`.trim();
|
|
7893
7948
|
}
|
|
7894
7949
|
return `
|
|
@@ -7915,6 +7970,24 @@ ${cadModelLines}
|
|
|
7915
7970
|
`.trim();
|
|
7916
7971
|
};
|
|
7917
7972
|
|
|
7973
|
+
// lib/websafe/convert-to-typescript-component/is-crystal-component.ts
|
|
7974
|
+
var frequencyPattern = /^\d+(?:\.\d+)?\s*(?:Hz|kHz|MHz|GHz)$/i;
|
|
7975
|
+
var isCrystalComponent = (betterEasy) => {
|
|
7976
|
+
const componentParameters = betterEasy.dataStr.head.c_para;
|
|
7977
|
+
const packageName = componentParameters.package;
|
|
7978
|
+
const value = componentParameters.Value;
|
|
7979
|
+
return componentParameters.pre === "X?" && packageName?.toUpperCase().startsWith("CRYSTAL-") === true && typeof value === "string" && frequencyPattern.test(value.trim());
|
|
7980
|
+
};
|
|
7981
|
+
|
|
7982
|
+
// lib/websafe/convert-to-typescript-component/is-inductor-component.ts
|
|
7983
|
+
var inductancePattern = /^\d+(?:\.\d+)?\s*(?:pH|nH|uH|µH|mH|H)$/i;
|
|
7984
|
+
var isInductorComponent = (betterEasy) => {
|
|
7985
|
+
const componentParameters = betterEasy.dataStr.head.c_para;
|
|
7986
|
+
const packageName = componentParameters.package;
|
|
7987
|
+
const value = componentParameters.Value;
|
|
7988
|
+
return packageName?.toUpperCase().startsWith("IND-") === true && typeof value === "string" && inductancePattern.test(value.trim());
|
|
7989
|
+
};
|
|
7990
|
+
|
|
7918
7991
|
// lib/websafe/convert-to-typescript-component/category-value-contains-pushbutton.ts
|
|
7919
7992
|
var categoryValueContainsPushbutton = (value) => {
|
|
7920
7993
|
if (typeof value === "string") {
|
|
@@ -8283,6 +8356,8 @@ var getGeneratedComponentType = (betterEasy) => {
|
|
|
8283
8356
|
if (isDiodeCategoryComponent(betterEasy)) return "diode";
|
|
8284
8357
|
if (isPushbuttonCategoryComponent(betterEasy)) return "pushbutton";
|
|
8285
8358
|
if (isSwitchCategoryComponent(betterEasy)) return "switch";
|
|
8359
|
+
if (isInductorComponent(betterEasy)) return "inductor";
|
|
8360
|
+
if (isCrystalComponent(betterEasy)) return "crystal";
|
|
8286
8361
|
return "chip";
|
|
8287
8362
|
};
|
|
8288
8363
|
var convertRawEasyToTsx = async ({ rawEasy }) => {
|
|
@@ -8310,8 +8385,13 @@ var convertBetterEasyToTsx = async ({
|
|
|
8310
8385
|
cadComponent.position.x = 0;
|
|
8311
8386
|
cadComponent.position.y = 0;
|
|
8312
8387
|
}
|
|
8313
|
-
const
|
|
8314
|
-
|
|
8388
|
+
const manufacturerPartNumber = betterEasy.dataStr.head.c_para["Manufacturer Part"];
|
|
8389
|
+
if (!manufacturerPartNumber) {
|
|
8390
|
+
throw new Error(
|
|
8391
|
+
`Missing manufacturer part number for ${betterEasy.lcsc.number}`
|
|
8392
|
+
);
|
|
8393
|
+
}
|
|
8394
|
+
const componentName = normalizeManufacturerPartNumber(manufacturerPartNumber);
|
|
8315
8395
|
const sourcePorts = su(circuitJson).source_port.list();
|
|
8316
8396
|
const pinLabels = {};
|
|
8317
8397
|
const sortedPorts = sourcePorts.sort((a, b) => {
|
|
@@ -8343,16 +8423,22 @@ var convertBetterEasyToTsx = async ({
|
|
|
8343
8423
|
jlcpcb: [betterEasy.lcsc.number]
|
|
8344
8424
|
};
|
|
8345
8425
|
const componentType = getGeneratedComponentType(betterEasy);
|
|
8426
|
+
const inductance2 = componentType === "inductor" ? betterEasy.dataStr.head.c_para.Value?.trim() : void 0;
|
|
8427
|
+
const crystalFrequency = componentType === "crystal" ? betterEasy.dataStr.head.c_para.Value?.trim() : void 0;
|
|
8428
|
+
const crystalPinVariant = componentType !== "crystal" ? void 0 : sourcePorts.length === 4 ? "four_pin" : sourcePorts.length === 2 ? "two_pin" : void 0;
|
|
8346
8429
|
const symbolTsx = componentType === "chip" && hasNonBoxSchematicSymbol(betterEasy) ? generateSymbolTsx(betterEasy, circuitJson) : void 0;
|
|
8347
8430
|
return generateTypescriptComponent({
|
|
8348
|
-
componentName
|
|
8349
|
-
manufacturerPartNumber
|
|
8431
|
+
componentName,
|
|
8432
|
+
manufacturerPartNumber,
|
|
8350
8433
|
pinLabels,
|
|
8351
8434
|
objUrl: modelObjUrl,
|
|
8352
8435
|
stepUrl: modelStepUrl,
|
|
8353
8436
|
circuitJson,
|
|
8354
8437
|
supplierPartNumbers,
|
|
8355
8438
|
componentType,
|
|
8439
|
+
inductance: inductance2,
|
|
8440
|
+
crystalFrequency,
|
|
8441
|
+
crystalPinVariant,
|
|
8356
8442
|
symbolTsx
|
|
8357
8443
|
});
|
|
8358
8444
|
};
|