@armoury/fivem-framework-common 1.0.11 → 1.0.12
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 +18 -1
- package/dist/esm/common/index.js +16 -0
- package/dist/types/common/index.d.ts +13 -0
- package/package.json +1 -1
package/dist/cjs/common/index.js
CHANGED
|
@@ -15,8 +15,10 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
15
15
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
16
16
|
};
|
|
17
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
-
exports.DecorationType = exports.Decorate = void 0;
|
|
18
|
+
exports.APP_INITIALIZER = exports.DecorationType = exports.Decorate = void 0;
|
|
19
|
+
exports.bootstrapWithProviders = bootstrapWithProviders;
|
|
19
20
|
require("reflect-metadata");
|
|
21
|
+
const injection_js_1 = require("injection-js");
|
|
20
22
|
__exportStar(require("../shared"), exports);
|
|
21
23
|
__exportStar(require("../decorators"), exports);
|
|
22
24
|
var decorator_utils_1 = require("../decorators/decorator.utils");
|
|
@@ -24,3 +26,18 @@ Object.defineProperty(exports, "Decorate", { enumerable: true, get: function ()
|
|
|
24
26
|
Object.defineProperty(exports, "DecorationType", { enumerable: true, get: function () { return decorator_utils_1.DecorationType; } });
|
|
25
27
|
__exportStar(require("../utils"), exports);
|
|
26
28
|
__exportStar(require("../utils/utils"), exports);
|
|
29
|
+
const decorator_utils_2 = require("../decorators/decorator.utils");
|
|
30
|
+
exports.APP_INITIALIZER = new injection_js_1.InjectionToken('APP_INITIALIZER');
|
|
31
|
+
async function bootstrapWithProviders(entryPoint, parentProviders, options = {}, decorationType = decorator_utils_2.DecorationType.SERVER) {
|
|
32
|
+
var _a, _b;
|
|
33
|
+
const eagerProviders = (_a = options.eager) !== null && _a !== void 0 ? _a : [];
|
|
34
|
+
const providers = [...((_b = options.providers) !== null && _b !== void 0 ? _b : []), ...eagerProviders];
|
|
35
|
+
const parentInjector = injection_js_1.ReflectiveInjector.resolveAndCreate(parentProviders);
|
|
36
|
+
const injector = injection_js_1.ReflectiveInjector.resolveAndCreate([...providers, entryPoint], parentInjector);
|
|
37
|
+
const instance = injector.get(entryPoint);
|
|
38
|
+
(0, decorator_utils_2.Decorate)(instance, entryPoint.prototype, [...parentProviders, ...providers], decorationType);
|
|
39
|
+
eagerProviders.forEach((provider) => injector.get(provider));
|
|
40
|
+
const initializers = injector.get(exports.APP_INITIALIZER, []);
|
|
41
|
+
await Promise.all(initializers.map((initializer) => initializer()));
|
|
42
|
+
return instance;
|
|
43
|
+
}
|
package/dist/esm/common/index.js
CHANGED
|
@@ -1,7 +1,23 @@
|
|
|
1
1
|
/// <reference path = "../ambient.declarations.d.ts" />
|
|
2
2
|
import 'reflect-metadata';
|
|
3
|
+
import { InjectionToken, ReflectiveInjector } from 'injection-js';
|
|
3
4
|
export * from '../shared';
|
|
4
5
|
export * from '../decorators';
|
|
5
6
|
export { Decorate, DecorationType } from '../decorators/decorator.utils';
|
|
6
7
|
export * from '../utils';
|
|
7
8
|
export * from '../utils/utils';
|
|
9
|
+
import { Decorate, DecorationType } from '../decorators/decorator.utils';
|
|
10
|
+
export const APP_INITIALIZER = new InjectionToken('APP_INITIALIZER');
|
|
11
|
+
export async function bootstrapWithProviders(entryPoint, parentProviders, options = {}, decorationType = DecorationType.SERVER) {
|
|
12
|
+
var _a, _b;
|
|
13
|
+
const eagerProviders = (_a = options.eager) !== null && _a !== void 0 ? _a : [];
|
|
14
|
+
const providers = [...((_b = options.providers) !== null && _b !== void 0 ? _b : []), ...eagerProviders];
|
|
15
|
+
const parentInjector = ReflectiveInjector.resolveAndCreate(parentProviders);
|
|
16
|
+
const injector = ReflectiveInjector.resolveAndCreate([...providers, entryPoint], parentInjector);
|
|
17
|
+
const instance = injector.get(entryPoint);
|
|
18
|
+
Decorate(instance, entryPoint.prototype, [...parentProviders, ...providers], decorationType);
|
|
19
|
+
eagerProviders.forEach((provider) => injector.get(provider));
|
|
20
|
+
const initializers = injector.get(APP_INITIALIZER, []);
|
|
21
|
+
await Promise.all(initializers.map((initializer) => initializer()));
|
|
22
|
+
return instance;
|
|
23
|
+
}
|
|
@@ -1,6 +1,19 @@
|
|
|
1
1
|
import 'reflect-metadata';
|
|
2
|
+
import { InjectionToken, Provider } from 'injection-js';
|
|
2
3
|
export * from '../shared';
|
|
3
4
|
export * from '../decorators';
|
|
4
5
|
export { Decorate, DecorationType } from '../decorators/decorator.utils';
|
|
5
6
|
export * from '../utils';
|
|
6
7
|
export * from '../utils/utils';
|
|
8
|
+
import { DecorationType } from '../decorators/decorator.utils';
|
|
9
|
+
export type AppInitializer = () => void | Promise<void>;
|
|
10
|
+
export declare const APP_INITIALIZER: InjectionToken<AppInitializer[]>;
|
|
11
|
+
export interface BootstrapOptions {
|
|
12
|
+
providers?: Provider[];
|
|
13
|
+
eager?: Array<{
|
|
14
|
+
new (...args: any[]): any;
|
|
15
|
+
}>;
|
|
16
|
+
}
|
|
17
|
+
export declare function bootstrapWithProviders<T extends {
|
|
18
|
+
new (...args: any[]): any;
|
|
19
|
+
} & Provider>(entryPoint: T, parentProviders: Provider[], options?: BootstrapOptions, decorationType?: DecorationType): Promise<InstanceType<T>>;
|