@angular/platform-browser 21.0.0-next.9 → 21.0.0-rc.1

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.
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license Angular v21.0.0-next.9
2
+ * @license Angular v21.0.0-rc.1
3
3
  * (c) 2010-2025 Google LLC. https://angular.dev/
4
4
  * License: MIT
5
5
  */
@@ -9,530 +9,416 @@ import * as i0 from '@angular/core';
9
9
  import { ɵglobal as _global, ɵRuntimeError as _RuntimeError, Injectable, Inject, ɵresolveComponentResources as _resolveComponentResources, ɵinternalCreateApplication as _internalCreateApplication, PLATFORM_ID, PLATFORM_INITIALIZER, createPlatformFactory, platformCore, InjectionToken, ɵTESTABILITY_GETTER as _TESTABILITY_GETTER, ɵTESTABILITY as _TESTABILITY, Testability, ɵINJECTOR_SCOPE as _INJECTOR_SCOPE, ErrorHandler, RendererFactory2, inject, ApplicationModule, NgModule, ɵsetDocument as _setDocument } from '@angular/core';
10
10
  import { EventManagerPlugin, EVENT_MANAGER_PLUGINS, DomEventsPlugin, DomRendererFactory2, SharedStylesHost, EventManager } from './_dom_renderer-chunk.mjs';
11
11
 
