platform-browser.mjs 85 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109
  1. /**
  2. * @license Angular v16.2.9
  3. * (c) 2010-2022 Google LLC. https://angular.io/
  4. * License: MIT
  5. */
  6. import * as i0 from '@angular/core';
  7. import { ɵglobal, ɵRuntimeError, Injectable, InjectionToken, Inject, APP_ID, CSP_NONCE, PLATFORM_ID, Optional, ViewEncapsulation, RendererStyleFlags2, ɵinternalCreateApplication, ErrorHandler, ɵsetDocument, PLATFORM_INITIALIZER, createPlatformFactory, platformCore, ɵTESTABILITY_GETTER, ɵTESTABILITY, Testability, NgZone, TestabilityRegistry, ɵINJECTOR_SCOPE, RendererFactory2, ApplicationModule, NgModule, SkipSelf, ɵɵinject, ApplicationRef, ɵConsole, forwardRef, ɵXSS_SECURITY_URL, SecurityContext, ɵallowSanitizationBypassAndThrow, ɵunwrapSafeValue, ɵ_sanitizeUrl, ɵ_sanitizeHtml, ɵbypassSanitizationTrustHtml, ɵbypassSanitizationTrustStyle, ɵbypassSanitizationTrustScript, ɵbypassSanitizationTrustUrl, ɵbypassSanitizationTrustResourceUrl, Injector, ENVIRONMENT_INITIALIZER, inject, ɵformatRuntimeError, makeEnvironmentProviders, ɵwithDomHydration, Version, makeStateKey as makeStateKey$1, TransferState as TransferState$1 } from '@angular/core';
  8. import { ɵDomAdapter, ɵsetRootDomAdapter, ɵparseCookieValue, ɵgetDOM, isPlatformServer, DOCUMENT, ɵPLATFORM_BROWSER_ID, XhrFactory, CommonModule } from '@angular/common';
  9. export { ɵgetDOM } from '@angular/common';
  10. import { ɵwithHttpTransferCache } from '@angular/common/http';
  11. /**
  12. * Provides DOM operations in any browser environment.
  13. *
  14. * @security Tread carefully! Interacting with the DOM directly is dangerous and
  15. * can introduce XSS risks.
  16. */
  17. class GenericBrowserDomAdapter extends ɵDomAdapter {
  18. constructor() {
  19. super(...arguments);
  20. this.supportsDOMEvents = true;
  21. }
  22. }
  23. /**
  24. * A `DomAdapter` powered by full browser DOM APIs.
  25. *
  26. * @security Tread carefully! Interacting with the DOM directly is dangerous and
  27. * can introduce XSS risks.
  28. */
  29. /* tslint:disable:requireParameterType no-console */
  30. class BrowserDomAdapter extends GenericBrowserDomAdapter {
  31. static makeCurrent() {
  32. ɵsetRootDomAdapter(new BrowserDomAdapter());
  33. }
  34. onAndCancel(el, evt, listener) {
  35. el.addEventListener(evt, listener);
  36. return () => {
  37. el.removeEventListener(evt, listener);
  38. };
  39. }
  40. dispatchEvent(el, evt) {
  41. el.dispatchEvent(evt);
  42. }
  43. remove(node) {
  44. if (node.parentNode) {
  45. node.parentNode.removeChild(node);
  46. }
  47. }
  48. createElement(tagName, doc) {
  49. doc = doc || this.getDefaultDocument();
  50. return doc.createElement(tagName);
  51. }
  52. createHtmlDocument() {
  53. return document.implementation.createHTMLDocument('fakeTitle');
  54. }
  55. getDefaultDocument() {
  56. return document;
  57. }
  58. isElementNode(node) {
  59. return node.nodeType === Node.ELEMENT_NODE;
  60. }
  61. isShadowRoot(node) {
  62. return node instanceof DocumentFragment;
  63. }
  64. /** @deprecated No longer being used in Ivy code. To be removed in version 14. */
  65. getGlobalEventTarget(doc, target) {
  66. if (target === 'window') {
  67. return window;
  68. }
  69. if (target === 'document') {
  70. return doc;
  71. }
  72. if (target === 'body') {
  73. return doc.body;
  74. }
  75. return null;
  76. }
  77. getBaseHref(doc) {
  78. const href = getBaseElementHref();
  79. return href == null ? null : relativePath(href);
  80. }
  81. resetBaseElement() {
  82. baseElement = null;
  83. }
  84. getUserAgent() {
  85. return window.navigator.userAgent;
  86. }
  87. getCookie(name) {
  88. return ɵparseCookieValue(document.cookie, name);
  89. }
  90. }
  91. let baseElement = null;
  92. function getBaseElementHref() {
  93. baseElement = baseElement || document.querySelector('base');
  94. return baseElement ? baseElement.getAttribute('href') : null;
  95. }
  96. // based on urlUtils.js in AngularJS 1
  97. let urlParsingNode;
  98. function relativePath(url) {
  99. urlParsingNode = urlParsingNode || document.createElement('a');
  100. urlParsingNode.setAttribute('href', url);
  101. const pathName = urlParsingNode.pathname;
  102. return pathName.charAt(0) === '/' ? pathName : `/${pathName}`;
  103. }
  104. class BrowserGetTestability {
  105. addToWindow(registry) {
  106. ɵglobal['getAngularTestability'] = (elem, findInAncestors = true) => {
  107. const testability = registry.findTestabilityInTree(elem, findInAncestors);
  108. if (testability == null) {
  109. throw new ɵRuntimeError(5103 /* RuntimeErrorCode.TESTABILITY_NOT_FOUND */, (typeof ngDevMode === 'undefined' || ngDevMode) &&
  110. 'Could not find testability for element.');
  111. }
  112. return testability;
  113. };
  114. ɵglobal['getAllAngularTestabilities'] = () => registry.getAllTestabilities();
  115. ɵglobal['getAllAngularRootElements'] = () => registry.getAllRootElements();
  116. const whenAllStable = (callback) => {
  117. const testabilities = ɵglobal['getAllAngularTestabilities']();
  118. let count = testabilities.length;
  119. let didWork = false;
  120. const decrement = function (didWork_) {
  121. didWork = didWork || didWork_;
  122. count--;
  123. if (count == 0) {
  124. callback(didWork);
  125. }
  126. };
  127. testabilities.forEach((testability) => {
  128. testability.whenStable(decrement);
  129. });
  130. };
  131. if (!ɵglobal['frameworkStabilizers']) {
  132. ɵglobal['frameworkStabilizers'] = [];
  133. }
  134. ɵglobal['frameworkStabilizers'].push(whenAllStable);
  135. }
  136. findTestabilityInTree(registry, elem, findInAncestors) {
  137. if (elem == null) {
  138. return null;
  139. }
  140. const t = registry.getTestability(elem);
  141. if (t != null) {
  142. return t;
  143. }
  144. else if (!findInAncestors) {
  145. return null;
  146. }
  147. if (ɵgetDOM().isShadowRoot(elem)) {
  148. return this.findTestabilityInTree(registry, elem.host, true);
  149. }
  150. return this.findTestabilityInTree(registry, elem.parentElement, true);
  151. }
  152. }
  153. /**
  154. * A factory for `HttpXhrBackend` that uses the `XMLHttpRequest` browser API.
  155. */
  156. class BrowserXhr {
  157. build() {
  158. return new XMLHttpRequest();
  159. }
  160. static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.9", ngImport: i0, type: BrowserXhr, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
  161. static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.2.9", ngImport: i0, type: BrowserXhr }); }
  162. }
  163. i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.9", ngImport: i0, type: BrowserXhr, decorators: [{
  164. type: Injectable
  165. }] });
  166. /**
  167. * The injection token for the event-manager plug-in service.
  168. *
  169. * @publicApi
  170. */
  171. const EVENT_MANAGER_PLUGINS = new InjectionToken('EventManagerPlugins');
  172. /**
  173. * An injectable service that provides event management for Angular
  174. * through a browser plug-in.
  175. *
  176. * @publicApi
  177. */
  178. class EventManager {
  179. /**
  180. * Initializes an instance of the event-manager service.
  181. */
  182. constructor(plugins, _zone) {
  183. this._zone = _zone;
  184. this._eventNameToPlugin = new Map();
  185. plugins.forEach((plugin) => {
  186. plugin.manager = this;
  187. });
  188. this._plugins = plugins.slice().reverse();
  189. }
  190. /**
  191. * Registers a handler for a specific element and event.
  192. *
  193. * @param element The HTML element to receive event notifications.
  194. * @param eventName The name of the event to listen for.
  195. * @param handler A function to call when the notification occurs. Receives the
  196. * event object as an argument.
  197. * @returns A callback function that can be used to remove the handler.
  198. */
  199. addEventListener(element, eventName, handler) {
  200. const plugin = this._findPluginFor(eventName);
  201. return plugin.addEventListener(element, eventName, handler);
  202. }
  203. /**
  204. * Retrieves the compilation zone in which event listeners are registered.
  205. */
  206. getZone() {
  207. return this._zone;
  208. }
  209. /** @internal */
  210. _findPluginFor(eventName) {
  211. let plugin = this._eventNameToPlugin.get(eventName);
  212. if (plugin) {
  213. return plugin;
  214. }
  215. const plugins = this._plugins;
  216. plugin = plugins.find((plugin) => plugin.supports(eventName));
  217. if (!plugin) {
  218. throw new ɵRuntimeError(5101 /* RuntimeErrorCode.NO_PLUGIN_FOR_EVENT */, (typeof ngDevMode === 'undefined' || ngDevMode) &&
  219. `No event manager plugin found for event ${eventName}`);
  220. }
  221. this._eventNameToPlugin.set(eventName, plugin);
  222. return plugin;
  223. }
  224. static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.9", ngImport: i0, type: EventManager, deps: [{ token: EVENT_MANAGER_PLUGINS }, { token: i0.NgZone }], target: i0.ɵɵFactoryTarget.Injectable }); }
  225. static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.2.9", ngImport: i0, type: EventManager }); }
  226. }
  227. i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.9", ngImport: i0, type: EventManager, decorators: [{
  228. type: Injectable
  229. }], ctorParameters: function () { return [{ type: undefined, decorators: [{
  230. type: Inject,
  231. args: [EVENT_MANAGER_PLUGINS]
  232. }] }, { type: i0.NgZone }]; } });
  233. class EventManagerPlugin {
  234. constructor(_doc) {
  235. this._doc = _doc;
  236. }
  237. }
  238. /** The style elements attribute name used to set value of `APP_ID` token. */
  239. const APP_ID_ATTRIBUTE_NAME = 'ng-app-id';
  240. class SharedStylesHost {
  241. constructor(doc, appId, nonce, platformId = {}) {
  242. this.doc = doc;
  243. this.appId = appId;
  244. this.nonce = nonce;
  245. this.platformId = platformId;
  246. // Maps all registered host nodes to a list of style nodes that have been added to the host node.
  247. this.styleRef = new Map();
  248. this.hostNodes = new Set();
  249. this.styleNodesInDOM = this.collectServerRenderedStyles();
  250. this.platformIsServer = isPlatformServer(platformId);
  251. this.resetHostNodes();
  252. }
  253. addStyles(styles) {
  254. for (const style of styles) {
  255. const usageCount = this.changeUsageCount(style, 1);
  256. if (usageCount === 1) {
  257. this.onStyleAdded(style);
  258. }
  259. }
  260. }
  261. removeStyles(styles) {
  262. for (const style of styles) {
  263. const usageCount = this.changeUsageCount(style, -1);
  264. if (usageCount <= 0) {
  265. this.onStyleRemoved(style);
  266. }
  267. }
  268. }
  269. ngOnDestroy() {
  270. const styleNodesInDOM = this.styleNodesInDOM;
  271. if (styleNodesInDOM) {
  272. styleNodesInDOM.forEach((node) => node.remove());
  273. styleNodesInDOM.clear();
  274. }
  275. for (const style of this.getAllStyles()) {
  276. this.onStyleRemoved(style);
  277. }
  278. this.resetHostNodes();
  279. }
  280. addHost(hostNode) {
  281. this.hostNodes.add(hostNode);
  282. for (const style of this.getAllStyles()) {
  283. this.addStyleToHost(hostNode, style);
  284. }
  285. }
  286. removeHost(hostNode) {
  287. this.hostNodes.delete(hostNode);
  288. }
  289. getAllStyles() {
  290. return this.styleRef.keys();
  291. }
  292. onStyleAdded(style) {
  293. for (const host of this.hostNodes) {
  294. this.addStyleToHost(host, style);
  295. }
  296. }
  297. onStyleRemoved(style) {
  298. const styleRef = this.styleRef;
  299. styleRef.get(style)?.elements?.forEach((node) => node.remove());
  300. styleRef.delete(style);
  301. }
  302. collectServerRenderedStyles() {
  303. const styles = this.doc.head?.querySelectorAll(`style[${APP_ID_ATTRIBUTE_NAME}="${this.appId}"]`);
  304. if (styles?.length) {
  305. const styleMap = new Map();
  306. styles.forEach((style) => {
  307. if (style.textContent != null) {
  308. styleMap.set(style.textContent, style);
  309. }
  310. });
  311. return styleMap;
  312. }
  313. return null;
  314. }
  315. changeUsageCount(style, delta) {
  316. const map = this.styleRef;
  317. if (map.has(style)) {
  318. const styleRefValue = map.get(style);
  319. styleRefValue.usage += delta;
  320. return styleRefValue.usage;
  321. }
  322. map.set(style, { usage: delta, elements: [] });
  323. return delta;
  324. }
  325. getStyleElement(host, style) {
  326. const styleNodesInDOM = this.styleNodesInDOM;
  327. const styleEl = styleNodesInDOM?.get(style);
  328. if (styleEl?.parentNode === host) {
  329. // `styleNodesInDOM` cannot be undefined due to the above `styleNodesInDOM?.get`.
  330. styleNodesInDOM.delete(style);
  331. styleEl.removeAttribute(APP_ID_ATTRIBUTE_NAME);
  332. if (typeof ngDevMode === 'undefined' || ngDevMode) {
  333. // This attribute is solely used for debugging purposes.
  334. styleEl.setAttribute('ng-style-reused', '');
  335. }
  336. return styleEl;
  337. }
  338. else {
  339. const styleEl = this.doc.createElement('style');
  340. if (this.nonce) {
  341. styleEl.setAttribute('nonce', this.nonce);
  342. }
  343. styleEl.textContent = style;
  344. if (this.platformIsServer) {
  345. styleEl.setAttribute(APP_ID_ATTRIBUTE_NAME, this.appId);
  346. }
  347. return styleEl;
  348. }
  349. }
  350. addStyleToHost(host, style) {
  351. const styleEl = this.getStyleElement(host, style);
  352. host.appendChild(styleEl);
  353. const styleRef = this.styleRef;
  354. const styleElRef = styleRef.get(style)?.elements;
  355. if (styleElRef) {
  356. styleElRef.push(styleEl);
  357. }
  358. else {
  359. styleRef.set(style, { elements: [styleEl], usage: 1 });
  360. }
  361. }
  362. resetHostNodes() {
  363. const hostNodes = this.hostNodes;
  364. hostNodes.clear();
  365. // Re-add the head element back since this is the default host.
  366. hostNodes.add(this.doc.head);
  367. }
  368. static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.9", ngImport: i0, type: SharedStylesHost, deps: [{ token: DOCUMENT }, { token: APP_ID }, { token: CSP_NONCE, optional: true }, { token: PLATFORM_ID }], target: i0.ɵɵFactoryTarget.Injectable }); }
  369. static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.2.9", ngImport: i0, type: SharedStylesHost }); }
  370. }
  371. i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.9", ngImport: i0, type: SharedStylesHost, decorators: [{
  372. type: Injectable
  373. }], ctorParameters: function () { return [{ type: Document, decorators: [{
  374. type: Inject,
  375. args: [DOCUMENT]
  376. }] }, { type: undefined, decorators: [{
  377. type: Inject,
  378. args: [APP_ID]
  379. }] }, { type: undefined, decorators: [{
  380. type: Inject,
  381. args: [CSP_NONCE]
  382. }, {
  383. type: Optional
  384. }] }, { type: undefined, decorators: [{
  385. type: Inject,
  386. args: [PLATFORM_ID]
  387. }] }]; } });
  388. const NAMESPACE_URIS = {
  389. 'svg': 'http://www.w3.org/2000/svg',
  390. 'xhtml': 'http://www.w3.org/1999/xhtml',
  391. 'xlink': 'http://www.w3.org/1999/xlink',
  392. 'xml': 'http://www.w3.org/XML/1998/namespace',
  393. 'xmlns': 'http://www.w3.org/2000/xmlns/',
  394. 'math': 'http://www.w3.org/1998/MathML/',
  395. };
  396. const COMPONENT_REGEX = /%COMP%/g;
  397. const COMPONENT_VARIABLE = '%COMP%';
  398. const HOST_ATTR = `_nghost-${COMPONENT_VARIABLE}`;
  399. const CONTENT_ATTR = `_ngcontent-${COMPONENT_VARIABLE}`;
  400. /**
  401. * The default value for the `REMOVE_STYLES_ON_COMPONENT_DESTROY` DI token.
  402. */
  403. const REMOVE_STYLES_ON_COMPONENT_DESTROY_DEFAULT = false;
  404. /**
  405. * A [DI token](guide/glossary#di-token "DI token definition") that indicates whether styles
  406. * of destroyed components should be removed from DOM.
  407. *
  408. * By default, the value is set to `false`. This will be changed in the next major version.
  409. * @publicApi
  410. */
  411. const REMOVE_STYLES_ON_COMPONENT_DESTROY = new InjectionToken('RemoveStylesOnCompDestroy', {
  412. providedIn: 'root',
  413. factory: () => REMOVE_STYLES_ON_COMPONENT_DESTROY_DEFAULT,
  414. });
  415. function shimContentAttribute(componentShortId) {
  416. return CONTENT_ATTR.replace(COMPONENT_REGEX, componentShortId);
  417. }
  418. function shimHostAttribute(componentShortId) {
  419. return HOST_ATTR.replace(COMPONENT_REGEX, componentShortId);
  420. }
  421. function shimStylesContent(compId, styles) {
  422. return styles.map(s => s.replace(COMPONENT_REGEX, compId));
  423. }
  424. class DomRendererFactory2 {
  425. constructor(eventManager, sharedStylesHost, appId, removeStylesOnCompDestroy, doc, platformId, ngZone, nonce = null) {
  426. this.eventManager = eventManager;
  427. this.sharedStylesHost = sharedStylesHost;
  428. this.appId = appId;
  429. this.removeStylesOnCompDestroy = removeStylesOnCompDestroy;
  430. this.doc = doc;
  431. this.platformId = platformId;
  432. this.ngZone = ngZone;
  433. this.nonce = nonce;
  434. this.rendererByCompId = new Map();
  435. this.platformIsServer = isPlatformServer(platformId);
  436. this.defaultRenderer =
  437. new DefaultDomRenderer2(eventManager, doc, ngZone, this.platformIsServer);
  438. }
  439. createRenderer(element, type) {
  440. if (!element || !type) {
  441. return this.defaultRenderer;
  442. }
  443. if (this.platformIsServer && type.encapsulation === ViewEncapsulation.ShadowDom) {
  444. // Domino does not support shadow DOM.
  445. type = { ...type, encapsulation: ViewEncapsulation.Emulated };
  446. }
  447. const renderer = this.getOrCreateRenderer(element, type);
  448. // Renderers have different logic due to different encapsulation behaviours.
  449. // Ex: for emulated, an attribute is added to the element.
  450. if (renderer instanceof EmulatedEncapsulationDomRenderer2) {
  451. renderer.applyToHost(element);
  452. }
  453. else if (renderer instanceof NoneEncapsulationDomRenderer) {
  454. renderer.applyStyles();
  455. }
  456. return renderer;
  457. }
  458. getOrCreateRenderer(element, type) {
  459. const rendererByCompId = this.rendererByCompId;
  460. let renderer = rendererByCompId.get(type.id);
  461. if (!renderer) {
  462. const doc = this.doc;
  463. const ngZone = this.ngZone;
  464. const eventManager = this.eventManager;
  465. const sharedStylesHost = this.sharedStylesHost;
  466. const removeStylesOnCompDestroy = this.removeStylesOnCompDestroy;
  467. const platformIsServer = this.platformIsServer;
  468. switch (type.encapsulation) {
  469. case ViewEncapsulation.Emulated:
  470. renderer = new EmulatedEncapsulationDomRenderer2(eventManager, sharedStylesHost, type, this.appId, removeStylesOnCompDestroy, doc, ngZone, platformIsServer);
  471. break;
  472. case ViewEncapsulation.ShadowDom:
  473. return new ShadowDomRenderer(eventManager, sharedStylesHost, element, type, doc, ngZone, this.nonce, platformIsServer);
  474. default:
  475. renderer = new NoneEncapsulationDomRenderer(eventManager, sharedStylesHost, type, removeStylesOnCompDestroy, doc, ngZone, platformIsServer);
  476. break;
  477. }
  478. rendererByCompId.set(type.id, renderer);
  479. }
  480. return renderer;
  481. }
  482. ngOnDestroy() {
  483. this.rendererByCompId.clear();
  484. }
  485. static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.9", ngImport: i0, type: DomRendererFactory2, deps: [{ token: EventManager }, { token: SharedStylesHost }, { token: APP_ID }, { token: REMOVE_STYLES_ON_COMPONENT_DESTROY }, { token: DOCUMENT }, { token: PLATFORM_ID }, { token: i0.NgZone }, { token: CSP_NONCE }], target: i0.ɵɵFactoryTarget.Injectable }); }
  486. static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.2.9", ngImport: i0, type: DomRendererFactory2 }); }
  487. }
  488. i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.9", ngImport: i0, type: DomRendererFactory2, decorators: [{
  489. type: Injectable
  490. }], ctorParameters: function () { return [{ type: EventManager }, { type: SharedStylesHost }, { type: undefined, decorators: [{
  491. type: Inject,
  492. args: [APP_ID]
  493. }] }, { type: undefined, decorators: [{
  494. type: Inject,
  495. args: [REMOVE_STYLES_ON_COMPONENT_DESTROY]
  496. }] }, { type: Document, decorators: [{
  497. type: Inject,
  498. args: [DOCUMENT]
  499. }] }, { type: Object, decorators: [{
  500. type: Inject,
  501. args: [PLATFORM_ID]
  502. }] }, { type: i0.NgZone }, { type: undefined, decorators: [{
  503. type: Inject,
  504. args: [CSP_NONCE]
  505. }] }]; } });
  506. class DefaultDomRenderer2 {
  507. constructor(eventManager, doc, ngZone, platformIsServer) {
  508. this.eventManager = eventManager;
  509. this.doc = doc;
  510. this.ngZone = ngZone;
  511. this.platformIsServer = platformIsServer;
  512. this.data = Object.create(null);
  513. this.destroyNode = null;
  514. }
  515. destroy() { }
  516. createElement(name, namespace) {
  517. if (namespace) {
  518. // TODO: `|| namespace` was added in
  519. // https://github.com/angular/angular/commit/2b9cc8503d48173492c29f5a271b61126104fbdb to
  520. // support how Ivy passed around the namespace URI rather than short name at the time. It did
  521. // not, however extend the support to other parts of the system (setAttribute, setAttribute,
  522. // and the ServerRenderer). We should decide what exactly the semantics for dealing with
  523. // namespaces should be and make it consistent.
  524. // Related issues:
  525. // https://github.com/angular/angular/issues/44028
  526. // https://github.com/angular/angular/issues/44883
  527. return this.doc.createElementNS(NAMESPACE_URIS[namespace] || namespace, name);
  528. }
  529. return this.doc.createElement(name);
  530. }
  531. createComment(value) {
  532. return this.doc.createComment(value);
  533. }
  534. createText(value) {
  535. return this.doc.createTextNode(value);
  536. }
  537. appendChild(parent, newChild) {
  538. const targetParent = isTemplateNode(parent) ? parent.content : parent;
  539. targetParent.appendChild(newChild);
  540. }
  541. insertBefore(parent, newChild, refChild) {
  542. if (parent) {
  543. const targetParent = isTemplateNode(parent) ? parent.content : parent;
  544. targetParent.insertBefore(newChild, refChild);
  545. }
  546. }
  547. removeChild(parent, oldChild) {
  548. if (parent) {
  549. parent.removeChild(oldChild);
  550. }
  551. }
  552. selectRootElement(selectorOrNode, preserveContent) {
  553. let el = typeof selectorOrNode === 'string' ? this.doc.querySelector(selectorOrNode) :
  554. selectorOrNode;
  555. if (!el) {
  556. throw new ɵRuntimeError(-5104 /* RuntimeErrorCode.ROOT_NODE_NOT_FOUND */, (typeof ngDevMode === 'undefined' || ngDevMode) &&
  557. `The selector "${selectorOrNode}" did not match any elements`);
  558. }
  559. if (!preserveContent) {
  560. el.textContent = '';
  561. }
  562. return el;
  563. }
  564. parentNode(node) {
  565. return node.parentNode;
  566. }
  567. nextSibling(node) {
  568. return node.nextSibling;
  569. }
  570. setAttribute(el, name, value, namespace) {
  571. if (namespace) {
  572. name = namespace + ':' + name;
  573. const namespaceUri = NAMESPACE_URIS[namespace];
  574. if (namespaceUri) {
  575. el.setAttributeNS(namespaceUri, name, value);
  576. }
  577. else {
  578. el.setAttribute(name, value);
  579. }
  580. }
  581. else {
  582. el.setAttribute(name, value);
  583. }
  584. }
  585. removeAttribute(el, name, namespace) {
  586. if (namespace) {
  587. const namespaceUri = NAMESPACE_URIS[namespace];
  588. if (namespaceUri) {
  589. el.removeAttributeNS(namespaceUri, name);
  590. }
  591. else {
  592. el.removeAttribute(`${namespace}:${name}`);
  593. }
  594. }
  595. else {
  596. el.removeAttribute(name);
  597. }
  598. }
  599. addClass(el, name) {
  600. el.classList.add(name);
  601. }
  602. removeClass(el, name) {
  603. el.classList.remove(name);
  604. }
  605. setStyle(el, style, value, flags) {
  606. if (flags & (RendererStyleFlags2.DashCase | RendererStyleFlags2.Important)) {
  607. el.style.setProperty(style, value, flags & RendererStyleFlags2.Important ? 'important' : '');
  608. }
  609. else {
  610. el.style[style] = value;
  611. }
  612. }
  613. removeStyle(el, style, flags) {
  614. if (flags & RendererStyleFlags2.DashCase) {
  615. // removeProperty has no effect when used on camelCased properties.
  616. el.style.removeProperty(style);
  617. }
  618. else {
  619. el.style[style] = '';
  620. }
  621. }
  622. setProperty(el, name, value) {
  623. (typeof ngDevMode === 'undefined' || ngDevMode) && checkNoSyntheticProp(name, 'property');
  624. el[name] = value;
  625. }
  626. setValue(node, value) {
  627. node.nodeValue = value;
  628. }
  629. listen(target, event, callback) {
  630. (typeof ngDevMode === 'undefined' || ngDevMode) && checkNoSyntheticProp(event, 'listener');
  631. if (typeof target === 'string') {
  632. target = ɵgetDOM().getGlobalEventTarget(this.doc, target);
  633. if (!target) {
  634. throw new Error(`Unsupported event target ${target} for event ${event}`);
  635. }
  636. }
  637. return this.eventManager.addEventListener(target, event, this.decoratePreventDefault(callback));
  638. }
  639. decoratePreventDefault(eventHandler) {
  640. // `DebugNode.triggerEventHandler` needs to know if the listener was created with
  641. // decoratePreventDefault or is a listener added outside the Angular context so it can handle
  642. // the two differently. In the first case, the special '__ngUnwrap__' token is passed to the
  643. // unwrap the listener (see below).
  644. return (event) => {
  645. // Ivy uses '__ngUnwrap__' as a special token that allows us to unwrap the function
  646. // so that it can be invoked programmatically by `DebugNode.triggerEventHandler`. The
  647. // debug_node can inspect the listener toString contents for the existence of this special
  648. // token. Because the token is a string literal, it is ensured to not be modified by compiled
  649. // code.
  650. if (event === '__ngUnwrap__') {
  651. return eventHandler;
  652. }
  653. // Run the event handler inside the ngZone because event handlers are not patched
  654. // by Zone on the server. This is required only for tests.
  655. const allowDefaultBehavior = this.platformIsServer ?
  656. this.ngZone.runGuarded(() => eventHandler(event)) :
  657. eventHandler(event);
  658. if (allowDefaultBehavior === false) {
  659. event.preventDefault();
  660. }
  661. return undefined;
  662. };
  663. }
  664. }
  665. const AT_CHARCODE = (() => '@'.charCodeAt(0))();
  666. function checkNoSyntheticProp(name, nameKind) {
  667. if (name.charCodeAt(0) === AT_CHARCODE) {
  668. throw new ɵRuntimeError(5105 /* RuntimeErrorCode.UNEXPECTED_SYNTHETIC_PROPERTY */, `Unexpected synthetic ${nameKind} ${name} found. Please make sure that:
  669. - Either \`BrowserAnimationsModule\` or \`NoopAnimationsModule\` are imported in your application.
  670. - There is corresponding configuration for the animation named \`${name}\` defined in the \`animations\` field of the \`@Component\` decorator (see https://angular.io/api/core/Component#animations).`);
  671. }
  672. }
  673. function isTemplateNode(node) {
  674. return node.tagName === 'TEMPLATE' && node.content !== undefined;
  675. }
  676. class ShadowDomRenderer extends DefaultDomRenderer2 {
  677. constructor(eventManager, sharedStylesHost, hostEl, component, doc, ngZone, nonce, platformIsServer) {
  678. super(eventManager, doc, ngZone, platformIsServer);
  679. this.sharedStylesHost = sharedStylesHost;
  680. this.hostEl = hostEl;
  681. this.shadowRoot = hostEl.attachShadow({ mode: 'open' });
  682. this.sharedStylesHost.addHost(this.shadowRoot);
  683. const styles = shimStylesContent(component.id, component.styles);
  684. for (const style of styles) {
  685. const styleEl = document.createElement('style');
  686. if (nonce) {
  687. styleEl.setAttribute('nonce', nonce);
  688. }
  689. styleEl.textContent = style;
  690. this.shadowRoot.appendChild(styleEl);
  691. }
  692. }
  693. nodeOrShadowRoot(node) {
  694. return node === this.hostEl ? this.shadowRoot : node;
  695. }
  696. appendChild(parent, newChild) {
  697. return super.appendChild(this.nodeOrShadowRoot(parent), newChild);
  698. }
  699. insertBefore(parent, newChild, refChild) {
  700. return super.insertBefore(this.nodeOrShadowRoot(parent), newChild, refChild);
  701. }
  702. removeChild(parent, oldChild) {
  703. return super.removeChild(this.nodeOrShadowRoot(parent), oldChild);
  704. }
  705. parentNode(node) {
  706. return this.nodeOrShadowRoot(super.parentNode(this.nodeOrShadowRoot(node)));
  707. }
  708. destroy() {
  709. this.sharedStylesHost.removeHost(this.shadowRoot);
  710. }
  711. }
  712. class NoneEncapsulationDomRenderer extends DefaultDomRenderer2 {
  713. constructor(eventManager, sharedStylesHost, component, removeStylesOnCompDestroy, doc, ngZone, platformIsServer, compId) {
  714. super(eventManager, doc, ngZone, platformIsServer);
  715. this.sharedStylesHost = sharedStylesHost;
  716. this.removeStylesOnCompDestroy = removeStylesOnCompDestroy;
  717. this.styles = compId ? shimStylesContent(compId, component.styles) : component.styles;
  718. }
  719. applyStyles() {
  720. this.sharedStylesHost.addStyles(this.styles);
  721. }
  722. destroy() {
  723. if (!this.removeStylesOnCompDestroy) {
  724. return;
  725. }
  726. this.sharedStylesHost.removeStyles(this.styles);
  727. }
  728. }
  729. class EmulatedEncapsulationDomRenderer2 extends NoneEncapsulationDomRenderer {
  730. constructor(eventManager, sharedStylesHost, component, appId, removeStylesOnCompDestroy, doc, ngZone, platformIsServer) {
  731. const compId = appId + '-' + component.id;
  732. super(eventManager, sharedStylesHost, component, removeStylesOnCompDestroy, doc, ngZone, platformIsServer, compId);
  733. this.contentAttr = shimContentAttribute(compId);
  734. this.hostAttr = shimHostAttribute(compId);
  735. }
  736. applyToHost(element) {
  737. this.applyStyles();
  738. this.setAttribute(element, this.hostAttr, '');
  739. }
  740. createElement(parent, name) {
  741. const el = super.createElement(parent, name);
  742. super.setAttribute(el, this.contentAttr, '');
  743. return el;
  744. }
  745. }
  746. class DomEventsPlugin extends EventManagerPlugin {
  747. constructor(doc) {
  748. super(doc);
  749. }
  750. // This plugin should come last in the list of plugins, because it accepts all
  751. // events.
  752. supports(eventName) {
  753. return true;
  754. }
  755. addEventListener(element, eventName, handler) {
  756. element.addEventListener(eventName, handler, false);
  757. return () => this.removeEventListener(element, eventName, handler);
  758. }
  759. removeEventListener(target, eventName, callback) {
  760. return target.removeEventListener(eventName, callback);
  761. }
  762. static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.9", ngImport: i0, type: DomEventsPlugin, deps: [{ token: DOCUMENT }], target: i0.ɵɵFactoryTarget.Injectable }); }
  763. static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.2.9", ngImport: i0, type: DomEventsPlugin }); }
  764. }
  765. i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.9", ngImport: i0, type: DomEventsPlugin, decorators: [{
  766. type: Injectable
  767. }], ctorParameters: function () { return [{ type: undefined, decorators: [{
  768. type: Inject,
  769. args: [DOCUMENT]
  770. }] }]; } });
  771. /**
  772. * Defines supported modifiers for key events.
  773. */
  774. const MODIFIER_KEYS = ['alt', 'control', 'meta', 'shift'];
  775. // The following values are here for cross-browser compatibility and to match the W3C standard
  776. // cf https://www.w3.org/TR/DOM-Level-3-Events-key/
  777. const _keyMap = {
  778. '\b': 'Backspace',
  779. '\t': 'Tab',
  780. '\x7F': 'Delete',
  781. '\x1B': 'Escape',
  782. 'Del': 'Delete',
  783. 'Esc': 'Escape',
  784. 'Left': 'ArrowLeft',
  785. 'Right': 'ArrowRight',
  786. 'Up': 'ArrowUp',
  787. 'Down': 'ArrowDown',
  788. 'Menu': 'ContextMenu',
  789. 'Scroll': 'ScrollLock',
  790. 'Win': 'OS'
  791. };
  792. /**
  793. * Retrieves modifiers from key-event objects.
  794. */
  795. const MODIFIER_KEY_GETTERS = {
  796. 'alt': (event) => event.altKey,
  797. 'control': (event) => event.ctrlKey,
  798. 'meta': (event) => event.metaKey,
  799. 'shift': (event) => event.shiftKey
  800. };
  801. /**
  802. * @publicApi
  803. * A browser plug-in that provides support for handling of key events in Angular.
  804. */
  805. class KeyEventsPlugin extends EventManagerPlugin {
  806. /**
  807. * Initializes an instance of the browser plug-in.
  808. * @param doc The document in which key events will be detected.
  809. */
  810. constructor(doc) {
  811. super(doc);
  812. }
  813. /**
  814. * Reports whether a named key event is supported.
  815. * @param eventName The event name to query.
  816. * @return True if the named key event is supported.
  817. */
  818. supports(eventName) {
  819. return KeyEventsPlugin.parseEventName(eventName) != null;
  820. }
  821. /**
  822. * Registers a handler for a specific element and key event.
  823. * @param element The HTML element to receive event notifications.
  824. * @param eventName The name of the key event to listen for.
  825. * @param handler A function to call when the notification occurs. Receives the
  826. * event object as an argument.
  827. * @returns The key event that was registered.
  828. */
  829. addEventListener(element, eventName, handler) {
  830. const parsedEvent = KeyEventsPlugin.parseEventName(eventName);
  831. const outsideHandler = KeyEventsPlugin.eventCallback(parsedEvent['fullKey'], handler, this.manager.getZone());
  832. return this.manager.getZone().runOutsideAngular(() => {
  833. return ɵgetDOM().onAndCancel(element, parsedEvent['domEventName'], outsideHandler);
  834. });
  835. }
  836. /**
  837. * Parses the user provided full keyboard event definition and normalizes it for
  838. * later internal use. It ensures the string is all lowercase, converts special
  839. * characters to a standard spelling, and orders all the values consistently.
  840. *
  841. * @param eventName The name of the key event to listen for.
  842. * @returns an object with the full, normalized string, and the dom event name
  843. * or null in the case when the event doesn't match a keyboard event.
  844. */
  845. static parseEventName(eventName) {
  846. const parts = eventName.toLowerCase().split('.');
  847. const domEventName = parts.shift();
  848. if ((parts.length === 0) || !(domEventName === 'keydown' || domEventName === 'keyup')) {
  849. return null;
  850. }
  851. const key = KeyEventsPlugin._normalizeKey(parts.pop());
  852. let fullKey = '';
  853. let codeIX = parts.indexOf('code');
  854. if (codeIX > -1) {
  855. parts.splice(codeIX, 1);
  856. fullKey = 'code.';
  857. }
  858. MODIFIER_KEYS.forEach(modifierName => {
  859. const index = parts.indexOf(modifierName);
  860. if (index > -1) {
  861. parts.splice(index, 1);
  862. fullKey += modifierName + '.';
  863. }
  864. });
  865. fullKey += key;
  866. if (parts.length != 0 || key.length === 0) {
  867. // returning null instead of throwing to let another plugin process the event
  868. return null;
  869. }
  870. // NOTE: Please don't rewrite this as so, as it will break JSCompiler property renaming.
  871. // The code must remain in the `result['domEventName']` form.
  872. // return {domEventName, fullKey};
  873. const result = {};
  874. result['domEventName'] = domEventName;
  875. result['fullKey'] = fullKey;
  876. return result;
  877. }
  878. /**
  879. * Determines whether the actual keys pressed match the configured key code string.
  880. * The `fullKeyCode` event is normalized in the `parseEventName` method when the
  881. * event is attached to the DOM during the `addEventListener` call. This is unseen
  882. * by the end user and is normalized for internal consistency and parsing.
  883. *
  884. * @param event The keyboard event.
  885. * @param fullKeyCode The normalized user defined expected key event string
  886. * @returns boolean.
  887. */
  888. static matchEventFullKeyCode(event, fullKeyCode) {
  889. let keycode = _keyMap[event.key] || event.key;
  890. let key = '';
  891. if (fullKeyCode.indexOf('code.') > -1) {
  892. keycode = event.code;
  893. key = 'code.';
  894. }
  895. // the keycode could be unidentified so we have to check here
  896. if (keycode == null || !keycode)
  897. return false;
  898. keycode = keycode.toLowerCase();
  899. if (keycode === ' ') {
  900. keycode = 'space'; // for readability
  901. }
  902. else if (keycode === '.') {
  903. keycode = 'dot'; // because '.' is used as a separator in event names
  904. }
  905. MODIFIER_KEYS.forEach(modifierName => {
  906. if (modifierName !== keycode) {
  907. const modifierGetter = MODIFIER_KEY_GETTERS[modifierName];
  908. if (modifierGetter(event)) {
  909. key += modifierName + '.';
  910. }
  911. }
  912. });
  913. key += keycode;
  914. return key === fullKeyCode;
  915. }
  916. /**
  917. * Configures a handler callback for a key event.
  918. * @param fullKey The event name that combines all simultaneous keystrokes.
  919. * @param handler The function that responds to the key event.
  920. * @param zone The zone in which the event occurred.
  921. * @returns A callback function.
  922. */
  923. static eventCallback(fullKey, handler, zone) {
  924. return (event) => {
  925. if (KeyEventsPlugin.matchEventFullKeyCode(event, fullKey)) {
  926. zone.runGuarded(() => handler(event));
  927. }
  928. };
  929. }
  930. /** @internal */
  931. static _normalizeKey(keyName) {
  932. // TODO: switch to a Map if the mapping grows too much
  933. switch (keyName) {
  934. case 'esc':
  935. return 'escape';
  936. default:
  937. return keyName;
  938. }
  939. }
  940. static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.9", ngImport: i0, type: KeyEventsPlugin, deps: [{ token: DOCUMENT }], target: i0.ɵɵFactoryTarget.Injectable }); }
  941. static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.2.9", ngImport: i0, type: KeyEventsPlugin }); }
  942. }
  943. i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.9", ngImport: i0, type: KeyEventsPlugin, decorators: [{
  944. type: Injectable
  945. }], ctorParameters: function () { return [{ type: undefined, decorators: [{
  946. type: Inject,
  947. args: [DOCUMENT]
  948. }] }]; } });
  949. /**
  950. * Bootstraps an instance of an Angular application and renders a standalone component as the
  951. * application's root component. More information about standalone components can be found in [this
  952. * guide](guide/standalone-components).
  953. *
  954. * @usageNotes
  955. * The root component passed into this function *must* be a standalone one (should have the
  956. * `standalone: true` flag in the `@Component` decorator config).
  957. *
  958. * ```typescript
  959. * @Component({
  960. * standalone: true,
  961. * template: 'Hello world!'
  962. * })
  963. * class RootComponent {}
  964. *
  965. * const appRef: ApplicationRef = await bootstrapApplication(RootComponent);
  966. * ```
  967. *
  968. * You can add the list of providers that should be available in the application injector by
  969. * specifying the `providers` field in an object passed as the second argument:
  970. *
  971. * ```typescript
  972. * await bootstrapApplication(RootComponent, {
  973. * providers: [
  974. * {provide: BACKEND_URL, useValue: 'https://yourdomain.com/api'}
  975. * ]
  976. * });
  977. * ```
  978. *
  979. * The `importProvidersFrom` helper method can be used to collect all providers from any
  980. * existing NgModule (and transitively from all NgModules that it imports):
  981. *
  982. * ```typescript
  983. * await bootstrapApplication(RootComponent, {
  984. * providers: [
  985. * importProvidersFrom(SomeNgModule)
  986. * ]
  987. * });
  988. * ```
  989. *
  990. * Note: the `bootstrapApplication` method doesn't include [Testability](api/core/Testability) by
  991. * default. You can add [Testability](api/core/Testability) by getting the list of necessary
  992. * providers using `provideProtractorTestingSupport()` function and adding them into the `providers`
  993. * array, for example:
  994. *
  995. * ```typescript
  996. * import {provideProtractorTestingSupport} from '@angular/platform-browser';
  997. *
  998. * await bootstrapApplication(RootComponent, {providers: [provideProtractorTestingSupport()]});
  999. * ```
  1000. *
  1001. * @param rootComponent A reference to a standalone component that should be rendered.
  1002. * @param options Extra configuration for the bootstrap operation, see `ApplicationConfig` for
  1003. * additional info.
  1004. * @returns A promise that returns an `ApplicationRef` instance once resolved.
  1005. *
  1006. * @publicApi
  1007. */
  1008. function bootstrapApplication(rootComponent, options) {
  1009. return ɵinternalCreateApplication({ rootComponent, ...createProvidersConfig(options) });
  1010. }
  1011. /**
  1012. * Create an instance of an Angular application without bootstrapping any components. This is useful
  1013. * for the situation where one wants to decouple application environment creation (a platform and
  1014. * associated injectors) from rendering components on a screen. Components can be subsequently
  1015. * bootstrapped on the returned `ApplicationRef`.
  1016. *
  1017. * @param options Extra configuration for the application environment, see `ApplicationConfig` for
  1018. * additional info.
  1019. * @returns A promise that returns an `ApplicationRef` instance once resolved.
  1020. *
  1021. * @publicApi
  1022. */
  1023. function createApplication(options) {
  1024. return ɵinternalCreateApplication(createProvidersConfig(options));
  1025. }
  1026. function createProvidersConfig(options) {
  1027. return {
  1028. appProviders: [
  1029. ...BROWSER_MODULE_PROVIDERS,
  1030. ...(options?.providers ?? []),
  1031. ],
  1032. platformProviders: INTERNAL_BROWSER_PLATFORM_PROVIDERS
  1033. };
  1034. }
  1035. /**
  1036. * Returns a set of providers required to setup [Testability](api/core/Testability) for an
  1037. * application bootstrapped using the `bootstrapApplication` function. The set of providers is
  1038. * needed to support testing an application with Protractor (which relies on the Testability APIs
  1039. * to be present).
  1040. *
  1041. * @returns An array of providers required to setup Testability for an application and make it
  1042. * available for testing using Protractor.
  1043. *
  1044. * @publicApi
  1045. */
  1046. function provideProtractorTestingSupport() {
  1047. // Return a copy to prevent changes to the original array in case any in-place
  1048. // alterations are performed to the `provideProtractorTestingSupport` call results in app
  1049. // code.
  1050. return [...TESTABILITY_PROVIDERS];
  1051. }
  1052. function initDomAdapter() {
  1053. BrowserDomAdapter.makeCurrent();
  1054. }
  1055. function errorHandler() {
  1056. return new ErrorHandler();
  1057. }
  1058. function _document() {
  1059. // Tell ivy about the global document
  1060. ɵsetDocument(document);
  1061. return document;
  1062. }
  1063. const INTERNAL_BROWSER_PLATFORM_PROVIDERS = [
  1064. { provide: PLATFORM_ID, useValue: ɵPLATFORM_BROWSER_ID },
  1065. { provide: PLATFORM_INITIALIZER, useValue: initDomAdapter, multi: true },
  1066. { provide: DOCUMENT, useFactory: _document, deps: [] },
  1067. ];
  1068. /**
  1069. * A factory function that returns a `PlatformRef` instance associated with browser service
  1070. * providers.
  1071. *
  1072. * @publicApi
  1073. */
  1074. const platformBrowser = createPlatformFactory(platformCore, 'browser', INTERNAL_BROWSER_PLATFORM_PROVIDERS);
  1075. /**
  1076. * Internal marker to signal whether providers from the `BrowserModule` are already present in DI.
  1077. * This is needed to avoid loading `BrowserModule` providers twice. We can't rely on the
  1078. * `BrowserModule` presence itself, since the standalone-based bootstrap just imports
  1079. * `BrowserModule` providers without referencing the module itself.
  1080. */
  1081. const BROWSER_MODULE_PROVIDERS_MARKER = new InjectionToken((typeof ngDevMode === 'undefined' || ngDevMode) ? 'BrowserModule Providers Marker' : '');
  1082. const TESTABILITY_PROVIDERS = [
  1083. {
  1084. provide: ɵTESTABILITY_GETTER,
  1085. useClass: BrowserGetTestability,
  1086. deps: [],
  1087. },
  1088. {
  1089. provide: ɵTESTABILITY,
  1090. useClass: Testability,
  1091. deps: [NgZone, TestabilityRegistry, ɵTESTABILITY_GETTER]
  1092. },
  1093. {
  1094. provide: Testability,
  1095. useClass: Testability,
  1096. deps: [NgZone, TestabilityRegistry, ɵTESTABILITY_GETTER]
  1097. }
  1098. ];
  1099. const BROWSER_MODULE_PROVIDERS = [
  1100. { provide: ɵINJECTOR_SCOPE, useValue: 'root' },
  1101. { provide: ErrorHandler, useFactory: errorHandler, deps: [] }, {
  1102. provide: EVENT_MANAGER_PLUGINS,
  1103. useClass: DomEventsPlugin,
  1104. multi: true,
  1105. deps: [DOCUMENT, NgZone, PLATFORM_ID]
  1106. },
  1107. { provide: EVENT_MANAGER_PLUGINS, useClass: KeyEventsPlugin, multi: true, deps: [DOCUMENT] },
  1108. DomRendererFactory2, SharedStylesHost, EventManager,
  1109. { provide: RendererFactory2, useExisting: DomRendererFactory2 },
  1110. { provide: XhrFactory, useClass: BrowserXhr, deps: [] },
  1111. (typeof ngDevMode === 'undefined' || ngDevMode) ?
  1112. { provide: BROWSER_MODULE_PROVIDERS_MARKER, useValue: true } :
  1113. []
  1114. ];
  1115. /**
  1116. * Exports required infrastructure for all Angular apps.
  1117. * Included by default in all Angular apps created with the CLI
  1118. * `new` command.
  1119. * Re-exports `CommonModule` and `ApplicationModule`, making their
  1120. * exports and providers available to all apps.
  1121. *
  1122. * @publicApi
  1123. */
  1124. class BrowserModule {
  1125. constructor(providersAlreadyPresent) {
  1126. if ((typeof ngDevMode === 'undefined' || ngDevMode) && providersAlreadyPresent) {
  1127. throw new ɵRuntimeError(5100 /* RuntimeErrorCode.BROWER_MODULE_ALREADY_LOADED */, `Providers from the \`BrowserModule\` have already been loaded. If you need access ` +
  1128. `to common directives such as NgIf and NgFor, import the \`CommonModule\` instead.`);
  1129. }
  1130. }
  1131. /**
  1132. * Configures a browser-based app to transition from a server-rendered app, if
  1133. * one is present on the page.
  1134. *
  1135. * @param params An object containing an identifier for the app to transition.
  1136. * The ID must match between the client and server versions of the app.
  1137. * @returns The reconfigured `BrowserModule` to import into the app's root `AppModule`.
  1138. *
  1139. * @deprecated Use {@link APP_ID} instead to set the application ID.
  1140. */
  1141. static withServerTransition(params) {
  1142. return {
  1143. ngModule: BrowserModule,
  1144. providers: [
  1145. { provide: APP_ID, useValue: params.appId },
  1146. ],
  1147. };
  1148. }
  1149. static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.9", ngImport: i0, type: BrowserModule, deps: [{ token: BROWSER_MODULE_PROVIDERS_MARKER, optional: true, skipSelf: true }], target: i0.ɵɵFactoryTarget.NgModule }); }
  1150. static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "16.2.9", ngImport: i0, type: BrowserModule, exports: [CommonModule, ApplicationModule] }); }
  1151. static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "16.2.9", ngImport: i0, type: BrowserModule, providers: [...BROWSER_MODULE_PROVIDERS, ...TESTABILITY_PROVIDERS], imports: [CommonModule, ApplicationModule] }); }
  1152. }
  1153. i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.9", ngImport: i0, type: BrowserModule, decorators: [{
  1154. type: NgModule,
  1155. args: [{
  1156. providers: [...BROWSER_MODULE_PROVIDERS, ...TESTABILITY_PROVIDERS],
  1157. exports: [CommonModule, ApplicationModule],
  1158. }]
  1159. }], ctorParameters: function () { return [{ type: undefined, decorators: [{
  1160. type: Optional
  1161. }, {
  1162. type: SkipSelf
  1163. }, {
  1164. type: Inject,
  1165. args: [BROWSER_MODULE_PROVIDERS_MARKER]
  1166. }] }]; } });
  1167. /**
  1168. * Factory to create a `Meta` service instance for the current DOM document.
  1169. */
  1170. function createMeta() {
  1171. return new Meta(ɵɵinject(DOCUMENT));
  1172. }
  1173. /**
  1174. * A service for managing HTML `<meta>` tags.
  1175. *
  1176. * Properties of the `MetaDefinition` object match the attributes of the
  1177. * HTML `<meta>` tag. These tags define document metadata that is important for
  1178. * things like configuring a Content Security Policy, defining browser compatibility
  1179. * and security settings, setting HTTP Headers, defining rich content for social sharing,
  1180. * and Search Engine Optimization (SEO).
  1181. *
  1182. * To identify specific `<meta>` tags in a document, use an attribute selection
  1183. * string in the format `"tag_attribute='value string'"`.
  1184. * For example, an `attrSelector` value of `"name='description'"` matches a tag
  1185. * whose `name` attribute has the value `"description"`.
  1186. * Selectors are used with the `querySelector()` Document method,
  1187. * in the format `meta[{attrSelector}]`.
  1188. *
  1189. * @see [HTML meta tag](https://developer.mozilla.org/docs/Web/HTML/Element/meta)
  1190. * @see [Document.querySelector()](https://developer.mozilla.org/docs/Web/API/Document/querySelector)
  1191. *
  1192. *
  1193. * @publicApi
  1194. */
  1195. class Meta {
  1196. constructor(_doc) {
  1197. this._doc = _doc;
  1198. this._dom = ɵgetDOM();
  1199. }
  1200. /**
  1201. * Retrieves or creates a specific `<meta>` tag element in the current HTML document.
  1202. * In searching for an existing tag, Angular attempts to match the `name` or `property` attribute
  1203. * values in the provided tag definition, and verifies that all other attribute values are equal.
  1204. * If an existing element is found, it is returned and is not modified in any way.
  1205. * @param tag The definition of a `<meta>` element to match or create.
  1206. * @param forceCreation True to create a new element without checking whether one already exists.
  1207. * @returns The existing element with the same attributes and values if found,
  1208. * the new element if no match is found, or `null` if the tag parameter is not defined.
  1209. */
  1210. addTag(tag, forceCreation = false) {
  1211. if (!tag)
  1212. return null;
  1213. return this._getOrCreateElement(tag, forceCreation);
  1214. }
  1215. /**
  1216. * Retrieves or creates a set of `<meta>` tag elements in the current HTML document.
  1217. * In searching for an existing tag, Angular attempts to match the `name` or `property` attribute
  1218. * values in the provided tag definition, and verifies that all other attribute values are equal.
  1219. * @param tags An array of tag definitions to match or create.
  1220. * @param forceCreation True to create new elements without checking whether they already exist.
  1221. * @returns The matching elements if found, or the new elements.
  1222. */
  1223. addTags(tags, forceCreation = false) {
  1224. if (!tags)
  1225. return [];
  1226. return tags.reduce((result, tag) => {
  1227. if (tag) {
  1228. result.push(this._getOrCreateElement(tag, forceCreation));
  1229. }
  1230. return result;
  1231. }, []);
  1232. }
  1233. /**
  1234. * Retrieves a `<meta>` tag element in the current HTML document.
  1235. * @param attrSelector The tag attribute and value to match against, in the format
  1236. * `"tag_attribute='value string'"`.
  1237. * @returns The matching element, if any.
  1238. */
  1239. getTag(attrSelector) {
  1240. if (!attrSelector)
  1241. return null;
  1242. return this._doc.querySelector(`meta[${attrSelector}]`) || null;
  1243. }
  1244. /**
  1245. * Retrieves a set of `<meta>` tag elements in the current HTML document.
  1246. * @param attrSelector The tag attribute and value to match against, in the format
  1247. * `"tag_attribute='value string'"`.
  1248. * @returns The matching elements, if any.
  1249. */
  1250. getTags(attrSelector) {
  1251. if (!attrSelector)
  1252. return [];
  1253. const list /*NodeList*/ = this._doc.querySelectorAll(`meta[${attrSelector}]`);
  1254. return list ? [].slice.call(list) : [];
  1255. }
  1256. /**
  1257. * Modifies an existing `<meta>` tag element in the current HTML document.
  1258. * @param tag The tag description with which to replace the existing tag content.
  1259. * @param selector A tag attribute and value to match against, to identify
  1260. * an existing tag. A string in the format `"tag_attribute=`value string`"`.
  1261. * If not supplied, matches a tag with the same `name` or `property` attribute value as the
  1262. * replacement tag.
  1263. * @return The modified element.
  1264. */
  1265. updateTag(tag, selector) {
  1266. if (!tag)
  1267. return null;
  1268. selector = selector || this._parseSelector(tag);
  1269. const meta = this.getTag(selector);
  1270. if (meta) {
  1271. return this._setMetaElementAttributes(tag, meta);
  1272. }
  1273. return this._getOrCreateElement(tag, true);
  1274. }
  1275. /**
  1276. * Removes an existing `<meta>` tag element from the current HTML document.
  1277. * @param attrSelector A tag attribute and value to match against, to identify
  1278. * an existing tag. A string in the format `"tag_attribute=`value string`"`.
  1279. */
  1280. removeTag(attrSelector) {
  1281. this.removeTagElement(this.getTag(attrSelector));
  1282. }
  1283. /**
  1284. * Removes an existing `<meta>` tag element from the current HTML document.
  1285. * @param meta The tag definition to match against to identify an existing tag.
  1286. */
  1287. removeTagElement(meta) {
  1288. if (meta) {
  1289. this._dom.remove(meta);
  1290. }
  1291. }
  1292. _getOrCreateElement(meta, forceCreation = false) {
  1293. if (!forceCreation) {
  1294. const selector = this._parseSelector(meta);
  1295. // It's allowed to have multiple elements with the same name so it's not enough to
  1296. // just check that element with the same name already present on the page. We also need to
  1297. // check if element has tag attributes
  1298. const elem = this.getTags(selector).filter(elem => this._containsAttributes(meta, elem))[0];
  1299. if (elem !== undefined)
  1300. return elem;
  1301. }
  1302. const element = this._dom.createElement('meta');
  1303. this._setMetaElementAttributes(meta, element);
  1304. const head = this._doc.getElementsByTagName('head')[0];
  1305. head.appendChild(element);
  1306. return element;
  1307. }
  1308. _setMetaElementAttributes(tag, el) {
  1309. Object.keys(tag).forEach((prop) => el.setAttribute(this._getMetaKeyMap(prop), tag[prop]));
  1310. return el;
  1311. }
  1312. _parseSelector(tag) {
  1313. const attr = tag.name ? 'name' : 'property';
  1314. return `${attr}="${tag[attr]}"`;
  1315. }
  1316. _containsAttributes(tag, elem) {
  1317. return Object.keys(tag).every((key) => elem.getAttribute(this._getMetaKeyMap(key)) === tag[key]);
  1318. }
  1319. _getMetaKeyMap(prop) {
  1320. return META_KEYS_MAP[prop] || prop;
  1321. }
  1322. static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.9", ngImport: i0, type: Meta, deps: [{ token: DOCUMENT }], target: i0.ɵɵFactoryTarget.Injectable }); }
  1323. static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.2.9", ngImport: i0, type: Meta, providedIn: 'root', useFactory: createMeta, deps: [] }); }
  1324. }
  1325. i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.9", ngImport: i0, type: Meta, decorators: [{
  1326. type: Injectable,
  1327. args: [{ providedIn: 'root', useFactory: createMeta, deps: [] }]
  1328. }], ctorParameters: function () { return [{ type: undefined, decorators: [{
  1329. type: Inject,
  1330. args: [DOCUMENT]
  1331. }] }]; } });
  1332. /**
  1333. * Mapping for MetaDefinition properties with their correct meta attribute names
  1334. */
  1335. const META_KEYS_MAP = {
  1336. httpEquiv: 'http-equiv'
  1337. };
  1338. /**
  1339. * Factory to create Title service.
  1340. */
  1341. function createTitle() {
  1342. return new Title(ɵɵinject(DOCUMENT));
  1343. }
  1344. /**
  1345. * A service that can be used to get and set the title of a current HTML document.
  1346. *
  1347. * Since an Angular application can't be bootstrapped on the entire HTML document (`<html>` tag)
  1348. * it is not possible to bind to the `text` property of the `HTMLTitleElement` elements
  1349. * (representing the `<title>` tag). Instead, this service can be used to set and get the current
  1350. * title value.
  1351. *
  1352. * @publicApi
  1353. */
  1354. class Title {
  1355. constructor(_doc) {
  1356. this._doc = _doc;
  1357. }
  1358. /**
  1359. * Get the title of the current HTML document.
  1360. */
  1361. getTitle() {
  1362. return this._doc.title;
  1363. }
  1364. /**
  1365. * Set the title of the current HTML document.
  1366. * @param newTitle
  1367. */
  1368. setTitle(newTitle) {
  1369. this._doc.title = newTitle || '';
  1370. }
  1371. static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.9", ngImport: i0, type: Title, deps: [{ token: DOCUMENT }], target: i0.ɵɵFactoryTarget.Injectable }); }
  1372. static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.2.9", ngImport: i0, type: Title, providedIn: 'root', useFactory: createTitle, deps: [] }); }
  1373. }
  1374. i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.9", ngImport: i0, type: Title, decorators: [{
  1375. type: Injectable,
  1376. args: [{ providedIn: 'root', useFactory: createTitle, deps: [] }]
  1377. }], ctorParameters: function () { return [{ type: undefined, decorators: [{
  1378. type: Inject,
  1379. args: [DOCUMENT]
  1380. }] }]; } });
  1381. /**
  1382. * Exports the value under a given `name` in the global property `ng`. For example `ng.probe` if
  1383. * `name` is `'probe'`.
  1384. * @param name Name under which it will be exported. Keep in mind this will be a property of the
  1385. * global `ng` object.
  1386. * @param value The value to export.
  1387. */
  1388. function exportNgVar(name, value) {
  1389. if (typeof COMPILED === 'undefined' || !COMPILED) {
  1390. // Note: we can't export `ng` when using closure enhanced optimization as:
  1391. // - closure declares globals itself for minified names, which sometimes clobber our `ng` global
  1392. // - we can't declare a closure extern as the namespace `ng` is already used within Google
  1393. // for typings for angularJS (via `goog.provide('ng....')`).
  1394. const ng = ɵglobal['ng'] = ɵglobal['ng'] || {};
  1395. ng[name] = value;
  1396. }
  1397. }
  1398. const win = typeof window !== 'undefined' && window || {};
  1399. class ChangeDetectionPerfRecord {
  1400. constructor(msPerTick, numTicks) {
  1401. this.msPerTick = msPerTick;
  1402. this.numTicks = numTicks;
  1403. }
  1404. }
  1405. /**
  1406. * Entry point for all Angular profiling-related debug tools. This object
  1407. * corresponds to the `ng.profiler` in the dev console.
  1408. */
  1409. class AngularProfiler {
  1410. constructor(ref) {
  1411. this.appRef = ref.injector.get(ApplicationRef);
  1412. }
  1413. // tslint:disable:no-console
  1414. /**
  1415. * Exercises change detection in a loop and then prints the average amount of
  1416. * time in milliseconds how long a single round of change detection takes for
  1417. * the current state of the UI. It runs a minimum of 5 rounds for a minimum
  1418. * of 500 milliseconds.
  1419. *
  1420. * Optionally, a user may pass a `config` parameter containing a map of
  1421. * options. Supported options are:
  1422. *
  1423. * `record` (boolean) - causes the profiler to record a CPU profile while
  1424. * it exercises the change detector. Example:
  1425. *
  1426. * ```
  1427. * ng.profiler.timeChangeDetection({record: true})
  1428. * ```
  1429. */
  1430. timeChangeDetection(config) {
  1431. const record = config && config['record'];
  1432. const profileName = 'Change Detection';
  1433. // Profiler is not available in Android browsers without dev tools opened
  1434. const isProfilerAvailable = win.console.profile != null;
  1435. if (record && isProfilerAvailable) {
  1436. win.console.profile(profileName);
  1437. }
  1438. const start = performanceNow();
  1439. let numTicks = 0;
  1440. while (numTicks < 5 || (performanceNow() - start) < 500) {
  1441. this.appRef.tick();
  1442. numTicks++;
  1443. }
  1444. const end = performanceNow();
  1445. if (record && isProfilerAvailable) {
  1446. win.console.profileEnd(profileName);
  1447. }
  1448. const msPerTick = (end - start) / numTicks;
  1449. win.console.log(`ran ${numTicks} change detection cycles`);
  1450. win.console.log(`${msPerTick.toFixed(2)} ms per check`);
  1451. return new ChangeDetectionPerfRecord(msPerTick, numTicks);
  1452. }
  1453. }
  1454. function performanceNow() {
  1455. return win.performance && win.performance.now ? win.performance.now() :
  1456. new Date().getTime();
  1457. }
  1458. const PROFILER_GLOBAL_NAME = 'profiler';
  1459. /**
  1460. * Enabled Angular debug tools that are accessible via your browser's
  1461. * developer console.
  1462. *
  1463. * Usage:
  1464. *
  1465. * 1. Open developer console (e.g. in Chrome Ctrl + Shift + j)
  1466. * 1. Type `ng.` (usually the console will show auto-complete suggestion)
  1467. * 1. Try the change detection profiler `ng.profiler.timeChangeDetection()`
  1468. * then hit Enter.
  1469. *
  1470. * @publicApi
  1471. */
  1472. function enableDebugTools(ref) {
  1473. exportNgVar(PROFILER_GLOBAL_NAME, new AngularProfiler(ref));
  1474. return ref;
  1475. }
  1476. /**
  1477. * Disables Angular tools.
  1478. *
  1479. * @publicApi
  1480. */
  1481. function disableDebugTools() {
  1482. exportNgVar(PROFILER_GLOBAL_NAME, null);
  1483. }
  1484. /**
  1485. * Predicates for use with {@link DebugElement}'s query functions.
  1486. *
  1487. * @publicApi
  1488. */
  1489. class By {
  1490. /**
  1491. * Match all nodes.
  1492. *
  1493. * @usageNotes
  1494. * ### Example
  1495. *
  1496. * {@example platform-browser/dom/debug/ts/by/by.ts region='by_all'}
  1497. */
  1498. static all() {
  1499. return () => true;
  1500. }
  1501. /**
  1502. * Match elements by the given CSS selector.
  1503. *
  1504. * @usageNotes
  1505. * ### Example
  1506. *
  1507. * {@example platform-browser/dom/debug/ts/by/by.ts region='by_css'}
  1508. */
  1509. static css(selector) {
  1510. return (debugElement) => {
  1511. return debugElement.nativeElement != null ?
  1512. elementMatches(debugElement.nativeElement, selector) :
  1513. false;
  1514. };
  1515. }
  1516. /**
  1517. * Match nodes that have the given directive present.
  1518. *
  1519. * @usageNotes
  1520. * ### Example
  1521. *
  1522. * {@example platform-browser/dom/debug/ts/by/by.ts region='by_directive'}
  1523. */
  1524. static directive(type) {
  1525. return (debugNode) => debugNode.providerTokens.indexOf(type) !== -1;
  1526. }
  1527. }
  1528. function elementMatches(n, selector) {
  1529. if (ɵgetDOM().isElementNode(n)) {
  1530. return n.matches && n.matches(selector) ||
  1531. n.msMatchesSelector && n.msMatchesSelector(selector) ||
  1532. n.webkitMatchesSelector && n.webkitMatchesSelector(selector);
  1533. }
  1534. return false;
  1535. }
  1536. /**
  1537. * Supported HammerJS recognizer event names.
  1538. */
  1539. const EVENT_NAMES = {
  1540. // pan
  1541. 'pan': true,
  1542. 'panstart': true,
  1543. 'panmove': true,
  1544. 'panend': true,
  1545. 'pancancel': true,
  1546. 'panleft': true,
  1547. 'panright': true,
  1548. 'panup': true,
  1549. 'pandown': true,
  1550. // pinch
  1551. 'pinch': true,
  1552. 'pinchstart': true,
  1553. 'pinchmove': true,
  1554. 'pinchend': true,
  1555. 'pinchcancel': true,
  1556. 'pinchin': true,
  1557. 'pinchout': true,
  1558. // press
  1559. 'press': true,
  1560. 'pressup': true,
  1561. // rotate
  1562. 'rotate': true,
  1563. 'rotatestart': true,
  1564. 'rotatemove': true,
  1565. 'rotateend': true,
  1566. 'rotatecancel': true,
  1567. // swipe
  1568. 'swipe': true,
  1569. 'swipeleft': true,
  1570. 'swiperight': true,
  1571. 'swipeup': true,
  1572. 'swipedown': true,
  1573. // tap
  1574. 'tap': true,
  1575. 'doubletap': true
  1576. };
  1577. /**
  1578. * DI token for providing [HammerJS](https://hammerjs.github.io/) support to Angular.
  1579. * @see {@link HammerGestureConfig}
  1580. *
  1581. * @ngModule HammerModule
  1582. * @publicApi
  1583. */
  1584. const HAMMER_GESTURE_CONFIG = new InjectionToken('HammerGestureConfig');
  1585. /**
  1586. * Injection token used to provide a {@link HammerLoader} to Angular.
  1587. *
  1588. * @publicApi
  1589. */
  1590. const HAMMER_LOADER = new InjectionToken('HammerLoader');
  1591. /**
  1592. * An injectable [HammerJS Manager](https://hammerjs.github.io/api/#hammermanager)
  1593. * for gesture recognition. Configures specific event recognition.
  1594. * @publicApi
  1595. */
  1596. class HammerGestureConfig {
  1597. constructor() {
  1598. /**
  1599. * A set of supported event names for gestures to be used in Angular.
  1600. * Angular supports all built-in recognizers, as listed in
  1601. * [HammerJS documentation](https://hammerjs.github.io/).
  1602. */
  1603. this.events = [];
  1604. /**
  1605. * Maps gesture event names to a set of configuration options
  1606. * that specify overrides to the default values for specific properties.
  1607. *
  1608. * The key is a supported event name to be configured,
  1609. * and the options object contains a set of properties, with override values
  1610. * to be applied to the named recognizer event.
  1611. * For example, to disable recognition of the rotate event, specify
  1612. * `{"rotate": {"enable": false}}`.
  1613. *
  1614. * Properties that are not present take the HammerJS default values.
  1615. * For information about which properties are supported for which events,
  1616. * and their allowed and default values, see
  1617. * [HammerJS documentation](https://hammerjs.github.io/).
  1618. *
  1619. */
  1620. this.overrides = {};
  1621. }
  1622. /**
  1623. * Creates a [HammerJS Manager](https://hammerjs.github.io/api/#hammermanager)
  1624. * and attaches it to a given HTML element.
  1625. * @param element The element that will recognize gestures.
  1626. * @returns A HammerJS event-manager object.
  1627. */
  1628. buildHammer(element) {
  1629. const mc = new Hammer(element, this.options);
  1630. mc.get('pinch').set({ enable: true });
  1631. mc.get('rotate').set({ enable: true });
  1632. for (const eventName in this.overrides) {
  1633. mc.get(eventName).set(this.overrides[eventName]);
  1634. }
  1635. return mc;
  1636. }
  1637. static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.9", ngImport: i0, type: HammerGestureConfig, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
  1638. static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.2.9", ngImport: i0, type: HammerGestureConfig }); }
  1639. }
  1640. i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.9", ngImport: i0, type: HammerGestureConfig, decorators: [{
  1641. type: Injectable
  1642. }] });
  1643. /**
  1644. * Event plugin that adds Hammer support to an application.
  1645. *
  1646. * @ngModule HammerModule
  1647. */
  1648. class HammerGesturesPlugin extends EventManagerPlugin {
  1649. constructor(doc, _config, console, loader) {
  1650. super(doc);
  1651. this._config = _config;
  1652. this.console = console;
  1653. this.loader = loader;
  1654. this._loaderPromise = null;
  1655. }
  1656. supports(eventName) {
  1657. if (!EVENT_NAMES.hasOwnProperty(eventName.toLowerCase()) && !this.isCustomEvent(eventName)) {
  1658. return false;
  1659. }
  1660. if (!window.Hammer && !this.loader) {
  1661. if (typeof ngDevMode === 'undefined' || ngDevMode) {
  1662. this.console.warn(`The "${eventName}" event cannot be bound because Hammer.JS is not ` +
  1663. `loaded and no custom loader has been specified.`);
  1664. }
  1665. return false;
  1666. }
  1667. return true;
  1668. }
  1669. addEventListener(element, eventName, handler) {
  1670. const zone = this.manager.getZone();
  1671. eventName = eventName.toLowerCase();
  1672. // If Hammer is not present but a loader is specified, we defer adding the event listener
  1673. // until Hammer is loaded.
  1674. if (!window.Hammer && this.loader) {
  1675. this._loaderPromise = this._loaderPromise || zone.runOutsideAngular(() => this.loader());
  1676. // This `addEventListener` method returns a function to remove the added listener.
  1677. // Until Hammer is loaded, the returned function needs to *cancel* the registration rather
  1678. // than remove anything.
  1679. let cancelRegistration = false;
  1680. let deregister = () => {
  1681. cancelRegistration = true;
  1682. };
  1683. zone.runOutsideAngular(() => this._loaderPromise
  1684. .then(() => {
  1685. // If Hammer isn't actually loaded when the custom loader resolves, give up.
  1686. if (!window.Hammer) {
  1687. if (typeof ngDevMode === 'undefined' || ngDevMode) {
  1688. this.console.warn(`The custom HAMMER_LOADER completed, but Hammer.JS is not present.`);
  1689. }
  1690. deregister = () => { };
  1691. return;
  1692. }
  1693. if (!cancelRegistration) {
  1694. // Now that Hammer is loaded and the listener is being loaded for real,
  1695. // the deregistration function changes from canceling registration to
  1696. // removal.
  1697. deregister = this.addEventListener(element, eventName, handler);
  1698. }
  1699. })
  1700. .catch(() => {
  1701. if (typeof ngDevMode === 'undefined' || ngDevMode) {
  1702. this.console.warn(`The "${eventName}" event cannot be bound because the custom ` +
  1703. `Hammer.JS loader failed.`);
  1704. }
  1705. deregister = () => { };
  1706. }));
  1707. // Return a function that *executes* `deregister` (and not `deregister` itself) so that we
  1708. // can change the behavior of `deregister` once the listener is added. Using a closure in
  1709. // this way allows us to avoid any additional data structures to track listener removal.
  1710. return () => {
  1711. deregister();
  1712. };
  1713. }
  1714. return zone.runOutsideAngular(() => {
  1715. // Creating the manager bind events, must be done outside of angular
  1716. const mc = this._config.buildHammer(element);
  1717. const callback = function (eventObj) {
  1718. zone.runGuarded(function () {
  1719. handler(eventObj);
  1720. });
  1721. };
  1722. mc.on(eventName, callback);
  1723. return () => {
  1724. mc.off(eventName, callback);
  1725. // destroy mc to prevent memory leak
  1726. if (typeof mc.destroy === 'function') {
  1727. mc.destroy();
  1728. }
  1729. };
  1730. });
  1731. }
  1732. isCustomEvent(eventName) {
  1733. return this._config.events.indexOf(eventName) > -1;
  1734. }
  1735. static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.9", ngImport: i0, type: HammerGesturesPlugin, deps: [{ token: DOCUMENT }, { token: HAMMER_GESTURE_CONFIG }, { token: i0.ɵConsole }, { token: HAMMER_LOADER, optional: true }], target: i0.ɵɵFactoryTarget.Injectable }); }
  1736. static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.2.9", ngImport: i0, type: HammerGesturesPlugin }); }
  1737. }
  1738. i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.9", ngImport: i0, type: HammerGesturesPlugin, decorators: [{
  1739. type: Injectable
  1740. }], ctorParameters: function () { return [{ type: undefined, decorators: [{
  1741. type: Inject,
  1742. args: [DOCUMENT]
  1743. }] }, { type: HammerGestureConfig, decorators: [{
  1744. type: Inject,
  1745. args: [HAMMER_GESTURE_CONFIG]
  1746. }] }, { type: i0.ɵConsole }, { type: undefined, decorators: [{
  1747. type: Optional
  1748. }, {
  1749. type: Inject,
  1750. args: [HAMMER_LOADER]
  1751. }] }]; } });
  1752. /**
  1753. * Adds support for HammerJS.
  1754. *
  1755. * Import this module at the root of your application so that Angular can work with
  1756. * HammerJS to detect gesture events.
  1757. *
  1758. * Note that applications still need to include the HammerJS script itself. This module
  1759. * simply sets up the coordination layer between HammerJS and Angular's EventManager.
  1760. *
  1761. * @publicApi
  1762. */
  1763. class HammerModule {
  1764. static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.9", ngImport: i0, type: HammerModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
  1765. static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "16.2.9", ngImport: i0, type: HammerModule }); }
  1766. static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "16.2.9", ngImport: i0, type: HammerModule, providers: [
  1767. {
  1768. provide: EVENT_MANAGER_PLUGINS,
  1769. useClass: HammerGesturesPlugin,
  1770. multi: true,
  1771. deps: [DOCUMENT, HAMMER_GESTURE_CONFIG, ɵConsole, [new Optional(), HAMMER_LOADER]]
  1772. },
  1773. { provide: HAMMER_GESTURE_CONFIG, useClass: HammerGestureConfig, deps: [] },
  1774. ] }); }
  1775. }
  1776. i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.9", ngImport: i0, type: HammerModule, decorators: [{
  1777. type: NgModule,
  1778. args: [{
  1779. providers: [
  1780. {
  1781. provide: EVENT_MANAGER_PLUGINS,
  1782. useClass: HammerGesturesPlugin,
  1783. multi: true,
  1784. deps: [DOCUMENT, HAMMER_GESTURE_CONFIG, ɵConsole, [new Optional(), HAMMER_LOADER]]
  1785. },
  1786. { provide: HAMMER_GESTURE_CONFIG, useClass: HammerGestureConfig, deps: [] },
  1787. ]
  1788. }]
  1789. }] });
  1790. /**
  1791. * DomSanitizer helps preventing Cross Site Scripting Security bugs (XSS) by sanitizing
  1792. * values to be safe to use in the different DOM contexts.
  1793. *
  1794. * For example, when binding a URL in an `<a [href]="someValue">` hyperlink, `someValue` will be
  1795. * sanitized so that an attacker cannot inject e.g. a `javascript:` URL that would execute code on
  1796. * the website.
  1797. *
  1798. * In specific situations, it might be necessary to disable sanitization, for example if the
  1799. * application genuinely needs to produce a `javascript:` style link with a dynamic value in it.
  1800. * Users can bypass security by constructing a value with one of the `bypassSecurityTrust...`
  1801. * methods, and then binding to that value from the template.
  1802. *
  1803. * These situations should be very rare, and extraordinary care must be taken to avoid creating a
  1804. * Cross Site Scripting (XSS) security bug!
  1805. *
  1806. * When using `bypassSecurityTrust...`, make sure to call the method as early as possible and as
  1807. * close as possible to the source of the value, to make it easy to verify no security bug is
  1808. * created by its use.
  1809. *
  1810. * It is not required (and not recommended) to bypass security if the value is safe, e.g. a URL that
  1811. * does not start with a suspicious protocol, or an HTML snippet that does not contain dangerous
  1812. * code. The sanitizer leaves safe values intact.
  1813. *
  1814. * @security Calling any of the `bypassSecurityTrust...` APIs disables Angular's built-in
  1815. * sanitization for the value passed in. Carefully check and audit all values and code paths going
  1816. * into this call. Make sure any user data is appropriately escaped for this security context.
  1817. * For more detail, see the [Security Guide](https://g.co/ng/security).
  1818. *
  1819. * @publicApi
  1820. */
  1821. class DomSanitizer {
  1822. static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.9", ngImport: i0, type: DomSanitizer, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
  1823. static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.2.9", ngImport: i0, type: DomSanitizer, providedIn: 'root', useExisting: i0.forwardRef(function () { return DomSanitizerImpl; }) }); }
  1824. }
  1825. i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.9", ngImport: i0, type: DomSanitizer, decorators: [{
  1826. type: Injectable,
  1827. args: [{ providedIn: 'root', useExisting: forwardRef(() => DomSanitizerImpl) }]
  1828. }] });
  1829. function domSanitizerImplFactory(injector) {
  1830. return new DomSanitizerImpl(injector.get(DOCUMENT));
  1831. }
  1832. class DomSanitizerImpl extends DomSanitizer {
  1833. constructor(_doc) {
  1834. super();
  1835. this._doc = _doc;
  1836. }
  1837. sanitize(ctx, value) {
  1838. if (value == null)
  1839. return null;
  1840. switch (ctx) {
  1841. case SecurityContext.NONE:
  1842. return value;
  1843. case SecurityContext.HTML:
  1844. if (ɵallowSanitizationBypassAndThrow(value, "HTML" /* BypassType.Html */)) {
  1845. return ɵunwrapSafeValue(value);
  1846. }
  1847. return ɵ_sanitizeHtml(this._doc, String(value)).toString();
  1848. case SecurityContext.STYLE:
  1849. if (ɵallowSanitizationBypassAndThrow(value, "Style" /* BypassType.Style */)) {
  1850. return ɵunwrapSafeValue(value);
  1851. }
  1852. return value;
  1853. case SecurityContext.SCRIPT:
  1854. if (ɵallowSanitizationBypassAndThrow(value, "Script" /* BypassType.Script */)) {
  1855. return ɵunwrapSafeValue(value);
  1856. }
  1857. throw new ɵRuntimeError(5200 /* RuntimeErrorCode.SANITIZATION_UNSAFE_SCRIPT */, (typeof ngDevMode === 'undefined' || ngDevMode) &&
  1858. 'unsafe value used in a script context');
  1859. case SecurityContext.URL:
  1860. if (ɵallowSanitizationBypassAndThrow(value, "URL" /* BypassType.Url */)) {
  1861. return ɵunwrapSafeValue(value);
  1862. }
  1863. return ɵ_sanitizeUrl(String(value));
  1864. case SecurityContext.RESOURCE_URL:
  1865. if (ɵallowSanitizationBypassAndThrow(value, "ResourceURL" /* BypassType.ResourceUrl */)) {
  1866. return ɵunwrapSafeValue(value);
  1867. }
  1868. throw new ɵRuntimeError(5201 /* RuntimeErrorCode.SANITIZATION_UNSAFE_RESOURCE_URL */, (typeof ngDevMode === 'undefined' || ngDevMode) &&
  1869. `unsafe value used in a resource URL context (see ${ɵXSS_SECURITY_URL})`);
  1870. default:
  1871. throw new ɵRuntimeError(5202 /* RuntimeErrorCode.SANITIZATION_UNEXPECTED_CTX */, (typeof ngDevMode === 'undefined' || ngDevMode) &&
  1872. `Unexpected SecurityContext ${ctx} (see ${ɵXSS_SECURITY_URL})`);
  1873. }
  1874. }
  1875. bypassSecurityTrustHtml(value) {
  1876. return ɵbypassSanitizationTrustHtml(value);
  1877. }
  1878. bypassSecurityTrustStyle(value) {
  1879. return ɵbypassSanitizationTrustStyle(value);
  1880. }
  1881. bypassSecurityTrustScript(value) {
  1882. return ɵbypassSanitizationTrustScript(value);
  1883. }
  1884. bypassSecurityTrustUrl(value) {
  1885. return ɵbypassSanitizationTrustUrl(value);
  1886. }
  1887. bypassSecurityTrustResourceUrl(value) {
  1888. return ɵbypassSanitizationTrustResourceUrl(value);
  1889. }
  1890. static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.9", ngImport: i0, type: DomSanitizerImpl, deps: [{ token: DOCUMENT }], target: i0.ɵɵFactoryTarget.Injectable }); }
  1891. static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.2.9", ngImport: i0, type: DomSanitizerImpl, providedIn: 'root', useFactory: domSanitizerImplFactory, deps: [{ token: Injector }] }); }
  1892. }
  1893. i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.9", ngImport: i0, type: DomSanitizerImpl, decorators: [{
  1894. type: Injectable,
  1895. args: [{ providedIn: 'root', useFactory: domSanitizerImplFactory, deps: [Injector] }]
  1896. }], ctorParameters: function () { return [{ type: undefined, decorators: [{
  1897. type: Inject,
  1898. args: [DOCUMENT]
  1899. }] }]; } });
  1900. /**
  1901. * Helper function to create an object that represents a Hydration feature.
  1902. */
  1903. function hydrationFeature(kind, providers = []) {
  1904. return { ɵkind: kind, ɵproviders: providers };
  1905. }
  1906. /**
  1907. * Disables DOM nodes reuse during hydration. Effectively makes
  1908. * Angular re-render an application from scratch on the client.
  1909. *
  1910. * When this option is enabled, make sure that the initial navigation
  1911. * option is configured for the Router as `enabledBlocking` by using the
  1912. * `withEnabledBlockingInitialNavigation` in the `provideRouter` call:
  1913. *
  1914. * ```
  1915. * bootstrapApplication(RootComponent, {
  1916. * providers: [
  1917. * provideRouter(
  1918. * // ... other features ...
  1919. * withEnabledBlockingInitialNavigation()
  1920. * ),
  1921. * provideClientHydration(withNoDomReuse())
  1922. * ]
  1923. * });
  1924. * ```
  1925. *
  1926. * This would ensure that the application is rerendered after all async
  1927. * operations in the Router (such as lazy-loading of components,
  1928. * waiting for async guards and resolvers) are completed to avoid
  1929. * clearing the DOM on the client too soon, thus causing content flicker.
  1930. *
  1931. * @see {@link provideRouter}
  1932. * @see {@link withEnabledBlockingInitialNavigation}
  1933. *
  1934. * @publicApi
  1935. * @developerPreview
  1936. */
  1937. function withNoDomReuse() {
  1938. // This feature has no providers and acts as a flag that turns off
  1939. // non-destructive hydration (which otherwise is turned on by default).
  1940. return hydrationFeature(0 /* HydrationFeatureKind.NoDomReuseFeature */);
  1941. }
  1942. /**
  1943. * Disables HTTP transfer cache. Effectively causes HTTP requests to be performed twice: once on the
  1944. * server and other one on the browser.
  1945. *
  1946. * @publicApi
  1947. * @developerPreview
  1948. */
  1949. function withNoHttpTransferCache() {
  1950. // This feature has no providers and acts as a flag that turns off
  1951. // HTTP transfer cache (which otherwise is turned on by default).
  1952. return hydrationFeature(1 /* HydrationFeatureKind.NoHttpTransferCache */);
  1953. }
  1954. /**
  1955. * Returns an `ENVIRONMENT_INITIALIZER` token setup with a function
  1956. * that verifies whether compatible ZoneJS was used in an application
  1957. * and logs a warning in a console if it's not the case.
  1958. */
  1959. function provideZoneJsCompatibilityDetector() {
  1960. return [{
  1961. provide: ENVIRONMENT_INITIALIZER,
  1962. useValue: () => {
  1963. const ngZone = inject(NgZone);
  1964. // Checking `ngZone instanceof NgZone` would be insufficient here,
  1965. // because custom implementations might use NgZone as a base class.
  1966. if (ngZone.constructor !== NgZone) {
  1967. const console = inject(ɵConsole);
  1968. const message = ɵformatRuntimeError(-5000 /* RuntimeErrorCode.UNSUPPORTED_ZONEJS_INSTANCE */, 'Angular detected that hydration was enabled for an application ' +
  1969. 'that uses a custom or a noop Zone.js implementation. ' +
  1970. 'This is not yet a fully supported configuration.');
  1971. // tslint:disable-next-line:no-console
  1972. console.warn(message);
  1973. }
  1974. },
  1975. multi: true,
  1976. }];
  1977. }
  1978. /**
  1979. * Sets up providers necessary to enable hydration functionality for the application.
  1980. *
  1981. * By default, the function enables the recommended set of features for the optimal
  1982. * performance for most of the applications. You can enable/disable features by
  1983. * passing special functions (from the `HydrationFeatures` set) as arguments to the
  1984. * `provideClientHydration` function. It includes the following features:
  1985. *
  1986. * * Reconciling DOM hydration. Learn more about it [here](guide/hydration).
  1987. * * [`HttpClient`](api/common/http/HttpClient) response caching while running on the server and
  1988. * transferring this cache to the client to avoid extra HTTP requests. Learn more about data caching
  1989. * [here](/guide/universal#caching-data-when-using-httpclient).
  1990. *
  1991. * These functions functions will allow you to disable some of the default features:
  1992. * * {@link withNoDomReuse} to disable DOM nodes reuse during hydration
  1993. * * {@link withNoHttpTransferCache} to disable HTTP transfer cache
  1994. *
  1995. *
  1996. * @usageNotes
  1997. *
  1998. * Basic example of how you can enable hydration in your application when
  1999. * `bootstrapApplication` function is used:
  2000. * ```
  2001. * bootstrapApplication(AppComponent, {
  2002. * providers: [provideClientHydration()]
  2003. * });
  2004. * ```
  2005. *
  2006. * Alternatively if you are using NgModules, you would add `provideClientHydration`
  2007. * to your root app module's provider list.
  2008. * ```
  2009. * @NgModule({
  2010. * declarations: [RootCmp],
  2011. * bootstrap: [RootCmp],
  2012. * providers: [provideClientHydration()],
  2013. * })
  2014. * export class AppModule {}
  2015. * ```
  2016. *
  2017. * @see {@link withNoDomReuse}
  2018. * @see {@link withNoHttpTransferCache}
  2019. *
  2020. * @param features Optional features to configure additional router behaviors.
  2021. * @returns A set of providers to enable hydration.
  2022. *
  2023. * @publicApi
  2024. * @developerPreview
  2025. */
  2026. function provideClientHydration(...features) {
  2027. const providers = [];
  2028. const featuresKind = new Set();
  2029. for (const { ɵproviders, ɵkind } of features) {
  2030. featuresKind.add(ɵkind);
  2031. if (ɵproviders.length) {
  2032. providers.push(ɵproviders);
  2033. }
  2034. }
  2035. return makeEnvironmentProviders([
  2036. (typeof ngDevMode !== 'undefined' && ngDevMode) ? provideZoneJsCompatibilityDetector() : [],
  2037. (featuresKind.has(0 /* HydrationFeatureKind.NoDomReuseFeature */) ? [] : ɵwithDomHydration()),
  2038. (featuresKind.has(1 /* HydrationFeatureKind.NoHttpTransferCache */) ? [] : ɵwithHttpTransferCache()),
  2039. providers,
  2040. ]);
  2041. }
  2042. /**
  2043. * @module
  2044. * @description
  2045. * Entry point for all public APIs of the platform-browser package.
  2046. */
  2047. /**
  2048. * @publicApi
  2049. */
  2050. const VERSION = new Version('16.2.9');
  2051. // Re-export TransferState to the public API of the `platform-browser` for backwards-compatibility.
  2052. /**
  2053. * Create a `StateKey<T>` that can be used to store value of type T with `TransferState`.
  2054. *
  2055. * Example:
  2056. *
  2057. * ```
  2058. * const COUNTER_KEY = makeStateKey<number>('counter');
  2059. * let value = 10;
  2060. *
  2061. * transferState.set(COUNTER_KEY, value);
  2062. * ```
  2063. *
  2064. * @publicApi
  2065. * @deprecated `makeStateKey` has moved, please import `makeStateKey` from `@angular/core` instead.
  2066. */
  2067. // The below is a workaround to add a deprecated message.
  2068. const makeStateKey = makeStateKey$1;
  2069. // The below type is needed for G3 due to JSC_CONFORMANCE_VIOLATION.
  2070. const TransferState = TransferState$1;
  2071. /**
  2072. * @module
  2073. * @description
  2074. * Entry point for all public APIs of this package.
  2075. */
  2076. // This file only reexports content of the `src` folder. Keep it that way.
  2077. // This file is not used to build this module. It is only used during editing
  2078. /**
  2079. * Generated bundle index. Do not edit.
  2080. */
  2081. export { BrowserModule, By, DomSanitizer, EVENT_MANAGER_PLUGINS, EventManager, HAMMER_GESTURE_CONFIG, HAMMER_LOADER, HammerGestureConfig, HammerModule, Meta, REMOVE_STYLES_ON_COMPONENT_DESTROY, Title, TransferState, VERSION, bootstrapApplication, createApplication, disableDebugTools, enableDebugTools, makeStateKey, platformBrowser, provideClientHydration, provideProtractorTestingSupport, withNoDomReuse, withNoHttpTransferCache, BrowserDomAdapter as ɵBrowserDomAdapter, BrowserGetTestability as ɵBrowserGetTestability, DomEventsPlugin as ɵDomEventsPlugin, DomRendererFactory2 as ɵDomRendererFactory2, DomSanitizerImpl as ɵDomSanitizerImpl, HammerGesturesPlugin as ɵHammerGesturesPlugin, INTERNAL_BROWSER_PLATFORM_PROVIDERS as ɵINTERNAL_BROWSER_PLATFORM_PROVIDERS, KeyEventsPlugin as ɵKeyEventsPlugin, SharedStylesHost as ɵSharedStylesHost, initDomAdapter as ɵinitDomAdapter };
  2082. //# sourceMappingURL=platform-browser.mjs.map