@rescript/webapi 0.1.0-experimental-b56f2cb → 0.1.0-experimental-fe47fc9
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
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rescript/webapi",
|
|
3
|
-
"version": "0.1.0-experimental-
|
|
3
|
+
"version": "0.1.0-experimental-fe47fc9",
|
|
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",
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
open ChannelMessagingAPI
|
|
2
|
+
open WebWorkersAPI
|
|
3
|
+
|
|
4
|
+
include EventTarget.Impl({
|
|
5
|
+
type t = sharedWorker
|
|
6
|
+
})
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
`make(string)`
|
|
10
|
+
|
|
11
|
+
The SharedWorker() constructor creates a SharedWorker object that executes the
|
|
12
|
+
script at the specified URL. This script must obey the same-origin policy.
|
|
13
|
+
|
|
14
|
+
```res
|
|
15
|
+
let shared: sharedWorker = SharedWorker.make("sharedworker.js")
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
[Read more on MDN](https://developer.mozilla.org/en-US/docs/Web/API/SharedWorker/)
|
|
19
|
+
*/
|
|
20
|
+
@new
|
|
21
|
+
external make: string => sharedWorker = "SharedWorker"
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
`makeWithName(string, string)`
|
|
25
|
+
|
|
26
|
+
The SharedWorker() constructor creates a SharedWorker object that executes the
|
|
27
|
+
script at the specified URL. This script must obey the same-origin policy.
|
|
28
|
+
|
|
29
|
+
```res
|
|
30
|
+
let shared: sharedWorker = SharedWorker.make("sharedworker.js", "name")
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
[Read more on MDN](https://developer.mozilla.org/en-US/docs/Web/API/SharedWorker/)
|
|
34
|
+
*/
|
|
35
|
+
@new
|
|
36
|
+
external makeWithName: (string, string) => sharedWorker = "SharedWorker"
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
`makeWithOptions(string, workerOptions)`
|
|
40
|
+
|
|
41
|
+
The SharedWorker() constructor creates a SharedWorker object that executes the
|
|
42
|
+
script at the specified URL. This script must obey the same-origin policy.
|
|
43
|
+
|
|
44
|
+
```res
|
|
45
|
+
let shared: sharedWorker = SharedWorker.makeWithOptions("sharedworker.js", {
|
|
46
|
+
name: "workerName",
|
|
47
|
+
type_: Module
|
|
48
|
+
})
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
[Read more on MDN](https://developer.mozilla.org/en-US/docs/Web/API/SharedWorker/)
|
|
52
|
+
*/
|
|
53
|
+
@new
|
|
54
|
+
external makeWithOptions: (string, workerOptions) => sharedWorker = "SharedWorker"
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
`port(sharedWorker)`
|
|
58
|
+
|
|
59
|
+
The port property of the SharedWorker interface returns a MessagePort object
|
|
60
|
+
used to communicate and control the shared worker.
|
|
61
|
+
|
|
62
|
+
```res
|
|
63
|
+
let port: WebAPI.ChannelMessagingAPI.messagePort = SharedWorker.port(myWorker)
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
[Read more on MDN](https://developer.mozilla.org/en-US/docs/Web/API/SharedWorker/port)
|
|
67
|
+
*/
|
|
68
|
+
@get
|
|
69
|
+
external port: sharedWorker => messagePort = "port"
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
open WebWorkersAPI
|
|
2
|
+
|
|
3
|
+
module Impl = (
|
|
4
|
+
T: {
|
|
5
|
+
type t
|
|
6
|
+
},
|
|
7
|
+
) => {
|
|
8
|
+
include WorkerGlobalScope.Impl({
|
|
9
|
+
type t = T.t
|
|
10
|
+
})
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
`close(sharedWorkerGlobalScope)`
|
|
14
|
+
|
|
15
|
+
The close() method of the SharedWorkerGlobalScope interface discards any tasks
|
|
16
|
+
queued in the SharedWorkerGlobalScope's event loop, effectively closing this
|
|
17
|
+
particular scope.
|
|
18
|
+
|
|
19
|
+
```res
|
|
20
|
+
self -> SharedWorkerGlobalScope.close
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
[Read more on MDN](https://developer.mozilla.org/en-US/docs/Web/API/SharedWorkerGlobalScope/close)
|
|
24
|
+
*/
|
|
25
|
+
@send
|
|
26
|
+
external close: T.t => unit = "close"
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
include Impl({
|
|
30
|
+
type t = sharedWorkerGlobalScope
|
|
31
|
+
})
|
|
32
|
+
|
package/src/WebWorkersAPI.res
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
open EventAPI
|
|
2
|
+
open FetchAPI
|
|
2
3
|
|
|
3
4
|
/**
|
|
4
5
|
Provides a storage mechanism for Request / Response object pairs that are cached, for example as part of the ServiceWorker life cycle. Note that the Cache interface is exposed to windowed scopes as well as workers. You don't have to use it in conjunction with service workers, even though it is defined in the service worker spec.
|
|
@@ -25,6 +26,8 @@ type multiCacheQueryOptions = {
|
|
|
25
26
|
mutable cacheName?: string,
|
|
26
27
|
}
|
|
27
28
|
|
|
29
|
+
type sharedWorker
|
|
30
|
+
|
|
28
31
|
/**
|
|
29
32
|
The WorkerGlobalScope interface of the Web Workers API is an interface representing the scope of any worker.
|
|
30
33
|
Workers have no browsing context; this scope contains the information usually conveyed by Window objects —
|
|
@@ -44,3 +47,29 @@ type workerGlobalScope = {
|
|
|
44
47
|
*/
|
|
45
48
|
crossOriginIsolated: bool,
|
|
46
49
|
}
|
|
50
|
+
|
|
51
|
+
type workerType =
|
|
52
|
+
| @as("classic") Classic
|
|
53
|
+
| @as("module") Module
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
/** An object containing option properties that can set when creating the
|
|
57
|
+
object instance. */
|
|
58
|
+
type workerOptions = {
|
|
59
|
+
@as("type") mutable type_?: workerType,
|
|
60
|
+
mutable credentials?: requestCredentials,
|
|
61
|
+
mutable name?: string,
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
The `SharedWorkerGlobalScope` object (the `SharedWorker` global scope) is
|
|
66
|
+
accessible through the self keyword. Some additional global functions,
|
|
67
|
+
namespaces objects, and constructors, not typically associated with the worker
|
|
68
|
+
global scope, but available on it, are listed in the JavaScript Reference. See
|
|
69
|
+
the complete list of functions available to workers.
|
|
70
|
+
*/
|
|
71
|
+
@editor.completeFrom(SharedWorkerGlobalScope)
|
|
72
|
+
type sharedWorkerGlobalScope = {
|
|
73
|
+
...workerGlobalScope,
|
|
74
|
+
name: option<string>
|
|
75
|
+
}
|