Skip to content

Commit e86cd33

Browse files
authored
Merge pull request #439 from saschanaz/serviceworkers
Add Service Worker types
2 parents 9c824b7 + 24a4262 commit e86cd33

7 files changed

+457
-44
lines changed

baselines/dom.generated.d.ts

Lines changed: 41 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,6 @@ interface ClientData {
151151
}
152152

153153
interface ClientQueryOptions {
154-
includeReserved?: boolean;
155154
includeUncontrolled?: boolean;
156155
type?: ClientTypes;
157156
}
@@ -373,14 +372,15 @@ interface ExtendableMessageEventInit extends ExtendableEventInit {
373372
data?: any;
374373
lastEventId?: string;
375374
origin?: string;
376-
ports?: MessagePort[] | null;
377-
source?: object | ServiceWorker | MessagePort | null;
375+
ports?: MessagePort[];
376+
source?: object | ServiceWorker | MessagePort;
378377
}
379378

380379
interface FetchEventInit extends ExtendableEventInit {
381380
clientId?: string;
381+
preloadResponse: Promise<any>;
382382
request: Request;
383-
reservedClientId?: string;
383+
resultingClientId?: string;
384384
targetClientId?: string;
385385
}
386386

@@ -962,6 +962,11 @@ interface MutationObserverInit {
962962
subtree?: boolean;
963963
}
964964

