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/main.cjs CHANGED
@@ -3454,9 +3454,24 @@ async function fetchEasyEDAComponent(jlcpcbPartNumber, {
3454
3454
  if (!searchResult.success || !searchResult.result.lists.lcsc.length) {
3455
3455
  throw new Error("Component not found");
3456
3456
  }
3457
+ const requestedPartNumber = jlcpcbPartNumber.trim().toUpperCase();
3457
3458
  const bestMatchComponent = searchResult.result.lists.lcsc.find(
3458
- (component) => component.dataStr.head.c_para["Supplier Part"] === jlcpcbPartNumber
3459
- ) ?? searchResult.result.lists.lcsc[0];
3459
+ (component) => {
3460
+ const candidatePartNumbers = [
3461
+ component.dataStr?.head?.c_para?.["Supplier Part"],
3462
+ component.lcsc?.number,
3463
+ component.szlcsc?.number
3464
+ ];
3465
+ return candidatePartNumbers.some(
3466
+ (partNumber) => typeof partNumber === "string" && partNumber.trim().toUpperCase() === requestedPartNumber
3467
+ );
3468
+ }
3469
+ );
3470
+ if (!bestMatchComponent) {
3471
+ throw new Error(
3472
+ `No exact EasyEDA component match for "${jlcpcbPartNumber}"`
3473
+ );
3474
+ }
3460
3475
  const componentUUID = bestMatchComponent.uuid;
3461
3476
  const componentResponse = await fetch2(componentUrl(componentUUID), {
3462
3477
  method: "GET",
@@ -3513,7 +3528,7 @@ var import_promises = __toESM(require("fs/promises"), 1);
3513
3528
  var package_default = {
3514
3529
  name: "easyeda",
3515
3530
  type: "module",
3516
- version: "0.0.281",
3531
+ version: "0.0.283",
3517
3532
  files: [
3518
3533
  "dist"
3519
3534
  ],
@@ -10680,8 +10695,12 @@ var parsePath = (str) => {
10680
10695
  };
10681
10696
  var PathShapeSchema = import_zod180.z.string().startsWith("PT~").transform(parsePath).pipe(PathShapeOutputSchema);
10682
10697
  var optionalEasyEdaTextField = (fieldSchema) => import_zod180.z.preprocess((textField) => {
10683
- if (textField == null || textField === "" || textField === "undefined") {
10684
- return void 0;
10698
+ if (textField == null) return void 0;
10699
+ if (typeof textField === "string") {
10700
+ const trimmedTextField = textField.trim();
10701
+ if (trimmedTextField === "" || trimmedTextField === "undefined") {
10702
+ return void 0;
10703
+ }
10685
10704
  }
10686
10705
  return textField;
10687
10706
  }, fieldSchema);