@modular-circuit/utils 0.0.38 → 0.0.40

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.
@@ -1 +1 @@
1
- export const KICAD_SHC_FILE_EXT = ".kicad_sch";
1
+ export var KICAD_SHC_FILE_EXT = ".kicad_sch";
@@ -1,18 +1,78 @@
1
+ var __values = (this && this.__values) || function(o) {
2
+ var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
3
+ if (m) return m.call(o);
4
+ if (o && typeof o.length === "number") return {
5
+ next: function () {
6
+ if (o && i >= o.length) o = void 0;
7
+ return { value: o && o[i++], done: !o };
8
+ }
9
+ };
10
+ throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
11
+ };
12
+ var __read = (this && this.__read) || function (o, n) {
13
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
14
+ if (!m) return o;
15
+ var i = m.call(o), r, ar = [], e;
16
+ try {
17
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
18
+ }
19
+ catch (error) { e = { error: error }; }
20
+ finally {
21
+ try {
22
+ if (r && !r.done && (m = i["return"])) m.call(i);
23
+ }
24
+ finally { if (e) throw e.error; }
25
+ }
26
+ return ar;
27
+ };
1
28
  import { dfs } from './graph';
2
29
  export function test_connected_components(G, visitors) {
3
- const ccs = [];
4
- const visited = new Set();
5
- for (const [k] of Object.entries(G)) {
6
- if (!visited.has(k)) {
7
- for (const v of visitors)
8
- if (v.start_visit_component)
9
- v.start_visit_component();
10
- const cc = dfs(G, k, visited, visitors);
11
- ccs.push(cc);
12
- for (const v of visitors)
13
- if (v.end_visit_component)
14
- v.end_visit_component(cc);
30
+ var e_1, _a, e_2, _b, e_3, _c;
31
+ var ccs = [];
32
+ var visited = new Set();
33
+ try {
34
+ for (var _d = __values(Object.entries(G)), _e = _d.next(); !_e.done; _e = _d.next()) {
35
+ var _f = __read(_e.value, 1), k = _f[0];
36
+ if (!visited.has(k)) {
37
+ try {
38
+ for (var visitors_1 = (e_2 = void 0, __values(visitors)), visitors_1_1 = visitors_1.next(); !visitors_1_1.done; visitors_1_1 = visitors_1.next()) {
39
+ var v = visitors_1_1.value;
40
+ if (v.start_visit_component)
41
+ v.start_visit_component();
42
+ }
43
+ }
44
+ catch (e_2_1) { e_2 = { error: e_2_1 }; }
45
+ finally {
46
+ try {
47
+ if (visitors_1_1 && !visitors_1_1.done && (_b = visitors_1.return)) _b.call(visitors_1);
48
+ }
49
+ finally { if (e_2) throw e_2.error; }
50
+ }
51
+ var cc = dfs(G, k, visited, visitors);
52
+ ccs.push(cc);
53
+ try {
54
+ for (var visitors_2 = (e_3 = void 0, __values(visitors)), visitors_2_1 = visitors_2.next(); !visitors_2_1.done; visitors_2_1 = visitors_2.next()) {
55
+ var v = visitors_2_1.value;
56
+ if (v.end_visit_component)
57
+ v.end_visit_component(cc);
58
+ }
59
+ }
60
+ catch (e_3_1) { e_3 = { error: e_3_1 }; }
61
+ finally {
62
+ try {
63
+ if (visitors_2_1 && !visitors_2_1.done && (_c = visitors_2.return)) _c.call(visitors_2);
64
+ }
65
+ finally { if (e_3) throw e_3.error; }
66
+ }
67
+ }
68
+ }
69
+ }
70
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
71
+ finally {
72
+ try {
73
+ if (_e && !_e.done && (_a = _d.return)) _a.call(_d);
15
74
  }
75
+ finally { if (e_1) throw e_1.error; }
16
76
  }
17
77
  return ccs;
18
78
  }
@@ -1,28 +1,77 @@
1
+ var __assign = (this && this.__assign) || function () {
2
+ __assign = Object.assign || function(t) {
3
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
4
+ s = arguments[i];
5
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
6
+ t[p] = s[p];
7
+ }
8
+ return t;
9
+ };
10
+ return __assign.apply(this, arguments);
11
+ };
12
+ var __values = (this && this.__values) || function(o) {
13
+ var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
14
+ if (m) return m.call(o);
15
+ if (o && typeof o.length === "number") return {
16
+ next: function () {
17
+ if (o && i >= o.length) o = void 0;
18
+ return { value: o && o[i++], done: !o };
19
+ }
20
+ };
21
+ throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
22
+ };
23
+ var __read = (this && this.__read) || function (o, n) {
24
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
25
+ if (!m) return o;
26
+ var i = m.call(o), r, ar = [], e;
27
+ try {
28
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
29
+ }
30
+ catch (error) { e = { error: error }; }
31
+ finally {
32
+ try {
33
+ if (r && !r.done && (m = i["return"])) m.call(i);
34
+ }
35
+ finally { if (e) throw e.error; }
36
+ }
37
+ return ar;
38
+ };
1
39
  import { LABEL_ASSOCIATED, LabelShapes } from '@modular-circuit/electronics-model';
2
40
  export function get_port_labels(port, circuit) {
3
- let labels = {};
4
- for (const [k, v] of Object.entries(port)) {
5
- if (k === LABEL_ASSOCIATED && typeof v === 'string') {
6
- if (circuit.eda_port_annotations[v]) {
7
- if ('shape' in circuit.eda_port_annotations[v] && circuit.eda_port_annotations[v].shape !== null) {
8
- labels[v] = circuit.eda_port_annotations[v].shape;
9
- }
10
- else if ('lib_id' in circuit.eda_port_annotations[v] && circuit.eda_port_annotations[v].lib_id !== null) {
11
- labels[v] = LabelShapes.Input;
41
+ var e_1, _a;
42
+ var labels = {};
43
+ try {
44
+ for (var _b = __values(Object.entries(port)), _c = _b.next(); !_c.done; _c = _b.next()) {
45
+ var _d = __read(_c.value, 2), k = _d[0], v = _d[1];
46
+ if (k === LABEL_ASSOCIATED && typeof v === 'string') {
47
+ if (circuit.eda_port_annotations[v]) {
48
+ if ('shape' in circuit.eda_port_annotations[v] && circuit.eda_port_annotations[v].shape !== null) {
49
+ labels[v] = circuit.eda_port_annotations[v].shape;
50
+ }
51
+ else if ('lib_id' in circuit.eda_port_annotations[v] && circuit.eda_port_annotations[v].lib_id !== null) {
52
+ labels[v] = LabelShapes.Input;
53
+ }
54
+ else {
55
+ throw new Error("Invalid port annotation for port ".concat(v, ": ").concat(circuit.eda_port_annotations[v]));
56
+ }
12
57
  }
13
58
  else {
14
- throw new Error(`Invalid port annotation for port ${v}: ${circuit.eda_port_annotations[v]}`);
59
+ // TODO : handel GND and VCC
60
+ // NOTE: Currently only GND and VCC will come here
61
+ labels[v] = LabelShapes.Output;
15
62
  }
16
63
  }
17
- else {
18
- // TODO : handel GND and VCC
19
- // NOTE: Currently only GND and VCC will come here
20
- labels[v] = LabelShapes.Output;
64
+ else if (typeof v === 'object' && !Array.isArray(v) && v !== null) {
65
+ labels = __assign(__assign({}, labels), get_port_labels(v, circuit));
21
66
  }
22
67
  }
23
- else if (typeof v === 'object' && !Array.isArray(v) && v !== null) {
24
- labels = { ...labels, ...get_port_labels(v, circuit) };
68
+ }
69
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
70
+ finally {
71
+ try {
72
+ if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
25
73
  }
74
+ finally { if (e_1) throw e_1.error; }
26
75
  }
27
76
  return labels;
28
77
  }
@@ -1,23 +1,91 @@
1
- export function dfs(G, start, visited = new Set(), visitors) {
1
+ var __values = (this && this.__values) || function(o) {
2
+ var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
3
+ if (m) return m.call(o);
4
+ if (o && typeof o.length === "number") return {
5
+ next: function () {
6
+ if (o && i >= o.length) o = void 0;
7
+ return { value: o && o[i++], done: !o };
8
+ }
9
+ };
10
+ throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
11
+ };
12
+ var __read = (this && this.__read) || function (o, n) {
13
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
14
+ if (!m) return o;
15
+ var i = m.call(o), r, ar = [], e;
16
+ try {
17
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
18
+ }
19
+ catch (error) { e = { error: error }; }
20
+ finally {
21
+ try {
22
+ if (r && !r.done && (m = i["return"])) m.call(i);
23
+ }
24
+ finally { if (e) throw e.error; }
25
+ }
26
+ return ar;
27
+ };
28
+ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
29
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
30
+ if (ar || !(i in from)) {
31
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
32
+ ar[i] = from[i];
33
+ }
34
+ }
35
+ return to.concat(ar || Array.prototype.slice.call(from));
36
+ };
37
+ export function dfs(G, start, visited, visitors) {
38
+ var e_1, _a, e_2, _b, e_3, _c;
39
+ if (visited === void 0) { visited = new Set(); }
2
40
  visited.add(start);
3
- const result = [start];
4
- for (const neighbor of G[start]) {
5
- if (!visited.has(neighbor)) {
6
- if (visitors) {
7
- for (const visitor of visitors) {
8
- if (visitor.visit_edge) {
9
- visitor.visit_edge(start, neighbor);
41
+ var result = [start];
42
+ try {
43
+ for (var _d = __values(G[start]), _e = _d.next(); !_e.done; _e = _d.next()) {
44
+ var neighbor = _e.value;
45
+ if (!visited.has(neighbor)) {
46
+ if (visitors) {
47
+ try {
48
+ for (var visitors_1 = (e_2 = void 0, __values(visitors)), visitors_1_1 = visitors_1.next(); !visitors_1_1.done; visitors_1_1 = visitors_1.next()) {
49
+ var visitor = visitors_1_1.value;
50
+ if (visitor.visit_edge) {
51
+ visitor.visit_edge(start, neighbor);
52
+ }
53
+ }
54
+ }
55
+ catch (e_2_1) { e_2 = { error: e_2_1 }; }
56
+ finally {
57
+ try {
58
+ if (visitors_1_1 && !visitors_1_1.done && (_b = visitors_1.return)) _b.call(visitors_1);
59
+ }
60
+ finally { if (e_2) throw e_2.error; }
10
61
  }
11
62
  }
63
+ result.push.apply(result, __spreadArray([], __read(dfs(G, neighbor, visited, visitors)), false));
12
64
  }
13
- result.push(...dfs(G, neighbor, visited, visitors));
14
65
  }
15
66
  }
67
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
68
+ finally {
69
+ try {
70
+ if (_e && !_e.done && (_a = _d.return)) _a.call(_d);
71
+ }
72
+ finally { if (e_1) throw e_1.error; }
73
+ }
16
74
  if (visitors) {
17
- for (const visitor of visitors) {
18
- if (visitor.visit_vertex) {
19
- visitor.visit_vertex(start);
75
+ try {
76
+ for (var visitors_2 = __values(visitors), visitors_2_1 = visitors_2.next(); !visitors_2_1.done; visitors_2_1 = visitors_2.next()) {
77
+ var visitor = visitors_2_1.value;
78
+ if (visitor.visit_vertex) {
79
+ visitor.visit_vertex(start);
80
+ }
81
+ }
82
+ }
83
+ catch (e_3_1) { e_3 = { error: e_3_1 }; }
84
+ finally {
85
+ try {
86
+ if (visitors_2_1 && !visitors_2_1.done && (_c = visitors_2.return)) _c.call(visitors_2);
20
87
  }
88
+ finally { if (e_3) throw e_3.error; }
21
89
  }
22
90
  }
23
91
  return result;
@@ -1,4 +1,4 @@
1
1
  import { LabelShapes } from '@modular-circuit/electronics-model';
2
2
  export function gen_passive_label(text) {
3
- return { text, shape: LabelShapes.Passive };
3
+ return { text: text, shape: LabelShapes.Passive };
4
4
  }
@@ -1,14 +1,30 @@
1
+ var __read = (this && this.__read) || function (o, n) {
2
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
3
+ if (!m) return o;
4
+ var i = m.call(o), r, ar = [], e;
5
+ try {
6
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
7
+ }
8
+ catch (error) { e = { error: error }; }
9
+ finally {
10
+ try {
11
+ if (r && !r.done && (m = i["return"])) m.call(i);
12
+ }
13
+ finally { if (e) throw e.error; }
14
+ }
15
+ return ar;
16
+ };
1
17
  export function parse_module_name(dep) {
2
- let [author, name] = dep.split('/');
18
+ var _a = __read(dep.split('/'), 2), author = _a[0], name = _a[1];
3
19
  author = author.substring(1);
4
20
  return {
5
- author,
6
- name,
21
+ author: author,
22
+ name: name,
7
23
  };
8
24
  }
9
25
  export function fmt_module_name(idx) {
10
- return `@${idx.author}/${idx.name}`;
26
+ return "@".concat(idx.author, "/").concat(idx.name);
11
27
  }
12
28
  export function stringify_dependency(idx) {
13
- return `${fmt_module_name(idx)}@${idx.version}`;
29
+ return "".concat(fmt_module_name(idx), "@").concat(idx.version);
14
30
  }
@@ -1,25 +1,58 @@
1
+ var __values = (this && this.__values) || function(o) {
2
+ var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
3
+ if (m) return m.call(o);
4
+ if (o && typeof o.length === "number") return {
5
+ next: function () {
6
+ if (o && i >= o.length) o = void 0;
7
+ return { value: o && o[i++], done: !o };
8
+ }
9
+ };
10
+ throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
11
+ };
1
12
  import { merge_port_label_shapes } from '@modular-circuit/electronics-model';
2
13
  import { get_port_labels } from './get_port_labels';
3
14
  import { gen_uuid } from './utility';
4
15
  export function get_circuit_ports(module) {
5
- const port_map = {};
6
- let index = 0;
7
- for (const port of module.ports) {
8
- port_map[index++] = port;
16
+ var e_1, _a;
17
+ var port_map = {};
18
+ var index = 0;
19
+ try {
20
+ for (var _b = __values(module.ports), _c = _b.next(); !_c.done; _c = _b.next()) {
21
+ var port = _c.value;
22
+ port_map[index++] = port;
23
+ }
24
+ }
25
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
26
+ finally {
27
+ try {
28
+ if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
29
+ }
30
+ finally { if (e_1) throw e_1.error; }
9
31
  }
10
32
  return port_map;
11
33
  }
12
34
  export function place_module(module) {
13
- const ports = [];
14
- let index = 0;
15
- for (const it of module.ports) {
16
- ports.push({
17
- index: index++,
18
- uuid: gen_uuid(),
19
- name: it.name,
20
- shape: merge_port_label_shapes(get_port_labels(it, module)),
21
- type: it.type,
22
- });
35
+ var e_2, _a;
36
+ var ports = [];
37
+ var index = 0;
38
+ try {
39
+ for (var _b = __values(module.ports), _c = _b.next(); !_c.done; _c = _b.next()) {
40
+ var it_1 = _c.value;
41
+ ports.push({
42
+ index: index++,
43
+ uuid: gen_uuid(),
44
+ name: it_1.name,
45
+ shape: merge_port_label_shapes(get_port_labels(it_1, module)),
46
+ type: it_1.type,
47
+ });
48
+ }
49
+ }
50
+ catch (e_2_1) { e_2 = { error: e_2_1 }; }
51
+ finally {
52
+ try {
53
+ if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
54
+ }
55
+ finally { if (e_2) throw e_2.error; }
23
56
  }
24
57
  return {
25
58
  uuid: gen_uuid(),
@@ -27,6 +60,6 @@ export function place_module(module) {
27
60
  author: module.author,
28
61
  name: module.name,
29
62
  },
30
- ports,
63
+ ports: ports,
31
64
  };
32
65
  }
@@ -1,10 +1,10 @@
1
1
  import _ from 'lodash';
2
2
  import { v4 as uuidv4 } from 'uuid';
3
- export const gen_uuid = () => uuidv4();
3
+ export var gen_uuid = function () { return uuidv4(); };
4
4
  export function deep_copy(obj) {
5
5
  return _.cloneDeep(obj);
6
6
  }
7
7
  export function replaceAll(str, search, replacement) {
8
- const regex = new RegExp(search, 'g');
8
+ var regex = new RegExp(search, 'g');
9
9
  return str.replace(regex, replacement);
10
10
  }
@@ -1,44 +1,117 @@
1
- import JSZip from 'jszip';
2
- export async function unzipFile(file) {
3
- const zip = new JSZip();
4
- try {
5
- // Load the zip file from the Blob
6
- const content = await zip.loadAsync(file);
7
- // Prepare an object to store the extracted file content
8
- const files = {};
9
- // Iterate through each file in the zip archive
10
- for (const fileName in content.files) {
11
- if (fileName in content.files) {
12
- const fileData = content.files[fileName];
13
- // Extract the file content as text (you can modify this to other formats like Blob or Uint8Array as needed)
14
- const fileText = await fileData.async('text');
15
- // Store the extracted content in the files object
16
- files[fileName] = fileText;
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ var __generator = (this && this.__generator) || function (thisArg, body) {
11
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
12
+ return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
13
+ function verb(n) { return function (v) { return step([n, v]); }; }
14
+ function step(op) {
15
+ if (f) throw new TypeError("Generator is already executing.");
16
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
17
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
18
+ if (y = 0, t) op = [op[0] & 2, t.value];
19
+ switch (op[0]) {
20
+ case 0: case 1: t = op; break;
21
+ case 4: _.label++; return { value: op[1], done: false };
22
+ case 5: _.label++; y = op[1]; op = [0]; continue;
23
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
24
+ default:
25
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
26
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
27
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
28
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
29
+ if (t[2]) _.ops.pop();
30
+ _.trys.pop(); continue;
17
31
  }
18
- }
19
- return files;
20
- }
21
- catch (error) {
22
- console.error('Error unzipping file:', error);
23
- throw new Error('Failed to unzip file');
32
+ op = body.call(thisArg, _);
33
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
34
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
24
35
  }
36
+ };
37
+ import JSZip from 'jszip';
38
+ export function unzipFile(file) {
39
+ return __awaiter(this, void 0, void 0, function () {
40
+ var zip, content, files, _a, _b, _c, _i, fileName, fileData, fileText, error_1;
41
+ return __generator(this, function (_d) {
42
+ switch (_d.label) {
43
+ case 0:
44
+ zip = new JSZip();
45
+ _d.label = 1;
46
+ case 1:
47
+ _d.trys.push([1, 7, , 8]);
48
+ return [4 /*yield*/, zip.loadAsync(file)
49
+ // Prepare an object to store the extracted file content
50
+ ];
51
+ case 2:
52
+ content = _d.sent();
53
+ files = {};
54
+ _a = content.files;
55
+ _b = [];
56
+ for (_c in _a)
57
+ _b.push(_c);
58
+ _i = 0;
59
+ _d.label = 3;
60
+ case 3:
61
+ if (!(_i < _b.length)) return [3 /*break*/, 6];
62
+ _c = _b[_i];
63
+ if (!(_c in _a)) return [3 /*break*/, 5];
64
+ fileName = _c;
65
+ if (!(fileName in content.files)) return [3 /*break*/, 5];
66
+ fileData = content.files[fileName];
67
+ return [4 /*yield*/, fileData.async('text')
68
+ // Store the extracted content in the files object
69
+ ];
70
+ case 4:
71
+ fileText = _d.sent();
72
+ // Store the extracted content in the files object
73
+ files[fileName] = fileText;
74
+ _d.label = 5;
75
+ case 5:
76
+ _i++;
77
+ return [3 /*break*/, 3];
78
+ case 6: return [2 /*return*/, files];
79
+ case 7:
80
+ error_1 = _d.sent();
81
+ console.error('Error unzipping file:', error_1);
82
+ throw new Error('Failed to unzip file');
83
+ case 8: return [2 /*return*/];
84
+ }
85
+ });
86
+ });
25
87
  }
26
- export async function zipFiles(files) {
27
- const zip = new JSZip();
28
- // Add files to the zip archive
29
- for (const filePath in files)
30
- zip.file(filePath, files[filePath]); // Add file content to the zip
31
- // Generate the zip file as a Blob
32
- try {
33
- const blob = await zip.generateAsync({ type: 'blob' });
34
- return blob;
35
- }
36
- catch (error) {
37
- console.error('Error creating zip:', error);
38
- throw new Error('Failed to create zip file');
39
- }
88
+ export function zipFiles(files) {
89
+ return __awaiter(this, void 0, void 0, function () {
90
+ var zip, filePath, blob, error_2;
91
+ return __generator(this, function (_a) {
92
+ switch (_a.label) {
93
+ case 0:
94
+ zip = new JSZip();
95
+ // Add files to the zip archive
96
+ for (filePath in files)
97
+ zip.file(filePath, files[filePath]); // Add file content to the zip
98
+ _a.label = 1;
99
+ case 1:
100
+ _a.trys.push([1, 3, , 4]);
101
+ return [4 /*yield*/, zip.generateAsync({ type: 'blob' })];
102
+ case 2:
103
+ blob = _a.sent();
104
+ return [2 /*return*/, blob];
105
+ case 3:
106
+ error_2 = _a.sent();
107
+ console.error('Error creating zip:', error_2);
108
+ throw new Error('Failed to create zip file');
109
+ case 4: return [2 /*return*/];
110
+ }
111
+ });
112
+ });
40
113
  }
41
114
  export function remove_filename_path_prefix(name) {
42
- const names = name.split('/');
115
+ var names = name.split('/');
43
116
  return names[names.length - 1];
44
117
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@modular-circuit/utils",
3
- "version": "0.0.38",
3
+ "version": "0.0.40",
4
4
  "description": "Intermediate representation of the modular circuit",
5
5
  "main": "./build/index.js",
6
6
  "exports": {
@@ -28,8 +28,8 @@
28
28
  "jszip": "^3.10.1",
29
29
  "lodash": "^4.17.21",
30
30
  "uuid": "^10.0.0",
31
- "@modular-circuit/electronics-model": "0.0.52",
32
- "@modular-circuit/ir": "0.0.59"
31
+ "@modular-circuit/electronics-model": "0.0.54",
32
+ "@modular-circuit/ir": "0.0.61"
33
33
  },
34
34
  "scripts": {
35
35
  "clean": "rimraf build",