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/index.js
CHANGED
|
@@ -7557,11 +7557,11 @@ var generateFootprintTsx = (circuitJson, options = {}) => {
|
|
|
7557
7557
|
const cornerRadius = smtPad.corner_radius ?? smtPad.rect_border_radius ?? void 0;
|
|
7558
7558
|
const cornerRadiusAttr = cornerRadius !== void 0 ? ` cornerRadius="${mmStr(cornerRadius)}"` : "";
|
|
7559
7559
|
elementStrings.push(
|
|
7560
|
-
`<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" />`
|
|
7560
|
+
`<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" />`
|
|
7561
7561
|
);
|
|
7562
7562
|
} else if (smtPad.shape === "pill") {
|
|
7563
7563
|
elementStrings.push(
|
|
7564
|
-
`<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" />`
|
|
7564
|
+
`<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" />`
|
|
7565
7565
|
);
|
|
7566
7566
|
} else if (smtPad.shape === "polygon") {
|
|
7567
7567
|
const pointsStr = smtPad.points.map((p) => `{x: "${mmStr(p.x)}", y: "${mmStr(p.y)}"}`).join(", ");
|
|
@@ -7604,7 +7604,11 @@ var getPinLabelValues = (labels) => {
|
|
|
7604
7604
|
if (typeof labels === "string") return [labels];
|
|
7605
7605
|
return [...labels];
|
|
7606
7606
|
};
|
|
7607
|
-
var
|
|
7607
|
+
var getPinKeySortValue = (pinKey) => {
|
|
7608
|
+
const match = /^pin(\d+)$/i.exec(pinKey);
|
|
7609
|
+
return match ? Number(match[1]) : Number.MAX_SAFE_INTEGER;
|
|
7610
|
+
};
|
|
7611
|
+
var getPolarizedPinMetadata = (pinLabels) => {
|
|
7608
7612
|
const labelsByPin = Object.entries(pinLabels ?? {}).map(([pin, labels]) => ({
|
|
7609
7613
|
pin,
|
|
7610
7614
|
labels: getPinLabelValues(labels).map((label) => label.toLowerCase())
|
|
@@ -7616,9 +7620,17 @@ var getPolarizedPortHintsMap = (pinLabels) => {
|
|
|
7616
7620
|
({ labels }) => labels.some((label) => ["c", "k", "cathode", "neg", "-"].includes(label))
|
|
7617
7621
|
)?.pin;
|
|
7618
7622
|
if (!anodePin || !cathodePin) return void 0;
|
|
7623
|
+
const polarizedPinEntries = [
|
|
7624
|
+
[anodePin, ["anode", "pos"]],
|
|
7625
|
+
[cathodePin, ["cathode", "neg"]]
|
|
7626
|
+
].sort(
|
|
7627
|
+
([pinA], [pinB]) => getPinKeySortValue(pinA) - getPinKeySortValue(pinB)
|
|
7628
|
+
);
|
|
7619
7629
|
return {
|
|
7620
|
-
|
|
7621
|
-
|
|
7630
|
+
portHintsMap: Object.fromEntries(
|
|
7631
|
+
polarizedPinEntries.map(([pin, labels]) => [pin, [pin, ...labels]])
|
|
7632
|
+
),
|
|
7633
|
+
pinLabels: Object.fromEntries(polarizedPinEntries)
|
|
7622
7634
|
};
|
|
7623
7635
|
};
|
|
7624
7636
|
var generateTypescriptComponent = ({
|
|
@@ -7632,10 +7644,13 @@ var generateTypescriptComponent = ({
|
|
|
7632
7644
|
componentType = "chip"
|
|
7633
7645
|
}) => {
|
|
7634
7646
|
const safePinLabels = pinLabels ?? {};
|
|
7647
|
+
const polarizedPinMetadata = getPolarizedPinMetadata(safePinLabels);
|
|
7648
|
+
const polarizedPortHintsMap = polarizedPinMetadata?.portHintsMap;
|
|
7649
|
+
const polarizedPinLabels = polarizedPinMetadata?.pinLabels;
|
|
7635
7650
|
const cadComponent = circuitJson.find((item) => item.type === "cad_component");
|
|
7636
7651
|
const footprintTsx = generateFootprintTsx(
|
|
7637
7652
|
circuitJson,
|
|
7638
|
-
componentType === "diode" || componentType === "led" ? { portHintsMap:
|
|
7653
|
+
componentType === "diode" || componentType === "led" ? { portHintsMap: polarizedPortHintsMap } : void 0
|
|
7639
7654
|
);
|
|
7640
7655
|
const simplifiedPinLabels = Object.fromEntries(
|
|
7641
7656
|
Object.entries(safePinLabels).map(([pin, labels]) => {
|
|
@@ -7646,6 +7661,14 @@ var generateTypescriptComponent = ({
|
|
|
7646
7661
|
})
|
|
7647
7662
|
);
|
|
7648
7663
|
const pinLabelsString = Object.entries(simplifiedPinLabels).map(([pin, labels]) => ` ${pin}: ${JSON.stringify(labels)}`).join(",\n");
|
|
7664
|
+
const polarizedPinLabelsString = Object.entries(polarizedPinLabels ?? {}).map(([pin, labels]) => ` ${pin}: ${JSON.stringify(labels)}`).join(",\n");
|
|
7665
|
+
const polarizedPinLabelsBlock = polarizedPinLabels ? `const pinLabels = {
|
|
7666
|
+
${polarizedPinLabelsString}
|
|
7667
|
+
} as const
|
|
7668
|
+
|
|
7669
|
+
` : "";
|
|
7670
|
+
const polarizedPinLabelsProp = polarizedPinLabels ? ` pinLabels={pinLabels}
|
|
7671
|
+
` : "";
|
|
7649
7672
|
const cadModelLines = [
|
|
7650
7673
|
objUrl ? `objUrl: "${objUrl}",` : "",
|
|
7651
7674
|
stepUrl ? `stepUrl: "${stepUrl}",` : "",
|
|
@@ -7656,13 +7679,13 @@ var generateTypescriptComponent = ({
|
|
|
7656
7679
|
return `
|
|
7657
7680
|
import type { DiodeProps } from "@tscircuit/props"
|
|
7658
7681
|
|
|
7659
|
-
export const ${componentName} = (props: DiodeProps) => {
|
|
7682
|
+
${polarizedPinLabelsBlock}export const ${componentName} = (props: DiodeProps) => {
|
|
7660
7683
|
const { name = "D1", ...restProps } = props
|
|
7661
7684
|
|
|
7662
7685
|
return (
|
|
7663
7686
|
<diode
|
|
7664
7687
|
name={name}
|
|
7665
|
-
supplierPartNumbers={${JSON.stringify(supplierPartNumbers, null, " ")}}
|
|
7688
|
+
${polarizedPinLabelsProp} supplierPartNumbers={${JSON.stringify(supplierPartNumbers, null, " ")}}
|
|
7666
7689
|
manufacturerPartNumber="${manufacturerPartNumber}"
|
|
7667
7690
|
footprint={${footprintTsx}}
|
|
7668
7691
|
${objUrl || stepUrl ? `cadModel={{
|
|
@@ -7678,13 +7701,13 @@ ${cadModelLines}
|
|
|
7678
7701
|
return `
|
|
7679
7702
|
import type { LedProps } from "@tscircuit/props"
|
|
7680
7703
|
|
|
7681
|
-
export const ${componentName} = (props: LedProps) => {
|
|
7704
|
+
${polarizedPinLabelsBlock}export const ${componentName} = (props: LedProps) => {
|
|
7682
7705
|
const { name = "LED1", ...restProps } = props
|
|
7683
7706
|
|
|
7684
7707
|
return (
|
|
7685
7708
|
<led
|
|
7686
7709
|
name={name}
|
|
7687
|
-
supplierPartNumbers={${JSON.stringify(supplierPartNumbers, null, " ")}}
|
|
7710
|
+
${polarizedPinLabelsProp} supplierPartNumbers={${JSON.stringify(supplierPartNumbers, null, " ")}}
|
|
7688
7711
|
manufacturerPartNumber="${manufacturerPartNumber}"
|
|
7689
7712
|
footprint={${footprintTsx}}
|
|
7690
7713
|
${objUrl || stepUrl ? `cadModel={{
|