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/index.js
CHANGED
|
@@ -8485,11 +8485,11 @@ var generateShapeTsx = ({
|
|
|
8485
8485
|
x: shape.position.x + shape.width / 2,
|
|
8486
8486
|
y: shape.position.y + shape.height / 2
|
|
8487
8487
|
});
|
|
8488
|
-
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)}` : ""} />`;
|
|
8488
|
+
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)}` : ""} />`;
|
|
8489
8489
|
}
|
|
8490
8490
|
if (shape.type === "ELLIPSE") {
|
|
8491
8491
|
const center = transformPoint(shape.center);
|
|
8492
|
-
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)}` : ""} />`;
|
|
8492
|
+
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)}` : ""} />`;
|
|
8493
8493
|
}
|
|
8494
8494
|
if (shape.type === "POLYLINE" || shape.type === "POLYGON") {
|
|
8495
8495
|
const isPolygon = shape.type === "POLYGON";
|
|
@@ -8801,7 +8801,8 @@ var generateTypescriptComponent = ({
|
|
|
8801
8801
|
crystalFrequency,
|
|
8802
8802
|
crystalPinVariant,
|
|
8803
8803
|
symbolTsx,
|
|
8804
|
-
schPinArrangement
|
|
8804
|
+
schPinArrangement,
|
|
8805
|
+
useSymbolPortsOnly = false
|
|
8805
8806
|
}) => {
|
|
8806
8807
|
const safePinLabels = pinLabels ?? {};
|
|
8807
8808
|
const polarizedPinMetadata = getPolarizedPinMetadata(safePinLabels);
|
|
@@ -8842,6 +8843,11 @@ ${polarizedPinLabelsString}
|
|
|
8842
8843
|
|
|
8843
8844
|
` : "";
|
|
8844
8845
|
const polarizedPinLabelsProp = polarizedPinLabels ? ` pinLabels={pinLabels}
|
|
8846
|
+
` : "";
|
|
8847
|
+
const isPolarizedCapacitor = componentType === "capacitor" && circuitJson.filter((item) => item.type === "source_port").length === 2 && polarizedPinMetadata !== void 0;
|
|
8848
|
+
const capacitorPolarizedPinLabelsBlock = isPolarizedCapacitor ? polarizedPinLabelsBlock : "";
|
|
8849
|
+
const capacitorPolarizedPinLabelsProp = isPolarizedCapacitor ? polarizedPinLabelsProp : "";
|
|
8850
|
+
const polarizedProp = isPolarizedCapacitor ? ` polarized
|
|
8845
8851
|
` : "";
|
|
8846
8852
|
const symbolProp = symbolTsx ? ` symbol={
|
|
8847
8853
|
${symbolTsx.split("\n").map((line) => ` ${line}`).join("\n")}
|
|
@@ -8960,14 +8966,14 @@ ${cadModelLines}
|
|
|
8960
8966
|
return `
|
|
8961
8967
|
import type { CapacitorProps } from "@tscircuit/props"
|
|
8962
8968
|
|
|
8963
|
-
export const ${componentName} = (props: Omit<CapacitorProps, "capacitance">) => {
|
|
8969
|
+
${capacitorPolarizedPinLabelsBlock}export const ${componentName} = (props: Omit<CapacitorProps, "capacitance">) => {
|
|
8964
8970
|
const { name = "C1", ...restProps } = props
|
|
8965
8971
|
|
|
8966
8972
|
return (
|
|
8967
8973
|
<capacitor
|
|
8968
8974
|
name={name}
|
|
8969
8975
|
capacitance=${JSON.stringify(capacitance2)}
|
|
8970
|
-
${symbolProp} supplierPartNumbers={${JSON.stringify(supplierPartNumbers, null, " ")}}
|
|
8976
|
+
${capacitorPolarizedPinLabelsProp}${polarizedProp}${symbolProp} supplierPartNumbers={${JSON.stringify(supplierPartNumbers, null, " ")}}
|
|
8971
8977
|
manufacturerPartNumber="${manufacturerPartNumber}"
|
|
8972
8978
|
footprint={${footprintTsx}}
|
|
8973
8979
|
${objUrl || stepUrl ? `cadModel={{
|
|
@@ -9091,8 +9097,7 @@ ${pinLabelsString}
|
|
|
9091
9097
|
${pinAttributesBlock}export const ${componentName} = (props: ChipProps<typeof pinLabels>) => {
|
|
9092
9098
|
return (
|
|
9093
9099
|
<chip
|
|
9094
|
-
pinLabels={pinLabels}
|
|
9095
|
-
${pinAttributesProp}${symbolProp}${schPinArrangementProp} supplierPartNumbers={${JSON.stringify(supplierPartNumbers, null, " ")}}
|
|
9100
|
+
${useSymbolPortsOnly ? "" : " pinLabels={pinLabels}\n"}${pinAttributesProp}${symbolProp}${schPinArrangementProp} supplierPartNumbers={${JSON.stringify(supplierPartNumbers, null, " ")}}
|
|
9096
9101
|
manufacturerPartNumber="${manufacturerPartNumber}"
|
|
9097
9102
|
footprint={${footprintTsx}}
|
|
9098
9103
|
${objUrl || stepUrl ? `cadModel={{
|
|
@@ -9129,6 +9134,29 @@ var isCrystalComponent = (betterEasy) => {
|
|
|
9129
9134
|
return componentParameters.pre === "X?" && packageName?.toUpperCase().startsWith("CRYSTAL-") === true && typeof value === "string" && frequencyPattern.test(value.trim());
|
|
9130
9135
|
};
|
|
9131
9136
|
|
|
9137
|
+
// lib/websafe/convert-to-typescript-component/is-dip-switch-category-component.ts
|
|
9138
|
+
var categoryValueContainsDipSwitch = (value) => {
|
|
9139
|
+
if (typeof value === "string") {
|
|
9140
|
+
return /\bdip\s+switch(?:es)?\b/i.test(value);
|
|
9141
|
+
}
|
|
9142
|
+
if (Array.isArray(value)) return value.some(categoryValueContainsDipSwitch);
|
|
9143
|
+
if (value && typeof value === "object") {
|
|
9144
|
+
return Object.values(value).some(categoryValueContainsDipSwitch);
|
|
9145
|
+
}
|
|
9146
|
+
return false;
|
|
9147
|
+
};
|
|
9148
|
+
var isDipSwitchCategoryComponent = (betterEasy) => {
|
|
9149
|
+
const cPara = betterEasy.dataStr.head.c_para;
|
|
9150
|
+
return [
|
|
9151
|
+
betterEasy.tags,
|
|
9152
|
+
cPara.category,
|
|
9153
|
+
cPara.Category,
|
|
9154
|
+
cPara["LCSC Category"],
|
|
9155
|
+
cPara["JLCPCB Category"],
|
|
9156
|
+
betterEasy.category
|
|
9157
|
+
].some(categoryValueContainsDipSwitch);
|
|
9158
|
+
};
|
|
9159
|
+
|
|
9132
9160
|
// lib/websafe/convert-to-typescript-component/is-inductor-component.ts
|
|
9133
9161
|
var inductancePattern = /^\d+(?:\.\d+)?\s*(?:pH|nH|uH|µH|mH|H)$/i;
|
|
9134
9162
|
var isInductorComponent = (betterEasy) => {
|
|
@@ -9252,6 +9280,7 @@ var getGeneratedComponentType = (betterEasy, pinCount) => {
|
|
|
9252
9280
|
if (isLedCategoryComponent(betterEasy) && pinCount === 2) return "led";
|
|
9253
9281
|
if (isDiodeCategoryComponent(betterEasy) && pinCount === 2) return "diode";
|
|
9254
9282
|
if (isPushbuttonCategoryComponent(betterEasy)) return "pushbutton";
|
|
9283
|
+
if (isDipSwitchCategoryComponent(betterEasy)) return "chip";
|
|
9255
9284
|
if (isSwitchCategoryComponent(betterEasy)) return "switch";
|
|
9256
9285
|
if (isCapacitorComponent(betterEasy)) return "capacitor";
|
|
9257
9286
|
if (isResistorComponent(betterEasy) && pinCount === 2) return "resistor";
|
|
@@ -9350,6 +9379,7 @@ var convertBetterEasyToTsx = async ({
|
|
|
9350
9379
|
betterEasy,
|
|
9351
9380
|
sourcePorts.length
|
|
9352
9381
|
);
|
|
9382
|
+
const isDipSwitch = isDipSwitchCategoryComponent(betterEasy);
|
|
9353
9383
|
const inductance2 = componentType === "inductor" ? betterEasy.dataStr.head.c_para.Value?.trim() : void 0;
|
|
9354
9384
|
const capacitance2 = componentType === "capacitor" ? normalizeCapacitanceValue(betterEasy.dataStr.head.c_para.Value) : void 0;
|
|
9355
9385
|
const resistance2 = componentType === "resistor" ? normalizeResistorValue(betterEasy.dataStr.head.c_para.Value) : void 0;
|
|
@@ -9357,7 +9387,7 @@ var convertBetterEasyToTsx = async ({
|
|
|
9357
9387
|
const crystalPinVariant = componentType !== "crystal" ? void 0 : sourcePorts.length === 4 ? "four_pin" : sourcePorts.length === 2 ? "two_pin" : void 0;
|
|
9358
9388
|
const isMultiPinDiode = isDiodeCategoryComponent(betterEasy) && sourcePorts.length !== 2;
|
|
9359
9389
|
const isMultiPinInductor = isInductorComponent(betterEasy) && sourcePorts.length !== 2;
|
|
9360
|
-
const isPassiveWithCustomSymbol = componentType === "capacitor";
|
|
9390
|
+
const isPassiveWithCustomSymbol = componentType === "capacitor" && sourcePorts.length !== 2;
|
|
9361
9391
|
const symbolTsx = isPassiveWithCustomSymbol || componentType === "chip" && !isMultiPinDiode && !isMultiPinInductor && hasNonBoxSchematicSymbol(betterEasy) ? generateSymbolTsx(betterEasy, circuitJson, {
|
|
9362
9392
|
alignPortsToDrawing: isPassiveWithCustomSymbol
|
|
9363
9393
|
}) : void 0;
|
|
@@ -9377,7 +9407,8 @@ var convertBetterEasyToTsx = async ({
|
|
|
9377
9407
|
crystalFrequency,
|
|
9378
9408
|
crystalPinVariant,
|
|
9379
9409
|
symbolTsx,
|
|
9380
|
-
schPinArrangement
|
|
9410
|
+
schPinArrangement,
|
|
9411
|
+
useSymbolPortsOnly: isDipSwitch && Boolean(symbolTsx)
|
|
9381
9412
|
});
|
|
9382
9413
|
};
|
|
9383
9414
|
var checkModelObjUrlValidity = async (url) => {
|