easyeda 0.0.282 → 0.0.284
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 +23 -4
- package/dist/browser/index.js.map +1 -1
- package/dist/index.js +23 -4
- package/dist/index.js.map +1 -1
- package/dist/main.cjs +24 -5
- package/dist/main.cjs.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -6703,9 +6703,24 @@ async function fetchEasyEDAComponent(jlcpcbPartNumber, {
|
|
|
6703
6703
|
if (!searchResult.success || !searchResult.result.lists.lcsc.length) {
|
|
6704
6704
|
throw new Error("Component not found");
|
|
6705
6705
|
}
|
|
6706
|
+
const requestedPartNumber = jlcpcbPartNumber.trim().toUpperCase();
|
|
6706
6707
|
const bestMatchComponent = searchResult.result.lists.lcsc.find(
|
|
6707
|
-
(component) =>
|
|
6708
|
-
|
|
6708
|
+
(component) => {
|
|
6709
|
+
const candidatePartNumbers = [
|
|
6710
|
+
component.dataStr?.head?.c_para?.["Supplier Part"],
|
|
6711
|
+
component.lcsc?.number,
|
|
6712
|
+
component.szlcsc?.number
|
|
6713
|
+
];
|
|
6714
|
+
return candidatePartNumbers.some(
|
|
6715
|
+
(partNumber) => typeof partNumber === "string" && partNumber.trim().toUpperCase() === requestedPartNumber
|
|
6716
|
+
);
|
|
6717
|
+
}
|
|
6718
|
+
);
|
|
6719
|
+
if (!bestMatchComponent) {
|
|
6720
|
+
throw new Error(
|
|
6721
|
+
`No exact EasyEDA component match for "${jlcpcbPartNumber}"`
|
|
6722
|
+
);
|
|
6723
|
+
}
|
|
6709
6724
|
const componentUUID = bestMatchComponent.uuid;
|
|
6710
6725
|
const componentResponse = await fetch2(componentUrl(componentUUID), {
|
|
6711
6726
|
method: "GET",
|
|
@@ -7273,8 +7288,12 @@ var parsePath = (str) => {
|
|
|
7273
7288
|
};
|
|
7274
7289
|
var PathShapeSchema = z180.string().startsWith("PT~").transform(parsePath).pipe(PathShapeOutputSchema);
|
|
7275
7290
|
var optionalEasyEdaTextField = (fieldSchema) => z180.preprocess((textField) => {
|
|
7276
|
-
if (textField == null
|
|
7277
|
-
|
|
7291
|
+
if (textField == null) return void 0;
|
|
7292
|
+
if (typeof textField === "string") {
|
|
7293
|
+
const trimmedTextField = textField.trim();
|
|
7294
|
+
if (trimmedTextField === "" || trimmedTextField === "undefined") {
|
|
7295
|
+
return void 0;
|
|
7296
|
+
}
|
|
7278
7297
|
}
|
|
7279
7298
|
return textField;
|
|
7280
7299
|
}, fieldSchema);
|