@armoury/fivem-framework-common 1.0.21 → 1.0.22
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cjs/common/index.js
CHANGED
|
@@ -111,7 +111,18 @@ async function bootstrapWithProviders(entryPoint, parentProviders, options = {},
|
|
|
111
111
|
const injector = injection_js_1.ReflectiveInjector.resolveAndCreate([...configProviders, ...resourceProviders, ...providers, entryPoint], parentInjector);
|
|
112
112
|
const instance = injector.get(entryPoint);
|
|
113
113
|
(0, decorator_utils_2.Decorate)(instance, entryPoint.prototype, [...parentProviders, ...providers], decorationType);
|
|
114
|
-
|
|
114
|
+
const decoratedInstances = new Set([instance]);
|
|
115
|
+
for (const token of eagerTokens) {
|
|
116
|
+
const eagerInstance = injector.get(token);
|
|
117
|
+
if (typeof eagerInstance !== 'object' || eagerInstance === null || decoratedInstances.has(eagerInstance)) {
|
|
118
|
+
continue;
|
|
119
|
+
}
|
|
120
|
+
const prototype = Object.getPrototypeOf(eagerInstance);
|
|
121
|
+
if (prototype && prototype !== Object.prototype) {
|
|
122
|
+
(0, decorator_utils_2.Decorate)(eagerInstance, prototype, [...parentProviders, ...providers], decorationType);
|
|
123
|
+
decoratedInstances.add(eagerInstance);
|
|
124
|
+
}
|
|
125
|
+
}
|
|
115
126
|
const initializers = injector.get(exports.APP_INITIALIZER, []);
|
|
116
127
|
await Promise.all(initializers.map((initializer) => initializer()));
|
|
117
128
|
return instance;
|
|
@@ -7,6 +7,7 @@ const event_listener_decorator_1 = require("./event-listener.decorator");
|
|
|
7
7
|
const export_decorator_1 = require("./export.decorator");
|
|
8
8
|
const key_binding_decorator_1 = require("./key-binding.decorator");
|
|
9
9
|
const ui_listener_decorator_1 = require("./ui-listener.decorator");
|
|
10
|
+
const decoratedTargets = new WeakSet();
|
|
10
11
|
class DecoratorUtils {
|
|
11
12
|
static map(target, _prototype, providers) {
|
|
12
13
|
return [
|
|
@@ -25,9 +26,16 @@ class DecoratorUtils {
|
|
|
25
26
|
}
|
|
26
27
|
exports.DecoratorUtils = DecoratorUtils;
|
|
27
28
|
function Decorate(instance, _prototype, providers, decorationType = DecorationType.SERVER) {
|
|
29
|
+
if (decoratedTargets.has(instance)) {
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
28
32
|
const relevantProvidersForClass = Object.values(instance)
|
|
29
33
|
.filter((provider) => typeof provider === 'object'
|
|
34
|
+
&& provider !== null
|
|
35
|
+
&& !decoratedTargets.has(provider)
|
|
30
36
|
&& Reflect.getMetadataKeys(provider).some((key) => key.startsWith('arm_')));
|
|
37
|
+
decoratedTargets.add(instance);
|
|
38
|
+
relevantProvidersForClass.forEach((provider) => decoratedTargets.add(provider));
|
|
31
39
|
(0, command_decorator_1.Commands)(instance, _prototype, relevantProvidersForClass);
|
|
32
40
|
(0, event_listener_decorator_1.EventListeners)(instance, _prototype, relevantProvidersForClass);
|
|
33
41
|
(0, export_decorator_1.Exports)(instance, _prototype, relevantProvidersForClass);
|
package/dist/esm/common/index.js
CHANGED
|
@@ -88,7 +88,18 @@ export async function bootstrapWithProviders(entryPoint, parentProviders, option
|
|
|
88
88
|
const injector = ReflectiveInjector.resolveAndCreate([...configProviders, ...resourceProviders, ...providers, entryPoint], parentInjector);
|
|
89
89
|
const instance = injector.get(entryPoint);
|
|
90
90
|
Decorate(instance, entryPoint.prototype, [...parentProviders, ...providers], decorationType);
|
|
91
|
-
|
|
91
|
+
const decoratedInstances = new Set([instance]);
|
|
92
|
+
for (const token of eagerTokens) {
|
|
93
|
+
const eagerInstance = injector.get(token);
|
|
94
|
+
if (typeof eagerInstance !== 'object' || eagerInstance === null || decoratedInstances.has(eagerInstance)) {
|
|
95
|
+
continue;
|
|
96
|
+
}
|
|
97
|
+
const prototype = Object.getPrototypeOf(eagerInstance);
|
|
98
|
+
if (prototype && prototype !== Object.prototype) {
|
|
99
|
+
Decorate(eagerInstance, prototype, [...parentProviders, ...providers], decorationType);
|
|
100
|
+
decoratedInstances.add(eagerInstance);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
92
103
|
const initializers = injector.get(APP_INITIALIZER, []);
|
|
93
104
|
await Promise.all(initializers.map((initializer) => initializer()));
|
|
94
105
|
return instance;
|
|
@@ -3,6 +3,7 @@ import { EventListeners } from "./event-listener.decorator";
|
|
|
3
3
|
import { Exports } from "./export.decorator";
|
|
4
4
|
import { KeyBindings } from "./key-binding.decorator";
|
|
5
5
|
import { UIListeners } from "./ui-listener.decorator";
|
|
6
|
+
const decoratedTargets = new WeakSet();
|
|
6
7
|
export class DecoratorUtils {
|
|
7
8
|
static map(target, _prototype, providers) {
|
|
8
9
|
return [
|
|
@@ -20,9 +21,16 @@ export class DecoratorUtils {
|
|
|
20
21
|
}
|
|
21
22
|
}
|
|
22
23
|
export function Decorate(instance, _prototype, providers, decorationType = DecorationType.SERVER) {
|
|
24
|
+
if (decoratedTargets.has(instance)) {
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
23
27
|
const relevantProvidersForClass = Object.values(instance)
|
|
24
28
|
.filter((provider) => typeof provider === 'object'
|
|
29
|
+
&& provider !== null
|
|
30
|
+
&& !decoratedTargets.has(provider)
|
|
25
31
|
&& Reflect.getMetadataKeys(provider).some((key) => key.startsWith('arm_')));
|
|
32
|
+
decoratedTargets.add(instance);
|
|
33
|
+
relevantProvidersForClass.forEach((provider) => decoratedTargets.add(provider));
|
|
26
34
|
Commands(instance, _prototype, relevantProvidersForClass);
|
|
27
35
|
EventListeners(instance, _prototype, relevantProvidersForClass);
|
|
28
36
|
Exports(instance, _prototype, relevantProvidersForClass);
|