forked from GoogleChromeLabs/sw-toolbox
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.d.ts
44 lines (38 loc) · 1.42 KB
/
index.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
declare module 'sw-toolbox' {
type URLPattern = string | RegExp
type PrecacheURL = Request | string
type PrecacheURLs = Promise<PrecacheURL[]> | PrecacheURL[]
export interface CacheOptions {
name: string
maxEntries?: number
maxAgeSeconds?: number
queryOptions?: CacheQueryOptions
}
export interface Options {
debug?: boolean
networkTimeoutSeconds?: number
cache?: CacheOptions
}
export interface Handler {
(request: Request): Promise<Response>
}
export interface Router {
any(urlPattern: URLPattern, handler: Handler, options?: Options): void
default(handler: Handler, options?: Options): void
delete(urlPattern: URLPattern, handler: Handler, options?: Options): void
get(urlPattern: URLPattern, handler: Handler, options?: Options): void
head(urlPattern: URLPattern, handler: Handler, options?: Options): void
post(urlPattern: URLPattern, handler: Handler, options?: Options): void
put(urlPattern: URLPattern, handler: Handler, options?: Options): void
}
export const cacheFirst: Handler
export const cacheOnly: Handler
export const fastest: Handler
export const networkFirst: Handler
export const networkOnly: Handler
export const options: Options
export const router: Router
export function cache(url: string, options: Options): void
export function precache(urls: PrecacheURLs): void
export function uncache(url: string): Promise<void>
}