easyeda 0.0.336 → 0.0.338
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 +40 -9
- package/dist/browser/index.js.map +1 -1
- package/dist/index.js +40 -9
- package/dist/index.js.map +1 -1
- package/dist/main.cjs +41 -10
- package/dist/main.cjs.map +1 -1
- package/package.json +1 -1
package/dist/main.cjs
CHANGED
|
@@ -1026,7 +1026,7 @@ var import_promises = __toESM(require("fs/promises"), 1);
|
|
|
1026
1026
|
var package_default = {
|
|
1027
1027
|
name: "easyeda",
|
|
1028
1028
|
type: "module",
|
|
1029
|
-
version: "0.0.
|
|
1029
|
+
version: "0.0.337",
|
|
1030
1030
|
files: [
|
|
1031
1031
|
"dist"
|
|
1032
1032
|
],
|
|
@@ -9390,11 +9390,11 @@ var generateShapeTsx = ({
|
|
|
9390
9390
|
x: shape.position.x + shape.width / 2,
|
|
9391
9391
|
y: shape.position.y + shape.height / 2
|
|
9392
9392
|
});
|
|
9393
|
-
return `<schematicrect schX={${center.x}} schY={${center.y}} width={${toSchematicUnits(shape.width)}} height={${toSchematicUnits(shape.height)}} color=${JSON.stringify(shape.color)}${shape.fillColor && shape.fillColor !== "none" ? ` isFilled fillColor=${JSON.stringify(shape.fillColor)}` : ""} />`;
|
|
9393
|
+
return `<schematicrect schX={${center.x}} schY={${center.y}} width={${toSchematicUnits(shape.width)}} height={${toSchematicUnits(shape.height)}} strokeWidth={${toSchematicUnits(shape.lineWidth)}} color=${JSON.stringify(shape.color)}${shape.fillColor && shape.fillColor !== "none" ? ` isFilled fillColor=${JSON.stringify(shape.fillColor)}` : ""} />`;
|
|
9394
9394
|
}
|
|
9395
9395
|
if (shape.type === "ELLIPSE") {
|
|
9396
9396
|
const center = transformPoint(shape.center);
|
|
9397
|
-
return `<schematiccircle center={{ x: ${center.x}, y: ${center.y} }} radius={${toSchematicUnits(Math.max(shape.radiusX, shape.radiusY))}} color=${JSON.stringify(shape.color)}${shape.fillColor && shape.fillColor !== "none" ? ` isFilled fillColor=${JSON.stringify(shape.fillColor)}` : ""} />`;
|
|
9397
|
+
return `<schematiccircle center={{ x: ${center.x}, y: ${center.y} }} radius={${toSchematicUnits(Math.max(shape.radiusX, shape.radiusY))}} strokeWidth={${toSchematicUnits(shape.lineWidth)}} color=${JSON.stringify(shape.color)}${shape.fillColor && shape.fillColor !== "none" ? ` isFilled fillColor=${JSON.stringify(shape.fillColor)}` : ""} />`;
|
|
9398
9398
|
}
|
|
9399
9399
|
if (shape.type === "POLYLINE" || shape.type === "POLYGON") {
|
|
9400
9400
|
const isPolygon = shape.type === "POLYGON";
|
|
@@ -9706,7 +9706,8 @@ var generateTypescriptComponent = ({
|
|
|
9706
9706
|
crystalFrequency,
|
|
9707
9707
|
crystalPinVariant,
|
|
9708
9708
|
symbolTsx,
|
|
9709
|
-
schPinArrangement
|
|
9709
|
+
schPinArrangement,
|
|
9710
|
+
useSymbolPortsOnly = false
|
|
9710
9711
|
}) => {
|
|
9711
9712
|
const safePinLabels = pinLabels ?? {};
|
|
9712
9713
|
const polarizedPinMetadata = getPolarizedPinMetadata(safePinLabels);
|
|
@@ -9747,6 +9748,11 @@ ${polarizedPinLabelsString}
|
|
|
9747
9748
|
|
|
9748
9749
|
` : "";
|
|
9749
9750
|
const polarizedPinLabelsProp = polarizedPinLabels ? ` pinLabels={pinLabels}
|
|
9751
|
+
` : "";
|
|
9752
|
+
const isPolarizedCapacitor = componentType === "capacitor" && circuitJson.filter((item) => item.type === "source_port").length === 2 && polarizedPinMetadata !== void 0;
|
|
9753
|
+
const capacitorPolarizedPinLabelsBlock = isPolarizedCapacitor ? polarizedPinLabelsBlock : "";
|
|
9754
|
+
const capacitorPolarizedPinLabelsProp = isPolarizedCapacitor ? polarizedPinLabelsProp : "";
|
|
9755
|
+
const polarizedProp = isPolarizedCapacitor ? ` polarized
|
|
9750
9756
|
` : "";
|
|
9751
9757
|
const symbolProp = symbolTsx ? ` symbol={
|
|
9752
9758
|
${symbolTsx.split("\n").map((line) => ` ${line}`).join("\n")}
|
|
@@ -9865,14 +9871,14 @@ ${cadModelLines}
|
|
|
9865
9871
|
return `
|
|
9866
9872
|
import type { CapacitorProps } from "@tscircuit/props"
|
|
9867
9873
|
|
|
9868
|
-
export const ${componentName} = (props: Omit<CapacitorProps, "capacitance">) => {
|
|
9874
|
+
${capacitorPolarizedPinLabelsBlock}export const ${componentName} = (props: Omit<CapacitorProps, "capacitance">) => {
|
|
9869
9875
|
const { name = "C1", ...restProps } = props
|
|
9870
9876
|
|
|
9871
9877
|
return (
|
|
9872
9878
|
<capacitor
|
|
9873
9879
|
name={name}
|
|
9874
9880
|
capacitance=${JSON.stringify(capacitance2)}
|
|
9875
|
-
${symbolProp} supplierPartNumbers={${JSON.stringify(supplierPartNumbers, null, " ")}}
|
|
9881
|
+
${capacitorPolarizedPinLabelsProp}${polarizedProp}${symbolProp} supplierPartNumbers={${JSON.stringify(supplierPartNumbers, null, " ")}}
|
|
9876
9882
|
manufacturerPartNumber="${manufacturerPartNumber}"
|
|
9877
9883
|
footprint={${footprintTsx}}
|
|
9878
9884
|
${objUrl || stepUrl ? `cadModel={{
|
|
@@ -9996,8 +10002,7 @@ ${pinLabelsString}
|
|
|
9996
10002
|
${pinAttributesBlock}export const ${componentName} = (props: ChipProps<typeof pinLabels>) => {
|
|
9997
10003
|
return (
|
|
9998
10004
|
<chip
|
|
9999
|
-
pinLabels={pinLabels}
|
|
10000
|
-
${pinAttributesProp}${symbolProp}${schPinArrangementProp} supplierPartNumbers={${JSON.stringify(supplierPartNumbers, null, " ")}}
|
|
10005
|
+
${useSymbolPortsOnly ? "" : " pinLabels={pinLabels}\n"}${pinAttributesProp}${symbolProp}${schPinArrangementProp} supplierPartNumbers={${JSON.stringify(supplierPartNumbers, null, " ")}}
|
|
10001
10006
|
manufacturerPartNumber="${manufacturerPartNumber}"
|
|
10002
10007
|
footprint={${footprintTsx}}
|
|
10003
10008
|
${objUrl || stepUrl ? `cadModel={{
|
|
@@ -10034,6 +10039,29 @@ var isCrystalComponent = (betterEasy) => {
|
|
|
10034
10039
|
return componentParameters.pre === "X?" && packageName?.toUpperCase().startsWith("CRYSTAL-") === true && typeof value === "string" && frequencyPattern.test(value.trim());
|
|
10035
10040
|
};
|
|
10036
10041
|
|
|
10042
|
+
// lib/websafe/convert-to-typescript-component/is-dip-switch-category-component.ts
|
|
10043
|
+
var categoryValueContainsDipSwitch = (value) => {
|
|
10044
|
+
if (typeof value === "string") {
|
|
10045
|
+
return /\bdip\s+switch(?:es)?\b/i.test(value);
|
|
10046
|
+
}
|
|
10047
|
+
if (Array.isArray(value)) return value.some(categoryValueContainsDipSwitch);
|
|
10048
|
+
if (value && typeof value === "object") {
|
|
10049
|
+
return Object.values(value).some(categoryValueContainsDipSwitch);
|
|
10050
|
+
}
|
|
10051
|
+
return false;
|
|
10052
|
+
};
|
|
10053
|
+
var isDipSwitchCategoryComponent = (betterEasy) => {
|
|
10054
|
+
const cPara = betterEasy.dataStr.head.c_para;
|
|
10055
|
+
return [
|
|
10056
|
+
betterEasy.tags,
|
|
10057
|
+
cPara.category,
|
|
10058
|
+
cPara.Category,
|
|
10059
|
+
cPara["LCSC Category"],
|
|
10060
|
+
cPara["JLCPCB Category"],
|
|
10061
|
+
betterEasy.category
|
|
10062
|
+
].some(categoryValueContainsDipSwitch);
|
|
10063
|
+
};
|
|
10064
|
+
|
|
10037
10065
|
// lib/websafe/convert-to-typescript-component/is-inductor-component.ts
|
|
10038
10066
|
var inductancePattern = /^\d+(?:\.\d+)?\s*(?:pH|nH|uH|µH|mH|H)$/i;
|
|
10039
10067
|
var isInductorComponent = (betterEasy) => {
|
|
@@ -10157,6 +10185,7 @@ var getGeneratedComponentType = (betterEasy, pinCount) => {
|
|
|
10157
10185
|
if (isLedCategoryComponent(betterEasy) && pinCount === 2) return "led";
|
|
10158
10186
|
if (isDiodeCategoryComponent(betterEasy) && pinCount === 2) return "diode";
|
|
10159
10187
|
if (isPushbuttonCategoryComponent(betterEasy)) return "pushbutton";
|
|
10188
|
+
if (isDipSwitchCategoryComponent(betterEasy)) return "chip";
|
|
10160
10189
|
if (isSwitchCategoryComponent(betterEasy)) return "switch";
|
|
10161
10190
|
if (isCapacitorComponent(betterEasy)) return "capacitor";
|
|
10162
10191
|
if (isResistorComponent(betterEasy) && pinCount === 2) return "resistor";
|
|
@@ -10255,6 +10284,7 @@ var convertBetterEasyToTsx = async ({
|
|
|
10255
10284
|
betterEasy,
|
|
10256
10285
|
sourcePorts.length
|
|
10257
10286
|
);
|
|
10287
|
+
const isDipSwitch = isDipSwitchCategoryComponent(betterEasy);
|
|
10258
10288
|
const inductance2 = componentType === "inductor" ? betterEasy.dataStr.head.c_para.Value?.trim() : void 0;
|
|
10259
10289
|
const capacitance2 = componentType === "capacitor" ? normalizeCapacitanceValue(betterEasy.dataStr.head.c_para.Value) : void 0;
|
|
10260
10290
|
const resistance2 = componentType === "resistor" ? normalizeResistorValue(betterEasy.dataStr.head.c_para.Value) : void 0;
|
|
@@ -10262,7 +10292,7 @@ var convertBetterEasyToTsx = async ({
|
|
|
10262
10292
|
const crystalPinVariant = componentType !== "crystal" ? void 0 : sourcePorts.length === 4 ? "four_pin" : sourcePorts.length === 2 ? "two_pin" : void 0;
|
|
10263
10293
|
const isMultiPinDiode = isDiodeCategoryComponent(betterEasy) && sourcePorts.length !== 2;
|
|
10264
10294
|
const isMultiPinInductor = isInductorComponent(betterEasy) && sourcePorts.length !== 2;
|
|
10265
|
-
const isPassiveWithCustomSymbol = componentType === "capacitor";
|
|
10295
|
+
const isPassiveWithCustomSymbol = componentType === "capacitor" && sourcePorts.length !== 2;
|
|
10266
10296
|
const symbolTsx = isPassiveWithCustomSymbol || componentType === "chip" && !isMultiPinDiode && !isMultiPinInductor && hasNonBoxSchematicSymbol(betterEasy) ? generateSymbolTsx(betterEasy, circuitJson, {
|
|
10267
10297
|
alignPortsToDrawing: isPassiveWithCustomSymbol
|
|
10268
10298
|
}) : void 0;
|
|
@@ -10282,7 +10312,8 @@ var convertBetterEasyToTsx = async ({
|
|
|
10282
10312
|
crystalFrequency,
|
|
10283
10313
|
crystalPinVariant,
|
|
10284
10314
|
symbolTsx,
|
|
10285
|
-
schPinArrangement
|
|
10315
|
+
schPinArrangement,
|
|
10316
|
+
useSymbolPortsOnly: isDipSwitch && Boolean(symbolTsx)
|
|
10286
10317
|
});
|
|
10287
10318
|
};
|
|
10288
10319
|
var checkModelObjUrlValidity = async (url) => {
|