Package-level declarations

Types

Link copied to clipboard
open class Client

The Client interface represents an executable context such as a Worker, or a SharedWorker. Window clients are represented by the more-specific WindowClient. You can get Client/WindowClient objects from methods such as Clients.matchAll() and Clients.get().

Link copied to clipboard
Link copied to clipboard
open class Clients

The Clients interface provides access to Client objects. Access it via self.clients within a service worker.

Link copied to clipboard
sealed interface ClientTypes
Link copied to clipboard
open class ExtendableEvent(val type: EventType<ExtendableEvent>, init: ExtendableEventInit = definedExternally) : Event

The ExtendableEvent interface extends the lifetime of the install and activate events dispatched on the global scope as part of the service worker lifecycle. This ensures that any functional events (like FetchEvent) are not dispatched until it upgrades database schemas and deletes the outdated cache entries.

Link copied to clipboard
Link copied to clipboard

The ExtendableMessageEvent interface of the Service Worker API represents the event object of a message event fired on a service worker (when a message is received on the ServiceWorkerGlobalScope from another context) — extends the lifetime of such events.

Link copied to clipboard

This is the event type for fetch events dispatched on the service worker global scope. It contains information about the fetch, including the request and how the receiver will treat the response. It provides the event.respondWith() method, which allows us to provide a response to this fetch.

Link copied to clipboard
Link copied to clipboard
sealed interface FrameType
Link copied to clipboard
Link copied to clipboard

The NavigationPreloadManager interface of the Service Worker API provides methods for managing the preloading of resources in parallel with service worker bootup. Available only in secure contexts.

Link copied to clipboard
Link copied to clipboard

The NotificationEvent interface of the Notifications API represents a notification event dispatched on the ServiceWorkerGlobalScope of a ServiceWorker.

Link copied to clipboard
Link copied to clipboard

The ServiceWorker interface of the Service Worker API provides a reference to a service worker. Multiple browsing contexts (e.g., pages, workers, etc.) can be associated with the same service worker, each through a unique ServiceWorker object. Available only in secure contexts.

Link copied to clipboard

The ServiceWorkerContainer interface of the Service Worker API provides an object representing the service worker as an overall unit in the network ecosystem, including facilities to register, unregister and update service workers, and access the state of service workers and their registrations. Available only in secure contexts.

Link copied to clipboard

The ServiceWorkerGlobalScope interface of the Service Worker API represents the global execution context of a service worker. Available only in secure contexts.

Link copied to clipboard
sealed interface ServiceWorkerModule
Link copied to clipboard

The ServiceWorkerRegistration interface of the Service Worker API represents the service worker registration. You register a service worker to control one or more pages that share the same origin. Available only in secure contexts.

Link copied to clipboard
sealed interface ServiceWorkerState
Link copied to clipboard
Link copied to clipboard
open class WindowClient : Client

The WindowClient interface of the ServiceWorker API represents the scope of a service worker client that is a document in a browsing context, controlled by an active worker. The service worker client independently selects and uses a service worker for its own loading and sub-resources.

Properties

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard

Functions

Link copied to clipboard
inline suspend fun Clients.claim()

The claim() method of the Clients interface allows an active service worker to set itself as the controller for all clients within its scope. This triggers a controllerchange event on navigator.serviceWorker in any clients that become controlled by this service worker.

Link copied to clipboard
inline suspend fun NavigationPreloadManager.disable()

The disable() method of the NavigationPreloadManager interface halts the automatic preloading of service-worker-managed resources previously started using enable() It returns a promise that resolves with undefined.

Link copied to clipboard
inline suspend fun NavigationPreloadManager.enable()

The enable() method of the NavigationPreloadManager interface is used to enable preloading of resources managed by the service worker. It returns a promise that resolves with undefined.

Link copied to clipboard
inline suspend fun WindowClient.focus(): WindowClient

The focus() method of the WindowClient interface gives user input focus to the current client and returns a Promise that resolves to the existing WindowClient.

Link copied to clipboard
inline suspend fun Clients.get(id: String): Client?

The get() method of the Clients interface gets a service worker client matching a given id and returns it in a Promise.

Link copied to clipboard

The getNotifications() method of the ServiceWorkerRegistration interface returns a list of the notifications in the order that they were created from the current origin via the current service worker registration. Origins can have many active but differently-scoped service worker registrations. Notifications created by one service worker on the same origin will not be available to other active service workers on that same origin.

Link copied to clipboard

The getRegistration() method of the ServiceWorkerContainer interface gets a ServiceWorkerRegistration object whose scope URL matches the provided client URL. The method returns a Promise that resolves to a ServiceWorkerRegistration or undefined.

Link copied to clipboard

The getRegistrations() method of the ServiceWorkerContainer interface gets all ServiceWorkerRegistrations associated with a ServiceWorkerContainer, in an array. The method returns a Promise that resolves to an array of ServiceWorkerRegistration.

Link copied to clipboard

The getState() method of the NavigationPreloadManager interface returns a Promise that resolves to an object with properties that indicate whether preload is enabled and what value will be sent in the Service-Worker-Navigation-Preload HTTP header.

Link copied to clipboard
inline suspend fun <T : ClientQueryOptions> Clients.matchAll(options: T): ReadonlyArray<Client>

The matchAll() method of the Clients interface returns a Promise for a list of service worker Client objects. Include the options parameter to return all service worker clients whose origin is the same as the associated service worker's origin. If options are not included, the method returns only the service worker clients controlled by the service worker.

Link copied to clipboard
inline suspend fun WindowClient.navigate(url: String): WindowClient?

The navigate() method of the WindowClient interface loads a specified URL into a controlled client page then returns a Promise that resolves to the existing WindowClient.

inline suspend fun WindowClient.navigate(url: URL): WindowClient?
Link copied to clipboard
inline suspend fun Clients.openWindow(url: String): WindowClient?

The openWindow() method of the Clients interface creates a new top level browsing context and loads a given URL. If the calling script doesn't have permission to show popups, openWindow() will throw an InvalidAccessError.

inline suspend fun Clients.openWindow(url: URL): WindowClient?
Link copied to clipboard

The register() method of the ServiceWorkerContainer interface creates or updates a ServiceWorkerRegistration for the given scope. If successful, the registration associates the provided script URL to a scope, which is subsequently used for matching documents to a specific service worker.

Link copied to clipboard
Link copied to clipboard

The setHeaderValue() method of the NavigationPreloadManager interface sets the value of the Service-Worker-Navigation-Preload header that will be sent with requests resulting from a fetch() operation made during service worker navigation preloading. It returns an empty Promise that resolves with undefined.

Link copied to clipboard

The showNotification() method of the ServiceWorkerRegistration interface creates a notification on an active service worker.

Link copied to clipboard

The skipWaiting() method of the ServiceWorkerGlobalScope interface forces the waiting service worker to become the active service worker.

Link copied to clipboard

The unregister() method of the ServiceWorkerRegistration interface unregisters the service worker registration and returns a Promise. The promise will resolve to false if no registration was found, otherwise it resolves to true irrespective of whether unregistration happened or not (it may not unregister if someone else just called ServiceWorkerContainer.register() with the same scope.) The service worker will finish any ongoing operations before it is unregistered.

Link copied to clipboard

The update() method of the ServiceWorkerRegistration interface attempts to update the service worker. It fetches the worker's script URL, and if the new worker is not byte-by-byte identical to the current worker, it installs the new worker. The fetch of the worker bypasses any browser caches if the previous fetch occurred over 24 hours ago.

Link copied to clipboard

The ExtendableEvent.waitUntil() method tells the event dispatcher that work is ongoing.