static-injector 4.0.2 → 5.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/{import/commonjs → commonjs}/index.js +29 -197
- package/{import/es2022 → es2022}/di/interface/defs.js +5 -1
- package/{import/es2022 → es2022}/index.js +0 -1
- package/{transform/compiler/index.d.ts → es2022/interface/lifecycle_hooks.js} +1 -1
- package/{transform/compiler-cli/src/ngtsc/translator/src/api/ast_factory.js → es2022/render3/definition_factory.js} +3 -2
- package/es2022/util/decorators.js +31 -0
- package/{import/fesm2022 → fesm2022}/index.js +30 -196
- package/package.json +17 -14
- package/readme.md +35 -13
- package/{import/typings → typings}/di/injectable.d.ts +0 -7
- package/{import/typings → typings}/index.d.ts +0 -1
- package/import/es2022/di/injectable.js +0 -14
- package/import/es2022/error_details_base_url.js +0 -19
- package/import/es2022/render3/definition_factory.js +0 -14
- package/import/es2022/render3/di.js +0 -49
- package/import/es2022/render3/error_code.js +0 -30
- package/import/es2022/util/array_utils.js +0 -17
- package/import/es2022/util/decorators.js +0 -53
- package/import/typings/error_details_base_url.d.ts +0 -19
- package/import/typings/render3/di.d.ts +0 -12
- package/import/typings/render3/error_code.d.ts +0 -24
- package/import/typings/util/array_utils.d.ts +0 -25
- package/transform/compiler/compiler.d.ts +0 -8
- package/transform/compiler/compiler.js +0 -28
- package/transform/compiler/index.js +0 -28
- package/transform/compiler/public_api.d.ts +0 -13
- package/transform/compiler/public_api.js +0 -30
- package/transform/compiler/src/compiler.d.ts +0 -5
- package/transform/compiler/src/compiler.js +0 -21
- package/transform/compiler/src/core.d.ts +0 -25
- package/transform/compiler/src/core.js +0 -22
- package/transform/compiler/src/injectable_compiler_2.d.ts +0 -23
- package/transform/compiler/src/injectable_compiler_2.js +0 -171
- package/transform/compiler/src/output/output_ast.d.ts +0 -512
- package/transform/compiler/src/output/output_ast.js +0 -1109
- package/transform/compiler/src/parse_util.d.ts +0 -50
- package/transform/compiler/src/parse_util.js +0 -71
- package/transform/compiler/src/render3/partial/api.d.ts +0 -171
- package/transform/compiler/src/render3/partial/api.js +0 -18
- package/transform/compiler/src/render3/r3_factory.d.ts +0 -82
- package/transform/compiler/src/render3/r3_factory.js +0 -225
- package/transform/compiler/src/render3/r3_identifiers.d.ts +0 -20
- package/transform/compiler/src/render3/r3_identifiers.js +0 -55
- package/transform/compiler/src/render3/util.d.ts +0 -85
- package/transform/compiler/src/render3/util.js +0 -82
- package/transform/compiler/src/render3/view/util.d.ts +0 -24
- package/transform/compiler/src/render3/view/util.js +0 -59
- package/transform/compiler-cli/src/ngtsc/annotations/common/index.d.ts +0 -3
- package/transform/compiler-cli/src/ngtsc/annotations/common/index.js +0 -19
- package/transform/compiler-cli/src/ngtsc/annotations/common/src/di.d.ts +0 -37
- package/transform/compiler-cli/src/ngtsc/annotations/common/src/di.js +0 -195
- package/transform/compiler-cli/src/ngtsc/annotations/common/src/factory.d.ts +0 -11
- package/transform/compiler-cli/src/ngtsc/annotations/common/src/factory.js +0 -22
- package/transform/compiler-cli/src/ngtsc/annotations/common/src/util.d.ts +0 -64
- package/transform/compiler-cli/src/ngtsc/annotations/common/src/util.js +0 -189
- package/transform/compiler-cli/src/ngtsc/annotations/src/injectable.d.ts +0 -43
- package/transform/compiler-cli/src/ngtsc/annotations/src/injectable.js +0 -277
- package/transform/compiler-cli/src/ngtsc/diagnostics/error.d.ts +0 -24
- package/transform/compiler-cli/src/ngtsc/diagnostics/error.js +0 -84
- package/transform/compiler-cli/src/ngtsc/diagnostics/error_code.d.ts +0 -188
- package/transform/compiler-cli/src/ngtsc/diagnostics/error_code.js +0 -206
- package/transform/compiler-cli/src/ngtsc/diagnostics/index.d.ts +0 -2
- package/transform/compiler-cli/src/ngtsc/diagnostics/index.js +0 -18
- package/transform/compiler-cli/src/ngtsc/imports/index.d.ts +0 -1
- package/transform/compiler-cli/src/ngtsc/imports/index.js +0 -17
- package/transform/compiler-cli/src/ngtsc/imports/src/core.d.ts +0 -36
- package/transform/compiler-cli/src/ngtsc/imports/src/core.js +0 -25
- package/transform/compiler-cli/src/ngtsc/imports/src/default.d.ts +0 -19
- package/transform/compiler-cli/src/ngtsc/imports/src/default.js +0 -27
- package/transform/compiler-cli/src/ngtsc/reflection/index.d.ts +0 -3
- package/transform/compiler-cli/src/ngtsc/reflection/index.js +0 -19
- package/transform/compiler-cli/src/ngtsc/reflection/src/host.d.ts +0 -522
- package/transform/compiler-cli/src/ngtsc/reflection/src/host.js +0 -34
- package/transform/compiler-cli/src/ngtsc/reflection/src/type_to_value.d.ts +0 -25
- package/transform/compiler-cli/src/ngtsc/reflection/src/type_to_value.js +0 -271
- package/transform/compiler-cli/src/ngtsc/reflection/src/typescript.d.ts +0 -53
- package/transform/compiler-cli/src/ngtsc/reflection/src/typescript.js +0 -393
- package/transform/compiler-cli/src/ngtsc/reflection/src/util.d.ts +0 -12
- package/transform/compiler-cli/src/ngtsc/reflection/src/util.js +0 -29
- package/transform/compiler-cli/src/ngtsc/transform/index.d.ts +0 -2
- package/transform/compiler-cli/src/ngtsc/transform/index.js +0 -18
- package/transform/compiler-cli/src/ngtsc/transform/src/api.d.ts +0 -115
- package/transform/compiler-cli/src/ngtsc/transform/src/api.js +0 -29
- package/transform/compiler-cli/src/ngtsc/transform/src/utils.d.ts +0 -15
- package/transform/compiler-cli/src/ngtsc/transform/src/utils.js +0 -79
- package/transform/compiler-cli/src/ngtsc/translator/index.d.ts +0 -5
- package/transform/compiler-cli/src/ngtsc/translator/index.js +0 -21
- package/transform/compiler-cli/src/ngtsc/translator/src/api/ast_factory.d.ts +0 -289
- package/transform/compiler-cli/src/ngtsc/translator/src/api/import_generator.d.ts +0 -27
- package/transform/compiler-cli/src/ngtsc/translator/src/api/import_generator.js +0 -9
- package/transform/compiler-cli/src/ngtsc/translator/src/context.d.ts +0 -18
- package/transform/compiler-cli/src/ngtsc/translator/src/context.js +0 -28
- package/transform/compiler-cli/src/ngtsc/translator/src/import_manager.d.ts +0 -47
- package/transform/compiler-cli/src/ngtsc/translator/src/import_manager.js +0 -66
- package/transform/compiler-cli/src/ngtsc/translator/src/translator.d.ts +0 -56
- package/transform/compiler-cli/src/ngtsc/translator/src/translator.js +0 -270
- package/transform/compiler-cli/src/ngtsc/translator/src/ts_util.d.ts +0 -12
- package/transform/compiler-cli/src/ngtsc/translator/src/ts_util.js +0 -27
- package/transform/compiler-cli/src/ngtsc/translator/src/typescript_ast_factory.d.ts +0 -53
- package/transform/compiler-cli/src/ngtsc/translator/src/typescript_ast_factory.js +0 -250
- package/transform/compiler-cli/src/ngtsc/translator/src/typescript_translator.d.ts +0 -13
- package/transform/compiler-cli/src/ngtsc/translator/src/typescript_translator.js +0 -21
- package/transform/compiler-cli/src/ngtsc/ts_compatibility/index.d.ts +0 -8
- package/transform/compiler-cli/src/ngtsc/ts_compatibility/index.js +0 -24
- package/transform/compiler-cli/src/ngtsc/ts_compatibility/src/ts_cross_version_utils.d.ts +0 -45
- package/transform/compiler-cli/src/ngtsc/ts_compatibility/src/ts_cross_version_utils.js +0 -86
- package/transform/compiler-cli/src/ngtsc/util/src/typescript.d.ts +0 -4
- package/transform/compiler-cli/src/ngtsc/util/src/typescript.js +0 -16
- package/transform/index.d.ts +0 -1
- package/transform/index.js +0 -17
- package/transform/injectable-transform.d.ts +0 -41
- package/transform/injectable-transform.js +0 -245
- package/transform/node-Iteration.d.ts +0 -2
- package/transform/node-Iteration.js +0 -12
- /package/{import/es2022 → es2022}/di/create_injector.js +0 -0
- /package/{import/es2022 → es2022}/di/forward_ref.js +0 -0
- /package/{import/es2022 → es2022}/di/index.js +0 -0
- /package/{import/es2022 → es2022}/di/initializer_token.js +0 -0
- /package/{import/es2022 → es2022}/di/inject_switch.js +0 -0
- /package/{import/es2022/di/injector_marker.js → es2022/di/injectable.js} +0 -0
- /package/{import/es2022 → es2022}/di/injection_token.js +0 -0
- /package/{import/es2022 → es2022}/di/injector.js +0 -0
- /package/{import/es2022 → es2022}/di/injector_compatibility.js +0 -0
- /package/{import/es2022/di/provider_token.js → es2022/di/injector_marker.js} +0 -0
- /package/{import/es2022 → es2022}/di/injector_token.js +0 -0
- /package/{import/es2022 → es2022}/di/interface/injector.js +0 -0
- /package/{import/es2022 → es2022}/di/interface/provider.js +0 -0
- /package/{import/es2022 → es2022}/di/internal_tokens.js +0 -0
- /package/{import/es2022 → es2022}/di/metadata.js +0 -0
- /package/{import/es2022 → es2022}/di/null_injector.js +0 -0
- /package/{import/es2022 → es2022}/di/provider_collection.js +0 -0
- /package/{import/es2022/interface/lifecycle_hooks.js → es2022/di/provider_token.js} +0 -0
- /package/{import/es2022 → es2022}/di/r3_injector.js +0 -0
- /package/{import/es2022 → es2022}/di/scope.js +0 -0
- /package/{import/es2022 → es2022}/di.js +0 -0
- /package/{import/es2022 → es2022}/errors.js +0 -0
- /package/{import/es2022 → es2022}/interface/type.js +0 -0
- /package/{import/es2022 → es2022}/render3/errors_di.js +0 -0
- /package/{import/es2022 → es2022}/render3/fields.js +0 -0
- /package/{import/es2022 → es2022}/render3/instructions/di.js +0 -0
- /package/{import/es2022 → es2022}/render3/util/stringify_utils.js +0 -0
- /package/{import/es2022 → es2022}/util/closure.js +0 -0
- /package/{import/es2022 → es2022}/util/empty.js +0 -0
- /package/{import/es2022 → es2022}/util/property.js +0 -0
- /package/{import/es2022 → es2022}/util/stringify.js +0 -0
- /package/{import/typings → typings}/di/create_injector.d.ts +0 -0
- /package/{import/typings → typings}/di/forward_ref.d.ts +0 -0
- /package/{import/typings → typings}/di/index.d.ts +0 -0
- /package/{import/typings → typings}/di/initializer_token.d.ts +0 -0
- /package/{import/typings → typings}/di/inject_switch.d.ts +0 -0
- /package/{import/typings → typings}/di/injection_token.d.ts +0 -0
- /package/{import/typings → typings}/di/injector.d.ts +0 -0
- /package/{import/typings → typings}/di/injector_compatibility.d.ts +0 -0
- /package/{import/typings → typings}/di/injector_marker.d.ts +0 -0
- /package/{import/typings → typings}/di/injector_token.d.ts +0 -0
- /package/{import/typings → typings}/di/interface/defs.d.ts +0 -0
- /package/{import/typings → typings}/di/interface/injector.d.ts +0 -0
- /package/{import/typings → typings}/di/interface/provider.d.ts +0 -0
- /package/{import/typings → typings}/di/internal_tokens.d.ts +0 -0
- /package/{import/typings → typings}/di/metadata.d.ts +0 -0
- /package/{import/typings → typings}/di/null_injector.d.ts +0 -0
- /package/{import/typings → typings}/di/provider_collection.d.ts +0 -0
- /package/{import/typings → typings}/di/provider_token.d.ts +0 -0
- /package/{import/typings → typings}/di/r3_injector.d.ts +0 -0
- /package/{import/typings → typings}/di/scope.d.ts +0 -0
- /package/{import/typings → typings}/di.d.ts +0 -0
- /package/{import/typings → typings}/errors.d.ts +0 -0
- /package/{import/typings → typings}/interface/lifecycle_hooks.d.ts +0 -0
- /package/{import/typings → typings}/interface/type.d.ts +0 -0
- /package/{import/typings → typings}/render3/definition_factory.d.ts +0 -0
- /package/{import/typings → typings}/render3/errors_di.d.ts +0 -0
- /package/{import/typings → typings}/render3/fields.d.ts +0 -0
- /package/{import/typings → typings}/render3/instructions/di.d.ts +0 -0
- /package/{import/typings → typings}/render3/util/stringify_utils.d.ts +0 -0
- /package/{import/typings → typings}/util/closure.d.ts +0 -0
- /package/{import/typings → typings}/util/decorators.d.ts +0 -0
- /package/{import/typings → typings}/util/empty.d.ts +0 -0
- /package/{import/typings → typings}/util/property.d.ts +0 -0
- /package/{import/typings → typings}/util/stringify.d.ts +0 -0
|
@@ -1,189 +0,0 @@
|
|
|
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
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
10
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
11
|
-
};
|
|
12
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
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
|
-
const compiler_1 = require("static-injector/transform/compiler");
|
|
15
|
-
const typescript_1 = __importDefault(require("typescript"));
|
|
16
|
-
/** Module name of the framework core. */
|
|
17
|
-
exports.CORE_MODULE = 'static-injector';
|
|
18
|
-
function valueReferenceToExpression(valueRef) {
|
|
19
|
-
if (valueRef.kind === 2 /* TypeValueReferenceKind.UNAVAILABLE */) {
|
|
20
|
-
return null;
|
|
21
|
-
}
|
|
22
|
-
else if (valueRef.kind === 0 /* TypeValueReferenceKind.LOCAL */) {
|
|
23
|
-
const expr = new compiler_1.WrappedNodeExpr(valueRef.expression);
|
|
24
|
-
return expr;
|
|
25
|
-
}
|
|
26
|
-
else {
|
|
27
|
-
let importExpr = new compiler_1.ExternalExpr({
|
|
28
|
-
moduleName: valueRef.moduleName,
|
|
29
|
-
name: valueRef.importedName,
|
|
30
|
-
});
|
|
31
|
-
if (valueRef.nestedPath !== null) {
|
|
32
|
-
for (const property of valueRef.nestedPath) {
|
|
33
|
-
importExpr = new compiler_1.ReadPropExpr(importExpr, property);
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
return importExpr;
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
exports.valueReferenceToExpression = valueReferenceToExpression;
|
|
40
|
-
function isAngularCore(decorator) {
|
|
41
|
-
return decorator.import !== null && decorator.import.from === exports.CORE_MODULE;
|
|
42
|
-
}
|
|
43
|
-
exports.isAngularCore = isAngularCore;
|
|
44
|
-
function findAngularDecorator(decorators, name, isCore) {
|
|
45
|
-
return decorators.find((decorator) => isAngularDecorator(decorator, name, isCore));
|
|
46
|
-
}
|
|
47
|
-
exports.findAngularDecorator = findAngularDecorator;
|
|
48
|
-
function isAngularDecorator(decorator, name, isCore) {
|
|
49
|
-
if (isCore) {
|
|
50
|
-
return decorator.name === name;
|
|
51
|
-
}
|
|
52
|
-
else if (isAngularCore(decorator)) {
|
|
53
|
-
return decorator.import.name === name;
|
|
54
|
-
}
|
|
55
|
-
return false;
|
|
56
|
-
}
|
|
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;
|
|
68
|
-
/**
|
|
69
|
-
* Unwrap a `ts.Expression`, removing outer type-casts or parentheses until the expression is in its
|
|
70
|
-
* lowest level form.
|
|
71
|
-
*
|
|
72
|
-
* For example, the expression "(foo as Type)" unwraps to "foo".
|
|
73
|
-
*/
|
|
74
|
-
function unwrapExpression(node) {
|
|
75
|
-
while (typescript_1.default.isAsExpression(node) || typescript_1.default.isParenthesizedExpression(node)) {
|
|
76
|
-
node = node.expression;
|
|
77
|
-
}
|
|
78
|
-
return node;
|
|
79
|
-
}
|
|
80
|
-
exports.unwrapExpression = unwrapExpression;
|
|
81
|
-
function expandForwardRef(arg) {
|
|
82
|
-
arg = unwrapExpression(arg);
|
|
83
|
-
if (!typescript_1.default.isArrowFunction(arg) && !typescript_1.default.isFunctionExpression(arg)) {
|
|
84
|
-
return null;
|
|
85
|
-
}
|
|
86
|
-
const body = arg.body;
|
|
87
|
-
// Either the body is a ts.Expression directly, or a block with a single return statement.
|
|
88
|
-
if (typescript_1.default.isBlock(body)) {
|
|
89
|
-
// Block body - look for a single return statement.
|
|
90
|
-
if (body.statements.length !== 1) {
|
|
91
|
-
return null;
|
|
92
|
-
}
|
|
93
|
-
const stmt = body.statements[0];
|
|
94
|
-
if (!typescript_1.default.isReturnStatement(stmt) || stmt.expression === undefined) {
|
|
95
|
-
return null;
|
|
96
|
-
}
|
|
97
|
-
return stmt.expression;
|
|
98
|
-
}
|
|
99
|
-
else {
|
|
100
|
-
// Shorthand body - return as an expression.
|
|
101
|
-
return body;
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
/**
|
|
105
|
-
* If the given `node` is a forwardRef() expression then resolve its inner value, otherwise return
|
|
106
|
-
* `null`.
|
|
107
|
-
*
|
|
108
|
-
* @param node the forwardRef() expression to resolve
|
|
109
|
-
* @param reflector a ReflectionHost
|
|
110
|
-
* @returns the resolved expression, if the original expression was a forwardRef(), or `null`
|
|
111
|
-
* otherwise.
|
|
112
|
-
*/
|
|
113
|
-
function tryUnwrapForwardRef(node, reflector) {
|
|
114
|
-
node = unwrapExpression(node);
|
|
115
|
-
if (!typescript_1.default.isCallExpression(node) || node.arguments.length !== 1) {
|
|
116
|
-
return null;
|
|
117
|
-
}
|
|
118
|
-
const fn = typescript_1.default.isPropertyAccessExpression(node.expression)
|
|
119
|
-
? node.expression.name
|
|
120
|
-
: node.expression;
|
|
121
|
-
if (!typescript_1.default.isIdentifier(fn)) {
|
|
122
|
-
return null;
|
|
123
|
-
}
|
|
124
|
-
const expr = expandForwardRef(node.arguments[0]);
|
|
125
|
-
if (expr === null) {
|
|
126
|
-
return null;
|
|
127
|
-
}
|
|
128
|
-
const imp = reflector.getImportOfIdentifier(fn);
|
|
129
|
-
if (imp === null ||
|
|
130
|
-
imp.from !== 'static-injector' ||
|
|
131
|
-
imp.name !== 'forwardRef') {
|
|
132
|
-
return null;
|
|
133
|
-
}
|
|
134
|
-
return expr;
|
|
135
|
-
}
|
|
136
|
-
exports.tryUnwrapForwardRef = tryUnwrapForwardRef;
|
|
137
|
-
const parensWrapperTransformerFactory = (context) => {
|
|
138
|
-
const visitor = (node) => {
|
|
139
|
-
const visited = typescript_1.default.visitEachChild(node, visitor, context);
|
|
140
|
-
if (typescript_1.default.isArrowFunction(visited) || typescript_1.default.isFunctionExpression(visited)) {
|
|
141
|
-
return typescript_1.default.factory.createParenthesizedExpression(visited);
|
|
142
|
-
}
|
|
143
|
-
return visited;
|
|
144
|
-
};
|
|
145
|
-
return (node) => typescript_1.default.visitEachChild(node, visitor, context);
|
|
146
|
-
};
|
|
147
|
-
/**
|
|
148
|
-
* Wraps all functions in a given expression in parentheses. This is needed to avoid problems
|
|
149
|
-
* where Tsickle annotations added between analyse and transform phases in Angular may trigger
|
|
150
|
-
* automatic semicolon insertion, e.g. if a function is the expression in a `return` statement.
|
|
151
|
-
* More
|
|
152
|
-
* info can be found in Tsickle source code here:
|
|
153
|
-
* https://github.com/angular/tsickle/blob/d7974262571c8a17d684e5ba07680e1b1993afdd/src/jsdoc_transformer.ts#L1021
|
|
154
|
-
*
|
|
155
|
-
* @param expression Expression where functions should be wrapped in parentheses
|
|
156
|
-
*/
|
|
157
|
-
function wrapFunctionExpressionsInParens(expression) {
|
|
158
|
-
return typescript_1.default.transform(expression, [parensWrapperTransformerFactory])
|
|
159
|
-
.transformed[0];
|
|
160
|
-
}
|
|
161
|
-
exports.wrapFunctionExpressionsInParens = wrapFunctionExpressionsInParens;
|
|
162
|
-
/**
|
|
163
|
-
* Create an R3Reference for a class.
|
|
164
|
-
*
|
|
165
|
-
* The `value` is the exported declaration of the class from its source file.
|
|
166
|
-
* The `type` is an expression that would be used in the typings (.d.ts) files.
|
|
167
|
-
*/
|
|
168
|
-
function wrapTypeReference(reflector, clazz) {
|
|
169
|
-
const value = new compiler_1.WrappedNodeExpr(clazz.name);
|
|
170
|
-
const type = value;
|
|
171
|
-
return { value, type };
|
|
172
|
-
}
|
|
173
|
-
exports.wrapTypeReference = wrapTypeReference;
|
|
174
|
-
function toFactoryMetadata(meta, target) {
|
|
175
|
-
return {
|
|
176
|
-
name: meta.name,
|
|
177
|
-
type: meta.type,
|
|
178
|
-
typeArgumentCount: meta.typeArgumentCount,
|
|
179
|
-
deps: meta.deps,
|
|
180
|
-
target,
|
|
181
|
-
};
|
|
182
|
-
}
|
|
183
|
-
exports.toFactoryMetadata = toFactoryMetadata;
|
|
184
|
-
function isAbstractClassDeclaration(clazz) {
|
|
185
|
-
return typescript_1.default.canHaveModifiers(clazz) && clazz.modifiers !== undefined
|
|
186
|
-
? clazz.modifiers.some((mod) => mod.kind === typescript_1.default.SyntaxKind.AbstractKeyword)
|
|
187
|
-
: false;
|
|
188
|
-
}
|
|
189
|
-
exports.isAbstractClassDeclaration = isAbstractClassDeclaration;
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license
|
|
3
|
-
* Copyright Google LLC All Rights Reserved.
|
|
4
|
-
*
|
|
5
|
-
* Use of this source code is governed by an MIT-style license that can be
|
|
6
|
-
* found in the LICENSE file at https://angular.io/license
|
|
7
|
-
*/
|
|
8
|
-
import { R3DependencyMetadata, R3InjectableMetadata } from 'static-injector/transform/compiler';
|
|
9
|
-
import { ClassDeclaration, Decorator, ReflectionHost } from '../../reflection';
|
|
10
|
-
import { AnalysisOutput, CompilationMode, CompileResult, DecoratorHandler, DetectResult } from '../../transform';
|
|
11
|
-
export interface InjectableHandlerData {
|
|
12
|
-
meta: R3InjectableMetadata;
|
|
13
|
-
ctorDeps: R3DependencyMetadata[] | 'invalid' | null;
|
|
14
|
-
}
|
|
15
|
-
/**
|
|
16
|
-
* Adapts the `compileInjectable` compiler for `@Injectable` decorators to the Ivy compiler.
|
|
17
|
-
*/
|
|
18
|
-
export declare class InjectableDecoratorHandler implements DecoratorHandler<Decorator, InjectableHandlerData, unknown> {
|
|
19
|
-
private reflector;
|
|
20
|
-
private isCore;
|
|
21
|
-
private strictCtorDeps;
|
|
22
|
-
private includeClassMetadata;
|
|
23
|
-
private readonly compilationMode;
|
|
24
|
-
/**
|
|
25
|
-
* What to do if the injectable already contains a ɵprov property.
|
|
26
|
-
*
|
|
27
|
-
* If true then an error diagnostic is reported.
|
|
28
|
-
* If false then there is no error and a new ɵprov property is not added.
|
|
29
|
-
*/
|
|
30
|
-
private errorOnDuplicateProv;
|
|
31
|
-
constructor(reflector: ReflectionHost, isCore: boolean, strictCtorDeps: boolean, includeClassMetadata: boolean, compilationMode: CompilationMode,
|
|
32
|
-
/**
|
|
33
|
-
* What to do if the injectable already contains a ɵprov property.
|
|
34
|
-
*
|
|
35
|
-
* If true then an error diagnostic is reported.
|
|
36
|
-
* If false then there is no error and a new ɵprov property is not added.
|
|
37
|
-
*/
|
|
38
|
-
errorOnDuplicateProv?: boolean);
|
|
39
|
-
detect(node: ClassDeclaration, decorators: Decorator[] | null): DetectResult<Decorator> | undefined;
|
|
40
|
-
analyze(node: ClassDeclaration, decorator: Readonly<Decorator>): AnalysisOutput<InjectableHandlerData>;
|
|
41
|
-
compileFull(node: ClassDeclaration, analysis: Readonly<InjectableHandlerData>): CompileResult[];
|
|
42
|
-
private compile;
|
|
43
|
-
}
|
|
@@ -1,277 +0,0 @@
|
|
|
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
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
10
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
11
|
-
};
|
|
12
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
-
exports.InjectableDecoratorHandler = void 0;
|
|
14
|
-
const compiler_1 = require("static-injector/transform/compiler");
|
|
15
|
-
const typescript_1 = __importDefault(require("typescript"));
|
|
16
|
-
const common_1 = require("../../annotations/common");
|
|
17
|
-
const diagnostics_1 = require("../../diagnostics");
|
|
18
|
-
const reflection_1 = require("../../reflection");
|
|
19
|
-
const common_2 = require("../common");
|
|
20
|
-
/**
|
|
21
|
-
* Adapts the `compileInjectable` compiler for `@Injectable` decorators to the Ivy compiler.
|
|
22
|
-
*/
|
|
23
|
-
class InjectableDecoratorHandler {
|
|
24
|
-
reflector;
|
|
25
|
-
isCore;
|
|
26
|
-
strictCtorDeps;
|
|
27
|
-
includeClassMetadata;
|
|
28
|
-
compilationMode;
|
|
29
|
-
errorOnDuplicateProv;
|
|
30
|
-
constructor(reflector, isCore, strictCtorDeps, includeClassMetadata, compilationMode,
|
|
31
|
-
/**
|
|
32
|
-
* What to do if the injectable already contains a ɵprov property.
|
|
33
|
-
*
|
|
34
|
-
* If true then an error diagnostic is reported.
|
|
35
|
-
* If false then there is no error and a new ɵprov property is not added.
|
|
36
|
-
*/
|
|
37
|
-
errorOnDuplicateProv = true) {
|
|
38
|
-
this.reflector = reflector;
|
|
39
|
-
this.isCore = isCore;
|
|
40
|
-
this.strictCtorDeps = strictCtorDeps;
|
|
41
|
-
this.includeClassMetadata = includeClassMetadata;
|
|
42
|
-
this.compilationMode = compilationMode;
|
|
43
|
-
this.errorOnDuplicateProv = errorOnDuplicateProv;
|
|
44
|
-
}
|
|
45
|
-
detect(node, decorators) {
|
|
46
|
-
if (!decorators) {
|
|
47
|
-
return undefined;
|
|
48
|
-
}
|
|
49
|
-
const decorator = (0, common_2.findAngularDecorator)(decorators, 'Injectable', this.isCore);
|
|
50
|
-
if (decorator !== undefined) {
|
|
51
|
-
return {
|
|
52
|
-
trigger: decorator.node,
|
|
53
|
-
decorator: decorator,
|
|
54
|
-
metadata: decorator,
|
|
55
|
-
};
|
|
56
|
-
}
|
|
57
|
-
else {
|
|
58
|
-
return undefined;
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
analyze(node, decorator) {
|
|
62
|
-
const meta = extractInjectableMetadata(node, decorator, this.reflector);
|
|
63
|
-
return {
|
|
64
|
-
analysis: {
|
|
65
|
-
meta,
|
|
66
|
-
ctorDeps: extractInjectableCtorDeps(node, meta, decorator, this.reflector, this.isCore, this.strictCtorDeps),
|
|
67
|
-
// Avoid generating multiple factories if a class has
|
|
68
|
-
// more Angular decorators, apart from Injectable.
|
|
69
|
-
},
|
|
70
|
-
};
|
|
71
|
-
}
|
|
72
|
-
compileFull(node, analysis) {
|
|
73
|
-
return this.compile(common_2.compileNgFactoryDefField, (meta) => (0, compiler_1.compileInjectable)(meta, false), node, analysis);
|
|
74
|
-
}
|
|
75
|
-
compile(compileFactoryFn, compileInjectableFn, node, analysis) {
|
|
76
|
-
const results = [];
|
|
77
|
-
if (true) {
|
|
78
|
-
const meta = analysis.meta;
|
|
79
|
-
const factoryRes = compileFactoryFn((0, common_2.toFactoryMetadata)({ ...meta, deps: analysis.ctorDeps }, compiler_1.FactoryTarget.Injectable));
|
|
80
|
-
results.push(factoryRes);
|
|
81
|
-
}
|
|
82
|
-
const ɵprov = this.reflector
|
|
83
|
-
.getMembersOfClass(node)
|
|
84
|
-
.find((member) => member.name === 'ɵprov');
|
|
85
|
-
if (ɵprov !== undefined && this.errorOnDuplicateProv) {
|
|
86
|
-
throw new diagnostics_1.FatalDiagnosticError(diagnostics_1.ErrorCode.INJECTABLE_DUPLICATE_PROV, ɵprov.nameNode || ɵprov.node || node, 'Injectables cannot contain a static ɵprov property, because the compiler is going to generate one.');
|
|
87
|
-
}
|
|
88
|
-
if (ɵprov === undefined) {
|
|
89
|
-
// Only add a new ɵprov if there is not one already
|
|
90
|
-
const res = compileInjectableFn(analysis.meta);
|
|
91
|
-
results.push({
|
|
92
|
-
name: 'ɵprov',
|
|
93
|
-
initializer: res.expression,
|
|
94
|
-
statements: res.statements,
|
|
95
|
-
type: res.type,
|
|
96
|
-
deferrableImports: null,
|
|
97
|
-
});
|
|
98
|
-
}
|
|
99
|
-
return results;
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
exports.InjectableDecoratorHandler = InjectableDecoratorHandler;
|
|
103
|
-
/**
|
|
104
|
-
* Read metadata from the `@Injectable` decorator and produce the `IvyInjectableMetadata`, the
|
|
105
|
-
* input metadata needed to run `compileInjectable`.
|
|
106
|
-
*
|
|
107
|
-
* A `null` return value indicates this is @Injectable has invalid data.
|
|
108
|
-
*/
|
|
109
|
-
function extractInjectableMetadata(clazz, decorator, reflector) {
|
|
110
|
-
const name = clazz.name.text;
|
|
111
|
-
const type = (0, common_2.wrapTypeReference)(reflector, clazz);
|
|
112
|
-
const typeArgumentCount = reflector.getGenericArityOfClass(clazz) || 0;
|
|
113
|
-
if (decorator.args === null) {
|
|
114
|
-
throw new diagnostics_1.FatalDiagnosticError(diagnostics_1.ErrorCode.DECORATOR_NOT_CALLED, decorator.node, '@Injectable must be called');
|
|
115
|
-
}
|
|
116
|
-
if (decorator.args.length === 0) {
|
|
117
|
-
return {
|
|
118
|
-
name,
|
|
119
|
-
type,
|
|
120
|
-
typeArgumentCount,
|
|
121
|
-
providedIn: (0, compiler_1.createMayBeForwardRefExpression)(new compiler_1.LiteralExpr(null), 0 /* ForwardRefHandling.None */),
|
|
122
|
-
};
|
|
123
|
-
}
|
|
124
|
-
else if (decorator.args.length === 1) {
|
|
125
|
-
const metaNode = decorator.args[0];
|
|
126
|
-
// Firstly make sure the decorator argument is an inline literal - if not, it's illegal to
|
|
127
|
-
// transport references from one location to another. This is the problem that lowering
|
|
128
|
-
// used to solve - if this restriction proves too undesirable we can re-implement lowering.
|
|
129
|
-
if (!typescript_1.default.isObjectLiteralExpression(metaNode)) {
|
|
130
|
-
throw new diagnostics_1.FatalDiagnosticError(diagnostics_1.ErrorCode.DECORATOR_ARG_NOT_LITERAL, metaNode, `@Injectable argument must be an object literal`);
|
|
131
|
-
}
|
|
132
|
-
// Resolve the fields of the literal into a map of field name to expression.
|
|
133
|
-
const meta = (0, reflection_1.reflectObjectLiteral)(metaNode);
|
|
134
|
-
const providedIn = meta.has('providedIn')
|
|
135
|
-
? getProviderExpression(meta.get('providedIn'), reflector)
|
|
136
|
-
: (0, compiler_1.createMayBeForwardRefExpression)(new compiler_1.LiteralExpr(null), 0 /* ForwardRefHandling.None */);
|
|
137
|
-
let deps = undefined;
|
|
138
|
-
if ((meta.has('useClass') || meta.has('useFactory')) && meta.has('deps')) {
|
|
139
|
-
const depsExpr = meta.get('deps');
|
|
140
|
-
if (!typescript_1.default.isArrayLiteralExpression(depsExpr)) {
|
|
141
|
-
throw new diagnostics_1.FatalDiagnosticError(diagnostics_1.ErrorCode.VALUE_NOT_LITERAL, depsExpr, `@Injectable deps metadata must be an inline array`);
|
|
142
|
-
}
|
|
143
|
-
deps = depsExpr.elements.map((dep) => getDep(dep, reflector));
|
|
144
|
-
}
|
|
145
|
-
const result = {
|
|
146
|
-
name,
|
|
147
|
-
type,
|
|
148
|
-
typeArgumentCount,
|
|
149
|
-
providedIn,
|
|
150
|
-
};
|
|
151
|
-
if (meta.has('useValue')) {
|
|
152
|
-
result.useValue = getProviderExpression(meta.get('useValue'), reflector);
|
|
153
|
-
}
|
|
154
|
-
else if (meta.has('useExisting')) {
|
|
155
|
-
result.useExisting = getProviderExpression(meta.get('useExisting'), reflector);
|
|
156
|
-
}
|
|
157
|
-
else if (meta.has('useClass')) {
|
|
158
|
-
result.useClass = getProviderExpression(meta.get('useClass'), reflector);
|
|
159
|
-
result.deps = deps;
|
|
160
|
-
}
|
|
161
|
-
else if (meta.has('useFactory')) {
|
|
162
|
-
result.useFactory = new compiler_1.WrappedNodeExpr(meta.get('useFactory'));
|
|
163
|
-
result.deps = deps;
|
|
164
|
-
}
|
|
165
|
-
return result;
|
|
166
|
-
}
|
|
167
|
-
else {
|
|
168
|
-
throw new diagnostics_1.FatalDiagnosticError(diagnostics_1.ErrorCode.DECORATOR_ARITY_WRONG, decorator.args[2], 'Too many arguments to @Injectable');
|
|
169
|
-
}
|
|
170
|
-
}
|
|
171
|
-
/**
|
|
172
|
-
* Get the `R3ProviderExpression` for this `expression`.
|
|
173
|
-
*
|
|
174
|
-
* The `useValue`, `useExisting` and `useClass` properties might be wrapped in a `ForwardRef`, which
|
|
175
|
-
* needs to be unwrapped. This function will do that unwrapping and set a flag on the returned
|
|
176
|
-
* object to indicate whether the value needed unwrapping.
|
|
177
|
-
*/
|
|
178
|
-
function getProviderExpression(expression, reflector) {
|
|
179
|
-
const forwardRefValue = (0, common_2.tryUnwrapForwardRef)(expression, reflector);
|
|
180
|
-
return (0, compiler_1.createMayBeForwardRefExpression)(new compiler_1.WrappedNodeExpr(forwardRefValue ?? expression), forwardRefValue !== null
|
|
181
|
-
? 2 /* ForwardRefHandling.Unwrapped */
|
|
182
|
-
: 0 /* ForwardRefHandling.None */);
|
|
183
|
-
}
|
|
184
|
-
function extractInjectableCtorDeps(clazz, meta, decorator, reflector, isCore, strictCtorDeps) {
|
|
185
|
-
if (decorator.args === null) {
|
|
186
|
-
throw new diagnostics_1.FatalDiagnosticError(diagnostics_1.ErrorCode.DECORATOR_NOT_CALLED, decorator.node, '@Injectable must be called');
|
|
187
|
-
}
|
|
188
|
-
let ctorDeps = null;
|
|
189
|
-
if (decorator.args.length === 0) {
|
|
190
|
-
// Ideally, using @Injectable() would have the same effect as using @Injectable({...}), and be
|
|
191
|
-
// subject to the same validation. However, existing Angular code abuses @Injectable, applying
|
|
192
|
-
// it to things like abstract classes with constructors that were never meant for use with
|
|
193
|
-
// Angular's DI.
|
|
194
|
-
//
|
|
195
|
-
// To deal with this, @Injectable() without an argument is more lenient, and if the
|
|
196
|
-
// constructor signature does not work for DI then a factory definition (ɵfac) that throws is
|
|
197
|
-
// generated.
|
|
198
|
-
if (strictCtorDeps && !(0, common_1.isAbstractClassDeclaration)(clazz)) {
|
|
199
|
-
ctorDeps = (0, common_2.getValidConstructorDependencies)(clazz, reflector, isCore);
|
|
200
|
-
}
|
|
201
|
-
else {
|
|
202
|
-
ctorDeps = (0, common_2.unwrapConstructorDependencies)((0, common_2.getConstructorDependencies)(clazz, reflector, isCore));
|
|
203
|
-
}
|
|
204
|
-
return ctorDeps;
|
|
205
|
-
}
|
|
206
|
-
else if (decorator.args.length === 1) {
|
|
207
|
-
const rawCtorDeps = (0, common_2.getConstructorDependencies)(clazz, reflector, isCore);
|
|
208
|
-
if (strictCtorDeps &&
|
|
209
|
-
!(0, common_1.isAbstractClassDeclaration)(clazz) &&
|
|
210
|
-
requiresValidCtor(meta)) {
|
|
211
|
-
// Since use* was not provided for a concrete class, validate the deps according to
|
|
212
|
-
// strictCtorDeps.
|
|
213
|
-
ctorDeps = (0, common_2.validateConstructorDependencies)(clazz, rawCtorDeps);
|
|
214
|
-
}
|
|
215
|
-
else {
|
|
216
|
-
ctorDeps = (0, common_2.unwrapConstructorDependencies)(rawCtorDeps);
|
|
217
|
-
}
|
|
218
|
-
}
|
|
219
|
-
return ctorDeps;
|
|
220
|
-
}
|
|
221
|
-
function requiresValidCtor(meta) {
|
|
222
|
-
return (meta.useValue === undefined &&
|
|
223
|
-
meta.useExisting === undefined &&
|
|
224
|
-
meta.useClass === undefined &&
|
|
225
|
-
meta.useFactory === undefined);
|
|
226
|
-
}
|
|
227
|
-
function getDep(dep, reflector) {
|
|
228
|
-
const meta = {
|
|
229
|
-
token: new compiler_1.WrappedNodeExpr(dep),
|
|
230
|
-
attributeNameType: null,
|
|
231
|
-
optional: false,
|
|
232
|
-
self: false,
|
|
233
|
-
skipSelf: false,
|
|
234
|
-
};
|
|
235
|
-
function maybeUpdateDecorator(dec, reflector, token) {
|
|
236
|
-
const source = reflector.getImportOfIdentifier(dec);
|
|
237
|
-
if (source === null || source.from !== 'static-injector') {
|
|
238
|
-
return false;
|
|
239
|
-
}
|
|
240
|
-
switch (source.name) {
|
|
241
|
-
case 'Inject':
|
|
242
|
-
if (token !== undefined) {
|
|
243
|
-
meta.token = new compiler_1.WrappedNodeExpr(token);
|
|
244
|
-
}
|
|
245
|
-
break;
|
|
246
|
-
case 'Optional':
|
|
247
|
-
meta.optional = true;
|
|
248
|
-
break;
|
|
249
|
-
case 'SkipSelf':
|
|
250
|
-
meta.skipSelf = true;
|
|
251
|
-
break;
|
|
252
|
-
case 'Self':
|
|
253
|
-
meta.self = true;
|
|
254
|
-
break;
|
|
255
|
-
default:
|
|
256
|
-
return false;
|
|
257
|
-
}
|
|
258
|
-
return true;
|
|
259
|
-
}
|
|
260
|
-
if (typescript_1.default.isArrayLiteralExpression(dep)) {
|
|
261
|
-
dep.elements.forEach((el) => {
|
|
262
|
-
let isDecorator = false;
|
|
263
|
-
if (typescript_1.default.isIdentifier(el)) {
|
|
264
|
-
isDecorator = maybeUpdateDecorator(el, reflector);
|
|
265
|
-
}
|
|
266
|
-
else if (typescript_1.default.isNewExpression(el) && typescript_1.default.isIdentifier(el.expression)) {
|
|
267
|
-
const token = (el.arguments && el.arguments.length > 0 && el.arguments[0]) ||
|
|
268
|
-
undefined;
|
|
269
|
-
isDecorator = maybeUpdateDecorator(el.expression, reflector, token);
|
|
270
|
-
}
|
|
271
|
-
if (!isDecorator) {
|
|
272
|
-
meta.token = new compiler_1.WrappedNodeExpr(el);
|
|
273
|
-
}
|
|
274
|
-
});
|
|
275
|
-
}
|
|
276
|
-
return meta;
|
|
277
|
-
}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license
|
|
3
|
-
* Copyright Google LLC All Rights Reserved.
|
|
4
|
-
*
|
|
5
|
-
* Use of this source code is governed by an MIT-style license that can be
|
|
6
|
-
* found in the LICENSE file at https://angular.io/license
|
|
7
|
-
*/
|
|
8
|
-
import * as ts from 'typescript';
|
|
9
|
-
import { ErrorCode } from './error_code';
|
|
10
|
-
export declare class FatalDiagnosticError {
|
|
11
|
-
readonly code: ErrorCode;
|
|
12
|
-
readonly node: ts.Node;
|
|
13
|
-
readonly message: string | ts.DiagnosticMessageChain;
|
|
14
|
-
readonly relatedInformation?: ts.DiagnosticRelatedInformation[] | undefined;
|
|
15
|
-
constructor(code: ErrorCode, node: ts.Node, message: string | ts.DiagnosticMessageChain, relatedInformation?: ts.DiagnosticRelatedInformation[] | undefined);
|
|
16
|
-
/**
|
|
17
|
-
* @internal
|
|
18
|
-
*/
|
|
19
|
-
_isFatalDiagnosticError: boolean;
|
|
20
|
-
toDiagnostic(): ts.DiagnosticWithLocation;
|
|
21
|
-
}
|
|
22
|
-
export declare function makeDiagnostic(code: ErrorCode, node: ts.Node, messageText: string | ts.DiagnosticMessageChain, relatedInformation?: ts.DiagnosticRelatedInformation[]): ts.DiagnosticWithLocation;
|
|
23
|
-
export declare function makeRelatedInformation(node: ts.Node, messageText: string): ts.DiagnosticRelatedInformation;
|
|
24
|
-
export declare function isFatalDiagnosticError(err: any): err is FatalDiagnosticError;
|
|
@@ -1,84 +0,0 @@
|
|
|
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
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
12
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
13
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
14
|
-
}
|
|
15
|
-
Object.defineProperty(o, k2, desc);
|
|
16
|
-
}) : (function(o, m, k, k2) {
|
|
17
|
-
if (k2 === undefined) k2 = k;
|
|
18
|
-
o[k2] = m[k];
|
|
19
|
-
}));
|
|
20
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
21
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
22
|
-
}) : function(o, v) {
|
|
23
|
-
o["default"] = v;
|
|
24
|
-
});
|
|
25
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
26
|
-
if (mod && mod.__esModule) return mod;
|
|
27
|
-
var result = {};
|
|
28
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
29
|
-
__setModuleDefault(result, mod);
|
|
30
|
-
return result;
|
|
31
|
-
};
|
|
32
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
33
|
-
exports.isFatalDiagnosticError = exports.makeRelatedInformation = exports.makeDiagnostic = exports.FatalDiagnosticError = void 0;
|
|
34
|
-
const ts = __importStar(require("typescript"));
|
|
35
|
-
const error_code_1 = require("./error_code");
|
|
36
|
-
class FatalDiagnosticError {
|
|
37
|
-
code;
|
|
38
|
-
node;
|
|
39
|
-
message;
|
|
40
|
-
relatedInformation;
|
|
41
|
-
constructor(code, node, message, relatedInformation) {
|
|
42
|
-
this.code = code;
|
|
43
|
-
this.node = node;
|
|
44
|
-
this.message = message;
|
|
45
|
-
this.relatedInformation = relatedInformation;
|
|
46
|
-
}
|
|
47
|
-
/**
|
|
48
|
-
* @internal
|
|
49
|
-
*/
|
|
50
|
-
_isFatalDiagnosticError = true;
|
|
51
|
-
toDiagnostic() {
|
|
52
|
-
return makeDiagnostic(this.code, this.node, this.message, this.relatedInformation);
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
exports.FatalDiagnosticError = FatalDiagnosticError;
|
|
56
|
-
function makeDiagnostic(code, node, messageText, relatedInformation) {
|
|
57
|
-
node = ts.getOriginalNode(node);
|
|
58
|
-
return {
|
|
59
|
-
category: ts.DiagnosticCategory.Error,
|
|
60
|
-
code: (0, error_code_1.ngErrorCode)(code),
|
|
61
|
-
file: ts.getOriginalNode(node).getSourceFile(),
|
|
62
|
-
start: node.getStart(undefined, false),
|
|
63
|
-
length: node.getWidth(),
|
|
64
|
-
messageText,
|
|
65
|
-
relatedInformation,
|
|
66
|
-
};
|
|
67
|
-
}
|
|
68
|
-
exports.makeDiagnostic = makeDiagnostic;
|
|
69
|
-
function makeRelatedInformation(node, messageText) {
|
|
70
|
-
node = ts.getOriginalNode(node);
|
|
71
|
-
return {
|
|
72
|
-
category: ts.DiagnosticCategory.Message,
|
|
73
|
-
code: 0,
|
|
74
|
-
file: node.getSourceFile(),
|
|
75
|
-
start: node.getStart(),
|
|
76
|
-
length: node.getWidth(),
|
|
77
|
-
messageText,
|
|
78
|
-
};
|
|
79
|
-
}
|
|
80
|
-
exports.makeRelatedInformation = makeRelatedInformation;
|
|
81
|
-
function isFatalDiagnosticError(err) {
|
|
82
|
-
return err._isFatalDiagnosticError === true;
|
|
83
|
-
}
|
|
84
|
-
exports.isFatalDiagnosticError = isFatalDiagnosticError;
|