UNPKG

@angular/compiler-cli

Version:
1,355 lines (1,322 loc) • 186 kB
import {createRequire as __cjsCompatRequire} from 'module'; const require = __cjsCompatRequire(import.meta.url); import { CompilationMode, ComponentDecoratorHandler, ComponentScopeKind, CompoundComponentScopeReader, CompoundMetadataReader, CompoundMetadataRegistry, DirectiveDecoratorHandler, DtsMetadataReader, DtsTransformRegistry, ExportedProviderStatusResolver, HostDirectivesResolver, INPUT_INITIALIZER_FN, InjectableClassRegistry, InjectableDecoratorHandler, LocalMetadataRegistry, LocalModuleScopeRegistry, MODEL_INITIALIZER_FN, MetaKind, MetadataDtsModuleScopeResolver, NgModuleDecoratorHandler, NgOriginalFile, NoopReferencesRegistry, OUTPUT_INITIALIZER_FNS, OptimizeFor, PartialEvaluator, PipeDecoratorHandler, QUERY_INITIALIZER_FNS, ResourceRegistry, SemanticDepGraphUpdater, ShimAdapter, ShimReferenceTagger, SymbolKind, TemplateTypeCheckerImpl, TraitCompiler, TsCreateProgramDriver, TypeCheckScopeRegistry, TypeCheckShimGenerator, aliasTransformFactory, declarationTransformFactory, isShim, ivyTransformFactory, retagAllTsFiles, tryParseInitializerApi, untagAllTsFiles } from "./chunk-E7DMD7OM.js"; import { AbsoluteModuleStrategy, AliasStrategy, COMPILER_ERRORS_WITH_GUIDES, DefaultImportTracker, DeferredSymbolTracker, ERROR_DETAILS_PAGE_BASE_URL, ErrorCode, ExtendedTemplateDiagnosticName, ImportedSymbolsTracker, LocalCompilationExtraImportsTracker, LocalIdentifierStrategy, LogicalProjectStrategy, ModuleResolver, NoopImportRewriter, PrivateExportAliasingHost, R3SymbolsImportRewriter, Reference, ReferenceEmitter, RelativePathStrategy, TypeScriptReflectionHost, UnifiedModulesAliasingHost, UnifiedModulesStrategy, getRootDirs, getSourceFileOrNull, isDtsPath, isFatalDiagnosticError, isNamedClassDeclaration, isNonDeclarationTsPath, makeDiagnostic, ngErrorCode, normalizeSeparators, relativePathBetween, replaceTsWithNgInErrors, toUnredirectedSourceFile } from "./chunk-AOEZR223.js"; import { ActivePerfRecorder, DelegatingPerfRecorder, PerfCheckpoint, PerfEvent, PerfPhase } from "./chunk-AQFTVE7F.js"; import { LogicalFileSystem, absoluteFrom, absoluteFromSourceFile, dirname, getFileSystem, join, resolve } from "./chunk-XNL3EK5H.js"; // bazel-out/darwin_arm64-fastbuild/bin/packages/compiler-cli/src/transformers/api.mjs var DEFAULT_ERROR_CODE = 100; var UNKNOWN_ERROR_CODE = 500; var SOURCE = "angular"; function isTsDiagnostic(diagnostic) { return diagnostic != null && diagnostic.source !== "angular"; } var EmitFlags; (function(EmitFlags2) { EmitFlags2[EmitFlags2["DTS"] = 1] = "DTS"; EmitFlags2[EmitFlags2["JS"] = 2] = "JS"; EmitFlags2[EmitFlags2["Metadata"] = 4] = "Metadata"; EmitFlags2[EmitFlags2["I18nBundle"] = 8] = "I18nBundle"; EmitFlags2[EmitFlags2["Codegen"] = 16] = "Codegen"; EmitFlags2[EmitFlags2["Default"] = 19] = "Default"; EmitFlags2[EmitFlags2["All"] = 31] = "All"; })(EmitFlags || (EmitFlags = {})); // bazel-out/darwin_arm64-fastbuild/bin/packages/compiler-cli/src/transformers/compiler_host.mjs import ts from "typescript"; var wrapHostForTest = null; function createCompilerHost({ options, tsHost = ts.createCompilerHost(options, true) }) { if (wrapHostForTest !== null) { tsHost = wrapHostForTest(tsHost); } return tsHost; } // bazel-out/darwin_arm64-fastbuild/bin/packages/compiler-cli/src/ngtsc/docs/src/entities.mjs var EntryType; (function(EntryType2) { EntryType2["Block"] = "block"; EntryType2["Component"] = "component"; EntryType2["Constant"] = "constant"; EntryType2["Decorator"] = "decorator"; EntryType2["Directive"] = "directive"; EntryType2["Element"] = "element"; EntryType2["Enum"] = "enum"; EntryType2["Function"] = "function"; EntryType2["Interface"] = "interface"; EntryType2["NgModule"] = "ng_module"; EntryType2["Pipe"] = "pipe"; EntryType2["TypeAlias"] = "type_alias"; EntryType2["UndecoratedClass"] = "undecorated_class"; EntryType2["InitializerApiFunction"] = "initializer_api_function"; })(EntryType || (EntryType = {})); var MemberType; (function(MemberType2) { MemberType2["Property"] = "property"; MemberType2["Method"] = "method"; MemberType2["Getter"] = "getter"; MemberType2["Setter"] = "setter"; MemberType2["EnumItem"] = "enum_item"; })(MemberType || (MemberType = {})); var DecoratorType; (function(DecoratorType2) { DecoratorType2["Class"] = "class"; DecoratorType2["Member"] = "member"; DecoratorType2["Parameter"] = "parameter"; })(DecoratorType || (DecoratorType = {})); var MemberTags; (function(MemberTags2) { MemberTags2["Abstract"] = "abstract"; MemberTags2["Static"] = "static"; MemberTags2["Readonly"] = "readonly"; MemberTags2["Protected"] = "protected"; MemberTags2["Optional"] = "optional"; MemberTags2["Input"] = "input"; MemberTags2["Output"] = "output"; MemberTags2["Inherited"] = "override"; })(MemberTags || (MemberTags = {})); function isDocEntryWithSourceInfo(entry) { return "source" in entry; } // bazel-out/darwin_arm64-fastbuild/bin/packages/compiler-cli/src/ngtsc/docs/src/extractor.mjs import ts10 from "typescript"; // bazel-out/darwin_arm64-fastbuild/bin/packages/compiler-cli/src/ngtsc/docs/src/class_extractor.mjs import ts5 from "typescript"; // bazel-out/darwin_arm64-fastbuild/bin/packages/compiler-cli/src/ngtsc/docs/src/filters.mjs function isAngularPrivateName(name) { var _a; const firstChar = (_a = name[0]) != null ? _a : ""; return firstChar === "\u0275" || firstChar === "_"; } // bazel-out/darwin_arm64-fastbuild/bin/packages/compiler-cli/src/ngtsc/docs/src/function_extractor.mjs import ts3 from "typescript"; // bazel-out/darwin_arm64-fastbuild/bin/packages/compiler-cli/src/ngtsc/docs/src/generics_extractor.mjs function extractGenerics(declaration) { var _a, _b; return (_b = (_a = declaration.typeParameters) == null ? void 0 : _a.map((typeParam) => { var _a2, _b2; return { name: typeParam.name.getText(), constraint: (_a2 = typeParam.constraint) == null ? void 0 : _a2.getText(), default: (_b2 = typeParam.default) == null ? void 0 : _b2.getText() }; })) != null ? _b : []; } // bazel-out/darwin_arm64-fastbuild/bin/packages/compiler-cli/src/ngtsc/docs/src/jsdoc_extractor.mjs import ts2 from "typescript"; var decoratorExpression = /@(?=(Injectable|Component|Directive|Pipe|NgModule|Input|Output|HostBinding|HostListener|Inject|Optional|Self|Host|SkipSelf|ViewChild|ViewChildren|ContentChild|ContentChildren))/g; function extractJsDocTags(node) { const escapedNode = getEscapedNode(node); return ts2.getJSDocTags(escapedNode).map((t) => { var _a; return { name: t.tagName.getText(), comment: unescapeAngularDecorators((_a = ts2.getTextOfJSDocComment(t.comment)) != null ? _a : "") }; }); } function extractJsDocDescription(node) { var _a, _b; const escapedNode = getEscapedNode(node); const commentOrTag = ts2.getJSDocCommentsAndTags(escapedNode).find((d) => { return ts2.isJSDoc(d) || ts2.isJSDocParameterTag(d); }); const comment = (_a = commentOrTag == null ? void 0 : commentOrTag.comment) != null ? _a : ""; const description = typeof comment === "string" ? comment : (_b = ts2.getTextOfJSDocComment(comment)) != null ? _b : ""; return unescapeAngularDecorators(description); } function extractRawJsDoc(node) { var _a, _b; const comment = (_b = (_a = ts2.getJSDocCommentsAndTags(node).find(ts2.isJSDoc)) == null ? void 0 : _a.getFullText()) != null ? _b : ""; return unescapeAngularDecorators(comment); } function getEscapedNode(node) { if (ts2.isParameter(node)) { return node; } const rawComment = extractRawJsDoc(node); const escaped = escapeAngularDecorators(rawComment); const file = ts2.createSourceFile("x.ts", `${escaped}class X {}`, ts2.ScriptTarget.ES2020, true); return file.statements.find((s) => ts2.isClassDeclaration(s)); } function escapeAngularDecorators(comment) { return comment.replace(decoratorExpression, "_NG_AT_"); } function unescapeAngularDecorators(comment) { return comment.replace(/_NG_AT_/g, "@"); } // bazel-out/darwin_arm64-fastbuild/bin/packages/compiler-cli/src/ngtsc/docs/src/type_extractor.mjs function extractResolvedTypeString(node, checker) { return checker.typeToString(checker.getTypeAtLocation(node)); } // bazel-out/darwin_arm64-fastbuild/bin/packages/compiler-cli/src/ngtsc/docs/src/function_extractor.mjs var FunctionExtractor = class { constructor(name, declaration, typeChecker) { this.name = name; this.declaration = declaration; this.typeChecker = typeChecker; } extract() { var _a; const signature = this.typeChecker.getSignatureFromDeclaration(this.declaration); const returnType = signature ? this.typeChecker.typeToString( this.typeChecker.getReturnTypeOfSignature(signature), void 0, ts3.TypeFormatFlags.NoTypeReduction | ts3.TypeFormatFlags.NoTruncation ) : "unknown"; const jsdocsTags = extractJsDocTags(this.declaration); return { params: extractAllParams(this.declaration.parameters, this.typeChecker), name: this.name, isNewType: ts3.isConstructSignatureDeclaration(this.declaration), returnType, returnDescription: (_a = jsdocsTags.find((tag) => tag.name === "returns")) == null ? void 0 : _a.comment, entryType: EntryType.Function, generics: extractGenerics(this.declaration), description: extractJsDocDescription(this.declaration), jsdocTags: jsdocsTags, rawComment: extractRawJsDoc(this.declaration) }; } getOverloads() { var _a, _b, _c, _d; const overloads = []; const symbol = this.getSymbol(); const declarationCount = (_b = (_a = symbol == null ? void 0 : symbol.declarations) == null ? void 0 : _a.length) != null ? _b : 0; if (declarationCount > 1) { for (let i = 0; i < declarationCount - 1; i++) { const overloadDeclaration = (_c = symbol == null ? void 0 : symbol.declarations) == null ? void 0 : _c[i]; if ((overloadDeclaration == null ? void 0 : overloadDeclaration.pos) === this.declaration.pos) continue; if (overloadDeclaration && ts3.isFunctionDeclaration(overloadDeclaration) && ((_d = overloadDeclaration.modifiers) == null ? void 0 : _d.some((mod) => mod.kind === ts3.SyntaxKind.ExportKeyword))) { overloads.push(overloadDeclaration); } } } return overloads; } getSymbol() { return this.typeChecker.getSymbolsInScope(this.declaration, ts3.SymbolFlags.Function).find((s) => { var _a; return s.name === ((_a = this.declaration.name) == null ? void 0 : _a.getText()); }); } }; function extractAllParams(params, typeChecker) { return params.map((param) => ({ name: param.name.getText(), description: extractJsDocDescription(param), type: extractResolvedTypeString(param, typeChecker), isOptional: !!(param.questionToken || param.initializer), isRestParam: !!param.dotDotDotToken })); } // bazel-out/darwin_arm64-fastbuild/bin/packages/compiler-cli/src/ngtsc/docs/src/internal.mjs import ts4 from "typescript"; function isInternal(member) { return extractJsDocTags(member).some((tag) => tag.name === "internal") || hasLeadingInternalComment(member); } function hasLeadingInternalComment(member) { var _a; const memberText = member.getSourceFile().text; return (_a = ts4.reduceEachLeadingCommentRange( memberText, member.getFullStart(), (pos, end, kind, hasTrailingNewLine, containsInternal) => { return containsInternal || memberText.slice(pos, end).includes("@internal"); }, false, false )) != null ? _a : false; } // bazel-out/darwin_arm64-fastbuild/bin/packages/compiler-cli/src/ngtsc/docs/src/class_extractor.mjs var ClassExtractor = class { constructor(declaration, typeChecker) { this.declaration = declaration; this.typeChecker = typeChecker; } extract() { return { name: this.declaration.name.text, isAbstract: this.isAbstract(), entryType: ts5.isInterfaceDeclaration(this.declaration) ? EntryType.Interface : EntryType.UndecoratedClass, members: this.extractSignatures().concat(this.extractAllClassMembers()), generics: extractGenerics(this.declaration), description: extractJsDocDescription(this.declaration), jsdocTags: extractJsDocTags(this.declaration), rawComment: extractRawJsDoc(this.declaration) }; } extractAllClassMembers() { const members = []; for (const member of this.getMemberDeclarations()) { if (this.isMemberExcluded(member)) continue; const memberEntry = this.extractClassMember(member); if (memberEntry) { members.push(memberEntry); } } return members; } extractClassMember(memberDeclaration) { if (this.isMethod(memberDeclaration) && !this.isImplementationForOverload(memberDeclaration)) { return this.extractMethod(memberDeclaration); } else if (this.isProperty(memberDeclaration)) { return this.extractClassProperty(memberDeclaration); } else if (ts5.isAccessor(memberDeclaration)) { return this.extractGetterSetter(memberDeclaration); } return void 0; } extractSignatures() { return this.computeAllSignatureDeclarations().map((s) => this.extractSignature(s)); } extractMethod(methodDeclaration) { const functionExtractor = new FunctionExtractor(methodDeclaration.name.getText(), methodDeclaration, this.typeChecker); return { ...functionExtractor.extract(), memberType: MemberType.Method, memberTags: this.getMemberTags(methodDeclaration) }; } extractSignature(signature) { const functionExtractor = new FunctionExtractor(ts5.isConstructSignatureDeclaration(signature) ? "new" : "", signature, this.typeChecker); return { ...functionExtractor.extract(), memberType: MemberType.Method, memberTags: [] }; } extractClassProperty(propertyDeclaration) { return { name: propertyDeclaration.name.getText(), type: extractResolvedTypeString(propertyDeclaration, this.typeChecker), memberType: MemberType.Property, memberTags: this.getMemberTags(propertyDeclaration), description: extractJsDocDescription(propertyDeclaration), jsdocTags: extractJsDocTags(propertyDeclaration) }; } extractGetterSetter(accessor) { return { ...this.extractClassProperty(accessor), memberType: ts5.isGetAccessor(accessor) ? MemberType.Getter : MemberType.Setter }; } getMemberTags(member) { var _a; const tags = this.getMemberTagsFromModifiers((_a = member.modifiers) != null ? _a : []); if (member.questionToken) { tags.push(MemberTags.Optional); } if (member.parent !== this.declaration) { tags.push(MemberTags.Inherited); } return tags; } computeAllSignatureDeclarations() { const type = this.typeChecker.getTypeAtLocation(this.declaration); const signatures = [...type.getCallSignatures(), ...type.getConstructSignatures()]; const result = []; for (const signature of signatures) { const decl = signature.getDeclaration(); if (this.isDocumentableSignature(decl) && this.isDocumentableMember(decl)) { result.push(decl); } } return result; } getMemberDeclarations() { var _a; const type = this.typeChecker.getTypeAtLocation(this.declaration); const members = type.getProperties(); const typeOfConstructor = this.typeChecker.getTypeOfSymbol(type.symbol); const staticMembers = typeOfConstructor.getProperties(); const result = []; for (const member of [...members, ...staticMembers]) { const memberDeclarations = (_a = member.getDeclarations()) != null ? _a : []; for (const memberDeclaration of memberDeclarations) { if (this.isDocumentableMember(memberDeclaration)) { result.push(memberDeclaration); } } } return result; } getMemberTagsFromModifiers(mods) { const tags = []; for (const mod of mods) { const tag = this.getTagForMemberModifier(mod); if (tag) tags.push(tag); } return tags; } getTagForMemberModifier(mod) { switch (mod.kind) { case ts5.SyntaxKind.StaticKeyword: return MemberTags.Static; case ts5.SyntaxKind.ReadonlyKeyword: return MemberTags.Readonly; case ts5.SyntaxKind.ProtectedKeyword: return MemberTags.Protected; case ts5.SyntaxKind.AbstractKeyword: return MemberTags.Abstract; default: return void 0; } } isMemberExcluded(member) { var _a; return !member.name || !this.isDocumentableMember(member) || !ts5.isCallSignatureDeclaration(member) && ((_a = member.modifiers) == null ? void 0 : _a.some((mod) => mod.kind === ts5.SyntaxKind.PrivateKeyword)) || member.name.getText() === "prototype" || isAngularPrivateName(member.name.getText()) || isInternal(member); } isDocumentableMember(member) { return this.isMethod(member) || this.isProperty(member) || ts5.isAccessor(member) || ts5.isCallSignatureDeclaration(member); } isPublicConstructorParameterProperty(node) { if (ts5.isParameterPropertyDeclaration(node, node.parent) && node.modifiers) { return node.modifiers.some((modifier) => modifier.kind === ts5.SyntaxKind.PublicKeyword); } return false; } isProperty(member) { return ts5.isPropertyDeclaration(member) || ts5.isPropertySignature(member) || this.isPublicConstructorParameterProperty(member); } isMethod(member) { return ts5.isMethodDeclaration(member) || ts5.isMethodSignature(member); } isDocumentableSignature(signature) { return ts5.isConstructSignatureDeclaration(signature) || ts5.isCallSignatureDeclaration(signature); } isAbstract() { var _a; const modifiers = (_a = this.declaration.modifiers) != null ? _a : []; return modifiers.some((mod) => mod.kind === ts5.SyntaxKind.AbstractKeyword); } isImplementationForOverload(method) { if (method.kind === ts5.SyntaxKind.MethodSignature) return false; const signature = this.typeChecker.getSignatureFromDeclaration(method); return signature && this.typeChecker.isImplementationOfOverload(signature.declaration); } }; var DirectiveExtractor = class extends ClassExtractor { constructor(declaration, reference, metadata, checker) { super(declaration, checker); this.reference = reference; this.metadata = metadata; } extract() { var _a, _b; return { ...super.extract(), isStandalone: this.metadata.isStandalone, selector: (_a = this.metadata.selector) != null ? _a : "", exportAs: (_b = this.metadata.exportAs) != null ? _b : [], entryType: this.metadata.isComponent ? EntryType.Component : EntryType.Directive }; } extractClassProperty(propertyDeclaration) { const entry = super.extractClassProperty(propertyDeclaration); const inputMetadata = this.getInputMetadata(propertyDeclaration); if (inputMetadata) { entry.memberTags.push(MemberTags.Input); entry.inputAlias = inputMetadata.bindingPropertyName; entry.isRequiredInput = inputMetadata.required; } const outputMetadata = this.getOutputMetadata(propertyDeclaration); if (outputMetadata) { entry.memberTags.push(MemberTags.Output); entry.outputAlias = outputMetadata.bindingPropertyName; } return entry; } getInputMetadata(prop) { var _a, _b; const propName = prop.name.getText(); return (_b = (_a = this.metadata.inputs) == null ? void 0 : _a.getByClassPropertyName(propName)) != null ? _b : void 0; } getOutputMetadata(prop) { var _a, _b, _c; const propName = prop.name.getText(); return (_c = (_b = (_a = this.metadata) == null ? void 0 : _a.outputs) == null ? void 0 : _b.getByClassPropertyName(propName)) != null ? _c : void 0; } }; var PipeExtractor = class extends ClassExtractor { constructor(declaration, reference, metadata, typeChecker) { super(declaration, typeChecker); this.reference = reference; this.metadata = metadata; } extract() { return { ...super.extract(), pipeName: this.metadata.name, entryType: EntryType.Pipe, isStandalone: this.metadata.isStandalone }; } }; var NgModuleExtractor = class extends ClassExtractor { constructor(declaration, reference, metadata, typeChecker) { super(declaration, typeChecker); this.reference = reference; this.metadata = metadata; } extract() { return { ...super.extract(), entryType: EntryType.NgModule }; } }; function extractClass(classDeclaration, metadataReader, typeChecker) { const ref = new Reference(classDeclaration); let extractor; let directiveMetadata = metadataReader.getDirectiveMetadata(ref); let pipeMetadata = metadataReader.getPipeMetadata(ref); let ngModuleMetadata = metadataReader.getNgModuleMetadata(ref); if (directiveMetadata) { extractor = new DirectiveExtractor(classDeclaration, ref, directiveMetadata, typeChecker); } else if (pipeMetadata) { extractor = new PipeExtractor(classDeclaration, ref, pipeMetadata, typeChecker); } else if (ngModuleMetadata) { extractor = new NgModuleExtractor(classDeclaration, ref, ngModuleMetadata, typeChecker); } else { extractor = new ClassExtractor(classDeclaration, typeChecker); } return extractor.extract(); } function extractInterface(declaration, typeChecker) { const extractor = new ClassExtractor(declaration, typeChecker); return extractor.extract(); } // bazel-out/darwin_arm64-fastbuild/bin/packages/compiler-cli/src/ngtsc/docs/src/constant_extractor.mjs import ts6 from "typescript"; var LITERAL_AS_ENUM_TAG = "object-literal-as-enum"; function extractConstant(declaration, typeChecker) { const resolvedType = typeChecker.getBaseTypeOfLiteralType(typeChecker.getTypeAtLocation(declaration)); const rawComment = extractRawJsDoc(declaration.parent.parent); const jsdocTags = extractJsDocTags(declaration); const description = extractJsDocDescription(declaration); const name = declaration.name.getText(); if (jsdocTags.some((tag) => tag.name === LITERAL_AS_ENUM_TAG)) { return { name, entryType: EntryType.Enum, members: extractLiteralPropertiesAsEnumMembers(declaration), rawComment, description, jsdocTags: jsdocTags.filter((tag) => tag.name !== LITERAL_AS_ENUM_TAG) }; } return { name, type: typeChecker.typeToString(resolvedType), entryType: EntryType.Constant, rawComment, description, jsdocTags }; } function isSyntheticAngularConstant(declaration) { return declaration.name.getText() === "USED_FOR_NG_TYPE_CHECKING"; } function extractLiteralPropertiesAsEnumMembers(declaration) { let initializer = declaration.initializer; while (initializer && (ts6.isAsExpression(initializer) || ts6.isParenthesizedExpression(initializer))) { initializer = initializer.expression; } if (initializer === void 0 || !ts6.isObjectLiteralExpression(initializer)) { throw new Error(`Declaration tagged with "${LITERAL_AS_ENUM_TAG}" must be initialized to an object literal, but received ${initializer ? ts6.SyntaxKind[initializer.kind] : "undefined"}`); } return initializer.properties.map((prop) => { if (!ts6.isPropertyAssignment(prop) || !ts6.isIdentifier(prop.name)) { throw new Error(`Property in declaration tagged with "${LITERAL_AS_ENUM_TAG}" must be a property assignment with a static name`); } if (!ts6.isNumericLiteral(prop.initializer) && !ts6.isStringLiteralLike(prop.initializer)) { throw new Error(`Property in declaration tagged with "${LITERAL_AS_ENUM_TAG}" must be initialized to a number or string literal`); } return { name: prop.name.text, type: `${declaration.name.getText()}.${prop.name.text}`, value: prop.initializer.getText(), memberType: MemberType.EnumItem, jsdocTags: extractJsDocTags(prop), description: extractJsDocDescription(prop), memberTags: [] }; }); } // bazel-out/darwin_arm64-fastbuild/bin/packages/compiler-cli/src/ngtsc/docs/src/decorator_extractor.mjs import ts7 from "typescript"; function extractorDecorator(declaration, typeChecker) { const documentedNode = getDecoratorJsDocNode(declaration); const decoratorType = getDecoratorType(declaration); if (!decoratorType) { throw new Error(`"${declaration.name.getText()} is not a decorator."`); } return { name: declaration.name.getText(), decoratorType, entryType: EntryType.Decorator, rawComment: extractRawJsDoc(documentedNode), description: extractJsDocDescription(documentedNode), jsdocTags: extractJsDocTags(documentedNode), members: getDecoratorOptions(declaration, typeChecker) }; } function isDecoratorDeclaration(declaration) { return !!getDecoratorType(declaration); } function isDecoratorOptionsInterface(declaration) { return declaration.getSourceFile().statements.some((s) => ts7.isVariableStatement(s) && s.declarationList.declarations.some((d) => isDecoratorDeclaration(d) && d.name.getText() === declaration.name.getText())); } function getDecoratorType(declaration) { var _a, _b; const initializer = (_b = (_a = declaration.initializer) == null ? void 0 : _a.getFullText()) != null ? _b : ""; if (initializer.includes("makeDecorator")) return DecoratorType.Class; if (initializer.includes("makePropDecorator")) return DecoratorType.Member; if (initializer.includes("makeParamDecorator")) return DecoratorType.Parameter; return void 0; } function getDecoratorOptions(declaration, typeChecker) { var _a, _b; const name = declaration.name.getText(); const optionsDeclaration = declaration.getSourceFile().statements.find((node) => { return (ts7.isInterfaceDeclaration(node) || ts7.isTypeAliasDeclaration(node)) && node.name.getText() === name; }); if (!optionsDeclaration) { throw new Error(`Decorator "${name}" has no corresponding options interface.`); } let optionsInterface; if (ts7.isTypeAliasDeclaration(optionsDeclaration)) { const aliasedType = typeChecker.getTypeAtLocation(optionsDeclaration.type); optionsInterface = ((_b = (_a = aliasedType.getSymbol()) == null ? void 0 : _a.getDeclarations()) != null ? _b : []).find((d) => ts7.isInterfaceDeclaration(d)); } else { optionsInterface = optionsDeclaration; } if (!optionsInterface || !ts7.isInterfaceDeclaration(optionsInterface)) { throw new Error(`Options for decorator "${name}" is not an interface.`); } return extractInterface(optionsInterface, typeChecker).members; } function getDecoratorJsDocNode(declaration) { const name = declaration.name.getText(); const decoratorInterface = declaration.getSourceFile().statements.find((s) => { return ts7.isInterfaceDeclaration(s) && s.name.getText() === `${name}Decorator`; }); if (!decoratorInterface || !ts7.isInterfaceDeclaration(decoratorInterface)) { throw new Error(`No interface "${name}Decorator" found.`); } const callSignature = decoratorInterface.members.find((node) => { return ts7.isCallSignatureDeclaration(node) && extractRawJsDoc(node); }); if (!callSignature || !ts7.isCallSignatureDeclaration(callSignature)) { throw new Error(`No call signature with JsDoc on "${name}Decorator"`); } return callSignature; } // bazel-out/darwin_arm64-fastbuild/bin/packages/compiler-cli/src/ngtsc/docs/src/enum_extractor.mjs import ts8 from "typescript"; function extractEnum(declaration, typeChecker) { return { name: declaration.name.getText(), entryType: EntryType.Enum, members: extractEnumMembers(declaration, typeChecker), rawComment: extractRawJsDoc(declaration), description: extractJsDocDescription(declaration), jsdocTags: extractJsDocTags(declaration) }; } function extractEnumMembers(declaration, checker) { return declaration.members.map((member) => ({ name: member.name.getText(), type: extractResolvedTypeString(member, checker), value: getEnumMemberValue(member), memberType: MemberType.EnumItem, jsdocTags: extractJsDocTags(member), description: extractJsDocDescription(member), memberTags: [] })); } function getEnumMemberValue(memberNode) { var _a; const literal = memberNode.getChildren().find((n) => { return ts8.isNumericLiteral(n) || ts8.isStringLiteral(n) || ts8.isPrefixUnaryExpression(n) && n.operator === ts8.SyntaxKind.MinusToken && ts8.isNumericLiteral(n.operand); }); return (_a = literal == null ? void 0 : literal.getText()) != null ? _a : ""; } // bazel-out/darwin_arm64-fastbuild/bin/packages/compiler-cli/src/ngtsc/docs/src/initializer_api_function_extractor.mjs import ts9 from "typescript"; var initializerApiTag = "initializerApiFunction"; function isInitializerApiFunction(node, typeChecker) { if (ts9.isFunctionDeclaration(node) && node.name !== void 0 && node.body === void 0) { const implementation = findImplementationOfFunction(node, typeChecker); if (implementation !== void 0) { node = implementation; } } if (!ts9.isFunctionDeclaration(node) && !ts9.isVariableDeclaration(node)) { return false; } let tagContainer = ts9.isFunctionDeclaration(node) ? node : getContainerVariableStatement(node); if (tagContainer === null) { return false; } const tags = ts9.getJSDocTags(tagContainer); return tags.some((t) => t.tagName.text === initializerApiTag); } function extractInitializerApiFunction(node, typeChecker) { var _a; if (node.name === void 0 || !ts9.isIdentifier(node.name)) { throw new Error(`Initializer API: Expected literal variable name.`); } const container = ts9.isFunctionDeclaration(node) ? node : getContainerVariableStatement(node); if (container === null) { throw new Error("Initializer API: Could not find container AST node of variable."); } const name = node.name.text; const type = typeChecker.getTypeAtLocation(node); const callFunction = extractFunctionWithOverloads(name, type.getCallSignatures(), typeChecker); const subFunctions = []; for (const property of type.getProperties()) { const subName = property.getName(); const subDecl = (_a = property.getDeclarations()) == null ? void 0 : _a[0]; if (subDecl === void 0 || !ts9.isPropertySignature(subDecl)) { throw new Error(`Initializer API: Could not resolve declaration of sub-property: ${name}.${subName}`); } const subType = typeChecker.getTypeAtLocation(subDecl); subFunctions.push(extractFunctionWithOverloads(subName, subType.getCallSignatures(), typeChecker)); } let jsdocTags; let description; let rawComment; if (ts9.isFunctionDeclaration(node)) { const implementation = findImplementationOfFunction(node, typeChecker); if (implementation === void 0) { throw new Error(`Initializer API: Could not find implementation of function: ${name}`); } callFunction.implementation = { name, entryType: EntryType.Function, isNewType: false, description: extractJsDocDescription(implementation), generics: extractGenerics(implementation), jsdocTags: extractJsDocTags(implementation), params: extractAllParams(implementation.parameters, typeChecker), rawComment: extractRawJsDoc(implementation), returnType: typeChecker.typeToString(typeChecker.getReturnTypeOfSignature(typeChecker.getSignatureFromDeclaration(implementation))) }; jsdocTags = callFunction.implementation.jsdocTags; description = callFunction.implementation.description; rawComment = callFunction.implementation.description; } else { jsdocTags = extractJsDocTags(container); description = extractJsDocDescription(container); rawComment = extractRawJsDoc(container); } const metadataTag = jsdocTags.find((t) => t.name === initializerApiTag); if (metadataTag === void 0) { throw new Error(`Initializer API: Detected initializer API function does not have "@initializerApiFunction" tag: ${name}`); } let parsedMetadata = void 0; if (metadataTag.comment.trim() !== "") { try { parsedMetadata = JSON.parse(metadataTag.comment); } catch (e) { throw new Error(`Could not parse initializer API function metadata: ${e}`); } } return { entryType: EntryType.InitializerApiFunction, name, description, jsdocTags, rawComment, callFunction, subFunctions, __docsMetadata__: parsedMetadata }; } function getContainerVariableStatement(node) { if (!ts9.isVariableDeclarationList(node.parent)) { return null; } if (!ts9.isVariableStatement(node.parent.parent)) { return null; } return node.parent.parent; } function filterSignatureDeclarations(signatures) { const result = []; for (const signature of signatures) { const decl = signature.getDeclaration(); if (ts9.isFunctionDeclaration(decl) || ts9.isCallSignatureDeclaration(decl)) { result.push({ signature, decl }); } } return result; } function extractFunctionWithOverloads(name, signatures, typeChecker) { return { name, signatures: filterSignatureDeclarations(signatures).map(({ decl, signature }) => ({ name, entryType: EntryType.Function, description: extractJsDocDescription(decl), generics: extractGenerics(decl), isNewType: false, jsdocTags: extractJsDocTags(decl), params: extractAllParams(decl.parameters, typeChecker), rawComment: extractRawJsDoc(decl), returnType: typeChecker.typeToString( typeChecker.getReturnTypeOfSignature(signature), void 0, ts9.TypeFormatFlags.NoTypeReduction | ts9.TypeFormatFlags.NoTruncation ) })), implementation: null }; } function findImplementationOfFunction(node, typeChecker) { var _a; if (node.body !== void 0 || node.name === void 0) { return node; } const symbol = typeChecker.getSymbolAtLocation(node.name); return (_a = symbol == null ? void 0 : symbol.declarations) == null ? void 0 : _a.find((s) => ts9.isFunctionDeclaration(s) && s.body !== void 0); } // bazel-out/darwin_arm64-fastbuild/bin/packages/compiler-cli/src/ngtsc/docs/src/type_alias_extractor.mjs function extractTypeAlias(declaration) { return { name: declaration.name.getText(), type: declaration.type.getText(), entryType: EntryType.TypeAlias, rawComment: extractRawJsDoc(declaration), description: extractJsDocDescription(declaration), jsdocTags: extractJsDocTags(declaration) }; } // bazel-out/darwin_arm64-fastbuild/bin/packages/compiler-cli/src/ngtsc/docs/src/extractor.mjs var DocsExtractor = class { constructor(typeChecker, metadataReader) { this.typeChecker = typeChecker; this.metadataReader = metadataReader; } extractAll(sourceFile, rootDir) { const entries = []; const exportedDeclarations = this.getExportedDeclarations(sourceFile); for (const [exportName, node] of exportedDeclarations) { if (isAngularPrivateName(exportName)) { continue; } const entry = this.extractDeclaration(node); if (entry && !isIgnoredDocEntry(entry)) { const realSourceFile = node.getSourceFile(); entry.source = { filePath: getRelativeFilePath(realSourceFile, rootDir), startLine: ts10.getLineAndCharacterOfPosition(realSourceFile, node.getStart()).line + 1, endLine: ts10.getLineAndCharacterOfPosition(realSourceFile, node.getEnd()).line + 1 }; entries.push({ ...entry, name: exportName }); } } return entries; } extractDeclaration(node) { if (isNamedClassDeclaration(node)) { return extractClass(node, this.metadataReader, this.typeChecker); } if (isInitializerApiFunction(node, this.typeChecker)) { return extractInitializerApiFunction(node, this.typeChecker); } if (ts10.isInterfaceDeclaration(node) && !isIgnoredInterface(node)) { return extractInterface(node, this.typeChecker); } if (ts10.isFunctionDeclaration(node)) { const functionExtractor = new FunctionExtractor(node.name.getText(), node, this.typeChecker); return functionExtractor.extract(); } if (ts10.isVariableDeclaration(node) && !isSyntheticAngularConstant(node)) { return isDecoratorDeclaration(node) ? extractorDecorator(node, this.typeChecker) : extractConstant(node, this.typeChecker); } if (ts10.isTypeAliasDeclaration(node)) { return extractTypeAlias(node); } if (ts10.isEnumDeclaration(node)) { return extractEnum(node, this.typeChecker); } return null; } getExportedDeclarations(sourceFile) { var _a; const reflector = new TypeScriptReflectionHost(this.typeChecker); const exportedDeclarationMap = reflector.getExportsOfModule(sourceFile); let exportedDeclarations = Array.from((_a = exportedDeclarationMap == null ? void 0 : exportedDeclarationMap.entries()) != null ? _a : []).map(([exportName, declaration]) => [exportName, declaration.node]); const declarationCount = exportedDeclarations.length; for (let i = 0; i < declarationCount; i++) { const [exportName, declaration] = exportedDeclarations[i]; if (ts10.isFunctionDeclaration(declaration)) { const extractor = new FunctionExtractor(exportName, declaration, this.typeChecker); const overloads = extractor.getOverloads().map((overload) => [exportName, overload]); exportedDeclarations.push(...overloads); } } return exportedDeclarations.sort(([a, declarationA], [b, declarationB]) => declarationA.pos - declarationB.pos); } }; function isIgnoredInterface(node) { return node.name.getText().endsWith("Decorator") || isDecoratorOptionsInterface(node); } function isIgnoredDocEntry(entry) { const isDocsPrivate = entry.jsdocTags.find((e) => e.name === "docsPrivate"); if (isDocsPrivate !== void 0 && isDocsPrivate.comment === "") { throw new Error(`Docs extraction: Entry "${entry.name}" is marked as "@docsPrivate" but without reasoning.`); } return isDocsPrivate !== void 0; } function getRelativeFilePath(sourceFile, rootDir) { const fullPath = sourceFile.fileName; const relativePath = fullPath.replace(rootDir, ""); return relativePath; } // bazel-out/darwin_arm64-fastbuild/bin/packages/compiler-cli/src/ngtsc/program.mjs import { HtmlParser, MessageBundle } from "@angular/compiler"; import ts24 from "typescript"; // bazel-out/darwin_arm64-fastbuild/bin/packages/compiler-cli/src/transformers/i18n.mjs import { Xliff, Xliff2, Xmb } from "@angular/compiler"; import * as path from "path"; function i18nGetExtension(formatName) { const format = formatName.toLowerCase(); switch (format) { case "xmb": return "xmb"; case "xlf": case "xlif": case "xliff": case "xlf2": case "xliff2": return "xlf"; } throw new Error(`Unsupported format "${formatName}"`); } function i18nExtract(formatName, outFile, host, options, bundle, pathResolve = path.resolve) { formatName = formatName || "xlf"; const ext = i18nGetExtension(formatName); const content = i18nSerialize(bundle, formatName, options); const dstFile = outFile || `messages.${ext}`; const dstPath = pathResolve(options.outDir || options.basePath, dstFile); host.writeFile(dstPath, content, false, void 0, []); return [dstPath]; } function i18nSerialize(bundle, formatName, options) { const format = formatName.toLowerCase(); let serializer; switch (format) { case "xmb": serializer = new Xmb(); break; case "xliff2": case "xlf2": serializer = new Xliff2(); break; case "xlf": case "xliff": default: serializer = new Xliff(); } return bundle.write(serializer, getPathNormalizer(options.basePath)); } function getPathNormalizer(basePath) { return (sourcePath) => { sourcePath = basePath ? path.relative(basePath, sourcePath) : sourcePath; return sourcePath.split(path.sep).join("/"); }; } // bazel-out/darwin_arm64-fastbuild/bin/packages/compiler-cli/src/typescript_support.mjs import ts11 from "typescript"; // bazel-out/darwin_arm64-fastbuild/bin/packages/compiler-cli/src/version_helpers.mjs function toNumbers(value) { const suffixIndex = value.lastIndexOf("-"); return value.slice(0, suffixIndex === -1 ? value.length : suffixIndex).split(".").map((segment) => { const parsed = parseInt(segment, 10); if (isNaN(parsed)) { throw Error(`Unable to parse version string ${value}.`); } return parsed; }); } function compareNumbers(a, b) { const max = Math.max(a.length, b.length); const min = Math.min(a.length, b.length); for (let i = 0; i < min; i++) { if (a[i] > b[i]) return 1; if (a[i] < b[i]) return -1; } if (min !== max) { const longestArray = a.length === max ? a : b; const comparisonResult = a.length === max ? 1 : -1; for (let i = min; i < max; i++) { if (longestArray[i] > 0) { return comparisonResult; } } } return 0; } function compareVersions(v1, v2) { return compareNumbers(toNumbers(v1), toNumbers(v2)); } // bazel-out/darwin_arm64-fastbuild/bin/packages/compiler-cli/src/typescript_support.mjs var MIN_TS_VERSION = "5.4.0"; var MAX_TS_VERSION = "5.6.0"; var tsVersion = ts11.version; function checkVersion(version, minVersion, maxVersion) { if (compareVersions(version, minVersion) < 0 || compareVersions(version, maxVersion) >= 0) { throw new Error(`The Angular Compiler requires TypeScript >=${minVersion} and <${maxVersion} but ${version} was found instead.`); } } function verifySupportedTypeScriptVersion() { checkVersion(tsVersion, MIN_TS_VERSION, MAX_TS_VERSION); } // bazel-out/darwin_arm64-fastbuild/bin/packages/compiler-cli/src/ngtsc/core/src/compiler.mjs import { R3Identifiers } from "@angular/compiler"; import ts22 from "typescript"; // bazel-out/darwin_arm64-fastbuild/bin/packages/compiler-cli/src/ngtsc/cycles/src/analyzer.mjs var CycleAnalyzer = class { constructor(importGraph) { this.importGraph = importGraph; this.cachedResults = null; } wouldCreateCycle(from, to) { if (this.cachedResults === null || this.cachedResults.from !== from) { this.cachedResults = new CycleResults(from, this.importGraph); } return this.cachedResults.wouldBeCyclic(to) ? new Cycle(this.importGraph, from, to) : null; } recordSyntheticImport(from, to) { this.cachedResults = null; this.importGraph.addSyntheticImport(from, to); } }; var NgCyclicResult = Symbol("NgCyclicResult"); var CycleResults = class { constructor(from, importGraph) { this.from = from; this.importGraph = importGraph; this.cyclic = {}; this.acyclic = {}; } wouldBeCyclic(sf) { const cached = this.getCachedResult(sf); if (cached !== null) { return cached; } if (sf === this.from) { return true; } this.markAcyclic(sf); const imports = this.importGraph.importsOf(sf); for (const imported of imports) { if (this.wouldBeCyclic(imported)) { this.markCyclic(sf); return true; } } return false; } getCachedResult(sf) { const result = sf[NgCyclicResult]; if (result === this.cyclic) { return true; } else if (result === this.acyclic) { return false; } else { return null; } } markCyclic(sf) { sf[NgCyclicResult] = this.cyclic; } markAcyclic(sf) { sf[NgCyclicResult] = this.acyclic; } }; var Cycle = class { constructor(importGraph, from, to) { this.importGraph = importGraph; this.from = from; this.to = to; } getPath() { return [this.from, ...this.importGraph.findPath(this.to, this.from)]; } }; // bazel-out/darwin_arm64-fastbuild/bin/packages/compiler-cli/src/ngtsc/cycles/src/imports.mjs import ts12 from "typescript"; var ImportGraph = class { constructor(checker, perf) { this.checker = checker; this.perf = perf; this.imports = /* @__PURE__ */ new Map(); } importsOf(sf) { if (!this.imports.has(sf)) { this.imports.set(sf, this.scanImports(sf)); } return this.imports.get(sf); } findPath(start, end) { if (start === end) { return [start]; } const found = /* @__PURE__ */ new Set([start]); const queue = [new Found(start, null)]; while (queue.length > 0) { const current = queue.shift(); const imports = this.importsOf(current.sourceFile); for (const importedFile of imports) { if (!found.has(importedFile)) { const next = new Found(importedFile, current); if (next.sourceFile === end) { return next.toPath(); } found.add(importedFile); queue.push(next); } } } return null; } addSyntheticImport(sf, imported) { if (isLocalFile(imported)) { this.importsOf(sf).add(imported); } } scanImports(sf) { return this.perf.inPhase(PerfPhase.CycleDetection, () => { const imports = /* @__PURE__ */ new Set(); for (const stmt of sf.statements) { if (!ts12.isImportDeclaration(stmt) && !ts12.isExportDeclaration(stmt) || stmt.moduleSpecifier === void 0) { continue; } if (ts12.isImportDeclaration(stmt) && stmt.importClause !== void 0 && isTypeOnlyImportClause(stmt.importClause)) { continue; } const symbol = this.checker.getSymbolAtLocation(stmt.moduleSpecifier); if (symbol === void 0 || symbol.valueDeclaration === void 0) { continue; } const moduleFile = symbol.valueDeclaration; if (ts12.isSourceFile(moduleFile) && isLocalFile(moduleFile)) { imports.add(moduleFile); } } return imports; }); } }; function isLocalFile(sf) { return !sf.isDeclarationFile; } function isTypeOnlyImportClause(node) { if (node.isTypeOnly) { return true; } if (node.namedBindings !== void 0 && ts12.isNamedImports(node.namedBindings) && node.namedBindings.elements.every((specifier) => specifier.isTypeOnly)) { return true; } return false; } var Found = class { constructor(sourceFile, parent) { this.sourceFile = sourceFile; this.parent = parent; } toPath() { const array = []; let current = this; while (current !== null) { array.push(current.sourceFile); current = current.parent; } return array.reverse(); } }; // bazel-out/darwin_arm64-fastbuild/bin/packages/compiler-cli/src/ngtsc/entry_point/src/generator.mjs import ts13 from "typescript"; var FlatIndexGenerator = class { constructor(entryPoint, relativeFlatIndexPath, moduleName) { this.entryPoint = entryPoint; this.moduleName = moduleName; this.shouldEmit = true; this.flatIndexPath = join(dirname(entryPoint), relativeFlatIndexPath).replace(/\.js$/, "") + ".ts"; } makeTopLevelShim() { const relativeEntryPoint = relativePathBetween(this.flatIndexPath, this.entryPoint); const contents = `/** * Generated bundle index. Do not edit. */ export * from '${relativeEntryPoint}'; `; const genFile = ts13.createSourceFile(this.flatIndexPath, contents, ts13.ScriptTarget.ES2015, true, ts13.ScriptKind.TS); if (this.moduleName !== null) { genFile.moduleName = this.moduleName; } return genFile; } }; // bazel-out/darwin_arm64-fastbuild/bin/packages/compiler-cli/src/ngtsc/entry_point/src/logic.mjs function findFlatIndexEntryPoint(rootFiles) { const tsFiles = rootFiles.filter((file) => isNonDeclarationTsPath(file)); let resolvedEntryPoint = null; if (tsFiles.length === 1) { resolvedEntryPoint = tsFiles[0]; } else { for (const tsFile of tsFiles) { if (getFileSystem().basename(tsFile) === "index.ts" && (resolvedEntryPoint === null || tsFile.length <= resolvedEntryPoint.length)) { resolvedEntryPoint = tsFile; } } } return resolvedEntryPoint; } // bazel-out/darwin_arm64-fastbuild/bin/packages/compiler-cli/src/ngtsc/entry_point/src/private_export_checker.mjs import ts14 from "typescript"; function checkForPrivateExports(entryPoint, checker, refGraph) { const diagnostics = []; const topLevelExports = /* @__PURE__ */ new Set(); const moduleSymbol = checker.getSymbolAtLocation(entryPoint); if (moduleSymbol === void 0) { throw new Error(`Internal error: failed to get symbol for entrypoint`); } const exportedSymbols = checker.getExportsOfModule(moduleSymbol); exportedSymbols.forEach((symbol) => { if (symbol.flags & ts14.SymbolFlags.Alias) { symbol = checker.getAliasedSymbol(symbol); } const decl = symbol.valueDeclaration; if (decl !== void 0) { topLevelExports.add(decl); } }); const checkedSet = /* @__PURE__ */ new Set(); topLevelExports.forEach((mainExport) => { refGraph.transitiveReferencesOf(mainExport).forEach((transitiveReference) => { if (checkedSet.has(transitiveReference)) { return; } checkedSet.add(transitiveReference); if (!topLevelExports.has(transitiveReference)) { const descriptor = getDescriptorOfDeclaration(transitiveReference); const name = getNameOfDeclaration(transitiveReference); let visibleVia = "NgModule exports"; const transitivePath = refGraph.pathFrom(mainExport, transitiveReference); if (transitivePath !== null) { visibleVia = transitivePath.map((seg) => getNameOfDeclaration(seg)).join(" -> "); } const diagnostic = { category: ts14.DiagnosticCategory.Error, code: ngErrorCode(ErrorCode.SYMBOL_NOT_EXPORTED), file: transitiveReference.getSourceFile(), ...getPosOfDeclaration(transitiveReference), messageText: `Unsupported private ${descriptor} ${name}. This ${descriptor} is visible to consumers via ${visibleV