@rescript/webapi 0.1.0-experimental-47c6b2c → 0.1.0-experimental-9b9723d
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/DOMAPI/Window.res +19 -2
- package/src/FetchAPI/BodyInit.res +47 -0
- package/src/FetchAPI/HeadersInit.res +11 -0
- package/src/FetchAPI.res +4 -2
- package/src/Global.res +21 -2
- package/src/Prelude.res +0 -2
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-9b9723d",
|
|
4
4
|
"description": "Experimental successor to [rescript-webapi](https://github.com/TheSpyder/rescript-webapi)",
|
|
5
5
|
"homepage": "https://rescript-lang.github.io/experimental-rescript-webapi/",
|
|
6
6
|
"bugs": "https://github.com/rescript-lang/experimental-rescript-webapi/issues",
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
"scripts": {
|
|
30
30
|
"test": "node tests/index.js",
|
|
31
31
|
"build": "rewatch",
|
|
32
|
-
"format": "rescript format -all && prettier --write ./
|
|
32
|
+
"format": "rescript format -all && prettier --write ./tests/index.js ./package.json",
|
|
33
33
|
"docs": "astro dev",
|
|
34
34
|
"build:docs": "astro build"
|
|
35
35
|
},
|
package/src/DOMAPI/Window.res
CHANGED
|
@@ -294,16 +294,33 @@ external structuredClone: (window, 't, ~options: structuredSerializeOptions=?) =
|
|
|
294
294
|
"structuredClone"
|
|
295
295
|
|
|
296
296
|
/**
|
|
297
|
+
`fetch(window, string, init)`
|
|
298
|
+
|
|
299
|
+
Starts the process of fetching a resource from the network,
|
|
300
|
+
returning a promise that is fulfilled once the response is available.
|
|
301
|
+
|
|
302
|
+
```res
|
|
303
|
+
let response = await window->Window.fetch("https://rescript-lang.org")
|
|
304
|
+
```
|
|
305
|
+
|
|
297
306
|
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Window/fetch)
|
|
298
307
|
*/
|
|
299
308
|
@send
|
|
300
|
-
external fetch: (window,
|
|
309
|
+
external fetch: (window, string, ~init: requestInit=?) => Promise.t<response> = "fetch"
|
|
301
310
|
|
|
302
311
|
/**
|
|
312
|
+
`fetch_withRequest(window, request, init)`
|
|
313
|
+
|
|
314
|
+
Starts the process of fetching a resource from the network,
|
|
315
|
+
returning a promise that is fulfilled once the response is available.
|
|
316
|
+
|
|
317
|
+
```res
|
|
318
|
+
let response = await window->Window.fetch(myRequest)
|
|
319
|
+
```
|
|
303
320
|
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Window/fetch)
|
|
304
321
|
*/
|
|
305
322
|
@send
|
|
306
|
-
external
|
|
323
|
+
external fetch_withRequest: (window, request, ~init: requestInit=?) => Promise.t<response> = "fetch"
|
|
307
324
|
|
|
308
325
|
/**
|
|
309
326
|
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/DedicatedWorkerGlobalScope/requestAnimationFrame)
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
open FileAPI
|
|
2
|
+
open FetchAPI
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
[Read more on MDN](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API/Using_Fetch#setting_a_body)
|
|
6
|
+
*/
|
|
7
|
+
external fromString: string => bodyInit = "%identity"
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
[Read more on MDN](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API/Using_Fetch#setting_a_body)
|
|
11
|
+
*/
|
|
12
|
+
external fromArrayBuffer: ArrayBuffer.t => bodyInit = "%identity"
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
[Read more on MDN](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API/Using_Fetch#setting_a_body)
|
|
16
|
+
*/
|
|
17
|
+
external fromTypedArray: TypedArray.t<'t> => bodyInit = "%identity"
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
[Read more on MDN](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API/Using_Fetch#setting_a_body)
|
|
21
|
+
*/
|
|
22
|
+
external fromDataView: DataView.t => bodyInit = "%identity"
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
[Read more on MDN](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API/Using_Fetch#setting_a_body)
|
|
26
|
+
*/
|
|
27
|
+
external fromBlob: blob => bodyInit = "%identity"
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
[Read more on MDN](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API/Using_Fetch#setting_a_body)
|
|
31
|
+
*/
|
|
32
|
+
external fromFile: file => bodyInit = "%identity"
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
[Read more on MDN](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API/Using_Fetch#setting_a_body)
|
|
36
|
+
*/
|
|
37
|
+
external fromURLSearchParams: urlSearchParams => bodyInit = "%identity"
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
[Read more on MDN](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API/Using_Fetch#setting_a_body)
|
|
41
|
+
*/
|
|
42
|
+
external fromFormData: formData => bodyInit = "%identity"
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
[Read more on MDN](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API/Using_Fetch#setting_a_body)
|
|
46
|
+
*/
|
|
47
|
+
external fromReadableStream: readableStream<'t> => bodyInit = "%identity"
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
open FetchAPI
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
[Read more on MDN](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API/Using_Fetch#setting_headers)
|
|
5
|
+
*/
|
|
6
|
+
external fromDict: dict<string> => headersInit = "%identity"
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
[Read more on MDN](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API/Using_Fetch#setting_headers)
|
|
10
|
+
*/
|
|
11
|
+
external fromHeaders: headers => headersInit = "%identity"
|
package/src/FetchAPI.res
CHANGED
|
@@ -218,7 +218,9 @@ type urlSearchParams = {
|
|
|
218
218
|
size: int,
|
|
219
219
|
}
|
|
220
220
|
|
|
221
|
-
type headersInit
|
|
221
|
+
type headersInit
|
|
222
|
+
|
|
223
|
+
type bodyInit
|
|
222
224
|
|
|
223
225
|
type requestInfo = any
|
|
224
226
|
|
|
@@ -236,7 +238,7 @@ type requestInit = {
|
|
|
236
238
|
/**
|
|
237
239
|
A BodyInit object or null to set request's body.
|
|
238
240
|
*/
|
|
239
|
-
mutable body?:
|
|
241
|
+
mutable body?: bodyInit,
|
|
240
242
|
/**
|
|
241
243
|
A string whose value is a same-origin URL, "about:client", or the empty string, to set request's referrer.
|
|
242
244
|
*/
|
package/src/Global.res
CHANGED
|
@@ -480,14 +480,33 @@ external createImageBitmap18: (
|
|
|
480
480
|
external structuredClone: ('t, ~options: structuredSerializeOptions=?) => 't = "structuredClone"
|
|
481
481
|
|
|
482
482
|
/**
|
|
483
|
+
`fetch(string, init)`
|
|
484
|
+
|
|
485
|
+
Starts the process of fetching a resource from the network,
|
|
486
|
+
returning a promise that is fulfilled once the response is available.
|
|
487
|
+
|
|
488
|
+
```res
|
|
489
|
+
let response = await fetch("https://rescript-lang.org")
|
|
490
|
+
```
|
|
491
|
+
|
|
483
492
|
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Window/fetch)
|
|
484
493
|
*/
|
|
485
|
-
external fetch: (
|
|
494
|
+
external fetch: (string, ~init: requestInit=?) => Promise.t<response> = "fetch"
|
|
486
495
|
|
|
487
496
|
/**
|
|
497
|
+
`fetch_withRequest(request, init)`
|
|
498
|
+
|
|
499
|
+
Starts the process of fetching a resource from the network,
|
|
500
|
+
returning a promise that is fulfilled once the response is available.
|
|
501
|
+
|
|
502
|
+
```res
|
|
503
|
+
let response = await fetch(myRequest)
|
|
504
|
+
```
|
|
505
|
+
|
|
488
506
|
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Window/fetch)
|
|
489
507
|
*/
|
|
490
|
-
|
|
508
|
+
@send
|
|
509
|
+
external fetch_withRequest: (request, ~init: requestInit=?) => Promise.t<response> = "fetch"
|
|
491
510
|
|
|
492
511
|
/**
|
|
493
512
|
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/DedicatedWorkerGlobalScope/requestAnimationFrame)
|