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/browser/index.js
CHANGED
|
@@ -11285,11 +11285,11 @@ var generateFootprintTsx = (circuitJson, options = {}) => {
|
|
|
11285
11285
|
const cornerRadius = smtPad.corner_radius ?? smtPad.rect_border_radius ?? void 0;
|
|
11286
11286
|
const cornerRadiusAttr = cornerRadius !== void 0 ? ` cornerRadius="${mmStr(cornerRadius)}"` : "";
|
|
11287
11287
|
elementStrings.push(
|
|
11288
|
-
`<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" />`
|
|
11288
|
+
`<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" />`
|
|
11289
11289
|
);
|
|
11290
11290
|
} else if (smtPad.shape === "pill") {
|
|
11291
11291
|
elementStrings.push(
|
|
11292
|
-
`<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" />`
|
|
11292
|
+
`<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" />`
|
|
11293
11293
|
);
|
|
11294
11294
|
} else if (smtPad.shape === "polygon") {
|
|
11295
11295
|
const pointsStr = smtPad.points.map((p) => `{x: "${mmStr(p.x)}", y: "${mmStr(p.y)}"}`).join(", ");
|
|
@@ -11332,7 +11332,11 @@ var getPinLabelValues = (labels) => {
|
|
|
11332
11332
|
if (typeof labels === "string") return [labels];
|
|
11333
11333
|
return [...labels];
|
|
11334
11334
|
};
|
|
11335
|
-
var
|
|
11335
|
+
var getPinKeySortValue = (pinKey) => {
|
|
11336
|
+
const match = /^pin(\d+)$/i.exec(pinKey);
|
|
11337
|
+
return match ? Number(match[1]) : Number.MAX_SAFE_INTEGER;
|
|
11338
|
+
};
|
|
11339
|
+
var getPolarizedPinMetadata = (pinLabels) => {
|
|
11336
11340
|
const labelsByPin = Object.entries(pinLabels ?? {}).map(([pin, labels]) => ({
|
|
11337
11341
|
pin,
|
|
11338
11342
|
labels: getPinLabelValues(labels).map((label) => label.toLowerCase())
|
|
@@ -11344,9 +11348,17 @@ var getPolarizedPortHintsMap = (pinLabels) => {
|
|
|
11344
11348
|
({ labels }) => labels.some((label) => ["c", "k", "cathode", "neg", "-"].includes(label))
|
|
11345
11349
|
)?.pin;
|
|
11346
11350
|
if (!anodePin || !cathodePin) return void 0;
|
|
11351
|
+
const polarizedPinEntries = [
|
|
11352
|
+
[anodePin, ["anode", "pos"]],
|
|
11353
|
+
[cathodePin, ["cathode", "neg"]]
|
|
11354
|
+
].sort(
|
|
11355
|
+
([pinA], [pinB]) => getPinKeySortValue(pinA) - getPinKeySortValue(pinB)
|
|
11356
|
+
);
|
|
11347
11357
|
return {
|
|
11348
|
-
|
|
11349
|
-
|
|
11358
|
+
portHintsMap: Object.fromEntries(
|
|
11359
|
+
polarizedPinEntries.map(([pin, labels]) => [pin, [pin, ...labels]])
|
|
11360
|
+
),
|
|
11361
|
+
pinLabels: Object.fromEntries(polarizedPinEntries)
|
|
11350
11362
|
};
|
|
11351
11363
|
};
|
|
11352
11364
|
var generateTypescriptComponent = ({
|
|
@@ -11360,10 +11372,13 @@ var generateTypescriptComponent = ({
|
|
|
11360
11372
|
componentType = "chip"
|
|
11361
11373
|
}) => {
|
|
11362
11374
|
const safePinLabels = pinLabels ?? {};
|
|
11375
|
+
const polarizedPinMetadata = getPolarizedPinMetadata(safePinLabels);
|
|
11376
|
+
const polarizedPortHintsMap = polarizedPinMetadata?.portHintsMap;
|
|
11377
|
+
const polarizedPinLabels = polarizedPinMetadata?.pinLabels;
|
|
11363
11378
|
const cadComponent = circuitJson.find((item) => item.type === "cad_component");
|
|
11364
11379
|
const footprintTsx = generateFootprintTsx(
|
|
11365
11380
|
circuitJson,
|
|
11366
|
-
componentType === "diode" || componentType === "led" ? { portHintsMap:
|
|
11381
|
+
componentType === "diode" || componentType === "led" ? { portHintsMap: polarizedPortHintsMap } : void 0
|
|
11367
11382
|
);
|
|
11368
11383
|
const simplifiedPinLabels = Object.fromEntries(
|
|
11369
11384
|
Object.entries(safePinLabels).map(([pin, labels]) => {
|
|
@@ -11374,6 +11389,14 @@ var generateTypescriptComponent = ({
|
|
|
11374
11389
|
})
|
|
11375
11390
|
);
|
|
11376
11391
|
const pinLabelsString = Object.entries(simplifiedPinLabels).map(([pin, labels]) => ` ${pin}: ${JSON.stringify(labels)}`).join(",\n");
|
|
11392
|
+
const polarizedPinLabelsString = Object.entries(polarizedPinLabels ?? {}).map(([pin, labels]) => ` ${pin}: ${JSON.stringify(labels)}`).join(",\n");
|
|
11393
|
+
const polarizedPinLabelsBlock = polarizedPinLabels ? `const pinLabels = {
|
|
11394
|
+
${polarizedPinLabelsString}
|
|
11395
|
+
} as const
|
|
11396
|
+
|
|
11397
|
+
` : "";
|
|
11398
|
+
const polarizedPinLabelsProp = polarizedPinLabels ? ` pinLabels={pinLabels}
|
|
11399
|
+
` : "";
|
|
11377
11400
|
const cadModelLines = [
|
|
11378
11401
|
objUrl ? `objUrl: "${objUrl}",` : "",
|
|
11379
11402
|
stepUrl ? `stepUrl: "${stepUrl}",` : "",
|
|
@@ -11384,13 +11407,13 @@ var generateTypescriptComponent = ({
|
|
|
11384
11407
|
return `
|
|
11385
11408
|
import type { DiodeProps } from "@tscircuit/props"
|
|
11386
11409
|
|
|
11387
|
-
export const ${componentName} = (props: DiodeProps) => {
|
|
11410
|
+
${polarizedPinLabelsBlock}export const ${componentName} = (props: DiodeProps) => {
|
|
11388
11411
|
const { name = "D1", ...restProps } = props
|
|
11389
11412
|
|
|
11390
11413
|
return (
|
|
11391
11414
|
<diode
|
|
11392
11415
|
name={name}
|
|
11393
|
-
supplierPartNumbers={${JSON.stringify(supplierPartNumbers, null, " ")}}
|
|
11416
|
+
${polarizedPinLabelsProp} supplierPartNumbers={${JSON.stringify(supplierPartNumbers, null, " ")}}
|
|
11394
11417
|
manufacturerPartNumber="${manufacturerPartNumber}"
|
|
11395
11418
|
footprint={${footprintTsx}}
|
|
11396
11419
|
${objUrl || stepUrl ? `cadModel={{
|
|
@@ -11406,13 +11429,13 @@ ${cadModelLines}
|
|
|
11406
11429
|
return `
|
|
11407
11430
|
import type { LedProps } from "@tscircuit/props"
|
|
11408
11431
|
|
|
11409
|
-
export const ${componentName} = (props: LedProps) => {
|
|
11432
|
+
${polarizedPinLabelsBlock}export const ${componentName} = (props: LedProps) => {
|
|
11410
11433
|
const { name = "LED1", ...restProps } = props
|
|
11411
11434
|
|
|
11412
11435
|
return (
|
|
11413
11436
|
<led
|
|
11414
11437
|
name={name}
|
|
11415
|
-
supplierPartNumbers={${JSON.stringify(supplierPartNumbers, null, " ")}}
|
|
11438
|
+
${polarizedPinLabelsProp} supplierPartNumbers={${JSON.stringify(supplierPartNumbers, null, " ")}}
|
|
11416
11439
|
manufacturerPartNumber="${manufacturerPartNumber}"
|
|
11417
11440
|
footprint={${footprintTsx}}
|
|
11418
11441
|
${objUrl || stepUrl ? `cadModel={{
|