static-injector 1.0.8
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 +1248 -0
- package/import/es2015/decorator/injectable.js +14 -0
- package/import/es2015/decorator/interface/provider.js +8 -0
- package/import/es2015/di/forward_ref.js +53 -0
- package/import/es2015/di/inject_switch.js +31 -0
- package/import/es2015/di/injection_token.js +71 -0
- package/import/es2015/di/injector.js +63 -0
- package/import/es2015/di/injector_compatibility.js +172 -0
- package/import/es2015/di/injector_marker.js +8 -0
- package/import/es2015/di/injector_token.js +21 -0
- package/import/es2015/di/interface/defs.js +72 -0
- package/import/es2015/di/interface/injector.js +25 -0
- package/import/es2015/di/interface/provider.js +8 -0
- package/import/es2015/di/metadata.js +49 -0
- package/import/es2015/di/null_injector.js +19 -0
- package/import/es2015/di/provider_token.js +8 -0
- package/import/es2015/di/r3_injector.js +382 -0
- package/import/es2015/di/scope.js +14 -0
- package/import/es2015/index.js +11 -0
- package/import/es2015/interface/lifecycle_hooks.js +8 -0
- package/import/es2015/interface/type.js +8 -0
- package/import/es2015/render3/definition_factory.js +15 -0
- package/import/es2015/render3/error_code.js +29 -0
- package/import/es2015/render3/errors_di.js +14 -0
- package/import/es2015/render3/fields.js +11 -0
- package/import/es2015/render3/instructions/di.js +23 -0
- package/import/es2015/render3/util/stringify_utils.js +37 -0
- package/import/es2015/util/array_utils.js +17 -0
- package/import/es2015/util/closure.js +19 -0
- package/import/es2015/util/decorators.js +30 -0
- package/import/es2015/util/empty.js +14 -0
- package/import/es2015/util/property.js +15 -0
- package/import/es2015/util/stringify.js +30 -0
- package/import/fesm2015/index.js +1211 -0
- package/import/typings/decorator/injectable.d.ts +82 -0
- package/import/typings/decorator/interface/provider.d.ts +312 -0
- package/import/typings/di/forward_ref.d.ts +49 -0
- package/import/typings/di/inject_switch.d.ts +17 -0
- package/import/typings/di/injection_token.d.ts +57 -0
- package/import/typings/di/injector.d.ts +76 -0
- package/import/typings/di/injector_compatibility.d.ts +77 -0
- package/import/typings/di/injector_marker.d.ts +23 -0
- package/import/typings/di/injector_token.d.ts +18 -0
- package/import/typings/di/interface/defs.d.ts +155 -0
- package/import/typings/di/interface/injector.d.ts +48 -0
- package/import/typings/di/interface/provider.d.ts +312 -0
- package/import/typings/di/metadata.d.ts +176 -0
- package/import/typings/di/null_injector.d.ts +11 -0
- package/import/typings/di/provider_token.d.ts +17 -0
- package/import/typings/di/r3_injector.d.ts +92 -0
- package/import/typings/di/scope.d.ts +14 -0
- package/import/typings/index.d.ts +11 -0
- package/import/typings/interface/lifecycle_hooks.d.ts +28 -0
- package/import/typings/interface/type.d.ts +21 -0
- package/import/typings/render3/definition_factory.d.ts +24 -0
- package/import/typings/render3/error_code.d.ts +24 -0
- package/import/typings/render3/errors_di.d.ts +2 -0
- package/import/typings/render3/fields.d.ts +8 -0
- package/import/typings/render3/instructions/di.d.ts +20 -0
- package/import/typings/render3/util/stringify_utils.d.ts +20 -0
- package/import/typings/util/array_utils.d.ts +10 -0
- package/import/typings/util/closure.d.ts +17 -0
- package/import/typings/util/decorators.d.ts +27 -0
- package/import/typings/util/empty.d.ts +14 -0
- package/import/typings/util/property.d.ts +8 -0
- package/import/typings/util/stringify.d.ts +8 -0
- package/package.json +34 -0
- package/readme.md +27 -0
- package/transform/compiler/index.d.ts +5 -0
- package/transform/compiler/index.js +17 -0
- package/transform/compiler/src/core.d.ts +19 -0
- package/transform/compiler/src/core.js +9 -0
- package/transform/compiler/src/injectable_compiler_2.d.ts +53 -0
- package/transform/compiler/src/injectable_compiler_2.js +159 -0
- package/transform/compiler/src/output/output_ast.d.ts +534 -0
- package/transform/compiler/src/output/output_ast.js +986 -0
- package/transform/compiler/src/parse_util.d.ts +50 -0
- package/transform/compiler/src/parse_util.js +61 -0
- package/transform/compiler/src/render3/partial/api.d.ts +166 -0
- package/transform/compiler/src/render3/partial/api.js +11 -0
- package/transform/compiler/src/render3/partial/util.d.ts +16 -0
- package/transform/compiler/src/render3/partial/util.js +44 -0
- package/transform/compiler/src/render3/r3_factory.d.ts +97 -0
- package/transform/compiler/src/render3/r3_factory.js +239 -0
- package/transform/compiler/src/render3/r3_identifiers.d.ts +20 -0
- package/transform/compiler/src/render3/r3_identifiers.js +51 -0
- package/transform/compiler/src/render3/util.d.ts +21 -0
- package/transform/compiler/src/render3/util.js +41 -0
- package/transform/compiler/src/render3/view/util.d.ts +30 -0
- package/transform/compiler/src/render3/view/util.js +57 -0
- package/transform/compiler-cli/src/ngtsc/annotations/src/factory.d.ts +11 -0
- package/transform/compiler-cli/src/ngtsc/annotations/src/factory.js +21 -0
- package/transform/compiler-cli/src/ngtsc/annotations/src/injectable.d.ts +42 -0
- package/transform/compiler-cli/src/ngtsc/annotations/src/injectable.js +278 -0
- package/transform/compiler-cli/src/ngtsc/annotations/src/util.d.ts +91 -0
- package/transform/compiler-cli/src/ngtsc/annotations/src/util.js +370 -0
- package/transform/compiler-cli/src/ngtsc/diagnostics/error.d.ts +24 -0
- package/transform/compiler-cli/src/ngtsc/diagnostics/error.js +76 -0
- package/transform/compiler-cli/src/ngtsc/diagnostics/error_code.d.ts +188 -0
- package/transform/compiler-cli/src/ngtsc/diagnostics/error_code.js +206 -0
- package/transform/compiler-cli/src/ngtsc/diagnostics/index.d.ts +2 -0
- package/transform/compiler-cli/src/ngtsc/diagnostics/index.js +14 -0
- package/transform/compiler-cli/src/ngtsc/imports/index.d.ts +1 -0
- package/transform/compiler-cli/src/ngtsc/imports/index.js +13 -0
- package/transform/compiler-cli/src/ngtsc/imports/src/core.d.ts +36 -0
- package/transform/compiler-cli/src/ngtsc/imports/src/core.js +25 -0
- package/transform/compiler-cli/src/ngtsc/reflection/index.d.ts +3 -0
- package/transform/compiler-cli/src/ngtsc/reflection/index.js +15 -0
- package/transform/compiler-cli/src/ngtsc/reflection/src/host.d.ts +667 -0
- package/transform/compiler-cli/src/ngtsc/reflection/src/host.js +98 -0
- package/transform/compiler-cli/src/ngtsc/reflection/src/type_to_value.d.ts +24 -0
- package/transform/compiler-cli/src/ngtsc/reflection/src/type_to_value.js +271 -0
- package/transform/compiler-cli/src/ngtsc/reflection/src/typescript.d.ts +50 -0
- package/transform/compiler-cli/src/ngtsc/reflection/src/typescript.js +396 -0
- package/transform/compiler-cli/src/ngtsc/reflection/src/util.d.ts +12 -0
- package/transform/compiler-cli/src/ngtsc/reflection/src/util.js +45 -0
- package/transform/compiler-cli/src/ngtsc/transform/index.d.ts +2 -0
- package/transform/compiler-cli/src/ngtsc/transform/index.js +14 -0
- package/transform/compiler-cli/src/ngtsc/transform/src/api.d.ts +115 -0
- package/transform/compiler-cli/src/ngtsc/transform/src/api.js +30 -0
- package/transform/compiler-cli/src/ngtsc/transform/src/utils.d.ts +15 -0
- package/transform/compiler-cli/src/ngtsc/transform/src/utils.js +84 -0
- package/transform/compiler-cli/src/ngtsc/translator/index.d.ts +5 -0
- package/transform/compiler-cli/src/ngtsc/translator/index.js +17 -0
- package/transform/compiler-cli/src/ngtsc/translator/src/api/ast_factory.d.ts +274 -0
- package/transform/compiler-cli/src/ngtsc/translator/src/api/ast_factory.js +9 -0
- package/transform/compiler-cli/src/ngtsc/translator/src/api/import_generator.d.ts +27 -0
- package/transform/compiler-cli/src/ngtsc/translator/src/api/import_generator.js +9 -0
- package/transform/compiler-cli/src/ngtsc/translator/src/context.d.ts +18 -0
- package/transform/compiler-cli/src/ngtsc/translator/src/context.js +27 -0
- package/transform/compiler-cli/src/ngtsc/translator/src/import_manager.d.ts +29 -0
- package/transform/compiler-cli/src/ngtsc/translator/src/import_manager.js +70 -0
- package/transform/compiler-cli/src/ngtsc/translator/src/translator.d.ts +58 -0
- package/transform/compiler-cli/src/ngtsc/translator/src/translator.js +270 -0
- package/transform/compiler-cli/src/ngtsc/translator/src/typescript_ast_factory.d.ts +54 -0
- package/transform/compiler-cli/src/ngtsc/translator/src/typescript_ast_factory.js +245 -0
- package/transform/compiler-cli/src/ngtsc/translator/src/typescript_translator.d.ts +13 -0
- package/transform/compiler-cli/src/ngtsc/translator/src/typescript_translator.js +21 -0
- package/transform/compiler-cli/src/ngtsc/util/src/typescript.d.ts +11 -0
- package/transform/compiler-cli/src/ngtsc/util/src/typescript.js +39 -0
- package/transform/index.d.ts +1 -0
- package/transform/index.js +13 -0
- package/transform/injectable-transform.d.ts +41 -0
- package/transform/injectable-transform.js +195 -0
- package/transform/node-Iteration.d.ts +2 -0
- package/transform/node-Iteration.js +12 -0
|
@@ -0,0 +1,239 @@
|
|
|
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
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
12
|
+
}) : (function(o, m, k, k2) {
|
|
13
|
+
if (k2 === undefined) k2 = k;
|
|
14
|
+
o[k2] = m[k];
|
|
15
|
+
}));
|
|
16
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
17
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
18
|
+
}) : function(o, v) {
|
|
19
|
+
o["default"] = v;
|
|
20
|
+
});
|
|
21
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
22
|
+
if (mod && mod.__esModule) return mod;
|
|
23
|
+
var result = {};
|
|
24
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
25
|
+
__setModuleDefault(result, mod);
|
|
26
|
+
return result;
|
|
27
|
+
};
|
|
28
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
+
exports.isExpressionFactoryMetadata = exports.isDelegatedFactoryMetadata = exports.createFactoryType = exports.compileFactoryFunction = exports.FactoryTarget = exports.R3FactoryDelegateType = void 0;
|
|
30
|
+
const outputAst = __importStar(require("../output/output_ast"));
|
|
31
|
+
const r3_identifiers_1 = require("../render3/r3_identifiers");
|
|
32
|
+
const util_1 = require("./util");
|
|
33
|
+
var R3FactoryDelegateType;
|
|
34
|
+
(function (R3FactoryDelegateType) {
|
|
35
|
+
R3FactoryDelegateType[R3FactoryDelegateType["Class"] = 0] = "Class";
|
|
36
|
+
R3FactoryDelegateType[R3FactoryDelegateType["Function"] = 1] = "Function";
|
|
37
|
+
})(R3FactoryDelegateType = exports.R3FactoryDelegateType || (exports.R3FactoryDelegateType = {}));
|
|
38
|
+
var FactoryTarget;
|
|
39
|
+
(function (FactoryTarget) {
|
|
40
|
+
FactoryTarget[FactoryTarget["Directive"] = 0] = "Directive";
|
|
41
|
+
FactoryTarget[FactoryTarget["Component"] = 1] = "Component";
|
|
42
|
+
FactoryTarget[FactoryTarget["Injectable"] = 2] = "Injectable";
|
|
43
|
+
FactoryTarget[FactoryTarget["Pipe"] = 3] = "Pipe";
|
|
44
|
+
FactoryTarget[FactoryTarget["NgModule"] = 4] = "NgModule";
|
|
45
|
+
})(FactoryTarget = exports.FactoryTarget || (exports.FactoryTarget = {}));
|
|
46
|
+
/**
|
|
47
|
+
* Construct a factory function expression for the given `R3FactoryMetadata`.
|
|
48
|
+
*/
|
|
49
|
+
function compileFactoryFunction(meta) {
|
|
50
|
+
const t = outputAst.variable('t');
|
|
51
|
+
let baseFactoryVar = null;
|
|
52
|
+
// The type to instantiate via constructor invocation. If there is no delegated factory, meaning
|
|
53
|
+
// this type is always created by constructor invocation, then this is the type-to-create
|
|
54
|
+
// parameter provided by the user (t) if specified, or the current type if not. If there is a
|
|
55
|
+
// delegated factory (which is used to create the current type) then this is only the type-to-
|
|
56
|
+
// create parameter (t).
|
|
57
|
+
const typeForCtor = !isDelegatedFactoryMetadata(meta)
|
|
58
|
+
? new outputAst.BinaryOperatorExpr(outputAst.BinaryOperator.Or, t, meta.internalType)
|
|
59
|
+
: t;
|
|
60
|
+
let ctorExpr = null;
|
|
61
|
+
if (meta.deps !== null) {
|
|
62
|
+
// There is a constructor (either explicitly or implicitly defined).
|
|
63
|
+
if (meta.deps !== 'invalid') {
|
|
64
|
+
ctorExpr = new outputAst.InstantiateExpr(typeForCtor, injectDependencies(meta.deps, meta.target));
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
else {
|
|
68
|
+
// There is no constructor, use the base class' factory to construct typeForCtor.
|
|
69
|
+
baseFactoryVar = outputAst.variable(`ɵ${meta.name}_BaseFactory`);
|
|
70
|
+
ctorExpr = baseFactoryVar.callFn([typeForCtor]);
|
|
71
|
+
}
|
|
72
|
+
const body = [];
|
|
73
|
+
let retExpr = null;
|
|
74
|
+
function makeConditionalFactory(nonCtorExpr) {
|
|
75
|
+
const r = outputAst.variable('r');
|
|
76
|
+
body.push(r.set(outputAst.NULL_EXPR).toDeclStmt());
|
|
77
|
+
const ctorStmt = ctorExpr !== null
|
|
78
|
+
? r.set(ctorExpr).toStmt()
|
|
79
|
+
: outputAst.importExpr(r3_identifiers_1.Identifiers.invalidFactory).callFn([]).toStmt();
|
|
80
|
+
body.push(outputAst.ifStmt(t, [ctorStmt], [r.set(nonCtorExpr).toStmt()]));
|
|
81
|
+
return r;
|
|
82
|
+
}
|
|
83
|
+
if (isDelegatedFactoryMetadata(meta)) {
|
|
84
|
+
// This type is created with a delegated factory. If a type parameter is not specified, call
|
|
85
|
+
// the factory instead.
|
|
86
|
+
const delegateArgs = injectDependencies(meta.delegateDeps, meta.target);
|
|
87
|
+
// Either call `new delegate(...)` or `delegate(...)` depending on meta.delegateType.
|
|
88
|
+
const factoryExpr = new (meta.delegateType === R3FactoryDelegateType.Class
|
|
89
|
+
? outputAst.InstantiateExpr
|
|
90
|
+
: outputAst.InvokeFunctionExpr)(meta.delegate, delegateArgs);
|
|
91
|
+
retExpr = makeConditionalFactory(factoryExpr);
|
|
92
|
+
}
|
|
93
|
+
else if (isExpressionFactoryMetadata(meta)) {
|
|
94
|
+
// TODO(alxhub): decide whether to lower the value here or in the caller
|
|
95
|
+
retExpr = makeConditionalFactory(meta.expression);
|
|
96
|
+
}
|
|
97
|
+
else {
|
|
98
|
+
retExpr = ctorExpr;
|
|
99
|
+
}
|
|
100
|
+
if (retExpr === null) {
|
|
101
|
+
// The expression cannot be formed so render an `ɵɵinvalidFactory()` call.
|
|
102
|
+
body.push(outputAst.importExpr(r3_identifiers_1.Identifiers.invalidFactory).callFn([]).toStmt());
|
|
103
|
+
}
|
|
104
|
+
else if (baseFactoryVar !== null) {
|
|
105
|
+
// This factory uses a base factory, so call `ɵɵgetInheritedFactory()` to compute it.
|
|
106
|
+
const getInheritedFactoryCall = outputAst
|
|
107
|
+
.importExpr(r3_identifiers_1.Identifiers.getInheritedFactory)
|
|
108
|
+
.callFn([meta.internalType]);
|
|
109
|
+
// Memoize the base factoryFn: `baseFactory || (baseFactory = ɵɵgetInheritedFactory(...))`
|
|
110
|
+
const baseFactory = new outputAst.BinaryOperatorExpr(outputAst.BinaryOperator.Or, baseFactoryVar, baseFactoryVar.set(getInheritedFactoryCall));
|
|
111
|
+
body.push(new outputAst.ReturnStatement(baseFactory.callFn([typeForCtor])));
|
|
112
|
+
}
|
|
113
|
+
else {
|
|
114
|
+
// This is straightforward factory, just return it.
|
|
115
|
+
body.push(new outputAst.ReturnStatement(retExpr));
|
|
116
|
+
}
|
|
117
|
+
let factoryFn = outputAst.fn([new outputAst.FnParam('t', outputAst.DYNAMIC_TYPE)], body, outputAst.INFERRED_TYPE, undefined, `${meta.name}_Factory`);
|
|
118
|
+
if (baseFactoryVar !== null) {
|
|
119
|
+
// There is a base factory variable so wrap its declaration along with the factory function into
|
|
120
|
+
// an IIFE.
|
|
121
|
+
factoryFn = outputAst
|
|
122
|
+
.fn([], [
|
|
123
|
+
new outputAst.DeclareVarStmt(baseFactoryVar.name),
|
|
124
|
+
new outputAst.ReturnStatement(factoryFn),
|
|
125
|
+
])
|
|
126
|
+
.callFn([], /* sourceSpan */ undefined, /* pure */ true);
|
|
127
|
+
}
|
|
128
|
+
return {
|
|
129
|
+
expression: factoryFn,
|
|
130
|
+
statements: [],
|
|
131
|
+
type: createFactoryType(meta),
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
exports.compileFactoryFunction = compileFactoryFunction;
|
|
135
|
+
function createFactoryType(meta) {
|
|
136
|
+
const ctorDepsType = meta.deps !== null && meta.deps !== 'invalid'
|
|
137
|
+
? createCtorDepsType(meta.deps)
|
|
138
|
+
: outputAst.NONE_TYPE;
|
|
139
|
+
return outputAst.expressionType(outputAst.importExpr(r3_identifiers_1.Identifiers.FactoryDeclaration, [
|
|
140
|
+
util_1.typeWithParameters(meta.type.type, meta.typeArgumentCount),
|
|
141
|
+
ctorDepsType,
|
|
142
|
+
]));
|
|
143
|
+
}
|
|
144
|
+
exports.createFactoryType = createFactoryType;
|
|
145
|
+
function injectDependencies(deps, target) {
|
|
146
|
+
return deps.map((dep, index) => compileInjectDependency(dep, target, index));
|
|
147
|
+
}
|
|
148
|
+
function compileInjectDependency(dep, target, index) {
|
|
149
|
+
// Interpret the dependency according to its resolved type.
|
|
150
|
+
if (dep.token === null) {
|
|
151
|
+
return outputAst
|
|
152
|
+
.importExpr(r3_identifiers_1.Identifiers.invalidFactoryDep)
|
|
153
|
+
.callFn([outputAst.literal(index)]);
|
|
154
|
+
}
|
|
155
|
+
else if (dep.attributeNameType === null) {
|
|
156
|
+
// Build up the injection flags according to the metadata.
|
|
157
|
+
const flags = 0 /* Default */ |
|
|
158
|
+
(dep.self ? 2 /* Self */ : 0) |
|
|
159
|
+
(dep.skipSelf ? 4 /* SkipSelf */ : 0) |
|
|
160
|
+
(dep.optional ? 8 /* Optional */ : 0);
|
|
161
|
+
// If this dependency is optional or otherwise has non-default flags, then additional
|
|
162
|
+
// parameters describing how to inject the dependency must be passed to the inject function
|
|
163
|
+
// that's being used.
|
|
164
|
+
let flagsParam = flags !== 0 /* Default */ || dep.optional
|
|
165
|
+
? outputAst.literal(flags)
|
|
166
|
+
: null;
|
|
167
|
+
// Build up the arguments to the injectFn call.
|
|
168
|
+
const injectArgs = [dep.token];
|
|
169
|
+
if (flagsParam) {
|
|
170
|
+
injectArgs.push(flagsParam);
|
|
171
|
+
}
|
|
172
|
+
const injectFn = getInjectFn(target);
|
|
173
|
+
return outputAst.importExpr(injectFn).callFn(injectArgs);
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
function createCtorDepsType(deps) {
|
|
177
|
+
let hasTypes = false;
|
|
178
|
+
const attributeTypes = deps.map((dep) => {
|
|
179
|
+
const type = createCtorDepType(dep);
|
|
180
|
+
if (type !== null) {
|
|
181
|
+
hasTypes = true;
|
|
182
|
+
return type;
|
|
183
|
+
}
|
|
184
|
+
else {
|
|
185
|
+
return outputAst.literal(null);
|
|
186
|
+
}
|
|
187
|
+
});
|
|
188
|
+
if (hasTypes) {
|
|
189
|
+
return outputAst.expressionType(outputAst.literalArr(attributeTypes));
|
|
190
|
+
}
|
|
191
|
+
else {
|
|
192
|
+
return outputAst.NONE_TYPE;
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
function createCtorDepType(dep) {
|
|
196
|
+
const entries = [];
|
|
197
|
+
if (dep.optional) {
|
|
198
|
+
entries.push({
|
|
199
|
+
key: 'optional',
|
|
200
|
+
value: outputAst.literal(true),
|
|
201
|
+
quoted: false,
|
|
202
|
+
});
|
|
203
|
+
}
|
|
204
|
+
if (dep.self) {
|
|
205
|
+
entries.push({
|
|
206
|
+
key: 'self',
|
|
207
|
+
value: outputAst.literal(true),
|
|
208
|
+
quoted: false,
|
|
209
|
+
});
|
|
210
|
+
}
|
|
211
|
+
if (dep.skipSelf) {
|
|
212
|
+
entries.push({
|
|
213
|
+
key: 'skipSelf',
|
|
214
|
+
value: outputAst.literal(true),
|
|
215
|
+
quoted: false,
|
|
216
|
+
});
|
|
217
|
+
}
|
|
218
|
+
return entries.length > 0 ? outputAst.literalMap(entries) : null;
|
|
219
|
+
}
|
|
220
|
+
function isDelegatedFactoryMetadata(meta) {
|
|
221
|
+
return meta.delegateType !== undefined;
|
|
222
|
+
}
|
|
223
|
+
exports.isDelegatedFactoryMetadata = isDelegatedFactoryMetadata;
|
|
224
|
+
function isExpressionFactoryMetadata(meta) {
|
|
225
|
+
return meta.expression !== undefined;
|
|
226
|
+
}
|
|
227
|
+
exports.isExpressionFactoryMetadata = isExpressionFactoryMetadata;
|
|
228
|
+
function getInjectFn(target) {
|
|
229
|
+
switch (target) {
|
|
230
|
+
case FactoryTarget.Component:
|
|
231
|
+
case FactoryTarget.Directive:
|
|
232
|
+
case FactoryTarget.Pipe:
|
|
233
|
+
return r3_identifiers_1.Identifiers.directiveInject;
|
|
234
|
+
case FactoryTarget.NgModule:
|
|
235
|
+
case FactoryTarget.Injectable:
|
|
236
|
+
default:
|
|
237
|
+
return r3_identifiers_1.Identifiers.inject;
|
|
238
|
+
}
|
|
239
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
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 o from '../output/output_ast';
|
|
9
|
+
export declare class Identifiers {
|
|
10
|
+
static inject: o.ExternalReference;
|
|
11
|
+
static directiveInject: o.ExternalReference;
|
|
12
|
+
static invalidFactory: o.ExternalReference;
|
|
13
|
+
static invalidFactoryDep: o.ExternalReference;
|
|
14
|
+
static forwardRef: o.ExternalReference;
|
|
15
|
+
static resolveForwardRef: o.ExternalReference;
|
|
16
|
+
static ɵɵdefineInjectable: o.ExternalReference;
|
|
17
|
+
static InjectableDeclaration: o.ExternalReference;
|
|
18
|
+
static FactoryDeclaration: o.ExternalReference;
|
|
19
|
+
static getInheritedFactory: o.ExternalReference;
|
|
20
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.Identifiers = void 0;
|
|
11
|
+
const CORE = 'static-injector';
|
|
12
|
+
class Identifiers {
|
|
13
|
+
}
|
|
14
|
+
exports.Identifiers = Identifiers;
|
|
15
|
+
Identifiers.inject = { name: 'ɵɵinject', moduleName: CORE };
|
|
16
|
+
Identifiers.directiveInject = {
|
|
17
|
+
name: 'ɵɵdirectiveInject',
|
|
18
|
+
moduleName: CORE,
|
|
19
|
+
};
|
|
20
|
+
Identifiers.invalidFactory = {
|
|
21
|
+
name: 'ɵɵinvalidFactory',
|
|
22
|
+
moduleName: CORE,
|
|
23
|
+
};
|
|
24
|
+
Identifiers.invalidFactoryDep = {
|
|
25
|
+
name: 'ɵɵinvalidFactoryDep',
|
|
26
|
+
moduleName: CORE,
|
|
27
|
+
};
|
|
28
|
+
Identifiers.forwardRef = {
|
|
29
|
+
name: 'forwardRef',
|
|
30
|
+
moduleName: CORE,
|
|
31
|
+
};
|
|
32
|
+
Identifiers.resolveForwardRef = {
|
|
33
|
+
name: 'resolveForwardRef',
|
|
34
|
+
moduleName: CORE,
|
|
35
|
+
};
|
|
36
|
+
Identifiers.ɵɵdefineInjectable = {
|
|
37
|
+
name: 'ɵɵdefineInjectable',
|
|
38
|
+
moduleName: CORE,
|
|
39
|
+
};
|
|
40
|
+
Identifiers.InjectableDeclaration = {
|
|
41
|
+
name: 'ɵɵInjectableDeclaration',
|
|
42
|
+
moduleName: CORE,
|
|
43
|
+
};
|
|
44
|
+
Identifiers.FactoryDeclaration = {
|
|
45
|
+
name: 'ɵɵFactoryDeclaration',
|
|
46
|
+
moduleName: CORE,
|
|
47
|
+
};
|
|
48
|
+
Identifiers.getInheritedFactory = {
|
|
49
|
+
name: 'ɵɵgetInheritedFactory',
|
|
50
|
+
moduleName: CORE,
|
|
51
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
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 o from '../output/output_ast';
|
|
9
|
+
export declare function typeWithParameters(type: o.Expression, numParams: number): o.ExpressionType;
|
|
10
|
+
export interface R3Reference {
|
|
11
|
+
value: o.Expression;
|
|
12
|
+
type: o.Expression;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Result of compilation of a render3 code unit, e.g. component, directive, pipe, etc.
|
|
16
|
+
*/
|
|
17
|
+
export interface R3CompiledExpression {
|
|
18
|
+
expression: o.Expression;
|
|
19
|
+
type: o.Type;
|
|
20
|
+
statements: o.Statement[];
|
|
21
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
+
}) : (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
o[k2] = m[k];
|
|
8
|
+
}));
|
|
9
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
10
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
11
|
+
}) : function(o, v) {
|
|
12
|
+
o["default"] = v;
|
|
13
|
+
});
|
|
14
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
|
+
if (mod && mod.__esModule) return mod;
|
|
16
|
+
var result = {};
|
|
17
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
|
+
__setModuleDefault(result, mod);
|
|
19
|
+
return result;
|
|
20
|
+
};
|
|
21
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
|
+
exports.typeWithParameters = void 0;
|
|
23
|
+
/**
|
|
24
|
+
* @license
|
|
25
|
+
* Copyright Google LLC All Rights Reserved.
|
|
26
|
+
*
|
|
27
|
+
* Use of this source code is governed by an MIT-style license that can be
|
|
28
|
+
* found in the LICENSE file at https://angular.io/license
|
|
29
|
+
*/
|
|
30
|
+
const o = __importStar(require("../output/output_ast"));
|
|
31
|
+
function typeWithParameters(type, numParams) {
|
|
32
|
+
if (numParams === 0) {
|
|
33
|
+
return o.expressionType(type);
|
|
34
|
+
}
|
|
35
|
+
const params = [];
|
|
36
|
+
for (let i = 0; i < numParams; i++) {
|
|
37
|
+
params.push(o.DYNAMIC_TYPE);
|
|
38
|
+
}
|
|
39
|
+
return o.expressionType(type, undefined, params);
|
|
40
|
+
}
|
|
41
|
+
exports.typeWithParameters = typeWithParameters;
|
|
@@ -0,0 +1,30 @@
|
|
|
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 o from '../../output/output_ast';
|
|
9
|
+
/**
|
|
10
|
+
* Checks whether an object key contains potentially unsafe chars, thus the key should be wrapped in
|
|
11
|
+
* quotes. Note: we do not wrap all keys into quotes, as it may have impact on minification and may
|
|
12
|
+
* bot work in some cases when object keys are mangled by minifier.
|
|
13
|
+
*
|
|
14
|
+
* TODO(FW-1136): this is a temporary solution, we need to come up with a better way of working with
|
|
15
|
+
* inputs that contain potentially unsafe chars.
|
|
16
|
+
*/
|
|
17
|
+
/**
|
|
18
|
+
* A representation for an object literal used during codegen of definition objects. The generic
|
|
19
|
+
* type `T` allows to reference a documented type of the generated structure, such that the
|
|
20
|
+
* property names that are set can be resolved to their documented declaration.
|
|
21
|
+
*/
|
|
22
|
+
export declare class DefinitionMap<T = any> {
|
|
23
|
+
values: {
|
|
24
|
+
key: string;
|
|
25
|
+
quoted: boolean;
|
|
26
|
+
value: o.Expression;
|
|
27
|
+
}[];
|
|
28
|
+
set(key: keyof T, value: o.Expression | null): void;
|
|
29
|
+
toLiteralMap(): o.LiteralMapExpr;
|
|
30
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
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
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
12
|
+
}) : (function(o, m, k, k2) {
|
|
13
|
+
if (k2 === undefined) k2 = k;
|
|
14
|
+
o[k2] = m[k];
|
|
15
|
+
}));
|
|
16
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
17
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
18
|
+
}) : function(o, v) {
|
|
19
|
+
o["default"] = v;
|
|
20
|
+
});
|
|
21
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
22
|
+
if (mod && mod.__esModule) return mod;
|
|
23
|
+
var result = {};
|
|
24
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
25
|
+
__setModuleDefault(result, mod);
|
|
26
|
+
return result;
|
|
27
|
+
};
|
|
28
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
+
exports.DefinitionMap = void 0;
|
|
30
|
+
const o = __importStar(require("../../output/output_ast"));
|
|
31
|
+
/**
|
|
32
|
+
* Checks whether an object key contains potentially unsafe chars, thus the key should be wrapped in
|
|
33
|
+
* quotes. Note: we do not wrap all keys into quotes, as it may have impact on minification and may
|
|
34
|
+
* bot work in some cases when object keys are mangled by minifier.
|
|
35
|
+
*
|
|
36
|
+
* TODO(FW-1136): this is a temporary solution, we need to come up with a better way of working with
|
|
37
|
+
* inputs that contain potentially unsafe chars.
|
|
38
|
+
*/
|
|
39
|
+
/**
|
|
40
|
+
* A representation for an object literal used during codegen of definition objects. The generic
|
|
41
|
+
* type `T` allows to reference a documented type of the generated structure, such that the
|
|
42
|
+
* property names that are set can be resolved to their documented declaration.
|
|
43
|
+
*/
|
|
44
|
+
class DefinitionMap {
|
|
45
|
+
constructor() {
|
|
46
|
+
this.values = [];
|
|
47
|
+
}
|
|
48
|
+
set(key, value) {
|
|
49
|
+
if (value) {
|
|
50
|
+
this.values.push({ key: key, value, quoted: false });
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
toLiteralMap() {
|
|
54
|
+
return o.literalMap(this.values);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
exports.DefinitionMap = DefinitionMap;
|