Skip to content

ServiceWorkerAPI

Types

client

The Client interface represents an executable context such as a Worker, or a SharedWorker. Window clients are represented by the more-specific WindowClient. See Client on MDN

type client = {id: string, url: string}

Record fields

id
string
url
string

clients

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

type clients

Module

There are methods and helpers defined in Clients .

type navigationPreloadManager = {}

Module

There are methods and helpers defined in NavigationPreloadManager .

type navigationPreloadState = {
mutable enabled?: bool,
mutable headerValue?: string,
}

Record fields

option< bool >
option< string >

registrationOptions

type registrationOptions = {
mutable scope?: string,
mutable type_?: workerType,
mutable updateViaCache?: serviceWorkerUpdateViaCache,
}

Record fields

scope
option< string >
type_
option< workerType >
updateViaCache

requestInfo

type requestInfo = WebAPI.Prelude.any

serviceWorker

This ServiceWorker API interface 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. See ServiceWorker on MDN

type serviceWorker = {
scriptURL: string,
state: serviceWorkerState,
}

Record fields

scriptURL
string

Module

There are methods and helpers defined in ServiceWorker .

serviceWorkerContainer

The ServiceWorkerContainer interface of the ServiceWorker 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. See ServiceWorkerContainer on MDN

type serviceWorkerContainer = {
controller: Null.t<serviceWorker>,
ready: promise<serviceWorkerRegistration>,
}

Record fields

controller
Null.t< serviceWorker >

Module

There are methods and helpers defined in ServiceWorkerContainer .

serviceWorkerGlobalScope

The ServiceWorkerGlobalScope interface of the Service Worker API represents the global execution context of a service worker. See ServiceWorkerGlobalScope on MDN

type serviceWorkerGlobalScope = {
caches: WebAPI.WebWorkersAPI.cacheStorage,
crossOriginIsolated: bool,
clients: clients,
registration: serviceWorkerRegistration,
}

Record fields

crossOriginIsolated
bool

Module

There are methods and helpers defined in ServiceWorkerGlobalScope .

serviceWorkerRegistration

This ServiceWorker API interface represents the service worker registration. You register a service worker to control one or more pages that share the same origin. See ServiceWorkerRegistration on MDN

type serviceWorkerRegistration = {
installing: Null.t<serviceWorker>,
waiting: Null.t<serviceWorker>,
active: Null.t<serviceWorker>,
navigationPreload: navigationPreloadManager,
scope: string,
updateViaCache: serviceWorkerUpdateViaCache,
pushManager: WebAPI.PushAPI.pushManager,
}

Record fields

installing
Null.t< serviceWorker >
waiting
Null.t< serviceWorker >
active
Null.t< serviceWorker >
scope
string

Module

There are methods and helpers defined in ServiceWorkerRegistration .

serviceWorkerState

type serviceWorkerState =
| @as("activated") Activated
| @as("activating") Activating
| @as("installed") Installed
| @as("installing") Installing
| @as("parsed") Parsed
| @as("redundant") Redundant

serviceWorkerUpdateViaCache

type serviceWorkerUpdateViaCache =
| @as("all") All
| @as("imports") Imports
| @as("none") None

windowClient

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. See WindowClient on MDN

type windowClient = {id: string, url: string}

Record fields

id
string
url
string

workerType

type workerType =
| @as("classic") Classic
| @as("module") Module