js.web.serviceworker.ServiceWorker Maven / Gradle / Ivy
package js.web.serviceworker;
import js.lang.Any;
import js.util.buffers.Transferable;
import js.util.collections.Array;
import js.web.channelmessaging.MessageEventSource;
import js.web.channelmessaging.PostMessageOptions;
import js.web.dom.*;
import js.web.webworkers.AbstractWorker;
import org.teavm.jso.JSBody;
import org.teavm.jso.JSByRef;
import org.teavm.jso.JSProperty;
import javax.annotation.Nullable;
/**
* This ServiceWorker API interface provides a reference to a service worker. Multiple browsing contexts (e.g. pages, workers, etc.) can be associated with the same service worker, each through a unique ServiceWorker object.
*/
public interface ServiceWorker extends EventTarget, AbstractWorker, MessageEventSource {
@JSBody(script = "return ServiceWorker.prototype")
static ServiceWorker prototype() {
throw new UnsupportedOperationException("Available only in JavaScript");
}
@JSBody(script = "return new ServiceWorker()")
static ServiceWorker create() {
throw new UnsupportedOperationException("Available only in JavaScript");
}
@JSProperty
@Nullable
EventListener getOnstatechange();
@JSProperty
void setOnstatechange(EventListener onstatechange);
default void addStateChangeEventListener(EventListener listener, AddEventListenerOptions options) {
addEventListener("statechange", listener, options);
}
default void addStateChangeEventListener(EventListener listener, boolean options) {
addEventListener("statechange", listener, options);
}
default void addStateChangeEventListener(EventListener listener) {
addEventListener("statechange", listener);
}
default void removeStateChangeEventListener(EventListener listener, EventListenerOptions options) {
removeEventListener("statechange", listener, options);
}
default void removeStateChangeEventListener(EventListener listener, boolean options) {
removeEventListener("statechange", listener, options);
}
default void removeStateChangeEventListener(EventListener listener) {
removeEventListener("statechange", listener);
}
@JSProperty
String getScriptURL();
@JSProperty
ServiceWorkerState getState();
void postMessage(Any message, Array transfer);
void postMessage(Any message, Transferable... transfer);
void postMessage(Any message, PostMessageOptions options);
void postMessage(Any message);
}