easyeda 0.0.277 → 0.0.279
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.d.ts +347 -65
- package/dist/browser/index.js +200 -179
- package/dist/browser/index.js.map +1 -1
- package/dist/index.d.ts +347 -65
- package/dist/index.js +200 -179
- package/dist/index.js.map +1 -1
- package/dist/main.cjs +201 -180
- package/dist/main.cjs.map +1 -1
- package/package.json +1 -1
package/dist/browser/index.js
CHANGED
|
@@ -9497,6 +9497,9 @@ var mil2mm = (mil) => {
|
|
|
9497
9497
|
return mm(mil);
|
|
9498
9498
|
};
|
|
9499
9499
|
|
|
9500
|
+
// lib/constants.ts
|
|
9501
|
+
var DEFAULT_PCB_THICKNESS_MM = 1.6;
|
|
9502
|
+
|
|
9500
9503
|
// lib/math/arc-utils.ts
|
|
9501
9504
|
function generateArcFromSweep(startX, startY, endX, endY, radius, largeArcFlag, sweepFlag) {
|
|
9502
9505
|
const start = { x: startX, y: startY };
|
|
@@ -9545,6 +9548,173 @@ function generateArcFromSweep(startX, startY, endX, endY, radius, largeArcFlag,
|
|
|
9545
9548
|
// lib/utils/easyeda-unit-to-mm.ts
|
|
9546
9549
|
var mil10ToMm = (value) => value * 10 * 0.0254;
|
|
9547
9550
|
|
|
9551
|
+
// lib/utils/get-polarized-pin-metadata.ts
|
|
9552
|
+
var getPinLabelValues = (labels) => {
|
|
9553
|
+
if (typeof labels === "string") return [labels];
|
|
9554
|
+
return [...labels];
|
|
9555
|
+
};
|
|
9556
|
+
var stripEasyEdaPolarityHintDecoration = (label) => label.toLowerCase().replace(/[^a-z0-9+-]/g, "");
|
|
9557
|
+
var getPinKeySortValue = (pinKey) => {
|
|
9558
|
+
const match = /^pin(\d+)$/i.exec(pinKey);
|
|
9559
|
+
return match ? Number(match[1]) : Number.MAX_SAFE_INTEGER;
|
|
9560
|
+
};
|
|
9561
|
+
var getPolarizedPinMetadata = (pinLabels) => {
|
|
9562
|
+
const labelsByPin = Object.entries(pinLabels).map(([pin, labels]) => ({
|
|
9563
|
+
pin,
|
|
9564
|
+
labels: getPinLabelValues(labels).map(stripEasyEdaPolarityHintDecoration)
|
|
9565
|
+
}));
|
|
9566
|
+
const anodePin = labelsByPin.find(
|
|
9567
|
+
({ labels }) => labels.some((label) => ["a", "anode", "pos", "+"].includes(label))
|
|
9568
|
+
)?.pin;
|
|
9569
|
+
const cathodePin = labelsByPin.find(
|
|
9570
|
+
({ labels }) => labels.some((label) => ["c", "k", "cathode", "neg", "-"].includes(label))
|
|
9571
|
+
)?.pin;
|
|
9572
|
+
if (!anodePin || !cathodePin || anodePin === cathodePin) return void 0;
|
|
9573
|
+
const polarizedPinEntries = [
|
|
9574
|
+
[anodePin, ["anode", "pos"]],
|
|
9575
|
+
[cathodePin, ["cathode", "neg"]]
|
|
9576
|
+
].sort(
|
|
9577
|
+
([pinA], [pinB]) => getPinKeySortValue(pinA) - getPinKeySortValue(pinB)
|
|
9578
|
+
);
|
|
9579
|
+
return {
|
|
9580
|
+
portHintsMap: Object.fromEntries(
|
|
9581
|
+
polarizedPinEntries.map(([pin, labels]) => [pin, [pin, ...labels]])
|
|
9582
|
+
),
|
|
9583
|
+
pinLabels: Object.fromEntries(polarizedPinEntries)
|
|
9584
|
+
};
|
|
9585
|
+
};
|
|
9586
|
+
|
|
9587
|
+
// lib/utils/normalize-pin-labels.ts
|
|
9588
|
+
var normalizePinLabels = (inputPinLabels) => {
|
|
9589
|
+
const uniqueInputPinLabels = inputPinLabels.map((labels) => [
|
|
9590
|
+
...new Set(labels)
|
|
9591
|
+
]);
|
|
9592
|
+
const result = uniqueInputPinLabels.map(() => []);
|
|
9593
|
+
const desiredNumbers = uniqueInputPinLabels.map(() => null);
|
|
9594
|
+
for (let i = 0; i < uniqueInputPinLabels.length; i++) {
|
|
9595
|
+
for (const label of uniqueInputPinLabels[i]) {
|
|
9596
|
+
if (/^\d+$/.test(label)) {
|
|
9597
|
+
desiredNumbers[i] = Number.parseInt(label);
|
|
9598
|
+
break;
|
|
9599
|
+
}
|
|
9600
|
+
}
|
|
9601
|
+
}
|
|
9602
|
+
let highestPinNumber = 0;
|
|
9603
|
+
const acceptedDesiredNumbers = /* @__PURE__ */ new Set();
|
|
9604
|
+
for (let i = 0; i < desiredNumbers.length; i++) {
|
|
9605
|
+
const desiredNumber = desiredNumbers[i];
|
|
9606
|
+
if (desiredNumber === null || desiredNumber < 1) continue;
|
|
9607
|
+
if (!acceptedDesiredNumbers.has(desiredNumber)) {
|
|
9608
|
+
acceptedDesiredNumbers.add(desiredNumber);
|
|
9609
|
+
result[i].push(`pin${desiredNumber}`);
|
|
9610
|
+
highestPinNumber = Math.max(highestPinNumber, desiredNumber);
|
|
9611
|
+
continue;
|
|
9612
|
+
}
|
|
9613
|
+
let existingAltCount = 0;
|
|
9614
|
+
for (const label of result[i]) {
|
|
9615
|
+
if (label.startsWith(`pin${desiredNumber}_alt`)) {
|
|
9616
|
+
existingAltCount += 1;
|
|
9617
|
+
}
|
|
9618
|
+
}
|
|
9619
|
+
result[i].push(`pin${desiredNumber}_alt${existingAltCount + 1}`);
|
|
9620
|
+
}
|
|
9621
|
+
for (let i = 0; i < result.length; i++) {
|
|
9622
|
+
const firstLabel = result[i][0];
|
|
9623
|
+
if (firstLabel?.includes("_alt")) {
|
|
9624
|
+
highestPinNumber += 1;
|
|
9625
|
+
result[i].unshift(`pin${highestPinNumber}`);
|
|
9626
|
+
}
|
|
9627
|
+
}
|
|
9628
|
+
for (let i = 0; i < result.length; i++) {
|
|
9629
|
+
if (result[i].length === 0) {
|
|
9630
|
+
highestPinNumber += 1;
|
|
9631
|
+
result[i].push(`pin${highestPinNumber}`);
|
|
9632
|
+
}
|
|
9633
|
+
}
|
|
9634
|
+
const totalLabelCounts = {};
|
|
9635
|
+
for (const inputLabels of uniqueInputPinLabels) {
|
|
9636
|
+
for (const label of inputLabels) {
|
|
9637
|
+
if (/^\d+$/.test(label)) continue;
|
|
9638
|
+
totalLabelCounts[label] = (totalLabelCounts[label] ?? 0) + 1;
|
|
9639
|
+
}
|
|
9640
|
+
}
|
|
9641
|
+
const incrementalLabelCounts = {};
|
|
9642
|
+
for (let i = 0; i < uniqueInputPinLabels.length; i++) {
|
|
9643
|
+
for (const label of uniqueInputPinLabels[i]) {
|
|
9644
|
+
if (/^\d+$/.test(label)) continue;
|
|
9645
|
+
if (totalLabelCounts[label] === 1) {
|
|
9646
|
+
result[i].push(label);
|
|
9647
|
+
} else {
|
|
9648
|
+
incrementalLabelCounts[label] = (incrementalLabelCounts[label] ?? 0) + 1;
|
|
9649
|
+
result[i].push(`${label}${incrementalLabelCounts[label]}`);
|
|
9650
|
+
}
|
|
9651
|
+
}
|
|
9652
|
+
}
|
|
9653
|
+
return result;
|
|
9654
|
+
};
|
|
9655
|
+
|
|
9656
|
+
// lib/utils/normalize-symbol-name.ts
|
|
9657
|
+
var normalizeSymbolName = (name) => {
|
|
9658
|
+
const trimmedName = name.trim();
|
|
9659
|
+
if (trimmedName === "+") return "_POS";
|
|
9660
|
+
if (trimmedName === "-") return "_NEG";
|
|
9661
|
+
return trimmedName;
|
|
9662
|
+
};
|
|
9663
|
+
|
|
9664
|
+
// lib/websafe/convert-to-typescript-component/category-value-contains-diode.ts
|
|
9665
|
+
var categoryValueContainsDiode = (value) => {
|
|
9666
|
+
if (typeof value === "string") {
|
|
9667
|
+
return /(^|[^a-z])diodes?([^a-z]|$)/i.test(value);
|
|
9668
|
+
}
|
|
9669
|
+
if (Array.isArray(value)) {
|
|
9670
|
+
return value.some(categoryValueContainsDiode);
|
|
9671
|
+
}
|
|
9672
|
+
if (value && typeof value === "object") {
|
|
9673
|
+
return Object.values(value).some(categoryValueContainsDiode);
|
|
9674
|
+
}
|
|
9675
|
+
return false;
|
|
9676
|
+
};
|
|
9677
|
+
|
|
9678
|
+
// lib/websafe/convert-to-typescript-component/is-diode-category-component.ts
|
|
9679
|
+
var isDiodeCategoryComponent = (betterEasy) => {
|
|
9680
|
+
const cPara = betterEasy.dataStr.head.c_para;
|
|
9681
|
+
return [
|
|
9682
|
+
betterEasy.tags,
|
|
9683
|
+
cPara.category,
|
|
9684
|
+
cPara.Category,
|
|
9685
|
+
cPara["LCSC Category"],
|
|
9686
|
+
cPara["JLCPCB Category"],
|
|
9687
|
+
betterEasy.category
|
|
9688
|
+
].some(categoryValueContainsDiode);
|
|
9689
|
+
};
|
|
9690
|
+
|
|
9691
|
+
// lib/websafe/convert-to-typescript-component/category-value-contains-led.ts
|
|
9692
|
+
var categoryValueContainsLed = (value) => {
|
|
9693
|
+
if (typeof value === "string") {
|
|
9694
|
+
return /(^|[^a-z])leds?([^a-z]|$)/i.test(value) || /light[-\s]?emitting\s+diodes?/i.test(value);
|
|
9695
|
+
}
|
|
9696
|
+
if (Array.isArray(value)) {
|
|
9697
|
+
return value.some(categoryValueContainsLed);
|
|
9698
|
+
}
|
|
9699
|
+
if (value && typeof value === "object") {
|
|
9700
|
+
return Object.values(value).some(categoryValueContainsLed);
|
|
9701
|
+
}
|
|
9702
|
+
return false;
|
|
9703
|
+
};
|
|
9704
|
+
|
|
9705
|
+
// lib/websafe/convert-to-typescript-component/is-led-category-component.ts
|
|
9706
|
+
var isLedCategoryComponent = (betterEasy) => {
|
|
9707
|
+
const cPara = betterEasy.dataStr.head.c_para;
|
|
9708
|
+
return [
|
|
9709
|
+
betterEasy.tags,
|
|
9710
|
+
cPara.category,
|
|
9711
|
+
cPara.Category,
|
|
9712
|
+
cPara["LCSC Category"],
|
|
9713
|
+
cPara["JLCPCB Category"],
|
|
9714
|
+
betterEasy.category
|
|
9715
|
+
].some(categoryValueContainsLed);
|
|
9716
|
+
};
|
|
9717
|
+
|
|
9548
9718
|
// node_modules/@tscircuit/math-utils/dist/chunk-3WCUPG5S.js
|
|
9549
9719
|
var getBoundsCenter = (bounds) => ({
|
|
9550
9720
|
x: (bounds.minX + bounds.maxX) / 2,
|
|
@@ -9681,86 +9851,6 @@ var getCadSvgNodeZOffsetMm = (easyEdaJson) => {
|
|
|
9681
9851
|
};
|
|
9682
9852
|
var getCadSvgNodeModelUuid = (easyEdaJson) => getCadSvgNode(easyEdaJson)?.svgData.attrs?.uuid ?? null;
|
|
9683
9853
|
|
|
9684
|
-
// lib/utils/normalize-pin-labels.ts
|
|
9685
|
-
var normalizePinLabels = (inputPinLabels) => {
|
|
9686
|
-
const uniqueInputPinLabels = inputPinLabels.map((labels) => [
|
|
9687
|
-
...new Set(labels)
|
|
9688
|
-
]);
|
|
9689
|
-
const result = uniqueInputPinLabels.map(() => []);
|
|
9690
|
-
const desiredNumbers = uniqueInputPinLabels.map(() => null);
|
|
9691
|
-
for (let i = 0; i < uniqueInputPinLabels.length; i++) {
|
|
9692
|
-
for (const label of uniqueInputPinLabels[i]) {
|
|
9693
|
-
if (/^\d+$/.test(label)) {
|
|
9694
|
-
desiredNumbers[i] = Number.parseInt(label);
|
|
9695
|
-
break;
|
|
9696
|
-
}
|
|
9697
|
-
}
|
|
9698
|
-
}
|
|
9699
|
-
let highestPinNumber = 0;
|
|
9700
|
-
const acceptedDesiredNumbers = /* @__PURE__ */ new Set();
|
|
9701
|
-
for (let i = 0; i < desiredNumbers.length; i++) {
|
|
9702
|
-
const desiredNumber = desiredNumbers[i];
|
|
9703
|
-
if (desiredNumber === null || desiredNumber < 1) continue;
|
|
9704
|
-
if (!acceptedDesiredNumbers.has(desiredNumber)) {
|
|
9705
|
-
acceptedDesiredNumbers.add(desiredNumber);
|
|
9706
|
-
result[i].push(`pin${desiredNumber}`);
|
|
9707
|
-
highestPinNumber = Math.max(highestPinNumber, desiredNumber);
|
|
9708
|
-
continue;
|
|
9709
|
-
}
|
|
9710
|
-
let existingAltCount = 0;
|
|
9711
|
-
for (const label of result[i]) {
|
|
9712
|
-
if (label.startsWith(`pin${desiredNumber}_alt`)) {
|
|
9713
|
-
existingAltCount += 1;
|
|
9714
|
-
}
|
|
9715
|
-
}
|
|
9716
|
-
result[i].push(`pin${desiredNumber}_alt${existingAltCount + 1}`);
|
|
9717
|
-
}
|
|
9718
|
-
for (let i = 0; i < result.length; i++) {
|
|
9719
|
-
const firstLabel = result[i][0];
|
|
9720
|
-
if (firstLabel?.includes("_alt")) {
|
|
9721
|
-
highestPinNumber += 1;
|
|
9722
|
-
result[i].unshift(`pin${highestPinNumber}`);
|
|
9723
|
-
}
|
|
9724
|
-
}
|
|
9725
|
-
for (let i = 0; i < result.length; i++) {
|
|
9726
|
-
if (result[i].length === 0) {
|
|
9727
|
-
highestPinNumber += 1;
|
|
9728
|
-
result[i].push(`pin${highestPinNumber}`);
|
|
9729
|
-
}
|
|
9730
|
-
}
|
|
9731
|
-
const totalLabelCounts = {};
|
|
9732
|
-
for (const inputLabels of uniqueInputPinLabels) {
|
|
9733
|
-
for (const label of inputLabels) {
|
|
9734
|
-
if (/^\d+$/.test(label)) continue;
|
|
9735
|
-
totalLabelCounts[label] = (totalLabelCounts[label] ?? 0) + 1;
|
|
9736
|
-
}
|
|
9737
|
-
}
|
|
9738
|
-
const incrementalLabelCounts = {};
|
|
9739
|
-
for (let i = 0; i < uniqueInputPinLabels.length; i++) {
|
|
9740
|
-
for (const label of uniqueInputPinLabels[i]) {
|
|
9741
|
-
if (/^\d+$/.test(label)) continue;
|
|
9742
|
-
if (totalLabelCounts[label] === 1) {
|
|
9743
|
-
result[i].push(label);
|
|
9744
|
-
} else {
|
|
9745
|
-
incrementalLabelCounts[label] = (incrementalLabelCounts[label] ?? 0) + 1;
|
|
9746
|
-
result[i].push(`${label}${incrementalLabelCounts[label]}`);
|
|
9747
|
-
}
|
|
9748
|
-
}
|
|
9749
|
-
}
|
|
9750
|
-
return result;
|
|
9751
|
-
};
|
|
9752
|
-
|
|
9753
|
-
// lib/utils/normalize-symbol-name.ts
|
|
9754
|
-
var normalizeSymbolName = (name) => {
|
|
9755
|
-
const trimmedName = name.trim();
|
|
9756
|
-
if (trimmedName === "+") return "_POS";
|
|
9757
|
-
if (trimmedName === "-") return "_NEG";
|
|
9758
|
-
return trimmedName;
|
|
9759
|
-
};
|
|
9760
|
-
|
|
9761
|
-
// lib/constants.ts
|
|
9762
|
-
var DEFAULT_PCB_THICKNESS_MM = 1.6;
|
|
9763
|
-
|
|
9764
9854
|
// lib/convert-easyeda-json-to-tscircuit-soup-json.ts
|
|
9765
9855
|
var EASYEDA_STEP_MODEL_URL = "https://modules.easyeda.com/qAxj6KHrDKw4blvCG8QJPs7Y";
|
|
9766
9856
|
var EASYEDA_OBJ_MODEL_URL = "https://modules.easyeda.com/3dmodel";
|
|
@@ -9966,11 +10056,20 @@ var convertEasyEdaJsonToCircuitJson = (easyEdaJson, {
|
|
|
9966
10056
|
return labels;
|
|
9967
10057
|
});
|
|
9968
10058
|
const normalizedPinLabels = normalizePinLabels(pinLabelSets);
|
|
10059
|
+
const normalizedPinLabelsByPin = Object.fromEntries(
|
|
10060
|
+
normalizedPinLabels.map((labels) => {
|
|
10061
|
+
const pin = labels.find((label) => /^pin\d+$/i.test(label));
|
|
10062
|
+
return [pin, labels.filter((label) => label !== pin)];
|
|
10063
|
+
})
|
|
10064
|
+
);
|
|
10065
|
+
const polarizedPinMetadata = pads.length === 2 && (isDiodeCategoryComponent(easyEdaJson) || isLedCategoryComponent(easyEdaJson)) ? getPolarizedPinMetadata(normalizedPinLabelsByPin) : void 0;
|
|
9969
10066
|
pads.forEach((pad, index) => {
|
|
9970
10067
|
const portHints = normalizedPinLabels[index];
|
|
9971
10068
|
const pinNumber = Number.parseInt(
|
|
9972
10069
|
portHints.find((hint) => hint.match(/pin\d+/)).replace("pin", "")
|
|
9973
10070
|
);
|
|
10071
|
+
const canonicalPinName = `pin${pinNumber}`;
|
|
10072
|
+
const pcbPortHints = polarizedPinMetadata?.portHintsMap[canonicalPinName] ?? [canonicalPinName];
|
|
9974
10073
|
circuitElements.push({
|
|
9975
10074
|
type: "source_port",
|
|
9976
10075
|
source_port_id: `source_port_${index + 1}`,
|
|
@@ -9987,7 +10086,7 @@ var convertEasyEdaJsonToCircuitJson = (easyEdaJson, {
|
|
|
9987
10086
|
x: mil2mm(pad.center.x),
|
|
9988
10087
|
y: mil2mm(pad.center.y),
|
|
9989
10088
|
layers: ["top"],
|
|
9990
|
-
port_hints:
|
|
10089
|
+
port_hints: pcbPortHints,
|
|
9991
10090
|
pcb_component_id: "pcb_component_1",
|
|
9992
10091
|
pcb_port_id: `pcb_port_${index + 1}`
|
|
9993
10092
|
};
|
|
@@ -10099,7 +10198,7 @@ var convertEasyEdaJsonToCircuitJson = (easyEdaJson, {
|
|
|
10099
10198
|
radius: Math.min(mil2mm(pad.width), mil2mm(pad.height)) / 2
|
|
10100
10199
|
},
|
|
10101
10200
|
layer: "top",
|
|
10102
|
-
port_hints:
|
|
10201
|
+
port_hints: pcbPortHints,
|
|
10103
10202
|
pcb_component_id: "pcb_component_1",
|
|
10104
10203
|
pcb_port_id: `pcb_port_${index + 1}`
|
|
10105
10204
|
});
|
|
@@ -10363,7 +10462,7 @@ var convertEasyEdaJsonToCircuitJson = (easyEdaJson, {
|
|
|
10363
10462
|
// lib/schemas/package-detail-shape-schema.ts
|
|
10364
10463
|
var safeNumber = (defaultValue = 0) => external_exports.union([external_exports.number(), external_exports.string()]).transform((val) => {
|
|
10365
10464
|
const num = Number(val);
|
|
10366
|
-
return isNaN(num) ? defaultValue : num;
|
|
10465
|
+
return Number.isNaN(num) ? defaultValue : num;
|
|
10367
10466
|
}).default(defaultValue);
|
|
10368
10467
|
var tenthmil = external_exports.union([external_exports.number(), external_exports.string()]).optional().transform(
|
|
10369
10468
|
(n) => typeof n === "string" && n.endsWith("mil") ? n : `${Number.parseFloat(n) * 10}mil`
|
|
@@ -10510,6 +10609,7 @@ var ShapeItemSchema = external_exports.object({
|
|
|
10510
10609
|
}
|
|
10511
10610
|
case "PAD": {
|
|
10512
10611
|
const [padShape, ...params] = shape.data.split("~");
|
|
10612
|
+
const rawPadNumber = params[6];
|
|
10513
10613
|
const [
|
|
10514
10614
|
centerX,
|
|
10515
10615
|
centerY,
|
|
@@ -10517,10 +10617,11 @@ var ShapeItemSchema = external_exports.object({
|
|
|
10517
10617
|
height,
|
|
10518
10618
|
layermask,
|
|
10519
10619
|
net,
|
|
10520
|
-
|
|
10620
|
+
numericPadNumber,
|
|
10521
10621
|
holeRadius,
|
|
10522
10622
|
...rest
|
|
10523
10623
|
] = params.map((p) => Number.isNaN(Number(p)) ? p : Number(p));
|
|
10624
|
+
const padNumber = /^[+-]?(?:\d+(?:\.\d*)?|\.\d+)$/.test(rawPadNumber) ? numericPadNumber : rawPadNumber;
|
|
10524
10625
|
const center = { x: centerX, y: centerY };
|
|
10525
10626
|
let points;
|
|
10526
10627
|
if (padShape === "RECT" || padShape === "POLYGON") {
|
|
@@ -10536,7 +10637,7 @@ var ShapeItemSchema = external_exports.object({
|
|
|
10536
10637
|
height,
|
|
10537
10638
|
layermask,
|
|
10538
10639
|
net,
|
|
10539
|
-
number,
|
|
10640
|
+
number: padNumber,
|
|
10540
10641
|
holeRadius,
|
|
10541
10642
|
points,
|
|
10542
10643
|
rotation: rotation2,
|
|
@@ -10987,7 +11088,7 @@ var OwnerSchema = external_exports.object({
|
|
|
10987
11088
|
});
|
|
10988
11089
|
var HeadSchema = external_exports.object({
|
|
10989
11090
|
docType: external_exports.preprocess((val) => val == null ? val : String(val), external_exports.string()),
|
|
10990
|
-
editorVersion: external_exports.string(),
|
|
11091
|
+
editorVersion: external_exports.string().default(""),
|
|
10991
11092
|
c_para: external_exports.record(external_exports.string(), external_exports.string().nullable()),
|
|
10992
11093
|
x: external_exports.number(),
|
|
10993
11094
|
y: external_exports.number(),
|
|
@@ -11000,7 +11101,7 @@ var HeadSchema = external_exports.object({
|
|
|
11000
11101
|
}, external_exports.number()),
|
|
11001
11102
|
importFlag: external_exports.number().optional(),
|
|
11002
11103
|
c_spiceCmd: external_exports.any().optional(),
|
|
11003
|
-
hasIdFlag: external_exports.boolean()
|
|
11104
|
+
hasIdFlag: external_exports.boolean().default(false)
|
|
11004
11105
|
});
|
|
11005
11106
|
var BBoxSchema = external_exports.object({
|
|
11006
11107
|
x: external_exports.number(),
|
|
@@ -11025,9 +11126,17 @@ var DataStrSchema = external_exports.object({
|
|
|
11025
11126
|
head: HeadSchema,
|
|
11026
11127
|
canvas: external_exports.string(),
|
|
11027
11128
|
shape: external_exports.array(SingleLetterShapeSchema),
|
|
11028
|
-
BBox: BBoxSchema,
|
|
11029
|
-
colors: external_exports.union([external_exports.array(external_exports.string()), external_exports.record(external_exports.string())])
|
|
11030
|
-
})
|
|
11129
|
+
BBox: BBoxSchema.optional(),
|
|
11130
|
+
colors: external_exports.union([external_exports.array(external_exports.string()), external_exports.record(external_exports.string())]).default([])
|
|
11131
|
+
}).transform((data) => ({
|
|
11132
|
+
...data,
|
|
11133
|
+
BBox: data.BBox ?? {
|
|
11134
|
+
x: data.head.x,
|
|
11135
|
+
y: data.head.y,
|
|
11136
|
+
width: 0,
|
|
11137
|
+
height: 0
|
|
11138
|
+
}
|
|
11139
|
+
}));
|
|
11031
11140
|
var PackageDetailDataStrSchema = external_exports.object({
|
|
11032
11141
|
head: HeadSchema,
|
|
11033
11142
|
canvas: external_exports.string(),
|
|
@@ -11237,7 +11346,7 @@ var getEasyEdaCadModelPlacement = async (easyEdaJson, { fetch: fetch2 = globalTh
|
|
|
11237
11346
|
// lib/websafe/generate-footprint-tsx.ts
|
|
11238
11347
|
var mapPortHints = (portHints, portHintsMap) => {
|
|
11239
11348
|
if (!portHintsMap || !portHints) return portHints;
|
|
11240
|
-
return portHints.flatMap((hint) => portHintsMap[hint] ?? [hint]);
|
|
11349
|
+
return [...new Set(portHints.flatMap((hint) => portHintsMap[hint] ?? [hint]))];
|
|
11241
11350
|
};
|
|
11242
11351
|
var generateFootprintTsx = (circuitJson, options = {}) => {
|
|
11243
11352
|
const holes = su(circuitJson).pcb_hole.list();
|
|
@@ -11331,40 +11440,6 @@ var generateFootprintTsx = (circuitJson, options = {}) => {
|
|
|
11331
11440
|
};
|
|
11332
11441
|
|
|
11333
11442
|
// lib/websafe/convert-to-typescript-component/generate-typescript-component.ts
|
|
11334
|
-
var getPinLabelValues = (labels) => {
|
|
11335
|
-
if (typeof labels === "string") return [labels];
|
|
11336
|
-
return [...labels];
|
|
11337
|
-
};
|
|
11338
|
-
var stripEasyEdaPolarityHintDecoration = (label) => label.toLowerCase().replace(/[^a-z0-9+-]/g, "");
|
|
11339
|
-
var getPinKeySortValue = (pinKey) => {
|
|
11340
|
-
const match = /^pin(\d+)$/i.exec(pinKey);
|
|
11341
|
-
return match ? Number(match[1]) : Number.MAX_SAFE_INTEGER;
|
|
11342
|
-
};
|
|
11343
|
-
var getPolarizedPinMetadata = (pinLabels) => {
|
|
11344
|
-
const labelsByPin = Object.entries(pinLabels ?? {}).map(([pin, labels]) => ({
|
|
11345
|
-
pin,
|
|
11346
|
-
labels: getPinLabelValues(labels).map(stripEasyEdaPolarityHintDecoration)
|
|
11347
|
-
}));
|
|
11348
|
-
const anodePin = labelsByPin.find(
|
|
11349
|
-
({ labels }) => labels.some((label) => ["a", "anode", "pos", "+"].includes(label))
|
|
11350
|
-
)?.pin;
|
|
11351
|
-
const cathodePin = labelsByPin.find(
|
|
11352
|
-
({ labels }) => labels.some((label) => ["c", "k", "cathode", "neg", "-"].includes(label))
|
|
11353
|
-
)?.pin;
|
|
11354
|
-
if (!anodePin || !cathodePin) return void 0;
|
|
11355
|
-
const polarizedPinEntries = [
|
|
11356
|
-
[anodePin, ["anode", "pos"]],
|
|
11357
|
-
[cathodePin, ["cathode", "neg"]]
|
|
11358
|
-
].sort(
|
|
11359
|
-
([pinA], [pinB]) => getPinKeySortValue(pinA) - getPinKeySortValue(pinB)
|
|
11360
|
-
);
|
|
11361
|
-
return {
|
|
11362
|
-
portHintsMap: Object.fromEntries(
|
|
11363
|
-
polarizedPinEntries.map(([pin, labels]) => [pin, [pin, ...labels]])
|
|
11364
|
-
),
|
|
11365
|
-
pinLabels: Object.fromEntries(polarizedPinEntries)
|
|
11366
|
-
};
|
|
11367
|
-
};
|
|
11368
11443
|
var generateTypescriptComponent = ({
|
|
11369
11444
|
pinLabels,
|
|
11370
11445
|
componentName,
|
|
@@ -11534,60 +11609,6 @@ ${cadModelLines}
|
|
|
11534
11609
|
`.trim();
|
|
11535
11610
|
};
|
|
11536
11611
|
|
|
11537
|
-
// lib/websafe/convert-to-typescript-component/category-value-contains-diode.ts
|
|
11538
|
-
var categoryValueContainsDiode = (value) => {
|
|
11539
|
-
if (typeof value === "string") {
|
|
11540
|
-
return /(^|[^a-z])diodes?([^a-z]|$)/i.test(value);
|
|
11541
|
-
}
|
|
11542
|
-
if (Array.isArray(value)) {
|
|
11543
|
-
return value.some(categoryValueContainsDiode);
|
|
11544
|
-
}
|
|
11545
|
-
if (value && typeof value === "object") {
|
|
11546
|
-
return Object.values(value).some(categoryValueContainsDiode);
|
|
11547
|
-
}
|
|
11548
|
-
return false;
|
|
11549
|
-
};
|
|
11550
|
-
|
|
11551
|
-
// lib/websafe/convert-to-typescript-component/is-diode-category-component.ts
|
|
11552
|
-
var isDiodeCategoryComponent = (betterEasy) => {
|
|
11553
|
-
const cPara = betterEasy.dataStr.head.c_para;
|
|
11554
|
-
return [
|
|
11555
|
-
betterEasy.tags,
|
|
11556
|
-
cPara.category,
|
|
11557
|
-
cPara.Category,
|
|
11558
|
-
cPara["LCSC Category"],
|
|
11559
|
-
cPara["JLCPCB Category"],
|
|
11560
|
-
betterEasy.category
|
|
11561
|
-
].some(categoryValueContainsDiode);
|
|
11562
|
-
};
|
|
11563
|
-
|
|
11564
|
-
// lib/websafe/convert-to-typescript-component/category-value-contains-led.ts
|
|
11565
|
-
var categoryValueContainsLed = (value) => {
|
|
11566
|
-
if (typeof value === "string") {
|
|
11567
|
-
return /(^|[^a-z])leds?([^a-z]|$)/i.test(value) || /light[-\s]?emitting\s+diodes?/i.test(value);
|
|
11568
|
-
}
|
|
11569
|
-
if (Array.isArray(value)) {
|
|
11570
|
-
return value.some(categoryValueContainsLed);
|
|
11571
|
-
}
|
|
11572
|
-
if (value && typeof value === "object") {
|
|
11573
|
-
return Object.values(value).some(categoryValueContainsLed);
|
|
11574
|
-
}
|
|
11575
|
-
return false;
|
|
11576
|
-
};
|
|
11577
|
-
|
|
11578
|
-
// lib/websafe/convert-to-typescript-component/is-led-category-component.ts
|
|
11579
|
-
var isLedCategoryComponent = (betterEasy) => {
|
|
11580
|
-
const cPara = betterEasy.dataStr.head.c_para;
|
|
11581
|
-
return [
|
|
11582
|
-
betterEasy.tags,
|
|
11583
|
-
cPara.category,
|
|
11584
|
-
cPara.Category,
|
|
11585
|
-
cPara["LCSC Category"],
|
|
11586
|
-
cPara["JLCPCB Category"],
|
|
11587
|
-
betterEasy.category
|
|
11588
|
-
].some(categoryValueContainsLed);
|
|
11589
|
-
};
|
|
11590
|
-
|
|
11591
11612
|
// lib/websafe/convert-to-typescript-component/category-value-contains-pushbutton.ts
|
|
11592
11613
|
var categoryValueContainsPushbutton = (value) => {
|
|
11593
11614
|
if (typeof value === "string") {
|