easyeda 0.0.350 → 0.0.352
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 +67 -16
- package/dist/browser/index.js.map +1 -1
- package/dist/index.js +339 -287
- package/dist/index.js.map +1 -1
- package/dist/main.cjs +2104 -2052
- package/dist/main.cjs.map +1 -1
- package/package.json +1 -1
package/dist/browser/index.js
CHANGED
|
@@ -13428,6 +13428,59 @@ var checkModelObjUrlValidity = async (url) => {
|
|
|
13428
13428
|
}
|
|
13429
13429
|
};
|
|
13430
13430
|
|
|
13431
|
+
// lib/websafe/parse-easyeda-search-response.ts
|
|
13432
|
+
var searchEnvelopeSchema = external_exports.object({
|
|
13433
|
+
success: external_exports.boolean(),
|
|
13434
|
+
code: external_exports.number().optional(),
|
|
13435
|
+
message: external_exports.string().optional()
|
|
13436
|
+
});
|
|
13437
|
+
var supplierNumberSchema = external_exports.object({ number: external_exports.string().nullish() }).nullish();
|
|
13438
|
+
var searchResultsSchema = external_exports.object({
|
|
13439
|
+
result: external_exports.object({
|
|
13440
|
+
lists: external_exports.object({
|
|
13441
|
+
lcsc: external_exports.array(
|
|
13442
|
+
external_exports.object({
|
|
13443
|
+
uuid: external_exports.string().min(1),
|
|
13444
|
+
lcsc: supplierNumberSchema,
|
|
13445
|
+
szlcsc: supplierNumberSchema,
|
|
13446
|
+
dataStr: external_exports.object({
|
|
13447
|
+
head: external_exports.object({
|
|
13448
|
+
c_para: external_exports.object({ "Supplier Part": external_exports.string().nullish() }).nullish()
|
|
13449
|
+
}).nullish()
|
|
13450
|
+
}).nullish()
|
|
13451
|
+
})
|
|
13452
|
+
)
|
|
13453
|
+
})
|
|
13454
|
+
})
|
|
13455
|
+
});
|
|
13456
|
+
var parseEasyEdaSearchResponse = (searchResponse, jlcpcbPartNumber) => {
|
|
13457
|
+
const envelope = searchEnvelopeSchema.safeParse(searchResponse);
|
|
13458
|
+
if (!envelope.success) {
|
|
13459
|
+
throw new Error(
|
|
13460
|
+
`Invalid EasyEDA search response for "${jlcpcbPartNumber}": expected a boolean success field`
|
|
13461
|
+
);
|
|
13462
|
+
}
|
|
13463
|
+
if (!envelope.data.success) {
|
|
13464
|
+
const { code, message } = envelope.data;
|
|
13465
|
+
throw new Error(
|
|
13466
|
+
`EasyEDA API rejected the component search for "${jlcpcbPartNumber}"${code === void 0 ? "" : ` (code ${code})`}${message ? `: ${message}` : ""}`
|
|
13467
|
+
);
|
|
13468
|
+
}
|
|
13469
|
+
const searchResults = searchResultsSchema.safeParse(searchResponse);
|
|
13470
|
+
if (!searchResults.success) {
|
|
13471
|
+
throw new Error(
|
|
13472
|
+
`Invalid EasyEDA search response for "${jlcpcbPartNumber}": expected result.lists.lcsc containing component UUIDs and supplier metadata`
|
|
13473
|
+
);
|
|
13474
|
+
}
|
|
13475
|
+
const components = searchResults.data.result.lists.lcsc;
|
|
13476
|
+
if (components.length === 0) {
|
|
13477
|
+
throw new Error(
|
|
13478
|
+
`Component not found in EasyEDA library search for "${jlcpcbPartNumber}". A supplier catalog listing does not guarantee importable symbol/footprint data.`
|
|
13479
|
+
);
|
|
13480
|
+
}
|
|
13481
|
+
return components;
|
|
13482
|
+
};
|
|
13483
|
+
|
|
13431
13484
|
// lib/websafe/fetch-easyeda-json.ts
|
|
13432
13485
|
var getModelUuidFromRawPackageDetail = (result) => {
|
|
13433
13486
|
const shapes = result.packageDetail?.dataStr?.shape;
|
|
@@ -13516,23 +13569,21 @@ async function fetchEasyEDAComponent(jlcpcbPartNumber, {
|
|
|
13516
13569
|
`Failed to search for the component (HTTP ${searchResponse.status})`
|
|
13517
13570
|
);
|
|
13518
13571
|
}
|
|
13519
|
-
const
|
|
13520
|
-
|
|
13521
|
-
|
|
13522
|
-
}
|
|
13523
|
-
const requestedPartNumber = jlcpcbPartNumber.trim().toUpperCase();
|
|
13524
|
-
const bestMatchComponent = searchResult.result.lists.lcsc.find(
|
|
13525
|
-
(component) => {
|
|
13526
|
-
const candidatePartNumbers = [
|
|
13527
|
-
component.dataStr?.head?.c_para?.["Supplier Part"],
|
|
13528
|
-
component.lcsc?.number,
|
|
13529
|
-
component.szlcsc?.number
|
|
13530
|
-
];
|
|
13531
|
-
return candidatePartNumbers.some(
|
|
13532
|
-
(partNumber) => typeof partNumber === "string" && partNumber.trim().toUpperCase() === requestedPartNumber
|
|
13533
|
-
);
|
|
13534
|
-
}
|
|
13572
|
+
const searchComponents = parseEasyEdaSearchResponse(
|
|
13573
|
+
await searchResponse.json(),
|
|
13574
|
+
jlcpcbPartNumber
|
|
13535
13575
|
);
|
|
13576
|
+
const requestedPartNumber = jlcpcbPartNumber.trim().toUpperCase();
|
|
13577
|
+
const bestMatchComponent = searchComponents.find((component) => {
|
|
13578
|
+
const candidatePartNumbers = [
|
|
13579
|
+
component.dataStr?.head?.c_para?.["Supplier Part"],
|
|
13580
|
+
component.lcsc?.number,
|
|
13581
|
+
component.szlcsc?.number
|
|
13582
|
+
];
|
|
13583
|
+
return candidatePartNumbers.some(
|
|
13584
|
+
(partNumber) => typeof partNumber === "string" && partNumber.trim().toUpperCase() === requestedPartNumber
|
|
13585
|
+
);
|
|
13586
|
+
});
|
|
13536
13587
|
if (!bestMatchComponent) {
|
|
13537
13588
|
throw new Error(
|
|
13538
13589
|
`No exact EasyEDA component match for "${jlcpcbPartNumber}"`
|