@contember/engine-common 2.1.0-alpha.30 → 2.1.0-alpha.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.
Files changed (72) hide show
  1. package/package.json +9 -4
  2. package/src/eventEmitter/events.ts +1 -1
  3. package/src/runnable/utils.ts +0 -1
  4. package/src/utils/PromiseMap.ts +1 -1
  5. package/tests/cases/supervisor.test.ts +6 -13
  6. package/dist/development/index.cjs +0 -11
  7. package/dist/development/index.cjs.map +0 -1
  8. package/dist/development/index.js +0 -11
  9. package/dist/development/index.js.map +0 -1
  10. package/dist/development/src/MigrationVersionHelper.cjs +0 -36
  11. package/dist/development/src/MigrationVersionHelper.cjs.map +0 -1
  12. package/dist/development/src/MigrationVersionHelper.js +0 -36
  13. package/dist/development/src/MigrationVersionHelper.js.map +0 -1
  14. package/dist/development/src/eventEmitter/events.cjs +0 -26
  15. package/dist/development/src/eventEmitter/events.cjs.map +0 -1
  16. package/dist/development/src/eventEmitter/events.js +0 -26
  17. package/dist/development/src/eventEmitter/events.js.map +0 -1
  18. package/dist/development/src/runnable/Supervisor.cjs +0 -70
  19. package/dist/development/src/runnable/Supervisor.cjs.map +0 -1
  20. package/dist/development/src/runnable/Supervisor.js +0 -70
  21. package/dist/development/src/runnable/Supervisor.js.map +0 -1
  22. package/dist/development/src/runnable/utils.cjs +0 -20
  23. package/dist/development/src/runnable/utils.cjs.map +0 -1
  24. package/dist/development/src/runnable/utils.js +0 -20
  25. package/dist/development/src/runnable/utils.js.map +0 -1
  26. package/dist/development/src/utils/PromiseMap.cjs +0 -20
  27. package/dist/development/src/utils/PromiseMap.cjs.map +0 -1
  28. package/dist/development/src/utils/PromiseMap.js +0 -20
  29. package/dist/development/src/utils/PromiseMap.js.map +0 -1
  30. package/dist/production/index.cjs +0 -11
  31. package/dist/production/index.cjs.map +0 -1
  32. package/dist/production/index.js +0 -11
  33. package/dist/production/index.js.map +0 -1
  34. package/dist/production/src/MigrationVersionHelper.cjs +0 -36
  35. package/dist/production/src/MigrationVersionHelper.cjs.map +0 -1
  36. package/dist/production/src/MigrationVersionHelper.js +0 -36
  37. package/dist/production/src/MigrationVersionHelper.js.map +0 -1
  38. package/dist/production/src/eventEmitter/events.cjs +0 -26
  39. package/dist/production/src/eventEmitter/events.cjs.map +0 -1
  40. package/dist/production/src/eventEmitter/events.js +0 -26
  41. package/dist/production/src/eventEmitter/events.js.map +0 -1
  42. package/dist/production/src/runnable/Supervisor.cjs +0 -70
  43. package/dist/production/src/runnable/Supervisor.cjs.map +0 -1
  44. package/dist/production/src/runnable/Supervisor.js +0 -70
  45. package/dist/production/src/runnable/Supervisor.js.map +0 -1
  46. package/dist/production/src/runnable/utils.cjs +0 -20
  47. package/dist/production/src/runnable/utils.cjs.map +0 -1
  48. package/dist/production/src/runnable/utils.js +0 -20
  49. package/dist/production/src/runnable/utils.js.map +0 -1
  50. package/dist/production/src/utils/PromiseMap.cjs +0 -20
  51. package/dist/production/src/utils/PromiseMap.cjs.map +0 -1
  52. package/dist/production/src/utils/PromiseMap.js +0 -20
  53. package/dist/production/src/utils/PromiseMap.js.map +0 -1
  54. package/dist/types/MigrationVersionHelper.d.ts +0 -9
  55. package/dist/types/MigrationVersionHelper.d.ts.map +0 -1
  56. package/dist/types/eventEmitter/events.d.ts +0 -13
  57. package/dist/types/eventEmitter/events.d.ts.map +0 -1
  58. package/dist/types/index.d.ts +0 -5
  59. package/dist/types/index.d.ts.map +0 -1
  60. package/dist/types/runnable/Runnable.d.ts +0 -13
  61. package/dist/types/runnable/Runnable.d.ts.map +0 -1
  62. package/dist/types/runnable/Supervisor.d.ts +0 -15
  63. package/dist/types/runnable/Supervisor.d.ts.map +0 -1
  64. package/dist/types/runnable/index.d.ts +0 -3
  65. package/dist/types/runnable/index.d.ts.map +0 -1
  66. package/dist/types/runnable/utils.d.ts +0 -2
  67. package/dist/types/runnable/utils.d.ts.map +0 -1
  68. package/dist/types/tsconfig.tsbuildinfo +0 -1
  69. package/dist/types/utils/PromiseMap.d.ts +0 -4
  70. package/dist/types/utils/PromiseMap.d.ts.map +0 -1
  71. package/dist/types/utils/index.d.ts +0 -2
  72. package/dist/types/utils/index.d.ts.map +0 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@contember/engine-common",
