@angular/platform-browser 16.0.0-next.3 → 16.0.0-next.5

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