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/fesm2022/index.js
CHANGED
|
@@ -166,7 +166,7 @@ function stringify(token) {
|
|
|
166
166
|
*
|
|
167
167
|
* @param string
|
|
168
168
|
* @param maxLength of the output string
|
|
169
|
-
* @returns
|
|
169
|
+
* @returns ellipsed string with ... in the middle
|
|
170
170
|
*/
|
|
171
171
|
function truncateMiddle(str, maxLength = 100) {
|
|
172
172
|
if (!str || maxLength < 1 || str.length <= maxLength)
|
|
@@ -281,8 +281,8 @@ function isForwardRef(fn) {
|
|
|
281
281
|
*/
|
|
282
282
|
/** Throws an error when a token is not found in DI. */
|
|
283
283
|
function throwProviderNotFoundError(token, injectorName) {
|
|
284
|
-
const
|
|
285
|
-
throw new RuntimeError(-201 /* RuntimeErrorCode.PROVIDER_NOT_FOUND */,
|
|
284
|
+
const errorMessage = null;
|
|
285
|
+
throw new RuntimeError(-201 /* RuntimeErrorCode.PROVIDER_NOT_FOUND */, errorMessage);
|
|
286
286
|
}
|
|
287
287
|
|
|
288
288
|
/**
|
|
@@ -464,7 +464,7 @@ function injectRootLimpMode(token, notFoundValue, flags) {
|
|
|
464
464
|
return null;
|
|
465
465
|
if (notFoundValue !== undefined)
|
|
466
466
|
return notFoundValue;
|
|
467
|
-
throwProviderNotFoundError(
|
|
467
|
+
throwProviderNotFoundError(token, 'Injector');
|
|
468
468
|
}
|
|
469
469
|
|
|
470
470
|
/**
|
|
@@ -529,6 +529,27 @@ function ɵɵinject(token, flags = InjectFlags.Default) {
|
|
|
529
529
|
function ɵɵinvalidFactoryDep(index) {
|
|
530
530
|
throw new RuntimeError(202 /* RuntimeErrorCode.INVALID_FACTORY_DEPENDENCY */, null);
|
|
531
531
|
}
|
|
532
|
+
/**
|
|
533
|
+
* @param token A token that represents a static attribute on the host node that should be injected.
|
|
534
|
+
* @returns Value of the attribute if it exists.
|
|
535
|
+
* @throws If called outside of a supported context or the attribute does not exist.
|
|
536
|
+
*
|
|
537
|
+
* @publicApi
|
|
538
|
+
*/
|
|
539
|
+
/**
|
|
540
|
+
* @param token A token that represents a static attribute on the host node that should be injected.
|
|
541
|
+
* @returns Value of the attribute if it exists, otherwise `null`.
|
|
542
|
+
* @throws If called outside of a supported context.
|
|
543
|
+
*
|
|
544
|
+
* @publicApi
|
|
545
|
+
*/
|
|
546
|
+
/**
|
|
547
|
+
* @param token A token that represents a static attribute on the host node that should be injected.
|
|
548
|
+
* @returns Value of the attribute if it exists.
|
|
549
|
+
* @throws If called outside of a supported context or the attribute does not exist.
|
|
550
|
+
*
|
|
551
|
+
* @publicApi
|
|
552
|
+
*/
|
|
532
553
|
/**
|
|
533
554
|
* Injects a token from the currently active injector.
|
|
534
555
|
* `inject` is only supported in an [injection context](/guide/dependency-injection-context). It can
|
|
@@ -595,6 +616,8 @@ function ɵɵinvalidFactoryDep(index) {
|
|
|
595
616
|
* @publicApi
|
|
596
617
|
*/
|
|
597
618
|
function inject(token, flags = InjectFlags.Default) {
|
|
619
|
+
// The `as any` here _shouldn't_ be necessary, but without it JSCompiler
|
|
620
|
+
// throws a disambiguation error due to the multiple signatures.
|
|
598
621
|
return ɵɵinject(token, convertToBitFlags(flags));
|
|
599
622
|
}
|
|
600
623
|
// Converts object-based DI flags (`InjectOptions`) to bit flags (`InjectFlags`).
|
|
@@ -789,17 +812,6 @@ function getFactoryDef(type, throwNotFound) {
|
|
|
789
812
|
return hasFactoryDef ? type[NG_FACTORY_DEF] : null;
|
|
790
813
|
}
|
|
791
814
|
|
|
792
|
-
function deepForEach(input, fn) {
|
|
793
|
-
input.forEach((value) => Array.isArray(value) ? deepForEach(value, fn) : fn(value));
|
|
794
|
-
}
|
|
795
|
-
function newArray(size, value) {
|
|
796
|
-
const list = [];
|
|
797
|
-
for (let i = 0; i < size; i++) {
|
|
798
|
-
list.push(value);
|
|
799
|
-
}
|
|
800
|
-
return list;
|
|
801
|
-
}
|
|
802
|
-
|
|
803
815
|
/**
|
|
804
816
|
* @license
|
|
805
817
|
* Copyright Google LLC All Rights Reserved.
|
|
@@ -890,6 +902,8 @@ class InjectionToken {
|
|
|
890
902
|
this._desc = _desc;
|
|
891
903
|
this.ɵprov = undefined;
|
|
892
904
|
if (typeof options == 'number') {
|
|
905
|
+
// This is a special hack to assign __NG_ELEMENT_ID__ to this instance.
|
|
906
|
+
// See `InjectorMarkers`
|
|
893
907
|
}
|
|
894
908
|
else if (options !== undefined) {
|
|
895
909
|
this.ɵprov = ɵɵdefineInjectable({
|
|
@@ -923,7 +937,7 @@ class InjectionToken {
|
|
|
923
937
|
*
|
|
924
938
|
* @publicApi
|
|
925
939
|
*/
|
|
926
|
-
const ENVIRONMENT_INITIALIZER = new InjectionToken('
|
|
940
|
+
const ENVIRONMENT_INITIALIZER = new InjectionToken('');
|
|
927
941
|
|
|
928
942
|
/**
|
|
929
943
|
* @license
|
|
@@ -940,11 +954,10 @@ const ENVIRONMENT_INITIALIZER = new InjectionToken('ENVIRONMENT_INITIALIZER');
|
|
|
940
954
|
*
|
|
941
955
|
* @publicApi
|
|
942
956
|
*/
|
|
943
|
-
const INJECTOR = new InjectionToken('
|
|
957
|
+
const INJECTOR = new InjectionToken('',
|
|
944
958
|
// Disable tslint because this is const enum which gets inlined not top level prop access.
|
|
945
959
|
// tslint:disable-next-line: no-toplevel-property-access
|
|
946
|
-
-1 /* InjectorMarkers.Injector */
|
|
947
|
-
);
|
|
960
|
+
-1 /* InjectorMarkers.Injector */);
|
|
948
961
|
|
|
949
962
|
/**
|
|
950
963
|
* @license
|
|
@@ -964,7 +977,7 @@ function isEnvironmentProviders(value) {
|
|
|
964
977
|
* Use of this source code is governed by an MIT-style license that can be
|
|
965
978
|
* found in the LICENSE file at https://angular.io/license
|
|
966
979
|
*/
|
|
967
|
-
const INJECTOR_DEF_TYPES = new InjectionToken('
|
|
980
|
+
const INJECTOR_DEF_TYPES = new InjectionToken('');
|
|
968
981
|
|
|
969
982
|
/**
|
|
970
983
|
* @license
|
|
@@ -1100,7 +1113,7 @@ function isClassProvider(value) {
|
|
|
1100
1113
|
* as a root scoped injector when processing requests for unknown tokens which may indicate
|
|
1101
1114
|
* they are provided in the root scope.
|
|
1102
1115
|
*/
|
|
1103
|
-
const INJECTOR_SCOPE = new InjectionToken('
|
|
1116
|
+
const INJECTOR_SCOPE = new InjectionToken('');
|
|
1104
1117
|
|
|
1105
1118
|
/**
|
|
1106
1119
|
* @license
|
|
@@ -1368,29 +1381,32 @@ class R3Injector extends EnvironmentInjector {
|
|
|
1368
1381
|
multiRecord.multi.push(provider);
|
|
1369
1382
|
}
|
|
1370
1383
|
else {
|
|
1371
|
-
const existing = this.records.get(token);
|
|
1372
1384
|
if (false) {
|
|
1373
1385
|
}
|
|
1374
1386
|
}
|
|
1375
1387
|
this.records.set(token, record);
|
|
1376
1388
|
}
|
|
1377
1389
|
hydrate(token, record) {
|
|
1378
|
-
|
|
1379
|
-
}
|
|
1380
|
-
else if (record.value === NOT_YET) {
|
|
1381
|
-
record.value = CIRCULAR;
|
|
1390
|
+
try {
|
|
1382
1391
|
if (false) {
|
|
1383
1392
|
}
|
|
1384
|
-
else {
|
|
1385
|
-
record.value =
|
|
1393
|
+
else if (record.value === NOT_YET) {
|
|
1394
|
+
record.value = CIRCULAR;
|
|
1395
|
+
if (false) {
|
|
1396
|
+
}
|
|
1397
|
+
else {
|
|
1398
|
+
record.value = record.factory();
|
|
1399
|
+
}
|
|
1400
|
+
}
|
|
1401
|
+
if (typeof record.value === 'object' &&
|
|
1402
|
+
record.value &&
|
|
1403
|
+
hasOnDestroy(record.value)) {
|
|
1404
|
+
this._ngOnDestroyHooks.add(record.value);
|
|
1386
1405
|
}
|
|
1406
|
+
return record.value;
|
|
1387
1407
|
}
|
|
1388
|
-
|
|
1389
|
-
record.value &&
|
|
1390
|
-
hasOnDestroy(record.value)) {
|
|
1391
|
-
this._ngOnDestroyHooks.add(record.value);
|
|
1408
|
+
finally {
|
|
1392
1409
|
}
|
|
1393
|
-
return record.value;
|
|
1394
1410
|
}
|
|
1395
1411
|
injectableDefInScope(def) {
|
|
1396
1412
|
if (!def.providedIn) {
|
|
@@ -1434,7 +1450,6 @@ function getUndecoratedInjectableFactory(token) {
|
|
|
1434
1450
|
// If the token has parameters then it has dependencies that we cannot resolve implicitly.
|
|
1435
1451
|
const paramLength = token.length;
|
|
1436
1452
|
if (paramLength > 0) {
|
|
1437
|
-
const args = newArray(paramLength, '?');
|
|
1438
1453
|
throw new RuntimeError(204 /* RuntimeErrorCode.INVALID_INJECTION_TOKEN */, null);
|
|
1439
1454
|
}
|
|
1440
1455
|
// The constructor function appears to have no parameters.
|
|
@@ -1570,10 +1585,10 @@ function createInjectorWithoutInjectorInstances(defType, parent = null, addition
|
|
|
1570
1585
|
*/
|
|
1571
1586
|
/**
|
|
1572
1587
|
* Concrete injectors implement this interface. Injectors are configured
|
|
1573
|
-
* with [providers](guide/
|
|
1574
|
-
* dependencies of various types with [injection tokens](guide/
|
|
1588
|
+
* with [providers](guide/dependency-injection-providers) that associate
|
|
1589
|
+
* dependencies of various types with [injection tokens](guide/dependency-injection-providers).
|
|
1575
1590
|
*
|
|
1576
|
-
* @see [
|
|
1591
|
+
* @see [DI Providers](guide/dependency-injection-providers).
|
|
1577
1592
|
* @see {@link StaticProvider}
|
|
1578
1593
|
*
|
|
1579
1594
|
* @usageNotes
|
|
@@ -1617,6 +1632,13 @@ class Injector {
|
|
|
1617
1632
|
static __NG_ELEMENT_ID__ = -1 /* InjectorMarkers.Injector */;
|
|
1618
1633
|
}
|
|
1619
1634
|
|
|
1635
|
+
/**
|
|
1636
|
+
* @license
|
|
1637
|
+
* Copyright Google LLC All Rights Reserved.
|
|
1638
|
+
*
|
|
1639
|
+
* Use of this source code is governed by an MIT-style license that can be
|
|
1640
|
+
* found in the LICENSE file at https://angular.io/license
|
|
1641
|
+
*/
|
|
1620
1642
|
/**
|
|
1621
1643
|
* Throws an error indicating that a factory function could not be generated by the compiler for a
|
|
1622
1644
|
* particular class.
|
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
* Use of this source code is governed by an MIT-style license that can be
|
|
6
6
|
* found in the LICENSE file at https://angular.io/license
|
|
7
7
|
*/
|
|
8
|
-
import { Injector } from './injector';
|
|
9
|
-
import { Provider, StaticProvider } from './interface/provider';
|
|
8
|
+
import type { Injector } from './injector';
|
|
9
|
+
import type { Provider, StaticProvider } from './interface/provider';
|
|
10
10
|
import { R3Injector } from './r3_injector';
|
|
11
11
|
import { InjectorScope } from './scope';
|
|
12
12
|
/**
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { ProviderToken } from './provider_token';
|
|
@@ -11,10 +11,10 @@ import { Provider, StaticProvider } from './interface/provider';
|
|
|
11
11
|
import { ProviderToken } from './provider_token';
|
|
12
12
|
/**
|
|
13
13
|
* Concrete injectors implement this interface. Injectors are configured
|
|
14
|
-
* with [providers](guide/
|
|
15
|
-
* dependencies of various types with [injection tokens](guide/
|
|
14
|
+
* with [providers](guide/dependency-injection-providers) that associate
|
|
15
|
+
* dependencies of various types with [injection tokens](guide/dependency-injection-providers).
|
|
16
16
|
*
|
|
17
|
-
* @see [
|
|
17
|
+
* @see [DI Providers](guide/dependency-injection-providers).
|
|
18
18
|
* @see {@link StaticProvider}
|
|
19
19
|
*
|
|
20
20
|
* @usageNotes
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* Use of this source code is governed by an MIT-style license that can be
|
|
6
6
|
* found in the LICENSE file at https://angular.io/license
|
|
7
7
|
*/
|
|
8
|
-
import { Injector } from './injector';
|
|
8
|
+
import type { Injector } from './injector';
|
|
9
9
|
import { DecoratorFlags, InjectFlags, InjectOptions, InternalInjectFlags } from './interface/injector';
|
|
10
10
|
import { ProviderToken } from './provider_token';
|
|
11
11
|
export declare const THROW_IF_NOT_FOUND: {};
|
|
@@ -27,6 +27,7 @@ export declare function injectInjectorOnly<T>(token: ProviderToken<T>, flags?: I
|
|
|
27
27
|
*/
|
|
28
28
|
export declare function ɵɵinject<T>(token: ProviderToken<T>): T;
|
|
29
29
|
export declare function ɵɵinject<T>(token: ProviderToken<T>, flags?: InjectFlags): T | null;
|
|
30
|
+
export declare function ɵɵinject<T>(token: ProviderToken<T>, flags?: InjectFlags): string | null;
|
|
30
31
|
/**
|
|
31
32
|
* Throws an error indicating that a factory function could not be generated by the compiler for a
|
|
32
33
|
* particular class.
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* found in the LICENSE file at https://angular.io/license
|
|
7
7
|
*/
|
|
8
8
|
import { InjectionToken } from './injection_token';
|
|
9
|
-
import { Injector } from './injector';
|
|
9
|
+
import type { Injector } from './injector';
|
|
10
10
|
/**
|
|
11
11
|
* An InjectionToken that gets the current `Injector` for `createInjector()`-style injectors.
|
|
12
12
|
*
|
|
@@ -20,7 +20,7 @@ export interface ValueSansProvider {
|
|
|
20
20
|
}
|
|
21
21
|
/**
|
|
22
22
|
* Configures the `Injector` to return a value for a token.
|
|
23
|
-
* @see [
|
|
23
|
+
* @see [Dependency Injection Guide](guide/dependency-injection).
|
|
24
24
|
*
|
|
25
25
|
* @usageNotes
|
|
26
26
|
*
|
|
@@ -65,7 +65,7 @@ export interface StaticClassSansProvider {
|
|
|
65
65
|
}
|
|
66
66
|
/**
|
|
67
67
|
* Configures the `Injector` to return an instance of `useClass` for a token.
|
|
68
|
-
* @see [
|
|
68
|
+
* @see [Dependency Injection Guide](guide/dependency-injection).
|
|
69
69
|
*
|
|
70
70
|
* @usageNotes
|
|
71
71
|
*
|
|
@@ -95,7 +95,7 @@ export interface StaticClassProvider extends StaticClassSansProvider {
|
|
|
95
95
|
/**
|
|
96
96
|
* Configures the `Injector` to return an instance of a token.
|
|
97
97
|
*
|
|
98
|
-
* @see [
|
|
98
|
+
* @see [Dependency Injection Guide](guide/dependency-injection).
|
|
99
99
|
*
|
|
100
100
|
* @usageNotes
|
|
101
101
|
*
|
|
@@ -115,7 +115,7 @@ export interface ConstructorSansProvider {
|
|
|
115
115
|
/**
|
|
116
116
|
* Configures the `Injector` to return an instance of a token.
|
|
117
117
|
*
|
|
118
|
-
* @see [
|
|
118
|
+
* @see [Dependency Injection Guide](guide/dependency-injection).
|
|
119
119
|
*
|
|
120
120
|
* @usageNotes
|
|
121
121
|
*
|
|
@@ -142,7 +142,7 @@ export interface ConstructorProvider extends ConstructorSansProvider {
|
|
|
142
142
|
* Configures the `Injector` to return a value of another `useExisting` token.
|
|
143
143
|
*
|
|
144
144
|
* @see {@link ExistingProvider}
|
|
145
|
-
* @see [
|
|
145
|
+
* @see [Dependency Injection Guide](guide/dependency-injection).
|
|
146
146
|
*
|
|
147
147
|
* @publicApi
|
|
148
148
|
*/
|
|
@@ -155,7 +155,7 @@ export interface ExistingSansProvider {
|
|
|
155
155
|
/**
|
|
156
156
|
* Configures the `Injector` to return a value of another `useExisting` token.
|
|
157
157
|
*
|
|
158
|
-
* @see [
|
|
158
|
+
* @see [Dependency Injection Guide](guide/dependency-injection).
|
|
159
159
|
*
|
|
160
160
|
* @usageNotes
|
|
161
161
|
*
|
|
@@ -182,7 +182,7 @@ export interface ExistingProvider extends ExistingSansProvider {
|
|
|
182
182
|
* Configures the `Injector` to return a value by invoking a `useFactory` function.
|
|
183
183
|
*
|
|
184
184
|
* @see {@link FactoryProvider}
|
|
185
|
-
* @see [
|
|
185
|
+
* @see [Dependency Injection Guide](guide/dependency-injection).
|
|
186
186
|
*
|
|
187
187
|
* @publicApi
|
|
188
188
|
*/
|
|
@@ -200,7 +200,7 @@ export interface FactorySansProvider {
|
|
|
200
200
|
}
|
|
201
201
|
/**
|
|
202
202
|
* Configures the `Injector` to return a value by invoking a `useFactory` function.
|
|
203
|
-
* @see [
|
|
203
|
+
* @see [Dependency Injection Guide](guide/dependency-injection).
|
|
204
204
|
*
|
|
205
205
|
* @usageNotes
|
|
206
206
|
*
|
|
@@ -232,7 +232,7 @@ export interface FactoryProvider extends FactorySansProvider {
|
|
|
232
232
|
* A static provider provides tokens to an injector for various types of dependencies.
|
|
233
233
|
*
|
|
234
234
|
* @see {@link Injector.create()}
|
|
235
|
-
* @see [
|
|
235
|
+
* @see [Dependency Injection Guide](guide/dependency-injection-providers).
|
|
236
236
|
*
|
|
237
237
|
* @publicApi
|
|
238
238
|
*/
|
|
@@ -257,7 +257,7 @@ export interface TypeProvider extends Type<any> {
|
|
|
257
257
|
* Configures the `Injector` to return a value by invoking a `useClass` function.
|
|
258
258
|
* Base for `ClassProvider` decorator.
|
|
259
259
|
*
|
|
260
|
-
* @see [
|
|
260
|
+
* @see [Dependency Injection Guide](guide/dependency-injection).
|
|
261
261
|
*
|
|
262
262
|
* @publicApi
|
|
263
263
|
*/
|
|
@@ -269,7 +269,7 @@ export interface ClassSansProvider {
|
|
|
269
269
|
}
|
|
270
270
|
/**
|
|
271
271
|
* Configures the `Injector` to return an instance of `useClass` for a token.
|
|
272
|
-
* @see [
|
|
272
|
+
* @see [Dependency Injection Guide](guide/dependency-injection).
|
|
273
273
|
*
|
|
274
274
|
* @usageNotes
|
|
275
275
|
*
|
|
@@ -298,7 +298,7 @@ export interface ClassProvider extends ClassSansProvider {
|
|
|
298
298
|
}
|
|
299
299
|
/**
|
|
300
300
|
* Describes how the `Injector` should be configured.
|
|
301
|
-
* @see [
|
|
301
|
+
* @see [Dependency Injection Guide](guide/dependency-injection).
|
|
302
302
|
*
|
|
303
303
|
* @see {@link StaticProvider}
|
|
304
304
|
*
|
|
@@ -25,7 +25,7 @@ export interface InjectDecorator {
|
|
|
25
25
|
* <code-example path="core/di/ts/metadata_spec.ts" region="InjectWithoutDecorator">
|
|
26
26
|
* </code-example>
|
|
27
27
|
*
|
|
28
|
-
* @see [
|
|
28
|
+
* @see [Dependency Injection Guide](guide/dependency-injection)
|
|
29
29
|
*
|
|
30
30
|
*/
|
|
31
31
|
(token: any): any;
|
|
@@ -70,7 +70,7 @@ export interface OptionalDecorator {
|
|
|
70
70
|
* <code-example path="core/di/ts/metadata_spec.ts" region="Optional">
|
|
71
71
|
* </code-example>
|
|
72
72
|
*
|
|
73
|
-
* @see [
|
|
73
|
+
* @see [Dependency Injection Guide](guide/dependency-injection).
|
|
74
74
|
*/
|
|
75
75
|
(): any;
|
|
76
76
|
new (): Optional;
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* Use of this source code is governed by an MIT-style license that can be
|
|
6
6
|
* found in the LICENSE file at https://angular.io/license
|
|
7
7
|
*/
|
|
8
|
-
import { Injector } from './injector';
|
|
8
|
+
import type { Injector } from './injector';
|
|
9
9
|
export declare class NullInjector implements Injector {
|
|
10
10
|
get(token: any, notFoundValue?: any): any;
|
|
11
11
|
}
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* Use of this source code is governed by an MIT-style license that can be
|
|
6
6
|
* found in the LICENSE file at https://angular.io/license
|
|
7
7
|
*/
|
|
8
|
-
import { Injector } from './injector';
|
|
8
|
+
import type { Injector } from './injector';
|
|
9
9
|
import { InjectorType } from './interface/defs';
|
|
10
10
|
import { InjectFlags, InjectOptions } from './interface/injector';
|
|
11
11
|
import { EnvironmentProviders, Provider } from './interface/provider';
|
|
@@ -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';
|
|
@@ -26,7 +26,6 @@
|
|
|
26
26
|
export declare const enum RuntimeErrorCode {
|
|
27
27
|
EXPRESSION_CHANGED_AFTER_CHECKED = -100,
|
|
28
28
|
RECURSIVE_APPLICATION_REF_TICK = 101,
|
|
29
|
-
RECURSIVE_APPLICATION_RENDER = 102,
|
|
30
29
|
INFINITE_CHANGE_DETECTION = 103,
|
|
31
30
|
CYCLIC_DI_DEPENDENCY = -200,
|
|
32
31
|
PROVIDER_NOT_FOUND = -201,
|
|
@@ -89,6 +88,10 @@ export declare const enum RuntimeErrorCode {
|
|
|
89
88
|
VIEW_ALREADY_DESTROYED = 911,
|
|
90
89
|
COMPONENT_ID_COLLISION = -912,
|
|
91
90
|
IMAGE_PERFORMANCE_WARNING = -913,
|
|
91
|
+
REQUIRED_INPUT_NO_VALUE = -950,
|
|
92
|
+
REQUIRED_QUERY_NO_VALUE = -951,
|
|
93
|
+
REQUIRED_MODEL_NO_VALUE = -952,
|
|
94
|
+
OUTPUT_REF_DESTROYED = 953,
|
|
92
95
|
RUNTIME_DEPS_INVALID_IMPORTED_TYPE = 1000,
|
|
93
96
|
RUNTIME_DEPS_ORPHAN_COMPONENT = 1001
|
|
94
97
|
}
|
|
@@ -5,5 +5,6 @@
|
|
|
5
5
|
* Use of this source code is governed by an MIT-style license that can be
|
|
6
6
|
* found in the LICENSE file at https://angular.io/license
|
|
7
7
|
*/
|
|
8
|
+
import type { ProviderToken } from '../di';
|
|
8
9
|
/** Throws an error when a token is not found in DI. */
|
|
9
|
-
export declare function throwProviderNotFoundError(token:
|
|
10
|
+
export declare function throwProviderNotFoundError(token: ProviderToken<unknown>, injectorName?: string): never;
|
|
@@ -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 declare function deepForEach<T>(input: (T | any[])[], fn: (value: T) => void): void;
|
|
2
9
|
export declare function newArray<T = any>(size: number): T[];
|
|
3
10
|
export declare function newArray<T>(size: number, value: T): T[];
|
|
@@ -11,6 +11,6 @@ export declare function stringify(token: any): string;
|
|
|
11
11
|
*
|
|
12
12
|
* @param string
|
|
13
13
|
* @param maxLength of the output string
|
|
14
|
-
* @returns
|
|
14
|
+
* @returns ellipsed string with ... in the middle
|
|
15
15
|
*/
|
|
16
16
|
export declare function truncateMiddle(str: string, maxLength?: number): string;
|
package/package.json
CHANGED
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "static-injector",
|
|
3
|
-
"version": "
|
|
4
|
-
"description": "Angular
|
|
3
|
+
"version": "4.0.0",
|
|
4
|
+
"description": "Angular 依赖注入独立版本;Angular dependency injection standalone version",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"angular",
|
|
7
|
-
"angular 17.
|
|
7
|
+
"angular 17.3.1",
|
|
8
8
|
"injector",
|
|
9
9
|
"typescript",
|
|
10
|
-
"typescript 5.
|
|
10
|
+
"typescript 5.4.2",
|
|
11
11
|
"injectable",
|
|
12
|
-
"static-inject"
|
|
12
|
+
"static-inject",
|
|
13
|
+
"dependency injection"
|
|
13
14
|
],
|
|
14
15
|
"repository": {
|
|
15
16
|
"type": "git",
|
|
@@ -34,4 +35,4 @@
|
|
|
34
35
|
},
|
|
35
36
|
"devDependencies": {},
|
|
36
37
|
"sideEffects": false
|
|
37
|
-
}
|
|
38
|
+
}
|
|
@@ -1,25 +1,3 @@
|
|
|
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
|
-
* @module
|
|
10
|
-
* @description
|
|
11
|
-
* Entry point for all APIs of the compiler package.
|
|
12
|
-
*
|
|
13
|
-
* <div class="callout is-critical">
|
|
14
|
-
* <header>Unstable APIs</header>
|
|
15
|
-
* <p>
|
|
16
|
-
* All compiler apis are currently considered experimental and private!
|
|
17
|
-
* </p>
|
|
18
|
-
* <p>
|
|
19
|
-
* We expect the APIs in this package to keep on changing. Do not rely on them.
|
|
20
|
-
* </p>
|
|
21
|
-
* </div>
|
|
22
|
-
*/
|
|
23
1
|
export * from './injectable_compiler_2';
|
|
24
2
|
export * from './render3/r3_factory';
|
|
25
3
|
export * from './output/output_ast';
|
|
@@ -1,11 +1,4 @@
|
|
|
1
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
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
10
3
|
if (k2 === undefined) k2 = k;
|
|
11
4
|
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
@@ -21,25 +14,6 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
21
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
22
15
|
};
|
|
23
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
24
|
-
//////////////////////////////////////
|
|
25
|
-
// THIS FILE HAS GLOBAL SIDE EFFECT //
|
|
26
|
-
// (see bottom of file) //
|
|
27
|
-
//////////////////////////////////////
|
|
28
|
-
/**
|
|
29
|
-
* @module
|
|
30
|
-
* @description
|
|
31
|
-
* Entry point for all APIs of the compiler package.
|
|
32
|
-
*
|
|
33
|
-
* <div class="callout is-critical">
|
|
34
|
-
* <header>Unstable APIs</header>
|
|
35
|
-
* <p>
|
|
36
|
-
* All compiler apis are currently considered experimental and private!
|
|
37
|
-
* </p>
|
|
38
|
-
* <p>
|
|
39
|
-
* We expect the APIs in this package to keep on changing. Do not rely on them.
|
|
40
|
-
* </p>
|
|
41
|
-
* </div>
|
|
42
|
-
*/
|
|
43
17
|
__exportStar(require("./injectable_compiler_2"), exports);
|
|
44
18
|
__exportStar(require("./render3/r3_factory"), exports);
|
|
45
19
|
__exportStar(require("./output/output_ast"), exports);
|
|
@@ -5,6 +5,12 @@
|
|
|
5
5
|
* Use of this source code is governed by an MIT-style license that can be
|
|
6
6
|
* found in the LICENSE file at https://angular.io/license
|
|
7
7
|
*/
|
|
8
|
+
/** Flags describing an input for a directive. */
|
|
9
|
+
export declare enum InputFlags {
|
|
10
|
+
None = 0,
|
|
11
|
+
SignalBased = 1,
|
|
12
|
+
HasDecoratorInputTransform = 2
|
|
13
|
+
}
|
|
8
14
|
/**
|
|
9
15
|
* Injection flags for DI.
|
|
10
16
|
*/
|
|
@@ -7,3 +7,16 @@
|
|
|
7
7
|
* found in the LICENSE file at https://angular.io/license
|
|
8
8
|
*/
|
|
9
9
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.InputFlags = void 0;
|
|
11
|
+
// Attention:
|
|
12
|
+
// This file duplicates types and values from @angular/core
|
|
13
|
+
// so that we are able to make @angular/compiler independent of @angular/core.
|
|
14
|
+
// This is important to prevent a build cycle, as @angular/core needs to
|
|
15
|
+
// be compiled with the compiler.
|
|
16
|
+
/** Flags describing an input for a directive. */
|
|
17
|
+
var InputFlags;
|
|
18
|
+
(function (InputFlags) {
|
|
19
|
+
InputFlags[InputFlags["None"] = 0] = "None";
|
|
20
|
+
InputFlags[InputFlags["SignalBased"] = 1] = "SignalBased";
|
|
21
|
+
InputFlags[InputFlags["HasDecoratorInputTransform"] = 2] = "HasDecoratorInputTransform";
|
|
22
|
+
})(InputFlags || (exports.InputFlags = InputFlags = {}));
|