static-injector 3.0.0 → 4.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/index.js +65 -43
- package/import/es2022/di/index.js +1 -0
- package/import/es2022/di/initializer_token.js +1 -1
- package/import/es2022/di/inject_switch.js +1 -2
- package/import/es2022/di/injection_token.js +2 -0
- package/import/es2022/di/injector.js +3 -3
- package/import/es2022/di/injector_compatibility.js +23 -0
- package/import/es2022/di/injector_token.js +2 -3
- package/import/es2022/di/internal_tokens.js +1 -1
- package/import/es2022/di/r3_injector.js +15 -14
- package/import/es2022/di/scope.js +1 -1
- package/import/es2022/di.js +24 -0
- package/import/es2022/render3/errors_di.js +2 -2
- package/import/es2022/render3/instructions/di.js +7 -0
- package/import/es2022/util/array_utils.js +7 -0
- package/import/es2022/util/stringify.js +1 -1
- package/import/fesm2022/index.js +59 -37
- package/import/typings/di/create_injector.d.ts +2 -2
- package/import/typings/di/forward_ref.d.ts +1 -1
- package/import/typings/di/index.d.ts +1 -0
- package/import/typings/di/injector.d.ts +3 -3
- package/import/typings/di/injector_compatibility.d.ts +2 -1
- package/import/typings/di/injector_token.d.ts +1 -1
- package/import/typings/di/interface/provider.d.ts +12 -12
- package/import/typings/di/metadata.d.ts +2 -2
- package/import/typings/di/null_injector.d.ts +1 -1
- package/import/typings/di/r3_injector.d.ts +1 -1
- package/import/typings/di.d.ts +24 -0
- package/import/typings/errors.d.ts +4 -1
- package/import/typings/render3/errors_di.d.ts +2 -1
- package/import/typings/render3/instructions/di.d.ts +7 -0
- package/import/typings/util/array_utils.d.ts +7 -0
- package/import/typings/util/empty.d.ts +1 -1
- package/import/typings/util/stringify.d.ts +1 -1
- package/package.json +7 -6
- package/transform/compiler/src/compiler.d.ts +0 -22
- package/transform/compiler/src/compiler.js +0 -26
- package/transform/compiler/src/core.d.ts +6 -0
- package/transform/compiler/src/core.js +13 -0
- package/transform/compiler/src/output/output_ast.d.ts +8 -6
- package/transform/compiler/src/output/output_ast.js +10 -6
- package/transform/compiler/src/render3/partial/api.d.ts +5 -0
- package/transform/compiler/src/render3/r3_identifiers.js +4 -0
- package/transform/compiler-cli/src/ngtsc/annotations/common/index.d.ts +0 -7
- package/transform/compiler-cli/src/ngtsc/annotations/common/index.js +0 -7
- package/transform/compiler-cli/src/ngtsc/annotations/common/src/di.d.ts +2 -3
- package/transform/compiler-cli/src/ngtsc/annotations/common/src/di.js +4 -31
- package/transform/compiler-cli/src/ngtsc/annotations/common/src/util.d.ts +3 -0
- package/transform/compiler-cli/src/ngtsc/annotations/common/src/util.js +14 -2
- package/transform/compiler-cli/src/ngtsc/annotations/src/injectable.js +5 -5
- package/transform/compiler-cli/src/ngtsc/diagnostics/index.d.ts +0 -7
- package/transform/compiler-cli/src/ngtsc/diagnostics/index.js +0 -7
- package/transform/compiler-cli/src/ngtsc/imports/index.d.ts +0 -7
- package/transform/compiler-cli/src/ngtsc/imports/index.js +0 -7
- package/transform/compiler-cli/src/ngtsc/reflection/index.d.ts +0 -7
- package/transform/compiler-cli/src/ngtsc/reflection/index.js +0 -7
- package/transform/compiler-cli/src/ngtsc/reflection/src/host.d.ts +7 -2
- package/transform/compiler-cli/src/ngtsc/reflection/src/host.js +3 -1
- package/transform/compiler-cli/src/ngtsc/reflection/src/type_to_value.d.ts +2 -1
- package/transform/compiler-cli/src/ngtsc/reflection/src/type_to_value.js +16 -5
- package/transform/compiler-cli/src/ngtsc/reflection/src/typescript.d.ts +4 -3
- package/transform/compiler-cli/src/ngtsc/reflection/src/typescript.js +25 -9
- package/transform/compiler-cli/src/ngtsc/transform/index.d.ts +0 -7
- package/transform/compiler-cli/src/ngtsc/transform/index.js +0 -7
- package/transform/compiler-cli/src/ngtsc/transform/src/utils.d.ts +1 -1
- package/transform/compiler-cli/src/ngtsc/transform/src/utils.js +35 -24
- package/transform/compiler-cli/src/ngtsc/translator/index.d.ts +0 -7
- package/transform/compiler-cli/src/ngtsc/translator/index.js +0 -7
- package/transform/compiler-cli/src/ngtsc/translator/src/api/ast_factory.d.ts +1 -1
- package/transform/compiler-cli/src/ngtsc/translator/src/import_manager.d.ts +21 -3
- package/transform/compiler-cli/src/ngtsc/translator/src/import_manager.js +13 -3
- package/transform/compiler-cli/src/ngtsc/translator/src/translator.js +1 -0
- package/transform/compiler-cli/src/ngtsc/translator/src/ts_util.d.ts +12 -0
- package/transform/compiler-cli/src/ngtsc/translator/src/ts_util.js +27 -0
- package/transform/compiler-cli/src/ngtsc/translator/src/typescript_ast_factory.js +3 -1
- package/transform/injectable-transform.js +1 -1
package/import/commonjs/index.js
CHANGED
|
@@ -168,7 +168,7 @@ function stringify(token) {
|
|
|
168
168
|
*
|
|
169
169
|
* @param string
|
|
170
170
|
* @param maxLength of the output string
|
|
171
|
-
* @returns
|
|
171
|
+
* @returns ellipsed string with ... in the middle
|
|
172
172
|
*/
|
|
173
173
|
function truncateMiddle(str, maxLength = 100) {
|
|
174
174
|
if (!str || maxLength < 1 || str.length <= maxLength)
|
|
@@ -283,8 +283,8 @@ function isForwardRef(fn) {
|
|
|
283
283
|
*/
|
|
284
284
|
/** Throws an error when a token is not found in DI. */
|
|
285
285
|
function throwProviderNotFoundError(token, injectorName) {
|
|
286
|
-
const
|
|
287
|
-
throw new RuntimeError(-201 /* RuntimeErrorCode.PROVIDER_NOT_FOUND */,
|
|
286
|
+
const errorMessage = null;
|
|
287
|
+
throw new RuntimeError(-201 /* RuntimeErrorCode.PROVIDER_NOT_FOUND */, errorMessage);
|
|
288
288
|
}
|
|
289
289
|
|
|
290
290
|
/**
|
|
@@ -466,7 +466,7 @@ function injectRootLimpMode(token, notFoundValue, flags) {
|
|
|
466
466
|
return null;
|
|
467
467
|
if (notFoundValue !== undefined)
|
|
468
468
|
return notFoundValue;
|
|
469
|
-
throwProviderNotFoundError(
|
|
469
|
+
throwProviderNotFoundError(token, 'Injector');
|
|
470
470
|
}
|
|
471
471
|
|
|
472
472
|
/**
|
|
@@ -531,6 +531,27 @@ function ɵɵinject(token, flags = exports.InjectFlags.Default) {
|
|
|
531
531
|
function ɵɵinvalidFactoryDep(index) {
|
|
532
532
|
throw new RuntimeError(202 /* RuntimeErrorCode.INVALID_FACTORY_DEPENDENCY */, null);
|
|
533
533
|
}
|
|
534
|
+
/**
|
|
535
|
+
* @param token A token that represents a static attribute on the host node that should be injected.
|
|
536
|
+
* @returns Value of the attribute if it exists.
|
|
537
|
+
* @throws If called outside of a supported context or the attribute does not exist.
|
|
538
|
+
*
|
|
539
|
+
* @publicApi
|
|
540
|
+
*/
|
|
541
|
+
/**
|
|
542
|
+
* @param token A token that represents a static attribute on the host node that should be injected.
|
|
543
|
+
* @returns Value of the attribute if it exists, otherwise `null`.
|
|
544
|
+
* @throws If called outside of a supported context.
|
|
545
|
+
*
|
|
546
|
+
* @publicApi
|
|
547
|
+
*/
|
|
548
|
+
/**
|
|
549
|
+
* @param token A token that represents a static attribute on the host node that should be injected.
|
|
550
|
+
* @returns Value of the attribute if it exists.
|
|
551
|
+
* @throws If called outside of a supported context or the attribute does not exist.
|
|
552
|
+
*
|
|
553
|
+
* @publicApi
|
|
554
|
+
*/
|
|
534
555
|
/**
|
|
535
556
|
* Injects a token from the currently active injector.
|
|
536
557
|
* `inject` is only supported in an [injection context](/guide/dependency-injection-context). It can
|
|
@@ -597,6 +618,8 @@ function ɵɵinvalidFactoryDep(index) {
|
|
|
597
618
|
* @publicApi
|
|
598
619
|
*/
|
|
599
620
|
function inject(token, flags = exports.InjectFlags.Default) {
|
|
621
|
+
// The `as any` here _shouldn't_ be necessary, but without it JSCompiler
|
|
622
|
+
// throws a disambiguation error due to the multiple signatures.
|
|
600
623
|
return ɵɵinject(token, convertToBitFlags(flags));
|
|
601
624
|
}
|
|
602
625
|
// Converts object-based DI flags (`InjectOptions`) to bit flags (`InjectFlags`).
|
|
@@ -791,17 +814,6 @@ function getFactoryDef(type, throwNotFound) {
|
|
|
791
814
|
return hasFactoryDef ? type[NG_FACTORY_DEF] : null;
|
|
792
815
|
}
|
|
793
816
|
|
|
794
|
-
function deepForEach(input, fn) {
|
|
795
|
-
input.forEach((value) => Array.isArray(value) ? deepForEach(value, fn) : fn(value));
|
|
796
|
-
}
|
|
797
|
-
function newArray(size, value) {
|
|
798
|
-
const list = [];
|
|
799
|
-
for (let i = 0; i < size; i++) {
|
|
800
|
-
list.push(value);
|
|
801
|
-
}
|
|
802
|
-
return list;
|
|
803
|
-
}
|
|
804
|
-
|
|
805
817
|
/**
|
|
806
818
|
* @license
|
|
807
819
|
* Copyright Google LLC All Rights Reserved.
|
|
@@ -892,6 +904,8 @@ class InjectionToken {
|
|
|
892
904
|
this._desc = _desc;
|
|
893
905
|
this.ɵprov = undefined;
|
|
894
906
|
if (typeof options == 'number') {
|
|
907
|
+
// This is a special hack to assign __NG_ELEMENT_ID__ to this instance.
|
|
908
|
+
// See `InjectorMarkers`
|
|
895
909
|
}
|
|
896
910
|
else if (options !== undefined) {
|
|
897
911
|
this.ɵprov = ɵɵdefineInjectable({
|
|
@@ -925,7 +939,7 @@ class InjectionToken {
|
|
|
925
939
|
*
|
|
926
940
|
* @publicApi
|
|
927
941
|
*/
|
|
928
|
-
const ENVIRONMENT_INITIALIZER = new InjectionToken('
|
|
942
|
+
const ENVIRONMENT_INITIALIZER = new InjectionToken('');
|
|
929
943
|
|
|
930
944
|
/**
|
|
931
945
|
* @license
|
|
@@ -942,11 +956,10 @@ const ENVIRONMENT_INITIALIZER = new InjectionToken('ENVIRONMENT_INITIALIZER');
|
|
|
942
956
|
*
|
|
943
957
|
* @publicApi
|
|
944
958
|
*/
|
|
945
|
-
const INJECTOR = new InjectionToken('
|
|
959
|
+
const INJECTOR = new InjectionToken('',
|
|
946
960
|
// Disable tslint because this is const enum which gets inlined not top level prop access.
|
|
947
961
|
// tslint:disable-next-line: no-toplevel-property-access
|
|
948
|
-
-1 /* InjectorMarkers.Injector */
|
|
949
|
-
);
|
|
962
|
+
-1 /* InjectorMarkers.Injector */);
|
|
950
963
|
|
|
951
964
|
/**
|
|
952
965
|
* @license
|
|
@@ -966,7 +979,7 @@ function isEnvironmentProviders(value) {
|
|
|
966
979
|
* Use of this source code is governed by an MIT-style license that can be
|
|
967
980
|
* found in the LICENSE file at https://angular.io/license
|
|
968
981
|
*/
|
|
969
|
-
const INJECTOR_DEF_TYPES = new InjectionToken('
|
|
982
|
+
const INJECTOR_DEF_TYPES = new InjectionToken('');
|
|
970
983
|
|
|
971
984
|
/**
|
|
972
985
|
* @license
|
|
@@ -1102,7 +1115,7 @@ function isClassProvider(value) {
|
|
|
1102
1115
|
* as a root scoped injector when processing requests for unknown tokens which may indicate
|
|
1103
1116
|
* they are provided in the root scope.
|
|
1104
1117
|
*/
|
|
1105
|
-
const INJECTOR_SCOPE = new InjectionToken('
|
|
1118
|
+
const INJECTOR_SCOPE = new InjectionToken('');
|
|
1106
1119
|
|
|
1107
1120
|
/**
|
|
1108
1121
|
* @license
|
|
@@ -1370,29 +1383,32 @@ class R3Injector extends EnvironmentInjector {
|
|
|
1370
1383
|
multiRecord.multi.push(provider);
|
|
1371
1384
|
}
|
|
1372
1385
|
else {
|
|
1373
|
-
const existing = this.records.get(token);
|
|
1374
1386
|
if (false) {
|
|
1375
1387
|
}
|
|
1376
1388
|
}
|
|
1377
1389
|
this.records.set(token, record);
|
|
1378
1390
|
}
|
|
1379
1391
|
hydrate(token, record) {
|
|
1380
|
-
|
|
1381
|
-
}
|
|
1382
|
-
else if (record.value === NOT_YET) {
|
|
1383
|
-
record.value = CIRCULAR;
|
|
1392
|
+
try {
|
|
1384
1393
|
if (false) {
|
|
1385
1394
|
}
|
|
1386
|
-
else {
|
|
1387
|
-
record.value =
|
|
1395
|
+
else if (record.value === NOT_YET) {
|
|
1396
|
+
record.value = CIRCULAR;
|
|
1397
|
+
if (false) {
|
|
1398
|
+
}
|
|
1399
|
+
else {
|
|
1400
|
+
record.value = record.factory();
|
|
1401
|
+
}
|
|
1402
|
+
}
|
|
1403
|
+
if (typeof record.value === 'object' &&
|
|
1404
|
+
record.value &&
|
|
1405
|
+
hasOnDestroy(record.value)) {
|
|
1406
|
+
this._ngOnDestroyHooks.add(record.value);
|
|
1388
1407
|
}
|
|
1408
|
+
return record.value;
|
|
1389
1409
|
}
|
|
1390
|
-
|
|
1391
|
-
record.value &&
|
|
1392
|
-
hasOnDestroy(record.value)) {
|
|
1393
|
-
this._ngOnDestroyHooks.add(record.value);
|
|
1410
|
+
finally {
|
|
1394
1411
|
}
|
|
1395
|
-
return record.value;
|
|
1396
1412
|
}
|
|
1397
1413
|
injectableDefInScope(def) {
|
|
1398
1414
|
if (!def.providedIn) {
|
|
@@ -1436,7 +1452,6 @@ function getUndecoratedInjectableFactory(token) {
|
|
|
1436
1452
|
// If the token has parameters then it has dependencies that we cannot resolve implicitly.
|
|
1437
1453
|
const paramLength = token.length;
|
|
1438
1454
|
if (paramLength > 0) {
|
|
1439
|
-
const args = newArray(paramLength, '?');
|
|
1440
1455
|
throw new RuntimeError(204 /* RuntimeErrorCode.INVALID_INJECTION_TOKEN */, null);
|
|
1441
1456
|
}
|
|
1442
1457
|
// The constructor function appears to have no parameters.
|
|
@@ -1572,10 +1587,10 @@ function createInjectorWithoutInjectorInstances(defType, parent = null, addition
|
|
|
1572
1587
|
*/
|
|
1573
1588
|
/**
|
|
1574
1589
|
* Concrete injectors implement this interface. Injectors are configured
|
|
1575
|
-
* with [providers](guide/
|
|
1576
|
-
* dependencies of various types with [injection tokens](guide/
|
|
1590
|
+
* with [providers](guide/dependency-injection-providers) that associate
|
|
1591
|
+
* dependencies of various types with [injection tokens](guide/dependency-injection-providers).
|
|
1577
1592
|
*
|
|
1578
|
-
* @see [
|
|
1593
|
+
* @see [DI Providers](guide/dependency-injection-providers).
|
|
1579
1594
|
* @see {@link StaticProvider}
|
|
1580
1595
|
*
|
|
1581
1596
|
* @usageNotes
|
|
@@ -1619,6 +1634,13 @@ class Injector {
|
|
|
1619
1634
|
static __NG_ELEMENT_ID__ = -1 /* InjectorMarkers.Injector */;
|
|
1620
1635
|
}
|
|
1621
1636
|
|
|
1637
|
+
/**
|
|
1638
|
+
* @license
|
|
1639
|
+
* Copyright Google LLC All Rights Reserved.
|
|
1640
|
+
*
|
|
1641
|
+
* Use of this source code is governed by an MIT-style license that can be
|
|
1642
|
+
* found in the LICENSE file at https://angular.io/license
|
|
1643
|
+
*/
|
|
1622
1644
|
/**
|
|
1623
1645
|
* Throws an error indicating that a factory function could not be generated by the compiler for a
|
|
1624
1646
|
* particular class.
|
|
@@ -1714,9 +1736,9 @@ exports.injectInjectorOnly = injectInjectorOnly;
|
|
|
1714
1736
|
exports.isInjectable = isInjectable;
|
|
1715
1737
|
exports.providerToFactory = providerToFactory;
|
|
1716
1738
|
exports.setCurrentInjector = setCurrentInjector;
|
|
1717
|
-
exports
|
|
1718
|
-
exports
|
|
1719
|
-
exports
|
|
1720
|
-
exports
|
|
1721
|
-
exports
|
|
1722
|
-
exports
|
|
1739
|
+
exports.ɵɵdefineInjectable = ɵɵdefineInjectable;
|
|
1740
|
+
exports.ɵɵdefineInjector = ɵɵdefineInjector;
|
|
1741
|
+
exports.ɵɵgetInheritedFactory = ɵɵgetInheritedFactory;
|
|
1742
|
+
exports.ɵɵinject = ɵɵinject;
|
|
1743
|
+
exports.ɵɵinvalidFactory = ɵɵinvalidFactory;
|
|
1744
|
+
exports.ɵɵinvalidFactoryDep = ɵɵinvalidFactoryDep;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -6,7 +6,6 @@
|
|
|
6
6
|
* found in the LICENSE file at https://angular.io/license
|
|
7
7
|
*/
|
|
8
8
|
import { throwProviderNotFoundError } from '../render3/errors_di';
|
|
9
|
-
import { stringify } from '../util/stringify';
|
|
10
9
|
import { getInjectableDef } from './interface/defs';
|
|
11
10
|
import { InjectFlags } from './interface/injector';
|
|
12
11
|
/**
|
|
@@ -48,5 +47,5 @@ export function injectRootLimpMode(token, notFoundValue, flags) {
|
|
|
48
47
|
return null;
|
|
49
48
|
if (notFoundValue !== undefined)
|
|
50
49
|
return notFoundValue;
|
|
51
|
-
throwProviderNotFoundError(
|
|
50
|
+
throwProviderNotFoundError(token, 'Injector');
|
|
52
51
|
}
|
|
@@ -70,6 +70,8 @@ export class InjectionToken {
|
|
|
70
70
|
this._desc = _desc;
|
|
71
71
|
this.ɵprov = undefined;
|
|
72
72
|
if (typeof options == 'number') {
|
|
73
|
+
// This is a special hack to assign __NG_ELEMENT_ID__ to this instance.
|
|
74
|
+
// See `InjectorMarkers`
|
|
73
75
|
}
|
|
74
76
|
else if (options !== undefined) {
|
|
75
77
|
this.ɵprov = ɵɵdefineInjectable({
|
|
@@ -12,10 +12,10 @@ import { ɵɵdefineInjectable } from './interface/defs';
|
|
|
12
12
|
import { NullInjector } from './null_injector';
|
|
13
13
|
/**
|
|
14
14
|
* Concrete injectors implement this interface. Injectors are configured
|
|
15
|
-
* with [providers](guide/
|
|
16
|
-
* dependencies of various types with [injection tokens](guide/
|
|
15
|
+
* with [providers](guide/dependency-injection-providers) that associate
|
|
16
|
+
* dependencies of various types with [injection tokens](guide/dependency-injection-providers).
|
|
17
17
|
*
|
|
18
|
-
* @see [
|
|
18
|
+
* @see [DI Providers](guide/dependency-injection-providers).
|
|
19
19
|
* @see {@link StaticProvider}
|
|
20
20
|
*
|
|
21
21
|
* @usageNotes
|
|
@@ -65,6 +65,27 @@ export function ɵɵinject(token, flags = InjectFlags.Default) {
|
|
|
65
65
|
export function ɵɵinvalidFactoryDep(index) {
|
|
66
66
|
throw new RuntimeError(202 /* RuntimeErrorCode.INVALID_FACTORY_DEPENDENCY */, null);
|
|
67
67
|
}
|
|
68
|
+
/**
|
|
69
|
+
* @param token A token that represents a static attribute on the host node that should be injected.
|
|
70
|
+
* @returns Value of the attribute if it exists.
|
|
71
|
+
* @throws If called outside of a supported context or the attribute does not exist.
|
|
72
|
+
*
|
|
73
|
+
* @publicApi
|
|
74
|
+
*/
|
|
75
|
+
/**
|
|
76
|
+
* @param token A token that represents a static attribute on the host node that should be injected.
|
|
77
|
+
* @returns Value of the attribute if it exists, otherwise `null`.
|
|
78
|
+
* @throws If called outside of a supported context.
|
|
79
|
+
*
|
|
80
|
+
* @publicApi
|
|
81
|
+
*/
|
|
82
|
+
/**
|
|
83
|
+
* @param token A token that represents a static attribute on the host node that should be injected.
|
|
84
|
+
* @returns Value of the attribute if it exists.
|
|
85
|
+
* @throws If called outside of a supported context or the attribute does not exist.
|
|
86
|
+
*
|
|
87
|
+
* @publicApi
|
|
88
|
+
*/
|
|
68
89
|
/**
|
|
69
90
|
* Injects a token from the currently active injector.
|
|
70
91
|
* `inject` is only supported in an [injection context](/guide/dependency-injection-context). It can
|
|
@@ -131,6 +152,8 @@ export function ɵɵinvalidFactoryDep(index) {
|
|
|
131
152
|
* @publicApi
|
|
132
153
|
*/
|
|
133
154
|
export function inject(token, flags = InjectFlags.Default) {
|
|
155
|
+
// The `as any` here _shouldn't_ be necessary, but without it JSCompiler
|
|
156
|
+
// throws a disambiguation error due to the multiple signatures.
|
|
134
157
|
return ɵɵinject(token, convertToBitFlags(flags));
|
|
135
158
|
}
|
|
136
159
|
// Converts object-based DI flags (`InjectOptions`) to bit flags (`InjectFlags`).
|
|
@@ -14,8 +14,7 @@ import { InjectionToken } from './injection_token';
|
|
|
14
14
|
*
|
|
15
15
|
* @publicApi
|
|
16
16
|
*/
|
|
17
|
-
export const INJECTOR = new InjectionToken('
|
|
17
|
+
export const INJECTOR = new InjectionToken('',
|
|
18
18
|
// Disable tslint because this is const enum which gets inlined not top level prop access.
|
|
19
19
|
// tslint:disable-next-line: no-toplevel-property-access
|
|
20
|
-
-1 /* InjectorMarkers.Injector */
|
|
21
|
-
);
|
|
20
|
+
-1 /* InjectorMarkers.Injector */);
|
|
@@ -8,7 +8,6 @@
|
|
|
8
8
|
import { RuntimeError } from '../errors';
|
|
9
9
|
import { getFactoryDef } from '../render3/definition_factory';
|
|
10
10
|
import { NG_ENV_ID } from '../render3/fields';
|
|
11
|
-
import { newArray } from '../util/array_utils';
|
|
12
11
|
import { EMPTY_ARRAY } from '../util/empty';
|
|
13
12
|
import { stringify } from '../util/stringify';
|
|
14
13
|
import { resolveForwardRef } from './forward_ref';
|
|
@@ -283,29 +282,32 @@ export class R3Injector extends EnvironmentInjector {
|
|
|
283
282
|
multiRecord.multi.push(provider);
|
|
284
283
|
}
|
|
285
284
|
else {
|
|
286
|
-
const existing = this.records.get(token);
|
|
287
285
|
if (false) {
|
|
288
286
|
}
|
|
289
287
|
}
|
|
290
288
|
this.records.set(token, record);
|
|
291
289
|
}
|
|
292
290
|
hydrate(token, record) {
|
|
293
|
-
|
|
294
|
-
}
|
|
295
|
-
else if (record.value === NOT_YET) {
|
|
296
|
-
record.value = CIRCULAR;
|
|
291
|
+
try {
|
|
297
292
|
if (false) {
|
|
298
293
|
}
|
|
299
|
-
else {
|
|
300
|
-
record.value =
|
|
294
|
+
else if (record.value === NOT_YET) {
|
|
295
|
+
record.value = CIRCULAR;
|
|
296
|
+
if (false) {
|
|
297
|
+
}
|
|
298
|
+
else {
|
|
299
|
+
record.value = record.factory();
|
|
300
|
+
}
|
|
301
301
|
}
|
|
302
|
+
if (typeof record.value === 'object' &&
|
|
303
|
+
record.value &&
|
|
304
|
+
hasOnDestroy(record.value)) {
|
|
305
|
+
this._ngOnDestroyHooks.add(record.value);
|
|
306
|
+
}
|
|
307
|
+
return record.value;
|
|
302
308
|
}
|
|
303
|
-
|
|
304
|
-
record.value &&
|
|
305
|
-
hasOnDestroy(record.value)) {
|
|
306
|
-
this._ngOnDestroyHooks.add(record.value);
|
|
309
|
+
finally {
|
|
307
310
|
}
|
|
308
|
-
return record.value;
|
|
309
311
|
}
|
|
310
312
|
injectableDefInScope(def) {
|
|
311
313
|
if (!def.providedIn) {
|
|
@@ -349,7 +351,6 @@ function getUndecoratedInjectableFactory(token) {
|
|
|
349
351
|
// If the token has parameters then it has dependencies that we cannot resolve implicitly.
|
|
350
352
|
const paramLength = token.length;
|
|
351
353
|
if (paramLength > 0) {
|
|
352
|
-
const args = newArray(paramLength, '?');
|
|
353
354
|
throw new RuntimeError(204 /* RuntimeErrorCode.INVALID_INJECTION_TOKEN */, null);
|
|
354
355
|
}
|
|
355
356
|
// The constructor function appears to have no parameters.
|
|
@@ -11,4 +11,4 @@ import { InjectionToken } from './injection_token';
|
|
|
11
11
|
* as a root scoped injector when processing requests for unknown tokens which may indicate
|
|
12
12
|
* they are provided in the root scope.
|
|
13
13
|
*/
|
|
14
|
-
export const INJECTOR_SCOPE = new InjectionToken('
|
|
14
|
+
export const INJECTOR_SCOPE = new InjectionToken('');
|
|
@@ -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
|
+
/**
|
|
9
|
+
* This file should not be necessary because node resolution should just default to `./di/index`!
|
|
10
|
+
*
|
|
11
|
+
* However it does not seem to work and it breaks:
|
|
12
|
+
* - //packages/animations/browser/test:test_web_chromium-local
|
|
13
|
+
* - //packages/compiler-cli/test:extract_i18n
|
|
14
|
+
* - //packages/compiler-cli/test:ngc
|
|
15
|
+
* - //packages/compiler-cli/test:perform_watch
|
|
16
|
+
* - //packages/compiler-cli/test/diagnostics:check_types
|
|
17
|
+
* - //packages/compiler-cli/test/transformers:test
|
|
18
|
+
* - //packages/compiler/test:test
|
|
19
|
+
* - //tools/public_api_guard:core_api
|
|
20
|
+
*
|
|
21
|
+
* Remove this file once the above is solved or wait until `ngc` is deleted and then it should be
|
|
22
|
+
* safe to delete this file.
|
|
23
|
+
*/
|
|
24
|
+
export * from './di/index';
|
|
@@ -8,6 +8,6 @@
|
|
|
8
8
|
import { RuntimeError } from '../errors';
|
|
9
9
|
/** Throws an error when a token is not found in DI. */
|
|
10
10
|
export function throwProviderNotFoundError(token, injectorName) {
|
|
11
|
-
const
|
|
12
|
-
throw new RuntimeError(-201 /* RuntimeErrorCode.PROVIDER_NOT_FOUND */,
|
|
11
|
+
const errorMessage = null;
|
|
12
|
+
throw new RuntimeError(-201 /* RuntimeErrorCode.PROVIDER_NOT_FOUND */, errorMessage);
|
|
13
13
|
}
|
|
@@ -1,3 +1,10 @@
|
|
|
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
|
+
*/
|
|
1
8
|
/**
|
|
2
9
|
* Throws an error indicating that a factory function could not be generated by the compiler for a
|
|
3
10
|
* particular class.
|
|
@@ -1,3 +1,10 @@
|
|
|
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
|
+
*/
|
|
1
8
|
export function deepForEach(input, fn) {
|
|
2
9
|
input.forEach((value) => Array.isArray(value) ? deepForEach(value, fn) : fn(value));
|
|
3
10
|
}
|
|
@@ -33,7 +33,7 @@ export function stringify(token) {
|
|
|
33
33
|
*
|
|
34
34
|
* @param string
|
|
35
35
|
* @param maxLength of the output string
|
|
36
|
-
* @returns
|
|
36
|
+
* @returns ellipsed string with ... in the middle
|
|
37
37
|
*/
|
|
38
38
|
export function truncateMiddle(str, maxLength = 100) {
|
|
39
39
|
if (!str || maxLength < 1 || str.length <= maxLength)
|