Js_of_ocaml.ServiceWorkerService Workers.
This module covers both sides of the API: the page-facing registration API (container, serviceWorkerContainer, serviceWorkerRegistration, serviceWorker) and the worker-side global scope (global, serviceWorkerGlobalScope and its events). The Cache API used inside a worker lives in Cache.
Service Workers require a secure context. The Promise-typed members use Promise.
class type serviceWorker = object ... endA service worker, as seen from a controlled page. Inherits EventTarget.
class type registrationOptions = object ... endOptions for serviceWorkerContainer##register_withOptions. Create an empty record with empty_registration_options.
val empty_registration_options : unit -> registrationOptions Js.tThe state of a registration's navigation preload, as resolved by navigationPreloadManager##getState.
Manages navigation preloading for a serviceWorkerRegistration, exposed as its navigationPreload.
class type serviceWorkerRegistration = object ... endA registration of a service worker against a scope. Inherits EventTarget.
class type serviceWorkerContainer = object ... endThe page-facing entry point, exposed as navigator.serviceWorker (see container). Inherits EventTarget.
val container : unit -> serviceWorkerContainer Js.t Js.optdefnavigator.serviceWorker, or undefined when service workers are not supported (including non-secure contexts).
Whether navigator.serviceWorker is available in the current environment.
The following bindings are meant to be used from inside a service worker (see global); they are not available on a controlled page.
class type extendableEvent = object ... endBase class of events that may extend the service worker's lifetime via waitUntil.
class type fetchEvent = object ... endThe event passed to the worker's fetch handler.
class type 'a extendableMessageEvent = object ... endThe event delivered to the worker's message / messageerror handlers. Unlike a plain Dom_html.messageEvent it extends extendableEvent, so the handler can call waitUntil to keep the worker alive until asynchronous processing of the message finishes. The type parameter 'a is the type of the data payload.
class type client = object ... endA client (a Window, worker or shared worker) controlled by the worker.
class type windowClient = object ... endA client that is a top-level browsing context (a window/tab).
class type clientsQueryOptions = object ... endOptions for clients##matchAll_withOptions. Create an empty record with empty_clients_query_options.
val empty_clients_query_options : unit -> clientsQueryOptions Js.tclass type clients = object ... endThe worker's clients object, used to enumerate and message controlled clients.
class type serviceWorkerGlobalScope = object ... endThe global scope of a running service worker (its self). Inherits EventTarget.
val global : unit -> serviceWorkerGlobalScope Js.tThe service worker's global scope. Only meaningful when the current code is actually running as a service worker.