easyeda 0.0.272 → 0.0.273
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 +33 -10
- package/dist/browser/index.js.map +1 -1
- package/dist/index.js +33 -10
- package/dist/index.js.map +1 -1
- package/dist/main.cjs +34 -11
- package/dist/main.cjs.map +1 -1
- package/package.json +1 -1
package/dist/main.cjs
CHANGED
|
@@ -3499,7 +3499,7 @@ var import_promises = __toESM(require("fs/promises"), 1);
|
|
|
3499
3499
|
var package_default = {
|
|
3500
3500
|
name: "easyeda",
|
|
3501
3501
|
type: "module",
|
|
3502
|
-
version: "0.0.
|
|
3502
|
+
version: "0.0.272",
|
|
3503
3503
|
files: [
|
|
3504
3504
|
"dist"
|
|
3505
3505
|
],
|
|
@@ -10964,11 +10964,11 @@ var generateFootprintTsx = (circuitJson, options = {}) => {
|
|
|
10964
10964
|
const cornerRadius = smtPad.corner_radius ?? smtPad.rect_border_radius ?? void 0;
|
|
10965
10965
|
const cornerRadiusAttr = cornerRadius !== void 0 ? ` cornerRadius="${mmStr(cornerRadius)}"` : "";
|
|
10966
10966
|
elementStrings.push(
|
|
10967
|
-
`<smtpad portHints={${JSON.stringify(smtPad.port_hints)}} pcbX="${mmStr(smtPad.x)}" pcbY="${mmStr(smtPad.y)}" width="${mmStr(smtPad.width)}" height="${mmStr(smtPad.height)}"${cornerRadiusAttr} shape="rect" />`
|
|
10967
|
+
`<smtpad portHints={${JSON.stringify(mapPortHints(smtPad.port_hints, options.portHintsMap))}} pcbX="${mmStr(smtPad.x)}" pcbY="${mmStr(smtPad.y)}" width="${mmStr(smtPad.width)}" height="${mmStr(smtPad.height)}"${cornerRadiusAttr} shape="rect" />`
|
|
10968
10968
|
);
|
|
10969
10969
|
} else if (smtPad.shape === "pill") {
|
|
10970
10970
|
elementStrings.push(
|
|
10971
|
-
`<smtpad portHints={${JSON.stringify(smtPad.port_hints)}} pcbX="${mmStr(smtPad.x)}" pcbY="${mmStr(smtPad.y)}" width="${mmStr(smtPad.width)}" height="${mmStr(smtPad.height)}" radius="${mmStr(smtPad.radius)}" shape="pill" />`
|
|
10971
|
+
`<smtpad portHints={${JSON.stringify(mapPortHints(smtPad.port_hints, options.portHintsMap))}} pcbX="${mmStr(smtPad.x)}" pcbY="${mmStr(smtPad.y)}" width="${mmStr(smtPad.width)}" height="${mmStr(smtPad.height)}" radius="${mmStr(smtPad.radius)}" shape="pill" />`
|
|
10972
10972
|
);
|
|
10973
10973
|
} else if (smtPad.shape === "polygon") {
|
|
10974
10974
|
const pointsStr = smtPad.points.map((p) => `{x: "${mmStr(p.x)}", y: "${mmStr(p.y)}"}`).join(", ");
|
|
@@ -11011,7 +11011,11 @@ var getPinLabelValues = (labels) => {
|
|
|
11011
11011
|
if (typeof labels === "string") return [labels];
|
|
11012
11012
|
return [...labels];
|
|
11013
11013
|
};
|
|
11014
|
-
var
|
|
11014
|
+
var getPinKeySortValue = (pinKey) => {
|
|
11015
|
+
const match = /^pin(\d+)$/i.exec(pinKey);
|
|
11016
|
+
return match ? Number(match[1]) : Number.MAX_SAFE_INTEGER;
|
|
11017
|
+
};
|
|
11018
|
+
var getPolarizedPinMetadata = (pinLabels) => {
|
|
11015
11019
|
const labelsByPin = Object.entries(pinLabels ?? {}).map(([pin, labels]) => ({
|
|
11016
11020
|
pin,
|
|
11017
11021
|
labels: getPinLabelValues(labels).map((label) => label.toLowerCase())
|
|
@@ -11023,9 +11027,17 @@ var getPolarizedPortHintsMap = (pinLabels) => {
|
|
|
11023
11027
|
({ labels }) => labels.some((label) => ["c", "k", "cathode", "neg", "-"].includes(label))
|
|
11024
11028
|
)?.pin;
|
|
11025
11029
|
if (!anodePin || !cathodePin) return void 0;
|
|
11030
|
+
const polarizedPinEntries = [
|
|
11031
|
+
[anodePin, ["anode", "pos"]],
|
|
11032
|
+
[cathodePin, ["cathode", "neg"]]
|
|
11033
|
+
].sort(
|
|
11034
|
+
([pinA], [pinB]) => getPinKeySortValue(pinA) - getPinKeySortValue(pinB)
|
|
11035
|
+
);
|
|
11026
11036
|
return {
|
|
11027
|
-
|
|
11028
|
-
|
|
11037
|
+
portHintsMap: Object.fromEntries(
|
|
11038
|
+
polarizedPinEntries.map(([pin, labels]) => [pin, [pin, ...labels]])
|
|
11039
|
+
),
|
|
11040
|
+
pinLabels: Object.fromEntries(polarizedPinEntries)
|
|
11029
11041
|
};
|
|
11030
11042
|
};
|
|
11031
11043
|
var generateTypescriptComponent = ({
|
|
@@ -11039,10 +11051,13 @@ var generateTypescriptComponent = ({
|
|
|
11039
11051
|
componentType = "chip"
|
|
11040
11052
|
}) => {
|
|
11041
11053
|
const safePinLabels = pinLabels ?? {};
|
|
11054
|
+
const polarizedPinMetadata = getPolarizedPinMetadata(safePinLabels);
|
|
11055
|
+
const polarizedPortHintsMap = polarizedPinMetadata?.portHintsMap;
|
|
11056
|
+
const polarizedPinLabels = polarizedPinMetadata?.pinLabels;
|
|
11042
11057
|
const cadComponent = circuitJson.find((item) => item.type === "cad_component");
|
|
11043
11058
|
const footprintTsx = generateFootprintTsx(
|
|
11044
11059
|
circuitJson,
|
|
11045
|
-
componentType === "diode" || componentType === "led" ? { portHintsMap:
|
|
11060
|
+
componentType === "diode" || componentType === "led" ? { portHintsMap: polarizedPortHintsMap } : void 0
|
|
11046
11061
|
);
|
|
11047
11062
|
const simplifiedPinLabels = Object.fromEntries(
|
|
11048
11063
|
Object.entries(safePinLabels).map(([pin, labels]) => {
|
|
@@ -11053,6 +11068,14 @@ var generateTypescriptComponent = ({
|
|
|
11053
11068
|
})
|
|
11054
11069
|
);
|
|
11055
11070
|
const pinLabelsString = Object.entries(simplifiedPinLabels).map(([pin, labels]) => ` ${pin}: ${JSON.stringify(labels)}`).join(",\n");
|
|
11071
|
+
const polarizedPinLabelsString = Object.entries(polarizedPinLabels ?? {}).map(([pin, labels]) => ` ${pin}: ${JSON.stringify(labels)}`).join(",\n");
|
|
11072
|
+
const polarizedPinLabelsBlock = polarizedPinLabels ? `const pinLabels = {
|
|
11073
|
+
${polarizedPinLabelsString}
|
|
11074
|
+
} as const
|
|
11075
|
+
|
|
11076
|
+
` : "";
|
|
11077
|
+
const polarizedPinLabelsProp = polarizedPinLabels ? ` pinLabels={pinLabels}
|
|
11078
|
+
` : "";
|
|
11056
11079
|
const cadModelLines = [
|
|
11057
11080
|
objUrl ? `objUrl: "${objUrl}",` : "",
|
|
11058
11081
|
stepUrl ? `stepUrl: "${stepUrl}",` : "",
|
|
@@ -11063,13 +11086,13 @@ var generateTypescriptComponent = ({
|
|
|
11063
11086
|
return `
|
|
11064
11087
|
import type { DiodeProps } from "@tscircuit/props"
|
|
11065
11088
|
|
|
11066
|
-
export const ${componentName} = (props: DiodeProps) => {
|
|
11089
|
+
${polarizedPinLabelsBlock}export const ${componentName} = (props: DiodeProps) => {
|
|
11067
11090
|
const { name = "D1", ...restProps } = props
|
|
11068
11091
|
|
|
11069
11092
|
return (
|
|
11070
11093
|
<diode
|
|
11071
11094
|
name={name}
|
|
11072
|
-
supplierPartNumbers={${JSON.stringify(supplierPartNumbers, null, " ")}}
|
|
11095
|
+
${polarizedPinLabelsProp} supplierPartNumbers={${JSON.stringify(supplierPartNumbers, null, " ")}}
|
|
11073
11096
|
manufacturerPartNumber="${manufacturerPartNumber}"
|
|
11074
11097
|
footprint={${footprintTsx}}
|
|
11075
11098
|
${objUrl || stepUrl ? `cadModel={{
|
|
@@ -11085,13 +11108,13 @@ ${cadModelLines}
|
|
|
11085
11108
|
return `
|
|
11086
11109
|
import type { LedProps } from "@tscircuit/props"
|
|
11087
11110
|
|
|
11088
|
-
export const ${componentName} = (props: LedProps) => {
|
|
11111
|
+
${polarizedPinLabelsBlock}export const ${componentName} = (props: LedProps) => {
|
|
11089
11112
|
const { name = "LED1", ...restProps } = props
|
|
11090
11113
|
|
|
11091
11114
|
return (
|
|
11092
11115
|
<led
|
|
11093
11116
|
name={name}
|
|
11094
|
-
supplierPartNumbers={${JSON.stringify(supplierPartNumbers, null, " ")}}
|
|
11117
|
+
${polarizedPinLabelsProp} supplierPartNumbers={${JSON.stringify(supplierPartNumbers, null, " ")}}
|
|
11095
11118
|
manufacturerPartNumber="${manufacturerPartNumber}"
|
|
11096
11119
|
footprint={${footprintTsx}}
|
|
11097
11120
|
${objUrl || stepUrl ? `cadModel={{
|