Skip to content

Commit b26c527

Browse files
committed
Add WorkerOptions to [Shared]Worker constructors
1 parent c12959e commit b26c527

File tree

4 files changed

+24
-5
lines changed

4 files changed

+24
-5
lines changed

api-reports/2_12.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25351,6 +25351,12 @@ WorkerNavigator[JT] def onLine: Boolean
2535125351
WorkerNavigator[JT] def platform: String
2535225352
WorkerNavigator[JT] def sendBeacon(url: String, data: BodyInit?): Boolean (@deprecated in 2.0.0)
2535325353
WorkerNavigator[JT] def userAgent: String
25354+
WorkerOptions[JT] var credentials: js.UndefOr[RequestCredentials]
25355+
WorkerOptions[JT] var name: js.UndefOr[String]
25356+
WorkerOptions[JT] var `type`: js.UndefOr[WorkerType]
25357+
WorkerType[JT]
25358+
WorkerType[SO] val classic: WorkerType
25359+
WorkerType[SO] val module: WorkerType
2535425360
WriteableState[JT]
2535525361
WriteableState[SO] val closed: WriteableState
2535625362
WriteableState[SO] val closing: WriteableState

api-reports/2_13.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25351,6 +25351,12 @@ WorkerNavigator[JT] def onLine: Boolean
2535125351
WorkerNavigator[JT] def platform: String
2535225352
WorkerNavigator[JT] def sendBeacon(url: String, data: BodyInit?): Boolean (@deprecated in 2.0.0)
2535325353
WorkerNavigator[JT] def userAgent: String
25354+
WorkerOptions[JT] var credentials: js.UndefOr[RequestCredentials]
25355+
WorkerOptions[JT] var name: js.UndefOr[String]
25356+
WorkerOptions[JT] var `type`: js.UndefOr[WorkerType]
25357+
WorkerType[JT]
25358+
WorkerType[SO] val classic: WorkerType
25359+
WorkerType[SO] val module: WorkerType
2535425360
WriteableState[JT]
2535525361
WriteableState[SO] val closed: WriteableState
2535625362
WriteableState[SO] val closing: WriteableState

dom/src/main/scala/org/scalajs/dom/SharedWorker.scala

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package org.scalajs.dom
22

33
import scala.scalajs.js
44
import scala.scalajs.js.annotation._
5+
import scala.scalajs.js.|
56

67
/** The SharedWorker interface represents a specific kind of worker that can be accessed from several browsing contexts,
78
* such as several windows, iframes or even workers. They implement an interface different than dedicated workers and
@@ -17,13 +18,14 @@ import scala.scalajs.js.annotation._
1718
* {{{var myWorker = new SharedWorker("aURL", name);}}}
1819
* @param stringUrl
1920
* A DOMString representing the URL of the script the worker will execute. It must obey the same-origin policy.
20-
* @param name
21-
* An optional argument that specifies an existing SharedWorkerGlobalScope.name — if this is specified then that
22-
* SharedWorkerGlobalScope will be used as the scope for this shared worker.
21+
* @param options
22+
* A DOMString specifying an identifying name for the SharedWorkerGlobalScope representing the scope of the worker,
23+
* which is mainly useful for debugging purposes. Or, an object containing option properties that can set when
24+
* creating the object instance.
2325
*/
2426
@js.native
2527
@JSGlobal
26-
class SharedWorker(stringUrl: String, name: js.UndefOr[String] = js.native) extends AbstractWorker {
28+
class SharedWorker(scriptURL: String, options: js.UndefOr[String | WorkerOptions] = js.native) extends AbstractWorker {
2729

2830
/** The port property of the SharedWorker interface returns a [[MessagePort]] object used to communicate and control
2931
* the shared worker.

dom/src/main/scala/org/scalajs/dom/Worker.scala

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,15 @@ import scala.scalajs.js.annotation._
1010
* Of note is the fact that workers may in turn spawn new workers as long as those workers are hosted within the same
1111
* origin as the parent page. In addition, workers may use XMLHttpRequest for network I/O, with the exception that the
1212
* responseXML and channel attributes on XMLHttpRequest always return null.
13+
*
14+
* @param scriptURL
15+
* A USVString representing the URL of the script the worker will execute. It must obey the same-origin policy.
16+
* @param options
17+
* An object containing option properties that can be set when creating the object instance.
1318
*/
1419
@js.native
1520
@JSGlobal
16-
class Worker(stringUrl: String) extends AbstractWorker {
21+
class Worker(scriptURL: String, options: js.UndefOr[WorkerOptions] = js.native) extends AbstractWorker {
1722

1823
/** The Worker.onmessage property represents an EventHandler, that is a function to be called when the message event
1924
* occurs. These events are of type MessageEvent and will be called when the worker calls its own postMessage()

0 commit comments

Comments
 (0)