chunk-7RPZKH3B.js 33 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876
  1. import {createRequire as __cjsCompatRequire} from 'module';
  2. const require = __cjsCompatRequire(import.meta.url);
  3. import {
  4. LogicalProjectPath,
  5. absoluteFrom,
  6. absoluteFromSourceFile,
  7. dirname,
  8. getFileSystem,
  9. relative,
  10. resolve,
  11. stripExtension,
  12. toRelativeImport
  13. } from "./chunk-K2U2VZ7S.js";
  14. // bazel-out/darwin-fastbuild/bin/packages/compiler-cli/src/ngtsc/util/src/typescript.mjs
  15. import ts from "typescript";
  16. var TS = /\.tsx?$/i;
  17. var D_TS = /\.d\.ts$/i;
  18. function isSymbolWithValueDeclaration(symbol) {
  19. return symbol != null && symbol.valueDeclaration !== void 0 && symbol.declarations !== void 0;
  20. }
  21. function isDtsPath(filePath) {
  22. return D_TS.test(filePath);
  23. }
  24. function isNonDeclarationTsPath(filePath) {
  25. return TS.test(filePath) && !D_TS.test(filePath);
  26. }
  27. function isFromDtsFile(node) {
  28. let sf = node.getSourceFile();
  29. if (sf === void 0) {
  30. sf = ts.getOriginalNode(node).getSourceFile();
  31. }
  32. return sf !== void 0 && sf.isDeclarationFile;
  33. }
  34. function nodeNameForError(node) {
  35. if (node.name !== void 0 && ts.isIdentifier(node.name)) {
  36. return node.name.text;
  37. } else {
  38. const kind = ts.SyntaxKind[node.kind];
  39. const { line, character } = ts.getLineAndCharacterOfPosition(node.getSourceFile(), node.getStart());
  40. return `${kind}@${line}:${character}`;
  41. }
  42. }
  43. function getSourceFile(node) {
  44. const directSf = node.getSourceFile();
  45. return directSf !== void 0 ? directSf : ts.getOriginalNode(node).getSourceFile();
  46. }
  47. function getSourceFileOrNull(program, fileName) {
  48. return program.getSourceFile(fileName) || null;
  49. }
  50. function getTokenAtPosition(sf, pos) {
  51. return ts.getTokenAtPosition(sf, pos);
  52. }
  53. function identifierOfNode(decl) {
  54. if (decl.name !== void 0 && ts.isIdentifier(decl.name)) {
  55. return decl.name;
  56. } else {
  57. return null;
  58. }
  59. }
  60. function isDeclaration(node) {
  61. return isValueDeclaration(node) || isTypeDeclaration(node);
  62. }
  63. function isValueDeclaration(node) {
  64. return ts.isClassDeclaration(node) || ts.isFunctionDeclaration(node) || ts.isVariableDeclaration(node);
  65. }
  66. function isTypeDeclaration(node) {
  67. return ts.isEnumDeclaration(node) || ts.isTypeAliasDeclaration(node) || ts.isInterfaceDeclaration(node);
  68. }
  69. function isNamedDeclaration(node) {
  70. const namedNode = node;
  71. return namedNode.name !== void 0 && ts.isIdentifier(namedNode.name);
  72. }
  73. function getRootDirs(host, options) {
  74. const rootDirs = [];
  75. const cwd = host.getCurrentDirectory();
  76. const fs = getFileSystem();
  77. if (options.rootDirs !== void 0) {
  78. rootDirs.push(...options.rootDirs);
  79. } else if (options.rootDir !== void 0) {
  80. rootDirs.push(options.rootDir);
  81. } else {
  82. rootDirs.push(cwd);
  83. }
  84. return rootDirs.map((rootDir) => fs.resolve(cwd, host.getCanonicalFileName(rootDir)));
  85. }
  86. function nodeDebugInfo(node) {
  87. const sf = getSourceFile(node);
  88. const { line, character } = ts.getLineAndCharacterOfPosition(sf, node.pos);
  89. return `[${sf.fileName}: ${ts.SyntaxKind[node.kind]} @ ${line}:${character}]`;
  90. }
  91. function resolveModuleName(moduleName, containingFile, compilerOptions, compilerHost, moduleResolutionCache) {
  92. if (compilerHost.resolveModuleNames) {
  93. return compilerHost.resolveModuleNames(
  94. [moduleName],
  95. containingFile,
  96. void 0,
  97. void 0,
  98. compilerOptions
  99. )[0];
  100. } else {
  101. return ts.resolveModuleName(moduleName, containingFile, compilerOptions, compilerHost, moduleResolutionCache !== null ? moduleResolutionCache : void 0).resolvedModule;
  102. }
  103. }
  104. function isAssignment(node) {
  105. return ts.isBinaryExpression(node) && node.operatorToken.kind === ts.SyntaxKind.EqualsToken;
  106. }
  107. function toUnredirectedSourceFile(sf) {
  108. const redirectInfo = sf.redirectInfo;
  109. if (redirectInfo === void 0) {
  110. return sf;
  111. }
  112. return redirectInfo.unredirected;
  113. }
  114. // bazel-out/darwin-fastbuild/bin/packages/compiler-cli/src/ngtsc/imports/src/references.mjs
  115. var Reference = class {
  116. constructor(node, bestGuessOwningModule = null) {
  117. this.node = node;
  118. this.identifiers = [];
  119. this.synthetic = false;
  120. this._alias = null;
  121. this.bestGuessOwningModule = bestGuessOwningModule;
  122. const id = identifierOfNode(node);
  123. if (id !== null) {
  124. this.identifiers.push(id);
  125. }
  126. }
  127. get ownedByModuleGuess() {
  128. if (this.bestGuessOwningModule !== null) {
  129. return this.bestGuessOwningModule.specifier;
  130. } else {
  131. return null;
  132. }
  133. }
  134. get hasOwningModuleGuess() {
  135. return this.bestGuessOwningModule !== null;
  136. }
  137. get debugName() {
  138. const id = identifierOfNode(this.node);
  139. return id !== null ? id.text : null;
  140. }
  141. get alias() {
  142. return this._alias;
  143. }
  144. addIdentifier(identifier) {
  145. this.identifiers.push(identifier);
  146. }
  147. getIdentityIn(context) {
  148. return this.identifiers.find((id) => id.getSourceFile() === context) || null;
  149. }
  150. getIdentityInExpression(expr) {
  151. const sf = expr.getSourceFile();
  152. return this.identifiers.find((id) => {
  153. if (id.getSourceFile() !== sf) {
  154. return false;
  155. }
  156. return id.pos >= expr.pos && id.end <= expr.end;
  157. }) || null;
  158. }
  159. getOriginForDiagnostics(container, fallback = container) {
  160. const id = this.getIdentityInExpression(container);
  161. return id !== null ? id : fallback;
  162. }
  163. cloneWithAlias(alias) {
  164. const ref = new Reference(this.node, this.bestGuessOwningModule);
  165. ref.identifiers = [...this.identifiers];
  166. ref._alias = alias;
  167. return ref;
  168. }
  169. cloneWithNoIdentifiers() {
  170. const ref = new Reference(this.node, this.bestGuessOwningModule);
  171. ref._alias = this._alias;
  172. ref.identifiers = [];
  173. return ref;
  174. }
  175. };
  176. // bazel-out/darwin-fastbuild/bin/packages/compiler-cli/src/ngtsc/imports/src/alias.mjs
  177. import { ExternalExpr as ExternalExpr2 } from "@angular/compiler";
  178. // bazel-out/darwin-fastbuild/bin/packages/compiler-cli/src/ngtsc/imports/src/emitter.mjs
  179. import { ExternalExpr, ExternalReference, WrappedNodeExpr } from "@angular/compiler";
  180. import ts3 from "typescript";
  181. // bazel-out/darwin-fastbuild/bin/packages/compiler-cli/src/ngtsc/diagnostics/src/error_code.mjs
  182. var ErrorCode;
  183. (function(ErrorCode2) {
  184. ErrorCode2[ErrorCode2["DECORATOR_ARG_NOT_LITERAL"] = 1001] = "DECORATOR_ARG_NOT_LITERAL";
  185. ErrorCode2[ErrorCode2["DECORATOR_ARITY_WRONG"] = 1002] = "DECORATOR_ARITY_WRONG";
  186. ErrorCode2[ErrorCode2["DECORATOR_NOT_CALLED"] = 1003] = "DECORATOR_NOT_CALLED";
  187. ErrorCode2[ErrorCode2["DECORATOR_UNEXPECTED"] = 1005] = "DECORATOR_UNEXPECTED";
  188. ErrorCode2[ErrorCode2["DECORATOR_COLLISION"] = 1006] = "DECORATOR_COLLISION";
  189. ErrorCode2[ErrorCode2["VALUE_HAS_WRONG_TYPE"] = 1010] = "VALUE_HAS_WRONG_TYPE";
  190. ErrorCode2[ErrorCode2["VALUE_NOT_LITERAL"] = 1011] = "VALUE_NOT_LITERAL";
  191. ErrorCode2[ErrorCode2["COMPONENT_MISSING_TEMPLATE"] = 2001] = "COMPONENT_MISSING_TEMPLATE";
  192. ErrorCode2[ErrorCode2["PIPE_MISSING_NAME"] = 2002] = "PIPE_MISSING_NAME";
  193. ErrorCode2[ErrorCode2["PARAM_MISSING_TOKEN"] = 2003] = "PARAM_MISSING_TOKEN";
  194. ErrorCode2[ErrorCode2["DIRECTIVE_MISSING_SELECTOR"] = 2004] = "DIRECTIVE_MISSING_SELECTOR";
  195. ErrorCode2[ErrorCode2["UNDECORATED_PROVIDER"] = 2005] = "UNDECORATED_PROVIDER";
  196. ErrorCode2[ErrorCode2["DIRECTIVE_INHERITS_UNDECORATED_CTOR"] = 2006] = "DIRECTIVE_INHERITS_UNDECORATED_CTOR";
  197. ErrorCode2[ErrorCode2["UNDECORATED_CLASS_USING_ANGULAR_FEATURES"] = 2007] = "UNDECORATED_CLASS_USING_ANGULAR_FEATURES";
  198. ErrorCode2[ErrorCode2["COMPONENT_RESOURCE_NOT_FOUND"] = 2008] = "COMPONENT_RESOURCE_NOT_FOUND";
  199. ErrorCode2[ErrorCode2["COMPONENT_INVALID_SHADOW_DOM_SELECTOR"] = 2009] = "COMPONENT_INVALID_SHADOW_DOM_SELECTOR";
  200. ErrorCode2[ErrorCode2["COMPONENT_NOT_STANDALONE"] = 2010] = "COMPONENT_NOT_STANDALONE";
  201. ErrorCode2[ErrorCode2["COMPONENT_IMPORT_NOT_STANDALONE"] = 2011] = "COMPONENT_IMPORT_NOT_STANDALONE";
  202. ErrorCode2[ErrorCode2["COMPONENT_UNKNOWN_IMPORT"] = 2012] = "COMPONENT_UNKNOWN_IMPORT";
  203. ErrorCode2[ErrorCode2["HOST_DIRECTIVE_INVALID"] = 2013] = "HOST_DIRECTIVE_INVALID";
  204. ErrorCode2[ErrorCode2["HOST_DIRECTIVE_NOT_STANDALONE"] = 2014] = "HOST_DIRECTIVE_NOT_STANDALONE";
  205. ErrorCode2[ErrorCode2["HOST_DIRECTIVE_COMPONENT"] = 2015] = "HOST_DIRECTIVE_COMPONENT";
  206. ErrorCode2[ErrorCode2["INJECTABLE_INHERITS_INVALID_CONSTRUCTOR"] = 2016] = "INJECTABLE_INHERITS_INVALID_CONSTRUCTOR";
  207. ErrorCode2[ErrorCode2["HOST_DIRECTIVE_UNDEFINED_BINDING"] = 2017] = "HOST_DIRECTIVE_UNDEFINED_BINDING";
  208. ErrorCode2[ErrorCode2["HOST_DIRECTIVE_CONFLICTING_ALIAS"] = 2018] = "HOST_DIRECTIVE_CONFLICTING_ALIAS";
  209. ErrorCode2[ErrorCode2["HOST_DIRECTIVE_MISSING_REQUIRED_BINDING"] = 2019] = "HOST_DIRECTIVE_MISSING_REQUIRED_BINDING";
  210. ErrorCode2[ErrorCode2["SYMBOL_NOT_EXPORTED"] = 3001] = "SYMBOL_NOT_EXPORTED";
  211. ErrorCode2[ErrorCode2["IMPORT_CYCLE_DETECTED"] = 3003] = "IMPORT_CYCLE_DETECTED";
  212. ErrorCode2[ErrorCode2["IMPORT_GENERATION_FAILURE"] = 3004] = "IMPORT_GENERATION_FAILURE";
  213. ErrorCode2[ErrorCode2["CONFIG_FLAT_MODULE_NO_INDEX"] = 4001] = "CONFIG_FLAT_MODULE_NO_INDEX";
  214. ErrorCode2[ErrorCode2["CONFIG_STRICT_TEMPLATES_IMPLIES_FULL_TEMPLATE_TYPECHECK"] = 4002] = "CONFIG_STRICT_TEMPLATES_IMPLIES_FULL_TEMPLATE_TYPECHECK";
  215. ErrorCode2[ErrorCode2["CONFIG_EXTENDED_DIAGNOSTICS_IMPLIES_STRICT_TEMPLATES"] = 4003] = "CONFIG_EXTENDED_DIAGNOSTICS_IMPLIES_STRICT_TEMPLATES";
  216. ErrorCode2[ErrorCode2["CONFIG_EXTENDED_DIAGNOSTICS_UNKNOWN_CATEGORY_LABEL"] = 4004] = "CONFIG_EXTENDED_DIAGNOSTICS_UNKNOWN_CATEGORY_LABEL";
  217. ErrorCode2[ErrorCode2["CONFIG_EXTENDED_DIAGNOSTICS_UNKNOWN_CHECK"] = 4005] = "CONFIG_EXTENDED_DIAGNOSTICS_UNKNOWN_CHECK";
  218. ErrorCode2[ErrorCode2["HOST_BINDING_PARSE_ERROR"] = 5001] = "HOST_BINDING_PARSE_ERROR";
  219. ErrorCode2[ErrorCode2["TEMPLATE_PARSE_ERROR"] = 5002] = "TEMPLATE_PARSE_ERROR";
  220. ErrorCode2[ErrorCode2["NGMODULE_INVALID_DECLARATION"] = 6001] = "NGMODULE_INVALID_DECLARATION";
  221. ErrorCode2[ErrorCode2["NGMODULE_INVALID_IMPORT"] = 6002] = "NGMODULE_INVALID_IMPORT";
  222. ErrorCode2[ErrorCode2["NGMODULE_INVALID_EXPORT"] = 6003] = "NGMODULE_INVALID_EXPORT";
  223. ErrorCode2[ErrorCode2["NGMODULE_INVALID_REEXPORT"] = 6004] = "NGMODULE_INVALID_REEXPORT";
  224. ErrorCode2[ErrorCode2["NGMODULE_MODULE_WITH_PROVIDERS_MISSING_GENERIC"] = 6005] = "NGMODULE_MODULE_WITH_PROVIDERS_MISSING_GENERIC";
  225. ErrorCode2[ErrorCode2["NGMODULE_REEXPORT_NAME_COLLISION"] = 6006] = "NGMODULE_REEXPORT_NAME_COLLISION";
  226. ErrorCode2[ErrorCode2["NGMODULE_DECLARATION_NOT_UNIQUE"] = 6007] = "NGMODULE_DECLARATION_NOT_UNIQUE";
  227. ErrorCode2[ErrorCode2["NGMODULE_DECLARATION_IS_STANDALONE"] = 6008] = "NGMODULE_DECLARATION_IS_STANDALONE";
  228. ErrorCode2[ErrorCode2["NGMODULE_BOOTSTRAP_IS_STANDALONE"] = 6009] = "NGMODULE_BOOTSTRAP_IS_STANDALONE";
  229. ErrorCode2[ErrorCode2["WARN_NGMODULE_ID_UNNECESSARY"] = 6100] = "WARN_NGMODULE_ID_UNNECESSARY";
  230. ErrorCode2[ErrorCode2["NGMODULE_VE_DEPENDENCY_ON_IVY_LIB"] = 6999] = "NGMODULE_VE_DEPENDENCY_ON_IVY_LIB";
  231. ErrorCode2[ErrorCode2["SCHEMA_INVALID_ELEMENT"] = 8001] = "SCHEMA_INVALID_ELEMENT";
  232. ErrorCode2[ErrorCode2["SCHEMA_INVALID_ATTRIBUTE"] = 8002] = "SCHEMA_INVALID_ATTRIBUTE";
  233. ErrorCode2[ErrorCode2["MISSING_REFERENCE_TARGET"] = 8003] = "MISSING_REFERENCE_TARGET";
  234. ErrorCode2[ErrorCode2["MISSING_PIPE"] = 8004] = "MISSING_PIPE";
  235. ErrorCode2[ErrorCode2["WRITE_TO_READ_ONLY_VARIABLE"] = 8005] = "WRITE_TO_READ_ONLY_VARIABLE";
  236. ErrorCode2[ErrorCode2["DUPLICATE_VARIABLE_DECLARATION"] = 8006] = "DUPLICATE_VARIABLE_DECLARATION";
  237. ErrorCode2[ErrorCode2["SPLIT_TWO_WAY_BINDING"] = 8007] = "SPLIT_TWO_WAY_BINDING";
  238. ErrorCode2[ErrorCode2["MISSING_REQUIRED_INPUTS"] = 8008] = "MISSING_REQUIRED_INPUTS";
  239. ErrorCode2[ErrorCode2["INVALID_BANANA_IN_BOX"] = 8101] = "INVALID_BANANA_IN_BOX";
  240. ErrorCode2[ErrorCode2["NULLISH_COALESCING_NOT_NULLABLE"] = 8102] = "NULLISH_COALESCING_NOT_NULLABLE";
  241. ErrorCode2[ErrorCode2["MISSING_CONTROL_FLOW_DIRECTIVE"] = 8103] = "MISSING_CONTROL_FLOW_DIRECTIVE";
  242. ErrorCode2[ErrorCode2["TEXT_ATTRIBUTE_NOT_BINDING"] = 8104] = "TEXT_ATTRIBUTE_NOT_BINDING";
  243. ErrorCode2[ErrorCode2["MISSING_NGFOROF_LET"] = 8105] = "MISSING_NGFOROF_LET";
  244. ErrorCode2[ErrorCode2["SUFFIX_NOT_SUPPORTED"] = 8106] = "SUFFIX_NOT_SUPPORTED";
  245. ErrorCode2[ErrorCode2["OPTIONAL_CHAIN_NOT_NULLABLE"] = 8107] = "OPTIONAL_CHAIN_NOT_NULLABLE";
  246. ErrorCode2[ErrorCode2["SKIP_HYDRATION_NOT_STATIC"] = 8108] = "SKIP_HYDRATION_NOT_STATIC";
  247. ErrorCode2[ErrorCode2["INLINE_TCB_REQUIRED"] = 8900] = "INLINE_TCB_REQUIRED";
  248. ErrorCode2[ErrorCode2["INLINE_TYPE_CTOR_REQUIRED"] = 8901] = "INLINE_TYPE_CTOR_REQUIRED";
  249. ErrorCode2[ErrorCode2["INJECTABLE_DUPLICATE_PROV"] = 9001] = "INJECTABLE_DUPLICATE_PROV";
  250. ErrorCode2[ErrorCode2["SUGGEST_STRICT_TEMPLATES"] = 10001] = "SUGGEST_STRICT_TEMPLATES";
  251. ErrorCode2[ErrorCode2["SUGGEST_SUBOPTIMAL_TYPE_INFERENCE"] = 10002] = "SUGGEST_SUBOPTIMAL_TYPE_INFERENCE";
  252. })(ErrorCode || (ErrorCode = {}));
  253. // bazel-out/darwin-fastbuild/bin/packages/compiler-cli/src/ngtsc/diagnostics/src/docs.mjs
  254. var COMPILER_ERRORS_WITH_GUIDES = /* @__PURE__ */ new Set([
  255. ErrorCode.DECORATOR_ARG_NOT_LITERAL,
  256. ErrorCode.IMPORT_CYCLE_DETECTED,
  257. ErrorCode.PARAM_MISSING_TOKEN,
  258. ErrorCode.SCHEMA_INVALID_ELEMENT,
  259. ErrorCode.SCHEMA_INVALID_ATTRIBUTE,
  260. ErrorCode.MISSING_REFERENCE_TARGET,
  261. ErrorCode.COMPONENT_INVALID_SHADOW_DOM_SELECTOR,
  262. ErrorCode.WARN_NGMODULE_ID_UNNECESSARY
  263. ]);
  264. // bazel-out/darwin-fastbuild/bin/packages/compiler-cli/src/ngtsc/diagnostics/src/error.mjs
  265. import ts2 from "typescript";
  266. // bazel-out/darwin-fastbuild/bin/packages/compiler-cli/src/ngtsc/diagnostics/src/util.mjs
  267. var ERROR_CODE_MATCHER = /(\u001b\[\d+m ?)TS-99(\d+: ?\u001b\[\d+m)/g;
  268. function replaceTsWithNgInErrors(errors) {
  269. return errors.replace(ERROR_CODE_MATCHER, "$1NG$2");
  270. }
  271. function ngErrorCode(code) {
  272. return parseInt("-99" + code);
  273. }
  274. // bazel-out/darwin-fastbuild/bin/packages/compiler-cli/src/ngtsc/diagnostics/src/error.mjs
  275. var FatalDiagnosticError = class {
  276. constructor(code, node, message, relatedInformation) {
  277. this.code = code;
  278. this.node = node;
  279. this.message = message;
  280. this.relatedInformation = relatedInformation;
  281. this._isFatalDiagnosticError = true;
  282. }
  283. toDiagnostic() {
  284. return makeDiagnostic(this.code, this.node, this.message, this.relatedInformation);
  285. }
  286. };
  287. function makeDiagnostic(code, node, messageText, relatedInformation) {
  288. node = ts2.getOriginalNode(node);
  289. return {
  290. category: ts2.DiagnosticCategory.Error,
  291. code: ngErrorCode(code),
  292. file: ts2.getOriginalNode(node).getSourceFile(),
  293. start: node.getStart(void 0, false),
  294. length: node.getWidth(),
  295. messageText,
  296. relatedInformation
  297. };
  298. }
  299. function makeDiagnosticChain(messageText, next) {
  300. return {
  301. category: ts2.DiagnosticCategory.Message,
  302. code: 0,
  303. messageText,
  304. next
  305. };
  306. }
  307. function makeRelatedInformation(node, messageText) {
  308. node = ts2.getOriginalNode(node);
  309. return {
  310. category: ts2.DiagnosticCategory.Message,
  311. code: 0,
  312. file: node.getSourceFile(),
  313. start: node.getStart(),
  314. length: node.getWidth(),
  315. messageText
  316. };
  317. }
  318. function addDiagnosticChain(messageText, add) {
  319. if (typeof messageText === "string") {
  320. return makeDiagnosticChain(messageText, add);
  321. }
  322. if (messageText.next === void 0) {
  323. messageText.next = add;
  324. } else {
  325. messageText.next.push(...add);
  326. }
  327. return messageText;
  328. }
  329. // bazel-out/darwin-fastbuild/bin/packages/compiler-cli/src/ngtsc/diagnostics/src/error_details_base_url.mjs
  330. var ERROR_DETAILS_PAGE_BASE_URL = "https://angular.io/errors";
  331. // bazel-out/darwin-fastbuild/bin/packages/compiler-cli/src/ngtsc/diagnostics/src/extended_template_diagnostic_name.mjs
  332. var ExtendedTemplateDiagnosticName;
  333. (function(ExtendedTemplateDiagnosticName2) {
  334. ExtendedTemplateDiagnosticName2["INVALID_BANANA_IN_BOX"] = "invalidBananaInBox";
  335. ExtendedTemplateDiagnosticName2["NULLISH_COALESCING_NOT_NULLABLE"] = "nullishCoalescingNotNullable";
  336. ExtendedTemplateDiagnosticName2["OPTIONAL_CHAIN_NOT_NULLABLE"] = "optionalChainNotNullable";
  337. ExtendedTemplateDiagnosticName2["MISSING_CONTROL_FLOW_DIRECTIVE"] = "missingControlFlowDirective";
  338. ExtendedTemplateDiagnosticName2["TEXT_ATTRIBUTE_NOT_BINDING"] = "textAttributeNotBinding";
  339. ExtendedTemplateDiagnosticName2["MISSING_NGFOROF_LET"] = "missingNgForOfLet";
  340. ExtendedTemplateDiagnosticName2["SUFFIX_NOT_SUPPORTED"] = "suffixNotSupported";
  341. ExtendedTemplateDiagnosticName2["SKIP_HYDRATION_NOT_STATIC"] = "skipHydrationNotStatic";
  342. })(ExtendedTemplateDiagnosticName || (ExtendedTemplateDiagnosticName = {}));
  343. // bazel-out/darwin-fastbuild/bin/packages/compiler-cli/src/ngtsc/imports/src/find_export.mjs
  344. function findExportedNameOfNode(target, file, reflector) {
  345. const exports = reflector.getExportsOfModule(file);
  346. if (exports === null) {
  347. return null;
  348. }
  349. const declaredName = isNamedDeclaration(target) ? target.name.text : null;
  350. let foundExportName = null;
  351. for (const [exportName, declaration] of exports) {
  352. if (declaration.node !== target) {
  353. continue;
  354. }
  355. if (exportName === declaredName) {
  356. return exportName;
  357. }
  358. foundExportName = exportName;
  359. }
  360. return foundExportName;
  361. }
  362. // bazel-out/darwin-fastbuild/bin/packages/compiler-cli/src/ngtsc/imports/src/emitter.mjs
  363. var ImportFlags;
  364. (function(ImportFlags2) {
  365. ImportFlags2[ImportFlags2["None"] = 0] = "None";
  366. ImportFlags2[ImportFlags2["ForceNewImport"] = 1] = "ForceNewImport";
  367. ImportFlags2[ImportFlags2["NoAliasing"] = 2] = "NoAliasing";
  368. ImportFlags2[ImportFlags2["AllowTypeImports"] = 4] = "AllowTypeImports";
  369. ImportFlags2[ImportFlags2["AllowRelativeDtsImports"] = 8] = "AllowRelativeDtsImports";
  370. })(ImportFlags || (ImportFlags = {}));
  371. function assertSuccessfulReferenceEmit(result, origin, typeKind) {
  372. if (result.kind === 0) {
  373. return;
  374. }
  375. const message = makeDiagnosticChain(`Unable to import ${typeKind} ${nodeNameForError(result.ref.node)}.`, [makeDiagnosticChain(result.reason)]);
  376. throw new FatalDiagnosticError(ErrorCode.IMPORT_GENERATION_FAILURE, origin, message, [makeRelatedInformation(result.ref.node, `The ${typeKind} is declared here.`)]);
  377. }
  378. var ReferenceEmitter = class {
  379. constructor(strategies) {
  380. this.strategies = strategies;
  381. }
  382. emit(ref, context, importFlags = ImportFlags.None) {
  383. for (const strategy of this.strategies) {
  384. const emitted = strategy.emit(ref, context, importFlags);
  385. if (emitted !== null) {
  386. return emitted;
  387. }
  388. }
  389. return {
  390. kind: 1,
  391. ref,
  392. context,
  393. reason: `Unable to write a reference to ${nodeNameForError(ref.node)}.`
  394. };
  395. }
  396. };
  397. var LocalIdentifierStrategy = class {
  398. emit(ref, context, importFlags) {
  399. const refSf = getSourceFile(ref.node);
  400. if (importFlags & ImportFlags.ForceNewImport && refSf !== context) {
  401. return null;
  402. }
  403. if (!isDeclaration(ref.node) && refSf === context) {
  404. return {
  405. kind: 0,
  406. expression: new WrappedNodeExpr(ref.node),
  407. importedFile: null
  408. };
  409. }
  410. const identifier = ref.getIdentityIn(context);
  411. if (identifier !== null) {
  412. return {
  413. kind: 0,
  414. expression: new WrappedNodeExpr(identifier),
  415. importedFile: null
  416. };
  417. } else {
  418. return null;
  419. }
  420. }
  421. };
  422. var AbsoluteModuleStrategy = class {
  423. constructor(program, checker, moduleResolver, reflectionHost) {
  424. this.program = program;
  425. this.checker = checker;
  426. this.moduleResolver = moduleResolver;
  427. this.reflectionHost = reflectionHost;
  428. this.moduleExportsCache = /* @__PURE__ */ new Map();
  429. }
  430. emit(ref, context, importFlags) {
  431. if (ref.bestGuessOwningModule === null) {
  432. return null;
  433. } else if (!isDeclaration(ref.node)) {
  434. throw new Error(`Debug assert: unable to import a Reference to non-declaration of type ${ts3.SyntaxKind[ref.node.kind]}.`);
  435. } else if ((importFlags & ImportFlags.AllowTypeImports) === 0 && isTypeDeclaration(ref.node)) {
  436. throw new Error(`Importing a type-only declaration of type ${ts3.SyntaxKind[ref.node.kind]} in a value position is not allowed.`);
  437. }
  438. const { specifier, resolutionContext } = ref.bestGuessOwningModule;
  439. const exports = this.getExportsOfModule(specifier, resolutionContext);
  440. if (exports.module === null) {
  441. return {
  442. kind: 1,
  443. ref,
  444. context,
  445. reason: `The module '${specifier}' could not be found.`
  446. };
  447. } else if (exports.exportMap === null || !exports.exportMap.has(ref.node)) {
  448. return {
  449. kind: 1,
  450. ref,
  451. context,
  452. reason: `The symbol is not exported from ${exports.module.fileName} (module '${specifier}').`
  453. };
  454. }
  455. const symbolName = exports.exportMap.get(ref.node);
  456. return {
  457. kind: 0,
  458. expression: new ExternalExpr(new ExternalReference(specifier, symbolName)),
  459. importedFile: exports.module
  460. };
  461. }
  462. getExportsOfModule(moduleName, fromFile) {
  463. if (!this.moduleExportsCache.has(moduleName)) {
  464. this.moduleExportsCache.set(moduleName, this.enumerateExportsOfModule(moduleName, fromFile));
  465. }
  466. return this.moduleExportsCache.get(moduleName);
  467. }
  468. enumerateExportsOfModule(specifier, fromFile) {
  469. const entryPointFile = this.moduleResolver.resolveModule(specifier, fromFile);
  470. if (entryPointFile === null) {
  471. return { module: null, exportMap: null };
  472. }
  473. const exports = this.reflectionHost.getExportsOfModule(entryPointFile);
  474. if (exports === null) {
  475. return { module: entryPointFile, exportMap: null };
  476. }
  477. const exportMap = /* @__PURE__ */ new Map();
  478. for (const [name, declaration] of exports) {
  479. if (exportMap.has(declaration.node)) {
  480. const existingExport = exportMap.get(declaration.node);
  481. if (isNamedDeclaration(declaration.node) && declaration.node.name.text === existingExport) {
  482. continue;
  483. }
  484. }
  485. exportMap.set(declaration.node, name);
  486. }
  487. return { module: entryPointFile, exportMap };
  488. }
  489. };
  490. var LogicalProjectStrategy = class {
  491. constructor(reflector, logicalFs) {
  492. this.reflector = reflector;
  493. this.logicalFs = logicalFs;
  494. this.relativePathStrategy = new RelativePathStrategy(this.reflector);
  495. }
  496. emit(ref, context, importFlags) {
  497. const destSf = getSourceFile(ref.node);
  498. const destPath = this.logicalFs.logicalPathOfSf(destSf);
  499. if (destPath === null) {
  500. if (destSf.isDeclarationFile && importFlags & ImportFlags.AllowRelativeDtsImports) {
  501. return this.relativePathStrategy.emit(ref, context);
  502. }
  503. return {
  504. kind: 1,
  505. ref,
  506. context,
  507. reason: `The file ${destSf.fileName} is outside of the configured 'rootDir'.`
  508. };
  509. }
  510. const originPath = this.logicalFs.logicalPathOfSf(context);
  511. if (originPath === null) {
  512. throw new Error(`Debug assert: attempt to import from ${context.fileName} but it's outside the program?`);
  513. }
  514. if (destPath === originPath) {
  515. return null;
  516. }
  517. const name = findExportedNameOfNode(ref.node, destSf, this.reflector);
  518. if (name === null) {
  519. return {
  520. kind: 1,
  521. ref,
  522. context,
  523. reason: `The symbol is not exported from ${destSf.fileName}.`
  524. };
  525. }
  526. const moduleName = LogicalProjectPath.relativePathBetween(originPath, destPath);
  527. return {
  528. kind: 0,
  529. expression: new ExternalExpr({ moduleName, name }),
  530. importedFile: destSf
  531. };
  532. }
  533. };
  534. var RelativePathStrategy = class {
  535. constructor(reflector) {
  536. this.reflector = reflector;
  537. }
  538. emit(ref, context) {
  539. const destSf = getSourceFile(ref.node);
  540. const relativePath = relative(dirname(absoluteFromSourceFile(context)), absoluteFromSourceFile(destSf));
  541. const moduleName = toRelativeImport(stripExtension(relativePath));
  542. const name = findExportedNameOfNode(ref.node, destSf, this.reflector);
  543. if (name === null) {
  544. return {
  545. kind: 1,
  546. ref,
  547. context,
  548. reason: `The symbol is not exported from ${destSf.fileName}.`
  549. };
  550. }
  551. return {
  552. kind: 0,
  553. expression: new ExternalExpr({ moduleName, name }),
  554. importedFile: destSf
  555. };
  556. }
  557. };
  558. var UnifiedModulesStrategy = class {
  559. constructor(reflector, unifiedModulesHost) {
  560. this.reflector = reflector;
  561. this.unifiedModulesHost = unifiedModulesHost;
  562. }
  563. emit(ref, context) {
  564. const destSf = getSourceFile(ref.node);
  565. const name = findExportedNameOfNode(ref.node, destSf, this.reflector);
  566. if (name === null) {
  567. return null;
  568. }
  569. const moduleName = this.unifiedModulesHost.fileNameToModuleName(destSf.fileName, context.fileName);
  570. return {
  571. kind: 0,
  572. expression: new ExternalExpr({ moduleName, name }),
  573. importedFile: destSf
  574. };
  575. }
  576. };
  577. // bazel-out/darwin-fastbuild/bin/packages/compiler-cli/src/ngtsc/imports/src/alias.mjs
  578. var CHARS_TO_ESCAPE = /[^a-zA-Z0-9/_]/g;
  579. var UnifiedModulesAliasingHost = class {
  580. constructor(unifiedModulesHost) {
  581. this.unifiedModulesHost = unifiedModulesHost;
  582. this.aliasExportsInDts = false;
  583. }
  584. maybeAliasSymbolAs(ref, context, ngModuleName, isReExport) {
  585. if (!isReExport) {
  586. return null;
  587. }
  588. return this.aliasName(ref.node, context);
  589. }
  590. getAliasIn(decl, via, isReExport) {
  591. if (!isReExport) {
  592. return null;
  593. }
  594. const moduleName = this.unifiedModulesHost.fileNameToModuleName(via.fileName, via.fileName);
  595. return new ExternalExpr2({ moduleName, name: this.aliasName(decl, via) });
  596. }
  597. aliasName(decl, context) {
  598. const declModule = this.unifiedModulesHost.fileNameToModuleName(decl.getSourceFile().fileName, context.fileName);
  599. const replaced = declModule.replace(CHARS_TO_ESCAPE, "_").replace(/\//g, "$");
  600. return "\u0275ng$" + replaced + "$$" + decl.name.text;
  601. }
  602. };
  603. var PrivateExportAliasingHost = class {
  604. constructor(host) {
  605. this.host = host;
  606. this.aliasExportsInDts = true;
  607. }
  608. maybeAliasSymbolAs(ref, context, ngModuleName) {
  609. if (ref.hasOwningModuleGuess) {
  610. return null;
  611. }
  612. const exports = this.host.getExportsOfModule(context);
  613. if (exports === null) {
  614. throw new Error(`Could not determine the exports of: ${context.fileName}`);
  615. }
  616. let found = false;
  617. exports.forEach((value) => {
  618. if (value.node === ref.node) {
  619. found = true;
  620. }
  621. });
  622. if (found) {
  623. return null;
  624. }
  625. return `\u0275ngExport\u0275${ngModuleName}\u0275${ref.node.name.text}`;
  626. }
  627. getAliasIn() {
  628. return null;
  629. }
  630. };
  631. var AliasStrategy = class {
  632. emit(ref, context, importMode) {
  633. if (importMode & ImportFlags.NoAliasing || ref.alias === null) {
  634. return null;
  635. }
  636. return {
  637. kind: 0,
  638. expression: ref.alias,
  639. importedFile: "unknown"
  640. };
  641. }
  642. };
  643. // bazel-out/darwin-fastbuild/bin/packages/compiler-cli/src/ngtsc/util/src/path.mjs
  644. function relativePathBetween(from, to) {
  645. const relativePath = stripExtension(relative(dirname(resolve(from)), resolve(to)));
  646. return relativePath !== "" ? toRelativeImport(relativePath) : null;
  647. }
  648. function normalizeSeparators(path) {
  649. return path.replace(/\\/g, "/");
  650. }
  651. // bazel-out/darwin-fastbuild/bin/packages/compiler-cli/src/ngtsc/imports/src/core.mjs
  652. var NoopImportRewriter = class {
  653. shouldImportSymbol(symbol, specifier) {
  654. return true;
  655. }
  656. rewriteSymbol(symbol, specifier) {
  657. return symbol;
  658. }
  659. rewriteSpecifier(specifier, inContextOfFile) {
  660. return specifier;
  661. }
  662. };
  663. var CORE_SUPPORTED_SYMBOLS = /* @__PURE__ */ new Map([
  664. ["\u0275\u0275defineInjectable", "\u0275\u0275defineInjectable"],
  665. ["\u0275\u0275defineInjector", "\u0275\u0275defineInjector"],
  666. ["\u0275\u0275defineNgModule", "\u0275\u0275defineNgModule"],
  667. ["\u0275\u0275setNgModuleScope", "\u0275\u0275setNgModuleScope"],
  668. ["\u0275\u0275inject", "\u0275\u0275inject"],
  669. ["\u0275\u0275FactoryDeclaration", "\u0275\u0275FactoryDeclaration"],
  670. ["\u0275setClassMetadata", "setClassMetadata"],
  671. ["\u0275\u0275InjectableDeclaration", "\u0275\u0275InjectableDeclaration"],
  672. ["\u0275\u0275InjectorDeclaration", "\u0275\u0275InjectorDeclaration"],
  673. ["\u0275\u0275NgModuleDeclaration", "\u0275\u0275NgModuleDeclaration"],
  674. ["\u0275NgModuleFactory", "NgModuleFactory"],
  675. ["\u0275noSideEffects", "\u0275noSideEffects"]
  676. ]);
  677. var CORE_MODULE = "@angular/core";
  678. var R3SymbolsImportRewriter = class {
  679. constructor(r3SymbolsPath) {
  680. this.r3SymbolsPath = r3SymbolsPath;
  681. }
  682. shouldImportSymbol(symbol, specifier) {
  683. return true;
  684. }
  685. rewriteSymbol(symbol, specifier) {
  686. if (specifier !== CORE_MODULE) {
  687. return symbol;
  688. }
  689. return validateAndRewriteCoreSymbol(symbol);
  690. }
  691. rewriteSpecifier(specifier, inContextOfFile) {
  692. if (specifier !== CORE_MODULE) {
  693. return specifier;
  694. }
  695. const relativePathToR3Symbols = relativePathBetween(inContextOfFile, this.r3SymbolsPath);
  696. if (relativePathToR3Symbols === null) {
  697. throw new Error(`Failed to rewrite import inside ${CORE_MODULE}: ${inContextOfFile} -> ${this.r3SymbolsPath}`);
  698. }
  699. return relativePathToR3Symbols;
  700. }
  701. };
  702. function validateAndRewriteCoreSymbol(name) {
  703. if (!CORE_SUPPORTED_SYMBOLS.has(name)) {
  704. throw new Error(`Importing unexpected symbol ${name} while compiling ${CORE_MODULE}`);
  705. }
  706. return CORE_SUPPORTED_SYMBOLS.get(name);
  707. }
  708. // bazel-out/darwin-fastbuild/bin/packages/compiler-cli/src/ngtsc/imports/src/patch_alias_reference_resolution.mjs
  709. import ts4 from "typescript";
  710. var patchedReferencedAliasesSymbol = Symbol("patchedReferencedAliases");
  711. function loadIsReferencedAliasDeclarationPatch(context) {
  712. if (!isTransformationContextWithEmitResolver(context)) {
  713. throwIncompatibleTransformationContextError();
  714. }
  715. const emitResolver = context.getEmitResolver();
  716. const existingReferencedAliases = emitResolver[patchedReferencedAliasesSymbol];
  717. if (existingReferencedAliases !== void 0) {
  718. return existingReferencedAliases;
  719. }
  720. const originalIsReferencedAliasDeclaration = emitResolver.isReferencedAliasDeclaration;
  721. if (originalIsReferencedAliasDeclaration === void 0) {
  722. throwIncompatibleTransformationContextError();
  723. }
  724. const referencedAliases = /* @__PURE__ */ new Set();
  725. emitResolver.isReferencedAliasDeclaration = function(node, ...args) {
  726. if (isAliasImportDeclaration(node) && referencedAliases.has(node)) {
  727. return true;
  728. }
  729. return originalIsReferencedAliasDeclaration.call(emitResolver, node, ...args);
  730. };
  731. return emitResolver[patchedReferencedAliasesSymbol] = referencedAliases;
  732. }
  733. function isAliasImportDeclaration(node) {
  734. return ts4.isImportSpecifier(node) || ts4.isNamespaceImport(node) || ts4.isImportClause(node);
  735. }
  736. function isTransformationContextWithEmitResolver(context) {
  737. return context.getEmitResolver !== void 0;
  738. }
  739. function throwIncompatibleTransformationContextError() {
  740. throw Error("Angular compiler is incompatible with this version of the TypeScript compiler.\n\nIf you recently updated TypeScript and this issue surfaces now, consider downgrading.\n\nPlease report an issue on the Angular repositories when this issue surfaces and you are using a supposedly compatible TypeScript version.");
  741. }
  742. // bazel-out/darwin-fastbuild/bin/packages/compiler-cli/src/ngtsc/imports/src/default.mjs
  743. var DefaultImportDeclaration = Symbol("DefaultImportDeclaration");
  744. function attachDefaultImportDeclaration(expr, importDecl) {
  745. expr[DefaultImportDeclaration] = importDecl;
  746. }
  747. function getDefaultImportDeclaration(expr) {
  748. var _a;
  749. return (_a = expr[DefaultImportDeclaration]) != null ? _a : null;
  750. }
  751. var DefaultImportTracker = class {
  752. constructor() {
  753. this.sourceFileToUsedImports = /* @__PURE__ */ new Map();
  754. }
  755. recordUsedImport(importDecl) {
  756. if (importDecl.importClause) {
  757. const sf = getSourceFile(importDecl);
  758. if (!this.sourceFileToUsedImports.has(sf.fileName)) {
  759. this.sourceFileToUsedImports.set(sf.fileName, /* @__PURE__ */ new Set());
  760. }
  761. this.sourceFileToUsedImports.get(sf.fileName).add(importDecl.importClause);
  762. }
  763. }
  764. importPreservingTransformer() {
  765. return (context) => {
  766. let clausesToPreserve = null;
  767. return (sourceFile) => {
  768. const clausesForFile = this.sourceFileToUsedImports.get(sourceFile.fileName);
  769. if (clausesForFile !== void 0) {
  770. for (const clause of clausesForFile) {
  771. if (clausesToPreserve === null) {
  772. clausesToPreserve = loadIsReferencedAliasDeclarationPatch(context);
  773. }
  774. clausesToPreserve.add(clause);
  775. }
  776. }
  777. return sourceFile;
  778. };
  779. };
  780. }
  781. };
  782. // bazel-out/darwin-fastbuild/bin/packages/compiler-cli/src/ngtsc/imports/src/resolver.mjs
  783. var ModuleResolver = class {
  784. constructor(program, compilerOptions, host, moduleResolutionCache) {
  785. this.program = program;
  786. this.compilerOptions = compilerOptions;
  787. this.host = host;
  788. this.moduleResolutionCache = moduleResolutionCache;
  789. }
  790. resolveModule(moduleName, containingFile) {
  791. const resolved = resolveModuleName(moduleName, containingFile, this.compilerOptions, this.host, this.moduleResolutionCache);
  792. if (resolved === void 0) {
  793. return null;
  794. }
  795. return getSourceFileOrNull(this.program, absoluteFrom(resolved.resolvedFileName));
  796. }
  797. };
  798. export {
  799. ErrorCode,
  800. COMPILER_ERRORS_WITH_GUIDES,
  801. replaceTsWithNgInErrors,
  802. ngErrorCode,
  803. FatalDiagnosticError,
  804. makeDiagnostic,
  805. makeDiagnosticChain,
  806. makeRelatedInformation,
  807. addDiagnosticChain,
  808. ERROR_DETAILS_PAGE_BASE_URL,
  809. ExtendedTemplateDiagnosticName,
  810. isSymbolWithValueDeclaration,
  811. isDtsPath,
  812. isNonDeclarationTsPath,
  813. isFromDtsFile,
  814. nodeNameForError,
  815. getSourceFile,
  816. getSourceFileOrNull,
  817. getTokenAtPosition,
  818. identifierOfNode,
  819. isDeclaration,
  820. getRootDirs,
  821. nodeDebugInfo,
  822. isAssignment,
  823. toUnredirectedSourceFile,
  824. ImportFlags,
  825. assertSuccessfulReferenceEmit,
  826. ReferenceEmitter,
  827. LocalIdentifierStrategy,
  828. AbsoluteModuleStrategy,
  829. LogicalProjectStrategy,
  830. RelativePathStrategy,
  831. UnifiedModulesStrategy,
  832. UnifiedModulesAliasingHost,
  833. PrivateExportAliasingHost,
  834. AliasStrategy,
  835. relativePathBetween,
  836. normalizeSeparators,
  837. NoopImportRewriter,
  838. R3SymbolsImportRewriter,
  839. loadIsReferencedAliasDeclarationPatch,
  840. isAliasImportDeclaration,
  841. attachDefaultImportDeclaration,
  842. getDefaultImportDeclaration,
  843. DefaultImportTracker,
  844. Reference,
  845. ModuleResolver
  846. };
  847. /**
  848. * @license
  849. * Copyright Google LLC All Rights Reserved.
  850. *
  851. * Use of this source code is governed by an MIT-style license that can be
  852. * found in the LICENSE file at https://angular.io/license
  853. */
  854. //# sourceMappingURL=chunk-7RPZKH3B.js.map