moost 0.5.21 → 0.5.23
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/LICENSE +21 -0
- package/dist/index.cjs +946 -928
- package/dist/index.d.ts +12 -350
- package/dist/index.mjs +824 -860
- package/package.json +19 -8
package/dist/index.cjs
CHANGED
|
@@ -1,1086 +1,1104 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
//#region rolldown:runtime
|
|
3
|
+
var __create = Object.create;
|
|
4
|
+
var __defProp = Object.defineProperty;
|
|
5
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
8
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
11
|
+
key = keys[i];
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
13
|
+
get: ((k) => from[k]).bind(null, key),
|
|
14
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
20
|
+
value: mod,
|
|
21
|
+
enumerable: true
|
|
22
|
+
}) : target, mod));
|
|
2
23
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
24
|
+
//#endregion
|
|
25
|
+
const __prostojs_mate = __toESM(require("@prostojs/mate"));
|
|
26
|
+
const __wooksjs_event_core = __toESM(require("@wooksjs/event-core"));
|
|
27
|
+
const __prostojs_infact = __toESM(require("@prostojs/infact"));
|
|
28
|
+
const __prostojs_logger = __toESM(require("@prostojs/logger"));
|
|
29
|
+
const hookable = __toESM(require("hookable"));
|
|
30
|
+
const wooks = __toESM(require("wooks"));
|
|
9
31
|
|
|
32
|
+
//#region packages/moost/src/logger.ts
|
|
10
33
|
let defaultLogger;
|
|
11
34
|
function setDefaultLogger(logger) {
|
|
12
|
-
|
|
35
|
+
defaultLogger = logger;
|
|
13
36
|
}
|
|
14
37
|
function getDefaultLogger(topic) {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
format: logger.coloredConsole,
|
|
21
|
-
}),
|
|
22
|
-
],
|
|
23
|
-
});
|
|
24
|
-
}
|
|
25
|
-
return topic && defaultLogger instanceof logger.ProstoLogger
|
|
26
|
-
? defaultLogger.createTopic(topic)
|
|
27
|
-
: defaultLogger;
|
|
38
|
+
if (!defaultLogger) defaultLogger = new __prostojs_logger.ProstoLogger({
|
|
39
|
+
level: 4,
|
|
40
|
+
transports: [(0, __prostojs_logger.createConsoleTransort)({ format: __prostojs_logger.coloredConsole })]
|
|
41
|
+
});
|
|
42
|
+
return topic && defaultLogger instanceof __prostojs_logger.ProstoLogger ? defaultLogger.createTopic(topic) : defaultLogger;
|
|
28
43
|
}
|
|
29
44
|
|
|
45
|
+
//#endregion
|
|
46
|
+
//#region packages/moost/src/pipes/run-pipes.ts
|
|
30
47
|
async function runPipes(pipes, initialValue, metas, level) {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
}
|
|
35
|
-
return v;
|
|
48
|
+
let v = initialValue;
|
|
49
|
+
for (const pipe of pipes) v = await pipe.handler(v, metas, level);
|
|
50
|
+
return v;
|
|
36
51
|
}
|
|
37
52
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
return !!targetMeta?.inherit;
|
|
51
|
-
},
|
|
53
|
+
//#endregion
|
|
54
|
+
//#region packages/moost/src/metadata/moost-metadata.ts
|
|
55
|
+
const METADATA_WORKSPACE = "moost";
|
|
56
|
+
const moostMate = new __prostojs_mate.Mate(METADATA_WORKSPACE, {
|
|
57
|
+
readType: true,
|
|
58
|
+
readReturnType: true,
|
|
59
|
+
collectPropKeys: true,
|
|
60
|
+
inherit(classMeta, targetMeta, level) {
|
|
61
|
+
if (level === "CLASS") return !!classMeta?.inherit;
|
|
62
|
+
if (level === "PROP") return !!targetMeta?.inherit || !!(classMeta?.inherit && !targetMeta);
|
|
63
|
+
return !!targetMeta?.inherit;
|
|
64
|
+
}
|
|
52
65
|
});
|
|
53
66
|
function getMoostMate() {
|
|
54
|
-
|
|
67
|
+
return moostMate;
|
|
55
68
|
}
|
|
56
69
|
|
|
70
|
+
//#endregion
|
|
71
|
+
//#region packages/moost/src/metadata/infact.ts
|
|
57
72
|
const sharedMoostInfact = getNewMoostInfact();
|
|
58
|
-
const INFACT_BANNER = `${
|
|
73
|
+
const INFACT_BANNER = `${"\x1B[2m\x1B[35m"}infact`;
|
|
59
74
|
let loggingOptions = {
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
75
|
+
newInstance: "SINGLETON",
|
|
76
|
+
warn: true,
|
|
77
|
+
error: true
|
|
63
78
|
};
|
|
64
79
|
function setInfactLoggingOptions(options) {
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
80
|
+
loggingOptions = {
|
|
81
|
+
...loggingOptions,
|
|
82
|
+
...options
|
|
83
|
+
};
|
|
69
84
|
}
|
|
70
85
|
function getMoostInfact() {
|
|
71
|
-
|
|
86
|
+
return sharedMoostInfact;
|
|
72
87
|
}
|
|
73
88
|
const scopeVarsMap = new Map();
|
|
74
89
|
function defineInfactScope(name, scopeVars) {
|
|
75
|
-
|
|
76
|
-
|
|
90
|
+
scopeVarsMap.set(name, scopeVars);
|
|
91
|
+
getMoostInfact().registerScope(name);
|
|
77
92
|
}
|
|
78
93
|
function getInfactScopeVars(name) {
|
|
79
|
-
|
|
94
|
+
return scopeVarsMap.get(name);
|
|
80
95
|
}
|
|
81
96
|
function getNewMoostInfact() {
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
return '{}';
|
|
177
|
-
}
|
|
178
|
-
default: {
|
|
179
|
-
return '*';
|
|
180
|
-
}
|
|
181
|
-
}
|
|
182
|
-
})
|
|
183
|
-
.map(a => `${'[2m' + '[1m'}${a}${'[22m' + '[2m'}`)
|
|
184
|
-
.join(', ') || '';
|
|
185
|
-
logger.info(`new ${instance}${'[2m' + '[34m'}(${params})`);
|
|
186
|
-
break;
|
|
187
|
-
}
|
|
188
|
-
case 'warn': {
|
|
189
|
-
const hier = `${'[2m' + '[34m'}⋱ ${args?.map(String).join(' → ') || ''}`;
|
|
190
|
-
logger.warn(`${instance} - ${message} ${hier}`);
|
|
191
|
-
break;
|
|
192
|
-
}
|
|
193
|
-
case 'error': {
|
|
194
|
-
const hier = `${'[2m' + '[34m'}⋱ ${args?.map(String).join(' → ') || ''}`;
|
|
195
|
-
logger.error(`Failed to instantiate ${instance}. ${message} ${hier}`);
|
|
196
|
-
break;
|
|
197
|
-
}
|
|
198
|
-
}
|
|
199
|
-
},
|
|
200
|
-
});
|
|
97
|
+
return new __prostojs_infact.Infact({
|
|
98
|
+
describeClass(classConstructor) {
|
|
99
|
+
const meta = getMoostMate().read(classConstructor);
|
|
100
|
+
return {
|
|
101
|
+
injectable: !!meta?.injectable,
|
|
102
|
+
global: false,
|
|
103
|
+
constructorParams: meta?.params || [],
|
|
104
|
+
provide: meta?.provide,
|
|
105
|
+
properties: meta?.properties || [],
|
|
106
|
+
scopeId: meta?.injectable === "FOR_EVENT" ? (0, __wooksjs_event_core.useEventId)().getId() : undefined
|
|
107
|
+
};
|
|
108
|
+
},
|
|
109
|
+
resolveParam({ paramMeta, customData, classConstructor, index, scopeId }) {
|
|
110
|
+
if (paramMeta && customData?.pipes) return runPipes(customData.pipes, undefined, {
|
|
111
|
+
paramMeta,
|
|
112
|
+
type: classConstructor,
|
|
113
|
+
key: "constructor",
|
|
114
|
+
scopeId,
|
|
115
|
+
classMeta: getMoostMate().read(classConstructor),
|
|
116
|
+
index,
|
|
117
|
+
targetMeta: paramMeta
|
|
118
|
+
}, "PARAM");
|
|
119
|
+
},
|
|
120
|
+
describeProp(classConstructor, key) {
|
|
121
|
+
const meta = getMoostMate().read(classConstructor, key);
|
|
122
|
+
return meta;
|
|
123
|
+
},
|
|
124
|
+
resolveProp({ instance, key, initialValue, propMeta, scopeId, classMeta, customData, classConstructor }) {
|
|
125
|
+
if (propMeta && customData?.pipes) return runPipes(customData.pipes, initialValue, {
|
|
126
|
+
instance,
|
|
127
|
+
type: classConstructor,
|
|
128
|
+
key,
|
|
129
|
+
scopeId,
|
|
130
|
+
propMeta,
|
|
131
|
+
targetMeta: propMeta,
|
|
132
|
+
classMeta
|
|
133
|
+
}, "PROP");
|
|
134
|
+
},
|
|
135
|
+
storeProvideRegByInstance: true,
|
|
136
|
+
on: (event, targetClass, message, args) => {
|
|
137
|
+
switch (event) {
|
|
138
|
+
case "new-instance": {
|
|
139
|
+
const scope = getMoostMate().read(targetClass)?.injectable || "SINGLETON";
|
|
140
|
+
if (loggingOptions.newInstance === false || !(loggingOptions.newInstance === scope || loggingOptions.newInstance === "SINGLETON" && scope === true)) return;
|
|
141
|
+
break;
|
|
142
|
+
}
|
|
143
|
+
case "warn": {
|
|
144
|
+
if (!loggingOptions.warn) return;
|
|
145
|
+
break;
|
|
146
|
+
}
|
|
147
|
+
case "error": {
|
|
148
|
+
if (!loggingOptions.error) return;
|
|
149
|
+
break;
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
let logger;
|
|
153
|
+
try {
|
|
154
|
+
logger = event === "error" ? getDefaultLogger(INFACT_BANNER) : (0, __wooksjs_event_core.useEventLogger)(INFACT_BANNER);
|
|
155
|
+
} catch (error) {
|
|
156
|
+
logger = getDefaultLogger(INFACT_BANNER);
|
|
157
|
+
}
|
|
158
|
+
const instance = `${"\x1B[4m"}${targetClass.name}${"\x1B[24m"}`;
|
|
159
|
+
switch (event) {
|
|
160
|
+
case "new-instance": {
|
|
161
|
+
const params = args?.map((a) => {
|
|
162
|
+
switch (typeof a) {
|
|
163
|
+
case "number":
|
|
164
|
+
case "boolean": return `${"\x1B[33m"}${a}${"\x1B[2m\x1B[34m"}`;
|
|
165
|
+
case "string": return `${"\x1B[92m"}"${a.slice(0, 1)}..."${"\x1B[2m\x1B[34m"}`;
|
|
166
|
+
case "object": {
|
|
167
|
+
if (Array.isArray(a)) return `[${a.length}]`;
|
|
168
|
+
if ((0, __prostojs_mate.getConstructor)(a)) return (0, __prostojs_mate.getConstructor)(a).name;
|
|
169
|
+
return "{}";
|
|
170
|
+
}
|
|
171
|
+
default: return "*";
|
|
172
|
+
}
|
|
173
|
+
}).map((a) => `${"\x1B[2m\x1B[1m"}${a}${"\x1B[22m\x1B[2m"}`).join(", ") || "";
|
|
174
|
+
logger.info(`new ${instance}${"\x1B[2m\x1B[34m"}(${params})`);
|
|
175
|
+
break;
|
|
176
|
+
}
|
|
177
|
+
case "warn": {
|
|
178
|
+
const hier = `${"\x1B[2m\x1B[34m"}⋱ ${args?.map(String).join(" → ") || ""}`;
|
|
179
|
+
logger.warn(`${instance} - ${message} ${hier}`);
|
|
180
|
+
break;
|
|
181
|
+
}
|
|
182
|
+
case "error": {
|
|
183
|
+
const hier = `${"\x1B[2m\x1B[34m"}⋱ ${args?.map(String).join(" → ") || ""}`;
|
|
184
|
+
logger.error(`Failed to instantiate ${instance}. ${message} ${hier}`);
|
|
185
|
+
break;
|
|
186
|
+
}
|
|
187
|
+
default: break;
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
});
|
|
201
191
|
}
|
|
202
192
|
|
|
193
|
+
//#endregion
|
|
194
|
+
//#region packages/moost/src/composables/controller.composable.ts
|
|
203
195
|
function setControllerContext(controller, method, route) {
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
196
|
+
const { store } = (0, __wooksjs_event_core.useAsyncEventContext)();
|
|
197
|
+
const { set } = store("controller");
|
|
198
|
+
set("instance", controller);
|
|
199
|
+
set("method", method);
|
|
200
|
+
set("route", route);
|
|
209
201
|
}
|
|
210
202
|
function useControllerContext() {
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
203
|
+
const { store } = (0, __wooksjs_event_core.useAsyncEventContext)();
|
|
204
|
+
const { get } = store("controller");
|
|
205
|
+
const getController = () => get("instance");
|
|
206
|
+
const getMethod = () => get("method");
|
|
207
|
+
const getRoute = () => get("route");
|
|
208
|
+
const getControllerMeta = () => getMoostMate().read(getController());
|
|
209
|
+
const getMethodMeta = (name) => getMoostMate().read(getController(), name || getMethod());
|
|
210
|
+
function instantiate(c) {
|
|
211
|
+
return getMoostInfact().getForInstance(getController(), c);
|
|
212
|
+
}
|
|
213
|
+
return {
|
|
214
|
+
instantiate,
|
|
215
|
+
getRoute,
|
|
216
|
+
getController,
|
|
217
|
+
getMethod,
|
|
218
|
+
getControllerMeta,
|
|
219
|
+
getMethodMeta,
|
|
220
|
+
getPropertiesList: () => getControllerMeta()?.properties || [],
|
|
221
|
+
getScope: () => getControllerMeta()?.injectable || "SINGLETON",
|
|
222
|
+
getParamsMeta: () => getMethodMeta()?.params || [],
|
|
223
|
+
getPropMeta: (name) => getMethodMeta(name)
|
|
224
|
+
};
|
|
233
225
|
}
|
|
234
226
|
|
|
227
|
+
//#endregion
|
|
228
|
+
//#region packages/moost/src/adapter-utils.ts
|
|
235
229
|
const infact = getMoostInfact();
|
|
236
230
|
function registerEventScope(scopeId) {
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
231
|
+
infact.registerScope(scopeId);
|
|
232
|
+
return () => {
|
|
233
|
+
infact.unregisterScope(scopeId);
|
|
234
|
+
};
|
|
241
235
|
}
|
|
242
236
|
function defineMoostEventHandler(options) {
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
options.logErrors && logger.error(error);
|
|
314
|
-
response = error;
|
|
315
|
-
return endWithResponse(true);
|
|
316
|
-
}
|
|
317
|
-
async function endWithResponse(raise = false) {
|
|
318
|
-
if (interceptorHandler?.countAfter || interceptorHandler?.countOnError) {
|
|
319
|
-
try {
|
|
320
|
-
response = await ci.with('Interceptors:after', () => interceptorHandler.fireAfter(response));
|
|
321
|
-
}
|
|
322
|
-
catch (error) {
|
|
323
|
-
options.logErrors && logger.error(error);
|
|
324
|
-
if (!options.manualUnscope) {
|
|
325
|
-
unscope();
|
|
326
|
-
}
|
|
327
|
-
throw error;
|
|
328
|
-
}
|
|
329
|
-
}
|
|
330
|
-
if (!options.manualUnscope) {
|
|
331
|
-
unscope();
|
|
332
|
-
}
|
|
333
|
-
if (options.hooks?.end) {
|
|
334
|
-
await options.hooks.end(hookOptions);
|
|
335
|
-
}
|
|
336
|
-
if (raise) {
|
|
337
|
-
throw response;
|
|
338
|
-
}
|
|
339
|
-
return response;
|
|
340
|
-
}
|
|
341
|
-
return endWithResponse();
|
|
342
|
-
};
|
|
237
|
+
const ci = (0, __wooksjs_event_core.getContextInjector)();
|
|
238
|
+
return async () => {
|
|
239
|
+
const scopeId = (0, __wooksjs_event_core.useEventId)().getId();
|
|
240
|
+
const logger = (0, __wooksjs_event_core.useEventLogger)(options.loggerTitle);
|
|
241
|
+
const unscope = registerEventScope(scopeId);
|
|
242
|
+
let response;
|
|
243
|
+
const hookOptions = {
|
|
244
|
+
scopeId,
|
|
245
|
+
logger,
|
|
246
|
+
unscope,
|
|
247
|
+
method: options.controllerMethod,
|
|
248
|
+
getResponse: () => response,
|
|
249
|
+
reply: (r) => response = r
|
|
250
|
+
};
|
|
251
|
+
if (options.hooks?.init) await options.hooks.init(hookOptions);
|
|
252
|
+
const instance = await options.getControllerInstance();
|
|
253
|
+
if (instance) {
|
|
254
|
+
setControllerContext(instance, options.controllerMethod || "", options.targetPath);
|
|
255
|
+
ci.hook(options.handlerType, "Controller:registered");
|
|
256
|
+
}
|
|
257
|
+
const interceptorHandler = await options.getIterceptorHandler();
|
|
258
|
+
if (interceptorHandler?.count) try {
|
|
259
|
+
response = await ci.with("Interceptors:init", () => interceptorHandler.init());
|
|
260
|
+
if (response !== undefined) return await endWithResponse();
|
|
261
|
+
} catch (error) {
|
|
262
|
+
options.logErrors && logger.error(error);
|
|
263
|
+
response = error;
|
|
264
|
+
return endWithResponse(true);
|
|
265
|
+
}
|
|
266
|
+
let args = [];
|
|
267
|
+
if (options.resolveArgs) try {
|
|
268
|
+
args = await ci.with("Arguments:resolve", () => options.resolveArgs());
|
|
269
|
+
} catch (error) {
|
|
270
|
+
options.logErrors && logger.error(error);
|
|
271
|
+
response = error;
|
|
272
|
+
return endWithResponse(true);
|
|
273
|
+
}
|
|
274
|
+
if (interceptorHandler?.countBefore) {
|
|
275
|
+
response = await ci.with("Interceptors:before", () => interceptorHandler.fireBefore(response));
|
|
276
|
+
if (response !== undefined) return endWithResponse();
|
|
277
|
+
}
|
|
278
|
+
const callControllerMethod = () => {
|
|
279
|
+
if (options.callControllerMethod) return options.callControllerMethod(args);
|
|
280
|
+
else if (instance && options.controllerMethod && typeof instance[options.controllerMethod] === "function") return instance[options.controllerMethod](...args);
|
|
281
|
+
};
|
|
282
|
+
try {
|
|
283
|
+
response = await ci.with(`Handler:${options.targetPath}`, {
|
|
284
|
+
"moost.handler": options.controllerMethod || "",
|
|
285
|
+
"moost.controller": (0, __prostojs_mate.getConstructor)(instance).name
|
|
286
|
+
}, () => callControllerMethod());
|
|
287
|
+
} catch (error) {
|
|
288
|
+
options.logErrors && logger.error(error);
|
|
289
|
+
response = error;
|
|
290
|
+
return endWithResponse(true);
|
|
291
|
+
}
|
|
292
|
+
async function endWithResponse(raise = false) {
|
|
293
|
+
if (interceptorHandler?.countAfter || interceptorHandler?.countOnError) try {
|
|
294
|
+
response = await ci.with("Interceptors:after", () => interceptorHandler.fireAfter(response));
|
|
295
|
+
} catch (error) {
|
|
296
|
+
options.logErrors && logger.error(error);
|
|
297
|
+
if (!options.manualUnscope) unscope();
|
|
298
|
+
throw error;
|
|
299
|
+
}
|
|
300
|
+
if (!options.manualUnscope) unscope();
|
|
301
|
+
if (options.hooks?.end) await options.hooks.end(hookOptions);
|
|
302
|
+
if (raise) throw response;
|
|
303
|
+
return response;
|
|
304
|
+
}
|
|
305
|
+
return endWithResponse();
|
|
306
|
+
};
|
|
343
307
|
}
|
|
344
308
|
|
|
309
|
+
//#endregion
|
|
310
|
+
//#region packages/moost/src/binding/utils.ts
|
|
345
311
|
function getInstanceOwnMethods(instance) {
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
312
|
+
const proto = Object.getPrototypeOf(instance);
|
|
313
|
+
return [
|
|
314
|
+
...getParentProps((0, __prostojs_mate.getConstructor)(instance)),
|
|
315
|
+
...Object.getOwnPropertyNames(proto),
|
|
316
|
+
...Object.getOwnPropertyNames(instance)
|
|
317
|
+
].filter((m) => typeof instance[m] === "function");
|
|
352
318
|
}
|
|
353
319
|
function getInstanceOwnProps(instance) {
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
320
|
+
const proto = Object.getPrototypeOf(instance);
|
|
321
|
+
return [
|
|
322
|
+
...getParentProps((0, __prostojs_mate.getConstructor)(instance)),
|
|
323
|
+
...Object.getOwnPropertyNames(proto),
|
|
324
|
+
...Object.getOwnPropertyNames(instance)
|
|
325
|
+
].filter((m) => typeof instance[m] !== "function");
|
|
360
326
|
}
|
|
361
327
|
const fnProto = Object.getPrototypeOf(Function);
|
|
362
328
|
function getParentProps(constructor) {
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
parent !== constructor &&
|
|
367
|
-
parent.prototype) {
|
|
368
|
-
return [...getParentProps(parent), ...Object.getOwnPropertyNames(parent.prototype)];
|
|
369
|
-
}
|
|
370
|
-
return [];
|
|
329
|
+
const parent = Object.getPrototypeOf(constructor);
|
|
330
|
+
if (typeof parent === "function" && parent !== fnProto && parent !== constructor && parent.prototype) return [...getParentProps(parent), ...Object.getOwnPropertyNames(parent.prototype)];
|
|
331
|
+
return [];
|
|
371
332
|
}
|
|
372
333
|
|
|
334
|
+
//#endregion
|
|
335
|
+
//#region packages/moost/src/class-function/class-function.ts
|
|
373
336
|
async function getCallableFn(targetInstance, fn, pipes, logger) {
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
if (typeof fn === 'function') {
|
|
386
|
-
return fn;
|
|
387
|
-
}
|
|
388
|
-
const e = new Error(`getCallableFn failed for "${mate$1.getConstructor(targetInstance).name}" because the passed arg is not a Function nor TClassFunction`);
|
|
389
|
-
logger.error(e);
|
|
390
|
-
throw e;
|
|
337
|
+
const mate$1 = getMoostMate();
|
|
338
|
+
const meta = mate$1.read(fn);
|
|
339
|
+
if (meta?.injectable) {
|
|
340
|
+
const infact$1 = getMoostInfact();
|
|
341
|
+
const instance = await infact$1.getForInstance(targetInstance, fn, { customData: { pipes: [...pipes || [], ...meta.pipes || []].sort((a, b) => a.priority - b.priority) } });
|
|
342
|
+
return (...args) => instance.handler(...args);
|
|
343
|
+
}
|
|
344
|
+
if (typeof fn === "function") return fn;
|
|
345
|
+
const e = new Error(`getCallableFn failed for "${(0, __prostojs_mate.getConstructor)(targetInstance).name}" because the passed arg is not a Function nor TClassFunction`);
|
|
346
|
+
logger.error(e);
|
|
347
|
+
throw e;
|
|
391
348
|
}
|
|
392
349
|
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
get countBefore() {
|
|
405
|
-
return this.before.length;
|
|
406
|
-
}
|
|
407
|
-
get countAfter() {
|
|
408
|
-
return this.after.length;
|
|
409
|
-
}
|
|
410
|
-
get countOnError() {
|
|
411
|
-
return this.onError.length;
|
|
412
|
-
}
|
|
413
|
-
replyFn(reply) {
|
|
414
|
-
this.response = reply;
|
|
415
|
-
this.responseOverwritten = true;
|
|
416
|
-
}
|
|
417
|
-
async init() {
|
|
418
|
-
const ci = eventCore.getContextInjector();
|
|
419
|
-
for (const { handler, name } of this.handlers) {
|
|
420
|
-
const response = await ci.with(`Interceptor:${name}`, {
|
|
421
|
-
'moost.interceptor.stage': 'init',
|
|
422
|
-
}, () => handler(fn => {
|
|
423
|
-
this.before.push({ name, fn });
|
|
424
|
-
}, fn => {
|
|
425
|
-
this.after.unshift({ name, fn });
|
|
426
|
-
}, fn => {
|
|
427
|
-
this.onError.unshift({ name, fn });
|
|
428
|
-
}));
|
|
429
|
-
if (response !== undefined) {
|
|
430
|
-
return response;
|
|
431
|
-
}
|
|
432
|
-
}
|
|
433
|
-
}
|
|
434
|
-
async fireBefore(response) {
|
|
435
|
-
const ci = eventCore.getContextInjector();
|
|
436
|
-
this.response = response;
|
|
437
|
-
for (const { name, fn } of this.before) {
|
|
438
|
-
await ci.with(`Interceptor:${name}`, {
|
|
439
|
-
'moost.interceptor.stage': 'before',
|
|
440
|
-
}, () => fn(this.replyFn.bind(this)));
|
|
441
|
-
if (this.responseOverwritten) {
|
|
442
|
-
break;
|
|
443
|
-
}
|
|
444
|
-
}
|
|
445
|
-
return this.response;
|
|
446
|
-
}
|
|
447
|
-
async fireAfter(response) {
|
|
448
|
-
const ci = eventCore.getContextInjector();
|
|
449
|
-
this.response = response;
|
|
450
|
-
if (response instanceof Error) {
|
|
451
|
-
for (const { name, fn } of this.onError) {
|
|
452
|
-
await ci.with(`Interceptor:${name}`, {
|
|
453
|
-
'moost.interceptor.stage': 'after',
|
|
454
|
-
}, () => fn(response, this.replyFn.bind(this)));
|
|
455
|
-
}
|
|
456
|
-
}
|
|
457
|
-
else {
|
|
458
|
-
for (const { name, fn } of this.after) {
|
|
459
|
-
await ci.with(`Interceptor:${name}`, {
|
|
460
|
-
'moost.interceptor.stage': 'onError',
|
|
461
|
-
}, () => fn(response, this.replyFn.bind(this)));
|
|
462
|
-
}
|
|
463
|
-
}
|
|
464
|
-
return this.response;
|
|
465
|
-
}
|
|
350
|
+
//#endregion
|
|
351
|
+
//#region packages/moost/src/interceptor-handler.ts
|
|
352
|
+
function _define_property$1(obj, key, value) {
|
|
353
|
+
if (key in obj) Object.defineProperty(obj, key, {
|
|
354
|
+
value,
|
|
355
|
+
enumerable: true,
|
|
356
|
+
configurable: true,
|
|
357
|
+
writable: true
|
|
358
|
+
});
|
|
359
|
+
else obj[key] = value;
|
|
360
|
+
return obj;
|
|
466
361
|
}
|
|
362
|
+
var InterceptorHandler = class {
|
|
363
|
+
get count() {
|
|
364
|
+
return this.handlers.length;
|
|
365
|
+
}
|
|
366
|
+
get countBefore() {
|
|
367
|
+
return this.before.length;
|
|
368
|
+
}
|
|
369
|
+
get countAfter() {
|
|
370
|
+
return this.after.length;
|
|
371
|
+
}
|
|
372
|
+
get countOnError() {
|
|
373
|
+
return this.onError.length;
|
|
374
|
+
}
|
|
375
|
+
replyFn(reply) {
|
|
376
|
+
this.response = reply;
|
|
377
|
+
this.responseOverwritten = true;
|
|
378
|
+
}
|
|
379
|
+
async init() {
|
|
380
|
+
const ci = (0, __wooksjs_event_core.getContextInjector)();
|
|
381
|
+
for (const { handler, name } of this.handlers) {
|
|
382
|
+
const response = await ci.with(`Interceptor:${name}`, { "moost.interceptor.stage": "init" }, () => handler((fn) => {
|
|
383
|
+
this.before.push({
|
|
384
|
+
name,
|
|
385
|
+
fn
|
|
386
|
+
});
|
|
387
|
+
}, (fn) => {
|
|
388
|
+
this.after.unshift({
|
|
389
|
+
name,
|
|
390
|
+
fn
|
|
391
|
+
});
|
|
392
|
+
}, (fn) => {
|
|
393
|
+
this.onError.unshift({
|
|
394
|
+
name,
|
|
395
|
+
fn
|
|
396
|
+
});
|
|
397
|
+
}));
|
|
398
|
+
if (response !== undefined) return response;
|
|
399
|
+
}
|
|
400
|
+
}
|
|
401
|
+
async fireBefore(response) {
|
|
402
|
+
const ci = (0, __wooksjs_event_core.getContextInjector)();
|
|
403
|
+
this.response = response;
|
|
404
|
+
for (const { name, fn } of this.before) {
|
|
405
|
+
await ci.with(`Interceptor:${name}`, { "moost.interceptor.stage": "before" }, () => fn(this.replyFn.bind(this)));
|
|
406
|
+
if (this.responseOverwritten) break;
|
|
407
|
+
}
|
|
408
|
+
return this.response;
|
|
409
|
+
}
|
|
410
|
+
async fireAfter(response) {
|
|
411
|
+
const ci = (0, __wooksjs_event_core.getContextInjector)();
|
|
412
|
+
this.response = response;
|
|
413
|
+
if (response instanceof Error) for (const { name, fn } of this.onError) await ci.with(`Interceptor:${name}`, { "moost.interceptor.stage": "after" }, () => fn(response, this.replyFn.bind(this)));
|
|
414
|
+
else for (const { name, fn } of this.after) await ci.with(`Interceptor:${name}`, { "moost.interceptor.stage": "onError" }, () => fn(response, this.replyFn.bind(this)));
|
|
415
|
+
return this.response;
|
|
416
|
+
}
|
|
417
|
+
constructor(handlers) {
|
|
418
|
+
_define_property$1(this, "handlers", void 0);
|
|
419
|
+
_define_property$1(this, "before", void 0);
|
|
420
|
+
_define_property$1(this, "after", void 0);
|
|
421
|
+
_define_property$1(this, "onError", void 0);
|
|
422
|
+
_define_property$1(this, "response", void 0);
|
|
423
|
+
_define_property$1(this, "responseOverwritten", void 0);
|
|
424
|
+
this.handlers = handlers;
|
|
425
|
+
this.before = [];
|
|
426
|
+
this.after = [];
|
|
427
|
+
this.onError = [];
|
|
428
|
+
this.responseOverwritten = false;
|
|
429
|
+
}
|
|
430
|
+
};
|
|
467
431
|
|
|
432
|
+
//#endregion
|
|
433
|
+
//#region packages/moost/src/utils.ts
|
|
468
434
|
const mate = getMoostMate();
|
|
469
435
|
function getIterceptorHandlerFactory(interceptors, getTargetInstance, pipes, logger) {
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
};
|
|
436
|
+
return () => {
|
|
437
|
+
const interceptorHandlers = [];
|
|
438
|
+
for (const { handler, name } of interceptors) {
|
|
439
|
+
const interceptorMeta = mate.read(handler);
|
|
440
|
+
if (interceptorMeta?.injectable) interceptorHandlers.push({
|
|
441
|
+
handler: async (...args) => {
|
|
442
|
+
const targetInstance = await getTargetInstance();
|
|
443
|
+
return (await getCallableFn(targetInstance, handler, pipes, logger))(...args);
|
|
444
|
+
},
|
|
445
|
+
name
|
|
446
|
+
});
|
|
447
|
+
else interceptorHandlers.push({
|
|
448
|
+
handler,
|
|
449
|
+
name
|
|
450
|
+
});
|
|
451
|
+
}
|
|
452
|
+
return Promise.resolve(new InterceptorHandler(interceptorHandlers));
|
|
453
|
+
};
|
|
489
454
|
}
|
|
490
455
|
|
|
456
|
+
//#endregion
|
|
457
|
+
//#region packages/moost/src/binding/bind-controller.ts
|
|
491
458
|
async function bindControllerMethods(options) {
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
const data = wm.get(h);
|
|
573
|
-
if (data) {
|
|
574
|
-
data.registeredAs.push({
|
|
575
|
-
path,
|
|
576
|
-
args,
|
|
577
|
-
});
|
|
578
|
-
}
|
|
579
|
-
},
|
|
580
|
-
});
|
|
581
|
-
}
|
|
582
|
-
}
|
|
583
|
-
return controllerOverview;
|
|
459
|
+
const opts = options || {};
|
|
460
|
+
const { getInstance } = opts;
|
|
461
|
+
const { classConstructor } = opts;
|
|
462
|
+
const { adapters } = opts;
|
|
463
|
+
opts.globalPrefix = opts.globalPrefix || "";
|
|
464
|
+
opts.provide = opts.provide || {};
|
|
465
|
+
const fakeInstance = Object.create(classConstructor.prototype);
|
|
466
|
+
const methods = getInstanceOwnMethods(fakeInstance);
|
|
467
|
+
const mate$1 = getMoostMate();
|
|
468
|
+
const meta = mate$1.read(classConstructor) || {};
|
|
469
|
+
const ownPrefix = typeof opts.replaceOwnPrefix === "string" ? opts.replaceOwnPrefix : meta.controller?.prefix || "";
|
|
470
|
+
const prefix = `${opts.globalPrefix}/${ownPrefix}`;
|
|
471
|
+
const controllerOverview = {
|
|
472
|
+
meta,
|
|
473
|
+
computedPrefix: prefix,
|
|
474
|
+
type: classConstructor,
|
|
475
|
+
handlers: []
|
|
476
|
+
};
|
|
477
|
+
for (const method of methods) {
|
|
478
|
+
const methodMeta = getMoostMate().read(fakeInstance, method) || {};
|
|
479
|
+
if (!methodMeta.handlers?.length) continue;
|
|
480
|
+
const pipes = [...opts.pipes || [], ...methodMeta.pipes || []].sort((a, b) => a.priority - b.priority);
|
|
481
|
+
const interceptors = [
|
|
482
|
+
...opts.interceptors || [],
|
|
483
|
+
...meta.interceptors || [],
|
|
484
|
+
...methodMeta.interceptors || []
|
|
485
|
+
].sort((a, b) => a.priority - b.priority);
|
|
486
|
+
const getIterceptorHandler = getIterceptorHandlerFactory(interceptors, getInstance, pipes, options.logger);
|
|
487
|
+
const argsPipes = [];
|
|
488
|
+
for (const p of methodMeta.params || []) argsPipes.push({
|
|
489
|
+
meta: p,
|
|
490
|
+
pipes: [...pipes, ...p.pipes || []].sort((a, b) => a.priority - b.priority)
|
|
491
|
+
});
|
|
492
|
+
const resolveArgs = async () => {
|
|
493
|
+
const args = [];
|
|
494
|
+
for (const [i, { pipes: pipes$1, meta: paramMeta }] of argsPipes.entries()) args[i] = await runPipes(pipes$1, undefined, {
|
|
495
|
+
classMeta: meta,
|
|
496
|
+
methodMeta,
|
|
497
|
+
paramMeta,
|
|
498
|
+
type: classConstructor,
|
|
499
|
+
key: method,
|
|
500
|
+
index: i,
|
|
501
|
+
targetMeta: paramMeta
|
|
502
|
+
}, "PARAM");
|
|
503
|
+
return args;
|
|
504
|
+
};
|
|
505
|
+
const wm = new WeakMap();
|
|
506
|
+
controllerOverview.handlers.push(...methodMeta.handlers.map((h) => {
|
|
507
|
+
const data = {
|
|
508
|
+
meta: methodMeta,
|
|
509
|
+
path: h.path,
|
|
510
|
+
type: h.type,
|
|
511
|
+
method,
|
|
512
|
+
handler: h,
|
|
513
|
+
registeredAs: []
|
|
514
|
+
};
|
|
515
|
+
wm.set(h, data);
|
|
516
|
+
return data;
|
|
517
|
+
}));
|
|
518
|
+
for (const adapter of adapters) await adapter.bindHandler({
|
|
519
|
+
prefix,
|
|
520
|
+
fakeInstance,
|
|
521
|
+
getInstance,
|
|
522
|
+
method,
|
|
523
|
+
handlers: methodMeta.handlers,
|
|
524
|
+
getIterceptorHandler,
|
|
525
|
+
resolveArgs,
|
|
526
|
+
logHandler: (eventName) => {
|
|
527
|
+
options.moostInstance.logMappedHandler(eventName, classConstructor, method);
|
|
528
|
+
},
|
|
529
|
+
register(h, path, args) {
|
|
530
|
+
const data = wm.get(h);
|
|
531
|
+
if (data) data.registeredAs.push({
|
|
532
|
+
path,
|
|
533
|
+
args
|
|
534
|
+
});
|
|
535
|
+
}
|
|
536
|
+
});
|
|
537
|
+
}
|
|
538
|
+
return controllerOverview;
|
|
584
539
|
}
|
|
585
540
|
|
|
541
|
+
//#endregion
|
|
542
|
+
//#region packages/moost/src/decorators/circular.decorator.ts
|
|
586
543
|
function Circular(resolver) {
|
|
587
|
-
|
|
544
|
+
return getMoostMate().decorate("circular", resolver);
|
|
588
545
|
}
|
|
589
546
|
|
|
547
|
+
//#endregion
|
|
548
|
+
//#region packages/moost/src/decorators/common.decorator.ts
|
|
590
549
|
function Label(value) {
|
|
591
|
-
|
|
550
|
+
return getMoostMate().decorate("label", value);
|
|
592
551
|
}
|
|
593
552
|
function Description(value) {
|
|
594
|
-
|
|
553
|
+
return getMoostMate().decorate("description", value);
|
|
595
554
|
}
|
|
596
555
|
function Value(value) {
|
|
597
|
-
|
|
556
|
+
return getMoostMate().decorate("value", value);
|
|
598
557
|
}
|
|
599
558
|
function Id(value) {
|
|
600
|
-
|
|
559
|
+
return getMoostMate().decorate("id", value);
|
|
601
560
|
}
|
|
602
561
|
function Optional() {
|
|
603
|
-
|
|
562
|
+
return getMoostMate().decorate("optional", true);
|
|
604
563
|
}
|
|
605
564
|
function Required() {
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
565
|
+
const mate$1 = getMoostMate();
|
|
566
|
+
return mate$1.apply(mate$1.decorate("required", true), mate$1.decorateClass((meta, level, key, index) => {
|
|
567
|
+
if (typeof index !== "number" && meta && ["string", "symbol"].includes(typeof key)) {
|
|
568
|
+
meta.requiredProps = meta.requiredProps || [];
|
|
569
|
+
meta.requiredProps.push(key);
|
|
570
|
+
}
|
|
571
|
+
return meta;
|
|
572
|
+
}));
|
|
614
573
|
}
|
|
615
574
|
|
|
575
|
+
//#endregion
|
|
576
|
+
//#region packages/moost/src/decorators/injectable.decorator.ts
|
|
616
577
|
function Injectable(scope = true) {
|
|
617
|
-
|
|
578
|
+
return getMoostMate().decorate("injectable", scope);
|
|
618
579
|
}
|
|
619
|
-
const insureInjectable = getMoostMate().decorate(meta => {
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
}
|
|
623
|
-
return meta;
|
|
580
|
+
const insureInjectable = getMoostMate().decorate((meta) => {
|
|
581
|
+
if (!meta.injectable) meta.injectable = true;
|
|
582
|
+
return meta;
|
|
624
583
|
});
|
|
625
584
|
|
|
585
|
+
//#endregion
|
|
586
|
+
//#region packages/moost/src/decorators/controller.decorator.ts
|
|
626
587
|
function Controller(prefix) {
|
|
627
|
-
|
|
628
|
-
|
|
588
|
+
const mate$1 = getMoostMate();
|
|
589
|
+
return mate$1.apply(insureInjectable, mate$1.decorate("controller", { prefix: prefix || "" }));
|
|
629
590
|
}
|
|
630
591
|
function ImportController(prefix, controller, provide) {
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
provide: typeof prefix === 'string'
|
|
637
|
-
? provide || undefined
|
|
638
|
-
: controller || undefined,
|
|
639
|
-
}, true);
|
|
592
|
+
return getMoostMate().decorate("importController", {
|
|
593
|
+
prefix: typeof prefix === "string" ? prefix : undefined,
|
|
594
|
+
typeResolver: typeof prefix === "string" ? controller : prefix,
|
|
595
|
+
provide: typeof prefix === "string" ? provide || undefined : controller || undefined
|
|
596
|
+
}, true);
|
|
640
597
|
}
|
|
641
598
|
|
|
642
|
-
|
|
599
|
+
//#endregion
|
|
600
|
+
//#region packages/moost/src/decorators/inherit.decorator.ts
|
|
601
|
+
const Inherit = () => getMoostMate().decorate("inherit", true);
|
|
643
602
|
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
603
|
+
//#endregion
|
|
604
|
+
//#region packages/moost/src/decorators/intercept.decorator.ts
|
|
605
|
+
var TInterceptorPriority = /*#__PURE__*/ function(TInterceptorPriority$1) {
|
|
606
|
+
TInterceptorPriority$1[TInterceptorPriority$1["BEFORE_ALL"] = 0] = "BEFORE_ALL";
|
|
607
|
+
TInterceptorPriority$1[TInterceptorPriority$1["BEFORE_GUARD"] = 1] = "BEFORE_GUARD";
|
|
608
|
+
TInterceptorPriority$1[TInterceptorPriority$1["GUARD"] = 2] = "GUARD";
|
|
609
|
+
TInterceptorPriority$1[TInterceptorPriority$1["AFTER_GUARD"] = 3] = "AFTER_GUARD";
|
|
610
|
+
TInterceptorPriority$1[TInterceptorPriority$1["INTERCEPTOR"] = 4] = "INTERCEPTOR";
|
|
611
|
+
TInterceptorPriority$1[TInterceptorPriority$1["CATCH_ERROR"] = 5] = "CATCH_ERROR";
|
|
612
|
+
TInterceptorPriority$1[TInterceptorPriority$1["AFTER_ALL"] = 6] = "AFTER_ALL";
|
|
613
|
+
return TInterceptorPriority$1;
|
|
614
|
+
}({});
|
|
654
615
|
function Intercept(handler, priority, name) {
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
616
|
+
return getMoostMate().decorate("interceptors", {
|
|
617
|
+
handler,
|
|
618
|
+
priority: priority || handler.priority || 4,
|
|
619
|
+
name: name || handler._name || handler.name
|
|
620
|
+
}, true);
|
|
660
621
|
}
|
|
661
622
|
|
|
623
|
+
//#endregion
|
|
624
|
+
//#region packages/moost/src/decorators/resolve.decorator.ts
|
|
662
625
|
function Resolve(resolver, label) {
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
})(target, key, i);
|
|
673
|
-
};
|
|
626
|
+
return (target, key, index) => {
|
|
627
|
+
const i = typeof index === "number" ? index : undefined;
|
|
628
|
+
getMoostMate().decorate("resolver", (metas, level) => {
|
|
629
|
+
let newLabel = label;
|
|
630
|
+
if (!newLabel && level === "PROP" && typeof metas.key === "string") newLabel = metas.key;
|
|
631
|
+
fillLabel(target, key || "", i, newLabel);
|
|
632
|
+
return resolver(metas, level);
|
|
633
|
+
})(target, key, i);
|
|
634
|
+
};
|
|
674
635
|
}
|
|
675
636
|
function Param(name) {
|
|
676
|
-
|
|
637
|
+
return getMoostMate().apply(getMoostMate().decorate("paramSource", "ROUTE"), getMoostMate().decorate("paramName", name), Resolve(() => (0, __wooksjs_event_core.useRouteParams)().get(name), name));
|
|
677
638
|
}
|
|
678
639
|
function Params() {
|
|
679
|
-
|
|
640
|
+
return Resolve(() => (0, __wooksjs_event_core.useRouteParams)().params, "params");
|
|
680
641
|
}
|
|
681
642
|
function Const(value, label) {
|
|
682
|
-
|
|
643
|
+
return Resolve(() => value, label);
|
|
683
644
|
}
|
|
684
645
|
function ConstFactory(factory, label) {
|
|
685
|
-
|
|
646
|
+
return Resolve(async () => factory(), label);
|
|
686
647
|
}
|
|
687
648
|
function fillLabel(target, key, index, name) {
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
}
|
|
695
|
-
else if (!meta?.label) {
|
|
696
|
-
Label(name)(target, key);
|
|
697
|
-
}
|
|
698
|
-
}
|
|
649
|
+
if (name) {
|
|
650
|
+
const meta = getMoostMate().read(target, key);
|
|
651
|
+
if (typeof index === "number") {
|
|
652
|
+
if (!meta?.params?.[index]?.label) Label(name)(target, key, index);
|
|
653
|
+
} else if (!meta?.label) Label(name)(target, key);
|
|
654
|
+
}
|
|
699
655
|
}
|
|
700
656
|
|
|
657
|
+
//#endregion
|
|
658
|
+
//#region packages/moost/src/decorators/logger.decorator.ts
|
|
701
659
|
function InjectEventLogger(topic) {
|
|
702
|
-
|
|
660
|
+
return Resolve(() => (0, __wooksjs_event_core.useEventLogger)(topic));
|
|
703
661
|
}
|
|
704
662
|
function InjectMoostLogger(topic) {
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
663
|
+
return Resolve(async (metas) => {
|
|
664
|
+
const { instantiate, getController } = useControllerContext();
|
|
665
|
+
const controller = getController();
|
|
666
|
+
const moostApp = controller instanceof Moost ? controller : await instantiate(Moost);
|
|
667
|
+
const meta = metas.classMeta;
|
|
668
|
+
return moostApp.getLogger(meta?.loggerTopic || topic || meta?.id);
|
|
669
|
+
});
|
|
712
670
|
}
|
|
713
671
|
function LoggerTopic(topic) {
|
|
714
|
-
|
|
672
|
+
return getMoostMate().decorate("loggerTopic", topic);
|
|
715
673
|
}
|
|
716
674
|
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
675
|
+
//#endregion
|
|
676
|
+
//#region packages/moost/src/pipes/types.ts
|
|
677
|
+
var TPipePriority = /*#__PURE__*/ function(TPipePriority$1) {
|
|
678
|
+
TPipePriority$1[TPipePriority$1["BEFORE_RESOLVE"] = 0] = "BEFORE_RESOLVE";
|
|
679
|
+
TPipePriority$1[TPipePriority$1["RESOLVE"] = 1] = "RESOLVE";
|
|
680
|
+
TPipePriority$1[TPipePriority$1["AFTER_RESOLVE"] = 2] = "AFTER_RESOLVE";
|
|
681
|
+
TPipePriority$1[TPipePriority$1["BEFORE_TRANSFORM"] = 3] = "BEFORE_TRANSFORM";
|
|
682
|
+
TPipePriority$1[TPipePriority$1["TRANSFORM"] = 4] = "TRANSFORM";
|
|
683
|
+
TPipePriority$1[TPipePriority$1["AFTER_TRANSFORM"] = 5] = "AFTER_TRANSFORM";
|
|
684
|
+
TPipePriority$1[TPipePriority$1["BEFORE_VALIDATE"] = 6] = "BEFORE_VALIDATE";
|
|
685
|
+
TPipePriority$1[TPipePriority$1["VALIDATE"] = 7] = "VALIDATE";
|
|
686
|
+
TPipePriority$1[TPipePriority$1["AFTER_VALIDATE"] = 8] = "AFTER_VALIDATE";
|
|
687
|
+
return TPipePriority$1;
|
|
688
|
+
}({});
|
|
729
689
|
|
|
690
|
+
//#endregion
|
|
691
|
+
//#region packages/moost/src/decorators/pipe.decorator.ts
|
|
730
692
|
function Pipe(handler, priority) {
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
693
|
+
if (typeof priority !== "number") priority = typeof handler.priority === "number" ? handler.priority : TPipePriority.TRANSFORM;
|
|
694
|
+
return getMoostMate().decorate("pipes", {
|
|
695
|
+
handler,
|
|
696
|
+
priority
|
|
697
|
+
}, true);
|
|
735
698
|
}
|
|
736
699
|
|
|
700
|
+
//#endregion
|
|
701
|
+
//#region packages/moost/src/decorators/provide.decorator.ts
|
|
737
702
|
function Provide(type, fn) {
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
703
|
+
return getMoostMate().decorate((meta) => {
|
|
704
|
+
meta.provide = meta.provide || {};
|
|
705
|
+
Object.assign(meta.provide, (0, __prostojs_infact.createProvideRegistry)([type, fn]));
|
|
706
|
+
return meta;
|
|
707
|
+
});
|
|
743
708
|
}
|
|
744
709
|
function Replace(type, newType) {
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
710
|
+
return getMoostMate().decorate((meta) => {
|
|
711
|
+
meta.replace = meta.replace || {};
|
|
712
|
+
Object.assign(meta.replace, (0, __prostojs_infact.createReplaceRegistry)([type, newType]));
|
|
713
|
+
return meta;
|
|
714
|
+
});
|
|
750
715
|
}
|
|
751
716
|
function Inject(type) {
|
|
752
|
-
|
|
717
|
+
return getMoostMate().decorate("inject", type);
|
|
753
718
|
}
|
|
754
719
|
function InjectFromScope(name) {
|
|
755
|
-
|
|
720
|
+
return getMoostMate().decorate("fromScope", name);
|
|
756
721
|
}
|
|
757
722
|
function InjectScopeVars(name) {
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
: getInfactScopeVars(scopeId);
|
|
763
|
-
}
|
|
764
|
-
return undefined;
|
|
765
|
-
});
|
|
723
|
+
return Resolve(({ scopeId }) => {
|
|
724
|
+
if (scopeId) return name ? getInfactScopeVars(scopeId)?.[name] : getInfactScopeVars(scopeId);
|
|
725
|
+
return undefined;
|
|
726
|
+
});
|
|
766
727
|
}
|
|
767
728
|
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
729
|
+
//#endregion
|
|
730
|
+
//#region packages/moost/src/define.ts
|
|
731
|
+
function defineInterceptorFn(fn, priority = TInterceptorPriority.INTERCEPTOR) {
|
|
732
|
+
fn.priority = priority;
|
|
733
|
+
return fn;
|
|
771
734
|
}
|
|
772
|
-
function definePipeFn(fn, priority =
|
|
773
|
-
|
|
774
|
-
|
|
735
|
+
function definePipeFn(fn, priority = TPipePriority.TRANSFORM) {
|
|
736
|
+
fn.priority = priority;
|
|
737
|
+
return fn;
|
|
775
738
|
}
|
|
776
739
|
|
|
740
|
+
//#endregion
|
|
741
|
+
//#region packages/moost/src/pipes/resolve.pipe.ts
|
|
777
742
|
const resolvePipe = definePipeFn((_value, metas, level) => {
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
return undefined;
|
|
783
|
-
}, exports.TPipePriority.RESOLVE);
|
|
743
|
+
const resolver = metas.targetMeta?.resolver;
|
|
744
|
+
if (resolver) return resolver(metas, level);
|
|
745
|
+
return undefined;
|
|
746
|
+
}, TPipePriority.RESOLVE);
|
|
784
747
|
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
];
|
|
748
|
+
//#endregion
|
|
749
|
+
//#region packages/moost/src/pipes/shared-pipes.ts
|
|
750
|
+
const sharedPipes = [{
|
|
751
|
+
handler: resolvePipe,
|
|
752
|
+
priority: TPipePriority.RESOLVE
|
|
753
|
+
}];
|
|
791
754
|
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
this.logger = options?.logger || getDefaultLogger(`${'[2m' + '[35m'}moost`);
|
|
804
|
-
setDefaultLogger(this.logger);
|
|
805
|
-
const mate = getMoostMate();
|
|
806
|
-
Object.assign(mate, { logger: this.getLogger('mate') });
|
|
807
|
-
}
|
|
808
|
-
_fireEventStart(source) {
|
|
809
|
-
this.callHook('event-start', source);
|
|
810
|
-
}
|
|
811
|
-
_fireEventEnd(source) {
|
|
812
|
-
this.callHook('event-end', source);
|
|
813
|
-
}
|
|
814
|
-
getLogger(topic) {
|
|
815
|
-
if (topic && this.logger instanceof logger.ProstoLogger) {
|
|
816
|
-
return this.logger.createTopic(topic);
|
|
817
|
-
}
|
|
818
|
-
return this.logger;
|
|
819
|
-
}
|
|
820
|
-
adapter(a) {
|
|
821
|
-
this.adapters.push(a);
|
|
822
|
-
return a;
|
|
823
|
-
}
|
|
824
|
-
getControllersOverview() {
|
|
825
|
-
return this.controllersOverview;
|
|
826
|
-
}
|
|
827
|
-
async init() {
|
|
828
|
-
this.setProvideRegistry(infact$1.createProvideRegistry([Moost, () => this], [logger.ProstoLogger, () => this.logger], ['MOOST_LOGGER', () => this.logger]));
|
|
829
|
-
for (const a of this.adapters) {
|
|
830
|
-
const constructor = mate$1.getConstructor(a);
|
|
831
|
-
if (constructor) {
|
|
832
|
-
this.setProvideRegistry(infact$1.createProvideRegistry([constructor, () => a]));
|
|
833
|
-
}
|
|
834
|
-
if (typeof a.getProvideRegistry === 'function') {
|
|
835
|
-
this.setProvideRegistry(a.getProvideRegistry());
|
|
836
|
-
}
|
|
837
|
-
}
|
|
838
|
-
this.unregisteredControllers.unshift(this);
|
|
839
|
-
await this.bindControllers();
|
|
840
|
-
for (const a of this.adapters) {
|
|
841
|
-
await (a.onInit && a.onInit(this));
|
|
842
|
-
}
|
|
843
|
-
}
|
|
844
|
-
async bindControllers() {
|
|
845
|
-
const meta = getMoostMate();
|
|
846
|
-
const thisMeta = meta.read(this);
|
|
847
|
-
const provide = { ...thisMeta?.provide, ...this.provide };
|
|
848
|
-
const replace = { ...thisMeta?.replace, ...this.replace };
|
|
849
|
-
for (const _controller of this.unregisteredControllers) {
|
|
850
|
-
let newPrefix;
|
|
851
|
-
let controller = _controller;
|
|
852
|
-
if (Array.isArray(_controller) && typeof _controller[0] === 'string') {
|
|
853
|
-
newPrefix = _controller[0];
|
|
854
|
-
controller = _controller[1];
|
|
855
|
-
}
|
|
856
|
-
await this.bindController(controller, provide, replace, this.options?.globalPrefix || '', newPrefix);
|
|
857
|
-
}
|
|
858
|
-
this.unregisteredControllers = [];
|
|
859
|
-
}
|
|
860
|
-
async bindController(controller, provide, replace, globalPrefix, replaceOwnPrefix) {
|
|
861
|
-
const mate = getMoostMate();
|
|
862
|
-
const classMeta = mate.read(controller);
|
|
863
|
-
const infact = getMoostInfact();
|
|
864
|
-
const isControllerConsructor = mate$1.isConstructor(controller);
|
|
865
|
-
const pipes = [...this.pipes, ...(classMeta?.pipes || [])].sort((a, b) => a.priority - b.priority);
|
|
866
|
-
let instance;
|
|
867
|
-
const infactOpts = { provide, replace, customData: { pipes } };
|
|
868
|
-
if (isControllerConsructor &&
|
|
869
|
-
(classMeta?.injectable === 'SINGLETON' || classMeta?.injectable === true)) {
|
|
870
|
-
await eventCore.createAsyncEventContext({
|
|
871
|
-
event: { type: 'init' },
|
|
872
|
-
options: {},
|
|
873
|
-
})(async () => {
|
|
874
|
-
setControllerContext(this, 'bindController', '');
|
|
875
|
-
instance = (await infact.get(controller, infactOpts));
|
|
876
|
-
});
|
|
877
|
-
}
|
|
878
|
-
else if (!isControllerConsructor) {
|
|
879
|
-
instance = controller;
|
|
880
|
-
infact.setInstanceRegistries(instance, provide, replace, { pipes });
|
|
881
|
-
}
|
|
882
|
-
const getInstance = instance
|
|
883
|
-
? () => Promise.resolve(instance)
|
|
884
|
-
: async () => (await infact.get(controller, {
|
|
885
|
-
...infactOpts,
|
|
886
|
-
}));
|
|
887
|
-
const classConstructor = mate$1.isConstructor(controller)
|
|
888
|
-
? controller
|
|
889
|
-
: mate$1.getConstructor(controller);
|
|
890
|
-
this.controllersOverview.push(await bindControllerMethods({
|
|
891
|
-
getInstance,
|
|
892
|
-
classConstructor,
|
|
893
|
-
adapters: this.adapters,
|
|
894
|
-
globalPrefix,
|
|
895
|
-
replaceOwnPrefix,
|
|
896
|
-
interceptors: Array.from(this.interceptors),
|
|
897
|
-
pipes,
|
|
898
|
-
provide: classMeta?.provide,
|
|
899
|
-
replace: classMeta?.replace,
|
|
900
|
-
logger: this.logger,
|
|
901
|
-
moostInstance: this,
|
|
902
|
-
}));
|
|
903
|
-
if (classMeta && classMeta.importController) {
|
|
904
|
-
const prefix = typeof replaceOwnPrefix === 'string' ? replaceOwnPrefix : classMeta.controller?.prefix;
|
|
905
|
-
const mergedProvide = { ...provide, ...classMeta.provide };
|
|
906
|
-
const mergedReplace = { ...this.replace, ...classMeta.replace };
|
|
907
|
-
for (const ic of classMeta.importController) {
|
|
908
|
-
if (ic.typeResolver) {
|
|
909
|
-
const isConstr = mate$1.isConstructor(ic.typeResolver);
|
|
910
|
-
const isFunc = typeof ic.typeResolver === 'function';
|
|
911
|
-
await this.bindController(isConstr
|
|
912
|
-
? ic.typeResolver
|
|
913
|
-
: isFunc
|
|
914
|
-
? await ic.typeResolver()
|
|
915
|
-
: ic.typeResolver, ic.provide ? { ...mergedProvide, ...ic.provide } : mergedProvide, mergedReplace, `${globalPrefix}/${prefix || ''}`, ic.prefix);
|
|
916
|
-
}
|
|
917
|
-
}
|
|
918
|
-
}
|
|
919
|
-
}
|
|
920
|
-
applyGlobalPipes(...items) {
|
|
921
|
-
for (const item of items) {
|
|
922
|
-
if (typeof item === 'function') {
|
|
923
|
-
this.pipes.push({
|
|
924
|
-
handler: item,
|
|
925
|
-
priority: typeof item.priority === 'number' ? item.priority : exports.TPipePriority.TRANSFORM,
|
|
926
|
-
});
|
|
927
|
-
}
|
|
928
|
-
else {
|
|
929
|
-
this.pipes.push({
|
|
930
|
-
handler: item.handler,
|
|
931
|
-
priority: item.priority,
|
|
932
|
-
});
|
|
933
|
-
}
|
|
934
|
-
}
|
|
935
|
-
this.globalInterceptorHandler = undefined;
|
|
936
|
-
return this;
|
|
937
|
-
}
|
|
938
|
-
getGlobalInterceptorHandler() {
|
|
939
|
-
if (!this.globalInterceptorHandler) {
|
|
940
|
-
const mate = getMoostMate();
|
|
941
|
-
const thisMeta = mate.read(this);
|
|
942
|
-
const pipes = [...(this.pipes || []), ...(thisMeta?.pipes || [])].sort((a, b) => a.priority - b.priority);
|
|
943
|
-
const interceptors = [...this.interceptors, ...(thisMeta?.interceptors || [])].sort((a, b) => a.priority - b.priority);
|
|
944
|
-
this.globalInterceptorHandler = getIterceptorHandlerFactory(interceptors, () => Promise.resolve(this), pipes, this.logger);
|
|
945
|
-
}
|
|
946
|
-
return this.globalInterceptorHandler();
|
|
947
|
-
}
|
|
948
|
-
applyGlobalInterceptors(...items) {
|
|
949
|
-
for (const item of items) {
|
|
950
|
-
if (typeof item === 'function') {
|
|
951
|
-
this.interceptors.push({
|
|
952
|
-
handler: item,
|
|
953
|
-
priority: typeof item.priority === 'number'
|
|
954
|
-
? item.priority
|
|
955
|
-
: exports.TInterceptorPriority.INTERCEPTOR,
|
|
956
|
-
name: item._name || item.name || '<anonymous>',
|
|
957
|
-
});
|
|
958
|
-
}
|
|
959
|
-
else {
|
|
960
|
-
this.interceptors.push({
|
|
961
|
-
handler: item.handler,
|
|
962
|
-
priority: item.priority,
|
|
963
|
-
name: item.name ||
|
|
964
|
-
item.handler._name ||
|
|
965
|
-
item.handler.name ||
|
|
966
|
-
'<anonymous>',
|
|
967
|
-
});
|
|
968
|
-
}
|
|
969
|
-
}
|
|
970
|
-
this.globalInterceptorHandler = undefined;
|
|
971
|
-
return this;
|
|
972
|
-
}
|
|
973
|
-
setProvideRegistry(provide) {
|
|
974
|
-
this.provide = { ...this.provide, ...provide };
|
|
975
|
-
return this;
|
|
976
|
-
}
|
|
977
|
-
setReplaceRegistry(replace) {
|
|
978
|
-
this.replace = { ...this.replace, ...replace };
|
|
979
|
-
return this;
|
|
980
|
-
}
|
|
981
|
-
registerControllers(...controllers) {
|
|
982
|
-
this.unregisteredControllers.push(...controllers);
|
|
983
|
-
return this;
|
|
984
|
-
}
|
|
985
|
-
logMappedHandler(eventName, classConstructor, method, stroke, prefix) {
|
|
986
|
-
const c = stroke ? '\u001B[9m' : '';
|
|
987
|
-
const coff = stroke ? '\u001B[29m' : '';
|
|
988
|
-
this.logger.info(`${prefix || ''}${c}${eventName} ${'[0m' + '[2m' + '[32m' + c}→ ${classConstructor.name}.${'[36m' + c}${method}${'[32m'}()${coff}`);
|
|
989
|
-
}
|
|
755
|
+
//#endregion
|
|
756
|
+
//#region packages/moost/src/moost.ts
|
|
757
|
+
function _define_property(obj, key, value) {
|
|
758
|
+
if (key in obj) Object.defineProperty(obj, key, {
|
|
759
|
+
value,
|
|
760
|
+
enumerable: true,
|
|
761
|
+
configurable: true,
|
|
762
|
+
writable: true
|
|
763
|
+
});
|
|
764
|
+
else obj[key] = value;
|
|
765
|
+
return obj;
|
|
990
766
|
}
|
|
767
|
+
var Moost = class Moost extends hookable.Hookable {
|
|
768
|
+
_fireEventStart(source) {
|
|
769
|
+
this.callHook("event-start", source);
|
|
770
|
+
}
|
|
771
|
+
_fireEventEnd(source) {
|
|
772
|
+
this.callHook("event-end", source);
|
|
773
|
+
}
|
|
774
|
+
/**
|
|
775
|
+
* ### getLogger
|
|
776
|
+
* Provides application logger
|
|
777
|
+
* ```js
|
|
778
|
+
* // get logger with topic = "App"
|
|
779
|
+
* const logger = app.getLogger('App')
|
|
780
|
+
* logger.log('...')
|
|
781
|
+
* ```
|
|
782
|
+
* @param topic
|
|
783
|
+
* @returns
|
|
784
|
+
*/ getLogger(topic) {
|
|
785
|
+
if (topic && this.logger instanceof __prostojs_logger.ProstoLogger) return this.logger.createTopic(topic);
|
|
786
|
+
return this.logger;
|
|
787
|
+
}
|
|
788
|
+
adapter(a) {
|
|
789
|
+
this.adapters.push(a);
|
|
790
|
+
return a;
|
|
791
|
+
}
|
|
792
|
+
getControllersOverview() {
|
|
793
|
+
return this.controllersOverview;
|
|
794
|
+
}
|
|
795
|
+
/**
|
|
796
|
+
* ### init
|
|
797
|
+
* Ititializes adapter. Must be called after adapters are attached.
|
|
798
|
+
*/ async init() {
|
|
799
|
+
this.setProvideRegistry((0, __prostojs_infact.createProvideRegistry)([Moost, () => this], [__prostojs_logger.ProstoLogger, () => this.logger], ["MOOST_LOGGER", () => this.logger]));
|
|
800
|
+
for (const a of this.adapters) {
|
|
801
|
+
const constructor = (0, __prostojs_mate.getConstructor)(a);
|
|
802
|
+
if (constructor) this.setProvideRegistry((0, __prostojs_infact.createProvideRegistry)([constructor, () => a]));
|
|
803
|
+
if (typeof a.getProvideRegistry === "function") this.setProvideRegistry(a.getProvideRegistry());
|
|
804
|
+
}
|
|
805
|
+
this.unregisteredControllers.unshift(this);
|
|
806
|
+
await this.bindControllers();
|
|
807
|
+
for (const a of this.adapters) await (a.onInit && a.onInit(this));
|
|
808
|
+
}
|
|
809
|
+
async bindControllers() {
|
|
810
|
+
const meta = getMoostMate();
|
|
811
|
+
const thisMeta = meta.read(this);
|
|
812
|
+
const provide = {
|
|
813
|
+
...thisMeta?.provide,
|
|
814
|
+
...this.provide
|
|
815
|
+
};
|
|
816
|
+
const replace = {
|
|
817
|
+
...thisMeta?.replace,
|
|
818
|
+
...this.replace
|
|
819
|
+
};
|
|
820
|
+
for (const _controller of this.unregisteredControllers) {
|
|
821
|
+
let newPrefix;
|
|
822
|
+
let controller = _controller;
|
|
823
|
+
if (Array.isArray(_controller) && typeof _controller[0] === "string") {
|
|
824
|
+
newPrefix = _controller[0];
|
|
825
|
+
controller = _controller[1];
|
|
826
|
+
}
|
|
827
|
+
await this.bindController(controller, provide, replace, this.options?.globalPrefix || "", newPrefix);
|
|
828
|
+
}
|
|
829
|
+
this.unregisteredControllers = [];
|
|
830
|
+
}
|
|
831
|
+
async bindController(controller, provide, replace, globalPrefix, replaceOwnPrefix) {
|
|
832
|
+
const mate$1 = getMoostMate();
|
|
833
|
+
const classMeta = mate$1.read(controller);
|
|
834
|
+
const infact$1 = getMoostInfact();
|
|
835
|
+
const isControllerConsructor = (0, __prostojs_mate.isConstructor)(controller);
|
|
836
|
+
const pipes = [...this.pipes, ...classMeta?.pipes || []].sort((a, b) => a.priority - b.priority);
|
|
837
|
+
let instance;
|
|
838
|
+
const infactOpts = {
|
|
839
|
+
provide,
|
|
840
|
+
replace,
|
|
841
|
+
customData: { pipes }
|
|
842
|
+
};
|
|
843
|
+
if (isControllerConsructor && (classMeta?.injectable === "SINGLETON" || classMeta?.injectable === true)) await (0, __wooksjs_event_core.createAsyncEventContext)({
|
|
844
|
+
event: { type: "init" },
|
|
845
|
+
options: {}
|
|
846
|
+
})(async () => {
|
|
847
|
+
setControllerContext(this, "bindController", "");
|
|
848
|
+
instance = await infact$1.get(controller, infactOpts);
|
|
849
|
+
});
|
|
850
|
+
else if (!isControllerConsructor) {
|
|
851
|
+
instance = controller;
|
|
852
|
+
infact$1.setInstanceRegistries(instance, provide, replace, { pipes });
|
|
853
|
+
}
|
|
854
|
+
const getInstance = instance ? () => Promise.resolve(instance) : async () => await infact$1.get(controller, { ...infactOpts });
|
|
855
|
+
const classConstructor = (0, __prostojs_mate.isConstructor)(controller) ? controller : (0, __prostojs_mate.getConstructor)(controller);
|
|
856
|
+
this.controllersOverview.push(await bindControllerMethods({
|
|
857
|
+
getInstance,
|
|
858
|
+
classConstructor,
|
|
859
|
+
adapters: this.adapters,
|
|
860
|
+
globalPrefix,
|
|
861
|
+
replaceOwnPrefix,
|
|
862
|
+
interceptors: Array.from(this.interceptors),
|
|
863
|
+
pipes,
|
|
864
|
+
provide: classMeta?.provide,
|
|
865
|
+
replace: classMeta?.replace,
|
|
866
|
+
logger: this.logger,
|
|
867
|
+
moostInstance: this
|
|
868
|
+
}));
|
|
869
|
+
if (classMeta?.importController) {
|
|
870
|
+
const prefix = typeof replaceOwnPrefix === "string" ? replaceOwnPrefix : classMeta.controller?.prefix;
|
|
871
|
+
const mergedProvide = {
|
|
872
|
+
...provide,
|
|
873
|
+
...classMeta.provide
|
|
874
|
+
};
|
|
875
|
+
const mergedReplace = {
|
|
876
|
+
...this.replace,
|
|
877
|
+
...classMeta.replace
|
|
878
|
+
};
|
|
879
|
+
for (const ic of classMeta.importController) if (ic.typeResolver) {
|
|
880
|
+
const isConstr = (0, __prostojs_mate.isConstructor)(ic.typeResolver);
|
|
881
|
+
const isFunc = typeof ic.typeResolver === "function";
|
|
882
|
+
await this.bindController(
|
|
883
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
|
884
|
+
isConstr ? ic.typeResolver : isFunc ? await ic.typeResolver() : ic.typeResolver,
|
|
885
|
+
ic.provide ? {
|
|
886
|
+
...mergedProvide,
|
|
887
|
+
...ic.provide
|
|
888
|
+
} : mergedProvide,
|
|
889
|
+
mergedReplace,
|
|
890
|
+
`${globalPrefix}/${prefix || ""}`,
|
|
891
|
+
ic.prefix
|
|
892
|
+
);
|
|
893
|
+
}
|
|
894
|
+
}
|
|
895
|
+
}
|
|
896
|
+
applyGlobalPipes(...items) {
|
|
897
|
+
for (const item of items) if (typeof item === "function") this.pipes.push({
|
|
898
|
+
handler: item,
|
|
899
|
+
priority: typeof item.priority === "number" ? item.priority : TPipePriority.TRANSFORM
|
|
900
|
+
});
|
|
901
|
+
else this.pipes.push({
|
|
902
|
+
handler: item.handler,
|
|
903
|
+
priority: item.priority
|
|
904
|
+
});
|
|
905
|
+
this.globalInterceptorHandler = undefined;
|
|
906
|
+
return this;
|
|
907
|
+
}
|
|
908
|
+
/**
|
|
909
|
+
* Provides InterceptorHandler with global interceptors and pipes.
|
|
910
|
+
* Used to process interceptors when event handler was not found.
|
|
911
|
+
*
|
|
912
|
+
* @returns IterceptorHandler
|
|
913
|
+
*/ getGlobalInterceptorHandler() {
|
|
914
|
+
if (!this.globalInterceptorHandler) {
|
|
915
|
+
const mate$1 = getMoostMate();
|
|
916
|
+
const thisMeta = mate$1.read(this);
|
|
917
|
+
const pipes = [...this.pipes || [], ...thisMeta?.pipes || []].sort((a, b) => a.priority - b.priority);
|
|
918
|
+
const interceptors = [...this.interceptors, ...thisMeta?.interceptors || []].sort((a, b) => a.priority - b.priority);
|
|
919
|
+
this.globalInterceptorHandler = getIterceptorHandlerFactory(interceptors, () => Promise.resolve(this), pipes, this.logger);
|
|
920
|
+
}
|
|
921
|
+
return this.globalInterceptorHandler();
|
|
922
|
+
}
|
|
923
|
+
applyGlobalInterceptors(...items) {
|
|
924
|
+
for (const item of items) if (typeof item === "function") this.interceptors.push({
|
|
925
|
+
handler: item,
|
|
926
|
+
priority: typeof item.priority === "number" ? item.priority : TInterceptorPriority.INTERCEPTOR,
|
|
927
|
+
name: item._name || item.name || "<anonymous>"
|
|
928
|
+
});
|
|
929
|
+
else this.interceptors.push({
|
|
930
|
+
handler: item.handler,
|
|
931
|
+
priority: item.priority,
|
|
932
|
+
name: item.name || item.handler._name || item.handler.name || "<anonymous>"
|
|
933
|
+
});
|
|
934
|
+
this.globalInterceptorHandler = undefined;
|
|
935
|
+
return this;
|
|
936
|
+
}
|
|
937
|
+
/**
|
|
938
|
+
* Register new entries to provide as dependency injections
|
|
939
|
+
* @param provide - Provide Registry (use createProvideRegistry from '\@prostojs/infact')
|
|
940
|
+
* @returns
|
|
941
|
+
*/ setProvideRegistry(provide) {
|
|
942
|
+
this.provide = {
|
|
943
|
+
...this.provide,
|
|
944
|
+
...provide
|
|
945
|
+
};
|
|
946
|
+
return this;
|
|
947
|
+
}
|
|
948
|
+
/**
|
|
949
|
+
* Register replace classes to provide as dependency injections
|
|
950
|
+
* @param replace - Replace Registry (use createReplaceRegistry from '\@prostojs/infact')
|
|
951
|
+
* @returns
|
|
952
|
+
*/ setReplaceRegistry(replace) {
|
|
953
|
+
this.replace = {
|
|
954
|
+
...this.replace,
|
|
955
|
+
...replace
|
|
956
|
+
};
|
|
957
|
+
return this;
|
|
958
|
+
}
|
|
959
|
+
/**
|
|
960
|
+
* Register controllers (similar to @ImportController decorator)
|
|
961
|
+
* @param controllers - list of target controllers (instances)
|
|
962
|
+
* @returns
|
|
963
|
+
*/ registerControllers(...controllers) {
|
|
964
|
+
this.unregisteredControllers.push(...controllers);
|
|
965
|
+
return this;
|
|
966
|
+
}
|
|
967
|
+
logMappedHandler(eventName, classConstructor, method, stroke, prefix) {
|
|
968
|
+
const c = stroke ? "\x1B[9m" : "";
|
|
969
|
+
const coff = stroke ? "\x1B[29m" : "";
|
|
970
|
+
this.logger.info(`${prefix || ""}${c}${eventName} ${"\x1B[0m\x1B[2m\x1B[32m" + c}→ ${classConstructor.name}.${"\x1B[36m" + c}${method}${"\x1B[32m"}()${coff}`);
|
|
971
|
+
}
|
|
972
|
+
constructor(options) {
|
|
973
|
+
super(), _define_property(this, "options", void 0), _define_property(this, "logger", void 0), _define_property(this, "pipes", void 0), _define_property(this, "interceptors", void 0), _define_property(this, "adapters", void 0), _define_property(this, "controllersOverview", void 0), _define_property(this, "provide", void 0), _define_property(this, "replace", void 0), _define_property(this, "unregisteredControllers", void 0), _define_property(this, "globalInterceptorHandler", void 0), this.options = options, this.pipes = Array.from(sharedPipes), this.interceptors = [], this.adapters = [], this.controllersOverview = [], this.provide = (0, __prostojs_infact.createProvideRegistry)([__prostojs_infact.Infact, getMoostInfact], [__prostojs_mate.Mate, getMoostMate]), this.replace = {}, this.unregisteredControllers = [];
|
|
974
|
+
this.logger = options?.logger || getDefaultLogger(`${"\x1B[2m\x1B[35m"}moost`);
|
|
975
|
+
setDefaultLogger(this.logger);
|
|
976
|
+
const mate$1 = getMoostMate();
|
|
977
|
+
Object.assign(mate$1, { logger: this.getLogger("mate") });
|
|
978
|
+
}
|
|
979
|
+
};
|
|
991
980
|
|
|
992
|
-
|
|
981
|
+
//#endregion
|
|
982
|
+
exports.Circular = Circular
|
|
983
|
+
exports.Const = Const
|
|
984
|
+
exports.ConstFactory = ConstFactory
|
|
985
|
+
Object.defineProperty(exports, 'ContextInjector', {
|
|
993
986
|
enumerable: true,
|
|
994
|
-
get: function () {
|
|
987
|
+
get: function () {
|
|
988
|
+
return __wooksjs_event_core.ContextInjector;
|
|
989
|
+
}
|
|
995
990
|
});
|
|
996
|
-
|
|
991
|
+
exports.Controller = Controller
|
|
992
|
+
exports.Description = Description
|
|
993
|
+
Object.defineProperty(exports, 'EventLogger', {
|
|
997
994
|
enumerable: true,
|
|
998
|
-
get: function () {
|
|
995
|
+
get: function () {
|
|
996
|
+
return __wooksjs_event_core.EventLogger;
|
|
997
|
+
}
|
|
999
998
|
});
|
|
1000
|
-
|
|
999
|
+
exports.Id = Id
|
|
1000
|
+
exports.ImportController = ImportController
|
|
1001
|
+
exports.Inherit = Inherit
|
|
1002
|
+
exports.Inject = Inject
|
|
1003
|
+
exports.InjectEventLogger = InjectEventLogger
|
|
1004
|
+
exports.InjectFromScope = InjectFromScope
|
|
1005
|
+
exports.InjectMoostLogger = InjectMoostLogger
|
|
1006
|
+
exports.InjectScopeVars = InjectScopeVars
|
|
1007
|
+
exports.Injectable = Injectable
|
|
1008
|
+
exports.Intercept = Intercept
|
|
1009
|
+
exports.InterceptorHandler = InterceptorHandler
|
|
1010
|
+
exports.Label = Label
|
|
1011
|
+
exports.LoggerTopic = LoggerTopic
|
|
1012
|
+
exports.Moost = Moost
|
|
1013
|
+
exports.Optional = Optional
|
|
1014
|
+
exports.Param = Param
|
|
1015
|
+
exports.Params = Params
|
|
1016
|
+
exports.Pipe = Pipe
|
|
1017
|
+
Object.defineProperty(exports, 'ProstoLogger', {
|
|
1001
1018
|
enumerable: true,
|
|
1002
|
-
get: function () {
|
|
1019
|
+
get: function () {
|
|
1020
|
+
return __prostojs_logger.ProstoLogger;
|
|
1021
|
+
}
|
|
1003
1022
|
});
|
|
1004
|
-
|
|
1023
|
+
exports.Provide = Provide
|
|
1024
|
+
exports.Replace = Replace
|
|
1025
|
+
exports.Required = Required
|
|
1026
|
+
exports.Resolve = Resolve
|
|
1027
|
+
exports.TInterceptorPriority = TInterceptorPriority
|
|
1028
|
+
exports.TPipePriority = TPipePriority
|
|
1029
|
+
exports.Value = Value
|
|
1030
|
+
Object.defineProperty(exports, 'clearGlobalWooks', {
|
|
1005
1031
|
enumerable: true,
|
|
1006
|
-
get: function () {
|
|
1032
|
+
get: function () {
|
|
1033
|
+
return wooks.clearGlobalWooks;
|
|
1034
|
+
}
|
|
1007
1035
|
});
|
|
1008
|
-
Object.defineProperty(exports,
|
|
1036
|
+
Object.defineProperty(exports, 'createProvideRegistry', {
|
|
1009
1037
|
enumerable: true,
|
|
1010
|
-
get: function () {
|
|
1038
|
+
get: function () {
|
|
1039
|
+
return __prostojs_infact.createProvideRegistry;
|
|
1040
|
+
}
|
|
1011
1041
|
});
|
|
1012
|
-
Object.defineProperty(exports,
|
|
1042
|
+
Object.defineProperty(exports, 'createReplaceRegistry', {
|
|
1013
1043
|
enumerable: true,
|
|
1014
|
-
get: function () {
|
|
1044
|
+
get: function () {
|
|
1045
|
+
return __prostojs_infact.createReplaceRegistry;
|
|
1046
|
+
}
|
|
1015
1047
|
});
|
|
1016
|
-
|
|
1048
|
+
exports.defineInfactScope = defineInfactScope
|
|
1049
|
+
exports.defineInterceptorFn = defineInterceptorFn
|
|
1050
|
+
exports.defineMoostEventHandler = defineMoostEventHandler
|
|
1051
|
+
exports.definePipeFn = definePipeFn
|
|
1052
|
+
Object.defineProperty(exports, 'getConstructor', {
|
|
1017
1053
|
enumerable: true,
|
|
1018
|
-
get: function () {
|
|
1054
|
+
get: function () {
|
|
1055
|
+
return __prostojs_mate.getConstructor;
|
|
1056
|
+
}
|
|
1019
1057
|
});
|
|
1020
|
-
Object.defineProperty(exports,
|
|
1058
|
+
Object.defineProperty(exports, 'getContextInjector', {
|
|
1021
1059
|
enumerable: true,
|
|
1022
|
-
get: function () {
|
|
1060
|
+
get: function () {
|
|
1061
|
+
return __wooksjs_event_core.getContextInjector;
|
|
1062
|
+
}
|
|
1023
1063
|
});
|
|
1024
|
-
Object.defineProperty(exports,
|
|
1064
|
+
Object.defineProperty(exports, 'getGlobalWooks', {
|
|
1025
1065
|
enumerable: true,
|
|
1026
|
-
get: function () {
|
|
1066
|
+
get: function () {
|
|
1067
|
+
return wooks.getGlobalWooks;
|
|
1068
|
+
}
|
|
1027
1069
|
});
|
|
1028
|
-
|
|
1070
|
+
exports.getInfactScopeVars = getInfactScopeVars
|
|
1071
|
+
exports.getInstanceOwnMethods = getInstanceOwnMethods
|
|
1072
|
+
exports.getInstanceOwnProps = getInstanceOwnProps
|
|
1073
|
+
exports.getMoostInfact = getMoostInfact
|
|
1074
|
+
exports.getMoostMate = getMoostMate
|
|
1075
|
+
exports.getNewMoostInfact = getNewMoostInfact
|
|
1076
|
+
Object.defineProperty(exports, 'isConstructor', {
|
|
1029
1077
|
enumerable: true,
|
|
1030
|
-
get: function () {
|
|
1078
|
+
get: function () {
|
|
1079
|
+
return __prostojs_mate.isConstructor;
|
|
1080
|
+
}
|
|
1031
1081
|
});
|
|
1032
|
-
|
|
1082
|
+
exports.registerEventScope = registerEventScope
|
|
1083
|
+
Object.defineProperty(exports, 'replaceContextInjector', {
|
|
1033
1084
|
enumerable: true,
|
|
1034
|
-
get: function () {
|
|
1085
|
+
get: function () {
|
|
1086
|
+
return __wooksjs_event_core.replaceContextInjector;
|
|
1087
|
+
}
|
|
1035
1088
|
});
|
|
1036
|
-
|
|
1089
|
+
exports.resolvePipe = resolvePipe
|
|
1090
|
+
exports.setControllerContext = setControllerContext
|
|
1091
|
+
exports.setInfactLoggingOptions = setInfactLoggingOptions
|
|
1092
|
+
Object.defineProperty(exports, 'useAsyncEventContext', {
|
|
1037
1093
|
enumerable: true,
|
|
1038
|
-
get: function () {
|
|
1094
|
+
get: function () {
|
|
1095
|
+
return __wooksjs_event_core.useAsyncEventContext;
|
|
1096
|
+
}
|
|
1039
1097
|
});
|
|
1040
|
-
|
|
1098
|
+
exports.useControllerContext = useControllerContext
|
|
1099
|
+
Object.defineProperty(exports, 'useEventLogger', {
|
|
1041
1100
|
enumerable: true,
|
|
1042
|
-
get: function () {
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
exports.ConstFactory = ConstFactory;
|
|
1047
|
-
exports.Controller = Controller;
|
|
1048
|
-
exports.Description = Description;
|
|
1049
|
-
exports.Id = Id;
|
|
1050
|
-
exports.ImportController = ImportController;
|
|
1051
|
-
exports.Inherit = Inherit;
|
|
1052
|
-
exports.Inject = Inject;
|
|
1053
|
-
exports.InjectEventLogger = InjectEventLogger;
|
|
1054
|
-
exports.InjectFromScope = InjectFromScope;
|
|
1055
|
-
exports.InjectMoostLogger = InjectMoostLogger;
|
|
1056
|
-
exports.InjectScopeVars = InjectScopeVars;
|
|
1057
|
-
exports.Injectable = Injectable;
|
|
1058
|
-
exports.Intercept = Intercept;
|
|
1059
|
-
exports.InterceptorHandler = InterceptorHandler;
|
|
1060
|
-
exports.Label = Label;
|
|
1061
|
-
exports.LoggerTopic = LoggerTopic;
|
|
1062
|
-
exports.Moost = Moost;
|
|
1063
|
-
exports.Optional = Optional;
|
|
1064
|
-
exports.Param = Param;
|
|
1065
|
-
exports.Params = Params;
|
|
1066
|
-
exports.Pipe = Pipe;
|
|
1067
|
-
exports.Provide = Provide;
|
|
1068
|
-
exports.Replace = Replace;
|
|
1069
|
-
exports.Required = Required;
|
|
1070
|
-
exports.Resolve = Resolve;
|
|
1071
|
-
exports.Value = Value;
|
|
1072
|
-
exports.defineInfactScope = defineInfactScope;
|
|
1073
|
-
exports.defineInterceptorFn = defineInterceptorFn;
|
|
1074
|
-
exports.defineMoostEventHandler = defineMoostEventHandler;
|
|
1075
|
-
exports.definePipeFn = definePipeFn;
|
|
1076
|
-
exports.getInfactScopeVars = getInfactScopeVars;
|
|
1077
|
-
exports.getInstanceOwnMethods = getInstanceOwnMethods;
|
|
1078
|
-
exports.getInstanceOwnProps = getInstanceOwnProps;
|
|
1079
|
-
exports.getMoostInfact = getMoostInfact;
|
|
1080
|
-
exports.getMoostMate = getMoostMate;
|
|
1081
|
-
exports.getNewMoostInfact = getNewMoostInfact;
|
|
1082
|
-
exports.registerEventScope = registerEventScope;
|
|
1083
|
-
exports.resolvePipe = resolvePipe;
|
|
1084
|
-
exports.setControllerContext = setControllerContext;
|
|
1085
|
-
exports.setInfactLoggingOptions = setInfactLoggingOptions;
|
|
1086
|
-
exports.useControllerContext = useControllerContext;
|
|
1101
|
+
get: function () {
|
|
1102
|
+
return __wooksjs_event_core.useEventLogger;
|
|
1103
|
+
}
|
|
1104
|
+
});
|