@modular-circuit/utils 0.0.30 → 0.0.32
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/build/constants/index.js +2 -1
- package/build/functions/connected_component.js +6 -3
- package/build/functions/get_port_labels.js +8 -5
- package/build/functions/graph.js +4 -1
- package/build/functions/index.js +24 -8
- package/build/functions/label.js +6 -3
- package/build/functions/module_name_parser.js +8 -3
- package/build/functions/place_module.js +12 -8
- package/build/functions/utility.js +15 -6
- package/build/functions/zip_utils.js +14 -6
- package/build/index.js +18 -2
- package/package.json +3 -3
package/build/constants/index.js
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
@@ -1,5 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.test_connected_components = test_connected_components;
|
|
4
|
+
const graph_1 = require("./graph");
|
|
5
|
+
function test_connected_components(G, visitors) {
|
|
3
6
|
const ccs = [];
|
|
4
7
|
const visited = new Set();
|
|
5
8
|
for (const [k] of Object.entries(G)) {
|
|
@@ -7,7 +10,7 @@ export function test_connected_components(G, visitors) {
|
|
|
7
10
|
for (const v of visitors)
|
|
8
11
|
if (v.start_visit_component)
|
|
9
12
|
v.start_visit_component();
|
|
10
|
-
const cc = dfs(G, k, visited, visitors);
|
|
13
|
+
const cc = (0, graph_1.dfs)(G, k, visited, visitors);
|
|
11
14
|
ccs.push(cc);
|
|
12
15
|
for (const v of visitors)
|
|
13
16
|
if (v.end_visit_component)
|
|
@@ -1,14 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.get_port_labels = get_port_labels;
|
|
4
|
+
const electronics_model_1 = require("@modular-circuit/electronics-model");
|
|
5
|
+
function get_port_labels(port, circuit) {
|
|
3
6
|
let labels = {};
|
|
4
7
|
for (const [k, v] of Object.entries(port)) {
|
|
5
|
-
if (k === LABEL_ASSOCIATED && typeof v === 'string') {
|
|
8
|
+
if (k === electronics_model_1.LABEL_ASSOCIATED && typeof v === 'string') {
|
|
6
9
|
if (circuit.eda_port_annotations[v]) {
|
|
7
10
|
if ('shape' in circuit.eda_port_annotations[v] && circuit.eda_port_annotations[v].shape !== null) {
|
|
8
11
|
labels[v] = circuit.eda_port_annotations[v].shape;
|
|
9
12
|
}
|
|
10
13
|
else if ('lib_id' in circuit.eda_port_annotations[v] && circuit.eda_port_annotations[v].lib_id !== null) {
|
|
11
|
-
labels[v] = LabelShapes.Input;
|
|
14
|
+
labels[v] = electronics_model_1.LabelShapes.Input;
|
|
12
15
|
}
|
|
13
16
|
else {
|
|
14
17
|
throw new Error(`Invalid port annotation for port ${v}: ${circuit.eda_port_annotations[v]}`);
|
|
@@ -17,7 +20,7 @@ export function get_port_labels(port, circuit) {
|
|
|
17
20
|
else {
|
|
18
21
|
// TODO : handel GND and VCC
|
|
19
22
|
// NOTE: Currently only GND and VCC will come here
|
|
20
|
-
labels[v] = LabelShapes.Output;
|
|
23
|
+
labels[v] = electronics_model_1.LabelShapes.Output;
|
|
21
24
|
}
|
|
22
25
|
}
|
|
23
26
|
else if (typeof v === 'object' && !Array.isArray(v) && v !== null) {
|
package/build/functions/graph.js
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.dfs = dfs;
|
|
4
|
+
function dfs(G, start, visited = new Set(), visitors) {
|
|
2
5
|
visited.add(start);
|
|
3
6
|
const result = [start];
|
|
4
7
|
for (const neighbor of G[start]) {
|
package/build/functions/index.js
CHANGED
|
@@ -1,8 +1,24 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./utility"), exports);
|
|
18
|
+
__exportStar(require("./place_module"), exports);
|
|
19
|
+
__exportStar(require("./module_name_parser"), exports);
|
|
20
|
+
__exportStar(require("./label"), exports);
|
|
21
|
+
__exportStar(require("./graph"), exports);
|
|
22
|
+
__exportStar(require("./connected_component"), exports);
|
|
23
|
+
__exportStar(require("./zip_utils"), exports);
|
|
24
|
+
__exportStar(require("./get_port_labels"), exports);
|
package/build/functions/label.js
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.gen_passive_label = gen_passive_label;
|
|
4
|
+
const electronics_model_1 = require("@modular-circuit/electronics-model");
|
|
5
|
+
function gen_passive_label(text) {
|
|
6
|
+
return { text, shape: electronics_model_1.LabelShapes.Passive };
|
|
4
7
|
}
|
|
@@ -1,4 +1,9 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.parse_module_name = parse_module_name;
|
|
4
|
+
exports.fmt_module_name = fmt_module_name;
|
|
5
|
+
exports.stringify_dependency = stringify_dependency;
|
|
6
|
+
function parse_module_name(dep) {
|
|
2
7
|
let [author, name] = dep.split('/');
|
|
3
8
|
author = author.substring(1);
|
|
4
9
|
return {
|
|
@@ -6,9 +11,9 @@ export function parse_module_name(dep) {
|
|
|
6
11
|
name,
|
|
7
12
|
};
|
|
8
13
|
}
|
|
9
|
-
|
|
14
|
+
function fmt_module_name(idx) {
|
|
10
15
|
return `@${idx.author}/${idx.name}`;
|
|
11
16
|
}
|
|
12
|
-
|
|
17
|
+
function stringify_dependency(idx) {
|
|
13
18
|
return `${fmt_module_name(idx)}@${idx.version}`;
|
|
14
19
|
}
|
|
@@ -1,7 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.get_circuit_ports = get_circuit_ports;
|
|
4
|
+
exports.place_module = place_module;
|
|
5
|
+
const electronics_model_1 = require("@modular-circuit/electronics-model");
|
|
6
|
+
const get_port_labels_1 = require("./get_port_labels");
|
|
7
|
+
const utility_1 = require("./utility");
|
|
8
|
+
function get_circuit_ports(module) {
|
|
5
9
|
const port_map = {};
|
|
6
10
|
let index = 0;
|
|
7
11
|
for (const port of module.ports) {
|
|
@@ -9,20 +13,20 @@ export function get_circuit_ports(module) {
|
|
|
9
13
|
}
|
|
10
14
|
return port_map;
|
|
11
15
|
}
|
|
12
|
-
|
|
16
|
+
function place_module(module) {
|
|
13
17
|
const ports = [];
|
|
14
18
|
let index = 0;
|
|
15
19
|
for (const it of module.ports) {
|
|
16
20
|
ports.push({
|
|
17
21
|
index: index++,
|
|
18
|
-
uuid: gen_uuid(),
|
|
22
|
+
uuid: (0, utility_1.gen_uuid)(),
|
|
19
23
|
name: it.name,
|
|
20
|
-
shape: merge_port_label_shapes(get_port_labels(it, module)),
|
|
24
|
+
shape: (0, electronics_model_1.merge_port_label_shapes)((0, get_port_labels_1.get_port_labels)(it, module)),
|
|
21
25
|
type: it.type,
|
|
22
26
|
});
|
|
23
27
|
}
|
|
24
28
|
return {
|
|
25
|
-
uuid: gen_uuid(),
|
|
29
|
+
uuid: (0, utility_1.gen_uuid)(),
|
|
26
30
|
type: {
|
|
27
31
|
author: module.author,
|
|
28
32
|
name: module.name,
|
|
@@ -1,10 +1,19 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.gen_uuid = void 0;
|
|
7
|
+
exports.deep_copy = deep_copy;
|
|
8
|
+
exports.replaceAll = replaceAll;
|
|
9
|
+
const lodash_1 = __importDefault(require("lodash"));
|
|
10
|
+
const uuid_1 = require("uuid");
|
|
11
|
+
const gen_uuid = () => (0, uuid_1.v4)();
|
|
12
|
+
exports.gen_uuid = gen_uuid;
|
|
13
|
+
function deep_copy(obj) {
|
|
14
|
+
return lodash_1.default.cloneDeep(obj);
|
|
6
15
|
}
|
|
7
|
-
|
|
16
|
+
function replaceAll(str, search, replacement) {
|
|
8
17
|
const regex = new RegExp(search, 'g');
|
|
9
18
|
return str.replace(regex, replacement);
|
|
10
19
|
}
|
|
@@ -1,6 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.unzipFile = unzipFile;
|
|
7
|
+
exports.zipFiles = zipFiles;
|
|
8
|
+
exports.remove_filename_path_prefix = remove_filename_path_prefix;
|
|
9
|
+
const jszip_1 = __importDefault(require("jszip"));
|
|
10
|
+
async function unzipFile(file) {
|
|
11
|
+
const zip = new jszip_1.default();
|
|
4
12
|
try {
|
|
5
13
|
// Load the zip file from the Blob
|
|
6
14
|
const content = await zip.loadAsync(file);
|
|
@@ -23,8 +31,8 @@ export async function unzipFile(file) {
|
|
|
23
31
|
throw new Error('Failed to unzip file');
|
|
24
32
|
}
|
|
25
33
|
}
|
|
26
|
-
|
|
27
|
-
const zip = new
|
|
34
|
+
async function zipFiles(files) {
|
|
35
|
+
const zip = new jszip_1.default();
|
|
28
36
|
// Add files to the zip archive
|
|
29
37
|
for (const filePath in files)
|
|
30
38
|
zip.file(filePath, files[filePath]); // Add file content to the zip
|
|
@@ -38,7 +46,7 @@ export async function zipFiles(files) {
|
|
|
38
46
|
throw new Error('Failed to create zip file');
|
|
39
47
|
}
|
|
40
48
|
}
|
|
41
|
-
|
|
49
|
+
function remove_filename_path_prefix(name) {
|
|
42
50
|
const names = name.split('/');
|
|
43
51
|
return names[names.length - 1];
|
|
44
52
|
}
|
package/build/index.js
CHANGED
|
@@ -1,2 +1,18 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./functions"), exports);
|
|
18
|
+
__exportStar(require("./constants"), exports);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@modular-circuit/utils",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.32",
|
|
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.
|
|
32
|
-
"@modular-circuit/ir": "0.0.
|
|
31
|
+
"@modular-circuit/electronics-model": "0.0.46",
|
|
32
|
+
"@modular-circuit/ir": "0.0.54"
|
|
33
33
|
},
|
|
34
34
|
"scripts": {
|
|
35
35
|
"clean": "rimraf build",
|