@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
package/README.md ADDED
@@ -0,0 +1,11 @@
1
+ # core
2
+
3
+ This library was generated with [Nx](https://nx.dev).
4
+
5
+ ## Running unit tests
6
+
7
+ Run `nx test core` to execute the unit tests via [Jest](https://jestjs.io).
8
+
9
+ ## Running lint
10
+
11
+ Run `nx lint core` to execute the lint via [ESLint](https://eslint.org/).
@@ -0,0 +1,23 @@
1
+ import { InjectionToken } from 'injection-js';
2
+ import 'reflect-metadata';
3
+ export declare const EXAMPLE_VALUE: InjectionToken<unknown>;
4
+ export declare abstract class Repository {
5
+ get name(): string;
6
+ }
7
+ export declare class AppService {
8
+ repository: Repository;
9
+ constructor(repository: Repository);
10
+ }
11
+ export declare class FeatureModule {
12
+ }
13
+ export declare class LibraryModule {
14
+ static forRoot(): {
15
+ nxModule: typeof LibraryModule;
16
+ providers: {
17
+ provide: InjectionToken<unknown>;
18
+ useValue: string;
19
+ }[];
20
+ };
21
+ }
22
+ export declare class AppModule {
23
+ }
@@ -0,0 +1,71 @@
1
+ "use strict";
2
+ var LibraryModule_1;
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.AppModule = exports.LibraryModule = exports.FeatureModule = exports.AppService = exports.Repository = exports.EXAMPLE_VALUE = void 0;
5
+ const tslib_1 = require("tslib");
6
+ const nx_module_1 = require("../nx-module");
7
+ const injection_js_1 = require("injection-js");
8
+ require("reflect-metadata");
9
+ exports.EXAMPLE_VALUE = new injection_js_1.InjectionToken('examole value');
10
+ let Repository = class Repository {
11
+ get name() {
12
+ throw new Error('Repository.name is not implemented!');
13
+ }
14
+ };
15
+ Repository = tslib_1.__decorate([
16
+ (0, injection_js_1.Injectable)()
17
+ ], Repository);
18
+ exports.Repository = Repository;
19
+ let AppService = class AppService {
20
+ constructor(repository) {
21
+ this.repository = repository;
22
+ }
23
+ };
24
+ AppService = tslib_1.__decorate([
25
+ (0, injection_js_1.Injectable)(),
26
+ tslib_1.__metadata("design:paramtypes", [Repository])
27
+ ], AppService);
28
+ exports.AppService = AppService;
29
+ let FeatureModule = class FeatureModule {
30
+ };
31
+ FeatureModule = tslib_1.__decorate([
32
+ (0, nx_module_1.NxModule)({
33
+ imports: [],
34
+ providers: [{ provide: exports.EXAMPLE_VALUE, useValue: 'featureValue' }],
35
+ })
36
+ ], FeatureModule);
37
+ exports.FeatureModule = FeatureModule;
38
+ let LibraryModule = LibraryModule_1 = class LibraryModule {
39
+ static forRoot() {
40
+ return {
41
+ nxModule: LibraryModule_1,
42
+ providers: [
43
+ { provide: exports.EXAMPLE_VALUE, useValue: 'rootValue' },
44
+ ],
45
+ };
46
+ }
47
+ };
48
+ LibraryModule = LibraryModule_1 = tslib_1.__decorate([
49
+ (0, nx_module_1.NxModule)({
50
+ imports: [
51
+ FeatureModule,
52
+ ],
53
+ providers: []
54
+ })
55
+ ], LibraryModule);
56
+ exports.LibraryModule = LibraryModule;
57
+ let AppModule = class AppModule {
58
+ };
59
+ AppModule = tslib_1.__decorate([
60
+ (0, nx_module_1.NxModule)({
61
+ imports: [
62
+ LibraryModule.forRoot(),
63
+ ],
64
+ providers: [
65
+ AppService,
66
+ Repository,
67
+ ]
68
+ })
69
+ ], AppModule);
70
+ exports.AppModule = AppModule;
71
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../libs/core/src/_testing/index.ts"],"names":[],"mappings":";;;;;AAAA,4CAAwC;AACxC,+CAA0D;AAC1D,4BAA0B;AAEb,QAAA,aAAa,GAAG,IAAI,6BAAc,CAAC,eAAe,CAAC,CAAC;AAIjE,IAAsB,UAAU,GAAhC,MAAsB,UAAU;IAC9B,IAAI,IAAI;QACN,MAAM,IAAI,KAAK,CAAC,qCAAqC,CAAC,CAAC;IACzD,CAAC;CACF,CAAA;AAJqB,UAAU;IAD/B,IAAA,yBAAU,GAAE;GACS,UAAU,CAI/B;AAJqB,gCAAU;AAOhC,IAAa,UAAU,GAAvB,MAAa,UAAU;IACrB,YAAmB,UAAsB;QAAtB,eAAU,GAAV,UAAU,CAAY;IAAI,CAAC;CAC/C,CAAA;AAFY,UAAU;IADtB,IAAA,yBAAU,GAAE;6CAEoB,UAAU;GAD9B,UAAU,CAEtB;AAFY,gCAAU;AAQvB,IAAa,aAAa,GAA1B,MAAa,aAAa;CAAI,CAAA;AAAjB,aAAa;IAJzB,IAAA,oBAAQ,EAAC;QACR,OAAO,EAAE,EAAE;QACX,SAAS,EAAE,CAAC,EAAE,OAAO,EAAE,qBAAa,EAAE,QAAQ,EAAE,cAAc,EAAC,CAAC;KACjE,CAAC;GACW,aAAa,CAAI;AAAjB,sCAAa;AAQ1B,IAAa,aAAa,qBAA1B,MAAa,aAAa;IACxB,MAAM,CAAC,OAAO;QACZ,OAAO;YACL,QAAQ,EAAE,eAAa;YACvB,SAAS,EAAE;gBACT,EAAC,OAAO,EAAE,qBAAa,EAAE,QAAQ,EAAE,WAAW,EAAC;aAChD;SACF,CAAA;IACH,CAAC;CACF,CAAA;AATY,aAAa;IANzB,IAAA,oBAAQ,EAAC;QACR,OAAO,EAAE;YACP,aAAa;SACd;QACD,SAAS,EAAE,EAAE;KACd,CAAC;GACW,aAAa,CASzB;AATY,sCAAa;AAoB1B,IAAa,SAAS,GAAtB,MAAa,SAAS;CAAI,CAAA;AAAb,SAAS;IATrB,IAAA,oBAAQ,EAAC;QACR,OAAO,EAAE;YACP,aAAa,CAAC,OAAO,EAAE;SACxB;QACD,SAAS,EAAE;YACT,UAAU;YACV,UAAU;SACX;KACF,CAAC;GACW,SAAS,CAAI;AAAb,8BAAS"}
@@ -0,0 +1,4 @@
1
+ import { Injector } from './injector';
2
+ import { StaticProvider } from './interface/provider';
3
+ export declare function createInjector(defType: any, additionalProviders?: StaticProvider[] | null, parent?: Injector | null, name?: string): Injector;
4
+ export declare function createInjectorWithoutInjectorInstances(defType: any, parent?: Injector | null, additionalProviders?: StaticProvider[] | null, name?: string): Injector;
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createInjectorWithoutInjectorInstances = exports.createInjector = void 0;
4
+ const empty_1 = require("../util/empty");
5
+ const stringify_1 = require("../util/stringify");
6
+ const injector_1 = require("./injector");
7
+ const provider_collection_1 = require("./provider-collection");
8
+ function createInjector(defType, additionalProviders = null, parent = null, name) {
9
+ return createInjectorWithoutInjectorInstances(defType, parent, additionalProviders, name);
10
+ }
11
+ exports.createInjector = createInjector;
12
+ function createInjectorWithoutInjectorInstances(defType, parent = null, additionalProviders = null, name) {
13
+ const providers = [
14
+ ...(0, provider_collection_1.internalImportProvidersFrom)(defType),
15
+ ...(additionalProviders || empty_1.EMPTY_ARRAY),
16
+ ];
17
+ name = name || (typeof defType === 'object' ? undefined : (0, stringify_1.stringify)(defType));
18
+ return (0, injector_1.resolveAndCreate)(providers, parent || injector_1.Injector.NULL);
19
+ }
20
+ exports.createInjectorWithoutInjectorInstances = createInjectorWithoutInjectorInstances;
21
+ //# sourceMappingURL=create-injector.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create-injector.js","sourceRoot":"","sources":["../../../../libs/core/src/di/create-injector.ts"],"names":[],"mappings":";;;AAAA,yCAA4C;AAC5C,iDAA8C;AAC9C,yCAAwD;AAExD,+DAAoE;AAEpE,SAAgB,cAAc,CAC5B,OAAoC,EACpC,sBAA+C,IAAI,EACnD,SAA0B,IAAI,EAC9B,IAAa;IAEb,OAAO,sCAAsC,CAAC,OAAO,EAAE,MAAM,EAAE,mBAAmB,EAAE,IAAI,CAAC,CAAC;AAC5F,CAAC;AAPD,wCAOC;AAED,SAAgB,sCAAsC,CACpD,OAAoC,EACpC,SAA0B,IAAI,EAC9B,sBAA+C,IAAI,EACnD,IAAa;IAEb,MAAM,SAAS,GAAG;QAChB,GAAG,IAAA,iDAA2B,EAAC,OAAO,CAAC;QACvC,GAAG,CAAC,mBAAmB,IAAI,mBAAW,CAAC;KACxC,CAAC;IACF,IAAI,GAAG,IAAI,IAAI,CAAC,OAAO,OAAO,KAAK,QAAQ,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,IAAA,qBAAS,EAAC,OAAO,CAAC,CAAC,CAAC;IAC9E,OAAO,IAAA,2BAAgB,EAAC,SAAS,EAAE,MAAM,IAAI,mBAAQ,CAAC,IAAI,CAAC,CAAC;AAC9D,CAAC;AAZD,wFAYC"}
@@ -0,0 +1,24 @@
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 './interface/type';
9
+ /**
10
+ * Definition of what a factory function should look like.
11
+ */
12
+ export declare type FactoryFn<T> = {
13
+ /**
14
+ * Subclasses without an explicit constructor call through to the factory of their base
15
+ * definition, providing it with their own constructor to instantiate.
16
+ */
17
+ <U extends T>(t?: Type<U>): U;
18
+ /**
19
+ * If no constructor to instantiate is provided, an instance of type T itself is created.
20
+ */
21
+ (t?: undefined): T;
22
+ };
23
+ export declare function getFactoryDef<T>(type: any, throwNotFound: true): FactoryFn<T>;
24
+ export declare function getFactoryDef<T>(type: any): FactoryFn<T> | null;
@@ -0,0 +1,22 @@
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.getFactoryDef = void 0;
11
+ const stringify_1 = require("../util/stringify");
12
+ // import {NG_FACTORY_DEF} from './fields';
13
+ const NG_FACTORY_DEF = 'ɵfac';
14
+ function getFactoryDef(type, throwNotFound) {
15
+ const hasFactoryDef = type.hasOwnProperty(NG_FACTORY_DEF);
16
+ if (!hasFactoryDef && throwNotFound === true) {
17
+ throw new Error(`Type ${(0, stringify_1.stringify)(type)} does not have 'ɵfac' property.`);
18
+ }
19
+ return hasFactoryDef ? type[NG_FACTORY_DEF] : null;
20
+ }
21
+ exports.getFactoryDef = getFactoryDef;
22
+ //# sourceMappingURL=definition-factory.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"definition-factory.js","sourceRoot":"","sources":["../../../../libs/core/src/di/definition-factory.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;AAGH,iDAA4C;AAC5C,2CAA2C;AAE3C,MAAM,cAAc,GAAG,MAAM,CAAC;AAoB9B,SAAgB,aAAa,CAAI,IAAS,EAAE,aAAuB;IACjE,MAAM,aAAa,GAAG,IAAI,CAAC,cAAc,CAAC,cAAc,CAAC,CAAC;IAC1D,IAAI,CAAC,aAAa,IAAI,aAAa,KAAK,IAAI,EAAE;QAC5C,MAAM,IAAI,KAAK,CAAC,QAAQ,IAAA,qBAAS,EAAC,IAAI,CAAC,iCAAiC,CAAC,CAAC;KAC3E;IACD,OAAO,aAAa,CAAC,CAAC,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;AACrD,CAAC;AAND,sCAMC"}
@@ -0,0 +1,49 @@
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 './interface/type';
9
+ /**
10
+ * An interface that a function passed into {@link forwardRef} has to implement.
11
+ *
12
+ * @usageNotes
13
+ * ### Example
14
+ *
15
+ * {@example core/di/ts/forward_ref/forward_ref_spec.ts region='forward_ref_fn'}
16
+ * @publicApi
17
+ */
18
+ export interface ForwardRefFn {
19
+ (): any;
20
+ }
21
+ /**
22
+ * Allows to refer to references which are not yet defined.
23
+ *
24
+ * For instance, `forwardRef` is used when the `token` which we need to refer to for the purposes of
25
+ * DI is declared, but not yet defined. It is also used when the `token` which we use when creating
26
+ * a query is not yet defined.
27
+ *
28
+ * @usageNotes
29
+ * ### Example
30
+ * {@example core/di/ts/forward_ref/forward_ref_spec.ts region='forward_ref'}
31
+ * @publicApi
32
+ */
33
+ export declare function forwardRef(forwardRefFn: ForwardRefFn): Type<any>;
34
+ /**
35
+ * Lazily retrieves the reference value from a forwardRef.
36
+ *
37
+ * Acts as the identity function when given a non-forward-ref value.
38
+ *
39
+ * @usageNotes
40
+ * ### Example
41
+ *
42
+ * {@example core/di/ts/forward_ref/forward_ref_spec.ts region='resolve_forward_ref'}
43
+ *
44
+ * @see `forwardRef`
45
+ * @publicApi
46
+ */
47
+ export declare function resolveForwardRef<T>(type: T): T;
48
+ /** Checks whether a function is wrapped by a `forwardRef`. */
49
+ export declare function isForwardRef(fn: any): fn is () => any;
@@ -0,0 +1,57 @@
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.isForwardRef = exports.resolveForwardRef = exports.forwardRef = void 0;
11
+ const property_1 = require("../util/property");
12
+ const stringify_1 = require("../util/stringify");
13
+ const __forward_ref__ = (0, property_1.getClosureSafeProperty)({ __forward_ref__: property_1.getClosureSafeProperty });
14
+ /**
15
+ * Allows to refer to references which are not yet defined.
16
+ *
17
+ * For instance, `forwardRef` is used when the `token` which we need to refer to for the purposes of
18
+ * DI is declared, but not yet defined. It is also used when the `token` which we use when creating
19
+ * a query is not yet defined.
20
+ *
21
+ * @usageNotes
22
+ * ### Example
23
+ * {@example core/di/ts/forward_ref/forward_ref_spec.ts region='forward_ref'}
24
+ * @publicApi
25
+ */
26
+ function forwardRef(forwardRefFn) {
27
+ forwardRefFn.__forward_ref__ = forwardRef;
28
+ forwardRefFn.toString = function () {
29
+ return (0, stringify_1.stringify)(this());
30
+ };
31
+ return forwardRefFn;
32
+ }
33
+ exports.forwardRef = forwardRef;
34
+ /**
35
+ * Lazily retrieves the reference value from a forwardRef.
36
+ *
37
+ * Acts as the identity function when given a non-forward-ref value.
38
+ *
39
+ * @usageNotes
40
+ * ### Example
41
+ *
42
+ * {@example core/di/ts/forward_ref/forward_ref_spec.ts region='resolve_forward_ref'}
43
+ *
44
+ * @see `forwardRef`
45
+ * @publicApi
46
+ */
47
+ function resolveForwardRef(type) {
48
+ return isForwardRef(type) ? type() : type;
49
+ }
50
+ exports.resolveForwardRef = resolveForwardRef;
51
+ /** Checks whether a function is wrapped by a `forwardRef`. */
52
+ function isForwardRef(fn) {
53
+ return typeof fn === 'function' && fn.hasOwnProperty(__forward_ref__) &&
54
+ fn.__forward_ref__ === forwardRef;
55
+ }
56
+ exports.isForwardRef = isForwardRef;
57
+ //# sourceMappingURL=forward_ref.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"forward_ref.js","sourceRoot":"","sources":["../../../../libs/core/src/di/forward_ref.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;AAGH,+CAAwD;AACxD,iDAA4C;AAiB5C,MAAM,eAAe,GAAG,IAAA,iCAAsB,EAAC,EAAC,eAAe,EAAE,iCAAsB,EAAC,CAAC,CAAC;AAE1F;;;;;;;;;;;GAWG;AACH,SAAgB,UAAU,CAAC,YAA0B;IAC7C,YAAa,CAAC,eAAe,GAAG,UAAU,CAAC;IAC3C,YAAa,CAAC,QAAQ,GAAG;QAC7B,OAAO,IAAA,qBAAS,EAAC,IAAI,EAAE,CAAC,CAAC;IAC3B,CAAC,CAAC;IACF,OAAwB,YAAa,CAAC;AACxC,CAAC;AAND,gCAMC;AAED;;;;;;;;;;;;GAYG;AACH,SAAgB,iBAAiB,CAAI,IAAO;IAC1C,OAAO,YAAY,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;AAC5C,CAAC;AAFD,8CAEC;AAED,8DAA8D;AAC9D,SAAgB,YAAY,CAAC,EAAO;IAClC,OAAO,OAAO,EAAE,KAAK,UAAU,IAAI,EAAE,CAAC,cAAc,CAAC,eAAe,CAAC;QACjE,EAAE,CAAC,eAAe,KAAK,UAAU,CAAC;AACxC,CAAC;AAHD,oCAGC"}
package/di/index.d.ts ADDED
@@ -0,0 +1,3 @@
1
+ export * from './create-injector';
2
+ export * from './injectable';
3
+ export * from './injector';
package/di/index.js ADDED
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ tslib_1.__exportStar(require("./create-injector"), exports);
5
+ tslib_1.__exportStar(require("./injectable"), exports);
6
+ tslib_1.__exportStar(require("./injector"), exports);
7
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../libs/core/src/di/index.ts"],"names":[],"mappings":";;;AAAA,4DAAkC;AAClC,uDAA6B;AAC7B,qDAA2B"}
@@ -0,0 +1,2 @@
1
+ import 'reflect-metadata';
2
+ export { Injectable, Inject, Optional, InjectionToken } from 'injection-js';
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.InjectionToken = exports.Optional = exports.Inject = exports.Injectable = void 0;
4
+ require("reflect-metadata");
5
+ var injection_js_1 = require("injection-js");
6
+ Object.defineProperty(exports, "Injectable", { enumerable: true, get: function () { return injection_js_1.Injectable; } });
7
+ Object.defineProperty(exports, "Inject", { enumerable: true, get: function () { return injection_js_1.Inject; } });
8
+ Object.defineProperty(exports, "Optional", { enumerable: true, get: function () { return injection_js_1.Optional; } });
9
+ Object.defineProperty(exports, "InjectionToken", { enumerable: true, get: function () { return injection_js_1.InjectionToken; } });
10
+ //# sourceMappingURL=injectable.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"injectable.js","sourceRoot":"","sources":["../../../../libs/core/src/di/injectable.ts"],"names":[],"mappings":";;;AAAA,4BAA0B;AAC1B,6CAA4E;AAAnE,0GAAA,UAAU,OAAA;AAAE,sGAAA,MAAM,OAAA;AAAE,wGAAA,QAAQ,OAAA;AAAE,8GAAA,cAAc,OAAA"}
@@ -0,0 +1,3 @@
1
+ import { Injector, ReflectiveInjector } from 'injection-js';
2
+ export { Injector };
3
+ export declare function resolveAndCreate(providers: any, parent?: Injector): ReflectiveInjector;
package/di/injector.js ADDED
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.resolveAndCreate = exports.Injector = void 0;
4
+ const injection_js_1 = require("injection-js");
5
+ Object.defineProperty(exports, "Injector", { enumerable: true, get: function () { return injection_js_1.Injector; } });
6
+ function resolveAndCreate(providers, parent = injection_js_1.Injector.NULL) {
7
+ return injection_js_1.ReflectiveInjector.resolveAndCreate(providers, parent);
8
+ }
9
+ exports.resolveAndCreate = resolveAndCreate;
10
+ //# sourceMappingURL=injector.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"injector.js","sourceRoot":"","sources":["../../../../libs/core/src/di/injector.ts"],"names":[],"mappings":";;;AAAA,+CAA4D;AAEnD,yFAFA,uBAAQ,OAEA;AAEjB,SAAgB,gBAAgB,CAAC,SAAS,EAAE,MAAM,GAAG,uBAAQ,CAAC,IAAI;IAChE,OAAO,iCAAkB,CAAC,gBAAgB,CAAC,SAAS,EAAE,MAAM,CAAC,CAAC;AAChE,CAAC;AAFD,4CAEC"}
@@ -0,0 +1,181 @@
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
+ import { ClassProvider, ConstructorProvider, ExistingProvider, FactoryProvider, StaticClassProvider, ValueProvider } from './provider';
10
+ /**
11
+ * Information about how a type or `InjectionToken` interfaces with the DI system.
12
+ *
13
+ * At a minimum, this includes a `factory` which defines how to create the given type `T`, possibly
14
+ * requesting injection of other types if necessary.
15
+ *
16
+ * Optionally, a `providedIn` parameter specifies that the given type belongs to a particular
17
+ * `Injector`, `NgModule`, or a special scope (e.g. `'root'`). A value of `null` indicates
18
+ * that the injectable does not belong to any scope.
19
+ *
20
+ * @codeGenApi
21
+ * @publicApi The ViewEngine compiler emits code with this type for injectables. This code is
22
+ * deployed to npm, and should be treated as public api.
23
+
24
+ */
25
+ export interface ɵɵInjectableDeclaration<T> {
26
+ /**
27
+ * Specifies that the given type belongs to a particular injector:
28
+ * - `InjectorType` such as `NgModule`,
29
+ * - `'root'` the root injector
30
+ * - `'any'` all injectors.
31
+ * - `null`, does not belong to any injector. Must be explicitly listed in the injector
32
+ * `providers`.
33
+ */
34
+ providedIn: InjectorType<any> | 'root' | 'platform' | 'any' | 'environment' | null;
35
+ /**
36
+ * The token to which this definition belongs.
37
+ *
38
+ * Note that this may not be the same as the type that the `factory` will create.
39
+ */
40
+ token: unknown;
41
+ /**
42
+ * Factory method to execute to create an instance of the injectable.
43
+ */
44
+ factory: (t?: Type<any>) => T;
45
+ /**
46
+ * In a case of no explicit injector, a location where the instance of the injectable is stored.
47
+ */
48
+ value: T | undefined;
49
+ }
50
+ /**
51
+ * Information about the providers to be included in an `Injector` as well as how the given type
52
+ * which carries the information should be created by the DI system.
53
+ *
54
+ * An `InjectorDef` can import other types which have `InjectorDefs`, forming a deep nested
55
+ * structure of providers with a defined priority (identically to how `NgModule`s also have
56
+ * an import/dependency structure).
57
+ *
58
+ * NOTE: This is a private type and should not be exported
59
+ *
60
+ * @codeGenApi
61
+ */
62
+ export interface ɵɵInjectorDef<T> {
63
+ providers: (Type<any> | ValueProvider | ExistingProvider | FactoryProvider | ConstructorProvider | StaticClassProvider | ClassProvider | any[])[];
64
+ imports: (InjectorType<any> | InjectorTypeWithProviders<any>)[];
65
+ }
66
+ /**
67
+ * A `Type` which has a `ɵprov: ɵɵInjectableDeclaration` static field.
68
+ *
69
+ * `InjectableType`s contain their own Dependency Injection metadata and are usable in an
70
+ * `InjectorDef`-based `StaticInjector`.
71
+ *
72
+ * @publicApi
73
+ */
74
+ export interface InjectableType<T> extends Type<T> {
75
+ /**
76
+ * Opaque type whose structure is highly version dependent. Do not rely on any properties.
77
+ */
78
+ ɵprov: unknown;
79
+ }
80
+ /**
81
+ * A type which has an `InjectorDef` static field.
82
+ *
83
+ * `InjectorTypes` can be used to configure a `StaticInjector`.
84
+ *
85
+ * This is an opaque type whose structure is highly version dependent. Do not rely on any
86
+ * properties.
87
+ *
88
+ * @publicApi
89
+ */
90
+ export interface InjectorType<T> extends Type<T> {
91
+ ɵfac?: unknown;
92
+ ɵinj: unknown;
93
+ }
94
+ /**
95
+ * Describes the `InjectorDef` equivalent of a `ModuleWithProviders`, an `InjectorType` with an
96
+ * associated array of providers.
97
+ *
98
+ * Objects of this type can be listed in the imports section of an `InjectorDef`.
99
+ *
100
+ * NOTE: This is a private type and should not be exported
101
+ */
102
+ export interface InjectorTypeWithProviders<T> {
103
+ nxModule: InjectorType<T>;
104
+ providers?: (Type<any> | ValueProvider | ExistingProvider | FactoryProvider | ConstructorProvider | StaticClassProvider | ClassProvider | any[])[];
105
+ }
106
+ /**
107
+ * Construct an injectable definition which defines how a token will be constructed by the DI
108
+ * system, and in which injectors (if any) it will be available.
109
+ *
110
+ * This should be assigned to a static `ɵprov` field on a type, which will then be an
111
+ * `InjectableType`.
112
+ *
113
+ * Options:
114
+ * * `providedIn` determines which injectors will include the injectable, by either associating it
115
+ * with an `@NgModule` or other `InjectorType`, or by specifying that this injectable should be
116
+ * provided in the `'root'` injector, which will be the application-level injector in most apps.
117
+ * * `factory` gives the zero argument function which will create an instance of the injectable.
118
+ * The factory can call `inject` to access the `Injector` and request injection of dependencies.
119
+ *
120
+ * @codeGenApi
121
+ * @publicApi This instruction has been emitted by ViewEngine for some time and is deployed to npm.
122
+ */
123
+ export declare function ɵɵdefineInjectable<T>(opts: {
124
+ token: unknown;
125
+ providedIn?: Type<any> | 'root' | 'platform' | 'any' | 'environment' | null;
126
+ factory: () => T;
127
+ }): unknown;
128
+ /**
129
+ * @deprecated in v8, delete after v10. This API should be used only by generated code, and that
130
+ * code should now use ɵɵdefineInjectable instead.
131
+ * @publicApi
132
+ */
133
+ export declare const defineInjectable: typeof ɵɵdefineInjectable;
134
+ /**
135
+ * Construct an `InjectorDef` which configures an injector.
136
+ *
137
+ * This should be assigned to a static injector def (`ɵinj`) field on a type, which will then be an
138
+ * `InjectorType`.
139
+ *
140
+ * Options:
141
+ *
142
+ * * `providers`: an optional array of providers to add to the injector. Each provider must
143
+ * either have a factory or point to a type which has a `ɵprov` static property (the
144
+ * type must be an `InjectableType`).
145
+ * * `imports`: an optional array of imports of other `InjectorType`s or `InjectorTypeWithModule`s
146
+ * whose providers will also be added to the injector. Locally provided types will override
147
+ * providers from imports.
148
+ *
149
+ * @codeGenApi
150
+ */
151
+ export declare function ɵɵdefineInjector(options: {
152
+ providers?: any[];
153
+ imports?: any[];
154
+ }): unknown;
155
+ /**
156
+ * Read the injectable def (`ɵprov`) for `type` in a way which is immune to accidentally reading
157
+ * inherited value.
158
+ *
159
+ * @param type A type which may have its own (non-inherited) `ɵprov`.
160
+ */
161
+ export declare function getInjectableDef<T>(type: any): ɵɵInjectableDeclaration<T> | null;
162
+ /**
163
+ * Read the injectable def (`ɵprov`) for `type` or read the `ɵprov` from one of its ancestors.
164
+ *
165
+ * @param type A type which may have `ɵprov`, via inheritance.
166
+ *
167
+ * @deprecated Will be removed in a future version of Angular, where an error will occur in the
168
+ * scenario if we find the `ɵprov` on an ancestor only.
169
+ */
170
+ export declare function getInheritedInjectableDef<T>(type: any): ɵɵInjectableDeclaration<T> | null;
171
+ export declare function hasInjectaorDef(type: any): boolean;
172
+ /**
173
+ * Read the injector def type in a way which is immune to accidentally reading inherited value.
174
+ *
175
+ * @param type type which may have an injector def (`ɵinj`)
176
+ */
177
+ export declare function getInjectorDef<T>(type: any): ɵɵInjectorDef<T> | null;
178
+ export declare const NG_PROV_DEF: string;
179
+ export declare const NG_INJ_DEF: string;
180
+ export declare const NG_INJECTABLE_DEF: string;
181
+ export declare const NG_INJECTOR_DEF: string;