static-injector 4.0.2 → 5.0.0-alpha.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 +32 -12
- 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,24 +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 __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
21
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
22
|
-
};
|
|
23
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
24
|
-
__exportStar(require("./src/ts_cross_version_utils"), exports);
|
|
@@ -1,45 +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 ts from 'typescript';
|
|
9
|
-
/** Type of `ts.factory.CreateParameterDeclaration` in TS 4.9+. */
|
|
10
|
-
type Ts49CreateParameterDeclarationFn = (modifiers: readonly ts.ModifierLike[] | undefined, dotDotDotToken: ts.DotDotDotToken | undefined, name: string | ts.BindingName, questionToken?: ts.QuestionToken | undefined, type?: ts.TypeNode | undefined, initializer?: ts.Expression) => ts.ParameterDeclaration;
|
|
11
|
-
/**
|
|
12
|
-
* Creates a `ts.ParameterDeclaration` declaration.
|
|
13
|
-
*
|
|
14
|
-
* TODO(crisbeto): this is a backwards-compatibility layer for versions of TypeScript less than 4.9.
|
|
15
|
-
* We should remove it once we have dropped support for the older versions.
|
|
16
|
-
*/
|
|
17
|
-
export declare const createParameterDeclaration: Ts49CreateParameterDeclarationFn;
|
|
18
|
-
/** Type of `ts.factory.createImportDeclaration` in TS 4.9+. */
|
|
19
|
-
type Ts49CreateImportDeclarationFn = (modifiers: readonly ts.Modifier[] | undefined, importClause: ts.ImportClause | undefined, moduleSpecifier: ts.Expression, assertClause?: ts.AssertClause) => ts.ImportDeclaration;
|
|
20
|
-
/**
|
|
21
|
-
* Creates a `ts.ImportDeclaration` declaration.
|
|
22
|
-
*
|
|
23
|
-
* TODO(crisbeto): this is a backwards-compatibility layer for versions of TypeScript less than 4.9.
|
|
24
|
-
* We should remove it once we have dropped support for the older versions.
|
|
25
|
-
*/
|
|
26
|
-
export declare const createImportDeclaration: Ts49CreateImportDeclarationFn;
|
|
27
|
-
/** Type of `ts.factory.createFunctionDeclaration` in TS 4.9+. */
|
|
28
|
-
type Ts49CreateFunctionDeclarationFn = (modifiers: readonly ts.ModifierLike[] | undefined, asteriskToken: ts.AsteriskToken | undefined, name: string | ts.Identifier | undefined, typeParameters: readonly ts.TypeParameterDeclaration[] | undefined, parameters: readonly ts.ParameterDeclaration[], type: ts.TypeNode | undefined, body: ts.Block | undefined) => ts.FunctionDeclaration;
|
|
29
|
-
/**
|
|
30
|
-
* Creates a `ts.FunctionDeclaration` declaration.
|
|
31
|
-
*
|
|
32
|
-
* TODO(crisbeto): this is a backwards-compatibility layer for versions of TypeScript less than 4.9.
|
|
33
|
-
* We should remove it once we have dropped support for the older versions.
|
|
34
|
-
*/
|
|
35
|
-
export declare const createFunctionDeclaration: Ts49CreateFunctionDeclarationFn;
|
|
36
|
-
/** Type of `ts.factory.createIndexSignature` in TS 4.9+. */
|
|
37
|
-
type Ts49CreateIndexSignatureFn = (modifiers: readonly ts.Modifier[] | undefined, parameters: readonly ts.ParameterDeclaration[], type: ts.TypeNode) => ts.IndexSignatureDeclaration;
|
|
38
|
-
/**
|
|
39
|
-
* Creates a `ts.IndexSignatureDeclaration` declaration.
|
|
40
|
-
*
|
|
41
|
-
* TODO(crisbeto): this is a backwards-compatibility layer for versions of TypeScript less than 4.9.
|
|
42
|
-
* We should remove it once we have dropped support for the older versions.
|
|
43
|
-
*/
|
|
44
|
-
export declare const createIndexSignature: Ts49CreateIndexSignatureFn;
|
|
45
|
-
export {};
|
|
@@ -1,86 +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.createIndexSignature = exports.createFunctionDeclaration = exports.createImportDeclaration = exports.createParameterDeclaration = void 0;
|
|
14
|
-
const typescript_1 = __importDefault(require("typescript"));
|
|
15
|
-
/** Whether the current TypeScript version is after 4.9. */
|
|
16
|
-
const IS_AFTER_TS_49 = isAfterVersion(4, 9);
|
|
17
|
-
/**
|
|
18
|
-
* Creates a `ts.ParameterDeclaration` declaration.
|
|
19
|
-
*
|
|
20
|
-
* TODO(crisbeto): this is a backwards-compatibility layer for versions of TypeScript less than 4.9.
|
|
21
|
-
* We should remove it once we have dropped support for the older versions.
|
|
22
|
-
*/
|
|
23
|
-
exports.createParameterDeclaration = IS_AFTER_TS_49
|
|
24
|
-
? typescript_1.default.factory.createParameterDeclaration
|
|
25
|
-
: (modifiers, dotDotDotToken, name, questionToken, type, initializer) => typescript_1.default.factory.createParameterDeclaration(...splitModifiers(modifiers), dotDotDotToken, name, questionToken, type, initializer);
|
|
26
|
-
/**
|
|
27
|
-
* Creates a `ts.ImportDeclaration` declaration.
|
|
28
|
-
*
|
|
29
|
-
* TODO(crisbeto): this is a backwards-compatibility layer for versions of TypeScript less than 4.9.
|
|
30
|
-
* We should remove it once we have dropped support for the older versions.
|
|
31
|
-
*/
|
|
32
|
-
exports.createImportDeclaration = IS_AFTER_TS_49
|
|
33
|
-
? typescript_1.default.factory.createImportDeclaration
|
|
34
|
-
: (modifiers, importClause, moduleSpecifier, assertClause) => typescript_1.default.factory.createImportDeclaration(undefined, modifiers, importClause, moduleSpecifier, assertClause);
|
|
35
|
-
/**
|
|
36
|
-
* Creates a `ts.FunctionDeclaration` declaration.
|
|
37
|
-
*
|
|
38
|
-
* TODO(crisbeto): this is a backwards-compatibility layer for versions of TypeScript less than 4.9.
|
|
39
|
-
* We should remove it once we have dropped support for the older versions.
|
|
40
|
-
*/
|
|
41
|
-
exports.createFunctionDeclaration = IS_AFTER_TS_49
|
|
42
|
-
? typescript_1.default.factory.createFunctionDeclaration
|
|
43
|
-
: (modifiers, asteriskToken, name, typeParameters, parameters, type, body) => typescript_1.default.factory.createFunctionDeclaration(...splitModifiers(modifiers), asteriskToken, name, typeParameters, parameters, type, body);
|
|
44
|
-
/**
|
|
45
|
-
* Creates a `ts.IndexSignatureDeclaration` declaration.
|
|
46
|
-
*
|
|
47
|
-
* TODO(crisbeto): this is a backwards-compatibility layer for versions of TypeScript less than 4.9.
|
|
48
|
-
* We should remove it once we have dropped support for the older versions.
|
|
49
|
-
*/
|
|
50
|
-
exports.createIndexSignature = IS_AFTER_TS_49
|
|
51
|
-
? typescript_1.default.factory.createIndexSignature
|
|
52
|
-
: (modifiers, parameters, type) => typescript_1.default.factory.createIndexSignature(modifiers, parameters, type);
|
|
53
|
-
/**
|
|
54
|
-
* Splits a `ModifierLike` into two arrays: decorators and modifiers. Used for backwards
|
|
55
|
-
* compatibility with TS 4.7 and below where most factory functions require separate `decorators`
|
|
56
|
-
* and `modifiers` arrays.
|
|
57
|
-
*/
|
|
58
|
-
function splitModifiers(allModifiers) {
|
|
59
|
-
if (!allModifiers) {
|
|
60
|
-
return [undefined, undefined];
|
|
61
|
-
}
|
|
62
|
-
const decorators = [];
|
|
63
|
-
const modifiers = [];
|
|
64
|
-
for (const current of allModifiers) {
|
|
65
|
-
if (typescript_1.default.isDecorator(current)) {
|
|
66
|
-
decorators.push(current);
|
|
67
|
-
}
|
|
68
|
-
else {
|
|
69
|
-
modifiers.push(current);
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
return [
|
|
73
|
-
decorators.length ? decorators : undefined,
|
|
74
|
-
modifiers.length ? modifiers : undefined,
|
|
75
|
-
];
|
|
76
|
-
}
|
|
77
|
-
/** Checks if the current version of TypeScript is after the specified major/minor versions. */
|
|
78
|
-
function isAfterVersion(targetMajor, targetMinor) {
|
|
79
|
-
const [major, minor] = typescript_1.default.versionMajorMinor
|
|
80
|
-
.split('.')
|
|
81
|
-
.map((part) => parseInt(part));
|
|
82
|
-
if (major < targetMajor) {
|
|
83
|
-
return false;
|
|
84
|
-
}
|
|
85
|
-
return major === targetMajor ? minor >= targetMinor : true;
|
|
86
|
-
}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.identifierOfNode = void 0;
|
|
7
|
-
const typescript_1 = __importDefault(require("typescript"));
|
|
8
|
-
function identifierOfNode(decl) {
|
|
9
|
-
if (decl.name !== undefined && typescript_1.default.isIdentifier(decl.name)) {
|
|
10
|
-
return decl.name;
|
|
11
|
-
}
|
|
12
|
-
else {
|
|
13
|
-
return null;
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
exports.identifierOfNode = identifierOfNode;
|
package/transform/index.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './injectable-transform';
|
package/transform/index.js
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./injectable-transform"), exports);
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import ts from 'typescript';
|
|
2
|
-
import { InjectableDecoratorHandler } from './compiler-cli/src/ngtsc/annotations/src/injectable';
|
|
3
|
-
import { TypeScriptReflectionHost } from './compiler-cli/src/ngtsc/reflection';
|
|
4
|
-
export interface InjectableTransformerFactoryOptions {
|
|
5
|
-
strictCtorDeps?: boolean;
|
|
6
|
-
}
|
|
7
|
-
export declare function createTransformer(program: ts.Program, options?: InjectableTransformerFactoryOptions): (context: ts.TransformationContext) => (sf: ts.SourceFile) => ts.SourceFile;
|
|
8
|
-
export declare class InjectableTransformerFactory {
|
|
9
|
-
private program;
|
|
10
|
-
private options;
|
|
11
|
-
typeChecker: ts.TypeChecker;
|
|
12
|
-
reflectionHost: TypeScriptReflectionHost;
|
|
13
|
-
handler: InjectableDecoratorHandler;
|
|
14
|
-
constructor(program: ts.Program, options?: InjectableTransformerFactoryOptions);
|
|
15
|
-
getTransform(): (context: ts.TransformationContext) => (sf: ts.SourceFile) => ts.SourceFile;
|
|
16
|
-
private visit;
|
|
17
|
-
private transform;
|
|
18
|
-
private preAnalysis;
|
|
19
|
-
private translate;
|
|
20
|
-
/**
|
|
21
|
-
* Remove Angular decorators from a `ts.Node` in a shallow manner.
|
|
22
|
-
*
|
|
23
|
-
* This will remove decorators from class elements (getters, setters, properties, methods) as well
|
|
24
|
-
* as parameters of constructors.
|
|
25
|
-
*/
|
|
26
|
-
private _stripAngularDecorators;
|
|
27
|
-
/**
|
|
28
|
-
* Return all decorators on a `Declaration` which are from static-injector, or an empty set if none
|
|
29
|
-
* are.
|
|
30
|
-
*/
|
|
31
|
-
private _angularCoreDecorators;
|
|
32
|
-
/**
|
|
33
|
-
* Given a `ts.Node`, filter the decorators array and return a version containing only non-Angular
|
|
34
|
-
* decorators.
|
|
35
|
-
*
|
|
36
|
-
* If all decorators are removed (or none existed in the first place), this method returns
|
|
37
|
-
* `undefined`.
|
|
38
|
-
*/
|
|
39
|
-
private _nonCoreDecoratorsOnly;
|
|
40
|
-
private updateStatements;
|
|
41
|
-
}
|
|
@@ -1,245 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.InjectableTransformerFactory = exports.createTransformer = void 0;
|
|
7
|
-
const typescript_1 = __importDefault(require("typescript"));
|
|
8
|
-
const injectable_1 = require("./compiler-cli/src/ngtsc/annotations/src/injectable");
|
|
9
|
-
const imports_1 = require("./compiler-cli/src/ngtsc/imports");
|
|
10
|
-
const reflection_1 = require("./compiler-cli/src/ngtsc/reflection");
|
|
11
|
-
const transform_1 = require("./compiler-cli/src/ngtsc/transform");
|
|
12
|
-
const translator_1 = require("./compiler-cli/src/ngtsc/translator");
|
|
13
|
-
const node_Iteration_1 = require("./node-Iteration");
|
|
14
|
-
const NO_DECORATORS = new Set();
|
|
15
|
-
function createTransformer(program, options) {
|
|
16
|
-
let factory = new InjectableTransformerFactory(program, options);
|
|
17
|
-
return factory.getTransform();
|
|
18
|
-
}
|
|
19
|
-
exports.createTransformer = createTransformer;
|
|
20
|
-
class InjectableTransformerFactory {
|
|
21
|
-
program;
|
|
22
|
-
options;
|
|
23
|
-
typeChecker;
|
|
24
|
-
reflectionHost;
|
|
25
|
-
handler;
|
|
26
|
-
constructor(program, options = {}) {
|
|
27
|
-
this.program = program;
|
|
28
|
-
this.options = options;
|
|
29
|
-
this.typeChecker = this.program.getTypeChecker();
|
|
30
|
-
this.reflectionHost = new reflection_1.TypeScriptReflectionHost(this.typeChecker);
|
|
31
|
-
this.handler = new injectable_1.InjectableDecoratorHandler(this.reflectionHost, false, !!this.options.strictCtorDeps, false, transform_1.CompilationMode.FULL);
|
|
32
|
-
}
|
|
33
|
-
getTransform() {
|
|
34
|
-
return (context) => this.transform(context);
|
|
35
|
-
}
|
|
36
|
-
visit(node, context, map) {
|
|
37
|
-
return typescript_1.default.visitEachChild(node, (node) => {
|
|
38
|
-
let result = map.get(node);
|
|
39
|
-
if (result) {
|
|
40
|
-
const filteredDecorators =
|
|
41
|
-
// Remove the decorator which triggered this compilation, leaving the others alone.
|
|
42
|
-
maybeFilterDecorator(typescript_1.default.getDecorators(node), [
|
|
43
|
-
result.decorator,
|
|
44
|
-
]);
|
|
45
|
-
const nodeModifiers = typescript_1.default.getModifiers(node);
|
|
46
|
-
let updatedModifiers;
|
|
47
|
-
if (filteredDecorators?.length || nodeModifiers?.length) {
|
|
48
|
-
updatedModifiers = [
|
|
49
|
-
...(filteredDecorators || []),
|
|
50
|
-
...(nodeModifiers || []),
|
|
51
|
-
];
|
|
52
|
-
}
|
|
53
|
-
return typescript_1.default.factory.updateClassDeclaration(node, updatedModifiers, node.name, node.typeParameters, node.heritageClauses || [], [
|
|
54
|
-
...node.members.map((node) => this._stripAngularDecorators(node)),
|
|
55
|
-
...result.members,
|
|
56
|
-
]);
|
|
57
|
-
}
|
|
58
|
-
return this.visit(node, context, map);
|
|
59
|
-
}, context);
|
|
60
|
-
}
|
|
61
|
-
transform(context) {
|
|
62
|
-
return (sf) => {
|
|
63
|
-
let map = this.preAnalysis(sf);
|
|
64
|
-
sf = this.updateStatements(sf, map.importManager);
|
|
65
|
-
return this.visit(sf, context, map.classMetadataMap);
|
|
66
|
-
};
|
|
67
|
-
}
|
|
68
|
-
preAnalysis(sf) {
|
|
69
|
-
let classMetadataMap = new Map();
|
|
70
|
-
let write = new imports_1.NoopImportRewriter();
|
|
71
|
-
let importManager = new translator_1.ImportManager(write);
|
|
72
|
-
(0, node_Iteration_1.nodeIteration)(sf, (node) => {
|
|
73
|
-
if (typescript_1.default.isClassDeclaration(node) &&
|
|
74
|
-
typescript_1.default.getDecorators(node) &&
|
|
75
|
-
this.reflectionHost.isClass(node)) {
|
|
76
|
-
const decorators = this.reflectionHost.getDecoratorsOfDeclaration(node) || [];
|
|
77
|
-
let result = this.handler.detect(node, decorators);
|
|
78
|
-
if (!result) {
|
|
79
|
-
return;
|
|
80
|
-
}
|
|
81
|
-
let analysisOutput = this.handler.analyze(node, result.metadata);
|
|
82
|
-
let compileResult = this.handler.compileFull(node, analysisOutput.analysis);
|
|
83
|
-
let resultNode = this.translate(compileResult, importManager);
|
|
84
|
-
classMetadataMap.set(node, {
|
|
85
|
-
...resultNode,
|
|
86
|
-
decorator: result.trigger,
|
|
87
|
-
});
|
|
88
|
-
}
|
|
89
|
-
});
|
|
90
|
-
// this.sourceFileMetadataMap.set(sf, {
|
|
91
|
-
// classMetadataMap,
|
|
92
|
-
// importManager: importManager,
|
|
93
|
-
// });
|
|
94
|
-
return { classMetadataMap, importManager };
|
|
95
|
-
}
|
|
96
|
-
translate(compileResult, importManager) {
|
|
97
|
-
// There is at least one field to add.
|
|
98
|
-
const statements = [];
|
|
99
|
-
const members = [];
|
|
100
|
-
for (const field of compileResult) {
|
|
101
|
-
// Translate the initializer for the field into TS nodes.
|
|
102
|
-
const exprNode = (0, translator_1.translateExpression)(field.initializer, importManager);
|
|
103
|
-
// Create a static property declaration for the new field.
|
|
104
|
-
const property = typescript_1.default.factory.createPropertyDeclaration([typescript_1.default.factory.createToken(typescript_1.default.SyntaxKind.StaticKeyword)], field.name, undefined, undefined, exprNode);
|
|
105
|
-
if (false) {
|
|
106
|
-
// Closure compiler transforms the form `Service.ɵprov = X` into `Service$ɵprov = X`. To
|
|
107
|
-
// prevent this transformation, such assignments need to be annotated with @nocollapse.
|
|
108
|
-
// Note that tsickle is typically responsible for adding such annotations, however it
|
|
109
|
-
// doesn't yet handle synthetic fields added during other transformations.
|
|
110
|
-
typescript_1.default.addSyntheticLeadingComment(property, typescript_1.default.SyntaxKind.MultiLineCommentTrivia, '* @nocollapse ',
|
|
111
|
-
/* hasTrailingNewLine */ false);
|
|
112
|
-
}
|
|
113
|
-
field.statements
|
|
114
|
-
.map((stmt) => (0, translator_1.translateStatement)(stmt, importManager))
|
|
115
|
-
.forEach((stmt) => statements.push(stmt));
|
|
116
|
-
members.push(property);
|
|
117
|
-
}
|
|
118
|
-
return { statements, members };
|
|
119
|
-
}
|
|
120
|
-
/**
|
|
121
|
-
* Remove Angular decorators from a `ts.Node` in a shallow manner.
|
|
122
|
-
*
|
|
123
|
-
* This will remove decorators from class elements (getters, setters, properties, methods) as well
|
|
124
|
-
* as parameters of constructors.
|
|
125
|
-
*/
|
|
126
|
-
_stripAngularDecorators(node) {
|
|
127
|
-
const modifiers = typescript_1.default.canHaveModifiers(node)
|
|
128
|
-
? typescript_1.default.getModifiers(node)
|
|
129
|
-
: undefined;
|
|
130
|
-
const nonCoreDecorators = typescript_1.default.canHaveDecorators(node)
|
|
131
|
-
? this._nonCoreDecoratorsOnly(node)
|
|
132
|
-
: undefined;
|
|
133
|
-
const combinedModifiers = [
|
|
134
|
-
...(nonCoreDecorators || []),
|
|
135
|
-
...(modifiers || []),
|
|
136
|
-
];
|
|
137
|
-
if (typescript_1.default.isParameter(node)) {
|
|
138
|
-
// Strip decorators from parameters (probably of the constructor).
|
|
139
|
-
node = typescript_1.default.factory.updateParameterDeclaration(node, combinedModifiers, node.dotDotDotToken, node.name, node.questionToken, node.type, node.initializer);
|
|
140
|
-
}
|
|
141
|
-
else if (typescript_1.default.isMethodDeclaration(node)) {
|
|
142
|
-
// Strip decorators of methods.
|
|
143
|
-
node = typescript_1.default.factory.updateMethodDeclaration(node, combinedModifiers, node.asteriskToken, node.name, node.questionToken, node.typeParameters, node.parameters, node.type, node.body);
|
|
144
|
-
}
|
|
145
|
-
else if (typescript_1.default.isPropertyDeclaration(node)) {
|
|
146
|
-
// Strip decorators of properties.
|
|
147
|
-
node = typescript_1.default.factory.updatePropertyDeclaration(node, combinedModifiers, node.name, node.questionToken, node.type, node.initializer);
|
|
148
|
-
}
|
|
149
|
-
else if (typescript_1.default.isGetAccessor(node)) {
|
|
150
|
-
// Strip decorators of getters.
|
|
151
|
-
node = typescript_1.default.factory.updateGetAccessorDeclaration(node, combinedModifiers, node.name, node.parameters, node.type, node.body);
|
|
152
|
-
}
|
|
153
|
-
else if (typescript_1.default.isSetAccessor(node)) {
|
|
154
|
-
// Strip decorators of setters.
|
|
155
|
-
node = typescript_1.default.factory.updateSetAccessorDeclaration(node, combinedModifiers, node.name, node.parameters, node.body);
|
|
156
|
-
}
|
|
157
|
-
else if (typescript_1.default.isConstructorDeclaration(node)) {
|
|
158
|
-
// For constructors, strip decorators of the parameters.
|
|
159
|
-
const parameters = node.parameters.map((param) => this._stripAngularDecorators(param));
|
|
160
|
-
node = typescript_1.default.factory.updateConstructorDeclaration(node, modifiers, parameters, node.body);
|
|
161
|
-
}
|
|
162
|
-
return node;
|
|
163
|
-
}
|
|
164
|
-
/**
|
|
165
|
-
* Return all decorators on a `Declaration` which are from static-injector, or an empty set if none
|
|
166
|
-
* are.
|
|
167
|
-
*/
|
|
168
|
-
_angularCoreDecorators(decl) {
|
|
169
|
-
const decorators = this.reflectionHost.getDecoratorsOfDeclaration(decl);
|
|
170
|
-
if (decorators === null) {
|
|
171
|
-
return NO_DECORATORS;
|
|
172
|
-
}
|
|
173
|
-
const coreDecorators = decorators
|
|
174
|
-
.filter((dec) => isFromAngularCore(dec))
|
|
175
|
-
.map((dec) => dec.node);
|
|
176
|
-
if (coreDecorators.length > 0) {
|
|
177
|
-
return new Set(coreDecorators);
|
|
178
|
-
}
|
|
179
|
-
else {
|
|
180
|
-
return NO_DECORATORS;
|
|
181
|
-
}
|
|
182
|
-
}
|
|
183
|
-
/**
|
|
184
|
-
* Given a `ts.Node`, filter the decorators array and return a version containing only non-Angular
|
|
185
|
-
* decorators.
|
|
186
|
-
*
|
|
187
|
-
* If all decorators are removed (or none existed in the first place), this method returns
|
|
188
|
-
* `undefined`.
|
|
189
|
-
*/
|
|
190
|
-
_nonCoreDecoratorsOnly(node) {
|
|
191
|
-
const decorators = typescript_1.default.getDecorators(node);
|
|
192
|
-
// Shortcut if the node has no decorators.
|
|
193
|
-
if (decorators === undefined) {
|
|
194
|
-
return undefined;
|
|
195
|
-
}
|
|
196
|
-
// Build a Set of the decorators on this node from @angular/core.
|
|
197
|
-
const coreDecorators = this._angularCoreDecorators(node);
|
|
198
|
-
if (coreDecorators.size === decorators.length) {
|
|
199
|
-
// If all decorators are to be removed, return `undefined`.
|
|
200
|
-
return undefined;
|
|
201
|
-
}
|
|
202
|
-
else if (coreDecorators.size === 0) {
|
|
203
|
-
// If no decorators need to be removed, return the original decorators array.
|
|
204
|
-
return nodeArrayFromDecoratorsArray(decorators);
|
|
205
|
-
}
|
|
206
|
-
// Filter out the core decorators.
|
|
207
|
-
const filtered = decorators.filter((dec) => !coreDecorators.has(dec));
|
|
208
|
-
// If no decorators survive, return `undefined`. This can only happen if a core decorator is
|
|
209
|
-
// repeated on the node.
|
|
210
|
-
if (filtered.length === 0) {
|
|
211
|
-
return undefined;
|
|
212
|
-
}
|
|
213
|
-
// Create a new `NodeArray` with the filtered decorators that sourcemaps back to the original.
|
|
214
|
-
return nodeArrayFromDecoratorsArray(filtered);
|
|
215
|
-
}
|
|
216
|
-
updateStatements(node, importManager) {
|
|
217
|
-
return (0, transform_1.addImports)(typescript_1.default.factory, importManager, node);
|
|
218
|
-
}
|
|
219
|
-
}
|
|
220
|
-
exports.InjectableTransformerFactory = InjectableTransformerFactory;
|
|
221
|
-
/**
|
|
222
|
-
* todo 引入
|
|
223
|
-
*/
|
|
224
|
-
function isFromAngularCore(decorator) {
|
|
225
|
-
return (decorator.import !== null && decorator.import.from === 'static-injector');
|
|
226
|
-
}
|
|
227
|
-
/** Creates a `NodeArray` with the correct offsets from an array of decorators. */
|
|
228
|
-
function nodeArrayFromDecoratorsArray(decorators) {
|
|
229
|
-
const array = typescript_1.default.factory.createNodeArray(decorators);
|
|
230
|
-
if (array.length > 0) {
|
|
231
|
-
array.pos = decorators[0].pos;
|
|
232
|
-
array.end = decorators[decorators.length - 1].end;
|
|
233
|
-
}
|
|
234
|
-
return array;
|
|
235
|
-
}
|
|
236
|
-
function maybeFilterDecorator(decorators, toRemove) {
|
|
237
|
-
if (decorators === undefined) {
|
|
238
|
-
return undefined;
|
|
239
|
-
}
|
|
240
|
-
const filtered = decorators.filter((dec) => toRemove.find((decToRemove) => typescript_1.default.getOriginalNode(dec) === decToRemove) === undefined);
|
|
241
|
-
if (filtered.length === 0) {
|
|
242
|
-
return undefined;
|
|
243
|
-
}
|
|
244
|
-
return typescript_1.default.factory.createNodeArray(filtered);
|
|
245
|
-
}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.nodeIteration = void 0;
|
|
7
|
-
const typescript_1 = __importDefault(require("typescript"));
|
|
8
|
-
function nodeIteration(node, fn) {
|
|
9
|
-
fn(node);
|
|
10
|
-
typescript_1.default.forEachChild(node, (node) => nodeIteration(node, fn));
|
|
11
|
-
}
|
|
12
|
-
exports.nodeIteration = nodeIteration;
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|