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/browser/index.js
CHANGED
|
@@ -12170,11 +12170,11 @@ var generateShapeTsx = ({
|
|
|
12170
12170
|
x: shape.position.x + shape.width / 2,
|
|
12171
12171
|
y: shape.position.y + shape.height / 2
|
|
12172
12172
|
});
|
|
12173
|
-
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)}` : ""} />`;
|
|
12173
|
+
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)}` : ""} />`;
|
|
12174
12174
|
}
|
|
12175
12175
|
if (shape.type === "ELLIPSE") {
|
|
12176
12176
|
const center = transformPoint(shape.center);
|
|
12177
|
-
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)}` : ""} />`;
|
|
12177
|
+
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)}` : ""} />`;
|
|
12178
12178
|
}
|
|
12179
12179
|
if (shape.type === "POLYLINE" || shape.type === "POLYGON") {
|
|
12180
12180
|
const isPolygon = shape.type === "POLYGON";
|
|
@@ -12486,7 +12486,8 @@ var generateTypescriptComponent = ({
|
|
|
12486
12486
|
crystalFrequency,
|
|
12487
12487
|
crystalPinVariant,
|
|
12488
12488
|
symbolTsx,
|
|
12489
|
-
schPinArrangement
|
|
12489
|
+
schPinArrangement,
|
|
12490
|
+
useSymbolPortsOnly = false
|
|
12490
12491
|
}) => {
|
|
12491
12492
|
const safePinLabels = pinLabels ?? {};
|
|
12492
12493
|
const polarizedPinMetadata = getPolarizedPinMetadata(safePinLabels);
|
|
@@ -12527,6 +12528,11 @@ ${polarizedPinLabelsString}
|
|
|
12527
12528
|
|
|
12528
12529
|
` : "";
|
|
12529
12530
|
const polarizedPinLabelsProp = polarizedPinLabels ? ` pinLabels={pinLabels}
|
|
12531
|
+
` : "";
|
|
12532
|
+
const isPolarizedCapacitor = componentType === "capacitor" && circuitJson.filter((item) => item.type === "source_port").length === 2 && polarizedPinMetadata !== void 0;
|
|
12533
|
+
const capacitorPolarizedPinLabelsBlock = isPolarizedCapacitor ? polarizedPinLabelsBlock : "";
|
|
12534
|
+
const capacitorPolarizedPinLabelsProp = isPolarizedCapacitor ? polarizedPinLabelsProp : "";
|
|
12535
|
+
const polarizedProp = isPolarizedCapacitor ? ` polarized
|
|
12530
12536
|
` : "";
|
|
12531
12537
|
const symbolProp = symbolTsx ? ` symbol={
|
|
12532
12538
|
${symbolTsx.split("\n").map((line) => ` ${line}`).join("\n")}
|
|
@@ -12645,14 +12651,14 @@ ${cadModelLines}
|
|
|
12645
12651
|
return `
|
|
12646
12652
|
import type { CapacitorProps } from "@tscircuit/props"
|
|
12647
12653
|
|
|
12648
|
-
export const ${componentName} = (props: Omit<CapacitorProps, "capacitance">) => {
|
|
12654
|
+
${capacitorPolarizedPinLabelsBlock}export const ${componentName} = (props: Omit<CapacitorProps, "capacitance">) => {
|
|
12649
12655
|
const { name = "C1", ...restProps } = props
|
|
12650
12656
|
|
|
12651
12657
|
return (
|
|
12652
12658
|
<capacitor
|
|
12653
12659
|
name={name}
|
|
12654
12660
|
capacitance=${JSON.stringify(capacitance2)}
|
|
12655
|
-
${symbolProp} supplierPartNumbers={${JSON.stringify(supplierPartNumbers, null, " ")}}
|
|
12661
|
+
${capacitorPolarizedPinLabelsProp}${polarizedProp}${symbolProp} supplierPartNumbers={${JSON.stringify(supplierPartNumbers, null, " ")}}
|
|
12656
12662
|
manufacturerPartNumber="${manufacturerPartNumber}"
|
|
12657
12663
|
footprint={${footprintTsx}}
|
|
12658
12664
|
${objUrl || stepUrl ? `cadModel={{
|
|
@@ -12776,8 +12782,7 @@ ${pinLabelsString}
|
|
|
12776
12782
|
${pinAttributesBlock}export const ${componentName} = (props: ChipProps<typeof pinLabels>) => {
|
|
12777
12783
|
return (
|
|
12778
12784
|
<chip
|
|
12779
|
-
pinLabels={pinLabels}
|
|
12780
|
-
${pinAttributesProp}${symbolProp}${schPinArrangementProp} supplierPartNumbers={${JSON.stringify(supplierPartNumbers, null, " ")}}
|
|
12785
|
+
${useSymbolPortsOnly ? "" : " pinLabels={pinLabels}\n"}${pinAttributesProp}${symbolProp}${schPinArrangementProp} supplierPartNumbers={${JSON.stringify(supplierPartNumbers, null, " ")}}
|
|
12781
12786
|
manufacturerPartNumber="${manufacturerPartNumber}"
|
|
12782
12787
|
footprint={${footprintTsx}}
|
|
12783
12788
|
${objUrl || stepUrl ? `cadModel={{
|
|
@@ -12814,6 +12819,29 @@ var isCrystalComponent = (betterEasy) => {
|
|
|
12814
12819
|
return componentParameters.pre === "X?" && packageName?.toUpperCase().startsWith("CRYSTAL-") === true && typeof value === "string" && frequencyPattern.test(value.trim());
|
|
12815
12820
|
};
|
|
12816
12821
|
|
|
12822
|
+
// lib/websafe/convert-to-typescript-component/is-dip-switch-category-component.ts
|
|
12823
|
+
var categoryValueContainsDipSwitch = (value) => {
|
|
12824
|
+
if (typeof value === "string") {
|
|
12825
|
+
return /\bdip\s+switch(?:es)?\b/i.test(value);
|
|
12826
|
+
}
|
|
12827
|
+
if (Array.isArray(value)) return value.some(categoryValueContainsDipSwitch);
|
|
12828
|
+
if (value && typeof value === "object") {
|
|
12829
|
+
return Object.values(value).some(categoryValueContainsDipSwitch);
|
|
12830
|
+
}
|
|
12831
|
+
return false;
|
|
12832
|
+
};
|
|
12833
|
+
var isDipSwitchCategoryComponent = (betterEasy) => {
|
|
12834
|
+
const cPara = betterEasy.dataStr.head.c_para;
|
|
12835
|
+
return [
|
|
12836
|
+
betterEasy.tags,
|
|
12837
|
+
cPara.category,
|
|
12838
|
+
cPara.Category,
|
|
12839
|
+
cPara["LCSC Category"],
|
|
12840
|
+
cPara["JLCPCB Category"],
|
|
12841
|
+
betterEasy.category
|
|
12842
|
+
].some(categoryValueContainsDipSwitch);
|
|
12843
|
+
};
|
|
12844
|
+
|
|
12817
12845
|
// lib/websafe/convert-to-typescript-component/is-inductor-component.ts
|
|
12818
12846
|
var inductancePattern = /^\d+(?:\.\d+)?\s*(?:pH|nH|uH|µH|mH|H)$/i;
|
|
12819
12847
|
var isInductorComponent = (betterEasy) => {
|
|
@@ -12937,6 +12965,7 @@ var getGeneratedComponentType = (betterEasy, pinCount) => {
|
|
|
12937
12965
|
if (isLedCategoryComponent(betterEasy) && pinCount === 2) return "led";
|
|
12938
12966
|
if (isDiodeCategoryComponent(betterEasy) && pinCount === 2) return "diode";
|
|
12939
12967
|
if (isPushbuttonCategoryComponent(betterEasy)) return "pushbutton";
|
|
12968
|
+
if (isDipSwitchCategoryComponent(betterEasy)) return "chip";
|
|
12940
12969
|
if (isSwitchCategoryComponent(betterEasy)) return "switch";
|
|
12941
12970
|
if (isCapacitorComponent(betterEasy)) return "capacitor";
|
|
12942
12971
|
if (isResistorComponent(betterEasy) && pinCount === 2) return "resistor";
|
|
@@ -13035,6 +13064,7 @@ var convertBetterEasyToTsx = async ({
|
|
|
13035
13064
|
betterEasy,
|
|
13036
13065
|
sourcePorts.length
|
|
13037
13066
|
);
|
|
13067
|
+
const isDipSwitch = isDipSwitchCategoryComponent(betterEasy);
|
|
13038
13068
|
const inductance2 = componentType === "inductor" ? betterEasy.dataStr.head.c_para.Value?.trim() : void 0;
|
|
13039
13069
|
const capacitance2 = componentType === "capacitor" ? normalizeCapacitanceValue(betterEasy.dataStr.head.c_para.Value) : void 0;
|
|
13040
13070
|
const resistance2 = componentType === "resistor" ? normalizeResistorValue(betterEasy.dataStr.head.c_para.Value) : void 0;
|
|
@@ -13042,7 +13072,7 @@ var convertBetterEasyToTsx = async ({
|
|
|
13042
13072
|
const crystalPinVariant = componentType !== "crystal" ? void 0 : sourcePorts.length === 4 ? "four_pin" : sourcePorts.length === 2 ? "two_pin" : void 0;
|
|
13043
13073
|
const isMultiPinDiode = isDiodeCategoryComponent(betterEasy) && sourcePorts.length !== 2;
|
|
13044
13074
|
const isMultiPinInductor = isInductorComponent(betterEasy) && sourcePorts.length !== 2;
|
|
13045
|
-
const isPassiveWithCustomSymbol = componentType === "capacitor";
|
|
13075
|
+
const isPassiveWithCustomSymbol = componentType === "capacitor" && sourcePorts.length !== 2;
|
|
13046
13076
|
const symbolTsx = isPassiveWithCustomSymbol || componentType === "chip" && !isMultiPinDiode && !isMultiPinInductor && hasNonBoxSchematicSymbol(betterEasy) ? generateSymbolTsx(betterEasy, circuitJson, {
|
|
13047
13077
|
alignPortsToDrawing: isPassiveWithCustomSymbol
|
|
13048
13078
|
}) : void 0;
|
|
@@ -13062,7 +13092,8 @@ var convertBetterEasyToTsx = async ({
|
|
|
13062
13092
|
crystalFrequency,
|
|
13063
13093
|
crystalPinVariant,
|
|
13064
13094
|
symbolTsx,
|
|
13065
|
-
schPinArrangement
|
|
13095
|
+
schPinArrangement,
|
|
13096
|
+
useSymbolPortsOnly: isDipSwitch && Boolean(symbolTsx)
|
|
13066
13097
|
});
|
|
13067
13098
|
};
|
|
13068
13099
|
var checkModelObjUrlValidity = async (url) => {
|