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/index.js
CHANGED
|
@@ -5634,6 +5634,9 @@ var mil2mm = (mil) => {
|
|
|
5634
5634
|
return mm(mil);
|
|
5635
5635
|
};
|
|
5636
5636
|
|
|
5637
|
+
// lib/constants.ts
|
|
5638
|
+
var DEFAULT_PCB_THICKNESS_MM = 1.6;
|
|
5639
|
+
|
|
5637
5640
|
// lib/math/arc-utils.ts
|
|
5638
5641
|
function generateArcFromSweep(startX, startY, endX, endY, radius, largeArcFlag, sweepFlag) {
|
|
5639
5642
|
const start = { x: startX, y: startY };
|
|
@@ -5682,6 +5685,173 @@ function generateArcFromSweep(startX, startY, endX, endY, radius, largeArcFlag,
|
|
|
5682
5685
|
// lib/utils/easyeda-unit-to-mm.ts
|
|
5683
5686
|
var mil10ToMm = (value) => value * 10 * 0.0254;
|
|
5684
5687
|
|
|
5688
|
+
// lib/utils/get-polarized-pin-metadata.ts
|
|
5689
|
+
var getPinLabelValues = (labels) => {
|
|
5690
|
+
if (typeof labels === "string") return [labels];
|
|
5691
|
+
return [...labels];
|
|
5692
|
+
};
|
|
5693
|
+
var stripEasyEdaPolarityHintDecoration = (label) => label.toLowerCase().replace(/[^a-z0-9+-]/g, "");
|
|
5694
|
+
var getPinKeySortValue = (pinKey) => {
|
|
5695
|
+
const match = /^pin(\d+)$/i.exec(pinKey);
|
|
5696
|
+
return match ? Number(match[1]) : Number.MAX_SAFE_INTEGER;
|
|
5697
|
+
};
|
|
5698
|
+
var getPolarizedPinMetadata = (pinLabels) => {
|
|
5699
|
+
const labelsByPin = Object.entries(pinLabels).map(([pin, labels]) => ({
|
|
5700
|
+
pin,
|
|
5701
|
+
labels: getPinLabelValues(labels).map(stripEasyEdaPolarityHintDecoration)
|
|
5702
|
+
}));
|
|
5703
|
+
const anodePin = labelsByPin.find(
|
|
5704
|
+
({ labels }) => labels.some((label) => ["a", "anode", "pos", "+"].includes(label))
|
|
5705
|
+
)?.pin;
|
|
5706
|
+
const cathodePin = labelsByPin.find(
|
|
5707
|
+
({ labels }) => labels.some((label) => ["c", "k", "cathode", "neg", "-"].includes(label))
|
|
5708
|
+
)?.pin;
|
|
5709
|
+
if (!anodePin || !cathodePin || anodePin === cathodePin) return void 0;
|
|
5710
|
+
const polarizedPinEntries = [
|
|
5711
|
+
[anodePin, ["anode", "pos"]],
|
|
5712
|
+
[cathodePin, ["cathode", "neg"]]
|
|
5713
|
+
].sort(
|
|
5714
|
+
([pinA], [pinB]) => getPinKeySortValue(pinA) - getPinKeySortValue(pinB)
|
|
5715
|
+
);
|
|
5716
|
+
return {
|
|
5717
|
+
portHintsMap: Object.fromEntries(
|
|
5718
|
+
polarizedPinEntries.map(([pin, labels]) => [pin, [pin, ...labels]])
|
|
5719
|
+
),
|
|
5720
|
+
pinLabels: Object.fromEntries(polarizedPinEntries)
|
|
5721
|
+
};
|
|
5722
|
+
};
|
|
5723
|
+
|
|
5724
|
+
// lib/utils/normalize-pin-labels.ts
|
|
5725
|
+
var normalizePinLabels = (inputPinLabels) => {
|
|
5726
|
+
const uniqueInputPinLabels = inputPinLabels.map((labels) => [
|
|
5727
|
+
...new Set(labels)
|
|
5728
|
+
]);
|
|
5729
|
+
const result = uniqueInputPinLabels.map(() => []);
|
|
5730
|
+
const desiredNumbers = uniqueInputPinLabels.map(() => null);
|
|
5731
|
+
for (let i = 0; i < uniqueInputPinLabels.length; i++) {
|
|
5732
|
+
for (const label of uniqueInputPinLabels[i]) {
|
|
5733
|
+
if (/^\d+$/.test(label)) {
|
|
5734
|
+
desiredNumbers[i] = Number.parseInt(label);
|
|
5735
|
+
break;
|
|
5736
|
+
}
|
|
5737
|
+
}
|
|
5738
|
+
}
|
|
5739
|
+
let highestPinNumber = 0;
|
|
5740
|
+
const acceptedDesiredNumbers = /* @__PURE__ */ new Set();
|
|
5741
|
+
for (let i = 0; i < desiredNumbers.length; i++) {
|
|
5742
|
+
const desiredNumber = desiredNumbers[i];
|
|
5743
|
+
if (desiredNumber === null || desiredNumber < 1) continue;
|
|
5744
|
+
if (!acceptedDesiredNumbers.has(desiredNumber)) {
|
|
5745
|
+
acceptedDesiredNumbers.add(desiredNumber);
|
|
5746
|
+
result[i].push(`pin${desiredNumber}`);
|
|
5747
|
+
highestPinNumber = Math.max(highestPinNumber, desiredNumber);
|
|
5748
|
+
continue;
|
|
5749
|
+
}
|
|
5750
|
+
let existingAltCount = 0;
|
|
5751
|
+
for (const label of result[i]) {
|
|
5752
|
+
if (label.startsWith(`pin${desiredNumber}_alt`)) {
|
|
5753
|
+
existingAltCount += 1;
|
|
5754
|
+
}
|
|
5755
|
+
}
|
|
5756
|
+
result[i].push(`pin${desiredNumber}_alt${existingAltCount + 1}`);
|
|
5757
|
+
}
|
|
5758
|
+
for (let i = 0; i < result.length; i++) {
|
|
5759
|
+
const firstLabel = result[i][0];
|
|
5760
|
+
if (firstLabel?.includes("_alt")) {
|
|
5761
|
+
highestPinNumber += 1;
|
|
5762
|
+
result[i].unshift(`pin${highestPinNumber}`);
|
|
5763
|
+
}
|
|
5764
|
+
}
|
|
5765
|
+
for (let i = 0; i < result.length; i++) {
|
|
5766
|
+
if (result[i].length === 0) {
|
|
5767
|
+
highestPinNumber += 1;
|
|
5768
|
+
result[i].push(`pin${highestPinNumber}`);
|
|
5769
|
+
}
|
|
5770
|
+
}
|
|
5771
|
+
const totalLabelCounts = {};
|
|
5772
|
+
for (const inputLabels of uniqueInputPinLabels) {
|
|
5773
|
+
for (const label of inputLabels) {
|
|
5774
|
+
if (/^\d+$/.test(label)) continue;
|
|
5775
|
+
totalLabelCounts[label] = (totalLabelCounts[label] ?? 0) + 1;
|
|
5776
|
+
}
|
|
5777
|
+
}
|
|
5778
|
+
const incrementalLabelCounts = {};
|
|
5779
|
+
for (let i = 0; i < uniqueInputPinLabels.length; i++) {
|
|
5780
|
+
for (const label of uniqueInputPinLabels[i]) {
|
|
5781
|
+
if (/^\d+$/.test(label)) continue;
|
|
5782
|
+
if (totalLabelCounts[label] === 1) {
|
|
5783
|
+
result[i].push(label);
|
|
5784
|
+
} else {
|
|
5785
|
+
incrementalLabelCounts[label] = (incrementalLabelCounts[label] ?? 0) + 1;
|
|
5786
|
+
result[i].push(`${label}${incrementalLabelCounts[label]}`);
|
|
5787
|
+
}
|
|
5788
|
+
}
|
|
5789
|
+
}
|
|
5790
|
+
return result;
|
|
5791
|
+
};
|
|
5792
|
+
|
|
5793
|
+
// lib/utils/normalize-symbol-name.ts
|
|
5794
|
+
var normalizeSymbolName = (name) => {
|
|
5795
|
+
const trimmedName = name.trim();
|
|
5796
|
+
if (trimmedName === "+") return "_POS";
|
|
5797
|
+
if (trimmedName === "-") return "_NEG";
|
|
5798
|
+
return trimmedName;
|
|
5799
|
+
};
|
|
5800
|
+
|
|
5801
|
+
// lib/websafe/convert-to-typescript-component/category-value-contains-diode.ts
|
|
5802
|
+
var categoryValueContainsDiode = (value) => {
|
|
5803
|
+
if (typeof value === "string") {
|
|
5804
|
+
return /(^|[^a-z])diodes?([^a-z]|$)/i.test(value);
|
|
5805
|
+
}
|
|
5806
|
+
if (Array.isArray(value)) {
|
|
5807
|
+
return value.some(categoryValueContainsDiode);
|
|
5808
|
+
}
|
|
5809
|
+
if (value && typeof value === "object") {
|
|
5810
|
+
return Object.values(value).some(categoryValueContainsDiode);
|
|
5811
|
+
}
|
|
5812
|
+
return false;
|
|
5813
|
+
};
|
|
5814
|
+
|
|
5815
|
+
// lib/websafe/convert-to-typescript-component/is-diode-category-component.ts
|
|
5816
|
+
var isDiodeCategoryComponent = (betterEasy) => {
|
|
5817
|
+
const cPara = betterEasy.dataStr.head.c_para;
|
|
5818
|
+
return [
|
|
5819
|
+
betterEasy.tags,
|
|
5820
|
+
cPara.category,
|
|
5821
|
+
cPara.Category,
|
|
5822
|
+
cPara["LCSC Category"],
|
|
5823
|
+
cPara["JLCPCB Category"],
|
|
5824
|
+
betterEasy.category
|
|
5825
|
+
].some(categoryValueContainsDiode);
|
|
5826
|
+
};
|
|
5827
|
+
|
|
5828
|
+
// lib/websafe/convert-to-typescript-component/category-value-contains-led.ts
|
|
5829
|
+
var categoryValueContainsLed = (value) => {
|
|
5830
|
+
if (typeof value === "string") {
|
|
5831
|
+
return /(^|[^a-z])leds?([^a-z]|$)/i.test(value) || /light[-\s]?emitting\s+diodes?/i.test(value);
|
|
5832
|
+
}
|
|
5833
|
+
if (Array.isArray(value)) {
|
|
5834
|
+
return value.some(categoryValueContainsLed);
|
|
5835
|
+
}
|
|
5836
|
+
if (value && typeof value === "object") {
|
|
5837
|
+
return Object.values(value).some(categoryValueContainsLed);
|
|
5838
|
+
}
|
|
5839
|
+
return false;
|
|
5840
|
+
};
|
|
5841
|
+
|
|
5842
|
+
// lib/websafe/convert-to-typescript-component/is-led-category-component.ts
|
|
5843
|
+
var isLedCategoryComponent = (betterEasy) => {
|
|
5844
|
+
const cPara = betterEasy.dataStr.head.c_para;
|
|
5845
|
+
return [
|
|
5846
|
+
betterEasy.tags,
|
|
5847
|
+
cPara.category,
|
|
5848
|
+
cPara.Category,
|
|
5849
|
+
cPara["LCSC Category"],
|
|
5850
|
+
cPara["JLCPCB Category"],
|
|
5851
|
+
betterEasy.category
|
|
5852
|
+
].some(categoryValueContainsLed);
|
|
5853
|
+
};
|
|
5854
|
+
|
|
5685
5855
|
// node_modules/@tscircuit/math-utils/dist/chunk-3WCUPG5S.js
|
|
5686
5856
|
var getBoundsCenter = (bounds) => ({
|
|
5687
5857
|
x: (bounds.minX + bounds.maxX) / 2,
|
|
@@ -5818,86 +5988,6 @@ var getCadSvgNodeZOffsetMm = (easyEdaJson) => {
|
|
|
5818
5988
|
};
|
|
5819
5989
|
var getCadSvgNodeModelUuid = (easyEdaJson) => getCadSvgNode(easyEdaJson)?.svgData.attrs?.uuid ?? null;
|
|
5820
5990
|
|
|
5821
|
-
// lib/utils/normalize-pin-labels.ts
|
|
5822
|
-
var normalizePinLabels = (inputPinLabels) => {
|
|
5823
|
-
const uniqueInputPinLabels = inputPinLabels.map((labels) => [
|
|
5824
|
-
...new Set(labels)
|
|
5825
|
-
]);
|
|
5826
|
-
const result = uniqueInputPinLabels.map(() => []);
|
|
5827
|
-
const desiredNumbers = uniqueInputPinLabels.map(() => null);
|
|
5828
|
-
for (let i = 0; i < uniqueInputPinLabels.length; i++) {
|
|
5829
|
-
for (const label of uniqueInputPinLabels[i]) {
|
|
5830
|
-
if (/^\d+$/.test(label)) {
|
|
5831
|
-
desiredNumbers[i] = Number.parseInt(label);
|
|
5832
|
-
break;
|
|
5833
|
-
}
|
|
5834
|
-
}
|
|
5835
|
-
}
|
|
5836
|
-
let highestPinNumber = 0;
|
|
5837
|
-
const acceptedDesiredNumbers = /* @__PURE__ */ new Set();
|
|
5838
|
-
for (let i = 0; i < desiredNumbers.length; i++) {
|
|
5839
|
-
const desiredNumber = desiredNumbers[i];
|
|
5840
|
-
if (desiredNumber === null || desiredNumber < 1) continue;
|
|
5841
|
-
if (!acceptedDesiredNumbers.has(desiredNumber)) {
|
|
5842
|
-
acceptedDesiredNumbers.add(desiredNumber);
|
|
5843
|
-
result[i].push(`pin${desiredNumber}`);
|
|
5844
|
-
highestPinNumber = Math.max(highestPinNumber, desiredNumber);
|
|
5845
|
-
continue;
|
|
5846
|
-
}
|
|
5847
|
-
let existingAltCount = 0;
|
|
5848
|
-
for (const label of result[i]) {
|
|
5849
|
-
if (label.startsWith(`pin${desiredNumber}_alt`)) {
|
|
5850
|
-
existingAltCount += 1;
|
|
5851
|
-
}
|
|
5852
|
-
}
|
|
5853
|
-
result[i].push(`pin${desiredNumber}_alt${existingAltCount + 1}`);
|
|
5854
|
-
}
|
|
5855
|
-
for (let i = 0; i < result.length; i++) {
|
|
5856
|
-
const firstLabel = result[i][0];
|
|
5857
|
-
if (firstLabel?.includes("_alt")) {
|
|
5858
|
-
highestPinNumber += 1;
|
|
5859
|
-
result[i].unshift(`pin${highestPinNumber}`);
|
|
5860
|
-
}
|
|
5861
|
-
}
|
|
5862
|
-
for (let i = 0; i < result.length; i++) {
|
|
5863
|
-
if (result[i].length === 0) {
|
|
5864
|
-
highestPinNumber += 1;
|
|
5865
|
-
result[i].push(`pin${highestPinNumber}`);
|
|
5866
|
-
}
|
|
5867
|
-
}
|
|
5868
|
-
const totalLabelCounts = {};
|
|
5869
|
-
for (const inputLabels of uniqueInputPinLabels) {
|
|
5870
|
-
for (const label of inputLabels) {
|
|
5871
|
-
if (/^\d+$/.test(label)) continue;
|
|
5872
|
-
totalLabelCounts[label] = (totalLabelCounts[label] ?? 0) + 1;
|
|
5873
|
-
}
|
|
5874
|
-
}
|
|
5875
|
-
const incrementalLabelCounts = {};
|
|
5876
|
-
for (let i = 0; i < uniqueInputPinLabels.length; i++) {
|
|
5877
|
-
for (const label of uniqueInputPinLabels[i]) {
|
|
5878
|
-
if (/^\d+$/.test(label)) continue;
|
|
5879
|
-
if (totalLabelCounts[label] === 1) {
|
|
5880
|
-
result[i].push(label);
|
|
5881
|
-
} else {
|
|
5882
|
-
incrementalLabelCounts[label] = (incrementalLabelCounts[label] ?? 0) + 1;
|
|
5883
|
-
result[i].push(`${label}${incrementalLabelCounts[label]}`);
|
|
5884
|
-
}
|
|
5885
|
-
}
|
|
5886
|
-
}
|
|
5887
|
-
return result;
|
|
5888
|
-
};
|
|
5889
|
-
|
|
5890
|
-
// lib/utils/normalize-symbol-name.ts
|
|
5891
|
-
var normalizeSymbolName = (name) => {
|
|
5892
|
-
const trimmedName = name.trim();
|
|
5893
|
-
if (trimmedName === "+") return "_POS";
|
|
5894
|
-
if (trimmedName === "-") return "_NEG";
|
|
5895
|
-
return trimmedName;
|
|
5896
|
-
};
|
|
5897
|
-
|
|
5898
|
-
// lib/constants.ts
|
|
5899
|
-
var DEFAULT_PCB_THICKNESS_MM = 1.6;
|
|
5900
|
-
|
|
5901
5991
|
// lib/convert-easyeda-json-to-tscircuit-soup-json.ts
|
|
5902
5992
|
var EASYEDA_STEP_MODEL_URL = "https://modules.easyeda.com/qAxj6KHrDKw4blvCG8QJPs7Y";
|
|
5903
5993
|
var EASYEDA_OBJ_MODEL_URL = "https://modules.easyeda.com/3dmodel";
|
|
@@ -6103,11 +6193,20 @@ var convertEasyEdaJsonToCircuitJson = (easyEdaJson, {
|
|
|
6103
6193
|
return labels;
|
|
6104
6194
|
});
|
|
6105
6195
|
const normalizedPinLabels = normalizePinLabels(pinLabelSets);
|
|
6196
|
+
const normalizedPinLabelsByPin = Object.fromEntries(
|
|
6197
|
+
normalizedPinLabels.map((labels) => {
|
|
6198
|
+
const pin = labels.find((label) => /^pin\d+$/i.test(label));
|
|
6199
|
+
return [pin, labels.filter((label) => label !== pin)];
|
|
6200
|
+
})
|
|
6201
|
+
);
|
|
6202
|
+
const polarizedPinMetadata = pads.length === 2 && (isDiodeCategoryComponent(easyEdaJson) || isLedCategoryComponent(easyEdaJson)) ? getPolarizedPinMetadata(normalizedPinLabelsByPin) : void 0;
|
|
6106
6203
|
pads.forEach((pad, index) => {
|
|
6107
6204
|
const portHints = normalizedPinLabels[index];
|
|
6108
6205
|
const pinNumber = Number.parseInt(
|
|
6109
6206
|
portHints.find((hint) => hint.match(/pin\d+/)).replace("pin", "")
|
|
6110
6207
|
);
|
|
6208
|
+
const canonicalPinName = `pin${pinNumber}`;
|
|
6209
|
+
const pcbPortHints = polarizedPinMetadata?.portHintsMap[canonicalPinName] ?? [canonicalPinName];
|
|
6111
6210
|
circuitElements.push({
|
|
6112
6211
|
type: "source_port",
|
|
6113
6212
|
source_port_id: `source_port_${index + 1}`,
|
|
@@ -6124,7 +6223,7 @@ var convertEasyEdaJsonToCircuitJson = (easyEdaJson, {
|
|
|
6124
6223
|
x: mil2mm(pad.center.x),
|
|
6125
6224
|
y: mil2mm(pad.center.y),
|
|
6126
6225
|
layers: ["top"],
|
|
6127
|
-
port_hints:
|
|
6226
|
+
port_hints: pcbPortHints,
|
|
6128
6227
|
pcb_component_id: "pcb_component_1",
|
|
6129
6228
|
pcb_port_id: `pcb_port_${index + 1}`
|
|
6130
6229
|
};
|
|
@@ -6236,7 +6335,7 @@ var convertEasyEdaJsonToCircuitJson = (easyEdaJson, {
|
|
|
6236
6335
|
radius: Math.min(mil2mm(pad.width), mil2mm(pad.height)) / 2
|
|
6237
6336
|
},
|
|
6238
6337
|
layer: "top",
|
|
6239
|
-
port_hints:
|
|
6338
|
+
port_hints: pcbPortHints,
|
|
6240
6339
|
pcb_component_id: "pcb_component_1",
|
|
6241
6340
|
pcb_port_id: `pcb_port_${index + 1}`
|
|
6242
6341
|
});
|
|
@@ -6663,7 +6762,7 @@ import { z as z181 } from "zod";
|
|
|
6663
6762
|
import { z as z179 } from "zod";
|
|
6664
6763
|
var safeNumber = (defaultValue = 0) => z179.union([z179.number(), z179.string()]).transform((val) => {
|
|
6665
6764
|
const num = Number(val);
|
|
6666
|
-
return isNaN(num) ? defaultValue : num;
|
|
6765
|
+
return Number.isNaN(num) ? defaultValue : num;
|
|
6667
6766
|
}).default(defaultValue);
|
|
6668
6767
|
var tenthmil = z179.union([z179.number(), z179.string()]).optional().transform(
|
|
6669
6768
|
(n) => typeof n === "string" && n.endsWith("mil") ? n : `${Number.parseFloat(n) * 10}mil`
|
|
@@ -6810,6 +6909,7 @@ var ShapeItemSchema = z179.object({
|
|
|
6810
6909
|
}
|
|
6811
6910
|
case "PAD": {
|
|
6812
6911
|
const [padShape, ...params] = shape.data.split("~");
|
|
6912
|
+
const rawPadNumber = params[6];
|
|
6813
6913
|
const [
|
|
6814
6914
|
centerX,
|
|
6815
6915
|
centerY,
|
|
@@ -6817,10 +6917,11 @@ var ShapeItemSchema = z179.object({
|
|
|
6817
6917
|
height,
|
|
6818
6918
|
layermask,
|
|
6819
6919
|
net,
|
|
6820
|
-
|
|
6920
|
+
numericPadNumber,
|
|
6821
6921
|
holeRadius,
|
|
6822
6922
|
...rest
|
|
6823
6923
|
] = params.map((p) => Number.isNaN(Number(p)) ? p : Number(p));
|
|
6924
|
+
const padNumber = /^[+-]?(?:\d+(?:\.\d*)?|\.\d+)$/.test(rawPadNumber) ? numericPadNumber : rawPadNumber;
|
|
6824
6925
|
const center = { x: centerX, y: centerY };
|
|
6825
6926
|
let points;
|
|
6826
6927
|
if (padShape === "RECT" || padShape === "POLYGON") {
|
|
@@ -6836,7 +6937,7 @@ var ShapeItemSchema = z179.object({
|
|
|
6836
6937
|
height,
|
|
6837
6938
|
layermask,
|
|
6838
6939
|
net,
|
|
6839
|
-
number,
|
|
6940
|
+
number: padNumber,
|
|
6840
6941
|
holeRadius,
|
|
6841
6942
|
points,
|
|
6842
6943
|
rotation: rotation2,
|
|
@@ -7288,7 +7389,7 @@ var OwnerSchema = z181.object({
|
|
|
7288
7389
|
});
|
|
7289
7390
|
var HeadSchema = z181.object({
|
|
7290
7391
|
docType: z181.preprocess((val) => val == null ? val : String(val), z181.string()),
|
|
7291
|
-
editorVersion: z181.string(),
|
|
7392
|
+
editorVersion: z181.string().default(""),
|
|
7292
7393
|
c_para: z181.record(z181.string(), z181.string().nullable()),
|
|
7293
7394
|
x: z181.number(),
|
|
7294
7395
|
y: z181.number(),
|
|
@@ -7301,7 +7402,7 @@ var HeadSchema = z181.object({
|
|
|
7301
7402
|
}, z181.number()),
|
|
7302
7403
|
importFlag: z181.number().optional(),
|
|
7303
7404
|
c_spiceCmd: z181.any().optional(),
|
|
7304
|
-
hasIdFlag: z181.boolean()
|
|
7405
|
+
hasIdFlag: z181.boolean().default(false)
|
|
7305
7406
|
});
|
|
7306
7407
|
var BBoxSchema = z181.object({
|
|
7307
7408
|
x: z181.number(),
|
|
@@ -7326,9 +7427,17 @@ var DataStrSchema = z181.object({
|
|
|
7326
7427
|
head: HeadSchema,
|
|
7327
7428
|
canvas: z181.string(),
|
|
7328
7429
|
shape: z181.array(SingleLetterShapeSchema),
|
|
7329
|
-
BBox: BBoxSchema,
|
|
7330
|
-
colors: z181.union([z181.array(z181.string()), z181.record(z181.string())])
|
|
7331
|
-
})
|
|
7430
|
+
BBox: BBoxSchema.optional(),
|
|
7431
|
+
colors: z181.union([z181.array(z181.string()), z181.record(z181.string())]).default([])
|
|
7432
|
+
}).transform((data) => ({
|
|
7433
|
+
...data,
|
|
7434
|
+
BBox: data.BBox ?? {
|
|
7435
|
+
x: data.head.x,
|
|
7436
|
+
y: data.head.y,
|
|
7437
|
+
width: 0,
|
|
7438
|
+
height: 0
|
|
7439
|
+
}
|
|
7440
|
+
}));
|
|
7332
7441
|
var PackageDetailDataStrSchema = z181.object({
|
|
7333
7442
|
head: HeadSchema,
|
|
7334
7443
|
canvas: z181.string(),
|
|
@@ -7523,7 +7632,7 @@ var getEasyEdaCadModelPlacement = async (easyEdaJson, { fetch: fetch2 = globalTh
|
|
|
7523
7632
|
// lib/websafe/generate-footprint-tsx.ts
|
|
7524
7633
|
var mapPortHints = (portHints, portHintsMap) => {
|
|
7525
7634
|
if (!portHintsMap || !portHints) return portHints;
|
|
7526
|
-
return portHints.flatMap((hint) => portHintsMap[hint] ?? [hint]);
|
|
7635
|
+
return [...new Set(portHints.flatMap((hint) => portHintsMap[hint] ?? [hint]))];
|
|
7527
7636
|
};
|
|
7528
7637
|
var generateFootprintTsx = (circuitJson, options = {}) => {
|
|
7529
7638
|
const holes = su(circuitJson).pcb_hole.list();
|
|
@@ -7617,40 +7726,6 @@ var generateFootprintTsx = (circuitJson, options = {}) => {
|
|
|
7617
7726
|
};
|
|
7618
7727
|
|
|
7619
7728
|
// lib/websafe/convert-to-typescript-component/generate-typescript-component.ts
|
|
7620
|
-
var getPinLabelValues = (labels) => {
|
|
7621
|
-
if (typeof labels === "string") return [labels];
|
|
7622
|
-
return [...labels];
|
|
7623
|
-
};
|
|
7624
|
-
var stripEasyEdaPolarityHintDecoration = (label) => label.toLowerCase().replace(/[^a-z0-9+-]/g, "");
|
|
7625
|
-
var getPinKeySortValue = (pinKey) => {
|
|
7626
|
-
const match = /^pin(\d+)$/i.exec(pinKey);
|
|
7627
|
-
return match ? Number(match[1]) : Number.MAX_SAFE_INTEGER;
|
|
7628
|
-
};
|
|
7629
|
-
var getPolarizedPinMetadata = (pinLabels) => {
|
|
7630
|
-
const labelsByPin = Object.entries(pinLabels ?? {}).map(([pin, labels]) => ({
|
|
7631
|
-
pin,
|
|
7632
|
-
labels: getPinLabelValues(labels).map(stripEasyEdaPolarityHintDecoration)
|
|
7633
|
-
}));
|
|
7634
|
-
const anodePin = labelsByPin.find(
|
|
7635
|
-
({ labels }) => labels.some((label) => ["a", "anode", "pos", "+"].includes(label))
|
|
7636
|
-
)?.pin;
|
|
7637
|
-
const cathodePin = labelsByPin.find(
|
|
7638
|
-
({ labels }) => labels.some((label) => ["c", "k", "cathode", "neg", "-"].includes(label))
|
|
7639
|
-
)?.pin;
|
|
7640
|
-
if (!anodePin || !cathodePin) return void 0;
|
|
7641
|
-
const polarizedPinEntries = [
|
|
7642
|
-
[anodePin, ["anode", "pos"]],
|
|
7643
|
-
[cathodePin, ["cathode", "neg"]]
|
|
7644
|
-
].sort(
|
|
7645
|
-
([pinA], [pinB]) => getPinKeySortValue(pinA) - getPinKeySortValue(pinB)
|
|
7646
|
-
);
|
|
7647
|
-
return {
|
|
7648
|
-
portHintsMap: Object.fromEntries(
|
|
7649
|
-
polarizedPinEntries.map(([pin, labels]) => [pin, [pin, ...labels]])
|
|
7650
|
-
),
|
|
7651
|
-
pinLabels: Object.fromEntries(polarizedPinEntries)
|
|
7652
|
-
};
|
|
7653
|
-
};
|
|
7654
7729
|
var generateTypescriptComponent = ({
|
|
7655
7730
|
pinLabels,
|
|
7656
7731
|
componentName,
|
|
@@ -7820,60 +7895,6 @@ ${cadModelLines}
|
|
|
7820
7895
|
`.trim();
|
|
7821
7896
|
};
|
|
7822
7897
|
|
|
7823
|
-
// lib/websafe/convert-to-typescript-component/category-value-contains-diode.ts
|
|
7824
|
-
var categoryValueContainsDiode = (value) => {
|
|
7825
|
-
if (typeof value === "string") {
|
|
7826
|
-
return /(^|[^a-z])diodes?([^a-z]|$)/i.test(value);
|
|
7827
|
-
}
|
|
7828
|
-
if (Array.isArray(value)) {
|
|
7829
|
-
return value.some(categoryValueContainsDiode);
|
|
7830
|
-
}
|
|
7831
|
-
if (value && typeof value === "object") {
|
|
7832
|
-
return Object.values(value).some(categoryValueContainsDiode);
|
|
7833
|
-
}
|
|
7834
|
-
return false;
|
|
7835
|
-
};
|
|
7836
|
-
|
|
7837
|
-
// lib/websafe/convert-to-typescript-component/is-diode-category-component.ts
|
|
7838
|
-
var isDiodeCategoryComponent = (betterEasy) => {
|
|
7839
|
-
const cPara = betterEasy.dataStr.head.c_para;
|
|
7840
|
-
return [
|
|
7841
|
-
betterEasy.tags,
|
|
7842
|
-
cPara.category,
|
|
7843
|
-
cPara.Category,
|
|
7844
|
-
cPara["LCSC Category"],
|
|
7845
|
-
cPara["JLCPCB Category"],
|
|
7846
|
-
betterEasy.category
|
|
7847
|
-
].some(categoryValueContainsDiode);
|
|
7848
|
-
};
|
|
7849
|
-
|
|
7850
|
-
// lib/websafe/convert-to-typescript-component/category-value-contains-led.ts
|
|
7851
|
-
var categoryValueContainsLed = (value) => {
|
|
7852
|
-
if (typeof value === "string") {
|
|
7853
|
-
return /(^|[^a-z])leds?([^a-z]|$)/i.test(value) || /light[-\s]?emitting\s+diodes?/i.test(value);
|
|
7854
|
-
}
|
|
7855
|
-
if (Array.isArray(value)) {
|
|
7856
|
-
return value.some(categoryValueContainsLed);
|
|
7857
|
-
}
|
|
7858
|
-
if (value && typeof value === "object") {
|
|
7859
|
-
return Object.values(value).some(categoryValueContainsLed);
|
|
7860
|
-
}
|
|
7861
|
-
return false;
|
|
7862
|
-
};
|
|
7863
|
-
|
|
7864
|
-
// lib/websafe/convert-to-typescript-component/is-led-category-component.ts
|
|
7865
|
-
var isLedCategoryComponent = (betterEasy) => {
|
|
7866
|
-
const cPara = betterEasy.dataStr.head.c_para;
|
|
7867
|
-
return [
|
|
7868
|
-
betterEasy.tags,
|
|
7869
|
-
cPara.category,
|
|
7870
|
-
cPara.Category,
|
|
7871
|
-
cPara["LCSC Category"],
|
|
7872
|
-
cPara["JLCPCB Category"],
|
|
7873
|
-
betterEasy.category
|
|
7874
|
-
].some(categoryValueContainsLed);
|
|
7875
|
-
};
|
|
7876
|
-
|
|
7877
7898
|
// lib/websafe/convert-to-typescript-component/category-value-contains-pushbutton.ts
|
|
7878
7899
|
var categoryValueContainsPushbutton = (value) => {
|
|
7879
7900
|
if (typeof value === "string") {
|