static-injector 1.0.10 → 2.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/import/commonjs/index.js +337 -124
- package/import/es2015/di/create_injector.js +30 -0
- package/import/es2015/di/initializer_token.js +15 -0
- package/import/es2015/di/inject_switch.js +27 -6
- package/import/es2015/di/injection_token.js +6 -0
- package/import/es2015/di/injector.js +6 -8
- package/import/es2015/di/injector_compatibility.js +90 -34
- package/import/es2015/di/injector_token.js +1 -1
- package/import/es2015/di/interface/defs.js +39 -0
- package/import/es2015/di/interface/injector.js +1 -0
- package/import/es2015/di/internal_tokens.js +9 -0
- package/import/es2015/di/metadata.js +4 -4
- package/import/es2015/di/provider_collection.js +49 -0
- package/import/es2015/di/r3_injector.js +102 -72
- package/import/es2015/di/scope.js +2 -2
- package/import/es2015/index.js +1 -1
- package/import/es2015/render3/errors_di.js +1 -1
- package/import/fesm2015/index.js +328 -114
- package/import/typings/di/create_injector.d.ts +23 -0
- package/import/typings/di/initializer_token.d.ts +15 -0
- package/import/typings/di/inject_switch.d.ts +7 -2
- package/import/typings/{decorator → di}/injectable.d.ts +2 -2
- package/import/typings/di/injection_token.d.ts +4 -0
- package/import/typings/di/injector.d.ts +20 -7
- package/import/typings/di/injector_compatibility.d.ts +42 -21
- package/import/typings/di/interface/defs.d.ts +10 -0
- package/import/typings/di/interface/injector.d.ts +26 -0
- package/import/typings/di/interface/provider.d.ts +3 -8
- package/import/typings/di/internal_tokens.d.ts +10 -0
- package/import/typings/di/provider_collection.d.ts +30 -0
- package/import/typings/di/provider_token.d.ts +1 -1
- package/import/typings/di/r3_injector.d.ts +68 -37
- package/import/typings/di/scope.d.ts +3 -2
- package/import/typings/index.d.ts +1 -1
- package/import/typings/render3/definition_factory.d.ts +1 -1
- package/package.json +5 -3
- package/{import/es2015/decorator/interface/provider.js → transform/compiler/compiler.d.ts} +1 -1
- package/transform/compiler/compiler.js +28 -0
- package/transform/compiler/index.d.ts +8 -5
- package/transform/compiler/index.js +17 -6
- package/transform/compiler/public_api.d.ts +13 -0
- package/transform/compiler/public_api.js +30 -0
- package/transform/compiler/src/compiler.d.ts +27 -0
- package/transform/compiler/src/compiler.js +47 -0
- package/transform/compiler/src/injectable_compiler_2.d.ts +7 -36
- package/transform/compiler/src/injectable_compiler_2.js +20 -23
- package/transform/compiler/src/output/output_ast.d.ts +30 -109
- package/transform/compiler/src/output/output_ast.js +66 -188
- package/transform/compiler/src/render3/partial/api.d.ts +1 -1
- package/transform/compiler/src/render3/partial/api.js +7 -0
- package/transform/compiler/src/render3/r3_factory.d.ts +8 -15
- package/transform/compiler/src/render3/r3_factory.js +46 -61
- package/transform/compiler/src/render3/util.d.ts +64 -0
- package/transform/compiler/src/render3/util.js +52 -9
- package/transform/compiler/src/render3/view/util.d.ts +0 -8
- package/transform/compiler/src/render3/view/util.js +5 -9
- package/transform/compiler-cli/src/ngtsc/annotations/common/index.d.ts +10 -0
- package/transform/compiler-cli/src/ngtsc/annotations/common/index.js +26 -0
- package/transform/compiler-cli/src/ngtsc/annotations/common/src/di.d.ts +37 -0
- package/transform/compiler-cli/src/ngtsc/annotations/common/src/di.js +197 -0
- package/transform/compiler-cli/src/ngtsc/annotations/{src → common/src}/factory.d.ts +3 -3
- package/transform/compiler-cli/src/ngtsc/annotations/{src → common/src}/factory.js +3 -3
- package/transform/compiler-cli/src/ngtsc/annotations/{src → common/src}/util.d.ts +4 -34
- package/transform/compiler-cli/src/ngtsc/annotations/common/src/util.js +181 -0
- package/transform/compiler-cli/src/ngtsc/annotations/src/injectable.d.ts +3 -4
- package/transform/compiler-cli/src/ngtsc/annotations/src/injectable.js +46 -53
- package/transform/compiler-cli/src/ngtsc/diagnostics/error.js +6 -2
- package/transform/compiler-cli/src/ngtsc/diagnostics/index.d.ts +9 -2
- package/transform/compiler-cli/src/ngtsc/diagnostics/index.js +12 -1
- package/transform/compiler-cli/src/ngtsc/imports/index.d.ts +7 -0
- package/transform/compiler-cli/src/ngtsc/imports/index.js +12 -1
- package/transform/compiler-cli/src/ngtsc/imports/src/default.d.ts +19 -0
- package/transform/compiler-cli/src/ngtsc/imports/src/default.js +28 -0
- package/transform/compiler-cli/src/ngtsc/reflection/index.d.ts +10 -3
- package/transform/compiler-cli/src/ngtsc/reflection/index.js +12 -1
- package/transform/compiler-cli/src/ngtsc/reflection/src/host.d.ts +13 -14
- package/transform/compiler-cli/src/ngtsc/reflection/src/host.js +8 -25
- package/transform/compiler-cli/src/ngtsc/reflection/src/type_to_value.d.ts +2 -2
- package/transform/compiler-cli/src/ngtsc/reflection/src/type_to_value.js +44 -55
- package/transform/compiler-cli/src/ngtsc/reflection/src/typescript.d.ts +1 -1
- package/transform/compiler-cli/src/ngtsc/reflection/src/typescript.js +55 -69
- package/transform/compiler-cli/src/ngtsc/reflection/src/util.d.ts +2 -2
- package/transform/compiler-cli/src/ngtsc/reflection/src/util.js +7 -23
- package/transform/compiler-cli/src/ngtsc/transform/index.d.ts +9 -2
- package/transform/compiler-cli/src/ngtsc/transform/index.js +12 -1
- package/transform/compiler-cli/src/ngtsc/transform/src/api.d.ts +4 -4
- package/transform/compiler-cli/src/ngtsc/transform/src/utils.d.ts +2 -2
- package/transform/compiler-cli/src/ngtsc/transform/src/utils.js +16 -31
- package/transform/compiler-cli/src/ngtsc/translator/index.d.ts +12 -5
- package/transform/compiler-cli/src/ngtsc/translator/index.js +12 -1
- package/transform/compiler-cli/src/ngtsc/translator/src/api/ast_factory.d.ts +5 -5
- package/transform/compiler-cli/src/ngtsc/translator/src/import_manager.d.ts +4 -4
- package/transform/compiler-cli/src/ngtsc/translator/src/import_manager.js +5 -21
- package/transform/compiler-cli/src/ngtsc/translator/src/translator.d.ts +2 -6
- package/transform/compiler-cli/src/ngtsc/translator/src/translator.js +6 -18
- package/transform/compiler-cli/src/ngtsc/translator/src/typescript_ast_factory.d.ts +3 -6
- package/transform/compiler-cli/src/ngtsc/translator/src/typescript_ast_factory.js +83 -90
- package/transform/compiler-cli/src/ngtsc/translator/src/typescript_translator.d.ts +4 -4
- package/transform/compiler-cli/src/ngtsc/ts_compatibility/index.d.ts +8 -0
- package/transform/compiler-cli/src/ngtsc/ts_compatibility/index.js +24 -0
- package/transform/compiler-cli/src/ngtsc/ts_compatibility/src/ts_cross_version_utils.d.ts +45 -0
- package/transform/compiler-cli/src/ngtsc/ts_compatibility/src/ts_cross_version_utils.js +86 -0
- package/transform/compiler-cli/src/ngtsc/util/src/typescript.d.ts +1 -8
- package/transform/compiler-cli/src/ngtsc/util/src/typescript.js +4 -27
- package/transform/index.js +5 -1
- package/transform/injectable-transform.js +59 -38
- package/import/typings/decorator/interface/provider.d.ts +0 -312
- package/transform/compiler/src/render3/partial/util.d.ts +0 -16
- package/transform/compiler/src/render3/partial/util.js +0 -44
- package/transform/compiler-cli/src/ngtsc/annotations/src/util.js +0 -370
- /package/import/es2015/{decorator → di}/injectable.js +0 -0
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright Google LLC All Rights Reserved.
|
|
4
|
+
*
|
|
5
|
+
* Use of this source code is governed by an MIT-style license that can be
|
|
6
|
+
* found in the LICENSE file at https://angular.io/license
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* @module
|
|
10
|
+
* @description
|
|
11
|
+
* Entry point for all public APIs of this package.
|
|
12
|
+
*/
|
|
13
|
+
export * from './src/compiler';
|
|
@@ -0,0 +1,30 @@
|
|
|
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
|
+
/**
|
|
25
|
+
* @module
|
|
26
|
+
* @description
|
|
27
|
+
* Entry point for all public APIs of this package.
|
|
28
|
+
*/
|
|
29
|
+
__exportStar(require("./src/compiler"), exports);
|
|
30
|
+
// This file only reexports content of the `src` folder. Keep it that way.
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright Google LLC All Rights Reserved.
|
|
4
|
+
*
|
|
5
|
+
* Use of this source code is governed by an MIT-style license that can be
|
|
6
|
+
* found in the LICENSE file at https://angular.io/license
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* @module
|
|
10
|
+
* @description
|
|
11
|
+
* Entry point for all APIs of the compiler package.
|
|
12
|
+
*
|
|
13
|
+
* <div class="callout is-critical">
|
|
14
|
+
* <header>Unstable APIs</header>
|
|
15
|
+
* <p>
|
|
16
|
+
* All compiler apis are currently considered experimental and private!
|
|
17
|
+
* </p>
|
|
18
|
+
* <p>
|
|
19
|
+
* We expect the APIs in this package to keep on changing. Do not rely on them.
|
|
20
|
+
* </p>
|
|
21
|
+
* </div>
|
|
22
|
+
*/
|
|
23
|
+
export * from './injectable_compiler_2';
|
|
24
|
+
export * from './render3/r3_factory';
|
|
25
|
+
export * from './output/output_ast';
|
|
26
|
+
export * from './render3/util';
|
|
27
|
+
export * from './parse_util';
|
|
@@ -0,0 +1,47 @@
|
|
|
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
|
+
//////////////////////////////////////
|
|
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
|
+
__exportStar(require("./injectable_compiler_2"), exports);
|
|
44
|
+
__exportStar(require("./render3/r3_factory"), exports);
|
|
45
|
+
__exportStar(require("./output/output_ast"), exports);
|
|
46
|
+
__exportStar(require("./render3/util"), exports);
|
|
47
|
+
__exportStar(require("./parse_util"), exports);
|
|
@@ -5,49 +5,20 @@
|
|
|
5
5
|
* Use of this source code is governed by an MIT-style license that can be
|
|
6
6
|
* found in the LICENSE file at https://angular.io/license
|
|
7
7
|
*/
|
|
8
|
-
import * as o from
|
|
9
|
-
import { R3DependencyMetadata } from
|
|
10
|
-
import { R3CompiledExpression, R3Reference } from
|
|
8
|
+
import * as o from './output/output_ast';
|
|
9
|
+
import { R3DependencyMetadata } from './render3/r3_factory';
|
|
10
|
+
import { MaybeForwardRefExpression, R3CompiledExpression, R3Reference } from './render3/util';
|
|
11
11
|
export interface R3InjectableMetadata {
|
|
12
12
|
name: string;
|
|
13
13
|
type: R3Reference;
|
|
14
14
|
internalType: o.Expression;
|
|
15
15
|
typeArgumentCount: number;
|
|
16
|
-
providedIn:
|
|
17
|
-
useClass?:
|
|
16
|
+
providedIn: MaybeForwardRefExpression;
|
|
17
|
+
useClass?: MaybeForwardRefExpression;
|
|
18
18
|
useFactory?: o.Expression;
|
|
19
|
-
useExisting?:
|
|
20
|
-
useValue?:
|
|
19
|
+
useExisting?: MaybeForwardRefExpression;
|
|
20
|
+
useValue?: MaybeForwardRefExpression;
|
|
21
21
|
deps?: R3DependencyMetadata[];
|
|
22
22
|
}
|
|
23
|
-
/**
|
|
24
|
-
* An expression used when instantiating an injectable.
|
|
25
|
-
*
|
|
26
|
-
* This is the type of the `useClass`, `useExisting` and `useValue` properties of
|
|
27
|
-
* `R3InjectableMetadata` since those can refer to types that may eagerly reference types that have
|
|
28
|
-
* not yet been defined.
|
|
29
|
-
*/
|
|
30
|
-
export interface R3ProviderExpression<T extends o.Expression = o.Expression> {
|
|
31
|
-
/**
|
|
32
|
-
* The expression that is used to instantiate the Injectable.
|
|
33
|
-
*/
|
|
34
|
-
expression: T;
|
|
35
|
-
/**
|
|
36
|
-
* If true, then the `expression` contains a reference to something that has not yet been
|
|
37
|
-
* defined.
|
|
38
|
-
*
|
|
39
|
-
* This means that the expression must not be eagerly evaluated. Instead it must be wrapped in a
|
|
40
|
-
* function closure that will be evaluated lazily to allow the definition of the expression to be
|
|
41
|
-
* evaluated first.
|
|
42
|
-
*
|
|
43
|
-
* In some cases the expression will naturally be placed inside such a function closure, such as
|
|
44
|
-
* in a fully compiled factory function. In those case nothing more needs to be done.
|
|
45
|
-
*
|
|
46
|
-
* But in other cases, such as partial-compilation the expression will be located in top level
|
|
47
|
-
* code so will need to be wrapped in a function that is passed to a `forwardRef()` call.
|
|
48
|
-
*/
|
|
49
|
-
isForwardRef: boolean;
|
|
50
|
-
}
|
|
51
|
-
export declare function createR3ProviderExpression<T extends o.Expression>(expression: T, isForwardRef: boolean): R3ProviderExpression<T>;
|
|
52
23
|
export declare function compileInjectable(meta: R3InjectableMetadata, resolveForwardRefs: boolean): R3CompiledExpression;
|
|
53
24
|
export declare function createInjectableType(meta: R3InjectableMetadata): o.ExpressionType;
|
|
@@ -8,7 +8,11 @@
|
|
|
8
8
|
*/
|
|
9
9
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
10
10
|
if (k2 === undefined) k2 = k;
|
|
11
|
-
Object.
|
|
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);
|
|
12
16
|
}) : (function(o, m, k, k2) {
|
|
13
17
|
if (k2 === undefined) k2 = k;
|
|
14
18
|
o[k2] = m[k];
|
|
@@ -26,17 +30,12 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
26
30
|
return result;
|
|
27
31
|
};
|
|
28
32
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
exports.createInjectableType = exports.compileInjectable =
|
|
33
|
+
exports.createInjectableType = exports.compileInjectable = void 0;
|
|
30
34
|
const o = __importStar(require("./output/output_ast"));
|
|
31
|
-
const util_1 = require("./render3/partial/util");
|
|
32
35
|
const r3_factory_1 = require("./render3/r3_factory");
|
|
33
36
|
const r3_identifiers_1 = require("./render3/r3_identifiers");
|
|
34
|
-
const
|
|
35
|
-
const
|
|
36
|
-
function createR3ProviderExpression(expression, isForwardRef) {
|
|
37
|
-
return { expression, isForwardRef };
|
|
38
|
-
}
|
|
39
|
-
exports.createR3ProviderExpression = createR3ProviderExpression;
|
|
37
|
+
const util_1 = require("./render3/util");
|
|
38
|
+
const util_2 = require("./render3/view/util");
|
|
40
39
|
function compileInjectable(meta, resolveForwardRefs) {
|
|
41
40
|
let result = null;
|
|
42
41
|
const factoryMeta = {
|
|
@@ -61,10 +60,10 @@ function compileInjectable(meta, resolveForwardRefs) {
|
|
|
61
60
|
}
|
|
62
61
|
if (deps !== undefined) {
|
|
63
62
|
// factory: () => new meta.useClass(...deps)
|
|
64
|
-
result = r3_factory_1.compileFactoryFunction(Object.assign(Object.assign({}, factoryMeta), { delegate: meta.useClass.expression, delegateDeps: deps, delegateType: r3_factory_1.R3FactoryDelegateType.Class }));
|
|
63
|
+
result = (0, r3_factory_1.compileFactoryFunction)(Object.assign(Object.assign({}, factoryMeta), { delegate: meta.useClass.expression, delegateDeps: deps, delegateType: r3_factory_1.R3FactoryDelegateType.Class }));
|
|
65
64
|
}
|
|
66
65
|
else if (useClassOnSelf) {
|
|
67
|
-
result = r3_factory_1.compileFactoryFunction(factoryMeta);
|
|
66
|
+
result = (0, r3_factory_1.compileFactoryFunction)(factoryMeta);
|
|
68
67
|
}
|
|
69
68
|
else {
|
|
70
69
|
result = {
|
|
@@ -75,7 +74,7 @@ function compileInjectable(meta, resolveForwardRefs) {
|
|
|
75
74
|
}
|
|
76
75
|
else if (meta.useFactory !== undefined) {
|
|
77
76
|
if (meta.deps !== undefined) {
|
|
78
|
-
result = r3_factory_1.compileFactoryFunction(Object.assign(Object.assign({}, factoryMeta), { delegate: meta.useFactory, delegateDeps: meta.deps || [], delegateType: r3_factory_1.R3FactoryDelegateType.Function }));
|
|
77
|
+
result = (0, r3_factory_1.compileFactoryFunction)(Object.assign(Object.assign({}, factoryMeta), { delegate: meta.useFactory, delegateDeps: meta.deps || [], delegateType: r3_factory_1.R3FactoryDelegateType.Function }));
|
|
79
78
|
}
|
|
80
79
|
else {
|
|
81
80
|
result = {
|
|
@@ -88,11 +87,11 @@ function compileInjectable(meta, resolveForwardRefs) {
|
|
|
88
87
|
// Note: it's safe to use `meta.useValue` instead of the `USE_VALUE in meta` check used for
|
|
89
88
|
// client code because meta.useValue is an Expression which will be defined even if the actual
|
|
90
89
|
// value is undefined.
|
|
91
|
-
result = r3_factory_1.compileFactoryFunction(Object.assign(Object.assign({}, factoryMeta), { expression: meta.useValue.expression }));
|
|
90
|
+
result = (0, r3_factory_1.compileFactoryFunction)(Object.assign(Object.assign({}, factoryMeta), { expression: meta.useValue.expression }));
|
|
92
91
|
}
|
|
93
92
|
else if (meta.useExisting !== undefined) {
|
|
94
93
|
// useExisting is an `inject` call on the existing token.
|
|
95
|
-
result = r3_factory_1.compileFactoryFunction(Object.assign(Object.assign({}, factoryMeta), { expression: o
|
|
94
|
+
result = (0, r3_factory_1.compileFactoryFunction)(Object.assign(Object.assign({}, factoryMeta), { expression: o
|
|
96
95
|
.importExpr(r3_identifiers_1.Identifiers.inject)
|
|
97
96
|
.callFn([meta.useExisting.expression]) }));
|
|
98
97
|
}
|
|
@@ -103,14 +102,12 @@ function compileInjectable(meta, resolveForwardRefs) {
|
|
|
103
102
|
};
|
|
104
103
|
}
|
|
105
104
|
const token = meta.internalType;
|
|
106
|
-
const injectableProps = new
|
|
107
|
-
injectableProps.set(
|
|
108
|
-
injectableProps.set(
|
|
105
|
+
const injectableProps = new util_2.DefinitionMap();
|
|
106
|
+
injectableProps.set('token', token);
|
|
107
|
+
injectableProps.set('factory', result.expression);
|
|
109
108
|
// Only generate providedIn property if it has a non-null value
|
|
110
109
|
if (meta.providedIn.expression.value !== null) {
|
|
111
|
-
injectableProps.set(
|
|
112
|
-
? util_1.generateForwardRef(meta.providedIn.expression)
|
|
113
|
-
: meta.providedIn.expression);
|
|
110
|
+
injectableProps.set('providedIn', (0, util_1.convertFromMaybeForwardRefExpression)(meta.providedIn));
|
|
114
111
|
}
|
|
115
112
|
const expression = o
|
|
116
113
|
.importExpr(r3_identifiers_1.Identifiers.ɵɵdefineInjectable)
|
|
@@ -124,7 +121,7 @@ function compileInjectable(meta, resolveForwardRefs) {
|
|
|
124
121
|
exports.compileInjectable = compileInjectable;
|
|
125
122
|
function createInjectableType(meta) {
|
|
126
123
|
return new o.ExpressionType(o.importExpr(r3_identifiers_1.Identifiers.InjectableDeclaration, [
|
|
127
|
-
|
|
124
|
+
(0, util_1.typeWithParameters)(meta.type.type, meta.typeArgumentCount),
|
|
128
125
|
]));
|
|
129
126
|
}
|
|
130
127
|
exports.createInjectableType = createInjectableType;
|
|
@@ -134,7 +131,7 @@ function delegateToFactory(type, internalType, unwrapForwardRefs) {
|
|
|
134
131
|
// ```
|
|
135
132
|
// factory: type.ɵfac
|
|
136
133
|
// ```
|
|
137
|
-
return internalType.prop(
|
|
134
|
+
return internalType.prop('ɵfac');
|
|
138
135
|
}
|
|
139
136
|
if (!unwrapForwardRefs) {
|
|
140
137
|
// The type is not wrapped in a `forwardRef()`, so we create a simple factory function that
|
|
@@ -155,5 +152,5 @@ function delegateToFactory(type, internalType, unwrapForwardRefs) {
|
|
|
155
152
|
return createFactoryFunction(unwrappedType);
|
|
156
153
|
}
|
|
157
154
|
function createFactoryFunction(type) {
|
|
158
|
-
return o.fn([new o.FnParam(
|
|
155
|
+
return o.fn([new o.FnParam('t', o.DYNAMIC_TYPE)], [new o.ReturnStatement(type.prop('ɵfac').callFn([o.variable('t')]))]);
|
|
159
156
|
}
|
|
@@ -7,11 +7,12 @@
|
|
|
7
7
|
*/
|
|
8
8
|
import { ParseSourceSpan } from '../parse_util';
|
|
9
9
|
export declare enum TypeModifier {
|
|
10
|
-
|
|
10
|
+
None = 0,
|
|
11
|
+
Const = 1
|
|
11
12
|
}
|
|
12
13
|
export declare abstract class Type {
|
|
13
|
-
modifiers: TypeModifier
|
|
14
|
-
constructor(modifiers?: TypeModifier
|
|
14
|
+
modifiers: TypeModifier;
|
|
15
|
+
constructor(modifiers?: TypeModifier);
|
|
15
16
|
abstract visitType(visitor: TypeVisitor, context: any): any;
|
|
16
17
|
hasModifier(modifier: TypeModifier): boolean;
|
|
17
18
|
}
|
|
@@ -27,23 +28,23 @@ export declare enum BuiltinTypeName {
|
|
|
27
28
|
}
|
|
28
29
|
export declare class BuiltinType extends Type {
|
|
29
30
|
name: BuiltinTypeName;
|
|
30
|
-
constructor(name: BuiltinTypeName, modifiers?: TypeModifier
|
|
31
|
+
constructor(name: BuiltinTypeName, modifiers?: TypeModifier);
|
|
31
32
|
visitType(visitor: TypeVisitor, context: any): any;
|
|
32
33
|
}
|
|
33
34
|
export declare class ExpressionType extends Type {
|
|
34
35
|
value: Expression;
|
|
35
36
|
typeParams: Type[] | null;
|
|
36
|
-
constructor(value: Expression, modifiers?: TypeModifier
|
|
37
|
+
constructor(value: Expression, modifiers?: TypeModifier, typeParams?: Type[] | null);
|
|
37
38
|
visitType(visitor: TypeVisitor, context: any): any;
|
|
38
39
|
}
|
|
39
40
|
export declare class ArrayType extends Type {
|
|
40
41
|
of: Type;
|
|
41
|
-
constructor(of: Type, modifiers?: TypeModifier
|
|
42
|
+
constructor(of: Type, modifiers?: TypeModifier);
|
|
42
43
|
visitType(visitor: TypeVisitor, context: any): any;
|
|
43
44
|
}
|
|
44
45
|
export declare class MapType extends Type {
|
|
45
46
|
valueType: Type | null;
|
|
46
|
-
constructor(valueType: Type | null | undefined, modifiers?: TypeModifier
|
|
47
|
+
constructor(valueType: Type | null | undefined, modifiers?: TypeModifier);
|
|
47
48
|
visitType(visitor: TypeVisitor, context: any): any;
|
|
48
49
|
}
|
|
49
50
|
export declare const DYNAMIC_TYPE: BuiltinType;
|
|
@@ -104,20 +105,13 @@ export declare abstract class Expression {
|
|
|
104
105
|
*/
|
|
105
106
|
abstract isConstant(): boolean;
|
|
106
107
|
prop(name: string, sourceSpan?: ParseSourceSpan | null): ReadPropExpr;
|
|
107
|
-
|
|
108
|
+
key(index: Expression, type?: Type | null, sourceSpan?: ParseSourceSpan | null): ReadKeyExpr;
|
|
108
109
|
callFn(params: Expression[], sourceSpan?: ParseSourceSpan | null, pure?: boolean): InvokeFunctionExpr;
|
|
109
110
|
toStmt(): Statement;
|
|
110
111
|
}
|
|
111
|
-
export declare enum BuiltinVar {
|
|
112
|
-
This = 0,
|
|
113
|
-
Super = 1,
|
|
114
|
-
CatchError = 2,
|
|
115
|
-
CatchStack = 3
|
|
116
|
-
}
|
|
117
112
|
export declare class ReadVarExpr extends Expression {
|
|
118
|
-
name: string
|
|
119
|
-
|
|
120
|
-
constructor(name: string | BuiltinVar, type?: Type | null, sourceSpan?: ParseSourceSpan | null);
|
|
113
|
+
name: string;
|
|
114
|
+
constructor(name: string, type?: Type | null, sourceSpan?: ParseSourceSpan | null);
|
|
121
115
|
isEquivalent(e: Expression): boolean;
|
|
122
116
|
isConstant(): boolean;
|
|
123
117
|
visitExpression(visitor: ExpressionVisitor, context: any): any;
|
|
@@ -144,7 +138,7 @@ export declare class WriteVarExpr extends Expression {
|
|
|
144
138
|
isEquivalent(e: Expression): boolean;
|
|
145
139
|
isConstant(): boolean;
|
|
146
140
|
visitExpression(visitor: ExpressionVisitor, context: any): any;
|
|
147
|
-
toDeclStmt(type?: Type | null, modifiers?: StmtModifier
|
|
141
|
+
toDeclStmt(type?: Type | null, modifiers?: StmtModifier): DeclareVarStmt;
|
|
148
142
|
toConstDecl(): DeclareVarStmt;
|
|
149
143
|
}
|
|
150
144
|
export declare class WriteKeyExpr extends Expression {
|
|
@@ -165,21 +159,6 @@ export declare class WritePropExpr extends Expression {
|
|
|
165
159
|
isConstant(): boolean;
|
|
166
160
|
visitExpression(visitor: ExpressionVisitor, context: any): any;
|
|
167
161
|
}
|
|
168
|
-
export declare enum BuiltinMethod {
|
|
169
|
-
ConcatArray = 0,
|
|
170
|
-
SubscribeObservable = 1,
|
|
171
|
-
Bind = 2
|
|
172
|
-
}
|
|
173
|
-
export declare class InvokeMethodExpr extends Expression {
|
|
174
|
-
receiver: Expression;
|
|
175
|
-
args: Expression[];
|
|
176
|
-
name: string | null;
|
|
177
|
-
builtin: BuiltinMethod | null;
|
|
178
|
-
constructor(receiver: Expression, method: string | BuiltinMethod, args: Expression[], type?: Type | null, sourceSpan?: ParseSourceSpan | null);
|
|
179
|
-
isEquivalent(e: Expression): boolean;
|
|
180
|
-
isConstant(): boolean;
|
|
181
|
-
visitExpression(visitor: ExpressionVisitor, context: any): any;
|
|
182
|
-
}
|
|
183
162
|
export declare class InvokeFunctionExpr extends Expression {
|
|
184
163
|
fn: Expression;
|
|
185
164
|
args: Expression[];
|
|
@@ -215,15 +194,11 @@ export declare class TemplateLiteralElement {
|
|
|
215
194
|
rawText: string;
|
|
216
195
|
constructor(text: string, sourceSpan?: ParseSourceSpan, rawText?: string);
|
|
217
196
|
}
|
|
218
|
-
export declare
|
|
197
|
+
export declare class LiteralPiece {
|
|
219
198
|
text: string;
|
|
220
199
|
sourceSpan: ParseSourceSpan;
|
|
221
200
|
constructor(text: string, sourceSpan: ParseSourceSpan);
|
|
222
201
|
}
|
|
223
|
-
export declare class LiteralPiece extends MessagePiece {
|
|
224
|
-
}
|
|
225
|
-
export declare class PlaceholderPiece extends MessagePiece {
|
|
226
|
-
}
|
|
227
202
|
/**
|
|
228
203
|
* A structure to hold the cooked and raw strings of a template literal element, along with its
|
|
229
204
|
* source-span range.
|
|
@@ -263,20 +238,6 @@ export declare class NotExpr extends Expression {
|
|
|
263
238
|
isConstant(): boolean;
|
|
264
239
|
visitExpression(visitor: ExpressionVisitor, context: any): any;
|
|
265
240
|
}
|
|
266
|
-
export declare class AssertNotNull extends Expression {
|
|
267
|
-
condition: Expression;
|
|
268
|
-
constructor(condition: Expression, sourceSpan?: ParseSourceSpan | null);
|
|
269
|
-
isEquivalent(e: Expression): boolean;
|
|
270
|
-
isConstant(): boolean;
|
|
271
|
-
visitExpression(visitor: ExpressionVisitor, context: any): any;
|
|
272
|
-
}
|
|
273
|
-
export declare class CastExpr extends Expression {
|
|
274
|
-
value: Expression;
|
|
275
|
-
constructor(value: Expression, type?: Type | null, sourceSpan?: ParseSourceSpan | null);
|
|
276
|
-
isEquivalent(e: Expression): boolean;
|
|
277
|
-
isConstant(): boolean;
|
|
278
|
-
visitExpression(visitor: ExpressionVisitor, context: any): any;
|
|
279
|
-
}
|
|
280
241
|
export declare class FnParam {
|
|
281
242
|
name: string;
|
|
282
243
|
type: Type | null;
|
|
@@ -291,7 +252,7 @@ export declare class FunctionExpr extends Expression {
|
|
|
291
252
|
isEquivalent(e: Expression): boolean;
|
|
292
253
|
isConstant(): boolean;
|
|
293
254
|
visitExpression(visitor: ExpressionVisitor, context: any): any;
|
|
294
|
-
toDeclStmt(name: string, modifiers?: StmtModifier
|
|
255
|
+
toDeclStmt(name: string, modifiers?: StmtModifier): DeclareFunctionStmt;
|
|
295
256
|
}
|
|
296
257
|
export declare class UnaryOperatorExpr extends Expression {
|
|
297
258
|
operator: UnaryOperator;
|
|
@@ -364,15 +325,12 @@ export interface ExpressionVisitor {
|
|
|
364
325
|
visitWriteVarExpr(expr: WriteVarExpr, context: any): any;
|
|
365
326
|
visitWriteKeyExpr(expr: WriteKeyExpr, context: any): any;
|
|
366
327
|
visitWritePropExpr(expr: WritePropExpr, context: any): any;
|
|
367
|
-
visitInvokeMethodExpr(ast: InvokeMethodExpr, context: any): any;
|
|
368
328
|
visitInvokeFunctionExpr(ast: InvokeFunctionExpr, context: any): any;
|
|
369
329
|
visitInstantiateExpr(ast: InstantiateExpr, context: any): any;
|
|
370
330
|
visitLiteralExpr(ast: LiteralExpr, context: any): any;
|
|
371
331
|
visitExternalExpr(ast: ExternalExpr, context: any): any;
|
|
372
332
|
visitConditionalExpr(ast: ConditionalExpr, context: any): any;
|
|
373
333
|
visitNotExpr(ast: NotExpr, context: any): any;
|
|
374
|
-
visitAssertNotNullExpr(ast: AssertNotNull, context: any): any;
|
|
375
|
-
visitCastExpr(ast: CastExpr, context: any): any;
|
|
376
334
|
visitFunctionExpr(ast: FunctionExpr, context: any): any;
|
|
377
335
|
visitUnaryOperatorExpr(ast: UnaryOperatorExpr, context: any): any;
|
|
378
336
|
visitBinaryOperatorExpr(ast: BinaryOperatorExpr, context: any): any;
|
|
@@ -384,17 +342,14 @@ export interface ExpressionVisitor {
|
|
|
384
342
|
visitWrappedNodeExpr(ast: WrappedNodeExpr<any>, context: any): any;
|
|
385
343
|
visitTypeofExpr(ast: TypeofExpr, context: any): any;
|
|
386
344
|
}
|
|
387
|
-
export declare const THIS_EXPR: ReadVarExpr;
|
|
388
|
-
export declare const SUPER_EXPR: ReadVarExpr;
|
|
389
|
-
export declare const CATCH_ERROR_VAR: ReadVarExpr;
|
|
390
|
-
export declare const CATCH_STACK_VAR: ReadVarExpr;
|
|
391
345
|
export declare const NULL_EXPR: LiteralExpr;
|
|
392
346
|
export declare const TYPED_NULL_EXPR: LiteralExpr;
|
|
393
347
|
export declare enum StmtModifier {
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
348
|
+
None = 0,
|
|
349
|
+
Final = 1,
|
|
350
|
+
Private = 2,
|
|
351
|
+
Exported = 4,
|
|
352
|
+
Static = 8
|
|
398
353
|
}
|
|
399
354
|
export declare class LeadingComment {
|
|
400
355
|
text: string;
|
|
@@ -409,10 +364,10 @@ export declare class JSDocComment extends LeadingComment {
|
|
|
409
364
|
toString(): string;
|
|
410
365
|
}
|
|
411
366
|
export declare abstract class Statement {
|
|
412
|
-
modifiers: StmtModifier
|
|
367
|
+
modifiers: StmtModifier;
|
|
413
368
|
sourceSpan: ParseSourceSpan | null;
|
|
414
369
|
leadingComments?: LeadingComment[];
|
|
415
|
-
constructor(modifiers?: StmtModifier
|
|
370
|
+
constructor(modifiers?: StmtModifier, sourceSpan?: ParseSourceSpan | null, leadingComments?: LeadingComment[]);
|
|
416
371
|
/**
|
|
417
372
|
* Calculates whether this statement produces the same value as the given statement.
|
|
418
373
|
* Note: We don't check Types nor ParseSourceSpans nor function arguments.
|
|
@@ -426,7 +381,7 @@ export declare class DeclareVarStmt extends Statement {
|
|
|
426
381
|
name: string;
|
|
427
382
|
value?: Expression;
|
|
428
383
|
type: Type | null;
|
|
429
|
-
constructor(name: string, value?: Expression, type?: Type | null, modifiers?: StmtModifier
|
|
384
|
+
constructor(name: string, value?: Expression, type?: Type | null, modifiers?: StmtModifier, sourceSpan?: ParseSourceSpan | null, leadingComments?: LeadingComment[]);
|
|
430
385
|
isEquivalent(stmt: Statement): boolean;
|
|
431
386
|
visitStatement(visitor: StatementVisitor, context: any): any;
|
|
432
387
|
}
|
|
@@ -435,7 +390,7 @@ export declare class DeclareFunctionStmt extends Statement {
|
|
|
435
390
|
params: FnParam[];
|
|
436
391
|
statements: Statement[];
|
|
437
392
|
type: Type | null;
|
|
438
|
-
constructor(name: string, params: FnParam[], statements: Statement[], type?: Type | null, modifiers?: StmtModifier
|
|
393
|
+
constructor(name: string, params: FnParam[], statements: Statement[], type?: Type | null, modifiers?: StmtModifier, sourceSpan?: ParseSourceSpan | null, leadingComments?: LeadingComment[]);
|
|
439
394
|
isEquivalent(stmt: Statement): boolean;
|
|
440
395
|
visitStatement(visitor: StatementVisitor, context: any): any;
|
|
441
396
|
}
|
|
@@ -451,42 +406,6 @@ export declare class ReturnStatement extends Statement {
|
|
|
451
406
|
isEquivalent(stmt: Statement): boolean;
|
|
452
407
|
visitStatement(visitor: StatementVisitor, context: any): any;
|
|
453
408
|
}
|
|
454
|
-
export declare class AbstractClassPart {
|
|
455
|
-
type: Type | null;
|
|
456
|
-
modifiers: StmtModifier[];
|
|
457
|
-
constructor(type?: Type | null, modifiers?: StmtModifier[]);
|
|
458
|
-
hasModifier(modifier: StmtModifier): boolean;
|
|
459
|
-
}
|
|
460
|
-
export declare class ClassField extends AbstractClassPart {
|
|
461
|
-
name: string;
|
|
462
|
-
initializer?: Expression;
|
|
463
|
-
constructor(name: string, type?: Type | null, modifiers?: StmtModifier[], initializer?: Expression);
|
|
464
|
-
isEquivalent(f: ClassField): boolean;
|
|
465
|
-
}
|
|
466
|
-
export declare class ClassMethod extends AbstractClassPart {
|
|
467
|
-
name: string | null;
|
|
468
|
-
params: FnParam[];
|
|
469
|
-
body: Statement[];
|
|
470
|
-
constructor(name: string | null, params: FnParam[], body: Statement[], type?: Type | null, modifiers?: StmtModifier[]);
|
|
471
|
-
isEquivalent(m: ClassMethod): boolean;
|
|
472
|
-
}
|
|
473
|
-
export declare class ClassGetter extends AbstractClassPart {
|
|
474
|
-
name: string;
|
|
475
|
-
body: Statement[];
|
|
476
|
-
constructor(name: string, body: Statement[], type?: Type | null, modifiers?: StmtModifier[]);
|
|
477
|
-
isEquivalent(m: ClassGetter): boolean;
|
|
478
|
-
}
|
|
479
|
-
export declare class ClassStmt extends Statement {
|
|
480
|
-
name: string;
|
|
481
|
-
parent: Expression | null;
|
|
482
|
-
fields: ClassField[];
|
|
483
|
-
getters: ClassGetter[];
|
|
484
|
-
constructorMethod: ClassMethod;
|
|
485
|
-
methods: ClassMethod[];
|
|
486
|
-
constructor(name: string, parent: Expression | null, fields: ClassField[], getters: ClassGetter[], constructorMethod: ClassMethod, methods: ClassMethod[], modifiers?: StmtModifier[], sourceSpan?: ParseSourceSpan | null, leadingComments?: LeadingComment[]);
|
|
487
|
-
isEquivalent(stmt: Statement): boolean;
|
|
488
|
-
visitStatement(visitor: StatementVisitor, context: any): any;
|
|
489
|
-
}
|
|
490
409
|
export declare class IfStmt extends Statement {
|
|
491
410
|
condition: Expression;
|
|
492
411
|
trueCase: Statement[];
|
|
@@ -500,12 +419,14 @@ export interface StatementVisitor {
|
|
|
500
419
|
visitDeclareFunctionStmt(stmt: DeclareFunctionStmt, context: any): any;
|
|
501
420
|
visitExpressionStmt(stmt: ExpressionStatement, context: any): any;
|
|
502
421
|
visitReturnStmt(stmt: ReturnStatement, context: any): any;
|
|
503
|
-
visitDeclareClassStmt(stmt: ClassStmt, context: any): any;
|
|
504
422
|
visitIfStmt(stmt: IfStmt, context: any): any;
|
|
505
423
|
}
|
|
424
|
+
export declare function leadingComment(text: string, multiline?: boolean, trailingNewline?: boolean): LeadingComment;
|
|
425
|
+
export declare function jsDocComment(tags?: JSDocTag[]): JSDocComment;
|
|
506
426
|
export declare function variable(name: string, type?: Type | null, sourceSpan?: ParseSourceSpan | null): ReadVarExpr;
|
|
507
427
|
export declare function importExpr(id: ExternalReference, typeParams?: Type[] | null, sourceSpan?: ParseSourceSpan | null): ExternalExpr;
|
|
508
|
-
export declare function
|
|
428
|
+
export declare function importType(id: ExternalReference, typeParams?: Type[] | null, typeModifiers?: TypeModifier): ExpressionType | null;
|
|
429
|
+
export declare function expressionType(expr: Expression, typeModifiers?: TypeModifier, typeParams?: Type[] | null): ExpressionType;
|
|
509
430
|
export declare function typeofExpr(expr: Expression): TypeofExpr;
|
|
510
431
|
export declare function literalArr(values: Expression[], type?: Type | null, sourceSpan?: ParseSourceSpan | null): LiteralArrayExpr;
|
|
511
432
|
export declare function literalMap(values: {
|
|
@@ -515,7 +436,6 @@ export declare function literalMap(values: {
|
|
|
515
436
|
}[], type?: MapType | null): LiteralMapExpr;
|
|
516
437
|
export declare function unary(operator: UnaryOperator, expr: Expression, type?: Type, sourceSpan?: ParseSourceSpan | null): UnaryOperatorExpr;
|
|
517
438
|
export declare function not(expr: Expression, sourceSpan?: ParseSourceSpan | null): NotExpr;
|
|
518
|
-
export declare function assertNotNull(expr: Expression, sourceSpan?: ParseSourceSpan | null): AssertNotNull;
|
|
519
439
|
export declare function fn(params: FnParam[], body: Statement[], type?: Type | null, sourceSpan?: ParseSourceSpan | null, name?: string | null): FunctionExpr;
|
|
520
440
|
export declare function ifStmt(condition: Expression, thenClause: Statement[], elseClause?: Statement[], sourceSpan?: ParseSourceSpan, leadingComments?: LeadingComment[]): IfStmt;
|
|
521
441
|
export declare function literal(value: any, type?: Type | null, sourceSpan?: ParseSourceSpan | null): LiteralExpr;
|
|
@@ -523,9 +443,10 @@ export declare function isNull(exp: Expression): boolean;
|
|
|
523
443
|
export declare const enum JSDocTagName {
|
|
524
444
|
Desc = "desc",
|
|
525
445
|
Id = "id",
|
|
526
|
-
Meaning = "meaning"
|
|
446
|
+
Meaning = "meaning",
|
|
447
|
+
Suppress = "suppress"
|
|
527
448
|
}
|
|
528
|
-
export
|
|
449
|
+
export type JSDocTag = {
|
|
529
450
|
tagName: JSDocTagName | string;
|
|
530
451
|
text?: string;
|
|
531
452
|
} | {
|