@adimm/x-injection 0.3.1 → 0.3.2
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 +1 -1
- package/dist/index.cjs +84 -75
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +50 -40
- package/dist/index.d.ts +50 -40
- package/dist/index.js +64 -59
- package/dist/index.js.map +1 -1
- package/package.json +6 -2
package/README.md
CHANGED
|
@@ -251,7 +251,7 @@ const AnimalModule = new ProviderModule({
|
|
|
251
251
|
// If the importer module is `CrowModule`, we'll export the entire
|
|
252
252
|
// `exports` list, because `moduleExports` is actually the `exports` array declared above.
|
|
253
253
|
// Meaning that the `CrowModule` container will also have access to the `WingsService`
|
|
254
|
-
if (importerModule.
|
|
254
|
+
if (importerModule.toString() === 'CrowModule') return moduleExports;
|
|
255
255
|
|
|
256
256
|
// Otherwise it is the `CatModule` and we are not
|
|
257
257
|
// exporting the `WingsService` as cats don't fly, or do they fly? 🧐
|
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: () =>
|
|
14
|
+
ANONYMOUS_MODULE_DEFAULT_ID: () => c,
|
|
15
|
+
AppModule: () => H,
|
|
16
16
|
GLOBAL_APP_MODULE_ID: () => d,
|
|
17
|
-
GlobalAppModule: () =>
|
|
18
|
-
GlobalContainer: () =>
|
|
19
|
-
Inject: () =>
|
|
20
|
-
InjectFromBase: () =>
|
|
21
|
-
Injectable: () =>
|
|
17
|
+
GlobalAppModule: () => z,
|
|
18
|
+
GlobalContainer: () => L,
|
|
19
|
+
Inject: () => E,
|
|
20
|
+
InjectFromBase: () => D,
|
|
21
|
+
Injectable: () => m,
|
|
22
22
|
InjectionScope: () => u,
|
|
23
|
-
MultiInject: () =>
|
|
24
|
-
Named: () =>
|
|
23
|
+
MultiInject: () => _,
|
|
24
|
+
Named: () => j,
|
|
25
25
|
Optional: () => M,
|
|
26
|
-
PostConstruct: () =>
|
|
27
|
-
PreDestroy: () =>
|
|
28
|
-
ProviderModule: () =>
|
|
26
|
+
PostConstruct: () => k,
|
|
27
|
+
PreDestroy: () => O,
|
|
28
|
+
ProviderModule: () => $,
|
|
29
29
|
ProviderModuleHelpers: () => p,
|
|
30
30
|
ProviderTokenHelpers: () => f,
|
|
31
|
-
Tagged: () =>
|
|
32
|
-
Unmanaged: () =>
|
|
33
|
-
XInjectionDynamicExportsOutOfRange: () =>
|
|
34
|
-
XInjectionError: () =>
|
|
35
|
-
XInjectionProviderModuleDisposedError: () =>
|
|
36
|
-
XInjectionProviderModuleError: () =>
|
|
37
|
-
|
|
31
|
+
Tagged: () => R,
|
|
32
|
+
Unmanaged: () => F,
|
|
33
|
+
XInjectionDynamicExportsOutOfRange: () => V,
|
|
34
|
+
XInjectionError: () => N,
|
|
35
|
+
XInjectionProviderModuleDisposedError: () => G,
|
|
36
|
+
XInjectionProviderModuleError: () => U,
|
|
37
|
+
bindingScopeToInjectionScope: () => l,
|
|
38
|
+
injectionScopeToBindingScope: () => h,
|
|
39
|
+
isClass: () => v,
|
|
40
|
+
isClassOrFunction: () => I,
|
|
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],
|
|
@@ -78,9 +82,9 @@ function l(e) {
|
|
|
78
82
|
|
|
79
83
|
o(h, "injectionScopeToBindingScope"), o(l, "bindingScopeToInjectionScope");
|
|
80
84
|
|
|
81
|
-
var f, p,
|
|
85
|
+
var f, p, g = require("@inversifyjs/core");
|
|
82
86
|
|
|
83
|
-
function
|
|
87
|
+
function v(e) {
|
|
84
88
|
return "function" == typeof e && /^class\s/.test(Function.prototype.toString.call(e));
|
|
85
89
|
}
|
|
86
90
|
|
|
@@ -97,10 +101,14 @@ function y(e) {
|
|
|
97
101
|
}
|
|
98
102
|
|
|
99
103
|
function I(e) {
|
|
104
|
+
return "function" == typeof e;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
function m(e) {
|
|
100
108
|
return void 0 === e ? (0, a.injectable)() : (0, a.injectable)(h(e));
|
|
101
109
|
}
|
|
102
110
|
|
|
103
|
-
o(
|
|
111
|
+
o(v, "isClass"), o(S, "isObject"), o(y, "isPlainObject"), function(e) {
|
|
104
112
|
function i(e) {
|
|
105
113
|
return f(e) && "useClass" in e;
|
|
106
114
|
}
|
|
@@ -111,7 +119,7 @@ o(g, "isClass"), o(S, "isObject"), o(y, "isPlainObject"), function(e) {
|
|
|
111
119
|
return f(e) && "useFactory" in e;
|
|
112
120
|
}
|
|
113
121
|
function r(e) {
|
|
114
|
-
return "string" == typeof e || "symbol" == typeof e ||
|
|
122
|
+
return "string" == typeof e || "symbol" == typeof e || v(e) || "function" == typeof e;
|
|
115
123
|
}
|
|
116
124
|
function s(e) {
|
|
117
125
|
return r(e) ? e : e.provide;
|
|
@@ -131,8 +139,8 @@ o(g, "isClass"), o(S, "isObject"), o(y, "isPlainObject"), function(e) {
|
|
|
131
139
|
}
|
|
132
140
|
function h(e) {
|
|
133
141
|
const i = s(e);
|
|
134
|
-
if (!
|
|
135
|
-
const t = (0,
|
|
142
|
+
if (!v(i)) return;
|
|
143
|
+
const t = (0, g.getClassMetadata)(i)?.scope;
|
|
136
144
|
return t ? l(t) : void 0;
|
|
137
145
|
}
|
|
138
146
|
function f(e) {
|
|
@@ -154,86 +162,86 @@ 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
|
-
}(p || (p = {})), o(I, "Injectable");
|
|
165
|
+
}(p || (p = {})), o(I, "isClassOrFunction"), o(m, "Injectable");
|
|
158
166
|
|
|
159
|
-
var
|
|
167
|
+
var b = require("inversify");
|
|
160
168
|
|
|
161
|
-
function
|
|
162
|
-
return (0,
|
|
169
|
+
function E(e) {
|
|
170
|
+
return (0, b.inject)(f.toServiceIdentifier(e));
|
|
163
171
|
}
|
|
164
172
|
|
|
165
|
-
o(
|
|
173
|
+
o(E, "Inject");
|
|
166
174
|
|
|
167
|
-
var
|
|
175
|
+
var T = require("inversify");
|
|
168
176
|
|
|
169
|
-
function
|
|
170
|
-
return (0,
|
|
177
|
+
function _(e) {
|
|
178
|
+
return (0, T.multiInject)(f.toServiceIdentifier(e));
|
|
171
179
|
}
|
|
172
180
|
|
|
173
|
-
o(
|
|
181
|
+
o(_, "MultiInject");
|
|
174
182
|
|
|
175
|
-
var
|
|
183
|
+
var B = require("inversify");
|
|
176
184
|
|
|
177
|
-
function
|
|
178
|
-
return (0,
|
|
185
|
+
function D(e) {
|
|
186
|
+
return (0, B.injectFromBase)(e);
|
|
179
187
|
}
|
|
180
188
|
|
|
181
|
-
o(
|
|
189
|
+
o(D, "InjectFromBase");
|
|
182
190
|
|
|
183
191
|
var w = require("inversify");
|
|
184
192
|
|
|
185
|
-
function
|
|
193
|
+
function j(e) {
|
|
186
194
|
return (0, w.named)(e);
|
|
187
195
|
}
|
|
188
196
|
|
|
189
|
-
o(
|
|
197
|
+
o(j, "Named");
|
|
190
198
|
|
|
191
|
-
var
|
|
199
|
+
var P = require("inversify");
|
|
192
200
|
|
|
193
201
|
function M() {
|
|
194
|
-
return (0,
|
|
202
|
+
return (0, P.optional)();
|
|
195
203
|
}
|
|
196
204
|
|
|
197
205
|
o(M, "Optional");
|
|
198
206
|
|
|
199
|
-
var
|
|
207
|
+
var C = require("inversify");
|
|
200
208
|
|
|
201
|
-
function
|
|
202
|
-
return (0,
|
|
209
|
+
function k() {
|
|
210
|
+
return (0, C.postConstruct)();
|
|
203
211
|
}
|
|
204
212
|
|
|
205
|
-
o(
|
|
213
|
+
o(k, "PostConstruct");
|
|
206
214
|
|
|
207
|
-
var
|
|
215
|
+
var A = require("inversify");
|
|
208
216
|
|
|
209
|
-
function
|
|
210
|
-
return (0,
|
|
217
|
+
function O() {
|
|
218
|
+
return (0, A.preDestroy)();
|
|
211
219
|
}
|
|
212
220
|
|
|
213
|
-
o(
|
|
221
|
+
o(O, "PreDestroy");
|
|
214
222
|
|
|
215
223
|
var x = require("inversify");
|
|
216
224
|
|
|
217
|
-
function
|
|
225
|
+
function R(e, i) {
|
|
218
226
|
return (0, x.tagged)(e, i);
|
|
219
227
|
}
|
|
220
228
|
|
|
221
|
-
o(
|
|
229
|
+
o(R, "Tagged");
|
|
222
230
|
|
|
223
|
-
var
|
|
231
|
+
var q = require("inversify");
|
|
224
232
|
|
|
225
|
-
function
|
|
226
|
-
return (0,
|
|
233
|
+
function F() {
|
|
234
|
+
return (0, q.unmanaged)();
|
|
227
235
|
}
|
|
228
236
|
|
|
229
|
-
o(
|
|
237
|
+
o(F, "Unmanaged");
|
|
230
238
|
|
|
231
|
-
var
|
|
239
|
+
var N = class e extends Error {
|
|
232
240
|
static {
|
|
233
241
|
o(this, "XInjectionError");
|
|
234
242
|
}
|
|
235
243
|
name=e.name;
|
|
236
|
-
},
|
|
244
|
+
}, U = class e extends Error {
|
|
237
245
|
static {
|
|
238
246
|
o(this, "XInjectionProviderModuleError");
|
|
239
247
|
}
|
|
@@ -241,7 +249,7 @@ var F = class e extends Error {
|
|
|
241
249
|
constructor(e, i) {
|
|
242
250
|
super(`{ProviderModule.${e.toString()}} => ${i}`);
|
|
243
251
|
}
|
|
244
|
-
},
|
|
252
|
+
}, G = class e extends U {
|
|
245
253
|
static {
|
|
246
254
|
o(this, "XInjectionProviderModuleDisposedError");
|
|
247
255
|
}
|
|
@@ -249,7 +257,7 @@ var F = class e extends Error {
|
|
|
249
257
|
constructor(e) {
|
|
250
258
|
super(e, "Has been disposed! You can re-initialize it by using the `_lazyInit` method.");
|
|
251
259
|
}
|
|
252
|
-
},
|
|
260
|
+
}, V = class e extends U {
|
|
253
261
|
static {
|
|
254
262
|
o(this, "XInjectionDynamicExportsOutOfRange");
|
|
255
263
|
}
|
|
@@ -257,9 +265,9 @@ 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
|
-
},
|
|
268
|
+
}, L = new (require("inversify").Container)({
|
|
261
269
|
defaultScope: "Singleton"
|
|
262
|
-
}),
|
|
270
|
+
}), X = require("inversify"), W = class {
|
|
263
271
|
static {
|
|
264
272
|
o(this, "ProviderModuleUtils");
|
|
265
273
|
}
|
|
@@ -316,11 +324,12 @@ var F = class e extends Error {
|
|
|
316
324
|
const t = e;
|
|
317
325
|
t.onEvent?.activation && i.onActivation(t.onEvent.activation), t.onEvent?.deactivation && i.onDeactivation(t.onEvent.deactivation);
|
|
318
326
|
}
|
|
319
|
-
},
|
|
327
|
+
}, $ = class e {
|
|
320
328
|
static {
|
|
321
329
|
o(this, "ProviderModule");
|
|
322
330
|
}
|
|
323
331
|
identifier;
|
|
332
|
+
isDisposed=!1;
|
|
324
333
|
isAppModule;
|
|
325
334
|
container;
|
|
326
335
|
defaultScope;
|
|
@@ -369,15 +378,15 @@ var F = class e extends Error {
|
|
|
369
378
|
return this.identifier.description;
|
|
370
379
|
}
|
|
371
380
|
prepareContainer(e) {
|
|
372
|
-
return this.isAppModule ? e.container?.() ??
|
|
373
|
-
e.container()) : new
|
|
374
|
-
parent:
|
|
381
|
+
return this.isAppModule ? e.container?.() ?? L : e.container ? (console.warn(`[xInjection]: The '${this.toString()}' module is using a dynamic container!`),
|
|
382
|
+
e.container()) : new X.Container({
|
|
383
|
+
parent: L,
|
|
375
384
|
defaultScope: this.defaultScope.inversify
|
|
376
385
|
});
|
|
377
386
|
}
|
|
378
387
|
injectImportedModules(i) {
|
|
379
388
|
i && 0 !== i.length && i.forEach((i => {
|
|
380
|
-
if ("GlobalAppModule" === i.toString()) throw new
|
|
389
|
+
if ("GlobalAppModule" === i.toString()) throw new U(this, "The 'GlobalAppModule' can't be imported!");
|
|
381
390
|
const t = i._getExportableModulesAndProviders(), n = i.dynamicExports?.(this, t);
|
|
382
391
|
void 0 !== n && this.shouldThrowWhenModuleDynamicExportsDontMatchTheStaticExports(i, t, n),
|
|
383
392
|
(n ?? t).forEach((t => {
|
|
@@ -415,23 +424,23 @@ var F = class e extends Error {
|
|
|
415
424
|
this.registeredBindingSideEffects.delete(e)) : this.registeredBindingSideEffects.forEach((({onUnbindEffects: e}) => e.forEach((e => e())))));
|
|
416
425
|
}
|
|
417
426
|
shouldThrowWhenModuleDynamicExportsDontMatchTheStaticExports(e, i, t) {
|
|
418
|
-
if (t.length > i.length || t.some((e => !i.includes(e)))) throw new
|
|
427
|
+
if (t.length > i.length || t.some((e => !i.includes(e)))) throw new V(e);
|
|
419
428
|
}
|
|
420
429
|
shouldThrowIfDisposed() {
|
|
421
|
-
if (null === this.container) throw new
|
|
430
|
+
if (null === this.container) throw new G(this);
|
|
422
431
|
}
|
|
423
432
|
async _dispose() {
|
|
424
433
|
await (this.onDispose?.(this)), await this.__unbindAll(), this.container = null,
|
|
425
434
|
this.imports = null, this.providers = null, this.exports = null, this.dynamicExports = null,
|
|
426
|
-
this.registeredBindingSideEffects = null;
|
|
435
|
+
this.registeredBindingSideEffects = null, this.isDisposed = !0;
|
|
427
436
|
}
|
|
428
437
|
_lazyInit({imports: e = [], providers: i = [], exports: t = [], defaultScope: n = u.Singleton, dynamicExports: r, onReady: o, onDispose: s, ...d}) {
|
|
429
|
-
this.imports = e, this.providers = i, this.exports = t, this.defaultScope = {
|
|
438
|
+
this.isDisposed = !1, this.imports = e, this.providers = i, this.exports = t, this.defaultScope = {
|
|
430
439
|
native: n,
|
|
431
440
|
inversify: h(n)
|
|
432
441
|
}, this.dynamicExports = r, this.onReady = o, this.onDispose = s, this.container = this.prepareContainer({
|
|
433
442
|
...d
|
|
434
|
-
}), this.moduleUtils = new
|
|
443
|
+
}), this.moduleUtils = new W(this), this.registeredBindingSideEffects = new Map,
|
|
435
444
|
this.injectImportedModules(this._getImportedModules()), this.injectProviders(),
|
|
436
445
|
this.onReady?.(this);
|
|
437
446
|
}
|
|
@@ -506,7 +515,7 @@ var F = class e extends Error {
|
|
|
506
515
|
async __unbindAll() {
|
|
507
516
|
this.shouldThrowIfDisposed(), await this.container.unbindAll(), this.removeRegisteredBindingSideEffects("all");
|
|
508
517
|
}
|
|
509
|
-
},
|
|
518
|
+
}, z = class extends $ {
|
|
510
519
|
static {
|
|
511
520
|
o(this, "GlobalAppModule");
|
|
512
521
|
}
|
|
@@ -519,7 +528,7 @@ var F = class e extends Error {
|
|
|
519
528
|
}));
|
|
520
529
|
}
|
|
521
530
|
register(e) {
|
|
522
|
-
if (this.isLoaded) throw new
|
|
531
|
+
if (this.isLoaded) throw new N(`The '${this.toString()}' has already been registered!`);
|
|
523
532
|
return this.nakedModule._lazyInit(e), this.isLoaded = !0, this;
|
|
524
533
|
}
|
|
525
534
|
toNaked() {
|
|
@@ -528,4 +537,4 @@ var F = class e extends Error {
|
|
|
528
537
|
async _dispose() {
|
|
529
538
|
this.isLoaded = !1, super._dispose();
|
|
530
539
|
}
|
|
531
|
-
},
|
|
540
|
+
}, H = new z;//# sourceMappingURL=index.cjs.map
|