@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 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
- const zip_archive_url = await module_resolver.get_module_archive({
194
- ...(0, import_utils.parse_module_name)(k),
195
- version: v
196
- });
197
- const module2 = await module_resolver.get_module_circuit({
198
- ...(0, import_utils.parse_module_name)(k),
199
- version: v
200
- });
201
- if (!zip_archive_url || !module2) {
202
- console.error(`Module ${k}/${v} not found`);
203
- continue;
204
- }
205
- if (!module2.main) {
206
- console.error(`Missing main entry in module ${k}/${v}`);
207
- continue;
208
- }
209
- module_main_sheet[k] = module2.main;
210
- modules[k] = module2;
211
- const zip_archive = await fetch(zip_archive_url).then((res) => res.arrayBuffer());
212
- const files = await (0, import_utils.unzipFile)(zip_archive);
213
- for (const [name, content] of Object.entries(files)) {
214
- if (name.endsWith(import_utils.KICAD_SHC_FILE_EXT)) {
215
- const fileName = (0, import_utils.remove_filename_path_prefix)(name);
216
- if (fileName in sheets) {
217
- console.error(`Duplicate sheet name: ${fileName}`);
218
- continue;
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
- const zip_archive_url = await module_resolver.get_module_archive_by_id(id);
294
- const module_circuit = await module_resolver.get_module_circuit_by_id(id);
295
- if (!module_circuit) {
296
- console.error(`Module ${id} not found`);
297
- continue;
298
- }
299
- if (!zip_archive_url || !module_circuit) {
300
- console.error(`Module ${module_circuit.author}/${module_circuit.name} not found`);
301
- continue;
302
- }
303
- if (!module_circuit.main) {
304
- console.error(`Missing main entry in module${module_circuit.author}/${module_circuit.name}`);
305
- continue;
306
- }
307
- const k = (0, import_utils2.fmt_module_name)(module_circuit);
308
- module_main_sheet[k] = module_circuit.main;
309
- modules[k] = module_circuit;
310
- const design_block = {
311
- main_sch: module_circuit.main,
312
- sheets: []
313
- };
314
- const zip_archive = await fetch(zip_archive_url).then((res) => res.arrayBuffer());
315
- const files = await (0, import_utils2.unzipFile)(zip_archive);
316
- for (const [name, content] of Object.entries(files)) {
317
- if (name.endsWith(import_utils2.KICAD_SHC_FILE_EXT)) {
318
- const filename = (0, import_utils2.remove_filename_path_prefix)(name);
319
- if (filename in sheets) {
320
- console.error(`Duplicate sheet name: ${filename}`);
321
- continue;
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
- const zip_archive_url = await module_resolver.get_module_archive({
75
- ...parse_module_name(k),
76
- version: v
77
- });
78
- const module = await module_resolver.get_module_circuit({
79
- ...parse_module_name(k),
80
- version: v
81
- });
82
- if (!zip_archive_url || !module) {
83
- console.error(`Module ${k}/${v} not found`);
84
- continue;
85
- }
86
- if (!module.main) {
87
- console.error(`Missing main entry in module ${k}/${v}`);
88
- continue;
89
- }
90
- module_main_sheet[k] = module.main;
91
- modules[k] = module;
92
- const zip_archive = await fetch(zip_archive_url).then((res) => res.arrayBuffer());
93
- const files = await unzipFile(zip_archive);
94
- for (const [name, content] of Object.entries(files)) {
95
- if (name.endsWith(KICAD_SHC_FILE_EXT)) {
96
- const fileName = remove_filename_path_prefix(name);
97
- if (fileName in sheets) {
98
- console.error(`Duplicate sheet name: ${fileName}`);
99
- continue;
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
- const zip_archive_url = await module_resolver.get_module_archive_by_id(id);
181
- const module_circuit = await module_resolver.get_module_circuit_by_id(id);
182
- if (!module_circuit) {
183
- console.error(`Module ${id} not found`);
184
- continue;
185
- }
186
- if (!zip_archive_url || !module_circuit) {
187
- console.error(`Module ${module_circuit.author}/${module_circuit.name} not found`);
188
- continue;
189
- }
190
- if (!module_circuit.main) {
191
- console.error(`Missing main entry in module${module_circuit.author}/${module_circuit.name}`);
192
- continue;
193
- }
194
- const k = fmt_module_name(module_circuit);
195
- module_main_sheet[k] = module_circuit.main;
196
- modules[k] = module_circuit;
197
- const design_block = {
198
- main_sch: module_circuit.main,
199
- sheets: []
200
- };
201
- const zip_archive = await fetch(zip_archive_url).then((res) => res.arrayBuffer());
202
- const files = await unzipFile2(zip_archive);
203
- for (const [name, content] of Object.entries(files)) {
204
- if (name.endsWith(KICAD_SHC_FILE_EXT2)) {
205
- const filename = remove_filename_path_prefix2(name);
206
- if (filename in sheets) {
207
- console.error(`Duplicate sheet name: ${filename}`);
208
- continue;
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.5",
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/utils": "0.1.2",
35
- "@modular-circuit/perc": "0.1.2"
34
+ "@modular-circuit/perc": "0.1.4",
35
+ "@modular-circuit/utils": "0.1.2"
36
36
  },
37
37
  "scripts": {
38
38
  "clean": "rimraf dist",