@modular-circuit/transpiler 0.1.5 → 0.1.7
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 +70 -62
- package/dist/index.mjs +70 -62
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -190,35 +190,39 @@ async function collect_sub_sheets(dependencies, module_resolver) {
|
|
|
190
190
|
const module_main_sheet = {};
|
|
191
191
|
const modules = {};
|
|
192
192
|
for (const [k, v] of Object.entries(dependencies)) {
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
193
|
+
try {
|
|
194
|
+
const zip_archive_url = await module_resolver.get_module_archive({
|
|
195
|
+
...(0, import_utils.parse_module_name)(k),
|
|
196
|
+
version: v
|
|
197
|
+
});
|
|
198
|
+
const module2 = await module_resolver.get_module_circuit({
|
|
199
|
+
...(0, import_utils.parse_module_name)(k),
|
|
200
|
+
version: v
|
|
201
|
+
});
|
|
202
|
+
if (!zip_archive_url || !module2) {
|
|
203
|
+
console.error(`Module ${k}/${v} not found`);
|
|
204
|
+
continue;
|
|
205
|
+
}
|
|
206
|
+
if (!module2.main) {
|
|
207
|
+
console.error(`Missing main entry in module ${k}/${v}`);
|
|
208
|
+
continue;
|
|
209
|
+
}
|
|
210
|
+
module_main_sheet[k] = module2.main;
|
|
211
|
+
modules[k] = module2;
|
|
212
|
+
const zip_archive = await fetch(zip_archive_url).then((res) => res.arrayBuffer());
|
|
213
|
+
const files = await (0, import_utils.unzipFile)(zip_archive);
|
|
214
|
+
for (const [name, content] of Object.entries(files)) {
|
|
215
|
+
if (name.endsWith(import_utils.KICAD_SHC_FILE_EXT)) {
|
|
216
|
+
const fileName = (0, import_utils.remove_filename_path_prefix)(name);
|
|
217
|
+
if (fileName in sheets) {
|
|
218
|
+
console.error(`Duplicate sheet name: ${fileName}`);
|
|
219
|
+
continue;
|
|
220
|
+
}
|
|
221
|
+
sheets[fileName] = content;
|
|
219
222
|
}
|
|
220
|
-
sheets[fileName] = content;
|
|
221
223
|
}
|
|
224
|
+
} catch (e) {
|
|
225
|
+
console.error(`Failed to download zip for module : ${e}`);
|
|
222
226
|
}
|
|
223
227
|
}
|
|
224
228
|
return { sheets, module_main_sheet, modules };
|
|
@@ -290,44 +294,48 @@ async function collect_sub_sheets_by_id(module_ids, module_resolver) {
|
|
|
290
294
|
const modules = {};
|
|
291
295
|
const design_blocks = [];
|
|
292
296
|
for (const id of module_ids) {
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
297
|
+
try {
|
|
298
|
+
const zip_archive_url = await module_resolver.get_module_archive_by_id(id);
|
|
299
|
+
const module_circuit = await module_resolver.get_module_circuit_by_id(id);
|
|
300
|
+
if (!module_circuit) {
|
|
301
|
+
console.error(`Module ${id} not found`);
|
|
302
|
+
continue;
|
|
303
|
+
}
|
|
304
|
+
if (!zip_archive_url || !module_circuit) {
|
|
305
|
+
console.error(`Module ${module_circuit.author}/${module_circuit.name} not found`);
|
|
306
|
+
continue;
|
|
307
|
+
}
|
|
308
|
+
if (!module_circuit.main) {
|
|
309
|
+
console.error(`Missing main entry in module${module_circuit.author}/${module_circuit.name}`);
|
|
310
|
+
continue;
|
|
311
|
+
}
|
|
312
|
+
const k = (0, import_utils2.fmt_module_name)(module_circuit);
|
|
313
|
+
module_main_sheet[k] = module_circuit.main;
|
|
314
|
+
modules[k] = module_circuit;
|
|
315
|
+
const design_block = {
|
|
316
|
+
main_sch: module_circuit.main,
|
|
317
|
+
sheets: []
|
|
318
|
+
};
|
|
319
|
+
const zip_archive = await fetch(zip_archive_url).then((res) => res.arrayBuffer());
|
|
320
|
+
const files = await (0, import_utils2.unzipFile)(zip_archive);
|
|
321
|
+
for (const [name, content] of Object.entries(files)) {
|
|
322
|
+
if (name.endsWith(import_utils2.KICAD_SHC_FILE_EXT)) {
|
|
323
|
+
const filename = (0, import_utils2.remove_filename_path_prefix)(name);
|
|
324
|
+
if (filename in sheets) {
|
|
325
|
+
console.error(`Duplicate sheet name: ${filename}`);
|
|
326
|
+
continue;
|
|
327
|
+
}
|
|
328
|
+
sheets[filename] = content;
|
|
329
|
+
design_block.sheets.push({ filename, content });
|
|
330
|
+
} else if (name.endsWith(import_utils2.KICAD_PCB_FILE_EXT)) {
|
|
331
|
+
const filename = (0, import_utils2.remove_filename_path_prefix)(name);
|
|
332
|
+
design_block.pcb = { filename, content };
|
|
322
333
|
}
|
|
323
|
-
sheets[filename] = content;
|
|
324
|
-
design_block.sheets.push({ filename, content });
|
|
325
|
-
} else if (name.endsWith(import_utils2.KICAD_PCB_FILE_EXT)) {
|
|
326
|
-
const filename = (0, import_utils2.remove_filename_path_prefix)(name);
|
|
327
|
-
design_block.pcb = { filename, content };
|
|
328
334
|
}
|
|
335
|
+
design_blocks.push(design_block);
|
|
336
|
+
} catch (e) {
|
|
337
|
+
console.error(`Failed to download zip for module : ${e}`);
|
|
329
338
|
}
|
|
330
|
-
design_blocks.push(design_block);
|
|
331
339
|
}
|
|
332
340
|
return { sheets, module_main_sheet, modules, design_blocks };
|
|
333
341
|
}
|
package/dist/index.mjs
CHANGED
|
@@ -71,35 +71,39 @@ async function collect_sub_sheets(dependencies, module_resolver) {
|
|
|
71
71
|
const module_main_sheet = {};
|
|
72
72
|
const modules = {};
|
|
73
73
|
for (const [k, v] of Object.entries(dependencies)) {
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
74
|
+
try {
|
|
75
|
+
const zip_archive_url = await module_resolver.get_module_archive({
|
|
76
|
+
...parse_module_name(k),
|
|
77
|
+
version: v
|
|
78
|
+
});
|
|
79
|
+
const module = await module_resolver.get_module_circuit({
|
|
80
|
+
...parse_module_name(k),
|
|
81
|
+
version: v
|
|
82
|
+
});
|
|
83
|
+
if (!zip_archive_url || !module) {
|
|
84
|
+
console.error(`Module ${k}/${v} not found`);
|
|
85
|
+
continue;
|
|
86
|
+
}
|
|
87
|
+
if (!module.main) {
|
|
88
|
+
console.error(`Missing main entry in module ${k}/${v}`);
|
|
89
|
+
continue;
|
|
90
|
+
}
|
|
91
|
+
module_main_sheet[k] = module.main;
|
|
92
|
+
modules[k] = module;
|
|
93
|
+
const zip_archive = await fetch(zip_archive_url).then((res) => res.arrayBuffer());
|
|
94
|
+
const files = await unzipFile(zip_archive);
|
|
95
|
+
for (const [name, content] of Object.entries(files)) {
|
|
96
|
+
if (name.endsWith(KICAD_SHC_FILE_EXT)) {
|
|
97
|
+
const fileName = remove_filename_path_prefix(name);
|
|
98
|
+
if (fileName in sheets) {
|
|
99
|
+
console.error(`Duplicate sheet name: ${fileName}`);
|
|
100
|
+
continue;
|
|
101
|
+
}
|
|
102
|
+
sheets[fileName] = content;
|
|
100
103
|
}
|
|
101
|
-
sheets[fileName] = content;
|
|
102
104
|
}
|
|
105
|
+
} catch (e) {
|
|
106
|
+
console.error(`Failed to download zip for module : ${e}`);
|
|
103
107
|
}
|
|
104
108
|
}
|
|
105
109
|
return { sheets, module_main_sheet, modules };
|
|
@@ -177,44 +181,48 @@ async function collect_sub_sheets_by_id(module_ids, module_resolver) {
|
|
|
177
181
|
const modules = {};
|
|
178
182
|
const design_blocks = [];
|
|
179
183
|
for (const id of module_ids) {
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
184
|
+
try {
|
|
185
|
+
const zip_archive_url = await module_resolver.get_module_archive_by_id(id);
|
|
186
|
+
const module_circuit = await module_resolver.get_module_circuit_by_id(id);
|
|
187
|
+
if (!module_circuit) {
|
|
188
|
+
console.error(`Module ${id} not found`);
|
|
189
|
+
continue;
|
|
190
|
+
}
|
|
191
|
+
if (!zip_archive_url || !module_circuit) {
|
|
192
|
+
console.error(`Module ${module_circuit.author}/${module_circuit.name} not found`);
|
|
193
|
+
continue;
|
|
194
|
+
}
|
|
195
|
+
if (!module_circuit.main) {
|
|
196
|
+
console.error(`Missing main entry in module${module_circuit.author}/${module_circuit.name}`);
|
|
197
|
+
continue;
|
|
198
|
+
}
|
|
199
|
+
const k = fmt_module_name(module_circuit);
|
|
200
|
+
module_main_sheet[k] = module_circuit.main;
|
|
201
|
+
modules[k] = module_circuit;
|
|
202
|
+
const design_block = {
|
|
203
|
+
main_sch: module_circuit.main,
|
|
204
|
+
sheets: []
|
|
205
|
+
};
|
|
206
|
+
const zip_archive = await fetch(zip_archive_url).then((res) => res.arrayBuffer());
|
|
207
|
+
const files = await unzipFile2(zip_archive);
|
|
208
|
+
for (const [name, content] of Object.entries(files)) {
|
|
209
|
+
if (name.endsWith(KICAD_SHC_FILE_EXT2)) {
|
|
210
|
+
const filename = remove_filename_path_prefix2(name);
|
|
211
|
+
if (filename in sheets) {
|
|
212
|
+
console.error(`Duplicate sheet name: ${filename}`);
|
|
213
|
+
continue;
|
|
214
|
+
}
|
|
215
|
+
sheets[filename] = content;
|
|
216
|
+
design_block.sheets.push({ filename, content });
|
|
217
|
+
} else if (name.endsWith(KICAD_PCB_FILE_EXT)) {
|
|
218
|
+
const filename = remove_filename_path_prefix2(name);
|
|
219
|
+
design_block.pcb = { filename, content };
|
|
209
220
|
}
|
|
210
|
-
sheets[filename] = content;
|
|
211
|
-
design_block.sheets.push({ filename, content });
|
|
212
|
-
} else if (name.endsWith(KICAD_PCB_FILE_EXT)) {
|
|
213
|
-
const filename = remove_filename_path_prefix2(name);
|
|
214
|
-
design_block.pcb = { filename, content };
|
|
215
221
|
}
|
|
222
|
+
design_blocks.push(design_block);
|
|
223
|
+
} catch (e) {
|
|
224
|
+
console.error(`Failed to download zip for module : ${e}`);
|
|
216
225
|
}
|
|
217
|
-
design_blocks.push(design_block);
|
|
218
226
|
}
|
|
219
227
|
return { sheets, module_main_sheet, modules, design_blocks };
|
|
220
228
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@modular-circuit/transpiler",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.7",
|
|
4
4
|
"description": "Intermediate representation of the modular circuit",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.mjs",
|
|
@@ -31,8 +31,8 @@
|
|
|
31
31
|
"jszip": "^3.10.1",
|
|
32
32
|
"@modular-circuit/electronics-model": "0.1.1",
|
|
33
33
|
"@modular-circuit/ir": "0.1.2",
|
|
34
|
-
"@modular-circuit/
|
|
35
|
-
"@modular-circuit/
|
|
34
|
+
"@modular-circuit/perc": "0.1.4",
|
|
35
|
+
"@modular-circuit/utils": "0.1.2"
|
|
36
36
|
},
|
|
37
37
|
"scripts": {
|
|
38
38
|
"clean": "rimraf dist",
|