@modular-circuit/middleware 0.0.39 → 0.1.1

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.
Files changed (42) hide show
  1. package/dist/index.d.mts +52 -0
  2. package/dist/index.d.ts +52 -0
  3. package/dist/index.js +119 -0
  4. package/dist/index.mjs +91 -0
  5. package/package.json +12 -10
  6. package/build/bom/bom_match.d.ts +0 -11
  7. package/build/bom/bom_match.d.ts.map +0 -1
  8. package/build/bom/bom_match.js +0 -0
  9. package/build/bom/index.d.ts +0 -2
  10. package/build/bom/index.d.ts.map +0 -1
  11. package/build/bom/index.js +0 -1
  12. package/build/index.d.ts +0 -3
  13. package/build/index.d.ts.map +0 -1
  14. package/build/index.js +0 -2
  15. package/build/mock/index.d.ts +0 -3
  16. package/build/mock/index.d.ts.map +0 -1
  17. package/build/mock/index.js +0 -2
  18. package/build/mock/module_circuits/index.d.ts +0 -5
  19. package/build/mock/module_circuits/index.d.ts.map +0 -1
  20. package/build/mock/module_circuits/index.js +0 -3
  21. package/build/mock/module_circuits/test_module_a.json +0 -71
  22. package/build/mock/module_circuits/test_module_b.json +0 -71
  23. package/build/mock/module_circuits_categories/categories.json +0 -1
  24. package/build/mock/module_circuits_categories/index.d.ts +0 -87
  25. package/build/mock/module_circuits_categories/index.d.ts.map +0 -1
  26. package/build/mock/module_circuits_categories/index.js +0 -2
  27. package/build/registry/default_registry_mgr.d.ts +0 -14
  28. package/build/registry/default_registry_mgr.d.ts.map +0 -1
  29. package/build/registry/default_registry_mgr.js +0 -160
  30. package/build/registry/http_registry.d.ts +0 -24
  31. package/build/registry/http_registry.d.ts.map +0 -1
  32. package/build/registry/http_registry.js +0 -124
  33. package/build/registry/index.d.ts +0 -4
  34. package/build/registry/index.d.ts.map +0 -1
  35. package/build/registry/index.js +0 -3
  36. package/build/registry/registry_mgr.d.ts +0 -8
  37. package/build/registry/registry_mgr.d.ts.map +0 -1
  38. package/build/registry/registry_mgr.js +0 -0
  39. package/build/tsconfig.build.tsbuildinfo +0 -1
  40. package/build/utils/index.d.ts +0 -3
  41. package/build/utils/index.d.ts.map +0 -1
  42. package/build/utils/index.js +0 -27
