@nx-ddd/core 3.1.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.
Files changed (62) hide show
  1. package/README.md +11 -0
  2. package/_testing/index.d.ts +23 -0
  3. package/_testing/index.js +71 -0
  4. package/_testing/index.js.map +1 -0
  5. package/di/create-injector.d.ts +4 -0
  6. package/di/create-injector.js +21 -0
  7. package/di/create-injector.js.map +1 -0
  8. package/di/definition-factory.d.ts +24 -0
  9. package/di/definition-factory.js +22 -0
  10. package/di/definition-factory.js.map +1 -0
  11. package/di/forward_ref.d.ts +49 -0
  12. package/di/forward_ref.js +57 -0
  13. package/di/forward_ref.js.map +1 -0
  14. package/di/index.d.ts +3 -0
  15. package/di/index.js +7 -0
  16. package/di/index.js.map +1 -0
  17. package/di/injectable.d.ts +2 -0
  18. package/di/injectable.js +10 -0
  19. package/di/injectable.js.map +1 -0
  20. package/di/injector.d.ts +3 -0
  21. package/di/injector.js +10 -0
  22. package/di/injector.js.map +1 -0
  23. package/di/interface/defs.d.ts +181 -0
  24. package/di/interface/defs.js +137 -0
  25. package/di/interface/defs.js.map +1 -0
  26. package/di/interface/provider.d.ts +324 -0
  27. package/di/interface/provider.js +10 -0
  28. package/di/interface/provider.js.map +1 -0
  29. package/di/interface/type.d.ts +3 -0
  30. package/di/interface/type.js +3 -0
  31. package/di/interface/type.js.map +1 -0
  32. package/di/provider-collection.d.ts +7 -0
  33. package/di/provider-collection.js +45 -0
  34. package/di/provider-collection.js.map +1 -0
  35. package/index.d.ts +2 -0
  36. package/index.js +6 -0
  37. package/index.js.map +1 -0
  38. package/nx-module/index.d.ts +2 -0
  39. package/nx-module/index.js +6 -0
  40. package/nx-module/index.js.map +1 -0
  41. package/nx-module/nx-module-ref.d.ts +15 -0
  42. package/nx-module/nx-module-ref.js +27 -0
  43. package/nx-module/nx-module-ref.js.map +1 -0
  44. package/nx-module/nx-module.d.ts +5 -0
  45. package/nx-module/nx-module.js +16 -0
  46. package/nx-module/nx-module.js.map +1 -0
  47. package/package.json +12 -0
  48. package/testing/index.d.ts +20 -0
  49. package/testing/index.js +32 -0
  50. package/testing/index.js.map +1 -0
  51. package/util/array_utils.d.ts +1 -0
  52. package/util/array_utils.js +8 -0
  53. package/util/array_utils.js.map +1 -0
  54. package/util/empty.d.ts +2 -0
  55. package/util/empty.js +6 -0
  56. package/util/empty.js.map +1 -0
  57. package/util/property.d.ts +19 -0
  58. package/util/property.js +34 -0
  59. package/util/property.js.map +1 -0
  60. package/util/stringify.d.ts +17 -0
  61. package/util/stringify.js +49 -0
  62. package/util/stringify.js.map +1 -0
