@modular-circuit/middleware 0.0.33 → 0.0.35

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,3 +1,3 @@
1
- const Test_Module_A = import('./test_module_a.json');
2
- const Test_Module_B = import('./test_module_b.json');
1
+ var Test_Module_A = import('./test_module_a.json');
2
+ var Test_Module_B = import('./test_module_b.json');
3
3
  export { Test_Module_A, Test_Module_B };
@@ -1,2 +1,2 @@
1
- const Categories = import('./categories.json');
1
+ var Categories = import('./categories.json');
2
2
  export { Categories };
@@ -1,24 +1,118 @@
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
+ };
1
48
  import { HttpRegistry } from './http_registry';
2
- export class DefaultRegistryMgr {
3
- registries = [];
4
- constructor(http_registries) {
5
- for (const cnf of http_registries) {
6
- this.registries.push(new HttpRegistry(cnf));
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; }
7
65
  }
8
66
  }
9
- async get_available_registries() {
10
- return this.registries;
11
- }
12
- get_module_achieve(idx) {
13
- return this.registries.reduce(async (prev, registry) => {
14
- const res = await registry.get_module_achieve(idx);
15
- return res ? res : await prev;
16
- }, Promise.resolve(undefined));
17
- }
18
- get_module_circuit(idx) {
19
- return this.registries.reduce(async (prev, registry) => {
20
- const res = await registry.get_module_circuit(idx);
21
- return res ? res : await prev;
22
- }, Promise.resolve(undefined));
23
- }
24
- }
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_achieve = 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_achieve(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
+ return DefaultRegistryMgr;
117
+ }());
118
+ export { DefaultRegistryMgr };
@@ -1,26 +1,85 @@
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
+ };
1
37
  import { stringify_dependency } from '@modular-circuit/utils';
2
38
  import { do_fetch } from '../utils';
3
- export class HttpRegistry {
4
- cnf;
5
- zip_origin;
6
- module_caches = {};
7
- constructor(cnf) {
39
+ var HttpRegistry = /** @class */ (function () {
40
+ function HttpRegistry(cnf) {
41
+ var _a;
8
42
  this.cnf = cnf;
9
- this.zip_origin = cnf.zip_origin ?? cnf.module_achieve_url.origin;
10
- }
11
- async get_module_achieve(idx) {
12
- const it = await do_fetch(this.cnf.module_achieve_url, idx);
13
- const pp = (await it.json()).result;
14
- if (!pp)
15
- return;
16
- const full = `${this.zip_origin}${pp}`;
17
- return new URL(full);
18
- }
19
- async get_module_circuit(idx) {
20
- const module_idx = stringify_dependency(idx);
21
- if (module_idx in this.module_caches)
22
- return this.module_caches[module_idx];
23
- const it = await do_fetch(this.cnf.module_circuit_url, idx);
24
- return (await it.json()).result;
43
+ this.module_caches = {};
44
+ this.zip_origin = (_a = cnf.zip_origin) !== null && _a !== void 0 ? _a : cnf.module_achieve_url.origin;
25
45
  }
26
- }
46
+ HttpRegistry.prototype.get_module_achieve = function (idx) {
47
+ return __awaiter(this, void 0, void 0, function () {
48
+ var it, pp, full;
49
+ return __generator(this, function (_a) {
50
+ switch (_a.label) {
51
+ case 0: return [4 /*yield*/, do_fetch(this.cnf.module_achieve_url, idx)];
52
+ case 1:
53
+ it = _a.sent();
54
+ return [4 /*yield*/, it.json()];
55
+ case 2:
56
+ pp = (_a.sent()).result;
57
+ if (!pp)
58
+ return [2 /*return*/];
59
+ full = "".concat(this.zip_origin).concat(pp);
60
+ return [2 /*return*/, new URL(full)];
61
+ }
62
+ });
63
+ });
64
+ };
65
+ HttpRegistry.prototype.get_module_circuit = function (idx) {
66
+ return __awaiter(this, void 0, void 0, function () {
67
+ var module_idx, it;
68
+ return __generator(this, function (_a) {
69
+ switch (_a.label) {
70
+ case 0:
71
+ module_idx = stringify_dependency(idx);
72
+ if (module_idx in this.module_caches)
73
+ return [2 /*return*/, this.module_caches[module_idx]];
74
+ return [4 /*yield*/, do_fetch(this.cnf.module_circuit_url, idx)];
75
+ case 1:
76
+ it = _a.sent();
77
+ return [4 /*yield*/, it.json()];
78
+ case 2: return [2 /*return*/, (_a.sent()).result];
79
+ }
80
+ });
81
+ });
82
+ };
83
+ return HttpRegistry;
84
+ }());
85
+ export { HttpRegistry };
@@ -1,8 +1,27 @@
1
- export const fmt_parameter_to_url = (params) => {
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) {
2
18
  return Object.entries(params)
3
- .map(([k, v]) => `${k}=${v}`)
19
+ .map(function (_a) {
20
+ var _b = __read(_a, 2), k = _b[0], v = _b[1];
21
+ return "".concat(k, "=").concat(v);
22
+ })
4
23
  .join('&');
5
24
  };
6
25
  export function do_fetch(url, params) {
7
- return fetch(`${url}?${fmt_parameter_to_url(params)}`);
26
+ return fetch("".concat(url, "?").concat(fmt_parameter_to_url(params)));
8
27
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@modular-circuit/middleware",
3
- "version": "0.0.33",
3
+ "version": "0.0.35",
4
4
  "description": "Intermediate representation of the modular circuit",
5
5
  "main": "./build/index.js",
6
6
  "exports": {
@@ -24,8 +24,8 @@
24
24
  "typescript": "^5.4.5"
25
25
  },
26
26
  "dependencies": {
27
- "@modular-circuit/ir": "0.0.59",
28
- "@modular-circuit/utils": "0.0.38"
27
+ "@modular-circuit/ir": "0.0.61",
28
+ "@modular-circuit/utils": "0.0.40"
29
29
  },
30
30
  "scripts": {
31
31
  "clean": "rimraf build",