3
- "version": "2.1.0-alpha.30",
3
+ "version": "2.1.0-alpha.35",
4
4
  "license": "Apache-2.0",
5
5
  "main": "./dist/production/index.js",
6
6
  "typings": "./dist/types/index.d.ts",
@@ -23,10 +23,15 @@
23
23
  }
24
24
  },
25
25
  "devDependencies": {
26
- "@types/node": "^20.17.22"
26
+ "@types/node": "catalog:"
27
27
  },
28
28
  "dependencies": {
29
- "@contember/logger": "2.1.0-alpha.30"
29
+ "@contember/logger": "workspace:*"
30
30
  },
31
- "type": "module"
31
+ "type": "module",
32
+ "repository": {
33
+ "type": "git",
34
+ "url": "git+https://github.com/contember/contember.git",
35
+ "directory": "packages/engine-common"
36
+ }
32
37
  }
@@ -14,7 +14,7 @@ export class EventManager<E extends EventMap> implements EventEmitter<E> {
14
14
  } = {}
15
15
 
16
16
  public on<K extends keyof E>(event: K, cb: E[K]): EventUnlisten {
17
- (this.listeners[event] ??= []).push(cb)
17
+ ;(this.listeners[event] ??= []).push(cb)
18
18
  return () => {
19
19
  return this.listeners[event] = this.listeners[event]?.filter(it => it !== cb)
20
20
  }
@@ -18,4 +18,3 @@ export const abortableTimeout = async (timeoutMs: number, abortSignal: AbortSign
18
18
  await Promise.race([abortPromise, timeoutPromise])
19
19
  cleanup.forEach(it => it())
20
20
  }
21
-
@@ -1,4 +1,4 @@
1
- export class PromiseMap<K, V> extends Map<K, Promise<V>>{
1
+ export class PromiseMap<K, V> extends Map<K, Promise<V>> {
2
2
  async fetch(key: K, generator: (key: K) => Promise<V>): Promise<V> {
3
3
  const value = this.get(key)
4
4
  if (value !== undefined) {
@@ -1,5 +1,5 @@
1
1
  import { createLogger, TestLoggerHandler } from '@contember/logger'
2
- import { test, expect } from 'bun:test'
2
+ import { expect, test } from 'bun:test'
3
3
  import { Runnable, RunnableArgs, Running, Supervisor } from '../../src'
4
4
 
5
5
  const shouldNotHappenCallback = () => {
@@ -25,7 +25,7 @@ test('supervisor: start - end', async () => {
25
25
  },
26
26
  }
27
27
  }
28
- }
28
+ }()
29
29
  const supervisor = new Supervisor(okRunnable)
30
30
  const running = await supervisor.run({
31
31
  logger,
@@ -39,7 +39,6 @@ test('supervisor: start - end', async () => {
39
39
  ])
40
40
  })
41
41
 
42
-
43
42
  test('supervisor: retry start', async () => {
44
43
  const { logger, testLogger } = createTestLogger()
45
44
  let attempt = 0
@@ -59,7 +58,7 @@ test('supervisor: retry start', async () => {
59
58
  },
60
59
  }
61
60
  }
62
- }
61
+ }()
63
62
 
64
63
  const supervisor = new Supervisor(okRunnable, { minBackoff: 1 })
65
64
  const running = await supervisor.run({
@@ -79,11 +78,9 @@ test('supervisor: retry start', async () => {
79
78
  'Starting runnable #3',
80
79
  'Runnable #3 started',
81
80
  'Runnable #3 terminated',
82
-
83
81
  ])
84
82
  })
85
83
 
86
-
87
84
  test('supervisor: failed to start', async () => {
88
85
  const { logger, testLogger } = createTestLogger()
89
86
  const okRunnable = new class OkRunnable implements Runnable {
@@ -92,7 +89,7 @@ test('supervisor: failed to start', async () => {
92
89
  await new Promise(resolve => setTimeout(resolve, 1))
93
90
  throw new Error('failed to start')
94
91
  }
95
- }
92
+ }()
96
93
 
97
94
  const supervisor = new Supervisor(okRunnable, { startupMax: 0 })
98
95
  const runningPromise = supervisor.run({
@@ -106,7 +103,6 @@ test('supervisor: failed to start', async () => {
106
103
  ])
107
104
  })
108
105
 
109
-
110
106
  test('supervisor: crash after start, restarts', async () => {
111
107
  const { logger, testLogger } = createTestLogger()
112
108
  let attempt = 0
@@ -127,7 +123,7 @@ test('supervisor: crash after start, restarts', async () => {
127
123
  },
128
124
  }
129
125
  }
130
- }
126
+ }()
131
127
 
132
128
  const supervisor = new Supervisor(okRunnable, { minBackoff: 1 })
133
129
  const running = await supervisor.run({
@@ -142,11 +138,9 @@ test('supervisor: crash after start, restarts', async () => {
142
138
  'Restarting runnable now',
143
139
  'Starting runnable #2',
144
140
  'Runnable #2 terminated',
145
-
146
141
  ])
147
142
  })
148
143
 
149
-
150
144
  test('supervisor: failed to restart', async () => {
151
145
  const { logger, testLogger } = createTestLogger()
152
146
  let attempt = 0
@@ -169,7 +163,7 @@ test('supervisor: failed to restart', async () => {
169
163
  },
170
164
  }
171
165
  }
172
- }
166
+ }()
173
167
 
174
168
  const supervisor = new Supervisor(okRunnable, { minBackoff: 1, max: 5 })
175
169
  const errorPromise = new Promise(async (resolve, reject) => {
@@ -201,4 +195,3 @@ test('supervisor: failed to restart', async () => {
201
195
  'Runnable crashed, stopping: failed to restart',
202
196
  ])
203
197
  })
204
-
@@ -1,11 +0,0 @@
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
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;"}
@@ -1,11 +0,0 @@
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
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;"}
@@ -1,36 +0,0 @@
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
@@ -1 +0,0 @@
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,EAAA;AAAA,EAG/C,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,EAAA;AAAA,EAGhD,OAAc,YAAY,UAA0B;AACnD,WAAO,SAAS,UAAU,GAAG,SAAS,YAAY,GAAG,CAAC;AAAA,EAAA;AAAA,EAGvD,OAAe,iBAAiB,WAA2B;AACpD,UAAA,0BAAU,KAAK;AACrB,QAAI,WAAW,IAAI,WAAW,IAAI,SAAS;AACrC,UAAA,OAAO,IAAI,YAAY;AACvB,UAAA,SAAS,IAAI,SAAS,IAAI,GAAG,WAAW,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,EAAA;AAAA,EAG5D,OAAe,wBAAwB,MAAc;AACpD,WAAO,KAAK,YAAA,EAAc,QAAQ,eAAe,GAAG;AAAA,EAAA;AAEtD;AA5CC,cADY,yBACE,gBAAe,oBAAoB,MAAA;AAD3C,IAAM,yBAAN;;"}
@@ -1,36 +0,0 @@
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
@@ -1 +0,0 @@
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,EAAA;AAAA,EAG/C,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,EAAA;AAAA,EAGhD,OAAc,YAAY,UAA0B;AACnD,WAAO,SAAS,UAAU,GAAG,SAAS,YAAY,GAAG,CAAC;AAAA,EAAA;AAAA,EAGvD,OAAe,iBAAiB,WAA2B;AACpD,UAAA,0BAAU,KAAK;AACrB,QAAI,WAAW,IAAI,WAAW,IAAI,SAAS;AACrC,UAAA,OAAO,IAAI,YAAY;AACvB,UAAA,SAAS,IAAI,SAAS,IAAI,GAAG,WAAW,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,EAAA;AAAA,EAG5D,OAAe,wBAAwB,MAAc;AACpD,WAAO,KAAK,YAAA,EAAc,QAAQ,eAAe,GAAG;AAAA,EAAA;AAEtD;AA5CC,cADY,yBACE,gBAAe,oBAAoB,MAAA;AAD3C,IAAM,yBAAN;"}
@@ -1,26 +0,0 @@
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
@@ -1 +0,0 @@
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,EAAC;AAAA,EAAA;AAAA,EAEE,GAAsB,OAAU,IAAyB;AAfjE,QAAA;AAgBE,MAAC,UAAK,WAAL,KAAA,MAAA,GAAA,KAAA,IAA0B,CAAA,IAAI,KAAK,EAAE;AACtC,WAAO,MAAM;AACL,aAAA,KAAK,UAAU,KAAK,IAAI,KAAK,UAAU,KAAK,GAAG,OAAO,CAAM,OAAA,OAAO,EAAE;AAAA,IAC7E;AAAA,EAAA;AAAA,EAGM,KAAwB,OAAU,MAA+C;AACvF,UAAM,SAA6B,CAAC;AACpC,eAAW,MAAM,KAAK,UAAU,KAAK,KAAK,CAAA,GAAI;AACtC,aAAA,KAAK,GAAG,IAAI,CAAC;AAAA,IAAA;AAEd,WAAA;AAAA,EAAA;AAET;;"}
@@ -1,26 +0,0 @@
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
@@ -1 +0,0 @@
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,EAAC;AAAA,EAAA;AAAA,EAEE,GAAsB,OAAU,IAAyB;AAfjE,QAAA;AAgBE,MAAC,UAAK,WAAL,KAAA,MAAA,GAAA,KAAA,IAA0B,CAAA,IAAI,KAAK,EAAE;AACtC,WAAO,MAAM;AACL,aAAA,KAAK,UAAU,KAAK,IAAI,KAAK,UAAU,KAAK,GAAG,OAAO,CAAM,OAAA,OAAO,EAAE;AAAA,IAC7E;AAAA,EAAA;AAAA,EAGM,KAAwB,OAAU,MAA+C;AACvF,UAAM,SAA6B,CAAC;AACpC,eAAW,MAAM,KAAK,UAAU,KAAK,KAAK,CAAA,GAAI;AACtC,aAAA,KAAK,GAAG,IAAI,CAAC;AAAA,IAAA;AAEd,WAAA;AAAA,EAAA;AAET;"}
@@ -1,70 +0,0 @@
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
@@ -1 +0,0 @@
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,EAAA;AAAA,EAIT,MAAa,IAAI,MAAsC;AAChD,UAAA,EAAE,QAAQ,QAAA,IAAY;AAC5B,QAAI,eAAe;AACb,UAAA,kBAAkB,IAAI,gBAAgB;AACxC,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,EAAG,CAAA;AAAA,cAAA,CACzE;AACc,6BAAA;AACP,sBAAA;AACK,2BAAA;AAAA,qBACL,GAAG;AACX,4BAAc,CAAC;AAAA,YAAA;AAAA,UAChB,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,YAAA;AAAA,UACtC,OACM;AACN,mBAAO,MAAM,8BAA8B;AAAA,cAC1C,OAAO;AAAA,YAAA,CACP;AACD,gBAAI,YAAY;AACf,sBAAQ,CAAC;AAAA,YAAA,OACH;AACN,qBAAO,CAAC;AAAA,YAAA;AAET;AAAA,UAAA;AAAA,QACD;AAAA,MACD;AAAA,IACD,CACA;AAEM,WAAA;AAAA,MACN,MAAM,MAAqB;AAC1B,wBAAgB,MAAM;AACtB,cAAM,cAAc,IAAI;AAAA,MAAA;AAAA,IAE1B;AAAA,EAAA;AAEF;;"}
@@ -1,70 +0,0 @@
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
@@ -1 +0,0 @@
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,EAAA;AAAA,EAIT,MAAa,IAAI,MAAsC;AAChD,UAAA,EAAE,QAAQ,QAAA,IAAY;AAC5B,QAAI,eAAe;AACb,UAAA,kBAAkB,IAAI,gBAAgB;AACxC,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,EAAG,CAAA;AAAA,cAAA,CACzE;AACc,6BAAA;AACP,sBAAA;AACK,2BAAA;AAAA,qBACL,GAAG;AACX,4BAAc,CAAC;AAAA,YAAA;AAAA,UAChB,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,YAAA;AAAA,UACtC,OACM;AACN,mBAAO,MAAM,8BAA8B;AAAA,cAC1C,OAAO;AAAA,YAAA,CACP;AACD,gBAAI,YAAY;AACf,sBAAQ,CAAC;AAAA,YAAA,OACH;AACN,qBAAO,CAAC;AAAA,YAAA;AAET;AAAA,UAAA;AAAA,QACD;AAAA,MACD;AAAA,IACD,CACA;AAEM,WAAA;AAAA,MACN,MAAM,MAAqB;AAC1B,wBAAgB,MAAM;AACtB,cAAM,cAAc,IAAI;AAAA,MAAA;AAAA,IAE1B;AAAA,EAAA;AAEF;"}
@@ -1,20 +0,0 @@
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
@@ -1 +0,0 @@
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,QAAQ;AAAA,EAAA;AAGxB,MAAI,UAA0B,CAAC;AAEzB,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,GAAA,CAAI;AAC3B;;"}
@@ -1,20 +0,0 @@
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
@@ -1 +0,0 @@
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,QAAQ;AAAA,EAAA;AAGxB,MAAI,UAA0B,CAAC;AAEzB,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,GAAA,CAAI;AAC3B;"}
@@ -1,20 +0,0 @@
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
@@ -1 +0,0 @@
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,IAAA;AAER,UAAA,WAAW,UAAU,GAAG;AACzB,SAAA,IAAI,KAAK,QAAQ;AAClB,QAAA;AACH,aAAO,MAAM;AAAA,aACL,GAAG;AACX,WAAK,OAAO,GAAG;AACT,YAAA;AAAA,IAAA;AAAA,EACP;AAEF;;"}
@@ -1,20 +0,0 @@
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
@@ -1 +0,0 @@
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,IAAA;AAER,UAAA,WAAW,UAAU,GAAG;AACzB,SAAA,IAAI,KAAK,QAAQ;AAClB,QAAA;AACH,aAAO,MAAM;AAAA,aACL,GAAG;AACX,WAAK,OAAO,GAAG;AACT,YAAA;AAAA,IAAA;AAAA,EACP;AAEF;"}
@@ -1,11 +0,0 @@
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
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;"}
@@ -1,11 +0,0 @@
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
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;"}