chunk-YEQZ4XY7.js 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539
  1. import {createRequire as __cjsCompatRequire} from 'module';
  2. const require = __cjsCompatRequire(import.meta.url);
  3. import {
  4. getAngularDecorators,
  5. isAngularDecorator,
  6. queryDecoratorNames,
  7. tryParseInitializerBasedOutput,
  8. tryParseSignalInputMapping,
  9. tryParseSignalModelMapping,
  10. tryParseSignalQueryFromInitializer
  11. } from "./chunk-YNWO773W.js";
  12. import {
  13. ImportManager,
  14. ImportedSymbolsTracker,
  15. TypeScriptReflectionHost,
  16. isAliasImportDeclaration,
  17. loadIsReferencedAliasDeclarationPatch,
  18. reflectClassMember
  19. } from "./chunk-KOIBHR3X.js";
  20. // bazel-out/darwin_arm64-fastbuild/bin/packages/compiler-cli/src/ngtsc/transform/jit/src/downlevel_decorators_transform.mjs
  21. import ts from "typescript";
  22. function isAngularDecorator2(decorator, isCore) {
  23. return isCore || decorator.import !== null && decorator.import.from === "@angular/core";
  24. }
  25. var DECORATOR_INVOCATION_JSDOC_TYPE = "!Array<{type: !Function, args: (undefined|!Array<?>)}>";
  26. function extractMetadataFromSingleDecorator(decorator, diagnostics) {
  27. const metadataProperties = [];
  28. const expr = decorator.expression;
  29. switch (expr.kind) {
  30. case ts.SyntaxKind.Identifier:
  31. metadataProperties.push(ts.factory.createPropertyAssignment("type", expr));
  32. break;
  33. case ts.SyntaxKind.CallExpression:
  34. const call = expr;
  35. metadataProperties.push(ts.factory.createPropertyAssignment("type", call.expression));
  36. if (call.arguments.length) {
  37. const args = [];
  38. for (const arg of call.arguments) {
  39. args.push(arg);
  40. }
  41. const argsArrayLiteral = ts.factory.createArrayLiteralExpression(ts.factory.createNodeArray(args, true));
  42. metadataProperties.push(ts.factory.createPropertyAssignment("args", argsArrayLiteral));
  43. }
  44. break;
  45. default:
  46. diagnostics.push({
  47. file: decorator.getSourceFile(),
  48. start: decorator.getStart(),
  49. length: decorator.getEnd() - decorator.getStart(),
  50. messageText: `${ts.SyntaxKind[decorator.kind]} not implemented in gathering decorator metadata.`,
  51. category: ts.DiagnosticCategory.Error,
  52. code: 0
  53. });
  54. break;
  55. }
  56. return ts.factory.createObjectLiteralExpression(metadataProperties);
  57. }
  58. function createCtorParametersClassProperty(diagnostics, entityNameToExpression, ctorParameters, isClosureCompilerEnabled) {
  59. const params = [];
  60. for (const ctorParam of ctorParameters) {
  61. if (!ctorParam.type && ctorParam.decorators.length === 0) {
  62. params.push(ts.factory.createNull());
  63. continue;
  64. }
  65. const paramType = ctorParam.type ? typeReferenceToExpression(entityNameToExpression, ctorParam.type) : void 0;
  66. const members = [
  67. ts.factory.createPropertyAssignment("type", paramType || ts.factory.createIdentifier("undefined"))
  68. ];
  69. const decorators = [];
  70. for (const deco of ctorParam.decorators) {
  71. decorators.push(extractMetadataFromSingleDecorator(deco, diagnostics));
  72. }
  73. if (decorators.length) {
  74. members.push(ts.factory.createPropertyAssignment("decorators", ts.factory.createArrayLiteralExpression(decorators)));
  75. }
  76. params.push(ts.factory.createObjectLiteralExpression(members));
  77. }
  78. const initializer = ts.factory.createArrowFunction(void 0, void 0, [], void 0, ts.factory.createToken(ts.SyntaxKind.EqualsGreaterThanToken), ts.factory.createArrayLiteralExpression(params, true));
  79. const ctorProp = ts.factory.createPropertyDeclaration([ts.factory.createToken(ts.SyntaxKind.StaticKeyword)], "ctorParameters", void 0, void 0, initializer);
  80. if (isClosureCompilerEnabled) {
  81. ts.setSyntheticLeadingComments(ctorProp, [
  82. {
  83. kind: ts.SyntaxKind.MultiLineCommentTrivia,
  84. text: [
  85. `*`,
  86. ` * @type {function(): !Array<(null|{`,
  87. ` * type: ?,`,
  88. ` * decorators: (undefined|${DECORATOR_INVOCATION_JSDOC_TYPE}),`,
  89. ` * })>}`,
  90. ` * @nocollapse`,
  91. ` `
  92. ].join("\n"),
  93. pos: -1,
  94. end: -1,
  95. hasTrailingNewLine: true
  96. }
  97. ]);
  98. }
  99. return ctorProp;
  100. }
  101. function typeReferenceToExpression(entityNameToExpression, node) {
  102. let kind = node.kind;
  103. if (ts.isLiteralTypeNode(node)) {
  104. kind = node.literal.kind;
  105. }
  106. switch (kind) {
  107. case ts.SyntaxKind.FunctionType:
  108. case ts.SyntaxKind.ConstructorType:
  109. return ts.factory.createIdentifier("Function");
  110. case ts.SyntaxKind.ArrayType:
  111. case ts.SyntaxKind.TupleType:
  112. return ts.factory.createIdentifier("Array");
  113. case ts.SyntaxKind.TypePredicate:
  114. case ts.SyntaxKind.TrueKeyword:
  115. case ts.SyntaxKind.FalseKeyword:
  116. case ts.SyntaxKind.BooleanKeyword:
  117. return ts.factory.createIdentifier("Boolean");
  118. case ts.SyntaxKind.StringLiteral:
  119. case ts.SyntaxKind.StringKeyword:
  120. return ts.factory.createIdentifier("String");
  121. case ts.SyntaxKind.ObjectKeyword:
  122. return ts.factory.createIdentifier("Object");
  123. case ts.SyntaxKind.NumberKeyword:
  124. case ts.SyntaxKind.NumericLiteral:
  125. return ts.factory.createIdentifier("Number");
  126. case ts.SyntaxKind.TypeReference:
  127. const typeRef = node;
  128. return entityNameToExpression(typeRef.typeName);
  129. case ts.SyntaxKind.UnionType:
  130. const childTypeNodes = node.types.filter((t) => !(ts.isLiteralTypeNode(t) && t.literal.kind === ts.SyntaxKind.NullKeyword));
  131. return childTypeNodes.length === 1 ? typeReferenceToExpression(entityNameToExpression, childTypeNodes[0]) : void 0;
  132. default:
  133. return void 0;
  134. }
  135. }
  136. function symbolIsRuntimeValue(typeChecker, symbol) {
  137. if (symbol.flags & ts.SymbolFlags.Alias) {
  138. symbol = typeChecker.getAliasedSymbol(symbol);
  139. }
  140. return (symbol.flags & ts.SymbolFlags.Value & ts.SymbolFlags.ConstEnumExcludes) !== 0;
  141. }
  142. function getDownlevelDecoratorsTransform(typeChecker, host, diagnostics, isCore, isClosureCompilerEnabled, shouldTransformClass) {
  143. function addJSDocTypeAnnotation(node, jsdocType) {
  144. if (!isClosureCompilerEnabled) {
  145. return;
  146. }
  147. ts.setSyntheticLeadingComments(node, [
  148. {
  149. kind: ts.SyntaxKind.MultiLineCommentTrivia,
  150. text: `* @type {${jsdocType}} `,
  151. pos: -1,
  152. end: -1,
  153. hasTrailingNewLine: true
  154. }
  155. ]);
  156. }
  157. function createPropDecoratorsClassProperty(diagnostics2, properties) {
  158. const entries = [];
  159. for (const [name, decorators] of properties.entries()) {
  160. entries.push(ts.factory.createPropertyAssignment(name, ts.factory.createArrayLiteralExpression(decorators.map((deco) => extractMetadataFromSingleDecorator(deco, diagnostics2)))));
  161. }
  162. const initializer = ts.factory.createObjectLiteralExpression(entries, true);
  163. const prop = ts.factory.createPropertyDeclaration([ts.factory.createToken(ts.SyntaxKind.StaticKeyword)], "propDecorators", void 0, void 0, initializer);
  164. addJSDocTypeAnnotation(prop, `!Object<string, ${DECORATOR_INVOCATION_JSDOC_TYPE}>`);
  165. return prop;
  166. }
  167. return (context) => {
  168. const referencedParameterTypes = loadIsReferencedAliasDeclarationPatch(context);
  169. function entityNameToExpression(name) {
  170. const symbol = typeChecker.getSymbolAtLocation(name);
  171. if (!symbol || !symbolIsRuntimeValue(typeChecker, symbol) || !symbol.declarations || symbol.declarations.length === 0) {
  172. return void 0;
  173. }
  174. if (ts.isQualifiedName(name)) {
  175. const containerExpr = entityNameToExpression(name.left);
  176. if (containerExpr === void 0) {
  177. return void 0;
  178. }
  179. return ts.factory.createPropertyAccessExpression(containerExpr, name.right);
  180. }
  181. const decl = symbol.declarations[0];
  182. if (isAliasImportDeclaration(decl)) {
  183. referencedParameterTypes == null ? void 0 : referencedParameterTypes.add(decl);
  184. if (decl.name !== void 0) {
  185. return ts.setOriginalNode(ts.factory.createIdentifier(decl.name.text), decl.name);
  186. }
  187. }
  188. return ts.setOriginalNode(ts.factory.createIdentifier(name.text), name);
  189. }
  190. function transformClassElement(element) {
  191. element = ts.visitEachChild(element, decoratorDownlevelVisitor, context);
  192. const decoratorsToKeep = [];
  193. const toLower = [];
  194. const decorators = host.getDecoratorsOfDeclaration(element) || [];
  195. for (const decorator of decorators) {
  196. const decoratorNode = decorator.node;
  197. if (!isAngularDecorator2(decorator, isCore)) {
  198. decoratorsToKeep.push(decoratorNode);
  199. continue;
  200. }
  201. toLower.push(decoratorNode);
  202. }
  203. if (!toLower.length)
  204. return [void 0, element, []];
  205. if (!element.name || !ts.isIdentifier(element.name)) {
  206. diagnostics.push({
  207. file: element.getSourceFile(),
  208. start: element.getStart(),
  209. length: element.getEnd() - element.getStart(),
  210. messageText: `Cannot process decorators for class element with non-analyzable name.`,
  211. category: ts.DiagnosticCategory.Error,
  212. code: 0
  213. });
  214. return [void 0, element, []];
  215. }
  216. const elementModifiers = ts.canHaveModifiers(element) ? ts.getModifiers(element) : void 0;
  217. let modifiers;
  218. if (decoratorsToKeep.length || (elementModifiers == null ? void 0 : elementModifiers.length)) {
  219. modifiers = ts.setTextRange(ts.factory.createNodeArray([...decoratorsToKeep, ...elementModifiers || []]), element.modifiers);
  220. }
  221. return [element.name.text, cloneClassElementWithModifiers(element, modifiers), toLower];
  222. }
  223. function transformConstructor(ctor) {
  224. ctor = ts.visitEachChild(ctor, decoratorDownlevelVisitor, context);
  225. const newParameters = [];
  226. const oldParameters = ctor.parameters;
  227. const parametersInfo = [];
  228. for (const param of oldParameters) {
  229. const decoratorsToKeep = [];
  230. const paramInfo = { decorators: [], type: null };
  231. const decorators = host.getDecoratorsOfDeclaration(param) || [];
  232. for (const decorator of decorators) {
  233. const decoratorNode = decorator.node;
  234. if (!isAngularDecorator2(decorator, isCore)) {
  235. decoratorsToKeep.push(decoratorNode);
  236. continue;
  237. }
  238. paramInfo.decorators.push(decoratorNode);
  239. }
  240. if (param.type) {
  241. paramInfo.type = param.type;
  242. }
  243. parametersInfo.push(paramInfo);
  244. let modifiers;
  245. const paramModifiers = ts.getModifiers(param);
  246. if (decoratorsToKeep.length || (paramModifiers == null ? void 0 : paramModifiers.length)) {
  247. modifiers = [...decoratorsToKeep, ...paramModifiers || []];
  248. }
  249. const newParam = ts.factory.updateParameterDeclaration(param, modifiers, param.dotDotDotToken, param.name, param.questionToken, param.type, param.initializer);
  250. newParameters.push(newParam);
  251. }
  252. const updated = ts.factory.updateConstructorDeclaration(ctor, ts.getModifiers(ctor), newParameters, ctor.body);
  253. return [updated, parametersInfo];
  254. }
  255. function transformClassDeclaration(classDecl) {
  256. const newMembers = [];
  257. const decoratedProperties = /* @__PURE__ */ new Map();
  258. let classParameters = null;
  259. for (const member of classDecl.members) {
  260. switch (member.kind) {
  261. case ts.SyntaxKind.PropertyDeclaration:
  262. case ts.SyntaxKind.GetAccessor:
  263. case ts.SyntaxKind.SetAccessor:
  264. case ts.SyntaxKind.MethodDeclaration: {
  265. const [name, newMember, decorators] = transformClassElement(member);
  266. newMembers.push(newMember);
  267. if (name)
  268. decoratedProperties.set(name, decorators);
  269. continue;
  270. }
  271. case ts.SyntaxKind.Constructor: {
  272. const ctor = member;
  273. if (!ctor.body)
  274. break;
  275. const [newMember, parametersInfo] = transformConstructor(member);
  276. classParameters = parametersInfo;
  277. newMembers.push(newMember);
  278. continue;
  279. }
  280. default:
  281. break;
  282. }
  283. newMembers.push(ts.visitEachChild(member, decoratorDownlevelVisitor, context));
  284. }
  285. const possibleAngularDecorators = host.getDecoratorsOfDeclaration(classDecl) || [];
  286. const hasAngularDecorator = possibleAngularDecorators.some((d) => isAngularDecorator2(d, isCore));
  287. if (classParameters) {
  288. if (hasAngularDecorator || classParameters.some((p) => !!p.decorators.length)) {
  289. newMembers.push(createCtorParametersClassProperty(diagnostics, entityNameToExpression, classParameters, isClosureCompilerEnabled));
  290. }
  291. }
  292. if (decoratedProperties.size) {
  293. newMembers.push(createPropDecoratorsClassProperty(diagnostics, decoratedProperties));
  294. }
  295. const members = ts.setTextRange(ts.factory.createNodeArray(newMembers, classDecl.members.hasTrailingComma), classDecl.members);
  296. return ts.factory.updateClassDeclaration(classDecl, classDecl.modifiers, classDecl.name, classDecl.typeParameters, classDecl.heritageClauses, members);
  297. }
  298. function decoratorDownlevelVisitor(node) {
  299. if (ts.isClassDeclaration(node) && (shouldTransformClass === void 0 || shouldTransformClass(node))) {
  300. return transformClassDeclaration(node);
  301. }
  302. return ts.visitEachChild(node, decoratorDownlevelVisitor, context);
  303. }
  304. return (sf) => {
  305. return ts.visitEachChild(sf, decoratorDownlevelVisitor, context);
  306. };
  307. };
  308. }
  309. function cloneClassElementWithModifiers(node, modifiers) {
  310. let clone;
  311. if (ts.isMethodDeclaration(node)) {
  312. clone = ts.factory.createMethodDeclaration(modifiers, node.asteriskToken, node.name, node.questionToken, node.typeParameters, node.parameters, node.type, node.body);
  313. } else if (ts.isPropertyDeclaration(node)) {
  314. clone = ts.factory.createPropertyDeclaration(modifiers, node.name, node.questionToken, node.type, node.initializer);
  315. } else if (ts.isGetAccessor(node)) {
  316. clone = ts.factory.createGetAccessorDeclaration(modifiers, node.name, node.parameters, node.type, node.body);
  317. } else if (ts.isSetAccessor(node)) {
  318. clone = ts.factory.createSetAccessorDeclaration(modifiers, node.name, node.parameters, node.body);
  319. } else {
  320. throw new Error(`Unsupported decorated member with kind ${ts.SyntaxKind[node.kind]}`);
  321. }
  322. return ts.setOriginalNode(clone, node);
  323. }
  324. // bazel-out/darwin_arm64-fastbuild/bin/packages/compiler-cli/src/ngtsc/transform/jit/src/initializer_api_transforms/transform.mjs
  325. import ts4 from "typescript";
  326. // bazel-out/darwin_arm64-fastbuild/bin/packages/compiler-cli/src/ngtsc/transform/jit/src/initializer_api_transforms/transform_api.mjs
  327. import ts2 from "typescript";
  328. function createSyntheticAngularCoreDecoratorAccess(factory, importManager, ngClassDecorator, sourceFile, decoratorName) {
  329. const classDecoratorIdentifier = ts2.isIdentifier(ngClassDecorator.identifier) ? ngClassDecorator.identifier : ngClassDecorator.identifier.expression;
  330. return factory.createPropertyAccessExpression(
  331. importManager.addImport({
  332. exportModuleSpecifier: "@angular/core",
  333. exportSymbolName: null,
  334. requestedFile: sourceFile
  335. }),
  336. ts2.setOriginalNode(factory.createIdentifier(decoratorName), classDecoratorIdentifier)
  337. );
  338. }
  339. function castAsAny(factory, expr) {
  340. return factory.createAsExpression(expr, factory.createKeywordTypeNode(ts2.SyntaxKind.AnyKeyword));
  341. }
  342. // bazel-out/darwin_arm64-fastbuild/bin/packages/compiler-cli/src/ngtsc/transform/jit/src/initializer_api_transforms/input_function.mjs
  343. var signalInputsTransform = (member, sourceFile, host, factory, importTracker, importManager, classDecorator, isCore) => {
  344. var _a, _b;
  345. if ((_a = host.getDecoratorsOfDeclaration(member.node)) == null ? void 0 : _a.some((d) => isAngularDecorator(d, "Input", isCore))) {
  346. return member.node;
  347. }
  348. const inputMapping = tryParseSignalInputMapping(member, host, importTracker);
  349. if (inputMapping === null) {
  350. return member.node;
  351. }
  352. const fields = {
  353. "isSignal": factory.createTrue(),
  354. "alias": factory.createStringLiteral(inputMapping.bindingPropertyName),
  355. "required": inputMapping.required ? factory.createTrue() : factory.createFalse(),
  356. "transform": factory.createIdentifier("undefined")
  357. };
  358. const newDecorator = factory.createDecorator(factory.createCallExpression(createSyntheticAngularCoreDecoratorAccess(factory, importManager, classDecorator, sourceFile, "Input"), void 0, [
  359. castAsAny(factory, factory.createObjectLiteralExpression(Object.entries(fields).map(([name, value]) => factory.createPropertyAssignment(name, value))))
  360. ]));
  361. return factory.updatePropertyDeclaration(member.node, [newDecorator, ...(_b = member.node.modifiers) != null ? _b : []], member.name, member.node.questionToken, member.node.type, member.node.initializer);
  362. };
  363. // bazel-out/darwin_arm64-fastbuild/bin/packages/compiler-cli/src/ngtsc/transform/jit/src/initializer_api_transforms/model_function.mjs
  364. import ts3 from "typescript";
  365. var signalModelTransform = (member, sourceFile, host, factory, importTracker, importManager, classDecorator, isCore) => {
  366. var _a, _b;
  367. if ((_a = host.getDecoratorsOfDeclaration(member.node)) == null ? void 0 : _a.some((d) => {
  368. return isAngularDecorator(d, "Input", isCore) || isAngularDecorator(d, "Output", isCore);
  369. })) {
  370. return member.node;
  371. }
  372. const modelMapping = tryParseSignalModelMapping(member, host, importTracker);
  373. if (modelMapping === null) {
  374. return member.node;
  375. }
  376. const inputConfig = factory.createObjectLiteralExpression([
  377. factory.createPropertyAssignment("isSignal", modelMapping.input.isSignal ? factory.createTrue() : factory.createFalse()),
  378. factory.createPropertyAssignment("alias", factory.createStringLiteral(modelMapping.input.bindingPropertyName)),
  379. factory.createPropertyAssignment("required", modelMapping.input.required ? factory.createTrue() : factory.createFalse())
  380. ]);
  381. const inputDecorator = createDecorator(
  382. "Input",
  383. factory.createAsExpression(inputConfig, factory.createKeywordTypeNode(ts3.SyntaxKind.AnyKeyword)),
  384. classDecorator,
  385. factory,
  386. sourceFile,
  387. importManager
  388. );
  389. const outputDecorator = createDecorator("Output", factory.createStringLiteral(modelMapping.output.bindingPropertyName), classDecorator, factory, sourceFile, importManager);
  390. return factory.updatePropertyDeclaration(member.node, [inputDecorator, outputDecorator, ...(_b = member.node.modifiers) != null ? _b : []], member.node.name, member.node.questionToken, member.node.type, member.node.initializer);
  391. };
  392. function createDecorator(name, config, classDecorator, factory, sourceFile, importManager) {
  393. const callTarget = createSyntheticAngularCoreDecoratorAccess(factory, importManager, classDecorator, sourceFile, name);
  394. return factory.createDecorator(factory.createCallExpression(callTarget, void 0, [config]));
  395. }
  396. // bazel-out/darwin_arm64-fastbuild/bin/packages/compiler-cli/src/ngtsc/transform/jit/src/initializer_api_transforms/output_function.mjs
  397. var initializerApiOutputTransform = (member, sourceFile, host, factory, importTracker, importManager, classDecorator, isCore) => {
  398. var _a, _b;
  399. if ((_a = host.getDecoratorsOfDeclaration(member.node)) == null ? void 0 : _a.some((d) => isAngularDecorator(d, "Output", isCore))) {
  400. return member.node;
  401. }
  402. const output = tryParseInitializerBasedOutput(member, host, importTracker);
  403. if (output === null) {
  404. return member.node;
  405. }
  406. const newDecorator = factory.createDecorator(factory.createCallExpression(createSyntheticAngularCoreDecoratorAccess(factory, importManager, classDecorator, sourceFile, "Output"), void 0, [factory.createStringLiteral(output.metadata.bindingPropertyName)]));
  407. return factory.updatePropertyDeclaration(member.node, [newDecorator, ...(_b = member.node.modifiers) != null ? _b : []], member.node.name, member.node.questionToken, member.node.type, member.node.initializer);
  408. };
  409. // bazel-out/darwin_arm64-fastbuild/bin/packages/compiler-cli/src/ngtsc/transform/jit/src/initializer_api_transforms/query_functions.mjs
  410. var queryFunctionToDecorator = {
  411. viewChild: "ViewChild",
  412. viewChildren: "ViewChildren",
  413. contentChild: "ContentChild",
  414. contentChildren: "ContentChildren"
  415. };
  416. var queryFunctionsTransforms = (member, sourceFile, host, factory, importTracker, importManager, classDecorator, isCore) => {
  417. var _a;
  418. const decorators = host.getDecoratorsOfDeclaration(member.node);
  419. const queryDecorators = decorators && getAngularDecorators(decorators, queryDecoratorNames, isCore);
  420. if (queryDecorators !== null && queryDecorators.length > 0) {
  421. return member.node;
  422. }
  423. const queryDefinition = tryParseSignalQueryFromInitializer(member, host, importTracker);
  424. if (queryDefinition === null) {
  425. return member.node;
  426. }
  427. const callArgs = queryDefinition.call.arguments;
  428. const newDecorator = factory.createDecorator(factory.createCallExpression(
  429. createSyntheticAngularCoreDecoratorAccess(factory, importManager, classDecorator, sourceFile, queryFunctionToDecorator[queryDefinition.name]),
  430. void 0,
  431. [
  432. queryDefinition.call.arguments[0],
  433. castAsAny(factory, factory.createObjectLiteralExpression([
  434. ...callArgs.length > 1 ? [factory.createSpreadAssignment(callArgs[1])] : [],
  435. factory.createPropertyAssignment("isSignal", factory.createTrue())
  436. ]))
  437. ]
  438. ));
  439. return factory.updatePropertyDeclaration(member.node, [newDecorator, ...(_a = member.node.modifiers) != null ? _a : []], member.node.name, member.node.questionToken, member.node.type, member.node.initializer);
  440. };
  441. // bazel-out/darwin_arm64-fastbuild/bin/packages/compiler-cli/src/ngtsc/transform/jit/src/initializer_api_transforms/transform.mjs
  442. var decoratorsWithInputs = ["Directive", "Component"];
  443. var propertyTransforms = [
  444. signalInputsTransform,
  445. initializerApiOutputTransform,
  446. queryFunctionsTransforms,
  447. signalModelTransform
  448. ];
  449. function getInitializerApiJitTransform(host, importTracker, isCore, shouldTransformClass) {
  450. return (ctx) => {
  451. return (sourceFile) => {
  452. const importManager = new ImportManager();
  453. sourceFile = ts4.visitNode(sourceFile, createTransformVisitor(ctx, host, importManager, importTracker, isCore, shouldTransformClass), ts4.isSourceFile);
  454. return importManager.transformTsFile(ctx, sourceFile);
  455. };
  456. };
  457. }
  458. function createTransformVisitor(ctx, host, importManager, importTracker, isCore, shouldTransformClass) {
  459. const visitor = (node) => {
  460. var _a;
  461. if (ts4.isClassDeclaration(node) && node.name !== void 0) {
  462. const originalNode = ts4.getOriginalNode(node, ts4.isClassDeclaration);
  463. const angularDecorator = (_a = host.getDecoratorsOfDeclaration(originalNode)) == null ? void 0 : _a.find((d) => decoratorsWithInputs.some((name) => isAngularDecorator(d, name, isCore)));
  464. if (angularDecorator !== void 0 && (shouldTransformClass === void 0 || shouldTransformClass(node))) {
  465. let hasChanged = false;
  466. const sourceFile = originalNode.getSourceFile();
  467. const members = node.members.map((memberNode) => {
  468. if (!ts4.isPropertyDeclaration(memberNode)) {
  469. return memberNode;
  470. }
  471. const member = reflectClassMember(memberNode);
  472. if (member === null) {
  473. return memberNode;
  474. }
  475. for (const transform of propertyTransforms) {
  476. const newNode = transform({ ...member, node: memberNode }, sourceFile, host, ctx.factory, importTracker, importManager, angularDecorator, isCore);
  477. if (newNode !== member.node) {
  478. hasChanged = true;
  479. return newNode;
  480. }
  481. }
  482. return memberNode;
  483. });
  484. if (hasChanged) {
  485. return ctx.factory.updateClassDeclaration(node, node.modifiers, node.name, node.typeParameters, node.heritageClauses, members);
  486. }
  487. }
  488. }
  489. return ts4.visitEachChild(node, visitor, ctx);
  490. };
  491. return visitor;
  492. }
  493. // bazel-out/darwin_arm64-fastbuild/bin/packages/compiler-cli/src/ngtsc/transform/jit/src/index.mjs
  494. function angularJitApplicationTransform(program, isCore = false, shouldTransformClass) {
  495. const typeChecker = program.getTypeChecker();
  496. const reflectionHost = new TypeScriptReflectionHost(typeChecker);
  497. const importTracker = new ImportedSymbolsTracker();
  498. const downlevelDecoratorTransform = getDownlevelDecoratorsTransform(
  499. typeChecker,
  500. reflectionHost,
  501. [],
  502. isCore,
  503. false,
  504. shouldTransformClass
  505. );
  506. const initializerApisJitTransform = getInitializerApiJitTransform(reflectionHost, importTracker, isCore, shouldTransformClass);
  507. return (ctx) => {
  508. return (sourceFile) => {
  509. sourceFile = initializerApisJitTransform(ctx)(sourceFile);
  510. sourceFile = downlevelDecoratorTransform(ctx)(sourceFile);
  511. return sourceFile;
  512. };
  513. };
  514. }
  515. export {
  516. getDownlevelDecoratorsTransform,
  517. getInitializerApiJitTransform,
  518. angularJitApplicationTransform
  519. };
  520. /**
  521. * @license
  522. * Copyright Google LLC All Rights Reserved.
  523. *
  524. * Use of this source code is governed by an MIT-style license that can be
  525. * found in the LICENSE file at https://angular.dev/license
  526. */
  527. //# sourceMappingURL=chunk-YEQZ4XY7.js.map