static-injector 3.0.0 → 4.0.1
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 +8 -6
- package/readme.md +33 -23
- 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
|
@@ -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 = {}));
|
|
@@ -83,12 +83,13 @@ export declare enum BinaryOperator {
|
|
|
83
83
|
Modulo = 8,
|
|
84
84
|
And = 9,
|
|
85
85
|
Or = 10,
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
86
|
+
BitwiseOr = 11,
|
|
87
|
+
BitwiseAnd = 12,
|
|
88
|
+
Lower = 13,
|
|
89
|
+
LowerEquals = 14,
|
|
90
|
+
Bigger = 15,
|
|
91
|
+
BiggerEquals = 16,
|
|
92
|
+
NullishCoalesce = 17
|
|
92
93
|
}
|
|
93
94
|
export declare function nullSafeIsEquivalent<T extends {
|
|
94
95
|
isEquivalent(other: T): boolean;
|
|
@@ -114,6 +115,7 @@ export declare abstract class Expression {
|
|
|
114
115
|
prop(name: string, sourceSpan?: ParseSourceSpan | null): ReadPropExpr;
|
|
115
116
|
key(index: Expression, type?: Type | null, sourceSpan?: ParseSourceSpan | null): ReadKeyExpr;
|
|
116
117
|
callFn(params: Expression[], sourceSpan?: ParseSourceSpan | null, pure?: boolean): InvokeFunctionExpr;
|
|
118
|
+
bitwiseOr(rhs: Expression, sourceSpan?: ParseSourceSpan | null, parens?: boolean): BinaryOperatorExpr;
|
|
117
119
|
toStmt(): Statement;
|
|
118
120
|
}
|
|
119
121
|
export declare class ReadVarExpr extends Expression {
|
|
@@ -120,12 +120,13 @@ var BinaryOperator;
|
|
|
120
120
|
BinaryOperator[BinaryOperator["Modulo"] = 8] = "Modulo";
|
|
121
121
|
BinaryOperator[BinaryOperator["And"] = 9] = "And";
|
|
122
122
|
BinaryOperator[BinaryOperator["Or"] = 10] = "Or";
|
|
123
|
-
BinaryOperator[BinaryOperator["
|
|
124
|
-
BinaryOperator[BinaryOperator["
|
|
125
|
-
BinaryOperator[BinaryOperator["
|
|
126
|
-
BinaryOperator[BinaryOperator["
|
|
127
|
-
BinaryOperator[BinaryOperator["
|
|
128
|
-
BinaryOperator[BinaryOperator["
|
|
123
|
+
BinaryOperator[BinaryOperator["BitwiseOr"] = 11] = "BitwiseOr";
|
|
124
|
+
BinaryOperator[BinaryOperator["BitwiseAnd"] = 12] = "BitwiseAnd";
|
|
125
|
+
BinaryOperator[BinaryOperator["Lower"] = 13] = "Lower";
|
|
126
|
+
BinaryOperator[BinaryOperator["LowerEquals"] = 14] = "LowerEquals";
|
|
127
|
+
BinaryOperator[BinaryOperator["Bigger"] = 15] = "Bigger";
|
|
128
|
+
BinaryOperator[BinaryOperator["BiggerEquals"] = 16] = "BiggerEquals";
|
|
129
|
+
BinaryOperator[BinaryOperator["NullishCoalesce"] = 17] = "NullishCoalesce";
|
|
129
130
|
})(BinaryOperator || (exports.BinaryOperator = BinaryOperator = {}));
|
|
130
131
|
function nullSafeIsEquivalent(base, other) {
|
|
131
132
|
if (base == null || other == null) {
|
|
@@ -166,6 +167,9 @@ class Expression {
|
|
|
166
167
|
callFn(params, sourceSpan, pure) {
|
|
167
168
|
return new InvokeFunctionExpr(this, params, null, sourceSpan, pure);
|
|
168
169
|
}
|
|
170
|
+
bitwiseOr(rhs, sourceSpan, parens = true) {
|
|
171
|
+
return new BinaryOperatorExpr(BinaryOperator.BitwiseOr, this, rhs, null, sourceSpan, parens);
|
|
172
|
+
}
|
|
169
173
|
toStmt() {
|
|
170
174
|
return new ExpressionStatement(this, null);
|
|
171
175
|
}
|
|
@@ -26,6 +26,11 @@ export interface R3PartialDeclaration {
|
|
|
26
26
|
*/
|
|
27
27
|
type: o.Expression;
|
|
28
28
|
}
|
|
29
|
+
export type LegacyInputPartialMapping = string | [
|
|
30
|
+
bindingPropertyName: string,
|
|
31
|
+
classPropertyName: string,
|
|
32
|
+
transformFunction?: o.Expression
|
|
33
|
+
];
|
|
29
34
|
/**
|
|
30
35
|
* Describes the shape of the objects that the `ɵɵngDeclareInjector()` accepts.
|
|
31
36
|
*/
|
|
@@ -10,6 +10,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
10
10
|
exports.Identifiers = void 0;
|
|
11
11
|
const CORE = 'static-injector';
|
|
12
12
|
class Identifiers {
|
|
13
|
+
/* Methods */
|
|
14
|
+
/* Instructions */
|
|
13
15
|
static inject = { name: 'ɵɵinject', moduleName: CORE };
|
|
14
16
|
static directiveInject = {
|
|
15
17
|
name: 'ɵɵdirectiveInject',
|
|
@@ -43,6 +45,8 @@ class Identifiers {
|
|
|
43
45
|
name: 'ɵɵFactoryDeclaration',
|
|
44
46
|
moduleName: CORE,
|
|
45
47
|
};
|
|
48
|
+
// Signal queries
|
|
49
|
+
// Two-way bindings
|
|
46
50
|
static getInheritedFactory = {
|
|
47
51
|
name: 'ɵɵgetInheritedFactory',
|
|
48
52
|
moduleName: CORE,
|
|
@@ -1,10 +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
1
|
export * from './src/di';
|
|
9
2
|
export * from './src/factory';
|
|
10
3
|
export * from './src/util';
|
|
@@ -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);
|
|
@@ -7,7 +7,6 @@
|
|
|
7
7
|
*/
|
|
8
8
|
import { R3DependencyMetadata } from 'static-injector/transform/compiler';
|
|
9
9
|
import { ClassDeclaration, CtorParameter, ReflectionHost, UnavailableValue } from '../../../reflection';
|
|
10
|
-
import { CompilationMode } from '../../../transform';
|
|
11
10
|
export type ConstructorDeps = {
|
|
12
11
|
deps: R3DependencyMetadata[];
|
|
13
12
|
} | {
|
|
@@ -19,7 +18,7 @@ export interface ConstructorDepError {
|
|
|
19
18
|
param: CtorParameter;
|
|
20
19
|
reason: UnavailableValue;
|
|
21
20
|
}
|
|
22
|
-
export declare function getConstructorDependencies(clazz: ClassDeclaration, reflector: ReflectionHost, isCore: boolean
|
|
21
|
+
export declare function getConstructorDependencies(clazz: ClassDeclaration, reflector: ReflectionHost, isCore: boolean): ConstructorDeps | null;
|
|
23
22
|
/**
|
|
24
23
|
* Convert `ConstructorDeps` into the `R3DependencyMetadata` array for those deps if they're valid,
|
|
25
24
|
* or into an `'invalid'` signal if they're not.
|
|
@@ -27,7 +26,7 @@ export declare function getConstructorDependencies(clazz: ClassDeclaration, refl
|
|
|
27
26
|
* This is a companion function to `validateConstructorDependencies` which accepts invalid deps.
|
|
28
27
|
*/
|
|
29
28
|
export declare function unwrapConstructorDependencies(deps: ConstructorDeps | null): R3DependencyMetadata[] | 'invalid' | null;
|
|
30
|
-
export declare function getValidConstructorDependencies(clazz: ClassDeclaration, reflector: ReflectionHost, isCore: boolean
|
|
29
|
+
export declare function getValidConstructorDependencies(clazz: ClassDeclaration, reflector: ReflectionHost, isCore: boolean): R3DependencyMetadata[] | null;
|
|
31
30
|
/**
|
|
32
31
|
* Validate that `ConstructorDeps` does not have any invalid dependencies and convert them into the
|
|
33
32
|
* `R3DependencyMetadata` array if so, or raise a diagnostic if some deps are invalid.
|
|
@@ -14,9 +14,8 @@ exports.validateConstructorDependencies = exports.getValidConstructorDependencie
|
|
|
14
14
|
const compiler_1 = require("static-injector/transform/compiler");
|
|
15
15
|
const typescript_1 = __importDefault(require("typescript"));
|
|
16
16
|
const diagnostics_1 = require("../../../diagnostics");
|
|
17
|
-
const transform_1 = require("../../../transform");
|
|
18
17
|
const util_1 = require("./util");
|
|
19
|
-
function getConstructorDependencies(clazz, reflector, isCore
|
|
18
|
+
function getConstructorDependencies(clazz, reflector, isCore) {
|
|
20
19
|
const deps = [];
|
|
21
20
|
const errors = [];
|
|
22
21
|
let ctorParams = reflector.getConstructorParameters(clazz);
|
|
@@ -29,26 +28,7 @@ function getConstructorDependencies(clazz, reflector, isCore, compilationMode) {
|
|
|
29
28
|
}
|
|
30
29
|
}
|
|
31
30
|
ctorParams.forEach((param, idx) => {
|
|
32
|
-
let token =
|
|
33
|
-
if (compilationMode === transform_1.CompilationMode.LOCAL &&
|
|
34
|
-
param.typeValueReference.kind === 2 /* TypeValueReferenceKind.UNAVAILABLE */ &&
|
|
35
|
-
param.typeValueReference.reason.kind !== 0 /* ValueUnavailableKind.MISSING_TYPE */) {
|
|
36
|
-
// The case of local compilation where injection token cannot be resolved because it is
|
|
37
|
-
// "probably" imported from another file
|
|
38
|
-
const typeNode = param.typeValueReference.reason.typeNode;
|
|
39
|
-
if (typescript_1.default.isTypeReferenceNode(typeNode)) {
|
|
40
|
-
// Here we manually create the token out of the typeName without caring about its
|
|
41
|
-
// references for better TS tracking. This is because in this code path the typeNode is
|
|
42
|
-
// imported from another file and since we are in local compilation mode (=single file
|
|
43
|
-
// mode) the reference of this node (or its typeName node) cannot be resolved. So all we
|
|
44
|
-
// can do is just to create a new expression.
|
|
45
|
-
token = toQualifiedExpression(typeNode.typeName);
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
else {
|
|
49
|
-
// In all other cases resolve the injection token
|
|
50
|
-
token = (0, util_1.valueReferenceToExpression)(param.typeValueReference);
|
|
51
|
-
}
|
|
31
|
+
let token = (0, util_1.valueReferenceToExpression)(param.typeValueReference);
|
|
52
32
|
let attributeNameType = null;
|
|
53
33
|
let optional = false, self = false, skipSelf = false, host = false;
|
|
54
34
|
(param.decorators || [])
|
|
@@ -100,13 +80,6 @@ function getConstructorDependencies(clazz, reflector, isCore, compilationMode) {
|
|
|
100
80
|
}
|
|
101
81
|
}
|
|
102
82
|
exports.getConstructorDependencies = getConstructorDependencies;
|
|
103
|
-
/** Converts a TS qualified name to output expression. */
|
|
104
|
-
function toQualifiedExpression(entity) {
|
|
105
|
-
if (typescript_1.default.isIdentifier(entity)) {
|
|
106
|
-
return new compiler_1.WrappedNodeExpr(entity);
|
|
107
|
-
}
|
|
108
|
-
return new compiler_1.ReadPropExpr(toQualifiedExpression(entity.left), entity.right.text);
|
|
109
|
-
}
|
|
110
83
|
/**
|
|
111
84
|
* Convert `ConstructorDeps` into the `R3DependencyMetadata` array for those deps if they're valid,
|
|
112
85
|
* or into an `'invalid'` signal if they're not.
|
|
@@ -127,8 +100,8 @@ function unwrapConstructorDependencies(deps) {
|
|
|
127
100
|
}
|
|
128
101
|
}
|
|
129
102
|
exports.unwrapConstructorDependencies = unwrapConstructorDependencies;
|
|
130
|
-
function getValidConstructorDependencies(clazz, reflector, isCore
|
|
131
|
-
return validateConstructorDependencies(clazz, getConstructorDependencies(clazz, reflector, isCore
|
|
103
|
+
function getValidConstructorDependencies(clazz, reflector, isCore) {
|
|
104
|
+
return validateConstructorDependencies(clazz, getConstructorDependencies(clazz, reflector, isCore));
|
|
132
105
|
}
|
|
133
106
|
exports.getValidConstructorDependencies = getValidConstructorDependencies;
|
|
134
107
|
/**
|
|
@@ -8,6 +8,8 @@
|
|
|
8
8
|
import { Expression, FactoryTarget, R3FactoryMetadata, R3Reference } from 'static-injector/transform/compiler';
|
|
9
9
|
import ts from 'typescript';
|
|
10
10
|
import { ClassDeclaration, Decorator, Import, ImportedTypeValueReference, LocalTypeValueReference, ReflectionHost, TypeValueReference } from '../../../reflection';
|
|
11
|
+
/** Module name of the framework core. */
|
|
12
|
+
export declare const CORE_MODULE = "static-injector";
|
|
11
13
|
/**
|
|
12
14
|
* Convert a `TypeValueReference` to an `Expression` which refers to the type as a value.
|
|
13
15
|
*
|
|
@@ -22,6 +24,7 @@ export declare function isAngularCore(decorator: Decorator): decorator is Decora
|
|
|
22
24
|
};
|
|
23
25
|
export declare function findAngularDecorator(decorators: Decorator[], name: string, isCore: boolean): Decorator | undefined;
|
|
24
26
|
export declare function isAngularDecorator(decorator: Decorator, name: string, isCore: boolean): boolean;
|
|
27
|
+
export declare function getAngularDecorators(decorators: Decorator[], names: readonly string[], isCore: boolean): Decorator[];
|
|
25
28
|
/**
|
|
26
29
|
* Unwrap a `ts.Expression`, removing outer type-casts or parentheses until the expression is in its
|
|
27
30
|
* lowest level form.
|
|
@@ -10,9 +10,11 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
10
10
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
11
11
|
};
|
|
12
12
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
-
exports.isAbstractClassDeclaration = exports.toFactoryMetadata = exports.wrapTypeReference = exports.wrapFunctionExpressionsInParens = exports.tryUnwrapForwardRef = exports.unwrapExpression = exports.isAngularDecorator = exports.findAngularDecorator = exports.isAngularCore = exports.valueReferenceToExpression = void 0;
|
|
13
|
+
exports.isAbstractClassDeclaration = exports.toFactoryMetadata = exports.wrapTypeReference = exports.wrapFunctionExpressionsInParens = exports.tryUnwrapForwardRef = exports.unwrapExpression = exports.getAngularDecorators = exports.isAngularDecorator = exports.findAngularDecorator = exports.isAngularCore = exports.valueReferenceToExpression = exports.CORE_MODULE = void 0;
|
|
14
14
|
const compiler_1 = require("static-injector/transform/compiler");
|
|
15
15
|
const typescript_1 = __importDefault(require("typescript"));
|
|
16
|
+
/** Module name of the framework core. */
|
|
17
|
+
exports.CORE_MODULE = 'static-injector';
|
|
16
18
|
function valueReferenceToExpression(valueRef) {
|
|
17
19
|
if (valueRef.kind === 2 /* TypeValueReferenceKind.UNAVAILABLE */) {
|
|
18
20
|
return null;
|
|
@@ -36,7 +38,7 @@ function valueReferenceToExpression(valueRef) {
|
|
|
36
38
|
}
|
|
37
39
|
exports.valueReferenceToExpression = valueReferenceToExpression;
|
|
38
40
|
function isAngularCore(decorator) {
|
|
39
|
-
return
|
|
41
|
+
return decorator.import !== null && decorator.import.from === exports.CORE_MODULE;
|
|
40
42
|
}
|
|
41
43
|
exports.isAngularCore = isAngularCore;
|
|
42
44
|
function findAngularDecorator(decorators, name, isCore) {
|
|
@@ -53,6 +55,16 @@ function isAngularDecorator(decorator, name, isCore) {
|
|
|
53
55
|
return false;
|
|
54
56
|
}
|
|
55
57
|
exports.isAngularDecorator = isAngularDecorator;
|
|
58
|
+
function getAngularDecorators(decorators, names, isCore) {
|
|
59
|
+
return decorators.filter((decorator) => {
|
|
60
|
+
const name = isCore ? decorator.name : decorator.import?.name;
|
|
61
|
+
if (name === undefined || !names.includes(name)) {
|
|
62
|
+
return false;
|
|
63
|
+
}
|
|
64
|
+
return isCore || isAngularCore(decorator);
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
exports.getAngularDecorators = getAngularDecorators;
|
|
56
68
|
/**
|
|
57
69
|
* Unwrap a `ts.Expression`, removing outer type-casts or parentheses until the expression is in its
|
|
58
70
|
* lowest level form.
|
|
@@ -63,7 +63,7 @@ class InjectableDecoratorHandler {
|
|
|
63
63
|
return {
|
|
64
64
|
analysis: {
|
|
65
65
|
meta,
|
|
66
|
-
ctorDeps: extractInjectableCtorDeps(node, meta, decorator, this.reflector, this.isCore, this.strictCtorDeps
|
|
66
|
+
ctorDeps: extractInjectableCtorDeps(node, meta, decorator, this.reflector, this.isCore, this.strictCtorDeps),
|
|
67
67
|
// Avoid generating multiple factories if a class has
|
|
68
68
|
// more Angular decorators, apart from Injectable.
|
|
69
69
|
},
|
|
@@ -181,7 +181,7 @@ function getProviderExpression(expression, reflector) {
|
|
|
181
181
|
? 2 /* ForwardRefHandling.Unwrapped */
|
|
182
182
|
: 0 /* ForwardRefHandling.None */);
|
|
183
183
|
}
|
|
184
|
-
function extractInjectableCtorDeps(clazz, meta, decorator, reflector, isCore, strictCtorDeps
|
|
184
|
+
function extractInjectableCtorDeps(clazz, meta, decorator, reflector, isCore, strictCtorDeps) {
|
|
185
185
|
if (decorator.args === null) {
|
|
186
186
|
throw new diagnostics_1.FatalDiagnosticError(diagnostics_1.ErrorCode.DECORATOR_NOT_CALLED, decorator.node, '@Injectable must be called');
|
|
187
187
|
}
|
|
@@ -196,15 +196,15 @@ function extractInjectableCtorDeps(clazz, meta, decorator, reflector, isCore, st
|
|
|
196
196
|
// constructor signature does not work for DI then a factory definition (ɵfac) that throws is
|
|
197
197
|
// generated.
|
|
198
198
|
if (strictCtorDeps && !(0, common_1.isAbstractClassDeclaration)(clazz)) {
|
|
199
|
-
ctorDeps = (0, common_2.getValidConstructorDependencies)(clazz, reflector, isCore
|
|
199
|
+
ctorDeps = (0, common_2.getValidConstructorDependencies)(clazz, reflector, isCore);
|
|
200
200
|
}
|
|
201
201
|
else {
|
|
202
|
-
ctorDeps = (0, common_2.unwrapConstructorDependencies)((0, common_2.getConstructorDependencies)(clazz, reflector, isCore
|
|
202
|
+
ctorDeps = (0, common_2.unwrapConstructorDependencies)((0, common_2.getConstructorDependencies)(clazz, reflector, isCore));
|
|
203
203
|
}
|
|
204
204
|
return ctorDeps;
|
|
205
205
|
}
|
|
206
206
|
else if (decorator.args.length === 1) {
|
|
207
|
-
const rawCtorDeps = (0, common_2.getConstructorDependencies)(clazz, reflector, isCore
|
|
207
|
+
const rawCtorDeps = (0, common_2.getConstructorDependencies)(clazz, reflector, isCore);
|
|
208
208
|
if (strictCtorDeps &&
|
|
209
209
|
!(0, common_1.isAbstractClassDeclaration)(clazz) &&
|
|
210
210
|
requiresValidCtor(meta)) {
|
|
@@ -1,9 +1,2 @@
|
|
|
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
1
|
export * from './error';
|
|
9
2
|
export * from './error_code';
|
|
@@ -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);
|
|
@@ -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);
|
|
@@ -1,10 +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
1
|
export * from './src/host';
|
|
9
2
|
export * from './src/typescript';
|
|
10
3
|
export * from './src/util';
|
|
@@ -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);
|
|
@@ -209,7 +209,7 @@ export interface ImportedTypeValueReference {
|
|
|
209
209
|
* When `null` or empty, the `importedName` itself is the symbol being referenced.
|
|
210
210
|
*/
|
|
211
211
|
nestedPath: string[] | null;
|
|
212
|
-
valueDeclaration: DeclarationNode;
|
|
212
|
+
valueDeclaration: DeclarationNode | null;
|
|
213
213
|
}
|
|
214
214
|
/**
|
|
215
215
|
* A representation for a type value reference that is used when no value is available. This can
|
|
@@ -410,6 +410,11 @@ export interface Import {
|
|
|
410
410
|
* A type that is used to identify a declaration.
|
|
411
411
|
*/
|
|
412
412
|
export type DeclarationNode = ts.Declaration;
|
|
413
|
+
export type AmbientImport = {
|
|
414
|
+
__brand: 'AmbientImport';
|
|
415
|
+
};
|
|
416
|
+
/** Indicates that a declaration is referenced through an ambient type. */
|
|
417
|
+
export declare const AmbientImport: AmbientImport;
|
|
413
418
|
/**
|
|
414
419
|
* The declaration of a symbol, along with information about how it was imported into the
|
|
415
420
|
* application.
|
|
@@ -420,7 +425,7 @@ export interface Declaration<T extends ts.Declaration = ts.Declaration> {
|
|
|
420
425
|
* was imported via an absolute module (even through a chain of re-exports). If the symbol is part
|
|
421
426
|
* of the application and was not imported from an absolute path, this will be `null`.
|
|
422
427
|
*/
|
|
423
|
-
viaModule: string | null;
|
|
428
|
+
viaModule: string | AmbientImport | null;
|
|
424
429
|
/**
|
|
425
430
|
* TypeScript reference to the declaration itself, if one exists.
|
|
426
431
|
*/
|
|
@@ -10,7 +10,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
10
10
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
11
11
|
};
|
|
12
12
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
-
exports.ClassMemberKind = exports.isDecoratorIdentifier = void 0;
|
|
13
|
+
exports.AmbientImport = exports.ClassMemberKind = exports.isDecoratorIdentifier = void 0;
|
|
14
14
|
const typescript_1 = __importDefault(require("typescript"));
|
|
15
15
|
function isDecoratorIdentifier(exp) {
|
|
16
16
|
return (typescript_1.default.isIdentifier(exp) ||
|
|
@@ -30,3 +30,5 @@ var ClassMemberKind;
|
|
|
30
30
|
ClassMemberKind[ClassMemberKind["Property"] = 3] = "Property";
|
|
31
31
|
ClassMemberKind[ClassMemberKind["Method"] = 4] = "Method";
|
|
32
32
|
})(ClassMemberKind || (exports.ClassMemberKind = ClassMemberKind = {}));
|
|
33
|
+
/** Indicates that a declaration is referenced through an ambient type. */
|
|
34
|
+
exports.AmbientImport = {};
|
|
@@ -14,7 +14,7 @@ import { TypeValueReference } from './host';
|
|
|
14
14
|
* This can return `null` if the `typeNode` is `null`, if it does not refer to a symbol with a value
|
|
15
15
|
* declaration, or if it is not possible to statically understand.
|
|
16
16
|
*/
|
|
17
|
-
export declare function typeToValue(typeNode: ts.TypeNode | null, checker: ts.TypeChecker): TypeValueReference;
|
|
17
|
+
export declare function typeToValue(typeNode: ts.TypeNode | null, checker: ts.TypeChecker, isLocalCompilation: boolean): TypeValueReference;
|
|
18
18
|
/**
|
|
19
19
|
* Attempt to extract a `ts.Expression` that's equivalent to a `ts.TypeNode`, as the two have
|
|
20
20
|
* different AST shapes but can reference the same symbols.
|
|
@@ -22,3 +22,4 @@ export declare function typeToValue(typeNode: ts.TypeNode | null, checker: ts.Ty
|
|
|
22
22
|
* This will return `null` if an equivalent expression cannot be constructed.
|
|
23
23
|
*/
|
|
24
24
|
export declare function typeNodeToValueExpr(node: ts.TypeNode): ts.Expression | null;
|
|
25
|
+
export declare function entityNameToValue(node: ts.EntityName): ts.Expression | null;
|
|
@@ -10,7 +10,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
10
10
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
11
11
|
};
|
|
12
12
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
-
exports.typeNodeToValueExpr = exports.typeToValue = void 0;
|
|
13
|
+
exports.entityNameToValue = exports.typeNodeToValueExpr = exports.typeToValue = void 0;
|
|
14
14
|
const typescript_1 = __importDefault(require("typescript"));
|
|
15
15
|
/**
|
|
16
16
|
* Potentially convert a `ts.TypeNode` to a `TypeValueReference`, which indicates how to use the
|
|
@@ -19,7 +19,7 @@ const typescript_1 = __importDefault(require("typescript"));
|
|
|
19
19
|
* This can return `null` if the `typeNode` is `null`, if it does not refer to a symbol with a value
|
|
20
20
|
* declaration, or if it is not possible to statically understand.
|
|
21
21
|
*/
|
|
22
|
-
function typeToValue(typeNode, checker) {
|
|
22
|
+
function typeToValue(typeNode, checker, isLocalCompilation) {
|
|
23
23
|
// It's not possible to get a value expression if the parameter doesn't even have a type.
|
|
24
24
|
if (typeNode === null) {
|
|
25
25
|
return missingType();
|
|
@@ -41,7 +41,17 @@ function typeToValue(typeNode, checker) {
|
|
|
41
41
|
if (decl.declarations !== undefined && decl.declarations.length > 0) {
|
|
42
42
|
typeOnlyDecl = decl.declarations[0];
|
|
43
43
|
}
|
|
44
|
-
|
|
44
|
+
// In local compilation mode a declaration is considered invalid only if it is a type related
|
|
45
|
+
// declaration.
|
|
46
|
+
if (!isLocalCompilation ||
|
|
47
|
+
(typeOnlyDecl &&
|
|
48
|
+
[
|
|
49
|
+
typescript_1.default.SyntaxKind.TypeParameter,
|
|
50
|
+
typescript_1.default.SyntaxKind.TypeAliasDeclaration,
|
|
51
|
+
typescript_1.default.SyntaxKind.InterfaceDeclaration,
|
|
52
|
+
].includes(typeOnlyDecl.kind))) {
|
|
53
|
+
return noValueDeclaration(typeNode, typeOnlyDecl);
|
|
54
|
+
}
|
|
45
55
|
}
|
|
46
56
|
// The type points to a valid value declaration. Rewrite the TypeReference into an
|
|
47
57
|
// Expression which references the value pointed to by the TypeReference, if possible.
|
|
@@ -85,7 +95,7 @@ function typeToValue(typeNode, checker) {
|
|
|
85
95
|
const moduleName = extractModuleName(firstDecl.parent.parent.parent);
|
|
86
96
|
return {
|
|
87
97
|
kind: 1 /* TypeValueReferenceKind.IMPORTED */,
|
|
88
|
-
valueDeclaration: decl.valueDeclaration,
|
|
98
|
+
valueDeclaration: decl.valueDeclaration ?? null,
|
|
89
99
|
moduleName,
|
|
90
100
|
importedName,
|
|
91
101
|
nestedPath,
|
|
@@ -109,7 +119,7 @@ function typeToValue(typeNode, checker) {
|
|
|
109
119
|
const moduleName = extractModuleName(firstDecl.parent.parent);
|
|
110
120
|
return {
|
|
111
121
|
kind: 1 /* TypeValueReferenceKind.IMPORTED */,
|
|
112
|
-
valueDeclaration: decl.valueDeclaration,
|
|
122
|
+
valueDeclaration: decl.valueDeclaration ?? null,
|
|
113
123
|
moduleName,
|
|
114
124
|
importedName,
|
|
115
125
|
nestedPath,
|
|
@@ -252,6 +262,7 @@ function entityNameToValue(node) {
|
|
|
252
262
|
return null;
|
|
253
263
|
}
|
|
254
264
|
}
|
|
265
|
+
exports.entityNameToValue = entityNameToValue;
|
|
255
266
|
function extractModuleName(node) {
|
|
256
267
|
if (!typescript_1.default.isStringLiteral(node.moduleSpecifier)) {
|
|
257
268
|
throw new Error('not a module specifier');
|
|
@@ -12,7 +12,8 @@ import { ClassDeclaration, ClassMember, CtorParameter, DeclarationNode, Decorato
|
|
|
12
12
|
*/
|
|
13
13
|
export declare class TypeScriptReflectionHost implements ReflectionHost {
|
|
14
14
|
protected checker: ts.TypeChecker;
|
|
15
|
-
|
|
15
|
+
private readonly isLocalCompilation;
|
|
16
|
+
constructor(checker: ts.TypeChecker, isLocalCompilation?: boolean);
|
|
16
17
|
getDecoratorsOfDeclaration(declaration: DeclarationNode): Decorator[] | null;
|
|
17
18
|
getMembersOfClass(clazz: ClassDeclaration): ClassMember[];
|
|
18
19
|
getConstructorParameters(clazz: ClassDeclaration): CtorParameter[] | null;
|
|
@@ -43,10 +44,10 @@ export declare class TypeScriptReflectionHost implements ReflectionHost {
|
|
|
43
44
|
protected getImportOfNamespacedIdentifier(id: ts.Identifier, namespaceIdentifier: ts.Identifier | null): Import | null;
|
|
44
45
|
private _reflectDecorator;
|
|
45
46
|
private _reflectMember;
|
|
47
|
+
private _viaModule;
|
|
46
48
|
}
|
|
47
49
|
export declare function reflectObjectLiteral(node: ts.ObjectLiteralExpression): Map<string, ts.Expression>;
|
|
48
50
|
/**
|
|
49
|
-
*
|
|
50
|
-
* `NamespaceImport`. If not return `null`.
|
|
51
|
+
* Gets the closest ancestor `ImportDeclaration` to a node.
|
|
51
52
|
*/
|
|
52
53
|
export declare function getContainingImportDeclaration(node: ts.Node): ts.ImportDeclaration | null;
|