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.
@@ -10972,8 +10972,12 @@ var parsePath = (str) => {
10972
10972
  };
10973
10973
  var PathShapeSchema = external_exports.string().startsWith("PT~").transform(parsePath).pipe(PathShapeOutputSchema);
10974
10974
  var optionalEasyEdaTextField = (fieldSchema) => external_exports.preprocess((textField) => {
10975
- if (textField == null || textField === "" || textField === "undefined") {
10976
- return void 0;
10975
+ if (textField == null) return void 0;
10976
+ if (typeof textField === "string") {
10977
+ const trimmedTextField = textField.trim();
10978
+ if (trimmedTextField === "" || trimmedTextField === "undefined") {
10979
+ return void 0;
10980
+ }
10977
10981
  }
10978
10982
  return textField;
10979
10983
  }, fieldSchema);
@@ -12151,9 +12155,24 @@ async function fetchEasyEDAComponent(jlcpcbPartNumber, {
12151
12155
  if (!searchResult.success || !searchResult.result.lists.lcsc.length) {
12152
12156
  throw new Error("Component not found");
12153
12157
  }
12158
+ const requestedPartNumber = jlcpcbPartNumber.trim().toUpperCase();
12154
12159
  const bestMatchComponent = searchResult.result.lists.lcsc.find(
12155
- (component) => component.dataStr.head.c_para["Supplier Part"] === jlcpcbPartNumber
12156
- ) ?? searchResult.result.lists.lcsc[0];
12160
+ (component) => {
12161
+ const candidatePartNumbers = [
12162
+ component.dataStr?.head?.c_para?.["Supplier Part"],
12163
+ component.lcsc?.number,
12164
+ component.szlcsc?.number
12165
+ ];
12166
+ return candidatePartNumbers.some(
12167
+ (partNumber) => typeof partNumber === "string" && partNumber.trim().toUpperCase() === requestedPartNumber
12168
+ );
12169
+ }
12170
+ );
12171
+ if (!bestMatchComponent) {
12172
+ throw new Error(
12173
+ `No exact EasyEDA component match for "${jlcpcbPartNumber}"`
12174
+ );
12175
+ }
12157
12176
  const componentUUID = bestMatchComponent.uuid;
12158
12177
  const componentResponse = await fetch2(componentUrl(componentUUID), {
12159
12178
  method: "GET",