Skip to content

ServiceWorker

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
type navigationPreloadManager = private {}
type navigationPreloadState = {
mutable enabled?: bool,
mutable headerValue?: string,
}

Record fields

option< bool >
option< string >

registrationOptions

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

Record fields

scope
option< string >
type_
option< WebWorkersTypes.workerType >
updateViaCache

requestInfo

type requestInfo = unknown

serviceWorker

This WebApiServiceWorker 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 WebApiServiceWorker object. See WebApiServiceWorker on MDN

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

Record fields

scriptURL
string

serviceWorkerContainer

The ServiceWorkerContainer interface of the WebApiServiceWorker 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 = private {
controller: Null.t<serviceWorker>,
ready: promise<serviceWorkerRegistration>,
}

Record fields

controller
Null.t< serviceWorker >

serviceWorkerGlobalScope

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

type serviceWorkerGlobalScope = private {
caches: WebWorkersTypes.cacheStorage,
crossOriginIsolated: bool,
clients: clients,
registration: serviceWorkerRegistration,
}

Record fields

caches
WebWorkersTypes.cacheStorage
crossOriginIsolated
bool

serviceWorkerRegistration

This WebApiServiceWorker 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 = private {
installing: Null.t<serviceWorker>,
waiting: Null.t<serviceWorker>,
active: Null.t<serviceWorker>,
navigationPreload: navigationPreloadManager,
scope: string,
updateViaCache: serviceWorkerUpdateViaCache,
pushManager: PushTypes.pushManager,
}

Record fields

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

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 WebApiServiceWorker 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