diff --git a/api-reports/2_12.txt b/api-reports/2_12.txt index 7cc217fa3..737dec74a 100644 --- a/api-reports/2_12.txt +++ b/api-reports/2_12.txt @@ -24452,7 +24452,7 @@ ServiceWorkerContainer[JT] def getRegistrations(): js.Promise[js.Array[ServiceWo ServiceWorkerContainer[JT] var oncontrollerchange: js.Function1[Event, _] ServiceWorkerContainer[JT] var onmessage: js.Function1[MessageEvent, _] ServiceWorkerContainer[JT] def ready: js.Promise[ServiceWorkerRegistration] -ServiceWorkerContainer[JT] def register(scriptURL: String, options: js.Object?): js.Promise[ServiceWorkerRegistration] +ServiceWorkerContainer[JT] def register(scriptURL: String, options: ServiceWorkerRegistrationOptions?): js.Promise[ServiceWorkerRegistration] ServiceWorkerContainer[JT] def removeEventListener[T <: Event](`type`: String, listener: js.Function1[T, _], options: EventListenerOptions): Unit ServiceWorkerContainer[JT] def removeEventListener[T <: Event](`type`: String, listener: js.Function1[T, _], useCapture: Boolean?): Unit ServiceWorkerGlobalScope[JO] def self: ServiceWorkerGlobalScope @@ -24520,12 +24520,19 @@ ServiceWorkerRegistration[JT] def showNotification(title: String, options: Notif ServiceWorkerRegistration[JT] def unregister(): js.Promise[Boolean] ServiceWorkerRegistration[JT] def update(): js.Promise[Unit] ServiceWorkerRegistration[JT] var waiting: ServiceWorker +ServiceWorkerRegistrationOptions[JT] var scope: js.UndefOr[String] +ServiceWorkerRegistrationOptions[JT] var `type`: js.UndefOr[WorkerType] +ServiceWorkerRegistrationOptions[JT] var updateViaCache: js.UndefOr[ServiceWorkerUpdateViaCache] ServiceWorkerState[JT] ServiceWorkerState[SO] val activated: ServiceWorkerState ServiceWorkerState[SO] val activating: ServiceWorkerState ServiceWorkerState[SO] val installed: ServiceWorkerState ServiceWorkerState[SO] val installing: ServiceWorkerState ServiceWorkerState[SO] val redundant: ServiceWorkerState +ServiceWorkerUpdateViaCache[JT] +ServiceWorkerUpdateViaCache[SO] val all: ServiceWorkerUpdateViaCache +ServiceWorkerUpdateViaCache[SO] val imports: ServiceWorkerUpdateViaCache +ServiceWorkerUpdateViaCache[SO] val none: ServiceWorkerUpdateViaCache ShadowRoot[JC] def activeElement: Element ShadowRoot[JC] def addEventListener[T <: Event](`type`: String, listener: js.Function1[T, _], options: EventListenerOptions): Unit ShadowRoot[JC] def addEventListener[T <: Event](`type`: String, listener: js.Function1[T, _], useCapture: Boolean?): Unit diff --git a/api-reports/2_13.txt b/api-reports/2_13.txt index 7cc217fa3..737dec74a 100644 --- a/api-reports/2_13.txt +++ b/api-reports/2_13.txt @@ -24452,7 +24452,7 @@ ServiceWorkerContainer[JT] def getRegistrations(): js.Promise[js.Array[ServiceWo ServiceWorkerContainer[JT] var oncontrollerchange: js.Function1[Event, _] ServiceWorkerContainer[JT] var onmessage: js.Function1[MessageEvent, _] ServiceWorkerContainer[JT] def ready: js.Promise[ServiceWorkerRegistration] -ServiceWorkerContainer[JT] def register(scriptURL: String, options: js.Object?): js.Promise[ServiceWorkerRegistration] +ServiceWorkerContainer[JT] def register(scriptURL: String, options: ServiceWorkerRegistrationOptions?): js.Promise[ServiceWorkerRegistration] ServiceWorkerContainer[JT] def removeEventListener[T <: Event](`type`: String, listener: js.Function1[T, _], options: EventListenerOptions): Unit ServiceWorkerContainer[JT] def removeEventListener[T <: Event](`type`: String, listener: js.Function1[T, _], useCapture: Boolean?): Unit ServiceWorkerGlobalScope[JO] def self: ServiceWorkerGlobalScope @@ -24520,12 +24520,19 @@ ServiceWorkerRegistration[JT] def showNotification(title: String, options: Notif ServiceWorkerRegistration[JT] def unregister(): js.Promise[Boolean] ServiceWorkerRegistration[JT] def update(): js.Promise[Unit] ServiceWorkerRegistration[JT] var waiting: ServiceWorker +ServiceWorkerRegistrationOptions[JT] var scope: js.UndefOr[String] +ServiceWorkerRegistrationOptions[JT] var `type`: js.UndefOr[WorkerType] +ServiceWorkerRegistrationOptions[JT] var updateViaCache: js.UndefOr[ServiceWorkerUpdateViaCache] ServiceWorkerState[JT] ServiceWorkerState[SO] val activated: ServiceWorkerState ServiceWorkerState[SO] val activating: ServiceWorkerState ServiceWorkerState[SO] val installed: ServiceWorkerState ServiceWorkerState[SO] val installing: ServiceWorkerState ServiceWorkerState[SO] val redundant: ServiceWorkerState +ServiceWorkerUpdateViaCache[JT] +ServiceWorkerUpdateViaCache[SO] val all: ServiceWorkerUpdateViaCache +ServiceWorkerUpdateViaCache[SO] val imports: ServiceWorkerUpdateViaCache +ServiceWorkerUpdateViaCache[SO] val none: ServiceWorkerUpdateViaCache ShadowRoot[JC] def activeElement: Element ShadowRoot[JC] def addEventListener[T <: Event](`type`: String, listener: js.Function1[T, _], options: EventListenerOptions): Unit ShadowRoot[JC] def addEventListener[T <: Event](`type`: String, listener: js.Function1[T, _], useCapture: Boolean?): Unit diff --git a/dom/src/main/scala-2/org/scalajs/dom/ServiceWorkerUpdateViaCache.scala b/dom/src/main/scala-2/org/scalajs/dom/ServiceWorkerUpdateViaCache.scala new file mode 100644 index 000000000..3b877003a --- /dev/null +++ b/dom/src/main/scala-2/org/scalajs/dom/ServiceWorkerUpdateViaCache.scala @@ -0,0 +1,17 @@ +package org.scalajs.dom + +import scala.scalajs.js + +@js.native +sealed trait ServiceWorkerUpdateViaCache extends js.Any + +object ServiceWorkerUpdateViaCache { + /** The service worker script and all of its imports will be updated. */ + val all: ServiceWorkerUpdateViaCache = "all".asInstanceOf[ServiceWorkerUpdateViaCache] + + /** Only imports referenced by the service worker script will be updated. This is the default. */ + val imports: ServiceWorkerUpdateViaCache = "imports".asInstanceOf[ServiceWorkerUpdateViaCache] + + /** Neither the service worker, nor its imports will be updated. */ + val none: ServiceWorkerUpdateViaCache = "none".asInstanceOf[ServiceWorkerUpdateViaCache] +} diff --git a/dom/src/main/scala-3/org/scalajs/dom/ServiceWorkerUpdateViaCache.scala b/dom/src/main/scala-3/org/scalajs/dom/ServiceWorkerUpdateViaCache.scala new file mode 100644 index 000000000..8003f2200 --- /dev/null +++ b/dom/src/main/scala-3/org/scalajs/dom/ServiceWorkerUpdateViaCache.scala @@ -0,0 +1,16 @@ +package org.scalajs.dom + +import scala.scalajs.js + +opaque type ServiceWorkerUpdateViaCache <: String = String + +object ServiceWorkerUpdateViaCache { + /** The service worker script and all of its imports will be updated. */ + val all: ServiceWorkerUpdateViaCache = "all" + + /** Only imports referenced by the service worker script will be updated. This is the default. */ + val imports: ServiceWorkerUpdateViaCache = "imports" + + /** Neither the service worker, nor its imports will be updated. */ + val none: ServiceWorkerUpdateViaCache = "none" +} diff --git a/dom/src/main/scala/org/scalajs/dom/ServiceWorkerContainer.scala b/dom/src/main/scala/org/scalajs/dom/ServiceWorkerContainer.scala index 68fac61b3..c62d084bd 100644 --- a/dom/src/main/scala/org/scalajs/dom/ServiceWorkerContainer.scala +++ b/dom/src/main/scala/org/scalajs/dom/ServiceWorkerContainer.scala @@ -14,7 +14,8 @@ trait ServiceWorkerContainer extends EventTarget { * method can't return a ServiceWorkerRegistration, it returns a Promise. You can call this method unconditionally * from the controlled page, i.e., you don't need to first check whether there's an active registration. */ - def register(scriptURL: String, options: js.Object = js.native): js.Promise[ServiceWorkerRegistration] = js.native + def register(scriptURL: String, + options: ServiceWorkerRegistrationOptions = js.native): js.Promise[ServiceWorkerRegistration] = js.native /** The ServiceWorkerContainer.controller read-only property of the ServiceWorkerContainer interface returns the * ServiceWorker whose state is activated (the same object returned by ServiceWorkerRegistration.active). This diff --git a/dom/src/main/scala/org/scalajs/dom/ServiceWorkerRegistrationOptions.scala b/dom/src/main/scala/org/scalajs/dom/ServiceWorkerRegistrationOptions.scala new file mode 100644 index 000000000..3afc0f7f5 --- /dev/null +++ b/dom/src/main/scala/org/scalajs/dom/ServiceWorkerRegistrationOptions.scala @@ -0,0 +1,28 @@ +/** All documentation for facades is thanks to Mozilla Contributors at https://developer.mozilla.org/en-US/docs/Web/API + * and available under the Creative Commons Attribution-ShareAlike v2.5 or later. + * http://creativecommons.org/licenses/by-sa/2.5/ + * + * Everything else is under the MIT License http://opensource.org/licenses/MIT + */ +package org.scalajs.dom + +import scala.scalajs.js + +/** An object containing registration options. */ +trait ServiceWorkerRegistrationOptions extends js.Object { + + /** A string representing a URL that defines a service worker's registration scope; that is, what range of URLs a + * service worker can control. This is usually a relative URL. It is relative to the base URL of the application. By + * default, the `scope` value for a service worker registration is set to the directory where the service worker + * script is located. + */ + var scope: js.UndefOr[String] = js.undefined + + /** A string specifying the type of worker to create. */ + var `type`: js.UndefOr[WorkerType] = js.undefined + + /** A string indicating how much of a service worker's resources will be updated when a call is made to + * `ServiceWorkerRegistration.updateViaCache`. + */ + var updateViaCache: js.UndefOr[ServiceWorkerUpdateViaCache] = js.undefined +}