Skip to content

Commit b32895f

Browse files
committed
Add missing Service Worker bindings for skipWaiting and Clients
1 parent b168970 commit b32895f

File tree

2 files changed

+37
-0
lines changed

2 files changed

+37
-0
lines changed

src/ServiceWorkerAPI/Clients.res

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,34 @@
11
open ServiceWorkerAPI
22

3+
type clientQueryOptions = {
4+
mutable includeUncontrolled?: bool,
5+
@as("type") mutable type_?: string,
6+
}
7+
8+
/**
9+
Returns a `Promise` for a `Client` matching a given id.
10+
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Clients/get)
11+
*/
12+
@send
13+
external get: (clients, string) => promise<Nullable.t<client>> = "get"
14+
15+
/**
16+
Returns a `Promise` for an array of `Client` objects matching the given options.
17+
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Clients/matchAll)
18+
*/
19+
@send
20+
external matchAll: (clients, ~options: clientQueryOptions=?) => promise<array<client>> = "matchAll"
21+
22+
/**
23+
Opens a new browser window for a given URL and returns a `Promise` for the new `WindowClient`.
24+
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Clients/openWindow)
25+
*/
326
@send
427
external openWindow: (clients, string) => promise<windowClient> = "open"
28+
29+
/**
30+
Allows an active service worker to set itself as the controller for all clients within its scope.
31+
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Clients/claim)
32+
*/
33+
@send
34+
external claim: clients => promise<unit> = "claim"
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
11
open ServiceWorkerAPI
22

33
include WorkerGlobalScope.Impl({type t = serviceWorkerGlobalScope})
4+
5+
/**
6+
Forces the waiting service worker to become the active service worker.
7+
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/ServiceWorkerGlobalScope/skipWaiting)
8+
*/
9+
@send
10+
external skipWaiting: serviceWorkerGlobalScope => promise<unit> = "skipWaiting"

0 commit comments

Comments
 (0)