circuit-json-to-kicad 0.0.33 → 0.0.34
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 +29 -2
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -3176,8 +3176,10 @@ var KicadLibraryConverter = class {
|
|
|
3176
3176
|
const builtTscircuitComponents = [];
|
|
3177
3177
|
const { entrypoint } = this.options;
|
|
3178
3178
|
const exports = await this.options.getExportsFromTsxFile(entrypoint);
|
|
3179
|
-
const
|
|
3180
|
-
|
|
3179
|
+
const namedExports = exports.filter(
|
|
3180
|
+
(name) => name !== "default" && /^[A-Z]/.test(name)
|
|
3181
|
+
);
|
|
3182
|
+
for (const exportName of namedExports) {
|
|
3181
3183
|
let componentPath = entrypoint;
|
|
3182
3184
|
if (this.options.resolveExportPath) {
|
|
3183
3185
|
const resolved = await this.options.resolveExportPath(
|
|
@@ -3197,6 +3199,27 @@ var KicadLibraryConverter = class {
|
|
|
3197
3199
|
});
|
|
3198
3200
|
}
|
|
3199
3201
|
}
|
|
3202
|
+
if (exports.includes("default")) {
|
|
3203
|
+
let componentPath = entrypoint;
|
|
3204
|
+
if (this.options.resolveExportPath) {
|
|
3205
|
+
const resolved = await this.options.resolveExportPath(
|
|
3206
|
+
entrypoint,
|
|
3207
|
+
"default"
|
|
3208
|
+
);
|
|
3209
|
+
if (resolved) componentPath = resolved;
|
|
3210
|
+
}
|
|
3211
|
+
const componentName = deriveComponentNameFromPath(componentPath);
|
|
3212
|
+
const circuitJson = await this.options.buildFileToCircuitJson(
|
|
3213
|
+
componentPath,
|
|
3214
|
+
"default"
|
|
3215
|
+
);
|
|
3216
|
+
if (circuitJson && (!Array.isArray(circuitJson) || circuitJson.length > 0)) {
|
|
3217
|
+
builtTscircuitComponents.push({
|
|
3218
|
+
tscircuitComponentName: componentName,
|
|
3219
|
+
circuitJson
|
|
3220
|
+
});
|
|
3221
|
+
}
|
|
3222
|
+
}
|
|
3200
3223
|
return builtTscircuitComponents;
|
|
3201
3224
|
}
|
|
3202
3225
|
/**
|
|
@@ -3249,6 +3272,10 @@ function createKicadLibraryConverterContext(params) {
|
|
|
3249
3272
|
kicadProjectFsMap: {}
|
|
3250
3273
|
};
|
|
3251
3274
|
}
|
|
3275
|
+
function deriveComponentNameFromPath(filePath) {
|
|
3276
|
+
const filename = filePath.split(/[/\\]/).pop() || filePath;
|
|
3277
|
+
return filename.replace(/\.(tsx?|jsx?)$/, "");
|
|
3278
|
+
}
|
|
3252
3279
|
export {
|
|
3253
3280
|
CircuitJsonToKicadLibraryConverter,
|
|
3254
3281
|
CircuitJsonToKicadPcbConverter,
|