Skip to content

Add ServiceWorkerRegistrationOptions #704

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 24, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion api-reports/2_12.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
9 changes: 8 additions & 1 deletion api-reports/2_13.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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]
}
Original file line number Diff line number Diff line change
@@ -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"
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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
}