@rescript/webapi 0.1.0-experimental-beb6b0c → 0.1.0-experimental-2d818ca

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-beb6b0c",
3
+ "version": "0.1.0-experimental-2d818ca",
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",
@@ -419,13 +419,13 @@ element->Element.scrollIntoView_alignToTop()
419
419
  Scrolls the element's ancestor containers such that the element on which scrollIntoView() is called is visible to the user.
420
420
 
421
421
  ```res
422
- element->Element.scrollIntoView_withOptions({ behavior: DOMAPI.Smooth })
422
+ element->Element.scrollIntoViewWithOptions({ behavior: DOMAPI.Smooth })
423
423
  ```
424
424
 
425
425
  [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Element/scrollIntoView)
426
426
  */
427
427
  @send
428
- external scrollIntoView_withOptions: (T.t, scrollIntoViewOptions) => unit = "scrollIntoView"
428
+ external scrollIntoViewWithOptions: (T.t, scrollIntoViewOptions) => unit = "scrollIntoView"
429
429
 
430
430
  /**
431
431
  [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Element/scrollTo)
@@ -303,7 +303,7 @@ let response = await window->Window.fetch("https://rescript-lang.org")
303
303
  external fetch: (window, string, ~init: requestInit=?) => promise<response> = "fetch"
304
304
 
305
305
  /**
306
- `fetch_withRequest(window, request, init)`
306
+ `fetchWithRequest(window, request, init)`
307
307
 
308
308
  Starts the process of fetching a resource from the network,
309
309
  returning a promise that is fulfilled once the response is available.
@@ -314,7 +314,7 @@ let response = await window->Window.fetch(myRequest)
314
314
  [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Window/fetch)
315
315
  */
316
316
  @send
317
- external fetch_withRequest: (window, request, ~init: requestInit=?) => promise<response> = "fetch"
317
+ external fetchWithRequest: (window, request, ~init: requestInit=?) => promise<response> = "fetch"
318
318
 
319
319
  /**
320
320
  [Read more on MDN](https://developer.mozilla.org/docs/Web/API/DedicatedWorkerGlobalScope/requestAnimationFrame)
package/src/Global.res CHANGED
@@ -493,7 +493,7 @@ let response = await fetch("https://rescript-lang.org")
493
493
  external fetch: (string, ~init: requestInit=?) => promise<response> = "fetch"
494
494
 
495
495
  /**
496
- `fetch_withRequest(request, init)`
496
+ `fetchWithRequest(request, init)`
497
497
 
498
498
  Starts the process of fetching a resource from the network,
499
499
  returning a promise that is fulfilled once the response is available.
@@ -504,7 +504,7 @@ let response = await fetch(myRequest)
504
504
 
505
505
  [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Window/fetch)
506
506
  */
507
- external fetch_withRequest: (request, ~init: requestInit=?) => promise<response> = "fetch"
507
+ external fetchWithRequest: (request, ~init: requestInit=?) => promise<response> = "fetch"
508
508
 
509
509
  /**
510
510
  [Read more on MDN](https://developer.mozilla.org/docs/Web/API/DedicatedWorkerGlobalScope/requestAnimationFrame)
@@ -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
+
@@ -24,7 +24,7 @@ let response = await self->WorkerGlobalScope.fetch("https://rescript-lang.org")
24
24
  external fetch: (T.t, string, ~init: requestInit=?) => promise<response> = "fetch"
25
25
 
26
26
  /**
27
- `fetch_withRequest(workerGlobalScope, request, init)`
27
+ `fetchWithRequest(workerGlobalScope, request, init)`
28
28
 
29
29
  The fetch() method of the WorkerGlobalScope interface starts the process of fetching a resource from the network,
30
30
  returning a promise that is fulfilled once the response is available.
@@ -35,7 +35,7 @@ let response = await self->WorkerGlobalScope.fetch(myRequest)
35
35
 
36
36
  [Read more on MDN](https://developer.mozilla.org/en-US/docs/Web/API/WorkerGlobalScope/fetch)
37
37
  */
38
- external fetch_withRequest: (T.t, request, ~init: requestInit=?) => promise<response> = "fetch"
38
+ external fetchWithRequest: (T.t, request, ~init: requestInit=?) => promise<response> = "fetch"
39
39
  }
40
40
 
41
41
  include Impl({type t = workerGlobalScope})
@@ -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
+ }