easyeda 0.0.23 → 0.0.24
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/cli/main.cjs +26 -8
- package/dist/cli/main.cjs.map +1 -1
- package/dist/lib/index.cjs +24 -6
- package/dist/lib/index.cjs.map +1 -1
- package/dist/lib/index.d.cts +1 -1
- package/package.json +1 -1
package/dist/cli/main.cjs
CHANGED
|
@@ -29176,7 +29176,7 @@ var import_promises = __toESM(require("fs/promises"), 1);
|
|
|
29176
29176
|
var package_default = {
|
|
29177
29177
|
name: "easyeda",
|
|
29178
29178
|
type: "module",
|
|
29179
|
-
version: "0.0.
|
|
29179
|
+
version: "0.0.23",
|
|
29180
29180
|
files: ["dist"],
|
|
29181
29181
|
repository: {
|
|
29182
29182
|
type: "git",
|
|
@@ -29580,9 +29580,9 @@ export const ${componentName} = (props: Props) => {
|
|
|
29580
29580
|
<bug
|
|
29581
29581
|
{...props}
|
|
29582
29582
|
footprint={${footprintTsx}}
|
|
29583
|
-
cadModel={{
|
|
29583
|
+
${objUrl ? `cadModel={{
|
|
29584
29584
|
objUrl: "${objUrl}"
|
|
29585
|
-
}}
|
|
29585
|
+
}}` : ""}
|
|
29586
29586
|
pinLabels={pinLabels}
|
|
29587
29587
|
schPinSpacing={0.75}
|
|
29588
29588
|
schPortArrangement={${JSON.stringify(schPinArrangement, null, " ")}}
|
|
@@ -29606,18 +29606,18 @@ function normalizeManufacturerPartNumber(partNumber) {
|
|
|
29606
29606
|
}
|
|
29607
29607
|
|
|
29608
29608
|
// lib/convert-to-typescript-component/index.tsx
|
|
29609
|
-
var convertRawEasyEdaToTs = (rawEasy) => {
|
|
29609
|
+
var convertRawEasyEdaToTs = async (rawEasy) => {
|
|
29610
29610
|
const easyeda = EasyEdaJsonSchema.parse(rawEasy);
|
|
29611
29611
|
const soup = convertEasyEdaJsonToTscircuitSoupJson(easyeda, {
|
|
29612
29612
|
useModelCdn: true
|
|
29613
29613
|
});
|
|
29614
|
-
const result = convertToTypescriptComponent({
|
|
29614
|
+
const result = await convertToTypescriptComponent({
|
|
29615
29615
|
easyeda,
|
|
29616
29616
|
soup
|
|
29617
29617
|
});
|
|
29618
29618
|
return result;
|
|
29619
29619
|
};
|
|
29620
|
-
var convertToTypescriptComponent = ({
|
|
29620
|
+
var convertToTypescriptComponent = async ({
|
|
29621
29621
|
soup,
|
|
29622
29622
|
easyeda: easyEdaJson
|
|
29623
29623
|
}) => {
|
|
@@ -29646,14 +29646,32 @@ var convertToTypescriptComponent = ({
|
|
|
29646
29646
|
pins: rightPins.map((pin) => pin.pinNumber).reverse()
|
|
29647
29647
|
}
|
|
29648
29648
|
};
|
|
29649
|
+
let modelObjUrl;
|
|
29650
|
+
if (cad_component2.model_obj_url) {
|
|
29651
|
+
const isValidUrl = await checkModelObjUrlValidity(
|
|
29652
|
+
cad_component2.model_obj_url
|
|
29653
|
+
);
|
|
29654
|
+
if (isValidUrl) {
|
|
29655
|
+
modelObjUrl = cad_component2.model_obj_url;
|
|
29656
|
+
}
|
|
29657
|
+
}
|
|
29649
29658
|
return soupTypescriptComponentTemplate({
|
|
29650
29659
|
componentName: pn,
|
|
29651
29660
|
pinLabels,
|
|
29652
29661
|
schPinArrangement,
|
|
29653
|
-
objUrl:
|
|
29662
|
+
objUrl: modelObjUrl,
|
|
29654
29663
|
easyEdaJson
|
|
29655
29664
|
});
|
|
29656
29665
|
};
|
|
29666
|
+
var checkModelObjUrlValidity = async (url) => {
|
|
29667
|
+
try {
|
|
29668
|
+
const response = await fetch(url, { method: "HEAD" });
|
|
29669
|
+
return response.status === 200;
|
|
29670
|
+
} catch (error) {
|
|
29671
|
+
console.error(`Error checking model object URL ${url}:`, error);
|
|
29672
|
+
return false;
|
|
29673
|
+
}
|
|
29674
|
+
};
|
|
29657
29675
|
|
|
29658
29676
|
// cli/main.ts
|
|
29659
29677
|
var path = __toESM(require("path"), 1);
|
|
@@ -29712,7 +29730,7 @@ program.command("convert").description("Convert EasyEDA JSON to various formats"
|
|
|
29712
29730
|
await import_promises.default.writeFile(options.output, JSON.stringify(betterEasy, null, 2));
|
|
29713
29731
|
console.log(`Saved better EasyEDA JSON: ${options.output}`);
|
|
29714
29732
|
} else if (options.output.endsWith(".tsx") || options.output.endsWith(".ts")) {
|
|
29715
|
-
const tsComp = convertRawEasyEdaToTs(rawEasyEdaJson);
|
|
29733
|
+
const tsComp = await convertRawEasyEdaToTs(rawEasyEdaJson);
|
|
29716
29734
|
await import_promises.default.writeFile(options.output, tsComp);
|
|
29717
29735
|
console.log(`Saved TypeScript component: ${options.output}`);
|
|
29718
29736
|
} else {
|