easyeda 0.0.282 → 0.0.283

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.
@@ -12151,9 +12151,24 @@ async function fetchEasyEDAComponent(jlcpcbPartNumber, {
12151
12151
  if (!searchResult.success || !searchResult.result.lists.lcsc.length) {
12152
12152
  throw new Error("Component not found");
12153
12153
  }
12154
+ const requestedPartNumber = jlcpcbPartNumber.trim().toUpperCase();
12154
12155
  const bestMatchComponent = searchResult.result.lists.lcsc.find(
12155
- (component) => component.dataStr.head.c_para["Supplier Part"] === jlcpcbPartNumber
12156
- ) ?? searchResult.result.lists.lcsc[0];
12156
+ (component) => {
12157
+ const candidatePartNumbers = [
12158
+ component.dataStr?.head?.c_para?.["Supplier Part"],
12159
+ component.lcsc?.number,
12160
+ component.szlcsc?.number
12161
+ ];
12162
+ return candidatePartNumbers.some(
12163
+ (partNumber) => typeof partNumber === "string" && partNumber.trim().toUpperCase() === requestedPartNumber
12164
+ );
12165
+ }
12166
+ );
12167
+ if (!bestMatchComponent) {
12168
+ throw new Error(
12169
+ `No exact EasyEDA component match for "${jlcpcbPartNumber}"`
12170
+ );
12171
+ }
12157
12172
  const componentUUID = bestMatchComponent.uuid;
12158
12173
  const componentResponse = await fetch2(componentUrl(componentUUID), {
12159
12174
  method: "GET",