@rescript/webapi 0.1.0-experimental-7e1d9b8 → 0.1.0-experimental-d591da9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +2 -2
- package/src/CanvasAPI/OffscreenCanvas.res +4 -4
- package/src/DOMAPI/Element.res +1 -1
- package/src/DOMAPI/FileList.res +11 -0
- package/src/DOMAPI/HTMLCanvasElement.res +4 -4
- package/src/EventAPI/EventTarget.res +1 -1
- package/src/EventAPI.res +2 -0
- package/src/Global.res +1 -1
- package/src/ServiceWorkerAPI/Clients.res +31 -1
- package/src/ServiceWorkerAPI/ServiceWorkerGlobalScope.res +7 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rescript/webapi",
|
|
3
|
-
"version": "0.1.0-experimental-
|
|
3
|
+
"version": "0.1.0-experimental-d591da9",
|
|
4
4
|
"description": "Experimental successor to [rescript-webapi](https://github.com/TheSpyder/rescript-webapi)",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"dom",
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
"@astrojs/starlight": "0.37.6",
|
|
45
45
|
"astro": "^5.10.1",
|
|
46
46
|
"micromark": "^4.0.1",
|
|
47
|
-
"oxfmt": "^0.
|
|
47
|
+
"oxfmt": "^0.34.0",
|
|
48
48
|
"prettier": "^3.3.3",
|
|
49
49
|
"prettier-plugin-astro": "^0.14.1",
|
|
50
50
|
"rescript": ">=12.0.0 <13",
|
|
@@ -18,7 +18,7 @@ Returns null if the canvas has already been initialized with another context typ
|
|
|
18
18
|
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/OffscreenCanvas/getContext)
|
|
19
19
|
*/
|
|
20
20
|
@send
|
|
21
|
-
external
|
|
21
|
+
external getContext2D: (
|
|
22
22
|
offscreenCanvas,
|
|
23
23
|
@as("2d") _,
|
|
24
24
|
~options: JSON.t=?,
|
|
@@ -33,7 +33,7 @@ Returns null if the canvas has already been initialized with another context typ
|
|
|
33
33
|
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/OffscreenCanvas/getContext)
|
|
34
34
|
*/
|
|
35
35
|
@send
|
|
36
|
-
external
|
|
36
|
+
external getContextWebGL: (
|
|
37
37
|
offscreenCanvas,
|
|
38
38
|
@as("webgl") _,
|
|
39
39
|
~options: webGLContextAttributes=?,
|
|
@@ -48,7 +48,7 @@ Returns null if the canvas has already been initialized with another context typ
|
|
|
48
48
|
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/OffscreenCanvas/getContext)
|
|
49
49
|
*/
|
|
50
50
|
@send
|
|
51
|
-
external
|
|
51
|
+
external getContextWebGL2: (
|
|
52
52
|
offscreenCanvas,
|
|
53
53
|
@as("webgl2") _,
|
|
54
54
|
~options: webGLContextAttributes=?,
|
|
@@ -63,7 +63,7 @@ Returns null if the canvas has already been initialized with another context typ
|
|
|
63
63
|
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/OffscreenCanvas/getContext)
|
|
64
64
|
*/
|
|
65
65
|
@send
|
|
66
|
-
external
|
|
66
|
+
external getContextBitmapRenderer: (
|
|
67
67
|
offscreenCanvas,
|
|
68
68
|
@as("bitmaprenderer") _,
|
|
69
69
|
~options: imageBitmapRenderingContextSettings=?,
|
package/src/DOMAPI/Element.res
CHANGED
|
@@ -411,7 +411,7 @@ element->Element.scrollIntoView_alignToTop()
|
|
|
411
411
|
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Element/scrollIntoView)
|
|
412
412
|
*/
|
|
413
413
|
@send
|
|
414
|
-
external
|
|
414
|
+
external scrollIntoViewAlignToTop: (T.t, @as(json`true`) _) => unit = "scrollIntoView"
|
|
415
415
|
|
|
416
416
|
/**
|
|
417
417
|
`scrollIntoView({ behavior: "smooth" })`
|
package/src/DOMAPI/FileList.res
CHANGED
|
@@ -2,6 +2,17 @@ open FileAPI
|
|
|
2
2
|
open DOMAPI
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
|
+
Returns the `File` at the specified index.
|
|
6
|
+
|
|
7
|
+
`FileList` is not an array, so you need to iterate manually using `length` and `item`:
|
|
8
|
+
|
|
9
|
+
```rescript
|
|
10
|
+
let files = []
|
|
11
|
+
for i in 0 to fileList.length - 1 {
|
|
12
|
+
files->Array.push(fileList->FileList.item(i))
|
|
13
|
+
}
|
|
14
|
+
```
|
|
15
|
+
|
|
5
16
|
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/FileList/item)
|
|
6
17
|
*/
|
|
7
18
|
@send
|
|
@@ -11,7 +11,7 @@ Creates a CanvasRenderingContext2D object representing a two-dimensional renderi
|
|
|
11
11
|
[Read more on MDN](https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/getContext#2d)
|
|
12
12
|
*/
|
|
13
13
|
@send
|
|
14
|
-
external
|
|
14
|
+
external getContext2D: (
|
|
15
15
|
htmlCanvasElement,
|
|
16
16
|
@as("2d") _,
|
|
17
17
|
~options: canvasRenderingContext2DSettings=?,
|
|
@@ -23,7 +23,7 @@ Returns an object that provides methods and properties for drawing and manipulat
|
|
|
23
23
|
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/HTMLCanvasElement/getContext)
|
|
24
24
|
*/
|
|
25
25
|
@send
|
|
26
|
-
external
|
|
26
|
+
external getContextWebGL: (
|
|
27
27
|
htmlCanvasElement,
|
|
28
28
|
@as("webgl") _,
|
|
29
29
|
~options: webGLContextAttributes=?,
|
|
@@ -35,7 +35,7 @@ Returns an object that provides methods and properties for drawing and manipulat
|
|
|
35
35
|
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/HTMLCanvasElement/getContext)
|
|
36
36
|
*/
|
|
37
37
|
@send
|
|
38
|
-
external
|
|
38
|
+
external getContextWebGL2: (
|
|
39
39
|
htmlCanvasElement,
|
|
40
40
|
@as("webgl2") _,
|
|
41
41
|
~options: webGLContextAttributes=?,
|
|
@@ -47,7 +47,7 @@ Returns an object that provides methods and properties for drawing and manipulat
|
|
|
47
47
|
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/HTMLCanvasElement/getContext)
|
|
48
48
|
*/
|
|
49
49
|
@send
|
|
50
|
-
external
|
|
50
|
+
external getContextBitmapRenderer: (
|
|
51
51
|
htmlCanvasElement,
|
|
52
52
|
@as("bitmaprenderer") _,
|
|
53
53
|
~options: imageBitmapRenderingContextSettings=?,
|
|
@@ -78,7 +78,7 @@ Removes the event listener in target's event listener list with the same type, c
|
|
|
78
78
|
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/EventTarget/removeEventListener)
|
|
79
79
|
*/
|
|
80
80
|
@send
|
|
81
|
-
external
|
|
81
|
+
external removeEventListenerUseCapture: (
|
|
82
82
|
T.t,
|
|
83
83
|
eventType,
|
|
84
84
|
eventListener<'event>,
|
package/src/EventAPI.res
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
@unboxed
|
|
4
4
|
type eventType =
|
|
5
5
|
| @as("abort") Abort
|
|
6
|
+
| @as("activate") Activate
|
|
6
7
|
| @as("auxclick") Auxclick
|
|
7
8
|
| @as("beforeinput") Beforeinput
|
|
8
9
|
| @as("beforetoggle") Beforetoggle
|
|
@@ -35,6 +36,7 @@ type eventType =
|
|
|
35
36
|
| @as("focus") Focus
|
|
36
37
|
| @as("formdata") Formdata
|
|
37
38
|
| @as("input") Input
|
|
39
|
+
| @as("install") Install
|
|
38
40
|
| @as("invalid") Invalid
|
|
39
41
|
| @as("keydown") Keydown
|
|
40
42
|
| @as("keypress") Keypress
|
package/src/Global.res
CHANGED
|
@@ -574,7 +574,7 @@ external removeEventListener: (
|
|
|
574
574
|
Removes the event listener in target's event listener list with the same type, callback, and options.
|
|
575
575
|
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/EventTarget/removeEventListener)
|
|
576
576
|
*/
|
|
577
|
-
external
|
|
577
|
+
external removeEventListenerUseCapture: (
|
|
578
578
|
eventType,
|
|
579
579
|
eventListener<'event>,
|
|
580
580
|
@as(json`true`) _,
|
|
@@ -1,4 +1,34 @@
|
|
|
1
1
|
open ServiceWorkerAPI
|
|
2
2
|
|
|
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
|
+
*/
|
|
26
|
+
@send
|
|
27
|
+
external openWindow: (clients, string) => promise<windowClient> = "openWindow"
|
|
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
|
+
*/
|
|
3
33
|
@send
|
|
4
|
-
external
|
|
34
|
+
external claim: clients => promise<unit> = "claim"
|
|
@@ -1,3 +1,10 @@
|
|
|
1
1
|
open ServiceWorkerAPI
|
|
2
2
|
|
|
3
3
|
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"
|