965+
interface NavigationPreloadState {
966+
enabled?: boolean;
967+
headerValue?: string;
968+
}
969+
965970
interface NotificationAction {
966971
action: string;
967972
icon?: string;
@@ -1530,6 +1535,8 @@ interface RTCTransportStats extends RTCStats {
15301535

15311536
interface RegistrationOptions {
15321537
scope?: string;
1538+
type?: WorkerType;
1539+
updateViaCache?: ServiceWorkerUpdateViaCache;
15331540
}
15341541

15351542
interface RequestInit {
@@ -2902,13 +2909,13 @@ declare var CSSSupportsRule: {
29022909
};
29032910

29042911
interface Cache {
2905-
add(request: Request | string): Promise<void>;
2906-
addAll(requests: (Request | string)[]): Promise<void>;
2907-
delete(request: Request | string, options?: CacheQueryOptions): Promise<boolean>;
2908-
keys(request?: Request | string, options?: CacheQueryOptions): Promise<Request[]>;
2909-
match(request: Request | string, options?: CacheQueryOptions): Promise<Response>;
2910-
matchAll(request?: Request | string, options?: CacheQueryOptions): Promise<Response[]>;
2911-
put(request: Request | string, response: Response): Promise<void>;
2912+
add(request: RequestInfo): Promise<void>;
2913+
addAll(requests: RequestInfo[]): Promise<void>;
2914+
delete(request: RequestInfo, options?: CacheQueryOptions): Promise<boolean>;
2915+
keys(request?: RequestInfo, options?: CacheQueryOptions): Promise<ReadonlyArray<Request>>;
2916+
match(request: RequestInfo, options?: CacheQueryOptions): Promise<Response | undefined>;
2917+
matchAll(request?: RequestInfo, options?: CacheQueryOptions): Promise<ReadonlyArray<Response>>;
2918+
put(request: RequestInfo, response: Response): Promise<void>;
29122919
}
29132920

29142921
declare var Cache: {
@@ -2920,7 +2927,7 @@ interface CacheStorage {
29202927
delete(cacheName: string): Promise<boolean>;
29212928
has(cacheName: string): Promise<boolean>;
29222929
keys(): Promise<string[]>;
2923-
match(request: Request | string, options?: CacheQueryOptions): Promise<any>;
2930+
match(request: RequestInfo, options?: CacheQueryOptions): Promise<Response | undefined>;
29242931
open(cacheName: string): Promise<Cache>;
29252932
}
29262933

@@ -9458,7 +9465,7 @@ interface MessageEvent extends Event {
94589465
readonly data: any;
94599466
readonly origin: string;
94609467
readonly ports: ReadonlyArray<MessagePort>;
9461-
readonly source: Window | null;
9468+
readonly source: MessageEventSource;
94629469
initMessageEvent(type: string, bubbles: boolean, cancelable: boolean, data: any, origin: string, lastEventId: string, source: Window): void;
94639470
}
94649471

@@ -9613,6 +9620,18 @@ declare var NamedNodeMap: {
96139620
new(): NamedNodeMap;
96149621
};
96159622

9623+
interface NavigationPreloadManager {
9624+
disable(): Promise<void>;
9625+
enable(): Promise<void>;
9626+
getState(): Promise<NavigationPreloadState>;
9627+
setHeaderValue(value: string): Promise<void>;
9628+
}
9629+
9630+
declare var NavigationPreloadManager: {
9631+
prototype: NavigationPreloadManager;
9632+
new(): NavigationPreloadManager;
9633+
};
9634+
96169635
interface Navigator extends NavigatorID, NavigatorOnLine, NavigatorContentUtils, NavigatorStorageUtils, MSNavigatorDoNotTrack, MSFileSaver, NavigatorBeacon, NavigatorConcurrentHardware, NavigatorUserMedia, NavigatorLanguage {
96179636
readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
96189637
readonly authentication: WebAuthentication;
@@ -13333,18 +13352,18 @@ declare var ServiceWorker: {
1333313352

1333413353
interface ServiceWorkerContainerEventMap {
1333513354
"controllerchange": Event;
13336-
"message": ServiceWorkerMessageEvent;
13355+
"message": MessageEvent;
1333713356
"messageerror": MessageEvent;
1333813357
}
1333913358

1334013359
interface ServiceWorkerContainer extends EventTarget {
1334113360
readonly controller: ServiceWorker | null;
1334213361
oncontrollerchange: ((this: ServiceWorkerContainer, ev: Event) => any) | null;
13343-
onmessage: ((this: ServiceWorkerContainer, ev: ServiceWorkerMessageEvent) => any) | null;
13362+
onmessage: ((this: ServiceWorkerContainer, ev: MessageEvent) => any) | null;
1334413363
onmessageerror: ((this: ServiceWorkerContainer, ev: MessageEvent) => any) | null;
1334513364
readonly ready: Promise<ServiceWorkerRegistration>;
1334613365
getRegistration(clientURL?: string): Promise<ServiceWorkerRegistration | undefined>;
13347-
getRegistrations(): Promise<ServiceWorkerRegistration[]>;
13366+
getRegistrations(): Promise<ReadonlyArray<ServiceWorkerRegistration>>;
1334813367
register(scriptURL: string, options?: RegistrationOptions): Promise<ServiceWorkerRegistration>;
1334913368
startMessages(): void;
1335013369
addEventListener<K extends keyof ServiceWorkerContainerEventMap>(type: K, listener: (this: ServiceWorkerContainer, ev: ServiceWorkerContainerEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
@@ -13378,10 +13397,12 @@ interface ServiceWorkerRegistrationEventMap {
1337813397
interface ServiceWorkerRegistration extends EventTarget {
1337913398
readonly active: ServiceWorker | null;
1338013399
readonly installing: ServiceWorker | null;
13400+
readonly navigationPreload: NavigationPreloadManager;
1338113401
onupdatefound: ((this: ServiceWorkerRegistration, ev: Event) => any) | null;
1338213402
readonly pushManager: PushManager;
1338313403
readonly scope: string;
1338413404
readonly sync: SyncManager;
13405+
readonly updateViaCache: ServiceWorkerUpdateViaCache;
1338513406
readonly waiting: ServiceWorker | null;
1338613407
getNotifications(filter?: GetNotificationOptions): Promise<Notification[]>;
1338713408
showNotification(title: string, options?: NotificationOptions): Promise<void>;
@@ -16552,7 +16573,7 @@ type RTCIceGatherCandidate = RTCIceCandidateDictionary | RTCIceCandidateComplete
1655216573
type RTCTransport = RTCDtlsTransport | RTCSrtpSdesTransport;
1655316574
type USVString = string;
1655416575
type payloadtype = number;
16555-
type ClientTypes = "window" | "worker" | "sharedworker" | "all";
16576+
type MessageEventSource = Window | MessagePort | ServiceWorker;
1655616577
type AppendMode = "segments" | "sequence";
1655716578
type AudioContextLatencyCategory = "balanced" | "interactive" | "playback";
1655816579
type AudioContextState = "suspended" | "running" | "closed";
@@ -16562,6 +16583,7 @@ type CanPlayTypeResult = "" | "maybe" | "probably";
1656216583
type CanvasFillRule = "nonzero" | "evenodd";
1656316584
type ChannelCountMode = "max" | "clamped-max" | "explicit";
1656416585
type ChannelInterpretation = "speakers" | "discrete";
16586+
type ClientTypes = "window" | "worker" | "sharedworker" | "all";
1656516587
type DisplayCaptureSurfaceType = "monitor" | "window" | "application" | "browser";
1656616588
type DistanceModelType = "linear" | "inverse" | "exponential";
1656716589
type DocumentReadyState = "loading" | "interactive" | "complete";
@@ -16641,6 +16663,7 @@ type RequestRedirect = "follow" | "error" | "manual";
1664116663
type ResponseType = "basic" | "cors" | "default" | "error" | "opaque" | "opaqueredirect";
1664216664
type ScopedCredentialType = "ScopedCred";
1664316665
type ServiceWorkerState = "installing" | "installed" | "activating" | "activated" | "redundant";
16666+
type ServiceWorkerUpdateViaCache = "imports" | "all" | "none";
1664416667
type TextTrackKind = "subtitles" | "captions" | "descriptions" | "chapters" | "metadata";
1664516668
type TextTrackMode = "disabled" | "hidden" | "showing";
1664616669
type TouchType = "direct" | "stylus";
@@ -16649,4 +16672,5 @@ type VRDisplayEventReason = "mounted" | "navigation" | "requested" | "unmounted"
1664916672
type VREye = "left" | "right";
1665016673
type VideoFacingModeEnum = "user" | "environment" | "left" | "right";
1665116674
type VisibilityState = "hidden" | "visible" | "prerender" | "unloaded";
16675+
type WorkerType = "classic" | "module";
1665216676
type XMLHttpRequestResponseType = "" | "arraybuffer" | "blob" | "document" | "json" | "text";

0 commit comments

Comments
 (0)