@adimm/x-injection 0.3.1 → 0.4.0
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/README.md +14 -6
- package/dist/index.cjs +115 -90
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +86 -47
- package/dist/index.d.ts +86 -47
- package/dist/index.js +118 -97
- package/dist/index.js.map +1 -1
- package/package.json +9 -5
package/README.md
CHANGED
|
@@ -26,6 +26,7 @@ xInjection <a href="https://www.npmjs.com/package/@adimm/x-injection" targe
|
|
|
26
26
|
- [Dynamic Exports](#dynamic-exports)
|
|
27
27
|
- [Advanced Usage](#advanced-usage)
|
|
28
28
|
- [Documentation](#documentation)
|
|
29
|
+
- [ReactJS Implementation](#reactjs-implementation)
|
|
29
30
|
- [Contributing](#contributing)
|
|
30
31
|
|
|
31
32
|
## Overview
|
|
@@ -126,6 +127,7 @@ The below list shows them in order of priority _(highest to lowest)_, meaning th
|
|
|
126
127
|
3. By providing the [defaultScope](https://adimarianmutu.github.io/x-injection/interfaces/ProviderModuleOptions.html#defaultscope) property when initializing a `ProviderModule`:
|
|
127
128
|
```ts
|
|
128
129
|
const RainModule = new ProviderModule({
|
|
130
|
+
identifier: Symbol('RainModule'),
|
|
129
131
|
defaultScope: InjectionScope.Transient,
|
|
130
132
|
});
|
|
131
133
|
```
|
|
@@ -152,7 +154,7 @@ export class SessionService {
|
|
|
152
154
|
}
|
|
153
155
|
|
|
154
156
|
export const DatabaseModule = new ProviderModule({
|
|
155
|
-
|
|
157
|
+
identifier: Symbol('DatabaseModule'),
|
|
156
158
|
providers: [DatabaseService],
|
|
157
159
|
exports: [DatabaseService],
|
|
158
160
|
onReady: async (module) => {
|
|
@@ -168,7 +170,7 @@ export const DatabaseModule = new ProviderModule({
|
|
|
168
170
|
});
|
|
169
171
|
|
|
170
172
|
export const SessionModule = new ProviderModule({
|
|
171
|
-
|
|
173
|
+
identifier: Symbol('SessionModule'),
|
|
172
174
|
defaultScope: InjectionScope.Request,
|
|
173
175
|
providers: [SessionService],
|
|
174
176
|
exports: [SessionService],
|
|
@@ -244,14 +246,14 @@ class CrowService extends AnimalService {
|
|
|
244
246
|
}
|
|
245
247
|
|
|
246
248
|
const AnimalModule = new ProviderModule({
|
|
247
|
-
|
|
249
|
+
identifier: Symbol('AnimalModule'),
|
|
248
250
|
providers: [AnimalService, { provide: WingsService, useClass: WingsService, scope: InjectionScope.Transient }],
|
|
249
251
|
exports: [AnimalService, WingsService],
|
|
250
252
|
dynamicExports: (importerModule, moduleExports) => {
|
|
251
253
|
// If the importer module is `CrowModule`, we'll export the entire
|
|
252
254
|
// `exports` list, because `moduleExports` is actually the `exports` array declared above.
|
|
253
255
|
// Meaning that the `CrowModule` container will also have access to the `WingsService`
|
|
254
|
-
if (importerModule.
|
|
256
|
+
if (importerModule.toString() === 'CrowModule') return moduleExports;
|
|
255
257
|
|
|
256
258
|
// Otherwise it is the `CatModule` and we are not
|
|
257
259
|
// exporting the `WingsService` as cats don't fly, or do they fly? 🧐
|
|
@@ -260,14 +262,14 @@ const AnimalModule = new ProviderModule({
|
|
|
260
262
|
});
|
|
261
263
|
|
|
262
264
|
const CrowModule = new ProviderModule({
|
|
263
|
-
|
|
265
|
+
identifier: Symbol('CrowModule'),
|
|
264
266
|
imports: [AnimalModule],
|
|
265
267
|
providers: [CrowService],
|
|
266
268
|
exports: [CrowService],
|
|
267
269
|
});
|
|
268
270
|
|
|
269
271
|
const CatModule = new ProviderModule({
|
|
270
|
-
|
|
272
|
+
identifier: Symbol('CatModule'),
|
|
271
273
|
imports: [AnimalModule],
|
|
272
274
|
providers: [CatService],
|
|
273
275
|
exports: [CatService],
|
|
@@ -308,6 +310,12 @@ Comprehensive, auto-generated documentation is available at:
|
|
|
308
310
|
|
|
309
311
|
👉 [https://adimarianmutu.github.io/x-injection/index.html](https://adimarianmutu.github.io/x-injection/index.html)
|
|
310
312
|
|
|
313
|
+
## ReactJS Implementation
|
|
314
|
+
|
|
315
|
+
You want to use it within a [ReactJS](https://react.dev/) project? Don't worry, the library does already have an official implementation for React ⚛️
|
|
316
|
+
|
|
317
|
+
For more details check out the [GitHub Repository](https://github.com/AdiMarianMutu/x-injection-reactjs).
|
|
318
|
+
|
|
311
319
|
## Contributing
|
|
312
320
|
|
|
313
321
|
Pull requests are warmly welcomed! 😃
|
package/dist/index.cjs
CHANGED
|
@@ -11,30 +11,34 @@ var e, i = Object.defineProperty, t = Object.getOwnPropertyDescriptor, n = Objec
|
|
|
11
11
|
enumerable: !0
|
|
12
12
|
});
|
|
13
13
|
})(s, {
|
|
14
|
-
|
|
15
|
-
AppModule: () => z,
|
|
14
|
+
AppModule: () => H,
|
|
16
15
|
GLOBAL_APP_MODULE_ID: () => d,
|
|
17
|
-
GlobalAppModule: () =>
|
|
18
|
-
GlobalContainer: () =>
|
|
16
|
+
GlobalAppModule: () => z,
|
|
17
|
+
GlobalContainer: () => X,
|
|
19
18
|
Inject: () => b,
|
|
20
19
|
InjectFromBase: () => B,
|
|
21
20
|
Injectable: () => I,
|
|
22
|
-
InjectionScope: () =>
|
|
21
|
+
InjectionScope: () => a,
|
|
23
22
|
MultiInject: () => T,
|
|
24
23
|
Named: () => D,
|
|
25
|
-
Optional: () =>
|
|
24
|
+
Optional: () => P,
|
|
26
25
|
PostConstruct: () => C,
|
|
27
|
-
PreDestroy: () =>
|
|
28
|
-
ProviderModule: () =>
|
|
29
|
-
ProviderModuleHelpers: () =>
|
|
30
|
-
ProviderTokenHelpers: () =>
|
|
26
|
+
PreDestroy: () => x,
|
|
27
|
+
ProviderModule: () => $,
|
|
28
|
+
ProviderModuleHelpers: () => f,
|
|
29
|
+
ProviderTokenHelpers: () => l,
|
|
31
30
|
Tagged: () => O,
|
|
32
31
|
Unmanaged: () => q,
|
|
33
32
|
XInjectionDynamicExportsOutOfRange: () => G,
|
|
34
33
|
XInjectionError: () => F,
|
|
35
34
|
XInjectionProviderModuleDisposedError: () => U,
|
|
36
35
|
XInjectionProviderModuleError: () => N,
|
|
37
|
-
|
|
36
|
+
XInjectionProviderModuleMissingIdentifierError: () => V,
|
|
37
|
+
bindingScopeToInjectionScope: () => h,
|
|
38
|
+
injectionScopeToBindingScope: () => u,
|
|
39
|
+
isClass: () => g,
|
|
40
|
+
isClassOrFunction: () => S,
|
|
41
|
+
isPlainObject: () => y
|
|
38
42
|
}), module.exports = (e = s, ((e, o, s, d) => {
|
|
39
43
|
if (o && "object" == typeof o || "function" == typeof o) for (let c of n(o)) r.call(e, c) || c === s || i(e, c, {
|
|
40
44
|
get: () => o[c],
|
|
@@ -45,62 +49,66 @@ var e, i = Object.defineProperty, t = Object.getOwnPropertyDescriptor, n = Objec
|
|
|
45
49
|
value: !0
|
|
46
50
|
}), e));
|
|
47
51
|
|
|
48
|
-
var d = "GlobalAppModule", c =
|
|
52
|
+
var d = "GlobalAppModule", c = require("inversify"), a = function(e) {
|
|
49
53
|
return e[e.Singleton = 0] = "Singleton", e[e.Transient = 1] = "Transient", e[e.Request = 2] = "Request",
|
|
50
54
|
e;
|
|
51
55
|
}({});
|
|
52
56
|
|
|
53
|
-
function
|
|
57
|
+
function u(e) {
|
|
54
58
|
switch (e) {
|
|
55
|
-
case
|
|
59
|
+
case a.Singleton:
|
|
56
60
|
return "Singleton";
|
|
57
61
|
|
|
58
|
-
case
|
|
62
|
+
case a.Transient:
|
|
59
63
|
return "Transient";
|
|
60
64
|
|
|
61
|
-
case
|
|
65
|
+
case a.Request:
|
|
62
66
|
return "Request";
|
|
63
67
|
}
|
|
64
68
|
}
|
|
65
69
|
|
|
66
|
-
function
|
|
70
|
+
function h(e) {
|
|
67
71
|
switch (e) {
|
|
68
72
|
case "Singleton":
|
|
69
|
-
return
|
|
73
|
+
return a.Singleton;
|
|
70
74
|
|
|
71
75
|
case "Transient":
|
|
72
|
-
return
|
|
76
|
+
return a.Transient;
|
|
73
77
|
|
|
74
78
|
case "Request":
|
|
75
|
-
return
|
|
79
|
+
return a.Request;
|
|
76
80
|
}
|
|
77
81
|
}
|
|
78
82
|
|
|
79
|
-
o(
|
|
83
|
+
o(u, "injectionScopeToBindingScope"), o(h, "bindingScopeToInjectionScope");
|
|
80
84
|
|
|
81
|
-
var f, p
|
|
85
|
+
var l, f, p = require("@inversifyjs/core");
|
|
82
86
|
|
|
83
87
|
function g(e) {
|
|
84
88
|
return "function" == typeof e && /^class\s/.test(Function.prototype.toString.call(e));
|
|
85
89
|
}
|
|
86
90
|
|
|
87
|
-
function
|
|
91
|
+
function v(e) {
|
|
88
92
|
return "[object Object]" === Object.prototype.toString.call(e);
|
|
89
93
|
}
|
|
90
94
|
|
|
91
95
|
function y(e) {
|
|
92
|
-
if (!1 ===
|
|
96
|
+
if (!1 === v(e)) return !1;
|
|
93
97
|
const i = e.constructor;
|
|
94
98
|
if (void 0 === i) return !0;
|
|
95
99
|
const t = i.prototype;
|
|
96
|
-
return !1 !==
|
|
100
|
+
return !1 !== v(t) && !1 !== t.hasOwnProperty("isPrototypeOf");
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
function S(e) {
|
|
104
|
+
return "function" == typeof e;
|
|
97
105
|
}
|
|
98
106
|
|
|
99
107
|
function I(e) {
|
|
100
|
-
return void 0 === e ? (0,
|
|
108
|
+
return void 0 === e ? (0, c.injectable)() : (0, c.injectable)(u(e));
|
|
101
109
|
}
|
|
102
110
|
|
|
103
|
-
o(g, "isClass"), o(
|
|
111
|
+
o(g, "isClass"), o(v, "isObject"), o(y, "isPlainObject"), function(e) {
|
|
104
112
|
function i(e) {
|
|
105
113
|
return f(e) && "useClass" in e;
|
|
106
114
|
}
|
|
@@ -120,7 +128,7 @@ o(g, "isClass"), o(S, "isObject"), o(y, "isPlainObject"), function(e) {
|
|
|
120
128
|
return e.map((e => s(e)));
|
|
121
129
|
}
|
|
122
130
|
function c(e, i) {
|
|
123
|
-
return u(e) ??
|
|
131
|
+
return u(e) ?? l(e) ?? i;
|
|
124
132
|
}
|
|
125
133
|
function a(e) {
|
|
126
134
|
if (f(e)) return e;
|
|
@@ -129,11 +137,11 @@ o(g, "isClass"), o(S, "isObject"), o(y, "isPlainObject"), function(e) {
|
|
|
129
137
|
const i = a(e);
|
|
130
138
|
if (i) return i.scope;
|
|
131
139
|
}
|
|
132
|
-
function
|
|
140
|
+
function l(e) {
|
|
133
141
|
const i = s(e);
|
|
134
142
|
if (!g(i)) return;
|
|
135
|
-
const t = (0,
|
|
136
|
-
return t ?
|
|
143
|
+
const t = (0, p.getClassMetadata)(i)?.scope;
|
|
144
|
+
return t ? h(t) : void 0;
|
|
137
145
|
}
|
|
138
146
|
function f(e) {
|
|
139
147
|
return y(e) && "object" == typeof e && "provide" in e;
|
|
@@ -143,9 +151,9 @@ o(g, "isClass"), o(S, "isObject"), o(y, "isPlainObject"), function(e) {
|
|
|
143
151
|
o(s, "toServiceIdentifier"), e.toServiceIdentifier = s, o(d, "toServiceIdentifiers"),
|
|
144
152
|
e.toServiceIdentifiers = d, o(c, "getInjectionScopeByPriority"), e.getInjectionScopeByPriority = c,
|
|
145
153
|
o(a, "tryGetProviderOptions"), e.tryGetProviderOptions = a, o(u, "tryGetScopeFromProvider"),
|
|
146
|
-
e.tryGetScopeFromProvider = u, o(
|
|
154
|
+
e.tryGetScopeFromProvider = u, o(l, "tryGetDecoratorScopeFromClass"), e.tryGetDecoratorScopeFromClass = l,
|
|
147
155
|
o(f, "hasProvideProperty");
|
|
148
|
-
}(
|
|
156
|
+
}(l || (l = {})), function(e) {
|
|
149
157
|
function i(e) {
|
|
150
158
|
return e;
|
|
151
159
|
}
|
|
@@ -154,12 +162,12 @@ o(g, "isClass"), o(S, "isObject"), o(y, "isPlainObject"), function(e) {
|
|
|
154
162
|
}
|
|
155
163
|
o(i, "buildInternalConstructorParams"), e.buildInternalConstructorParams = i, o(t, "isDynamicExport"),
|
|
156
164
|
e.isDynamicExport = t;
|
|
157
|
-
}(
|
|
165
|
+
}(f || (f = {})), o(S, "isClassOrFunction"), o(I, "Injectable");
|
|
158
166
|
|
|
159
167
|
var m = require("inversify");
|
|
160
168
|
|
|
161
169
|
function b(e) {
|
|
162
|
-
return (0, m.inject)(
|
|
170
|
+
return (0, m.inject)(l.toServiceIdentifier(e));
|
|
163
171
|
}
|
|
164
172
|
|
|
165
173
|
o(b, "Inject");
|
|
@@ -167,7 +175,7 @@ o(b, "Inject");
|
|
|
167
175
|
var E = require("inversify");
|
|
168
176
|
|
|
169
177
|
function T(e) {
|
|
170
|
-
return (0, E.multiInject)(
|
|
178
|
+
return (0, E.multiInject)(l.toServiceIdentifier(e));
|
|
171
179
|
}
|
|
172
180
|
|
|
173
181
|
o(T, "MultiInject");
|
|
@@ -190,32 +198,32 @@ o(D, "Named");
|
|
|
190
198
|
|
|
191
199
|
var j = require("inversify");
|
|
192
200
|
|
|
193
|
-
function
|
|
201
|
+
function P() {
|
|
194
202
|
return (0, j.optional)();
|
|
195
203
|
}
|
|
196
204
|
|
|
197
|
-
o(
|
|
205
|
+
o(P, "Optional");
|
|
198
206
|
|
|
199
|
-
var
|
|
207
|
+
var M = require("inversify");
|
|
200
208
|
|
|
201
209
|
function C() {
|
|
202
|
-
return (0,
|
|
210
|
+
return (0, M.postConstruct)();
|
|
203
211
|
}
|
|
204
212
|
|
|
205
213
|
o(C, "PostConstruct");
|
|
206
214
|
|
|
207
215
|
var k = require("inversify");
|
|
208
216
|
|
|
209
|
-
function
|
|
217
|
+
function x() {
|
|
210
218
|
return (0, k.preDestroy)();
|
|
211
219
|
}
|
|
212
220
|
|
|
213
|
-
o(
|
|
221
|
+
o(x, "PreDestroy");
|
|
214
222
|
|
|
215
|
-
var
|
|
223
|
+
var A = require("inversify");
|
|
216
224
|
|
|
217
225
|
function O(e, i) {
|
|
218
|
-
return (0,
|
|
226
|
+
return (0, A.tagged)(e, i);
|
|
219
227
|
}
|
|
220
228
|
|
|
221
229
|
o(O, "Tagged");
|
|
@@ -257,9 +265,17 @@ var F = class e extends Error {
|
|
|
257
265
|
constructor(e) {
|
|
258
266
|
super(e, `The 'ProviderModule.${e.toString()}' is trying to dynamically export providers/modules out of the declared range of the static exports!`);
|
|
259
267
|
}
|
|
260
|
-
}, V =
|
|
268
|
+
}, V = class e extends N {
|
|
269
|
+
static {
|
|
270
|
+
o(this, "XInjectionProviderModuleMissingIdentifierError");
|
|
271
|
+
}
|
|
272
|
+
name=e.name;
|
|
273
|
+
constructor(e) {
|
|
274
|
+
super(e, "An `identifier` must be supplied!");
|
|
275
|
+
}
|
|
276
|
+
}, X = new (require("inversify").Container)({
|
|
261
277
|
defaultScope: "Singleton"
|
|
262
|
-
}), L = require("inversify"),
|
|
278
|
+
}), L = require("inversify"), W = class {
|
|
263
279
|
static {
|
|
264
280
|
o(this, "ProviderModuleUtils");
|
|
265
281
|
}
|
|
@@ -272,55 +288,56 @@ var F = class e extends Error {
|
|
|
272
288
|
this.module = e, this.moduleNaked = e.toNaked();
|
|
273
289
|
}
|
|
274
290
|
bindToContainer(e, i) {
|
|
275
|
-
return
|
|
291
|
+
return l.isProviderIdentifier(e) ? this.bindSelfTokenToContainer(e, i) : l.isClassToken(e) ? this.bindClassTokenToContainer(e, i) : l.isValueToken(e) ? this.bindValueTokenToContainer(e) : !!l.isFactoryToken(e) && this.bindFactoryTokenToContainer(e, i);
|
|
276
292
|
}
|
|
277
293
|
bindManyToContainer(e, i) {
|
|
278
294
|
e.forEach((e => this.bindToContainer(e, i)));
|
|
279
295
|
}
|
|
280
296
|
bindSelfTokenToContainer(e, i) {
|
|
281
|
-
return this.setBindingScope(e, this.container.bind(
|
|
297
|
+
return this.setBindingScope(e, this.container.bind(l.toServiceIdentifier(e)).toSelf(), i),
|
|
282
298
|
this.moduleNaked.__isCurrentBound(e);
|
|
283
299
|
}
|
|
284
300
|
bindClassTokenToContainer(e, i) {
|
|
285
|
-
return this.setBindingOnEvent(e, this.setWhenBinding(e, this.setBindingScope(e, this.container.bind(
|
|
301
|
+
return this.setBindingOnEvent(e, this.setWhenBinding(e, this.setBindingScope(e, this.container.bind(l.toServiceIdentifier(e)).to(e.useClass), i))),
|
|
286
302
|
this.moduleNaked.__isCurrentBound(e);
|
|
287
303
|
}
|
|
288
304
|
bindValueTokenToContainer(e) {
|
|
289
|
-
return this.setBindingOnEvent(e, this.setWhenBinding(e, this.container.bind(
|
|
305
|
+
return this.setBindingOnEvent(e, this.setWhenBinding(e, this.container.bind(l.toServiceIdentifier(e)).toConstantValue(e.useValue))),
|
|
290
306
|
this.moduleNaked.__isCurrentBound(e);
|
|
291
307
|
}
|
|
292
308
|
bindFactoryTokenToContainer(e, i) {
|
|
293
|
-
return this.setBindingOnEvent(e, this.setWhenBinding(e, this.setBindingScope(e, this.container.bind(
|
|
309
|
+
return this.setBindingOnEvent(e, this.setWhenBinding(e, this.setBindingScope(e, this.container.bind(l.toServiceIdentifier(e)).toResolvedValue(e.useFactory, l.toServiceIdentifiers(e.inject ?? [])), i))),
|
|
294
310
|
this.moduleNaked.__isCurrentBound(e);
|
|
295
311
|
}
|
|
296
312
|
setBindingScope(e, i, t) {
|
|
297
|
-
if (
|
|
298
|
-
switch (
|
|
299
|
-
case
|
|
313
|
+
if (l.isValueToken(e)) return i;
|
|
314
|
+
switch (l.getInjectionScopeByPriority(e, t)) {
|
|
315
|
+
case a.Singleton:
|
|
300
316
|
return i.inSingletonScope();
|
|
301
317
|
|
|
302
|
-
case
|
|
318
|
+
case a.Transient:
|
|
303
319
|
return i.inTransientScope();
|
|
304
320
|
|
|
305
|
-
case
|
|
321
|
+
case a.Request:
|
|
306
322
|
return i.inRequestScope();
|
|
307
323
|
}
|
|
308
324
|
}
|
|
309
325
|
setWhenBinding(e, i) {
|
|
310
|
-
if (
|
|
326
|
+
if (l.isProviderIdentifier(e)) return i;
|
|
311
327
|
const t = e.when;
|
|
312
328
|
return t ? i.when(t) : i;
|
|
313
329
|
}
|
|
314
330
|
setBindingOnEvent(e, i) {
|
|
315
|
-
if (
|
|
331
|
+
if (l.isProviderIdentifier(e)) return;
|
|
316
332
|
const t = e;
|
|
317
333
|
t.onEvent?.activation && i.onActivation(t.onEvent.activation), t.onEvent?.deactivation && i.onDeactivation(t.onEvent.deactivation);
|
|
318
334
|
}
|
|
319
|
-
},
|
|
335
|
+
}, $ = class e {
|
|
320
336
|
static {
|
|
321
337
|
o(this, "ProviderModule");
|
|
322
338
|
}
|
|
323
339
|
identifier;
|
|
340
|
+
isDisposed=!1;
|
|
324
341
|
isAppModule;
|
|
325
342
|
container;
|
|
326
343
|
defaultScope;
|
|
@@ -332,9 +349,10 @@ var F = class e extends Error {
|
|
|
332
349
|
exports;
|
|
333
350
|
imports;
|
|
334
351
|
registeredBindingSideEffects;
|
|
335
|
-
constructor({identifier: e
|
|
336
|
-
const
|
|
337
|
-
this.identifier = e, this.isAppModule =
|
|
352
|
+
constructor({identifier: e, imports: i, providers: t, exports: n, defaultScope: r, dynamicExports: o, onReady: s, onDispose: d, ...c}) {
|
|
353
|
+
const a = c;
|
|
354
|
+
this.identifier = this.setIdentifier(e), this.isAppModule = a.isAppModule ?? !1,
|
|
355
|
+
this.isAppModule || this._lazyInit({
|
|
338
356
|
imports: i,
|
|
339
357
|
providers: t,
|
|
340
358
|
exports: n,
|
|
@@ -342,7 +360,7 @@ var F = class e extends Error {
|
|
|
342
360
|
dynamicExports: o,
|
|
343
361
|
onReady: s,
|
|
344
362
|
onDispose: d,
|
|
345
|
-
...
|
|
363
|
+
...c
|
|
346
364
|
});
|
|
347
365
|
}
|
|
348
366
|
get(e, i) {
|
|
@@ -357,21 +375,25 @@ var F = class e extends Error {
|
|
|
357
375
|
}));
|
|
358
376
|
}
|
|
359
377
|
onActivationEvent(e, i) {
|
|
360
|
-
this.container.onActivation(
|
|
378
|
+
this.container.onActivation(l.toServiceIdentifier(e), i);
|
|
361
379
|
}
|
|
362
380
|
onDeactivationEvent(e, i) {
|
|
363
|
-
this.container.onDeactivation(
|
|
381
|
+
this.container.onDeactivation(l.toServiceIdentifier(e), i);
|
|
364
382
|
}
|
|
365
383
|
toNaked() {
|
|
366
384
|
return this;
|
|
367
385
|
}
|
|
368
386
|
toString() {
|
|
369
|
-
return this.identifier
|
|
387
|
+
return this.identifier?.description ?? "Unknown";
|
|
388
|
+
}
|
|
389
|
+
setIdentifier(e) {
|
|
390
|
+
if (!e) throw new V(this);
|
|
391
|
+
return e;
|
|
370
392
|
}
|
|
371
393
|
prepareContainer(e) {
|
|
372
|
-
return this.isAppModule ? e.container?.() ??
|
|
394
|
+
return this.isAppModule ? e.container?.() ?? X : e.container ? (console.warn(`[xInjection]: The '${this.toString()}' module is using a dynamic container!`),
|
|
373
395
|
e.container()) : new L.Container({
|
|
374
|
-
parent:
|
|
396
|
+
parent: X,
|
|
375
397
|
defaultScope: this.defaultScope.inversify
|
|
376
398
|
});
|
|
377
399
|
}
|
|
@@ -387,9 +409,9 @@ var F = class e extends Error {
|
|
|
387
409
|
}
|
|
388
410
|
const n = t;
|
|
389
411
|
this.moduleUtils.bindToContainer({
|
|
390
|
-
scope:
|
|
391
|
-
provide:
|
|
392
|
-
useFactory: o((() =>
|
|
412
|
+
scope: l.getInjectionScopeByPriority(n, i.defaultScope.native),
|
|
413
|
+
provide: l.toServiceIdentifier(n),
|
|
414
|
+
useFactory: o((() => this._importedDependencyFactory(n, i)), "useFactory")
|
|
393
415
|
}, i.defaultScope.native);
|
|
394
416
|
}));
|
|
395
417
|
}));
|
|
@@ -420,18 +442,21 @@ var F = class e extends Error {
|
|
|
420
442
|
shouldThrowIfDisposed() {
|
|
421
443
|
if (null === this.container) throw new U(this);
|
|
422
444
|
}
|
|
445
|
+
_importedDependencyFactory(e, i) {
|
|
446
|
+
return i.get(e);
|
|
447
|
+
}
|
|
423
448
|
async _dispose() {
|
|
424
449
|
await (this.onDispose?.(this)), await this.__unbindAll(), this.container = null,
|
|
425
450
|
this.imports = null, this.providers = null, this.exports = null, this.dynamicExports = null,
|
|
426
|
-
this.registeredBindingSideEffects = null;
|
|
451
|
+
this.registeredBindingSideEffects = null, this.isDisposed = !0;
|
|
427
452
|
}
|
|
428
|
-
_lazyInit({imports: e = [], providers: i = [], exports: t = [], defaultScope: n =
|
|
429
|
-
this.imports = e, this.providers = i, this.exports = t, this.defaultScope = {
|
|
453
|
+
_lazyInit({imports: e = [], providers: i = [], exports: t = [], defaultScope: n = a.Singleton, dynamicExports: r, onReady: o, onDispose: s, ...d}) {
|
|
454
|
+
this.isDisposed = !1, this.imports = e, this.providers = i, this.exports = t, this.defaultScope = {
|
|
430
455
|
native: n,
|
|
431
|
-
inversify:
|
|
456
|
+
inversify: u(n)
|
|
432
457
|
}, this.dynamicExports = r, this.onReady = o, this.onDispose = s, this.container = this.prepareContainer({
|
|
433
458
|
...d
|
|
434
|
-
}), this.moduleUtils = new
|
|
459
|
+
}), this.moduleUtils = new W(this), this.registeredBindingSideEffects = new Map,
|
|
435
460
|
this.injectImportedModules(this._getImportedModules()), this.injectProviders(),
|
|
436
461
|
this.onReady?.(this);
|
|
437
462
|
}
|
|
@@ -458,26 +483,26 @@ var F = class e extends Error {
|
|
|
458
483
|
}
|
|
459
484
|
__bind(e) {
|
|
460
485
|
this.shouldThrowIfDisposed();
|
|
461
|
-
const i = this.container.bind(
|
|
486
|
+
const i = this.container.bind(l.toServiceIdentifier(e));
|
|
462
487
|
return this.invokeRegisteredBindingSideEffects(e, "onBind"), i;
|
|
463
488
|
}
|
|
464
489
|
__get(e, i) {
|
|
465
|
-
return this.shouldThrowIfDisposed(), this.container.get(
|
|
490
|
+
return this.shouldThrowIfDisposed(), this.container.get(l.toServiceIdentifier(e), i);
|
|
466
491
|
}
|
|
467
492
|
async __getAsync(e, i) {
|
|
468
|
-
return this.shouldThrowIfDisposed(), this.container.getAsync(
|
|
493
|
+
return this.shouldThrowIfDisposed(), this.container.getAsync(l.toServiceIdentifier(e), i);
|
|
469
494
|
}
|
|
470
495
|
__getAll(e, i) {
|
|
471
|
-
return this.shouldThrowIfDisposed(), this.container.getAll(
|
|
496
|
+
return this.shouldThrowIfDisposed(), this.container.getAll(l.toServiceIdentifier(e), i);
|
|
472
497
|
}
|
|
473
498
|
async __getAllAsync(e, i) {
|
|
474
|
-
return this.shouldThrowIfDisposed(), this.container.getAllAsync(
|
|
499
|
+
return this.shouldThrowIfDisposed(), this.container.getAllAsync(l.toServiceIdentifier(e), i);
|
|
475
500
|
}
|
|
476
501
|
__isBound(e, i) {
|
|
477
|
-
return this.shouldThrowIfDisposed(), this.container.isBound(
|
|
502
|
+
return this.shouldThrowIfDisposed(), this.container.isBound(l.toServiceIdentifier(e), i);
|
|
478
503
|
}
|
|
479
504
|
__isCurrentBound(e, i) {
|
|
480
|
-
return this.shouldThrowIfDisposed(), this.container.isCurrentBound(
|
|
505
|
+
return this.shouldThrowIfDisposed(), this.container.isCurrentBound(l.toServiceIdentifier(e), i);
|
|
481
506
|
}
|
|
482
507
|
__takeSnapshot() {
|
|
483
508
|
this.shouldThrowIfDisposed(), this.container.snapshot();
|
|
@@ -487,33 +512,33 @@ var F = class e extends Error {
|
|
|
487
512
|
}
|
|
488
513
|
async __rebind(e) {
|
|
489
514
|
this.shouldThrowIfDisposed();
|
|
490
|
-
const i = await this.container.rebind(
|
|
515
|
+
const i = await this.container.rebind(l.toServiceIdentifier(e));
|
|
491
516
|
return this.invokeRegisteredBindingSideEffects(e, "onRebind"), i;
|
|
492
517
|
}
|
|
493
518
|
__rebindSync(e) {
|
|
494
519
|
this.shouldThrowIfDisposed();
|
|
495
|
-
const i = this.container.rebindSync(
|
|
520
|
+
const i = this.container.rebindSync(l.toServiceIdentifier(e));
|
|
496
521
|
return this.invokeRegisteredBindingSideEffects(e, "onRebind"), i;
|
|
497
522
|
}
|
|
498
523
|
async __unbind(e) {
|
|
499
|
-
this.shouldThrowIfDisposed(), await this.container.unbind(
|
|
524
|
+
this.shouldThrowIfDisposed(), await this.container.unbind(l.toServiceIdentifier(e)),
|
|
500
525
|
this.removeRegisteredBindingSideEffects(e);
|
|
501
526
|
}
|
|
502
527
|
__unbindSync(e) {
|
|
503
|
-
this.shouldThrowIfDisposed(), this.container.unbindSync(
|
|
528
|
+
this.shouldThrowIfDisposed(), this.container.unbindSync(l.toServiceIdentifier(e)),
|
|
504
529
|
this.removeRegisteredBindingSideEffects(e);
|
|
505
530
|
}
|
|
506
531
|
async __unbindAll() {
|
|
507
532
|
this.shouldThrowIfDisposed(), await this.container.unbindAll(), this.removeRegisteredBindingSideEffects("all");
|
|
508
533
|
}
|
|
509
|
-
},
|
|
534
|
+
}, z = class extends $ {
|
|
510
535
|
static {
|
|
511
536
|
o(this, "GlobalAppModule");
|
|
512
537
|
}
|
|
513
538
|
nakedModule=this;
|
|
514
539
|
isLoaded=!1;
|
|
515
540
|
constructor() {
|
|
516
|
-
super(
|
|
541
|
+
super(f.buildInternalConstructorParams({
|
|
517
542
|
identifier: Symbol(d),
|
|
518
543
|
isAppModule: !0
|
|
519
544
|
}));
|
|
@@ -528,4 +553,4 @@ var F = class e extends Error {
|
|
|
528
553
|
async _dispose() {
|
|
529
554
|
this.isLoaded = !1, super._dispose();
|
|
530
555
|
}
|
|
531
|
-
},
|
|
556
|
+
}, H = new z;//# sourceMappingURL=index.cjs.map
|