@angular/compiler-cli 14.0.0-next.9 → 14.0.0-rc.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bundles/{chunk-SNAJD4VP.js → chunk-53V6MPBS.js} +15 -4
- package/bundles/chunk-53V6MPBS.js.map +6 -0
- package/bundles/{chunk-FJDIFR5C.js → chunk-7XY4OMWJ.js} +70 -34
- package/bundles/chunk-7XY4OMWJ.js.map +6 -0
- package/bundles/{chunk-34QUU6SJ.js → chunk-BHGVN4MI.js} +64 -19
- package/bundles/chunk-BHGVN4MI.js.map +6 -0
- package/bundles/{chunk-GYVY4Y2L.js → chunk-GJVJ6GH4.js} +1056 -805
- package/bundles/chunk-GJVJ6GH4.js.map +6 -0
- package/bundles/{chunk-UMDDHI5B.js → chunk-JDKMNZ6O.js} +2 -1
- package/bundles/chunk-JDKMNZ6O.js.map +6 -0
- package/bundles/{chunk-AGDZS4UG.js → chunk-KPGMJT2X.js} +2 -2
- package/bundles/{chunk-AGDZS4UG.js.map → chunk-KPGMJT2X.js.map} +0 -0
- package/bundles/{chunk-M3IOYIU5.js → chunk-N6HUFHQ6.js} +962 -896
- package/bundles/chunk-N6HUFHQ6.js.map +6 -0
- package/bundles/index.js +5 -6
- package/bundles/index.js.map +1 -1
- package/bundles/linker/babel/index.js +2 -2
- package/bundles/linker/index.js +2 -2
- package/bundles/ngcc/index.js +5 -5
- package/bundles/ngcc/main-ngcc.js +5 -5
- package/bundles/ngcc/src/execution/cluster/ngcc_cluster_worker.js +4 -4
- package/bundles/private/migrations.js +2 -2
- package/bundles/src/bin/ng_xi18n.js +4 -4
- package/bundles/src/bin/ngc.js +4 -4
- package/bundles_metadata.json +1 -1
- package/ngcc/src/dependencies/module_resolver.d.ts +5 -2
- package/ngcc/src/execution/cluster/api.d.ts +1 -1
- package/ngcc/src/execution/cluster/package_json_updater.d.ts +1 -1
- package/ngcc/src/execution/tasks/api.d.ts +2 -2
- package/ngcc/src/packages/build_marker.d.ts +1 -1
- package/ngcc/src/packages/entry_point.d.ts +1 -7
- package/ngcc/src/utils.d.ts +26 -0
- package/ngcc/src/writing/package_json_updater.d.ts +2 -1
- package/package.json +4 -4
- package/src/ngtsc/annotations/common/index.d.ts +1 -0
- package/src/ngtsc/annotations/common/src/schema.d.ts +12 -0
- package/src/ngtsc/annotations/common/src/util.d.ts +1 -1
- package/src/ngtsc/annotations/component/src/metadata.d.ts +7 -8
- package/src/ngtsc/annotations/component/src/resources.d.ts +1 -1
- package/src/ngtsc/annotations/ng_module/src/handler.d.ts +10 -7
- package/src/ngtsc/core/api/src/adapter.d.ts +12 -1
- package/src/ngtsc/core/src/host.d.ts +9 -2
- package/src/ngtsc/diagnostics/src/error_code.d.ts +4 -0
- package/src/ngtsc/metadata/src/api.d.ts +32 -5
- package/src/ngtsc/metadata/src/util.d.ts +1 -0
- package/src/ngtsc/partial_evaluator/index.d.ts +1 -0
- package/src/ngtsc/partial_evaluator/src/dynamic.d.ts +9 -1
- package/src/ngtsc/partial_evaluator/src/interface.d.ts +2 -1
- package/src/ngtsc/partial_evaluator/src/result.d.ts +2 -1
- package/src/ngtsc/partial_evaluator/src/synthetic.d.ts +19 -0
- package/src/ngtsc/program_driver/src/ts_create_program_driver.d.ts +2 -2
- package/src/ngtsc/scope/index.d.ts +4 -3
- package/src/ngtsc/scope/src/api.d.ts +36 -14
- package/src/ngtsc/scope/src/component_scope.d.ts +2 -16
- package/src/ngtsc/scope/src/local.d.ts +4 -11
- package/src/ngtsc/scope/src/standalone.d.ts +26 -0
- package/src/ngtsc/scope/src/typecheck.d.ts +1 -1
- package/src/ngtsc/scope/src/util.d.ts +15 -0
- package/src/ngtsc/transform/src/compilation.d.ts +3 -1
- package/src/ngtsc/typecheck/api/checker.d.ts +6 -6
- package/src/ngtsc/typecheck/api/completion.d.ts +3 -3
- package/src/ngtsc/typecheck/api/symbols.d.ts +23 -16
- package/src/ngtsc/typecheck/src/checker.d.ts +5 -4
- package/src/ngtsc/typecheck/src/completion.d.ts +6 -5
- package/src/ngtsc/typecheck/src/template_symbol_builder.d.ts +4 -3
- package/src/ngtsc/typecheck/src/ts_util.d.ts +7 -0
- package/bundles/chunk-34QUU6SJ.js.map +0 -6
- package/bundles/chunk-FJDIFR5C.js.map +0 -6
- package/bundles/chunk-GYVY4Y2L.js.map +0 -6
- package/bundles/chunk-M3IOYIU5.js.map +0 -6
- package/bundles/chunk-SNAJD4VP.js.map +0 -6
- package/bundles/chunk-UMDDHI5B.js.map +0 -6
- package/src/ngtsc/annotations/component/src/scope.d.ts +0 -20
|
@@ -26,19 +26,17 @@ import {
|
|
|
26
26
|
getSourceFile,
|
|
27
27
|
identifierOfNode,
|
|
28
28
|
isDeclaration,
|
|
29
|
-
isDtsPath,
|
|
30
|
-
isNonDeclarationTsPath,
|
|
31
29
|
makeDiagnostic,
|
|
32
30
|
makeRelatedInformation,
|
|
33
31
|
nodeDebugInfo,
|
|
32
|
+
nodeNameForError,
|
|
34
33
|
translateExpression,
|
|
35
34
|
translateStatement,
|
|
36
35
|
translateType
|
|
37
|
-
} from "./chunk-
|
|
36
|
+
} from "./chunk-JDKMNZ6O.js";
|
|
38
37
|
import {
|
|
39
38
|
absoluteFrom,
|
|
40
39
|
absoluteFromSourceFile,
|
|
41
|
-
basename,
|
|
42
40
|
relative
|
|
43
41
|
} from "./chunk-T7MYRXIE.js";
|
|
44
42
|
import {
|
|
@@ -143,21 +141,26 @@ function tryUnwrapForwardRef(node, reflector) {
|
|
|
143
141
|
}
|
|
144
142
|
return expr;
|
|
145
143
|
}
|
|
146
|
-
|
|
147
|
-
if (!isAngularCoreReference(
|
|
148
|
-
return
|
|
144
|
+
var forwardRefResolver = (fn, callExpr, resolve, unresolvable) => {
|
|
145
|
+
if (!isAngularCoreReference(fn, "forwardRef") || callExpr.arguments.length !== 1) {
|
|
146
|
+
return unresolvable;
|
|
149
147
|
}
|
|
150
|
-
|
|
151
|
-
|
|
148
|
+
const expanded = expandForwardRef(callExpr.arguments[0]);
|
|
149
|
+
if (expanded !== null) {
|
|
150
|
+
return resolve(expanded);
|
|
151
|
+
} else {
|
|
152
|
+
return unresolvable;
|
|
153
|
+
}
|
|
154
|
+
};
|
|
152
155
|
function combineResolvers(resolvers) {
|
|
153
|
-
return (
|
|
156
|
+
return (fn, callExpr, resolve, unresolvable) => {
|
|
154
157
|
for (const resolver of resolvers) {
|
|
155
|
-
const resolved = resolver(
|
|
156
|
-
if (resolved !==
|
|
158
|
+
const resolved = resolver(fn, callExpr, resolve, unresolvable);
|
|
159
|
+
if (resolved !== unresolvable) {
|
|
157
160
|
return resolved;
|
|
158
161
|
}
|
|
159
162
|
}
|
|
160
|
-
return
|
|
163
|
+
return unresolvable;
|
|
161
164
|
};
|
|
162
165
|
}
|
|
163
166
|
function isExpressionForwardReference(expr, context, contextSource) {
|
|
@@ -303,8 +306,11 @@ var DynamicValue = class {
|
|
|
303
306
|
static fromDynamicType(node) {
|
|
304
307
|
return new DynamicValue(node, void 0, 7);
|
|
305
308
|
}
|
|
309
|
+
static fromSyntheticInput(node, value) {
|
|
310
|
+
return new DynamicValue(node, value, 8);
|
|
311
|
+
}
|
|
306
312
|
static fromUnknown(node) {
|
|
307
|
-
return new DynamicValue(node, void 0,
|
|
313
|
+
return new DynamicValue(node, void 0, 9);
|
|
308
314
|
}
|
|
309
315
|
isFromDynamicInput() {
|
|
310
316
|
return this.code === 0;
|
|
@@ -331,7 +337,7 @@ var DynamicValue = class {
|
|
|
331
337
|
return this.code === 7;
|
|
332
338
|
}
|
|
333
339
|
isFromUnknown() {
|
|
334
|
-
return this.code ===
|
|
340
|
+
return this.code === 9;
|
|
335
341
|
}
|
|
336
342
|
accept(visitor) {
|
|
337
343
|
switch (this.code) {
|
|
@@ -352,6 +358,8 @@ var DynamicValue = class {
|
|
|
352
358
|
case 7:
|
|
353
359
|
return visitor.visitDynamicType(this);
|
|
354
360
|
case 8:
|
|
361
|
+
return visitor.visitSyntheticInput(this);
|
|
362
|
+
case 9:
|
|
355
363
|
return visitor.visitUnknown(this);
|
|
356
364
|
}
|
|
357
365
|
}
|
|
@@ -538,6 +546,13 @@ function resolveKnownDeclaration(decl) {
|
|
|
538
546
|
}
|
|
539
547
|
}
|
|
540
548
|
|
|
549
|
+
// bazel-out/k8-fastbuild/bin/packages/compiler-cli/src/ngtsc/partial_evaluator/src/synthetic.mjs
|
|
550
|
+
var SyntheticValue = class {
|
|
551
|
+
constructor(value) {
|
|
552
|
+
this.value = value;
|
|
553
|
+
}
|
|
554
|
+
};
|
|
555
|
+
|
|
541
556
|
// bazel-out/k8-fastbuild/bin/packages/compiler-cli/src/ngtsc/partial_evaluator/src/interpreter.mjs
|
|
542
557
|
function literalBinaryOp(op) {
|
|
543
558
|
return { op, literal: true };
|
|
@@ -853,6 +868,8 @@ var StaticInterpreter = class {
|
|
|
853
868
|
}
|
|
854
869
|
} else if (lhs instanceof DynamicValue) {
|
|
855
870
|
return DynamicValue.fromDynamicInput(node, lhs);
|
|
871
|
+
} else if (lhs instanceof SyntheticValue) {
|
|
872
|
+
return DynamicValue.fromSyntheticInput(node, lhs);
|
|
856
873
|
}
|
|
857
874
|
return DynamicValue.fromUnknown(node);
|
|
858
875
|
}
|
|
@@ -874,31 +891,24 @@ var StaticInterpreter = class {
|
|
|
874
891
|
if (!isFunctionOrMethodReference(lhs)) {
|
|
875
892
|
return DynamicValue.fromInvalidExpressionType(node.expression, lhs);
|
|
876
893
|
}
|
|
877
|
-
|
|
878
|
-
let
|
|
879
|
-
if (
|
|
880
|
-
|
|
881
|
-
}
|
|
882
|
-
if (expr === null) {
|
|
883
|
-
return DynamicValue.fromDynamicInput(node, DynamicValue.fromExternalReference(node.expression, lhs));
|
|
884
|
-
}
|
|
885
|
-
if (expr.getSourceFile() !== node.expression.getSourceFile() && lhs.bestGuessOwningModule !== null) {
|
|
886
|
-
context = __spreadProps(__spreadValues({}, context), {
|
|
894
|
+
const resolveFfrExpr = (expr) => {
|
|
895
|
+
let contextExtension = {};
|
|
896
|
+
if (fn.body === null && expr.getSourceFile() !== node.expression.getSourceFile() && lhs.bestGuessOwningModule !== null) {
|
|
897
|
+
contextExtension = {
|
|
887
898
|
absoluteModuleName: lhs.bestGuessOwningModule.specifier,
|
|
888
899
|
resolutionContext: lhs.bestGuessOwningModule.resolutionContext
|
|
889
|
-
}
|
|
900
|
+
};
|
|
890
901
|
}
|
|
891
|
-
return this.visitFfrExpression(expr, context);
|
|
902
|
+
return this.visitFfrExpression(expr, __spreadValues(__spreadValues({}, context), contextExtension));
|
|
903
|
+
};
|
|
904
|
+
if (fn.body === null && context.foreignFunctionResolver !== void 0) {
|
|
905
|
+
const unresolvable = DynamicValue.fromDynamicInput(node, DynamicValue.fromExternalReference(node.expression, lhs));
|
|
906
|
+
return context.foreignFunctionResolver(lhs, node, resolveFfrExpr, unresolvable);
|
|
892
907
|
}
|
|
893
|
-
|
|
908
|
+
const res = this.visitFunctionBody(node, fn, context);
|
|
894
909
|
if (res instanceof DynamicValue && context.foreignFunctionResolver !== void 0) {
|
|
895
|
-
const
|
|
896
|
-
|
|
897
|
-
const ffrRes = this.visitFfrExpression(ffrExpr, context);
|
|
898
|
-
if (!(ffrRes instanceof DynamicValue)) {
|
|
899
|
-
res = ffrRes;
|
|
900
|
-
}
|
|
901
|
-
}
|
|
910
|
+
const unresolvable = DynamicValue.fromComplexFunctionCall(node, fn);
|
|
911
|
+
return context.foreignFunctionResolver(lhs, node, resolveFfrExpr, unresolvable);
|
|
902
912
|
}
|
|
903
913
|
return res;
|
|
904
914
|
}
|
|
@@ -1205,6 +1215,9 @@ var TraceDynamicValueVisitor = class {
|
|
|
1205
1215
|
}
|
|
1206
1216
|
return trace;
|
|
1207
1217
|
}
|
|
1218
|
+
visitSyntheticInput(value) {
|
|
1219
|
+
return [makeRelatedInformation(value.node, "Unable to evaluate this expression further.")];
|
|
1220
|
+
}
|
|
1208
1221
|
visitDynamicString(value) {
|
|
1209
1222
|
return [makeRelatedInformation(value.node, "A string value could not be determined statically.")];
|
|
1210
1223
|
}
|
|
@@ -1662,9 +1675,39 @@ var NoopReferencesRegistry = class {
|
|
|
1662
1675
|
}
|
|
1663
1676
|
};
|
|
1664
1677
|
|
|
1678
|
+
// bazel-out/k8-fastbuild/bin/packages/compiler-cli/src/ngtsc/annotations/common/src/schema.mjs
|
|
1679
|
+
import { CUSTOM_ELEMENTS_SCHEMA, NO_ERRORS_SCHEMA } from "@angular/compiler";
|
|
1680
|
+
function extractSchemas(rawExpr, evaluator, context) {
|
|
1681
|
+
const schemas = [];
|
|
1682
|
+
const result = evaluator.evaluate(rawExpr);
|
|
1683
|
+
if (!Array.isArray(result)) {
|
|
1684
|
+
throw createValueHasWrongTypeError(rawExpr, result, `${context}.schemas must be an array`);
|
|
1685
|
+
}
|
|
1686
|
+
for (const schemaRef of result) {
|
|
1687
|
+
if (!(schemaRef instanceof Reference)) {
|
|
1688
|
+
throw createValueHasWrongTypeError(rawExpr, result, `${context}.schemas must be an array of schemas`);
|
|
1689
|
+
}
|
|
1690
|
+
const id = schemaRef.getIdentityIn(schemaRef.node.getSourceFile());
|
|
1691
|
+
if (id === null || schemaRef.ownedByModuleGuess !== "@angular/core") {
|
|
1692
|
+
throw createValueHasWrongTypeError(rawExpr, result, `${context}.schemas must be an array of schemas`);
|
|
1693
|
+
}
|
|
1694
|
+
switch (id.text) {
|
|
1695
|
+
case "CUSTOM_ELEMENTS_SCHEMA":
|
|
1696
|
+
schemas.push(CUSTOM_ELEMENTS_SCHEMA);
|
|
1697
|
+
break;
|
|
1698
|
+
case "NO_ERRORS_SCHEMA":
|
|
1699
|
+
schemas.push(NO_ERRORS_SCHEMA);
|
|
1700
|
+
break;
|
|
1701
|
+
default:
|
|
1702
|
+
throw createValueHasWrongTypeError(rawExpr, schemaRef, `'${schemaRef.debugName}' is not a valid ${context} schema`);
|
|
1703
|
+
}
|
|
1704
|
+
}
|
|
1705
|
+
return schemas;
|
|
1706
|
+
}
|
|
1707
|
+
|
|
1665
1708
|
// bazel-out/k8-fastbuild/bin/packages/compiler-cli/src/ngtsc/annotations/component/src/handler.mjs
|
|
1666
|
-
import { compileClassMetadata as compileClassMetadata3, compileComponentFromMetadata, compileDeclareClassMetadata as compileDeclareClassMetadata3, compileDeclareComponentFromMetadata, CssSelector, DEFAULT_INTERPOLATION_CONFIG as DEFAULT_INTERPOLATION_CONFIG2, DomElementSchemaRegistry, FactoryTarget as FactoryTarget3, makeBindingParser as makeBindingParser2, R3TargetBinder, SelectorMatcher, ViewEncapsulation, WrappedNodeExpr as WrappedNodeExpr7 } from "@angular/compiler";
|
|
1667
|
-
import
|
|
1709
|
+
import { compileClassMetadata as compileClassMetadata3, compileComponentFromMetadata, compileDeclareClassMetadata as compileDeclareClassMetadata3, compileDeclareComponentFromMetadata, CssSelector as CssSelector2, DEFAULT_INTERPOLATION_CONFIG as DEFAULT_INTERPOLATION_CONFIG2, DomElementSchemaRegistry, FactoryTarget as FactoryTarget3, makeBindingParser as makeBindingParser2, R3TargetBinder, R3TemplateDependencyKind, SelectorMatcher as SelectorMatcher2, ViewEncapsulation, WrappedNodeExpr as WrappedNodeExpr7 } from "@angular/compiler";
|
|
1710
|
+
import ts23 from "typescript";
|
|
1668
1711
|
|
|
1669
1712
|
// bazel-out/k8-fastbuild/bin/packages/compiler-cli/src/ngtsc/incremental/semantic_graph/src/api.mjs
|
|
1670
1713
|
import ts8 from "typescript";
|
|
@@ -1899,11 +1942,12 @@ function isTypeParameterEqual(a, b) {
|
|
|
1899
1942
|
}
|
|
1900
1943
|
|
|
1901
1944
|
// bazel-out/k8-fastbuild/bin/packages/compiler-cli/src/ngtsc/metadata/src/api.mjs
|
|
1902
|
-
var
|
|
1903
|
-
(function(
|
|
1904
|
-
|
|
1905
|
-
|
|
1906
|
-
|
|
1945
|
+
var MetaKind;
|
|
1946
|
+
(function(MetaKind2) {
|
|
1947
|
+
MetaKind2[MetaKind2["Directive"] = 0] = "Directive";
|
|
1948
|
+
MetaKind2[MetaKind2["Pipe"] = 1] = "Pipe";
|
|
1949
|
+
MetaKind2[MetaKind2["NgModule"] = 2] = "NgModule";
|
|
1950
|
+
})(MetaKind || (MetaKind = {}));
|
|
1907
1951
|
|
|
1908
1952
|
// bazel-out/k8-fastbuild/bin/packages/compiler-cli/src/ngtsc/metadata/src/dts.mjs
|
|
1909
1953
|
import ts11 from "typescript";
|
|
@@ -2006,6 +2050,19 @@ function extractReferencesFromType(checker, def, bestGuessOwningModule) {
|
|
|
2006
2050
|
}
|
|
2007
2051
|
});
|
|
2008
2052
|
}
|
|
2053
|
+
function readBooleanType(type) {
|
|
2054
|
+
if (!ts10.isLiteralTypeNode(type)) {
|
|
2055
|
+
return null;
|
|
2056
|
+
}
|
|
2057
|
+
switch (type.literal.kind) {
|
|
2058
|
+
case ts10.SyntaxKind.TrueKeyword:
|
|
2059
|
+
return true;
|
|
2060
|
+
case ts10.SyntaxKind.FalseKeyword:
|
|
2061
|
+
return false;
|
|
2062
|
+
default:
|
|
2063
|
+
return null;
|
|
2064
|
+
}
|
|
2065
|
+
}
|
|
2009
2066
|
function readStringType(type) {
|
|
2010
2067
|
if (!ts10.isLiteralTypeNode(type) || !ts10.isStringLiteral(type.literal)) {
|
|
2011
2068
|
return null;
|
|
@@ -2167,15 +2224,19 @@ var DtsMetadataReader = class {
|
|
|
2167
2224
|
}
|
|
2168
2225
|
const [_, declarationMetadata, importMetadata, exportMetadata] = ngModuleDef.type.typeArguments;
|
|
2169
2226
|
return {
|
|
2227
|
+
kind: MetaKind.NgModule,
|
|
2170
2228
|
ref,
|
|
2171
2229
|
declarations: extractReferencesFromType(this.checker, declarationMetadata, ref.bestGuessOwningModule),
|
|
2172
2230
|
exports: extractReferencesFromType(this.checker, exportMetadata, ref.bestGuessOwningModule),
|
|
2173
2231
|
imports: extractReferencesFromType(this.checker, importMetadata, ref.bestGuessOwningModule),
|
|
2174
2232
|
schemas: [],
|
|
2175
|
-
rawDeclarations: null
|
|
2233
|
+
rawDeclarations: null,
|
|
2234
|
+
rawImports: null,
|
|
2235
|
+
rawExports: null
|
|
2176
2236
|
};
|
|
2177
2237
|
}
|
|
2178
2238
|
getDirectiveMetadata(ref) {
|
|
2239
|
+
var _a;
|
|
2179
2240
|
const clazz = ref.node;
|
|
2180
2241
|
const def = this.reflector.getMembersOfClass(clazz).find((field) => field.isStatic && (field.name === "\u0275cmp" || field.name === "\u0275dir"));
|
|
2181
2242
|
if (def === void 0) {
|
|
@@ -2188,10 +2249,11 @@ var DtsMetadataReader = class {
|
|
|
2188
2249
|
const isStructural = !isComponent && ctorParams !== null && ctorParams.some((param) => {
|
|
2189
2250
|
return param.typeValueReference.kind === 1 && param.typeValueReference.moduleName === "@angular/core" && param.typeValueReference.importedName === "TemplateRef";
|
|
2190
2251
|
});
|
|
2252
|
+
const isStandalone = def.type.typeArguments.length > 7 && ((_a = readBooleanType(def.type.typeArguments[7])) != null ? _a : false);
|
|
2191
2253
|
const inputs = ClassPropertyMapping.fromMappedObject(readStringMapType(def.type.typeArguments[3]));
|
|
2192
2254
|
const outputs = ClassPropertyMapping.fromMappedObject(readStringMapType(def.type.typeArguments[4]));
|
|
2193
2255
|
return __spreadProps(__spreadValues({
|
|
2194
|
-
|
|
2256
|
+
kind: MetaKind.Directive,
|
|
2195
2257
|
ref,
|
|
2196
2258
|
name: clazz.name.text,
|
|
2197
2259
|
isComponent,
|
|
@@ -2205,10 +2267,13 @@ var DtsMetadataReader = class {
|
|
|
2205
2267
|
isPoisoned: false,
|
|
2206
2268
|
isStructural,
|
|
2207
2269
|
animationTriggerNames: null,
|
|
2208
|
-
isStandalone
|
|
2270
|
+
isStandalone,
|
|
2271
|
+
imports: null,
|
|
2272
|
+
schemas: null
|
|
2209
2273
|
});
|
|
2210
2274
|
}
|
|
2211
2275
|
getPipeMetadata(ref) {
|
|
2276
|
+
var _a;
|
|
2212
2277
|
const def = this.reflector.getMembersOfClass(ref.node).find((field) => field.isStatic && field.name === "\u0275pipe");
|
|
2213
2278
|
if (def === void 0) {
|
|
2214
2279
|
return null;
|
|
@@ -2220,12 +2285,13 @@ var DtsMetadataReader = class {
|
|
|
2220
2285
|
return null;
|
|
2221
2286
|
}
|
|
2222
2287
|
const name = type.literal.text;
|
|
2288
|
+
const isStandalone = def.type.typeArguments.length > 2 && ((_a = readBooleanType(def.type.typeArguments[2])) != null ? _a : false);
|
|
2223
2289
|
return {
|
|
2224
|
-
|
|
2290
|
+
kind: MetaKind.Pipe,
|
|
2225
2291
|
ref,
|
|
2226
2292
|
name,
|
|
2227
2293
|
nameExpr: null,
|
|
2228
|
-
isStandalone
|
|
2294
|
+
isStandalone
|
|
2229
2295
|
};
|
|
2230
2296
|
}
|
|
2231
2297
|
};
|
|
@@ -2435,441 +2501,583 @@ var ResourceRegistry = class {
|
|
|
2435
2501
|
}
|
|
2436
2502
|
};
|
|
2437
2503
|
|
|
2438
|
-
// bazel-out/k8-fastbuild/bin/packages/compiler-cli/src/ngtsc/
|
|
2439
|
-
var
|
|
2440
|
-
(function(
|
|
2441
|
-
|
|
2442
|
-
|
|
2443
|
-
})(
|
|
2444
|
-
var HandlerPrecedence;
|
|
2445
|
-
(function(HandlerPrecedence2) {
|
|
2446
|
-
HandlerPrecedence2[HandlerPrecedence2["PRIMARY"] = 0] = "PRIMARY";
|
|
2447
|
-
HandlerPrecedence2[HandlerPrecedence2["SHARED"] = 1] = "SHARED";
|
|
2448
|
-
HandlerPrecedence2[HandlerPrecedence2["WEAK"] = 2] = "WEAK";
|
|
2449
|
-
})(HandlerPrecedence || (HandlerPrecedence = {}));
|
|
2450
|
-
var HandlerFlags;
|
|
2451
|
-
(function(HandlerFlags2) {
|
|
2452
|
-
HandlerFlags2[HandlerFlags2["NONE"] = 0] = "NONE";
|
|
2453
|
-
HandlerFlags2[HandlerFlags2["FULL_INHERITANCE"] = 1] = "FULL_INHERITANCE";
|
|
2454
|
-
})(HandlerFlags || (HandlerFlags = {}));
|
|
2455
|
-
|
|
2456
|
-
// bazel-out/k8-fastbuild/bin/packages/compiler-cli/src/ngtsc/transform/src/alias.mjs
|
|
2457
|
-
import ts12 from "typescript";
|
|
2458
|
-
function aliasTransformFactory(exportStatements) {
|
|
2459
|
-
return (context) => {
|
|
2460
|
-
return (file) => {
|
|
2461
|
-
if (ts12.isBundle(file) || !exportStatements.has(file.fileName)) {
|
|
2462
|
-
return file;
|
|
2463
|
-
}
|
|
2464
|
-
const statements = [...file.statements];
|
|
2465
|
-
exportStatements.get(file.fileName).forEach(([moduleName, symbolName], aliasName) => {
|
|
2466
|
-
const stmt = ts12.factory.createExportDeclaration(void 0, void 0, false, ts12.createNamedExports([ts12.factory.createExportSpecifier(false, symbolName, aliasName)]), ts12.factory.createStringLiteral(moduleName));
|
|
2467
|
-
statements.push(stmt);
|
|
2468
|
-
});
|
|
2469
|
-
return ts12.factory.updateSourceFile(file, statements);
|
|
2470
|
-
};
|
|
2471
|
-
};
|
|
2472
|
-
}
|
|
2473
|
-
|
|
2474
|
-
// bazel-out/k8-fastbuild/bin/packages/compiler-cli/src/ngtsc/transform/src/compilation.mjs
|
|
2475
|
-
import ts16 from "typescript";
|
|
2476
|
-
|
|
2477
|
-
// bazel-out/k8-fastbuild/bin/packages/compiler-cli/src/ngtsc/shims/src/adapter.mjs
|
|
2478
|
-
import ts13 from "typescript";
|
|
2504
|
+
// bazel-out/k8-fastbuild/bin/packages/compiler-cli/src/ngtsc/scope/src/api.mjs
|
|
2505
|
+
var ComponentScopeKind;
|
|
2506
|
+
(function(ComponentScopeKind2) {
|
|
2507
|
+
ComponentScopeKind2[ComponentScopeKind2["NgModule"] = 0] = "NgModule";
|
|
2508
|
+
ComponentScopeKind2[ComponentScopeKind2["Standalone"] = 1] = "Standalone";
|
|
2509
|
+
})(ComponentScopeKind || (ComponentScopeKind = {}));
|
|
2479
2510
|
|
|
2480
|
-
// bazel-out/k8-fastbuild/bin/packages/compiler-cli/src/ngtsc/
|
|
2481
|
-
var
|
|
2482
|
-
|
|
2483
|
-
|
|
2484
|
-
}
|
|
2485
|
-
function sfExtensionData(sf) {
|
|
2486
|
-
const extSf = sf;
|
|
2487
|
-
if (extSf[NgExtension] !== void 0) {
|
|
2488
|
-
return extSf[NgExtension];
|
|
2489
|
-
}
|
|
2490
|
-
const extension = {
|
|
2491
|
-
isTopLevelShim: false,
|
|
2492
|
-
fileShim: null,
|
|
2493
|
-
originalReferencedFiles: null,
|
|
2494
|
-
taggedReferenceFiles: null
|
|
2495
|
-
};
|
|
2496
|
-
extSf[NgExtension] = extension;
|
|
2497
|
-
return extension;
|
|
2498
|
-
}
|
|
2499
|
-
function isFileShimSourceFile(sf) {
|
|
2500
|
-
return isExtended(sf) && sf[NgExtension].fileShim !== null;
|
|
2501
|
-
}
|
|
2502
|
-
function isShim(sf) {
|
|
2503
|
-
return isExtended(sf) && (sf[NgExtension].fileShim !== null || sf[NgExtension].isTopLevelShim);
|
|
2504
|
-
}
|
|
2505
|
-
function copyFileShimData(from, to) {
|
|
2506
|
-
if (!isFileShimSourceFile(from)) {
|
|
2507
|
-
return;
|
|
2508
|
-
}
|
|
2509
|
-
sfExtensionData(to).fileShim = sfExtensionData(from).fileShim;
|
|
2510
|
-
}
|
|
2511
|
-
function untagAllTsFiles(program) {
|
|
2512
|
-
for (const sf of program.getSourceFiles()) {
|
|
2513
|
-
untagTsFile(sf);
|
|
2514
|
-
}
|
|
2515
|
-
}
|
|
2516
|
-
function retagAllTsFiles(program) {
|
|
2517
|
-
for (const sf of program.getSourceFiles()) {
|
|
2518
|
-
retagTsFile(sf);
|
|
2519
|
-
}
|
|
2520
|
-
}
|
|
2521
|
-
function untagTsFile(sf) {
|
|
2522
|
-
if (sf.isDeclarationFile || !isExtended(sf)) {
|
|
2523
|
-
return;
|
|
2524
|
-
}
|
|
2525
|
-
const ext = sfExtensionData(sf);
|
|
2526
|
-
if (ext.originalReferencedFiles !== null) {
|
|
2527
|
-
sf.referencedFiles = ext.originalReferencedFiles;
|
|
2528
|
-
}
|
|
2529
|
-
}
|
|
2530
|
-
function retagTsFile(sf) {
|
|
2531
|
-
if (sf.isDeclarationFile || !isExtended(sf)) {
|
|
2532
|
-
return;
|
|
2533
|
-
}
|
|
2534
|
-
const ext = sfExtensionData(sf);
|
|
2535
|
-
if (ext.taggedReferenceFiles !== null) {
|
|
2536
|
-
sf.referencedFiles = ext.taggedReferenceFiles;
|
|
2537
|
-
}
|
|
2538
|
-
}
|
|
2539
|
-
|
|
2540
|
-
// bazel-out/k8-fastbuild/bin/packages/compiler-cli/src/ngtsc/shims/src/util.mjs
|
|
2541
|
-
var TS_EXTENSIONS = /\.tsx?$/i;
|
|
2542
|
-
function makeShimFileName(fileName, suffix) {
|
|
2543
|
-
return absoluteFrom(fileName.replace(TS_EXTENSIONS, suffix));
|
|
2544
|
-
}
|
|
2545
|
-
function generatedModuleName(originalModuleName, originalFileName, genSuffix) {
|
|
2546
|
-
let moduleName;
|
|
2547
|
-
if (originalFileName.endsWith("/index.ts")) {
|
|
2548
|
-
moduleName = originalModuleName + "/index" + genSuffix;
|
|
2549
|
-
} else {
|
|
2550
|
-
moduleName = originalModuleName + genSuffix;
|
|
2511
|
+
// bazel-out/k8-fastbuild/bin/packages/compiler-cli/src/ngtsc/scope/src/component_scope.mjs
|
|
2512
|
+
var CompoundComponentScopeReader = class {
|
|
2513
|
+
constructor(readers) {
|
|
2514
|
+
this.readers = readers;
|
|
2551
2515
|
}
|
|
2552
|
-
|
|
2553
|
-
|
|
2554
|
-
|
|
2555
|
-
|
|
2556
|
-
|
|
2557
|
-
constructor(delegate, tsRootFiles, topLevelGenerators, perFileGenerators, oldProgram) {
|
|
2558
|
-
this.delegate = delegate;
|
|
2559
|
-
this.shims = /* @__PURE__ */ new Map();
|
|
2560
|
-
this.priorShims = /* @__PURE__ */ new Map();
|
|
2561
|
-
this.notShims = /* @__PURE__ */ new Set();
|
|
2562
|
-
this.generators = [];
|
|
2563
|
-
this.ignoreForEmit = /* @__PURE__ */ new Set();
|
|
2564
|
-
this.extensionPrefixes = [];
|
|
2565
|
-
for (const gen of perFileGenerators) {
|
|
2566
|
-
const pattern = `^(.*)\\.${gen.extensionPrefix}\\.ts$`;
|
|
2567
|
-
const regexp = new RegExp(pattern, "i");
|
|
2568
|
-
this.generators.push({
|
|
2569
|
-
generator: gen,
|
|
2570
|
-
test: regexp,
|
|
2571
|
-
suffix: `.${gen.extensionPrefix}.ts`
|
|
2572
|
-
});
|
|
2573
|
-
this.extensionPrefixes.push(gen.extensionPrefix);
|
|
2574
|
-
}
|
|
2575
|
-
const extraInputFiles = [];
|
|
2576
|
-
for (const gen of topLevelGenerators) {
|
|
2577
|
-
const sf = gen.makeTopLevelShim();
|
|
2578
|
-
sfExtensionData(sf).isTopLevelShim = true;
|
|
2579
|
-
if (!gen.shouldEmit) {
|
|
2580
|
-
this.ignoreForEmit.add(sf);
|
|
2581
|
-
}
|
|
2582
|
-
const fileName = absoluteFromSourceFile(sf);
|
|
2583
|
-
this.shims.set(fileName, sf);
|
|
2584
|
-
extraInputFiles.push(fileName);
|
|
2585
|
-
}
|
|
2586
|
-
for (const rootFile of tsRootFiles) {
|
|
2587
|
-
for (const gen of this.generators) {
|
|
2588
|
-
extraInputFiles.push(makeShimFileName(rootFile, gen.suffix));
|
|
2516
|
+
getScopeForComponent(clazz) {
|
|
2517
|
+
for (const reader of this.readers) {
|
|
2518
|
+
const meta = reader.getScopeForComponent(clazz);
|
|
2519
|
+
if (meta !== null) {
|
|
2520
|
+
return meta;
|
|
2589
2521
|
}
|
|
2590
2522
|
}
|
|
2591
|
-
|
|
2592
|
-
|
|
2593
|
-
|
|
2594
|
-
|
|
2595
|
-
|
|
2596
|
-
|
|
2597
|
-
|
|
2523
|
+
return null;
|
|
2524
|
+
}
|
|
2525
|
+
getRemoteScope(clazz) {
|
|
2526
|
+
for (const reader of this.readers) {
|
|
2527
|
+
const remoteScope = reader.getRemoteScope(clazz);
|
|
2528
|
+
if (remoteScope !== null) {
|
|
2529
|
+
return remoteScope;
|
|
2598
2530
|
}
|
|
2599
2531
|
}
|
|
2532
|
+
return null;
|
|
2600
2533
|
}
|
|
2601
|
-
|
|
2602
|
-
|
|
2603
|
-
|
|
2604
|
-
|
|
2605
|
-
|
|
2534
|
+
};
|
|
2535
|
+
|
|
2536
|
+
// bazel-out/k8-fastbuild/bin/packages/compiler-cli/src/ngtsc/scope/src/dependency.mjs
|
|
2537
|
+
var MetadataDtsModuleScopeResolver = class {
|
|
2538
|
+
constructor(dtsMetaReader, aliasingHost) {
|
|
2539
|
+
this.dtsMetaReader = dtsMetaReader;
|
|
2540
|
+
this.aliasingHost = aliasingHost;
|
|
2541
|
+
this.cache = /* @__PURE__ */ new Map();
|
|
2542
|
+
}
|
|
2543
|
+
resolve(ref) {
|
|
2544
|
+
const clazz = ref.node;
|
|
2545
|
+
const sourceFile = clazz.getSourceFile();
|
|
2546
|
+
if (!sourceFile.isDeclarationFile) {
|
|
2547
|
+
throw new Error(`Debug error: DtsModuleScopeResolver.read(${ref.debugName} from ${sourceFile.fileName}), but not a .d.ts file`);
|
|
2548
|
+
}
|
|
2549
|
+
if (this.cache.has(clazz)) {
|
|
2550
|
+
return this.cache.get(clazz);
|
|
2606
2551
|
}
|
|
2607
|
-
|
|
2608
|
-
|
|
2552
|
+
const dependencies = [];
|
|
2553
|
+
const meta = this.dtsMetaReader.getNgModuleMetadata(ref);
|
|
2554
|
+
if (meta === null) {
|
|
2555
|
+
this.cache.set(clazz, null);
|
|
2609
2556
|
return null;
|
|
2610
2557
|
}
|
|
2611
|
-
|
|
2612
|
-
|
|
2613
|
-
|
|
2558
|
+
const declarations = /* @__PURE__ */ new Set();
|
|
2559
|
+
for (const declRef of meta.declarations) {
|
|
2560
|
+
declarations.add(declRef.node);
|
|
2561
|
+
}
|
|
2562
|
+
for (const exportRef of meta.exports) {
|
|
2563
|
+
const directive = this.dtsMetaReader.getDirectiveMetadata(exportRef);
|
|
2564
|
+
if (directive !== null) {
|
|
2565
|
+
const isReExport = !declarations.has(exportRef.node);
|
|
2566
|
+
dependencies.push(this.maybeAlias(directive, sourceFile, isReExport));
|
|
2614
2567
|
continue;
|
|
2615
2568
|
}
|
|
2616
|
-
const
|
|
2617
|
-
|
|
2618
|
-
|
|
2619
|
-
|
|
2620
|
-
|
|
2621
|
-
return void 0;
|
|
2622
|
-
}
|
|
2569
|
+
const pipe = this.dtsMetaReader.getPipeMetadata(exportRef);
|
|
2570
|
+
if (pipe !== null) {
|
|
2571
|
+
const isReExport = !declarations.has(exportRef.node);
|
|
2572
|
+
dependencies.push(this.maybeAlias(pipe, sourceFile, isReExport));
|
|
2573
|
+
continue;
|
|
2623
2574
|
}
|
|
2624
|
-
const
|
|
2625
|
-
if (
|
|
2626
|
-
|
|
2575
|
+
const exportScope2 = this.resolve(exportRef);
|
|
2576
|
+
if (exportScope2 !== null) {
|
|
2577
|
+
if (this.aliasingHost === null) {
|
|
2578
|
+
dependencies.push(...exportScope2.exported.dependencies);
|
|
2579
|
+
} else {
|
|
2580
|
+
for (const dep of exportScope2.exported.dependencies) {
|
|
2581
|
+
dependencies.push(this.maybeAlias(dep, sourceFile, true));
|
|
2582
|
+
}
|
|
2583
|
+
}
|
|
2627
2584
|
}
|
|
2628
|
-
|
|
2585
|
+
continue;
|
|
2629
2586
|
}
|
|
2630
|
-
|
|
2631
|
-
|
|
2587
|
+
const exportScope = {
|
|
2588
|
+
exported: {
|
|
2589
|
+
dependencies,
|
|
2590
|
+
isPoisoned: false
|
|
2591
|
+
}
|
|
2592
|
+
};
|
|
2593
|
+
this.cache.set(clazz, exportScope);
|
|
2594
|
+
return exportScope;
|
|
2632
2595
|
}
|
|
2633
|
-
|
|
2634
|
-
|
|
2635
|
-
if (this.
|
|
2636
|
-
|
|
2637
|
-
this.priorShims.delete(fileName);
|
|
2596
|
+
maybeAlias(dirOrPipe, maybeAliasFrom, isReExport) {
|
|
2597
|
+
const ref = dirOrPipe.ref;
|
|
2598
|
+
if (this.aliasingHost === null || ref.node.getSourceFile() === maybeAliasFrom) {
|
|
2599
|
+
return dirOrPipe;
|
|
2638
2600
|
}
|
|
2639
|
-
const
|
|
2640
|
-
|
|
2641
|
-
|
|
2642
|
-
generatedFrom: absoluteFromSourceFile(inputFile)
|
|
2643
|
-
};
|
|
2644
|
-
if (!generator.shouldEmit) {
|
|
2645
|
-
this.ignoreForEmit.add(shimSf);
|
|
2601
|
+
const alias = this.aliasingHost.getAliasIn(ref.node, maybeAliasFrom, isReExport);
|
|
2602
|
+
if (alias === null) {
|
|
2603
|
+
return dirOrPipe;
|
|
2646
2604
|
}
|
|
2647
|
-
|
|
2648
|
-
|
|
2605
|
+
return __spreadProps(__spreadValues({}, dirOrPipe), {
|
|
2606
|
+
ref: ref.cloneWithAlias(alias)
|
|
2607
|
+
});
|
|
2649
2608
|
}
|
|
2650
2609
|
};
|
|
2651
2610
|
|
|
2652
|
-
// bazel-out/k8-fastbuild/bin/packages/compiler-cli/src/ngtsc/
|
|
2653
|
-
import
|
|
2654
|
-
|
|
2655
|
-
|
|
2656
|
-
|
|
2657
|
-
|
|
2658
|
-
|
|
2659
|
-
|
|
2660
|
-
|
|
2661
|
-
|
|
2662
|
-
}
|
|
2663
|
-
|
|
2664
|
-
|
|
2665
|
-
const
|
|
2666
|
-
|
|
2667
|
-
|
|
2668
|
-
|
|
2669
|
-
|
|
2670
|
-
sourceText = leadingComment + "\n\n";
|
|
2671
|
-
}
|
|
2672
|
-
if (symbolNames.length > 0) {
|
|
2673
|
-
const varLines = symbolNames.map((name) => `export const ${name}NgFactory: i0.\u0275NgModuleFactory<any> = new i0.\u0275NgModuleFactory(${name});`);
|
|
2674
|
-
sourceText += [
|
|
2675
|
-
`import * as i0 from '@angular/core';`,
|
|
2676
|
-
`import {${symbolNames.join(", ")}} from '${relativePathToSource}';`,
|
|
2677
|
-
...varLines
|
|
2678
|
-
].join("\n");
|
|
2679
|
-
}
|
|
2680
|
-
sourceText += "\nexport const \u0275NonEmptyModule = true;";
|
|
2681
|
-
const genFile = ts14.createSourceFile(genFilePath, sourceText, sf.languageVersion, true, ts14.ScriptKind.TS);
|
|
2682
|
-
if (sf.moduleName !== void 0) {
|
|
2683
|
-
genFile.moduleName = generatedModuleName(sf.moduleName, sf.fileName, ".ngfactory");
|
|
2684
|
-
}
|
|
2685
|
-
const moduleSymbols = /* @__PURE__ */ new Map();
|
|
2686
|
-
this.sourceToFactorySymbols.set(absoluteSfPath, moduleSymbols);
|
|
2687
|
-
this.sourceInfo.set(genFilePath, {
|
|
2688
|
-
sourceFilePath: absoluteSfPath,
|
|
2689
|
-
moduleSymbols
|
|
2690
|
-
});
|
|
2691
|
-
return genFile;
|
|
2692
|
-
}
|
|
2693
|
-
track(sf, moduleInfo) {
|
|
2694
|
-
if (this.sourceToFactorySymbols.has(sf.fileName)) {
|
|
2695
|
-
this.sourceToFactorySymbols.get(sf.fileName).set(moduleInfo.name, moduleInfo);
|
|
2611
|
+
// bazel-out/k8-fastbuild/bin/packages/compiler-cli/src/ngtsc/scope/src/local.mjs
|
|
2612
|
+
import { ExternalExpr as ExternalExpr3 } from "@angular/compiler";
|
|
2613
|
+
import ts12 from "typescript";
|
|
2614
|
+
|
|
2615
|
+
// bazel-out/k8-fastbuild/bin/packages/compiler-cli/src/ngtsc/scope/src/util.mjs
|
|
2616
|
+
function getDiagnosticNode(ref, rawExpr) {
|
|
2617
|
+
return rawExpr !== null ? ref.getOriginForDiagnostics(rawExpr) : ref.node.name;
|
|
2618
|
+
}
|
|
2619
|
+
function makeNotStandaloneDiagnostic(scopeReader, ref, rawExpr, kind) {
|
|
2620
|
+
const scope = scopeReader.getScopeForComponent(ref.node);
|
|
2621
|
+
let message = `The ${kind} '${ref.node.name.text}' appears in 'imports', but is not standalone and cannot be imported directly.`;
|
|
2622
|
+
let relatedInformation = void 0;
|
|
2623
|
+
if (scope !== null && scope.kind === ComponentScopeKind.NgModule) {
|
|
2624
|
+
const isExported = scope.exported.dependencies.some((dep) => dep.ref.node === ref.node);
|
|
2625
|
+
if (isExported) {
|
|
2626
|
+
relatedInformation = [makeRelatedInformation(scope.ngModule.name, `It can be imported using its NgModule '${scope.ngModule.name.text}' instead.`)];
|
|
2627
|
+
} else {
|
|
2628
|
+
relatedInformation = [makeRelatedInformation(scope.ngModule.name, `It's declared in the NgModule '${scope.ngModule.name.text}', but is not exported. Consider exporting it.`)];
|
|
2696
2629
|
}
|
|
2630
|
+
} else {
|
|
2697
2631
|
}
|
|
2698
|
-
|
|
2699
|
-
|
|
2700
|
-
|
|
2632
|
+
if (relatedInformation === void 0) {
|
|
2633
|
+
message += " It must be imported via an NgModule.";
|
|
2634
|
+
}
|
|
2635
|
+
return makeDiagnostic(ErrorCode.COMPONENT_IMPORT_NOT_STANDALONE, getDiagnosticNode(ref, rawExpr), message, relatedInformation);
|
|
2701
2636
|
}
|
|
2702
|
-
function
|
|
2703
|
-
return (
|
|
2704
|
-
return (file) => {
|
|
2705
|
-
return transformFactorySourceFile(factoryMap, context, importRewriter, file);
|
|
2706
|
-
};
|
|
2707
|
-
};
|
|
2637
|
+
function makeUnknownComponentImportDiagnostic(ref, rawExpr) {
|
|
2638
|
+
return makeDiagnostic(ErrorCode.COMPONENT_UNKNOWN_IMPORT, getDiagnosticNode(ref, rawExpr), `Component imports must be standalone components, directives, pipes, or must be NgModules.`);
|
|
2708
2639
|
}
|
|
2709
|
-
|
|
2710
|
-
|
|
2711
|
-
|
|
2712
|
-
|
|
2713
|
-
|
|
2714
|
-
|
|
2715
|
-
|
|
2716
|
-
|
|
2717
|
-
|
|
2718
|
-
|
|
2719
|
-
|
|
2720
|
-
|
|
2721
|
-
|
|
2722
|
-
|
|
2723
|
-
|
|
2640
|
+
|
|
2641
|
+
// bazel-out/k8-fastbuild/bin/packages/compiler-cli/src/ngtsc/scope/src/local.mjs
|
|
2642
|
+
var LocalModuleScopeRegistry = class {
|
|
2643
|
+
constructor(localReader, fullReader, dependencyScopeReader, refEmitter, aliasingHost) {
|
|
2644
|
+
this.localReader = localReader;
|
|
2645
|
+
this.fullReader = fullReader;
|
|
2646
|
+
this.dependencyScopeReader = dependencyScopeReader;
|
|
2647
|
+
this.refEmitter = refEmitter;
|
|
2648
|
+
this.aliasingHost = aliasingHost;
|
|
2649
|
+
this.sealed = false;
|
|
2650
|
+
this.declarationToModule = /* @__PURE__ */ new Map();
|
|
2651
|
+
this.duplicateDeclarations = /* @__PURE__ */ new Map();
|
|
2652
|
+
this.moduleToRef = /* @__PURE__ */ new Map();
|
|
2653
|
+
this.cache = /* @__PURE__ */ new Map();
|
|
2654
|
+
this.remoteScoping = /* @__PURE__ */ new Map();
|
|
2655
|
+
this.scopeErrors = /* @__PURE__ */ new Map();
|
|
2656
|
+
this.modulesWithStructuralErrors = /* @__PURE__ */ new Set();
|
|
2657
|
+
}
|
|
2658
|
+
registerNgModuleMetadata(data) {
|
|
2659
|
+
this.assertCollecting();
|
|
2660
|
+
const ngModule = data.ref.node;
|
|
2661
|
+
this.moduleToRef.set(data.ref.node, data.ref);
|
|
2662
|
+
for (const decl of data.declarations) {
|
|
2663
|
+
this.registerDeclarationOfModule(ngModule, decl, data.rawDeclarations);
|
|
2664
|
+
}
|
|
2665
|
+
}
|
|
2666
|
+
registerDirectiveMetadata(directive) {
|
|
2667
|
+
}
|
|
2668
|
+
registerPipeMetadata(pipe) {
|
|
2669
|
+
}
|
|
2670
|
+
getScopeForComponent(clazz) {
|
|
2671
|
+
const scope = !this.declarationToModule.has(clazz) ? null : this.getScopeOfModule(this.declarationToModule.get(clazz).ngModule);
|
|
2672
|
+
return scope;
|
|
2673
|
+
}
|
|
2674
|
+
getDuplicateDeclarations(node) {
|
|
2675
|
+
if (!this.duplicateDeclarations.has(node)) {
|
|
2676
|
+
return null;
|
|
2677
|
+
}
|
|
2678
|
+
return Array.from(this.duplicateDeclarations.get(node).values());
|
|
2679
|
+
}
|
|
2680
|
+
getScopeOfModule(clazz) {
|
|
2681
|
+
return this.moduleToRef.has(clazz) ? this.getScopeOfModuleReference(this.moduleToRef.get(clazz)) : null;
|
|
2682
|
+
}
|
|
2683
|
+
getDiagnosticsOfModule(clazz) {
|
|
2684
|
+
this.getScopeOfModule(clazz);
|
|
2685
|
+
if (this.scopeErrors.has(clazz)) {
|
|
2686
|
+
return this.scopeErrors.get(clazz);
|
|
2687
|
+
} else {
|
|
2688
|
+
return null;
|
|
2689
|
+
}
|
|
2690
|
+
}
|
|
2691
|
+
registerDeclarationOfModule(ngModule, decl, rawDeclarations) {
|
|
2692
|
+
const declData = {
|
|
2693
|
+
ngModule,
|
|
2694
|
+
ref: decl,
|
|
2695
|
+
rawDeclarations
|
|
2696
|
+
};
|
|
2697
|
+
if (this.duplicateDeclarations.has(decl.node)) {
|
|
2698
|
+
this.duplicateDeclarations.get(decl.node).set(ngModule, declData);
|
|
2699
|
+
} else if (this.declarationToModule.has(decl.node) && this.declarationToModule.get(decl.node).ngModule !== ngModule) {
|
|
2700
|
+
const duplicateDeclMap = /* @__PURE__ */ new Map();
|
|
2701
|
+
const firstDeclData = this.declarationToModule.get(decl.node);
|
|
2702
|
+
this.modulesWithStructuralErrors.add(firstDeclData.ngModule);
|
|
2703
|
+
this.modulesWithStructuralErrors.add(ngModule);
|
|
2704
|
+
duplicateDeclMap.set(firstDeclData.ngModule, firstDeclData);
|
|
2705
|
+
duplicateDeclMap.set(ngModule, declData);
|
|
2706
|
+
this.duplicateDeclarations.set(decl.node, duplicateDeclMap);
|
|
2707
|
+
this.declarationToModule.delete(decl.node);
|
|
2708
|
+
} else {
|
|
2709
|
+
this.declarationToModule.set(decl.node, declData);
|
|
2710
|
+
}
|
|
2711
|
+
}
|
|
2712
|
+
getScopeOfModuleReference(ref) {
|
|
2713
|
+
if (this.cache.has(ref.node)) {
|
|
2714
|
+
return this.cache.get(ref.node);
|
|
2715
|
+
}
|
|
2716
|
+
this.sealed = true;
|
|
2717
|
+
const ngModule = this.localReader.getNgModuleMetadata(ref);
|
|
2718
|
+
if (ngModule === null) {
|
|
2719
|
+
this.cache.set(ref.node, null);
|
|
2720
|
+
return null;
|
|
2721
|
+
}
|
|
2722
|
+
const diagnostics = [];
|
|
2723
|
+
const compilationDirectives = /* @__PURE__ */ new Map();
|
|
2724
|
+
const compilationPipes = /* @__PURE__ */ new Map();
|
|
2725
|
+
const declared = /* @__PURE__ */ new Set();
|
|
2726
|
+
const exportDirectives = /* @__PURE__ */ new Map();
|
|
2727
|
+
const exportPipes = /* @__PURE__ */ new Map();
|
|
2728
|
+
let isPoisoned = false;
|
|
2729
|
+
if (this.modulesWithStructuralErrors.has(ngModule.ref.node)) {
|
|
2730
|
+
isPoisoned = true;
|
|
2731
|
+
}
|
|
2732
|
+
for (const decl of ngModule.imports) {
|
|
2733
|
+
const importScope = this.getExportedScope(decl, diagnostics, ref.node, "import");
|
|
2734
|
+
if (importScope !== null) {
|
|
2735
|
+
if (importScope === "invalid" || importScope.exported.isPoisoned) {
|
|
2736
|
+
diagnostics.push(invalidTransitiveNgModuleRef(decl, ngModule.rawImports, "import"));
|
|
2737
|
+
isPoisoned = true;
|
|
2738
|
+
if (importScope === "invalid") {
|
|
2739
|
+
continue;
|
|
2740
|
+
}
|
|
2724
2741
|
}
|
|
2742
|
+
for (const dep of importScope.exported.dependencies) {
|
|
2743
|
+
if (dep.kind === MetaKind.Directive) {
|
|
2744
|
+
compilationDirectives.set(dep.ref.node, dep);
|
|
2745
|
+
} else if (dep.kind === MetaKind.Pipe) {
|
|
2746
|
+
compilationPipes.set(dep.ref.node, dep);
|
|
2747
|
+
}
|
|
2748
|
+
}
|
|
2749
|
+
continue;
|
|
2750
|
+
}
|
|
2751
|
+
const directive = this.fullReader.getDirectiveMetadata(decl);
|
|
2752
|
+
if (directive !== null) {
|
|
2753
|
+
if (directive.isStandalone) {
|
|
2754
|
+
compilationDirectives.set(directive.ref.node, directive);
|
|
2755
|
+
} else {
|
|
2756
|
+
diagnostics.push(makeNotStandaloneDiagnostic(this, decl, ngModule.rawImports, directive.isComponent ? "component" : "directive"));
|
|
2757
|
+
isPoisoned = true;
|
|
2758
|
+
}
|
|
2759
|
+
continue;
|
|
2760
|
+
}
|
|
2761
|
+
const pipe = this.fullReader.getPipeMetadata(decl);
|
|
2762
|
+
if (pipe !== null) {
|
|
2763
|
+
if (pipe.isStandalone) {
|
|
2764
|
+
compilationPipes.set(pipe.ref.node, pipe);
|
|
2765
|
+
} else {
|
|
2766
|
+
diagnostics.push(makeNotStandaloneDiagnostic(this, decl, ngModule.rawImports, "pipe"));
|
|
2767
|
+
isPoisoned = true;
|
|
2768
|
+
}
|
|
2769
|
+
continue;
|
|
2770
|
+
}
|
|
2771
|
+
diagnostics.push(invalidRef(decl, ngModule.rawImports, "import"));
|
|
2772
|
+
isPoisoned = true;
|
|
2773
|
+
}
|
|
2774
|
+
for (const decl of ngModule.declarations) {
|
|
2775
|
+
const directive = this.localReader.getDirectiveMetadata(decl);
|
|
2776
|
+
const pipe = this.localReader.getPipeMetadata(decl);
|
|
2777
|
+
if (directive !== null) {
|
|
2778
|
+
if (directive.isStandalone) {
|
|
2779
|
+
const refType = directive.isComponent ? "Component" : "Directive";
|
|
2780
|
+
diagnostics.push(makeDiagnostic(ErrorCode.NGMODULE_DECLARATION_IS_STANDALONE, decl.getOriginForDiagnostics(ngModule.rawDeclarations), `${refType} ${decl.node.name.text} is standalone, and cannot be declared in an NgModule. Did you mean to import it instead?`));
|
|
2781
|
+
isPoisoned = true;
|
|
2782
|
+
continue;
|
|
2783
|
+
}
|
|
2784
|
+
compilationDirectives.set(decl.node, __spreadProps(__spreadValues({}, directive), { ref: decl }));
|
|
2785
|
+
if (directive.isPoisoned) {
|
|
2786
|
+
isPoisoned = true;
|
|
2787
|
+
}
|
|
2788
|
+
} else if (pipe !== null) {
|
|
2789
|
+
if (pipe.isStandalone) {
|
|
2790
|
+
diagnostics.push(makeDiagnostic(ErrorCode.NGMODULE_DECLARATION_IS_STANDALONE, decl.getOriginForDiagnostics(ngModule.rawDeclarations), `Pipe ${decl.node.name.text} is standalone, and cannot be declared in an NgModule. Did you mean to import it instead?`));
|
|
2791
|
+
isPoisoned = true;
|
|
2792
|
+
continue;
|
|
2793
|
+
}
|
|
2794
|
+
compilationPipes.set(decl.node, __spreadProps(__spreadValues({}, pipe), { ref: decl }));
|
|
2725
2795
|
} else {
|
|
2726
|
-
|
|
2796
|
+
const errorNode = decl.getOriginForDiagnostics(ngModule.rawDeclarations);
|
|
2797
|
+
diagnostics.push(makeDiagnostic(ErrorCode.NGMODULE_INVALID_DECLARATION, errorNode, `The class '${decl.node.name.text}' is listed in the declarations of the NgModule '${ngModule.ref.node.name.text}', but is not a directive, a component, or a pipe. Either remove it from the NgModule's declarations, or add an appropriate Angular decorator.`, [makeRelatedInformation(decl.node.name, `'${decl.node.name.text}' is declared here.`)]));
|
|
2798
|
+
isPoisoned = true;
|
|
2799
|
+
continue;
|
|
2727
2800
|
}
|
|
2728
|
-
|
|
2729
|
-
|
|
2730
|
-
|
|
2731
|
-
|
|
2732
|
-
|
|
2801
|
+
declared.add(decl.node);
|
|
2802
|
+
}
|
|
2803
|
+
for (const decl of ngModule.exports) {
|
|
2804
|
+
const exportScope = this.getExportedScope(decl, diagnostics, ref.node, "export");
|
|
2805
|
+
if (exportScope === "invalid" || exportScope !== null && exportScope.exported.isPoisoned) {
|
|
2806
|
+
diagnostics.push(invalidTransitiveNgModuleRef(decl, ngModule.rawExports, "export"));
|
|
2807
|
+
isPoisoned = true;
|
|
2808
|
+
if (exportScope === "invalid") {
|
|
2733
2809
|
continue;
|
|
2734
2810
|
}
|
|
2735
|
-
|
|
2736
|
-
const
|
|
2737
|
-
|
|
2738
|
-
|
|
2811
|
+
} else if (exportScope !== null) {
|
|
2812
|
+
for (const dep of exportScope.exported.dependencies) {
|
|
2813
|
+
if (dep.kind == MetaKind.Directive) {
|
|
2814
|
+
exportDirectives.set(dep.ref.node, dep);
|
|
2815
|
+
} else if (dep.kind === MetaKind.Pipe) {
|
|
2816
|
+
exportPipes.set(dep.ref.node, dep);
|
|
2817
|
+
}
|
|
2739
2818
|
}
|
|
2819
|
+
} else if (compilationDirectives.has(decl.node)) {
|
|
2820
|
+
const directive = compilationDirectives.get(decl.node);
|
|
2821
|
+
exportDirectives.set(decl.node, directive);
|
|
2822
|
+
} else if (compilationPipes.has(decl.node)) {
|
|
2823
|
+
const pipe = compilationPipes.get(decl.node);
|
|
2824
|
+
exportPipes.set(decl.node, pipe);
|
|
2740
2825
|
} else {
|
|
2741
|
-
|
|
2826
|
+
const dirMeta = this.fullReader.getDirectiveMetadata(decl);
|
|
2827
|
+
const pipeMeta = this.fullReader.getPipeMetadata(decl);
|
|
2828
|
+
if (dirMeta !== null || pipeMeta !== null) {
|
|
2829
|
+
const isStandalone = dirMeta !== null ? dirMeta.isStandalone : pipeMeta.isStandalone;
|
|
2830
|
+
diagnostics.push(invalidReexport(decl, ngModule.rawExports, isStandalone));
|
|
2831
|
+
} else {
|
|
2832
|
+
diagnostics.push(invalidRef(decl, ngModule.rawExports, "export"));
|
|
2833
|
+
}
|
|
2834
|
+
isPoisoned = true;
|
|
2835
|
+
continue;
|
|
2742
2836
|
}
|
|
2743
|
-
} else {
|
|
2744
|
-
transformedStatements.push(stmt);
|
|
2745
2837
|
}
|
|
2838
|
+
const exported = {
|
|
2839
|
+
dependencies: [...exportDirectives.values(), ...exportPipes.values()],
|
|
2840
|
+
isPoisoned
|
|
2841
|
+
};
|
|
2842
|
+
const reexports = this.getReexports(ngModule, ref, declared, exported.dependencies, diagnostics);
|
|
2843
|
+
const scope = {
|
|
2844
|
+
kind: ComponentScopeKind.NgModule,
|
|
2845
|
+
ngModule: ngModule.ref.node,
|
|
2846
|
+
compilation: {
|
|
2847
|
+
dependencies: [...compilationDirectives.values(), ...compilationPipes.values()],
|
|
2848
|
+
isPoisoned
|
|
2849
|
+
},
|
|
2850
|
+
exported,
|
|
2851
|
+
reexports,
|
|
2852
|
+
schemas: ngModule.schemas
|
|
2853
|
+
};
|
|
2854
|
+
if (diagnostics.length > 0) {
|
|
2855
|
+
this.scopeErrors.set(ref.node, diagnostics);
|
|
2856
|
+
this.modulesWithStructuralErrors.add(ref.node);
|
|
2857
|
+
}
|
|
2858
|
+
this.cache.set(ref.node, scope);
|
|
2859
|
+
return scope;
|
|
2746
2860
|
}
|
|
2747
|
-
|
|
2748
|
-
|
|
2861
|
+
getRemoteScope(node) {
|
|
2862
|
+
return this.remoteScoping.has(node) ? this.remoteScoping.get(node) : null;
|
|
2749
2863
|
}
|
|
2750
|
-
|
|
2751
|
-
|
|
2752
|
-
|
|
2753
|
-
|
|
2754
|
-
|
|
2755
|
-
|
|
2756
|
-
|
|
2757
|
-
|
|
2758
|
-
|
|
2864
|
+
setComponentRemoteScope(node, directives, pipes) {
|
|
2865
|
+
this.remoteScoping.set(node, { directives, pipes });
|
|
2866
|
+
}
|
|
2867
|
+
getExportedScope(ref, diagnostics, ownerForErrors, type) {
|
|
2868
|
+
if (ref.node.getSourceFile().isDeclarationFile) {
|
|
2869
|
+
if (!ts12.isClassDeclaration(ref.node)) {
|
|
2870
|
+
const code = type === "import" ? ErrorCode.NGMODULE_INVALID_IMPORT : ErrorCode.NGMODULE_INVALID_EXPORT;
|
|
2871
|
+
diagnostics.push(makeDiagnostic(code, identifierOfNode(ref.node) || ref.node, `Appears in the NgModule.${type}s of ${nodeNameForError(ownerForErrors)}, but could not be resolved to an NgModule`));
|
|
2872
|
+
return "invalid";
|
|
2873
|
+
}
|
|
2874
|
+
return this.dependencyScopeReader.resolve(ref);
|
|
2875
|
+
} else {
|
|
2876
|
+
return this.getScopeOfModuleReference(ref);
|
|
2877
|
+
}
|
|
2878
|
+
}
|
|
2879
|
+
getReexports(ngModule, ref, declared, exported, diagnostics) {
|
|
2880
|
+
let reexports = null;
|
|
2881
|
+
const sourceFile = ref.node.getSourceFile();
|
|
2882
|
+
if (this.aliasingHost === null) {
|
|
2883
|
+
return null;
|
|
2884
|
+
}
|
|
2885
|
+
reexports = [];
|
|
2886
|
+
const reexportMap = /* @__PURE__ */ new Map();
|
|
2887
|
+
const ngModuleRef = ref;
|
|
2888
|
+
const addReexport = (exportRef) => {
|
|
2889
|
+
if (exportRef.node.getSourceFile() === sourceFile) {
|
|
2890
|
+
return;
|
|
2891
|
+
}
|
|
2892
|
+
const isReExport = !declared.has(exportRef.node);
|
|
2893
|
+
const exportName = this.aliasingHost.maybeAliasSymbolAs(exportRef, sourceFile, ngModule.ref.node.name.text, isReExport);
|
|
2894
|
+
if (exportName === null) {
|
|
2895
|
+
return;
|
|
2896
|
+
}
|
|
2897
|
+
if (!reexportMap.has(exportName)) {
|
|
2898
|
+
if (exportRef.alias && exportRef.alias instanceof ExternalExpr3) {
|
|
2899
|
+
reexports.push({
|
|
2900
|
+
fromModule: exportRef.alias.value.moduleName,
|
|
2901
|
+
symbolName: exportRef.alias.value.name,
|
|
2902
|
+
asAlias: exportName
|
|
2903
|
+
});
|
|
2904
|
+
} else {
|
|
2905
|
+
const emittedRef = this.refEmitter.emit(exportRef.cloneWithNoIdentifiers(), sourceFile);
|
|
2906
|
+
assertSuccessfulReferenceEmit(emittedRef, ngModuleRef.node.name, "class");
|
|
2907
|
+
const expr = emittedRef.expression;
|
|
2908
|
+
if (!(expr instanceof ExternalExpr3) || expr.value.moduleName === null || expr.value.name === null) {
|
|
2909
|
+
throw new Error("Expected ExternalExpr");
|
|
2910
|
+
}
|
|
2911
|
+
reexports.push({
|
|
2912
|
+
fromModule: expr.value.moduleName,
|
|
2913
|
+
symbolName: expr.value.name,
|
|
2914
|
+
asAlias: exportName
|
|
2915
|
+
});
|
|
2759
2916
|
}
|
|
2917
|
+
reexportMap.set(exportName, exportRef);
|
|
2918
|
+
} else {
|
|
2919
|
+
const prevRef = reexportMap.get(exportName);
|
|
2920
|
+
diagnostics.push(reexportCollision(ngModuleRef.node, prevRef, exportRef));
|
|
2760
2921
|
}
|
|
2761
|
-
return node;
|
|
2762
2922
|
};
|
|
2763
|
-
|
|
2764
|
-
|
|
2765
|
-
|
|
2766
|
-
|
|
2767
|
-
function getFileoverviewComment(sourceFile) {
|
|
2768
|
-
const text = sourceFile.getFullText();
|
|
2769
|
-
const trivia = text.substring(0, sourceFile.getStart());
|
|
2770
|
-
const leadingComments = ts14.getLeadingCommentRanges(trivia, 0);
|
|
2771
|
-
if (!leadingComments || leadingComments.length === 0) {
|
|
2772
|
-
return null;
|
|
2923
|
+
for (const { ref: ref2 } of exported) {
|
|
2924
|
+
addReexport(ref2);
|
|
2925
|
+
}
|
|
2926
|
+
return reexports;
|
|
2773
2927
|
}
|
|
2774
|
-
|
|
2775
|
-
|
|
2776
|
-
|
|
2928
|
+
assertCollecting() {
|
|
2929
|
+
if (this.sealed) {
|
|
2930
|
+
throw new Error(`Assertion: LocalModuleScopeRegistry is not COLLECTING`);
|
|
2931
|
+
}
|
|
2777
2932
|
}
|
|
2778
|
-
|
|
2779
|
-
|
|
2933
|
+
};
|
|
2934
|
+
function invalidRef(decl, rawExpr, type) {
|
|
2935
|
+
const code = type === "import" ? ErrorCode.NGMODULE_INVALID_IMPORT : ErrorCode.NGMODULE_INVALID_EXPORT;
|
|
2936
|
+
const resolveTarget = type === "import" ? "NgModule" : "NgModule, Component, Directive, or Pipe";
|
|
2937
|
+
const message = `'${decl.node.name.text}' does not appear to be an ${resolveTarget} class.`;
|
|
2938
|
+
const library = decl.ownedByModuleGuess !== null ? ` (${decl.ownedByModuleGuess})` : "";
|
|
2939
|
+
const sf = decl.node.getSourceFile();
|
|
2940
|
+
let relatedMessage;
|
|
2941
|
+
if (!sf.isDeclarationFile) {
|
|
2942
|
+
const annotationType = type === "import" ? "@NgModule" : "Angular";
|
|
2943
|
+
relatedMessage = `Is it missing an ${annotationType} annotation?`;
|
|
2944
|
+
} else if (sf.fileName.indexOf("node_modules") !== -1) {
|
|
2945
|
+
relatedMessage = `This likely means that the library${library} which declares ${decl.debugName} has not been processed correctly by ngcc, or is not compatible with Angular Ivy. Check if a newer version of the library is available, and update if so. Also consider checking with the library's authors to see if the library is expected to be compatible with Ivy.`;
|
|
2946
|
+
} else {
|
|
2947
|
+
relatedMessage = `This likely means that the dependency${library} which declares ${decl.debugName} has not been processed correctly by ngcc.`;
|
|
2780
2948
|
}
|
|
2781
|
-
|
|
2782
|
-
|
|
2783
|
-
|
|
2949
|
+
return makeDiagnostic(code, getDiagnosticNode(decl, rawExpr), message, [makeRelatedInformation(decl.node.name, relatedMessage)]);
|
|
2950
|
+
}
|
|
2951
|
+
function invalidTransitiveNgModuleRef(decl, rawExpr, type) {
|
|
2952
|
+
const code = type === "import" ? ErrorCode.NGMODULE_INVALID_IMPORT : ErrorCode.NGMODULE_INVALID_EXPORT;
|
|
2953
|
+
return makeDiagnostic(code, getDiagnosticNode(decl, rawExpr), `This ${type} contains errors, which may affect components that depend on this NgModule.`);
|
|
2954
|
+
}
|
|
2955
|
+
function invalidReexport(decl, rawExpr, isStandalone) {
|
|
2956
|
+
let message = `Can't be exported from this NgModule, as `;
|
|
2957
|
+
if (isStandalone) {
|
|
2958
|
+
message += "it must be imported first";
|
|
2959
|
+
} else if (decl.node.getSourceFile().isDeclarationFile) {
|
|
2960
|
+
message += "it must be imported via its NgModule first";
|
|
2961
|
+
} else {
|
|
2962
|
+
message += "it must be either declared by this NgModule, or imported here via its NgModule first";
|
|
2784
2963
|
}
|
|
2785
|
-
return
|
|
2964
|
+
return makeDiagnostic(ErrorCode.NGMODULE_INVALID_REEXPORT, getDiagnosticNode(decl, rawExpr), message);
|
|
2786
2965
|
}
|
|
2787
|
-
function
|
|
2788
|
-
const
|
|
2789
|
-
return
|
|
2790
|
-
|
|
2791
|
-
|
|
2792
|
-
|
|
2966
|
+
function reexportCollision(module, refA, refB) {
|
|
2967
|
+
const childMessageText = `This directive/pipe is part of the exports of '${module.name.text}' and shares the same name as another exported directive/pipe.`;
|
|
2968
|
+
return makeDiagnostic(ErrorCode.NGMODULE_REEXPORT_NAME_COLLISION, module.name, `
|
|
2969
|
+
There was a name collision between two classes named '${refA.node.name.text}', which are both part of the exports of '${module.name.text}'.
|
|
2970
|
+
|
|
2971
|
+
Angular generates re-exports of an NgModule's exported directives/pipes from the module's source file in certain cases, using the declared name of the class. If two classes of the same name are exported, this automatic naming does not work.
|
|
2972
|
+
|
|
2973
|
+
To fix this problem please re-export one or both classes directly from this file.
|
|
2974
|
+
`.trim(), [
|
|
2975
|
+
makeRelatedInformation(refA.node.name, childMessageText),
|
|
2976
|
+
makeRelatedInformation(refB.node.name, childMessageText)
|
|
2793
2977
|
]);
|
|
2794
2978
|
}
|
|
2795
|
-
function updateInitializers(stmt, update) {
|
|
2796
|
-
return ts14.factory.updateVariableStatement(stmt, stmt.modifiers, ts14.factory.updateVariableDeclarationList(stmt.declarationList, stmt.declarationList.declarations.map((decl) => ts14.updateVariableDeclaration(decl, decl.name, decl.type, update(decl.initializer)))));
|
|
2797
|
-
}
|
|
2798
2979
|
|
|
2799
|
-
// bazel-out/k8-fastbuild/bin/packages/compiler-cli/src/ngtsc/
|
|
2800
|
-
|
|
2801
|
-
|
|
2802
|
-
|
|
2803
|
-
|
|
2804
|
-
this.
|
|
2805
|
-
|
|
2806
|
-
|
|
2807
|
-
|
|
2808
|
-
return;
|
|
2809
|
-
}
|
|
2810
|
-
const ext = sfExtensionData(sf);
|
|
2811
|
-
if (ext.originalReferencedFiles === null) {
|
|
2812
|
-
ext.originalReferencedFiles = sf.referencedFiles;
|
|
2813
|
-
}
|
|
2814
|
-
const referencedFiles = [...ext.originalReferencedFiles];
|
|
2815
|
-
const sfPath = absoluteFromSourceFile(sf);
|
|
2816
|
-
for (const suffix of this.suffixes) {
|
|
2817
|
-
referencedFiles.push({
|
|
2818
|
-
fileName: makeShimFileName(sfPath, suffix),
|
|
2819
|
-
pos: 0,
|
|
2820
|
-
end: 0
|
|
2821
|
-
});
|
|
2822
|
-
}
|
|
2823
|
-
ext.taggedReferenceFiles = referencedFiles;
|
|
2824
|
-
sf.referencedFiles = referencedFiles;
|
|
2825
|
-
this.tagged.add(sf);
|
|
2826
|
-
}
|
|
2827
|
-
finalize() {
|
|
2828
|
-
this.enabled = false;
|
|
2829
|
-
this.tagged.clear();
|
|
2980
|
+
// bazel-out/k8-fastbuild/bin/packages/compiler-cli/src/ngtsc/scope/src/typecheck.mjs
|
|
2981
|
+
import { CssSelector, SelectorMatcher } from "@angular/compiler";
|
|
2982
|
+
import ts13 from "typescript";
|
|
2983
|
+
var TypeCheckScopeRegistry = class {
|
|
2984
|
+
constructor(scopeReader, metaReader) {
|
|
2985
|
+
this.scopeReader = scopeReader;
|
|
2986
|
+
this.metaReader = metaReader;
|
|
2987
|
+
this.flattenedDirectiveMetaCache = /* @__PURE__ */ new Map();
|
|
2988
|
+
this.scopeCache = /* @__PURE__ */ new Map();
|
|
2830
2989
|
}
|
|
2831
|
-
|
|
2832
|
-
|
|
2833
|
-
|
|
2834
|
-
|
|
2835
|
-
|
|
2836
|
-
|
|
2837
|
-
|
|
2838
|
-
|
|
2839
|
-
|
|
2840
|
-
|
|
2841
|
-
|
|
2842
|
-
|
|
2843
|
-
|
|
2844
|
-
|
|
2845
|
-
|
|
2846
|
-
|
|
2847
|
-
|
|
2848
|
-
|
|
2849
|
-
|
|
2850
|
-
|
|
2851
|
-
|
|
2852
|
-
|
|
2853
|
-
|
|
2990
|
+
getTypeCheckScope(node) {
|
|
2991
|
+
const matcher = new SelectorMatcher();
|
|
2992
|
+
const directives = [];
|
|
2993
|
+
const pipes = /* @__PURE__ */ new Map();
|
|
2994
|
+
const scope = this.scopeReader.getScopeForComponent(node);
|
|
2995
|
+
if (scope === null) {
|
|
2996
|
+
return {
|
|
2997
|
+
matcher,
|
|
2998
|
+
directives,
|
|
2999
|
+
pipes,
|
|
3000
|
+
schemas: [],
|
|
3001
|
+
isPoisoned: false
|
|
3002
|
+
};
|
|
3003
|
+
}
|
|
3004
|
+
const cacheKey = scope.kind === ComponentScopeKind.NgModule ? scope.ngModule : scope.component;
|
|
3005
|
+
const dependencies = scope.kind === ComponentScopeKind.NgModule ? scope.compilation.dependencies : scope.dependencies;
|
|
3006
|
+
if (this.scopeCache.has(cacheKey)) {
|
|
3007
|
+
return this.scopeCache.get(cacheKey);
|
|
3008
|
+
}
|
|
3009
|
+
for (const meta of dependencies) {
|
|
3010
|
+
if (meta.kind === MetaKind.Directive && meta.selector !== null) {
|
|
3011
|
+
const extMeta = this.getTypeCheckDirectiveMetadata(meta.ref);
|
|
3012
|
+
matcher.addSelectables(CssSelector.parse(meta.selector), extMeta);
|
|
3013
|
+
directives.push(extMeta);
|
|
3014
|
+
} else if (meta.kind === MetaKind.Pipe) {
|
|
3015
|
+
if (!ts13.isClassDeclaration(meta.ref.node)) {
|
|
3016
|
+
throw new Error(`Unexpected non-class declaration ${ts13.SyntaxKind[meta.ref.node.kind]} for pipe ${meta.ref.debugName}`);
|
|
2854
3017
|
}
|
|
3018
|
+
pipes.set(meta.name, meta.ref);
|
|
2855
3019
|
}
|
|
2856
3020
|
}
|
|
2857
|
-
const
|
|
2858
|
-
|
|
2859
|
-
|
|
2860
|
-
|
|
2861
|
-
|
|
2862
|
-
|
|
2863
|
-
|
|
2864
|
-
|
|
3021
|
+
const typeCheckScope = {
|
|
3022
|
+
matcher,
|
|
3023
|
+
directives,
|
|
3024
|
+
pipes,
|
|
3025
|
+
schemas: scope.schemas,
|
|
3026
|
+
isPoisoned: scope.kind === ComponentScopeKind.NgModule ? scope.compilation.isPoisoned || scope.exported.isPoisoned : scope.isPoisoned
|
|
3027
|
+
};
|
|
3028
|
+
this.scopeCache.set(cacheKey, typeCheckScope);
|
|
3029
|
+
return typeCheckScope;
|
|
3030
|
+
}
|
|
3031
|
+
getTypeCheckDirectiveMetadata(ref) {
|
|
3032
|
+
const clazz = ref.node;
|
|
3033
|
+
if (this.flattenedDirectiveMetaCache.has(clazz)) {
|
|
3034
|
+
return this.flattenedDirectiveMetaCache.get(clazz);
|
|
2865
3035
|
}
|
|
2866
|
-
|
|
3036
|
+
const meta = flattenInheritedDirectiveMetadata(this.metaReader, ref);
|
|
3037
|
+
this.flattenedDirectiveMetaCache.set(clazz, meta);
|
|
3038
|
+
return meta;
|
|
2867
3039
|
}
|
|
2868
3040
|
};
|
|
2869
|
-
|
|
2870
|
-
|
|
3041
|
+
|
|
3042
|
+
// bazel-out/k8-fastbuild/bin/packages/compiler-cli/src/ngtsc/transform/src/api.mjs
|
|
3043
|
+
var CompilationMode;
|
|
3044
|
+
(function(CompilationMode2) {
|
|
3045
|
+
CompilationMode2[CompilationMode2["FULL"] = 0] = "FULL";
|
|
3046
|
+
CompilationMode2[CompilationMode2["PARTIAL"] = 1] = "PARTIAL";
|
|
3047
|
+
})(CompilationMode || (CompilationMode = {}));
|
|
3048
|
+
var HandlerPrecedence;
|
|
3049
|
+
(function(HandlerPrecedence2) {
|
|
3050
|
+
HandlerPrecedence2[HandlerPrecedence2["PRIMARY"] = 0] = "PRIMARY";
|
|
3051
|
+
HandlerPrecedence2[HandlerPrecedence2["SHARED"] = 1] = "SHARED";
|
|
3052
|
+
HandlerPrecedence2[HandlerPrecedence2["WEAK"] = 2] = "WEAK";
|
|
3053
|
+
})(HandlerPrecedence || (HandlerPrecedence = {}));
|
|
3054
|
+
var HandlerFlags;
|
|
3055
|
+
(function(HandlerFlags2) {
|
|
3056
|
+
HandlerFlags2[HandlerFlags2["NONE"] = 0] = "NONE";
|
|
3057
|
+
HandlerFlags2[HandlerFlags2["FULL_INHERITANCE"] = 1] = "FULL_INHERITANCE";
|
|
3058
|
+
})(HandlerFlags || (HandlerFlags = {}));
|
|
3059
|
+
|
|
3060
|
+
// bazel-out/k8-fastbuild/bin/packages/compiler-cli/src/ngtsc/transform/src/alias.mjs
|
|
3061
|
+
import ts14 from "typescript";
|
|
3062
|
+
function aliasTransformFactory(exportStatements) {
|
|
3063
|
+
return (context) => {
|
|
3064
|
+
return (file) => {
|
|
3065
|
+
if (ts14.isBundle(file) || !exportStatements.has(file.fileName)) {
|
|
3066
|
+
return file;
|
|
3067
|
+
}
|
|
3068
|
+
const statements = [...file.statements];
|
|
3069
|
+
exportStatements.get(file.fileName).forEach(([moduleName, symbolName], aliasName) => {
|
|
3070
|
+
const stmt = ts14.factory.createExportDeclaration(void 0, void 0, false, ts14.createNamedExports([ts14.factory.createExportSpecifier(false, symbolName, aliasName)]), ts14.factory.createStringLiteral(moduleName));
|
|
3071
|
+
statements.push(stmt);
|
|
3072
|
+
});
|
|
3073
|
+
return ts14.factory.updateSourceFile(file, statements);
|
|
3074
|
+
};
|
|
3075
|
+
};
|
|
2871
3076
|
}
|
|
2872
3077
|
|
|
3078
|
+
// bazel-out/k8-fastbuild/bin/packages/compiler-cli/src/ngtsc/transform/src/compilation.mjs
|
|
3079
|
+
import ts15 from "typescript";
|
|
3080
|
+
|
|
2873
3081
|
// bazel-out/k8-fastbuild/bin/packages/compiler-cli/src/ngtsc/transform/src/trait.mjs
|
|
2874
3082
|
var TraitState;
|
|
2875
3083
|
(function(TraitState2) {
|
|
@@ -2927,7 +3135,7 @@ var TraitImpl = class {
|
|
|
2927
3135
|
|
|
2928
3136
|
// bazel-out/k8-fastbuild/bin/packages/compiler-cli/src/ngtsc/transform/src/compilation.mjs
|
|
2929
3137
|
var TraitCompiler = class {
|
|
2930
|
-
constructor(handlers, reflector, perf, incrementalBuild, compileNonExportedClasses, compilationMode, dtsTransforms, semanticDepGraphUpdater) {
|
|
3138
|
+
constructor(handlers, reflector, perf, incrementalBuild, compileNonExportedClasses, compilationMode, dtsTransforms, semanticDepGraphUpdater, sourceFileTypeIdentifier) {
|
|
2931
3139
|
this.handlers = handlers;
|
|
2932
3140
|
this.reflector = reflector;
|
|
2933
3141
|
this.perf = perf;
|
|
@@ -2936,6 +3144,7 @@ var TraitCompiler = class {
|
|
|
2936
3144
|
this.compilationMode = compilationMode;
|
|
2937
3145
|
this.dtsTransforms = dtsTransforms;
|
|
2938
3146
|
this.semanticDepGraphUpdater = semanticDepGraphUpdater;
|
|
3147
|
+
this.sourceFileTypeIdentifier = sourceFileTypeIdentifier;
|
|
2939
3148
|
this.classes = /* @__PURE__ */ new Map();
|
|
2940
3149
|
this.fileToClasses = /* @__PURE__ */ new Map();
|
|
2941
3150
|
this.filesWithoutTraits = /* @__PURE__ */ new Set();
|
|
@@ -2952,7 +3161,7 @@ var TraitCompiler = class {
|
|
|
2952
3161
|
return this.analyze(sf, true);
|
|
2953
3162
|
}
|
|
2954
3163
|
analyze(sf, preanalyze) {
|
|
2955
|
-
if (sf.isDeclarationFile || isShim(sf)) {
|
|
3164
|
+
if (sf.isDeclarationFile || this.sourceFileTypeIdentifier.isShim(sf) || this.sourceFileTypeIdentifier.isResource(sf)) {
|
|
2956
3165
|
return void 0;
|
|
2957
3166
|
}
|
|
2958
3167
|
const promises = [];
|
|
@@ -2973,7 +3182,7 @@ var TraitCompiler = class {
|
|
|
2973
3182
|
if (this.reflector.isClass(node)) {
|
|
2974
3183
|
this.analyzeClass(node, preanalyze ? promises : null);
|
|
2975
3184
|
}
|
|
2976
|
-
|
|
3185
|
+
ts15.forEachChild(node, visit2);
|
|
2977
3186
|
};
|
|
2978
3187
|
visit2(sf);
|
|
2979
3188
|
if (!this.fileToClasses.has(sf)) {
|
|
@@ -3087,7 +3296,7 @@ var TraitCompiler = class {
|
|
|
3087
3296
|
}
|
|
3088
3297
|
if (isPrimaryHandler && record.hasPrimaryHandler) {
|
|
3089
3298
|
record.metaDiagnostics = [{
|
|
3090
|
-
category:
|
|
3299
|
+
category: ts15.DiagnosticCategory.Error,
|
|
3091
3300
|
code: Number("-99" + ErrorCode.DECORATOR_COLLISION),
|
|
3092
3301
|
file: getSourceFile(clazz),
|
|
3093
3302
|
start: clazz.getStart(void 0, false),
|
|
@@ -3295,7 +3504,7 @@ var TraitCompiler = class {
|
|
|
3295
3504
|
}
|
|
3296
3505
|
}
|
|
3297
3506
|
compile(clazz, constantPool) {
|
|
3298
|
-
const original =
|
|
3507
|
+
const original = ts15.getOriginalNode(clazz);
|
|
3299
3508
|
if (!this.reflector.isClass(clazz) || !this.reflector.isClass(original) || !this.classes.has(original)) {
|
|
3300
3509
|
return null;
|
|
3301
3510
|
}
|
|
@@ -3326,7 +3535,7 @@ var TraitCompiler = class {
|
|
|
3326
3535
|
return res.length > 0 ? res : null;
|
|
3327
3536
|
}
|
|
3328
3537
|
decoratorsFor(node) {
|
|
3329
|
-
const original =
|
|
3538
|
+
const original = ts15.getOriginalNode(node);
|
|
3330
3539
|
if (!this.reflector.isClass(original) || !this.classes.has(original)) {
|
|
3331
3540
|
return [];
|
|
3332
3541
|
}
|
|
@@ -3336,7 +3545,7 @@ var TraitCompiler = class {
|
|
|
3336
3545
|
if (trait.state !== TraitState.Resolved) {
|
|
3337
3546
|
continue;
|
|
3338
3547
|
}
|
|
3339
|
-
if (trait.detected.trigger !== null &&
|
|
3548
|
+
if (trait.detected.trigger !== null && ts15.isDecorator(trait.detected.trigger)) {
|
|
3340
3549
|
decorators.push(trait.detected.trigger);
|
|
3341
3550
|
}
|
|
3342
3551
|
}
|
|
@@ -3365,27 +3574,27 @@ var TraitCompiler = class {
|
|
|
3365
3574
|
}
|
|
3366
3575
|
};
|
|
3367
3576
|
function containsErrors(diagnostics) {
|
|
3368
|
-
return diagnostics !== null && diagnostics.some((diag) => diag.category ===
|
|
3577
|
+
return diagnostics !== null && diagnostics.some((diag) => diag.category === ts15.DiagnosticCategory.Error);
|
|
3369
3578
|
}
|
|
3370
3579
|
|
|
3371
3580
|
// bazel-out/k8-fastbuild/bin/packages/compiler-cli/src/ngtsc/transform/src/declaration.mjs
|
|
3372
|
-
import
|
|
3581
|
+
import ts17 from "typescript";
|
|
3373
3582
|
|
|
3374
3583
|
// bazel-out/k8-fastbuild/bin/packages/compiler-cli/src/ngtsc/transform/src/utils.mjs
|
|
3375
|
-
import
|
|
3584
|
+
import ts16 from "typescript";
|
|
3376
3585
|
function addImports(importManager, sf, extraStatements = []) {
|
|
3377
3586
|
const addedImports = importManager.getAllImports(sf.fileName).map((i) => {
|
|
3378
|
-
const qualifier =
|
|
3379
|
-
const importClause =
|
|
3380
|
-
const decl =
|
|
3381
|
-
|
|
3587
|
+
const qualifier = ts16.factory.createIdentifier(i.qualifier.text);
|
|
3588
|
+
const importClause = ts16.factory.createImportClause(false, void 0, ts16.factory.createNamespaceImport(qualifier));
|
|
3589
|
+
const decl = ts16.factory.createImportDeclaration(void 0, void 0, importClause, ts16.factory.createStringLiteral(i.specifier));
|
|
3590
|
+
ts16.setOriginalNode(i.qualifier, decl);
|
|
3382
3591
|
return decl;
|
|
3383
3592
|
});
|
|
3384
3593
|
const existingImports = sf.statements.filter((stmt) => isImportStatement(stmt));
|
|
3385
3594
|
const body = sf.statements.filter((stmt) => !isImportStatement(stmt));
|
|
3386
3595
|
if (addedImports.length > 0) {
|
|
3387
|
-
const fileoverviewAnchorStmt =
|
|
3388
|
-
return
|
|
3596
|
+
const fileoverviewAnchorStmt = ts16.factory.createNotEmittedStatement(sf);
|
|
3597
|
+
return ts16.factory.updateSourceFile(sf, ts16.factory.createNodeArray([
|
|
3389
3598
|
fileoverviewAnchorStmt,
|
|
3390
3599
|
...existingImports,
|
|
3391
3600
|
...addedImports,
|
|
@@ -3396,7 +3605,7 @@ function addImports(importManager, sf, extraStatements = []) {
|
|
|
3396
3605
|
return sf;
|
|
3397
3606
|
}
|
|
3398
3607
|
function isImportStatement(stmt) {
|
|
3399
|
-
return
|
|
3608
|
+
return ts16.isImportDeclaration(stmt) || ts16.isImportEqualsDeclaration(stmt) || ts16.isNamespaceImport(stmt);
|
|
3400
3609
|
}
|
|
3401
3610
|
|
|
3402
3611
|
// bazel-out/k8-fastbuild/bin/packages/compiler-cli/src/ngtsc/transform/src/declaration.mjs
|
|
@@ -3414,7 +3623,7 @@ var DtsTransformRegistry = class {
|
|
|
3414
3623
|
if (!sf.isDeclarationFile) {
|
|
3415
3624
|
return null;
|
|
3416
3625
|
}
|
|
3417
|
-
const originalSf =
|
|
3626
|
+
const originalSf = ts17.getOriginalNode(sf);
|
|
3418
3627
|
let transforms = null;
|
|
3419
3628
|
if (this.ivyDeclarationTransforms.has(originalSf)) {
|
|
3420
3629
|
transforms = [];
|
|
@@ -3427,7 +3636,7 @@ function declarationTransformFactory(transformRegistry, importRewriter, importPr
|
|
|
3427
3636
|
return (context) => {
|
|
3428
3637
|
const transformer = new DtsTransformer(context, importRewriter, importPrefix);
|
|
3429
3638
|
return (fileOrBundle) => {
|
|
3430
|
-
if (
|
|
3639
|
+
if (ts17.isBundle(fileOrBundle)) {
|
|
3431
3640
|
return fileOrBundle;
|
|
3432
3641
|
}
|
|
3433
3642
|
const transforms = transformRegistry.getAllTransforms(fileOrBundle);
|
|
@@ -3447,15 +3656,15 @@ var DtsTransformer = class {
|
|
|
3447
3656
|
transform(sf, transforms) {
|
|
3448
3657
|
const imports = new ImportManager(this.importRewriter, this.importPrefix);
|
|
3449
3658
|
const visitor = (node) => {
|
|
3450
|
-
if (
|
|
3659
|
+
if (ts17.isClassDeclaration(node)) {
|
|
3451
3660
|
return this.transformClassDeclaration(node, transforms, imports);
|
|
3452
|
-
} else if (
|
|
3661
|
+
} else if (ts17.isFunctionDeclaration(node)) {
|
|
3453
3662
|
return this.transformFunctionDeclaration(node, transforms, imports);
|
|
3454
3663
|
} else {
|
|
3455
|
-
return
|
|
3664
|
+
return ts17.visitEachChild(node, visitor, this.ctx);
|
|
3456
3665
|
}
|
|
3457
3666
|
};
|
|
3458
|
-
sf =
|
|
3667
|
+
sf = ts17.visitNode(sf, visitor);
|
|
3459
3668
|
return addImports(imports, sf);
|
|
3460
3669
|
}
|
|
3461
3670
|
transformClassDeclaration(clazz, transforms, imports) {
|
|
@@ -3483,7 +3692,7 @@ var DtsTransformer = class {
|
|
|
3483
3692
|
}
|
|
3484
3693
|
}
|
|
3485
3694
|
if (elementsChanged && clazz === newClazz) {
|
|
3486
|
-
newClazz =
|
|
3695
|
+
newClazz = ts17.factory.updateClassDeclaration(clazz, clazz.decorators, clazz.modifiers, clazz.name, clazz.typeParameters, clazz.heritageClauses, elements);
|
|
3487
3696
|
}
|
|
3488
3697
|
return newClazz;
|
|
3489
3698
|
}
|
|
@@ -3505,31 +3714,31 @@ var IvyDeclarationDtsTransform = class {
|
|
|
3505
3714
|
this.declarationFields.set(decl, fields);
|
|
3506
3715
|
}
|
|
3507
3716
|
transformClass(clazz, members, imports) {
|
|
3508
|
-
const original =
|
|
3717
|
+
const original = ts17.getOriginalNode(clazz);
|
|
3509
3718
|
if (!this.declarationFields.has(original)) {
|
|
3510
3719
|
return clazz;
|
|
3511
3720
|
}
|
|
3512
3721
|
const fields = this.declarationFields.get(original);
|
|
3513
3722
|
const newMembers = fields.map((decl) => {
|
|
3514
|
-
const modifiers = [
|
|
3723
|
+
const modifiers = [ts17.factory.createModifier(ts17.SyntaxKind.StaticKeyword)];
|
|
3515
3724
|
const typeRef = translateType(decl.type, imports);
|
|
3516
3725
|
markForEmitAsSingleLine(typeRef);
|
|
3517
|
-
return
|
|
3726
|
+
return ts17.factory.createPropertyDeclaration(void 0, modifiers, decl.name, void 0, typeRef, void 0);
|
|
3518
3727
|
});
|
|
3519
|
-
return
|
|
3728
|
+
return ts17.factory.updateClassDeclaration(clazz, clazz.decorators, clazz.modifiers, clazz.name, clazz.typeParameters, clazz.heritageClauses, [...members, ...newMembers]);
|
|
3520
3729
|
}
|
|
3521
3730
|
};
|
|
3522
3731
|
function markForEmitAsSingleLine(node) {
|
|
3523
|
-
|
|
3524
|
-
|
|
3732
|
+
ts17.setEmitFlags(node, ts17.EmitFlags.SingleLine);
|
|
3733
|
+
ts17.forEachChild(node, markForEmitAsSingleLine);
|
|
3525
3734
|
}
|
|
3526
3735
|
|
|
3527
3736
|
// bazel-out/k8-fastbuild/bin/packages/compiler-cli/src/ngtsc/transform/src/transform.mjs
|
|
3528
3737
|
import { ConstantPool } from "@angular/compiler";
|
|
3529
|
-
import
|
|
3738
|
+
import ts19 from "typescript";
|
|
3530
3739
|
|
|
3531
3740
|
// bazel-out/k8-fastbuild/bin/packages/compiler-cli/src/ngtsc/util/src/visitor.mjs
|
|
3532
|
-
import
|
|
3741
|
+
import ts18 from "typescript";
|
|
3533
3742
|
function visit(node, visitor, context) {
|
|
3534
3743
|
return visitor._visit(node, context);
|
|
3535
3744
|
}
|
|
@@ -3553,8 +3762,8 @@ var Visitor = class {
|
|
|
3553
3762
|
}
|
|
3554
3763
|
_visit(node, context) {
|
|
3555
3764
|
let visitedNode = null;
|
|
3556
|
-
node =
|
|
3557
|
-
if (
|
|
3765
|
+
node = ts18.visitEachChild(node, (child) => this._visit(child, context), context);
|
|
3766
|
+
if (ts18.isClassDeclaration(node)) {
|
|
3558
3767
|
visitedNode = this._visitListEntryNode(node, (node2) => this.visitClassDeclaration(node2));
|
|
3559
3768
|
} else {
|
|
3560
3769
|
visitedNode = this.visitOtherNode(node);
|
|
@@ -3568,7 +3777,7 @@ var Visitor = class {
|
|
|
3568
3777
|
if (node.statements.every((stmt) => !this._before.has(stmt) && !this._after.has(stmt))) {
|
|
3569
3778
|
return node;
|
|
3570
3779
|
}
|
|
3571
|
-
const clone =
|
|
3780
|
+
const clone = ts18.getMutableClone(node);
|
|
3572
3781
|
const newStatements = [];
|
|
3573
3782
|
clone.statements.forEach((stmt) => {
|
|
3574
3783
|
if (this._before.has(stmt)) {
|
|
@@ -3581,7 +3790,7 @@ var Visitor = class {
|
|
|
3581
3790
|
this._after.delete(stmt);
|
|
3582
3791
|
}
|
|
3583
3792
|
});
|
|
3584
|
-
clone.statements =
|
|
3793
|
+
clone.statements = ts18.factory.createNodeArray(newStatements, node.statements.hasTrailingComma);
|
|
3585
3794
|
return clone;
|
|
3586
3795
|
}
|
|
3587
3796
|
};
|
|
@@ -3639,14 +3848,14 @@ var IvyTransformationVisitor = class extends Visitor {
|
|
|
3639
3848
|
const members = [...node.members];
|
|
3640
3849
|
for (const field of this.classCompilationMap.get(node)) {
|
|
3641
3850
|
const exprNode = translateExpression(field.initializer, this.importManager, translateOptions);
|
|
3642
|
-
const property =
|
|
3851
|
+
const property = ts19.factory.createPropertyDeclaration(void 0, [ts19.factory.createToken(ts19.SyntaxKind.StaticKeyword)], field.name, void 0, void 0, exprNode);
|
|
3643
3852
|
if (this.isClosureCompilerEnabled) {
|
|
3644
|
-
|
|
3853
|
+
ts19.addSyntheticLeadingComment(property, ts19.SyntaxKind.MultiLineCommentTrivia, "* @nocollapse ", false);
|
|
3645
3854
|
}
|
|
3646
3855
|
field.statements.map((stmt) => translateStatement(stmt, this.importManager, translateOptions)).forEach((stmt) => statements.push(stmt));
|
|
3647
3856
|
members.push(property);
|
|
3648
3857
|
}
|
|
3649
|
-
node =
|
|
3858
|
+
node = ts19.factory.updateClassDeclaration(node, maybeFilterDecorator(node.decorators, this.compilation.decoratorsFor(node)), node.modifiers, node.name, node.typeParameters, node.heritageClauses || [], members.map((member) => this._stripAngularDecorators(member)));
|
|
3650
3859
|
return { node, after: statements };
|
|
3651
3860
|
}
|
|
3652
3861
|
_angularCoreDecorators(decl) {
|
|
@@ -3675,25 +3884,25 @@ var IvyTransformationVisitor = class extends Visitor {
|
|
|
3675
3884
|
if (filtered.length === 0) {
|
|
3676
3885
|
return void 0;
|
|
3677
3886
|
}
|
|
3678
|
-
const array =
|
|
3887
|
+
const array = ts19.factory.createNodeArray(filtered);
|
|
3679
3888
|
array.pos = node.decorators.pos;
|
|
3680
3889
|
array.end = node.decorators.end;
|
|
3681
3890
|
return array;
|
|
3682
3891
|
}
|
|
3683
3892
|
_stripAngularDecorators(node) {
|
|
3684
|
-
if (
|
|
3685
|
-
node =
|
|
3686
|
-
} else if (
|
|
3687
|
-
node =
|
|
3688
|
-
} else if (
|
|
3689
|
-
node =
|
|
3690
|
-
} else if (
|
|
3691
|
-
node =
|
|
3692
|
-
} else if (
|
|
3693
|
-
node =
|
|
3694
|
-
} else if (
|
|
3893
|
+
if (ts19.isParameter(node)) {
|
|
3894
|
+
node = ts19.factory.updateParameterDeclaration(node, this._nonCoreDecoratorsOnly(node), node.modifiers, node.dotDotDotToken, node.name, node.questionToken, node.type, node.initializer);
|
|
3895
|
+
} else if (ts19.isMethodDeclaration(node) && node.decorators !== void 0) {
|
|
3896
|
+
node = ts19.factory.updateMethodDeclaration(node, this._nonCoreDecoratorsOnly(node), node.modifiers, node.asteriskToken, node.name, node.questionToken, node.typeParameters, node.parameters, node.type, node.body);
|
|
3897
|
+
} else if (ts19.isPropertyDeclaration(node) && node.decorators !== void 0) {
|
|
3898
|
+
node = ts19.factory.updatePropertyDeclaration(node, this._nonCoreDecoratorsOnly(node), node.modifiers, node.name, node.questionToken, node.type, node.initializer);
|
|
3899
|
+
} else if (ts19.isGetAccessor(node)) {
|
|
3900
|
+
node = ts19.factory.updateGetAccessorDeclaration(node, this._nonCoreDecoratorsOnly(node), node.modifiers, node.name, node.parameters, node.type, node.body);
|
|
3901
|
+
} else if (ts19.isSetAccessor(node)) {
|
|
3902
|
+
node = ts19.factory.updateSetAccessorDeclaration(node, this._nonCoreDecoratorsOnly(node), node.modifiers, node.name, node.parameters, node.body);
|
|
3903
|
+
} else if (ts19.isConstructorDeclaration(node)) {
|
|
3695
3904
|
const parameters = node.parameters.map((param) => this._stripAngularDecorators(param));
|
|
3696
|
-
node =
|
|
3905
|
+
node = ts19.factory.updateConstructorDeclaration(node, node.decorators, node.modifiers, parameters, node.body);
|
|
3697
3906
|
}
|
|
3698
3907
|
return node;
|
|
3699
3908
|
}
|
|
@@ -3705,7 +3914,7 @@ function transformIvySourceFile(compilation, context, reflector, importRewriter,
|
|
|
3705
3914
|
visit(file, compilationVisitor, context);
|
|
3706
3915
|
const transformationVisitor = new IvyTransformationVisitor(compilation, compilationVisitor.classCompilationMap, reflector, importManager, recordWrappedNode, isClosureCompilerEnabled, isCore);
|
|
3707
3916
|
let sf = visit(file, transformationVisitor, context);
|
|
3708
|
-
const downlevelTranslatedCode = getLocalizeCompileTarget(context) <
|
|
3917
|
+
const downlevelTranslatedCode = getLocalizeCompileTarget(context) < ts19.ScriptTarget.ES2015;
|
|
3709
3918
|
const constants = constantPool.statements.map((stmt) => translateStatement(stmt, importManager, {
|
|
3710
3919
|
recordWrappedNode,
|
|
3711
3920
|
downlevelTaggedTemplates: downlevelTranslatedCode,
|
|
@@ -3720,17 +3929,17 @@ function transformIvySourceFile(compilation, context, reflector, importRewriter,
|
|
|
3720
3929
|
return sf;
|
|
3721
3930
|
}
|
|
3722
3931
|
function getLocalizeCompileTarget(context) {
|
|
3723
|
-
const target = context.getCompilerOptions().target ||
|
|
3724
|
-
return target !==
|
|
3932
|
+
const target = context.getCompilerOptions().target || ts19.ScriptTarget.ES2015;
|
|
3933
|
+
return target !== ts19.ScriptTarget.JSON ? target : ts19.ScriptTarget.ES2015;
|
|
3725
3934
|
}
|
|
3726
3935
|
function getFileOverviewComment(statements) {
|
|
3727
3936
|
if (statements.length > 0) {
|
|
3728
3937
|
const host = statements[0];
|
|
3729
3938
|
let trailing = false;
|
|
3730
|
-
let comments =
|
|
3939
|
+
let comments = ts19.getSyntheticLeadingComments(host);
|
|
3731
3940
|
if (!comments || comments.length === 0) {
|
|
3732
3941
|
trailing = true;
|
|
3733
|
-
comments =
|
|
3942
|
+
comments = ts19.getSyntheticTrailingComments(host);
|
|
3734
3943
|
}
|
|
3735
3944
|
if (comments && comments.length > 0 && CLOSURE_FILE_OVERVIEW_REGEXP.test(comments[0].text)) {
|
|
3736
3945
|
return { comments, host, trailing };
|
|
@@ -3742,22 +3951,22 @@ function setFileOverviewComment(sf, fileoverview) {
|
|
|
3742
3951
|
const { comments, host, trailing } = fileoverview;
|
|
3743
3952
|
if (sf.statements.length > 0 && host !== sf.statements[0]) {
|
|
3744
3953
|
if (trailing) {
|
|
3745
|
-
|
|
3954
|
+
ts19.setSyntheticTrailingComments(host, void 0);
|
|
3746
3955
|
} else {
|
|
3747
|
-
|
|
3956
|
+
ts19.setSyntheticLeadingComments(host, void 0);
|
|
3748
3957
|
}
|
|
3749
|
-
|
|
3958
|
+
ts19.setSyntheticLeadingComments(sf.statements[0], comments);
|
|
3750
3959
|
}
|
|
3751
3960
|
}
|
|
3752
3961
|
function maybeFilterDecorator(decorators, toRemove) {
|
|
3753
3962
|
if (decorators === void 0) {
|
|
3754
3963
|
return void 0;
|
|
3755
3964
|
}
|
|
3756
|
-
const filtered = decorators.filter((dec) => toRemove.find((decToRemove) =>
|
|
3965
|
+
const filtered = decorators.filter((dec) => toRemove.find((decToRemove) => ts19.getOriginalNode(dec) === decToRemove) === void 0);
|
|
3757
3966
|
if (filtered.length === 0) {
|
|
3758
3967
|
return void 0;
|
|
3759
3968
|
}
|
|
3760
|
-
return
|
|
3969
|
+
return ts19.factory.createNodeArray(filtered);
|
|
3761
3970
|
}
|
|
3762
3971
|
function isFromAngularCore(decorator) {
|
|
3763
3972
|
return decorator.import !== null && decorator.import.from === "@angular/core";
|
|
@@ -3775,8 +3984,8 @@ function createRecorderFn(defaultImportTracker) {
|
|
|
3775
3984
|
import { compileClassMetadata, compileDeclareClassMetadata, compileDeclareDirectiveFromMetadata, compileDirectiveFromMetadata, FactoryTarget, makeBindingParser, WrappedNodeExpr as WrappedNodeExpr5 } from "@angular/compiler";
|
|
3776
3985
|
|
|
3777
3986
|
// bazel-out/k8-fastbuild/bin/packages/compiler-cli/src/ngtsc/annotations/directive/src/shared.mjs
|
|
3778
|
-
import { createMayBeForwardRefExpression, emitDistinctChangesOnlyDefaultValue, ExternalExpr as
|
|
3779
|
-
import
|
|
3987
|
+
import { createMayBeForwardRefExpression, emitDistinctChangesOnlyDefaultValue, ExternalExpr as ExternalExpr4, getSafePropertyAccessString, parseHostBindings, verifyHostBindings, WrappedNodeExpr as WrappedNodeExpr4 } from "@angular/compiler";
|
|
3988
|
+
import ts20 from "typescript";
|
|
3780
3989
|
var EMPTY_OBJECT = {};
|
|
3781
3990
|
var QUERY_TYPES = /* @__PURE__ */ new Set([
|
|
3782
3991
|
"ContentChild",
|
|
@@ -3792,7 +4001,7 @@ function extractDirectiveMetadata(clazz, decorator, reflector, evaluator, isCore
|
|
|
3792
4001
|
throw new FatalDiagnosticError(ErrorCode.DECORATOR_ARITY_WRONG, Decorator.nodeForError(decorator), `Incorrect number of arguments to @${decorator.name} decorator`);
|
|
3793
4002
|
} else {
|
|
3794
4003
|
const meta = unwrapExpression(decorator.args[0]);
|
|
3795
|
-
if (!
|
|
4004
|
+
if (!ts20.isObjectLiteralExpression(meta)) {
|
|
3796
4005
|
throw new FatalDiagnosticError(ErrorCode.DECORATOR_ARG_NOT_LITERAL, meta, `@${decorator.name} argument must be an object literal`);
|
|
3797
4006
|
}
|
|
3798
4007
|
directive = reflectObjectLiteral(meta);
|
|
@@ -3844,7 +4053,7 @@ function extractDirectiveMetadata(clazz, decorator, reflector, evaluator, isCore
|
|
|
3844
4053
|
}
|
|
3845
4054
|
const rawCtorDeps = getConstructorDependencies(clazz, reflector, isCore);
|
|
3846
4055
|
const ctorDeps = selector !== null ? validateConstructorDependencies(clazz, rawCtorDeps) : unwrapConstructorDependencies(rawCtorDeps);
|
|
3847
|
-
const isStructural = ctorDeps !== null && ctorDeps !== "invalid" && ctorDeps.some((dep) => dep.token instanceof
|
|
4056
|
+
const isStructural = ctorDeps !== null && ctorDeps !== "invalid" && ctorDeps.some((dep) => dep.token instanceof ExternalExpr4 && dep.token.value.moduleName === "@angular/core" && dep.token.value.name === "TemplateRef");
|
|
3848
4057
|
let isStandalone = false;
|
|
3849
4058
|
if (directive.has("standalone")) {
|
|
3850
4059
|
const expr = directive.get("standalone");
|
|
@@ -3913,7 +4122,7 @@ function extractQueryMetadata(exprNode, name, args, propertyName, reflector, eva
|
|
|
3913
4122
|
let emitDistinctChangesOnly = emitDistinctChangesOnlyDefaultValue;
|
|
3914
4123
|
if (args.length === 2) {
|
|
3915
4124
|
const optionsExpr = unwrapExpression(args[1]);
|
|
3916
|
-
if (!
|
|
4125
|
+
if (!ts20.isObjectLiteralExpression(optionsExpr)) {
|
|
3917
4126
|
throw new FatalDiagnosticError(ErrorCode.DECORATOR_ARG_NOT_LITERAL, optionsExpr, `@${name} options must be an object literal`);
|
|
3918
4127
|
}
|
|
3919
4128
|
const options = reflectObjectLiteral(optionsExpr);
|
|
@@ -4008,16 +4217,16 @@ function extractHostBindings(members, evaluator, coreModule, metadata) {
|
|
|
4008
4217
|
}
|
|
4009
4218
|
function extractQueriesFromDecorator(queryData, reflector, evaluator, isCore) {
|
|
4010
4219
|
const content = [], view = [];
|
|
4011
|
-
if (!
|
|
4220
|
+
if (!ts20.isObjectLiteralExpression(queryData)) {
|
|
4012
4221
|
throw new FatalDiagnosticError(ErrorCode.VALUE_HAS_WRONG_TYPE, queryData, "Decorator queries metadata must be an object literal");
|
|
4013
4222
|
}
|
|
4014
4223
|
reflectObjectLiteral(queryData).forEach((queryExpr, propertyName) => {
|
|
4015
4224
|
queryExpr = unwrapExpression(queryExpr);
|
|
4016
|
-
if (!
|
|
4225
|
+
if (!ts20.isNewExpression(queryExpr)) {
|
|
4017
4226
|
throw new FatalDiagnosticError(ErrorCode.VALUE_HAS_WRONG_TYPE, queryData, "Decorator query metadata must be an instance of a query type");
|
|
4018
4227
|
}
|
|
4019
|
-
const queryType =
|
|
4020
|
-
if (!
|
|
4228
|
+
const queryType = ts20.isPropertyAccessExpression(queryExpr.expression) ? queryExpr.expression.name : queryExpr.expression;
|
|
4229
|
+
if (!ts20.isIdentifier(queryType)) {
|
|
4021
4230
|
throw new FatalDiagnosticError(ErrorCode.VALUE_HAS_WRONG_TYPE, queryData, "Decorator query metadata must be an instance of a query type");
|
|
4022
4231
|
}
|
|
4023
4232
|
const type = reflector.getImportOfIdentifier(queryType);
|
|
@@ -4263,6 +4472,9 @@ var DirectiveDecoratorHandler = class {
|
|
|
4263
4472
|
}
|
|
4264
4473
|
analyze(node, decorator, flags = HandlerFlags.NONE) {
|
|
4265
4474
|
if (this.compileUndecoratedClassesWithAngularFeatures === false && decorator === null) {
|
|
4475
|
+
if (this.isCore) {
|
|
4476
|
+
return {};
|
|
4477
|
+
}
|
|
4266
4478
|
return { diagnostics: [getUndecoratedClassWithAngularFeaturesDiagnostic(node)] };
|
|
4267
4479
|
}
|
|
4268
4480
|
this.perf.eventCount(PerfEvent.AnalyzeDirective);
|
|
@@ -4296,7 +4508,7 @@ var DirectiveDecoratorHandler = class {
|
|
|
4296
4508
|
register(node, analysis) {
|
|
4297
4509
|
const ref = new Reference(node);
|
|
4298
4510
|
this.metaRegistry.registerDirectiveMetadata(__spreadProps(__spreadValues({
|
|
4299
|
-
|
|
4511
|
+
kind: MetaKind.Directive,
|
|
4300
4512
|
ref,
|
|
4301
4513
|
name: node.name.text,
|
|
4302
4514
|
selector: analysis.meta.selector,
|
|
@@ -4310,7 +4522,9 @@ var DirectiveDecoratorHandler = class {
|
|
|
4310
4522
|
isPoisoned: analysis.isPoisoned,
|
|
4311
4523
|
isStructural: analysis.isStructural,
|
|
4312
4524
|
animationTriggerNames: null,
|
|
4313
|
-
isStandalone: analysis.meta.isStandalone
|
|
4525
|
+
isStandalone: analysis.meta.isStandalone,
|
|
4526
|
+
imports: null,
|
|
4527
|
+
schemas: null
|
|
4314
4528
|
}));
|
|
4315
4529
|
this.injectableRegistry.registerInjectable(node);
|
|
4316
4530
|
}
|
|
@@ -4355,8 +4569,8 @@ var DirectiveDecoratorHandler = class {
|
|
|
4355
4569
|
};
|
|
4356
4570
|
|
|
4357
4571
|
// bazel-out/k8-fastbuild/bin/packages/compiler-cli/src/ngtsc/annotations/ng_module/src/handler.mjs
|
|
4358
|
-
import { compileClassMetadata as compileClassMetadata2, compileDeclareClassMetadata as compileDeclareClassMetadata2, compileDeclareInjectorFromMetadata, compileDeclareNgModuleFromMetadata, compileInjector, compileNgModule,
|
|
4359
|
-
import
|
|
4572
|
+
import { compileClassMetadata as compileClassMetadata2, compileDeclareClassMetadata as compileDeclareClassMetadata2, compileDeclareInjectorFromMetadata, compileDeclareNgModuleFromMetadata, compileInjector, compileNgModule, ExternalExpr as ExternalExpr5, FactoryTarget as FactoryTarget2, InvokeFunctionExpr, LiteralArrayExpr as LiteralArrayExpr2, R3Identifiers, R3SelectorScopeMode, WrappedNodeExpr as WrappedNodeExpr6 } from "@angular/compiler";
|
|
4573
|
+
import ts21 from "typescript";
|
|
4360
4574
|
var NgModuleSymbol = class extends SemanticSymbol {
|
|
4361
4575
|
constructor() {
|
|
4362
4576
|
super(...arguments);
|
|
@@ -4439,8 +4653,8 @@ var NgModuleDecoratorHandler = class {
|
|
|
4439
4653
|
if (decorator.args === null || decorator.args.length > 1) {
|
|
4440
4654
|
throw new FatalDiagnosticError(ErrorCode.DECORATOR_ARITY_WRONG, Decorator.nodeForError(decorator), `Incorrect number of arguments to @NgModule decorator`);
|
|
4441
4655
|
}
|
|
4442
|
-
const meta = decorator.args.length === 1 ? unwrapExpression(decorator.args[0]) :
|
|
4443
|
-
if (!
|
|
4656
|
+
const meta = decorator.args.length === 1 ? unwrapExpression(decorator.args[0]) : ts21.factory.createObjectLiteralExpression([]);
|
|
4657
|
+
if (!ts21.isObjectLiteralExpression(meta)) {
|
|
4444
4658
|
throw new FatalDiagnosticError(ErrorCode.DECORATOR_ARG_NOT_LITERAL, meta, "@NgModule argument must be an object literal");
|
|
4445
4659
|
}
|
|
4446
4660
|
const ngModule = reflectObjectLiteral(meta);
|
|
@@ -4448,7 +4662,7 @@ var NgModuleDecoratorHandler = class {
|
|
|
4448
4662
|
return {};
|
|
4449
4663
|
}
|
|
4450
4664
|
const moduleResolvers = combineResolvers([
|
|
4451
|
-
(
|
|
4665
|
+
(fn, call, resolve, unresolvable) => this._extractModuleFromModuleWithProvidersFn(fn, call, resolve, unresolvable),
|
|
4452
4666
|
forwardRefResolver
|
|
4453
4667
|
]);
|
|
4454
4668
|
const diagnostics = [];
|
|
@@ -4457,7 +4671,7 @@ var NgModuleDecoratorHandler = class {
|
|
|
4457
4671
|
if (ngModule.has("declarations")) {
|
|
4458
4672
|
rawDeclarations = ngModule.get("declarations");
|
|
4459
4673
|
const declarationMeta = this.evaluator.evaluate(rawDeclarations, forwardRefResolver);
|
|
4460
|
-
declarationRefs = this.resolveTypeList(rawDeclarations, declarationMeta, name, "declarations");
|
|
4674
|
+
declarationRefs = this.resolveTypeList(rawDeclarations, declarationMeta, name, "declarations", 0).references;
|
|
4461
4675
|
for (const ref of declarationRefs) {
|
|
4462
4676
|
if (ref.node.getSourceFile().isDeclarationFile) {
|
|
4463
4677
|
const errorNode = ref.getOriginForDiagnostics(rawDeclarations);
|
|
@@ -4469,51 +4683,33 @@ var NgModuleDecoratorHandler = class {
|
|
|
4469
4683
|
return { diagnostics };
|
|
4470
4684
|
}
|
|
4471
4685
|
let importRefs = [];
|
|
4686
|
+
let rawImports = null;
|
|
4472
4687
|
if (ngModule.has("imports")) {
|
|
4473
|
-
|
|
4688
|
+
rawImports = ngModule.get("imports");
|
|
4474
4689
|
const importsMeta = this.evaluator.evaluate(rawImports, moduleResolvers);
|
|
4475
|
-
importRefs = this.resolveTypeList(rawImports, importsMeta, name, "imports");
|
|
4690
|
+
importRefs = this.resolveTypeList(rawImports, importsMeta, name, "imports", 0).references;
|
|
4476
4691
|
}
|
|
4477
4692
|
let exportRefs = [];
|
|
4693
|
+
let rawExports = null;
|
|
4478
4694
|
if (ngModule.has("exports")) {
|
|
4479
|
-
|
|
4695
|
+
rawExports = ngModule.get("exports");
|
|
4480
4696
|
const exportsMeta = this.evaluator.evaluate(rawExports, moduleResolvers);
|
|
4481
|
-
exportRefs = this.resolveTypeList(rawExports, exportsMeta, name, "exports");
|
|
4697
|
+
exportRefs = this.resolveTypeList(rawExports, exportsMeta, name, "exports", 0).references;
|
|
4482
4698
|
this.referencesRegistry.add(node, ...exportRefs);
|
|
4483
4699
|
}
|
|
4484
4700
|
let bootstrapRefs = [];
|
|
4485
4701
|
if (ngModule.has("bootstrap")) {
|
|
4486
4702
|
const expr = ngModule.get("bootstrap");
|
|
4487
4703
|
const bootstrapMeta = this.evaluator.evaluate(expr, forwardRefResolver);
|
|
4488
|
-
bootstrapRefs = this.resolveTypeList(expr, bootstrapMeta, name, "bootstrap");
|
|
4489
|
-
|
|
4490
|
-
|
|
4491
|
-
|
|
4492
|
-
|
|
4493
|
-
const result = this.evaluator.evaluate(rawExpr);
|
|
4494
|
-
if (!Array.isArray(result)) {
|
|
4495
|
-
throw createValueHasWrongTypeError(rawExpr, result, `NgModule.schemas must be an array`);
|
|
4496
|
-
}
|
|
4497
|
-
for (const schemaRef of result) {
|
|
4498
|
-
if (!(schemaRef instanceof Reference)) {
|
|
4499
|
-
throw createValueHasWrongTypeError(rawExpr, result, "NgModule.schemas must be an array of schemas");
|
|
4500
|
-
}
|
|
4501
|
-
const id2 = schemaRef.getIdentityIn(schemaRef.node.getSourceFile());
|
|
4502
|
-
if (id2 === null || schemaRef.ownedByModuleGuess !== "@angular/core") {
|
|
4503
|
-
throw createValueHasWrongTypeError(rawExpr, result, "NgModule.schemas must be an array of schemas");
|
|
4504
|
-
}
|
|
4505
|
-
switch (id2.text) {
|
|
4506
|
-
case "CUSTOM_ELEMENTS_SCHEMA":
|
|
4507
|
-
schemas.push(CUSTOM_ELEMENTS_SCHEMA);
|
|
4508
|
-
break;
|
|
4509
|
-
case "NO_ERRORS_SCHEMA":
|
|
4510
|
-
schemas.push(NO_ERRORS_SCHEMA);
|
|
4511
|
-
break;
|
|
4512
|
-
default:
|
|
4513
|
-
throw createValueHasWrongTypeError(rawExpr, schemaRef, `'${schemaRef.debugName}' is not a valid NgModule schema`);
|
|
4704
|
+
bootstrapRefs = this.resolveTypeList(expr, bootstrapMeta, name, "bootstrap", 0).references;
|
|
4705
|
+
for (const ref of bootstrapRefs) {
|
|
4706
|
+
const dirMeta = this.metaReader.getDirectiveMetadata(ref);
|
|
4707
|
+
if (dirMeta == null ? void 0 : dirMeta.isStandalone) {
|
|
4708
|
+
diagnostics.push(makeStandaloneBootstrapDiagnostic(node, ref, expr));
|
|
4514
4709
|
}
|
|
4515
4710
|
}
|
|
4516
4711
|
}
|
|
4712
|
+
const schemas = ngModule.has("schemas") ? extractSchemas(ngModule.get("schemas"), this.evaluator, "NgModule") : [];
|
|
4517
4713
|
let id = null;
|
|
4518
4714
|
if (ngModule.has("id")) {
|
|
4519
4715
|
const idExpr = ngModule.get("id");
|
|
@@ -4521,7 +4717,7 @@ var NgModuleDecoratorHandler = class {
|
|
|
4521
4717
|
id = new WrappedNodeExpr6(idExpr);
|
|
4522
4718
|
} else {
|
|
4523
4719
|
const diag = makeDiagnostic(ErrorCode.WARN_NGMODULE_ID_UNNECESSARY, idExpr, `Using 'module.id' for NgModule.id is a common anti-pattern that is ignored by the Angular compiler.`);
|
|
4524
|
-
diag.category =
|
|
4720
|
+
diag.category = ts21.DiagnosticCategory.Warning;
|
|
4525
4721
|
diagnostics.push(diag);
|
|
4526
4722
|
}
|
|
4527
4723
|
}
|
|
@@ -4555,16 +4751,38 @@ var NgModuleDecoratorHandler = class {
|
|
|
4555
4751
|
};
|
|
4556
4752
|
const rawProviders = ngModule.has("providers") ? ngModule.get("providers") : null;
|
|
4557
4753
|
const wrapperProviders = rawProviders !== null ? new WrappedNodeExpr6(this.annotateForClosureCompiler ? wrapFunctionExpressionsInParens(rawProviders) : rawProviders) : null;
|
|
4558
|
-
const
|
|
4754
|
+
const topLevelImports = [];
|
|
4559
4755
|
if (ngModule.has("imports")) {
|
|
4560
|
-
|
|
4756
|
+
const rawImports2 = unwrapExpression(ngModule.get("imports"));
|
|
4757
|
+
let topLevelExpressions = [];
|
|
4758
|
+
if (ts21.isArrayLiteralExpression(rawImports2)) {
|
|
4759
|
+
for (const element of rawImports2.elements) {
|
|
4760
|
+
if (ts21.isSpreadElement(element)) {
|
|
4761
|
+
topLevelExpressions.push(element.expression);
|
|
4762
|
+
continue;
|
|
4763
|
+
}
|
|
4764
|
+
topLevelExpressions.push(element);
|
|
4765
|
+
}
|
|
4766
|
+
} else {
|
|
4767
|
+
topLevelExpressions.push(rawImports2);
|
|
4768
|
+
}
|
|
4769
|
+
let absoluteIndex = 0;
|
|
4770
|
+
for (const importExpr of topLevelExpressions) {
|
|
4771
|
+
const resolved = this.evaluator.evaluate(importExpr, moduleResolvers);
|
|
4772
|
+
const { references, hasModuleWithProviders } = this.resolveTypeList(importExpr, [resolved], node.name.text, "imports", absoluteIndex);
|
|
4773
|
+
absoluteIndex += references.length;
|
|
4774
|
+
topLevelImports.push({
|
|
4775
|
+
expression: importExpr,
|
|
4776
|
+
resolvedReferences: references,
|
|
4777
|
+
hasModuleWithProviders
|
|
4778
|
+
});
|
|
4779
|
+
}
|
|
4561
4780
|
}
|
|
4562
4781
|
const injectorMetadata = {
|
|
4563
4782
|
name,
|
|
4564
4783
|
type,
|
|
4565
4784
|
internalType,
|
|
4566
|
-
providers: wrapperProviders
|
|
4567
|
-
imports: injectorImports
|
|
4785
|
+
providers: wrapperProviders
|
|
4568
4786
|
};
|
|
4569
4787
|
const factoryMetadata = {
|
|
4570
4788
|
name,
|
|
@@ -4584,8 +4802,11 @@ var NgModuleDecoratorHandler = class {
|
|
|
4584
4802
|
fac: factoryMetadata,
|
|
4585
4803
|
declarations: declarationRefs,
|
|
4586
4804
|
rawDeclarations,
|
|
4587
|
-
imports:
|
|
4805
|
+
imports: topLevelImports,
|
|
4806
|
+
rawImports,
|
|
4807
|
+
importRefs,
|
|
4588
4808
|
exports: exportRefs,
|
|
4809
|
+
rawExports,
|
|
4589
4810
|
providers: rawProviders,
|
|
4590
4811
|
providersRequiringFactory: rawProviders ? resolveProvidersRequiringFactory(rawProviders, this.reflector, this.evaluator) : null,
|
|
4591
4812
|
classMetadata: extractClassMetadata(node, this.reflector, this.isCore, this.annotateForClosureCompiler),
|
|
@@ -4598,12 +4819,15 @@ var NgModuleDecoratorHandler = class {
|
|
|
4598
4819
|
}
|
|
4599
4820
|
register(node, analysis) {
|
|
4600
4821
|
this.metaRegistry.registerNgModuleMetadata({
|
|
4822
|
+
kind: MetaKind.NgModule,
|
|
4601
4823
|
ref: new Reference(node),
|
|
4602
4824
|
schemas: analysis.schemas,
|
|
4603
4825
|
declarations: analysis.declarations,
|
|
4604
|
-
imports: analysis.
|
|
4826
|
+
imports: analysis.importRefs,
|
|
4605
4827
|
exports: analysis.exports,
|
|
4606
|
-
rawDeclarations: analysis.rawDeclarations
|
|
4828
|
+
rawDeclarations: analysis.rawDeclarations,
|
|
4829
|
+
rawImports: analysis.rawImports,
|
|
4830
|
+
rawExports: analysis.rawExports
|
|
4607
4831
|
});
|
|
4608
4832
|
if (this.factoryTracker !== null) {
|
|
4609
4833
|
this.factoryTracker.track(node.getSourceFile(), {
|
|
@@ -4626,6 +4850,34 @@ var NgModuleDecoratorHandler = class {
|
|
|
4626
4850
|
const data = {
|
|
4627
4851
|
injectorImports: []
|
|
4628
4852
|
};
|
|
4853
|
+
for (const topLevelImport of analysis.imports) {
|
|
4854
|
+
if (topLevelImport.hasModuleWithProviders) {
|
|
4855
|
+
data.injectorImports.push(new WrappedNodeExpr6(topLevelImport.expression));
|
|
4856
|
+
continue;
|
|
4857
|
+
}
|
|
4858
|
+
const refsToEmit = [];
|
|
4859
|
+
for (const ref of topLevelImport.resolvedReferences) {
|
|
4860
|
+
const dirMeta = this.metaReader.getDirectiveMetadata(ref);
|
|
4861
|
+
if (dirMeta !== null && !dirMeta.isComponent) {
|
|
4862
|
+
continue;
|
|
4863
|
+
}
|
|
4864
|
+
const pipeMeta = dirMeta === null ? this.metaReader.getPipeMetadata(ref) : null;
|
|
4865
|
+
if (pipeMeta !== null) {
|
|
4866
|
+
continue;
|
|
4867
|
+
}
|
|
4868
|
+
refsToEmit.push(ref);
|
|
4869
|
+
}
|
|
4870
|
+
if (refsToEmit.length === topLevelImport.resolvedReferences.length) {
|
|
4871
|
+
data.injectorImports.push(new WrappedNodeExpr6(topLevelImport.expression));
|
|
4872
|
+
} else {
|
|
4873
|
+
const context = node.getSourceFile();
|
|
4874
|
+
for (const ref of refsToEmit) {
|
|
4875
|
+
const emittedRef = this.refEmitter.emit(ref, context);
|
|
4876
|
+
assertSuccessfulReferenceEmit(emittedRef, topLevelImport.expression, "class");
|
|
4877
|
+
data.injectorImports.push(emittedRef.expression);
|
|
4878
|
+
}
|
|
4879
|
+
}
|
|
4880
|
+
}
|
|
4629
4881
|
if (scope !== null && !scope.compilation.isPoisoned) {
|
|
4630
4882
|
const context = getSourceFile(node);
|
|
4631
4883
|
for (const exportRef of analysis.exports) {
|
|
@@ -4642,15 +4894,8 @@ var NgModuleDecoratorHandler = class {
|
|
|
4642
4894
|
if (dirMeta.selector === null) {
|
|
4643
4895
|
throw new FatalDiagnosticError(ErrorCode.DIRECTIVE_MISSING_SELECTOR, decl.node, `${refType} ${decl.node.name.text} has no selector, please add it!`);
|
|
4644
4896
|
}
|
|
4645
|
-
if (dirMeta.isStandalone) {
|
|
4646
|
-
diagnostics.push(makeDiagnostic(ErrorCode.NGMODULE_DECLARATION_IS_STANDALONE, decl.getOriginForDiagnostics(analysis.rawDeclarations), `${refType} ${decl.node.name.text} is standalone, and cannot be declared in an NgModule. Did you mean to import it instead?`));
|
|
4647
|
-
}
|
|
4648
4897
|
continue;
|
|
4649
4898
|
}
|
|
4650
|
-
const pipeMeta = this.metaReader.getPipeMetadata(decl);
|
|
4651
|
-
if (pipeMeta !== null && pipeMeta.isStandalone) {
|
|
4652
|
-
diagnostics.push(makeDiagnostic(ErrorCode.NGMODULE_DECLARATION_IS_STANDALONE, decl.getOriginForDiagnostics(analysis.rawDeclarations), `Pipe ${decl.node.name.text} is standalone, and cannot be declared in an NgModule. Did you mean to import it instead?`));
|
|
4653
|
-
}
|
|
4654
4899
|
}
|
|
4655
4900
|
}
|
|
4656
4901
|
if (diagnostics.length > 0) {
|
|
@@ -4667,7 +4912,9 @@ var NgModuleDecoratorHandler = class {
|
|
|
4667
4912
|
}
|
|
4668
4913
|
compileFull(node, { inj, mod, fac, classMetadata, declarations }, { injectorImports }) {
|
|
4669
4914
|
const factoryFn = compileNgFactoryDefField(fac);
|
|
4670
|
-
const ngInjectorDef = compileInjector(
|
|
4915
|
+
const ngInjectorDef = compileInjector(__spreadProps(__spreadValues({}, inj), {
|
|
4916
|
+
imports: injectorImports
|
|
4917
|
+
}));
|
|
4671
4918
|
const ngModuleDef = compileNgModule(mod);
|
|
4672
4919
|
const statements = ngModuleDef.statements;
|
|
4673
4920
|
const metadata = classMetadata !== null ? compileClassMetadata2(classMetadata) : null;
|
|
@@ -4677,15 +4924,14 @@ var NgModuleDecoratorHandler = class {
|
|
|
4677
4924
|
}
|
|
4678
4925
|
compilePartial(node, { inj, fac, mod, classMetadata }, { injectorImports }) {
|
|
4679
4926
|
const factoryFn = compileDeclareFactory(fac);
|
|
4680
|
-
const injectorDef = compileDeclareInjectorFromMetadata(
|
|
4927
|
+
const injectorDef = compileDeclareInjectorFromMetadata(__spreadProps(__spreadValues({}, inj), {
|
|
4928
|
+
imports: injectorImports
|
|
4929
|
+
}));
|
|
4681
4930
|
const ngModuleDef = compileDeclareNgModuleFromMetadata(mod);
|
|
4682
4931
|
const metadata = classMetadata !== null ? compileDeclareClassMetadata2(classMetadata) : null;
|
|
4683
4932
|
this.insertMetadataStatement(ngModuleDef.statements, metadata);
|
|
4684
4933
|
return this.compileNgModule(factoryFn, injectorDef, ngModuleDef);
|
|
4685
4934
|
}
|
|
4686
|
-
mergeInjectorImports(inj, injectorImports) {
|
|
4687
|
-
return __spreadProps(__spreadValues({}, inj), { imports: [...inj.imports, ...injectorImports] });
|
|
4688
|
-
}
|
|
4689
4935
|
insertMetadataStatement(ngModuleStatements, metadata) {
|
|
4690
4936
|
if (metadata !== null) {
|
|
4691
4937
|
ngModuleStatements.unshift(metadata.toStmt());
|
|
@@ -4711,7 +4957,7 @@ var NgModuleDecoratorHandler = class {
|
|
|
4711
4957
|
const componentType = this.refEmitter.emit(decl, context);
|
|
4712
4958
|
assertSuccessfulReferenceEmit(componentType, node, "component");
|
|
4713
4959
|
const declExpr = componentType.expression;
|
|
4714
|
-
const setComponentScope = new
|
|
4960
|
+
const setComponentScope = new ExternalExpr5(R3Identifiers.setComponentScope);
|
|
4715
4961
|
const callExpr = new InvokeFunctionExpr(setComponentScope, [declExpr, directiveArray, pipesArray]);
|
|
4716
4962
|
ngModuleStatements.push(callExpr.toStmt());
|
|
4717
4963
|
}
|
|
@@ -4747,15 +4993,26 @@ var NgModuleDecoratorHandler = class {
|
|
|
4747
4993
|
return toR3Reference(origin, valueRef, typeRef, valueContext, typeContext, this.refEmitter);
|
|
4748
4994
|
}
|
|
4749
4995
|
}
|
|
4750
|
-
_extractModuleFromModuleWithProvidersFn(node) {
|
|
4751
|
-
const
|
|
4752
|
-
|
|
4996
|
+
_extractModuleFromModuleWithProvidersFn(fn, node, resolve, unresolvable) {
|
|
4997
|
+
const rawType = fn.node.type || null;
|
|
4998
|
+
const type = rawType && (this._reflectModuleFromTypeParam(rawType, fn.node) || this._reflectModuleFromLiteralType(rawType));
|
|
4999
|
+
if (type === null) {
|
|
5000
|
+
return unresolvable;
|
|
5001
|
+
}
|
|
5002
|
+
const ngModule = resolve(type);
|
|
5003
|
+
if (!(ngModule instanceof Reference) || !isNamedClassDeclaration(ngModule.node)) {
|
|
5004
|
+
return unresolvable;
|
|
5005
|
+
}
|
|
5006
|
+
return new SyntheticValue({
|
|
5007
|
+
ngModule,
|
|
5008
|
+
mwpCall: node
|
|
5009
|
+
});
|
|
4753
5010
|
}
|
|
4754
5011
|
_reflectModuleFromTypeParam(type, node) {
|
|
4755
|
-
if (!
|
|
5012
|
+
if (!ts21.isTypeReferenceNode(type)) {
|
|
4756
5013
|
return null;
|
|
4757
5014
|
}
|
|
4758
|
-
const typeName = type && (
|
|
5015
|
+
const typeName = type && (ts21.isIdentifier(type.typeName) && type.typeName || ts21.isQualifiedName(type.typeName) && type.typeName.right) || null;
|
|
4759
5016
|
if (typeName === null) {
|
|
4760
5017
|
return null;
|
|
4761
5018
|
}
|
|
@@ -4767,7 +5024,7 @@ var NgModuleDecoratorHandler = class {
|
|
|
4767
5024
|
return null;
|
|
4768
5025
|
}
|
|
4769
5026
|
if (type.typeArguments === void 0 || type.typeArguments.length !== 1) {
|
|
4770
|
-
const parent =
|
|
5027
|
+
const parent = ts21.isMethodDeclaration(node) && ts21.isClassDeclaration(node.parent) ? node.parent : null;
|
|
4771
5028
|
const symbolName = (parent && parent.name ? parent.name.getText() + "." : "") + (node.name ? node.name.getText() : "anonymous");
|
|
4772
5029
|
throw new FatalDiagnosticError(ErrorCode.NGMODULE_MODULE_WITH_PROVIDERS_MISSING_GENERIC, type, `${symbolName} returns a ModuleWithProviders type without a generic type argument. Please add a generic type argument to the ModuleWithProviders type. If this occurrence is in library code you don't control, please contact the library authors.`);
|
|
4773
5030
|
}
|
|
@@ -4775,13 +5032,13 @@ var NgModuleDecoratorHandler = class {
|
|
|
4775
5032
|
return typeNodeToValueExpr(arg);
|
|
4776
5033
|
}
|
|
4777
5034
|
_reflectModuleFromLiteralType(type) {
|
|
4778
|
-
if (!
|
|
5035
|
+
if (!ts21.isIntersectionTypeNode(type)) {
|
|
4779
5036
|
return null;
|
|
4780
5037
|
}
|
|
4781
5038
|
for (const t of type.types) {
|
|
4782
|
-
if (
|
|
5039
|
+
if (ts21.isTypeLiteralNode(t)) {
|
|
4783
5040
|
for (const m of t.members) {
|
|
4784
|
-
const ngModuleType =
|
|
5041
|
+
const ngModuleType = ts21.isPropertySignature(m) && ts21.isIdentifier(m.name) && m.name.text === "ngModule" && m.type || null;
|
|
4785
5042
|
const ngModuleExpression = ngModuleType && typeNodeToValueExpr(ngModuleType);
|
|
4786
5043
|
if (ngModuleExpression) {
|
|
4787
5044
|
return ngModuleExpression;
|
|
@@ -4794,34 +5051,56 @@ var NgModuleDecoratorHandler = class {
|
|
|
4794
5051
|
isClassDeclarationReference(ref) {
|
|
4795
5052
|
return this.reflector.isClass(ref.node);
|
|
4796
5053
|
}
|
|
4797
|
-
resolveTypeList(expr, resolvedList, className, arrayName) {
|
|
5054
|
+
resolveTypeList(expr, resolvedList, className, arrayName, absoluteIndex) {
|
|
5055
|
+
let hasModuleWithProviders = false;
|
|
4798
5056
|
const refList = [];
|
|
4799
5057
|
if (!Array.isArray(resolvedList)) {
|
|
4800
5058
|
throw createValueHasWrongTypeError(expr, resolvedList, `Expected array when reading the NgModule.${arrayName} of ${className}`);
|
|
4801
5059
|
}
|
|
4802
|
-
resolvedList.
|
|
4803
|
-
|
|
5060
|
+
for (let idx = 0; idx < resolvedList.length; idx++) {
|
|
5061
|
+
let entry = resolvedList[idx];
|
|
5062
|
+
if (entry instanceof SyntheticValue && isResolvedModuleWithProviders(entry)) {
|
|
5063
|
+
entry = entry.value.ngModule;
|
|
5064
|
+
hasModuleWithProviders = true;
|
|
5065
|
+
} else if (entry instanceof Map && entry.has("ngModule")) {
|
|
4804
5066
|
entry = entry.get("ngModule");
|
|
5067
|
+
hasModuleWithProviders = true;
|
|
4805
5068
|
}
|
|
4806
5069
|
if (Array.isArray(entry)) {
|
|
4807
|
-
|
|
5070
|
+
const recursiveResult = this.resolveTypeList(expr, entry, className, arrayName, absoluteIndex);
|
|
5071
|
+
refList.push(...recursiveResult.references);
|
|
5072
|
+
absoluteIndex += recursiveResult.references.length;
|
|
5073
|
+
hasModuleWithProviders = hasModuleWithProviders || recursiveResult.hasModuleWithProviders;
|
|
4808
5074
|
} else if (entry instanceof Reference) {
|
|
4809
5075
|
if (!this.isClassDeclarationReference(entry)) {
|
|
4810
|
-
throw createValueHasWrongTypeError(entry.node, entry, `Value at position ${
|
|
5076
|
+
throw createValueHasWrongTypeError(entry.node, entry, `Value at position ${absoluteIndex} in the NgModule.${arrayName} of ${className} is not a class`);
|
|
4811
5077
|
}
|
|
4812
5078
|
refList.push(entry);
|
|
5079
|
+
absoluteIndex += 1;
|
|
4813
5080
|
} else {
|
|
4814
|
-
throw createValueHasWrongTypeError(expr, entry, `Value at position ${
|
|
5081
|
+
throw createValueHasWrongTypeError(expr, entry, `Value at position ${absoluteIndex} in the NgModule.${arrayName} of ${className} is not a reference`);
|
|
4815
5082
|
}
|
|
4816
|
-
}
|
|
4817
|
-
return
|
|
5083
|
+
}
|
|
5084
|
+
return {
|
|
5085
|
+
references: refList,
|
|
5086
|
+
hasModuleWithProviders
|
|
5087
|
+
};
|
|
4818
5088
|
}
|
|
4819
5089
|
};
|
|
4820
5090
|
function isNgModule(node, compilation) {
|
|
4821
|
-
return !compilation.
|
|
5091
|
+
return !compilation.dependencies.some((dep) => dep.ref.node === node);
|
|
4822
5092
|
}
|
|
4823
5093
|
function isModuleIdExpression(expr) {
|
|
4824
|
-
return
|
|
5094
|
+
return ts21.isPropertyAccessExpression(expr) && ts21.isIdentifier(expr.expression) && expr.expression.text === "module" && expr.name.text === "id";
|
|
5095
|
+
}
|
|
5096
|
+
function isResolvedModuleWithProviders(sv) {
|
|
5097
|
+
return typeof sv.value === "object" && sv.value != null && sv.value.hasOwnProperty("ngModule") && sv.value.hasOwnProperty("mwpCall");
|
|
5098
|
+
}
|
|
5099
|
+
function makeStandaloneBootstrapDiagnostic(ngModuleClass, bootstrappedClassRef, rawBootstrapExpr) {
|
|
5100
|
+
const componentClassName = bootstrappedClassRef.node.name.text;
|
|
5101
|
+
const message = `The \`${componentClassName}\` class is a standalone component, which can not be used in the \`@NgModule.bootstrap\` array. Use the \`bootstrapApplication\` function for bootstrap instead.`;
|
|
5102
|
+
const relatedInformation = [makeRelatedInformation(ngModuleClass, `The 'bootstrap' array is present on this NgModule.`)];
|
|
5103
|
+
return makeDiagnostic(ErrorCode.NGMODULE_BOOTSTRAP_IS_STANDALONE, getDiagnosticNode(bootstrappedClassRef, rawBootstrapExpr), message, relatedInformation);
|
|
4825
5104
|
}
|
|
4826
5105
|
|
|
4827
5106
|
// bazel-out/k8-fastbuild/bin/packages/compiler-cli/src/ngtsc/annotations/component/src/diagnostics.mjs
|
|
@@ -4849,7 +5128,7 @@ function checkCustomElementSelectorForErrors(selector) {
|
|
|
4849
5128
|
|
|
4850
5129
|
// bazel-out/k8-fastbuild/bin/packages/compiler-cli/src/ngtsc/annotations/component/src/resources.mjs
|
|
4851
5130
|
import { DEFAULT_INTERPOLATION_CONFIG, InterpolationConfig, ParseSourceFile as ParseSourceFile2, parseTemplate } from "@angular/compiler";
|
|
4852
|
-
import
|
|
5131
|
+
import ts22 from "typescript";
|
|
4853
5132
|
function getTemplateDeclarationNodeForError(declaration) {
|
|
4854
5133
|
switch (declaration.isInline) {
|
|
4855
5134
|
case true:
|
|
@@ -4866,7 +5145,7 @@ function extractTemplate(node, template, evaluator, depTracker, resourceLoader,
|
|
|
4866
5145
|
let sourceMapping;
|
|
4867
5146
|
let escapedString = false;
|
|
4868
5147
|
let sourceMapUrl;
|
|
4869
|
-
if (
|
|
5148
|
+
if (ts22.isStringLiteral(template.expression) || ts22.isNoSubstitutionTemplateLiteral(template.expression)) {
|
|
4870
5149
|
sourceParseRange = getTemplateRange(template.expression);
|
|
4871
5150
|
sourceStr = template.expression.getSourceFile().text;
|
|
4872
5151
|
templateContent = template.expression.text;
|
|
@@ -5024,7 +5303,7 @@ function preloadAndParseTemplate(evaluator, resourceLoader, depTracker, preanaly
|
|
|
5024
5303
|
}
|
|
5025
5304
|
function getTemplateRange(templateExpr) {
|
|
5026
5305
|
const startPos = templateExpr.getStart() + 1;
|
|
5027
|
-
const { line, character } =
|
|
5306
|
+
const { line, character } = ts22.getLineAndCharacterOfPosition(templateExpr.getSourceFile(), startPos);
|
|
5028
5307
|
return {
|
|
5029
5308
|
startPos,
|
|
5030
5309
|
startLine: line,
|
|
@@ -5047,27 +5326,38 @@ function makeResourceNotFoundError(file, nodeForError, resourceType) {
|
|
|
5047
5326
|
}
|
|
5048
5327
|
return new FatalDiagnosticError(ErrorCode.COMPONENT_RESOURCE_NOT_FOUND, nodeForError, errorText);
|
|
5049
5328
|
}
|
|
5050
|
-
function
|
|
5329
|
+
function transformDecoratorResources(dec, component, styles, template) {
|
|
5051
5330
|
if (dec.name !== "Component") {
|
|
5052
5331
|
return dec;
|
|
5053
5332
|
}
|
|
5054
|
-
if (!component.has("templateUrl") && !component.has("styleUrls")) {
|
|
5333
|
+
if (!component.has("templateUrl") && !component.has("styleUrls") && !component.has("styles")) {
|
|
5055
5334
|
return dec;
|
|
5056
5335
|
}
|
|
5057
5336
|
const metadata = new Map(component);
|
|
5058
5337
|
if (metadata.has("templateUrl")) {
|
|
5059
5338
|
metadata.delete("templateUrl");
|
|
5060
|
-
metadata.set("template",
|
|
5339
|
+
metadata.set("template", ts22.factory.createStringLiteral(template.content));
|
|
5061
5340
|
}
|
|
5062
|
-
if (metadata.has("styleUrls")) {
|
|
5341
|
+
if (metadata.has("styleUrls") || metadata.has("styles")) {
|
|
5342
|
+
metadata.delete("styles");
|
|
5063
5343
|
metadata.delete("styleUrls");
|
|
5064
|
-
|
|
5344
|
+
if (styles.length > 0) {
|
|
5345
|
+
const styleNodes = styles.reduce((result, style) => {
|
|
5346
|
+
if (style.trim().length > 0) {
|
|
5347
|
+
result.push(ts22.factory.createStringLiteral(style));
|
|
5348
|
+
}
|
|
5349
|
+
return result;
|
|
5350
|
+
}, []);
|
|
5351
|
+
if (styleNodes.length > 0) {
|
|
5352
|
+
metadata.set("styles", ts22.factory.createArrayLiteralExpression(styleNodes));
|
|
5353
|
+
}
|
|
5354
|
+
}
|
|
5065
5355
|
}
|
|
5066
5356
|
const newMetadataFields = [];
|
|
5067
5357
|
for (const [name, value] of metadata.entries()) {
|
|
5068
|
-
newMetadataFields.push(
|
|
5358
|
+
newMetadataFields.push(ts22.factory.createPropertyAssignment(name, value));
|
|
5069
5359
|
}
|
|
5070
|
-
return __spreadProps(__spreadValues({}, dec), { args: [
|
|
5360
|
+
return __spreadProps(__spreadValues({}, dec), { args: [ts22.factory.createObjectLiteralExpression(newMetadataFields)] });
|
|
5071
5361
|
}
|
|
5072
5362
|
function extractComponentStyleUrls(evaluator, component) {
|
|
5073
5363
|
if (!component.has("styleUrls")) {
|
|
@@ -5077,9 +5367,9 @@ function extractComponentStyleUrls(evaluator, component) {
|
|
|
5077
5367
|
}
|
|
5078
5368
|
function extractStyleUrlsFromExpression(evaluator, styleUrlsExpr) {
|
|
5079
5369
|
const styleUrls = [];
|
|
5080
|
-
if (
|
|
5370
|
+
if (ts22.isArrayLiteralExpression(styleUrlsExpr)) {
|
|
5081
5371
|
for (const styleUrlExpr of styleUrlsExpr.elements) {
|
|
5082
|
-
if (
|
|
5372
|
+
if (ts22.isSpreadElement(styleUrlExpr)) {
|
|
5083
5373
|
styleUrls.push(...extractStyleUrlsFromExpression(evaluator, styleUrlExpr.expression));
|
|
5084
5374
|
} else {
|
|
5085
5375
|
const styleUrl = evaluator.evaluate(styleUrlExpr);
|
|
@@ -5111,10 +5401,10 @@ function extractStyleUrlsFromExpression(evaluator, styleUrlsExpr) {
|
|
|
5111
5401
|
function extractStyleResources(resourceLoader, component, containingFile) {
|
|
5112
5402
|
const styles = /* @__PURE__ */ new Set();
|
|
5113
5403
|
function stringLiteralElements(array) {
|
|
5114
|
-
return array.elements.filter((e) =>
|
|
5404
|
+
return array.elements.filter((e) => ts22.isStringLiteralLike(e));
|
|
5115
5405
|
}
|
|
5116
5406
|
const styleUrlsExpr = component.get("styleUrls");
|
|
5117
|
-
if (styleUrlsExpr !== void 0 &&
|
|
5407
|
+
if (styleUrlsExpr !== void 0 && ts22.isArrayLiteralExpression(styleUrlsExpr)) {
|
|
5118
5408
|
for (const expression of stringLiteralElements(styleUrlsExpr)) {
|
|
5119
5409
|
try {
|
|
5120
5410
|
const resourceUrl = resourceLoader.resolve(expression.text, containingFile);
|
|
@@ -5124,7 +5414,7 @@ function extractStyleResources(resourceLoader, component, containingFile) {
|
|
|
5124
5414
|
}
|
|
5125
5415
|
}
|
|
5126
5416
|
const stylesExpr = component.get("styles");
|
|
5127
|
-
if (stylesExpr !== void 0 &&
|
|
5417
|
+
if (stylesExpr !== void 0 && ts22.isArrayLiteralExpression(stylesExpr)) {
|
|
5128
5418
|
for (const expression of stringLiteralElements(stylesExpr)) {
|
|
5129
5419
|
styles.add({ path: null, expression });
|
|
5130
5420
|
}
|
|
@@ -5139,112 +5429,6 @@ function _extractTemplateStyleUrls(template) {
|
|
|
5139
5429
|
return template.styleUrls.map((url) => ({ url, source: 1, nodeForError }));
|
|
5140
5430
|
}
|
|
5141
5431
|
|
|
5142
|
-
// bazel-out/k8-fastbuild/bin/packages/compiler-cli/src/ngtsc/annotations/component/src/scope.mjs
|
|
5143
|
-
function scopeTemplate(scopeReader, dtsScopeReader, scopeRegistry, metaReader, node, analysis, usePoisonedData) {
|
|
5144
|
-
const scope = scopeReader.getScopeForComponent(node);
|
|
5145
|
-
if (analysis.meta.isStandalone && scope !== null) {
|
|
5146
|
-
return null;
|
|
5147
|
-
} else if (scope !== null && scope.compilation.isPoisoned && !usePoisonedData) {
|
|
5148
|
-
return null;
|
|
5149
|
-
}
|
|
5150
|
-
if (scope !== null) {
|
|
5151
|
-
return {
|
|
5152
|
-
directives: scope.compilation.directives,
|
|
5153
|
-
pipes: scope.compilation.pipes,
|
|
5154
|
-
ngModule: scope.ngModule,
|
|
5155
|
-
diagnostics: []
|
|
5156
|
-
};
|
|
5157
|
-
} else if (analysis.meta.isStandalone) {
|
|
5158
|
-
if (analysis.imports === null) {
|
|
5159
|
-
return {
|
|
5160
|
-
directives: [],
|
|
5161
|
-
pipes: [],
|
|
5162
|
-
ngModule: null,
|
|
5163
|
-
diagnostics: []
|
|
5164
|
-
};
|
|
5165
|
-
}
|
|
5166
|
-
const diagnostics = [];
|
|
5167
|
-
const directives = /* @__PURE__ */ new Map();
|
|
5168
|
-
const pipes = /* @__PURE__ */ new Map();
|
|
5169
|
-
for (const ref of analysis.imports.resolved) {
|
|
5170
|
-
const dirMeta = metaReader.getDirectiveMetadata(ref);
|
|
5171
|
-
if (dirMeta !== null) {
|
|
5172
|
-
if (!dirMeta.isStandalone) {
|
|
5173
|
-
diagnostics.push(makeNotStandaloneDiagnostic(scopeReader, ref, analysis.imports.raw, dirMeta.isComponent ? "component" : "directive"));
|
|
5174
|
-
continue;
|
|
5175
|
-
}
|
|
5176
|
-
if (!directives.has(ref.node)) {
|
|
5177
|
-
directives.set(ref.node, dirMeta);
|
|
5178
|
-
}
|
|
5179
|
-
continue;
|
|
5180
|
-
}
|
|
5181
|
-
const pipeMeta = metaReader.getPipeMetadata(ref);
|
|
5182
|
-
if (pipeMeta !== null) {
|
|
5183
|
-
if (!pipeMeta.isStandalone) {
|
|
5184
|
-
diagnostics.push(makeNotStandaloneDiagnostic(scopeReader, ref, analysis.imports.raw, "pipe"));
|
|
5185
|
-
continue;
|
|
5186
|
-
}
|
|
5187
|
-
}
|
|
5188
|
-
const ngModuleMeta = metaReader.getNgModuleMetadata(ref);
|
|
5189
|
-
if (ngModuleMeta !== null) {
|
|
5190
|
-
let scope2;
|
|
5191
|
-
if (ref.node.getSourceFile().isDeclarationFile) {
|
|
5192
|
-
scope2 = dtsScopeReader.resolve(ref);
|
|
5193
|
-
} else {
|
|
5194
|
-
scope2 = scopeRegistry.getScopeOfModule(ref.node);
|
|
5195
|
-
}
|
|
5196
|
-
if (scope2 === null) {
|
|
5197
|
-
continue;
|
|
5198
|
-
}
|
|
5199
|
-
if (scope2.exported.isPoisoned && !usePoisonedData) {
|
|
5200
|
-
return null;
|
|
5201
|
-
}
|
|
5202
|
-
for (const dir of scope2.exported.directives) {
|
|
5203
|
-
if (!directives.has(dir.ref.node)) {
|
|
5204
|
-
directives.set(dir.ref.node, dir);
|
|
5205
|
-
}
|
|
5206
|
-
}
|
|
5207
|
-
for (const pipe of scope2.exported.pipes) {
|
|
5208
|
-
if (!pipes.has(pipe.ref.node)) {
|
|
5209
|
-
pipes.set(pipe.ref.node, pipe);
|
|
5210
|
-
}
|
|
5211
|
-
}
|
|
5212
|
-
}
|
|
5213
|
-
}
|
|
5214
|
-
return {
|
|
5215
|
-
directives: Array.from(directives.values()),
|
|
5216
|
-
pipes: Array.from(pipes.values()),
|
|
5217
|
-
diagnostics,
|
|
5218
|
-
ngModule: null
|
|
5219
|
-
};
|
|
5220
|
-
} else {
|
|
5221
|
-
return {
|
|
5222
|
-
directives: [],
|
|
5223
|
-
pipes: [],
|
|
5224
|
-
ngModule: null,
|
|
5225
|
-
diagnostics: []
|
|
5226
|
-
};
|
|
5227
|
-
}
|
|
5228
|
-
}
|
|
5229
|
-
function makeNotStandaloneDiagnostic(scopeReader, ref, rawExpr, kind) {
|
|
5230
|
-
const scope = scopeReader.getScopeForComponent(ref.node);
|
|
5231
|
-
let relatedInformation = void 0;
|
|
5232
|
-
if (scope !== null) {
|
|
5233
|
-
const isExported3 = scope.exported.directives.some((exp) => exp.ref.node === ref.node) || scope.exported.pipes.some((exp) => exp.ref.node);
|
|
5234
|
-
if (isExported3) {
|
|
5235
|
-
relatedInformation = [makeRelatedInformation(scope.ngModule.name, `It can be imported using its NgModule '${scope.ngModule.name.text}' instead.`)];
|
|
5236
|
-
} else {
|
|
5237
|
-
relatedInformation = [makeRelatedInformation(scope.ngModule.name, `It's declared in the NgModule '${scope.ngModule.name.text}', but is not exported. Consider exporting it.`)];
|
|
5238
|
-
}
|
|
5239
|
-
} else {
|
|
5240
|
-
}
|
|
5241
|
-
let extraText = "";
|
|
5242
|
-
if (relatedInformation === void 0) {
|
|
5243
|
-
extraText = " It must be imported via an NgModule.";
|
|
5244
|
-
}
|
|
5245
|
-
return makeDiagnostic(ErrorCode.COMPONENT_IMPORT_NOT_STANDALONE, ref.getOriginForDiagnostics(rawExpr), `The ${kind} '${ref.node.name.text}' appears in 'imports', but is not standalone and cannot be imported directly.${extraText}`, relatedInformation);
|
|
5246
|
-
}
|
|
5247
|
-
|
|
5248
5432
|
// bazel-out/k8-fastbuild/bin/packages/compiler-cli/src/ngtsc/annotations/component/src/symbol.mjs
|
|
5249
5433
|
var ComponentSymbol = class extends DirectiveSymbol {
|
|
5250
5434
|
constructor() {
|
|
@@ -5281,7 +5465,6 @@ var ComponentSymbol = class extends DirectiveSymbol {
|
|
|
5281
5465
|
};
|
|
5282
5466
|
|
|
5283
5467
|
// bazel-out/k8-fastbuild/bin/packages/compiler-cli/src/ngtsc/annotations/component/src/util.mjs
|
|
5284
|
-
import ts24 from "typescript";
|
|
5285
5468
|
function collectAnimationNames(value, animationTriggerNames) {
|
|
5286
5469
|
if (value instanceof Map) {
|
|
5287
5470
|
const name = value.get("name");
|
|
@@ -5301,19 +5484,18 @@ function collectAnimationNames(value, animationTriggerNames) {
|
|
|
5301
5484
|
function isAngularAnimationsReference(reference, symbolName) {
|
|
5302
5485
|
return reference.ownedByModuleGuess === "@angular/animations" && reference.debugName === symbolName;
|
|
5303
5486
|
}
|
|
5304
|
-
var animationTriggerResolver = (
|
|
5487
|
+
var animationTriggerResolver = (fn, node, resolve, unresolvable) => {
|
|
5305
5488
|
const animationTriggerMethodName = "trigger";
|
|
5306
|
-
if (!isAngularAnimationsReference(
|
|
5307
|
-
return
|
|
5489
|
+
if (!isAngularAnimationsReference(fn, animationTriggerMethodName)) {
|
|
5490
|
+
return unresolvable;
|
|
5308
5491
|
}
|
|
5309
|
-
const triggerNameExpression =
|
|
5492
|
+
const triggerNameExpression = node.arguments[0];
|
|
5310
5493
|
if (!triggerNameExpression) {
|
|
5311
|
-
return
|
|
5494
|
+
return unresolvable;
|
|
5312
5495
|
}
|
|
5313
|
-
const
|
|
5314
|
-
|
|
5315
|
-
|
|
5316
|
-
], true);
|
|
5496
|
+
const res = /* @__PURE__ */ new Map();
|
|
5497
|
+
res.set("name", resolve(triggerNameExpression));
|
|
5498
|
+
return res;
|
|
5317
5499
|
};
|
|
5318
5500
|
function validateAndFlattenComponentImports(imports, expr) {
|
|
5319
5501
|
const flattened = [];
|
|
@@ -5344,7 +5526,6 @@ function validateAndFlattenComponentImports(imports, expr) {
|
|
|
5344
5526
|
}
|
|
5345
5527
|
|
|
5346
5528
|
// bazel-out/k8-fastbuild/bin/packages/compiler-cli/src/ngtsc/annotations/component/src/handler.mjs
|
|
5347
|
-
var EMPTY_MAP = /* @__PURE__ */ new Map();
|
|
5348
5529
|
var EMPTY_ARRAY = [];
|
|
5349
5530
|
var ComponentDecoratorHandler = class {
|
|
5350
5531
|
constructor(reflector, evaluator, metaRegistry, metaReader, scopeReader, dtsScopeReader, scopeRegistry, typeCheckScopeRegistry, resourceRegistry, isCore, resourceLoader, rootDirs, defaultPreserveWhitespaces, i18nUseExternalIds, enableI18nLegacyMessageIdFormat, usePoisonedData, i18nNormalizeLineEndingsInICUs, moduleResolver, cycleAnalyzer, cycleHandlingStrategy, refEmitter, depTracker, injectableRegistry, semanticDepGraphUpdater, annotateForClosureCompiler, perf) {
|
|
@@ -5484,20 +5665,20 @@ var ComponentDecoratorHandler = class {
|
|
|
5484
5665
|
if (component.has("providers")) {
|
|
5485
5666
|
providersRequiringFactory = resolveProvidersRequiringFactory(component.get("providers"), this.reflector, this.evaluator);
|
|
5486
5667
|
}
|
|
5487
|
-
let
|
|
5668
|
+
let resolvedImports = null;
|
|
5669
|
+
let rawImports = null;
|
|
5488
5670
|
if (component.has("imports") && !metadata.isStandalone) {
|
|
5489
5671
|
if (diagnostics === void 0) {
|
|
5490
5672
|
diagnostics = [];
|
|
5491
5673
|
}
|
|
5492
|
-
diagnostics.push(makeDiagnostic(ErrorCode.COMPONENT_NOT_STANDALONE, component.get("imports"), `'imports' is only valid on a component that is standalone
|
|
5674
|
+
diagnostics.push(makeDiagnostic(ErrorCode.COMPONENT_NOT_STANDALONE, component.get("imports"), `'imports' is only valid on a component that is standalone.`, [makeRelatedInformation(node.name, `Did you forget to add 'standalone: true' to this @Component?`)]));
|
|
5675
|
+
isPoisoned = true;
|
|
5493
5676
|
} else if (component.has("imports")) {
|
|
5494
5677
|
const expr = component.get("imports");
|
|
5495
|
-
const imported = this.evaluator.evaluate(expr);
|
|
5678
|
+
const imported = this.evaluator.evaluate(expr, forwardRefResolver);
|
|
5496
5679
|
const { imports: flattened, diagnostics: importDiagnostics } = validateAndFlattenComponentImports(imported, expr);
|
|
5497
|
-
|
|
5498
|
-
|
|
5499
|
-
raw: expr
|
|
5500
|
-
};
|
|
5680
|
+
resolvedImports = flattened;
|
|
5681
|
+
rawImports = expr;
|
|
5501
5682
|
if (importDiagnostics.length > 0) {
|
|
5502
5683
|
isPoisoned = true;
|
|
5503
5684
|
if (diagnostics === void 0) {
|
|
@@ -5506,6 +5687,17 @@ var ComponentDecoratorHandler = class {
|
|
|
5506
5687
|
diagnostics.push(...importDiagnostics);
|
|
5507
5688
|
}
|
|
5508
5689
|
}
|
|
5690
|
+
let schemas = null;
|
|
5691
|
+
if (component.has("schemas") && !metadata.isStandalone) {
|
|
5692
|
+
if (diagnostics === void 0) {
|
|
5693
|
+
diagnostics = [];
|
|
5694
|
+
}
|
|
5695
|
+
diagnostics.push(makeDiagnostic(ErrorCode.COMPONENT_NOT_STANDALONE, component.get("schemas"), `'schemas' is only valid on a component that is standalone.`));
|
|
5696
|
+
} else if (component.has("schemas")) {
|
|
5697
|
+
schemas = extractSchemas(component.get("schemas"), this.evaluator, "Component");
|
|
5698
|
+
} else if (metadata.isStandalone) {
|
|
5699
|
+
schemas = [];
|
|
5700
|
+
}
|
|
5509
5701
|
let template;
|
|
5510
5702
|
if (this.preanalyzeTemplateCache.has(node)) {
|
|
5511
5703
|
const preanalyzed = this.preanalyzeTemplateCache.get(node);
|
|
@@ -5595,7 +5787,7 @@ var ComponentDecoratorHandler = class {
|
|
|
5595
5787
|
relativeContextFilePath
|
|
5596
5788
|
}),
|
|
5597
5789
|
typeCheckMeta: extractDirectiveTypeCheckMeta(node, inputs, this.reflector),
|
|
5598
|
-
classMetadata: extractClassMetadata(node, this.reflector, this.isCore, this.annotateForClosureCompiler, (dec) =>
|
|
5790
|
+
classMetadata: extractClassMetadata(node, this.reflector, this.isCore, this.annotateForClosureCompiler, (dec) => transformDecoratorResources(dec, component, styles, template)),
|
|
5599
5791
|
template,
|
|
5600
5792
|
providersRequiringFactory,
|
|
5601
5793
|
viewProvidersRequiringFactory,
|
|
@@ -5607,7 +5799,9 @@ var ComponentDecoratorHandler = class {
|
|
|
5607
5799
|
},
|
|
5608
5800
|
isPoisoned,
|
|
5609
5801
|
animationTriggerNames,
|
|
5610
|
-
|
|
5802
|
+
rawImports,
|
|
5803
|
+
resolvedImports,
|
|
5804
|
+
schemas
|
|
5611
5805
|
},
|
|
5612
5806
|
diagnostics
|
|
5613
5807
|
};
|
|
@@ -5623,7 +5817,7 @@ var ComponentDecoratorHandler = class {
|
|
|
5623
5817
|
register(node, analysis) {
|
|
5624
5818
|
const ref = new Reference(node);
|
|
5625
5819
|
this.metaRegistry.registerDirectiveMetadata(__spreadProps(__spreadValues({
|
|
5626
|
-
|
|
5820
|
+
kind: MetaKind.Directive,
|
|
5627
5821
|
ref,
|
|
5628
5822
|
name: node.name.text,
|
|
5629
5823
|
selector: analysis.meta.selector,
|
|
@@ -5637,7 +5831,9 @@ var ComponentDecoratorHandler = class {
|
|
|
5637
5831
|
isPoisoned: analysis.isPoisoned,
|
|
5638
5832
|
isStructural: false,
|
|
5639
5833
|
isStandalone: analysis.meta.isStandalone,
|
|
5640
|
-
|
|
5834
|
+
imports: analysis.resolvedImports,
|
|
5835
|
+
animationTriggerNames: analysis.animationTriggerNames,
|
|
5836
|
+
schemas: analysis.schemas
|
|
5641
5837
|
}));
|
|
5642
5838
|
this.resourceRegistry.registerResources(analysis.resources, node);
|
|
5643
5839
|
this.injectableRegistry.registerInjectable(node);
|
|
@@ -5648,14 +5844,15 @@ var ComponentDecoratorHandler = class {
|
|
|
5648
5844
|
}
|
|
5649
5845
|
const scope = this.scopeReader.getScopeForComponent(node);
|
|
5650
5846
|
const selector = analysis.meta.selector;
|
|
5651
|
-
const matcher = new
|
|
5847
|
+
const matcher = new SelectorMatcher2();
|
|
5652
5848
|
if (scope !== null) {
|
|
5653
|
-
|
|
5849
|
+
let { dependencies, isPoisoned } = scope.kind === ComponentScopeKind.NgModule ? scope.compilation : scope;
|
|
5850
|
+
if ((isPoisoned || scope.kind === ComponentScopeKind.NgModule && scope.exported.isPoisoned) && !this.usePoisonedData) {
|
|
5654
5851
|
return null;
|
|
5655
5852
|
}
|
|
5656
|
-
for (const
|
|
5657
|
-
if (
|
|
5658
|
-
matcher.addSelectables(
|
|
5853
|
+
for (const dep of dependencies) {
|
|
5854
|
+
if (dep.kind === MetaKind.Directive && dep.selector !== null) {
|
|
5855
|
+
matcher.addSelectables(CssSelector2.parse(dep.selector), dep);
|
|
5659
5856
|
}
|
|
5660
5857
|
}
|
|
5661
5858
|
}
|
|
@@ -5672,7 +5869,7 @@ var ComponentDecoratorHandler = class {
|
|
|
5672
5869
|
});
|
|
5673
5870
|
}
|
|
5674
5871
|
typeCheck(ctx, node, meta) {
|
|
5675
|
-
if (this.typeCheckScopeRegistry === null || !
|
|
5872
|
+
if (this.typeCheckScopeRegistry === null || !ts23.isClassDeclaration(node)) {
|
|
5676
5873
|
return;
|
|
5677
5874
|
}
|
|
5678
5875
|
if (meta.isPoisoned && !this.usePoisonedData) {
|
|
@@ -5698,90 +5895,120 @@ var ComponentDecoratorHandler = class {
|
|
|
5698
5895
|
const context = getSourceFile(node);
|
|
5699
5896
|
const metadata = analysis.meta;
|
|
5700
5897
|
const data = {
|
|
5701
|
-
|
|
5702
|
-
pipes: EMPTY_MAP,
|
|
5898
|
+
declarations: EMPTY_ARRAY,
|
|
5703
5899
|
declarationListEmitMode: 0
|
|
5704
5900
|
};
|
|
5705
5901
|
const diagnostics = [];
|
|
5706
|
-
const scope =
|
|
5902
|
+
const scope = this.scopeReader.getScopeForComponent(node);
|
|
5707
5903
|
if (scope !== null) {
|
|
5708
|
-
|
|
5709
|
-
const matcher = new SelectorMatcher();
|
|
5710
|
-
for (const dir of scope.directives) {
|
|
5711
|
-
if (dir.selector !== null) {
|
|
5712
|
-
matcher.addSelectables(CssSelector.parse(dir.selector), dir);
|
|
5713
|
-
}
|
|
5714
|
-
}
|
|
5904
|
+
const matcher = new SelectorMatcher2();
|
|
5715
5905
|
const pipes = /* @__PURE__ */ new Map();
|
|
5716
|
-
|
|
5717
|
-
|
|
5906
|
+
const dependencies = scope.kind === ComponentScopeKind.NgModule ? scope.compilation.dependencies : scope.dependencies;
|
|
5907
|
+
for (const dep of dependencies) {
|
|
5908
|
+
if (dep.kind === MetaKind.Directive && dep.selector !== null) {
|
|
5909
|
+
matcher.addSelectables(CssSelector2.parse(dep.selector), dep);
|
|
5910
|
+
} else if (dep.kind === MetaKind.Pipe) {
|
|
5911
|
+
pipes.set(dep.name, dep);
|
|
5912
|
+
}
|
|
5718
5913
|
}
|
|
5719
5914
|
const binder = new R3TargetBinder(matcher);
|
|
5720
5915
|
const bound = binder.bind({ template: metadata.template.nodes });
|
|
5721
|
-
const
|
|
5722
|
-
|
|
5723
|
-
|
|
5724
|
-
|
|
5725
|
-
|
|
5726
|
-
|
|
5727
|
-
importedFile: type.importedFile,
|
|
5728
|
-
selector: directive.selector,
|
|
5729
|
-
inputs: directive.inputs.propertyNames,
|
|
5730
|
-
outputs: directive.outputs.propertyNames,
|
|
5731
|
-
exportAs: directive.exportAs,
|
|
5732
|
-
isComponent: directive.isComponent
|
|
5733
|
-
};
|
|
5734
|
-
});
|
|
5735
|
-
const usedPipes = [];
|
|
5736
|
-
for (const pipeName of bound.getUsedPipes()) {
|
|
5737
|
-
if (!pipes.has(pipeName)) {
|
|
5916
|
+
const used = /* @__PURE__ */ new Set();
|
|
5917
|
+
for (const dir of bound.getUsedDirectives()) {
|
|
5918
|
+
used.add(dir.ref.node);
|
|
5919
|
+
}
|
|
5920
|
+
for (const name of bound.getUsedPipes()) {
|
|
5921
|
+
if (!pipes.has(name)) {
|
|
5738
5922
|
continue;
|
|
5739
5923
|
}
|
|
5740
|
-
|
|
5741
|
-
|
|
5742
|
-
|
|
5743
|
-
|
|
5744
|
-
|
|
5745
|
-
|
|
5746
|
-
|
|
5747
|
-
|
|
5748
|
-
|
|
5924
|
+
used.add(pipes.get(name).ref.node);
|
|
5925
|
+
}
|
|
5926
|
+
const declarations = [];
|
|
5927
|
+
const seen = /* @__PURE__ */ new Set();
|
|
5928
|
+
for (const dep of dependencies) {
|
|
5929
|
+
if (seen.has(dep.ref.node)) {
|
|
5930
|
+
continue;
|
|
5931
|
+
}
|
|
5932
|
+
seen.add(dep.ref.node);
|
|
5933
|
+
switch (dep.kind) {
|
|
5934
|
+
case MetaKind.Directive:
|
|
5935
|
+
if (!used.has(dep.ref.node)) {
|
|
5936
|
+
continue;
|
|
5937
|
+
}
|
|
5938
|
+
const dirType = this.refEmitter.emit(dep.ref, context);
|
|
5939
|
+
assertSuccessfulReferenceEmit(dirType, node.name, dep.isComponent ? "component" : "directive");
|
|
5940
|
+
declarations.push({
|
|
5941
|
+
kind: R3TemplateDependencyKind.Directive,
|
|
5942
|
+
ref: dep.ref,
|
|
5943
|
+
type: dirType.expression,
|
|
5944
|
+
importedFile: dirType.importedFile,
|
|
5945
|
+
selector: dep.selector,
|
|
5946
|
+
inputs: dep.inputs.propertyNames,
|
|
5947
|
+
outputs: dep.outputs.propertyNames,
|
|
5948
|
+
exportAs: dep.exportAs,
|
|
5949
|
+
isComponent: dep.isComponent
|
|
5950
|
+
});
|
|
5951
|
+
break;
|
|
5952
|
+
case MetaKind.Pipe:
|
|
5953
|
+
if (!used.has(dep.ref.node)) {
|
|
5954
|
+
continue;
|
|
5955
|
+
}
|
|
5956
|
+
const pipeType = this.refEmitter.emit(dep.ref, context);
|
|
5957
|
+
assertSuccessfulReferenceEmit(pipeType, node.name, "pipe");
|
|
5958
|
+
declarations.push({
|
|
5959
|
+
kind: R3TemplateDependencyKind.Pipe,
|
|
5960
|
+
type: pipeType.expression,
|
|
5961
|
+
name: dep.name,
|
|
5962
|
+
ref: dep.ref,
|
|
5963
|
+
importedFile: pipeType.importedFile
|
|
5964
|
+
});
|
|
5965
|
+
break;
|
|
5966
|
+
case MetaKind.NgModule:
|
|
5967
|
+
const ngModuleType = this.refEmitter.emit(dep.ref, context);
|
|
5968
|
+
assertSuccessfulReferenceEmit(ngModuleType, node.name, "NgModule");
|
|
5969
|
+
declarations.push({
|
|
5970
|
+
kind: R3TemplateDependencyKind.NgModule,
|
|
5971
|
+
type: ngModuleType.expression,
|
|
5972
|
+
importedFile: ngModuleType.importedFile
|
|
5973
|
+
});
|
|
5974
|
+
break;
|
|
5975
|
+
}
|
|
5749
5976
|
}
|
|
5977
|
+
const isUsedDirective = (decl) => decl.kind === R3TemplateDependencyKind.Directive;
|
|
5978
|
+
const isUsedPipe = (decl) => decl.kind === R3TemplateDependencyKind.Pipe;
|
|
5979
|
+
const getSemanticReference = (decl) => this.semanticDepGraphUpdater.getSemanticReference(decl.ref.node, decl.type);
|
|
5750
5980
|
if (this.semanticDepGraphUpdater !== null) {
|
|
5751
|
-
symbol.usedDirectives =
|
|
5752
|
-
symbol.usedPipes =
|
|
5981
|
+
symbol.usedDirectives = declarations.filter(isUsedDirective).map(getSemanticReference);
|
|
5982
|
+
symbol.usedPipes = declarations.filter(isUsedPipe).map(getSemanticReference);
|
|
5753
5983
|
}
|
|
5754
5984
|
const cyclesFromDirectives = /* @__PURE__ */ new Map();
|
|
5755
|
-
for (const usedDirective of usedDirectives) {
|
|
5756
|
-
const cycle = this._checkForCyclicImport(usedDirective.importedFile, usedDirective.type, context);
|
|
5757
|
-
if (cycle !== null) {
|
|
5758
|
-
cyclesFromDirectives.set(usedDirective, cycle);
|
|
5759
|
-
}
|
|
5760
|
-
}
|
|
5761
5985
|
const cyclesFromPipes = /* @__PURE__ */ new Map();
|
|
5762
|
-
for (const
|
|
5763
|
-
const cycle = this._checkForCyclicImport(
|
|
5986
|
+
for (const usedDep of declarations) {
|
|
5987
|
+
const cycle = this._checkForCyclicImport(usedDep.importedFile, usedDep.type, context);
|
|
5764
5988
|
if (cycle !== null) {
|
|
5765
|
-
|
|
5989
|
+
switch (usedDep.kind) {
|
|
5990
|
+
case R3TemplateDependencyKind.Directive:
|
|
5991
|
+
cyclesFromDirectives.set(usedDep, cycle);
|
|
5992
|
+
break;
|
|
5993
|
+
case R3TemplateDependencyKind.Pipe:
|
|
5994
|
+
cyclesFromPipes.set(usedDep, cycle);
|
|
5995
|
+
break;
|
|
5996
|
+
}
|
|
5766
5997
|
}
|
|
5767
5998
|
}
|
|
5768
5999
|
const cycleDetected = cyclesFromDirectives.size !== 0 || cyclesFromPipes.size !== 0;
|
|
5769
6000
|
if (!cycleDetected) {
|
|
5770
|
-
for (const { type, importedFile } of
|
|
6001
|
+
for (const { type, importedFile } of declarations) {
|
|
5771
6002
|
this._recordSyntheticImport(importedFile, type, context);
|
|
5772
6003
|
}
|
|
5773
|
-
|
|
5774
|
-
|
|
5775
|
-
}
|
|
5776
|
-
const wrapDirectivesAndPipesInClosure = usedDirectives.some((dir) => isExpressionForwardReference(dir.type, node.name, context)) || usedPipes.some((pipe) => isExpressionForwardReference(pipe.expression, node.name, context));
|
|
5777
|
-
data.directives = usedDirectives;
|
|
5778
|
-
data.pipes = new Map(usedPipes.map((pipe) => [pipe.pipeName, pipe.expression]));
|
|
6004
|
+
const wrapDirectivesAndPipesInClosure = declarations.some((decl) => isExpressionForwardReference(decl.type, node.name, context));
|
|
6005
|
+
data.declarations = declarations;
|
|
5779
6006
|
data.declarationListEmitMode = wrapDirectivesAndPipesInClosure ? 1 : 0;
|
|
5780
6007
|
} else {
|
|
5781
6008
|
if (this.cycleHandlingStrategy === 0) {
|
|
5782
|
-
this.scopeRegistry.setComponentRemoteScope(node,
|
|
6009
|
+
this.scopeRegistry.setComponentRemoteScope(node, declarations.filter(isUsedDirective).map((dir) => dir.ref), declarations.filter(isUsedPipe).map((pipe) => pipe.ref));
|
|
5783
6010
|
symbol.isRemotelyScoped = true;
|
|
5784
|
-
if (this.semanticDepGraphUpdater !== null && scope.ngModule !== null) {
|
|
6011
|
+
if (this.semanticDepGraphUpdater !== null && scope.kind === ComponentScopeKind.NgModule && scope.ngModule !== null) {
|
|
5785
6012
|
const moduleSymbol = this.semanticDepGraphUpdater.getSymbol(scope.ngModule);
|
|
5786
6013
|
if (!(moduleSymbol instanceof NgModuleSymbol)) {
|
|
5787
6014
|
throw new Error(`AssertionError: Expected ${scope.ngModule.name} to be an NgModuleSymbol.`);
|
|
@@ -5800,6 +6027,10 @@ var ComponentDecoratorHandler = class {
|
|
|
5800
6027
|
}
|
|
5801
6028
|
}
|
|
5802
6029
|
}
|
|
6030
|
+
if (analysis.resolvedImports !== null && analysis.rawImports !== null) {
|
|
6031
|
+
const standaloneDiagnostics = validateStandaloneImports(analysis.resolvedImports, analysis.rawImports, this.metaReader, this.scopeReader);
|
|
6032
|
+
diagnostics.push(...standaloneDiagnostics);
|
|
6033
|
+
}
|
|
5803
6034
|
if (analysis.providersRequiringFactory !== null && analysis.meta.providers instanceof WrappedNodeExpr7) {
|
|
5804
6035
|
const providerDiagnostics = getProviderDiagnostics(analysis.providersRequiringFactory, analysis.meta.providers.node, this.injectableRegistry);
|
|
5805
6036
|
diagnostics.push(...providerDiagnostics);
|
|
@@ -5846,7 +6077,7 @@ var ComponentDecoratorHandler = class {
|
|
|
5846
6077
|
for (const styleText of analysis.template.styles) {
|
|
5847
6078
|
styles.push(styleText);
|
|
5848
6079
|
}
|
|
5849
|
-
analysis.meta.styles = styles;
|
|
6080
|
+
analysis.meta.styles = styles.filter((s) => s.trim().length > 0);
|
|
5850
6081
|
}
|
|
5851
6082
|
compileFull(node, analysis, resolution, pool) {
|
|
5852
6083
|
if (analysis.template.errors !== null && analysis.template.errors.length > 0) {
|
|
@@ -5889,10 +6120,35 @@ var ComponentDecoratorHandler = class {
|
|
|
5889
6120
|
this.cycleAnalyzer.recordSyntheticImport(origin, imported);
|
|
5890
6121
|
}
|
|
5891
6122
|
};
|
|
6123
|
+
function validateStandaloneImports(importRefs, importExpr, metaReader, scopeReader) {
|
|
6124
|
+
const diagnostics = [];
|
|
6125
|
+
for (const ref of importRefs) {
|
|
6126
|
+
const dirMeta = metaReader.getDirectiveMetadata(ref);
|
|
6127
|
+
if (dirMeta !== null) {
|
|
6128
|
+
if (!dirMeta.isStandalone) {
|
|
6129
|
+
diagnostics.push(makeNotStandaloneDiagnostic(scopeReader, ref, importExpr, dirMeta.isComponent ? "component" : "directive"));
|
|
6130
|
+
}
|
|
6131
|
+
continue;
|
|
6132
|
+
}
|
|
6133
|
+
const pipeMeta = metaReader.getPipeMetadata(ref);
|
|
6134
|
+
if (pipeMeta !== null) {
|
|
6135
|
+
if (!pipeMeta.isStandalone) {
|
|
6136
|
+
diagnostics.push(makeNotStandaloneDiagnostic(scopeReader, ref, importExpr, "pipe"));
|
|
6137
|
+
}
|
|
6138
|
+
continue;
|
|
6139
|
+
}
|
|
6140
|
+
const ngModuleMeta = metaReader.getNgModuleMetadata(ref);
|
|
6141
|
+
if (ngModuleMeta !== null) {
|
|
6142
|
+
continue;
|
|
6143
|
+
}
|
|
6144
|
+
diagnostics.push(makeUnknownComponentImportDiagnostic(ref, importExpr));
|
|
6145
|
+
}
|
|
6146
|
+
return diagnostics;
|
|
6147
|
+
}
|
|
5892
6148
|
|
|
5893
6149
|
// bazel-out/k8-fastbuild/bin/packages/compiler-cli/src/ngtsc/annotations/src/injectable.mjs
|
|
5894
6150
|
import { compileClassMetadata as compileClassMetadata4, compileDeclareClassMetadata as compileDeclareClassMetadata4, compileDeclareInjectableFromMetadata, compileInjectable, createMayBeForwardRefExpression as createMayBeForwardRefExpression2, FactoryTarget as FactoryTarget4, LiteralExpr as LiteralExpr3, WrappedNodeExpr as WrappedNodeExpr8 } from "@angular/compiler";
|
|
5895
|
-
import
|
|
6151
|
+
import ts24 from "typescript";
|
|
5896
6152
|
var InjectableDecoratorHandler = class {
|
|
5897
6153
|
constructor(reflector, isCore, strictCtorDeps, injectableRegistry, perf, errorOnDuplicateProv = true) {
|
|
5898
6154
|
this.reflector = reflector;
|
|
@@ -5983,7 +6239,7 @@ function extractInjectableMetadata(clazz, decorator, reflector) {
|
|
|
5983
6239
|
};
|
|
5984
6240
|
} else if (decorator.args.length === 1) {
|
|
5985
6241
|
const metaNode = decorator.args[0];
|
|
5986
|
-
if (!
|
|
6242
|
+
if (!ts24.isObjectLiteralExpression(metaNode)) {
|
|
5987
6243
|
throw new FatalDiagnosticError(ErrorCode.DECORATOR_ARG_NOT_LITERAL, metaNode, `@Injectable argument must be an object literal`);
|
|
5988
6244
|
}
|
|
5989
6245
|
const meta = reflectObjectLiteral(metaNode);
|
|
@@ -5991,7 +6247,7 @@ function extractInjectableMetadata(clazz, decorator, reflector) {
|
|
|
5991
6247
|
let deps = void 0;
|
|
5992
6248
|
if ((meta.has("useClass") || meta.has("useFactory")) && meta.has("deps")) {
|
|
5993
6249
|
const depsExpr = meta.get("deps");
|
|
5994
|
-
if (!
|
|
6250
|
+
if (!ts24.isArrayLiteralExpression(depsExpr)) {
|
|
5995
6251
|
throw new FatalDiagnosticError(ErrorCode.VALUE_NOT_LITERAL, depsExpr, `@Injectable deps metadata must be an inline array`);
|
|
5996
6252
|
}
|
|
5997
6253
|
deps = depsExpr.elements.map((dep) => getDep(dep, reflector));
|
|
@@ -6073,12 +6329,12 @@ function getDep(dep, reflector) {
|
|
|
6073
6329
|
}
|
|
6074
6330
|
return true;
|
|
6075
6331
|
}
|
|
6076
|
-
if (
|
|
6332
|
+
if (ts24.isArrayLiteralExpression(dep)) {
|
|
6077
6333
|
dep.elements.forEach((el) => {
|
|
6078
6334
|
let isDecorator = false;
|
|
6079
|
-
if (
|
|
6335
|
+
if (ts24.isIdentifier(el)) {
|
|
6080
6336
|
isDecorator = maybeUpdateDecorator(el, reflector);
|
|
6081
|
-
} else if (
|
|
6337
|
+
} else if (ts24.isNewExpression(el) && ts24.isIdentifier(el.expression)) {
|
|
6082
6338
|
const token = el.arguments && el.arguments.length > 0 && el.arguments[0] || void 0;
|
|
6083
6339
|
isDecorator = maybeUpdateDecorator(el.expression, reflector, token);
|
|
6084
6340
|
}
|
|
@@ -6092,7 +6348,7 @@ function getDep(dep, reflector) {
|
|
|
6092
6348
|
|
|
6093
6349
|
// bazel-out/k8-fastbuild/bin/packages/compiler-cli/src/ngtsc/annotations/src/pipe.mjs
|
|
6094
6350
|
import { compileClassMetadata as compileClassMetadata5, compileDeclareClassMetadata as compileDeclareClassMetadata5, compileDeclarePipeFromMetadata, compilePipeFromMetadata, FactoryTarget as FactoryTarget5, WrappedNodeExpr as WrappedNodeExpr9 } from "@angular/compiler";
|
|
6095
|
-
import
|
|
6351
|
+
import ts25 from "typescript";
|
|
6096
6352
|
var PipeSymbol = class extends SemanticSymbol {
|
|
6097
6353
|
constructor(decl, name) {
|
|
6098
6354
|
super(decl);
|
|
@@ -6147,7 +6403,7 @@ var PipeDecoratorHandler = class {
|
|
|
6147
6403
|
throw new FatalDiagnosticError(ErrorCode.DECORATOR_ARITY_WRONG, Decorator.nodeForError(decorator), "@Pipe must have exactly one argument");
|
|
6148
6404
|
}
|
|
6149
6405
|
const meta = unwrapExpression(decorator.args[0]);
|
|
6150
|
-
if (!
|
|
6406
|
+
if (!ts25.isObjectLiteralExpression(meta)) {
|
|
6151
6407
|
throw new FatalDiagnosticError(ErrorCode.DECORATOR_ARG_NOT_LITERAL, meta, "@Pipe must have a literal argument");
|
|
6152
6408
|
}
|
|
6153
6409
|
const pipe = reflectObjectLiteral(meta);
|
|
@@ -6195,12 +6451,12 @@ var PipeDecoratorHandler = class {
|
|
|
6195
6451
|
};
|
|
6196
6452
|
}
|
|
6197
6453
|
symbol(node, analysis) {
|
|
6198
|
-
return new PipeSymbol(node, analysis.meta.
|
|
6454
|
+
return new PipeSymbol(node, analysis.meta.pipeName);
|
|
6199
6455
|
}
|
|
6200
6456
|
register(node, analysis) {
|
|
6201
6457
|
const ref = new Reference(node);
|
|
6202
6458
|
this.metaRegistry.registerPipeMetadata({
|
|
6203
|
-
|
|
6459
|
+
kind: MetaKind.Pipe,
|
|
6204
6460
|
ref,
|
|
6205
6461
|
name: analysis.meta.pipeName,
|
|
6206
6462
|
nameExpr: analysis.pipeNameExpr,
|
|
@@ -6239,25 +6495,21 @@ export {
|
|
|
6239
6495
|
PartialEvaluator,
|
|
6240
6496
|
NoopReferencesRegistry,
|
|
6241
6497
|
SemanticDepGraphUpdater,
|
|
6498
|
+
MetaKind,
|
|
6242
6499
|
CompoundMetadataReader,
|
|
6243
6500
|
DtsMetadataReader,
|
|
6244
|
-
flattenInheritedDirectiveMetadata,
|
|
6245
6501
|
LocalMetadataRegistry,
|
|
6246
6502
|
CompoundMetadataRegistry,
|
|
6247
6503
|
InjectableClassRegistry,
|
|
6248
6504
|
ResourceRegistry,
|
|
6505
|
+
ComponentScopeKind,
|
|
6506
|
+
CompoundComponentScopeReader,
|
|
6507
|
+
MetadataDtsModuleScopeResolver,
|
|
6508
|
+
LocalModuleScopeRegistry,
|
|
6509
|
+
TypeCheckScopeRegistry,
|
|
6249
6510
|
CompilationMode,
|
|
6250
6511
|
HandlerFlags,
|
|
6251
6512
|
aliasTransformFactory,
|
|
6252
|
-
isShim,
|
|
6253
|
-
copyFileShimData,
|
|
6254
|
-
untagAllTsFiles,
|
|
6255
|
-
retagAllTsFiles,
|
|
6256
|
-
ShimAdapter,
|
|
6257
|
-
FactoryGenerator,
|
|
6258
|
-
generatedFactoryTransform,
|
|
6259
|
-
ShimReferenceTagger,
|
|
6260
|
-
SummaryGenerator,
|
|
6261
6513
|
TraitState,
|
|
6262
6514
|
TraitCompiler,
|
|
6263
6515
|
DtsTransformRegistry,
|
|
@@ -6276,5 +6528,4 @@ export {
|
|
|
6276
6528
|
* Use of this source code is governed by an MIT-style license that can be
|
|
6277
6529
|
* found in the LICENSE file at https://angular.io/license
|
|
6278
6530
|
*/
|
|
6279
|
-
|
|
6280
|
-
//# sourceMappingURL=chunk-GYVY4Y2L.js.map
|
|
6531
|
+
//# sourceMappingURL=chunk-GJVJ6GH4.js.map
|