12
- /**
13
- * A `DomAdapter` powered by full browser DOM APIs.
14
- *
15
- * @security Tread carefully! Interacting with the DOM directly is dangerous and
16
- * can introduce XSS risks.
17
- */
18
12
  class BrowserDomAdapter extends _DomAdapter {
19
- supportsDOMEvents = true;
20
- static makeCurrent() {
21
- _setRootDomAdapter(new BrowserDomAdapter());
22
- }
23
- onAndCancel(el, evt, listener, options) {
24
- el.addEventListener(evt, listener, options);
25
- return () => {
26
- el.removeEventListener(evt, listener, options);
27
- };
28
- }
29
- dispatchEvent(el, evt) {
30
- el.dispatchEvent(evt);
31
- }
32
- remove(node) {
33
- node.remove();
34
- }
35
- createElement(tagName, doc) {
36
- doc = doc || this.getDefaultDocument();
37
- return doc.createElement(tagName);
38
- }
39
- createHtmlDocument() {
40
- return document.implementation.createHTMLDocument('fakeTitle');
41
- }
42
- getDefaultDocument() {
43
- return document;
44
- }
45
- isElementNode(node) {
46
- return node.nodeType === Node.ELEMENT_NODE;
47
- }
48
- isShadowRoot(node) {
49
- return node instanceof DocumentFragment;
50
- }
51
- /** @deprecated No longer being used in Ivy code. To be removed in version 14. */
52
- getGlobalEventTarget(doc, target) {
53
- if (target === 'window') {
54
- return window;
55
- }
56
- if (target === 'document') {
57
- return doc;
58
- }
59
- if (target === 'body') {
60
- return doc.body;
61
- }
62
- return null;
63
- }
64
- getBaseHref(doc) {
65
- const href = getBaseElementHref();
66
- return href == null ? null : relativePath(href);
67
- }
68
- resetBaseElement() {
69
- baseElement = null;
13
+ supportsDOMEvents = true;
14
+ static makeCurrent() {
15
+ _setRootDomAdapter(new BrowserDomAdapter());
16
+ }
17
+ onAndCancel(el, evt, listener, options) {
18
+ el.addEventListener(evt, listener, options);
19
+ return () => {
20
+ el.removeEventListener(evt, listener, options);
21
+ };
22
+ }
23
+ dispatchEvent(el, evt) {
24
+ el.dispatchEvent(evt);
25
+ }
26
+ remove(node) {
27
+ node.remove();
28
+ }
29
+ createElement(tagName, doc) {
30
+ doc = doc || this.getDefaultDocument();
31
+ return doc.createElement(tagName);
32
+ }
33
+ createHtmlDocument() {
34
+ return document.implementation.createHTMLDocument('fakeTitle');
35
+ }
36
+ getDefaultDocument() {
37
+ return document;
38
+ }
39
+ isElementNode(node) {
40
+ return node.nodeType === Node.ELEMENT_NODE;
41
+ }
42
+ isShadowRoot(node) {
43
+ return node instanceof DocumentFragment;
44
+ }
45
+ getGlobalEventTarget(doc, target) {
46
+ if (target === 'window') {
47
+ return window;
70
48
  }
71
- getUserAgent() {
72
- return window.navigator.userAgent;
49
+ if (target === 'document') {
50
+ return doc;
73
51
  }
74
- getCookie(name) {
75
- return _parseCookieValue(document.cookie, name);
52
+ if (target === 'body') {
53
+ return doc.body;
76
54
  }
55
+ return null;
56
+ }
57
+ getBaseHref(doc) {
58
+ const href = getBaseElementHref();
59
+ return href == null ? null : relativePath(href);
60
+ }
61
+ resetBaseElement() {
62
+ baseElement = null;
63
+ }
64
+ getUserAgent() {
65
+ return window.navigator.userAgent;
66
+ }
67
+ getCookie(name) {
68
+ return _parseCookieValue(document.cookie, name);
69
+ }
77
70
  }
78
71
  let baseElement = null;
79
72
  function getBaseElementHref() {
80
- baseElement = baseElement || document.head.querySelector('base');
81
- return baseElement ? baseElement.getAttribute('href') : null;
73
+ baseElement = baseElement || document.head.querySelector('base');
74
+ return baseElement ? baseElement.getAttribute('href') : null;
82
75
  }
83
76
  function relativePath(url) {
84
- // The base URL doesn't really matter, we just need it so relative paths have something
85
- // to resolve against. In the browser `HTMLBaseElement.href` is always absolute.
86
- return new URL(url, document.baseURI).pathname;
77
+ return new URL(url, document.baseURI).pathname;
87
78
  }
88
79
 
89
80
  class BrowserGetTestability {
90
- addToWindow(registry) {
91
- _global['getAngularTestability'] = (elem, findInAncestors = true) => {
92
- const testability = registry.findTestabilityInTree(elem, findInAncestors);
93
- if (testability == null) {
94
- throw new _RuntimeError(5103 /* RuntimeErrorCode.TESTABILITY_NOT_FOUND */, (typeof ngDevMode === 'undefined' || ngDevMode) &&
95
- 'Could not find testability for element.');
96
- }
97
- return testability;
98
- };
99
- _global['getAllAngularTestabilities'] = () => registry.getAllTestabilities();
100
- _global['getAllAngularRootElements'] = () => registry.getAllRootElements();
101
- const whenAllStable = (callback) => {
102
- const testabilities = _global['getAllAngularTestabilities']();
103
- let count = testabilities.length;
104
- const decrement = function () {
105
- count--;
106
- if (count == 0) {
107
- callback();
108
- }
109
- };
110
- testabilities.forEach((testability) => {
111
- testability.whenStable(decrement);
112
- });
113
- };
114
- if (!_global['frameworkStabilizers']) {
115
- _global['frameworkStabilizers'] = [];
81
+ addToWindow(registry) {
82
+ _global['getAngularTestability'] = (elem, findInAncestors = true) => {
83
+ const testability = registry.findTestabilityInTree(elem, findInAncestors);
84
+ if (testability == null) {
85
+ throw new _RuntimeError(5103, (typeof ngDevMode === 'undefined' || ngDevMode) && 'Could not find testability for element.');
86
+ }
87
+ return testability;
88
+ };
89
+ _global['getAllAngularTestabilities'] = () => registry.getAllTestabilities();
90
+ _global['getAllAngularRootElements'] = () => registry.getAllRootElements();
91
+ const whenAllStable = callback => {
92
+ const testabilities = _global['getAllAngularTestabilities']();
93
+ let count = testabilities.length;
94
+ const decrement = function () {
95
+ count--;
96
+ if (count == 0) {
97
+ callback();
116
98
  }
117
- _global['frameworkStabilizers'].push(whenAllStable);
99
+ };
100
+ testabilities.forEach(testability => {
101
+ testability.whenStable(decrement);
102
+ });
103
+ };
104
+ if (!_global['frameworkStabilizers']) {
105
+ _global['frameworkStabilizers'] = [];
118
106
  }
119
- findTestabilityInTree(registry, elem, findInAncestors) {
120
- if (elem == null) {
121
- return null;
122
- }
123
- const t = registry.getTestability(elem);
124
- if (t != null) {
125
- return t;
126
- }
127
- else if (!findInAncestors) {
128
- return null;
129
- }
130
- if (_getDOM().isShadowRoot(elem)) {
131
- return this.findTestabilityInTree(registry, elem.host, true);
132
- }
133
- return this.findTestabilityInTree(registry, elem.parentElement, true);
107
+ _global['frameworkStabilizers'].push(whenAllStable);
108
+ }
109
+ findTestabilityInTree(registry, elem, findInAncestors) {
110
+ if (elem == null) {
111
+ return null;
134
112
  }
113
+ const t = registry.getTestability(elem);
114
+ if (t != null) {
115
+ return t;
116
+ } else if (!findInAncestors) {
117
+ return null;
118
+ }
119
+ if (_getDOM().isShadowRoot(elem)) {
120
+ return this.findTestabilityInTree(registry, elem.host, true);
121
+ }
122
+ return this.findTestabilityInTree(registry, elem.parentElement, true);
123
+ }
135
124
  }
136
125
 
137
- /**
138
- * A factory for `HttpXhrBackend` that uses the `XMLHttpRequest` browser API.
139
- */
140
126
  class BrowserXhr {
141
- build() {
142
- return new XMLHttpRequest();
143
- }
144
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.0.0-next.9", ngImport: i0, type: BrowserXhr, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
145
- static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.0.0-next.9", ngImport: i0, type: BrowserXhr });
127
+ build() {
128
+ return new XMLHttpRequest();
129
+ }
130
+ static ɵfac = i0.ɵɵngDeclareFactory({
131
+ minVersion: "12.0.0",
132
+ version: "21.0.0-rc.1",
133
+ ngImport: i0,
134
+ type: BrowserXhr,
135
+ deps: [],
136
+ target: i0.ɵɵFactoryTarget.Injectable
137
+ });
138
+ static ɵprov = i0.ɵɵngDeclareInjectable({
139
+ minVersion: "12.0.0",
140
+ version: "21.0.0-rc.1",
141
+ ngImport: i0,
142
+ type: BrowserXhr
143
+ });
146
144
  }
147
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.0.0-next.9", ngImport: i0, type: BrowserXhr, decorators: [{
148
- type: Injectable
149
- }] });
145
+ i0.ɵɵngDeclareClassMetadata({
146
+ minVersion: "12.0.0",
147
+ version: "21.0.0-rc.1",
148
+ ngImport: i0,
149
+ type: BrowserXhr,
150
+ decorators: [{
151
+ type: Injectable
152
+ }]
153
+ });
150
154
 
151
- /**
152
- * Defines supported modifiers for key events.
153
- */
154
155
  const MODIFIER_KEYS = ['alt', 'control', 'meta', 'shift'];
155
- // The following values are here for cross-browser compatibility and to match the W3C standard
156
- // cf https://www.w3.org/TR/DOM-Level-3-Events-key/
157
156
  const _keyMap = {
158
- '\b': 'Backspace',
159
- '\t': 'Tab',
160
- '\x7F': 'Delete',
161
- '\x1B': 'Escape',
162
- 'Del': 'Delete',
163
- 'Esc': 'Escape',
164
- 'Left': 'ArrowLeft',
165
- 'Right': 'ArrowRight',
166
- 'Up': 'ArrowUp',
167
- 'Down': 'ArrowDown',
168
- 'Menu': 'ContextMenu',
169
- 'Scroll': 'ScrollLock',
170
- 'Win': 'OS',
157
+ '\b': 'Backspace',
158
+ '\t': 'Tab',
159
+ '\x7F': 'Delete',
160
+ '\x1B': 'Escape',
161
+ 'Del': 'Delete',
162
+ 'Esc': 'Escape',
163
+ 'Left': 'ArrowLeft',
164
+ 'Right': 'ArrowRight',
165
+ 'Up': 'ArrowUp',
166
+ 'Down': 'ArrowDown',
167
+ 'Menu': 'ContextMenu',
168
+ 'Scroll': 'ScrollLock',
169
+ 'Win': 'OS'
171
170
  };
172
- /**
173
- * Retrieves modifiers from key-event objects.
174
- */
175
171
  const MODIFIER_KEY_GETTERS = {
176
- 'alt': (event) => event.altKey,
177
- 'control': (event) => event.ctrlKey,
178
- 'meta': (event) => event.metaKey,
179
- 'shift': (event) => event.shiftKey,
172
+ 'alt': event => event.altKey,
173
+ 'control': event => event.ctrlKey,
174
+ 'meta': event => event.metaKey,
175
+ 'shift': event => event.shiftKey
180
176
  };
181
- /**
182
- * A browser plug-in that provides support for handling of key events in Angular.
183
- */
184
177
  class KeyEventsPlugin extends EventManagerPlugin {
185
- /**
186
- * Initializes an instance of the browser plug-in.
187
- * @param doc The document in which key events will be detected.
188
- */
189
- constructor(doc) {
190
- super(doc);
178
+ constructor(doc) {
179
+ super(doc);
180
+ }
181
+ supports(eventName) {
182
+ return KeyEventsPlugin.parseEventName(eventName) != null;
183
+ }
184
+ addEventListener(element, eventName, handler, options) {
185
+ const parsedEvent = KeyEventsPlugin.parseEventName(eventName);
186
+ const outsideHandler = KeyEventsPlugin.eventCallback(parsedEvent['fullKey'], handler, this.manager.getZone());
187
+ return this.manager.getZone().runOutsideAngular(() => {
188
+ return _getDOM().onAndCancel(element, parsedEvent['domEventName'], outsideHandler, options);
189
+ });
190
+ }
191
+ static parseEventName(eventName) {
192
+ const parts = eventName.toLowerCase().split('.');
193
+ const domEventName = parts.shift();
194
+ if (parts.length === 0 || !(domEventName === 'keydown' || domEventName === 'keyup')) {
195
+ return null;
191
196
  }
192
- /**
193
- * Reports whether a named key event is supported.
194
- * @param eventName The event name to query.
195
- * @return True if the named key event is supported.
196
- */
197
- supports(eventName) {
198
- return KeyEventsPlugin.parseEventName(eventName) != null;
199
- }
200
- /**
201
- * Registers a handler for a specific element and key event.
202
- * @param element The HTML element to receive event notifications.
203
- * @param eventName The name of the key event to listen for.
204
- * @param handler A function to call when the notification occurs. Receives the
205
- * event object as an argument.
206
- * @returns The key event that was registered.
207
- */
208
- addEventListener(element, eventName, handler, options) {
209
- const parsedEvent = KeyEventsPlugin.parseEventName(eventName);
210
- const outsideHandler = KeyEventsPlugin.eventCallback(parsedEvent['fullKey'], handler, this.manager.getZone());
211
- return this.manager.getZone().runOutsideAngular(() => {
212
- return _getDOM().onAndCancel(element, parsedEvent['domEventName'], outsideHandler, options);
213
- });
214
- }
215
- /**
216
- * Parses the user provided full keyboard event definition and normalizes it for
217
- * later internal use. It ensures the string is all lowercase, converts special
218
- * characters to a standard spelling, and orders all the values consistently.
219
- *
220
- * @param eventName The name of the key event to listen for.
221
- * @returns an object with the full, normalized string, and the dom event name
222
- * or null in the case when the event doesn't match a keyboard event.
223
- */
224
- static parseEventName(eventName) {
225
- const parts = eventName.toLowerCase().split('.');
226
- const domEventName = parts.shift();
227
- if (parts.length === 0 || !(domEventName === 'keydown' || domEventName === 'keyup')) {
228
- return null;
229
- }
230
- const key = KeyEventsPlugin._normalizeKey(parts.pop());
231
- let fullKey = '';
232
- let codeIX = parts.indexOf('code');
233
- if (codeIX > -1) {
234
- parts.splice(codeIX, 1);
235
- fullKey = 'code.';
236
- }
237
- MODIFIER_KEYS.forEach((modifierName) => {
238
- const index = parts.indexOf(modifierName);
239
- if (index > -1) {
240
- parts.splice(index, 1);
241
- fullKey += modifierName + '.';
242
- }
243
- });
244
- fullKey += key;
245
- if (parts.length != 0 || key.length === 0) {
246
- // returning null instead of throwing to let another plugin process the event
247
- return null;
248
- }
249
- // NOTE: Please don't rewrite this as so, as it will break JSCompiler property renaming.
250
- // The code must remain in the `result['domEventName']` form.
251
- // return {domEventName, fullKey};
252
- const result = {};
253
- result['domEventName'] = domEventName;
254
- result['fullKey'] = fullKey;
255
- return result;
197
+ const key = KeyEventsPlugin._normalizeKey(parts.pop());
198
+ let fullKey = '';
199
+ let codeIX = parts.indexOf('code');
200
+ if (codeIX > -1) {
201
+ parts.splice(codeIX, 1);
202
+ fullKey = 'code.';
256
203
  }
257
- /**
258
- * Determines whether the actual keys pressed match the configured key code string.
259
- * The `fullKeyCode` event is normalized in the `parseEventName` method when the
260
- * event is attached to the DOM during the `addEventListener` call. This is unseen
261
- * by the end user and is normalized for internal consistency and parsing.
262
- *
263
- * @param event The keyboard event.
264
- * @param fullKeyCode The normalized user defined expected key event string
265
- * @returns boolean.
266
- */
267
- static matchEventFullKeyCode(event, fullKeyCode) {
268
- let keycode = _keyMap[event.key] || event.key;
269
- let key = '';
270
- if (fullKeyCode.indexOf('code.') > -1) {
271
- keycode = event.code;
272
- key = 'code.';
273
- }
274
- // the keycode could be unidentified so we have to check here
275
- if (keycode == null || !keycode)
276
- return false;
277
- keycode = keycode.toLowerCase();
278
- if (keycode === ' ') {
279
- keycode = 'space'; // for readability
280
- }
281
- else if (keycode === '.') {
282
- keycode = 'dot'; // because '.' is used as a separator in event names
283
- }
284
- MODIFIER_KEYS.forEach((modifierName) => {
285
- if (modifierName !== keycode) {
286
- const modifierGetter = MODIFIER_KEY_GETTERS[modifierName];
287
- if (modifierGetter(event)) {
288
- key += modifierName + '.';
289
- }
290
- }
291
- });
292
- key += keycode;
293
- return key === fullKeyCode;
204
+ MODIFIER_KEYS.forEach(modifierName => {
205
+ const index = parts.indexOf(modifierName);
206
+ if (index > -1) {
207
+ parts.splice(index, 1);
208
+ fullKey += modifierName + '.';
209
+ }
210
+ });
211
+ fullKey += key;
212
+ if (parts.length != 0 || key.length === 0) {
213
+ return null;
294
214
  }
295
- /**
296
- * Configures a handler callback for a key event.
297
- * @param fullKey The event name that combines all simultaneous keystrokes.
298
- * @param handler The function that responds to the key event.
299
- * @param zone The zone in which the event occurred.
300
- * @returns A callback function.
301
- */
302
- static eventCallback(fullKey, handler, zone) {
303
- return (event) => {
304
- if (KeyEventsPlugin.matchEventFullKeyCode(event, fullKey)) {
305
- zone.runGuarded(() => handler(event));
306
- }
307
- };
215
+ const result = {};
216
+ result['domEventName'] = domEventName;
217
+ result['fullKey'] = fullKey;
218
+ return result;
219
+ }
220
+ static matchEventFullKeyCode(event, fullKeyCode) {
221
+ let keycode = _keyMap[event.key] || event.key;
222
+ let key = '';
223
+ if (fullKeyCode.indexOf('code.') > -1) {
224
+ keycode = event.code;
225
+ key = 'code.';
308
226
  }
309
- /** @internal */
310
- static _normalizeKey(keyName) {
311
- return keyName === 'esc' ? 'escape' : keyName;
227
+ if (keycode == null || !keycode) return false;
228
+ keycode = keycode.toLowerCase();
229
+ if (keycode === ' ') {
230
+ keycode = 'space';
231
+ } else if (keycode === '.') {
232
+ keycode = 'dot';
312
233
  }
313
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.0.0-next.9", ngImport: i0, type: KeyEventsPlugin, deps: [{ token: DOCUMENT }], target: i0.ɵɵFactoryTarget.Injectable });
314
- static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.0.0-next.9", ngImport: i0, type: KeyEventsPlugin });
234
+ MODIFIER_KEYS.forEach(modifierName => {
235
+ if (modifierName !== keycode) {
236
+ const modifierGetter = MODIFIER_KEY_GETTERS[modifierName];
237
+ if (modifierGetter(event)) {
238
+ key += modifierName + '.';
239
+ }
240
+ }
241
+ });
242
+ key += keycode;
243
+ return key === fullKeyCode;
244
+ }
245
+ static eventCallback(fullKey, handler, zone) {
246
+ return event => {
247
+ if (KeyEventsPlugin.matchEventFullKeyCode(event, fullKey)) {
248
+ zone.runGuarded(() => handler(event));
249
+ }
250
+ };
251
+ }
252
+ static _normalizeKey(keyName) {
253
+ return keyName === 'esc' ? 'escape' : keyName;
254
+ }
255
+ static ɵfac = i0.ɵɵngDeclareFactory({
256
+ minVersion: "12.0.0",
257
+ version: "21.0.0-rc.1",
258
+ ngImport: i0,
259
+ type: KeyEventsPlugin,
260
+ deps: [{
261
+ token: DOCUMENT
262
+ }],
263
+ target: i0.ɵɵFactoryTarget.Injectable
264
+ });
265
+ static ɵprov = i0.ɵɵngDeclareInjectable({
266
+ minVersion: "12.0.0",
267
+ version: "21.0.0-rc.1",
268
+ ngImport: i0,
269
+ type: KeyEventsPlugin
270
+ });
315
271
  }
316
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.0.0-next.9", ngImport: i0, type: KeyEventsPlugin, decorators: [{
317
- type: Injectable
318
- }], ctorParameters: () => [{ type: undefined, decorators: [{
319
- type: Inject,
320
- args: [DOCUMENT]
321
- }] }] });
272
+ i0.ɵɵngDeclareClassMetadata({
273
+ minVersion: "12.0.0",
274
+ version: "21.0.0-rc.1",
275
+ ngImport: i0,
276
+ type: KeyEventsPlugin,
277
+ decorators: [{
278
+ type: Injectable
279
+ }],
280
+ ctorParameters: () => [{
281
+ type: undefined,
282
+ decorators: [{
283
+ type: Inject,
284
+ args: [DOCUMENT]
285
+ }]
286
+ }]
287
+ });
322
288
 
323
- /**
324
- * Bootstraps an instance of an Angular application and renders a standalone component as the
325
- * application's root component. More information about standalone components can be found in [this
326
- * guide](guide/components/importing).
327
- *
328
- * @usageNotes
329
- * The root component passed into this function *must* be a standalone one (should have the
330
- * `standalone: true` flag in the `@Component` decorator config).
331
- *
332
- * ```angular-ts
333
- * @Component({
334
- * standalone: true,
335
- * template: 'Hello world!'
336
- * })
337
- * class RootComponent {}
338
- *
339
- * const appRef: ApplicationRef = await bootstrapApplication(RootComponent);
340
- * ```
341
- *
342
- * You can add the list of providers that should be available in the application injector by
343
- * specifying the `providers` field in an object passed as the second argument:
344
- *
345
- * ```ts
346
- * await bootstrapApplication(RootComponent, {
347
- * providers: [
348
- * {provide: BACKEND_URL, useValue: 'https://yourdomain.com/api'}
349
- * ]
350
- * });
351
- * ```
352
- *
353
- * The `importProvidersFrom` helper method can be used to collect all providers from any
354
- * existing NgModule (and transitively from all NgModules that it imports):
355
- *
356
- * ```ts
357
- * await bootstrapApplication(RootComponent, {
358
- * providers: [
359
- * importProvidersFrom(SomeNgModule)
360
- * ]
361
- * });
362
- * ```
363
- *
364
- * Note: the `bootstrapApplication` method doesn't include [Testability](api/core/Testability) by
365
- * default. You can add [Testability](api/core/Testability) by getting the list of necessary
366
- * providers using `provideProtractorTestingSupport()` function and adding them into the `providers`
367
- * array, for example:
368
- *
369
- * ```ts
370
- * import {provideProtractorTestingSupport} from '@angular/platform-browser';
371
- *
372
- * await bootstrapApplication(RootComponent, {providers: [provideProtractorTestingSupport()]});
373
- * ```
374
- *
375
- * @param rootComponent A reference to a standalone component that should be rendered.
376
- * @param options Extra configuration for the bootstrap operation, see `ApplicationConfig` for
377
- * additional info.
378
- * @param context Optional context object that can be used to provide a pre-existing
379
- * platform injector. This is useful for advanced use-cases, for example, server-side
380
- * rendering, where the platform is created for each request.
381
- * @returns A promise that returns an `ApplicationRef` instance once resolved.
382
- *
383
- * @publicApi
384
- */
385
289
  function bootstrapApplication(rootComponent, options, context) {
386
- const config = {
387
- rootComponent,
388
- platformRef: context?.platformRef,
389
- ...createProvidersConfig(options),
390
- };
391
- // Attempt to resolve component resources before bootstrapping in JIT mode,
392
- // however don't interrupt the bootstrapping process.
393
- if ((typeof ngJitMode === 'undefined' || ngJitMode) && typeof fetch === 'function') {
394
- return _resolveComponentResources(fetch)
395
- .catch((error) => {
396
- console.error(error);
397
- return Promise.resolve();
398
- })
399
- .then(() => _internalCreateApplication(config));
400
- }
401
- return _internalCreateApplication(config);
290
+ const config = {
291
+ rootComponent,
292
+ platformRef: context?.platformRef,
293
+ ...createProvidersConfig(options)
294
+ };
295
+ if ((typeof ngJitMode === 'undefined' || ngJitMode) && typeof fetch === 'function') {
296
+ return _resolveComponentResources(fetch).catch(error => {
297
+ console.error(error);
298
+ return Promise.resolve();
299
+ }).then(() => _internalCreateApplication(config));
300
+ }
301
+ return _internalCreateApplication(config);
402
302
  }
403
- /**
404
- * Create an instance of an Angular application without bootstrapping any components. This is useful
405
- * for the situation where one wants to decouple application environment creation (a platform and
406
- * associated injectors) from rendering components on a screen. Components can be subsequently
407
- * bootstrapped on the returned `ApplicationRef`.
408
- *
409
- * @param options Extra configuration for the application environment, see `ApplicationConfig` for
410
- * additional info.
411
- * @returns A promise that returns an `ApplicationRef` instance once resolved.
412
- *
413
- * @publicApi
414
- */
415
303
  function createApplication(options) {
416
- return _internalCreateApplication(createProvidersConfig(options));
304
+ return _internalCreateApplication(createProvidersConfig(options));
417
305
  }
418
306
  function createProvidersConfig(options) {
419
- return {
420
- appProviders: [...BROWSER_MODULE_PROVIDERS, ...(options?.providers ?? [])],
421
- platformProviders: INTERNAL_BROWSER_PLATFORM_PROVIDERS,
422
- };
307
+ return {
308
+ appProviders: [...BROWSER_MODULE_PROVIDERS, ...(options?.providers ?? [])],
309
+ platformProviders: INTERNAL_BROWSER_PLATFORM_PROVIDERS
310
+ };
423
311
  }
424
- /**
425
- * Returns a set of providers required to setup [Testability](api/core/Testability) for an
426
- * application bootstrapped using the `bootstrapApplication` function. The set of providers is
427
- * needed to support testing an application with Protractor (which relies on the Testability APIs
428
- * to be present).
429
- *
430
- * @returns An array of providers required to setup Testability for an application and make it
431
- * available for testing using Protractor.
432
- *
433
- * @publicApi
434
- */
435
312
  function provideProtractorTestingSupport() {
436
- // Return a copy to prevent changes to the original array in case any in-place
437
- // alterations are performed to the `provideProtractorTestingSupport` call results in app
438
- // code.
439
- return [...TESTABILITY_PROVIDERS];
313
+ return [...TESTABILITY_PROVIDERS];
440
314
  }
441
315
  function initDomAdapter() {
442
- BrowserDomAdapter.makeCurrent();
316
+ BrowserDomAdapter.makeCurrent();
443
317
  }
444
318
  function errorHandler() {
445
- return new ErrorHandler();
319
+ return new ErrorHandler();
446
320
  }
447
321
  function _document() {
448
- // Tell ivy about the global document
449
- _setDocument(document);
450
- return document;
322
+ _setDocument(document);
323
+ return document;
451
324
  }
452
- const INTERNAL_BROWSER_PLATFORM_PROVIDERS = [
453
- { provide: PLATFORM_ID, useValue: _PLATFORM_BROWSER_ID },
454
- { provide: PLATFORM_INITIALIZER, useValue: initDomAdapter, multi: true },
455
- { provide: DOCUMENT, useFactory: _document },
456
- ];
457
- /**
458
- * A factory function that returns a `PlatformRef` instance associated with browser service
459
- * providers.
460
- *
461
- * @publicApi
462
- */
325
+ const INTERNAL_BROWSER_PLATFORM_PROVIDERS = [{
326
+ provide: PLATFORM_ID,
327
+ useValue: _PLATFORM_BROWSER_ID
328
+ }, {
329
+ provide: PLATFORM_INITIALIZER,
330
+ useValue: initDomAdapter,
331
+ multi: true
332
+ }, {
333
+ provide: DOCUMENT,
334
+ useFactory: _document
335
+ }];
463
336
  const platformBrowser = createPlatformFactory(platformCore, 'browser', INTERNAL_BROWSER_PLATFORM_PROVIDERS);
464
- /**
465
- * Internal marker to signal whether providers from the `BrowserModule` are already present in DI.
466
- * This is needed to avoid loading `BrowserModule` providers twice. We can't rely on the
467
- * `BrowserModule` presence itself, since the standalone-based bootstrap just imports
468
- * `BrowserModule` providers without referencing the module itself.
469
- */
470
337
  const BROWSER_MODULE_PROVIDERS_MARKER = new InjectionToken(typeof ngDevMode === 'undefined' || ngDevMode ? 'BrowserModule Providers Marker' : '');
471
- const TESTABILITY_PROVIDERS = [
472
- {
473
- provide: _TESTABILITY_GETTER,
474
- useClass: BrowserGetTestability,
475
- },
476
- {
477
- provide: _TESTABILITY,
478
- useClass: Testability,
479
- },
480
- {
481
- provide: Testability, // Also provide as `Testability` for backwards-compatibility.
482
- useClass: Testability,
483
- },
484
- ];
485
- const BROWSER_MODULE_PROVIDERS = [
486
- { provide: _INJECTOR_SCOPE, useValue: 'root' },
487
- { provide: ErrorHandler, useFactory: errorHandler },
488
- {
489
- provide: EVENT_MANAGER_PLUGINS,
490
- useClass: DomEventsPlugin,
491
- multi: true,
492
- },
493
- { provide: EVENT_MANAGER_PLUGINS, useClass: KeyEventsPlugin, multi: true },
494
- DomRendererFactory2,
495
- SharedStylesHost,
496
- EventManager,
497
- { provide: RendererFactory2, useExisting: DomRendererFactory2 },
498
- { provide: XhrFactory, useClass: BrowserXhr },
499
- typeof ngDevMode === 'undefined' || ngDevMode
500
- ? { provide: BROWSER_MODULE_PROVIDERS_MARKER, useValue: true }
501
- : [],
502
- ];
503
- /**
504
- * Exports required infrastructure for all Angular apps.
505
- * Included by default in all Angular apps created with the CLI
506
- * `new` command.
507
- * Re-exports `CommonModule` and `ApplicationModule`, making their
508
- * exports and providers available to all apps.
509
- *
510
- * @publicApi
511
- */
338
+ const TESTABILITY_PROVIDERS = [{
339
+ provide: _TESTABILITY_GETTER,
340
+ useClass: BrowserGetTestability
341
+ }, {
342
+ provide: _TESTABILITY,
343
+ useClass: Testability
344
+ }, {
345
+ provide: Testability,
346
+ useClass: Testability
347
+ }];
348
+ const BROWSER_MODULE_PROVIDERS = [{
349
+ provide: _INJECTOR_SCOPE,
350
+ useValue: 'root'
351
+ }, {
352
+ provide: ErrorHandler,
353
+ useFactory: errorHandler
354
+ }, {
355
+ provide: EVENT_MANAGER_PLUGINS,
356
+ useClass: DomEventsPlugin,
357
+ multi: true
358
+ }, {
359
+ provide: EVENT_MANAGER_PLUGINS,
360
+ useClass: KeyEventsPlugin,
361
+ multi: true
362
+ }, DomRendererFactory2, SharedStylesHost, EventManager, {
363
+ provide: RendererFactory2,
364
+ useExisting: DomRendererFactory2
365
+ }, {
366
+ provide: XhrFactory,
367
+ useClass: BrowserXhr
368
+ }, typeof ngDevMode === 'undefined' || ngDevMode ? {
369
+ provide: BROWSER_MODULE_PROVIDERS_MARKER,
370
+ useValue: true
371
+ } : []];
512
372
  class BrowserModule {
513
- constructor() {
514
- if (typeof ngDevMode === 'undefined' || ngDevMode) {
515
- const providersAlreadyPresent = inject(BROWSER_MODULE_PROVIDERS_MARKER, {
516
- optional: true,
517
- skipSelf: true,
518
- });
519
- if (providersAlreadyPresent) {
520
- throw new _RuntimeError(5100 /* RuntimeErrorCode.BROWSER_MODULE_ALREADY_LOADED */, `Providers from the \`BrowserModule\` have already been loaded. If you need access ` +
521
- `to common directives such as NgIf and NgFor, import the \`CommonModule\` instead.`);
522
- }
523
- }
373
+ constructor() {
374
+ if (typeof ngDevMode === 'undefined' || ngDevMode) {
375
+ const providersAlreadyPresent = inject(BROWSER_MODULE_PROVIDERS_MARKER, {
376
+ optional: true,
377
+ skipSelf: true
378
+ });
379
+ if (providersAlreadyPresent) {
380
+ throw new _RuntimeError(5100, `Providers from the \`BrowserModule\` have already been loaded. If you need access ` + `to common directives such as NgIf and NgFor, import the \`CommonModule\` instead.`);
381
+ }
524
382
  }
525
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.0.0-next.9", ngImport: i0, type: BrowserModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
526
- static ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "21.0.0-next.9", ngImport: i0, type: BrowserModule, exports: [CommonModule, ApplicationModule] });
527
- static ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "21.0.0-next.9", ngImport: i0, type: BrowserModule, providers: [...BROWSER_MODULE_PROVIDERS, ...TESTABILITY_PROVIDERS], imports: [CommonModule, ApplicationModule] });
383
+ }
384
+ static ɵfac = i0.ɵɵngDeclareFactory({
385
+ minVersion: "12.0.0",
386
+ version: "21.0.0-rc.1",
387
+ ngImport: i0,
388
+ type: BrowserModule,
389
+ deps: [],
390
+ target: i0.ɵɵFactoryTarget.NgModule
391
+ });
392
+ static ɵmod = i0.ɵɵngDeclareNgModule({
393
+ minVersion: "14.0.0",
394
+ version: "21.0.0-rc.1",
395
+ ngImport: i0,
396
+ type: BrowserModule,
397
+ exports: [CommonModule, ApplicationModule]
398
+ });
399
+ static ɵinj = i0.ɵɵngDeclareInjector({
400
+ minVersion: "12.0.0",
401
+ version: "21.0.0-rc.1",
402
+ ngImport: i0,
403
+ type: BrowserModule,
404
+ providers: [...BROWSER_MODULE_PROVIDERS, ...TESTABILITY_PROVIDERS],
405
+ imports: [CommonModule, ApplicationModule]
406
+ });
528
407
  }
529
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.0.0-next.9", ngImport: i0, type: BrowserModule, decorators: [{
530
- type: NgModule,
531
- args: [{
532
- providers: [...BROWSER_MODULE_PROVIDERS, ...TESTABILITY_PROVIDERS],
533
- exports: [CommonModule, ApplicationModule],
534
- }]
535
- }], ctorParameters: () => [] });
408
+ i0.ɵɵngDeclareClassMetadata({
409
+ minVersion: "12.0.0",
410
+ version: "21.0.0-rc.1",
411
+ ngImport: i0,
412
+ type: BrowserModule,
413
+ decorators: [{
414
+ type: NgModule,
415
+ args: [{
416
+ providers: [...BROWSER_MODULE_PROVIDERS, ...TESTABILITY_PROVIDERS],
417
+ exports: [CommonModule, ApplicationModule]
418
+ }]
419
+ }],
420
+ ctorParameters: () => []
421
+ });
536
422
 
537
423
  export { BrowserDomAdapter, BrowserGetTestability, BrowserModule, KeyEventsPlugin, bootstrapApplication, createApplication, platformBrowser, provideProtractorTestingSupport };
538
424
  //# sourceMappingURL=_browser-chunk.mjs.map