chunk-4NU6EGYK.js 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640
  1. import {createRequire as __cjsCompatRequire} from 'module';
  2. const require = __cjsCompatRequire(import.meta.url);
  3. // bazel-out/darwin-fastbuild/bin/packages/compiler-cli/src/ngtsc/reflection/src/typescript.mjs
  4. import ts4 from "typescript";
  5. // bazel-out/darwin-fastbuild/bin/packages/compiler-cli/src/ngtsc/reflection/src/host.mjs
  6. import ts from "typescript";
  7. function isDecoratorIdentifier(exp) {
  8. return ts.isIdentifier(exp) || ts.isPropertyAccessExpression(exp) && ts.isIdentifier(exp.expression) && ts.isIdentifier(exp.name);
  9. }
  10. var ClassMemberKind;
  11. (function(ClassMemberKind2) {
  12. ClassMemberKind2[ClassMemberKind2["Constructor"] = 0] = "Constructor";
  13. ClassMemberKind2[ClassMemberKind2["Getter"] = 1] = "Getter";
  14. ClassMemberKind2[ClassMemberKind2["Setter"] = 2] = "Setter";
  15. ClassMemberKind2[ClassMemberKind2["Property"] = 3] = "Property";
  16. ClassMemberKind2[ClassMemberKind2["Method"] = 4] = "Method";
  17. })(ClassMemberKind || (ClassMemberKind = {}));
  18. // bazel-out/darwin-fastbuild/bin/packages/compiler-cli/src/ngtsc/reflection/src/type_to_value.mjs
  19. import ts2 from "typescript";
  20. function typeToValue(typeNode, checker) {
  21. if (typeNode === null) {
  22. return missingType();
  23. }
  24. if (!ts2.isTypeReferenceNode(typeNode)) {
  25. return unsupportedType(typeNode);
  26. }
  27. const symbols = resolveTypeSymbols(typeNode, checker);
  28. if (symbols === null) {
  29. return unknownReference(typeNode);
  30. }
  31. const { local, decl } = symbols;
  32. if (decl.valueDeclaration === void 0 || decl.flags & ts2.SymbolFlags.ConstEnum) {
  33. let typeOnlyDecl = null;
  34. if (decl.declarations !== void 0 && decl.declarations.length > 0) {
  35. typeOnlyDecl = decl.declarations[0];
  36. }
  37. return noValueDeclaration(typeNode, typeOnlyDecl);
  38. }
  39. const firstDecl = local.declarations && local.declarations[0];
  40. if (firstDecl !== void 0) {
  41. if (ts2.isImportClause(firstDecl) && firstDecl.name !== void 0) {
  42. if (firstDecl.isTypeOnly) {
  43. return typeOnlyImport(typeNode, firstDecl);
  44. }
  45. return {
  46. kind: 0,
  47. expression: firstDecl.name,
  48. defaultImportStatement: firstDecl.parent
  49. };
  50. } else if (ts2.isImportSpecifier(firstDecl)) {
  51. if (firstDecl.isTypeOnly) {
  52. return typeOnlyImport(typeNode, firstDecl);
  53. }
  54. if (firstDecl.parent.parent.isTypeOnly) {
  55. return typeOnlyImport(typeNode, firstDecl.parent.parent);
  56. }
  57. const importedName = (firstDecl.propertyName || firstDecl.name).text;
  58. const [_localName, ...nestedPath] = symbols.symbolNames;
  59. const moduleName = extractModuleName(firstDecl.parent.parent.parent);
  60. return {
  61. kind: 1,
  62. valueDeclaration: decl.valueDeclaration,
  63. moduleName,
  64. importedName,
  65. nestedPath
  66. };
  67. } else if (ts2.isNamespaceImport(firstDecl)) {
  68. if (firstDecl.parent.isTypeOnly) {
  69. return typeOnlyImport(typeNode, firstDecl.parent);
  70. }
  71. if (symbols.symbolNames.length === 1) {
  72. return namespaceImport(typeNode, firstDecl.parent);
  73. }
  74. const [_ns, importedName, ...nestedPath] = symbols.symbolNames;
  75. const moduleName = extractModuleName(firstDecl.parent.parent);
  76. return {
  77. kind: 1,
  78. valueDeclaration: decl.valueDeclaration,
  79. moduleName,
  80. importedName,
  81. nestedPath
  82. };
  83. }
  84. }
  85. const expression = typeNodeToValueExpr(typeNode);
  86. if (expression !== null) {
  87. return {
  88. kind: 0,
  89. expression,
  90. defaultImportStatement: null
  91. };
  92. } else {
  93. return unsupportedType(typeNode);
  94. }
  95. }
  96. function unsupportedType(typeNode) {
  97. return {
  98. kind: 2,
  99. reason: { kind: 5, typeNode }
  100. };
  101. }
  102. function noValueDeclaration(typeNode, decl) {
  103. return {
  104. kind: 2,
  105. reason: { kind: 1, typeNode, decl }
  106. };
  107. }
  108. function typeOnlyImport(typeNode, node) {
  109. return {
  110. kind: 2,
  111. reason: { kind: 2, typeNode, node }
  112. };
  113. }
  114. function unknownReference(typeNode) {
  115. return {
  116. kind: 2,
  117. reason: { kind: 3, typeNode }
  118. };
  119. }
  120. function namespaceImport(typeNode, importClause) {
  121. return {
  122. kind: 2,
  123. reason: { kind: 4, typeNode, importClause }
  124. };
  125. }
  126. function missingType() {
  127. return {
  128. kind: 2,
  129. reason: { kind: 0 }
  130. };
  131. }
  132. function typeNodeToValueExpr(node) {
  133. if (ts2.isTypeReferenceNode(node)) {
  134. return entityNameToValue(node.typeName);
  135. } else {
  136. return null;
  137. }
  138. }
  139. function resolveTypeSymbols(typeRef, checker) {
  140. const typeName = typeRef.typeName;
  141. const typeRefSymbol = checker.getSymbolAtLocation(typeName);
  142. if (typeRefSymbol === void 0) {
  143. return null;
  144. }
  145. let local = typeRefSymbol;
  146. let leftMost = typeName;
  147. const symbolNames = [];
  148. while (ts2.isQualifiedName(leftMost)) {
  149. symbolNames.unshift(leftMost.right.text);
  150. leftMost = leftMost.left;
  151. }
  152. symbolNames.unshift(leftMost.text);
  153. if (leftMost !== typeName) {
  154. const localTmp = checker.getSymbolAtLocation(leftMost);
  155. if (localTmp !== void 0) {
  156. local = localTmp;
  157. }
  158. }
  159. let decl = typeRefSymbol;
  160. if (typeRefSymbol.flags & ts2.SymbolFlags.Alias) {
  161. decl = checker.getAliasedSymbol(typeRefSymbol);
  162. }
  163. return { local, decl, symbolNames };
  164. }
  165. function entityNameToValue(node) {
  166. if (ts2.isQualifiedName(node)) {
  167. const left = entityNameToValue(node.left);
  168. return left !== null ? ts2.factory.createPropertyAccessExpression(left, node.right) : null;
  169. } else if (ts2.isIdentifier(node)) {
  170. const clone = ts2.setOriginalNode(ts2.factory.createIdentifier(node.text), node);
  171. clone.parent = node.parent;
  172. return clone;
  173. } else {
  174. return null;
  175. }
  176. }
  177. function extractModuleName(node) {
  178. if (!ts2.isStringLiteral(node.moduleSpecifier)) {
  179. throw new Error("not a module specifier");
  180. }
  181. return node.moduleSpecifier.text;
  182. }
  183. // bazel-out/darwin-fastbuild/bin/packages/compiler-cli/src/ngtsc/reflection/src/util.mjs
  184. import ts3 from "typescript";
  185. function isNamedClassDeclaration(node) {
  186. return ts3.isClassDeclaration(node) && isIdentifier(node.name);
  187. }
  188. function isIdentifier(node) {
  189. return node !== void 0 && ts3.isIdentifier(node);
  190. }
  191. // bazel-out/darwin-fastbuild/bin/packages/compiler-cli/src/ngtsc/reflection/src/typescript.mjs
  192. var TypeScriptReflectionHost = class {
  193. constructor(checker) {
  194. this.checker = checker;
  195. }
  196. getDecoratorsOfDeclaration(declaration) {
  197. const decorators = ts4.canHaveDecorators(declaration) ? ts4.getDecorators(declaration) : void 0;
  198. return decorators !== void 0 && decorators.length ? decorators.map((decorator) => this._reflectDecorator(decorator)).filter((dec) => dec !== null) : null;
  199. }
  200. getMembersOfClass(clazz) {
  201. const tsClazz = castDeclarationToClassOrDie(clazz);
  202. return tsClazz.members.map((member) => this._reflectMember(member)).filter((member) => member !== null);
  203. }
  204. getConstructorParameters(clazz) {
  205. const tsClazz = castDeclarationToClassOrDie(clazz);
  206. const isDeclaration = tsClazz.getSourceFile().isDeclarationFile;
  207. const ctor = tsClazz.members.find((member) => ts4.isConstructorDeclaration(member) && (isDeclaration || member.body !== void 0));
  208. if (ctor === void 0) {
  209. return null;
  210. }
  211. return ctor.parameters.map((node) => {
  212. const name = parameterName(node.name);
  213. const decorators = this.getDecoratorsOfDeclaration(node);
  214. let originalTypeNode = node.type || null;
  215. let typeNode = originalTypeNode;
  216. if (typeNode && ts4.isUnionTypeNode(typeNode)) {
  217. let childTypeNodes = typeNode.types.filter((childTypeNode) => !(ts4.isLiteralTypeNode(childTypeNode) && childTypeNode.literal.kind === ts4.SyntaxKind.NullKeyword));
  218. if (childTypeNodes.length === 1) {
  219. typeNode = childTypeNodes[0];
  220. }
  221. }
  222. const typeValueReference = typeToValue(typeNode, this.checker);
  223. return {
  224. name,
  225. nameNode: node.name,
  226. typeValueReference,
  227. typeNode: originalTypeNode,
  228. decorators
  229. };
  230. });
  231. }
  232. getImportOfIdentifier(id) {
  233. const directImport = this.getDirectImportOfIdentifier(id);
  234. if (directImport !== null) {
  235. return directImport;
  236. } else if (ts4.isQualifiedName(id.parent) && id.parent.right === id) {
  237. return this.getImportOfNamespacedIdentifier(id, getQualifiedNameRoot(id.parent));
  238. } else if (ts4.isPropertyAccessExpression(id.parent) && id.parent.name === id) {
  239. return this.getImportOfNamespacedIdentifier(id, getFarLeftIdentifier(id.parent));
  240. } else {
  241. return null;
  242. }
  243. }
  244. getExportsOfModule(node) {
  245. if (!ts4.isSourceFile(node)) {
  246. throw new Error(`getExportsOfModule() called on non-SourceFile in TS code`);
  247. }
  248. const symbol = this.checker.getSymbolAtLocation(node);
  249. if (symbol === void 0) {
  250. return null;
  251. }
  252. const map = /* @__PURE__ */ new Map();
  253. this.checker.getExportsOfModule(symbol).forEach((exportSymbol) => {
  254. const decl = this.getDeclarationOfSymbol(exportSymbol, null);
  255. if (decl !== null) {
  256. map.set(exportSymbol.name, decl);
  257. }
  258. });
  259. return map;
  260. }
  261. isClass(node) {
  262. return isNamedClassDeclaration(node);
  263. }
  264. hasBaseClass(clazz) {
  265. return this.getBaseClassExpression(clazz) !== null;
  266. }
  267. getBaseClassExpression(clazz) {
  268. if (!(ts4.isClassDeclaration(clazz) || ts4.isClassExpression(clazz)) || clazz.heritageClauses === void 0) {
  269. return null;
  270. }
  271. const extendsClause = clazz.heritageClauses.find((clause) => clause.token === ts4.SyntaxKind.ExtendsKeyword);
  272. if (extendsClause === void 0) {
  273. return null;
  274. }
  275. const extendsType = extendsClause.types[0];
  276. if (extendsType === void 0) {
  277. return null;
  278. }
  279. return extendsType.expression;
  280. }
  281. getDeclarationOfIdentifier(id) {
  282. let symbol = this.checker.getSymbolAtLocation(id);
  283. if (symbol === void 0) {
  284. return null;
  285. }
  286. return this.getDeclarationOfSymbol(symbol, id);
  287. }
  288. getDefinitionOfFunction(node) {
  289. if (!ts4.isFunctionDeclaration(node) && !ts4.isMethodDeclaration(node) && !ts4.isFunctionExpression(node) && !ts4.isArrowFunction(node)) {
  290. return null;
  291. }
  292. let body = null;
  293. if (node.body !== void 0) {
  294. body = ts4.isBlock(node.body) ? Array.from(node.body.statements) : [ts4.factory.createReturnStatement(node.body)];
  295. }
  296. return {
  297. node,
  298. body,
  299. typeParameters: node.typeParameters === void 0 ? null : Array.from(node.typeParameters),
  300. parameters: node.parameters.map((param) => {
  301. const name = parameterName(param.name);
  302. const initializer = param.initializer || null;
  303. return { name, node: param, initializer, type: param.type || null };
  304. })
  305. };
  306. }
  307. getGenericArityOfClass(clazz) {
  308. if (!ts4.isClassDeclaration(clazz)) {
  309. return null;
  310. }
  311. return clazz.typeParameters !== void 0 ? clazz.typeParameters.length : 0;
  312. }
  313. getVariableValue(declaration) {
  314. return declaration.initializer || null;
  315. }
  316. isStaticallyExported(decl) {
  317. let topLevel = decl;
  318. if (ts4.isVariableDeclaration(decl) && ts4.isVariableDeclarationList(decl.parent)) {
  319. topLevel = decl.parent.parent;
  320. }
  321. const modifiers = ts4.canHaveModifiers(topLevel) ? ts4.getModifiers(topLevel) : void 0;
  322. if (modifiers !== void 0 && modifiers.some((modifier) => modifier.kind === ts4.SyntaxKind.ExportKeyword)) {
  323. return true;
  324. }
  325. if (topLevel.parent === void 0 || !ts4.isSourceFile(topLevel.parent)) {
  326. return false;
  327. }
  328. const localExports = this.getLocalExportedDeclarationsOfSourceFile(decl.getSourceFile());
  329. return localExports.has(decl);
  330. }
  331. getDirectImportOfIdentifier(id) {
  332. const symbol = this.checker.getSymbolAtLocation(id);
  333. if (symbol === void 0 || symbol.declarations === void 0 || symbol.declarations.length !== 1) {
  334. return null;
  335. }
  336. const decl = symbol.declarations[0];
  337. const importDecl = getContainingImportDeclaration(decl);
  338. if (importDecl === null) {
  339. return null;
  340. }
  341. if (!ts4.isStringLiteral(importDecl.moduleSpecifier)) {
  342. return null;
  343. }
  344. return { from: importDecl.moduleSpecifier.text, name: getExportedName(decl, id) };
  345. }
  346. getImportOfNamespacedIdentifier(id, namespaceIdentifier) {
  347. if (namespaceIdentifier === null) {
  348. return null;
  349. }
  350. const namespaceSymbol = this.checker.getSymbolAtLocation(namespaceIdentifier);
  351. if (!namespaceSymbol || namespaceSymbol.declarations === void 0) {
  352. return null;
  353. }
  354. const declaration = namespaceSymbol.declarations.length === 1 ? namespaceSymbol.declarations[0] : null;
  355. if (!declaration) {
  356. return null;
  357. }
  358. const namespaceDeclaration = ts4.isNamespaceImport(declaration) ? declaration : null;
  359. if (!namespaceDeclaration) {
  360. return null;
  361. }
  362. const importDeclaration = namespaceDeclaration.parent.parent;
  363. if (!ts4.isStringLiteral(importDeclaration.moduleSpecifier)) {
  364. return null;
  365. }
  366. return {
  367. from: importDeclaration.moduleSpecifier.text,
  368. name: id.text
  369. };
  370. }
  371. getDeclarationOfSymbol(symbol, originalId) {
  372. let valueDeclaration = void 0;
  373. if (symbol.valueDeclaration !== void 0) {
  374. valueDeclaration = symbol.valueDeclaration;
  375. } else if (symbol.declarations !== void 0 && symbol.declarations.length > 0) {
  376. valueDeclaration = symbol.declarations[0];
  377. }
  378. if (valueDeclaration !== void 0 && ts4.isShorthandPropertyAssignment(valueDeclaration)) {
  379. const shorthandSymbol = this.checker.getShorthandAssignmentValueSymbol(valueDeclaration);
  380. if (shorthandSymbol === void 0) {
  381. return null;
  382. }
  383. return this.getDeclarationOfSymbol(shorthandSymbol, originalId);
  384. } else if (valueDeclaration !== void 0 && ts4.isExportSpecifier(valueDeclaration)) {
  385. const targetSymbol = this.checker.getExportSpecifierLocalTargetSymbol(valueDeclaration);
  386. if (targetSymbol === void 0) {
  387. return null;
  388. }
  389. return this.getDeclarationOfSymbol(targetSymbol, originalId);
  390. }
  391. const importInfo = originalId && this.getImportOfIdentifier(originalId);
  392. const viaModule = importInfo !== null && importInfo.from !== null && !importInfo.from.startsWith(".") ? importInfo.from : null;
  393. while (symbol.flags & ts4.SymbolFlags.Alias) {
  394. symbol = this.checker.getAliasedSymbol(symbol);
  395. }
  396. if (symbol.valueDeclaration !== void 0) {
  397. return {
  398. node: symbol.valueDeclaration,
  399. viaModule
  400. };
  401. } else if (symbol.declarations !== void 0 && symbol.declarations.length > 0) {
  402. return {
  403. node: symbol.declarations[0],
  404. viaModule
  405. };
  406. } else {
  407. return null;
  408. }
  409. }
  410. _reflectDecorator(node) {
  411. let decoratorExpr = node.expression;
  412. let args = null;
  413. if (ts4.isCallExpression(decoratorExpr)) {
  414. args = Array.from(decoratorExpr.arguments);
  415. decoratorExpr = decoratorExpr.expression;
  416. }
  417. if (!isDecoratorIdentifier(decoratorExpr)) {
  418. return null;
  419. }
  420. const decoratorIdentifier = ts4.isIdentifier(decoratorExpr) ? decoratorExpr : decoratorExpr.name;
  421. const importDecl = this.getImportOfIdentifier(decoratorIdentifier);
  422. return {
  423. name: decoratorIdentifier.text,
  424. identifier: decoratorExpr,
  425. import: importDecl,
  426. node,
  427. args
  428. };
  429. }
  430. _reflectMember(node) {
  431. let kind = null;
  432. let value = null;
  433. let name = null;
  434. let nameNode = null;
  435. if (ts4.isPropertyDeclaration(node)) {
  436. kind = ClassMemberKind.Property;
  437. value = node.initializer || null;
  438. } else if (ts4.isGetAccessorDeclaration(node)) {
  439. kind = ClassMemberKind.Getter;
  440. } else if (ts4.isSetAccessorDeclaration(node)) {
  441. kind = ClassMemberKind.Setter;
  442. } else if (ts4.isMethodDeclaration(node)) {
  443. kind = ClassMemberKind.Method;
  444. } else if (ts4.isConstructorDeclaration(node)) {
  445. kind = ClassMemberKind.Constructor;
  446. } else {
  447. return null;
  448. }
  449. if (ts4.isConstructorDeclaration(node)) {
  450. name = "constructor";
  451. } else if (ts4.isIdentifier(node.name)) {
  452. name = node.name.text;
  453. nameNode = node.name;
  454. } else if (ts4.isStringLiteral(node.name)) {
  455. name = node.name.text;
  456. nameNode = node.name;
  457. } else {
  458. return null;
  459. }
  460. const decorators = this.getDecoratorsOfDeclaration(node);
  461. const modifiers = ts4.getModifiers(node);
  462. const isStatic = modifiers !== void 0 && modifiers.some((mod) => mod.kind === ts4.SyntaxKind.StaticKeyword);
  463. return {
  464. node,
  465. implementation: node,
  466. kind,
  467. type: node.type || null,
  468. name,
  469. nameNode,
  470. decorators,
  471. value,
  472. isStatic
  473. };
  474. }
  475. getLocalExportedDeclarationsOfSourceFile(file) {
  476. const cacheSf = file;
  477. if (cacheSf[LocalExportedDeclarations] !== void 0) {
  478. return cacheSf[LocalExportedDeclarations];
  479. }
  480. const exportSet = /* @__PURE__ */ new Set();
  481. cacheSf[LocalExportedDeclarations] = exportSet;
  482. const sfSymbol = this.checker.getSymbolAtLocation(cacheSf);
  483. if (sfSymbol === void 0 || sfSymbol.exports === void 0) {
  484. return exportSet;
  485. }
  486. const iter = sfSymbol.exports.values();
  487. let item = iter.next();
  488. while (item.done !== true) {
  489. let exportedSymbol = item.value;
  490. if (exportedSymbol.flags & ts4.SymbolFlags.Alias) {
  491. exportedSymbol = this.checker.getAliasedSymbol(exportedSymbol);
  492. }
  493. if (exportedSymbol.valueDeclaration !== void 0 && exportedSymbol.valueDeclaration.getSourceFile() === file) {
  494. exportSet.add(exportedSymbol.valueDeclaration);
  495. }
  496. item = iter.next();
  497. }
  498. return exportSet;
  499. }
  500. };
  501. function reflectTypeEntityToDeclaration(type, checker) {
  502. let realSymbol = checker.getSymbolAtLocation(type);
  503. if (realSymbol === void 0) {
  504. throw new Error(`Cannot resolve type entity ${type.getText()} to symbol`);
  505. }
  506. while (realSymbol.flags & ts4.SymbolFlags.Alias) {
  507. realSymbol = checker.getAliasedSymbol(realSymbol);
  508. }
  509. let node = null;
  510. if (realSymbol.valueDeclaration !== void 0) {
  511. node = realSymbol.valueDeclaration;
  512. } else if (realSymbol.declarations !== void 0 && realSymbol.declarations.length === 1) {
  513. node = realSymbol.declarations[0];
  514. } else {
  515. throw new Error(`Cannot resolve type entity symbol to declaration`);
  516. }
  517. if (ts4.isQualifiedName(type)) {
  518. if (!ts4.isIdentifier(type.left)) {
  519. throw new Error(`Cannot handle qualified name with non-identifier lhs`);
  520. }
  521. const symbol = checker.getSymbolAtLocation(type.left);
  522. if (symbol === void 0 || symbol.declarations === void 0 || symbol.declarations.length !== 1) {
  523. throw new Error(`Cannot resolve qualified type entity lhs to symbol`);
  524. }
  525. const decl = symbol.declarations[0];
  526. if (ts4.isNamespaceImport(decl)) {
  527. const clause = decl.parent;
  528. const importDecl = clause.parent;
  529. if (!ts4.isStringLiteral(importDecl.moduleSpecifier)) {
  530. throw new Error(`Module specifier is not a string`);
  531. }
  532. return { node, from: importDecl.moduleSpecifier.text };
  533. } else if (ts4.isModuleDeclaration(decl)) {
  534. return { node, from: null };
  535. } else {
  536. throw new Error(`Unknown import type?`);
  537. }
  538. } else {
  539. return { node, from: null };
  540. }
  541. }
  542. function filterToMembersWithDecorator(members, name, module) {
  543. return members.filter((member) => !member.isStatic).map((member) => {
  544. if (member.decorators === null) {
  545. return null;
  546. }
  547. const decorators = member.decorators.filter((dec) => {
  548. if (dec.import !== null) {
  549. return dec.import.name === name && (module === void 0 || dec.import.from === module);
  550. } else {
  551. return dec.name === name && module === void 0;
  552. }
  553. });
  554. if (decorators.length === 0) {
  555. return null;
  556. }
  557. return { member, decorators };
  558. }).filter((value) => value !== null);
  559. }
  560. function reflectObjectLiteral(node) {
  561. const map = /* @__PURE__ */ new Map();
  562. node.properties.forEach((prop) => {
  563. if (ts4.isPropertyAssignment(prop)) {
  564. const name = propertyNameToString(prop.name);
  565. if (name === null) {
  566. return;
  567. }
  568. map.set(name, prop.initializer);
  569. } else if (ts4.isShorthandPropertyAssignment(prop)) {
  570. map.set(prop.name.text, prop.name);
  571. } else {
  572. return;
  573. }
  574. });
  575. return map;
  576. }
  577. function castDeclarationToClassOrDie(declaration) {
  578. if (!ts4.isClassDeclaration(declaration)) {
  579. throw new Error(`Reflecting on a ${ts4.SyntaxKind[declaration.kind]} instead of a ClassDeclaration.`);
  580. }
  581. return declaration;
  582. }
  583. function parameterName(name) {
  584. if (ts4.isIdentifier(name)) {
  585. return name.text;
  586. } else {
  587. return null;
  588. }
  589. }
  590. function propertyNameToString(node) {
  591. if (ts4.isIdentifier(node) || ts4.isStringLiteral(node) || ts4.isNumericLiteral(node)) {
  592. return node.text;
  593. } else {
  594. return null;
  595. }
  596. }
  597. function getQualifiedNameRoot(qualifiedName) {
  598. while (ts4.isQualifiedName(qualifiedName.left)) {
  599. qualifiedName = qualifiedName.left;
  600. }
  601. return ts4.isIdentifier(qualifiedName.left) ? qualifiedName.left : null;
  602. }
  603. function getFarLeftIdentifier(propertyAccess) {
  604. while (ts4.isPropertyAccessExpression(propertyAccess.expression)) {
  605. propertyAccess = propertyAccess.expression;
  606. }
  607. return ts4.isIdentifier(propertyAccess.expression) ? propertyAccess.expression : null;
  608. }
  609. function getContainingImportDeclaration(node) {
  610. return ts4.isImportSpecifier(node) ? node.parent.parent.parent : ts4.isNamespaceImport(node) ? node.parent.parent : null;
  611. }
  612. function getExportedName(decl, originalId) {
  613. return ts4.isImportSpecifier(decl) ? (decl.propertyName !== void 0 ? decl.propertyName : decl.name).text : originalId.text;
  614. }
  615. var LocalExportedDeclarations = Symbol("LocalExportedDeclarations");
  616. export {
  617. ClassMemberKind,
  618. typeNodeToValueExpr,
  619. isNamedClassDeclaration,
  620. TypeScriptReflectionHost,
  621. reflectTypeEntityToDeclaration,
  622. filterToMembersWithDecorator,
  623. reflectObjectLiteral
  624. };
  625. /**
  626. * @license
  627. * Copyright Google LLC All Rights Reserved.
  628. *
  629. * Use of this source code is governed by an MIT-style license that can be
  630. * found in the LICENSE file at https://angular.io/license
  631. */
  632. //# sourceMappingURL=chunk-4NU6EGYK.js.map