@modular-circuit/middleware 0.0.35 → 0.0.39

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.
@@ -6,7 +6,9 @@ export declare class DefaultRegistryMgr implements RegistryMgr {
6
6
  private registries;
7
7
  constructor(http_registries: HttpConfig[]);
8
8
  get_available_registries(): Promise<ModuleResolver[]>;
9
- get_module_achieve(idx: ModuleIndex): Promise<URL | undefined>;
9
+ get_module_archive(idx: ModuleIndex): Promise<URL | undefined>;
10
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>;
11
13
  }
12
14
  //# sourceMappingURL=default_registry_mgr.d.ts.map
@@ -1 +1 @@
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;CASzE"}
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"}
@@ -71,13 +71,13 @@ var DefaultRegistryMgr = /** @class */ (function () {
71
71
  });
72
72
  });
73
73
  };
74
- DefaultRegistryMgr.prototype.get_module_achieve = function (idx) {
74
+ DefaultRegistryMgr.prototype.get_module_archive = function (idx) {
75
75
  var _this = this;
76
76
  return this.registries.reduce(function (prev, registry) { return __awaiter(_this, void 0, void 0, function () {
77
77
  var res, _a;
78
78
  return __generator(this, function (_b) {
79
79
  switch (_b.label) {
80
- case 0: return [4 /*yield*/, registry.get_module_achieve(idx)];
80
+ case 0: return [4 /*yield*/, registry.get_module_archive(idx)];
81
81
  case 1:
82
82
  res = _b.sent();
83
83
  if (!res) return [3 /*break*/, 2];
@@ -113,6 +113,48 @@ var DefaultRegistryMgr = /** @class */ (function () {
113
113
  });
114
114
  }); }, Promise.resolve(undefined));
115
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
+ };
116
158
  return DefaultRegistryMgr;
117
159
  }());
118
160
  export { DefaultRegistryMgr };
@@ -1,4 +1,4 @@
1
- import type { ModuleCircuit, ModuleResolver } from '@modular-circuit/ir';
1
+ import type { ModuleCircuit, ModuleResolver, RuntimeModuleCircuit } from '@modular-circuit/ir';
2
2
  import type { ModuleIndex } from '@modular-circuit/ir';
3
3
  export interface HttpResponse {
4
4
  code: number;
@@ -6,16 +6,19 @@ export interface HttpResponse {
6
6
  result: unknown;
7
7
  }
8
8
  export interface HttpConfig {
9
- module_achieve_url: URL;
9
+ module_archive_url: URL;
10
10
  module_circuit_url: URL;
11
11
  zip_origin?: string;
12
+ all_modules?: RuntimeModuleCircuit[];
12
13
  }
13
14
  export declare class HttpRegistry implements ModuleResolver {
14
15
  private cnf;
15
16
  private zip_origin;
16
17
  private module_caches;
17
18
  constructor(cnf: HttpConfig);
18
- get_module_achieve(idx: ModuleIndex): Promise<URL | undefined>;
19
+ get_module_archive(idx: ModuleIndex): Promise<URL | undefined>;
19
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>;
20
23
  }
21
24
  //# sourceMappingURL=http_registry.d.ts.map
@@ -1 +1 @@
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,MAAM,qBAAqB,CAAA;AACxE,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;CACpB;AACD,qBAAa,YAAa,YAAW,cAAc;IAG9B,OAAO,CAAC,GAAG;IAF9B,OAAO,CAAC,UAAU,CAAQ;IAC1B,OAAO,CAAC,aAAa,CAAoC;gBAC9B,GAAG,EAAE,UAAU;IAGpC,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;CAQ/E"}
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"}
@@ -34,21 +34,45 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
34
34
  if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
35
35
  }
36
36
  };
37
- import { stringify_dependency } from '@modular-circuit/utils';
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
+ };
38
48
  import { do_fetch } from '../utils';
39
49
  var HttpRegistry = /** @class */ (function () {
40
50
  function HttpRegistry(cnf) {
41
- var _a;
51
+ var e_1, _a;
52
+ var _b, _c;
42
53
  this.cnf = cnf;
43
54
  this.module_caches = {};
44
- this.zip_origin = (_a = cnf.zip_origin) !== null && _a !== void 0 ? _a : cnf.module_achieve_url.origin;
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
+ }
45
69
  }
46
- HttpRegistry.prototype.get_module_achieve = function (idx) {
70
+ HttpRegistry.prototype.get_module_archive = function (idx) {
47
71
  return __awaiter(this, void 0, void 0, function () {
48
72
  var it, pp, full;
49
73
  return __generator(this, function (_a) {
50
74
  switch (_a.label) {
51
- case 0: return [4 /*yield*/, do_fetch(this.cnf.module_achieve_url, idx)];
75
+ case 0: return [4 /*yield*/, do_fetch(this.cnf.module_archive_url, idx)];
52
76
  case 1:
53
77
  it = _a.sent();
54
78
  return [4 /*yield*/, it.json()];
@@ -64,14 +88,10 @@ var HttpRegistry = /** @class */ (function () {
64
88
  };
65
89
  HttpRegistry.prototype.get_module_circuit = function (idx) {
66
90
  return __awaiter(this, void 0, void 0, function () {
67
- var module_idx, it;
91
+ var it;
68
92
  return __generator(this, function (_a) {
69
93
  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)];
94
+ case 0: return [4 /*yield*/, do_fetch(this.cnf.module_circuit_url, idx)];
75
95
  case 1:
76
96
  it = _a.sent();
77
97
  return [4 /*yield*/, it.json()];
@@ -80,6 +100,25 @@ var HttpRegistry = /** @class */ (function () {
80
100
  });
81
101
  });
82
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
+ };
83
122
  return HttpRegistry;
84
123
  }());
85
124
  export { HttpRegistry };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@modular-circuit/middleware",
3
- "version": "0.0.35",
3
+ "version": "0.0.39",
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.61",
28
- "@modular-circuit/utils": "0.0.40"
27
+ "@modular-circuit/ir": "0.0.63",
28
+ "@modular-circuit/utils": "0.0.41"
29
29
  },
30
30
  "scripts": {
31
31
  "clean": "rimraf build",