@@ -0,0 +1,137 @@
1
+ "use strict";
2
+ /**
3
+ * @license
4
+ * Copyright Google LLC All Rights Reserved.
5
+ *
6
+ * Use of this source code is governed by an MIT-style license that can be
7
+ * found in the LICENSE file at https://angular.io/license
8
+ */
9
+ Object.defineProperty(exports, "__esModule", { value: true });
10
+ exports.NG_INJECTOR_DEF = exports.NG_INJECTABLE_DEF = exports.NG_INJ_DEF = exports.NG_PROV_DEF = exports.getInjectorDef = exports.hasInjectaorDef = exports.getInheritedInjectableDef = exports.getInjectableDef = exports.ɵɵdefineInjector = exports.defineInjectable = exports.ɵɵdefineInjectable = void 0;
11
+ const property_1 = require("../../util/property");
12
+ /**
13
+ * Construct an injectable definition which defines how a token will be constructed by the DI
14
+ * system, and in which injectors (if any) it will be available.
15
+ *
16
+ * This should be assigned to a static `ɵprov` field on a type, which will then be an
17
+ * `InjectableType`.
18
+ *
19
+ * Options:
20
+ * * `providedIn` determines which injectors will include the injectable, by either associating it
21
+ * with an `@NgModule` or other `InjectorType`, or by specifying that this injectable should be
22
+ * provided in the `'root'` injector, which will be the application-level injector in most apps.
23
+ * * `factory` gives the zero argument function which will create an instance of the injectable.
24
+ * The factory can call `inject` to access the `Injector` and request injection of dependencies.
25
+ *
26
+ * @codeGenApi
27
+ * @publicApi This instruction has been emitted by ViewEngine for some time and is deployed to npm.
28
+ */
29
+ function ɵɵdefineInjectable(opts) {
30
+ return {
31
+ token: opts.token,
32
+ providedIn: opts.providedIn || null,
33
+ factory: opts.factory,
34
+ value: undefined,
35
+ };
36
+ }
37
+ exports.ɵɵdefineInjectable = ɵɵdefineInjectable;
38
+ /**
39
+ * @deprecated in v8, delete after v10. This API should be used only by generated code, and that
40
+ * code should now use ɵɵdefineInjectable instead.
41
+ * @publicApi
42
+ */
43
+ exports.defineInjectable = ɵɵdefineInjectable;
44
+ /**
45
+ * Construct an `InjectorDef` which configures an injector.
46
+ *
47
+ * This should be assigned to a static injector def (`ɵinj`) field on a type, which will then be an
48
+ * `InjectorType`.
49
+ *
50
+ * Options:
51
+ *
52
+ * * `providers`: an optional array of providers to add to the injector. Each provider must
53
+ * either have a factory or point to a type which has a `ɵprov` static property (the
54
+ * type must be an `InjectableType`).
55
+ * * `imports`: an optional array of imports of other `InjectorType`s or `InjectorTypeWithModule`s
56
+ * whose providers will also be added to the injector. Locally provided types will override
57
+ * providers from imports.
58
+ *
59
+ * @codeGenApi
60
+ */
61
+ function ɵɵdefineInjector(options) {
62
+ return { providers: options.providers || [], imports: options.imports || [] };
63
+ }
64
+ exports.ɵɵdefineInjector = ɵɵdefineInjector;
65
+ /**
66
+ * Read the injectable def (`ɵprov`) for `type` in a way which is immune to accidentally reading
67
+ * inherited value.
68
+ *
69
+ * @param type A type which may have its own (non-inherited) `ɵprov`.
70
+ */
71
+ function getInjectableDef(type) {
72
+ return getOwnDefinition(type, exports.NG_PROV_DEF) || getOwnDefinition(type, exports.NG_INJECTABLE_DEF);
73
+ }
74
+ exports.getInjectableDef = getInjectableDef;
75
+ /**
76
+ * Return definition only if it is defined directly on `type` and is not inherited from a base
77
+ * class of `type`.
78
+ */
79
+ function getOwnDefinition(type, field) {
80
+ return type.hasOwnProperty(field) ? type[field] : null;
81
+ }
82
+ /**
83
+ * Read the injectable def (`ɵprov`) for `type` or read the `ɵprov` from one of its ancestors.
84
+ *
85
+ * @param type A type which may have `ɵprov`, via inheritance.
86
+ *
87
+ * @deprecated Will be removed in a future version of Angular, where an error will occur in the
88
+ * scenario if we find the `ɵprov` on an ancestor only.
89
+ */
90
+ function getInheritedInjectableDef(type) {
91
+ const def = type && (type[exports.NG_PROV_DEF] || type[exports.NG_INJECTABLE_DEF]);
92
+ if (def) {
93
+ const typeName = getTypeName(type);
94
+ // TODO(FW-1307): Re-add ngDevMode when closure can handle it
95
+ // ngDevMode &&
96
+ console.warn(`DEPRECATED: DI is instantiating a token "${typeName}" that inherits its @Injectable decorator but does not provide one itself.\n` +
97
+ `This will become an error in a future version of Angular. Please add @Injectable() to the "${typeName}" class.`);
98
+ return def;
99
+ }
100
+ else {
101
+ return null;
102
+ }
103
+ }
104
+ exports.getInheritedInjectableDef = getInheritedInjectableDef;
105
+ /** Gets the name of a type, accounting for some cross-browser differences. */
106
+ function getTypeName(type) {
107
+ // `Function.prototype.name` behaves differently between IE and other browsers. In most browsers
108
+ // it'll always return the name of the function itself, no matter how many other functions it
109
+ // inherits from. On IE the function doesn't have its own `name` property, but it takes it from
110
+ // the lowest level in the prototype chain. E.g. if we have `class Foo extends Parent` most
111
+ // browsers will evaluate `Foo.name` to `Foo` while IE will return `Parent`. We work around
112
+ // the issue by converting the function to a string and parsing its name out that way via a regex.
113
+ if (type.hasOwnProperty('name')) {
114
+ return type.name;
115
+ }
116
+ const match = ('' + type).match(/^function\s*([^\s(]+)/);
117
+ return match === null ? '' : match[1];
118
+ }
119
+ function hasInjectaorDef(type) {
120
+ return type && (type.hasOwnProperty(exports.NG_INJ_DEF) || type.hasOwnProperty(exports.NG_INJECTOR_DEF));
121
+ }
122
+ exports.hasInjectaorDef = hasInjectaorDef;
123
+ /**
124
+ * Read the injector def type in a way which is immune to accidentally reading inherited value.
125
+ *
126
+ * @param type type which may have an injector def (`ɵinj`)
127
+ */
128
+ function getInjectorDef(type) {
129
+ return hasInjectaorDef(type) ? type[exports.NG_INJ_DEF] : null;
130
+ }
131
+ exports.getInjectorDef = getInjectorDef;
132
+ exports.NG_PROV_DEF = (0, property_1.getClosureSafeProperty)({ ɵprov: property_1.getClosureSafeProperty });
133
+ exports.NG_INJ_DEF = (0, property_1.getClosureSafeProperty)({ ɵinj: property_1.getClosureSafeProperty });
134
+ // We need to keep these around so we can read off old defs if new defs are unavailable
135
+ exports.NG_INJECTABLE_DEF = (0, property_1.getClosureSafeProperty)({ ngInjectableDef: property_1.getClosureSafeProperty });
136
+ exports.NG_INJECTOR_DEF = (0, property_1.getClosureSafeProperty)({ ngInjectorDef: property_1.getClosureSafeProperty });
137
+ //# sourceMappingURL=defs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"defs.js","sourceRoot":"","sources":["../../../../../libs/core/src/di/interface/defs.ts"],"names":[],"mappings":"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"}
@@ -0,0 +1,324 @@
1
+ /**
2
+ * @license
3
+ * Copyright Google LLC All Rights Reserved.
4
+ *
5
+ * Use of this source code is governed by an MIT-style license that can be
6
+ * found in the LICENSE file at https://angular.io/license
7
+ */
8
+ import { Type } from "./type";
9
+ /**
10
+ * Configures the `Injector` to return a value for a token.
11
+ * Base for `ValueProvider` decorator.
12
+ *
13
+ * @publicApi
14
+ */
15
+ export interface ValueSansProvider {
16
+ /**
17
+ * The value to inject.
18
+ */
19
+ useValue: any;
20
+ }
21
+ /**
22
+ * Configures the `Injector` to return a value for a token.
23
+ * @see ["Dependency Injection Guide"](guide/dependency-injection).
24
+ *
25
+ * @usageNotes
26
+ *
27
+ * ### Example
28
+ *
29
+ * {@example core/di/ts/provider_spec.ts region='ValueProvider'}
30
+ *
31
+ * ### Multi-value example
32
+ *
33
+ * {@example core/di/ts/provider_spec.ts region='MultiProviderAspect'}
34
+ *
35
+ * @publicApi
36
+ */
37
+ export interface ValueProvider extends ValueSansProvider {
38
+ /**
39
+ * An injection token. Typically an instance of `Type` or `InjectionToken`, but can be `any`.
40
+ */
41
+ provide: any;
42
+ /**
43
+ * When true, injector returns an array of instances. This is useful to allow multiple
44
+ * providers spread across many files to provide configuration information to a common token.
45
+ */
46
+ multi?: boolean;
47
+ }
48
+ /**
49
+ * Configures the `Injector` to return an instance of `useClass` for a token.
50
+ * Base for `StaticClassProvider` decorator.
51
+ *
52
+ * @publicApi
53
+ */
54
+ export interface StaticClassSansProvider {
55
+ /**
56
+ * An optional class to instantiate for the `token`. By default, the `provide`
57
+ * class is instantiated.
58
+ */
59
+ useClass: Type<any>;
60
+ /**
61
+ * A list of `token`s to be resolved by the injector. The list of values is then
62
+ * used as arguments to the `useClass` constructor.
63
+ */
64
+ deps: any[];
65
+ }
66
+ /**
67
+ * Configures the `Injector` to return an instance of `useClass` for a token.
68
+ * @see ["Dependency Injection Guide"](guide/dependency-injection).
69
+ *
70
+ * @usageNotes
71
+ *
72
+ * {@example core/di/ts/provider_spec.ts region='StaticClassProvider'}
73
+ *
74
+ * Note that following two providers are not equal:
75
+ *
76
+ * {@example core/di/ts/provider_spec.ts region='StaticClassProviderDifference'}
77
+ *
78
+ * ### Multi-value example
79
+ *
80
+ * {@example core/di/ts/provider_spec.ts region='MultiProviderAspect'}
81
+ *
82
+ * @publicApi
83
+ */
84
+ export interface StaticClassProvider extends StaticClassSansProvider {
85
+ /**
86
+ * An injection token. Typically an instance of `Type` or `InjectionToken`, but can be `any`.
87
+ */
88
+ provide: any;
89
+ /**
90
+ * When true, injector returns an array of instances. This is useful to allow multiple
91
+ * providers spread across many files to provide configuration information to a common token.
92
+ */
93
+ multi?: boolean;
94
+ }
95
+ /**
96
+ * Configures the `Injector` to return an instance of a token.
97
+ *
98
+ * @see ["Dependency Injection Guide"](guide/dependency-injection).
99
+ *
100
+ * @usageNotes
101
+ *
102
+ * ```ts
103
+ * @Injectable(SomeModule, {deps: []})
104
+ * class MyService {}
105
+ * ```
106
+ *
107
+ * @publicApi
108
+ */
109
+ export interface ConstructorSansProvider {
110
+ /**
111
+ * A list of `token`s to be resolved by the injector.
112
+ */
113
+ deps?: any[];
114
+ }
115
+ /**
116
+ * Configures the `Injector` to return an instance of a token.
117
+ *
118
+ * @see ["Dependency Injection Guide"](guide/dependency-injection).
119
+ *
120
+ * @usageNotes
121
+ *
122
+ * {@example core/di/ts/provider_spec.ts region='ConstructorProvider'}
123
+ *
124
+ * ### Multi-value example
125
+ *
126
+ * {@example core/di/ts/provider_spec.ts region='MultiProviderAspect'}
127
+ *
128
+ * @publicApi
129
+ */
130
+ export interface ConstructorProvider extends ConstructorSansProvider {
131
+ /**
132
+ * An injection token. Typically an instance of `Type` or `InjectionToken`, but can be `any`.
133
+ */
134
+ provide: Type<any>;
135
+ /**
136
+ * When true, injector returns an array of instances. This is useful to allow multiple
137
+ * providers spread across many files to provide configuration information to a common token.
138
+ */
139
+ multi?: boolean;
140
+ }
141
+ /**
142
+ * Configures the `Injector` to return a value of another `useExisting` token.
143
+ *
144
+ * @see `ExistingProvider`
145
+ * @see ["Dependency Injection Guide"](guide/dependency-injection).
146
+ *
147
+ * @publicApi
148
+ */
149
+ export interface ExistingSansProvider {
150
+ /**
151
+ * Existing `token` to return. (Equivalent to `injector.get(useExisting)`)
152
+ */
153
+ useExisting: any;
154
+ }
155
+ /**
156
+ * Configures the `Injector` to return a value of another `useExisting` token.
157
+ *
158
+ * @see ["Dependency Injection Guide"](guide/dependency-injection).
159
+ *
160
+ * @usageNotes
161
+ *
162
+ * {@example core/di/ts/provider_spec.ts region='ExistingProvider'}
163
+ *
164
+ * ### Multi-value example
165
+ *
166
+ * {@example core/di/ts/provider_spec.ts region='MultiProviderAspect'}
167
+ *
168
+ * @publicApi
169
+ */
170
+ export interface ExistingProvider extends ExistingSansProvider {
171
+ /**
172
+ * An injection token. Typically an instance of `Type` or `InjectionToken`, but can be `any`.
173
+ */
174
+ provide: any;
175
+ /**
176
+ * When true, injector returns an array of instances. This is useful to allow multiple
177
+ * providers spread across many files to provide configuration information to a common token.
178
+ */
179
+ multi?: boolean;
180
+ }
181
+ /**
182
+ * Configures the `Injector` to return a value by invoking a `useFactory` function.
183
+ *
184
+ * @see `FactoryProvider`
185
+ * @see ["Dependency Injection Guide"](guide/dependency-injection).
186
+ *
187
+ * @publicApi
188
+ */
189
+ export interface FactorySansProvider {
190
+ /**
191
+ * A function to invoke to create a value for this `token`. The function is invoked with
192
+ * resolved values of `token`s in the `deps` field.
193
+ */
194
+ useFactory: Function;
195
+ /**
196
+ * A list of `token`s to be resolved by the injector. The list of values is then
197
+ * used as arguments to the `useFactory` function.
198
+ */
199
+ deps?: any[];
200
+ }
201
+ /**
202
+ * Configures the `Injector` to return a value by invoking a `useFactory` function.
203
+ * @see ["Dependency Injection Guide"](guide/dependency-injection).
204
+ *
205
+ * @usageNotes
206
+ *
207
+ * {@example core/di/ts/provider_spec.ts region='FactoryProvider'}
208
+ *
209
+ * Dependencies can also be marked as optional:
210
+ *
211
+ * {@example core/di/ts/provider_spec.ts region='FactoryProviderOptionalDeps'}
212
+ *
213
+ * ### Multi-value example
214
+ *
215
+ * {@example core/di/ts/provider_spec.ts region='MultiProviderAspect'}
216
+ *
217
+ * @publicApi
218
+ */
219
+ export interface FactoryProvider extends FactorySansProvider {
220
+ /**
221
+ * An injection token. (Typically an instance of `Type` or `InjectionToken`, but can be `any`).
222
+ */
223
+ provide: any;
224
+ /**
225
+ * When true, injector returns an array of instances. This is useful to allow multiple
226
+ * providers spread across many files to provide configuration information to a common token.
227
+ */
228
+ multi?: boolean;
229
+ }
230
+ /**
231
+ * Describes how an `Injector` should be configured as static (that is, without reflection).
232
+ * A static provider provides tokens to an injector for various types of dependencies.
233
+ *
234
+ * @see `Injector.create()`.
235
+ * @see ["Dependency Injection Guide"](guide/dependency-injection-providers).
236
+ *
237
+ * @publicApi
238
+ */
239
+ export declare type StaticProvider = ValueProvider | ExistingProvider | StaticClassProvider | ConstructorProvider | FactoryProvider | any[];
240
+ /**
241
+ * Configures the `Injector` to return an instance of `Type` when `Type' is used as the token.
242
+ *
243
+ * Create an instance by invoking the `new` operator and supplying additional arguments.
244
+ * This form is a short form of `TypeProvider`;
245
+ *
246
+ * For more details, see the ["Dependency Injection Guide"](guide/dependency-injection).
247
+ *
248
+ * @usageNotes
249
+ *
250
+ * {@example core/di/ts/provider_spec.ts region='TypeProvider'}
251
+ *
252
+ * @publicApi
253
+ */
254
+ export interface TypeProvider extends Type<any> {
255
+ }
256
+ /**
257
+ * Configures the `Injector` to return a value by invoking a `useClass` function.
258
+ * Base for `ClassProvider` decorator.
259
+ *
260
+ * @see ["Dependency Injection Guide"](guide/dependency-injection).
261
+ *
262
+ * @publicApi
263
+ */
264
+ export interface ClassSansProvider {
265
+ /**
266
+ * Class to instantiate for the `token`.
267
+ */
268
+ useClass: Type<any>;
269
+ }
270
+ /**
271
+ * Configures the `Injector` to return an instance of `useClass` for a token.
272
+ * @see ["Dependency Injection Guide"](guide/dependency-injection).
273
+ *
274
+ * @usageNotes
275
+ *
276
+ * {@example core/di/ts/provider_spec.ts region='ClassProvider'}
277
+ *
278
+ * Note that following two providers are not equal:
279
+ *
280
+ * {@example core/di/ts/provider_spec.ts region='ClassProviderDifference'}
281
+ *
282
+ * ### Multi-value example
283
+ *
284
+ * {@example core/di/ts/provider_spec.ts region='MultiProviderAspect'}
285
+ *
286
+ * @publicApi
287
+ */
288
+ export interface ClassProvider extends ClassSansProvider {
289
+ /**
290
+ * An injection token. (Typically an instance of `Type` or `InjectionToken`, but can be `any`).
291
+ */
292
+ provide: any;
293
+ /**
294
+ * When true, injector returns an array of instances. This is useful to allow multiple
295
+ * providers spread across many files to provide configuration information to a common token.
296
+ */
297
+ multi?: boolean;
298
+ }
299
+ /**
300
+ * Describes how the `Injector` should be configured.
301
+ * @see ["Dependency Injection Guide"](guide/dependency-injection).
302
+ *
303
+ * @see `StaticProvider`
304
+ *
305
+ * @publicApi
306
+ */
307
+ export declare type Provider = TypeProvider | ValueProvider | ClassProvider | ConstructorProvider | ExistingProvider | FactoryProvider | any[];
308
+ /**
309
+ * Describes a function that is used to process provider lists (such as provider
310
+ * overrides).
311
+ */
312
+ export declare type ProcessProvidersFunction = (providers: Provider[]) => Provider[];
313
+ /**
314
+ * A wrapper around an NgModule that associates it with [providers](guide/glossary#provider
315
+ * "Definition"). Usage without a generic type is deprecated.
316
+ *
317
+ * @see [Deprecations](guide/deprecations#modulewithproviders-type-without-a-generic)
318
+ *
319
+ * @publicApi
320
+ */
321
+ export interface ModuleWithProviders<T> {
322
+ nxModule: Type<T>;
323
+ providers?: Provider[];
324
+ }
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ /**
3
+ * @license
4
+ * Copyright Google LLC All Rights Reserved.
5
+ *
6
+ * Use of this source code is governed by an MIT-style license that can be
7
+ * found in the LICENSE file at https://angular.io/license
8
+ */
9
+ Object.defineProperty(exports, "__esModule", { value: true });
10
+ //# sourceMappingURL=provider.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"provider.js","sourceRoot":"","sources":["../../../../../libs/core/src/di/interface/provider.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG"}
@@ -0,0 +1,3 @@
1
+ export interface Type<T> extends Function {
2
+ new (...args: any[]): T;
3
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=type.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"type.js","sourceRoot":"","sources":["../../../../../libs/core/src/di/interface/type.ts"],"names":[],"mappings":""}
@@ -0,0 +1,7 @@
1
+ import { Type } from './interface/type';
2
+ import { InjectorTypeWithProviders } from './interface/defs';
3
+ import { ClassProvider, ConstructorProvider, ExistingProvider, FactoryProvider, ModuleWithProviders, Provider, StaticClassProvider, TypeProvider, ValueProvider } from './interface/provider';
4
+ export declare type ImportProvidersSource = Type<unknown> | ModuleWithProviders<unknown> | Array<ImportProvidersSource>;
5
+ export declare type SingleProvider = TypeProvider | ValueProvider | ClassProvider | ConstructorProvider | ExistingProvider | FactoryProvider | StaticClassProvider;
6
+ export declare function internalImportProvidersFrom(...sources: ImportProvidersSource[]): SingleProvider[];
7
+ export declare function walkProviderTree(sources: (Type<unknown> | InjectorTypeWithProviders<unknown>)[], parents: Type<unknown>[], callback: (providers: Provider[]) => void, dedup?: Set<Type<unknown>>): void;
@@ -0,0 +1,45 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.walkProviderTree = exports.internalImportProvidersFrom = void 0;
4
+ const defs_1 = require("./interface/defs");
5
+ const forward_ref_1 = require("./forward_ref");
6
+ const array_utils_1 = require("../util/array_utils");
7
+ const definition_factory_1 = require("./definition-factory");
8
+ const empty_1 = require("../util/empty");
9
+ function internalImportProvidersFrom(...sources) {
10
+ const providersOut = [];
11
+ walkProviderTree(sources, [], (providers) => {
12
+ (0, array_utils_1.deepForEach)(providers, provider => providersOut.push(provider));
13
+ });
14
+ return providersOut;
15
+ }
16
+ exports.internalImportProvidersFrom = internalImportProvidersFrom;
17
+ function getNxModuleType(container) {
18
+ const isNxModuleType = (obj) => (0, defs_1.hasInjectaorDef)(obj);
19
+ return isNxModuleType(container) ? container : container.nxModule;
20
+ }
21
+ function walkProviderTree(sources, parents, callback, dedup = new Set()) {
22
+ (0, array_utils_1.deepForEach)(sources, container => {
23
+ var _a, _b, _c;
24
+ container = (0, forward_ref_1.resolveForwardRef)(container);
25
+ if (!container)
26
+ return;
27
+ const nxModuleType = getNxModuleType(container);
28
+ const injDef = (0, defs_1.getInjectorDef)(nxModuleType);
29
+ if (!injDef)
30
+ return;
31
+ if (!dedup.has(nxModuleType) && dedup.add(nxModuleType)) {
32
+ walkProviderTree((_a = injDef.imports) !== null && _a !== void 0 ? _a : [], parents, callback, dedup);
33
+ callback([
34
+ { provide: nxModuleType, useFactory: (0, definition_factory_1.getFactoryDef)(nxModuleType) || (() => new nxModuleType()), deps: empty_1.EMPTY_ARRAY },
35
+ // { provide: INJECTOR_DEF_TYPES, useValue: nxModuleType, multi: true },
36
+ // { provide: ENVIRONMENT_INITIALIZER, useValue: () => inject(nxModuleType!), multi: true },
37
+ ...((_b = injDef.providers) !== null && _b !== void 0 ? _b : []),
38
+ ]);
39
+ }
40
+ const isInjectorTypeWithProviders = (container) => container !== nxModuleType;
41
+ isInjectorTypeWithProviders(container) && callback((_c = container.providers) !== null && _c !== void 0 ? _c : []);
42
+ });
43
+ }
44
+ exports.walkProviderTree = walkProviderTree;
45
+ //# sourceMappingURL=provider-collection.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"provider-collection.js","sourceRoot":"","sources":["../../../../libs/core/src/di/provider-collection.ts"],"names":[],"mappings":";;;AACA,2CAA8F;AAE9F,+CAAkD;AAClD,qDAAkD;AAClD,6DAAqD;AACrD,yCAA4C;AAc5C,SAAgB,2BAA2B,CAAC,GAAG,OAAgC;IAC7E,MAAM,YAAY,GAAqB,EAAE,CAAC;IAC1C,gBAAgB,CAAC,OAAgE,EAAE,EAAE,EAAE,CAAC,SAAgB,EAAE,EAAE;QAC1G,IAAA,yBAAW,EAAC,SAAS,EAAE,QAAQ,CAAC,EAAE,CAAC,YAAY,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC;IAClE,CAAC,CAAC,CAAC;IACH,OAAO,YAAY,CAAC;AACtB,CAAC;AAND,kEAMC;AAED,SAAS,eAAe,CAAC,SAA6D;IACpF,MAAM,cAAc,GAAG,CAAC,GAAG,EAAwB,EAAE,CAAC,IAAA,sBAAe,EAAC,GAAG,CAAC,CAAC;IAC3E,OAAO,cAAc,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,QAAQ,CAAC;AACpE,CAAC;AAED,SAAgB,gBAAgB,CAC9B,OAA+D,EAC/D,OAAwB,EACxB,QAAyC,EACzC,QAAQ,IAAI,GAAG,EAAiB;IAEhC,IAAA,yBAAW,EAAC,OAAO,EAAE,SAAS,CAAC,EAAE;;QAC/B,SAAS,GAAG,IAAA,+BAAiB,EAAC,SAAS,CAAC,CAAC;QACzC,IAAI,CAAC,SAAS;YAAE,OAAO;QAEvB,MAAM,YAAY,GAAG,eAAe,CAAC,SAAS,CAAC,CAAC;QAChD,MAAM,MAAM,GAAG,IAAA,qBAAc,EAAC,YAAY,CAAC,CAAC;QAC5C,IAAI,CAAC,MAAM;YAAE,OAAO;QAEpB,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,YAAY,CAAC,IAAI,KAAK,CAAC,GAAG,CAAC,YAAY,CAAC,EAAE;YACvD,gBAAgB,CAAC,MAAA,MAAM,CAAC,OAAO,mCAAI,EAAE,EAAE,OAAO,EAAE,QAAQ,EAAE,KAAK,CAAC,CAAC;YACjE,QAAQ,CAAC;gBACP,EAAE,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,IAAA,kCAAa,EAAC,YAAY,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,IAAI,YAAa,EAAE,CAAC,EAAE,IAAI,EAAE,mBAAW,EAAE;gBACpH,wEAAwE;gBACxE,4FAA4F;gBAC5F,GAAG,CAAC,MAAA,MAAM,CAAC,SAAS,mCAAI,EAAE,CAAC;aAC5B,CAAC,CAAC;SACJ;QAED,MAAM,2BAA2B,GAC/B,CAAC,SAAS,EAA+C,EAAE,CAAC,SAAS,KAAK,YAAY,CAAC;QAEzF,2BAA2B,CAAC,SAAS,CAAC,IAAI,QAAQ,CAAC,MAAA,SAAS,CAAC,SAAS,mCAAI,EAAE,CAAC,CAAC;IAChF,CAAC,CAAC,CAAC;AACL,CAAC;AA7BD,4CA6BC"}
package/index.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ export * from './di';
2
+ export * from './nx-module';
package/index.js ADDED
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ tslib_1.__exportStar(require("./di"), exports);
5
+ tslib_1.__exportStar(require("./nx-module"), exports);
6
+ //# sourceMappingURL=index.js.map
package/index.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../libs/core/src/index.ts"],"names":[],"mappings":";;;AAAA,+CAAqB;AACrB,sDAA4B"}
@@ -0,0 +1,2 @@
1
+ export * from './nx-module-ref';
2
+ export * from './nx-module';
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ tslib_1.__exportStar(require("./nx-module-ref"), exports);
5
+ tslib_1.__exportStar(require("./nx-module"), exports);
6
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../libs/core/src/nx-module/index.ts"],"names":[],"mappings":";;;AAAA,0DAAgC;AAChC,sDAA4B"}
@@ -0,0 +1,15 @@
1
+ import { Injector } from 'injection-js';
2
+ export declare type Type<T> = any;
3
+ export declare function createNxModuleRef<T>(moduleType: Type<T>, injector?: Injector): NxModuleRef<T>;
4
+ export declare class NxModuleRef<T = any> {
5
+ nxModuleType: Type<T>;
6
+ _parent: Injector;
7
+ injector: Injector;
8
+ instance: T;
9
+ constructor(nxModuleType: Type<T>, _parent: Injector);
10
+ }
11
+ export declare class NxModuleFactory<T> {
12
+ moduleType: Type<T>;
13
+ constructor(moduleType: Type<T>);
14
+ create(parentInjector: Injector | null): NxModuleRef<T>;
15
+ }
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.NxModuleFactory = exports.NxModuleRef = exports.createNxModuleRef = void 0;
4
+ const create_injector_1 = require("../di/create-injector");
5
+ function createNxModuleRef(moduleType, injector) {
6
+ return new NxModuleRef(moduleType, injector !== null && injector !== void 0 ? injector : null);
7
+ }
8
+ exports.createNxModuleRef = createNxModuleRef;
9
+ class NxModuleRef {
10
+ constructor(nxModuleType, _parent) {
11
+ this.nxModuleType = nxModuleType;
12
+ this._parent = _parent;
13
+ this.injector = (0, create_injector_1.createInjectorWithoutInjectorInstances)(nxModuleType, _parent);
14
+ this.instance = this.injector.get(nxModuleType);
15
+ }
16
+ }
17
+ exports.NxModuleRef = NxModuleRef;
18
+ class NxModuleFactory {
19
+ constructor(moduleType) {
20
+ this.moduleType = moduleType;
21
+ }
22
+ create(parentInjector) {
23
+ return new NxModuleRef(this.moduleType, parentInjector);
24
+ }
25
+ }
26
+ exports.NxModuleFactory = NxModuleFactory;
27
+ //# sourceMappingURL=nx-module-ref.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"nx-module-ref.js","sourceRoot":"","sources":["../../../../libs/core/src/nx-module/nx-module-ref.ts"],"names":[],"mappings":";;;AACA,2DAA+E;AAI/E,SAAgB,iBAAiB,CAAI,UAAmB,EAAE,QAAmB;IAC3E,OAAO,IAAI,WAAW,CAAC,UAAU,EAAE,QAAQ,aAAR,QAAQ,cAAR,QAAQ,GAAI,IAAI,CAAC,CAAC;AACvD,CAAC;AAFD,8CAEC;AAED,MAAa,WAAW;IAItB,YACS,YAAqB,EACrB,OAAiB;QADjB,iBAAY,GAAZ,YAAY,CAAS;QACrB,YAAO,GAAP,OAAO,CAAU;QAExB,IAAI,CAAC,QAAQ,GAAG,IAAA,wDAAsC,EAAC,YAAY,EAAE,OAAO,CAAC,CAAC;QAC9E,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC;IAClD,CAAC;CACF;AAXD,kCAWC;AAED,MAAa,eAAe;IAC1B,YAAmB,UAAmB;QAAnB,eAAU,GAAV,UAAU,CAAS;IAAI,CAAC;IAE3C,MAAM,CAAC,cAA6B;QAClC,OAAO,IAAI,WAAW,CAAC,IAAI,CAAC,UAAU,EAAE,cAAc,CAAC,CAAC;IAC1D,CAAC;CACF;AAND,0CAMC"}
@@ -0,0 +1,5 @@
1
+ export interface NxModule {
2
+ imports?: any[];
3
+ providers?: any[];
4
+ }
5
+ export declare function NxModule(nxModule: NxModule): (target: any) => any;
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.NxModule = void 0;
4
+ const defs_1 = require("../di/interface/defs");
5
+ function NxModule(nxModule) {
6
+ return function (target) {
7
+ var _a, _b;
8
+ target[defs_1.NG_INJ_DEF] = {
9
+ imports: [...((_a = nxModule.imports) !== null && _a !== void 0 ? _a : [])],
10
+ providers: [...((_b = nxModule.providers) !== null && _b !== void 0 ? _b : [])],
11
+ };
12
+ return target;
13
+ };
14
+ }
15
+ exports.NxModule = NxModule;
16
+ //# sourceMappingURL=nx-module.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"nx-module.js","sourceRoot":"","sources":["../../../../libs/core/src/nx-module/nx-module.ts"],"names":[],"mappings":";;;AAAA,+CAAkD;AAOlD,SAAgB,QAAQ,CAAC,QAAkB;IACzC,OAAO,UAAU,MAAM;;QACrB,MAAM,CAAC,iBAAU,CAAC,GAAG;YACnB,OAAO,EAAE,CAAC,GAAG,CAAC,MAAA,QAAQ,CAAC,OAAO,mCAAI,EAAE,CAAC,CAAC;YACtC,SAAS,EAAE,CAAC,GAAG,CAAC,MAAA,QAAQ,CAAC,SAAS,mCAAI,EAAE,CAAC,CAAC;SAC3C,CAAC;QACF,OAAO,MAAM,CAAC;IAChB,CAAC,CAAC;AACJ,CAAC;AARD,4BAQC"}