@tstdl/base 0.84.15 → 0.84.16
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.
|
@@ -7,8 +7,7 @@ export declare class Application {
|
|
|
7
7
|
private static _instance;
|
|
8
8
|
private static get instance();
|
|
9
9
|
private readonly logger;
|
|
10
|
-
private readonly
|
|
11
|
-
private readonly moduleInstances;
|
|
10
|
+
private readonly moduleTypesAndInstances;
|
|
12
11
|
private readonly shutdownPromise;
|
|
13
12
|
private readonly _shutdownToken;
|
|
14
13
|
get shutdownToken(): ReadonlyCancellationToken;
|
|
@@ -16,14 +15,12 @@ export declare class Application {
|
|
|
16
15
|
constructor(logger: Logger);
|
|
17
16
|
static registerModule(moduleType: Type<Module>): void;
|
|
18
17
|
static registerModuleFunction(fn: FunctionModuleFunction): void;
|
|
19
|
-
static registerModuleInstance(module: Module): void;
|
|
20
18
|
static run(...functionsAndModules: OneOrMany<FunctionModuleFunction | Type<Module>>[]): void;
|
|
21
19
|
static waitForShutdown(): Promise<void>;
|
|
22
20
|
static shutdown(): Promise<void>;
|
|
23
21
|
static requestShutdown(): void;
|
|
24
|
-
registerModule(moduleType: Type<Module>): void;
|
|
22
|
+
registerModule(moduleType: Module | Type<Module>): void;
|
|
25
23
|
registerModuleFunction(fn: FunctionModuleFunction): void;
|
|
26
|
-
registerModuleInstance(module: Module): void;
|
|
27
24
|
run(...functionsAndModules: OneOrMany<FunctionModuleFunction | Type<Module>>[]): void;
|
|
28
25
|
shutdown(): Promise<void>;
|
|
29
26
|
requestShutdown(): void;
|
|
@@ -63,8 +63,7 @@ let Application = Application_1 = class Application2 {
|
|
|
63
63
|
return this._instance;
|
|
64
64
|
}
|
|
65
65
|
logger;
|
|
66
|
-
|
|
67
|
-
moduleInstances;
|
|
66
|
+
moduleTypesAndInstances;
|
|
68
67
|
shutdownPromise;
|
|
69
68
|
_shutdownToken;
|
|
70
69
|
get shutdownToken() {
|
|
@@ -75,8 +74,7 @@ let Application = Application_1 = class Application2 {
|
|
|
75
74
|
}
|
|
76
75
|
constructor(logger) {
|
|
77
76
|
this.logger = logger;
|
|
78
|
-
this.
|
|
79
|
-
this.moduleInstances = /* @__PURE__ */ new Set();
|
|
77
|
+
this.moduleTypesAndInstances = /* @__PURE__ */ new Set();
|
|
80
78
|
this.shutdownPromise = new import_deferred_promise.DeferredPromise();
|
|
81
79
|
this._shutdownToken = import_process_shutdown.shutdownToken.createChild();
|
|
82
80
|
}
|
|
@@ -86,9 +84,6 @@ let Application = Application_1 = class Application2 {
|
|
|
86
84
|
static registerModuleFunction(fn) {
|
|
87
85
|
Application_1.instance.registerModuleFunction(fn);
|
|
88
86
|
}
|
|
89
|
-
static registerModuleInstance(module2) {
|
|
90
|
-
Application_1.instance.registerModuleInstance(module2);
|
|
91
|
-
}
|
|
92
87
|
static run(...functionsAndModules) {
|
|
93
88
|
Application_1.instance.run(...functionsAndModules);
|
|
94
89
|
}
|
|
@@ -102,14 +97,11 @@ let Application = Application_1 = class Application2 {
|
|
|
102
97
|
Application_1.instance.requestShutdown();
|
|
103
98
|
}
|
|
104
99
|
registerModule(moduleType) {
|
|
105
|
-
this.
|
|
100
|
+
this.moduleTypesAndInstances.add(moduleType);
|
|
106
101
|
}
|
|
107
102
|
registerModuleFunction(fn) {
|
|
108
103
|
const module2 = new import_function_module.FunctionModule(fn);
|
|
109
|
-
this.
|
|
110
|
-
}
|
|
111
|
-
registerModuleInstance(module2) {
|
|
112
|
-
this.moduleInstances.add(module2);
|
|
104
|
+
this.registerModule(module2);
|
|
113
105
|
}
|
|
114
106
|
run(...functionsAndModules) {
|
|
115
107
|
void this._run(...functionsAndModules);
|
|
@@ -135,8 +127,7 @@ let Application = Application_1 = class Application2 {
|
|
|
135
127
|
this.registerModuleFunction(fnOrModule);
|
|
136
128
|
}
|
|
137
129
|
}
|
|
138
|
-
const
|
|
139
|
-
const modules = [...this.moduleInstances, ...resolvedModules];
|
|
130
|
+
const modules = await (0, import_to_array.toArrayAsync)((0, import_map.mapAsync)(this.moduleTypesAndInstances, async (instanceOrType) => (0, import_type_guards.isFunction)(instanceOrType) ? import_container.container.resolveAsync(instanceOrType) : instanceOrType));
|
|
140
131
|
try {
|
|
141
132
|
await Promise.race([
|
|
142
133
|
this.runModules(modules),
|