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/browser/index.js
CHANGED
|
@@ -11454,6 +11454,9 @@ var generateTypescriptComponent = ({
|
|
|
11454
11454
|
supplierPartNumbers,
|
|
11455
11455
|
manufacturerPartNumber,
|
|
11456
11456
|
componentType = "chip",
|
|
11457
|
+
inductance: inductance2,
|
|
11458
|
+
crystalFrequency,
|
|
11459
|
+
crystalPinVariant,
|
|
11457
11460
|
symbolTsx
|
|
11458
11461
|
}) => {
|
|
11459
11462
|
const safePinLabels = pinLabels ?? {};
|
|
@@ -11588,6 +11591,58 @@ ${cadModelLines}
|
|
|
11588
11591
|
/>
|
|
11589
11592
|
)
|
|
11590
11593
|
}
|
|
11594
|
+
`.trim();
|
|
11595
|
+
}
|
|
11596
|
+
if (componentType === "inductor") {
|
|
11597
|
+
if (!inductance2) {
|
|
11598
|
+
throw new Error("Inductance is required for inductor components");
|
|
11599
|
+
}
|
|
11600
|
+
return `
|
|
11601
|
+
import type { InductorProps } from "@tscircuit/props"
|
|
11602
|
+
|
|
11603
|
+
export const ${componentName} = (props: Omit<InductorProps, "inductance">) => {
|
|
11604
|
+
return (
|
|
11605
|
+
<inductor
|
|
11606
|
+
inductance=${JSON.stringify(inductance2)}
|
|
11607
|
+
supplierPartNumbers={${JSON.stringify(supplierPartNumbers, null, " ")}}
|
|
11608
|
+
manufacturerPartNumber="${manufacturerPartNumber}"
|
|
11609
|
+
footprint={${footprintTsx}}
|
|
11610
|
+
${objUrl || stepUrl ? `cadModel={{
|
|
11611
|
+
${cadModelLines}
|
|
11612
|
+
}}` : ""}
|
|
11613
|
+
{...props}
|
|
11614
|
+
/>
|
|
11615
|
+
)
|
|
11616
|
+
}
|
|
11617
|
+
`.trim();
|
|
11618
|
+
}
|
|
11619
|
+
if (componentType === "crystal") {
|
|
11620
|
+
if (!crystalFrequency || !crystalPinVariant) {
|
|
11621
|
+
throw new Error("Crystal frequency and pin variant are required");
|
|
11622
|
+
}
|
|
11623
|
+
return `
|
|
11624
|
+
import type { CrystalProps } from "@tscircuit/props"
|
|
11625
|
+
|
|
11626
|
+
type ImportedCrystalProps = Omit<CrystalProps, "frequency" | "pinVariant">
|
|
11627
|
+
|
|
11628
|
+
export const ${componentName} = (props: ImportedCrystalProps) => {
|
|
11629
|
+
const { name = "X1", ...restProps } = props
|
|
11630
|
+
|
|
11631
|
+
return (
|
|
11632
|
+
<crystal
|
|
11633
|
+
name={name}
|
|
11634
|
+
frequency=${JSON.stringify(crystalFrequency)}
|
|
11635
|
+
pinVariant=${JSON.stringify(crystalPinVariant)}
|
|
11636
|
+
supplierPartNumbers={${JSON.stringify(supplierPartNumbers, null, " ")}}
|
|
11637
|
+
manufacturerPartNumber="${manufacturerPartNumber}"
|
|
11638
|
+
footprint={${footprintTsx}}
|
|
11639
|
+
${objUrl || stepUrl ? `cadModel={{
|
|
11640
|
+
${cadModelLines}
|
|
11641
|
+
}}` : ""}
|
|
11642
|
+
{...restProps}
|
|
11643
|
+
/>
|
|
11644
|
+
)
|
|
11645
|
+
}
|
|
11591
11646
|
`.trim();
|
|
11592
11647
|
}
|
|
11593
11648
|
return `
|
|
@@ -11614,6 +11669,24 @@ ${cadModelLines}
|
|
|
11614
11669
|
`.trim();
|
|
11615
11670
|
};
|
|
11616
11671
|
|
|
11672
|
+
// lib/websafe/convert-to-typescript-component/is-crystal-component.ts
|
|
11673
|
+
var frequencyPattern = /^\d+(?:\.\d+)?\s*(?:Hz|kHz|MHz|GHz)$/i;
|
|
11674
|
+
var isCrystalComponent = (betterEasy) => {
|
|
11675
|
+
const componentParameters = betterEasy.dataStr.head.c_para;
|
|
11676
|
+
const packageName = componentParameters.package;
|
|
11677
|
+
const value = componentParameters.Value;
|
|
11678
|
+
return componentParameters.pre === "X?" && packageName?.toUpperCase().startsWith("CRYSTAL-") === true && typeof value === "string" && frequencyPattern.test(value.trim());
|
|
11679
|
+
};
|
|
11680
|
+
|
|
11681
|
+
// lib/websafe/convert-to-typescript-component/is-inductor-component.ts
|
|
11682
|
+
var inductancePattern = /^\d+(?:\.\d+)?\s*(?:pH|nH|uH|µH|mH|H)$/i;
|
|
11683
|
+
var isInductorComponent = (betterEasy) => {
|
|
11684
|
+
const componentParameters = betterEasy.dataStr.head.c_para;
|
|
11685
|
+
const packageName = componentParameters.package;
|
|
11686
|
+
const value = componentParameters.Value;
|
|
11687
|
+
return packageName?.toUpperCase().startsWith("IND-") === true && typeof value === "string" && inductancePattern.test(value.trim());
|
|
11688
|
+
};
|
|
11689
|
+
|
|
11617
11690
|
// lib/websafe/convert-to-typescript-component/category-value-contains-pushbutton.ts
|
|
11618
11691
|
var categoryValueContainsPushbutton = (value) => {
|
|
11619
11692
|
if (typeof value === "string") {
|
|
@@ -11982,6 +12055,8 @@ var getGeneratedComponentType = (betterEasy) => {
|
|
|
11982
12055
|
if (isDiodeCategoryComponent(betterEasy)) return "diode";
|
|
11983
12056
|
if (isPushbuttonCategoryComponent(betterEasy)) return "pushbutton";
|
|
11984
12057
|
if (isSwitchCategoryComponent(betterEasy)) return "switch";
|
|
12058
|
+
if (isInductorComponent(betterEasy)) return "inductor";
|
|
12059
|
+
if (isCrystalComponent(betterEasy)) return "crystal";
|
|
11985
12060
|
return "chip";
|
|
11986
12061
|
};
|
|
11987
12062
|
var convertRawEasyToTsx = async ({ rawEasy }) => {
|
|
@@ -12009,8 +12084,13 @@ var convertBetterEasyToTsx = async ({
|
|
|
12009
12084
|
cadComponent.position.x = 0;
|
|
12010
12085
|
cadComponent.position.y = 0;
|
|
12011
12086
|
}
|
|
12012
|
-
const
|
|
12013
|
-
|
|
12087
|
+
const manufacturerPartNumber = betterEasy.dataStr.head.c_para["Manufacturer Part"];
|
|
12088
|
+
if (!manufacturerPartNumber) {
|
|
12089
|
+
throw new Error(
|
|
12090
|
+
`Missing manufacturer part number for ${betterEasy.lcsc.number}`
|
|
12091
|
+
);
|
|
12092
|
+
}
|
|
12093
|
+
const componentName = normalizeManufacturerPartNumber(manufacturerPartNumber);
|
|
12014
12094
|
const sourcePorts = su(circuitJson).source_port.list();
|
|
12015
12095
|
const pinLabels = {};
|
|
12016
12096
|
const sortedPorts = sourcePorts.sort((a, b) => {
|
|
@@ -12042,16 +12122,22 @@ var convertBetterEasyToTsx = async ({
|
|
|
12042
12122
|
jlcpcb: [betterEasy.lcsc.number]
|
|
12043
12123
|
};
|
|
12044
12124
|
const componentType = getGeneratedComponentType(betterEasy);
|
|
12125
|
+
const inductance2 = componentType === "inductor" ? betterEasy.dataStr.head.c_para.Value?.trim() : void 0;
|
|
12126
|
+
const crystalFrequency = componentType === "crystal" ? betterEasy.dataStr.head.c_para.Value?.trim() : void 0;
|
|
12127
|
+
const crystalPinVariant = componentType !== "crystal" ? void 0 : sourcePorts.length === 4 ? "four_pin" : sourcePorts.length === 2 ? "two_pin" : void 0;
|
|
12045
12128
|
const symbolTsx = componentType === "chip" && hasNonBoxSchematicSymbol(betterEasy) ? generateSymbolTsx(betterEasy, circuitJson) : void 0;
|
|
12046
12129
|
return generateTypescriptComponent({
|
|
12047
|
-
componentName
|
|
12048
|
-
manufacturerPartNumber
|
|
12130
|
+
componentName,
|
|
12131
|
+
manufacturerPartNumber,
|
|
12049
12132
|
pinLabels,
|
|
12050
12133
|
objUrl: modelObjUrl,
|
|
12051
12134
|
stepUrl: modelStepUrl,
|
|
12052
12135
|
circuitJson,
|
|
12053
12136
|
supplierPartNumbers,
|
|
12054
12137
|
componentType,
|
|
12138
|
+
inductance: inductance2,
|
|
12139
|
+
crystalFrequency,
|
|
12140
|
+
crystalPinVariant,
|
|
12055
12141
|
symbolTsx
|
|
12056
12142
|
});
|
|
12057
12143
|
};
|