@angular/service-worker 20.0.0-next.4 → 20.0.0-next.6

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.
package/config/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license Angular v20.0.0-next.4
2
+ * @license Angular v20.0.0-next.6
3
3
  * (c) 2010-2025 Google LLC. https://angular.io/
4
4
  * License: MIT
5
5
  */
@@ -88,4 +88,5 @@ declare class Generator {
88
88
  private processDataGroups;
89
89
  }
90
90
 
91
- export { type AssetGroup, type Config, type DataGroup, type Duration, type Filesystem, Generator, type Glob };
91
+ export { Generator };
92
+ export type { AssetGroup, Config, DataGroup, Duration, Filesystem, Glob };
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license Angular v20.0.0-next.4
2
+ * @license Angular v20.0.0-next.6
3
3
  * (c) 2010-2025 Google LLC. https://angular.io/
4
4
  * License: MIT
5
5
  */
@@ -1,18 +1,15 @@
1
1
  /**
2
- * @license Angular v20.0.0-next.4
2
+ * @license Angular v20.0.0-next.6
3
3
  * (c) 2010-2025 Google LLC. https://angular.io/
4
4
  * License: MIT
5
5
  */
6
6
 
7
7
  import * as i0 from '@angular/core';
8
- import { Injectable, makeEnvironmentProviders, InjectionToken, Injector, APP_INITIALIZER, NgZone, ApplicationRef, NgModule } from '@angular/core';
9
- import { fromEvent, defer, of, concat, throwError, Subject, NEVER, merge, from } from 'rxjs';
10
- import { map, filter, switchMap, publish, take, tap, delay } from 'rxjs/operators';
8
+ import { ApplicationRef, Injectable, makeEnvironmentProviders, InjectionToken, Injector, provideAppInitializer, inject, NgZone, NgModule } from '@angular/core';
9
+ import { Observable, Subject, NEVER } from 'rxjs';
10
+ import { switchMap, take, filter, map } from 'rxjs/operators';
11
11
 
12
12
  const ERR_SW_NOT_SUPPORTED = 'Service workers are disabled or not supported by this browser';
13
- function errorObservable(message) {
14
- return defer(() => throwError(new Error(message)));
15
- }
16
13
  /**
17
14
  * @publicApi
18
15
  */
@@ -21,36 +18,61 @@ class NgswCommChannel {
21
18
  worker;
22
19
  registration;
23
20
  events;
24
- constructor(serviceWorker) {
21
+ constructor(serviceWorker, injector) {
25
22
  this.serviceWorker = serviceWorker;
26
23
  if (!serviceWorker) {
27
- this.worker = this.events = this.registration = errorObservable(ERR_SW_NOT_SUPPORTED);
24
+ this.worker =
25
+ this.events =
26
+ this.registration =
27
+ new Observable((subscriber) => subscriber.error(new Error(ERR_SW_NOT_SUPPORTED)));
28
28
  }
29
29
  else {
30
- const controllerChangeEvents = fromEvent(serviceWorker, 'controllerchange');
31
- const controllerChanges = controllerChangeEvents.pipe(map(() => serviceWorker.controller));
32
- const currentController = defer(() => of(serviceWorker.controller));
33
- const controllerWithChanges = concat(currentController, controllerChanges);
34
- this.worker = controllerWithChanges.pipe(filter((c) => !!c));
30
+ let currentWorker = null;
31
+ const workerSubject = new Subject();
32
+ this.worker = new Observable((subscriber) => {
33
+ if (currentWorker !== null) {
34
+ subscriber.next(currentWorker);
35
+ }
36
+ return workerSubject.subscribe((v) => subscriber.next(v));
37
+ });
38
+ const updateController = () => {
39
+ const { controller } = serviceWorker;
40
+ if (controller === null) {
41
+ return;
42
+ }
43
+ currentWorker = controller;
44
+ workerSubject.next(currentWorker);
45
+ };
46
+ serviceWorker.addEventListener('controllerchange', updateController);
47
+ updateController();
35
48
  this.registration = (this.worker.pipe(switchMap(() => serviceWorker.getRegistration())));
36
- const rawEvents = fromEvent(serviceWorker, 'message');
37
- const rawEventPayload = rawEvents.pipe(map((event) => event.data));
38
- const eventsUnconnected = rawEventPayload.pipe(filter((event) => event && event.type));
39
- const events = eventsUnconnected.pipe(publish());
40
- events.connect();
41
- this.events = events;
49
+ const _events = new Subject();
50
+ this.events = _events.asObservable();
51
+ const messageListener = (event) => {
52
+ const { data } = event;
53
+ if (data?.type) {
54
+ _events.next(data);
55
+ }
56
+ };
57
+ serviceWorker.addEventListener('message', messageListener);
58
+ // The injector is optional to avoid breaking changes.
59
+ const appRef = injector?.get(ApplicationRef, null, { optional: true });
60
+ appRef?.onDestroy(() => {
61
+ serviceWorker.removeEventListener('controllerchange', updateController);
62
+ serviceWorker.removeEventListener('message', messageListener);
63
+ });
42
64
  }
43
65
  }
44
66
  postMessage(action, payload) {
45
- return this.worker
46
- .pipe(take(1), tap((sw) => {
47
- sw.postMessage({
48
- action,
49
- ...payload,
67
+ return new Promise((resolve) => {
68
+ this.worker.pipe(take(1)).subscribe((sw) => {
69
+ sw.postMessage({
70
+ action,
71
+ ...payload,
72
+ });
73
+ resolve();
50
74
  });
51
- }))
52
- .toPromise()
53
- .then(() => undefined);
75
+ });
54
76
  }
55
77
  postMessageWithOperation(type, payload, operationNonce) {
56
78
  const waitForOperationCompleted = this.waitForOperationCompleted(operationNonce);
@@ -74,14 +96,19 @@ class NgswCommChannel {
74
96
  return this.eventsOfType(type).pipe(take(1));
75
97
  }
76
98
  waitForOperationCompleted(nonce) {
77
- return this.eventsOfType('OPERATION_COMPLETED')
78
- .pipe(filter((event) => event.nonce === nonce), take(1), map((event) => {
79
- if (event.result !== undefined) {
80
- return event.result;
81
- }
82
- throw new Error(event.error);
83
- }))
84
- .toPromise();
99
+ return new Promise((resolve, reject) => {
100
+ this.eventsOfType('OPERATION_COMPLETED')
101
+ .pipe(filter((event) => event.nonce === nonce), take(1), map((event) => {
102
+ if (event.result !== undefined) {
103
+ return event.result;
104
+ }
105
+ throw new Error(event.error);
106
+ }))
107
+ .subscribe({
108
+ next: resolve,
109
+ error: reject,
110
+ });
111
+ });
85
112
  }
86
113
  get isEnabled() {
87
114
  return !!this.serviceWorker;
@@ -214,7 +241,14 @@ class SwPush {
214
241
  .pipe(map((message) => message.data));
215
242
  this.pushManager = this.sw.registration.pipe(map((registration) => registration.pushManager));
216
243
  const workerDrivenSubscriptions = this.pushManager.pipe(switchMap((pm) => pm.getSubscription()));
217
- this.subscription = merge(workerDrivenSubscriptions, this.subscriptionChanges);
244
+ this.subscription = new Observable((subscriber) => {
245
+ const workerDrivenSubscription = workerDrivenSubscriptions.subscribe(subscriber);
246
+ const subscriptionChanges = this.subscriptionChanges.subscribe(subscriber);
247
+ return () => {
248
+ workerDrivenSubscription.unsubscribe();
249
+ subscriptionChanges.unsubscribe();
250
+ };
251
+ });
218
252
  }
219
253
  /**
220
254
  * Subscribes to Web Push Notifications,
@@ -234,12 +268,14 @@ class SwPush {
234
268
  applicationServerKey[i] = key.charCodeAt(i);
235
269
  }
236
270
  pushOptions.applicationServerKey = applicationServerKey;
237
- return this.pushManager
238
- .pipe(switchMap((pm) => pm.subscribe(pushOptions)), take(1))
239
- .toPromise()
240
- .then((sub) => {
241
- this.subscriptionChanges.next(sub);
242
- return sub;
271
+ return new Promise((resolve, reject) => {
272
+ this.pushManager.pipe(switchMap((pm) => pm.subscribe(pushOptions)), take(1)).subscribe({
273
+ next: (sub) => {
274
+ this.subscriptionChanges.next(sub);
275
+ resolve(sub);
276
+ },
277
+ error: reject,
278
+ });
243
279
  });
244
280
  }
245
281
  /**
@@ -263,15 +299,19 @@ class SwPush {
263
299
  this.subscriptionChanges.next(null);
264
300
  });
265
301
  };
266
- return this.subscription.pipe(take(1), switchMap(doUnsubscribe)).toPromise();
302
+ return new Promise((resolve, reject) => {
303
+ this.subscription
304
+ .pipe(take(1), switchMap(doUnsubscribe))
305
+ .subscribe({ next: resolve, error: reject });
306
+ });
267
307
  }
268
308
  decodeBase64(input) {
269
309
  return atob(input);
270
310
  }
271
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.0.0-next.4", ngImport: i0, type: SwPush, deps: [{ token: NgswCommChannel }], target: i0.ɵɵFactoryTarget.Injectable });
272
- static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.0.0-next.4", ngImport: i0, type: SwPush });
311
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.0.0-next.6", ngImport: i0, type: SwPush, deps: [{ token: NgswCommChannel }], target: i0.ɵɵFactoryTarget.Injectable });
312
+ static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.0.0-next.6", ngImport: i0, type: SwPush });
273
313
  }
274
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.0.0-next.4", ngImport: i0, type: SwPush, decorators: [{
314
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.0.0-next.6", ngImport: i0, type: SwPush, decorators: [{
275
315
  type: Injectable
276
316
  }], ctorParameters: () => [{ type: NgswCommChannel }] });
277
317
 
@@ -370,10 +410,10 @@ class SwUpdate {
370
410
  const nonce = this.sw.generateNonce();
371
411
  return this.sw.postMessageWithOperation('ACTIVATE_UPDATE', { nonce }, nonce);
372
412
  }
373
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.0.0-next.4", ngImport: i0, type: SwUpdate, deps: [{ token: NgswCommChannel }], target: i0.ɵɵFactoryTarget.Injectable });
374
- static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.0.0-next.4", ngImport: i0, type: SwUpdate });
413
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.0.0-next.6", ngImport: i0, type: SwUpdate, deps: [{ token: NgswCommChannel }], target: i0.ɵɵFactoryTarget.Injectable });
414
+ static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.0.0-next.6", ngImport: i0, type: SwUpdate });
375
415
  }
376
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.0.0-next.4", ngImport: i0, type: SwUpdate, decorators: [{
416
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.0.0-next.6", ngImport: i0, type: SwUpdate, decorators: [{
377
417
  type: Injectable
378
418
  }], ctorParameters: () => [{ type: NgswCommChannel }] });
379
419
 
@@ -385,48 +425,50 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.0.0-next.4",
385
425
  * found in the LICENSE file at https://angular.dev/license
386
426
  */
387
427
  const SCRIPT = new InjectionToken(ngDevMode ? 'NGSW_REGISTER_SCRIPT' : '');
388
- function ngswAppInitializer(injector, script, options) {
389
- return () => {
390
- if (typeof ngServerMode !== 'undefined' && ngServerMode) {
391
- return;
392
- }
393
- if (!('serviceWorker' in navigator && options.enabled !== false)) {
394
- return;
395
- }
396
- const ngZone = injector.get(NgZone);
397
- const appRef = injector.get(ApplicationRef);
398
- // Set up the `controllerchange` event listener outside of
399
- // the Angular zone to avoid unnecessary change detections,
400
- // as this event has no impact on view updates.
401
- ngZone.runOutsideAngular(() => {
402
- // Wait for service worker controller changes, and fire an INITIALIZE action when a new SW
403
- // becomes active. This allows the SW to initialize itself even if there is no application
404
- // traffic.
405
- const sw = navigator.serviceWorker;
406
- const onControllerChange = () => sw.controller?.postMessage({ action: 'INITIALIZE' });
407
- sw.addEventListener('controllerchange', onControllerChange);
408
- appRef.onDestroy(() => {
409
- sw.removeEventListener('controllerchange', onControllerChange);
410
- });
428
+ function ngswAppInitializer() {
429
+ if (typeof ngServerMode !== 'undefined' && ngServerMode) {
430
+ return;
431
+ }
432
+ const options = inject(SwRegistrationOptions);
433
+ if (!('serviceWorker' in navigator && options.enabled !== false)) {
434
+ return;
435
+ }
436
+ const script = inject(SCRIPT);
437
+ const ngZone = inject(NgZone);
438
+ const appRef = inject(ApplicationRef);
439
+ // Set up the `controllerchange` event listener outside of
440
+ // the Angular zone to avoid unnecessary change detections,
441
+ // as this event has no impact on view updates.
442
+ ngZone.runOutsideAngular(() => {
443
+ // Wait for service worker controller changes, and fire an INITIALIZE action when a new SW
444
+ // becomes active. This allows the SW to initialize itself even if there is no application
445
+ // traffic.
446
+ const sw = navigator.serviceWorker;
447
+ const onControllerChange = () => sw.controller?.postMessage({ action: 'INITIALIZE' });
448
+ sw.addEventListener('controllerchange', onControllerChange);
449
+ appRef.onDestroy(() => {
450
+ sw.removeEventListener('controllerchange', onControllerChange);
411
451
  });
412
- let readyToRegister$;
413
- if (typeof options.registrationStrategy === 'function') {
414
- readyToRegister$ = options.registrationStrategy();
452
+ });
453
+ // Run outside the Angular zone to avoid preventing the app from stabilizing (especially
454
+ // given that some registration strategies wait for the app to stabilize).
455
+ ngZone.runOutsideAngular(() => {
456
+ let readyToRegister;
457
+ const { registrationStrategy } = options;
458
+ if (typeof registrationStrategy === 'function') {
459
+ readyToRegister = new Promise((resolve) => registrationStrategy().subscribe(() => resolve()));
415
460
  }
416
461
  else {
417
- const [strategy, ...args] = (options.registrationStrategy || 'registerWhenStable:30000').split(':');
462
+ const [strategy, ...args] = (registrationStrategy || 'registerWhenStable:30000').split(':');
418
463
  switch (strategy) {
419
464
  case 'registerImmediately':
420
- readyToRegister$ = of(null);
465
+ readyToRegister = Promise.resolve();
421
466
  break;
422
467
  case 'registerWithDelay':
423
- readyToRegister$ = delayWithTimeout(+args[0] || 0);
468
+ readyToRegister = delayWithTimeout(+args[0] || 0);
424
469
  break;
425
470
  case 'registerWhenStable':
426
- const whenStable$ = from(injector.get(ApplicationRef).whenStable());
427
- readyToRegister$ = !args[0]
428
- ? whenStable$
429
- : merge(whenStable$, delayWithTimeout(+args[0]));
471
+ readyToRegister = Promise.race([appRef.whenStable(), delayWithTimeout(+args[0])]);
430
472
  break;
431
473
  default:
432
474
  // Unknown strategy.
@@ -434,22 +476,18 @@ function ngswAppInitializer(injector, script, options) {
434
476
  }
435
477
  }
436
478
  // Don't return anything to avoid blocking the application until the SW is registered.
437
- // Also, run outside the Angular zone to avoid preventing the app from stabilizing (especially
438
- // given that some registration strategies wait for the app to stabilize).
439
479
  // Catch and log the error if SW registration fails to avoid uncaught rejection warning.
440
- ngZone.runOutsideAngular(() => readyToRegister$
441
- .pipe(take(1))
442
- .subscribe(() => navigator.serviceWorker
480
+ readyToRegister.then(() => navigator.serviceWorker
443
481
  .register(script, { scope: options.scope })
444
- .catch((err) => console.error('Service worker registration failed with:', err))));
445
- };
482
+ .catch((err) => console.error('Service worker registration failed with:', err)));
483
+ });
446
484
  }
447
485
  function delayWithTimeout(timeout) {
448
- return of(null).pipe(delay(timeout));
486
+ return new Promise((resolve) => setTimeout(resolve, timeout));
449
487
  }
450
- function ngswCommChannelFactory(opts) {
488
+ function ngswCommChannelFactory(opts, injector) {
451
489
  const isBrowser = !(typeof ngServerMode !== 'undefined' && ngServerMode);
452
- return new NgswCommChannel(isBrowser && opts.enabled !== false ? navigator.serviceWorker : undefined);
490
+ return new NgswCommChannel(isBrowser && opts.enabled !== false ? navigator.serviceWorker : undefined, injector);
453
491
  }
454
492
  /**
455
493
  * Token that can be used to provide options for `ServiceWorkerModule` outside of
@@ -534,14 +572,9 @@ function provideServiceWorker(script, options = {}) {
534
572
  {
535
573
  provide: NgswCommChannel,
536
574
  useFactory: ngswCommChannelFactory,
537
- deps: [SwRegistrationOptions],
538
- },
539
- {
540
- provide: APP_INITIALIZER,
541
- useFactory: ngswAppInitializer,
542
- deps: [Injector, SCRIPT, SwRegistrationOptions],
543
- multi: true,
575
+ deps: [SwRegistrationOptions, Injector],
544
576
  },
577
+ provideAppInitializer(ngswAppInitializer),
545
578
  ]);
546
579
  }
547
580
 
@@ -561,11 +594,11 @@ class ServiceWorkerModule {
561
594
  providers: [provideServiceWorker(script, options)],
562
595
  };
563
596
  }
564
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.0.0-next.4", ngImport: i0, type: ServiceWorkerModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
565
- static ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "20.0.0-next.4", ngImport: i0, type: ServiceWorkerModule });
566
- static ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "20.0.0-next.4", ngImport: i0, type: ServiceWorkerModule, providers: [SwPush, SwUpdate] });
597
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.0.0-next.6", ngImport: i0, type: ServiceWorkerModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
598
+ static ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "20.0.0-next.6", ngImport: i0, type: ServiceWorkerModule });
599
+ static ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "20.0.0-next.6", ngImport: i0, type: ServiceWorkerModule, providers: [SwPush, SwUpdate] });
567
600
  }
568
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.0.0-next.4", ngImport: i0, type: ServiceWorkerModule, decorators: [{
601
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.0.0-next.6", ngImport: i0, type: ServiceWorkerModule, decorators: [{
569
602
  type: NgModule,
570
603
  args: [{ providers: [SwPush, SwUpdate] }]
571
604
  }] });
@@ -1 +1 @@
1
- {"version":3,"file":"service-worker.mjs","sources":["../../../../../../packages/service-worker/src/low_level.ts","../../../../../../packages/service-worker/src/push.ts","../../../../../../packages/service-worker/src/update.ts","../../../../../../packages/service-worker/src/provider.ts","../../../../../../packages/service-worker/src/module.ts"],"sourcesContent":["/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.dev/license\n */\n\nimport {concat, ConnectableObservable, defer, fromEvent, Observable, of, throwError} from 'rxjs';\nimport {filter, map, publish, switchMap, take, tap} from 'rxjs/operators';\n\nexport const ERR_SW_NOT_SUPPORTED = 'Service workers are disabled or not supported by this browser';\n\n/**\n * An event emitted when the service worker has checked the version of the app on the server and it\n * didn't find a new version that it doesn't have already downloaded.\n *\n * @see {@link /ecosystem/service-workers/communications Service Worker Communication Guide}\n\n *\n * @publicApi\n */\nexport interface NoNewVersionDetectedEvent {\n type: 'NO_NEW_VERSION_DETECTED';\n version: {hash: string; appData?: Object};\n}\n\n/**\n * An event emitted when the service worker has detected a new version of the app on the server and\n * is about to start downloading it.\n *\n * @see {@link /ecosystem/service-workers/communications Service Worker Communication Guide}\n\n *\n * @publicApi\n */\nexport interface VersionDetectedEvent {\n type: 'VERSION_DETECTED';\n version: {hash: string; appData?: object};\n}\n\n/**\n * An event emitted when the installation of a new version failed.\n * It may be used for logging/monitoring purposes.\n *\n * @see {@link /ecosystem/service-workers/communications Service Worker Communication Guide}\n *a\n * @publicApi\n */\nexport interface VersionInstallationFailedEvent {\n type: 'VERSION_INSTALLATION_FAILED';\n version: {hash: string; appData?: object};\n error: string;\n}\n\n/**\n * An event emitted when a new version of the app is available.\n *\n * @see {@link /ecosystem/service-workers/communications Service Worker Communication Guide}\n\n *\n * @publicApi\n */\nexport interface VersionReadyEvent {\n type: 'VERSION_READY';\n currentVersion: {hash: string; appData?: object};\n latestVersion: {hash: string; appData?: object};\n}\n\n/**\n * A union of all event types that can be emitted by\n * {@link SwUpdate#versionUpdates}.\n *\n * @publicApi\n */\nexport type VersionEvent =\n | VersionDetectedEvent\n | VersionInstallationFailedEvent\n | VersionReadyEvent\n | NoNewVersionDetectedEvent;\n\n/**\n * An event emitted when the version of the app used by the service worker to serve this client is\n * in a broken state that cannot be recovered from and a full page reload is required.\n *\n * For example, the service worker may not be able to retrieve a required resource, neither from the\n * cache nor from the server. This could happen if a new version is deployed to the server and the\n * service worker cache has been partially cleaned by the browser, removing some files of a previous\n * app version but not all.\n *\n * @see {@link /ecosystem/service-workers/communications Service Worker Communication Guide}\n\n *\n * @publicApi\n */\nexport interface UnrecoverableStateEvent {\n type: 'UNRECOVERABLE_STATE';\n reason: string;\n}\n\n/**\n * An event emitted when a `PushEvent` is received by the service worker.\n */\nexport interface PushEvent {\n type: 'PUSH';\n data: any;\n}\n\nexport type IncomingEvent = UnrecoverableStateEvent | VersionEvent;\n\nexport interface TypedEvent {\n type: string;\n}\n\ntype OperationCompletedEvent =\n | {\n type: 'OPERATION_COMPLETED';\n nonce: number;\n result: boolean;\n }\n | {\n type: 'OPERATION_COMPLETED';\n nonce: number;\n result?: undefined;\n error: string;\n };\n\nfunction errorObservable(message: string): Observable<any> {\n return defer(() => throwError(new Error(message)));\n}\n\n/**\n * @publicApi\n */\nexport class NgswCommChannel {\n readonly worker: Observable<ServiceWorker>;\n\n readonly registration: Observable<ServiceWorkerRegistration>;\n\n readonly events: Observable<TypedEvent>;\n\n constructor(private serviceWorker: ServiceWorkerContainer | undefined) {\n if (!serviceWorker) {\n this.worker = this.events = this.registration = errorObservable(ERR_SW_NOT_SUPPORTED);\n } else {\n const controllerChangeEvents = fromEvent(serviceWorker, 'controllerchange');\n const controllerChanges = controllerChangeEvents.pipe(map(() => serviceWorker.controller));\n const currentController = defer(() => of(serviceWorker.controller));\n const controllerWithChanges = concat(currentController, controllerChanges);\n\n this.worker = controllerWithChanges.pipe(filter((c): c is ServiceWorker => !!c));\n\n this.registration = <Observable<ServiceWorkerRegistration>>(\n this.worker.pipe(switchMap(() => serviceWorker.getRegistration()))\n );\n\n const rawEvents = fromEvent<MessageEvent>(serviceWorker, 'message');\n const rawEventPayload = rawEvents.pipe(map((event) => event.data));\n const eventsUnconnected = rawEventPayload.pipe(filter((event) => event && event.type));\n const events = eventsUnconnected.pipe(publish()) as ConnectableObservable<IncomingEvent>;\n events.connect();\n\n this.events = events;\n }\n }\n\n postMessage(action: string, payload: Object): Promise<void> {\n return this.worker\n .pipe(\n take(1),\n tap((sw: ServiceWorker) => {\n sw.postMessage({\n action,\n ...payload,\n });\n }),\n )\n .toPromise()\n .then(() => undefined);\n }\n\n postMessageWithOperation(\n type: string,\n payload: Object,\n operationNonce: number,\n ): Promise<boolean> {\n const waitForOperationCompleted = this.waitForOperationCompleted(operationNonce);\n const postMessage = this.postMessage(type, payload);\n return Promise.all([postMessage, waitForOperationCompleted]).then(([, result]) => result);\n }\n\n generateNonce(): number {\n return Math.round(Math.random() * 10000000);\n }\n\n eventsOfType<T extends TypedEvent>(type: T['type'] | T['type'][]): Observable<T> {\n let filterFn: (event: TypedEvent) => event is T;\n if (typeof type === 'string') {\n filterFn = (event: TypedEvent): event is T => event.type === type;\n } else {\n filterFn = (event: TypedEvent): event is T => type.includes(event.type);\n }\n return this.events.pipe(filter(filterFn));\n }\n\n nextEventOfType<T extends TypedEvent>(type: T['type']): Observable<T> {\n return this.eventsOfType(type).pipe(take(1));\n }\n\n waitForOperationCompleted(nonce: number): Promise<boolean> {\n return this.eventsOfType<OperationCompletedEvent>('OPERATION_COMPLETED')\n .pipe(\n filter((event) => event.nonce === nonce),\n take(1),\n map((event) => {\n if (event.result !== undefined) {\n return event.result;\n }\n throw new Error(event.error!);\n }),\n )\n .toPromise() as Promise<boolean>;\n }\n\n get isEnabled(): boolean {\n return !!this.serviceWorker;\n }\n}\n","/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.dev/license\n */\n\nimport {Injectable} from '@angular/core';\nimport {merge, NEVER, Observable, Subject} from 'rxjs';\nimport {map, switchMap, take} from 'rxjs/operators';\n\nimport {ERR_SW_NOT_SUPPORTED, NgswCommChannel, PushEvent} from './low_level';\n\n/**\n * Subscribe and listen to\n * [Web Push\n * Notifications](https://developer.mozilla.org/en-US/docs/Web/API/Push_API/Best_Practices) through\n * Angular Service Worker.\n *\n * @usageNotes\n *\n * You can inject a `SwPush` instance into any component or service\n * as a dependency.\n *\n * <code-example path=\"service-worker/push/module.ts\" region=\"inject-sw-push\"\n * header=\"app.component.ts\"></code-example>\n *\n * To subscribe, call `SwPush.requestSubscription()`, which asks the user for permission.\n * The call returns a `Promise` with a new\n * [`PushSubscription`](https://developer.mozilla.org/en-US/docs/Web/API/PushSubscription)\n * instance.\n *\n * <code-example path=\"service-worker/push/module.ts\" region=\"subscribe-to-push\"\n * header=\"app.component.ts\"></code-example>\n *\n * A request is rejected if the user denies permission, or if the browser\n * blocks or does not support the Push API or ServiceWorkers.\n * Check `SwPush.isEnabled` to confirm status.\n *\n * Invoke Push Notifications by pushing a message with the following payload.\n *\n * ```ts\n * {\n * \"notification\": {\n * \"actions\": NotificationAction[],\n * \"badge\": USVString,\n * \"body\": DOMString,\n * \"data\": any,\n * \"dir\": \"auto\"|\"ltr\"|\"rtl\",\n * \"icon\": USVString,\n * \"image\": USVString,\n * \"lang\": DOMString,\n * \"renotify\": boolean,\n * \"requireInteraction\": boolean,\n * \"silent\": boolean,\n * \"tag\": DOMString,\n * \"timestamp\": DOMTimeStamp,\n * \"title\": DOMString,\n * \"vibrate\": number[]\n * }\n * }\n * ```\n *\n * Only `title` is required. See `Notification`\n * [instance\n * properties](https://developer.mozilla.org/en-US/docs/Web/API/Notification#Instance_properties).\n *\n * While the subscription is active, Service Worker listens for\n * [PushEvent](https://developer.mozilla.org/en-US/docs/Web/API/PushEvent)\n * occurrences and creates\n * [Notification](https://developer.mozilla.org/en-US/docs/Web/API/Notification)\n * instances in response.\n *\n * Unsubscribe using `SwPush.unsubscribe()`.\n *\n * An application can subscribe to `SwPush.notificationClicks` observable to be notified when a user\n * clicks on a notification. For example:\n *\n * <code-example path=\"service-worker/push/module.ts\" region=\"subscribe-to-notification-clicks\"\n * header=\"app.component.ts\"></code-example>\n *\n * You can read more on handling notification clicks in the [Service worker notifications\n * guide](ecosystem/service-workers/push-notifications).\n *\n * @see [Push Notifications](https://developers.google.com/web/fundamentals/codelabs/push-notifications/)\n * @see [Angular Push Notifications](https://blog.angular-university.io/angular-push-notifications/)\n * @see [MDN: Push API](https://developer.mozilla.org/en-US/docs/Web/API/Push_API)\n * @see [MDN: Notifications API](https://developer.mozilla.org/en-US/docs/Web/API/Notifications_API)\n * @see [MDN: Web Push API Notifications best practices](https://developer.mozilla.org/en-US/docs/Web/API/Push_API/Best_Practices)\n *\n * @publicApi\n */\n@Injectable()\nexport class SwPush {\n /**\n * Emits the payloads of the received push notification messages.\n */\n readonly messages: Observable<object>;\n\n /**\n * Emits the payloads of the received push notification messages as well as the action the user\n * interacted with. If no action was used the `action` property contains an empty string `''`.\n *\n * Note that the `notification` property does **not** contain a\n * [Notification][Mozilla Notification] object but rather a\n * [NotificationOptions](https://notifications.spec.whatwg.org/#dictdef-notificationoptions)\n * object that also includes the `title` of the [Notification][Mozilla Notification] object.\n *\n * [Mozilla Notification]: https://developer.mozilla.org/en-US/docs/Web/API/Notification\n */\n readonly notificationClicks: Observable<{\n action: string;\n notification: NotificationOptions & {\n title: string;\n };\n }>;\n\n /**\n * Emits the currently active\n * [PushSubscription](https://developer.mozilla.org/en-US/docs/Web/API/PushSubscription)\n * associated to the Service Worker registration or `null` if there is no subscription.\n */\n readonly subscription: Observable<PushSubscription | null>;\n\n /**\n * True if the Service Worker is enabled (supported by the browser and enabled via\n * `ServiceWorkerModule`).\n */\n get isEnabled(): boolean {\n return this.sw.isEnabled;\n }\n\n private pushManager: Observable<PushManager> | null = null;\n private subscriptionChanges = new Subject<PushSubscription | null>();\n\n constructor(private sw: NgswCommChannel) {\n if (!sw.isEnabled) {\n this.messages = NEVER;\n this.notificationClicks = NEVER;\n this.subscription = NEVER;\n return;\n }\n\n this.messages = this.sw.eventsOfType<PushEvent>('PUSH').pipe(map((message) => message.data));\n\n this.notificationClicks = this.sw\n .eventsOfType('NOTIFICATION_CLICK')\n .pipe(map((message: any) => message.data));\n\n this.pushManager = this.sw.registration.pipe(map((registration) => registration.pushManager));\n\n const workerDrivenSubscriptions = this.pushManager.pipe(\n switchMap((pm) => pm.getSubscription()),\n );\n this.subscription = merge(workerDrivenSubscriptions, this.subscriptionChanges);\n }\n\n /**\n * Subscribes to Web Push Notifications,\n * after requesting and receiving user permission.\n *\n * @param options An object containing the `serverPublicKey` string.\n * @returns A Promise that resolves to the new subscription object.\n */\n requestSubscription(options: {serverPublicKey: string}): Promise<PushSubscription> {\n if (!this.sw.isEnabled || this.pushManager === null) {\n return Promise.reject(new Error(ERR_SW_NOT_SUPPORTED));\n }\n const pushOptions: PushSubscriptionOptionsInit = {userVisibleOnly: true};\n let key = this.decodeBase64(options.serverPublicKey.replace(/_/g, '/').replace(/-/g, '+'));\n let applicationServerKey = new Uint8Array(new ArrayBuffer(key.length));\n for (let i = 0; i < key.length; i++) {\n applicationServerKey[i] = key.charCodeAt(i);\n }\n pushOptions.applicationServerKey = applicationServerKey;\n\n return this.pushManager\n .pipe(\n switchMap((pm) => pm.subscribe(pushOptions)),\n take(1),\n )\n .toPromise()\n .then((sub) => {\n this.subscriptionChanges.next(sub!);\n return sub!;\n });\n }\n\n /**\n * Unsubscribes from Service Worker push notifications.\n *\n * @returns A Promise that is resolved when the operation succeeds, or is rejected if there is no\n * active subscription or the unsubscribe operation fails.\n */\n unsubscribe(): Promise<void> {\n if (!this.sw.isEnabled) {\n return Promise.reject(new Error(ERR_SW_NOT_SUPPORTED));\n }\n\n const doUnsubscribe = (sub: PushSubscription | null) => {\n if (sub === null) {\n throw new Error('Not subscribed to push notifications.');\n }\n\n return sub.unsubscribe().then((success) => {\n if (!success) {\n throw new Error('Unsubscribe failed!');\n }\n\n this.subscriptionChanges.next(null);\n });\n };\n\n return this.subscription.pipe(take(1), switchMap(doUnsubscribe)).toPromise();\n }\n\n private decodeBase64(input: string): string {\n return atob(input);\n }\n}\n","/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.dev/license\n */\n\nimport {Injectable} from '@angular/core';\nimport {NEVER, Observable} from 'rxjs';\n\nimport {\n ERR_SW_NOT_SUPPORTED,\n NgswCommChannel,\n UnrecoverableStateEvent,\n VersionEvent,\n} from './low_level';\n\n/**\n * Subscribe to update notifications from the Service Worker, trigger update\n * checks, and forcibly activate updates.\n *\n * @see {@link /ecosystem/service-workers/communications Service Worker Communication Guide}\n *\n * @publicApi\n */\n@Injectable()\nexport class SwUpdate {\n /**\n * Emits a `VersionDetectedEvent` event whenever a new version is detected on the server.\n *\n * Emits a `VersionInstallationFailedEvent` event whenever checking for or downloading a new\n * version fails.\n *\n * Emits a `VersionReadyEvent` event whenever a new version has been downloaded and is ready for\n * activation.\n */\n readonly versionUpdates: Observable<VersionEvent>;\n\n /**\n * Emits an `UnrecoverableStateEvent` event whenever the version of the app used by the service\n * worker to serve this client is in a broken state that cannot be recovered from without a full\n * page reload.\n */\n readonly unrecoverable: Observable<UnrecoverableStateEvent>;\n\n /**\n * True if the Service Worker is enabled (supported by the browser and enabled via\n * `ServiceWorkerModule`).\n */\n get isEnabled(): boolean {\n return this.sw.isEnabled;\n }\n\n constructor(private sw: NgswCommChannel) {\n if (!sw.isEnabled) {\n this.versionUpdates = NEVER;\n this.unrecoverable = NEVER;\n return;\n }\n this.versionUpdates = this.sw.eventsOfType<VersionEvent>([\n 'VERSION_DETECTED',\n 'VERSION_INSTALLATION_FAILED',\n 'VERSION_READY',\n 'NO_NEW_VERSION_DETECTED',\n ]);\n this.unrecoverable = this.sw.eventsOfType<UnrecoverableStateEvent>('UNRECOVERABLE_STATE');\n }\n\n /**\n * Checks for an update and waits until the new version is downloaded from the server and ready\n * for activation.\n *\n * @returns a promise that\n * - resolves to `true` if a new version was found and is ready to be activated.\n * - resolves to `false` if no new version was found\n * - rejects if any error occurs\n */\n checkForUpdate(): Promise<boolean> {\n if (!this.sw.isEnabled) {\n return Promise.reject(new Error(ERR_SW_NOT_SUPPORTED));\n }\n const nonce = this.sw.generateNonce();\n return this.sw.postMessageWithOperation('CHECK_FOR_UPDATES', {nonce}, nonce);\n }\n\n /**\n * Updates the current client (i.e. browser tab) to the latest version that is ready for\n * activation.\n *\n * In most cases, you should not use this method and instead should update a client by reloading\n * the page.\n *\n * <div class=\"docs-alert docs-alert-important\">\n *\n * Updating a client without reloading can easily result in a broken application due to a version\n * mismatch between the application shell and other page resources,\n * such as lazy-loaded chunks, whose filenames may change between\n * versions.\n *\n * Only use this method, if you are certain it is safe for your specific use case.\n *\n * </div>\n *\n * @returns a promise that\n * - resolves to `true` if an update was activated successfully\n * - resolves to `false` if no update was available (for example, the client was already on the\n * latest version).\n * - rejects if any error occurs\n */\n activateUpdate(): Promise<boolean> {\n if (!this.sw.isEnabled) {\n return Promise.reject(new Error(ERR_SW_NOT_SUPPORTED));\n }\n const nonce = this.sw.generateNonce();\n return this.sw.postMessageWithOperation('ACTIVATE_UPDATE', {nonce}, nonce);\n }\n}\n","/*!\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.dev/license\n */\n\nimport {\n APP_INITIALIZER,\n ApplicationRef,\n EnvironmentProviders,\n InjectionToken,\n Injector,\n makeEnvironmentProviders,\n NgZone,\n} from '@angular/core';\nimport {merge, from, Observable, of} from 'rxjs';\nimport {delay, take} from 'rxjs/operators';\n\nimport {NgswCommChannel} from './low_level';\nimport {SwPush} from './push';\nimport {SwUpdate} from './update';\n\nexport const SCRIPT = new InjectionToken<string>(ngDevMode ? 'NGSW_REGISTER_SCRIPT' : '');\n\nexport function ngswAppInitializer(\n injector: Injector,\n script: string,\n options: SwRegistrationOptions,\n): Function {\n return () => {\n if (typeof ngServerMode !== 'undefined' && ngServerMode) {\n return;\n }\n\n if (!('serviceWorker' in navigator && options.enabled !== false)) {\n return;\n }\n\n const ngZone = injector.get(NgZone);\n const appRef = injector.get(ApplicationRef);\n\n // Set up the `controllerchange` event listener outside of\n // the Angular zone to avoid unnecessary change detections,\n // as this event has no impact on view updates.\n ngZone.runOutsideAngular(() => {\n // Wait for service worker controller changes, and fire an INITIALIZE action when a new SW\n // becomes active. This allows the SW to initialize itself even if there is no application\n // traffic.\n const sw = navigator.serviceWorker;\n const onControllerChange = () => sw.controller?.postMessage({action: 'INITIALIZE'});\n\n sw.addEventListener('controllerchange', onControllerChange);\n\n appRef.onDestroy(() => {\n sw.removeEventListener('controllerchange', onControllerChange);\n });\n });\n\n let readyToRegister$: Observable<unknown>;\n\n if (typeof options.registrationStrategy === 'function') {\n readyToRegister$ = options.registrationStrategy();\n } else {\n const [strategy, ...args] = (\n options.registrationStrategy || 'registerWhenStable:30000'\n ).split(':');\n\n switch (strategy) {\n case 'registerImmediately':\n readyToRegister$ = of(null);\n break;\n case 'registerWithDelay':\n readyToRegister$ = delayWithTimeout(+args[0] || 0);\n break;\n case 'registerWhenStable':\n const whenStable$ = from(injector.get(ApplicationRef).whenStable());\n readyToRegister$ = !args[0]\n ? whenStable$\n : merge(whenStable$, delayWithTimeout(+args[0]));\n break;\n default:\n // Unknown strategy.\n throw new Error(\n `Unknown ServiceWorker registration strategy: ${options.registrationStrategy}`,\n );\n }\n }\n\n // Don't return anything to avoid blocking the application until the SW is registered.\n // Also, run outside the Angular zone to avoid preventing the app from stabilizing (especially\n // given that some registration strategies wait for the app to stabilize).\n // Catch and log the error if SW registration fails to avoid uncaught rejection warning.\n ngZone.runOutsideAngular(() =>\n readyToRegister$\n .pipe(take(1))\n .subscribe(() =>\n navigator.serviceWorker\n .register(script, {scope: options.scope})\n .catch((err) => console.error('Service worker registration failed with:', err)),\n ),\n );\n };\n}\n\nfunction delayWithTimeout(timeout: number): Observable<unknown> {\n return of(null).pipe(delay(timeout));\n}\n\nexport function ngswCommChannelFactory(opts: SwRegistrationOptions): NgswCommChannel {\n const isBrowser = !(typeof ngServerMode !== 'undefined' && ngServerMode);\n\n return new NgswCommChannel(\n isBrowser && opts.enabled !== false ? navigator.serviceWorker : undefined,\n );\n}\n\n/**\n * Token that can be used to provide options for `ServiceWorkerModule` outside of\n * `ServiceWorkerModule.register()`.\n *\n * You can use this token to define a provider that generates the registration options at runtime,\n * for example via a function call:\n *\n * {@example service-worker/registration-options/module.ts region=\"registration-options\"\n * header=\"app.module.ts\"}\n *\n * @publicApi\n */\nexport abstract class SwRegistrationOptions {\n /**\n * Whether the ServiceWorker will be registered and the related services (such as `SwPush` and\n * `SwUpdate`) will attempt to communicate and interact with it.\n *\n * Default: true\n */\n enabled?: boolean;\n\n /**\n * A URL that defines the ServiceWorker's registration scope; that is, what range of URLs it can\n * control. It will be used when calling\n * [ServiceWorkerContainer#register()](https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorkerContainer/register).\n */\n scope?: string;\n\n /**\n * Defines the ServiceWorker registration strategy, which determines when it will be registered\n * with the browser.\n *\n * The default behavior of registering once the application stabilizes (i.e. as soon as there are\n * no pending micro- and macro-tasks) is designed to register the ServiceWorker as soon as\n * possible but without affecting the application's first time load.\n *\n * Still, there might be cases where you want more control over when the ServiceWorker is\n * registered (for example, there might be a long-running timeout or polling interval, preventing\n * the app from stabilizing). The available option are:\n *\n * - `registerWhenStable:<timeout>`: Register as soon as the application stabilizes (no pending\n * micro-/macro-tasks) but no later than `<timeout>` milliseconds. If the app hasn't\n * stabilized after `<timeout>` milliseconds (for example, due to a recurrent asynchronous\n * task), the ServiceWorker will be registered anyway.\n * If `<timeout>` is omitted, the ServiceWorker will only be registered once the app\n * stabilizes.\n * - `registerImmediately`: Register immediately.\n * - `registerWithDelay:<timeout>`: Register with a delay of `<timeout>` milliseconds. For\n * example, use `registerWithDelay:5000` to register the ServiceWorker after 5 seconds. If\n * `<timeout>` is omitted, is defaults to `0`, which will register the ServiceWorker as soon\n * as possible but still asynchronously, once all pending micro-tasks are completed.\n * - An Observable factory function: A function that returns an `Observable`.\n * The function will be used at runtime to obtain and subscribe to the `Observable` and the\n * ServiceWorker will be registered as soon as the first value is emitted.\n *\n * Default: 'registerWhenStable:30000'\n */\n registrationStrategy?: string | (() => Observable<unknown>);\n}\n\n/**\n * @publicApi\n *\n * Sets up providers to register the given Angular Service Worker script.\n *\n * If `enabled` is set to `false` in the given options, the module will behave as if service\n * workers are not supported by the browser, and the service worker will not be registered.\n *\n * Example usage:\n * ```ts\n * bootstrapApplication(AppComponent, {\n * providers: [\n * provideServiceWorker('ngsw-worker.js')\n * ],\n * });\n * ```\n */\nexport function provideServiceWorker(\n script: string,\n options: SwRegistrationOptions = {},\n): EnvironmentProviders {\n return makeEnvironmentProviders([\n SwPush,\n SwUpdate,\n {provide: SCRIPT, useValue: script},\n {provide: SwRegistrationOptions, useValue: options},\n {\n provide: NgswCommChannel,\n useFactory: ngswCommChannelFactory,\n deps: [SwRegistrationOptions],\n },\n {\n provide: APP_INITIALIZER,\n useFactory: ngswAppInitializer,\n deps: [Injector, SCRIPT, SwRegistrationOptions],\n multi: true,\n },\n ]);\n}\n","/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.dev/license\n */\n\nimport {ModuleWithProviders, NgModule} from '@angular/core';\n\nimport {provideServiceWorker, SwRegistrationOptions} from './provider';\nimport {SwPush} from './push';\nimport {SwUpdate} from './update';\n\n/**\n * @publicApi\n */\n@NgModule({providers: [SwPush, SwUpdate]})\nexport class ServiceWorkerModule {\n /**\n * Register the given Angular Service Worker script.\n *\n * If `enabled` is set to `false` in the given options, the module will behave as if service\n * workers are not supported by the browser, and the service worker will not be registered.\n */\n static register(\n script: string,\n options: SwRegistrationOptions = {},\n ): ModuleWithProviders<ServiceWorkerModule> {\n return {\n ngModule: ServiceWorkerModule,\n providers: [provideServiceWorker(script, options)],\n };\n }\n}\n"],"names":["i1.NgswCommChannel"],"mappings":";;;;;;;;;;;AAWO,MAAM,oBAAoB,GAAG,+DAA+D;AAoHnG,SAAS,eAAe,CAAC,OAAe,EAAA;AACtC,IAAA,OAAO,KAAK,CAAC,MAAM,UAAU,CAAC,IAAI,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC;AACpD;AAEA;;AAEG;MACU,eAAe,CAAA;AAON,IAAA,aAAA;AANX,IAAA,MAAM;AAEN,IAAA,YAAY;AAEZ,IAAA,MAAM;AAEf,IAAA,WAAA,CAAoB,aAAiD,EAAA;QAAjD,IAAa,CAAA,aAAA,GAAb,aAAa;QAC/B,IAAI,CAAC,aAAa,EAAE;AAClB,YAAA,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,YAAY,GAAG,eAAe,CAAC,oBAAoB,CAAC;;aAChF;YACL,MAAM,sBAAsB,GAAG,SAAS,CAAC,aAAa,EAAE,kBAAkB,CAAC;AAC3E,YAAA,MAAM,iBAAiB,GAAG,sBAAsB,CAAC,IAAI,CAAC,GAAG,CAAC,MAAM,aAAa,CAAC,UA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O;AACL,YAAA,QAAQ,EAAE,mBAAmB;YAC7B,SAAS,EAAE,CAAC,oBAAoB,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;SACnD;;kHAdQ,mBAAmB,EAAA,IAAA,EAAA,EAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,QAAA,EAAA,CAAA;mHAAnB,mBAAmB,EAAA,CAAA;AAAnB,IAAA,OAAA,IAAA,GAAA,EAAA,CAAA,mBAAA,CAAA,EAAA,UAAA,EAAA,QAAA,EAAA,OAAA,EAAA,mBAAA,EAAA,QAAA,EAAA,EAAA,EAAA,IAAA,EAAA,mBAAmB,EADV,SAAA,EAAA,CAAC,MAAM,EAAE,QAAQ,CAAC,EAAA,CAAA;;sGAC3B,mBAAmB,EAAA,UAAA,EAAA,CAAA;kBAD/B,QAAQ;AAAC,YAAA,IAAA,EAAA,CAAA,EAAC,SAAS,EAAE,CAAC,MAAM,EAAE,QAAQ,CAAC,EAAC;;;;;"}
1
+ {"version":3,"file":"service-worker.mjs","sources":["../../../../../../packages/service-worker/src/low_level.ts","../../../../../../packages/service-worker/src/push.ts","../../../../../../packages/service-worker/src/update.ts","../../../../../../packages/service-worker/src/provider.ts","../../../../../../packages/service-worker/src/module.ts"],"sourcesContent":["/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.dev/license\n */\n\nimport {ApplicationRef, type Injector} from '@angular/core';\nimport {Observable, Subject} from 'rxjs';\nimport {filter, map, switchMap, take} from 'rxjs/operators';\n\nexport const ERR_SW_NOT_SUPPORTED = 'Service workers are disabled or not supported by this browser';\n\n/**\n * An event emitted when the service worker has checked the version of the app on the server and it\n * didn't find a new version that it doesn't have already downloaded.\n *\n * @see {@link /ecosystem/service-workers/communications Service Worker Communication Guide}\n\n *\n * @publicApi\n */\nexport interface NoNewVersionDetectedEvent {\n type: 'NO_NEW_VERSION_DETECTED';\n version: {hash: string; appData?: Object};\n}\n\n/**\n * An event emitted when the service worker has detected a new version of the app on the server and\n * is about to start downloading it.\n *\n * @see {@link /ecosystem/service-workers/communications Service Worker Communication Guide}\n\n *\n * @publicApi\n */\nexport interface VersionDetectedEvent {\n type: 'VERSION_DETECTED';\n version: {hash: string; appData?: object};\n}\n\n/**\n * An event emitted when the installation of a new version failed.\n * It may be used for logging/monitoring purposes.\n *\n * @see {@link /ecosystem/service-workers/communications Service Worker Communication Guide}\n *a\n * @publicApi\n */\nexport interface VersionInstallationFailedEvent {\n type: 'VERSION_INSTALLATION_FAILED';\n version: {hash: string; appData?: object};\n error: string;\n}\n\n/**\n * An event emitted when a new version of the app is available.\n *\n * @see {@link /ecosystem/service-workers/communications Service Worker Communication Guide}\n\n *\n * @publicApi\n */\nexport interface VersionReadyEvent {\n type: 'VERSION_READY';\n currentVersion: {hash: string; appData?: object};\n latestVersion: {hash: string; appData?: object};\n}\n\n/**\n * A union of all event types that can be emitted by\n * {@link SwUpdate#versionUpdates}.\n *\n * @publicApi\n */\nexport type VersionEvent =\n | VersionDetectedEvent\n | VersionInstallationFailedEvent\n | VersionReadyEvent\n | NoNewVersionDetectedEvent;\n\n/**\n * An event emitted when the version of the app used by the service worker to serve this client is\n * in a broken state that cannot be recovered from and a full page reload is required.\n *\n * For example, the service worker may not be able to retrieve a required resource, neither from the\n * cache nor from the server. This could happen if a new version is deployed to the server and the\n * service worker cache has been partially cleaned by the browser, removing some files of a previous\n * app version but not all.\n *\n * @see {@link /ecosystem/service-workers/communications Service Worker Communication Guide}\n\n *\n * @publicApi\n */\nexport interface UnrecoverableStateEvent {\n type: 'UNRECOVERABLE_STATE';\n reason: string;\n}\n\n/**\n * An event emitted when a `PushEvent` is received by the service worker.\n */\nexport interface PushEvent {\n type: 'PUSH';\n data: any;\n}\n\nexport type IncomingEvent = UnrecoverableStateEvent | VersionEvent;\n\nexport interface TypedEvent {\n type: string;\n}\n\ntype OperationCompletedEvent =\n | {\n type: 'OPERATION_COMPLETED';\n nonce: number;\n result: boolean;\n }\n | {\n type: 'OPERATION_COMPLETED';\n nonce: number;\n result?: undefined;\n error: string;\n };\n\n/**\n * @publicApi\n */\nexport class NgswCommChannel {\n readonly worker: Observable<ServiceWorker>;\n\n readonly registration: Observable<ServiceWorkerRegistration>;\n\n readonly events: Observable<TypedEvent>;\n\n constructor(\n private serviceWorker: ServiceWorkerContainer | undefined,\n injector?: Injector,\n ) {\n if (!serviceWorker) {\n this.worker =\n this.events =\n this.registration =\n new Observable<never>((subscriber) => subscriber.error(new Error(ERR_SW_NOT_SUPPORTED)));\n } else {\n let currentWorker: ServiceWorker | null = null;\n const workerSubject = new Subject<ServiceWorker>();\n this.worker = new Observable((subscriber) => {\n if (currentWorker !== null) {\n subscriber.next(currentWorker);\n }\n return workerSubject.subscribe((v) => subscriber.next(v));\n });\n const updateController = () => {\n const {controller} = serviceWorker;\n if (controller === null) {\n return;\n }\n currentWorker = controller;\n workerSubject.next(currentWorker);\n };\n serviceWorker.addEventListener('controllerchange', updateController);\n updateController();\n\n this.registration = <Observable<ServiceWorkerRegistration>>(\n this.worker.pipe(switchMap(() => serviceWorker.getRegistration()))\n );\n\n const _events = new Subject<TypedEvent>();\n this.events = _events.asObservable();\n\n const messageListener = (event: MessageEvent) => {\n const {data} = event;\n if (data?.type) {\n _events.next(data);\n }\n };\n serviceWorker.addEventListener('message', messageListener);\n\n // The injector is optional to avoid breaking changes.\n const appRef = injector?.get(ApplicationRef, null, {optional: true});\n appRef?.onDestroy(() => {\n serviceWorker.removeEventListener('controllerchange', updateController);\n serviceWorker.removeEventListener('message', messageListener);\n });\n }\n }\n\n postMessage(action: string, payload: Object): Promise<void> {\n return new Promise<void>((resolve) => {\n this.worker.pipe(take(1)).subscribe((sw) => {\n sw.postMessage({\n action,\n ...payload,\n });\n\n resolve();\n });\n });\n }\n\n postMessageWithOperation(\n type: string,\n payload: Object,\n operationNonce: number,\n ): Promise<boolean> {\n const waitForOperationCompleted = this.waitForOperationCompleted(operationNonce);\n const postMessage = this.postMessage(type, payload);\n return Promise.all([postMessage, waitForOperationCompleted]).then(([, result]) => result);\n }\n\n generateNonce(): number {\n return Math.round(Math.random() * 10000000);\n }\n\n eventsOfType<T extends TypedEvent>(type: T['type'] | T['type'][]): Observable<T> {\n let filterFn: (event: TypedEvent) => event is T;\n if (typeof type === 'string') {\n filterFn = (event: TypedEvent): event is T => event.type === type;\n } else {\n filterFn = (event: TypedEvent): event is T => type.includes(event.type);\n }\n return this.events.pipe(filter(filterFn));\n }\n\n nextEventOfType<T extends TypedEvent>(type: T['type']): Observable<T> {\n return this.eventsOfType(type).pipe(take(1));\n }\n\n waitForOperationCompleted(nonce: number): Promise<boolean> {\n return new Promise<boolean>((resolve, reject) => {\n this.eventsOfType<OperationCompletedEvent>('OPERATION_COMPLETED')\n .pipe(\n filter((event) => event.nonce === nonce),\n take(1),\n map((event) => {\n if (event.result !== undefined) {\n return event.result;\n }\n throw new Error(event.error!);\n }),\n )\n .subscribe({\n next: resolve,\n error: reject,\n });\n });\n }\n\n get isEnabled(): boolean {\n return !!this.serviceWorker;\n }\n}\n","/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.dev/license\n */\n\nimport {Injectable} from '@angular/core';\nimport {NEVER, Observable, Subject} from 'rxjs';\nimport {map, switchMap, take} from 'rxjs/operators';\n\nimport {ERR_SW_NOT_SUPPORTED, NgswCommChannel, PushEvent} from './low_level';\n\n/**\n * Subscribe and listen to\n * [Web Push\n * Notifications](https://developer.mozilla.org/en-US/docs/Web/API/Push_API/Best_Practices) through\n * Angular Service Worker.\n *\n * @usageNotes\n *\n * You can inject a `SwPush` instance into any component or service\n * as a dependency.\n *\n * <code-example path=\"service-worker/push/module.ts\" region=\"inject-sw-push\"\n * header=\"app.component.ts\"></code-example>\n *\n * To subscribe, call `SwPush.requestSubscription()`, which asks the user for permission.\n * The call returns a `Promise` with a new\n * [`PushSubscription`](https://developer.mozilla.org/en-US/docs/Web/API/PushSubscription)\n * instance.\n *\n * <code-example path=\"service-worker/push/module.ts\" region=\"subscribe-to-push\"\n * header=\"app.component.ts\"></code-example>\n *\n * A request is rejected if the user denies permission, or if the browser\n * blocks or does not support the Push API or ServiceWorkers.\n * Check `SwPush.isEnabled` to confirm status.\n *\n * Invoke Push Notifications by pushing a message with the following payload.\n *\n * ```ts\n * {\n * \"notification\": {\n * \"actions\": NotificationAction[],\n * \"badge\": USVString,\n * \"body\": DOMString,\n * \"data\": any,\n * \"dir\": \"auto\"|\"ltr\"|\"rtl\",\n * \"icon\": USVString,\n * \"image\": USVString,\n * \"lang\": DOMString,\n * \"renotify\": boolean,\n * \"requireInteraction\": boolean,\n * \"silent\": boolean,\n * \"tag\": DOMString,\n * \"timestamp\": DOMTimeStamp,\n * \"title\": DOMString,\n * \"vibrate\": number[]\n * }\n * }\n * ```\n *\n * Only `title` is required. See `Notification`\n * [instance\n * properties](https://developer.mozilla.org/en-US/docs/Web/API/Notification#Instance_properties).\n *\n * While the subscription is active, Service Worker listens for\n * [PushEvent](https://developer.mozilla.org/en-US/docs/Web/API/PushEvent)\n * occurrences and creates\n * [Notification](https://developer.mozilla.org/en-US/docs/Web/API/Notification)\n * instances in response.\n *\n * Unsubscribe using `SwPush.unsubscribe()`.\n *\n * An application can subscribe to `SwPush.notificationClicks` observable to be notified when a user\n * clicks on a notification. For example:\n *\n * <code-example path=\"service-worker/push/module.ts\" region=\"subscribe-to-notification-clicks\"\n * header=\"app.component.ts\"></code-example>\n *\n * You can read more on handling notification clicks in the [Service worker notifications\n * guide](ecosystem/service-workers/push-notifications).\n *\n * @see [Push Notifications](https://developers.google.com/web/fundamentals/codelabs/push-notifications/)\n * @see [Angular Push Notifications](https://blog.angular-university.io/angular-push-notifications/)\n * @see [MDN: Push API](https://developer.mozilla.org/en-US/docs/Web/API/Push_API)\n * @see [MDN: Notifications API](https://developer.mozilla.org/en-US/docs/Web/API/Notifications_API)\n * @see [MDN: Web Push API Notifications best practices](https://developer.mozilla.org/en-US/docs/Web/API/Push_API/Best_Practices)\n *\n * @publicApi\n */\n@Injectable()\nexport class SwPush {\n /**\n * Emits the payloads of the received push notification messages.\n */\n readonly messages: Observable<object>;\n\n /**\n * Emits the payloads of the received push notification messages as well as the action the user\n * interacted with. If no action was used the `action` property contains an empty string `''`.\n *\n * Note that the `notification` property does **not** contain a\n * [Notification][Mozilla Notification] object but rather a\n * [NotificationOptions](https://notifications.spec.whatwg.org/#dictdef-notificationoptions)\n * object that also includes the `title` of the [Notification][Mozilla Notification] object.\n *\n * [Mozilla Notification]: https://developer.mozilla.org/en-US/docs/Web/API/Notification\n */\n readonly notificationClicks: Observable<{\n action: string;\n notification: NotificationOptions & {\n title: string;\n };\n }>;\n\n /**\n * Emits the currently active\n * [PushSubscription](https://developer.mozilla.org/en-US/docs/Web/API/PushSubscription)\n * associated to the Service Worker registration or `null` if there is no subscription.\n */\n readonly subscription: Observable<PushSubscription | null>;\n\n /**\n * True if the Service Worker is enabled (supported by the browser and enabled via\n * `ServiceWorkerModule`).\n */\n get isEnabled(): boolean {\n return this.sw.isEnabled;\n }\n\n private pushManager: Observable<PushManager> | null = null;\n private subscriptionChanges = new Subject<PushSubscription | null>();\n\n constructor(private sw: NgswCommChannel) {\n if (!sw.isEnabled) {\n this.messages = NEVER;\n this.notificationClicks = NEVER;\n this.subscription = NEVER;\n return;\n }\n\n this.messages = this.sw.eventsOfType<PushEvent>('PUSH').pipe(map((message) => message.data));\n\n this.notificationClicks = this.sw\n .eventsOfType('NOTIFICATION_CLICK')\n .pipe(map((message: any) => message.data));\n\n this.pushManager = this.sw.registration.pipe(map((registration) => registration.pushManager));\n\n const workerDrivenSubscriptions = this.pushManager.pipe(\n switchMap((pm) => pm.getSubscription()),\n );\n this.subscription = new Observable((subscriber) => {\n const workerDrivenSubscription = workerDrivenSubscriptions.subscribe(subscriber);\n const subscriptionChanges = this.subscriptionChanges.subscribe(subscriber);\n return () => {\n workerDrivenSubscription.unsubscribe();\n subscriptionChanges.unsubscribe();\n };\n });\n }\n\n /**\n * Subscribes to Web Push Notifications,\n * after requesting and receiving user permission.\n *\n * @param options An object containing the `serverPublicKey` string.\n * @returns A Promise that resolves to the new subscription object.\n */\n requestSubscription(options: {serverPublicKey: string}): Promise<PushSubscription> {\n if (!this.sw.isEnabled || this.pushManager === null) {\n return Promise.reject(new Error(ERR_SW_NOT_SUPPORTED));\n }\n const pushOptions: PushSubscriptionOptionsInit = {userVisibleOnly: true};\n let key = this.decodeBase64(options.serverPublicKey.replace(/_/g, '/').replace(/-/g, '+'));\n let applicationServerKey = new Uint8Array(new ArrayBuffer(key.length));\n for (let i = 0; i < key.length; i++) {\n applicationServerKey[i] = key.charCodeAt(i);\n }\n pushOptions.applicationServerKey = applicationServerKey;\n\n return new Promise((resolve, reject) => {\n this.pushManager!.pipe(\n switchMap((pm) => pm.subscribe(pushOptions)),\n take(1),\n ).subscribe({\n next: (sub) => {\n this.subscriptionChanges.next(sub);\n resolve(sub);\n },\n error: reject,\n });\n });\n }\n\n /**\n * Unsubscribes from Service Worker push notifications.\n *\n * @returns A Promise that is resolved when the operation succeeds, or is rejected if there is no\n * active subscription or the unsubscribe operation fails.\n */\n unsubscribe(): Promise<void> {\n if (!this.sw.isEnabled) {\n return Promise.reject(new Error(ERR_SW_NOT_SUPPORTED));\n }\n\n const doUnsubscribe = (sub: PushSubscription | null) => {\n if (sub === null) {\n throw new Error('Not subscribed to push notifications.');\n }\n\n return sub.unsubscribe().then((success) => {\n if (!success) {\n throw new Error('Unsubscribe failed!');\n }\n\n this.subscriptionChanges.next(null);\n });\n };\n\n return new Promise((resolve, reject) => {\n this.subscription\n .pipe(take(1), switchMap(doUnsubscribe))\n .subscribe({next: resolve, error: reject});\n });\n }\n\n private decodeBase64(input: string): string {\n return atob(input);\n }\n}\n","/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.dev/license\n */\n\nimport {Injectable} from '@angular/core';\nimport {NEVER, Observable} from 'rxjs';\n\nimport {\n ERR_SW_NOT_SUPPORTED,\n NgswCommChannel,\n UnrecoverableStateEvent,\n VersionEvent,\n} from './low_level';\n\n/**\n * Subscribe to update notifications from the Service Worker, trigger update\n * checks, and forcibly activate updates.\n *\n * @see {@link /ecosystem/service-workers/communications Service Worker Communication Guide}\n *\n * @publicApi\n */\n@Injectable()\nexport class SwUpdate {\n /**\n * Emits a `VersionDetectedEvent` event whenever a new version is detected on the server.\n *\n * Emits a `VersionInstallationFailedEvent` event whenever checking for or downloading a new\n * version fails.\n *\n * Emits a `VersionReadyEvent` event whenever a new version has been downloaded and is ready for\n * activation.\n */\n readonly versionUpdates: Observable<VersionEvent>;\n\n /**\n * Emits an `UnrecoverableStateEvent` event whenever the version of the app used by the service\n * worker to serve this client is in a broken state that cannot be recovered from without a full\n * page reload.\n */\n readonly unrecoverable: Observable<UnrecoverableStateEvent>;\n\n /**\n * True if the Service Worker is enabled (supported by the browser and enabled via\n * `ServiceWorkerModule`).\n */\n get isEnabled(): boolean {\n return this.sw.isEnabled;\n }\n\n constructor(private sw: NgswCommChannel) {\n if (!sw.isEnabled) {\n this.versionUpdates = NEVER;\n this.unrecoverable = NEVER;\n return;\n }\n this.versionUpdates = this.sw.eventsOfType<VersionEvent>([\n 'VERSION_DETECTED',\n 'VERSION_INSTALLATION_FAILED',\n 'VERSION_READY',\n 'NO_NEW_VERSION_DETECTED',\n ]);\n this.unrecoverable = this.sw.eventsOfType<UnrecoverableStateEvent>('UNRECOVERABLE_STATE');\n }\n\n /**\n * Checks for an update and waits until the new version is downloaded from the server and ready\n * for activation.\n *\n * @returns a promise that\n * - resolves to `true` if a new version was found and is ready to be activated.\n * - resolves to `false` if no new version was found\n * - rejects if any error occurs\n */\n checkForUpdate(): Promise<boolean> {\n if (!this.sw.isEnabled) {\n return Promise.reject(new Error(ERR_SW_NOT_SUPPORTED));\n }\n const nonce = this.sw.generateNonce();\n return this.sw.postMessageWithOperation('CHECK_FOR_UPDATES', {nonce}, nonce);\n }\n\n /**\n * Updates the current client (i.e. browser tab) to the latest version that is ready for\n * activation.\n *\n * In most cases, you should not use this method and instead should update a client by reloading\n * the page.\n *\n * <div class=\"docs-alert docs-alert-important\">\n *\n * Updating a client without reloading can easily result in a broken application due to a version\n * mismatch between the application shell and other page resources,\n * such as lazy-loaded chunks, whose filenames may change between\n * versions.\n *\n * Only use this method, if you are certain it is safe for your specific use case.\n *\n * </div>\n *\n * @returns a promise that\n * - resolves to `true` if an update was activated successfully\n * - resolves to `false` if no update was available (for example, the client was already on the\n * latest version).\n * - rejects if any error occurs\n */\n activateUpdate(): Promise<boolean> {\n if (!this.sw.isEnabled) {\n return Promise.reject(new Error(ERR_SW_NOT_SUPPORTED));\n }\n const nonce = this.sw.generateNonce();\n return this.sw.postMessageWithOperation('ACTIVATE_UPDATE', {nonce}, nonce);\n }\n}\n","/*!\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.dev/license\n */\n\nimport {\n ApplicationRef,\n EnvironmentProviders,\n inject,\n InjectionToken,\n Injector,\n makeEnvironmentProviders,\n NgZone,\n provideAppInitializer,\n} from '@angular/core';\nimport type {Observable} from 'rxjs';\n\nimport {NgswCommChannel} from './low_level';\nimport {SwPush} from './push';\nimport {SwUpdate} from './update';\n\nexport const SCRIPT = new InjectionToken<string>(ngDevMode ? 'NGSW_REGISTER_SCRIPT' : '');\n\nexport function ngswAppInitializer(): void {\n if (typeof ngServerMode !== 'undefined' && ngServerMode) {\n return;\n }\n\n const options = inject(SwRegistrationOptions);\n\n if (!('serviceWorker' in navigator && options.enabled !== false)) {\n return;\n }\n\n const script = inject(SCRIPT);\n const ngZone = inject(NgZone);\n const appRef = inject(ApplicationRef);\n\n // Set up the `controllerchange` event listener outside of\n // the Angular zone to avoid unnecessary change detections,\n // as this event has no impact on view updates.\n ngZone.runOutsideAngular(() => {\n // Wait for service worker controller changes, and fire an INITIALIZE action when a new SW\n // becomes active. This allows the SW to initialize itself even if there is no application\n // traffic.\n const sw = navigator.serviceWorker;\n const onControllerChange = () => sw.controller?.postMessage({action: 'INITIALIZE'});\n\n sw.addEventListener('controllerchange', onControllerChange);\n\n appRef.onDestroy(() => {\n sw.removeEventListener('controllerchange', onControllerChange);\n });\n });\n\n // Run outside the Angular zone to avoid preventing the app from stabilizing (especially\n // given that some registration strategies wait for the app to stabilize).\n ngZone.runOutsideAngular(() => {\n let readyToRegister: Promise<void>;\n\n const {registrationStrategy} = options;\n if (typeof registrationStrategy === 'function') {\n readyToRegister = new Promise((resolve) => registrationStrategy().subscribe(() => resolve()));\n } else {\n const [strategy, ...args] = (registrationStrategy || 'registerWhenStable:30000').split(':');\n\n switch (strategy) {\n case 'registerImmediately':\n readyToRegister = Promise.resolve();\n break;\n case 'registerWithDelay':\n readyToRegister = delayWithTimeout(+args[0] || 0);\n break;\n case 'registerWhenStable':\n readyToRegister = Promise.race([appRef.whenStable(), delayWithTimeout(+args[0])]);\n break;\n default:\n // Unknown strategy.\n throw new Error(\n `Unknown ServiceWorker registration strategy: ${options.registrationStrategy}`,\n );\n }\n }\n\n // Don't return anything to avoid blocking the application until the SW is registered.\n // Catch and log the error if SW registration fails to avoid uncaught rejection warning.\n readyToRegister.then(() =>\n navigator.serviceWorker\n .register(script, {scope: options.scope})\n .catch((err) => console.error('Service worker registration failed with:', err)),\n );\n });\n}\n\nfunction delayWithTimeout(timeout: number): Promise<void> {\n return new Promise((resolve) => setTimeout(resolve, timeout));\n}\n\nexport function ngswCommChannelFactory(\n opts: SwRegistrationOptions,\n injector: Injector,\n): NgswCommChannel {\n const isBrowser = !(typeof ngServerMode !== 'undefined' && ngServerMode);\n\n return new NgswCommChannel(\n isBrowser && opts.enabled !== false ? navigator.serviceWorker : undefined,\n injector,\n );\n}\n\n/**\n * Token that can be used to provide options for `ServiceWorkerModule` outside of\n * `ServiceWorkerModule.register()`.\n *\n * You can use this token to define a provider that generates the registration options at runtime,\n * for example via a function call:\n *\n * {@example service-worker/registration-options/module.ts region=\"registration-options\"\n * header=\"app.module.ts\"}\n *\n * @publicApi\n */\nexport abstract class SwRegistrationOptions {\n /**\n * Whether the ServiceWorker will be registered and the related services (such as `SwPush` and\n * `SwUpdate`) will attempt to communicate and interact with it.\n *\n * Default: true\n */\n enabled?: boolean;\n\n /**\n * A URL that defines the ServiceWorker's registration scope; that is, what range of URLs it can\n * control. It will be used when calling\n * [ServiceWorkerContainer#register()](https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorkerContainer/register).\n */\n scope?: string;\n\n /**\n * Defines the ServiceWorker registration strategy, which determines when it will be registered\n * with the browser.\n *\n * The default behavior of registering once the application stabilizes (i.e. as soon as there are\n * no pending micro- and macro-tasks) is designed to register the ServiceWorker as soon as\n * possible but without affecting the application's first time load.\n *\n * Still, there might be cases where you want more control over when the ServiceWorker is\n * registered (for example, there might be a long-running timeout or polling interval, preventing\n * the app from stabilizing). The available option are:\n *\n * - `registerWhenStable:<timeout>`: Register as soon as the application stabilizes (no pending\n * micro-/macro-tasks) but no later than `<timeout>` milliseconds. If the app hasn't\n * stabilized after `<timeout>` milliseconds (for example, due to a recurrent asynchronous\n * task), the ServiceWorker will be registered anyway.\n * If `<timeout>` is omitted, the ServiceWorker will only be registered once the app\n * stabilizes.\n * - `registerImmediately`: Register immediately.\n * - `registerWithDelay:<timeout>`: Register with a delay of `<timeout>` milliseconds. For\n * example, use `registerWithDelay:5000` to register the ServiceWorker after 5 seconds. If\n * `<timeout>` is omitted, is defaults to `0`, which will register the ServiceWorker as soon\n * as possible but still asynchronously, once all pending micro-tasks are completed.\n * - An Observable factory function: A function that returns an `Observable`.\n * The function will be used at runtime to obtain and subscribe to the `Observable` and the\n * ServiceWorker will be registered as soon as the first value is emitted.\n *\n * Default: 'registerWhenStable:30000'\n */\n registrationStrategy?: string | (() => Observable<unknown>);\n}\n\n/**\n * @publicApi\n *\n * Sets up providers to register the given Angular Service Worker script.\n *\n * If `enabled` is set to `false` in the given options, the module will behave as if service\n * workers are not supported by the browser, and the service worker will not be registered.\n *\n * Example usage:\n * ```ts\n * bootstrapApplication(AppComponent, {\n * providers: [\n * provideServiceWorker('ngsw-worker.js')\n * ],\n * });\n * ```\n */\nexport function provideServiceWorker(\n script: string,\n options: SwRegistrationOptions = {},\n): EnvironmentProviders {\n return makeEnvironmentProviders([\n SwPush,\n SwUpdate,\n {provide: SCRIPT, useValue: script},\n {provide: SwRegistrationOptions, useValue: options},\n {\n provide: NgswCommChannel,\n useFactory: ngswCommChannelFactory,\n deps: [SwRegistrationOptions, Injector],\n },\n provideAppInitializer(ngswAppInitializer),\n ]);\n}\n","/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.dev/license\n */\n\nimport {ModuleWithProviders, NgModule} from '@angular/core';\n\nimport {provideServiceWorker, SwRegistrationOptions} from './provider';\nimport {SwPush} from './push';\nimport {SwUpdate} from './update';\n\n/**\n * @publicApi\n */\n@NgModule({providers: [SwPush, SwUpdate]})\nexport class ServiceWorkerModule {\n /**\n * Register the given Angular Service Worker script.\n *\n * If `enabled` is set to `false` in the given options, the module will behave as if service\n * workers are not supported by the browser, and the service worker will not be registered.\n */\n static register(\n script: string,\n options: SwRegistrationOptions = {},\n ): ModuleWithProviders<ServiceWorkerModule> {\n return {\n ngModule: ServiceWorkerModule,\n providers: [provideServiceWorker(script, options)],\n };\n }\n}\n"],"names":["i1.NgswCommChannel"],"mappings":";;;;;;;;;;;AAYO,MAAM,oBAAoB,GAAG,+DAA+D;AAoHnG;;AAEG;MACU,eAAe,CAAA;AAQhB,IAAA,aAAA;AAPD,IAAA,MAAM;AAEN,IAAA,YAAY;AAEZ,IAAA,MAAM;IAEf,WACU,CAAA,aAAiD,EACzD,QAAmB,EAAA;QADX,IAAa,CAAA,aAAA,GAAb,aAAa;QAGrB,IAAI,CAAC,aAAa,EAAE;AAClB,YAAA,IA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,kBAAkB,CAAC;AAC1C,KAAA,CAAC;AACJ;;AChMA;;AAEG;MAEU,mBAAmB,CAAA;AAC9B;;;;;AAKG;AACH,IAAA,OAAO,QAAQ,CACb,MAAc,EACd,UAAiC,EAAE,EAAA;QAEnC,OAAO;AACL,YAAA,QAAQ,EAAE,mBAAmB;YAC7B,SAAS,EAAE,CAAC,oBAAoB,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;SACnD;;kHAdQ,mBAAmB,EAAA,IAAA,EAAA,EAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,QAAA,EAAA,CAAA;mHAAnB,mBAAmB,EAAA,CAAA;AAAnB,IAAA,OAAA,IAAA,GAAA,EAAA,CAAA,mBAAA,CAAA,EAAA,UAAA,EAAA,QAAA,EAAA,OAAA,EAAA,mBAAA,EAAA,QAAA,EAAA,EAAA,EAAA,IAAA,EAAA,mBAAmB,EADV,SAAA,EAAA,CAAC,MAAM,EAAE,QAAQ,CAAC,EAAA,CAAA;;sGAC3B,mBAAmB,EAAA,UAAA,EAAA,CAAA;kBAD/B,QAAQ;AAAC,YAAA,IAAA,EAAA,CAAA,EAAC,SAAS,EAAE,CAAC,MAAM,EAAE,QAAQ,CAAC,EAAC;;;;;"}
package/index.d.ts CHANGED
@@ -1,12 +1,12 @@
1
1
  /**
2
- * @license Angular v20.0.0-next.4
2
+ * @license Angular v20.0.0-next.6
3
3
  * (c) 2010-2025 Google LLC. https://angular.io/
4
4
  * License: MIT
5
5
  */
6
6
 
7
- import { Observable } from 'rxjs';
8
7
  import * as i0 from '@angular/core';
9
- import { EnvironmentProviders, ModuleWithProviders } from '@angular/core';
8
+ import { Injector, EnvironmentProviders, ModuleWithProviders } from '@angular/core';
9
+ import { Observable } from 'rxjs';
10
10
 
11
11
  /**
12
12
  * An event emitted when the service worker has checked the version of the app on the server and it
@@ -111,7 +111,7 @@ declare class NgswCommChannel {
111
111
  readonly worker: Observable<ServiceWorker>;
112
112
  readonly registration: Observable<ServiceWorkerRegistration>;
113
113
  readonly events: Observable<TypedEvent>;
114
- constructor(serviceWorker: ServiceWorkerContainer | undefined);
114
+ constructor(serviceWorker: ServiceWorkerContainer | undefined, injector?: Injector);
115
115
  postMessage(action: string, payload: Object): Promise<void>;
116
116
  postMessageWithOperation(type: string, payload: Object, operationNonce: number): Promise<boolean>;
117
117
  generateNonce(): number;
@@ -430,4 +430,5 @@ declare class SwUpdate {
430
430
  static ɵprov: i0.ɵɵInjectableDeclaration<SwUpdate>;
431
431
  }
432
432
 
433
- export { type NoNewVersionDetectedEvent, ServiceWorkerModule, SwPush, SwRegistrationOptions, SwUpdate, type UnrecoverableStateEvent, type VersionDetectedEvent, type VersionEvent, type VersionInstallationFailedEvent, type VersionReadyEvent, provideServiceWorker };
433
+ export { ServiceWorkerModule, SwPush, SwRegistrationOptions, SwUpdate, provideServiceWorker };
434
+ export type { NoNewVersionDetectedEvent, UnrecoverableStateEvent, VersionDetectedEvent, VersionEvent, VersionInstallationFailedEvent, VersionReadyEvent };
package/ngsw-config.js CHANGED
@@ -4,8 +4,219 @@
4
4
  const require = __cjsCompatRequire(import.meta.url);
5
5
 
6
6
 
7
+ // bazel-out/darwin_arm64-fastbuild-ST-2e5f3376adb5/bin/packages/service-worker/config/src/duration.mjs
8
+ var PARSE_TO_PAIRS = /([0-9]+[^0-9]+)/g;
9
+ var PAIR_SPLIT = /^([0-9]+)([dhmsu]+)$/;
10
+ function parseDurationToMs(duration) {
11
+ const matches2 = [];
12
+ let array;
13
+ while ((array = PARSE_TO_PAIRS.exec(duration)) !== null) {
14
+ matches2.push(array[0]);
15
+ }
16
+ return matches2.map((match) => {
17
+ const res = PAIR_SPLIT.exec(match);
18
+ if (res === null) {
19
+ throw new Error(`Not a valid duration: ${match}`);
20
+ }
21
+ let factor = 0;
22
+ switch (res[2]) {
23
+ case "d":
24
+ factor = 864e5;
25
+ break;
26
+ case "h":
27
+ factor = 36e5;
28
+ break;
29
+ case "m":
30
+ factor = 6e4;
31
+ break;
32
+ case "s":
33
+ factor = 1e3;
34
+ break;
35
+ case "u":
36
+ factor = 1;
37
+ break;
38
+ default:
39
+ throw new Error(`Not a valid duration unit: ${res[2]}`);
40
+ }
41
+ return parseInt(res[1]) * factor;
42
+ }).reduce((total, value) => total + value, 0);
43
+ }
44
+
45
+ // bazel-out/darwin_arm64-fastbuild-ST-2e5f3376adb5/bin/packages/service-worker/config/src/glob.mjs
46
+ var QUESTION_MARK = "[^/]";
47
+ var WILD_SINGLE = "[^/]*";
48
+ var WILD_OPEN = "(?:.+\\/)?";
49
+ var TO_ESCAPE_BASE = [
50
+ { replace: /\./g, with: "\\." },
51
+ { replace: /\+/g, with: "\\+" },
52
+ { replace: /\*/g, with: WILD_SINGLE }
53
+ ];
54
+ var TO_ESCAPE_WILDCARD_QM = [...TO_ESCAPE_BASE, { replace: /\?/g, with: QUESTION_MARK }];
55
+ var TO_ESCAPE_LITERAL_QM = [...TO_ESCAPE_BASE, { replace: /\?/g, with: "\\?" }];
56
+ function globToRegex(glob, literalQuestionMark = false) {
57
+ const toEscape = literalQuestionMark ? TO_ESCAPE_LITERAL_QM : TO_ESCAPE_WILDCARD_QM;
58
+ const segments = glob.split("/").reverse();
59
+ let regex = "";
60
+ while (segments.length > 0) {
61
+ const segment = segments.pop();
62
+ if (segment === "**") {
63
+ if (segments.length > 0) {
64
+ regex += WILD_OPEN;
65
+ } else {
66
+ regex += ".*";
67
+ }
68
+ } else {
69
+ const processed = toEscape.reduce((segment2, escape) => segment2.replace(escape.replace, escape.with), segment);
70
+ regex += processed;
71
+ if (segments.length > 0) {
72
+ regex += "\\/";
73
+ }
74
+ }
75
+ }
76
+ return regex;
77
+ }
78
+
79
+ // bazel-out/darwin_arm64-fastbuild-ST-2e5f3376adb5/bin/packages/service-worker/config/src/generator.mjs
80
+ var DEFAULT_NAVIGATION_URLS = [
81
+ "/**",
82
+ "!/**/*.*",
83
+ "!/**/*__*",
84
+ "!/**/*__*/**"
85
+ ];
86
+ var Generator = class {
87
+ fs;
88
+ baseHref;
89
+ constructor(fs3, baseHref2) {
90
+ this.fs = fs3;
91
+ this.baseHref = baseHref2;
92
+ }
93
+ async process(config2) {
94
+ var _a;
95
+ const unorderedHashTable = {};
96
+ const assetGroups = await this.processAssetGroups(config2, unorderedHashTable);
97
+ return {
98
+ configVersion: 1,
99
+ timestamp: Date.now(),
100
+ appData: config2.appData,
101
+ index: joinUrls(this.baseHref, config2.index),
102
+ assetGroups,
103
+ dataGroups: this.processDataGroups(config2),
104
+ hashTable: withOrderedKeys(unorderedHashTable),
105
+ navigationUrls: processNavigationUrls(this.baseHref, config2.navigationUrls),
106
+ navigationRequestStrategy: (_a = config2.navigationRequestStrategy) != null ? _a : "performance",
107
+ applicationMaxAge: config2.applicationMaxAge ? parseDurationToMs(config2.applicationMaxAge) : void 0
108
+ };
109
+ }
110
+ async processAssetGroups(config2, hashTable) {
111
+ const allFiles = await this.fs.list("/");
112
+ const seenMap = /* @__PURE__ */ new Set();
113
+ const filesPerGroup = /* @__PURE__ */ new Map();
114
+ for (const group of config2.assetGroups || []) {
115
+ if (group.resources.versionedFiles) {
116
+ throw new Error(`Asset-group '${group.name}' in 'ngsw-config.json' uses the 'versionedFiles' option, which is no longer supported. Use 'files' instead.`);
117
+ }
118
+ const fileMatcher = globListToMatcher(group.resources.files || []);
119
+ const matchedFiles = allFiles.filter(fileMatcher).filter((file) => !seenMap.has(file)).sort();
120
+ matchedFiles.forEach((file) => seenMap.add(file));
121
+ filesPerGroup.set(group, matchedFiles);
122
+ }
123
+ const allMatchedFiles = [].concat(...Array.from(filesPerGroup.values())).sort();
124
+ const allMatchedHashes = await processInBatches(allMatchedFiles, 500, (file) => this.fs.hash(file));
125
+ allMatchedFiles.forEach((file, idx) => {
126
+ hashTable[joinUrls(this.baseHref, file)] = allMatchedHashes[idx];
127
+ });
128
+ return Array.from(filesPerGroup.entries()).map(([group, matchedFiles]) => ({
129
+ name: group.name,
130
+ installMode: group.installMode || "prefetch",
131
+ updateMode: group.updateMode || group.installMode || "prefetch",
132
+ cacheQueryOptions: buildCacheQueryOptions(group.cacheQueryOptions),
133
+ urls: matchedFiles.map((url) => joinUrls(this.baseHref, url)),
134
+ patterns: (group.resources.urls || []).map((url) => urlToRegex(url, this.baseHref, true))
135
+ }));
136
+ }
137
+ processDataGroups(config2) {
138
+ return (config2.dataGroups || []).map((group) => {
139
+ return {
140
+ name: group.name,
141
+ patterns: group.urls.map((url) => urlToRegex(url, this.baseHref, true)),
142
+ strategy: group.cacheConfig.strategy || "performance",
143
+ maxSize: group.cacheConfig.maxSize,
144
+ maxAge: parseDurationToMs(group.cacheConfig.maxAge),
145
+ timeoutMs: group.cacheConfig.timeout && parseDurationToMs(group.cacheConfig.timeout),
146
+ refreshAheadMs: group.cacheConfig.refreshAhead && parseDurationToMs(group.cacheConfig.refreshAhead),
147
+ cacheOpaqueResponses: group.cacheConfig.cacheOpaqueResponses,
148
+ cacheQueryOptions: buildCacheQueryOptions(group.cacheQueryOptions),
149
+ version: group.version !== void 0 ? group.version : 1
150
+ };
151
+ });
152
+ }
153
+ };
154
+ function processNavigationUrls(baseHref2, urls = DEFAULT_NAVIGATION_URLS) {
155
+ return urls.map((url) => {
156
+ const positive = !url.startsWith("!");
157
+ url = positive ? url : url.slice(1);
158
+ return { positive, regex: `^${urlToRegex(url, baseHref2)}$` };
159
+ });
160
+ }
161
+ async function processInBatches(items, batchSize, processFn) {
162
+ const batches = [];
163
+ for (let i = 0; i < items.length; i += batchSize) {
164
+ batches.push(items.slice(i, i + batchSize));
165
+ }
166
+ return batches.reduce(async (prev, batch) => (await prev).concat(await Promise.all(batch.map((item) => processFn(item)))), Promise.resolve([]));
167
+ }
168
+ function globListToMatcher(globs) {
169
+ const patterns = globs.map((pattern) => {
170
+ if (pattern.startsWith("!")) {
171
+ return {
172
+ positive: false,
173
+ regex: new RegExp("^" + globToRegex(pattern.slice(1)) + "$")
174
+ };
175
+ } else {
176
+ return {
177
+ positive: true,
178
+ regex: new RegExp("^" + globToRegex(pattern) + "$")
179
+ };
180
+ }
181
+ });
182
+ return (file) => matches(file, patterns);
183
+ }
184
+ function matches(file, patterns) {
185
+ return patterns.reduce((isMatch, pattern) => {
186
+ if (pattern.positive) {
187
+ return isMatch || pattern.regex.test(file);
188
+ } else {
189
+ return isMatch && !pattern.regex.test(file);
190
+ }
191
+ }, false);
192
+ }
193
+ function urlToRegex(url, baseHref2, literalQuestionMark) {
194
+ if (!url.startsWith("/") && url.indexOf("://") === -1) {
195
+ url = joinUrls(baseHref2.replace(/^\.(?=\/)/, ""), url);
196
+ }
197
+ return globToRegex(url, literalQuestionMark);
198
+ }
199
+ function joinUrls(a, b) {
200
+ if (a.endsWith("/") && b.startsWith("/")) {
201
+ return a + b.slice(1);
202
+ } else if (!a.endsWith("/") && !b.startsWith("/")) {
203
+ return a + "/" + b;
204
+ }
205
+ return a + b;
206
+ }
207
+ function withOrderedKeys(unorderedObj) {
208
+ const orderedObj = {};
209
+ Object.keys(unorderedObj).sort().forEach((key) => orderedObj[key] = unorderedObj[key]);
210
+ return orderedObj;
211
+ }
212
+ function buildCacheQueryOptions(inOptions) {
213
+ return {
214
+ ignoreVary: true,
215
+ ...inOptions
216
+ };
217
+ }
218
+
7
219
  // bazel-out/darwin_arm64-fastbuild-ST-2e5f3376adb5/bin/packages/service-worker/cli/main.mjs
8
- import { Generator } from "@angular/service-worker/config";
9
220
  import * as fs2 from "fs";
10
221
  import * as path2 from "path";
11
222
 
package/ngsw-worker.js CHANGED
@@ -1069,7 +1069,7 @@ ${error.stack}`;
1069
1069
  };
1070
1070
 
1071
1071
  // bazel-out/darwin_arm64-fastbuild-ST-2e5f3376adb5/bin/packages/service-worker/worker/src/debug.mjs
1072
- var SW_VERSION = "20.0.0-next.4";
1072
+ var SW_VERSION = "20.0.0-next.6";
1073
1073
  var DEBUG_LOG_BUFFER_SIZE = 100;
1074
1074
  var DebugHandler = class {
1075
1075
  constructor(driver, adapter2) {
@@ -1579,7 +1579,8 @@ ${msgIdle}`, { headers: this.adapter.newHeaders({ "Content-Type": "text/plain" }
1579
1579
  return this.versions.get(hash);
1580
1580
  }
1581
1581
  async assignVersion(event) {
1582
- const clientId = event.resultingClientId || event.clientId;
1582
+ const isWorkerScriptRequest = event.request.destination === "worker" && event.resultingClientId && event.clientId;
1583
+ const clientId = isWorkerScriptRequest ? event.clientId : event.resultingClientId || event.clientId;
1583
1584
  if (clientId) {
1584
1585
  if (this.clientVersionMap.has(clientId)) {
1585
1586
  const hash = this.clientVersionMap.get(clientId);
@@ -1594,6 +1595,14 @@ ${msgIdle}`, { headers: this.adapter.newHeaders({ "Content-Type": "text/plain" }
1594
1595
  }
1595
1596
  appVersion = this.lookupVersionByHash(this.latestHash, "assignVersion");
1596
1597
  }
1598
+ if (isWorkerScriptRequest) {
1599
+ if (!this.clientVersionMap.has(event.resultingClientId)) {
1600
+ this.clientVersionMap.set(event.resultingClientId, hash);
1601
+ await this.sync();
1602
+ } else if (this.clientVersionMap.get(event.resultingClientId) !== hash) {
1603
+ throw new Error(`Version mismatch between worker client ${event.resultingClientId} and requesting client ${clientId}`);
1604
+ }
1605
+ }
1597
1606
  return appVersion;
1598
1607
  } else {
1599
1608
  if (this.state !== DriverReadyState.NORMAL) {
@@ -1602,6 +1611,13 @@ ${msgIdle}`, { headers: this.adapter.newHeaders({ "Content-Type": "text/plain" }
1602
1611
  if (this.latestHash === null) {
1603
1612
  throw new Error(`Invariant violated (assignVersion): latestHash was null`);
1604
1613
  }
1614
+ if (isWorkerScriptRequest) {
1615
+ if (!this.clientVersionMap.has(event.resultingClientId)) {
1616
+ this.clientVersionMap.set(event.resultingClientId, this.latestHash);
1617
+ } else if (this.clientVersionMap.get(event.resultingClientId) !== this.latestHash) {
1618
+ throw new Error(`Version mismatch between worker client ${event.resultingClientId} and requesting client ${clientId}`);
1619
+ }
1620
+ }
1605
1621
  this.clientVersionMap.set(clientId, this.latestHash);
1606
1622
  await this.sync();
1607
1623
  return this.lookupVersionByHash(this.latestHash, "assignVersion");
package/package.json CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "@angular/service-worker",
3
- "version": "20.0.0-next.4",
3
+ "version": "20.0.0-next.6",
4
4
  "description": "Angular - service worker tooling!",
5
5
  "author": "angular",
6
6
  "license": "MIT",
7
7
  "engines": {
8
- "node": "^18.19.1 || ^20.11.1 || >=22.0.0"
8
+ "node": "^20.11.1 || >=22.11.0"
9
9
  },
10
10
  "exports": {
11
11
  "./ngsw-worker.js": {
@@ -33,7 +33,7 @@
33
33
  "tslib": "^2.3.0"
34
34
  },
35
35
  "peerDependencies": {
36
- "@angular/core": "20.0.0-next.4",
36
+ "@angular/core": "20.0.0-next.6",
37
37
  "rxjs": "^6.5.3 || ^7.4.0"
38
38
  },
39
39
  "repository": {