@@ -0,0 +1,52 @@
1
+ import { RuntimeModuleCircuit, ModuleResolver, ModuleIndex, ModuleCircuit, SCH_SYMBOL_PROPERTIES, Component } from '@modular-circuit/ir';
2
+
3
+ interface HttpResponse {
4
+ code: number;
5
+ message: string;
6
+ result: unknown;
7
+ }
8
+ interface HttpConfig {
9
+ module_archive_url: URL;
10
+ module_circuit_url: URL;
11
+ zip_origin?: string;
12
+ all_modules?: RuntimeModuleCircuit[];
13
+ }
14
+ declare class HttpRegistry implements ModuleResolver {
15
+ private cnf;
16
+ private zip_origin;
17
+ private module_caches;
18
+ constructor(cnf: HttpConfig);
19
+ get_module_archive(idx: ModuleIndex): Promise<URL | undefined>;
20
+ get_module_circuit(idx: ModuleIndex): Promise<ModuleCircuit | undefined>;
21
+ get_module_circuit_by_id(id: string): Promise<ModuleCircuit | undefined>;
22
+ get_module_archive_by_id(id: string): Promise<URL | undefined>;
23
+ }
24
+
25
+ interface RegistryMgr extends ModuleResolver {
26
+ /**
27
+ * 获取所有可用的Registry
28
+ */
29
+ get_available_registries(): Promise<ModuleResolver[]>;
30
+ }
31
+
32
+ declare class DefaultRegistryMgr implements RegistryMgr {
33
+ private registries;
34
+ constructor(http_registries: HttpConfig[]);
35
+ get_available_registries(): Promise<ModuleResolver[]>;
36
+ get_module_archive(idx: ModuleIndex): Promise<URL | undefined>;
37
+ get_module_circuit(idx: ModuleIndex): Promise<ModuleCircuit | undefined>;
38
+ get_module_circuit_by_id(id: string): Promise<ModuleCircuit | undefined>;
39
+ get_module_archive_by_id(id: string): Promise<URL | undefined>;
40
+ }
41
+
42
+ /**
43
+ * BOM 匹配
44
+ */
45
+ interface BomMatch {
46
+ /**
47
+ * 匹配 KiCad的原理图符号
48
+ */
49
+ match_sch_symbol(sch_symbol: SCH_SYMBOL_PROPERTIES & Record<string, string>): Component[];
50
+ }
51
+
52
+ export { type BomMatch, DefaultRegistryMgr, type HttpConfig, HttpRegistry, type HttpResponse, type RegistryMgr };
@@ -0,0 +1,52 @@
1
+ import { RuntimeModuleCircuit, ModuleResolver, ModuleIndex, ModuleCircuit, SCH_SYMBOL_PROPERTIES, Component } from '@modular-circuit/ir';
2
+
3
+ interface HttpResponse {
4
+ code: number;
5
+ message: string;
6
+ result: unknown;
7
+ }
8
+ interface HttpConfig {
9
+ module_archive_url: URL;
10
+ module_circuit_url: URL;
11
+ zip_origin?: string;
12
+ all_modules?: RuntimeModuleCircuit[];
13
+ }
14
+ declare class HttpRegistry implements ModuleResolver {
15
+ private cnf;
16
+ private zip_origin;
17
+ private module_caches;
18
+ constructor(cnf: HttpConfig);
19
+ get_module_archive(idx: ModuleIndex): Promise<URL | undefined>;
20
+ get_module_circuit(idx: ModuleIndex): Promise<ModuleCircuit | undefined>;
21
+ get_module_circuit_by_id(id: string): Promise<ModuleCircuit | undefined>;
22
+ get_module_archive_by_id(id: string): Promise<URL | undefined>;
23
+ }
24
+
25
+ interface RegistryMgr extends ModuleResolver {
26
+ /**
27
+ * 获取所有可用的Registry
28
+ */
29
+ get_available_registries(): Promise<ModuleResolver[]>;
30
+ }
31
+
32
+ declare class DefaultRegistryMgr implements RegistryMgr {
33
+ private registries;
34
+ constructor(http_registries: HttpConfig[]);
35
+ get_available_registries(): Promise<ModuleResolver[]>;
36
+ get_module_archive(idx: ModuleIndex): Promise<URL | undefined>;
37
+ get_module_circuit(idx: ModuleIndex): Promise<ModuleCircuit | undefined>;
38
+ get_module_circuit_by_id(id: string): Promise<ModuleCircuit | undefined>;
39
+ get_module_archive_by_id(id: string): Promise<URL | undefined>;
40
+ }
41
+
42
+ /**
43
+ * BOM 匹配
44
+ */
45
+ interface BomMatch {
46
+ /**
47
+ * 匹配 KiCad的原理图符号
48
+ */
49
+ match_sch_symbol(sch_symbol: SCH_SYMBOL_PROPERTIES & Record<string, string>): Component[];
50
+ }
51
+
52
+ export { type BomMatch, DefaultRegistryMgr, type HttpConfig, HttpRegistry, type HttpResponse, type RegistryMgr };
package/dist/index.js ADDED
@@ -0,0 +1,119 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/index.ts
21
+ var index_exports = {};
22
+ __export(index_exports, {
23
+ DefaultRegistryMgr: () => DefaultRegistryMgr,
24
+ HttpRegistry: () => HttpRegistry
25
+ });
26
+ module.exports = __toCommonJS(index_exports);
27
+
28
+ // src/utils/index.ts
29
+ var fmt_parameter_to_url = (params) => {
30
+ return Object.entries(params).map(([k, v]) => `${k}=${v}`).join("&");
31
+ };
32
+ function do_fetch(url, params) {
33
+ return fetch(`${url}?${fmt_parameter_to_url(params)}`);
34
+ }
35
+
36
+ // src/registry/http_registry.ts
37
+ var HttpRegistry = class {
38
+ constructor(cnf) {
39
+ this.cnf = cnf;
40
+ this.module_caches = {};
41
+ this.zip_origin = cnf.zip_origin ?? cnf.module_archive_url.origin;
42
+ for (const module_circuit of cnf.all_modules ?? []) {
43
+ this.module_caches[module_circuit.id] = module_circuit;
44
+ }
45
+ }
46
+ async get_module_archive(idx) {
47
+ const it = await do_fetch(this.cnf.module_archive_url, idx);
48
+ const pp = (await it.json()).result;
49
+ if (!pp) return;
50
+ const full = `${this.zip_origin}${pp}`;
51
+ return new URL(full);
52
+ }
53
+ async get_module_circuit(idx) {
54
+ const it = await do_fetch(this.cnf.module_circuit_url, idx);
55
+ return (await it.json()).result;
56
+ }
57
+ async get_module_circuit_by_id(id) {
58
+ return this.module_caches[id];
59
+ }
60
+ async get_module_archive_by_id(id) {
61
+ const path = this.module_caches[id]?.file_zip;
62
+ if (!path) return;
63
+ return new URL(!path.startsWith("/") ? `${this.zip_origin}/${path}` : `${this.zip_origin}${path}`);
64
+ }
65
+ };
66
+
67
+ // src/registry/default_registry_mgr.ts
68
+ var DefaultRegistryMgr = class {
69
+ constructor(http_registries) {
70
+ this.registries = [];
71
+ for (const cnf of http_registries) {
72
+ this.registries.push(new HttpRegistry(cnf));
73
+ }
74
+ }
75
+ async get_available_registries() {
76
+ return this.registries;
77
+ }
78
+ get_module_archive(idx) {
79
+ return this.registries.reduce(
80
+ async (prev, registry) => {
81
+ const res = await registry.get_module_archive(idx);
82
+ return res ? res : await prev;
83
+ },
84
+ Promise.resolve(void 0)
85
+ );
86
+ }
87
+ get_module_circuit(idx) {
88
+ return this.registries.reduce(
89
+ async (prev, registry) => {
90
+ const res = await registry.get_module_circuit(idx);
91
+ return res ? res : await prev;
92
+ },
93
+ Promise.resolve(void 0)
94
+ );
95
+ }
96
+ get_module_circuit_by_id(id) {
97
+ return this.registries.reduce(
98
+ async (prev, registry) => {
99
+ const res = await registry.get_module_circuit_by_id(id);
100
+ return res ? res : await prev;
101
+ },
102
+ Promise.resolve(void 0)
103
+ );
104
+ }
105
+ get_module_archive_by_id(id) {
106
+ return this.registries.reduce(
107
+ async (prev, registry) => {
108
+ const res = await registry.get_module_archive_by_id(id);
109
+ return res ? res : await prev;
110
+ },
111
+ Promise.resolve(void 0)
112
+ );
113
+ }
114
+ };
115
+ // Annotate the CommonJS export names for ESM import in node:
116
+ 0 && (module.exports = {
117
+ DefaultRegistryMgr,
118
+ HttpRegistry
119
+ });
package/dist/index.mjs ADDED
@@ -0,0 +1,91 @@
1
+ // src/utils/index.ts
2
+ var fmt_parameter_to_url = (params) => {
3
+ return Object.entries(params).map(([k, v]) => `${k}=${v}`).join("&");
4
+ };
5
+ function do_fetch(url, params) {
6
+ return fetch(`${url}?${fmt_parameter_to_url(params)}`);
7
+ }
8
+
9
+ // src/registry/http_registry.ts
10
+ var HttpRegistry = class {
11
+ constructor(cnf) {
12
+ this.cnf = cnf;
13
+ this.module_caches = {};
14
+ this.zip_origin = cnf.zip_origin ?? cnf.module_archive_url.origin;
15
+ for (const module_circuit of cnf.all_modules ?? []) {
16
+ this.module_caches[module_circuit.id] = module_circuit;
17
+ }
18
+ }
19
+ async get_module_archive(idx) {
20
+ const it = await do_fetch(this.cnf.module_archive_url, idx);
21
+ const pp = (await it.json()).result;
22
+ if (!pp) return;
23
+ const full = `${this.zip_origin}${pp}`;
24
+ return new URL(full);
25
+ }
26
+ async get_module_circuit(idx) {
27
+ const it = await do_fetch(this.cnf.module_circuit_url, idx);
28
+ return (await it.json()).result;
29
+ }
30
+ async get_module_circuit_by_id(id) {
31
+ return this.module_caches[id];
32
+ }
33
+ async get_module_archive_by_id(id) {
34
+ const path = this.module_caches[id]?.file_zip;
35
+ if (!path) return;
36
+ return new URL(!path.startsWith("/") ? `${this.zip_origin}/${path}` : `${this.zip_origin}${path}`);
37
+ }
38
+ };
39
+
40
+ // src/registry/default_registry_mgr.ts
41
+ var DefaultRegistryMgr = class {
42
+ constructor(http_registries) {
43
+ this.registries = [];
44
+ for (const cnf of http_registries) {
45
+ this.registries.push(new HttpRegistry(cnf));
46
+ }
47
+ }
48
+ async get_available_registries() {
49
+ return this.registries;
50
+ }
51
+ get_module_archive(idx) {
52
+ return this.registries.reduce(
53
+ async (prev, registry) => {
54
+ const res = await registry.get_module_archive(idx);
55
+ return res ? res : await prev;
56
+ },
57
+ Promise.resolve(void 0)
58
+ );
59
+ }
60
+ get_module_circuit(idx) {
61
+ return this.registries.reduce(
62
+ async (prev, registry) => {
63
+ const res = await registry.get_module_circuit(idx);
64
+ return res ? res : await prev;
65
+ },
66
+ Promise.resolve(void 0)
67
+ );
68
+ }
69
+ get_module_circuit_by_id(id) {
70
+ return this.registries.reduce(
71
+ async (prev, registry) => {
72
+ const res = await registry.get_module_circuit_by_id(id);
73
+ return res ? res : await prev;
74
+ },
75
+ Promise.resolve(void 0)
76
+ );
77
+ }
78
+ get_module_archive_by_id(id) {
79
+ return this.registries.reduce(
80
+ async (prev, registry) => {
81
+ const res = await registry.get_module_archive_by_id(id);
82
+ return res ? res : await prev;
83
+ },
84
+ Promise.resolve(void 0)
85
+ );
86
+ }
87
+ };
88
+ export {
89
+ DefaultRegistryMgr,
90
+ HttpRegistry
91
+ };
package/package.json CHANGED
@@ -1,17 +1,18 @@
1
1
  {
2
2
  "name": "@modular-circuit/middleware",
3
- "version": "0.0.39",
3
+ "version": "0.1.1",
4
4
  "description": "Intermediate representation of the modular circuit",
5
- "main": "./build/index.js",
5
+ "main": "./dist/index.js",
6
+ "module": "./dist/index.mjs",
7
+ "types": "./dist/index.d.ts",
6
8
  "exports": {
7
9
  ".": {
8
- "import": "./build/index.js",
9
- "require": "./build/index.js",
10
- "types": "./build/index.d.ts"
10
+ "import": "./dist/index.mjs",
11
+ "require": "./dist/index.js"
11
12
  }
12
13
  },
13
14
  "files": [
14
- "build"
15
+ "dist"
15
16
  ],
16
17
  "keywords": [],
17
18
  "author": "",
@@ -19,18 +20,19 @@
19
20
  "devDependencies": {
20
21
  "@biomejs/biome": "^1.8.3",
21
22
  "@types/convert-units": "^2.3.9",
23
+ "@types/node": "20.9.0",
22
24
  "esbuild": "^0.20.2",
23
25
  "tsup": "^8.3.0",
24
26
  "typescript": "^5.4.5"
25
27
  },
26
28
  "dependencies": {
27
- "@modular-circuit/ir": "0.0.63",
28
- "@modular-circuit/utils": "0.0.41"
29
+ "@modular-circuit/ir": "0.1.2",
30
+ "@modular-circuit/utils": "0.1.2"
29
31
  },
30
32
  "scripts": {
31
- "clean": "rimraf build",
33
+ "clean": "rimraf dist",
32
34
  "prebuild": "pnpm clean",
33
- "build": "tsc --build tsconfig.build.json",
35
+ "build": "tsup src/index.ts --format cjs,esm --dts --clean --tsconfig tsconfig.build.json",
34
36
  "lint:ci": "biome ci",
35
37
  "lint": "biome check --fix --unsafe",
36
38
  "test:integration": "vitest --workspace ../../vitest.workspace.ts --project integration run"
@@ -1,11 +0,0 @@
1
- import type { Component, SCH_SYMBOL_PROPERTIES } from '@modular-circuit/ir';
2
- /**
3
- * BOM 匹配
4
- */
5
- export interface BomMatch {
6
- /**
7
- * 匹配 KiCad的原理图符号
8
- */
9
- match_sch_symbol(sch_symbol: SCH_SYMBOL_PROPERTIES & Record<string, string>): Component[];
10
- }
11
- //# sourceMappingURL=bom_match.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"bom_match.d.ts","sourceRoot":"","sources":["../../src/bom/bom_match.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAA;AAE3E;;GAEG;AACH,MAAM,WAAW,QAAQ;IACvB;;OAEG;IACH,gBAAgB,CAAC,UAAU,EAAE,qBAAqB,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,SAAS,EAAE,CAAA;CAC1F"}
File without changes
@@ -1,2 +0,0 @@
1
- export * from './bom_match';
2
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/bom/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAA"}
@@ -1 +0,0 @@
1
- export * from './bom_match';
package/build/index.d.ts DELETED
@@ -1,3 +0,0 @@
1
- export * from './registry';
2
- export * from './bom';
3
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAA;AAC1B,cAAc,OAAO,CAAA"}
package/build/index.js DELETED
@@ -1,2 +0,0 @@
1
- export * from './registry';
2
- export * from './bom';
@@ -1,3 +0,0 @@
1
- export * from './module_circuits';
2
- export * from './module_circuits_categories';
3
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/mock/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAA;AACjC,cAAc,8BAA8B,CAAA"}
@@ -1,2 +0,0 @@
1
- export * from './module_circuits';
2
- export * from './module_circuits_categories';
@@ -1,5 +0,0 @@
1
- import type { ModuleCircuit } from '@modular-circuit/ir';
2
- declare const Test_Module_A: Promise<ModuleCircuit>;
3
- declare const Test_Module_B: Promise<ModuleCircuit>;
4
- export { Test_Module_A, Test_Module_B };
5
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/mock/module_circuits/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAA;AAExD,QAAA,MAAM,aAAa,EAAgD,OAAO,CAAC,aAAa,CAAC,CAAA;AACzF,QAAA,MAAM,aAAa,EAAgD,OAAO,CAAC,aAAa,CAAC,CAAA;AAEzF,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,CAAA"}
@@ -1,3 +0,0 @@
1
- var Test_Module_A = import('./test_module_a.json');
2
- var Test_Module_B = import('./test_module_b.json');
3
- export { Test_Module_A, Test_Module_B };
@@ -1,71 +0,0 @@
1
- {
2
- "name": "TestModuleNamA",
3
- "main": "example_module.modular_circuit",
4
- "author": "Jane Doe",
5
- "short_description": "This is a short description of the module.",
6
- "detailed_description": "This is a detailed description of the module, including its features and usage.",
7
- "create_date_time": "2024-04-01T12:00:00Z",
8
- "dependencies": {
9
- "dependency1": "1.0.0",
10
- "dependency2": "2.0.0"
11
- },
12
- "bom_is_completed": true,
13
- "version": "1.0.0",
14
- "specifications": [
15
- {
16
- "name": "Voltage",
17
- "value": "5V",
18
- "functionality": ""
19
- },
20
- {
21
- "name": "Current",
22
- "value": "2A",
23
- "functionality": ""
24
- }
25
- ],
26
- "categories": ["category1", "category2"],
27
- "tags": [
28
- {
29
- "name": "Electronics",
30
- "description": "Electronic components"
31
- },
32
- {
33
- "name": "Power",
34
- "description": "Power supply modules"
35
- }
36
- ],
37
- "bom": [
38
- {
39
- "item": "Resistor",
40
- "value": "100 Ohms",
41
- "quantity": 10
42
- },
43
- {
44
- "item": "Capacitor",
45
- "value": "10uF",
46
- "quantity": 5
47
- }
48
- ],
49
- "ports": {
50
- "power:GND": {
51
- "type": "GND",
52
- "description": "Input port"
53
- },
54
- "power:+3V3": {
55
- "type": "power",
56
- "description": "Output port"
57
- },
58
- "PortA": {
59
- "type": "analog",
60
- "shape": "input",
61
- "description": "Output port"
62
- },
63
- "PortB": {
64
- "type": "analog",
65
- "shape": "output",
66
- "description": "Output port"
67
- }
68
- },
69
- "number_of_uses": 150,
70
- "number_of_collections": 50
71
- }
@@ -1,71 +0,0 @@
1
- {
2
- "name": "TestModuleNamB",
3
- "main": "example_module.modular_circuit",
4
- "author": "Jane Doe",
5
- "short_description": "This is a short description of the module.",
6
- "detailed_description": "This is a detailed description of the module, including its features and usage.",
7
- "create_date_time": "2024-04-01T12:00:00Z",
8
- "dependencies": {
9
- "dependency1": "1.0.0",
10
- "dependency2": "2.0.0"
11
- },
12
- "bom_is_completed": true,
13
- "version": "1.0.0",
14
- "specifications": [
15
- {
16
- "name": "Voltage",
17
- "value": "5V",
18
- "functionality": ""
19
- },
20
- {
21
- "name": "Current",
22
- "value": "2A",
23
- "functionality": ""
24
- }
25
- ],
26
- "categories": ["category1", "category2"],
27
- "tags": [
28
- {
29
- "name": "Electronics",
30
- "description": "Electronic components"
31
- },
32
- {
33
- "name": "Power",
34
- "description": "Power supply modules"
35
- }
36
- ],
37
- "bom": [
38
- {
39
- "item": "Resistor",
40
- "value": "100 Ohms",
41
- "quantity": 10
42
- },
43
- {
44
- "item": "Capacitor",
45
- "value": "10uF",
46
- "quantity": 5
47
- }
48
- ],
49
- "ports": {
50
- "power:GND": {
51
- "type": "GND",
52
- "description": "Input port"
53
- },
54
- "power:+3V3": {
55
- "type": "power",
56
- "description": "Output port"
57
- },
58
- "PortA": {
59
- "type": "analog",
60
- "shape": "input",
61
- "description": "Output port"
62
- },
63
- "PortB": {
64
- "type": "analog",
65
- "shape": "output",
66
- "description": "Output port"
67
- }
68
- },
69
- "number_of_uses": 150,
70
- "number_of_collections": 50
71
- }
@@ -1 +0,0 @@
1
- ["AUDIO INPUT", "AC DC VOLTAGE CONVERTER", "BLUETOOTH", "EEPROM", "FLASH", "MCU", "USB BRIDGE"]
@@ -1,87 +0,0 @@
1
- declare const Categories: Promise<{
2
- default: string[];
3
- length: number;
4
- toString(): string;
5
- toLocaleString(): string;
6
- toLocaleString(locales: string | string[], options?: Intl.NumberFormatOptions & Intl.DateTimeFormatOptions): string;
7
- pop(): string | undefined;
8
- push(...items: string[]): number;
9
- concat(...items: ConcatArray<string>[]): string[];
10
- concat(...items: (string | ConcatArray<string>)[]): string[];
11
- join(separator?: string): string;
12
- reverse(): string[];
13
- shift(): string | undefined;
14
- slice(start?: number, end?: number): string[];
15
- sort(compareFn?: ((a: string, b: string) => number) | undefined): string[];
16
- splice(start: number, deleteCount?: number): string[];
17
- splice(start: number, deleteCount: number, ...items: string[]): string[];
18
- unshift(...items: string[]): number;
19
- indexOf(searchElement: string, fromIndex?: number): number;
20
- lastIndexOf(searchElement: string, fromIndex?: number): number;
21
- every<S extends string>(predicate: (value: string, index: number, array: string[]) => value is S, thisArg?: any): this is S[];
22
- every(predicate: (value: string, index: number, array: string[]) => unknown, thisArg?: any): boolean;
23
- some(predicate: (value: string, index: number, array: string[]) => unknown, thisArg?: any): boolean;
24
- forEach(callbackfn: (value: string, index: number, array: string[]) => void, thisArg?: any): void;
25
- map<U>(callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any): U[];
26
- filter<S extends string>(predicate: (value: string, index: number, array: string[]) => value is S, thisArg?: any): S[];
27
- filter(predicate: (value: string, index: number, array: string[]) => unknown, thisArg?: any): string[];
28
- reduce(callbackfn: (previousValue: string, currentValue: string, currentIndex: number, array: string[]) => string): string;
29
- reduce(callbackfn: (previousValue: string, currentValue: string, currentIndex: number, array: string[]) => string, initialValue: string): string;
30
- reduce<U>(callbackfn: (previousValue: U, currentValue: string, currentIndex: number, array: string[]) => U, initialValue: U): U;
31
- reduceRight(callbackfn: (previousValue: string, currentValue: string, currentIndex: number, array: string[]) => string): string;
32
- reduceRight(callbackfn: (previousValue: string, currentValue: string, currentIndex: number, array: string[]) => string, initialValue: string): string;
33
- reduceRight<U>(callbackfn: (previousValue: U, currentValue: string, currentIndex: number, array: string[]) => U, initialValue: U): U;
34
- find<S extends string>(predicate: (value: string, index: number, obj: string[]) => value is S, thisArg?: any): S | undefined;
35
- find(predicate: (value: string, index: number, obj: string[]) => unknown, thisArg?: any): string | undefined;
36
- findIndex(predicate: (value: string, index: number, obj: string[]) => unknown, thisArg?: any): number;
37
- fill(value: string, start?: number, end?: number): string[];
38
- copyWithin(target: number, start: number, end?: number): string[];
39
- entries(): ArrayIterator<[number, string]>;
40
- keys(): ArrayIterator<number>;
41
- values(): ArrayIterator<string>;
42
- includes(searchElement: string, fromIndex?: number): boolean;
43
- flatMap<U, This = undefined>(callback: (this: This, value: string, index: number, array: string[]) => U | readonly U[], thisArg?: This | undefined): U[];
44
- flat<A, D extends number = 1>(this: A, depth?: D | undefined): FlatArray<A, D>[];
45
- [Symbol.iterator](): ArrayIterator<string>;
46
- [Symbol.unscopables]: {
47
- [x: number]: boolean | undefined;
48
- length?: boolean | undefined;
49
- toString?: boolean | undefined;
50
- toLocaleString?: boolean | undefined;
51
- pop?: boolean | undefined;
52
- push?: boolean | undefined;
53
- concat?: boolean | undefined;
54
- join?: boolean | undefined;
55
- reverse?: boolean | undefined;
56
- shift?: boolean | undefined;
57
- slice?: boolean | undefined;
58
- sort?: boolean | undefined;
59
- splice?: boolean | undefined;
60
- unshift?: boolean | undefined;
61
- indexOf?: boolean | undefined;
62
- lastIndexOf?: boolean | undefined;
63
- every?: boolean | undefined;
64
- some?: boolean | undefined;
65
- forEach?: boolean | undefined;
66
- map?: boolean | undefined;
67
- filter?: boolean | undefined;
68
- reduce?: boolean | undefined;
69
- reduceRight?: boolean | undefined;
70
- find?: boolean | undefined;
71
- findIndex?: boolean | undefined;
72
- fill?: boolean | undefined;
73
- copyWithin?: boolean | undefined;
74
- entries?: boolean | undefined;
75
- keys?: boolean | undefined;
76
- values?: boolean | undefined;
77
- includes?: boolean | undefined;
78
- flatMap?: boolean | undefined;
79
- flat?: boolean | undefined;
80
- [Symbol.iterator]?: boolean | undefined;
81
- readonly [Symbol.unscopables]?: boolean | undefined;
82
- at?: boolean | undefined;
83
- };
84
- at(index: number): string | undefined;
85
- }>;
86
- export { Categories };
87
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/mock/module_circuits_categories/index.ts"],"names":[],"mappings":"AAAA,QAAA,MAAM,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAA8B,CAAA;AAE9C,OAAO,EAAE,UAAU,EAAE,CAAA"}
@@ -1,2 +0,0 @@
1
- var Categories = import('./categories.json');
2
- export { Categories };
@@ -1,14 +0,0 @@
1
- import type { ModuleCircuit, ModuleResolver } from '@modular-circuit/ir';
2
- import type { ModuleIndex } from '@modular-circuit/ir';
3
- import { type HttpConfig } from './http_registry';
4
- import type { RegistryMgr } from './registry_mgr';
5
- export declare class DefaultRegistryMgr implements RegistryMgr {
6
- private registries;
7
- constructor(http_registries: HttpConfig[]);
8
- get_available_registries(): Promise<ModuleResolver[]>;
9
- get_module_archive(idx: ModuleIndex): Promise<URL | undefined>;
10
- get_module_circuit(idx: ModuleIndex): Promise<ModuleCircuit | undefined>;
11
- get_module_circuit_by_id(id: string): Promise<ModuleCircuit | undefined>;
12
- get_module_archive_by_id(id: string): Promise<URL | undefined>;
13
- }
14
- //# sourceMappingURL=default_registry_mgr.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"default_registry_mgr.d.ts","sourceRoot":"","sources":["../../src/registry/default_registry_mgr.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAA;AACxE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAA;AACtD,OAAO,EAAE,KAAK,UAAU,EAAgB,MAAM,iBAAiB,CAAA;AAC/D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAA;AAEjD,qBAAa,kBAAmB,YAAW,WAAW;IACpD,OAAO,CAAC,UAAU,CAAuB;gBACtB,eAAe,EAAE,UAAU,EAAE;IAK1C,wBAAwB,IAAI,OAAO,CAAC,cAAc,EAAE,CAAC;IAG3D,kBAAkB,CAAC,GAAG,EAAE,WAAW,GAAG,OAAO,CAAC,GAAG,GAAG,SAAS,CAAC;IAS9D,kBAAkB,CAAC,GAAG,EAAE,WAAW,GAAG,OAAO,CAAC,aAAa,GAAG,SAAS,CAAC;IASxE,wBAAwB,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,GAAG,SAAS,CAAC;IAUxE,wBAAwB,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,GAAG,GAAG,SAAS,CAAC;CAS/D"}
@@ -1,160 +0,0 @@
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;
31
- }
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 };
35
- }
36
- };
37
- var __values = (this && this.__values) || function(o) {
38
- var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
39
- if (m) return m.call(o);
40
- if (o && typeof o.length === "number") return {
41
- next: function () {
42
- if (o && i >= o.length) o = void 0;
43
- return { value: o && o[i++], done: !o };
44
- }
45
- };
46
- throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
47
- };
48
- import { HttpRegistry } from './http_registry';
49
- var DefaultRegistryMgr = /** @class */ (function () {
50
- function DefaultRegistryMgr(http_registries) {
51
- var e_1, _a;
52
- this.registries = [];
53
- try {
54
- for (var http_registries_1 = __values(http_registries), http_registries_1_1 = http_registries_1.next(); !http_registries_1_1.done; http_registries_1_1 = http_registries_1.next()) {
55
- var cnf = http_registries_1_1.value;
56
- this.registries.push(new HttpRegistry(cnf));
57
- }
58
- }
59
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
60
- finally {
61
- try {
62
- if (http_registries_1_1 && !http_registries_1_1.done && (_a = http_registries_1.return)) _a.call(http_registries_1);
63
- }
64
- finally { if (e_1) throw e_1.error; }
65
- }
66
- }
67
- DefaultRegistryMgr.prototype.get_available_registries = function () {
68
- return __awaiter(this, void 0, void 0, function () {
69
- return __generator(this, function (_a) {
70
- return [2 /*return*/, this.registries];
71
- });
72
- });
73
- };
74
- DefaultRegistryMgr.prototype.get_module_archive = function (idx) {
75
- var _this = this;
76
- return this.registries.reduce(function (prev, registry) { return __awaiter(_this, void 0, void 0, function () {
77
- var res, _a;
78
- return __generator(this, function (_b) {
79
- switch (_b.label) {
80
- case 0: return [4 /*yield*/, registry.get_module_archive(idx)];
81
- case 1:
82
- res = _b.sent();
83
- if (!res) return [3 /*break*/, 2];
84
- _a = res;
85
- return [3 /*break*/, 4];
86
- case 2: return [4 /*yield*/, prev];
87
- case 3:
88
- _a = _b.sent();
89
- _b.label = 4;
90
- case 4: return [2 /*return*/, _a];
91
- }
92
- });
93
- }); }, Promise.resolve(undefined));
94
- };
95
- DefaultRegistryMgr.prototype.get_module_circuit = function (idx) {
96
- var _this = this;
97
- return this.registries.reduce(function (prev, registry) { return __awaiter(_this, void 0, void 0, function () {
98
- var res, _a;
99
- return __generator(this, function (_b) {
100
- switch (_b.label) {
101
- case 0: return [4 /*yield*/, registry.get_module_circuit(idx)];
102
- case 1:
103
- res = _b.sent();
104
- if (!res) return [3 /*break*/, 2];
105
- _a = res;
106
- return [3 /*break*/, 4];
107
- case 2: return [4 /*yield*/, prev];
108
- case 3:
109
- _a = _b.sent();
110
- _b.label = 4;
111
- case 4: return [2 /*return*/, _a];
112
- }
113
- });
114
- }); }, Promise.resolve(undefined));
115
- };
116
- DefaultRegistryMgr.prototype.get_module_circuit_by_id = function (id) {
117
- var _this = this;
118
- return this.registries.reduce(function (prev, registry) { return __awaiter(_this, void 0, void 0, function () {
119
- var res, _a;
120
- return __generator(this, function (_b) {
121
- switch (_b.label) {
122
- case 0: return [4 /*yield*/, registry.get_module_circuit_by_id(id)];
123
- case 1:
124
- res = _b.sent();
125
- if (!res) return [3 /*break*/, 2];
126
- _a = res;
127
- return [3 /*break*/, 4];
128
- case 2: return [4 /*yield*/, prev];
129
- case 3:
130
- _a = _b.sent();
131
- _b.label = 4;
132
- case 4: return [2 /*return*/, _a];
133
- }
134
- });
135
- }); }, Promise.resolve(undefined));
136
- };
137
- DefaultRegistryMgr.prototype.get_module_archive_by_id = function (id) {
138
- var _this = this;
139
- return this.registries.reduce(function (prev, registry) { return __awaiter(_this, void 0, void 0, function () {
140
- var res, _a;
141
- return __generator(this, function (_b) {
142
- switch (_b.label) {
143
- case 0: return [4 /*yield*/, registry.get_module_archive_by_id(id)];
144
- case 1:
145
- res = _b.sent();
146
- if (!res) return [3 /*break*/, 2];
147
- _a = res;
148
- return [3 /*break*/, 4];
149
- case 2: return [4 /*yield*/, prev];
150
- case 3:
151
- _a = _b.sent();
152
- _b.label = 4;
153
- case 4: return [2 /*return*/, _a];
154
- }
155
- });
156
- }); }, Promise.resolve(undefined));
157
- };
158
- return DefaultRegistryMgr;
159
- }());
160
- export { DefaultRegistryMgr };
@@ -1,24 +0,0 @@
1
- import type { ModuleCircuit, ModuleResolver, RuntimeModuleCircuit } from '@modular-circuit/ir';
2
- import type { ModuleIndex } from '@modular-circuit/ir';
3
- export interface HttpResponse {
4
- code: number;
5
- message: string;
6
- result: unknown;
7
- }
8
- export interface HttpConfig {
9
- module_archive_url: URL;
10
- module_circuit_url: URL;
11
- zip_origin?: string;
12
- all_modules?: RuntimeModuleCircuit[];
13
- }
14
- export declare class HttpRegistry implements ModuleResolver {
15
- private cnf;
16
- private zip_origin;
17
- private module_caches;
18
- constructor(cnf: HttpConfig);
19
- get_module_archive(idx: ModuleIndex): Promise<URL | undefined>;
20
- get_module_circuit(idx: ModuleIndex): Promise<ModuleCircuit | undefined>;
21
- get_module_circuit_by_id(id: string): Promise<ModuleCircuit | undefined>;
22
- get_module_archive_by_id(id: string): Promise<URL | undefined>;
23
- }
24
- //# sourceMappingURL=http_registry.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"http_registry.d.ts","sourceRoot":"","sources":["../../src/registry/http_registry.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,cAAc,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAA;AAC9F,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAA;AAItD,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,MAAM,CAAA;IACZ,OAAO,EAAE,MAAM,CAAA;IACf,MAAM,EAAE,OAAO,CAAA;CAChB;AAED,MAAM,WAAW,UAAU;IACzB,kBAAkB,EAAE,GAAG,CAAA;IACvB,kBAAkB,EAAE,GAAG,CAAA;IACvB,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,WAAW,CAAC,EAAE,oBAAoB,EAAE,CAAA;CACrC;AACD,qBAAa,YAAa,YAAW,cAAc;IAG9B,OAAO,CAAC,GAAG;IAF9B,OAAO,CAAC,UAAU,CAAQ;IAC1B,OAAO,CAAC,aAAa,CAA2C;gBACrC,GAAG,EAAE,UAAU;IAMpC,kBAAkB,CAAC,GAAG,EAAE,WAAW,GAAG,OAAO,CAAC,GAAG,GAAG,SAAS,CAAC;IAO9D,kBAAkB,CAAC,GAAG,EAAE,WAAW,GAAG,OAAO,CAAC,aAAa,GAAG,SAAS,CAAC;IAKxE,wBAAwB,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,GAAG,SAAS,CAAC;IAIxE,wBAAwB,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,GAAG,GAAG,SAAS,CAAC;CAKrE"}
@@ -1,124 +0,0 @@
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;
31
- }
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 };
35
- }
36
- };
37
- var __values = (this && this.__values) || function(o) {
38
- var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
39
- if (m) return m.call(o);
40
- if (o && typeof o.length === "number") return {
41
- next: function () {
42
- if (o && i >= o.length) o = void 0;
43
- return { value: o && o[i++], done: !o };
44
- }
45
- };
46
- throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
47
- };
48
- import { do_fetch } from '../utils';
49
- var HttpRegistry = /** @class */ (function () {
50
- function HttpRegistry(cnf) {
51
- var e_1, _a;
52
- var _b, _c;
53
- this.cnf = cnf;
54
- this.module_caches = {};
55
- this.zip_origin = (_b = cnf.zip_origin) !== null && _b !== void 0 ? _b : cnf.module_archive_url.origin;
56
- try {
57
- for (var _d = __values((_c = cnf.all_modules) !== null && _c !== void 0 ? _c : []), _e = _d.next(); !_e.done; _e = _d.next()) {
58
- var module_circuit = _e.value;
59
- this.module_caches[module_circuit.id] = module_circuit;
60
- }
61
- }
62
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
63
- finally {
64
- try {
65
- if (_e && !_e.done && (_a = _d.return)) _a.call(_d);
66
- }
67
- finally { if (e_1) throw e_1.error; }
68
- }
69
- }
70
- HttpRegistry.prototype.get_module_archive = function (idx) {
71
- return __awaiter(this, void 0, void 0, function () {
72
- var it, pp, full;
73
- return __generator(this, function (_a) {
74
- switch (_a.label) {
75
- case 0: return [4 /*yield*/, do_fetch(this.cnf.module_archive_url, idx)];
76
- case 1:
77
- it = _a.sent();
78
- return [4 /*yield*/, it.json()];
79
- case 2:
80
- pp = (_a.sent()).result;
81
- if (!pp)
82
- return [2 /*return*/];
83
- full = "".concat(this.zip_origin).concat(pp);
84
- return [2 /*return*/, new URL(full)];
85
- }
86
- });
87
- });
88
- };
89
- HttpRegistry.prototype.get_module_circuit = function (idx) {
90
- return __awaiter(this, void 0, void 0, function () {
91
- var it;
92
- return __generator(this, function (_a) {
93
- switch (_a.label) {
94
- case 0: return [4 /*yield*/, do_fetch(this.cnf.module_circuit_url, idx)];
95
- case 1:
96
- it = _a.sent();
97
- return [4 /*yield*/, it.json()];
98
- case 2: return [2 /*return*/, (_a.sent()).result];
99
- }
100
- });
101
- });
102
- };
103
- HttpRegistry.prototype.get_module_circuit_by_id = function (id) {
104
- return __awaiter(this, void 0, void 0, function () {
105
- return __generator(this, function (_a) {
106
- return [2 /*return*/, this.module_caches[id]];
107
- });
108
- });
109
- };
110
- HttpRegistry.prototype.get_module_archive_by_id = function (id) {
111
- return __awaiter(this, void 0, void 0, function () {
112
- var path;
113
- var _a;
114
- return __generator(this, function (_b) {
115
- path = (_a = this.module_caches[id]) === null || _a === void 0 ? void 0 : _a.file_zip;
116
- if (!path)
117
- return [2 /*return*/];
118
- return [2 /*return*/, new URL(!path.startsWith('/') ? "".concat(this.zip_origin, "/").concat(path) : "".concat(this.zip_origin).concat(path))];
119
- });
120
- });
121
- };
122
- return HttpRegistry;
123
- }());
124
- export { HttpRegistry };
@@ -1,4 +0,0 @@
1
- export * from './default_registry_mgr';
2
- export * from './http_registry';
3
- export * from './registry_mgr';
4
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/registry/index.ts"],"names":[],"mappings":"AAAA,cAAc,wBAAwB,CAAA;AACtC,cAAc,iBAAiB,CAAA;AAC/B,cAAc,gBAAgB,CAAA"}
@@ -1,3 +0,0 @@
1
- export * from './default_registry_mgr';
2
- export * from './http_registry';
3
- export * from './registry_mgr';
@@ -1,8 +0,0 @@
1
- import type { ModuleResolver } from '@modular-circuit/ir';
2
- export interface RegistryMgr extends ModuleResolver {
3
- /**
4
- * 获取所有可用的Registry
5
- */
6
- get_available_registries(): Promise<ModuleResolver[]>;
7
- }
8
- //# sourceMappingURL=registry_mgr.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"registry_mgr.d.ts","sourceRoot":"","sources":["../../src/registry/registry_mgr.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAA;AAEzD,MAAM,WAAW,WAAY,SAAQ,cAAc;IACjD;;OAEG;IACH,wBAAwB,IAAI,OAAO,CAAC,cAAc,EAAE,CAAC,CAAA;CACtD"}
File without changes
@@ -1 +0,0 @@
1
- {"root":["../src/index.ts","../src/bom/bom_match.ts","../src/bom/index.ts","../src/mock/index.ts","../src/mock/module_circuits/index.ts","../src/mock/module_circuits_categories/index.ts","../src/registry/default_registry_mgr.ts","../src/registry/http_registry.ts","../src/registry/index.ts","../src/registry/registry_mgr.ts","../src/utils/index.ts"],"version":"5.8.3"}
@@ -1,3 +0,0 @@
1
- export declare const fmt_parameter_to_url: (params: unknown) => string;
2
- export declare function do_fetch(url: URL, params: unknown): Promise<Response>;
3
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,oBAAoB,GAAI,QAAQ,OAAO,WAInD,CAAA;AAED,wBAAgB,QAAQ,CAAC,GAAG,EAAE,GAAG,EAAE,MAAM,EAAE,OAAO,qBAEjD"}
@@ -1,27 +0,0 @@
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
- };
17
- export var fmt_parameter_to_url = function (params) {
18
- return Object.entries(params)
19
- .map(function (_a) {
20
- var _b = __read(_a, 2), k = _b[0], v = _b[1];
21
- return "".concat(k, "=").concat(v);
22
- })
23
- .join('&');
24
- };
25
- export function do_fetch(url, params) {
26
- return fetch("".concat(url, "?").concat(fmt_parameter_to_url(params)));
27
- }