static-injector 1.0.6 → 1.0.10
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 +1295 -0
- package/import/{decorator → es2015/decorator}/injectable.js +1 -4
- package/import/{di → es2015/decorator}/interface/provider.js +1 -2
- package/import/{di → es2015/di}/forward_ref.js +8 -14
- package/import/{di → es2015/di}/inject_switch.js +8 -12
- package/import/{di → es2015/di}/injection_token.js +3 -9
- package/import/es2015/di/injector.js +63 -0
- package/import/{di → es2015/di}/injector_compatibility.js +31 -42
- package/import/{di → es2015/di}/injector_marker.js +1 -2
- package/import/{di → es2015/di}/injector_token.js +2 -5
- package/import/{di → es2015/di}/interface/defs.js +7 -42
- package/import/{di → es2015/di}/interface/injector.js +2 -5
- package/import/{decorator → es2015/di}/interface/provider.js +1 -2
- package/import/{di → es2015/di}/metadata.js +10 -13
- package/import/es2015/di/null_injector.js +19 -0
- package/import/{di → es2015/di}/provider_token.js +1 -2
- package/import/{di → es2015/di}/r3_injector.js +53 -153
- package/import/{di → es2015/di}/scope.js +2 -5
- package/import/es2015/index.js +12 -0
- package/import/{interface → es2015/interface}/lifecycle_hooks.js +1 -2
- package/import/es2015/interface/type.js +8 -0
- package/import/es2015/render3/definition_factory.js +15 -0
- package/import/es2015/render3/di.js +49 -0
- package/import/{render3 → es2015/render3}/error_code.js +2 -7
- package/import/es2015/render3/errors_di.js +14 -0
- package/import/es2015/render3/fields.js +11 -0
- package/import/{render3 → es2015/render3}/instructions/di.js +1 -5
- package/import/{render3 → es2015/render3}/util/stringify_utils.js +2 -7
- package/import/{util → es2015/util}/array_utils.js +2 -7
- package/import/{util → es2015/util}/closure.js +1 -5
- package/import/es2015/util/decorators.js +30 -0
- package/import/{util → es2015/util}/empty.js +1 -4
- package/import/{util → es2015/util}/property.js +1 -5
- package/import/{util → es2015/util}/stringify.js +1 -5
- package/import/fesm2015/index.js +1257 -0
- package/import/{decorator → typings/decorator}/injectable.d.ts +0 -0
- package/import/{decorator → typings/decorator}/interface/provider.d.ts +0 -0
- package/import/{di → typings/di}/forward_ref.d.ts +0 -0
- package/import/{di → typings/di}/inject_switch.d.ts +0 -0
- package/import/{di → typings/di}/injection_token.d.ts +0 -2
- package/import/{di → typings/di}/injector.d.ts +0 -10
- package/import/{di → typings/di}/injector_compatibility.d.ts +0 -0
- package/import/{di → typings/di}/injector_marker.d.ts +0 -0
- package/import/{di → typings/di}/injector_token.d.ts +0 -0
- package/import/{di → typings/di}/interface/defs.d.ts +4 -20
- package/import/{di → typings/di}/interface/injector.d.ts +0 -0
- package/import/{di → typings/di}/interface/provider.d.ts +0 -0
- package/import/{di → typings/di}/metadata.d.ts +0 -0
- package/import/{di → typings/di}/null_injector.d.ts +0 -0
- package/import/{di → typings/di}/provider_token.d.ts +0 -0
- package/import/{di → typings/di}/r3_injector.d.ts +0 -2
- package/import/{di → typings/di}/scope.d.ts +0 -0
- package/import/{index.d.ts → typings/index.d.ts} +1 -0
- package/import/{interface → typings/interface}/lifecycle_hooks.d.ts +0 -0
- package/import/{interface → typings/interface}/type.d.ts +0 -11
- package/import/{render3 → typings/render3}/definition_factory.d.ts +0 -0
- package/import/typings/render3/di.d.ts +12 -0
- package/import/{render3 → typings/render3}/error_code.d.ts +0 -0
- package/import/{render3 → typings/render3}/errors_di.d.ts +0 -0
- package/import/{render3 → typings/render3}/fields.d.ts +0 -0
- package/import/{render3 → typings/render3}/instructions/di.d.ts +0 -0
- package/import/{render3 → typings/render3}/util/stringify_utils.d.ts +0 -0
- package/import/{util → typings/util}/array_utils.d.ts +0 -0
- package/import/{util → typings/util}/closure.d.ts +0 -0
- package/import/{util → typings/util}/decorators.d.ts +1 -3
- package/import/{util → typings/util}/empty.d.ts +0 -0
- package/import/{util → typings/util}/property.d.ts +0 -0
- package/import/{util → typings/util}/stringify.d.ts +0 -0
- package/package.json +8 -4
- package/readme.md +6 -0
- package/transform/compiler/index.js +15 -6
- package/transform/compiler/src/injectable_compiler_2.js +20 -2
- package/transform/compiler/src/render3/partial/util.js +20 -2
- package/transform/compiler/src/render3/r3_factory.js +20 -2
- package/transform/compiler/src/render3/util.js +20 -2
- package/transform/compiler/src/render3/view/util.js +20 -2
- package/transform/compiler-cli/src/ngtsc/annotations/src/injectable.js +20 -2
- package/transform/compiler-cli/src/ngtsc/annotations/src/util.js +20 -2
- package/transform/compiler-cli/src/ngtsc/diagnostics/error.js +20 -2
- package/transform/compiler-cli/src/ngtsc/diagnostics/index.js +12 -3
- package/transform/compiler-cli/src/ngtsc/imports/index.js +11 -2
- package/transform/compiler-cli/src/ngtsc/reflection/index.js +13 -4
- package/transform/compiler-cli/src/ngtsc/reflection/src/host.js +20 -2
- package/transform/compiler-cli/src/ngtsc/reflection/src/type_to_value.js +20 -2
- package/transform/compiler-cli/src/ngtsc/reflection/src/typescript.js +20 -2
- package/transform/compiler-cli/src/ngtsc/reflection/src/util.js +20 -2
- package/transform/compiler-cli/src/ngtsc/transform/index.js +12 -3
- package/transform/compiler-cli/src/ngtsc/transform/src/utils.js +20 -2
- package/transform/compiler-cli/src/ngtsc/translator/index.js +15 -6
- package/transform/compiler-cli/src/ngtsc/translator/src/import_manager.js +20 -2
- package/transform/compiler-cli/src/ngtsc/translator/src/translator.js +20 -2
- package/transform/compiler-cli/src/ngtsc/translator/src/typescript_ast_factory.js +20 -2
- package/transform/compiler-cli/src/ngtsc/util/src/typescript.js +20 -2
- package/transform/index.js +11 -2
- package/transform/injectable-transform.js +23 -2
- package/transform/node-Iteration.js +4 -2
- package/import/di/injector.js +0 -350
- package/import/di/null_injector.js +0 -23
- package/import/index.js +0 -14
- package/import/interface/type.js +0 -21
- package/import/render3/definition_factory.js +0 -19
- package/import/render3/errors_di.js +0 -18
- package/import/render3/fields.js +0 -14
- package/import/util/decorators.js +0 -58
package/import/di/injector.js
DELETED
|
@@ -1,350 +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
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
-
exports.StaticInjector = exports.Injector = exports.INJECTOR_IMPL = exports.INJECTOR_IMPL__POST_R3__ = void 0;
|
|
11
|
-
const stringify_1 = require("../util/stringify");
|
|
12
|
-
const forward_ref_1 = require("./forward_ref");
|
|
13
|
-
const injector_compatibility_1 = require("./injector_compatibility");
|
|
14
|
-
const injector_token_1 = require("./injector_token");
|
|
15
|
-
const defs_1 = require("./interface/defs");
|
|
16
|
-
const injector_1 = require("./interface/injector");
|
|
17
|
-
const metadata_1 = require("./metadata");
|
|
18
|
-
const null_injector_1 = require("./null_injector");
|
|
19
|
-
const r3_injector_1 = require("./r3_injector");
|
|
20
|
-
const scope_1 = require("./scope");
|
|
21
|
-
function INJECTOR_IMPL__POST_R3__(providers, parent, name) {
|
|
22
|
-
return r3_injector_1.createInjector({ name: name }, parent, providers, name);
|
|
23
|
-
}
|
|
24
|
-
exports.INJECTOR_IMPL__POST_R3__ = INJECTOR_IMPL__POST_R3__;
|
|
25
|
-
exports.INJECTOR_IMPL = INJECTOR_IMPL__POST_R3__;
|
|
26
|
-
/**
|
|
27
|
-
* Concrete injectors implement this interface. Injectors are configured
|
|
28
|
-
* with [providers](guide/glossary#provider) that associate
|
|
29
|
-
* dependencies of various types with [injection tokens](guide/glossary#di-token).
|
|
30
|
-
*
|
|
31
|
-
* @see ["DI Providers"](guide/dependency-injection-providers).
|
|
32
|
-
* @see `StaticProvider`
|
|
33
|
-
*
|
|
34
|
-
* @usageNotes
|
|
35
|
-
*
|
|
36
|
-
* The following example creates a service injector instance.
|
|
37
|
-
*
|
|
38
|
-
* {@example core/di/ts/provider_spec.ts region='ConstructorProvider'}
|
|
39
|
-
*
|
|
40
|
-
* ### Usage example
|
|
41
|
-
*
|
|
42
|
-
* {@example core/di/ts/injector_spec.ts region='Injector'}
|
|
43
|
-
*
|
|
44
|
-
* `Injector` returns itself when given `Injector` as a token:
|
|
45
|
-
*
|
|
46
|
-
* {@example core/di/ts/injector_spec.ts region='injectInjector'}
|
|
47
|
-
*
|
|
48
|
-
* @publicApi
|
|
49
|
-
*/
|
|
50
|
-
class Injector {
|
|
51
|
-
static create(options, parent) {
|
|
52
|
-
if (Array.isArray(options)) {
|
|
53
|
-
return exports.INJECTOR_IMPL(options, parent, '');
|
|
54
|
-
}
|
|
55
|
-
else {
|
|
56
|
-
return exports.INJECTOR_IMPL(options.providers, options.parent, options.name || '');
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
exports.Injector = Injector;
|
|
61
|
-
Injector.THROW_IF_NOT_FOUND = injector_compatibility_1.THROW_IF_NOT_FOUND;
|
|
62
|
-
Injector.NULL = new null_injector_1.NullInjector();
|
|
63
|
-
/** @nocollapse */
|
|
64
|
-
Injector.ɵprov = defs_1.ɵɵdefineInjectable({
|
|
65
|
-
token: Injector,
|
|
66
|
-
providedIn: 'any',
|
|
67
|
-
factory: () => injector_compatibility_1.ɵɵinject(injector_token_1.INJECTOR),
|
|
68
|
-
});
|
|
69
|
-
/**
|
|
70
|
-
* @internal
|
|
71
|
-
* @nocollapse
|
|
72
|
-
*/
|
|
73
|
-
Injector.__NG_ELEMENT_ID__ = -1 /* Injector */;
|
|
74
|
-
const IDENT = function (value) {
|
|
75
|
-
return value;
|
|
76
|
-
};
|
|
77
|
-
const EMPTY = [];
|
|
78
|
-
const CIRCULAR = IDENT;
|
|
79
|
-
const MULTI_PROVIDER_FN = function () {
|
|
80
|
-
return Array.prototype.slice.call(arguments);
|
|
81
|
-
};
|
|
82
|
-
const NO_NEW_LINE = 'ɵ';
|
|
83
|
-
class StaticInjector {
|
|
84
|
-
constructor(providers, parent = Injector.NULL, source = null) {
|
|
85
|
-
this.parent = parent;
|
|
86
|
-
this.source = source;
|
|
87
|
-
const records = (this._records = new Map());
|
|
88
|
-
records.set(Injector, {
|
|
89
|
-
token: Injector,
|
|
90
|
-
fn: IDENT,
|
|
91
|
-
deps: EMPTY,
|
|
92
|
-
value: this,
|
|
93
|
-
useNew: false,
|
|
94
|
-
});
|
|
95
|
-
records.set(injector_token_1.INJECTOR, {
|
|
96
|
-
token: injector_token_1.INJECTOR,
|
|
97
|
-
fn: IDENT,
|
|
98
|
-
deps: EMPTY,
|
|
99
|
-
value: this,
|
|
100
|
-
useNew: false,
|
|
101
|
-
});
|
|
102
|
-
this.scope = recursivelyProcessProviders(records, providers);
|
|
103
|
-
}
|
|
104
|
-
get(token, notFoundValue, flags = injector_1.InjectFlags.Default) {
|
|
105
|
-
const records = this._records;
|
|
106
|
-
let record = records.get(token);
|
|
107
|
-
if (record === undefined) {
|
|
108
|
-
// This means we have never seen this record, see if it is tree shakable provider.
|
|
109
|
-
const injectableDef = defs_1.getInjectableDef(token);
|
|
110
|
-
if (injectableDef) {
|
|
111
|
-
const providedIn = injectableDef && forward_ref_1.resolveForwardRef(injectableDef.providedIn);
|
|
112
|
-
if (providedIn === 'any' ||
|
|
113
|
-
(providedIn != null && providedIn === this.scope)) {
|
|
114
|
-
records.set(token, (record = resolveProvider({
|
|
115
|
-
provide: token,
|
|
116
|
-
useFactory: injectableDef.factory,
|
|
117
|
-
deps: EMPTY,
|
|
118
|
-
})));
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
if (record === undefined) {
|
|
122
|
-
// Set record to null to make sure that we don't go through expensive lookup above again.
|
|
123
|
-
records.set(token, null);
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
let lastInjector = injector_compatibility_1.setCurrentInjector(this);
|
|
127
|
-
try {
|
|
128
|
-
return tryResolveToken(token, record, records, this.parent, notFoundValue, flags);
|
|
129
|
-
}
|
|
130
|
-
catch (e) {
|
|
131
|
-
return injector_compatibility_1.catchInjectorError(e, token, 'StaticInjectorError', this.source);
|
|
132
|
-
}
|
|
133
|
-
finally {
|
|
134
|
-
injector_compatibility_1.setCurrentInjector(lastInjector);
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
toString() {
|
|
138
|
-
const tokens = [], records = this._records;
|
|
139
|
-
records.forEach((v, token) => tokens.push(stringify_1.stringify(token)));
|
|
140
|
-
return `StaticInjector[${tokens.join(', ')}]`;
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
exports.StaticInjector = StaticInjector;
|
|
144
|
-
function resolveProvider(provider) {
|
|
145
|
-
const deps = computeDeps(provider);
|
|
146
|
-
let fn = IDENT;
|
|
147
|
-
let value = EMPTY;
|
|
148
|
-
let useNew = false;
|
|
149
|
-
let provide = forward_ref_1.resolveForwardRef(provider.provide);
|
|
150
|
-
if (injector_compatibility_1.USE_VALUE in provider) {
|
|
151
|
-
// We need to use USE_VALUE in provider since provider.useValue could be defined as undefined.
|
|
152
|
-
value = provider.useValue;
|
|
153
|
-
}
|
|
154
|
-
else if (provider.useFactory) {
|
|
155
|
-
fn = provider.useFactory;
|
|
156
|
-
}
|
|
157
|
-
else if (provider.useExisting) {
|
|
158
|
-
// Just use IDENT
|
|
159
|
-
}
|
|
160
|
-
else if (provider.useClass) {
|
|
161
|
-
useNew = true;
|
|
162
|
-
fn = forward_ref_1.resolveForwardRef(provider.useClass);
|
|
163
|
-
}
|
|
164
|
-
else if (typeof provide == 'function') {
|
|
165
|
-
useNew = true;
|
|
166
|
-
fn = provide;
|
|
167
|
-
}
|
|
168
|
-
else {
|
|
169
|
-
throw staticError('StaticProvider does not have [useValue|useFactory|useExisting|useClass] or [provide] is not newable', provider);
|
|
170
|
-
}
|
|
171
|
-
return { deps, fn, useNew, value };
|
|
172
|
-
}
|
|
173
|
-
function multiProviderMixError(token) {
|
|
174
|
-
return staticError('Cannot mix multi providers and regular providers', token);
|
|
175
|
-
}
|
|
176
|
-
function recursivelyProcessProviders(records, provider) {
|
|
177
|
-
let scope = null;
|
|
178
|
-
if (provider) {
|
|
179
|
-
provider = forward_ref_1.resolveForwardRef(provider);
|
|
180
|
-
if (Array.isArray(provider)) {
|
|
181
|
-
// if we have an array recurse into the array
|
|
182
|
-
for (let i = 0; i < provider.length; i++) {
|
|
183
|
-
scope = recursivelyProcessProviders(records, provider[i]) || scope;
|
|
184
|
-
}
|
|
185
|
-
}
|
|
186
|
-
else if (typeof provider === 'function') {
|
|
187
|
-
// Functions were supported in ReflectiveInjector, but are not here. For safety give useful
|
|
188
|
-
// error messages
|
|
189
|
-
throw staticError('Function/Class not supported', provider);
|
|
190
|
-
}
|
|
191
|
-
else if (provider && typeof provider === 'object' && provider.provide) {
|
|
192
|
-
// At this point we have what looks like a provider: {provide: ?, ....}
|
|
193
|
-
let token = forward_ref_1.resolveForwardRef(provider.provide);
|
|
194
|
-
const resolvedProvider = resolveProvider(provider);
|
|
195
|
-
if (provider.multi === true) {
|
|
196
|
-
// This is a multi provider.
|
|
197
|
-
let multiProvider = records.get(token);
|
|
198
|
-
if (multiProvider) {
|
|
199
|
-
if (multiProvider.fn !== MULTI_PROVIDER_FN) {
|
|
200
|
-
throw multiProviderMixError(token);
|
|
201
|
-
}
|
|
202
|
-
}
|
|
203
|
-
else {
|
|
204
|
-
// Create a placeholder factory which will look up the constituents of the multi provider.
|
|
205
|
-
records.set(token, (multiProvider = {
|
|
206
|
-
token: provider.provide,
|
|
207
|
-
deps: [],
|
|
208
|
-
useNew: false,
|
|
209
|
-
fn: MULTI_PROVIDER_FN,
|
|
210
|
-
value: EMPTY,
|
|
211
|
-
}));
|
|
212
|
-
}
|
|
213
|
-
// Treat the provider as the token.
|
|
214
|
-
token = provider;
|
|
215
|
-
multiProvider.deps.push({ token, options: 6 /* Default */ });
|
|
216
|
-
}
|
|
217
|
-
const record = records.get(token);
|
|
218
|
-
if (record && record.fn == MULTI_PROVIDER_FN) {
|
|
219
|
-
throw multiProviderMixError(token);
|
|
220
|
-
}
|
|
221
|
-
if (token === scope_1.INJECTOR_SCOPE) {
|
|
222
|
-
scope = resolvedProvider.value;
|
|
223
|
-
}
|
|
224
|
-
records.set(token, resolvedProvider);
|
|
225
|
-
}
|
|
226
|
-
else {
|
|
227
|
-
throw staticError('Unexpected provider', provider);
|
|
228
|
-
}
|
|
229
|
-
}
|
|
230
|
-
return scope;
|
|
231
|
-
}
|
|
232
|
-
function tryResolveToken(token, record, records, parent, notFoundValue, flags) {
|
|
233
|
-
try {
|
|
234
|
-
return resolveToken(token, record, records, parent, notFoundValue, flags);
|
|
235
|
-
}
|
|
236
|
-
catch (e) {
|
|
237
|
-
// ensure that 'e' is of type Error.
|
|
238
|
-
if (!(e instanceof Error)) {
|
|
239
|
-
e = new Error(e);
|
|
240
|
-
}
|
|
241
|
-
const path = (e[injector_compatibility_1.NG_TEMP_TOKEN_PATH] = e[injector_compatibility_1.NG_TEMP_TOKEN_PATH] || []);
|
|
242
|
-
path.unshift(token);
|
|
243
|
-
if (record && record.value == CIRCULAR) {
|
|
244
|
-
// Reset the Circular flag.
|
|
245
|
-
record.value = EMPTY;
|
|
246
|
-
}
|
|
247
|
-
throw e;
|
|
248
|
-
}
|
|
249
|
-
}
|
|
250
|
-
function resolveToken(token, record, records, parent, notFoundValue, flags) {
|
|
251
|
-
let value;
|
|
252
|
-
if (record && !(flags & injector_1.InjectFlags.SkipSelf)) {
|
|
253
|
-
// If we don't have a record, this implies that we don't own the provider hence don't know how
|
|
254
|
-
// to resolve it.
|
|
255
|
-
value = record.value;
|
|
256
|
-
if (value == CIRCULAR) {
|
|
257
|
-
throw Error(NO_NEW_LINE + 'Circular dependency');
|
|
258
|
-
}
|
|
259
|
-
else if (value === EMPTY) {
|
|
260
|
-
record.value = CIRCULAR;
|
|
261
|
-
let obj = undefined;
|
|
262
|
-
let useNew = record.useNew;
|
|
263
|
-
let fn = record.fn;
|
|
264
|
-
let depRecords = record.deps;
|
|
265
|
-
let deps = EMPTY;
|
|
266
|
-
if (depRecords.length) {
|
|
267
|
-
deps = [];
|
|
268
|
-
for (let i = 0; i < depRecords.length; i++) {
|
|
269
|
-
const depRecord = depRecords[i];
|
|
270
|
-
const options = depRecord.options;
|
|
271
|
-
const childRecord = options & 2 /* CheckSelf */
|
|
272
|
-
? records.get(depRecord.token)
|
|
273
|
-
: undefined;
|
|
274
|
-
deps.push(tryResolveToken(
|
|
275
|
-
// Current Token to resolve
|
|
276
|
-
depRecord.token,
|
|
277
|
-
// A record which describes how to resolve the token.
|
|
278
|
-
// If undefined, this means we don't have such a record
|
|
279
|
-
childRecord,
|
|
280
|
-
// Other records we know about.
|
|
281
|
-
records,
|
|
282
|
-
// If we don't know how to resolve dependency and we should not check parent for it,
|
|
283
|
-
// than pass in Null injector.
|
|
284
|
-
!childRecord && !(options & 4 /* CheckParent */)
|
|
285
|
-
? Injector.NULL
|
|
286
|
-
: parent, options & 1 /* Optional */
|
|
287
|
-
? null
|
|
288
|
-
: Injector.THROW_IF_NOT_FOUND, injector_1.InjectFlags.Default));
|
|
289
|
-
}
|
|
290
|
-
}
|
|
291
|
-
record.value = value = useNew
|
|
292
|
-
? new fn(...deps)
|
|
293
|
-
: fn.apply(obj, deps);
|
|
294
|
-
}
|
|
295
|
-
}
|
|
296
|
-
else if (!(flags & injector_1.InjectFlags.Self)) {
|
|
297
|
-
value = parent.get(token, notFoundValue, injector_1.InjectFlags.Default);
|
|
298
|
-
}
|
|
299
|
-
else if (!(flags & injector_1.InjectFlags.Optional)) {
|
|
300
|
-
value = Injector.NULL.get(token, notFoundValue);
|
|
301
|
-
}
|
|
302
|
-
else {
|
|
303
|
-
value = Injector.NULL.get(token, typeof notFoundValue !== 'undefined' ? notFoundValue : null);
|
|
304
|
-
}
|
|
305
|
-
return value;
|
|
306
|
-
}
|
|
307
|
-
function computeDeps(provider) {
|
|
308
|
-
let deps = EMPTY;
|
|
309
|
-
const providerDeps = provider.deps;
|
|
310
|
-
if (providerDeps && providerDeps.length) {
|
|
311
|
-
deps = [];
|
|
312
|
-
for (let i = 0; i < providerDeps.length; i++) {
|
|
313
|
-
let options = 6 /* Default */;
|
|
314
|
-
let token = forward_ref_1.resolveForwardRef(providerDeps[i]);
|
|
315
|
-
if (Array.isArray(token)) {
|
|
316
|
-
for (let j = 0, annotations = token; j < annotations.length; j++) {
|
|
317
|
-
const annotation = annotations[j];
|
|
318
|
-
if (annotation instanceof metadata_1.Optional || annotation == metadata_1.Optional) {
|
|
319
|
-
options = options | 1 /* Optional */;
|
|
320
|
-
}
|
|
321
|
-
else if (annotation instanceof metadata_1.SkipSelf || annotation == metadata_1.SkipSelf) {
|
|
322
|
-
options = options & ~2 /* CheckSelf */;
|
|
323
|
-
}
|
|
324
|
-
else if (annotation instanceof metadata_1.Self || annotation == metadata_1.Self) {
|
|
325
|
-
options = options & ~4 /* CheckParent */;
|
|
326
|
-
}
|
|
327
|
-
else if (annotation instanceof metadata_1.Inject) {
|
|
328
|
-
token = annotation.token;
|
|
329
|
-
}
|
|
330
|
-
else {
|
|
331
|
-
token = forward_ref_1.resolveForwardRef(annotation);
|
|
332
|
-
}
|
|
333
|
-
}
|
|
334
|
-
}
|
|
335
|
-
deps.push({ token, options });
|
|
336
|
-
}
|
|
337
|
-
}
|
|
338
|
-
else if (provider.useExisting) {
|
|
339
|
-
const token = forward_ref_1.resolveForwardRef(provider.useExisting);
|
|
340
|
-
deps = [{ token, options: 6 /* Default */ }];
|
|
341
|
-
}
|
|
342
|
-
else if (!providerDeps && !(injector_compatibility_1.USE_VALUE in provider)) {
|
|
343
|
-
// useValue & useExisting are the only ones which are exempt from deps all others need it.
|
|
344
|
-
throw staticError("'deps' required", provider);
|
|
345
|
-
}
|
|
346
|
-
return deps;
|
|
347
|
-
}
|
|
348
|
-
function staticError(text, obj) {
|
|
349
|
-
return new Error(injector_compatibility_1.formatError(text, obj, 'StaticInjectorError'));
|
|
350
|
-
}
|
|
@@ -1,23 +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
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
-
exports.NullInjector = void 0;
|
|
11
|
-
const stringify_1 = require("../util/stringify");
|
|
12
|
-
const injector_compatibility_1 = require("./injector_compatibility");
|
|
13
|
-
class NullInjector {
|
|
14
|
-
get(token, notFoundValue = injector_compatibility_1.THROW_IF_NOT_FOUND) {
|
|
15
|
-
if (notFoundValue === injector_compatibility_1.THROW_IF_NOT_FOUND) {
|
|
16
|
-
const error = new Error(`NullInjectorError: No provider for ${stringify_1.stringify(token)}!`);
|
|
17
|
-
error.name = "NullInjectorError";
|
|
18
|
-
throw error;
|
|
19
|
-
}
|
|
20
|
-
return notFoundValue;
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
exports.NullInjector = NullInjector;
|
package/import/index.js
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const tslib_1 = require("tslib");
|
|
4
|
-
tslib_1.__exportStar(require("./decorator/injectable"), exports);
|
|
5
|
-
tslib_1.__exportStar(require("./di/metadata"), exports);
|
|
6
|
-
tslib_1.__exportStar(require("./di/r3_injector"), exports);
|
|
7
|
-
tslib_1.__exportStar(require("./di/interface/defs"), exports);
|
|
8
|
-
tslib_1.__exportStar(require("./di/injector_compatibility"), exports);
|
|
9
|
-
tslib_1.__exportStar(require("./di/injection_token"), exports);
|
|
10
|
-
tslib_1.__exportStar(require("./di/null_injector"), exports);
|
|
11
|
-
tslib_1.__exportStar(require("./di/injector"), exports);
|
|
12
|
-
tslib_1.__exportStar(require("./di/interface/injector"), exports);
|
|
13
|
-
tslib_1.__exportStar(require("./di/scope"), exports);
|
|
14
|
-
tslib_1.__exportStar(require("./render3/instructions/di"), exports);
|
package/import/interface/type.js
DELETED
|
@@ -1,21 +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
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
-
exports.Type = void 0;
|
|
11
|
-
/**
|
|
12
|
-
* @description
|
|
13
|
-
*
|
|
14
|
-
* Represents a type that a Component or other object is instances of.
|
|
15
|
-
*
|
|
16
|
-
* An example of a `Type` is `MyCustomComponent` class, which in JavaScript is represented by
|
|
17
|
-
* the `MyCustomComponent` constructor function.
|
|
18
|
-
*
|
|
19
|
-
* @publicApi
|
|
20
|
-
*/
|
|
21
|
-
exports.Type = Function;
|
|
@@ -1,19 +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
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
-
exports.getFactoryDef = void 0;
|
|
11
|
-
const fields_1 = require("./fields");
|
|
12
|
-
function getFactoryDef(type, throwNotFound) {
|
|
13
|
-
const hasFactoryDef = type.hasOwnProperty(fields_1.NG_FACTORY_DEF);
|
|
14
|
-
// if (!hasFactoryDef && throwNotFound === true && ngDevMode) {
|
|
15
|
-
// throw new Error(`Type ${stringify(type)} does not have 'ɵfac' property.`);
|
|
16
|
-
// }
|
|
17
|
-
return hasFactoryDef ? type[fields_1.NG_FACTORY_DEF] : null;
|
|
18
|
-
}
|
|
19
|
-
exports.getFactoryDef = getFactoryDef;
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.throwProviderNotFoundError = void 0;
|
|
4
|
-
/**
|
|
5
|
-
* @license
|
|
6
|
-
* Copyright Google LLC All Rights Reserved.
|
|
7
|
-
*
|
|
8
|
-
* Use of this source code is governed by an MIT-style license that can be
|
|
9
|
-
* found in the LICENSE file at https://angular.io/license
|
|
10
|
-
*/
|
|
11
|
-
const error_code_1 = require("./error_code");
|
|
12
|
-
const stringify_utils_1 = require("./util/stringify_utils");
|
|
13
|
-
/** Throws an error when a token is not found in DI. */
|
|
14
|
-
function throwProviderNotFoundError(token, injectorName) {
|
|
15
|
-
const injectorDetails = injectorName ? ` in ${injectorName}` : '';
|
|
16
|
-
throw new error_code_1.RuntimeError("201" /* PROVIDER_NOT_FOUND */, `No provider for ${stringify_utils_1.stringifyForError(token)} found${injectorDetails}`);
|
|
17
|
-
}
|
|
18
|
-
exports.throwProviderNotFoundError = throwProviderNotFoundError;
|
package/import/render3/fields.js
DELETED
|
@@ -1,14 +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
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
-
exports.NG_FACTORY_DEF = void 0;
|
|
11
|
-
const property_1 = require("../util/property");
|
|
12
|
-
exports.NG_FACTORY_DEF = property_1.getClosureSafeProperty({
|
|
13
|
-
ɵfac: property_1.getClosureSafeProperty,
|
|
14
|
-
});
|
|
@@ -1,58 +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
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
-
exports.makeParamDecorator = exports.PARAMETERS = exports.ANNOTATIONS = void 0;
|
|
11
|
-
const closure_1 = require("./closure");
|
|
12
|
-
exports.ANNOTATIONS = '__annotations__';
|
|
13
|
-
exports.PARAMETERS = '__parameters__';
|
|
14
|
-
function makeMetadataCtor(props) {
|
|
15
|
-
return function ctor(...args) {
|
|
16
|
-
if (props) {
|
|
17
|
-
const values = props(...args);
|
|
18
|
-
for (const propName in values) {
|
|
19
|
-
this[propName] = values[propName];
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
};
|
|
23
|
-
}
|
|
24
|
-
function makeParamDecorator(name, props, parentClass) {
|
|
25
|
-
return closure_1.noSideEffects(() => {
|
|
26
|
-
const metaCtor = makeMetadataCtor(props);
|
|
27
|
-
function ParamDecoratorFactory(...args) {
|
|
28
|
-
if (this instanceof ParamDecoratorFactory) {
|
|
29
|
-
metaCtor.apply(this, args);
|
|
30
|
-
return this;
|
|
31
|
-
}
|
|
32
|
-
const annotationInstance = new ParamDecoratorFactory(...args);
|
|
33
|
-
ParamDecorator.annotation = annotationInstance;
|
|
34
|
-
return ParamDecorator;
|
|
35
|
-
function ParamDecorator(cls, unusedKey, index) {
|
|
36
|
-
// Use of Object.defineProperty is important since it creates non-enumerable property which
|
|
37
|
-
// prevents the property is copied during subclassing.
|
|
38
|
-
const parameters = cls.hasOwnProperty(exports.PARAMETERS)
|
|
39
|
-
? cls[exports.PARAMETERS]
|
|
40
|
-
: Object.defineProperty(cls, exports.PARAMETERS, { value: [] })[exports.PARAMETERS];
|
|
41
|
-
// there might be gaps if some in between parameters do not have annotations.
|
|
42
|
-
// we pad with nulls.
|
|
43
|
-
while (parameters.length <= index) {
|
|
44
|
-
parameters.push(null);
|
|
45
|
-
}
|
|
46
|
-
(parameters[index] = parameters[index] || []).push(annotationInstance);
|
|
47
|
-
return cls;
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
if (parentClass) {
|
|
51
|
-
ParamDecoratorFactory.prototype = Object.create(parentClass.prototype);
|
|
52
|
-
}
|
|
53
|
-
ParamDecoratorFactory.prototype.ngMetadataName = name;
|
|
54
|
-
ParamDecoratorFactory.annotationCls = ParamDecoratorFactory;
|
|
55
|
-
return ParamDecoratorFactory;
|
|
56
|
-
});
|
|
57
|
-
}
|
|
58
|
-
exports.makeParamDecorator = makeParamDecorator;
|