chunk-RNO4EXM5.js 45 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153
  1. import {createRequire as __cjsCompatRequire} from 'module';
  2. const require = __cjsCompatRequire(import.meta.url);
  3. import {
  4. Context,
  5. ExpressionTranslatorVisitor
  6. } from "./chunk-KOIBHR3X.js";
  7. import {
  8. SourceFileLoader
  9. } from "./chunk-5UDS2TPQ.js";
  10. // bazel-out/darwin_arm64-fastbuild/bin/packages/compiler-cli/linker/src/fatal_linker_error.mjs
  11. var FatalLinkerError = class extends Error {
  12. node;
  13. type = "FatalLinkerError";
  14. constructor(node, message) {
  15. super(message);
  16. this.node = node;
  17. }
  18. };
  19. function isFatalLinkerError(e) {
  20. return e && e.type === "FatalLinkerError";
  21. }
  22. // bazel-out/darwin_arm64-fastbuild/bin/packages/compiler-cli/linker/src/ast/utils.mjs
  23. function assert(node, predicate, expected) {
  24. if (!predicate(node)) {
  25. throw new FatalLinkerError(node, `Unsupported syntax, expected ${expected}.`);
  26. }
  27. }
  28. // bazel-out/darwin_arm64-fastbuild/bin/packages/compiler-cli/linker/src/ast/ast_value.mjs
  29. import * as o from "@angular/compiler";
  30. var AstObject = class {
  31. expression;
  32. obj;
  33. host;
  34. static parse(expression, host) {
  35. const obj = host.parseObjectLiteral(expression);
  36. return new AstObject(expression, obj, host);
  37. }
  38. constructor(expression, obj, host) {
  39. this.expression = expression;
  40. this.obj = obj;
  41. this.host = host;
  42. }
  43. has(propertyName) {
  44. return this.obj.has(propertyName);
  45. }
  46. getNumber(propertyName) {
  47. return this.host.parseNumericLiteral(this.getRequiredProperty(propertyName));
  48. }
  49. getString(propertyName) {
  50. return this.host.parseStringLiteral(this.getRequiredProperty(propertyName));
  51. }
  52. getBoolean(propertyName) {
  53. return this.host.parseBooleanLiteral(this.getRequiredProperty(propertyName));
  54. }
  55. getObject(propertyName) {
  56. const expr = this.getRequiredProperty(propertyName);
  57. const obj = this.host.parseObjectLiteral(expr);
  58. return new AstObject(expr, obj, this.host);
  59. }
  60. getArray(propertyName) {
  61. const arr = this.host.parseArrayLiteral(this.getRequiredProperty(propertyName));
  62. return arr.map((entry) => new AstValue(entry, this.host));
  63. }
  64. getOpaque(propertyName) {
  65. return new o.WrappedNodeExpr(this.getRequiredProperty(propertyName));
  66. }
  67. getNode(propertyName) {
  68. return this.getRequiredProperty(propertyName);
  69. }
  70. getValue(propertyName) {
  71. return new AstValue(this.getRequiredProperty(propertyName), this.host);
  72. }
  73. toLiteral(mapper) {
  74. const result = {};
  75. for (const [key, expression] of this.obj) {
  76. result[key] = mapper(new AstValue(expression, this.host), key);
  77. }
  78. return result;
  79. }
  80. toMap(mapper) {
  81. const result = /* @__PURE__ */ new Map();
  82. for (const [key, expression] of this.obj) {
  83. result.set(key, mapper(new AstValue(expression, this.host)));
  84. }
  85. return result;
  86. }
  87. getRequiredProperty(propertyName) {
  88. if (!this.obj.has(propertyName)) {
  89. throw new FatalLinkerError(this.expression, `Expected property '${propertyName}' to be present.`);
  90. }
  91. return this.obj.get(propertyName);
  92. }
  93. };
  94. var AstValue = class {
  95. expression;
  96. host;
  97. \u0275typeBrand = null;
  98. constructor(expression, host) {
  99. this.expression = expression;
  100. this.host = host;
  101. }
  102. getSymbolName() {
  103. return this.host.getSymbolName(this.expression);
  104. }
  105. isNumber() {
  106. return this.host.isNumericLiteral(this.expression);
  107. }
  108. getNumber() {
  109. return this.host.parseNumericLiteral(this.expression);
  110. }
  111. isString() {
  112. return this.host.isStringLiteral(this.expression);
  113. }
  114. getString() {
  115. return this.host.parseStringLiteral(this.expression);
  116. }
  117. isBoolean() {
  118. return this.host.isBooleanLiteral(this.expression);
  119. }
  120. getBoolean() {
  121. return this.host.parseBooleanLiteral(this.expression);
  122. }
  123. isObject() {
  124. return this.host.isObjectLiteral(this.expression);
  125. }
  126. getObject() {
  127. return AstObject.parse(this.expression, this.host);
  128. }
  129. isArray() {
  130. return this.host.isArrayLiteral(this.expression);
  131. }
  132. isNull() {
  133. return this.host.isNull(this.expression);
  134. }
  135. getArray() {
  136. const arr = this.host.parseArrayLiteral(this.expression);
  137. return arr.map((entry) => new AstValue(entry, this.host));
  138. }
  139. isFunction() {
  140. return this.host.isFunctionExpression(this.expression);
  141. }
  142. getFunctionReturnValue() {
  143. return new AstValue(this.host.parseReturnValue(this.expression), this.host);
  144. }
  145. getFunctionParameters() {
  146. return this.host.parseParameters(this.expression).map((param) => new AstValue(param, this.host));
  147. }
  148. isCallExpression() {
  149. return this.host.isCallExpression(this.expression);
  150. }
  151. getCallee() {
  152. return new AstValue(this.host.parseCallee(this.expression), this.host);
  153. }
  154. getArguments() {
  155. const args = this.host.parseArguments(this.expression);
  156. return args.map((arg) => new AstValue(arg, this.host));
  157. }
  158. getOpaque() {
  159. return new o.WrappedNodeExpr(this.expression);
  160. }
  161. getRange() {
  162. return this.host.getRange(this.expression);
  163. }
  164. };
  165. // bazel-out/darwin_arm64-fastbuild/bin/packages/compiler-cli/linker/src/file_linker/emit_scopes/emit_scope.mjs
  166. import { ConstantPool } from "@angular/compiler";
  167. // bazel-out/darwin_arm64-fastbuild/bin/packages/compiler-cli/linker/src/linker_import_generator.mjs
  168. var LinkerImportGenerator = class {
  169. factory;
  170. ngImport;
  171. constructor(factory, ngImport) {
  172. this.factory = factory;
  173. this.ngImport = ngImport;
  174. }
  175. addImport(request) {
  176. this.assertModuleName(request.exportModuleSpecifier);
  177. if (request.exportSymbolName === null) {
  178. return this.ngImport;
  179. }
  180. return this.factory.createPropertyAccess(this.ngImport, request.exportSymbolName);
  181. }
  182. assertModuleName(moduleName) {
  183. if (moduleName !== "@angular/core") {
  184. throw new FatalLinkerError(this.ngImport, `Unable to import from anything other than '@angular/core'`);
  185. }
  186. }
  187. };
  188. // bazel-out/darwin_arm64-fastbuild/bin/packages/compiler-cli/linker/src/file_linker/emit_scopes/emit_scope.mjs
  189. var EmitScope = class {
  190. ngImport;
  191. translator;
  192. factory;
  193. constantPool = new ConstantPool();
  194. constructor(ngImport, translator, factory) {
  195. this.ngImport = ngImport;
  196. this.translator = translator;
  197. this.factory = factory;
  198. }
  199. translateDefinition(definition) {
  200. const expression = this.translator.translateExpression(definition.expression, new LinkerImportGenerator(this.factory, this.ngImport));
  201. if (definition.statements.length > 0) {
  202. const importGenerator = new LinkerImportGenerator(this.factory, this.ngImport);
  203. return this.wrapInIifeWithStatements(expression, definition.statements.map((statement) => this.translator.translateStatement(statement, importGenerator)));
  204. } else {
  205. return expression;
  206. }
  207. }
  208. getConstantStatements() {
  209. const importGenerator = new LinkerImportGenerator(this.factory, this.ngImport);
  210. return this.constantPool.statements.map((statement) => this.translator.translateStatement(statement, importGenerator));
  211. }
  212. wrapInIifeWithStatements(expression, statements) {
  213. const returnStatement = this.factory.createReturnStatement(expression);
  214. const body = this.factory.createBlock([...statements, returnStatement]);
  215. const fn = this.factory.createFunctionExpression(null, [], body);
  216. return this.factory.createCallExpression(fn, [], false);
  217. }
  218. };
  219. // bazel-out/darwin_arm64-fastbuild/bin/packages/compiler-cli/linker/src/file_linker/emit_scopes/local_emit_scope.mjs
  220. var LocalEmitScope = class extends EmitScope {
  221. translateDefinition(definition) {
  222. return super.translateDefinition({
  223. expression: definition.expression,
  224. statements: [...this.constantPool.statements, ...definition.statements]
  225. });
  226. }
  227. getConstantStatements() {
  228. throw new Error("BUG - LocalEmitScope should not expose any constant statements");
  229. }
  230. };
  231. // bazel-out/darwin_arm64-fastbuild/bin/packages/compiler-cli/linker/src/file_linker/partial_linkers/partial_linker_selector.mjs
  232. import semver3 from "semver";
  233. // bazel-out/darwin_arm64-fastbuild/bin/packages/compiler-cli/linker/src/file_linker/get_source_file.mjs
  234. function createGetSourceFile(sourceUrl, code, loader) {
  235. if (loader === null) {
  236. return () => null;
  237. } else {
  238. let sourceFile = void 0;
  239. return () => {
  240. if (sourceFile === void 0) {
  241. sourceFile = loader.loadSourceFile(sourceUrl, code);
  242. }
  243. return sourceFile;
  244. };
  245. }
  246. }
  247. // bazel-out/darwin_arm64-fastbuild/bin/packages/compiler-cli/linker/src/file_linker/partial_linkers/partial_class_metadata_async_linker_1.mjs
  248. import { compileOpaqueAsyncClassMetadata } from "@angular/compiler";
  249. var PartialClassMetadataAsyncLinkerVersion1 = class {
  250. linkPartialDeclaration(constantPool, metaObj) {
  251. const resolveMetadataKey = "resolveMetadata";
  252. const resolveMetadata = metaObj.getValue(resolveMetadataKey);
  253. if (!resolveMetadata.isFunction()) {
  254. throw new FatalLinkerError(resolveMetadata, `Unsupported \`${resolveMetadataKey}\` value. Expected a function.`);
  255. }
  256. const dependencyResolverFunction = metaObj.getOpaque("resolveDeferredDeps");
  257. const deferredSymbolNames = resolveMetadata.getFunctionParameters().map((p) => p.getSymbolName());
  258. const returnValue = resolveMetadata.getFunctionReturnValue().getObject();
  259. const metadata = {
  260. type: metaObj.getOpaque("type"),
  261. decorators: returnValue.getOpaque("decorators"),
  262. ctorParameters: returnValue.getOpaque("ctorParameters"),
  263. propDecorators: returnValue.getOpaque("propDecorators")
  264. };
  265. return {
  266. expression: compileOpaqueAsyncClassMetadata(metadata, dependencyResolverFunction, deferredSymbolNames),
  267. statements: []
  268. };
  269. }
  270. };
  271. // bazel-out/darwin_arm64-fastbuild/bin/packages/compiler-cli/linker/src/file_linker/partial_linkers/partial_class_metadata_linker_1.mjs
  272. import { compileClassMetadata } from "@angular/compiler";
  273. var PartialClassMetadataLinkerVersion1 = class {
  274. linkPartialDeclaration(constantPool, metaObj) {
  275. const meta = toR3ClassMetadata(metaObj);
  276. return {
  277. expression: compileClassMetadata(meta),
  278. statements: []
  279. };
  280. }
  281. };
  282. function toR3ClassMetadata(metaObj) {
  283. return {
  284. type: metaObj.getOpaque("type"),
  285. decorators: metaObj.getOpaque("decorators"),
  286. ctorParameters: metaObj.has("ctorParameters") ? metaObj.getOpaque("ctorParameters") : null,
  287. propDecorators: metaObj.has("propDecorators") ? metaObj.getOpaque("propDecorators") : null
  288. };
  289. }
  290. // bazel-out/darwin_arm64-fastbuild/bin/packages/compiler-cli/linker/src/file_linker/partial_linkers/partial_component_linker_1.mjs
  291. import { ChangeDetectionStrategy, compileComponentFromMetadata, DEFAULT_INTERPOLATION_CONFIG, InterpolationConfig, makeBindingParser as makeBindingParser2, parseTemplate, R3TargetBinder, R3TemplateDependencyKind, SelectorMatcher, ViewEncapsulation } from "@angular/compiler";
  292. import semver2 from "semver";
  293. // bazel-out/darwin_arm64-fastbuild/bin/packages/compiler-cli/linker/src/file_linker/partial_linkers/partial_directive_linker_1.mjs
  294. import { compileDirectiveFromMetadata, makeBindingParser, ParseLocation, ParseSourceFile, ParseSourceSpan } from "@angular/compiler";
  295. // bazel-out/darwin_arm64-fastbuild/bin/packages/compiler-cli/linker/src/file_linker/partial_linkers/util.mjs
  296. import { createMayBeForwardRefExpression, outputAst as o2 } from "@angular/compiler";
  297. import semver from "semver";
  298. var PLACEHOLDER_VERSION = "19.2.4";
  299. function wrapReference(wrapped) {
  300. return { value: wrapped, type: wrapped };
  301. }
  302. function parseEnum(value, Enum) {
  303. const symbolName = value.getSymbolName();
  304. if (symbolName === null) {
  305. throw new FatalLinkerError(value.expression, "Expected value to have a symbol name");
  306. }
  307. const enumValue = Enum[symbolName];
  308. if (enumValue === void 0) {
  309. throw new FatalLinkerError(value.expression, `Unsupported enum value for ${Enum}`);
  310. }
  311. return enumValue;
  312. }
  313. function getDependency(depObj) {
  314. const isAttribute = depObj.has("attribute") && depObj.getBoolean("attribute");
  315. const token = depObj.getOpaque("token");
  316. const attributeNameType = isAttribute ? o2.literal("unknown") : null;
  317. return {
  318. token,
  319. attributeNameType,
  320. host: depObj.has("host") && depObj.getBoolean("host"),
  321. optional: depObj.has("optional") && depObj.getBoolean("optional"),
  322. self: depObj.has("self") && depObj.getBoolean("self"),
  323. skipSelf: depObj.has("skipSelf") && depObj.getBoolean("skipSelf")
  324. };
  325. }
  326. function extractForwardRef(expr) {
  327. if (!expr.isCallExpression()) {
  328. return createMayBeForwardRefExpression(expr.getOpaque(), 0);
  329. }
  330. const callee = expr.getCallee();
  331. if (callee.getSymbolName() !== "forwardRef") {
  332. throw new FatalLinkerError(callee.expression, "Unsupported expression, expected a `forwardRef()` call or a type reference");
  333. }
  334. const args = expr.getArguments();
  335. if (args.length !== 1) {
  336. throw new FatalLinkerError(expr, "Unsupported `forwardRef(fn)` call, expected a single argument");
  337. }
  338. const wrapperFn = args[0];
  339. if (!wrapperFn.isFunction()) {
  340. throw new FatalLinkerError(wrapperFn, "Unsupported `forwardRef(fn)` call, expected its argument to be a function");
  341. }
  342. return createMayBeForwardRefExpression(wrapperFn.getFunctionReturnValue().getOpaque(), 2);
  343. }
  344. var STANDALONE_IS_DEFAULT_RANGE = new semver.Range(`>= 19.0.0 || ${PLACEHOLDER_VERSION}`, {
  345. includePrerelease: true
  346. });
  347. function getDefaultStandaloneValue(version) {
  348. return STANDALONE_IS_DEFAULT_RANGE.test(version);
  349. }
  350. // bazel-out/darwin_arm64-fastbuild/bin/packages/compiler-cli/linker/src/file_linker/partial_linkers/partial_directive_linker_1.mjs
  351. var PartialDirectiveLinkerVersion1 = class {
  352. sourceUrl;
  353. code;
  354. constructor(sourceUrl, code) {
  355. this.sourceUrl = sourceUrl;
  356. this.code = code;
  357. }
  358. linkPartialDeclaration(constantPool, metaObj, version) {
  359. const meta = toR3DirectiveMeta(metaObj, this.code, this.sourceUrl, version);
  360. return compileDirectiveFromMetadata(meta, constantPool, makeBindingParser());
  361. }
  362. };
  363. function toR3DirectiveMeta(metaObj, code, sourceUrl, version) {
  364. const typeExpr = metaObj.getValue("type");
  365. const typeName = typeExpr.getSymbolName();
  366. if (typeName === null) {
  367. throw new FatalLinkerError(typeExpr.expression, "Unsupported type, its name could not be determined");
  368. }
  369. return {
  370. typeSourceSpan: createSourceSpan(typeExpr.getRange(), code, sourceUrl),
  371. type: wrapReference(typeExpr.getOpaque()),
  372. typeArgumentCount: 0,
  373. deps: null,
  374. host: toHostMetadata(metaObj),
  375. inputs: metaObj.has("inputs") ? metaObj.getObject("inputs").toLiteral(toInputMapping) : {},
  376. outputs: metaObj.has("outputs") ? metaObj.getObject("outputs").toLiteral((value) => value.getString()) : {},
  377. queries: metaObj.has("queries") ? metaObj.getArray("queries").map((entry) => toQueryMetadata(entry.getObject())) : [],
  378. viewQueries: metaObj.has("viewQueries") ? metaObj.getArray("viewQueries").map((entry) => toQueryMetadata(entry.getObject())) : [],
  379. providers: metaObj.has("providers") ? metaObj.getOpaque("providers") : null,
  380. fullInheritance: false,
  381. selector: metaObj.has("selector") ? metaObj.getString("selector") : null,
  382. exportAs: metaObj.has("exportAs") ? metaObj.getArray("exportAs").map((entry) => entry.getString()) : null,
  383. lifecycle: {
  384. usesOnChanges: metaObj.has("usesOnChanges") ? metaObj.getBoolean("usesOnChanges") : false
  385. },
  386. name: typeName,
  387. usesInheritance: metaObj.has("usesInheritance") ? metaObj.getBoolean("usesInheritance") : false,
  388. isStandalone: metaObj.has("isStandalone") ? metaObj.getBoolean("isStandalone") : getDefaultStandaloneValue(version),
  389. isSignal: metaObj.has("isSignal") ? metaObj.getBoolean("isSignal") : false,
  390. hostDirectives: metaObj.has("hostDirectives") ? toHostDirectivesMetadata(metaObj.getValue("hostDirectives")) : null
  391. };
  392. }
  393. function toInputMapping(value, key) {
  394. if (value.isObject()) {
  395. const obj = value.getObject();
  396. const transformValue = obj.getValue("transformFunction");
  397. return {
  398. classPropertyName: obj.getString("classPropertyName"),
  399. bindingPropertyName: obj.getString("publicName"),
  400. isSignal: obj.getBoolean("isSignal"),
  401. required: obj.getBoolean("isRequired"),
  402. transformFunction: transformValue.isNull() ? null : transformValue.getOpaque()
  403. };
  404. }
  405. return parseLegacyInputPartialOutput(key, value);
  406. }
  407. function parseLegacyInputPartialOutput(key, value) {
  408. if (value.isString()) {
  409. return {
  410. bindingPropertyName: value.getString(),
  411. classPropertyName: key,
  412. required: false,
  413. transformFunction: null,
  414. isSignal: false
  415. };
  416. }
  417. const values = value.getArray();
  418. if (values.length !== 2 && values.length !== 3) {
  419. throw new FatalLinkerError(value.expression, "Unsupported input, expected a string or an array containing two strings and an optional function");
  420. }
  421. return {
  422. bindingPropertyName: values[0].getString(),
  423. classPropertyName: values[1].getString(),
  424. transformFunction: values.length > 2 ? values[2].getOpaque() : null,
  425. required: false,
  426. isSignal: false
  427. };
  428. }
  429. function toHostMetadata(metaObj) {
  430. if (!metaObj.has("host")) {
  431. return {
  432. attributes: {},
  433. listeners: {},
  434. properties: {},
  435. specialAttributes: {}
  436. };
  437. }
  438. const host = metaObj.getObject("host");
  439. const specialAttributes = {};
  440. if (host.has("styleAttribute")) {
  441. specialAttributes.styleAttr = host.getString("styleAttribute");
  442. }
  443. if (host.has("classAttribute")) {
  444. specialAttributes.classAttr = host.getString("classAttribute");
  445. }
  446. return {
  447. attributes: host.has("attributes") ? host.getObject("attributes").toLiteral((value) => value.getOpaque()) : {},
  448. listeners: host.has("listeners") ? host.getObject("listeners").toLiteral((value) => value.getString()) : {},
  449. properties: host.has("properties") ? host.getObject("properties").toLiteral((value) => value.getString()) : {},
  450. specialAttributes
  451. };
  452. }
  453. function toQueryMetadata(obj) {
  454. let predicate;
  455. const predicateExpr = obj.getValue("predicate");
  456. if (predicateExpr.isArray()) {
  457. predicate = predicateExpr.getArray().map((entry) => entry.getString());
  458. } else {
  459. predicate = extractForwardRef(predicateExpr);
  460. }
  461. return {
  462. propertyName: obj.getString("propertyName"),
  463. first: obj.has("first") ? obj.getBoolean("first") : false,
  464. predicate,
  465. descendants: obj.has("descendants") ? obj.getBoolean("descendants") : false,
  466. emitDistinctChangesOnly: obj.has("emitDistinctChangesOnly") ? obj.getBoolean("emitDistinctChangesOnly") : true,
  467. read: obj.has("read") ? obj.getOpaque("read") : null,
  468. static: obj.has("static") ? obj.getBoolean("static") : false,
  469. isSignal: obj.has("isSignal") ? obj.getBoolean("isSignal") : false
  470. };
  471. }
  472. function toHostDirectivesMetadata(hostDirectives) {
  473. return hostDirectives.getArray().map((hostDirective) => {
  474. const hostObject = hostDirective.getObject();
  475. const type = extractForwardRef(hostObject.getValue("directive"));
  476. const meta = {
  477. directive: wrapReference(type.expression),
  478. isForwardReference: type.forwardRef !== 0,
  479. inputs: hostObject.has("inputs") ? getHostDirectiveBindingMapping(hostObject.getArray("inputs")) : null,
  480. outputs: hostObject.has("outputs") ? getHostDirectiveBindingMapping(hostObject.getArray("outputs")) : null
  481. };
  482. return meta;
  483. });
  484. }
  485. function getHostDirectiveBindingMapping(array) {
  486. let result = null;
  487. for (let i = 1; i < array.length; i += 2) {
  488. result = result || {};
  489. result[array[i - 1].getString()] = array[i].getString();
  490. }
  491. return result;
  492. }
  493. function createSourceSpan(range, code, sourceUrl) {
  494. const sourceFile = new ParseSourceFile(code, sourceUrl);
  495. const startLocation = new ParseLocation(sourceFile, range.startPos, range.startLine, range.startCol);
  496. return new ParseSourceSpan(startLocation, startLocation.moveBy(range.endPos - range.startPos));
  497. }
  498. // bazel-out/darwin_arm64-fastbuild/bin/packages/compiler-cli/linker/src/file_linker/partial_linkers/partial_component_linker_1.mjs
  499. function makeDirectiveMetadata(directiveExpr, typeExpr, isComponentByDefault = null) {
  500. return {
  501. kind: R3TemplateDependencyKind.Directive,
  502. isComponent: isComponentByDefault || directiveExpr.has("kind") && directiveExpr.getString("kind") === "component",
  503. type: typeExpr,
  504. selector: directiveExpr.getString("selector"),
  505. inputs: directiveExpr.has("inputs") ? directiveExpr.getArray("inputs").map((input) => input.getString()) : [],
  506. outputs: directiveExpr.has("outputs") ? directiveExpr.getArray("outputs").map((input) => input.getString()) : [],
  507. exportAs: directiveExpr.has("exportAs") ? directiveExpr.getArray("exportAs").map((exportAs) => exportAs.getString()) : null
  508. };
  509. }
  510. var PartialComponentLinkerVersion1 = class {
  511. getSourceFile;
  512. sourceUrl;
  513. code;
  514. constructor(getSourceFile, sourceUrl, code) {
  515. this.getSourceFile = getSourceFile;
  516. this.sourceUrl = sourceUrl;
  517. this.code = code;
  518. }
  519. linkPartialDeclaration(constantPool, metaObj, version) {
  520. const meta = this.toR3ComponentMeta(metaObj, version);
  521. return compileComponentFromMetadata(meta, constantPool, makeBindingParser2());
  522. }
  523. toR3ComponentMeta(metaObj, version) {
  524. const interpolation = parseInterpolationConfig(metaObj);
  525. const templateSource = metaObj.getValue("template");
  526. const isInline = metaObj.has("isInline") ? metaObj.getBoolean("isInline") : false;
  527. const templateInfo = this.getTemplateInfo(templateSource, isInline);
  528. const { major, minor } = new semver2.SemVer(version);
  529. const enableBlockSyntax = major >= 17 || version === PLACEHOLDER_VERSION;
  530. const enableLetSyntax = major > 18 || major === 18 && minor >= 1 || version === PLACEHOLDER_VERSION;
  531. const template = parseTemplate(templateInfo.code, templateInfo.sourceUrl, {
  532. escapedString: templateInfo.isEscaped,
  533. interpolationConfig: interpolation,
  534. range: templateInfo.range,
  535. enableI18nLegacyMessageIdFormat: false,
  536. preserveWhitespaces: metaObj.has("preserveWhitespaces") ? metaObj.getBoolean("preserveWhitespaces") : false,
  537. i18nNormalizeLineEndingsInICUs: isInline,
  538. enableBlockSyntax,
  539. enableLetSyntax
  540. });
  541. if (template.errors !== null) {
  542. const errors = template.errors.map((err) => err.toString()).join("\n");
  543. throw new FatalLinkerError(templateSource.expression, `Errors found in the template:
  544. ${errors}`);
  545. }
  546. const binder = new R3TargetBinder(new SelectorMatcher());
  547. const boundTarget = binder.bind({ template: template.nodes });
  548. let declarationListEmitMode = 0;
  549. const extractDeclarationTypeExpr = (type) => {
  550. const { expression, forwardRef } = extractForwardRef(type);
  551. if (forwardRef === 2) {
  552. declarationListEmitMode = 1;
  553. }
  554. return expression;
  555. };
  556. let declarations = [];
  557. if (metaObj.has("components")) {
  558. declarations.push(...metaObj.getArray("components").map((dir) => {
  559. const dirExpr = dir.getObject();
  560. const typeExpr = extractDeclarationTypeExpr(dirExpr.getValue("type"));
  561. return makeDirectiveMetadata(dirExpr, typeExpr, true);
  562. }));
  563. }
  564. if (metaObj.has("directives")) {
  565. declarations.push(...metaObj.getArray("directives").map((dir) => {
  566. const dirExpr = dir.getObject();
  567. const typeExpr = extractDeclarationTypeExpr(dirExpr.getValue("type"));
  568. return makeDirectiveMetadata(dirExpr, typeExpr);
  569. }));
  570. }
  571. if (metaObj.has("pipes")) {
  572. const pipes = metaObj.getObject("pipes").toMap((pipe) => pipe);
  573. for (const [name, type] of pipes) {
  574. const typeExpr = extractDeclarationTypeExpr(type);
  575. declarations.push({
  576. kind: R3TemplateDependencyKind.Pipe,
  577. name,
  578. type: typeExpr
  579. });
  580. }
  581. }
  582. if (metaObj.has("dependencies")) {
  583. for (const dep of metaObj.getArray("dependencies")) {
  584. const depObj = dep.getObject();
  585. const typeExpr = extractDeclarationTypeExpr(depObj.getValue("type"));
  586. switch (depObj.getString("kind")) {
  587. case "directive":
  588. case "component":
  589. declarations.push(makeDirectiveMetadata(depObj, typeExpr));
  590. break;
  591. case "pipe":
  592. const pipeObj = depObj;
  593. declarations.push({
  594. kind: R3TemplateDependencyKind.Pipe,
  595. name: pipeObj.getString("name"),
  596. type: typeExpr
  597. });
  598. break;
  599. case "ngmodule":
  600. declarations.push({
  601. kind: R3TemplateDependencyKind.NgModule,
  602. type: typeExpr
  603. });
  604. break;
  605. default:
  606. continue;
  607. }
  608. }
  609. }
  610. return {
  611. ...toR3DirectiveMeta(metaObj, this.code, this.sourceUrl, version),
  612. viewProviders: metaObj.has("viewProviders") ? metaObj.getOpaque("viewProviders") : null,
  613. template: {
  614. nodes: template.nodes,
  615. ngContentSelectors: template.ngContentSelectors
  616. },
  617. declarationListEmitMode,
  618. styles: metaObj.has("styles") ? metaObj.getArray("styles").map((entry) => entry.getString()) : [],
  619. defer: this.createR3ComponentDeferMetadata(metaObj, boundTarget),
  620. encapsulation: metaObj.has("encapsulation") ? parseEncapsulation(metaObj.getValue("encapsulation")) : ViewEncapsulation.Emulated,
  621. interpolation,
  622. changeDetection: metaObj.has("changeDetection") ? parseChangeDetectionStrategy(metaObj.getValue("changeDetection")) : ChangeDetectionStrategy.Default,
  623. animations: metaObj.has("animations") ? metaObj.getOpaque("animations") : null,
  624. relativeContextFilePath: this.sourceUrl,
  625. relativeTemplatePath: null,
  626. i18nUseExternalIds: false,
  627. declarations
  628. };
  629. }
  630. getTemplateInfo(templateNode, isInline) {
  631. const range = templateNode.getRange();
  632. if (!isInline) {
  633. const externalTemplate = this.tryExternalTemplate(range);
  634. if (externalTemplate !== null) {
  635. return externalTemplate;
  636. }
  637. }
  638. return this.templateFromPartialCode(templateNode, range);
  639. }
  640. tryExternalTemplate(range) {
  641. const sourceFile = this.getSourceFile();
  642. if (sourceFile === null) {
  643. return null;
  644. }
  645. const pos = sourceFile.getOriginalLocation(range.startLine, range.startCol);
  646. if (pos === null || pos.file === this.sourceUrl || /\.[jt]s$/.test(pos.file) || pos.line !== 0 || pos.column !== 0) {
  647. return null;
  648. }
  649. const templateContents = sourceFile.sources.find((src) => (src == null ? void 0 : src.sourcePath) === pos.file).contents;
  650. return {
  651. code: templateContents,
  652. sourceUrl: pos.file,
  653. range: { startPos: 0, startLine: 0, startCol: 0, endPos: templateContents.length },
  654. isEscaped: false
  655. };
  656. }
  657. templateFromPartialCode(templateNode, { startPos, endPos, startLine, startCol }) {
  658. if (!/["'`]/.test(this.code[startPos]) || this.code[startPos] !== this.code[endPos - 1]) {
  659. throw new FatalLinkerError(templateNode.expression, `Expected the template string to be wrapped in quotes but got: ${this.code.substring(startPos, endPos)}`);
  660. }
  661. return {
  662. code: this.code,
  663. sourceUrl: this.sourceUrl,
  664. range: { startPos: startPos + 1, endPos: endPos - 1, startLine, startCol: startCol + 1 },
  665. isEscaped: true
  666. };
  667. }
  668. createR3ComponentDeferMetadata(metaObj, boundTarget) {
  669. const deferredBlocks = boundTarget.getDeferBlocks();
  670. const blocks = /* @__PURE__ */ new Map();
  671. const dependencies = metaObj.has("deferBlockDependencies") ? metaObj.getArray("deferBlockDependencies") : null;
  672. for (let i = 0; i < deferredBlocks.length; i++) {
  673. const matchingDependencyFn = dependencies == null ? void 0 : dependencies[i];
  674. if (matchingDependencyFn == null) {
  675. blocks.set(deferredBlocks[i], null);
  676. } else {
  677. blocks.set(deferredBlocks[i], matchingDependencyFn.isNull() ? null : matchingDependencyFn.getOpaque());
  678. }
  679. }
  680. return { mode: 0, blocks };
  681. }
  682. };
  683. function parseInterpolationConfig(metaObj) {
  684. if (!metaObj.has("interpolation")) {
  685. return DEFAULT_INTERPOLATION_CONFIG;
  686. }
  687. const interpolationExpr = metaObj.getValue("interpolation");
  688. const values = interpolationExpr.getArray().map((entry) => entry.getString());
  689. if (values.length !== 2) {
  690. throw new FatalLinkerError(interpolationExpr.expression, "Unsupported interpolation config, expected an array containing exactly two strings");
  691. }
  692. return InterpolationConfig.fromArray(values);
  693. }
  694. function parseEncapsulation(encapsulation) {
  695. const symbolName = encapsulation.getSymbolName();
  696. if (symbolName === null) {
  697. throw new FatalLinkerError(encapsulation.expression, "Expected encapsulation to have a symbol name");
  698. }
  699. const enumValue = ViewEncapsulation[symbolName];
  700. if (enumValue === void 0) {
  701. throw new FatalLinkerError(encapsulation.expression, "Unsupported encapsulation");
  702. }
  703. return enumValue;
  704. }
  705. function parseChangeDetectionStrategy(changeDetectionStrategy) {
  706. const symbolName = changeDetectionStrategy.getSymbolName();
  707. if (symbolName === null) {
  708. throw new FatalLinkerError(changeDetectionStrategy.expression, "Expected change detection strategy to have a symbol name");
  709. }
  710. const enumValue = ChangeDetectionStrategy[symbolName];
  711. if (enumValue === void 0) {
  712. throw new FatalLinkerError(changeDetectionStrategy.expression, "Unsupported change detection strategy");
  713. }
  714. return enumValue;
  715. }
  716. // bazel-out/darwin_arm64-fastbuild/bin/packages/compiler-cli/linker/src/file_linker/partial_linkers/partial_factory_linker_1.mjs
  717. import { compileFactoryFunction, FactoryTarget } from "@angular/compiler";
  718. var PartialFactoryLinkerVersion1 = class {
  719. linkPartialDeclaration(constantPool, metaObj) {
  720. const meta = toR3FactoryMeta(metaObj);
  721. return compileFactoryFunction(meta);
  722. }
  723. };
  724. function toR3FactoryMeta(metaObj) {
  725. const typeExpr = metaObj.getValue("type");
  726. const typeName = typeExpr.getSymbolName();
  727. if (typeName === null) {
  728. throw new FatalLinkerError(typeExpr.expression, "Unsupported type, its name could not be determined");
  729. }
  730. return {
  731. name: typeName,
  732. type: wrapReference(typeExpr.getOpaque()),
  733. typeArgumentCount: 0,
  734. target: parseEnum(metaObj.getValue("target"), FactoryTarget),
  735. deps: getDependencies(metaObj, "deps")
  736. };
  737. }
  738. function getDependencies(metaObj, propName) {
  739. if (!metaObj.has(propName)) {
  740. return null;
  741. }
  742. const deps = metaObj.getValue(propName);
  743. if (deps.isArray()) {
  744. return deps.getArray().map((dep) => getDependency(dep.getObject()));
  745. }
  746. if (deps.isString()) {
  747. return "invalid";
  748. }
  749. return null;
  750. }
  751. // bazel-out/darwin_arm64-fastbuild/bin/packages/compiler-cli/linker/src/file_linker/partial_linkers/partial_injectable_linker_1.mjs
  752. import { compileInjectable, createMayBeForwardRefExpression as createMayBeForwardRefExpression2, outputAst as o3 } from "@angular/compiler";
  753. var PartialInjectableLinkerVersion1 = class {
  754. linkPartialDeclaration(constantPool, metaObj) {
  755. const meta = toR3InjectableMeta(metaObj);
  756. return compileInjectable(meta, false);
  757. }
  758. };
  759. function toR3InjectableMeta(metaObj) {
  760. const typeExpr = metaObj.getValue("type");
  761. const typeName = typeExpr.getSymbolName();
  762. if (typeName === null) {
  763. throw new FatalLinkerError(typeExpr.expression, "Unsupported type, its name could not be determined");
  764. }
  765. const meta = {
  766. name: typeName,
  767. type: wrapReference(typeExpr.getOpaque()),
  768. typeArgumentCount: 0,
  769. providedIn: metaObj.has("providedIn") ? extractForwardRef(metaObj.getValue("providedIn")) : createMayBeForwardRefExpression2(o3.literal(null), 0)
  770. };
  771. if (metaObj.has("useClass")) {
  772. meta.useClass = extractForwardRef(metaObj.getValue("useClass"));
  773. }
  774. if (metaObj.has("useFactory")) {
  775. meta.useFactory = metaObj.getOpaque("useFactory");
  776. }
  777. if (metaObj.has("useExisting")) {
  778. meta.useExisting = extractForwardRef(metaObj.getValue("useExisting"));
  779. }
  780. if (metaObj.has("useValue")) {
  781. meta.useValue = extractForwardRef(metaObj.getValue("useValue"));
  782. }
  783. if (metaObj.has("deps")) {
  784. meta.deps = metaObj.getArray("deps").map((dep) => getDependency(dep.getObject()));
  785. }
  786. return meta;
  787. }
  788. // bazel-out/darwin_arm64-fastbuild/bin/packages/compiler-cli/linker/src/file_linker/partial_linkers/partial_injector_linker_1.mjs
  789. import { compileInjector } from "@angular/compiler";
  790. var PartialInjectorLinkerVersion1 = class {
  791. linkPartialDeclaration(constantPool, metaObj) {
  792. const meta = toR3InjectorMeta(metaObj);
  793. return compileInjector(meta);
  794. }
  795. };
  796. function toR3InjectorMeta(metaObj) {
  797. const typeExpr = metaObj.getValue("type");
  798. const typeName = typeExpr.getSymbolName();
  799. if (typeName === null) {
  800. throw new FatalLinkerError(typeExpr.expression, "Unsupported type, its name could not be determined");
  801. }
  802. return {
  803. name: typeName,
  804. type: wrapReference(typeExpr.getOpaque()),
  805. providers: metaObj.has("providers") ? metaObj.getOpaque("providers") : null,
  806. imports: metaObj.has("imports") ? metaObj.getArray("imports").map((i) => i.getOpaque()) : []
  807. };
  808. }
  809. // bazel-out/darwin_arm64-fastbuild/bin/packages/compiler-cli/linker/src/file_linker/partial_linkers/partial_ng_module_linker_1.mjs
  810. import { compileNgModule, R3NgModuleMetadataKind, R3SelectorScopeMode } from "@angular/compiler";
  811. var PartialNgModuleLinkerVersion1 = class {
  812. emitInline;
  813. constructor(emitInline) {
  814. this.emitInline = emitInline;
  815. }
  816. linkPartialDeclaration(constantPool, metaObj) {
  817. const meta = toR3NgModuleMeta(metaObj, this.emitInline);
  818. return compileNgModule(meta);
  819. }
  820. };
  821. function toR3NgModuleMeta(metaObj, supportJit) {
  822. const wrappedType = metaObj.getOpaque("type");
  823. const meta = {
  824. kind: R3NgModuleMetadataKind.Global,
  825. type: wrapReference(wrappedType),
  826. bootstrap: [],
  827. declarations: [],
  828. publicDeclarationTypes: null,
  829. includeImportTypes: true,
  830. imports: [],
  831. exports: [],
  832. selectorScopeMode: supportJit ? R3SelectorScopeMode.Inline : R3SelectorScopeMode.Omit,
  833. containsForwardDecls: false,
  834. schemas: [],
  835. id: metaObj.has("id") ? metaObj.getOpaque("id") : null
  836. };
  837. if (metaObj.has("bootstrap")) {
  838. const bootstrap = metaObj.getValue("bootstrap");
  839. if (bootstrap.isFunction()) {
  840. meta.containsForwardDecls = true;
  841. meta.bootstrap = wrapReferences(unwrapForwardRefs(bootstrap));
  842. } else
  843. meta.bootstrap = wrapReferences(bootstrap);
  844. }
  845. if (metaObj.has("declarations")) {
  846. const declarations = metaObj.getValue("declarations");
  847. if (declarations.isFunction()) {
  848. meta.containsForwardDecls = true;
  849. meta.declarations = wrapReferences(unwrapForwardRefs(declarations));
  850. } else
  851. meta.declarations = wrapReferences(declarations);
  852. }
  853. if (metaObj.has("imports")) {
  854. const imports = metaObj.getValue("imports");
  855. if (imports.isFunction()) {
  856. meta.containsForwardDecls = true;
  857. meta.imports = wrapReferences(unwrapForwardRefs(imports));
  858. } else
  859. meta.imports = wrapReferences(imports);
  860. }
  861. if (metaObj.has("exports")) {
  862. const exports = metaObj.getValue("exports");
  863. if (exports.isFunction()) {
  864. meta.containsForwardDecls = true;
  865. meta.exports = wrapReferences(unwrapForwardRefs(exports));
  866. } else
  867. meta.exports = wrapReferences(exports);
  868. }
  869. if (metaObj.has("schemas")) {
  870. const schemas = metaObj.getValue("schemas");
  871. meta.schemas = wrapReferences(schemas);
  872. }
  873. return meta;
  874. }
  875. function unwrapForwardRefs(field) {
  876. return field.getFunctionReturnValue();
  877. }
  878. function wrapReferences(values) {
  879. return values.getArray().map((i) => wrapReference(i.getOpaque()));
  880. }
  881. // bazel-out/darwin_arm64-fastbuild/bin/packages/compiler-cli/linker/src/file_linker/partial_linkers/partial_pipe_linker_1.mjs
  882. import { compilePipeFromMetadata } from "@angular/compiler";
  883. var PartialPipeLinkerVersion1 = class {
  884. constructor() {
  885. }
  886. linkPartialDeclaration(constantPool, metaObj, version) {
  887. const meta = toR3PipeMeta(metaObj, version);
  888. return compilePipeFromMetadata(meta);
  889. }
  890. };
  891. function toR3PipeMeta(metaObj, version) {
  892. const typeExpr = metaObj.getValue("type");
  893. const typeName = typeExpr.getSymbolName();
  894. if (typeName === null) {
  895. throw new FatalLinkerError(typeExpr.expression, "Unsupported type, its name could not be determined");
  896. }
  897. const pure = metaObj.has("pure") ? metaObj.getBoolean("pure") : true;
  898. const isStandalone = metaObj.has("isStandalone") ? metaObj.getBoolean("isStandalone") : getDefaultStandaloneValue(version);
  899. return {
  900. name: typeName,
  901. type: wrapReference(typeExpr.getOpaque()),
  902. typeArgumentCount: 0,
  903. deps: null,
  904. pipeName: metaObj.getString("name"),
  905. pure,
  906. isStandalone
  907. };
  908. }
  909. // bazel-out/darwin_arm64-fastbuild/bin/packages/compiler-cli/linker/src/file_linker/partial_linkers/partial_linker_selector.mjs
  910. var \u0275\u0275ngDeclareDirective = "\u0275\u0275ngDeclareDirective";
  911. var \u0275\u0275ngDeclareClassMetadata = "\u0275\u0275ngDeclareClassMetadata";
  912. var \u0275\u0275ngDeclareComponent = "\u0275\u0275ngDeclareComponent";
  913. var \u0275\u0275ngDeclareFactory = "\u0275\u0275ngDeclareFactory";
  914. var \u0275\u0275ngDeclareInjectable = "\u0275\u0275ngDeclareInjectable";
  915. var \u0275\u0275ngDeclareInjector = "\u0275\u0275ngDeclareInjector";
  916. var \u0275\u0275ngDeclareNgModule = "\u0275\u0275ngDeclareNgModule";
  917. var \u0275\u0275ngDeclarePipe = "\u0275\u0275ngDeclarePipe";
  918. var \u0275\u0275ngDeclareClassMetadataAsync = "\u0275\u0275ngDeclareClassMetadataAsync";
  919. var declarationFunctions = [
  920. \u0275\u0275ngDeclareDirective,
  921. \u0275\u0275ngDeclareClassMetadata,
  922. \u0275\u0275ngDeclareComponent,
  923. \u0275\u0275ngDeclareFactory,
  924. \u0275\u0275ngDeclareInjectable,
  925. \u0275\u0275ngDeclareInjector,
  926. \u0275\u0275ngDeclareNgModule,
  927. \u0275\u0275ngDeclarePipe,
  928. \u0275\u0275ngDeclareClassMetadataAsync
  929. ];
  930. function createLinkerMap(environment, sourceUrl, code) {
  931. const linkers = /* @__PURE__ */ new Map();
  932. const LATEST_VERSION_RANGE = getRange("<=", PLACEHOLDER_VERSION);
  933. linkers.set(\u0275\u0275ngDeclareDirective, [
  934. { range: LATEST_VERSION_RANGE, linker: new PartialDirectiveLinkerVersion1(sourceUrl, code) }
  935. ]);
  936. linkers.set(\u0275\u0275ngDeclareClassMetadataAsync, [
  937. { range: LATEST_VERSION_RANGE, linker: new PartialClassMetadataAsyncLinkerVersion1() }
  938. ]);
  939. linkers.set(\u0275\u0275ngDeclareClassMetadata, [
  940. { range: LATEST_VERSION_RANGE, linker: new PartialClassMetadataLinkerVersion1() }
  941. ]);
  942. linkers.set(\u0275\u0275ngDeclareComponent, [
  943. {
  944. range: LATEST_VERSION_RANGE,
  945. linker: new PartialComponentLinkerVersion1(createGetSourceFile(sourceUrl, code, environment.sourceFileLoader), sourceUrl, code)
  946. }
  947. ]);
  948. linkers.set(\u0275\u0275ngDeclareFactory, [
  949. { range: LATEST_VERSION_RANGE, linker: new PartialFactoryLinkerVersion1() }
  950. ]);
  951. linkers.set(\u0275\u0275ngDeclareInjectable, [
  952. { range: LATEST_VERSION_RANGE, linker: new PartialInjectableLinkerVersion1() }
  953. ]);
  954. linkers.set(\u0275\u0275ngDeclareInjector, [
  955. { range: LATEST_VERSION_RANGE, linker: new PartialInjectorLinkerVersion1() }
  956. ]);
  957. linkers.set(\u0275\u0275ngDeclareNgModule, [
  958. {
  959. range: LATEST_VERSION_RANGE,
  960. linker: new PartialNgModuleLinkerVersion1(environment.options.linkerJitMode)
  961. }
  962. ]);
  963. linkers.set(\u0275\u0275ngDeclarePipe, [
  964. { range: LATEST_VERSION_RANGE, linker: new PartialPipeLinkerVersion1() }
  965. ]);
  966. return linkers;
  967. }
  968. var PartialLinkerSelector = class {
  969. linkers;
  970. logger;
  971. unknownDeclarationVersionHandling;
  972. constructor(linkers, logger, unknownDeclarationVersionHandling) {
  973. this.linkers = linkers;
  974. this.logger = logger;
  975. this.unknownDeclarationVersionHandling = unknownDeclarationVersionHandling;
  976. }
  977. supportsDeclaration(functionName) {
  978. return this.linkers.has(functionName);
  979. }
  980. getLinker(functionName, minVersion, version) {
  981. if (!this.linkers.has(functionName)) {
  982. throw new Error(`Unknown partial declaration function ${functionName}.`);
  983. }
  984. const linkerRanges = this.linkers.get(functionName);
  985. if (version === PLACEHOLDER_VERSION) {
  986. return linkerRanges[linkerRanges.length - 1].linker;
  987. }
  988. const declarationRange = getRange(">=", minVersion);
  989. for (const { range: linkerRange, linker } of linkerRanges) {
  990. if (semver3.intersects(declarationRange, linkerRange)) {
  991. return linker;
  992. }
  993. }
  994. const message = `This application depends upon a library published using Angular version ${version}, which requires Angular version ${minVersion} or newer to work correctly.
  995. Consider upgrading your application to use a more recent version of Angular.`;
  996. if (this.unknownDeclarationVersionHandling === "error") {
  997. throw new Error(message);
  998. } else if (this.unknownDeclarationVersionHandling === "warn") {
  999. this.logger.warn(`${message}
  1000. Attempting to continue using this version of Angular.`);
  1001. }
  1002. return linkerRanges[linkerRanges.length - 1].linker;
  1003. }
  1004. };
  1005. function getRange(comparator, versionStr) {
  1006. if (versionStr === "0.0.0" && PLACEHOLDER_VERSION === "0.0.0") {
  1007. return new semver3.Range("*.*.*");
  1008. }
  1009. const version = new semver3.SemVer(versionStr);
  1010. version.prerelease = [];
  1011. return new semver3.Range(`${comparator}${version.format()}`);
  1012. }
  1013. // bazel-out/darwin_arm64-fastbuild/bin/packages/compiler-cli/linker/src/file_linker/file_linker.mjs
  1014. var FileLinker = class {
  1015. linkerEnvironment;
  1016. linkerSelector;
  1017. emitScopes = /* @__PURE__ */ new Map();
  1018. constructor(linkerEnvironment, sourceUrl, code) {
  1019. this.linkerEnvironment = linkerEnvironment;
  1020. this.linkerSelector = new PartialLinkerSelector(createLinkerMap(this.linkerEnvironment, sourceUrl, code), this.linkerEnvironment.logger, this.linkerEnvironment.options.unknownDeclarationVersionHandling);
  1021. }
  1022. isPartialDeclaration(calleeName) {
  1023. return this.linkerSelector.supportsDeclaration(calleeName);
  1024. }
  1025. linkPartialDeclaration(declarationFn, args, declarationScope) {
  1026. if (args.length !== 1) {
  1027. throw new Error(`Invalid function call: It should have only a single object literal argument, but contained ${args.length}.`);
  1028. }
  1029. const metaObj = AstObject.parse(args[0], this.linkerEnvironment.host);
  1030. const ngImport = metaObj.getNode("ngImport");
  1031. const emitScope = this.getEmitScope(ngImport, declarationScope);
  1032. const minVersion = metaObj.getString("minVersion");
  1033. const version = metaObj.getString("version");
  1034. const linker = this.linkerSelector.getLinker(declarationFn, minVersion, version);
  1035. const definition = linker.linkPartialDeclaration(emitScope.constantPool, metaObj, version);
  1036. return emitScope.translateDefinition(definition);
  1037. }
  1038. getConstantStatements() {
  1039. const results = [];
  1040. for (const [constantScope, emitScope] of this.emitScopes.entries()) {
  1041. const statements = emitScope.getConstantStatements();
  1042. results.push({ constantScope, statements });
  1043. }
  1044. return results;
  1045. }
  1046. getEmitScope(ngImport, declarationScope) {
  1047. const constantScope = declarationScope.getConstantScopeRef(ngImport);
  1048. if (constantScope === null) {
  1049. return new LocalEmitScope(ngImport, this.linkerEnvironment.translator, this.linkerEnvironment.factory);
  1050. }
  1051. if (!this.emitScopes.has(constantScope)) {
  1052. this.emitScopes.set(constantScope, new EmitScope(ngImport, this.linkerEnvironment.translator, this.linkerEnvironment.factory));
  1053. }
  1054. return this.emitScopes.get(constantScope);
  1055. }
  1056. };
  1057. // bazel-out/darwin_arm64-fastbuild/bin/packages/compiler-cli/linker/src/file_linker/linker_options.mjs
  1058. var DEFAULT_LINKER_OPTIONS = {
  1059. sourceMapping: true,
  1060. linkerJitMode: false,
  1061. unknownDeclarationVersionHandling: "error"
  1062. };
  1063. // bazel-out/darwin_arm64-fastbuild/bin/packages/compiler-cli/linker/src/file_linker/translator.mjs
  1064. var Translator = class {
  1065. factory;
  1066. constructor(factory) {
  1067. this.factory = factory;
  1068. }
  1069. translateExpression(expression, imports, options = {}) {
  1070. return expression.visitExpression(new ExpressionTranslatorVisitor(this.factory, imports, null, options), new Context(false));
  1071. }
  1072. translateStatement(statement, imports, options = {}) {
  1073. return statement.visitStatement(new ExpressionTranslatorVisitor(this.factory, imports, null, options), new Context(true));
  1074. }
  1075. };
  1076. // bazel-out/darwin_arm64-fastbuild/bin/packages/compiler-cli/linker/src/file_linker/linker_environment.mjs
  1077. var LinkerEnvironment = class {
  1078. fileSystem;
  1079. logger;
  1080. host;
  1081. factory;
  1082. options;
  1083. translator;
  1084. sourceFileLoader;
  1085. constructor(fileSystem, logger, host, factory, options) {
  1086. this.fileSystem = fileSystem;
  1087. this.logger = logger;
  1088. this.host = host;
  1089. this.factory = factory;
  1090. this.options = options;
  1091. this.translator = new Translator(this.factory);
  1092. this.sourceFileLoader = this.options.sourceMapping ? new SourceFileLoader(this.fileSystem, this.logger, {}) : null;
  1093. }
  1094. static create(fileSystem, logger, host, factory, options) {
  1095. var _a, _b, _c;
  1096. return new LinkerEnvironment(fileSystem, logger, host, factory, {
  1097. sourceMapping: (_a = options.sourceMapping) != null ? _a : DEFAULT_LINKER_OPTIONS.sourceMapping,
  1098. linkerJitMode: (_b = options.linkerJitMode) != null ? _b : DEFAULT_LINKER_OPTIONS.linkerJitMode,
  1099. unknownDeclarationVersionHandling: (_c = options.unknownDeclarationVersionHandling) != null ? _c : DEFAULT_LINKER_OPTIONS.unknownDeclarationVersionHandling
  1100. });
  1101. }
  1102. };
  1103. // bazel-out/darwin_arm64-fastbuild/bin/packages/compiler-cli/linker/src/file_linker/needs_linking.mjs
  1104. function needsLinking(path, source) {
  1105. return declarationFunctions.some((fn) => source.includes(fn));
  1106. }
  1107. export {
  1108. FatalLinkerError,
  1109. isFatalLinkerError,
  1110. assert,
  1111. FileLinker,
  1112. DEFAULT_LINKER_OPTIONS,
  1113. LinkerEnvironment,
  1114. needsLinking
  1115. };
  1116. /**
  1117. * @license
  1118. * Copyright Google LLC All Rights Reserved.
  1119. *
  1120. * Use of this source code is governed by an MIT-style license that can be
  1121. * found in the LICENSE file at https://angular.dev/license
  1122. */
  1123. //# sourceMappingURL=chunk-RNO4EXM5.js.map