-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Include waitUntil for activate/install
- Loading branch information
1 parent
3ad2fd5
commit 92f1080
Showing
16 changed files
with
103 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import {dispatcher} from "../../../events/schedule/schedule"; | ||
import {createWaitUntil, ExtendableEvent} from "../../../fetch"; | ||
|
||
export interface ActivateEvent extends ExtendableEvent { | ||
|
||
} | ||
|
||
export const removeActivateDispatcher = dispatcher("activate", async (event, dispatch) => { | ||
const { | ||
wait, | ||
waitUntil | ||
} = createWaitUntil(event); | ||
await dispatch({ | ||
...event, | ||
waitUntil | ||
}); | ||
await wait(); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export * from "./activate"; | ||
export * from "./install"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import {dispatcher} from "../../../events/schedule/schedule"; | ||
import {createWaitUntil, ExtendableEvent} from "../../../fetch"; | ||
|
||
export interface InstallEvent extends ExtendableEvent { | ||
skipWaiting(): void; | ||
} | ||
|
||
export const removeInstallDispatcher = dispatcher("install", async (event, dispatch) => { | ||
const { | ||
wait, | ||
waitUntil | ||
} = createWaitUntil(event); | ||
await dispatch({ | ||
...event, | ||
waitUntil, | ||
skipWaiting() { | ||
// TODO noop | ||
} | ||
}) | ||
await wait(); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,29 @@ | ||
import {DurableServiceWorkerRegistration} from "./container"; | ||
import {DurableCacheStorage, FetchEvent} from "../../fetch"; | ||
import {DurableCacheStorage, ExtendableEvent, FetchEvent} from "../../fetch"; | ||
import {DurableContentIndex} from "../../content-index"; | ||
import {DurableSyncManager} from "../../sync"; | ||
import {SyncEvent} from "../../sync"; | ||
import {DurableEventData} from "../../data"; | ||
import {PeriodicSyncEvent} from "../../periodic-sync"; | ||
import {ActivateEvent, InstallEvent} from "./dispatchers"; | ||
|
||
|
||
|
||
|
||
|
||
export interface DurableServiceWorkerScope { | ||
registration: DurableServiceWorkerRegistration, | ||
caches: DurableCacheStorage, | ||
index: DurableContentIndex, | ||
sync: DurableSyncManager, | ||
serviceWorker: ServiceWorkerContainer | ||
self: DurableServiceWorkerScope, | ||
isSecureContext: boolean | ||
origin: string | ||
addEventListener(type: "fetch", fn: (event: FetchEvent) => void): void; | ||
addEventListener(type: "install", fn: (event: InstallEvent) => void): void; | ||
addEventListener(type: "activate", fn: (event: ActivateEvent) => void): void; | ||
addEventListener(type: "message", fn: (message: MessageEvent) => void): void; | ||
addEventListener(type: "sync", fn: (message: SyncEvent) => void): void; | ||
addEventListener(type: "periodicsync", fn: (message: PeriodicSyncEvent) => void): void; | ||
addEventListener(type: string, fn: (event: DurableEventData) => void): void; | ||
removeEventListener: typeof removeEventListener | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters