@angular/service-worker 17.1.0 → 17.1.2
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 +1 -1
- package/esm2022/config/src/duration.mjs +2 -2
- package/esm2022/config/src/generator.mjs +20 -16
- package/esm2022/config/src/glob.mjs +3 -9
- package/esm2022/config/src/in.mjs +1 -1
- package/esm2022/src/index.mjs +1 -1
- package/esm2022/src/low_level.mjs +4 -4
- package/esm2022/src/module.mjs +5 -5
- package/esm2022/src/provider.mjs +14 -12
- package/esm2022/src/push.mjs +14 -12
- package/esm2022/src/update.mjs +5 -5
- package/fesm2022/config.mjs +23 -25
- package/fesm2022/config.mjs.map +1 -1
- package/fesm2022/service-worker.mjs +37 -33
- package/fesm2022/service-worker.mjs.map +1 -1
- package/index.d.ts +1 -1
- package/ngsw-config.js +5 -5
- package/ngsw-worker.js +26 -23
- package/package.json +3 -3
- package/safety-worker.js +13 -9
|
@@ -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","../../../../../../packages/service-worker/public_api.ts","../../../../../../packages/service-worker/index.ts","../../../../../../packages/service-worker/service-worker.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.io/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 guide/service-worker-communications Service worker communication guide}\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 guide/service-worker-communications Service worker communication guide}\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 guide/service-worker-communications Service worker communication guide}\n *\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 guide/service-worker-communications Service worker communication guide}\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/**\n * A union of all event types that can be emitted by\n * {@link api/service-worker/SwUpdate#versionUpdates SwUpdate#versionUpdates}.\n *\n * @publicApi\n */\nexport type VersionEvent =\n VersionDetectedEvent|VersionInstallationFailedEvent|VersionReadyEvent|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 guide/service-worker-communications Service worker communication guide}\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 type: 'OPERATION_COMPLETED'; nonce: number; result: boolean;\n}|{\n type: 'OPERATION_COMPLETED';\n nonce: number;\n result?: undefined;\n error: string;\n};\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 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(take(1), tap((sw: ServiceWorker) => {\n sw.postMessage({\n action,\n ...payload,\n });\n }))\n .toPromise()\n .then(() => undefined);\n }\n\n postMessageWithOperation(type: string, payload: Object, 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(filter(event => event.nonce === nonce), take(1), map(event => {\n if (event.result !== undefined) {\n return event.result;\n }\n throw new Error(event.error!);\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.io/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/**\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](guide/service-worker-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; notification: NotificationOptions &\n {\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 =\n this.sw.eventsOfType('NOTIFICATION_CLICK').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(switchMap(pm => pm.getSubscription()));\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.pipe(switchMap(pm => pm.subscribe(pushOptions)), take(1))\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.io/license\n */\n\nimport {Injectable} from '@angular/core';\nimport {NEVER, Observable} from 'rxjs';\n\nimport {ERR_SW_NOT_SUPPORTED, NgswCommChannel, UnrecoverableStateEvent, VersionEvent} 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 guide/service-worker-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=\"alert is-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](guide/glossary#app-shell) and other page resources,\n * such as [lazy-loaded chunks](guide/glossary#lazy-loading), 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.io/license\n */\n\nimport {isPlatformBrowser} from '@angular/common';\nimport {APP_INITIALIZER, ApplicationRef, EnvironmentProviders, InjectionToken, Injector, makeEnvironmentProviders, NgZone, PLATFORM_ID,} from '@angular/core';\nimport {merge, Observable, of} from 'rxjs';\nimport {delay, filter, 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>('NGSW_REGISTER_SCRIPT');\n\nexport function ngswAppInitializer(\n injector: Injector, script: string, options: SwRegistrationOptions,\n platformId: string): Function {\n return () => {\n if (!(isPlatformBrowser(platformId) && ('serviceWorker' in navigator) &&\n options.enabled !== false)) {\n return;\n }\n\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 navigator.serviceWorker.addEventListener('controllerchange', () => {\n if (navigator.serviceWorker.controller !== null) {\n navigator.serviceWorker.controller.postMessage({action: 'INITIALIZE'});\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').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 readyToRegister$ = !args[0] ? whenStable(injector) :\n merge(whenStable(injector), 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 // 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 const ngZone = injector.get(NgZone);\n ngZone.runOutsideAngular(\n () => readyToRegister$.pipe(take(1)).subscribe(\n () =>\n navigator.serviceWorker.register(script, {scope: options.scope})\n .catch(err => console.error('Service worker registration failed with:', err))));\n };\n}\n\nfunction delayWithTimeout(timeout: number): Observable<unknown> {\n return of(null).pipe(delay(timeout));\n}\n\nfunction whenStable(injector: Injector): Observable<unknown> {\n const appRef = injector.get(ApplicationRef);\n return appRef.isStable.pipe(filter(stable => stable));\n}\n\nexport function ngswCommChannelFactory(\n opts: SwRegistrationOptions, platformId: string): NgswCommChannel {\n return new NgswCommChannel(\n isPlatformBrowser(platformId) && opts.enabled !== false ? navigator.serviceWorker :\n undefined);\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](guide/observables) 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, options: SwRegistrationOptions = {}): 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, PLATFORM_ID]\n },\n {\n provide: APP_INITIALIZER,\n useFactory: ngswAppInitializer,\n deps: [Injector, SCRIPT, SwRegistrationOptions, PLATFORM_ID],\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.io/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(script: string, options: SwRegistrationOptions = {}):\n ModuleWithProviders<ServiceWorkerModule> {\n return {\n ngModule: ServiceWorkerModule,\n providers: [provideServiceWorker(script, options)],\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.io/license\n */\n\n/**\n * @module\n * @description\n * Entry point for all public APIs of this package.\n */\nexport * from './src/index';\n\n// This file only reexports content of the `src` folder. Keep it that way.\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.io/license\n */\n\n// This file is not used to build this module. It is only used during editing\n// by the TypeScript language service and during build for verification. `ngc`\n// replaces this file with production index.ts when it rewrites private symbol\n// names.\n\nexport * from './public_api';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":["i1.NgswCommChannel"],"mappings":";;;;;;;;;;;;AAWO,MAAM,oBAAoB,GAAG,+DAA+D,CAAC;AA2GpG,SAAS,eAAe,CAAC,OAAe,EAAA;AACtC,IAAA,OAAO,KAAK,CAAC,MAAM,UAAU,CAAC,IAAI,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;AACrD,CAAC;AAED;;AAEG;MACU,eAAe,CAAA;AAO1B,IAAA,WAAA,CAAoB,aAA+C,EAAA;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;kBAD/B,QAAQ;AAAC,YAAA,IAAA,EAAA,CAAA,EAAC,SAAS,EAAE,CAAC,MAAM,EAAE,QAAQ,CAAC,EAAC,CAAA;;;ACTzC;;;;AAIG;AAGH;;ACPA;;ACRA;;AAEG;;;;"}
|
|
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","../../../../../../packages/service-worker/public_api.ts","../../../../../../packages/service-worker/index.ts","../../../../../../packages/service-worker/service-worker.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.io/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 guide/service-worker-communications Service worker communication guide}\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 guide/service-worker-communications Service worker communication guide}\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 guide/service-worker-communications Service worker communication guide}\n *\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 guide/service-worker-communications Service worker communication guide}\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 api/service-worker/SwUpdate#versionUpdates 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 guide/service-worker-communications Service worker communication guide}\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.io/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](guide/service-worker-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.io/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 guide/service-worker-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=\"alert is-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](guide/glossary#app-shell) and other page resources,\n * such as [lazy-loaded chunks](guide/glossary#lazy-loading), 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.io/license\n */\n\nimport {isPlatformBrowser} from '@angular/common';\nimport {\n APP_INITIALIZER,\n ApplicationRef,\n EnvironmentProviders,\n InjectionToken,\n Injector,\n makeEnvironmentProviders,\n NgZone,\n PLATFORM_ID,\n} from '@angular/core';\nimport {merge, Observable, of} from 'rxjs';\nimport {delay, filter, 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 platformId: string,\n): Function {\n return () => {\n if (\n !(isPlatformBrowser(platformId) && 'serviceWorker' in navigator && options.enabled !== false)\n ) {\n return;\n }\n\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 navigator.serviceWorker.addEventListener('controllerchange', () => {\n if (navigator.serviceWorker.controller !== null) {\n navigator.serviceWorker.controller.postMessage({action: 'INITIALIZE'});\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 readyToRegister$ = !args[0]\n ? whenStable(injector)\n : merge(whenStable(injector), 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 const ngZone = injector.get(NgZone);\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\nfunction whenStable(injector: Injector): Observable<unknown> {\n const appRef = injector.get(ApplicationRef);\n return appRef.isStable.pipe(filter((stable) => stable));\n}\n\nexport function ngswCommChannelFactory(\n opts: SwRegistrationOptions,\n platformId: string,\n): NgswCommChannel {\n return new NgswCommChannel(\n isPlatformBrowser(platformId) && 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](guide/observables) 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, PLATFORM_ID],\n },\n {\n provide: APP_INITIALIZER,\n useFactory: ngswAppInitializer,\n deps: [Injector, SCRIPT, SwRegistrationOptions, PLATFORM_ID],\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.io/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","/**\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.io/license\n */\n\n/**\n * @module\n * @description\n * Entry point for all public APIs of this package.\n */\nexport * from './src/index';\n\n// This file only reexports content of the `src` folder. Keep it that way.\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.io/license\n */\n\n// This file is not used to build this module. It is only used during editing\n// by the TypeScript language service and during build for verification. `ngc`\n// replaces this file with production index.ts when it rewrites private symbol\n// names.\n\nexport * from './public_api';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":["i1.NgswCommChannel"],"mappings":";;;;;;;;;;;;AAWO,MAAM,oBAAoB,GAAG,+DAA+D,CAAC;AAgHpG,SAAS,eAAe,CAAC,OAAe,EAAA;AACtC,IAAA,OAAO,KAAK,CAAC,MAAM,UAAU,CAAC,IAAI,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;AACrD,CAAC;AAED;;AAEG;MACU,eAAe,CAAA;AAO1B,IAAA,WAAA,CAAoB,aAAiD,EAAA;QAAjD,IAAa,CAAA,aAAA,GAAb,aAAa,CAAoC;QACnE,IAAI,CAAC,aAAa,EAAE;AAClB,YAAA,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,YAAY,GAAG,eAAe,CAAC,oBAAoB,CAAC,CAAC;SACvF;aAAM;YACL,MAAM,sBAAsB,GAAG,SAAS,CAAC,aAAa,EAAE,kBAAkB,CAAC,CAAC;AAC5E,Y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.js
CHANGED
|
@@ -4,16 +4,16 @@
|
|
|
4
4
|
const require = __cjsCompatRequire(import.meta.url);
|
|
5
5
|
|
|
6
6
|
|
|
7
|
-
// bazel-out/
|
|
7
|
+
// bazel-out/k8-fastbuild-ST-2e5f3376adb5/bin/packages/service-worker/cli/main.mjs
|
|
8
8
|
import { Generator } from "@angular/service-worker/config";
|
|
9
9
|
import * as fs2 from "fs";
|
|
10
10
|
import * as path2 from "path";
|
|
11
11
|
|
|
12
|
-
// bazel-out/
|
|
12
|
+
// bazel-out/k8-fastbuild-ST-2e5f3376adb5/bin/packages/service-worker/cli/filesystem.mjs
|
|
13
13
|
import * as fs from "fs";
|
|
14
14
|
import * as path from "path";
|
|
15
15
|
|
|
16
|
-
// bazel-out/
|
|
16
|
+
// bazel-out/k8-fastbuild-ST-2e5f3376adb5/bin/packages/service-worker/cli/sha1.mjs
|
|
17
17
|
function sha1Binary(buffer) {
|
|
18
18
|
const words32 = arrayBufferToWords32(buffer, Endian.Big);
|
|
19
19
|
return _sha1(words32, buffer.byteLength * 8);
|
|
@@ -115,7 +115,7 @@ function byteStringToHexString(str) {
|
|
|
115
115
|
return hex.toLowerCase();
|
|
116
116
|
}
|
|
117
117
|
|
|
118
|
-
// bazel-out/
|
|
118
|
+
// bazel-out/k8-fastbuild-ST-2e5f3376adb5/bin/packages/service-worker/cli/filesystem.mjs
|
|
119
119
|
var NodeFilesystem = class {
|
|
120
120
|
base;
|
|
121
121
|
constructor(base) {
|
|
@@ -145,7 +145,7 @@ var NodeFilesystem = class {
|
|
|
145
145
|
}
|
|
146
146
|
};
|
|
147
147
|
|
|
148
|
-
// bazel-out/
|
|
148
|
+
// bazel-out/k8-fastbuild-ST-2e5f3376adb5/bin/packages/service-worker/cli/main.mjs
|
|
149
149
|
var cwd = process.cwd();
|
|
150
150
|
var distDir = path2.join(cwd, process.argv[2]);
|
|
151
151
|
var config = path2.join(cwd, process.argv[3]);
|
package/ngsw-worker.js
CHANGED
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
};
|
|
20
20
|
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
21
21
|
|
|
22
|
-
// bazel-out/
|
|
22
|
+
// bazel-out/k8-fastbuild-ST-2e5f3376adb5/bin/packages/service-worker/worker/src/named-cache-storage.mjs
|
|
23
23
|
var NamedCacheStorage = class {
|
|
24
24
|
constructor(original, cacheNamePrefix) {
|
|
25
25
|
this.original = original;
|
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
}
|
|
47
47
|
};
|
|
48
48
|
|
|
49
|
-
// bazel-out/
|
|
49
|
+
// bazel-out/k8-fastbuild-ST-2e5f3376adb5/bin/packages/service-worker/worker/src/adapter.mjs
|
|
50
50
|
var Adapter = class {
|
|
51
51
|
constructor(scopeUrl, caches) {
|
|
52
52
|
this.scopeUrl = scopeUrl;
|
|
@@ -84,7 +84,7 @@
|
|
|
84
84
|
}
|
|
85
85
|
};
|
|
86
86
|
|
|
87
|
-
// bazel-out/
|
|
87
|
+
// bazel-out/k8-fastbuild-ST-2e5f3376adb5/bin/packages/service-worker/worker/src/database.mjs
|
|
88
88
|
var NotFound = class {
|
|
89
89
|
constructor(table, key) {
|
|
90
90
|
this.table = table;
|
|
@@ -92,7 +92,7 @@
|
|
|
92
92
|
}
|
|
93
93
|
};
|
|
94
94
|
|
|
95
|
-
// bazel-out/
|
|
95
|
+
// bazel-out/k8-fastbuild-ST-2e5f3376adb5/bin/packages/service-worker/worker/src/db-cache.mjs
|
|
96
96
|
var CacheDatabase = class {
|
|
97
97
|
constructor(adapter2) {
|
|
98
98
|
this.adapter = adapter2;
|
|
@@ -150,7 +150,7 @@
|
|
|
150
150
|
}
|
|
151
151
|
};
|
|
152
152
|
|
|
153
|
-
// bazel-out/
|
|
153
|
+
// bazel-out/k8-fastbuild-ST-2e5f3376adb5/bin/packages/service-worker/worker/src/api.mjs
|
|
154
154
|
var UpdateCacheStatus;
|
|
155
155
|
(function(UpdateCacheStatus2) {
|
|
156
156
|
UpdateCacheStatus2[UpdateCacheStatus2["NOT_CACHED"] = 0] = "NOT_CACHED";
|
|
@@ -158,7 +158,7 @@
|
|
|
158
158
|
UpdateCacheStatus2[UpdateCacheStatus2["CACHED"] = 2] = "CACHED";
|
|
159
159
|
})(UpdateCacheStatus || (UpdateCacheStatus = {}));
|
|
160
160
|
|
|
161
|
-
// bazel-out/
|
|
161
|
+
// bazel-out/k8-fastbuild-ST-2e5f3376adb5/bin/packages/service-worker/worker/src/error.mjs
|
|
162
162
|
var SwCriticalError = class extends Error {
|
|
163
163
|
constructor() {
|
|
164
164
|
super(...arguments);
|
|
@@ -180,7 +180,7 @@ ${error.stack}`;
|
|
|
180
180
|
}
|
|
181
181
|
};
|
|
182
182
|
|
|
183
|
-
// bazel-out/
|
|
183
|
+
// bazel-out/k8-fastbuild-ST-2e5f3376adb5/bin/packages/service-worker/worker/src/sha1.mjs
|
|
184
184
|
function sha1(str) {
|
|
185
185
|
const utf8 = str;
|
|
186
186
|
const words32 = stringToWords32(utf8, Endian.Big);
|
|
@@ -295,7 +295,7 @@ ${error.stack}`;
|
|
|
295
295
|
return hex.toLowerCase();
|
|
296
296
|
}
|
|
297
297
|
|
|
298
|
-
// bazel-out/
|
|
298
|
+
// bazel-out/k8-fastbuild-ST-2e5f3376adb5/bin/packages/service-worker/worker/src/assets.mjs
|
|
299
299
|
var AssetGroup = class {
|
|
300
300
|
constructor(scope2, adapter2, idle, config, hashes, db, cacheNamePrefix) {
|
|
301
301
|
this.scope = scope2;
|
|
@@ -331,10 +331,7 @@ ${error.stack}`;
|
|
|
331
331
|
return UpdateCacheStatus.CACHED;
|
|
332
332
|
}
|
|
333
333
|
async getCacheNames() {
|
|
334
|
-
const [cache, metadata] = await Promise.all([
|
|
335
|
-
this.cache,
|
|
336
|
-
this.metadata
|
|
337
|
-
]);
|
|
334
|
+
const [cache, metadata] = await Promise.all([this.cache, this.metadata]);
|
|
338
335
|
return [cache.name, metadata.cacheName];
|
|
339
336
|
}
|
|
340
337
|
async handleFetch(req, _event) {
|
|
@@ -586,7 +583,7 @@ ${error.stack}`;
|
|
|
586
583
|
}
|
|
587
584
|
};
|
|
588
585
|
|
|
589
|
-
// bazel-out/
|
|
586
|
+
// bazel-out/k8-fastbuild-ST-2e5f3376adb5/bin/packages/service-worker/worker/src/data.mjs
|
|
590
587
|
var LruList = class {
|
|
591
588
|
constructor(state) {
|
|
592
589
|
if (state === void 0) {
|
|
@@ -880,7 +877,7 @@ ${error.stack}`;
|
|
|
880
877
|
}
|
|
881
878
|
};
|
|
882
879
|
|
|
883
|
-
// bazel-out/
|
|
880
|
+
// bazel-out/k8-fastbuild-ST-2e5f3376adb5/bin/packages/service-worker/worker/src/app-version.mjs
|
|
884
881
|
var BACKWARDS_COMPATIBILITY_NAVIGATION_URLS = [
|
|
885
882
|
{ positive: true, regex: "^/.*$" },
|
|
886
883
|
{ positive: false, regex: "^/.*\\.[^/]*$" },
|
|
@@ -1031,8 +1028,8 @@ ${error.stack}`;
|
|
|
1031
1028
|
}
|
|
1032
1029
|
};
|
|
1033
1030
|
|
|
1034
|
-
// bazel-out/
|
|
1035
|
-
var SW_VERSION = "17.1.
|
|
1031
|
+
// bazel-out/k8-fastbuild-ST-2e5f3376adb5/bin/packages/service-worker/worker/src/debug.mjs
|
|
1032
|
+
var SW_VERSION = "17.1.2";
|
|
1036
1033
|
var DEBUG_LOG_BUFFER_SIZE = 100;
|
|
1037
1034
|
var DebugHandler = class {
|
|
1038
1035
|
constructor(driver, adapter2) {
|
|
@@ -1105,7 +1102,7 @@ ${msgIdle}`, { headers: this.adapter.newHeaders({ "Content-Type": "text/plain" }
|
|
|
1105
1102
|
}
|
|
1106
1103
|
};
|
|
1107
1104
|
|
|
1108
|
-
// bazel-out/
|
|
1105
|
+
// bazel-out/k8-fastbuild-ST-2e5f3376adb5/bin/packages/service-worker/worker/src/idle.mjs
|
|
1109
1106
|
var IdleScheduler = class {
|
|
1110
1107
|
constructor(adapter2, delay, maxDelay, debug) {
|
|
1111
1108
|
this.adapter = adapter2;
|
|
@@ -1183,12 +1180,12 @@ ${msgIdle}`, { headers: this.adapter.newHeaders({ "Content-Type": "text/plain" }
|
|
|
1183
1180
|
}
|
|
1184
1181
|
};
|
|
1185
1182
|
|
|
1186
|
-
// bazel-out/
|
|
1183
|
+
// bazel-out/k8-fastbuild-ST-2e5f3376adb5/bin/packages/service-worker/worker/src/manifest.mjs
|
|
1187
1184
|
function hashManifest(manifest) {
|
|
1188
1185
|
return sha1(JSON.stringify(manifest));
|
|
1189
1186
|
}
|
|
1190
1187
|
|
|
1191
|
-
// bazel-out/
|
|
1188
|
+
// bazel-out/k8-fastbuild-ST-2e5f3376adb5/bin/packages/service-worker/worker/src/msg.mjs
|
|
1192
1189
|
function isMsgCheckForUpdates(msg) {
|
|
1193
1190
|
return msg.action === "CHECK_FOR_UPDATES";
|
|
1194
1191
|
}
|
|
@@ -1196,7 +1193,7 @@ ${msgIdle}`, { headers: this.adapter.newHeaders({ "Content-Type": "text/plain" }
|
|
|
1196
1193
|
return msg.action === "ACTIVATE_UPDATE";
|
|
1197
1194
|
}
|
|
1198
1195
|
|
|
1199
|
-
// bazel-out/
|
|
1196
|
+
// bazel-out/k8-fastbuild-ST-2e5f3376adb5/bin/packages/service-worker/worker/src/driver.mjs
|
|
1200
1197
|
var IDLE_DELAY = 5e3;
|
|
1201
1198
|
var MAX_IDLE_DELAY = 3e4;
|
|
1202
1199
|
var SUPPORTED_CONFIG_VERSION = 1;
|
|
@@ -1760,7 +1757,10 @@ ${msgIdle}`, { headers: this.adapter.newHeaders({ "Content-Type": "text/plain" }
|
|
|
1760
1757
|
await this.initialized;
|
|
1761
1758
|
const clients = await this.scope.clients.matchAll();
|
|
1762
1759
|
await Promise.all(clients.map(async (client) => {
|
|
1763
|
-
client.postMessage({
|
|
1760
|
+
client.postMessage({
|
|
1761
|
+
type: "NO_NEW_VERSION_DETECTED",
|
|
1762
|
+
version: this.mergeHashWithAppData(manifest, hash)
|
|
1763
|
+
});
|
|
1764
1764
|
}));
|
|
1765
1765
|
}
|
|
1766
1766
|
async notifyClientsAboutVersionDetected(manifest, hash) {
|
|
@@ -1771,7 +1771,10 @@ ${msgIdle}`, { headers: this.adapter.newHeaders({ "Content-Type": "text/plain" }
|
|
|
1771
1771
|
if (version === void 0) {
|
|
1772
1772
|
return;
|
|
1773
1773
|
}
|
|
1774
|
-
client.postMessage({
|
|
1774
|
+
client.postMessage({
|
|
1775
|
+
type: "VERSION_DETECTED",
|
|
1776
|
+
version: this.mergeHashWithAppData(manifest, hash)
|
|
1777
|
+
});
|
|
1775
1778
|
}));
|
|
1776
1779
|
}
|
|
1777
1780
|
async notifyClientsAboutVersionReady(manifest, hash) {
|
|
@@ -1846,7 +1849,7 @@ ${msgIdle}`, { headers: this.adapter.newHeaders({ "Content-Type": "text/plain" }
|
|
|
1846
1849
|
}
|
|
1847
1850
|
};
|
|
1848
1851
|
|
|
1849
|
-
// bazel-out/
|
|
1852
|
+
// bazel-out/k8-fastbuild-ST-2e5f3376adb5/bin/packages/service-worker/worker/main.mjs
|
|
1850
1853
|
var scope = self;
|
|
1851
1854
|
var adapter = new Adapter(scope.registration.scope, self.caches);
|
|
1852
1855
|
new Driver(scope, adapter, new CacheDatabase(adapter));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@angular/service-worker",
|
|
3
|
-
"version": "17.1.
|
|
3
|
+
"version": "17.1.2",
|
|
4
4
|
"description": "Angular - service worker tooling!",
|
|
5
5
|
"author": "angular",
|
|
6
6
|
"license": "MIT",
|
|
@@ -37,8 +37,8 @@
|
|
|
37
37
|
"tslib": "^2.3.0"
|
|
38
38
|
},
|
|
39
39
|
"peerDependencies": {
|
|
40
|
-
"@angular/core": "17.1.
|
|
41
|
-
"@angular/common": "17.1.
|
|
40
|
+
"@angular/core": "17.1.2",
|
|
41
|
+
"@angular/common": "17.1.2"
|
|
42
42
|
},
|
|
43
43
|
"repository": {
|
|
44
44
|
"type": "git",
|
package/safety-worker.js
CHANGED
|
@@ -8,19 +8,23 @@
|
|
|
8
8
|
|
|
9
9
|
// tslint:disable:no-console
|
|
10
10
|
|
|
11
|
-
self.addEventListener('install', event => {
|
|
11
|
+
self.addEventListener('install', (event) => {
|
|
12
12
|
self.skipWaiting();
|
|
13
13
|
});
|
|
14
14
|
|
|
15
|
-
self.addEventListener('activate', event => {
|
|
15
|
+
self.addEventListener('activate', (event) => {
|
|
16
16
|
event.waitUntil(self.clients.claim());
|
|
17
17
|
|
|
18
|
-
event.waitUntil(
|
|
19
|
-
|
|
20
|
-
|
|
18
|
+
event.waitUntil(
|
|
19
|
+
self.registration.unregister().then(() => {
|
|
20
|
+
console.log('NGSW Safety Worker - unregistered old service worker');
|
|
21
|
+
}),
|
|
22
|
+
);
|
|
21
23
|
|
|
22
|
-
event.waitUntil(
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
24
|
+
event.waitUntil(
|
|
25
|
+
caches.keys().then((cacheNames) => {
|
|
26
|
+
const ngswCacheNames = cacheNames.filter((name) => /^ngsw:/.test(name));
|
|
27
|
+
return Promise.all(ngswCacheNames.map((name) => caches.delete(name)));
|
|
28
|
+
}),
|
|
29
|
+
);
|
|
26
30
|
});
|