easyeda 0.0.281 → 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.
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) => component.dataStr.head.c_para["Supplier Part"] === jlcpcbPartNumber
6708
- ) ?? searchResult.result.lists.lcsc[0];
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",