@angular/service-worker
Advanced tools
Comparing version
/** | ||
* @license Angular v19.2.1 | ||
* @license Angular v19.2.2 | ||
* (c) 2010-2025 Google LLC. https://angular.io/ | ||
@@ -7,20 +7,24 @@ * License: MIT | ||
/** | ||
* Configuration for a particular group of assets. | ||
* An abstraction over a virtual file system used to enable testing and operation | ||
* of the config generator in different environments. | ||
* | ||
* @publicApi | ||
*/ | ||
export declare interface AssetGroup { | ||
name: string; | ||
installMode?: 'prefetch' | 'lazy'; | ||
updateMode?: 'prefetch' | 'lazy'; | ||
resources: { | ||
files?: Glob[]; | ||
urls?: Glob[]; | ||
}; | ||
cacheQueryOptions?: Pick<CacheQueryOptions, 'ignoreSearch'>; | ||
interface Filesystem { | ||
list(dir: string): Promise<string[]>; | ||
read(file: string): Promise<string>; | ||
hash(file: string): Promise<string>; | ||
write(file: string, contents: string): Promise<void>; | ||
} | ||
/** | ||
* @publicApi | ||
*/ | ||
type Glob = string; | ||
/** | ||
* @publicApi | ||
*/ | ||
type Duration = string; | ||
/** | ||
* A top-level Angular Service Worker configuration object. | ||
@@ -30,3 +34,3 @@ * | ||
*/ | ||
export declare interface Config { | ||
interface Config { | ||
appData?: {}; | ||
@@ -40,4 +44,18 @@ index: string; | ||
} | ||
/** | ||
* Configuration for a particular group of assets. | ||
* | ||
* @publicApi | ||
*/ | ||
interface AssetGroup { | ||
name: string; | ||
installMode?: 'prefetch' | 'lazy'; | ||
updateMode?: 'prefetch' | 'lazy'; | ||
resources: { | ||
files?: Glob[]; | ||
urls?: Glob[]; | ||
}; | ||
cacheQueryOptions?: Pick<CacheQueryOptions, 'ignoreSearch'>; | ||
} | ||
/** | ||
* Configuration for a particular group of dynamic URLs. | ||
@@ -47,3 +65,3 @@ * | ||
*/ | ||
export declare interface DataGroup { | ||
interface DataGroup { | ||
name: string; | ||
@@ -64,21 +82,2 @@ urls: Glob[]; | ||
/** | ||
* @publicApi | ||
*/ | ||
export declare type Duration = string; | ||
/** | ||
* An abstraction over a virtual file system used to enable testing and operation | ||
* of the config generator in different environments. | ||
* | ||
* @publicApi | ||
*/ | ||
export declare interface Filesystem { | ||
list(dir: string): Promise<string[]>; | ||
read(file: string): Promise<string>; | ||
hash(file: string): Promise<string>; | ||
write(file: string, contents: string): Promise<void>; | ||
} | ||
/** | ||
* Consumes service worker configuration files and processes them into control files. | ||
@@ -88,3 +87,3 @@ * | ||
*/ | ||
declare class Generator_2 { | ||
declare class Generator { | ||
readonly fs: Filesystem; | ||
@@ -97,10 +96,3 @@ private baseHref; | ||
} | ||
export { Generator_2 as Generator } | ||
/** | ||
* @publicApi | ||
*/ | ||
export declare type Glob = string; | ||
export { } | ||
export { type AssetGroup, type Config, type DataGroup, type Duration, type Filesystem, Generator, type Glob }; |
326
index.d.ts
/** | ||
* @license Angular v19.2.1 | ||
* @license Angular v19.2.2 | ||
* (c) 2010-2025 Google LLC. https://angular.io/ | ||
@@ -7,11 +7,104 @@ * License: MIT | ||
import { EnvironmentProviders } from '@angular/core'; | ||
import { Observable } from 'rxjs'; | ||
import * as i0 from '@angular/core'; | ||
import { ModuleWithProviders } from '@angular/core'; | ||
import { Observable } from 'rxjs'; | ||
import { EnvironmentProviders, ModuleWithProviders } from '@angular/core'; | ||
/** | ||
* An event emitted when the service worker has checked the version of the app on the server and it | ||
* didn't find a new version that it doesn't have already downloaded. | ||
* | ||
* @see {@link /ecosystem/service-workers/communications Service Worker Communication Guide} | ||
* | ||
* @publicApi | ||
*/ | ||
interface NoNewVersionDetectedEvent { | ||
type: 'NO_NEW_VERSION_DETECTED'; | ||
version: { | ||
hash: string; | ||
appData?: Object; | ||
}; | ||
} | ||
/** | ||
* An event emitted when the service worker has detected a new version of the app on the server and | ||
* is about to start downloading it. | ||
* | ||
* @see {@link /ecosystem/service-workers/communications Service Worker Communication Guide} | ||
* | ||
* @publicApi | ||
*/ | ||
interface VersionDetectedEvent { | ||
type: 'VERSION_DETECTED'; | ||
version: { | ||
hash: string; | ||
appData?: object; | ||
}; | ||
} | ||
/** | ||
* An event emitted when the installation of a new version failed. | ||
* It may be used for logging/monitoring purposes. | ||
* | ||
* @see {@link /ecosystem/service-workers/communications Service Worker Communication Guide} | ||
*a | ||
* @publicApi | ||
*/ | ||
interface VersionInstallationFailedEvent { | ||
type: 'VERSION_INSTALLATION_FAILED'; | ||
version: { | ||
hash: string; | ||
appData?: object; | ||
}; | ||
error: string; | ||
} | ||
/** | ||
* An event emitted when a new version of the app is available. | ||
* | ||
* @see {@link /ecosystem/service-workers/communications Service Worker Communication Guide} | ||
* | ||
* @publicApi | ||
*/ | ||
interface VersionReadyEvent { | ||
type: 'VERSION_READY'; | ||
currentVersion: { | ||
hash: string; | ||
appData?: object; | ||
}; | ||
latestVersion: { | ||
hash: string; | ||
appData?: object; | ||
}; | ||
} | ||
/** | ||
* A union of all event types that can be emitted by | ||
* {@link SwUpdate#versionUpdates}. | ||
* | ||
* @publicApi | ||
*/ | ||
type VersionEvent = VersionDetectedEvent | VersionInstallationFailedEvent | VersionReadyEvent | NoNewVersionDetectedEvent; | ||
/** | ||
* An event emitted when the version of the app used by the service worker to serve this client is | ||
* in a broken state that cannot be recovered from and a full page reload is required. | ||
* | ||
* For example, the service worker may not be able to retrieve a required resource, neither from the | ||
* cache nor from the server. This could happen if a new version is deployed to the server and the | ||
* service worker cache has been partially cleaned by the browser, removing some files of a previous | ||
* app version but not all. | ||
* | ||
* @see {@link /ecosystem/service-workers/communications Service Worker Communication Guide} | ||
* | ||
* @publicApi | ||
*/ | ||
interface UnrecoverableStateEvent { | ||
type: 'UNRECOVERABLE_STATE'; | ||
reason: string; | ||
} | ||
interface TypedEvent { | ||
type: string; | ||
} | ||
/** | ||
* @publicApi | ||
*/ | ||
declare class NgswCommChannel { | ||
@@ -32,19 +125,67 @@ private serviceWorker; | ||
/** | ||
* An event emitted when the service worker has checked the version of the app on the server and it | ||
* didn't find a new version that it doesn't have already downloaded. | ||
/*! | ||
* @license | ||
* Copyright Google LLC All Rights Reserved. | ||
* | ||
* @see {@link /ecosystem/service-workers/communications Service Worker Communication Guide} | ||
* Use of this source code is governed by an MIT-style license that can be | ||
* found in the LICENSE file at https://angular.dev/license | ||
*/ | ||
/** | ||
* Token that can be used to provide options for `ServiceWorkerModule` outside of | ||
* `ServiceWorkerModule.register()`. | ||
* | ||
* You can use this token to define a provider that generates the registration options at runtime, | ||
* for example via a function call: | ||
* | ||
* {@example service-worker/registration-options/module.ts region="registration-options" | ||
* header="app.module.ts"} | ||
* | ||
* @publicApi | ||
*/ | ||
export declare interface NoNewVersionDetectedEvent { | ||
type: 'NO_NEW_VERSION_DETECTED'; | ||
version: { | ||
hash: string; | ||
appData?: Object; | ||
}; | ||
declare abstract class SwRegistrationOptions { | ||
/** | ||
* Whether the ServiceWorker will be registered and the related services (such as `SwPush` and | ||
* `SwUpdate`) will attempt to communicate and interact with it. | ||
* | ||
* Default: true | ||
*/ | ||
enabled?: boolean; | ||
/** | ||
* A URL that defines the ServiceWorker's registration scope; that is, what range of URLs it can | ||
* control. It will be used when calling | ||
* [ServiceWorkerContainer#register()](https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorkerContainer/register). | ||
*/ | ||
scope?: string; | ||
/** | ||
* Defines the ServiceWorker registration strategy, which determines when it will be registered | ||
* with the browser. | ||
* | ||
* The default behavior of registering once the application stabilizes (i.e. as soon as there are | ||
* no pending micro- and macro-tasks) is designed to register the ServiceWorker as soon as | ||
* possible but without affecting the application's first time load. | ||
* | ||
* Still, there might be cases where you want more control over when the ServiceWorker is | ||
* registered (for example, there might be a long-running timeout or polling interval, preventing | ||
* the app from stabilizing). The available option are: | ||
* | ||
* - `registerWhenStable:<timeout>`: Register as soon as the application stabilizes (no pending | ||
* micro-/macro-tasks) but no later than `<timeout>` milliseconds. If the app hasn't | ||
* stabilized after `<timeout>` milliseconds (for example, due to a recurrent asynchronous | ||
* task), the ServiceWorker will be registered anyway. | ||
* If `<timeout>` is omitted, the ServiceWorker will only be registered once the app | ||
* stabilizes. | ||
* - `registerImmediately`: Register immediately. | ||
* - `registerWithDelay:<timeout>`: Register with a delay of `<timeout>` milliseconds. For | ||
* example, use `registerWithDelay:5000` to register the ServiceWorker after 5 seconds. If | ||
* `<timeout>` is omitted, is defaults to `0`, which will register the ServiceWorker as soon | ||
* as possible but still asynchronously, once all pending micro-tasks are completed. | ||
* - An Observable factory function: A function that returns an `Observable`. | ||
* The function will be used at runtime to obtain and subscribe to the `Observable` and the | ||
* ServiceWorker will be registered as soon as the first value is emitted. | ||
* | ||
* Default: 'registerWhenStable:30000' | ||
*/ | ||
registrationStrategy?: string | (() => Observable<unknown>); | ||
} | ||
/** | ||
@@ -67,3 +208,3 @@ * @publicApi | ||
*/ | ||
export declare function provideServiceWorker(script: string, options?: SwRegistrationOptions): EnvironmentProviders; | ||
declare function provideServiceWorker(script: string, options?: SwRegistrationOptions): EnvironmentProviders; | ||
@@ -73,3 +214,3 @@ /** | ||
*/ | ||
export declare class ServiceWorkerModule { | ||
declare class ServiceWorkerModule { | ||
/** | ||
@@ -166,3 +307,3 @@ * Register the given Angular Service Worker script. | ||
*/ | ||
export declare class SwPush { | ||
declare class SwPush { | ||
private sw; | ||
@@ -227,60 +368,2 @@ /** | ||
/** | ||
* Token that can be used to provide options for `ServiceWorkerModule` outside of | ||
* `ServiceWorkerModule.register()`. | ||
* | ||
* You can use this token to define a provider that generates the registration options at runtime, | ||
* for example via a function call: | ||
* | ||
* {@example service-worker/registration-options/module.ts region="registration-options" | ||
* header="app.module.ts"} | ||
* | ||
* @publicApi | ||
*/ | ||
export declare abstract class SwRegistrationOptions { | ||
/** | ||
* Whether the ServiceWorker will be registered and the related services (such as `SwPush` and | ||
* `SwUpdate`) will attempt to communicate and interact with it. | ||
* | ||
* Default: true | ||
*/ | ||
enabled?: boolean; | ||
/** | ||
* A URL that defines the ServiceWorker's registration scope; that is, what range of URLs it can | ||
* control. It will be used when calling | ||
* [ServiceWorkerContainer#register()](https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorkerContainer/register). | ||
*/ | ||
scope?: string; | ||
/** | ||
* Defines the ServiceWorker registration strategy, which determines when it will be registered | ||
* with the browser. | ||
* | ||
* The default behavior of registering once the application stabilizes (i.e. as soon as there are | ||
* no pending micro- and macro-tasks) is designed to register the ServiceWorker as soon as | ||
* possible but without affecting the application's first time load. | ||
* | ||
* Still, there might be cases where you want more control over when the ServiceWorker is | ||
* registered (for example, there might be a long-running timeout or polling interval, preventing | ||
* the app from stabilizing). The available option are: | ||
* | ||
* - `registerWhenStable:<timeout>`: Register as soon as the application stabilizes (no pending | ||
* micro-/macro-tasks) but no later than `<timeout>` milliseconds. If the app hasn't | ||
* stabilized after `<timeout>` milliseconds (for example, due to a recurrent asynchronous | ||
* task), the ServiceWorker will be registered anyway. | ||
* If `<timeout>` is omitted, the ServiceWorker will only be registered once the app | ||
* stabilizes. | ||
* - `registerImmediately`: Register immediately. | ||
* - `registerWithDelay:<timeout>`: Register with a delay of `<timeout>` milliseconds. For | ||
* example, use `registerWithDelay:5000` to register the ServiceWorker after 5 seconds. If | ||
* `<timeout>` is omitted, is defaults to `0`, which will register the ServiceWorker as soon | ||
* as possible but still asynchronously, once all pending micro-tasks are completed. | ||
* - An Observable factory function: A function that returns an `Observable`. | ||
* The function will be used at runtime to obtain and subscribe to the `Observable` and the | ||
* ServiceWorker will be registered as soon as the first value is emitted. | ||
* | ||
* Default: 'registerWhenStable:30000' | ||
*/ | ||
registrationStrategy?: string | (() => Observable<unknown>); | ||
} | ||
/** | ||
* Subscribe to update notifications from the Service Worker, trigger update | ||
@@ -293,3 +376,3 @@ * checks, and forcibly activate updates. | ||
*/ | ||
export declare class SwUpdate { | ||
declare class SwUpdate { | ||
private sw; | ||
@@ -357,87 +440,2 @@ /** | ||
declare interface TypedEvent { | ||
type: string; | ||
} | ||
/** | ||
* An event emitted when the version of the app used by the service worker to serve this client is | ||
* in a broken state that cannot be recovered from and a full page reload is required. | ||
* | ||
* For example, the service worker may not be able to retrieve a required resource, neither from the | ||
* cache nor from the server. This could happen if a new version is deployed to the server and the | ||
* service worker cache has been partially cleaned by the browser, removing some files of a previous | ||
* app version but not all. | ||
* | ||
* @see {@link /ecosystem/service-workers/communications Service Worker Communication Guide} | ||
* | ||
* @publicApi | ||
*/ | ||
export declare interface UnrecoverableStateEvent { | ||
type: 'UNRECOVERABLE_STATE'; | ||
reason: string; | ||
} | ||
/** | ||
* An event emitted when the service worker has detected a new version of the app on the server and | ||
* is about to start downloading it. | ||
* | ||
* @see {@link /ecosystem/service-workers/communications Service Worker Communication Guide} | ||
* | ||
* @publicApi | ||
*/ | ||
export declare interface VersionDetectedEvent { | ||
type: 'VERSION_DETECTED'; | ||
version: { | ||
hash: string; | ||
appData?: object; | ||
}; | ||
} | ||
/** | ||
* A union of all event types that can be emitted by | ||
* {@link SwUpdate#versionUpdates}. | ||
* | ||
* @publicApi | ||
*/ | ||
export declare type VersionEvent = VersionDetectedEvent | VersionInstallationFailedEvent | VersionReadyEvent | NoNewVersionDetectedEvent; | ||
/** | ||
* An event emitted when the installation of a new version failed. | ||
* It may be used for logging/monitoring purposes. | ||
* | ||
* @see {@link /ecosystem/service-workers/communications Service Worker Communication Guide} | ||
*a | ||
* @publicApi | ||
*/ | ||
export declare interface VersionInstallationFailedEvent { | ||
type: 'VERSION_INSTALLATION_FAILED'; | ||
version: { | ||
hash: string; | ||
appData?: object; | ||
}; | ||
error: string; | ||
} | ||
/** | ||
* An event emitted when a new version of the app is available. | ||
* | ||
* @see {@link /ecosystem/service-workers/communications Service Worker Communication Guide} | ||
* | ||
* @publicApi | ||
*/ | ||
export declare interface VersionReadyEvent { | ||
type: 'VERSION_READY'; | ||
currentVersion: { | ||
hash: string; | ||
appData?: object; | ||
}; | ||
latestVersion: { | ||
hash: string; | ||
appData?: object; | ||
}; | ||
} | ||
export { } | ||
export { type NoNewVersionDetectedEvent, ServiceWorkerModule, SwPush, SwRegistrationOptions, SwUpdate, type UnrecoverableStateEvent, type VersionDetectedEvent, type VersionEvent, type VersionInstallationFailedEvent, type VersionReadyEvent, provideServiceWorker }; |
{ | ||
"name": "@angular/service-worker", | ||
"version": "19.2.1", | ||
"version": "19.2.2", | ||
"description": "Angular - service worker tooling!", | ||
@@ -36,3 +36,3 @@ "author": "angular", | ||
"peerDependencies": { | ||
"@angular/core": "19.2.1", | ||
"@angular/core": "19.2.2", | ||
"rxjs": "^6.5.3 || ^7.4.0" | ||
@@ -39,0 +39,0 @@ }, |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
199634
-1.77%3587
-0.25%