static-injector 4.0.2 → 5.0.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/{import/commonjs → commonjs}/index.js +29 -197
- package/{import/es2022 → es2022}/di/interface/defs.js +5 -1
- package/{import/es2022 → es2022}/index.js +0 -1
- package/{transform/compiler/index.d.ts → es2022/interface/lifecycle_hooks.js} +1 -1
- package/{transform/compiler-cli/src/ngtsc/translator/src/api/ast_factory.js → es2022/render3/definition_factory.js} +3 -2
- package/es2022/util/decorators.js +31 -0
- package/{import/fesm2022 → fesm2022}/index.js +30 -196
- package/package.json +17 -14
- package/readme.md +35 -13
- package/{import/typings → typings}/di/injectable.d.ts +0 -7
- package/{import/typings → typings}/index.d.ts +0 -1
- package/import/es2022/di/injectable.js +0 -14
- package/import/es2022/error_details_base_url.js +0 -19
- package/import/es2022/render3/definition_factory.js +0 -14
- package/import/es2022/render3/di.js +0 -49
- package/import/es2022/render3/error_code.js +0 -30
- package/import/es2022/util/array_utils.js +0 -17
- package/import/es2022/util/decorators.js +0 -53
- package/import/typings/error_details_base_url.d.ts +0 -19
- package/import/typings/render3/di.d.ts +0 -12
- package/import/typings/render3/error_code.d.ts +0 -24
- package/import/typings/util/array_utils.d.ts +0 -25
- package/transform/compiler/compiler.d.ts +0 -8
- package/transform/compiler/compiler.js +0 -28
- package/transform/compiler/index.js +0 -28
- package/transform/compiler/public_api.d.ts +0 -13
- package/transform/compiler/public_api.js +0 -30
- package/transform/compiler/src/compiler.d.ts +0 -5
- package/transform/compiler/src/compiler.js +0 -21
- package/transform/compiler/src/core.d.ts +0 -25
- package/transform/compiler/src/core.js +0 -22
- package/transform/compiler/src/injectable_compiler_2.d.ts +0 -23
- package/transform/compiler/src/injectable_compiler_2.js +0 -171
- package/transform/compiler/src/output/output_ast.d.ts +0 -512
- package/transform/compiler/src/output/output_ast.js +0 -1109
- package/transform/compiler/src/parse_util.d.ts +0 -50
- package/transform/compiler/src/parse_util.js +0 -71
- package/transform/compiler/src/render3/partial/api.d.ts +0 -171
- package/transform/compiler/src/render3/partial/api.js +0 -18
- package/transform/compiler/src/render3/r3_factory.d.ts +0 -82
- package/transform/compiler/src/render3/r3_factory.js +0 -225
- package/transform/compiler/src/render3/r3_identifiers.d.ts +0 -20
- package/transform/compiler/src/render3/r3_identifiers.js +0 -55
- package/transform/compiler/src/render3/util.d.ts +0 -85
- package/transform/compiler/src/render3/util.js +0 -82
- package/transform/compiler/src/render3/view/util.d.ts +0 -24
- package/transform/compiler/src/render3/view/util.js +0 -59
- package/transform/compiler-cli/src/ngtsc/annotations/common/index.d.ts +0 -3
- package/transform/compiler-cli/src/ngtsc/annotations/common/index.js +0 -19
- package/transform/compiler-cli/src/ngtsc/annotations/common/src/di.d.ts +0 -37
- package/transform/compiler-cli/src/ngtsc/annotations/common/src/di.js +0 -195
- package/transform/compiler-cli/src/ngtsc/annotations/common/src/factory.d.ts +0 -11
- package/transform/compiler-cli/src/ngtsc/annotations/common/src/factory.js +0 -22
- package/transform/compiler-cli/src/ngtsc/annotations/common/src/util.d.ts +0 -64
- package/transform/compiler-cli/src/ngtsc/annotations/common/src/util.js +0 -189
- package/transform/compiler-cli/src/ngtsc/annotations/src/injectable.d.ts +0 -43
- package/transform/compiler-cli/src/ngtsc/annotations/src/injectable.js +0 -277
- package/transform/compiler-cli/src/ngtsc/diagnostics/error.d.ts +0 -24
- package/transform/compiler-cli/src/ngtsc/diagnostics/error.js +0 -84
- package/transform/compiler-cli/src/ngtsc/diagnostics/error_code.d.ts +0 -188
- package/transform/compiler-cli/src/ngtsc/diagnostics/error_code.js +0 -206
- package/transform/compiler-cli/src/ngtsc/diagnostics/index.d.ts +0 -2
- package/transform/compiler-cli/src/ngtsc/diagnostics/index.js +0 -18
- package/transform/compiler-cli/src/ngtsc/imports/index.d.ts +0 -1
- package/transform/compiler-cli/src/ngtsc/imports/index.js +0 -17
- package/transform/compiler-cli/src/ngtsc/imports/src/core.d.ts +0 -36
- package/transform/compiler-cli/src/ngtsc/imports/src/core.js +0 -25
- package/transform/compiler-cli/src/ngtsc/imports/src/default.d.ts +0 -19
- package/transform/compiler-cli/src/ngtsc/imports/src/default.js +0 -27
- package/transform/compiler-cli/src/ngtsc/reflection/index.d.ts +0 -3
- package/transform/compiler-cli/src/ngtsc/reflection/index.js +0 -19
- package/transform/compiler-cli/src/ngtsc/reflection/src/host.d.ts +0 -522
- package/transform/compiler-cli/src/ngtsc/reflection/src/host.js +0 -34
- package/transform/compiler-cli/src/ngtsc/reflection/src/type_to_value.d.ts +0 -25
- package/transform/compiler-cli/src/ngtsc/reflection/src/type_to_value.js +0 -271
- package/transform/compiler-cli/src/ngtsc/reflection/src/typescript.d.ts +0 -53
- package/transform/compiler-cli/src/ngtsc/reflection/src/typescript.js +0 -393
- package/transform/compiler-cli/src/ngtsc/reflection/src/util.d.ts +0 -12
- package/transform/compiler-cli/src/ngtsc/reflection/src/util.js +0 -29
- package/transform/compiler-cli/src/ngtsc/transform/index.d.ts +0 -2
- package/transform/compiler-cli/src/ngtsc/transform/index.js +0 -18
- package/transform/compiler-cli/src/ngtsc/transform/src/api.d.ts +0 -115
- package/transform/compiler-cli/src/ngtsc/transform/src/api.js +0 -29
- package/transform/compiler-cli/src/ngtsc/transform/src/utils.d.ts +0 -15
- package/transform/compiler-cli/src/ngtsc/transform/src/utils.js +0 -79
- package/transform/compiler-cli/src/ngtsc/translator/index.d.ts +0 -5
- package/transform/compiler-cli/src/ngtsc/translator/index.js +0 -21
- package/transform/compiler-cli/src/ngtsc/translator/src/api/ast_factory.d.ts +0 -289
- package/transform/compiler-cli/src/ngtsc/translator/src/api/import_generator.d.ts +0 -27
- package/transform/compiler-cli/src/ngtsc/translator/src/api/import_generator.js +0 -9
- package/transform/compiler-cli/src/ngtsc/translator/src/context.d.ts +0 -18
- package/transform/compiler-cli/src/ngtsc/translator/src/context.js +0 -28
- package/transform/compiler-cli/src/ngtsc/translator/src/import_manager.d.ts +0 -47
- package/transform/compiler-cli/src/ngtsc/translator/src/import_manager.js +0 -66
- package/transform/compiler-cli/src/ngtsc/translator/src/translator.d.ts +0 -56
- package/transform/compiler-cli/src/ngtsc/translator/src/translator.js +0 -270
- package/transform/compiler-cli/src/ngtsc/translator/src/ts_util.d.ts +0 -12
- package/transform/compiler-cli/src/ngtsc/translator/src/ts_util.js +0 -27
- package/transform/compiler-cli/src/ngtsc/translator/src/typescript_ast_factory.d.ts +0 -53
- package/transform/compiler-cli/src/ngtsc/translator/src/typescript_ast_factory.js +0 -250
- package/transform/compiler-cli/src/ngtsc/translator/src/typescript_translator.d.ts +0 -13
- package/transform/compiler-cli/src/ngtsc/translator/src/typescript_translator.js +0 -21
- package/transform/compiler-cli/src/ngtsc/ts_compatibility/index.d.ts +0 -8
- package/transform/compiler-cli/src/ngtsc/ts_compatibility/index.js +0 -24
- package/transform/compiler-cli/src/ngtsc/ts_compatibility/src/ts_cross_version_utils.d.ts +0 -45
- package/transform/compiler-cli/src/ngtsc/ts_compatibility/src/ts_cross_version_utils.js +0 -86
- package/transform/compiler-cli/src/ngtsc/util/src/typescript.d.ts +0 -4
- package/transform/compiler-cli/src/ngtsc/util/src/typescript.js +0 -16
- package/transform/index.d.ts +0 -1
- package/transform/index.js +0 -17
- package/transform/injectable-transform.d.ts +0 -41
- package/transform/injectable-transform.js +0 -245
- package/transform/node-Iteration.d.ts +0 -2
- package/transform/node-Iteration.js +0 -12
- /package/{import/es2022 → es2022}/di/create_injector.js +0 -0
- /package/{import/es2022 → es2022}/di/forward_ref.js +0 -0
- /package/{import/es2022 → es2022}/di/index.js +0 -0
- /package/{import/es2022 → es2022}/di/initializer_token.js +0 -0
- /package/{import/es2022 → es2022}/di/inject_switch.js +0 -0
- /package/{import/es2022/di/injector_marker.js → es2022/di/injectable.js} +0 -0
- /package/{import/es2022 → es2022}/di/injection_token.js +0 -0
- /package/{import/es2022 → es2022}/di/injector.js +0 -0
- /package/{import/es2022 → es2022}/di/injector_compatibility.js +0 -0
- /package/{import/es2022/di/provider_token.js → es2022/di/injector_marker.js} +0 -0
- /package/{import/es2022 → es2022}/di/injector_token.js +0 -0
- /package/{import/es2022 → es2022}/di/interface/injector.js +0 -0
- /package/{import/es2022 → es2022}/di/interface/provider.js +0 -0
- /package/{import/es2022 → es2022}/di/internal_tokens.js +0 -0
- /package/{import/es2022 → es2022}/di/metadata.js +0 -0
- /package/{import/es2022 → es2022}/di/null_injector.js +0 -0
- /package/{import/es2022 → es2022}/di/provider_collection.js +0 -0
- /package/{import/es2022/interface/lifecycle_hooks.js → es2022/di/provider_token.js} +0 -0
- /package/{import/es2022 → es2022}/di/r3_injector.js +0 -0
- /package/{import/es2022 → es2022}/di/scope.js +0 -0
- /package/{import/es2022 → es2022}/di.js +0 -0
- /package/{import/es2022 → es2022}/errors.js +0 -0
- /package/{import/es2022 → es2022}/interface/type.js +0 -0
- /package/{import/es2022 → es2022}/render3/errors_di.js +0 -0
- /package/{import/es2022 → es2022}/render3/fields.js +0 -0
- /package/{import/es2022 → es2022}/render3/instructions/di.js +0 -0
- /package/{import/es2022 → es2022}/render3/util/stringify_utils.js +0 -0
- /package/{import/es2022 → es2022}/util/closure.js +0 -0
- /package/{import/es2022 → es2022}/util/empty.js +0 -0
- /package/{import/es2022 → es2022}/util/property.js +0 -0
- /package/{import/es2022 → es2022}/util/stringify.js +0 -0
- /package/{import/typings → typings}/di/create_injector.d.ts +0 -0
- /package/{import/typings → typings}/di/forward_ref.d.ts +0 -0
- /package/{import/typings → typings}/di/index.d.ts +0 -0
- /package/{import/typings → typings}/di/initializer_token.d.ts +0 -0
- /package/{import/typings → typings}/di/inject_switch.d.ts +0 -0
- /package/{import/typings → typings}/di/injection_token.d.ts +0 -0
- /package/{import/typings → typings}/di/injector.d.ts +0 -0
- /package/{import/typings → typings}/di/injector_compatibility.d.ts +0 -0
- /package/{import/typings → typings}/di/injector_marker.d.ts +0 -0
- /package/{import/typings → typings}/di/injector_token.d.ts +0 -0
- /package/{import/typings → typings}/di/interface/defs.d.ts +0 -0
- /package/{import/typings → typings}/di/interface/injector.d.ts +0 -0
- /package/{import/typings → typings}/di/interface/provider.d.ts +0 -0
- /package/{import/typings → typings}/di/internal_tokens.d.ts +0 -0
- /package/{import/typings → typings}/di/metadata.d.ts +0 -0
- /package/{import/typings → typings}/di/null_injector.d.ts +0 -0
- /package/{import/typings → typings}/di/provider_collection.d.ts +0 -0
- /package/{import/typings → typings}/di/provider_token.d.ts +0 -0
- /package/{import/typings → typings}/di/r3_injector.d.ts +0 -0
- /package/{import/typings → typings}/di/scope.d.ts +0 -0
- /package/{import/typings → typings}/di.d.ts +0 -0
- /package/{import/typings → typings}/errors.d.ts +0 -0
- /package/{import/typings → typings}/interface/lifecycle_hooks.d.ts +0 -0
- /package/{import/typings → typings}/interface/type.d.ts +0 -0
- /package/{import/typings → typings}/render3/definition_factory.d.ts +0 -0
- /package/{import/typings → typings}/render3/errors_di.d.ts +0 -0
- /package/{import/typings → typings}/render3/fields.d.ts +0 -0
- /package/{import/typings → typings}/render3/instructions/di.d.ts +0 -0
- /package/{import/typings → typings}/render3/util/stringify_utils.d.ts +0 -0
- /package/{import/typings → typings}/util/closure.d.ts +0 -0
- /package/{import/typings → typings}/util/decorators.d.ts +0 -0
- /package/{import/typings → typings}/util/empty.d.ts +0 -0
- /package/{import/typings → typings}/util/property.d.ts +0 -0
- /package/{import/typings → typings}/util/stringify.d.ts +0 -0
|
@@ -1,20 +1,5 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
/**
|
|
4
|
-
* @license
|
|
5
|
-
* Copyright Google LLC All Rights Reserved.
|
|
6
|
-
*
|
|
7
|
-
* Use of this source code is governed by an MIT-style license that can be
|
|
8
|
-
* found in the LICENSE file at https://angular.io/license
|
|
9
|
-
*/
|
|
10
|
-
/**
|
|
11
|
-
* Injectable decorator and metadata.
|
|
12
|
-
*
|
|
13
|
-
* @Annotation
|
|
14
|
-
* @publicApi
|
|
15
|
-
*/
|
|
16
|
-
const Injectable = undefined;
|
|
17
|
-
|
|
18
3
|
/**
|
|
19
4
|
* @license
|
|
20
5
|
* Copyright Google LLC All Rights Reserved.
|
|
@@ -42,7 +27,6 @@ function noSideEffects(fn) {
|
|
|
42
27
|
* Use of this source code is governed by an MIT-style license that can be
|
|
43
28
|
* found in the LICENSE file at https://angular.io/license
|
|
44
29
|
*/
|
|
45
|
-
const PARAMETERS = '__parameters__';
|
|
46
30
|
function makeMetadataCtor(props) {
|
|
47
31
|
return function ctor(...args) {
|
|
48
32
|
if (props) {
|
|
@@ -57,33 +41,9 @@ function makeParamDecorator(name, props, parentClass) {
|
|
|
57
41
|
return noSideEffects(() => {
|
|
58
42
|
const metaCtor = makeMetadataCtor(props);
|
|
59
43
|
function ParamDecoratorFactory(...args) {
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
return this;
|
|
63
|
-
}
|
|
64
|
-
const annotationInstance = new ParamDecoratorFactory(...args);
|
|
65
|
-
ParamDecorator.annotation = annotationInstance;
|
|
66
|
-
return ParamDecorator;
|
|
67
|
-
function ParamDecorator(cls, unusedKey, index) {
|
|
68
|
-
// Use of Object.defineProperty is important since it creates non-enumerable property which
|
|
69
|
-
// prevents the property is copied during subclassing.
|
|
70
|
-
const parameters = cls.hasOwnProperty(PARAMETERS)
|
|
71
|
-
? cls[PARAMETERS]
|
|
72
|
-
: Object.defineProperty(cls, PARAMETERS, { value: [] })[PARAMETERS];
|
|
73
|
-
// there might be gaps if some in between parameters do not have annotations.
|
|
74
|
-
// we pad with nulls.
|
|
75
|
-
while (parameters.length <= index) {
|
|
76
|
-
parameters.push(null);
|
|
77
|
-
}
|
|
78
|
-
(parameters[index] = parameters[index] || []).push(annotationInstance);
|
|
79
|
-
return cls;
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
if (parentClass) {
|
|
83
|
-
ParamDecoratorFactory.prototype = Object.create(parentClass.prototype);
|
|
44
|
+
metaCtor.apply(this, args);
|
|
45
|
+
return this;
|
|
84
46
|
}
|
|
85
|
-
ParamDecoratorFactory.prototype.ngMetadataName = name;
|
|
86
|
-
ParamDecoratorFactory.annotationCls = ParamDecoratorFactory;
|
|
87
47
|
return ParamDecoratorFactory;
|
|
88
48
|
});
|
|
89
49
|
}
|
|
@@ -128,8 +88,6 @@ function formatRuntimeError(code, message) {
|
|
|
128
88
|
// We also prepend `0` to non-compile-time errors.
|
|
129
89
|
const fullCode = `NG0${Math.abs(code)}`;
|
|
130
90
|
let errorMessage = `${fullCode}${message ? ': ' + message : ''}`;
|
|
131
|
-
if (false) {
|
|
132
|
-
}
|
|
133
91
|
return errorMessage;
|
|
134
92
|
}
|
|
135
93
|
|
|
@@ -163,21 +121,6 @@ function stringify(token) {
|
|
|
163
121
|
const newLineIndex = res.indexOf('\n');
|
|
164
122
|
return newLineIndex === -1 ? res : res.substring(0, newLineIndex);
|
|
165
123
|
}
|
|
166
|
-
/**
|
|
167
|
-
* Ellipses the string in the middle when longer than the max length
|
|
168
|
-
*
|
|
169
|
-
* @param string
|
|
170
|
-
* @param maxLength of the output string
|
|
171
|
-
* @returns ellipsed string with ... in the middle
|
|
172
|
-
*/
|
|
173
|
-
function truncateMiddle(str, maxLength = 100) {
|
|
174
|
-
if (!str || maxLength < 1 || str.length <= maxLength)
|
|
175
|
-
return str;
|
|
176
|
-
if (maxLength == 1)
|
|
177
|
-
return str.substring(0, 1) + '...';
|
|
178
|
-
const halfLimit = Math.round(maxLength / 2);
|
|
179
|
-
return (str.substring(0, halfLimit) + '...' + str.substring(str.length - halfLimit));
|
|
180
|
-
}
|
|
181
124
|
|
|
182
125
|
/**
|
|
183
126
|
* @license
|
|
@@ -347,7 +290,11 @@ function ɵɵdefineInjector(options) {
|
|
|
347
290
|
* @param type A type which may have its own (non-inherited) `ɵprov`.
|
|
348
291
|
*/
|
|
349
292
|
function getInjectableDef(type) {
|
|
350
|
-
return getOwnDefinition(type, NG_PROV_DEF) ||
|
|
293
|
+
return (getOwnDefinition(type, NG_PROV_DEF) || {
|
|
294
|
+
token: type,
|
|
295
|
+
factory: () => new type(),
|
|
296
|
+
...type.injectOptions,
|
|
297
|
+
});
|
|
351
298
|
}
|
|
352
299
|
function isInjectable(type) {
|
|
353
300
|
return getInjectableDef(type) !== null;
|
|
@@ -464,9 +411,7 @@ function injectRootLimpMode(token, notFoundValue, flags) {
|
|
|
464
411
|
}
|
|
465
412
|
if (flags & exports.InjectFlags.Optional)
|
|
466
413
|
return null;
|
|
467
|
-
|
|
468
|
-
return notFoundValue;
|
|
469
|
-
throwProviderNotFoundError(token, 'Injector');
|
|
414
|
+
throwProviderNotFoundError();
|
|
470
415
|
}
|
|
471
416
|
|
|
472
417
|
/**
|
|
@@ -756,7 +701,7 @@ makeParamDecorator('Inject', (token) => ({ token })), -1 /* DecoratorFlags.Injec
|
|
|
756
701
|
const Optional =
|
|
757
702
|
// Disable tslint because `InternalInjectFlags` is a const enum which gets inlined.
|
|
758
703
|
// tslint:disable-next-line: no-toplevel-property-access
|
|
759
|
-
attachInjectFlag(makeParamDecorator(
|
|
704
|
+
attachInjectFlag(makeParamDecorator(), 8 /* InternalInjectFlags.Optional */);
|
|
760
705
|
/**
|
|
761
706
|
* Self decorator and metadata.
|
|
762
707
|
*
|
|
@@ -766,7 +711,7 @@ attachInjectFlag(makeParamDecorator('Optional'), 8 /* InternalInjectFlags.Option
|
|
|
766
711
|
const Self =
|
|
767
712
|
// Disable tslint because `InternalInjectFlags` is a const enum which gets inlined.
|
|
768
713
|
// tslint:disable-next-line: no-toplevel-property-access
|
|
769
|
-
attachInjectFlag(makeParamDecorator(
|
|
714
|
+
attachInjectFlag(makeParamDecorator(), 2 /* InternalInjectFlags.Self */);
|
|
770
715
|
/**
|
|
771
716
|
* `SkipSelf` decorator and metadata.
|
|
772
717
|
*
|
|
@@ -776,7 +721,18 @@ attachInjectFlag(makeParamDecorator('Self'), 2 /* InternalInjectFlags.Self */);
|
|
|
776
721
|
const SkipSelf =
|
|
777
722
|
// Disable tslint because `InternalInjectFlags` is a const enum which gets inlined.
|
|
778
723
|
// tslint:disable-next-line: no-toplevel-property-access
|
|
779
|
-
attachInjectFlag(makeParamDecorator(
|
|
724
|
+
attachInjectFlag(makeParamDecorator(), 4 /* InternalInjectFlags.SkipSelf */);
|
|
725
|
+
|
|
726
|
+
/**
|
|
727
|
+
* @license
|
|
728
|
+
* Copyright Google LLC All Rights Reserved.
|
|
729
|
+
*
|
|
730
|
+
* Use of this source code is governed by an MIT-style license that can be
|
|
731
|
+
* found in the LICENSE file at https://angular.io/license
|
|
732
|
+
*/
|
|
733
|
+
function getFactoryDef(type, throwNotFound) {
|
|
734
|
+
return () => new type();
|
|
735
|
+
}
|
|
780
736
|
|
|
781
737
|
/**
|
|
782
738
|
* @license
|
|
@@ -785,7 +741,7 @@ attachInjectFlag(makeParamDecorator('SkipSelf'), 4 /* InternalInjectFlags.SkipSe
|
|
|
785
741
|
* Use of this source code is governed by an MIT-style license that can be
|
|
786
742
|
* found in the LICENSE file at https://angular.io/license
|
|
787
743
|
*/
|
|
788
|
-
|
|
744
|
+
getClosureSafeProperty({
|
|
789
745
|
ɵfac: getClosureSafeProperty,
|
|
790
746
|
});
|
|
791
747
|
/**
|
|
@@ -800,20 +756,6 @@ const NG_ENV_ID = getClosureSafeProperty({
|
|
|
800
756
|
__NG_ENV_ID__: getClosureSafeProperty,
|
|
801
757
|
});
|
|
802
758
|
|
|
803
|
-
/**
|
|
804
|
-
* @license
|
|
805
|
-
* Copyright Google LLC All Rights Reserved.
|
|
806
|
-
*
|
|
807
|
-
* Use of this source code is governed by an MIT-style license that can be
|
|
808
|
-
* found in the LICENSE file at https://angular.io/license
|
|
809
|
-
*/
|
|
810
|
-
function getFactoryDef(type, throwNotFound) {
|
|
811
|
-
const hasFactoryDef = type.hasOwnProperty(NG_FACTORY_DEF);
|
|
812
|
-
if (false) {
|
|
813
|
-
}
|
|
814
|
-
return hasFactoryDef ? type[NG_FACTORY_DEF] : null;
|
|
815
|
-
}
|
|
816
|
-
|
|
817
759
|
/**
|
|
818
760
|
* @license
|
|
819
761
|
* Copyright Google LLC All Rights Reserved.
|
|
@@ -827,11 +769,7 @@ function getFactoryDef(type, throwNotFound) {
|
|
|
827
769
|
* allows for identity checks against these values to be consistently used by the framework
|
|
828
770
|
* code.
|
|
829
771
|
*/
|
|
830
|
-
const EMPTY_OBJ = {};
|
|
831
772
|
const EMPTY_ARRAY = [];
|
|
832
|
-
// freezing the values prevents any code from accidentally inserting new values in
|
|
833
|
-
if (false) {
|
|
834
|
-
}
|
|
835
773
|
|
|
836
774
|
/**
|
|
837
775
|
* @license
|
|
@@ -903,10 +841,7 @@ class InjectionToken {
|
|
|
903
841
|
constructor(_desc, options) {
|
|
904
842
|
this._desc = _desc;
|
|
905
843
|
this.ɵprov = undefined;
|
|
906
|
-
if (typeof options == 'number')
|
|
907
|
-
// This is a special hack to assign __NG_ELEMENT_ID__ to this instance.
|
|
908
|
-
// See `InjectorMarkers`
|
|
909
|
-
}
|
|
844
|
+
if (typeof options == 'number') ;
|
|
910
845
|
else if (options !== undefined) {
|
|
911
846
|
this.ɵprov = ɵɵdefineInjectable({
|
|
912
847
|
token: this,
|
|
@@ -1006,15 +941,6 @@ class NullInjector {
|
|
|
1006
941
|
* Use of this source code is governed by an MIT-style license that can be
|
|
1007
942
|
* found in the LICENSE file at https://angular.io/license
|
|
1008
943
|
*/
|
|
1009
|
-
/**
|
|
1010
|
-
* Wrap an array of `Provider`s into `EnvironmentProviders`, preventing them from being accidentally
|
|
1011
|
-
* referenced in `@Component` in a component injector.
|
|
1012
|
-
*/
|
|
1013
|
-
function makeEnvironmentProviders(providers) {
|
|
1014
|
-
return {
|
|
1015
|
-
ɵproviders: providers,
|
|
1016
|
-
};
|
|
1017
|
-
}
|
|
1018
944
|
/**
|
|
1019
945
|
* Collects providers from all NgModules and standalone components, including transitively imported
|
|
1020
946
|
* ones.
|
|
@@ -1063,26 +989,8 @@ function importProvidersFrom(...sources) {
|
|
|
1063
989
|
}
|
|
1064
990
|
function internalImportProvidersFrom(checkForStandaloneCmp, ...sources) {
|
|
1065
991
|
const providersOut = [];
|
|
1066
|
-
const dedup = new Set(); // already seen types
|
|
1067
|
-
let injectorTypesWithProviders;
|
|
1068
|
-
const collectProviders = (provider) => {
|
|
1069
|
-
providersOut.push(provider);
|
|
1070
|
-
};
|
|
1071
|
-
// Collect all providers from `ModuleWithProviders` types.
|
|
1072
|
-
if (injectorTypesWithProviders !== undefined) {
|
|
1073
|
-
processInjectorTypesWithProviders(injectorTypesWithProviders, collectProviders);
|
|
1074
|
-
}
|
|
1075
992
|
return providersOut;
|
|
1076
993
|
}
|
|
1077
|
-
/**
|
|
1078
|
-
* Collects all providers from the list of `ModuleWithProviders` and appends them to the provided
|
|
1079
|
-
* array.
|
|
1080
|
-
*/
|
|
1081
|
-
function processInjectorTypesWithProviders(typesWithProviders, visitor) {
|
|
1082
|
-
for (let i = 0; i < typesWithProviders.length; i++) {
|
|
1083
|
-
const { ngModule, providers } = typesWithProviders[i];
|
|
1084
|
-
}
|
|
1085
|
-
}
|
|
1086
994
|
const USE_VALUE = getClosureSafeProperty({
|
|
1087
995
|
provide: String,
|
|
1088
996
|
useValue: getClosureSafeProperty,
|
|
@@ -1099,9 +1007,6 @@ function isFactoryProvider(value) {
|
|
|
1099
1007
|
function isTypeProvider(value) {
|
|
1100
1008
|
return typeof value === 'function';
|
|
1101
1009
|
}
|
|
1102
|
-
function isClassProvider(value) {
|
|
1103
|
-
return !!value.useClass;
|
|
1104
|
-
}
|
|
1105
1010
|
|
|
1106
1011
|
/**
|
|
1107
1012
|
* @license
|
|
@@ -1235,8 +1140,6 @@ class R3Injector extends EnvironmentInjector {
|
|
|
1235
1140
|
this.assertNotDestroyed();
|
|
1236
1141
|
const previousInjector = setCurrentInjector(this);
|
|
1237
1142
|
const previousInjectImplementation = setInjectImplementation(undefined);
|
|
1238
|
-
if (false) {
|
|
1239
|
-
}
|
|
1240
1143
|
try {
|
|
1241
1144
|
return fn();
|
|
1242
1145
|
}
|
|
@@ -1251,9 +1154,6 @@ class R3Injector extends EnvironmentInjector {
|
|
|
1251
1154
|
return token[NG_ENV_ID](this);
|
|
1252
1155
|
}
|
|
1253
1156
|
flags = convertToBitFlags(flags);
|
|
1254
|
-
// Set the injection context.
|
|
1255
|
-
if (false) {
|
|
1256
|
-
}
|
|
1257
1157
|
const previousInjector = setCurrentInjector(this);
|
|
1258
1158
|
const previousInjectImplementation = setInjectImplementation(undefined);
|
|
1259
1159
|
try {
|
|
@@ -1268,8 +1168,7 @@ class R3Injector extends EnvironmentInjector {
|
|
|
1268
1168
|
if (def && this.injectableDefInScope(def)) {
|
|
1269
1169
|
// Found an injectable def and it's scoped to this injector. Pretend as if it was here
|
|
1270
1170
|
// all along.
|
|
1271
|
-
if (false)
|
|
1272
|
-
}
|
|
1171
|
+
if (false) ;
|
|
1273
1172
|
record = makeRecord(injectableDefOrInjectorDefFactory(token), NOT_YET);
|
|
1274
1173
|
}
|
|
1275
1174
|
else {
|
|
@@ -1323,12 +1222,9 @@ class R3Injector extends EnvironmentInjector {
|
|
|
1323
1222
|
resolveInjectorInitializers() {
|
|
1324
1223
|
const previousInjector = setCurrentInjector(this);
|
|
1325
1224
|
const previousInjectImplementation = setInjectImplementation(undefined);
|
|
1326
|
-
if (false) {
|
|
1327
|
-
}
|
|
1328
1225
|
try {
|
|
1329
1226
|
const initializers = this.get(ENVIRONMENT_INITIALIZER, EMPTY_ARRAY, exports.InjectFlags.Self);
|
|
1330
|
-
if (false)
|
|
1331
|
-
}
|
|
1227
|
+
if (false) ;
|
|
1332
1228
|
for (const initializer of initializers) {
|
|
1333
1229
|
initializer();
|
|
1334
1230
|
}
|
|
@@ -1363,17 +1259,11 @@ class R3Injector extends EnvironmentInjector {
|
|
|
1363
1259
|
: resolveForwardRef(provider && provider.provide);
|
|
1364
1260
|
// Construct a `Record` for the provider.
|
|
1365
1261
|
const record = providerToRecord(provider);
|
|
1366
|
-
if (false) {
|
|
1367
|
-
}
|
|
1368
1262
|
if (!isTypeProvider(provider) && provider.multi === true) {
|
|
1369
1263
|
// If the provider indicates that it's a multi-provider, process it specially.
|
|
1370
1264
|
// First check whether it's been defined already.
|
|
1371
1265
|
let multiRecord = this.records.get(token);
|
|
1372
|
-
if (multiRecord)
|
|
1373
|
-
// It has. Throw a nice error if
|
|
1374
|
-
if (false) {
|
|
1375
|
-
}
|
|
1376
|
-
}
|
|
1266
|
+
if (multiRecord) ;
|
|
1377
1267
|
else {
|
|
1378
1268
|
multiRecord = makeRecord(undefined, NOT_YET, true);
|
|
1379
1269
|
multiRecord.factory = () => injectArgs(multiRecord.multi);
|
|
@@ -1382,20 +1272,14 @@ class R3Injector extends EnvironmentInjector {
|
|
|
1382
1272
|
token = provider;
|
|
1383
1273
|
multiRecord.multi.push(provider);
|
|
1384
1274
|
}
|
|
1385
|
-
else {
|
|
1386
|
-
if (false) {
|
|
1387
|
-
}
|
|
1388
|
-
}
|
|
1389
1275
|
this.records.set(token, record);
|
|
1390
1276
|
}
|
|
1391
1277
|
hydrate(token, record) {
|
|
1392
1278
|
try {
|
|
1393
|
-
if (false)
|
|
1394
|
-
}
|
|
1279
|
+
if (false) ;
|
|
1395
1280
|
else if (record.value === NOT_YET) {
|
|
1396
1281
|
record.value = CIRCULAR;
|
|
1397
|
-
if (false)
|
|
1398
|
-
}
|
|
1282
|
+
if (false) ;
|
|
1399
1283
|
else {
|
|
1400
1284
|
record.value = record.factory();
|
|
1401
1285
|
}
|
|
@@ -1483,8 +1367,6 @@ function providerToRecord(provider) {
|
|
|
1483
1367
|
*/
|
|
1484
1368
|
function providerToFactory(provider, ngModuleType, providers) {
|
|
1485
1369
|
let factory = undefined;
|
|
1486
|
-
if (false) {
|
|
1487
|
-
}
|
|
1488
1370
|
if (isTypeProvider(provider)) {
|
|
1489
1371
|
const unwrappedProvider = resolveForwardRef(provider);
|
|
1490
1372
|
return (getFactoryDef(unwrappedProvider) ||
|
|
@@ -1504,8 +1386,6 @@ function providerToFactory(provider, ngModuleType, providers) {
|
|
|
1504
1386
|
const classRef = resolveForwardRef(provider &&
|
|
1505
1387
|
(provider.useClass ||
|
|
1506
1388
|
provider.provide));
|
|
1507
|
-
if (false) {
|
|
1508
|
-
}
|
|
1509
1389
|
if (hasDeps(provider)) {
|
|
1510
1390
|
factory = () => new classRef(...injectArgs(provider.deps));
|
|
1511
1391
|
}
|
|
@@ -1658,56 +1538,9 @@ function ɵɵinvalidFactory() {
|
|
|
1658
1538
|
throw new Error(msg);
|
|
1659
1539
|
}
|
|
1660
1540
|
|
|
1661
|
-
/**
|
|
1662
|
-
* @license
|
|
1663
|
-
* Copyright Google LLC All Rights Reserved.
|
|
1664
|
-
*
|
|
1665
|
-
* Use of this source code is governed by an MIT-style license that can be
|
|
1666
|
-
* found in the LICENSE file at https://angular.io/license
|
|
1667
|
-
*/
|
|
1668
|
-
/**
|
|
1669
|
-
* @codeGenApi
|
|
1670
|
-
*/
|
|
1671
|
-
function ɵɵgetInheritedFactory(type) {
|
|
1672
|
-
return noSideEffects(() => {
|
|
1673
|
-
const ownConstructor = type.prototype.constructor;
|
|
1674
|
-
const ownFactory = ownConstructor[NG_FACTORY_DEF] || getFactoryOf(ownConstructor);
|
|
1675
|
-
const objectPrototype = Object.prototype;
|
|
1676
|
-
let parent = Object.getPrototypeOf(type.prototype).constructor;
|
|
1677
|
-
// Go up the prototype until we hit `Object`.
|
|
1678
|
-
while (parent && parent !== objectPrototype) {
|
|
1679
|
-
const factory = parent[NG_FACTORY_DEF] || getFactoryOf(parent);
|
|
1680
|
-
// If we hit something that has a factory and the factory isn't the same as the type,
|
|
1681
|
-
// we've found the inherited factory. Note the check that the factory isn't the type's
|
|
1682
|
-
// own factory is redundant in most cases, but if the user has custom decorators on the
|
|
1683
|
-
// class, this lookup will start one level down in the prototype chain, causing us to
|
|
1684
|
-
// find the own factory first and potentially triggering an infinite loop downstream.
|
|
1685
|
-
if (factory && factory !== ownFactory) {
|
|
1686
|
-
return factory;
|
|
1687
|
-
}
|
|
1688
|
-
parent = Object.getPrototypeOf(parent);
|
|
1689
|
-
}
|
|
1690
|
-
// There is no factory defined. Either this was improper usage of inheritance
|
|
1691
|
-
// (no Angular decorator on the superclass) or there is no constructor at all
|
|
1692
|
-
// in the inheritance chain. Since the two cases cannot be distinguished, the
|
|
1693
|
-
// latter has to be assumed.
|
|
1694
|
-
return (t) => new t();
|
|
1695
|
-
});
|
|
1696
|
-
}
|
|
1697
|
-
function getFactoryOf(type) {
|
|
1698
|
-
if (isForwardRef(type)) {
|
|
1699
|
-
return () => {
|
|
1700
|
-
const factory = getFactoryOf(resolveForwardRef(type));
|
|
1701
|
-
return factory && factory();
|
|
1702
|
-
};
|
|
1703
|
-
}
|
|
1704
|
-
return getFactoryDef(type);
|
|
1705
|
-
}
|
|
1706
|
-
|
|
1707
1541
|
exports.EnvironmentInjector = EnvironmentInjector;
|
|
1708
1542
|
exports.INJECTOR_SCOPE = INJECTOR_SCOPE;
|
|
1709
1543
|
exports.Inject = Inject;
|
|
1710
|
-
exports.Injectable = Injectable;
|
|
1711
1544
|
exports.InjectionToken = InjectionToken;
|
|
1712
1545
|
exports.Injector = Injector;
|
|
1713
1546
|
exports.NG_INJ_DEF = NG_INJ_DEF;
|
|
@@ -1738,7 +1571,6 @@ exports.providerToFactory = providerToFactory;
|
|
|
1738
1571
|
exports.setCurrentInjector = setCurrentInjector;
|
|
1739
1572
|
exports.ɵɵdefineInjectable = ɵɵdefineInjectable;
|
|
1740
1573
|
exports.ɵɵdefineInjector = ɵɵdefineInjector;
|
|
1741
|
-
exports.ɵɵgetInheritedFactory = ɵɵgetInheritedFactory;
|
|
1742
1574
|
exports.ɵɵinject = ɵɵinject;
|
|
1743
1575
|
exports.ɵɵinvalidFactory = ɵɵinvalidFactory;
|
|
1744
1576
|
exports.ɵɵinvalidFactoryDep = ɵɵinvalidFactoryDep;
|
|
@@ -59,7 +59,11 @@ export function ɵɵdefineInjector(options) {
|
|
|
59
59
|
* @param type A type which may have its own (non-inherited) `ɵprov`.
|
|
60
60
|
*/
|
|
61
61
|
export function getInjectableDef(type) {
|
|
62
|
-
return getOwnDefinition(type, NG_PROV_DEF) ||
|
|
62
|
+
return (getOwnDefinition(type, NG_PROV_DEF) || {
|
|
63
|
+
token: type,
|
|
64
|
+
factory: () => new type(),
|
|
65
|
+
...type.injectOptions,
|
|
66
|
+
});
|
|
63
67
|
}
|
|
64
68
|
export function isInjectable(type) {
|
|
65
69
|
return getInjectableDef(type) !== null;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
/**
|
|
3
2
|
* @license
|
|
4
3
|
* Copyright Google LLC All Rights Reserved.
|
|
@@ -6,4 +5,6 @@
|
|
|
6
5
|
* Use of this source code is governed by an MIT-style license that can be
|
|
7
6
|
* found in the LICENSE file at https://angular.io/license
|
|
8
7
|
*/
|
|
9
|
-
|
|
8
|
+
export function getFactoryDef(type, throwNotFound) {
|
|
9
|
+
return () => new type();
|
|
10
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
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 { noSideEffects } from './closure';
|
|
9
|
+
export const PARAMETERS = '__parameters__';
|
|
10
|
+
function makeMetadataCtor(props) {
|
|
11
|
+
return function ctor(...args) {
|
|
12
|
+
if (props) {
|
|
13
|
+
const values = props(...args);
|
|
14
|
+
for (const propName in values) {
|
|
15
|
+
this[propName] = values[propName];
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
export function makeParamDecorator(name, props, parentClass) {
|
|
21
|
+
return noSideEffects(() => {
|
|
22
|
+
const metaCtor = makeMetadataCtor(props);
|
|
23
|
+
function ParamDecoratorFactory(...args) {
|
|
24
|
+
metaCtor.apply(this, args);
|
|
25
|
+
return this;
|
|
26
|
+
}
|
|
27
|
+
if (parentClass) {
|
|
28
|
+
}
|
|
29
|
+
return ParamDecoratorFactory;
|
|
30
|
+
});
|
|
31
|
+
}
|