@angular/language-service 12.2.2 → 12.2.6
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/bundles/ivy.js +287 -18
- package/bundles/language-service.js +5 -869
- package/package.json +1 -1
package/bundles/ivy.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @license Angular v12.2.
|
|
2
|
+
* @license Angular v12.2.6
|
|
3
3
|
* Copyright Google LLC All Rights Reserved.
|
|
4
4
|
* License: MIT
|
|
5
5
|
*/
|
|
@@ -19938,7 +19938,7 @@ define(['exports', 'typescript/lib/tsserverlibrary', 'os', 'typescript', 'fs', '
|
|
|
19938
19938
|
* Use of this source code is governed by an MIT-style license that can be
|
|
19939
19939
|
* found in the LICENSE file at https://angular.io/license
|
|
19940
19940
|
*/
|
|
19941
|
-
const VERSION$1 = new Version('12.2.
|
|
19941
|
+
const VERSION$1 = new Version('12.2.6');
|
|
19942
19942
|
|
|
19943
19943
|
/**
|
|
19944
19944
|
* @license
|
|
@@ -20577,7 +20577,7 @@ define(['exports', 'typescript/lib/tsserverlibrary', 'os', 'typescript', 'fs', '
|
|
|
20577
20577
|
function compileDeclareClassMetadata(metadata) {
|
|
20578
20578
|
const definitionMap = new DefinitionMap();
|
|
20579
20579
|
definitionMap.set('minVersion', literal(MINIMUM_PARTIAL_LINKER_VERSION));
|
|
20580
|
-
definitionMap.set('version', literal('12.2.
|
|
20580
|
+
definitionMap.set('version', literal('12.2.6'));
|
|
20581
20581
|
definitionMap.set('ngImport', importExpr(Identifiers.core));
|
|
20582
20582
|
definitionMap.set('type', metadata.type);
|
|
20583
20583
|
definitionMap.set('decorators', metadata.decorators);
|
|
@@ -20617,7 +20617,7 @@ define(['exports', 'typescript/lib/tsserverlibrary', 'os', 'typescript', 'fs', '
|
|
|
20617
20617
|
function createDirectiveDefinitionMap(meta) {
|
|
20618
20618
|
const definitionMap = new DefinitionMap();
|
|
20619
20619
|
definitionMap.set('minVersion', literal(MINIMUM_PARTIAL_LINKER_VERSION$1));
|
|
20620
|
-
definitionMap.set('version', literal('12.2.
|
|
20620
|
+
definitionMap.set('version', literal('12.2.6'));
|
|
20621
20621
|
// e.g. `type: MyDirective`
|
|
20622
20622
|
definitionMap.set('type', meta.internalType);
|
|
20623
20623
|
// e.g. `selector: 'some-dir'`
|
|
@@ -20834,7 +20834,7 @@ define(['exports', 'typescript/lib/tsserverlibrary', 'os', 'typescript', 'fs', '
|
|
|
20834
20834
|
function compileDeclareFactoryFunction(meta) {
|
|
20835
20835
|
const definitionMap = new DefinitionMap();
|
|
20836
20836
|
definitionMap.set('minVersion', literal(MINIMUM_PARTIAL_LINKER_VERSION$2));
|
|
20837
|
-
definitionMap.set('version', literal('12.2.
|
|
20837
|
+
definitionMap.set('version', literal('12.2.6'));
|
|
20838
20838
|
definitionMap.set('ngImport', importExpr(Identifiers.core));
|
|
20839
20839
|
definitionMap.set('type', meta.internalType);
|
|
20840
20840
|
definitionMap.set('deps', compileDependencies(meta.deps));
|
|
@@ -20876,7 +20876,7 @@ define(['exports', 'typescript/lib/tsserverlibrary', 'os', 'typescript', 'fs', '
|
|
|
20876
20876
|
function createInjectableDefinitionMap(meta) {
|
|
20877
20877
|
const definitionMap = new DefinitionMap();
|
|
20878
20878
|
definitionMap.set('minVersion', literal(MINIMUM_PARTIAL_LINKER_VERSION$3));
|
|
20879
|
-
definitionMap.set('version', literal('12.2.
|
|
20879
|
+
definitionMap.set('version', literal('12.2.6'));
|
|
20880
20880
|
definitionMap.set('ngImport', importExpr(Identifiers.core));
|
|
20881
20881
|
definitionMap.set('type', meta.internalType);
|
|
20882
20882
|
// Only generate providedIn property if it has a non-null value
|
|
@@ -20955,7 +20955,7 @@ define(['exports', 'typescript/lib/tsserverlibrary', 'os', 'typescript', 'fs', '
|
|
|
20955
20955
|
function createInjectorDefinitionMap(meta) {
|
|
20956
20956
|
const definitionMap = new DefinitionMap();
|
|
20957
20957
|
definitionMap.set('minVersion', literal(MINIMUM_PARTIAL_LINKER_VERSION$4));
|
|
20958
|
-
definitionMap.set('version', literal('12.2.
|
|
20958
|
+
definitionMap.set('version', literal('12.2.6'));
|
|
20959
20959
|
definitionMap.set('ngImport', importExpr(Identifiers.core));
|
|
20960
20960
|
definitionMap.set('type', meta.internalType);
|
|
20961
20961
|
definitionMap.set('providers', meta.providers);
|
|
@@ -20992,7 +20992,7 @@ define(['exports', 'typescript/lib/tsserverlibrary', 'os', 'typescript', 'fs', '
|
|
|
20992
20992
|
function createNgModuleDefinitionMap(meta) {
|
|
20993
20993
|
const definitionMap = new DefinitionMap();
|
|
20994
20994
|
definitionMap.set('minVersion', literal(MINIMUM_PARTIAL_LINKER_VERSION$5));
|
|
20995
|
-
definitionMap.set('version', literal('12.2.
|
|
20995
|
+
definitionMap.set('version', literal('12.2.6'));
|
|
20996
20996
|
definitionMap.set('ngImport', importExpr(Identifiers.core));
|
|
20997
20997
|
definitionMap.set('type', meta.internalType);
|
|
20998
20998
|
// We only generate the keys in the metadata if the arrays contain values.
|
|
@@ -21050,7 +21050,7 @@ define(['exports', 'typescript/lib/tsserverlibrary', 'os', 'typescript', 'fs', '
|
|
|
21050
21050
|
function createPipeDefinitionMap(meta) {
|
|
21051
21051
|
const definitionMap = new DefinitionMap();
|
|
21052
21052
|
definitionMap.set('minVersion', literal(MINIMUM_PARTIAL_LINKER_VERSION$6));
|
|
21053
|
-
definitionMap.set('version', literal('12.2.
|
|
21053
|
+
definitionMap.set('version', literal('12.2.6'));
|
|
21054
21054
|
definitionMap.set('ngImport', importExpr(Identifiers.core));
|
|
21055
21055
|
// e.g. `type: MyPipe`
|
|
21056
21056
|
definitionMap.set('type', meta.internalType);
|
|
@@ -21082,7 +21082,7 @@ define(['exports', 'typescript/lib/tsserverlibrary', 'os', 'typescript', 'fs', '
|
|
|
21082
21082
|
* Use of this source code is governed by an MIT-style license that can be
|
|
21083
21083
|
* found in the LICENSE file at https://angular.io/license
|
|
21084
21084
|
*/
|
|
21085
|
-
const VERSION$2 = new Version('12.2.
|
|
21085
|
+
const VERSION$2 = new Version('12.2.6');
|
|
21086
21086
|
|
|
21087
21087
|
/**
|
|
21088
21088
|
* @license
|
|
@@ -21294,6 +21294,15 @@ define(['exports', 'typescript/lib/tsserverlibrary', 'os', 'typescript', 'fs', '
|
|
|
21294
21294
|
* ```
|
|
21295
21295
|
*/
|
|
21296
21296
|
ErrorCode[ErrorCode["INVALID_BANANA_IN_BOX"] = 8101] = "INVALID_BANANA_IN_BOX";
|
|
21297
|
+
/**
|
|
21298
|
+
* The left side of a nullish coalescing operation is not nullable.
|
|
21299
|
+
*
|
|
21300
|
+
* ```
|
|
21301
|
+
* {{ foo ?? bar }}
|
|
21302
|
+
* ```
|
|
21303
|
+
* When the type of foo doesn't include `null` or `undefined`.
|
|
21304
|
+
*/
|
|
21305
|
+
ErrorCode[ErrorCode["NULLISH_COALESCING_NOT_NULLABLE"] = 8102] = "NULLISH_COALESCING_NOT_NULLABLE";
|
|
21297
21306
|
/**
|
|
21298
21307
|
* The template type-checking engine would need to generate an inline type check block for a
|
|
21299
21308
|
* component, but the current type-checking environment doesn't support it.
|
|
@@ -26546,6 +26555,26 @@ define(['exports', 'typescript/lib/tsserverlibrary', 'os', 'typescript', 'fs', '
|
|
|
26546
26555
|
}
|
|
26547
26556
|
}
|
|
26548
26557
|
}
|
|
26558
|
+
extendedTemplateCheck(sf, extendedTemplateChecker) {
|
|
26559
|
+
const classes = this.fileToClasses.get(sf);
|
|
26560
|
+
if (classes === undefined) {
|
|
26561
|
+
return [];
|
|
26562
|
+
}
|
|
26563
|
+
const diagnostics = [];
|
|
26564
|
+
for (const clazz of classes) {
|
|
26565
|
+
if (!isNamedClassDeclaration(clazz)) {
|
|
26566
|
+
continue;
|
|
26567
|
+
}
|
|
26568
|
+
const record = this.classes.get(clazz);
|
|
26569
|
+
for (const trait of record.traits) {
|
|
26570
|
+
if (trait.handler.extendedTemplateCheck === undefined) {
|
|
26571
|
+
continue;
|
|
26572
|
+
}
|
|
26573
|
+
diagnostics.push(...trait.handler.extendedTemplateCheck(clazz, extendedTemplateChecker));
|
|
26574
|
+
}
|
|
26575
|
+
}
|
|
26576
|
+
return diagnostics;
|
|
26577
|
+
}
|
|
26549
26578
|
index(ctx) {
|
|
26550
26579
|
for (const clazz of this.classes.keys()) {
|
|
26551
26580
|
const record = this.classes.get(clazz);
|
|
@@ -30553,6 +30582,9 @@ Either add the @Injectable() decorator to '${provider.node.name
|
|
|
30553
30582
|
const binder = new R3TargetBinder(scope.matcher);
|
|
30554
30583
|
ctx.addTemplate(new Reference$1(node), binder, meta.template.diagNodes, scope.pipes, scope.schemas, meta.template.sourceMapping, meta.template.file, meta.template.errors);
|
|
30555
30584
|
}
|
|
30585
|
+
extendedTemplateCheck(component, extendedTemplateChecker) {
|
|
30586
|
+
return extendedTemplateChecker.getDiagnosticsForComponent(component);
|
|
30587
|
+
}
|
|
30556
30588
|
resolve(node, analysis, symbol) {
|
|
30557
30589
|
if (this.semanticDepGraphUpdater !== null && analysis.baseClass instanceof Reference$1) {
|
|
30558
30590
|
symbol.baseClass = this.semanticDepGraphUpdater.getSymbol(analysis.baseClass.node);
|
|
@@ -39731,7 +39763,7 @@ Either add the @Injectable() decorator to '${provider.node.name
|
|
|
39731
39763
|
const fileRecord = this.state.get(sfPath);
|
|
39732
39764
|
const templateId = fileRecord.sourceManager.getTemplateId(clazz);
|
|
39733
39765
|
const mapping = fileRecord.sourceManager.getSourceMapping(templateId);
|
|
39734
|
-
return makeTemplateDiagnostic(templateId, mapping, sourceSpan, category, errorCode, message, relatedInformation);
|
|
39766
|
+
return Object.assign(Object.assign({}, makeTemplateDiagnostic(templateId, mapping, sourceSpan, category, ngErrorCode(errorCode), message, relatedInformation)), { __ngCode: errorCode });
|
|
39735
39767
|
}
|
|
39736
39768
|
getOrCreateCompletionEngine(component) {
|
|
39737
39769
|
if (this.completionCache.has(component)) {
|
|
@@ -40093,6 +40125,195 @@ Either add the @Injectable() decorator to '${provider.node.name
|
|
|
40093
40125
|
}
|
|
40094
40126
|
}
|
|
40095
40127
|
|
|
40128
|
+
/**
|
|
40129
|
+
* @license
|
|
40130
|
+
* Copyright Google LLC All Rights Reserved.
|
|
40131
|
+
*
|
|
40132
|
+
* Use of this source code is governed by an MIT-style license that can be
|
|
40133
|
+
* found in the LICENSE file at https://angular.io/license
|
|
40134
|
+
*/
|
|
40135
|
+
class ExtendedTemplateCheckerImpl {
|
|
40136
|
+
constructor(templateTypeChecker, typeChecker, templateChecks) {
|
|
40137
|
+
this.templateChecks = templateChecks;
|
|
40138
|
+
this.ctx = { templateTypeChecker: templateTypeChecker, typeChecker: typeChecker };
|
|
40139
|
+
}
|
|
40140
|
+
getDiagnosticsForComponent(component) {
|
|
40141
|
+
const template = this.ctx.templateTypeChecker.getTemplate(component);
|
|
40142
|
+
// Skip checks if component has no template. This can happen if the user writes a
|
|
40143
|
+
// `@Component()` but doesn't add the template, could happen in the language service
|
|
40144
|
+
// when users are in the middle of typing code.
|
|
40145
|
+
if (template === null) {
|
|
40146
|
+
return [];
|
|
40147
|
+
}
|
|
40148
|
+
const diagnostics = [];
|
|
40149
|
+
for (const check of this.templateChecks) {
|
|
40150
|
+
diagnostics.push(...check.run(this.ctx, component, template));
|
|
40151
|
+
}
|
|
40152
|
+
return diagnostics;
|
|
40153
|
+
}
|
|
40154
|
+
}
|
|
40155
|
+
|
|
40156
|
+
/**
|
|
40157
|
+
* @license
|
|
40158
|
+
* Copyright Google LLC All Rights Reserved.
|
|
40159
|
+
*
|
|
40160
|
+
* Use of this source code is governed by an MIT-style license that can be
|
|
40161
|
+
* found in the LICENSE file at https://angular.io/license
|
|
40162
|
+
*/
|
|
40163
|
+
/**
|
|
40164
|
+
* This abstract class provides a base implementation for the run method.
|
|
40165
|
+
*/
|
|
40166
|
+
class TemplateCheckWithVisitor {
|
|
40167
|
+
/**
|
|
40168
|
+
* Base implementation for run function, visits all nodes in template and calls
|
|
40169
|
+
* `visitNode()` for each one.
|
|
40170
|
+
*/
|
|
40171
|
+
run(ctx, component, template) {
|
|
40172
|
+
const visitor = new TemplateVisitor$1(ctx, component, this);
|
|
40173
|
+
return visitor.getDiagnostics(template);
|
|
40174
|
+
}
|
|
40175
|
+
}
|
|
40176
|
+
/**
|
|
40177
|
+
* Visits all nodes in a template (TmplAstNode and AST) and calls `visitNode` for each one.
|
|
40178
|
+
*/
|
|
40179
|
+
class TemplateVisitor$1 extends RecursiveAstVisitor {
|
|
40180
|
+
constructor(ctx, component, check) {
|
|
40181
|
+
super();
|
|
40182
|
+
this.ctx = ctx;
|
|
40183
|
+
this.component = component;
|
|
40184
|
+
this.check = check;
|
|
40185
|
+
this.diagnostics = [];
|
|
40186
|
+
}
|
|
40187
|
+
visit(node, context) {
|
|
40188
|
+
this.diagnostics.push(...this.check.visitNode(this.ctx, this.component, node));
|
|
40189
|
+
node.visit(this);
|
|
40190
|
+
}
|
|
40191
|
+
visitAllNodes(nodes) {
|
|
40192
|
+
for (const node of nodes) {
|
|
40193
|
+
this.visit(node);
|
|
40194
|
+
}
|
|
40195
|
+
}
|
|
40196
|
+
visitAst(ast) {
|
|
40197
|
+
if (ast instanceof ASTWithSource) {
|
|
40198
|
+
ast = ast.ast;
|
|
40199
|
+
}
|
|
40200
|
+
this.visit(ast);
|
|
40201
|
+
}
|
|
40202
|
+
visitElement(element) {
|
|
40203
|
+
this.visitAllNodes(element.attributes);
|
|
40204
|
+
this.visitAllNodes(element.inputs);
|
|
40205
|
+
this.visitAllNodes(element.outputs);
|
|
40206
|
+
this.visitAllNodes(element.references);
|
|
40207
|
+
this.visitAllNodes(element.children);
|
|
40208
|
+
}
|
|
40209
|
+
visitTemplate(template) {
|
|
40210
|
+
this.visitAllNodes(template.attributes);
|
|
40211
|
+
if (template.tagName === 'ng-template') {
|
|
40212
|
+
// Only visit input/outputs/templateAttrs if this isn't an inline template node
|
|
40213
|
+
// generated for a structural directive (like `<div *ngIf></div>`). These nodes
|
|
40214
|
+
// would be visited when the underlying element of an inline template node is processed.
|
|
40215
|
+
this.visitAllNodes(template.inputs);
|
|
40216
|
+
this.visitAllNodes(template.outputs);
|
|
40217
|
+
this.visitAllNodes(template.templateAttrs);
|
|
40218
|
+
}
|
|
40219
|
+
this.visitAllNodes(template.variables);
|
|
40220
|
+
this.visitAllNodes(template.references);
|
|
40221
|
+
this.visitAllNodes(template.children);
|
|
40222
|
+
}
|
|
40223
|
+
visitContent(content) { }
|
|
40224
|
+
visitVariable(variable) { }
|
|
40225
|
+
visitReference(reference) { }
|
|
40226
|
+
visitTextAttribute(attribute) { }
|
|
40227
|
+
visitBoundAttribute(attribute) {
|
|
40228
|
+
this.visitAst(attribute.value);
|
|
40229
|
+
}
|
|
40230
|
+
visitBoundEvent(attribute) {
|
|
40231
|
+
this.visitAst(attribute.handler);
|
|
40232
|
+
}
|
|
40233
|
+
visitText(text) { }
|
|
40234
|
+
visitBoundText(text) {
|
|
40235
|
+
this.visitAst(text.value);
|
|
40236
|
+
}
|
|
40237
|
+
visitIcu(icu) { }
|
|
40238
|
+
getDiagnostics(template) {
|
|
40239
|
+
this.diagnostics = [];
|
|
40240
|
+
this.visitAllNodes(template);
|
|
40241
|
+
return this.diagnostics;
|
|
40242
|
+
}
|
|
40243
|
+
}
|
|
40244
|
+
|
|
40245
|
+
/**
|
|
40246
|
+
* @license
|
|
40247
|
+
* Copyright Google LLC All Rights Reserved.
|
|
40248
|
+
*
|
|
40249
|
+
* Use of this source code is governed by an MIT-style license that can be
|
|
40250
|
+
* found in the LICENSE file at https://angular.io/license
|
|
40251
|
+
*/
|
|
40252
|
+
/**
|
|
40253
|
+
* Ensures the two-way binding syntax is correct.
|
|
40254
|
+
* Parentheses should be inside the brackets "[()]".
|
|
40255
|
+
* Will return diagnostic information when "([])" is found.
|
|
40256
|
+
*/
|
|
40257
|
+
class InvalidBananaInBoxCheck extends TemplateCheckWithVisitor {
|
|
40258
|
+
constructor() {
|
|
40259
|
+
super(...arguments);
|
|
40260
|
+
this.code = ErrorCode.INVALID_BANANA_IN_BOX;
|
|
40261
|
+
}
|
|
40262
|
+
visitNode(ctx, component, node) {
|
|
40263
|
+
if (!(node instanceof BoundEvent))
|
|
40264
|
+
return [];
|
|
40265
|
+
const name = node.name;
|
|
40266
|
+
if (!name.startsWith('[') || !name.endsWith(']'))
|
|
40267
|
+
return [];
|
|
40268
|
+
const boundSyntax = node.sourceSpan.toString();
|
|
40269
|
+
const expectedBoundSyntax = boundSyntax.replace(`(${name})`, `[(${name.slice(1, -1)})]`);
|
|
40270
|
+
const diagnostic = ctx.templateTypeChecker.makeTemplateDiagnostic(component, node.sourceSpan, ts$1.DiagnosticCategory.Warning, ErrorCode.INVALID_BANANA_IN_BOX, `In the two-way binding syntax the parentheses should be inside the brackets, ex. '${expectedBoundSyntax}'.
|
|
40271
|
+
Find more at https://angular.io/guide/two-way-binding`);
|
|
40272
|
+
return [diagnostic];
|
|
40273
|
+
}
|
|
40274
|
+
}
|
|
40275
|
+
|
|
40276
|
+
/**
|
|
40277
|
+
* @license
|
|
40278
|
+
* Copyright Google LLC All Rights Reserved.
|
|
40279
|
+
*
|
|
40280
|
+
* Use of this source code is governed by an MIT-style license that can be
|
|
40281
|
+
* found in the LICENSE file at https://angular.io/license
|
|
40282
|
+
*/
|
|
40283
|
+
/**
|
|
40284
|
+
* Ensures the left side of a nullish coalescing operation is nullable.
|
|
40285
|
+
* Returns diagnostics for the cases where the operator is useless.
|
|
40286
|
+
* This check should only be use if `strictNullChecks` is enabled,
|
|
40287
|
+
* otherwise it would produce inaccurate results.
|
|
40288
|
+
*/
|
|
40289
|
+
class NullishCoalescingNotNullableCheck extends TemplateCheckWithVisitor {
|
|
40290
|
+
constructor() {
|
|
40291
|
+
super(...arguments);
|
|
40292
|
+
this.code = ErrorCode.NULLISH_COALESCING_NOT_NULLABLE;
|
|
40293
|
+
}
|
|
40294
|
+
visitNode(ctx, component, node) {
|
|
40295
|
+
if (!(node instanceof Binary) || node.operation !== '??')
|
|
40296
|
+
return [];
|
|
40297
|
+
const symbolLeft = ctx.templateTypeChecker.getSymbolOfNode(node.left, component);
|
|
40298
|
+
if (symbolLeft.kind !== SymbolKind.Expression) {
|
|
40299
|
+
return [];
|
|
40300
|
+
}
|
|
40301
|
+
const typeLeft = symbolLeft.tsType;
|
|
40302
|
+
// If the left operand's type is different from its non-nullable self, then it must
|
|
40303
|
+
// contain a null or undefined so this nullish coalescing operator is useful. No diagnostic to
|
|
40304
|
+
// report.
|
|
40305
|
+
if (typeLeft.getNonNullableType() !== typeLeft)
|
|
40306
|
+
return [];
|
|
40307
|
+
const symbol = ctx.templateTypeChecker.getSymbolOfNode(node, component);
|
|
40308
|
+
if (symbol.kind !== SymbolKind.Expression) {
|
|
40309
|
+
return [];
|
|
40310
|
+
}
|
|
40311
|
+
const span = ctx.templateTypeChecker.getTemplateMappingAtShimLocation(symbol.shimLocation).span;
|
|
40312
|
+
const diagnostic = ctx.templateTypeChecker.makeTemplateDiagnostic(component, span, ts$1.DiagnosticCategory.Warning, ErrorCode.NULLISH_COALESCING_NOT_NULLABLE, `The left side of this nullish coalescing operation does not include 'null' or 'undefined' in its type, therefore the '??' operator can be safely removed.`);
|
|
40313
|
+
return [diagnostic];
|
|
40314
|
+
}
|
|
40315
|
+
}
|
|
40316
|
+
|
|
40096
40317
|
/**
|
|
40097
40318
|
* @license
|
|
40098
40319
|
* Copyright Google LLC All Rights Reserved.
|
|
@@ -40209,6 +40430,10 @@ Either add the @Injectable() decorator to '${provider.node.name
|
|
|
40209
40430
|
* with each fresh compilation.
|
|
40210
40431
|
*/
|
|
40211
40432
|
this.delegatingPerfRecorder = new DelegatingPerfRecorder(this.perfRecorder);
|
|
40433
|
+
if (this.options._extendedTemplateDiagnostics === true &&
|
|
40434
|
+
this.options.strictTemplates === false) {
|
|
40435
|
+
throw new Error('The \'_extendedTemplateDiagnostics\' option requires \'strictTemplates\' to also be enabled.');
|
|
40436
|
+
}
|
|
40212
40437
|
this.constructionDiagnostics.push(...this.adapter.constructionDiagnostics);
|
|
40213
40438
|
const incompatibleTypeCheckOptionsDiagnostic = verifyCompatibleTypeCheckOptions(this.options);
|
|
40214
40439
|
if (incompatibleTypeCheckOptionsDiagnostic !== null) {
|
|
@@ -40318,7 +40543,12 @@ Either add the @Injectable() decorator to '${provider.node.name
|
|
|
40318
40543
|
* Get all Angular-related diagnostics for this compilation.
|
|
40319
40544
|
*/
|
|
40320
40545
|
getDiagnostics() {
|
|
40321
|
-
|
|
40546
|
+
const diagnostics = [];
|
|
40547
|
+
diagnostics.push(...this.getNonTemplateDiagnostics(), ...this.getTemplateDiagnostics());
|
|
40548
|
+
if (this.options._extendedTemplateDiagnostics) {
|
|
40549
|
+
diagnostics.push(...this.getExtendedTemplateDiagnostics());
|
|
40550
|
+
}
|
|
40551
|
+
return this.addMessageTextDetails(diagnostics);
|
|
40322
40552
|
}
|
|
40323
40553
|
/**
|
|
40324
40554
|
* Get all Angular-related diagnostics for this compilation.
|
|
@@ -40326,10 +40556,26 @@ Either add the @Injectable() decorator to '${provider.node.name
|
|
|
40326
40556
|
* If a `ts.SourceFile` is passed, only diagnostics related to that file are returned.
|
|
40327
40557
|
*/
|
|
40328
40558
|
getDiagnosticsForFile(file, optimizeFor) {
|
|
40329
|
-
|
|
40330
|
-
|
|
40331
|
-
|
|
40332
|
-
|
|
40559
|
+
const diagnostics = [];
|
|
40560
|
+
diagnostics.push(...this.getNonTemplateDiagnostics().filter(diag => diag.file === file), ...this.getTemplateDiagnosticsForFile(file, optimizeFor));
|
|
40561
|
+
if (this.options._extendedTemplateDiagnostics) {
|
|
40562
|
+
diagnostics.push(...this.getExtendedTemplateDiagnostics(file));
|
|
40563
|
+
}
|
|
40564
|
+
return this.addMessageTextDetails(diagnostics);
|
|
40565
|
+
}
|
|
40566
|
+
/**
|
|
40567
|
+
* Get all `ts.Diagnostic`s currently available that pertain to the given component.
|
|
40568
|
+
*/
|
|
40569
|
+
getDiagnosticsForComponent(component) {
|
|
40570
|
+
const compilation = this.ensureAnalyzed();
|
|
40571
|
+
const ttc = compilation.templateTypeChecker;
|
|
40572
|
+
const diagnostics = [];
|
|
40573
|
+
diagnostics.push(...ttc.getDiagnosticsForComponent(component));
|
|
40574
|
+
if (this.options._extendedTemplateDiagnostics) {
|
|
40575
|
+
const extendedTemplateChecker = compilation.extendedTemplateChecker;
|
|
40576
|
+
diagnostics.push(...extendedTemplateChecker.getDiagnosticsForComponent(component));
|
|
40577
|
+
}
|
|
40578
|
+
return this.addMessageTextDetails(diagnostics);
|
|
40333
40579
|
}
|
|
40334
40580
|
/**
|
|
40335
40581
|
* Add Angular.io error guide links to diagnostics for this compilation.
|
|
@@ -40719,6 +40965,24 @@ Either add the @Injectable() decorator to '${provider.node.name
|
|
|
40719
40965
|
}
|
|
40720
40966
|
return this.nonTemplateDiagnostics;
|
|
40721
40967
|
}
|
|
40968
|
+
/**
|
|
40969
|
+
* Calls the `extendedTemplateCheck` phase of the trait compiler
|
|
40970
|
+
* @param sf optional parameter to get diagnostics for a certain file
|
|
40971
|
+
* or all files in the program if `sf` is undefined
|
|
40972
|
+
* @returns generated extended template diagnostics
|
|
40973
|
+
*/
|
|
40974
|
+
getExtendedTemplateDiagnostics(sf) {
|
|
40975
|
+
const diagnostics = [];
|
|
40976
|
+
const compilation = this.ensureAnalyzed();
|
|
40977
|
+
const extendedTemplateChecker = compilation.extendedTemplateChecker;
|
|
40978
|
+
if (sf !== undefined) {
|
|
40979
|
+
return compilation.traitCompiler.extendedTemplateCheck(sf, extendedTemplateChecker);
|
|
40980
|
+
}
|
|
40981
|
+
for (const sf of this.inputProgram.getSourceFiles()) {
|
|
40982
|
+
diagnostics.push(...compilation.traitCompiler.extendedTemplateCheck(sf, extendedTemplateChecker));
|
|
40983
|
+
}
|
|
40984
|
+
return diagnostics;
|
|
40985
|
+
}
|
|
40722
40986
|
makeCompilation() {
|
|
40723
40987
|
const checker = this.inputProgram.getTypeChecker();
|
|
40724
40988
|
const reflector = new TypeScriptReflectionHost(checker);
|
|
@@ -40832,6 +41096,11 @@ Either add the @Injectable() decorator to '${provider.node.name
|
|
|
40832
41096
|
this.currentProgram = program;
|
|
40833
41097
|
});
|
|
40834
41098
|
const templateTypeChecker = new TemplateTypeCheckerImpl(this.inputProgram, notifyingDriver, traitCompiler, this.getTypeCheckingConfig(), refEmitter, reflector, this.adapter, this.incrementalCompilation, scopeRegistry, typeCheckScopeRegistry, this.delegatingPerfRecorder);
|
|
41099
|
+
const templateChecks = [new InvalidBananaInBoxCheck()];
|
|
41100
|
+
if (this.options.strictNullChecks) {
|
|
41101
|
+
templateChecks.push(new NullishCoalescingNotNullableCheck());
|
|
41102
|
+
}
|
|
41103
|
+
const extendedTemplateChecker = new ExtendedTemplateCheckerImpl(templateTypeChecker, checker, templateChecks);
|
|
40835
41104
|
return {
|
|
40836
41105
|
isCore,
|
|
40837
41106
|
traitCompiler,
|
|
@@ -40846,6 +41115,7 @@ Either add the @Injectable() decorator to '${provider.node.name
|
|
|
40846
41115
|
refEmitter,
|
|
40847
41116
|
templateTypeChecker,
|
|
40848
41117
|
resourceRegistry,
|
|
41118
|
+
extendedTemplateChecker
|
|
40849
41119
|
};
|
|
40850
41120
|
}
|
|
40851
41121
|
}
|
|
@@ -44409,7 +44679,6 @@ https://v9.angular.io/guide/template-typecheck#template-type-checking`,
|
|
|
44409
44679
|
}
|
|
44410
44680
|
getSemanticDiagnostics(fileName) {
|
|
44411
44681
|
return this.withCompilerAndPerfTracing(PerfPhase.LsDiagnostics, (compiler) => {
|
|
44412
|
-
const ttc = compiler.getTemplateTypeChecker();
|
|
44413
44682
|
const diagnostics = [];
|
|
44414
44683
|
if (isTypeScriptFile(fileName)) {
|
|
44415
44684
|
const program = compiler.getCurrentProgram();
|
|
@@ -44445,7 +44714,7 @@ https://v9.angular.io/guide/template-typecheck#template-type-checking`,
|
|
|
44445
44714
|
const components = compiler.getComponentsWithTemplateFile(fileName);
|
|
44446
44715
|
for (const component of components) {
|
|
44447
44716
|
if (ts.isClassDeclaration(component)) {
|
|
44448
|
-
diagnostics.push(...
|
|
44717
|
+
diagnostics.push(...compiler.getDiagnosticsForComponent(component));
|
|
44449
44718
|
}
|
|
44450
44719
|
}
|
|
44451
44720
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @license Angular v12.2.
|
|
2
|
+
* @license Angular v12.2.6
|
|
3
3
|
* Copyright Google LLC All Rights Reserved.
|
|
4
4
|
* License: MIT
|
|
5
5
|
*/
|
|
@@ -21475,7 +21475,7 @@ define(['exports', 'typescript/lib/tsserverlibrary', 'typescript', 'path'], func
|
|
|
21475
21475
|
* Use of this source code is governed by an MIT-style license that can be
|
|
21476
21476
|
* found in the LICENSE file at https://angular.io/license
|
|
21477
21477
|
*/
|
|
21478
|
-
const VERSION$1 = new Version('12.2.
|
|
21478
|
+
const VERSION$1 = new Version('12.2.6');
|
|
21479
21479
|
|
|
21480
21480
|
/**
|
|
21481
21481
|
* @license
|
|
@@ -32958,12 +32958,6 @@ define(['exports', 'typescript/lib/tsserverlibrary', 'typescript', 'path'], func
|
|
|
32958
32958
|
const ERROR_DEBUG_CONTEXT = 'ngDebugContext';
|
|
32959
32959
|
const ERROR_ORIGINAL_ERROR = 'ngOriginalError';
|
|
32960
32960
|
const ERROR_LOGGER = 'ngErrorLogger';
|
|
32961
|
-
function wrappedError(message, originalError) {
|
|
32962
|
-
const msg = `${message} caused by: ${originalError instanceof Error ? originalError.message : originalError}`;
|
|
32963
|
-
const error = Error(msg);
|
|
32964
|
-
error[ERROR_ORIGINAL_ERROR] = originalError;
|
|
32965
|
-
return error;
|
|
32966
|
-
}
|
|
32967
32961
|
|
|
32968
32962
|
/**
|
|
32969
32963
|
* @license
|
|
@@ -35794,7 +35788,7 @@ define(['exports', 'typescript/lib/tsserverlibrary', 'typescript', 'path'], func
|
|
|
35794
35788
|
}
|
|
35795
35789
|
}
|
|
35796
35790
|
Injector.THROW_IF_NOT_FOUND = THROW_IF_NOT_FOUND;
|
|
35797
|
-
Injector.NULL = new NullInjector();
|
|
35791
|
+
Injector.NULL = ( /* @__PURE__ */new NullInjector());
|
|
35798
35792
|
/** @nocollapse */
|
|
35799
35793
|
Injector.ɵprov = ɵɵdefineInjectable({
|
|
35800
35794
|
token: Injector,
|
|
@@ -36316,864 +36310,6 @@ define(['exports', 'typescript/lib/tsserverlibrary', 'typescript', 'path'], func
|
|
|
36316
36310
|
const SWITCH_COMPILE_INJECTABLE__PRE_R3__ = render2CompileInjectable;
|
|
36317
36311
|
const SWITCH_COMPILE_INJECTABLE = SWITCH_COMPILE_INJECTABLE__PRE_R3__;
|
|
36318
36312
|
|
|
36319
|
-
/**
|
|
36320
|
-
* @license
|
|
36321
|
-
* Copyright Google LLC All Rights Reserved.
|
|
36322
|
-
*
|
|
36323
|
-
* Use of this source code is governed by an MIT-style license that can be
|
|
36324
|
-
* found in the LICENSE file at https://angular.io/license
|
|
36325
|
-
*/
|
|
36326
|
-
function findFirstClosedCycle(keys) {
|
|
36327
|
-
const res = [];
|
|
36328
|
-
for (let i = 0; i < keys.length; ++i) {
|
|
36329
|
-
if (res.indexOf(keys[i]) > -1) {
|
|
36330
|
-
res.push(keys[i]);
|
|
36331
|
-
return res;
|
|
36332
|
-
}
|
|
36333
|
-
res.push(keys[i]);
|
|
36334
|
-
}
|
|
36335
|
-
return res;
|
|
36336
|
-
}
|
|
36337
|
-
function constructResolvingPath(keys) {
|
|
36338
|
-
if (keys.length > 1) {
|
|
36339
|
-
const reversed = findFirstClosedCycle(keys.slice().reverse());
|
|
36340
|
-
const tokenStrs = reversed.map(k => stringify$1(k.token));
|
|
36341
|
-
return ' (' + tokenStrs.join(' -> ') + ')';
|
|
36342
|
-
}
|
|
36343
|
-
return '';
|
|
36344
|
-
}
|
|
36345
|
-
function injectionError(injector, key, constructResolvingMessage, originalError) {
|
|
36346
|
-
const keys = [key];
|
|
36347
|
-
const errMsg = constructResolvingMessage(keys);
|
|
36348
|
-
const error = (originalError ? wrappedError(errMsg, originalError) : Error(errMsg));
|
|
36349
|
-
error.addKey = addKey;
|
|
36350
|
-
error.keys = keys;
|
|
36351
|
-
error.injectors = [injector];
|
|
36352
|
-
error.constructResolvingMessage = constructResolvingMessage;
|
|
36353
|
-
error[ERROR_ORIGINAL_ERROR] = originalError;
|
|
36354
|
-
return error;
|
|
36355
|
-
}
|
|
36356
|
-
function addKey(injector, key) {
|
|
36357
|
-
this.injectors.push(injector);
|
|
36358
|
-
this.keys.push(key);
|
|
36359
|
-
// Note: This updated message won't be reflected in the `.stack` property
|
|
36360
|
-
this.message = this.constructResolvingMessage(this.keys);
|
|
36361
|
-
}
|
|
36362
|
-
/**
|
|
36363
|
-
* Thrown when trying to retrieve a dependency by key from {@link Injector}, but the
|
|
36364
|
-
* {@link Injector} does not have a {@link Provider} for the given key.
|
|
36365
|
-
*
|
|
36366
|
-
* @usageNotes
|
|
36367
|
-
* ### Example
|
|
36368
|
-
*
|
|
36369
|
-
* ```typescript
|
|
36370
|
-
* class A {
|
|
36371
|
-
* constructor(b:B) {}
|
|
36372
|
-
* }
|
|
36373
|
-
*
|
|
36374
|
-
* expect(() => Injector.resolveAndCreate([A])).toThrowError();
|
|
36375
|
-
* ```
|
|
36376
|
-
*/
|
|
36377
|
-
function noProviderError(injector, key) {
|
|
36378
|
-
return injectionError(injector, key, function (keys) {
|
|
36379
|
-
const first = stringify$1(keys[0].token);
|
|
36380
|
-
return `No provider for ${first}!${constructResolvingPath(keys)}`;
|
|
36381
|
-
});
|
|
36382
|
-
}
|
|
36383
|
-
/**
|
|
36384
|
-
* Thrown when dependencies form a cycle.
|
|
36385
|
-
*
|
|
36386
|
-
* @usageNotes
|
|
36387
|
-
* ### Example
|
|
36388
|
-
*
|
|
36389
|
-
* ```typescript
|
|
36390
|
-
* var injector = Injector.resolveAndCreate([
|
|
36391
|
-
* {provide: "one", useFactory: (two) => "two", deps: [[new Inject("two")]]},
|
|
36392
|
-
* {provide: "two", useFactory: (one) => "one", deps: [[new Inject("one")]]}
|
|
36393
|
-
* ]);
|
|
36394
|
-
*
|
|
36395
|
-
* expect(() => injector.get("one")).toThrowError();
|
|
36396
|
-
* ```
|
|
36397
|
-
*
|
|
36398
|
-
* Retrieving `A` or `B` throws a `CyclicDependencyError` as the graph above cannot be constructed.
|
|
36399
|
-
*/
|
|
36400
|
-
function cyclicDependencyError(injector, key) {
|
|
36401
|
-
return injectionError(injector, key, function (keys) {
|
|
36402
|
-
return `Cannot instantiate cyclic dependency!${constructResolvingPath(keys)}`;
|
|
36403
|
-
});
|
|
36404
|
-
}
|
|
36405
|
-
/**
|
|
36406
|
-
* Thrown when a constructing type returns with an Error.
|
|
36407
|
-
*
|
|
36408
|
-
* The `InstantiationError` class contains the original error plus the dependency graph which caused
|
|
36409
|
-
* this object to be instantiated.
|
|
36410
|
-
*
|
|
36411
|
-
* @usageNotes
|
|
36412
|
-
* ### Example
|
|
36413
|
-
*
|
|
36414
|
-
* ```typescript
|
|
36415
|
-
* class A {
|
|
36416
|
-
* constructor() {
|
|
36417
|
-
* throw new Error('message');
|
|
36418
|
-
* }
|
|
36419
|
-
* }
|
|
36420
|
-
*
|
|
36421
|
-
* var injector = Injector.resolveAndCreate([A]);
|
|
36422
|
-
|
|
36423
|
-
* try {
|
|
36424
|
-
* injector.get(A);
|
|
36425
|
-
* } catch (e) {
|
|
36426
|
-
* expect(e instanceof InstantiationError).toBe(true);
|
|
36427
|
-
* expect(e.originalException.message).toEqual("message");
|
|
36428
|
-
* expect(e.originalStack).toBeDefined();
|
|
36429
|
-
* }
|
|
36430
|
-
* ```
|
|
36431
|
-
*/
|
|
36432
|
-
function instantiationError(injector, originalException, originalStack, key) {
|
|
36433
|
-
return injectionError(injector, key, function (keys) {
|
|
36434
|
-
const first = stringify$1(keys[0].token);
|
|
36435
|
-
return `${originalException.message}: Error during instantiation of ${first}!${constructResolvingPath(keys)}.`;
|
|
36436
|
-
}, originalException);
|
|
36437
|
-
}
|
|
36438
|
-
/**
|
|
36439
|
-
* Thrown when an object other then {@link Provider} (or `Type`) is passed to {@link Injector}
|
|
36440
|
-
* creation.
|
|
36441
|
-
*
|
|
36442
|
-
* @usageNotes
|
|
36443
|
-
* ### Example
|
|
36444
|
-
*
|
|
36445
|
-
* ```typescript
|
|
36446
|
-
* expect(() => Injector.resolveAndCreate(["not a type"])).toThrowError();
|
|
36447
|
-
* ```
|
|
36448
|
-
*/
|
|
36449
|
-
function invalidProviderError(provider) {
|
|
36450
|
-
return Error(`Invalid provider - only instances of Provider and Type are allowed, got: ${provider}`);
|
|
36451
|
-
}
|
|
36452
|
-
/**
|
|
36453
|
-
* Thrown when the class has no annotation information.
|
|
36454
|
-
*
|
|
36455
|
-
* Lack of annotation information prevents the {@link Injector} from determining which dependencies
|
|
36456
|
-
* need to be injected into the constructor.
|
|
36457
|
-
*
|
|
36458
|
-
* @usageNotes
|
|
36459
|
-
* ### Example
|
|
36460
|
-
*
|
|
36461
|
-
* ```typescript
|
|
36462
|
-
* class A {
|
|
36463
|
-
* constructor(b) {}
|
|
36464
|
-
* }
|
|
36465
|
-
*
|
|
36466
|
-
* expect(() => Injector.resolveAndCreate([A])).toThrowError();
|
|
36467
|
-
* ```
|
|
36468
|
-
*
|
|
36469
|
-
* This error is also thrown when the class not marked with {@link Injectable} has parameter types.
|
|
36470
|
-
*
|
|
36471
|
-
* ```typescript
|
|
36472
|
-
* class B {}
|
|
36473
|
-
*
|
|
36474
|
-
* class A {
|
|
36475
|
-
* constructor(b:B) {} // no information about the parameter types of A is available at runtime.
|
|
36476
|
-
* }
|
|
36477
|
-
*
|
|
36478
|
-
* expect(() => Injector.resolveAndCreate([A,B])).toThrowError();
|
|
36479
|
-
* ```
|
|
36480
|
-
*
|
|
36481
|
-
*/
|
|
36482
|
-
function noAnnotationError(typeOrFunc, params) {
|
|
36483
|
-
const signature = [];
|
|
36484
|
-
for (let i = 0, ii = params.length; i < ii; i++) {
|
|
36485
|
-
const parameter = params[i];
|
|
36486
|
-
if (!parameter || parameter.length == 0) {
|
|
36487
|
-
signature.push('?');
|
|
36488
|
-
}
|
|
36489
|
-
else {
|
|
36490
|
-
signature.push(parameter.map(stringify$1).join(' '));
|
|
36491
|
-
}
|
|
36492
|
-
}
|
|
36493
|
-
return Error('Cannot resolve all parameters for \'' + stringify$1(typeOrFunc) + '\'(' +
|
|
36494
|
-
signature.join(', ') + '). ' +
|
|
36495
|
-
'Make sure that all the parameters are decorated with Inject or have valid type annotations and that \'' +
|
|
36496
|
-
stringify$1(typeOrFunc) + '\' is decorated with Injectable.');
|
|
36497
|
-
}
|
|
36498
|
-
/**
|
|
36499
|
-
* Thrown when getting an object by index.
|
|
36500
|
-
*
|
|
36501
|
-
* @usageNotes
|
|
36502
|
-
* ### Example
|
|
36503
|
-
*
|
|
36504
|
-
* ```typescript
|
|
36505
|
-
* class A {}
|
|
36506
|
-
*
|
|
36507
|
-
* var injector = Injector.resolveAndCreate([A]);
|
|
36508
|
-
*
|
|
36509
|
-
* expect(() => injector.getAt(100)).toThrowError();
|
|
36510
|
-
* ```
|
|
36511
|
-
*
|
|
36512
|
-
*/
|
|
36513
|
-
function outOfBoundsError(index) {
|
|
36514
|
-
return Error(`Index ${index} is out-of-bounds.`);
|
|
36515
|
-
}
|
|
36516
|
-
// TODO: add a working example after alpha38 is released
|
|
36517
|
-
/**
|
|
36518
|
-
* Thrown when a multi provider and a regular provider are bound to the same token.
|
|
36519
|
-
*
|
|
36520
|
-
* @usageNotes
|
|
36521
|
-
* ### Example
|
|
36522
|
-
*
|
|
36523
|
-
* ```typescript
|
|
36524
|
-
* expect(() => Injector.resolveAndCreate([
|
|
36525
|
-
* { provide: "Strings", useValue: "string1", multi: true},
|
|
36526
|
-
* { provide: "Strings", useValue: "string2", multi: false}
|
|
36527
|
-
* ])).toThrowError();
|
|
36528
|
-
* ```
|
|
36529
|
-
*/
|
|
36530
|
-
function mixingMultiProvidersWithRegularProvidersError(provider1, provider2) {
|
|
36531
|
-
return Error(`Cannot mix multi providers and regular providers, got: ${provider1} ${provider2}`);
|
|
36532
|
-
}
|
|
36533
|
-
|
|
36534
|
-
/**
|
|
36535
|
-
* @license
|
|
36536
|
-
* Copyright Google LLC All Rights Reserved.
|
|
36537
|
-
*
|
|
36538
|
-
* Use of this source code is governed by an MIT-style license that can be
|
|
36539
|
-
* found in the LICENSE file at https://angular.io/license
|
|
36540
|
-
*/
|
|
36541
|
-
/**
|
|
36542
|
-
* A unique object used for retrieving items from the {@link ReflectiveInjector}.
|
|
36543
|
-
*
|
|
36544
|
-
* Keys have:
|
|
36545
|
-
* - a system-wide unique `id`.
|
|
36546
|
-
* - a `token`.
|
|
36547
|
-
*
|
|
36548
|
-
* `Key` is used internally by {@link ReflectiveInjector} because its system-wide unique `id` allows
|
|
36549
|
-
* the
|
|
36550
|
-
* injector to store created objects in a more efficient way.
|
|
36551
|
-
*
|
|
36552
|
-
* `Key` should not be created directly. {@link ReflectiveInjector} creates keys automatically when
|
|
36553
|
-
* resolving
|
|
36554
|
-
* providers.
|
|
36555
|
-
*
|
|
36556
|
-
* @deprecated No replacement
|
|
36557
|
-
* @publicApi
|
|
36558
|
-
*/
|
|
36559
|
-
class ReflectiveKey {
|
|
36560
|
-
/**
|
|
36561
|
-
* Private
|
|
36562
|
-
*/
|
|
36563
|
-
constructor(token, id) {
|
|
36564
|
-
this.token = token;
|
|
36565
|
-
this.id = id;
|
|
36566
|
-
if (!token) {
|
|
36567
|
-
throw new Error('Token must be defined!');
|
|
36568
|
-
}
|
|
36569
|
-
this.displayName = stringify$1(this.token);
|
|
36570
|
-
}
|
|
36571
|
-
/**
|
|
36572
|
-
* Retrieves a `Key` for a token.
|
|
36573
|
-
*/
|
|
36574
|
-
static get(token) {
|
|
36575
|
-
return _globalKeyRegistry.get(resolveForwardRef$1(token));
|
|
36576
|
-
}
|
|
36577
|
-
/**
|
|
36578
|
-
* @returns the number of keys registered in the system.
|
|
36579
|
-
*/
|
|
36580
|
-
static get numberOfKeys() {
|
|
36581
|
-
return _globalKeyRegistry.numberOfKeys;
|
|
36582
|
-
}
|
|
36583
|
-
}
|
|
36584
|
-
class KeyRegistry {
|
|
36585
|
-
constructor() {
|
|
36586
|
-
this._allKeys = new Map();
|
|
36587
|
-
}
|
|
36588
|
-
get(token) {
|
|
36589
|
-
if (token instanceof ReflectiveKey)
|
|
36590
|
-
return token;
|
|
36591
|
-
if (this._allKeys.has(token)) {
|
|
36592
|
-
return this._allKeys.get(token);
|
|
36593
|
-
}
|
|
36594
|
-
const newKey = new ReflectiveKey(token, ReflectiveKey.numberOfKeys);
|
|
36595
|
-
this._allKeys.set(token, newKey);
|
|
36596
|
-
return newKey;
|
|
36597
|
-
}
|
|
36598
|
-
get numberOfKeys() {
|
|
36599
|
-
return this._allKeys.size;
|
|
36600
|
-
}
|
|
36601
|
-
}
|
|
36602
|
-
const _globalKeyRegistry = new KeyRegistry();
|
|
36603
|
-
|
|
36604
|
-
/**
|
|
36605
|
-
* @license
|
|
36606
|
-
* Copyright Google LLC All Rights Reserved.
|
|
36607
|
-
*
|
|
36608
|
-
* Use of this source code is governed by an MIT-style license that can be
|
|
36609
|
-
* found in the LICENSE file at https://angular.io/license
|
|
36610
|
-
*/
|
|
36611
|
-
/**
|
|
36612
|
-
* Provides access to reflection data about symbols. Used internally by Angular
|
|
36613
|
-
* to power dependency injection and compilation.
|
|
36614
|
-
*/
|
|
36615
|
-
class Reflector {
|
|
36616
|
-
constructor(reflectionCapabilities) {
|
|
36617
|
-
this.reflectionCapabilities = reflectionCapabilities;
|
|
36618
|
-
}
|
|
36619
|
-
updateCapabilities(caps) {
|
|
36620
|
-
this.reflectionCapabilities = caps;
|
|
36621
|
-
}
|
|
36622
|
-
factory(type) {
|
|
36623
|
-
return this.reflectionCapabilities.factory(type);
|
|
36624
|
-
}
|
|
36625
|
-
parameters(typeOrFunc) {
|
|
36626
|
-
return this.reflectionCapabilities.parameters(typeOrFunc);
|
|
36627
|
-
}
|
|
36628
|
-
annotations(typeOrFunc) {
|
|
36629
|
-
return this.reflectionCapabilities.annotations(typeOrFunc);
|
|
36630
|
-
}
|
|
36631
|
-
propMetadata(typeOrFunc) {
|
|
36632
|
-
return this.reflectionCapabilities.propMetadata(typeOrFunc);
|
|
36633
|
-
}
|
|
36634
|
-
hasLifecycleHook(type, lcProperty) {
|
|
36635
|
-
return this.reflectionCapabilities.hasLifecycleHook(type, lcProperty);
|
|
36636
|
-
}
|
|
36637
|
-
getter(name) {
|
|
36638
|
-
return this.reflectionCapabilities.getter(name);
|
|
36639
|
-
}
|
|
36640
|
-
setter(name) {
|
|
36641
|
-
return this.reflectionCapabilities.setter(name);
|
|
36642
|
-
}
|
|
36643
|
-
method(name) {
|
|
36644
|
-
return this.reflectionCapabilities.method(name);
|
|
36645
|
-
}
|
|
36646
|
-
importUri(type) {
|
|
36647
|
-
return this.reflectionCapabilities.importUri(type);
|
|
36648
|
-
}
|
|
36649
|
-
resourceUri(type) {
|
|
36650
|
-
return this.reflectionCapabilities.resourceUri(type);
|
|
36651
|
-
}
|
|
36652
|
-
resolveIdentifier(name, moduleUrl, members, runtime) {
|
|
36653
|
-
return this.reflectionCapabilities.resolveIdentifier(name, moduleUrl, members, runtime);
|
|
36654
|
-
}
|
|
36655
|
-
resolveEnum(identifier, name) {
|
|
36656
|
-
return this.reflectionCapabilities.resolveEnum(identifier, name);
|
|
36657
|
-
}
|
|
36658
|
-
}
|
|
36659
|
-
|
|
36660
|
-
/**
|
|
36661
|
-
* @license
|
|
36662
|
-
* Copyright Google LLC All Rights Reserved.
|
|
36663
|
-
*
|
|
36664
|
-
* Use of this source code is governed by an MIT-style license that can be
|
|
36665
|
-
* found in the LICENSE file at https://angular.io/license
|
|
36666
|
-
*/
|
|
36667
|
-
/**
|
|
36668
|
-
* The {@link Reflector} used internally in Angular to access metadata
|
|
36669
|
-
* about symbols.
|
|
36670
|
-
*/
|
|
36671
|
-
const reflector = new Reflector(new ReflectionCapabilities());
|
|
36672
|
-
|
|
36673
|
-
/**
|
|
36674
|
-
* @license
|
|
36675
|
-
* Copyright Google LLC All Rights Reserved.
|
|
36676
|
-
*
|
|
36677
|
-
* Use of this source code is governed by an MIT-style license that can be
|
|
36678
|
-
* found in the LICENSE file at https://angular.io/license
|
|
36679
|
-
*/
|
|
36680
|
-
/**
|
|
36681
|
-
* `Dependency` is used by the framework to extend DI.
|
|
36682
|
-
* This is internal to Angular and should not be used directly.
|
|
36683
|
-
*/
|
|
36684
|
-
class ReflectiveDependency {
|
|
36685
|
-
constructor(key, optional, visibility) {
|
|
36686
|
-
this.key = key;
|
|
36687
|
-
this.optional = optional;
|
|
36688
|
-
this.visibility = visibility;
|
|
36689
|
-
}
|
|
36690
|
-
static fromKey(key) {
|
|
36691
|
-
return new ReflectiveDependency(key, false, null);
|
|
36692
|
-
}
|
|
36693
|
-
}
|
|
36694
|
-
const _EMPTY_LIST = [];
|
|
36695
|
-
class ResolvedReflectiveProvider_ {
|
|
36696
|
-
constructor(key, resolvedFactories, multiProvider) {
|
|
36697
|
-
this.key = key;
|
|
36698
|
-
this.resolvedFactories = resolvedFactories;
|
|
36699
|
-
this.multiProvider = multiProvider;
|
|
36700
|
-
this.resolvedFactory = this.resolvedFactories[0];
|
|
36701
|
-
}
|
|
36702
|
-
}
|
|
36703
|
-
/**
|
|
36704
|
-
* An internal resolved representation of a factory function created by resolving `Provider`.
|
|
36705
|
-
* @publicApi
|
|
36706
|
-
*/
|
|
36707
|
-
class ResolvedReflectiveFactory {
|
|
36708
|
-
constructor(
|
|
36709
|
-
/**
|
|
36710
|
-
* Factory function which can return an instance of an object represented by a key.
|
|
36711
|
-
*/
|
|
36712
|
-
factory,
|
|
36713
|
-
/**
|
|
36714
|
-
* Arguments (dependencies) to the `factory` function.
|
|
36715
|
-
*/
|
|
36716
|
-
dependencies) {
|
|
36717
|
-
this.factory = factory;
|
|
36718
|
-
this.dependencies = dependencies;
|
|
36719
|
-
}
|
|
36720
|
-
}
|
|
36721
|
-
/**
|
|
36722
|
-
* Resolve a single provider.
|
|
36723
|
-
*/
|
|
36724
|
-
function resolveReflectiveFactory(provider) {
|
|
36725
|
-
let factoryFn;
|
|
36726
|
-
let resolvedDeps;
|
|
36727
|
-
if (provider.useClass) {
|
|
36728
|
-
const useClass = resolveForwardRef$1(provider.useClass);
|
|
36729
|
-
factoryFn = reflector.factory(useClass);
|
|
36730
|
-
resolvedDeps = _dependenciesFor(useClass);
|
|
36731
|
-
}
|
|
36732
|
-
else if (provider.useExisting) {
|
|
36733
|
-
factoryFn = (aliasInstance) => aliasInstance;
|
|
36734
|
-
resolvedDeps = [ReflectiveDependency.fromKey(ReflectiveKey.get(provider.useExisting))];
|
|
36735
|
-
}
|
|
36736
|
-
else if (provider.useFactory) {
|
|
36737
|
-
factoryFn = provider.useFactory;
|
|
36738
|
-
resolvedDeps = constructDependencies(provider.useFactory, provider.deps);
|
|
36739
|
-
}
|
|
36740
|
-
else {
|
|
36741
|
-
factoryFn = () => provider.useValue;
|
|
36742
|
-
resolvedDeps = _EMPTY_LIST;
|
|
36743
|
-
}
|
|
36744
|
-
return new ResolvedReflectiveFactory(factoryFn, resolvedDeps);
|
|
36745
|
-
}
|
|
36746
|
-
/**
|
|
36747
|
-
* Converts the `Provider` into `ResolvedProvider`.
|
|
36748
|
-
*
|
|
36749
|
-
* `Injector` internally only uses `ResolvedProvider`, `Provider` contains convenience provider
|
|
36750
|
-
* syntax.
|
|
36751
|
-
*/
|
|
36752
|
-
function resolveReflectiveProvider(provider) {
|
|
36753
|
-
return new ResolvedReflectiveProvider_(ReflectiveKey.get(provider.provide), [resolveReflectiveFactory(provider)], provider.multi || false);
|
|
36754
|
-
}
|
|
36755
|
-
/**
|
|
36756
|
-
* Resolve a list of Providers.
|
|
36757
|
-
*/
|
|
36758
|
-
function resolveReflectiveProviders(providers) {
|
|
36759
|
-
const normalized = _normalizeProviders(providers, []);
|
|
36760
|
-
const resolved = normalized.map(resolveReflectiveProvider);
|
|
36761
|
-
const resolvedProviderMap = mergeResolvedReflectiveProviders(resolved, new Map());
|
|
36762
|
-
return Array.from(resolvedProviderMap.values());
|
|
36763
|
-
}
|
|
36764
|
-
/**
|
|
36765
|
-
* Merges a list of ResolvedProviders into a list where each key is contained exactly once and
|
|
36766
|
-
* multi providers have been merged.
|
|
36767
|
-
*/
|
|
36768
|
-
function mergeResolvedReflectiveProviders(providers, normalizedProvidersMap) {
|
|
36769
|
-
for (let i = 0; i < providers.length; i++) {
|
|
36770
|
-
const provider = providers[i];
|
|
36771
|
-
const existing = normalizedProvidersMap.get(provider.key.id);
|
|
36772
|
-
if (existing) {
|
|
36773
|
-
if (provider.multiProvider !== existing.multiProvider) {
|
|
36774
|
-
throw mixingMultiProvidersWithRegularProvidersError(existing, provider);
|
|
36775
|
-
}
|
|
36776
|
-
if (provider.multiProvider) {
|
|
36777
|
-
for (let j = 0; j < provider.resolvedFactories.length; j++) {
|
|
36778
|
-
existing.resolvedFactories.push(provider.resolvedFactories[j]);
|
|
36779
|
-
}
|
|
36780
|
-
}
|
|
36781
|
-
else {
|
|
36782
|
-
normalizedProvidersMap.set(provider.key.id, provider);
|
|
36783
|
-
}
|
|
36784
|
-
}
|
|
36785
|
-
else {
|
|
36786
|
-
let resolvedProvider;
|
|
36787
|
-
if (provider.multiProvider) {
|
|
36788
|
-
resolvedProvider = new ResolvedReflectiveProvider_(provider.key, provider.resolvedFactories.slice(), provider.multiProvider);
|
|
36789
|
-
}
|
|
36790
|
-
else {
|
|
36791
|
-
resolvedProvider = provider;
|
|
36792
|
-
}
|
|
36793
|
-
normalizedProvidersMap.set(provider.key.id, resolvedProvider);
|
|
36794
|
-
}
|
|
36795
|
-
}
|
|
36796
|
-
return normalizedProvidersMap;
|
|
36797
|
-
}
|
|
36798
|
-
function _normalizeProviders(providers, res) {
|
|
36799
|
-
providers.forEach(b => {
|
|
36800
|
-
if (b instanceof Type$2) {
|
|
36801
|
-
res.push({ provide: b, useClass: b });
|
|
36802
|
-
}
|
|
36803
|
-
else if (b && typeof b == 'object' && b.provide !== undefined) {
|
|
36804
|
-
res.push(b);
|
|
36805
|
-
}
|
|
36806
|
-
else if (Array.isArray(b)) {
|
|
36807
|
-
_normalizeProviders(b, res);
|
|
36808
|
-
}
|
|
36809
|
-
else {
|
|
36810
|
-
throw invalidProviderError(b);
|
|
36811
|
-
}
|
|
36812
|
-
});
|
|
36813
|
-
return res;
|
|
36814
|
-
}
|
|
36815
|
-
function constructDependencies(typeOrFunc, dependencies) {
|
|
36816
|
-
if (!dependencies) {
|
|
36817
|
-
return _dependenciesFor(typeOrFunc);
|
|
36818
|
-
}
|
|
36819
|
-
else {
|
|
36820
|
-
const params = dependencies.map(t => [t]);
|
|
36821
|
-
return dependencies.map(t => _extractToken(typeOrFunc, t, params));
|
|
36822
|
-
}
|
|
36823
|
-
}
|
|
36824
|
-
function _dependenciesFor(typeOrFunc) {
|
|
36825
|
-
const params = reflector.parameters(typeOrFunc);
|
|
36826
|
-
if (!params)
|
|
36827
|
-
return [];
|
|
36828
|
-
if (params.some(p => p == null)) {
|
|
36829
|
-
throw noAnnotationError(typeOrFunc, params);
|
|
36830
|
-
}
|
|
36831
|
-
return params.map(p => _extractToken(typeOrFunc, p, params));
|
|
36832
|
-
}
|
|
36833
|
-
function _extractToken(typeOrFunc, metadata, params) {
|
|
36834
|
-
let token = null;
|
|
36835
|
-
let optional = false;
|
|
36836
|
-
if (!Array.isArray(metadata)) {
|
|
36837
|
-
if (metadata instanceof Inject) {
|
|
36838
|
-
return _createDependency(metadata.token, optional, null);
|
|
36839
|
-
}
|
|
36840
|
-
else {
|
|
36841
|
-
return _createDependency(metadata, optional, null);
|
|
36842
|
-
}
|
|
36843
|
-
}
|
|
36844
|
-
let visibility = null;
|
|
36845
|
-
for (let i = 0; i < metadata.length; ++i) {
|
|
36846
|
-
const paramMetadata = metadata[i];
|
|
36847
|
-
if (paramMetadata instanceof Type$2) {
|
|
36848
|
-
token = paramMetadata;
|
|
36849
|
-
}
|
|
36850
|
-
else if (paramMetadata instanceof Inject) {
|
|
36851
|
-
token = paramMetadata.token;
|
|
36852
|
-
}
|
|
36853
|
-
else if (paramMetadata instanceof Optional) {
|
|
36854
|
-
optional = true;
|
|
36855
|
-
}
|
|
36856
|
-
else if (paramMetadata instanceof Self || paramMetadata instanceof SkipSelf) {
|
|
36857
|
-
visibility = paramMetadata;
|
|
36858
|
-
}
|
|
36859
|
-
else if (paramMetadata instanceof InjectionToken) {
|
|
36860
|
-
token = paramMetadata;
|
|
36861
|
-
}
|
|
36862
|
-
}
|
|
36863
|
-
token = resolveForwardRef$1(token);
|
|
36864
|
-
if (token != null) {
|
|
36865
|
-
return _createDependency(token, optional, visibility);
|
|
36866
|
-
}
|
|
36867
|
-
else {
|
|
36868
|
-
throw noAnnotationError(typeOrFunc, params);
|
|
36869
|
-
}
|
|
36870
|
-
}
|
|
36871
|
-
function _createDependency(token, optional, visibility) {
|
|
36872
|
-
return new ReflectiveDependency(ReflectiveKey.get(token), optional, visibility);
|
|
36873
|
-
}
|
|
36874
|
-
|
|
36875
|
-
/**
|
|
36876
|
-
* @license
|
|
36877
|
-
* Copyright Google LLC All Rights Reserved.
|
|
36878
|
-
*
|
|
36879
|
-
* Use of this source code is governed by an MIT-style license that can be
|
|
36880
|
-
* found in the LICENSE file at https://angular.io/license
|
|
36881
|
-
*/
|
|
36882
|
-
// Threshold for the dynamic version
|
|
36883
|
-
const UNDEFINED = {};
|
|
36884
|
-
/**
|
|
36885
|
-
* A ReflectiveDependency injection container used for instantiating objects and resolving
|
|
36886
|
-
* dependencies.
|
|
36887
|
-
*
|
|
36888
|
-
* An `Injector` is a replacement for a `new` operator, which can automatically resolve the
|
|
36889
|
-
* constructor dependencies.
|
|
36890
|
-
*
|
|
36891
|
-
* In typical use, application code asks for the dependencies in the constructor and they are
|
|
36892
|
-
* resolved by the `Injector`.
|
|
36893
|
-
*
|
|
36894
|
-
* @usageNotes
|
|
36895
|
-
* ### Example
|
|
36896
|
-
*
|
|
36897
|
-
* The following example creates an `Injector` configured to create `Engine` and `Car`.
|
|
36898
|
-
*
|
|
36899
|
-
* ```typescript
|
|
36900
|
-
* @Injectable()
|
|
36901
|
-
* class Engine {
|
|
36902
|
-
* }
|
|
36903
|
-
*
|
|
36904
|
-
* @Injectable()
|
|
36905
|
-
* class Car {
|
|
36906
|
-
* constructor(public engine:Engine) {}
|
|
36907
|
-
* }
|
|
36908
|
-
*
|
|
36909
|
-
* var injector = ReflectiveInjector.resolveAndCreate([Car, Engine]);
|
|
36910
|
-
* var car = injector.get(Car);
|
|
36911
|
-
* expect(car instanceof Car).toBe(true);
|
|
36912
|
-
* expect(car.engine instanceof Engine).toBe(true);
|
|
36913
|
-
* ```
|
|
36914
|
-
*
|
|
36915
|
-
* Notice, we don't use the `new` operator because we explicitly want to have the `Injector`
|
|
36916
|
-
* resolve all of the object's dependencies automatically.
|
|
36917
|
-
*
|
|
36918
|
-
* @deprecated from v5 - slow and brings in a lot of code, Use `Injector.create` instead.
|
|
36919
|
-
* @publicApi
|
|
36920
|
-
*/
|
|
36921
|
-
class ReflectiveInjector {
|
|
36922
|
-
/**
|
|
36923
|
-
* Turns an array of provider definitions into an array of resolved providers.
|
|
36924
|
-
*
|
|
36925
|
-
* A resolution is a process of flattening multiple nested arrays and converting individual
|
|
36926
|
-
* providers into an array of `ResolvedReflectiveProvider`s.
|
|
36927
|
-
*
|
|
36928
|
-
* @usageNotes
|
|
36929
|
-
* ### Example
|
|
36930
|
-
*
|
|
36931
|
-
* ```typescript
|
|
36932
|
-
* @Injectable()
|
|
36933
|
-
* class Engine {
|
|
36934
|
-
* }
|
|
36935
|
-
*
|
|
36936
|
-
* @Injectable()
|
|
36937
|
-
* class Car {
|
|
36938
|
-
* constructor(public engine:Engine) {}
|
|
36939
|
-
* }
|
|
36940
|
-
*
|
|
36941
|
-
* var providers = ReflectiveInjector.resolve([Car, [[Engine]]]);
|
|
36942
|
-
*
|
|
36943
|
-
* expect(providers.length).toEqual(2);
|
|
36944
|
-
*
|
|
36945
|
-
* expect(providers[0] instanceof ResolvedReflectiveProvider).toBe(true);
|
|
36946
|
-
* expect(providers[0].key.displayName).toBe("Car");
|
|
36947
|
-
* expect(providers[0].dependencies.length).toEqual(1);
|
|
36948
|
-
* expect(providers[0].factory).toBeDefined();
|
|
36949
|
-
*
|
|
36950
|
-
* expect(providers[1].key.displayName).toBe("Engine");
|
|
36951
|
-
* });
|
|
36952
|
-
* ```
|
|
36953
|
-
*
|
|
36954
|
-
*/
|
|
36955
|
-
static resolve(providers) {
|
|
36956
|
-
return resolveReflectiveProviders(providers);
|
|
36957
|
-
}
|
|
36958
|
-
/**
|
|
36959
|
-
* Resolves an array of providers and creates an injector from those providers.
|
|
36960
|
-
*
|
|
36961
|
-
* The passed-in providers can be an array of `Type`, `Provider`,
|
|
36962
|
-
* or a recursive array of more providers.
|
|
36963
|
-
*
|
|
36964
|
-
* @usageNotes
|
|
36965
|
-
* ### Example
|
|
36966
|
-
*
|
|
36967
|
-
* ```typescript
|
|
36968
|
-
* @Injectable()
|
|
36969
|
-
* class Engine {
|
|
36970
|
-
* }
|
|
36971
|
-
*
|
|
36972
|
-
* @Injectable()
|
|
36973
|
-
* class Car {
|
|
36974
|
-
* constructor(public engine:Engine) {}
|
|
36975
|
-
* }
|
|
36976
|
-
*
|
|
36977
|
-
* var injector = ReflectiveInjector.resolveAndCreate([Car, Engine]);
|
|
36978
|
-
* expect(injector.get(Car) instanceof Car).toBe(true);
|
|
36979
|
-
* ```
|
|
36980
|
-
*/
|
|
36981
|
-
static resolveAndCreate(providers, parent) {
|
|
36982
|
-
const ResolvedReflectiveProviders = ReflectiveInjector.resolve(providers);
|
|
36983
|
-
return ReflectiveInjector.fromResolvedProviders(ResolvedReflectiveProviders, parent);
|
|
36984
|
-
}
|
|
36985
|
-
/**
|
|
36986
|
-
* Creates an injector from previously resolved providers.
|
|
36987
|
-
*
|
|
36988
|
-
* This API is the recommended way to construct injectors in performance-sensitive parts.
|
|
36989
|
-
*
|
|
36990
|
-
* @usageNotes
|
|
36991
|
-
* ### Example
|
|
36992
|
-
*
|
|
36993
|
-
* ```typescript
|
|
36994
|
-
* @Injectable()
|
|
36995
|
-
* class Engine {
|
|
36996
|
-
* }
|
|
36997
|
-
*
|
|
36998
|
-
* @Injectable()
|
|
36999
|
-
* class Car {
|
|
37000
|
-
* constructor(public engine:Engine) {}
|
|
37001
|
-
* }
|
|
37002
|
-
*
|
|
37003
|
-
* var providers = ReflectiveInjector.resolve([Car, Engine]);
|
|
37004
|
-
* var injector = ReflectiveInjector.fromResolvedProviders(providers);
|
|
37005
|
-
* expect(injector.get(Car) instanceof Car).toBe(true);
|
|
37006
|
-
* ```
|
|
37007
|
-
*/
|
|
37008
|
-
static fromResolvedProviders(providers, parent) {
|
|
37009
|
-
return new ReflectiveInjector_(providers, parent);
|
|
37010
|
-
}
|
|
37011
|
-
}
|
|
37012
|
-
class ReflectiveInjector_ {
|
|
37013
|
-
/**
|
|
37014
|
-
* Private
|
|
37015
|
-
*/
|
|
37016
|
-
constructor(_providers, _parent) {
|
|
37017
|
-
/** @internal */
|
|
37018
|
-
this._constructionCounter = 0;
|
|
37019
|
-
this._providers = _providers;
|
|
37020
|
-
this.parent = _parent || null;
|
|
37021
|
-
const len = _providers.length;
|
|
37022
|
-
this.keyIds = [];
|
|
37023
|
-
this.objs = [];
|
|
37024
|
-
for (let i = 0; i < len; i++) {
|
|
37025
|
-
this.keyIds[i] = _providers[i].key.id;
|
|
37026
|
-
this.objs[i] = UNDEFINED;
|
|
37027
|
-
}
|
|
37028
|
-
}
|
|
37029
|
-
get(token, notFoundValue = THROW_IF_NOT_FOUND) {
|
|
37030
|
-
return this._getByKey(ReflectiveKey.get(token), null, notFoundValue);
|
|
37031
|
-
}
|
|
37032
|
-
resolveAndCreateChild(providers) {
|
|
37033
|
-
const ResolvedReflectiveProviders = ReflectiveInjector.resolve(providers);
|
|
37034
|
-
return this.createChildFromResolved(ResolvedReflectiveProviders);
|
|
37035
|
-
}
|
|
37036
|
-
createChildFromResolved(providers) {
|
|
37037
|
-
const inj = new ReflectiveInjector_(providers);
|
|
37038
|
-
inj.parent = this;
|
|
37039
|
-
return inj;
|
|
37040
|
-
}
|
|
37041
|
-
resolveAndInstantiate(provider) {
|
|
37042
|
-
return this.instantiateResolved(ReflectiveInjector.resolve([provider])[0]);
|
|
37043
|
-
}
|
|
37044
|
-
instantiateResolved(provider) {
|
|
37045
|
-
return this._instantiateProvider(provider);
|
|
37046
|
-
}
|
|
37047
|
-
getProviderAtIndex(index) {
|
|
37048
|
-
if (index < 0 || index >= this._providers.length) {
|
|
37049
|
-
throw outOfBoundsError(index);
|
|
37050
|
-
}
|
|
37051
|
-
return this._providers[index];
|
|
37052
|
-
}
|
|
37053
|
-
/** @internal */
|
|
37054
|
-
_new(provider) {
|
|
37055
|
-
if (this._constructionCounter++ > this._getMaxNumberOfObjects()) {
|
|
37056
|
-
throw cyclicDependencyError(this, provider.key);
|
|
37057
|
-
}
|
|
37058
|
-
return this._instantiateProvider(provider);
|
|
37059
|
-
}
|
|
37060
|
-
_getMaxNumberOfObjects() {
|
|
37061
|
-
return this.objs.length;
|
|
37062
|
-
}
|
|
37063
|
-
_instantiateProvider(provider) {
|
|
37064
|
-
if (provider.multiProvider) {
|
|
37065
|
-
const res = [];
|
|
37066
|
-
for (let i = 0; i < provider.resolvedFactories.length; ++i) {
|
|
37067
|
-
res[i] = this._instantiate(provider, provider.resolvedFactories[i]);
|
|
37068
|
-
}
|
|
37069
|
-
return res;
|
|
37070
|
-
}
|
|
37071
|
-
else {
|
|
37072
|
-
return this._instantiate(provider, provider.resolvedFactories[0]);
|
|
37073
|
-
}
|
|
37074
|
-
}
|
|
37075
|
-
_instantiate(provider, ResolvedReflectiveFactory) {
|
|
37076
|
-
const factory = ResolvedReflectiveFactory.factory;
|
|
37077
|
-
let deps;
|
|
37078
|
-
try {
|
|
37079
|
-
deps =
|
|
37080
|
-
ResolvedReflectiveFactory.dependencies.map(dep => this._getByReflectiveDependency(dep));
|
|
37081
|
-
}
|
|
37082
|
-
catch (e) {
|
|
37083
|
-
if (e.addKey) {
|
|
37084
|
-
e.addKey(this, provider.key);
|
|
37085
|
-
}
|
|
37086
|
-
throw e;
|
|
37087
|
-
}
|
|
37088
|
-
let obj;
|
|
37089
|
-
try {
|
|
37090
|
-
obj = factory(...deps);
|
|
37091
|
-
}
|
|
37092
|
-
catch (e) {
|
|
37093
|
-
throw instantiationError(this, e, e.stack, provider.key);
|
|
37094
|
-
}
|
|
37095
|
-
return obj;
|
|
37096
|
-
}
|
|
37097
|
-
_getByReflectiveDependency(dep) {
|
|
37098
|
-
return this._getByKey(dep.key, dep.visibility, dep.optional ? null : THROW_IF_NOT_FOUND);
|
|
37099
|
-
}
|
|
37100
|
-
_getByKey(key, visibility, notFoundValue) {
|
|
37101
|
-
if (key === ReflectiveInjector_.INJECTOR_KEY) {
|
|
37102
|
-
return this;
|
|
37103
|
-
}
|
|
37104
|
-
if (visibility instanceof Self) {
|
|
37105
|
-
return this._getByKeySelf(key, notFoundValue);
|
|
37106
|
-
}
|
|
37107
|
-
else {
|
|
37108
|
-
return this._getByKeyDefault(key, notFoundValue, visibility);
|
|
37109
|
-
}
|
|
37110
|
-
}
|
|
37111
|
-
_getObjByKeyId(keyId) {
|
|
37112
|
-
for (let i = 0; i < this.keyIds.length; i++) {
|
|
37113
|
-
if (this.keyIds[i] === keyId) {
|
|
37114
|
-
if (this.objs[i] === UNDEFINED) {
|
|
37115
|
-
this.objs[i] = this._new(this._providers[i]);
|
|
37116
|
-
}
|
|
37117
|
-
return this.objs[i];
|
|
37118
|
-
}
|
|
37119
|
-
}
|
|
37120
|
-
return UNDEFINED;
|
|
37121
|
-
}
|
|
37122
|
-
/** @internal */
|
|
37123
|
-
_throwOrNull(key, notFoundValue) {
|
|
37124
|
-
if (notFoundValue !== THROW_IF_NOT_FOUND) {
|
|
37125
|
-
return notFoundValue;
|
|
37126
|
-
}
|
|
37127
|
-
else {
|
|
37128
|
-
throw noProviderError(this, key);
|
|
37129
|
-
}
|
|
37130
|
-
}
|
|
37131
|
-
/** @internal */
|
|
37132
|
-
_getByKeySelf(key, notFoundValue) {
|
|
37133
|
-
const obj = this._getObjByKeyId(key.id);
|
|
37134
|
-
return (obj !== UNDEFINED) ? obj : this._throwOrNull(key, notFoundValue);
|
|
37135
|
-
}
|
|
37136
|
-
/** @internal */
|
|
37137
|
-
_getByKeyDefault(key, notFoundValue, visibility) {
|
|
37138
|
-
let inj;
|
|
37139
|
-
if (visibility instanceof SkipSelf) {
|
|
37140
|
-
inj = this.parent;
|
|
37141
|
-
}
|
|
37142
|
-
else {
|
|
37143
|
-
inj = this;
|
|
37144
|
-
}
|
|
37145
|
-
while (inj instanceof ReflectiveInjector_) {
|
|
37146
|
-
const inj_ = inj;
|
|
37147
|
-
const obj = inj_._getObjByKeyId(key.id);
|
|
37148
|
-
if (obj !== UNDEFINED)
|
|
37149
|
-
return obj;
|
|
37150
|
-
inj = inj_.parent;
|
|
37151
|
-
}
|
|
37152
|
-
if (inj !== null) {
|
|
37153
|
-
return inj.get(key.token, notFoundValue);
|
|
37154
|
-
}
|
|
37155
|
-
else {
|
|
37156
|
-
return this._throwOrNull(key, notFoundValue);
|
|
37157
|
-
}
|
|
37158
|
-
}
|
|
37159
|
-
get displayName() {
|
|
37160
|
-
const providers = _mapProviders(this, (b) => ' "' + b.key.displayName + '" ')
|
|
37161
|
-
.join(', ');
|
|
37162
|
-
return `ReflectiveInjector(providers: [${providers}])`;
|
|
37163
|
-
}
|
|
37164
|
-
toString() {
|
|
37165
|
-
return this.displayName;
|
|
37166
|
-
}
|
|
37167
|
-
}
|
|
37168
|
-
ReflectiveInjector_.INJECTOR_KEY = ReflectiveKey.get(Injector);
|
|
37169
|
-
function _mapProviders(injector, fn) {
|
|
37170
|
-
const res = [];
|
|
37171
|
-
for (let i = 0; i < injector._providers.length; ++i) {
|
|
37172
|
-
res[i] = fn(injector.getProviderAtIndex(i));
|
|
37173
|
-
}
|
|
37174
|
-
return res;
|
|
37175
|
-
}
|
|
37176
|
-
|
|
37177
36313
|
/**
|
|
37178
36314
|
* @license
|
|
37179
36315
|
* Copyright Google LLC All Rights Reserved.
|
|
@@ -37397,7 +36533,7 @@ define(['exports', 'typescript/lib/tsserverlibrary', 'typescript', 'path'], func
|
|
|
37397
36533
|
*/
|
|
37398
36534
|
class ComponentFactoryResolver {
|
|
37399
36535
|
}
|
|
37400
|
-
ComponentFactoryResolver.NULL = new _NullComponentFactoryResolver();
|
|
36536
|
+
ComponentFactoryResolver.NULL = ( /* @__PURE__ */new _NullComponentFactoryResolver());
|
|
37401
36537
|
class ComponentFactoryBoundToModule extends ComponentFactory {
|
|
37402
36538
|
constructor(factory, ngModule) {
|
|
37403
36539
|
super();
|
|
@@ -37554,7 +36690,7 @@ define(['exports', 'typescript/lib/tsserverlibrary', 'typescript', 'path'], func
|
|
|
37554
36690
|
/**
|
|
37555
36691
|
* @publicApi
|
|
37556
36692
|
*/
|
|
37557
|
-
const VERSION$2 = new Version$1('12.2.
|
|
36693
|
+
const VERSION$2 = new Version$1('12.2.6');
|
|
37558
36694
|
|
|
37559
36695
|
/**
|
|
37560
36696
|
* @license
|