@contember/engine-common 1.4.0-rc.8 → 2.0.0-alpha.8
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/dist/development/index.cjs +11 -0
- package/dist/development/index.cjs.map +1 -0
- package/dist/development/index.js +11 -0
- package/dist/development/index.js.map +1 -0
- package/dist/development/src/MigrationVersionHelper.cjs +36 -0
- package/dist/development/src/MigrationVersionHelper.cjs.map +1 -0
- package/dist/development/src/MigrationVersionHelper.js +36 -0
- package/dist/development/src/MigrationVersionHelper.js.map +1 -0
- package/dist/development/src/eventEmitter/events.cjs +26 -0
- package/dist/development/src/eventEmitter/events.cjs.map +1 -0
- package/dist/development/src/eventEmitter/events.js +26 -0
- package/dist/development/src/eventEmitter/events.js.map +1 -0
- package/dist/development/src/runnable/Supervisor.cjs +70 -0
- package/dist/development/src/runnable/Supervisor.cjs.map +1 -0
- package/dist/development/src/runnable/Supervisor.js +70 -0
- package/dist/development/src/runnable/Supervisor.js.map +1 -0
- package/dist/development/src/runnable/utils.cjs +20 -0
- package/dist/development/src/runnable/utils.cjs.map +1 -0
- package/dist/development/src/runnable/utils.js +20 -0
- package/dist/development/src/runnable/utils.js.map +1 -0
- package/dist/development/src/utils/PromiseMap.cjs +20 -0
- package/dist/development/src/utils/PromiseMap.cjs.map +1 -0
- package/dist/development/src/utils/PromiseMap.js +20 -0
- package/dist/development/src/utils/PromiseMap.js.map +1 -0
- package/dist/production/index.cjs +11 -0
- package/dist/production/index.cjs.map +1 -0
- package/dist/production/index.js +11 -0
- package/dist/production/index.js.map +1 -0
- package/dist/production/src/MigrationVersionHelper.cjs +36 -0
- package/dist/production/src/MigrationVersionHelper.cjs.map +1 -0
- package/dist/production/src/MigrationVersionHelper.js +36 -0
- package/dist/production/src/MigrationVersionHelper.js.map +1 -0
- package/dist/production/src/eventEmitter/events.cjs +26 -0
- package/dist/production/src/eventEmitter/events.cjs.map +1 -0
- package/dist/production/src/eventEmitter/events.js +26 -0
- package/dist/production/src/eventEmitter/events.js.map +1 -0
- package/dist/production/src/runnable/Supervisor.cjs +70 -0
- package/dist/production/src/runnable/Supervisor.cjs.map +1 -0
- package/dist/production/src/runnable/Supervisor.js +70 -0
- package/dist/production/src/runnable/Supervisor.js.map +1 -0
- package/dist/production/src/runnable/utils.cjs +20 -0
- package/dist/production/src/runnable/utils.cjs.map +1 -0
- package/dist/production/src/runnable/utils.js +20 -0
- package/dist/production/src/runnable/utils.js.map +1 -0
- package/dist/production/src/utils/PromiseMap.cjs +20 -0
- package/dist/production/src/utils/PromiseMap.cjs.map +1 -0
- package/dist/production/src/utils/PromiseMap.js +20 -0
- package/dist/production/src/utils/PromiseMap.js.map +1 -0
- package/dist/{src → types}/runnable/utils.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -0
- package/package.json +22 -10
- package/src/tsconfig.json +1 -1
- package/vitest.config.ts +3 -0
- package/dist/src/MigrationVersionHelper.js +0 -45
- package/dist/src/MigrationVersionHelper.js.map +0 -1
- package/dist/src/eventEmitter/events.js +0 -27
- package/dist/src/eventEmitter/events.js.map +0 -1
- package/dist/src/index.js +0 -21
- package/dist/src/index.js.map +0 -1
- package/dist/src/runnable/Runnable.js +0 -3
- package/dist/src/runnable/Runnable.js.map +0 -1
- package/dist/src/runnable/Supervisor.js +0 -75
- package/dist/src/runnable/Supervisor.js.map +0 -1
- package/dist/src/runnable/index.js +0 -19
- package/dist/src/runnable/index.js.map +0 -1
- package/dist/src/runnable/utils.js +0 -21
- package/dist/src/runnable/utils.js.map +0 -1
- package/dist/src/tsconfig.tsbuildinfo +0 -1
- package/dist/src/utils/PromiseMap.js +0 -22
- package/dist/src/utils/PromiseMap.js.map +0 -1
- package/dist/src/utils/index.js +0 -18
- package/dist/src/utils/index.js.map +0 -1
- /package/dist/{src → types}/MigrationVersionHelper.d.ts +0 -0
- /package/dist/{src → types}/MigrationVersionHelper.d.ts.map +0 -0
- /package/dist/{src → types}/eventEmitter/events.d.ts +0 -0
- /package/dist/{src → types}/eventEmitter/events.d.ts.map +0 -0
- /package/dist/{src → types}/index.d.ts +0 -0
- /package/dist/{src → types}/index.d.ts.map +0 -0
- /package/dist/{src → types}/runnable/Runnable.d.ts +0 -0
- /package/dist/{src → types}/runnable/Runnable.d.ts.map +0 -0
- /package/dist/{src → types}/runnable/Supervisor.d.ts +0 -0
- /package/dist/{src → types}/runnable/Supervisor.d.ts.map +0 -0
- /package/dist/{src → types}/runnable/index.d.ts +0 -0
- /package/dist/{src → types}/runnable/index.d.ts.map +0 -0
- /package/dist/{src → types}/runnable/utils.d.ts +0 -0
- /package/dist/{src → types}/utils/PromiseMap.d.ts +0 -0
- /package/dist/{src → types}/utils/PromiseMap.d.ts.map +0 -0
- /package/dist/{src → types}/utils/index.d.ts +0 -0
- /package/dist/{src → types}/utils/index.d.ts.map +0 -0
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const PromiseMap = require("./src/utils/PromiseMap.cjs");
|
|
4
|
+
const Supervisor = require("./src/runnable/Supervisor.cjs");
|
|
5
|
+
const events = require("./src/eventEmitter/events.cjs");
|
|
6
|
+
const MigrationVersionHelper = require("./src/MigrationVersionHelper.cjs");
|
|
7
|
+
exports.PromiseMap = PromiseMap.PromiseMap;
|
|
8
|
+
exports.Supervisor = Supervisor.Supervisor;
|
|
9
|
+
exports.EventManager = events.EventManager;
|
|
10
|
+
exports.MigrationVersionHelper = MigrationVersionHelper.MigrationVersionHelper;
|
|
11
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { PromiseMap } from "./src/utils/PromiseMap.js";
|
|
2
|
+
import { Supervisor } from "./src/runnable/Supervisor.js";
|
|
3
|
+
import { EventManager } from "./src/eventEmitter/events.js";
|
|
4
|
+
import { MigrationVersionHelper } from "./src/MigrationVersionHelper.js";
|
|
5
|
+
export {
|
|
6
|
+
EventManager,
|
|
7
|
+
MigrationVersionHelper,
|
|
8
|
+
PromiseMap,
|
|
9
|
+
Supervisor
|
|
10
|
+
};
|
|
11
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
5
|
+
var __publicField = (obj, key, value) => __defNormalProp(obj, key + "", value);
|
|
6
|
+
const _MigrationVersionHelper = class _MigrationVersionHelper2 {
|
|
7
|
+
static extractVersion(filename) {
|
|
8
|
+
return filename.substring(0, this.prefixLength);
|
|
9
|
+
}
|
|
10
|
+
static createVersion(name, increment = 0) {
|
|
11
|
+
const normalizedName = _MigrationVersionHelper2.normalizeMigrationLabel(name);
|
|
12
|
+
const version = _MigrationVersionHelper2.createTimePrefix(increment);
|
|
13
|
+
return [version, `${version}-${normalizedName}`];
|
|
14
|
+
}
|
|
15
|
+
static extractName(filename) {
|
|
16
|
+
return filename.substring(0, filename.lastIndexOf("."));
|
|
17
|
+
}
|
|
18
|
+
static createTimePrefix(increment) {
|
|
19
|
+
const now = /* @__PURE__ */ new Date();
|
|
20
|
+
now.setSeconds(now.getSeconds() + increment);
|
|
21
|
+
const year = now.getFullYear();
|
|
22
|
+
const month = (now.getMonth() + 1).toString().padStart(2, "0");
|
|
23
|
+
const day = now.getDate().toString().padStart(2, "0");
|
|
24
|
+
const hours = now.getHours().toString().padStart(2, "0");
|
|
25
|
+
const minutes = now.getMinutes().toString().padStart(2, "0");
|
|
26
|
+
const seconds = now.getSeconds().toString().padStart(2, "0");
|
|
27
|
+
return `${year}-${month}-${day}-${hours}${minutes}${seconds}`;
|
|
28
|
+
}
|
|
29
|
+
static normalizeMigrationLabel(name) {
|
|
30
|
+
return name.toLowerCase().replace(/[^a-z0-9]+/g, "-");
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
__publicField(_MigrationVersionHelper, "prefixLength", "YYYY-MM-DD-HHIISS".length);
|
|
34
|
+
let MigrationVersionHelper = _MigrationVersionHelper;
|
|
35
|
+
exports.MigrationVersionHelper = MigrationVersionHelper;
|
|
36
|
+
//# sourceMappingURL=MigrationVersionHelper.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MigrationVersionHelper.cjs","sources":["../../../../packages/engine-common/src/MigrationVersionHelper.ts"],"sourcesContent":["export class MigrationVersionHelper {\n\tpublic static prefixLength = 'YYYY-MM-DD-HHIISS'.length\n\n\tpublic static extractVersion(filename: string): string {\n\t\treturn filename.substring(0, this.prefixLength)\n\t}\n\n\tpublic static createVersion(name: string, increment: number = 0): [string, string] {\n\t\tconst normalizedName = MigrationVersionHelper.normalizeMigrationLabel(name)\n\t\tconst version = MigrationVersionHelper.createTimePrefix(increment)\n\t\treturn [version, `${version}-${normalizedName}`]\n\t}\n\n\tpublic static extractName(filename: string): string {\n\t\treturn filename.substring(0, filename.lastIndexOf('.'))\n\t}\n\n\tprivate static createTimePrefix(increment: number): string {\n\t\tconst now = new Date()\n\t\tnow.setSeconds(now.getSeconds() + increment)\n\t\tconst year = now.getFullYear()\n\t\tconst month = (now.getMonth() + 1).toString().padStart(2, '0')\n\t\tconst day = now //\n\t\t\t.getDate()\n\t\t\t.toString()\n\t\t\t.padStart(2, '0')\n\t\tconst hours = now //\n\t\t\t.getHours()\n\t\t\t.toString()\n\t\t\t.padStart(2, '0')\n\t\tconst minutes = now //\n\t\t\t.getMinutes()\n\t\t\t.toString()\n\t\t\t.padStart(2, '0')\n\t\tconst seconds = now //\n\t\t\t.getSeconds()\n\t\t\t.toString()\n\t\t\t.padStart(2, '0')\n\n\t\treturn `${year}-${month}-${day}-${hours}${minutes}${seconds}`\n\t}\n\n\tprivate static normalizeMigrationLabel(name: string) {\n\t\treturn name.toLowerCase().replace(/[^a-z0-9]+/g, '-')\n\t}\n}\n"],"names":["_MigrationVersionHelper"],"mappings":";;;;;AAAO,MAAM,0BAAN,MAAMA,yBAAuB;AAAA,EAGnC,OAAc,eAAe,UAA0B;AACtD,WAAO,SAAS,UAAU,GAAG,KAAK,YAAY;AAAA,EAC/C;AAAA,EAEA,OAAc,cAAc,MAAc,YAAoB,GAAqB;AAC5E,UAAA,iBAAiBA,yBAAuB,wBAAwB,IAAI;AACpE,UAAA,UAAUA,yBAAuB,iBAAiB,SAAS;AACjE,WAAO,CAAC,SAAS,GAAG,OAAO,IAAI,cAAc,EAAE;AAAA,EAChD;AAAA,EAEA,OAAc,YAAY,UAA0B;AACnD,WAAO,SAAS,UAAU,GAAG,SAAS,YAAY,GAAG,CAAC;AAAA,EACvD;AAAA,EAEA,OAAe,iBAAiB,WAA2B;AACpD,UAAA,0BAAU;AAChB,QAAI,WAAW,IAAI,WAAW,IAAI,SAAS;AACrC,UAAA,OAAO,IAAI;AACX,UAAA,SAAS,IAAI,aAAa,GAAG,SAAS,EAAE,SAAS,GAAG,GAAG;AACvD,UAAA,MAAM,IACV,QAAQ,EACR,WACA,SAAS,GAAG,GAAG;AACX,UAAA,QAAQ,IACZ,SAAS,EACT,WACA,SAAS,GAAG,GAAG;AACX,UAAA,UAAU,IACd,WAAW,EACX,WACA,SAAS,GAAG,GAAG;AACX,UAAA,UAAU,IACd,WAAW,EACX,WACA,SAAS,GAAG,GAAG;AAEV,WAAA,GAAG,IAAI,IAAI,KAAK,IAAI,GAAG,IAAI,KAAK,GAAG,OAAO,GAAG,OAAO;AAAA,EAC5D;AAAA,EAEA,OAAe,wBAAwB,MAAc;AACpD,WAAO,KAAK,YAAc,EAAA,QAAQ,eAAe,GAAG;AAAA,EACrD;AACD;AA5CC,cADY,yBACE,gBAAe,oBAAoB,MAAA;AAD3C,IAAM,yBAAN;;"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
3
|
+
var __publicField = (obj, key, value) => __defNormalProp(obj, key + "", value);
|
|
4
|
+
const _MigrationVersionHelper = class _MigrationVersionHelper2 {
|
|
5
|
+
static extractVersion(filename) {
|
|
6
|
+
return filename.substring(0, this.prefixLength);
|
|
7
|
+
}
|
|
8
|
+
static createVersion(name, increment = 0) {
|
|
9
|
+
const normalizedName = _MigrationVersionHelper2.normalizeMigrationLabel(name);
|
|
10
|
+
const version = _MigrationVersionHelper2.createTimePrefix(increment);
|
|
11
|
+
return [version, `${version}-${normalizedName}`];
|
|
12
|
+
}
|
|
13
|
+
static extractName(filename) {
|
|
14
|
+
return filename.substring(0, filename.lastIndexOf("."));
|
|
15
|
+
}
|
|
16
|
+
static createTimePrefix(increment) {
|
|
17
|
+
const now = /* @__PURE__ */ new Date();
|
|
18
|
+
now.setSeconds(now.getSeconds() + increment);
|
|
19
|
+
const year = now.getFullYear();
|
|
20
|
+
const month = (now.getMonth() + 1).toString().padStart(2, "0");
|
|
21
|
+
const day = now.getDate().toString().padStart(2, "0");
|
|
22
|
+
const hours = now.getHours().toString().padStart(2, "0");
|
|
23
|
+
const minutes = now.getMinutes().toString().padStart(2, "0");
|
|
24
|
+
const seconds = now.getSeconds().toString().padStart(2, "0");
|
|
25
|
+
return `${year}-${month}-${day}-${hours}${minutes}${seconds}`;
|
|
26
|
+
}
|
|
27
|
+
static normalizeMigrationLabel(name) {
|
|
28
|
+
return name.toLowerCase().replace(/[^a-z0-9]+/g, "-");
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
__publicField(_MigrationVersionHelper, "prefixLength", "YYYY-MM-DD-HHIISS".length);
|
|
32
|
+
let MigrationVersionHelper = _MigrationVersionHelper;
|
|
33
|
+
export {
|
|
34
|
+
MigrationVersionHelper
|
|
35
|
+
};
|
|
36
|
+
//# sourceMappingURL=MigrationVersionHelper.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MigrationVersionHelper.js","sources":["../../../../packages/engine-common/src/MigrationVersionHelper.ts"],"sourcesContent":["export class MigrationVersionHelper {\n\tpublic static prefixLength = 'YYYY-MM-DD-HHIISS'.length\n\n\tpublic static extractVersion(filename: string): string {\n\t\treturn filename.substring(0, this.prefixLength)\n\t}\n\n\tpublic static createVersion(name: string, increment: number = 0): [string, string] {\n\t\tconst normalizedName = MigrationVersionHelper.normalizeMigrationLabel(name)\n\t\tconst version = MigrationVersionHelper.createTimePrefix(increment)\n\t\treturn [version, `${version}-${normalizedName}`]\n\t}\n\n\tpublic static extractName(filename: string): string {\n\t\treturn filename.substring(0, filename.lastIndexOf('.'))\n\t}\n\n\tprivate static createTimePrefix(increment: number): string {\n\t\tconst now = new Date()\n\t\tnow.setSeconds(now.getSeconds() + increment)\n\t\tconst year = now.getFullYear()\n\t\tconst month = (now.getMonth() + 1).toString().padStart(2, '0')\n\t\tconst day = now //\n\t\t\t.getDate()\n\t\t\t.toString()\n\t\t\t.padStart(2, '0')\n\t\tconst hours = now //\n\t\t\t.getHours()\n\t\t\t.toString()\n\t\t\t.padStart(2, '0')\n\t\tconst minutes = now //\n\t\t\t.getMinutes()\n\t\t\t.toString()\n\t\t\t.padStart(2, '0')\n\t\tconst seconds = now //\n\t\t\t.getSeconds()\n\t\t\t.toString()\n\t\t\t.padStart(2, '0')\n\n\t\treturn `${year}-${month}-${day}-${hours}${minutes}${seconds}`\n\t}\n\n\tprivate static normalizeMigrationLabel(name: string) {\n\t\treturn name.toLowerCase().replace(/[^a-z0-9]+/g, '-')\n\t}\n}\n"],"names":["_MigrationVersionHelper"],"mappings":";;;AAAO,MAAM,0BAAN,MAAMA,yBAAuB;AAAA,EAGnC,OAAc,eAAe,UAA0B;AACtD,WAAO,SAAS,UAAU,GAAG,KAAK,YAAY;AAAA,EAC/C;AAAA,EAEA,OAAc,cAAc,MAAc,YAAoB,GAAqB;AAC5E,UAAA,iBAAiBA,yBAAuB,wBAAwB,IAAI;AACpE,UAAA,UAAUA,yBAAuB,iBAAiB,SAAS;AACjE,WAAO,CAAC,SAAS,GAAG,OAAO,IAAI,cAAc,EAAE;AAAA,EAChD;AAAA,EAEA,OAAc,YAAY,UAA0B;AACnD,WAAO,SAAS,UAAU,GAAG,SAAS,YAAY,GAAG,CAAC;AAAA,EACvD;AAAA,EAEA,OAAe,iBAAiB,WAA2B;AACpD,UAAA,0BAAU;AAChB,QAAI,WAAW,IAAI,WAAW,IAAI,SAAS;AACrC,UAAA,OAAO,IAAI;AACX,UAAA,SAAS,IAAI,aAAa,GAAG,SAAS,EAAE,SAAS,GAAG,GAAG;AACvD,UAAA,MAAM,IACV,QAAQ,EACR,WACA,SAAS,GAAG,GAAG;AACX,UAAA,QAAQ,IACZ,SAAS,EACT,WACA,SAAS,GAAG,GAAG;AACX,UAAA,UAAU,IACd,WAAW,EACX,WACA,SAAS,GAAG,GAAG;AACX,UAAA,UAAU,IACd,WAAW,EACX,WACA,SAAS,GAAG,GAAG;AAEV,WAAA,GAAG,IAAI,IAAI,KAAK,IAAI,GAAG,IAAI,KAAK,GAAG,OAAO,GAAG,OAAO;AAAA,EAC5D;AAAA,EAEA,OAAe,wBAAwB,MAAc;AACpD,WAAO,KAAK,YAAc,EAAA,QAAQ,eAAe,GAAG;AAAA,EACrD;AACD;AA5CC,cADY,yBACE,gBAAe,oBAAoB,MAAA;AAD3C,IAAM,yBAAN;"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
5
|
+
var __publicField = (obj, key, value) => __defNormalProp(obj, key + "", value);
|
|
6
|
+
class EventManager {
|
|
7
|
+
constructor() {
|
|
8
|
+
__publicField(this, "listeners", {});
|
|
9
|
+
}
|
|
10
|
+
on(event, cb) {
|
|
11
|
+
var _a;
|
|
12
|
+
((_a = this.listeners)[event] ?? (_a[event] = [])).push(cb);
|
|
13
|
+
return () => {
|
|
14
|
+
return this.listeners[event] = this.listeners[event]?.filter((it) => it !== cb);
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
fire(event, args) {
|
|
18
|
+
const result = [];
|
|
19
|
+
for (const cb of this.listeners[event] ?? []) {
|
|
20
|
+
result.push(cb(args));
|
|
21
|
+
}
|
|
22
|
+
return result;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
exports.EventManager = EventManager;
|
|
26
|
+
//# sourceMappingURL=events.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"events.cjs","sources":["../../../../../packages/engine-common/src/eventEmitter/events.ts"],"sourcesContent":["export type EventMap = {\n\t[name: string]: (arg: any) => any\n}\n\nexport type EventUnlisten = () => void\n\nexport interface EventEmitter<E extends EventMap> {\n\ton<K extends keyof E>(event: K, cb: E[K]): EventUnlisten\n}\n\nexport class EventManager<E extends EventMap> implements EventEmitter<E> {\n\tprivate listeners: {\n\t\t[K in keyof E]?: E[K][]\n\t} = {}\n\n\tpublic on<K extends keyof E>(event: K, cb: E[K]): EventUnlisten {\n\t\t(this.listeners[event] ??= []).push(cb)\n\t\treturn () => {\n\t\t\treturn this.listeners[event] = this.listeners[event]?.filter(it => it !== cb)\n\t\t}\n\t}\n\n\tpublic fire<K extends keyof E>(event: K, args: Parameters<E[K]>[0]): ReturnType<E[K]>[] {\n\t\tconst result: ReturnType<E[K]>[] = []\n\t\tfor (const cb of this.listeners[event] ?? []) {\n\t\t\tresult.push(cb(args))\n\t\t}\n\t\treturn result\n\t}\n}\n"],"names":[],"mappings":";;;;;AAUO,MAAM,aAA4D;AAAA,EAAlE,cAAA;AACN,kBAAA,MAAQ,aAEJ,CAAA,CAAC;AAAA,EAAA;AAAA,EAEE,GAAsB,OAAU,IAAyB;AAfjE,QAAA;AAgBE,MAAC,UAAK,WAAL,KAAA,MAAA,GAAA,KAAA,IAA0B,CAAC,IAAG,KAAK,EAAE;AACtC,WAAO,MAAM;AACL,aAAA,KAAK,UAAU,KAAK,IAAI,KAAK,UAAU,KAAK,GAAG,OAAO,CAAM,OAAA,OAAO,EAAE;AAAA,IAAA;AAAA,EAE9E;AAAA,EAEO,KAAwB,OAAU,MAA+C;AACvF,UAAM,SAA6B,CAAA;AACnC,eAAW,MAAM,KAAK,UAAU,KAAK,KAAK,CAAA,GAAI;AACtC,aAAA,KAAK,GAAG,IAAI,CAAC;AAAA,IACrB;AACO,WAAA;AAAA,EACR;AACD;;"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
3
|
+
var __publicField = (obj, key, value) => __defNormalProp(obj, key + "", value);
|
|
4
|
+
class EventManager {
|
|
5
|
+
constructor() {
|
|
6
|
+
__publicField(this, "listeners", {});
|
|
7
|
+
}
|
|
8
|
+
on(event, cb) {
|
|
9
|
+
var _a;
|
|
10
|
+
((_a = this.listeners)[event] ?? (_a[event] = [])).push(cb);
|
|
11
|
+
return () => {
|
|
12
|
+
return this.listeners[event] = this.listeners[event]?.filter((it) => it !== cb);
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
fire(event, args) {
|
|
16
|
+
const result = [];
|
|
17
|
+
for (const cb of this.listeners[event] ?? []) {
|
|
18
|
+
result.push(cb(args));
|
|
19
|
+
}
|
|
20
|
+
return result;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
export {
|
|
24
|
+
EventManager
|
|
25
|
+
};
|
|
26
|
+
//# sourceMappingURL=events.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"events.js","sources":["../../../../../packages/engine-common/src/eventEmitter/events.ts"],"sourcesContent":["export type EventMap = {\n\t[name: string]: (arg: any) => any\n}\n\nexport type EventUnlisten = () => void\n\nexport interface EventEmitter<E extends EventMap> {\n\ton<K extends keyof E>(event: K, cb: E[K]): EventUnlisten\n}\n\nexport class EventManager<E extends EventMap> implements EventEmitter<E> {\n\tprivate listeners: {\n\t\t[K in keyof E]?: E[K][]\n\t} = {}\n\n\tpublic on<K extends keyof E>(event: K, cb: E[K]): EventUnlisten {\n\t\t(this.listeners[event] ??= []).push(cb)\n\t\treturn () => {\n\t\t\treturn this.listeners[event] = this.listeners[event]?.filter(it => it !== cb)\n\t\t}\n\t}\n\n\tpublic fire<K extends keyof E>(event: K, args: Parameters<E[K]>[0]): ReturnType<E[K]>[] {\n\t\tconst result: ReturnType<E[K]>[] = []\n\t\tfor (const cb of this.listeners[event] ?? []) {\n\t\t\tresult.push(cb(args))\n\t\t}\n\t\treturn result\n\t}\n}\n"],"names":[],"mappings":";;;AAUO,MAAM,aAA4D;AAAA,EAAlE,cAAA;AACN,kBAAA,MAAQ,aAEJ,CAAA,CAAC;AAAA,EAAA;AAAA,EAEE,GAAsB,OAAU,IAAyB;AAfjE,QAAA;AAgBE,MAAC,UAAK,WAAL,KAAA,MAAA,GAAA,KAAA,IAA0B,CAAC,IAAG,KAAK,EAAE;AACtC,WAAO,MAAM;AACL,aAAA,KAAK,UAAU,KAAK,IAAI,KAAK,UAAU,KAAK,GAAG,OAAO,CAAM,OAAA,OAAO,EAAE;AAAA,IAAA;AAAA,EAE9E;AAAA,EAEO,KAAwB,OAAU,MAA+C;AACvF,UAAM,SAA6B,CAAA;AACnC,eAAW,MAAM,KAAK,UAAU,KAAK,KAAK,CAAA,GAAI;AACtC,aAAA,KAAK,GAAG,IAAI,CAAC;AAAA,IACrB;AACO,WAAA;AAAA,EACR;AACD;"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const utils = require("./utils.cjs");
|
|
4
|
+
class Supervisor {
|
|
5
|
+
constructor(runnable, options = {}) {
|
|
6
|
+
this.runnable = runnable;
|
|
7
|
+
this.options = options;
|
|
8
|
+
}
|
|
9
|
+
async run(args) {
|
|
10
|
+
const { logger, onError } = args;
|
|
11
|
+
let restartCount = 0;
|
|
12
|
+
const abortController = new AbortController();
|
|
13
|
+
let innerRunning;
|
|
14
|
+
let wasHealthy = false;
|
|
15
|
+
await new Promise(async (resolve, reject) => {
|
|
16
|
+
while (!abortController.signal.aborted) {
|
|
17
|
+
try {
|
|
18
|
+
await new Promise(async (resolveRunning, rejectRunning) => {
|
|
19
|
+
try {
|
|
20
|
+
innerRunning = await this.runnable.run({
|
|
21
|
+
onClose: resolveRunning,
|
|
22
|
+
onError: rejectRunning,
|
|
23
|
+
logger: logger.child({ runningId: Math.random().toString().substring(2) })
|
|
24
|
+
});
|
|
25
|
+
restartCount = 0;
|
|
26
|
+
resolve();
|
|
27
|
+
wasHealthy = true;
|
|
28
|
+
} catch (e) {
|
|
29
|
+
rejectRunning(e);
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
} catch (e) {
|
|
33
|
+
innerRunning = void 0;
|
|
34
|
+
const shouldRestart = wasHealthy ? this.options.max === void 0 || restartCount++ < this.options.max : restartCount++ < (this.options.startupMax ?? 10);
|
|
35
|
+
if (shouldRestart) {
|
|
36
|
+
const timeoutMs = Math.ceil(Math.min(
|
|
37
|
+
Math.pow(this.options.exponentiationBase ?? 2, restartCount - 1) * (this.options.minBackoff ?? 1e3),
|
|
38
|
+
this.options.maxBackoff ?? 6e4
|
|
39
|
+
));
|
|
40
|
+
logger.error(`Runnable crashed, restarting in ${timeoutMs} ms ...`, {
|
|
41
|
+
error: e
|
|
42
|
+
});
|
|
43
|
+
await utils.abortableTimeout(timeoutMs, abortController.signal);
|
|
44
|
+
if (!abortController.signal.aborted) {
|
|
45
|
+
logger.info(`Restarting runnable now`);
|
|
46
|
+
}
|
|
47
|
+
} else {
|
|
48
|
+
logger.error(`Runnable crashed, stopping`, {
|
|
49
|
+
error: e
|
|
50
|
+
});
|
|
51
|
+
if (wasHealthy) {
|
|
52
|
+
onError(e);
|
|
53
|
+
} else {
|
|
54
|
+
reject(e);
|
|
55
|
+
}
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
return {
|
|
62
|
+
async end() {
|
|
63
|
+
abortController.abort();
|
|
64
|
+
await innerRunning?.end();
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
exports.Supervisor = Supervisor;
|
|
70
|
+
//# sourceMappingURL=Supervisor.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Supervisor.cjs","sources":["../../../../../packages/engine-common/src/runnable/Supervisor.ts"],"sourcesContent":["import { Runnable, RunnableArgs, Running } from './Runnable'\nimport { abortableTimeout } from './utils'\n\nexport type SupervisorOptions = {\n\tmax?: number\n\tstartupMax?: number\n\tminBackoff?: number\n\tmaxBackoff?: number\n\texponentiationBase?: number\n}\n\nexport class Supervisor implements Runnable {\n\tconstructor(\n\t\tprivate runnable: Runnable,\n\t\tprivate options: SupervisorOptions = {},\n\t) {\n\t}\n\n\tpublic async run(args: RunnableArgs): Promise<Running> {\n\t\tconst { logger, onError } = args\n\t\tlet restartCount = 0\n\t\tconst abortController = new AbortController()\n\t\tlet innerRunning: Running | undefined\n\t\tlet wasHealthy = false\n\n\t\tawait new Promise<void>(async (resolve, reject) => {\n\t\t\twhile (!abortController.signal.aborted) {\n\t\t\t\ttry {\n\t\t\t\t\tawait new Promise<void>(async (resolveRunning, rejectRunning) => {\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\tinnerRunning = await this.runnable.run({\n\t\t\t\t\t\t\t\tonClose: resolveRunning,\n\t\t\t\t\t\t\t\tonError: rejectRunning,\n\t\t\t\t\t\t\t\tlogger: logger.child({ runningId: Math.random().toString().substring(2) }),\n\t\t\t\t\t\t\t})\n\t\t\t\t\t\t\trestartCount = 0\n\t\t\t\t\t\t\tresolve()\n\t\t\t\t\t\t\twasHealthy = true\n\t\t\t\t\t\t} catch (e) {\n\t\t\t\t\t\t\trejectRunning(e)\n\t\t\t\t\t\t}\n\t\t\t\t\t})\n\t\t\t\t} catch (e) {\n\t\t\t\t\tinnerRunning = undefined\n\t\t\t\t\tconst shouldRestart = wasHealthy\n\t\t\t\t\t\t? (this.options.max === undefined || restartCount++ < this.options.max)\n\t\t\t\t\t\t: (restartCount++ < (this.options.startupMax ?? 10))\n\t\t\t\t\tif (shouldRestart) {\n\t\t\t\t\t\tconst timeoutMs = Math.ceil(Math.min(\n\t\t\t\t\t\t\tMath.pow(this.options.exponentiationBase ?? 2, restartCount - 1) * (this.options.minBackoff ?? 1_000),\n\t\t\t\t\t\t\tthis.options.maxBackoff ?? 60_000,\n\t\t\t\t\t\t))\n\t\t\t\t\t\tlogger.error(`Runnable crashed, restarting in ${timeoutMs} ms ...`, {\n\t\t\t\t\t\t\terror: e,\n\t\t\t\t\t\t})\n\t\t\t\t\t\tawait abortableTimeout(timeoutMs, abortController.signal)\n\t\t\t\t\t\tif (!abortController.signal.aborted) {\n\t\t\t\t\t\t\tlogger.info(`Restarting runnable now`)\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\tlogger.error(`Runnable crashed, stopping`, {\n\t\t\t\t\t\t\terror: e,\n\t\t\t\t\t\t})\n\t\t\t\t\t\tif (wasHealthy) {\n\t\t\t\t\t\t\tonError(e)\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\treject(e)\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t})\n\n\t\treturn {\n\t\t\tasync end(): Promise<void> {\n\t\t\t\tabortController.abort()\n\t\t\t\tawait innerRunning?.end()\n\t\t\t},\n\t\t}\n\t}\n}\n"],"names":["abortableTimeout"],"mappings":";;;AAWO,MAAM,WAA+B;AAAA,EAC3C,YACS,UACA,UAA6B,IACpC;AAFO,SAAA,WAAA;AACA,SAAA,UAAA;AAAA,EAET;AAAA,EAEA,MAAa,IAAI,MAAsC;AAChD,UAAA,EAAE,QAAQ,QAAY,IAAA;AAC5B,QAAI,eAAe;AACb,UAAA,kBAAkB,IAAI;AACxB,QAAA;AACJ,QAAI,aAAa;AAEjB,UAAM,IAAI,QAAc,OAAO,SAAS,WAAW;AAC3C,aAAA,CAAC,gBAAgB,OAAO,SAAS;AACnC,YAAA;AACH,gBAAM,IAAI,QAAc,OAAO,gBAAgB,kBAAkB;AAC5D,gBAAA;AACY,6BAAA,MAAM,KAAK,SAAS,IAAI;AAAA,gBACtC,SAAS;AAAA,gBACT,SAAS;AAAA,gBACT,QAAQ,OAAO,MAAM,EAAE,WAAW,KAAK,OAAO,EAAE,SAAS,EAAE,UAAU,CAAC,GAAG;AAAA,cAAA,CACzE;AACc,6BAAA;AACP;AACK,2BAAA;AAAA,qBACL,GAAG;AACX,4BAAc,CAAC;AAAA,YAChB;AAAA,UAAA,CACA;AAAA,iBACO,GAAG;AACI,yBAAA;AACf,gBAAM,gBAAgB,aAClB,KAAK,QAAQ,QAAQ,UAAa,iBAAiB,KAAK,QAAQ,MAChE,kBAAkB,KAAK,QAAQ,cAAc;AACjD,cAAI,eAAe;AACZ,kBAAA,YAAY,KAAK,KAAK,KAAK;AAAA,cAChC,KAAK,IAAI,KAAK,QAAQ,sBAAsB,GAAG,eAAe,CAAC,KAAK,KAAK,QAAQ,cAAc;AAAA,cAC/F,KAAK,QAAQ,cAAc;AAAA,YAAA,CAC3B;AACM,mBAAA,MAAM,mCAAmC,SAAS,WAAW;AAAA,cACnE,OAAO;AAAA,YAAA,CACP;AACK,kBAAAA,uBAAiB,WAAW,gBAAgB,MAAM;AACpD,gBAAA,CAAC,gBAAgB,OAAO,SAAS;AACpC,qBAAO,KAAK,yBAAyB;AAAA,YACtC;AAAA,UAAA,OACM;AACN,mBAAO,MAAM,8BAA8B;AAAA,cAC1C,OAAO;AAAA,YAAA,CACP;AACD,gBAAI,YAAY;AACf,sBAAQ,CAAC;AAAA,YAAA,OACH;AACN,qBAAO,CAAC;AAAA,YACT;AACA;AAAA,UACD;AAAA,QACD;AAAA,MACD;AAAA,IAAA,CACA;AAEM,WAAA;AAAA,MACN,MAAM,MAAqB;AAC1B,wBAAgB,MAAM;AACtB,cAAM,cAAc;MACrB;AAAA,IAAA;AAAA,EAEF;AACD;;"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { abortableTimeout } from "./utils.js";
|
|
2
|
+
class Supervisor {
|
|
3
|
+
constructor(runnable, options = {}) {
|
|
4
|
+
this.runnable = runnable;
|
|
5
|
+
this.options = options;
|
|
6
|
+
}
|
|
7
|
+
async run(args) {
|
|
8
|
+
const { logger, onError } = args;
|
|
9
|
+
let restartCount = 0;
|
|
10
|
+
const abortController = new AbortController();
|
|
11
|
+
let innerRunning;
|
|
12
|
+
let wasHealthy = false;
|
|
13
|
+
await new Promise(async (resolve, reject) => {
|
|
14
|
+
while (!abortController.signal.aborted) {
|
|
15
|
+
try {
|
|
16
|
+
await new Promise(async (resolveRunning, rejectRunning) => {
|
|
17
|
+
try {
|
|
18
|
+
innerRunning = await this.runnable.run({
|
|
19
|
+
onClose: resolveRunning,
|
|
20
|
+
onError: rejectRunning,
|
|
21
|
+
logger: logger.child({ runningId: Math.random().toString().substring(2) })
|
|
22
|
+
});
|
|
23
|
+
restartCount = 0;
|
|
24
|
+
resolve();
|
|
25
|
+
wasHealthy = true;
|
|
26
|
+
} catch (e) {
|
|
27
|
+
rejectRunning(e);
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
} catch (e) {
|
|
31
|
+
innerRunning = void 0;
|
|
32
|
+
const shouldRestart = wasHealthy ? this.options.max === void 0 || restartCount++ < this.options.max : restartCount++ < (this.options.startupMax ?? 10);
|
|
33
|
+
if (shouldRestart) {
|
|
34
|
+
const timeoutMs = Math.ceil(Math.min(
|
|
35
|
+
Math.pow(this.options.exponentiationBase ?? 2, restartCount - 1) * (this.options.minBackoff ?? 1e3),
|
|
36
|
+
this.options.maxBackoff ?? 6e4
|
|
37
|
+
));
|
|
38
|
+
logger.error(`Runnable crashed, restarting in ${timeoutMs} ms ...`, {
|
|
39
|
+
error: e
|
|
40
|
+
});
|
|
41
|
+
await abortableTimeout(timeoutMs, abortController.signal);
|
|
42
|
+
if (!abortController.signal.aborted) {
|
|
43
|
+
logger.info(`Restarting runnable now`);
|
|
44
|
+
}
|
|
45
|
+
} else {
|
|
46
|
+
logger.error(`Runnable crashed, stopping`, {
|
|
47
|
+
error: e
|
|
48
|
+
});
|
|
49
|
+
if (wasHealthy) {
|
|
50
|
+
onError(e);
|
|
51
|
+
} else {
|
|
52
|
+
reject(e);
|
|
53
|
+
}
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
return {
|
|
60
|
+
async end() {
|
|
61
|
+
abortController.abort();
|
|
62
|
+
await innerRunning?.end();
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
export {
|
|
68
|
+
Supervisor
|
|
69
|
+
};
|
|
70
|
+
//# sourceMappingURL=Supervisor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Supervisor.js","sources":["../../../../../packages/engine-common/src/runnable/Supervisor.ts"],"sourcesContent":["import { Runnable, RunnableArgs, Running } from './Runnable'\nimport { abortableTimeout } from './utils'\n\nexport type SupervisorOptions = {\n\tmax?: number\n\tstartupMax?: number\n\tminBackoff?: number\n\tmaxBackoff?: number\n\texponentiationBase?: number\n}\n\nexport class Supervisor implements Runnable {\n\tconstructor(\n\t\tprivate runnable: Runnable,\n\t\tprivate options: SupervisorOptions = {},\n\t) {\n\t}\n\n\tpublic async run(args: RunnableArgs): Promise<Running> {\n\t\tconst { logger, onError } = args\n\t\tlet restartCount = 0\n\t\tconst abortController = new AbortController()\n\t\tlet innerRunning: Running | undefined\n\t\tlet wasHealthy = false\n\n\t\tawait new Promise<void>(async (resolve, reject) => {\n\t\t\twhile (!abortController.signal.aborted) {\n\t\t\t\ttry {\n\t\t\t\t\tawait new Promise<void>(async (resolveRunning, rejectRunning) => {\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\tinnerRunning = await this.runnable.run({\n\t\t\t\t\t\t\t\tonClose: resolveRunning,\n\t\t\t\t\t\t\t\tonError: rejectRunning,\n\t\t\t\t\t\t\t\tlogger: logger.child({ runningId: Math.random().toString().substring(2) }),\n\t\t\t\t\t\t\t})\n\t\t\t\t\t\t\trestartCount = 0\n\t\t\t\t\t\t\tresolve()\n\t\t\t\t\t\t\twasHealthy = true\n\t\t\t\t\t\t} catch (e) {\n\t\t\t\t\t\t\trejectRunning(e)\n\t\t\t\t\t\t}\n\t\t\t\t\t})\n\t\t\t\t} catch (e) {\n\t\t\t\t\tinnerRunning = undefined\n\t\t\t\t\tconst shouldRestart = wasHealthy\n\t\t\t\t\t\t? (this.options.max === undefined || restartCount++ < this.options.max)\n\t\t\t\t\t\t: (restartCount++ < (this.options.startupMax ?? 10))\n\t\t\t\t\tif (shouldRestart) {\n\t\t\t\t\t\tconst timeoutMs = Math.ceil(Math.min(\n\t\t\t\t\t\t\tMath.pow(this.options.exponentiationBase ?? 2, restartCount - 1) * (this.options.minBackoff ?? 1_000),\n\t\t\t\t\t\t\tthis.options.maxBackoff ?? 60_000,\n\t\t\t\t\t\t))\n\t\t\t\t\t\tlogger.error(`Runnable crashed, restarting in ${timeoutMs} ms ...`, {\n\t\t\t\t\t\t\terror: e,\n\t\t\t\t\t\t})\n\t\t\t\t\t\tawait abortableTimeout(timeoutMs, abortController.signal)\n\t\t\t\t\t\tif (!abortController.signal.aborted) {\n\t\t\t\t\t\t\tlogger.info(`Restarting runnable now`)\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\tlogger.error(`Runnable crashed, stopping`, {\n\t\t\t\t\t\t\terror: e,\n\t\t\t\t\t\t})\n\t\t\t\t\t\tif (wasHealthy) {\n\t\t\t\t\t\t\tonError(e)\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\treject(e)\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t})\n\n\t\treturn {\n\t\t\tasync end(): Promise<void> {\n\t\t\t\tabortController.abort()\n\t\t\t\tawait innerRunning?.end()\n\t\t\t},\n\t\t}\n\t}\n}\n"],"names":[],"mappings":";AAWO,MAAM,WAA+B;AAAA,EAC3C,YACS,UACA,UAA6B,IACpC;AAFO,SAAA,WAAA;AACA,SAAA,UAAA;AAAA,EAET;AAAA,EAEA,MAAa,IAAI,MAAsC;AAChD,UAAA,EAAE,QAAQ,QAAY,IAAA;AAC5B,QAAI,eAAe;AACb,UAAA,kBAAkB,IAAI;AACxB,QAAA;AACJ,QAAI,aAAa;AAEjB,UAAM,IAAI,QAAc,OAAO,SAAS,WAAW;AAC3C,aAAA,CAAC,gBAAgB,OAAO,SAAS;AACnC,YAAA;AACH,gBAAM,IAAI,QAAc,OAAO,gBAAgB,kBAAkB;AAC5D,gBAAA;AACY,6BAAA,MAAM,KAAK,SAAS,IAAI;AAAA,gBACtC,SAAS;AAAA,gBACT,SAAS;AAAA,gBACT,QAAQ,OAAO,MAAM,EAAE,WAAW,KAAK,OAAO,EAAE,SAAS,EAAE,UAAU,CAAC,GAAG;AAAA,cAAA,CACzE;AACc,6BAAA;AACP;AACK,2BAAA;AAAA,qBACL,GAAG;AACX,4BAAc,CAAC;AAAA,YAChB;AAAA,UAAA,CACA;AAAA,iBACO,GAAG;AACI,yBAAA;AACf,gBAAM,gBAAgB,aAClB,KAAK,QAAQ,QAAQ,UAAa,iBAAiB,KAAK,QAAQ,MAChE,kBAAkB,KAAK,QAAQ,cAAc;AACjD,cAAI,eAAe;AACZ,kBAAA,YAAY,KAAK,KAAK,KAAK;AAAA,cAChC,KAAK,IAAI,KAAK,QAAQ,sBAAsB,GAAG,eAAe,CAAC,KAAK,KAAK,QAAQ,cAAc;AAAA,cAC/F,KAAK,QAAQ,cAAc;AAAA,YAAA,CAC3B;AACM,mBAAA,MAAM,mCAAmC,SAAS,WAAW;AAAA,cACnE,OAAO;AAAA,YAAA,CACP;AACK,kBAAA,iBAAiB,WAAW,gBAAgB,MAAM;AACpD,gBAAA,CAAC,gBAAgB,OAAO,SAAS;AACpC,qBAAO,KAAK,yBAAyB;AAAA,YACtC;AAAA,UAAA,OACM;AACN,mBAAO,MAAM,8BAA8B;AAAA,cAC1C,OAAO;AAAA,YAAA,CACP;AACD,gBAAI,YAAY;AACf,sBAAQ,CAAC;AAAA,YAAA,OACH;AACN,qBAAO,CAAC;AAAA,YACT;AACA;AAAA,UACD;AAAA,QACD;AAAA,MACD;AAAA,IAAA,CACA;AAEM,WAAA;AAAA,MACN,MAAM,MAAqB;AAC1B,wBAAgB,MAAM;AACtB,cAAM,cAAc;MACrB;AAAA,IAAA;AAAA,EAEF;AACD;"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const abortableTimeout = async (timeoutMs, abortSignal) => {
|
|
4
|
+
if (abortSignal.aborted) {
|
|
5
|
+
return Promise.resolve();
|
|
6
|
+
}
|
|
7
|
+
let cleanup = [];
|
|
8
|
+
const abortPromise = new Promise((resolve) => {
|
|
9
|
+
abortSignal.addEventListener("abort", resolve);
|
|
10
|
+
cleanup.push(() => abortSignal.removeEventListener("abort", resolve));
|
|
11
|
+
});
|
|
12
|
+
const timeoutPromise = new Promise((resolve) => {
|
|
13
|
+
const timeoutHandle = setTimeout(resolve, timeoutMs);
|
|
14
|
+
cleanup.push(() => clearTimeout(timeoutHandle));
|
|
15
|
+
});
|
|
16
|
+
await Promise.race([abortPromise, timeoutPromise]);
|
|
17
|
+
cleanup.forEach((it) => it());
|
|
18
|
+
};
|
|
19
|
+
exports.abortableTimeout = abortableTimeout;
|
|
20
|
+
//# sourceMappingURL=utils.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.cjs","sources":["../../../../../packages/engine-common/src/runnable/utils.ts"],"sourcesContent":["export const abortableTimeout = async (timeoutMs: number, abortSignal: AbortSignal): Promise<void> => {\n\tif (abortSignal.aborted) {\n\t\treturn Promise.resolve()\n\t}\n\n\tlet cleanup: (() => void)[] = []\n\n\tconst abortPromise = new Promise(resolve => {\n\t\tabortSignal.addEventListener('abort', resolve)\n\t\tcleanup.push(() => abortSignal.removeEventListener('abort', resolve))\n\t})\n\n\tconst timeoutPromise = new Promise<void>(resolve => {\n\t\tconst timeoutHandle = setTimeout(resolve, timeoutMs)\n\t\tcleanup.push(() => clearTimeout(timeoutHandle))\n\t})\n\n\tawait Promise.race([abortPromise, timeoutPromise])\n\tcleanup.forEach(it => it())\n}\n\n"],"names":[],"mappings":";;AAAa,MAAA,mBAAmB,OAAO,WAAmB,gBAA4C;AACrG,MAAI,YAAY,SAAS;AACxB,WAAO,QAAQ;EAChB;AAEA,MAAI,UAA0B,CAAA;AAExB,QAAA,eAAe,IAAI,QAAQ,CAAW,YAAA;AAC/B,gBAAA,iBAAiB,SAAS,OAAO;AAC7C,YAAQ,KAAK,MAAM,YAAY,oBAAoB,SAAS,OAAO,CAAC;AAAA,EAAA,CACpE;AAEK,QAAA,iBAAiB,IAAI,QAAc,CAAW,YAAA;AAC7C,UAAA,gBAAgB,WAAW,SAAS,SAAS;AACnD,YAAQ,KAAK,MAAM,aAAa,aAAa,CAAC;AAAA,EAAA,CAC9C;AAED,QAAM,QAAQ,KAAK,CAAC,cAAc,cAAc,CAAC;AACzC,UAAA,QAAQ,CAAM,OAAA,GAAI,CAAA;AAC3B;;"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
const abortableTimeout = async (timeoutMs, abortSignal) => {
|
|
2
|
+
if (abortSignal.aborted) {
|
|
3
|
+
return Promise.resolve();
|
|
4
|
+
}
|
|
5
|
+
let cleanup = [];
|
|
6
|
+
const abortPromise = new Promise((resolve) => {
|
|
7
|
+
abortSignal.addEventListener("abort", resolve);
|
|
8
|
+
cleanup.push(() => abortSignal.removeEventListener("abort", resolve));
|
|
9
|
+
});
|
|
10
|
+
const timeoutPromise = new Promise((resolve) => {
|
|
11
|
+
const timeoutHandle = setTimeout(resolve, timeoutMs);
|
|
12
|
+
cleanup.push(() => clearTimeout(timeoutHandle));
|
|
13
|
+
});
|
|
14
|
+
await Promise.race([abortPromise, timeoutPromise]);
|
|
15
|
+
cleanup.forEach((it) => it());
|
|
16
|
+
};
|
|
17
|
+
export {
|
|
18
|
+
abortableTimeout
|
|
19
|
+
};
|
|
20
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","sources":["../../../../../packages/engine-common/src/runnable/utils.ts"],"sourcesContent":["export const abortableTimeout = async (timeoutMs: number, abortSignal: AbortSignal): Promise<void> => {\n\tif (abortSignal.aborted) {\n\t\treturn Promise.resolve()\n\t}\n\n\tlet cleanup: (() => void)[] = []\n\n\tconst abortPromise = new Promise(resolve => {\n\t\tabortSignal.addEventListener('abort', resolve)\n\t\tcleanup.push(() => abortSignal.removeEventListener('abort', resolve))\n\t})\n\n\tconst timeoutPromise = new Promise<void>(resolve => {\n\t\tconst timeoutHandle = setTimeout(resolve, timeoutMs)\n\t\tcleanup.push(() => clearTimeout(timeoutHandle))\n\t})\n\n\tawait Promise.race([abortPromise, timeoutPromise])\n\tcleanup.forEach(it => it())\n}\n\n"],"names":[],"mappings":"AAAa,MAAA,mBAAmB,OAAO,WAAmB,gBAA4C;AACrG,MAAI,YAAY,SAAS;AACxB,WAAO,QAAQ;EAChB;AAEA,MAAI,UAA0B,CAAA;AAExB,QAAA,eAAe,IAAI,QAAQ,CAAW,YAAA;AAC/B,gBAAA,iBAAiB,SAAS,OAAO;AAC7C,YAAQ,KAAK,MAAM,YAAY,oBAAoB,SAAS,OAAO,CAAC;AAAA,EAAA,CACpE;AAEK,QAAA,iBAAiB,IAAI,QAAc,CAAW,YAAA;AAC7C,UAAA,gBAAgB,WAAW,SAAS,SAAS;AACnD,YAAQ,KAAK,MAAM,aAAa,aAAa,CAAC;AAAA,EAAA,CAC9C;AAED,QAAM,QAAQ,KAAK,CAAC,cAAc,cAAc,CAAC;AACzC,UAAA,QAAQ,CAAM,OAAA,GAAI,CAAA;AAC3B;"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
class PromiseMap extends Map {
|
|
4
|
+
async fetch(key, generator) {
|
|
5
|
+
const value = this.get(key);
|
|
6
|
+
if (value !== void 0) {
|
|
7
|
+
return await value;
|
|
8
|
+
}
|
|
9
|
+
const newValue = generator(key);
|
|
10
|
+
this.set(key, newValue);
|
|
11
|
+
try {
|
|
12
|
+
return await newValue;
|
|
13
|
+
} catch (e) {
|
|
14
|
+
this.delete(key);
|
|
15
|
+
throw e;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
exports.PromiseMap = PromiseMap;
|
|
20
|
+
//# sourceMappingURL=PromiseMap.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PromiseMap.cjs","sources":["../../../../../packages/engine-common/src/utils/PromiseMap.ts"],"sourcesContent":["export class PromiseMap<K, V> extends Map<K, Promise<V>>{\n\tasync fetch(key: K, generator: (key: K) => Promise<V>): Promise<V> {\n\t\tconst value = this.get(key)\n\t\tif (value !== undefined) {\n\t\t\treturn await value\n\t\t}\n\t\tconst newValue = generator(key) // intentionally not awaiting\n\t\tthis.set(key, newValue)\n\t\ttry {\n\t\t\treturn await newValue\n\t\t} catch (e) {\n\t\t\tthis.delete(key)\n\t\t\tthrow e\n\t\t}\n\t}\n}\n"],"names":[],"mappings":";;AAAO,MAAM,mBAAyB,IAAkB;AAAA,EACvD,MAAM,MAAM,KAAQ,WAA+C;AAC5D,UAAA,QAAQ,KAAK,IAAI,GAAG;AAC1B,QAAI,UAAU,QAAW;AACxB,aAAO,MAAM;AAAA,IACd;AACM,UAAA,WAAW,UAAU,GAAG;AACzB,SAAA,IAAI,KAAK,QAAQ;AAClB,QAAA;AACH,aAAO,MAAM;AAAA,aACL,GAAG;AACX,WAAK,OAAO,GAAG;AACT,YAAA;AAAA,IACP;AAAA,EACD;AACD;;"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
class PromiseMap extends Map {
|
|
2
|
+
async fetch(key, generator) {
|
|
3
|
+
const value = this.get(key);
|
|
4
|
+
if (value !== void 0) {
|
|
5
|
+
return await value;
|
|
6
|
+
}
|
|
7
|
+
const newValue = generator(key);
|
|
8
|
+
this.set(key, newValue);
|
|
9
|
+
try {
|
|
10
|
+
return await newValue;
|
|
11
|
+
} catch (e) {
|
|
12
|
+
this.delete(key);
|
|
13
|
+
throw e;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
export {
|
|
18
|
+
PromiseMap
|
|
19
|
+
};
|
|
20
|
+
//# sourceMappingURL=PromiseMap.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PromiseMap.js","sources":["../../../../../packages/engine-common/src/utils/PromiseMap.ts"],"sourcesContent":["export class PromiseMap<K, V> extends Map<K, Promise<V>>{\n\tasync fetch(key: K, generator: (key: K) => Promise<V>): Promise<V> {\n\t\tconst value = this.get(key)\n\t\tif (value !== undefined) {\n\t\t\treturn await value\n\t\t}\n\t\tconst newValue = generator(key) // intentionally not awaiting\n\t\tthis.set(key, newValue)\n\t\ttry {\n\t\t\treturn await newValue\n\t\t} catch (e) {\n\t\t\tthis.delete(key)\n\t\t\tthrow e\n\t\t}\n\t}\n}\n"],"names":[],"mappings":"AAAO,MAAM,mBAAyB,IAAkB;AAAA,EACvD,MAAM,MAAM,KAAQ,WAA+C;AAC5D,UAAA,QAAQ,KAAK,IAAI,GAAG;AAC1B,QAAI,UAAU,QAAW;AACxB,aAAO,MAAM;AAAA,IACd;AACM,UAAA,WAAW,UAAU,GAAG;AACzB,SAAA,IAAI,KAAK,QAAQ;AAClB,QAAA;AACH,aAAO,MAAM;AAAA,aACL,GAAG;AACX,WAAK,OAAO,GAAG;AACT,YAAA;AAAA,IACP;AAAA,EACD;AACD;"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const PromiseMap = require("./src/utils/PromiseMap.cjs");
|
|
4
|
+
const Supervisor = require("./src/runnable/Supervisor.cjs");
|
|
5
|
+
const events = require("./src/eventEmitter/events.cjs");
|
|
6
|
+
const MigrationVersionHelper = require("./src/MigrationVersionHelper.cjs");
|
|
7
|
+
exports.PromiseMap = PromiseMap.PromiseMap;
|
|
8
|
+
exports.Supervisor = Supervisor.Supervisor;
|
|
9
|
+
exports.EventManager = events.EventManager;
|
|
10
|
+
exports.MigrationVersionHelper = MigrationVersionHelper.MigrationVersionHelper;
|
|
11
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { PromiseMap } from "./src/utils/PromiseMap.js";
|
|
2
|
+
import { Supervisor } from "./src/runnable/Supervisor.js";
|
|
3
|
+
import { EventManager } from "./src/eventEmitter/events.js";
|
|
4
|
+
import { MigrationVersionHelper } from "./src/MigrationVersionHelper.js";
|
|
5
|
+
export {
|
|
6
|
+
EventManager,
|
|
7
|
+
MigrationVersionHelper,
|
|
8
|
+
PromiseMap,
|
|
9
|
+
Supervisor
|
|
10
|
+
};
|
|
11
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
5
|
+
var __publicField = (obj, key, value) => __defNormalProp(obj, key + "", value);
|
|
6
|
+
const _MigrationVersionHelper = class _MigrationVersionHelper2 {
|
|
7
|
+
static extractVersion(filename) {
|
|
8
|
+
return filename.substring(0, this.prefixLength);
|
|
9
|
+
}
|
|
10
|
+
static createVersion(name, increment = 0) {
|
|
11
|
+
const normalizedName = _MigrationVersionHelper2.normalizeMigrationLabel(name);
|
|
12
|
+
const version = _MigrationVersionHelper2.createTimePrefix(increment);
|
|
13
|
+
return [version, `${version}-${normalizedName}`];
|
|
14
|
+
}
|
|
15
|
+
static extractName(filename) {
|
|
16
|
+
return filename.substring(0, filename.lastIndexOf("."));
|
|
17
|
+
}
|
|
18
|
+
static createTimePrefix(increment) {
|
|
19
|
+
const now = /* @__PURE__ */ new Date();
|
|
20
|
+
now.setSeconds(now.getSeconds() + increment);
|
|
21
|
+
const year = now.getFullYear();
|
|
22
|
+
const month = (now.getMonth() + 1).toString().padStart(2, "0");
|
|
23
|
+
const day = now.getDate().toString().padStart(2, "0");
|
|
24
|
+
const hours = now.getHours().toString().padStart(2, "0");
|
|
25
|
+
const minutes = now.getMinutes().toString().padStart(2, "0");
|
|
26
|
+
const seconds = now.getSeconds().toString().padStart(2, "0");
|
|
27
|
+
return `${year}-${month}-${day}-${hours}${minutes}${seconds}`;
|
|
28
|
+
}
|
|
29
|
+
static normalizeMigrationLabel(name) {
|
|
30
|
+
return name.toLowerCase().replace(/[^a-z0-9]+/g, "-");
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
__publicField(_MigrationVersionHelper, "prefixLength", "YYYY-MM-DD-HHIISS".length);
|
|
34
|
+
let MigrationVersionHelper = _MigrationVersionHelper;
|
|
35
|
+
exports.MigrationVersionHelper = MigrationVersionHelper;
|
|
36
|
+
//# sourceMappingURL=MigrationVersionHelper.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MigrationVersionHelper.cjs","sources":["../../../../packages/engine-common/src/MigrationVersionHelper.ts"],"sourcesContent":["export class MigrationVersionHelper {\n\tpublic static prefixLength = 'YYYY-MM-DD-HHIISS'.length\n\n\tpublic static extractVersion(filename: string): string {\n\t\treturn filename.substring(0, this.prefixLength)\n\t}\n\n\tpublic static createVersion(name: string, increment: number = 0): [string, string] {\n\t\tconst normalizedName = MigrationVersionHelper.normalizeMigrationLabel(name)\n\t\tconst version = MigrationVersionHelper.createTimePrefix(increment)\n\t\treturn [version, `${version}-${normalizedName}`]\n\t}\n\n\tpublic static extractName(filename: string): string {\n\t\treturn filename.substring(0, filename.lastIndexOf('.'))\n\t}\n\n\tprivate static createTimePrefix(increment: number): string {\n\t\tconst now = new Date()\n\t\tnow.setSeconds(now.getSeconds() + increment)\n\t\tconst year = now.getFullYear()\n\t\tconst month = (now.getMonth() + 1).toString().padStart(2, '0')\n\t\tconst day = now //\n\t\t\t.getDate()\n\t\t\t.toString()\n\t\t\t.padStart(2, '0')\n\t\tconst hours = now //\n\t\t\t.getHours()\n\t\t\t.toString()\n\t\t\t.padStart(2, '0')\n\t\tconst minutes = now //\n\t\t\t.getMinutes()\n\t\t\t.toString()\n\t\t\t.padStart(2, '0')\n\t\tconst seconds = now //\n\t\t\t.getSeconds()\n\t\t\t.toString()\n\t\t\t.padStart(2, '0')\n\n\t\treturn `${year}-${month}-${day}-${hours}${minutes}${seconds}`\n\t}\n\n\tprivate static normalizeMigrationLabel(name: string) {\n\t\treturn name.toLowerCase().replace(/[^a-z0-9]+/g, '-')\n\t}\n}\n"],"names":["_MigrationVersionHelper"],"mappings":";;;;;AAAO,MAAM,0BAAN,MAAMA,yBAAuB;AAAA,EAGnC,OAAc,eAAe,UAA0B;AACtD,WAAO,SAAS,UAAU,GAAG,KAAK,YAAY;AAAA,EAC/C;AAAA,EAEA,OAAc,cAAc,MAAc,YAAoB,GAAqB;AAC5E,UAAA,iBAAiBA,yBAAuB,wBAAwB,IAAI;AACpE,UAAA,UAAUA,yBAAuB,iBAAiB,SAAS;AACjE,WAAO,CAAC,SAAS,GAAG,OAAO,IAAI,cAAc,EAAE;AAAA,EAChD;AAAA,EAEA,OAAc,YAAY,UAA0B;AACnD,WAAO,SAAS,UAAU,GAAG,SAAS,YAAY,GAAG,CAAC;AAAA,EACvD;AAAA,EAEA,OAAe,iBAAiB,WAA2B;AACpD,UAAA,0BAAU;AAChB,QAAI,WAAW,IAAI,WAAW,IAAI,SAAS;AACrC,UAAA,OAAO,IAAI;AACX,UAAA,SAAS,IAAI,aAAa,GAAG,SAAS,EAAE,SAAS,GAAG,GAAG;AACvD,UAAA,MAAM,IACV,QAAQ,EACR,WACA,SAAS,GAAG,GAAG;AACX,UAAA,QAAQ,IACZ,SAAS,EACT,WACA,SAAS,GAAG,GAAG;AACX,UAAA,UAAU,IACd,WAAW,EACX,WACA,SAAS,GAAG,GAAG;AACX,UAAA,UAAU,IACd,WAAW,EACX,WACA,SAAS,GAAG,GAAG;AAEV,WAAA,GAAG,IAAI,IAAI,KAAK,IAAI,GAAG,IAAI,KAAK,GAAG,OAAO,GAAG,OAAO;AAAA,EAC5D;AAAA,EAEA,OAAe,wBAAwB,MAAc;AACpD,WAAO,KAAK,YAAc,EAAA,QAAQ,eAAe,GAAG;AAAA,EACrD;AACD;AA5CC,cADY,yBACE,gBAAe,oBAAoB,MAAA;AAD3C,IAAM,yBAAN;;"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
3
|
+
var __publicField = (obj, key, value) => __defNormalProp(obj, key + "", value);
|
|
4
|
+
const _MigrationVersionHelper = class _MigrationVersionHelper2 {
|
|
5
|
+
static extractVersion(filename) {
|
|
6
|
+
return filename.substring(0, this.prefixLength);
|
|
7
|
+
}
|
|
8
|
+
static createVersion(name, increment = 0) {
|
|
9
|
+
const normalizedName = _MigrationVersionHelper2.normalizeMigrationLabel(name);
|
|
10
|
+
const version = _MigrationVersionHelper2.createTimePrefix(increment);
|
|
11
|
+
return [version, `${version}-${normalizedName}`];
|
|
12
|
+
}
|
|
13
|
+
static extractName(filename) {
|
|
14
|
+
return filename.substring(0, filename.lastIndexOf("."));
|
|
15
|
+
}
|
|
16
|
+
static createTimePrefix(increment) {
|
|
17
|
+
const now = /* @__PURE__ */ new Date();
|
|
18
|
+
now.setSeconds(now.getSeconds() + increment);
|
|
19
|
+
const year = now.getFullYear();
|
|
20
|
+
const month = (now.getMonth() + 1).toString().padStart(2, "0");
|
|
21
|
+
const day = now.getDate().toString().padStart(2, "0");
|
|
22
|
+
const hours = now.getHours().toString().padStart(2, "0");
|
|
23
|
+
const minutes = now.getMinutes().toString().padStart(2, "0");
|
|
24
|
+
const seconds = now.getSeconds().toString().padStart(2, "0");
|
|
25
|
+
return `${year}-${month}-${day}-${hours}${minutes}${seconds}`;
|
|
26
|
+
}
|
|
27
|
+
static normalizeMigrationLabel(name) {
|
|
28
|
+
return name.toLowerCase().replace(/[^a-z0-9]+/g, "-");
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
__publicField(_MigrationVersionHelper, "prefixLength", "YYYY-MM-DD-HHIISS".length);
|
|
32
|
+
let MigrationVersionHelper = _MigrationVersionHelper;
|
|
33
|
+
export {
|
|
34
|
+
MigrationVersionHelper
|
|
35
|
+
};
|
|
36
|
+
//# sourceMappingURL=MigrationVersionHelper.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MigrationVersionHelper.js","sources":["../../../../packages/engine-common/src/MigrationVersionHelper.ts"],"sourcesContent":["export class MigrationVersionHelper {\n\tpublic static prefixLength = 'YYYY-MM-DD-HHIISS'.length\n\n\tpublic static extractVersion(filename: string): string {\n\t\treturn filename.substring(0, this.prefixLength)\n\t}\n\n\tpublic static createVersion(name: string, increment: number = 0): [string, string] {\n\t\tconst normalizedName = MigrationVersionHelper.normalizeMigrationLabel(name)\n\t\tconst version = MigrationVersionHelper.createTimePrefix(increment)\n\t\treturn [version, `${version}-${normalizedName}`]\n\t}\n\n\tpublic static extractName(filename: string): string {\n\t\treturn filename.substring(0, filename.lastIndexOf('.'))\n\t}\n\n\tprivate static createTimePrefix(increment: number): string {\n\t\tconst now = new Date()\n\t\tnow.setSeconds(now.getSeconds() + increment)\n\t\tconst year = now.getFullYear()\n\t\tconst month = (now.getMonth() + 1).toString().padStart(2, '0')\n\t\tconst day = now //\n\t\t\t.getDate()\n\t\t\t.toString()\n\t\t\t.padStart(2, '0')\n\t\tconst hours = now //\n\t\t\t.getHours()\n\t\t\t.toString()\n\t\t\t.padStart(2, '0')\n\t\tconst minutes = now //\n\t\t\t.getMinutes()\n\t\t\t.toString()\n\t\t\t.padStart(2, '0')\n\t\tconst seconds = now //\n\t\t\t.getSeconds()\n\t\t\t.toString()\n\t\t\t.padStart(2, '0')\n\n\t\treturn `${year}-${month}-${day}-${hours}${minutes}${seconds}`\n\t}\n\n\tprivate static normalizeMigrationLabel(name: string) {\n\t\treturn name.toLowerCase().replace(/[^a-z0-9]+/g, '-')\n\t}\n}\n"],"names":["_MigrationVersionHelper"],"mappings":";;;AAAO,MAAM,0BAAN,MAAMA,yBAAuB;AAAA,EAGnC,OAAc,eAAe,UAA0B;AACtD,WAAO,SAAS,UAAU,GAAG,KAAK,YAAY;AAAA,EAC/C;AAAA,EAEA,OAAc,cAAc,MAAc,YAAoB,GAAqB;AAC5E,UAAA,iBAAiBA,yBAAuB,wBAAwB,IAAI;AACpE,UAAA,UAAUA,yBAAuB,iBAAiB,SAAS;AACjE,WAAO,CAAC,SAAS,GAAG,OAAO,IAAI,cAAc,EAAE;AAAA,EAChD;AAAA,EAEA,OAAc,YAAY,UAA0B;AACnD,WAAO,SAAS,UAAU,GAAG,SAAS,YAAY,GAAG,CAAC;AAAA,EACvD;AAAA,EAEA,OAAe,iBAAiB,WAA2B;AACpD,UAAA,0BAAU;AAChB,QAAI,WAAW,IAAI,WAAW,IAAI,SAAS;AACrC,UAAA,OAAO,IAAI;AACX,UAAA,SAAS,IAAI,aAAa,GAAG,SAAS,EAAE,SAAS,GAAG,GAAG;AACvD,UAAA,MAAM,IACV,QAAQ,EACR,WACA,SAAS,GAAG,GAAG;AACX,UAAA,QAAQ,IACZ,SAAS,EACT,WACA,SAAS,GAAG,GAAG;AACX,UAAA,UAAU,IACd,WAAW,EACX,WACA,SAAS,GAAG,GAAG;AACX,UAAA,UAAU,IACd,WAAW,EACX,WACA,SAAS,GAAG,GAAG;AAEV,WAAA,GAAG,IAAI,IAAI,KAAK,IAAI,GAAG,IAAI,KAAK,GAAG,OAAO,GAAG,OAAO;AAAA,EAC5D;AAAA,EAEA,OAAe,wBAAwB,MAAc;AACpD,WAAO,KAAK,YAAc,EAAA,QAAQ,eAAe,GAAG;AAAA,EACrD;AACD;AA5CC,cADY,yBACE,gBAAe,oBAAoB,MAAA;AAD3C,IAAM,yBAAN;"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
5
|
+
var __publicField = (obj, key, value) => __defNormalProp(obj, key + "", value);
|
|
6
|
+
class EventManager {
|
|
7
|
+
constructor() {
|
|
8
|
+
__publicField(this, "listeners", {});
|
|
9
|
+
}
|
|
10
|
+
on(event, cb) {
|
|
11
|
+
var _a;
|
|
12
|
+
((_a = this.listeners)[event] ?? (_a[event] = [])).push(cb);
|
|
13
|
+
return () => {
|
|
14
|
+
return this.listeners[event] = this.listeners[event]?.filter((it) => it !== cb);
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
fire(event, args) {
|
|
18
|
+
const result = [];
|
|
19
|
+
for (const cb of this.listeners[event] ?? []) {
|
|
20
|
+
result.push(cb(args));
|
|
21
|
+
}
|
|
22
|
+
return result;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
exports.EventManager = EventManager;
|
|
26
|
+
//# sourceMappingURL=events.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"events.cjs","sources":["../../../../../packages/engine-common/src/eventEmitter/events.ts"],"sourcesContent":["export type EventMap = {\n\t[name: string]: (arg: any) => any\n}\n\nexport type EventUnlisten = () => void\n\nexport interface EventEmitter<E extends EventMap> {\n\ton<K extends keyof E>(event: K, cb: E[K]): EventUnlisten\n}\n\nexport class EventManager<E extends EventMap> implements EventEmitter<E> {\n\tprivate listeners: {\n\t\t[K in keyof E]?: E[K][]\n\t} = {}\n\n\tpublic on<K extends keyof E>(event: K, cb: E[K]): EventUnlisten {\n\t\t(this.listeners[event] ??= []).push(cb)\n\t\treturn () => {\n\t\t\treturn this.listeners[event] = this.listeners[event]?.filter(it => it !== cb)\n\t\t}\n\t}\n\n\tpublic fire<K extends keyof E>(event: K, args: Parameters<E[K]>[0]): ReturnType<E[K]>[] {\n\t\tconst result: ReturnType<E[K]>[] = []\n\t\tfor (const cb of this.listeners[event] ?? []) {\n\t\t\tresult.push(cb(args))\n\t\t}\n\t\treturn result\n\t}\n}\n"],"names":[],"mappings":";;;;;AAUO,MAAM,aAA4D;AAAA,EAAlE,cAAA;AACN,kBAAA,MAAQ,aAEJ,CAAA,CAAC;AAAA,EAAA;AAAA,EAEE,GAAsB,OAAU,IAAyB;AAfjE,QAAA;AAgBE,MAAC,UAAK,WAAL,KAAA,MAAA,GAAA,KAAA,IAA0B,CAAC,IAAG,KAAK,EAAE;AACtC,WAAO,MAAM;AACL,aAAA,KAAK,UAAU,KAAK,IAAI,KAAK,UAAU,KAAK,GAAG,OAAO,CAAM,OAAA,OAAO,EAAE;AAAA,IAAA;AAAA,EAE9E;AAAA,EAEO,KAAwB,OAAU,MAA+C;AACvF,UAAM,SAA6B,CAAA;AACnC,eAAW,MAAM,KAAK,UAAU,KAAK,KAAK,CAAA,GAAI;AACtC,aAAA,KAAK,GAAG,IAAI,CAAC;AAAA,IACrB;AACO,WAAA;AAAA,EACR;AACD;;"}
|