mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-10-04 14:57:10 +00:00
[workbox] Added type definitions for all packages (#40277)
* [workbox-core] Added type definitions * [workbox-core] Updated ts-doc * [workbox-core] Added types.d.ts * [workbox-core] Removed TSDoc * [workbox-core] Moved some types * [workbox-core] Bug fixes * [workbox-expiration] Added type definitions * [workbox-strategies] Added type definitions * [workbox-strategies] Change "es6" to "es2015" * [workbox-precaching] Added type definitions * [workbox-precaching] Added missing method * [workbox-core] Moved some files to a sub-folder * [workbox-core] Moved some files to a sub-folder * [workbox-precaching] Moved some file to sub-folder * [workbox-core] Added generic type support * [workbox-routing] Added type definitions * [workbox-routing] Changed from "es6" to "es2015" * [workbox-background-sync] Added type definitions * [workbox-google-analytics] Added type definitions * [workbox-cacheable-response] Added type definition * [workbox-broadcast-update] Added type definitions * [workbox-range-requests] Added type definitions * [workbox-streams] Added type definitions * [workbox-streams] Added "use strict" to tests * [workbox-navigation-preload] Added type definition * [workbox-precaching] Added the missing type def... * Added the missing type definitions * [workbox-precaching] Commented the upcoming properties * [workbox-routing] Added the missing type definitions * [workbox-strategies] Changed package references * [workbox-expiration] Added the missing tests * [workbox-strategies] Updated tests * [workbox-background-sync] Fixed wrong file name * [workbox-google-analytics] Updated tests * [workbox-cacheable-response] Fixed the incorrectly named files * [workbox-broadcast-update] Fixed the incorrectly named files * [workbox-broadcast-update] Added the missing function * [workbox-broadcast-update] Fixed typo * [workbox-navigation-preload] Updated tests * [workbox-range-requests] Fixed the incorrectly named files * [workbox-streams] Updated tests * [workbox-core] Updated tests * [workbox-window] Updated tests and moved some files * [workbox-window] Updated "es6" to "es2015" * [workbox-sw] Updated definition to make use of the newly added definitions * [workbox] Updated "Definitions by" field * [workbox-sw] Updated rules * [workbox] Updated version numbers * [workbox-window] Fixed version number
This commit is contained in:
committed by
Pranav Senthilnathan
parent
c93e733426
commit
dbb7ff8e17
+11
@@ -0,0 +1,11 @@
|
||||
import {
|
||||
FetchDidFailCallback,
|
||||
WorkboxPlugin,
|
||||
} from "workbox-core/types/WorkboxPlugin";
|
||||
|
||||
import { QueueOptions } from "./Queue";
|
||||
|
||||
export class Plugin implements WorkboxPlugin {
|
||||
constructor(name: string, options?: QueueOptions);
|
||||
fetchDidFail: FetchDidFailCallback;
|
||||
}
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
export class Queue {
|
||||
constructor(name: string, options?: QueueOptions);
|
||||
readonly name: string;
|
||||
getAll(): Promise<QueueEntry[]>;
|
||||
popRequest(): Promise<QueueEntry>;
|
||||
pushRequest(entry: QueueEntry): Promise<void>;
|
||||
registerSync(): Promise<void>;
|
||||
shiftRequest(): Promise<QueueEntry>;
|
||||
unshiftRequest(entry: QueueEntry): Promise<void>;
|
||||
}
|
||||
|
||||
export interface QueueOptions {
|
||||
maxRetentionTime?: number;
|
||||
onSync?: () => void;
|
||||
}
|
||||
|
||||
export interface QueueEntry<Metadata = any> {
|
||||
request: Request;
|
||||
metadata?: Metadata;
|
||||
timestamp?: number;
|
||||
}
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
// Type definitions for workbox-background-sync 4.3
|
||||
// Project: https://github.com/GoogleChrome/workbox
|
||||
// Definitions by: Jason Kwok <https://github.com/JasonHK>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.3
|
||||
|
||||
export * from "./Plugin";
|
||||
export * from "./Queue";
|
||||
@@ -0,0 +1,26 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es2015",
|
||||
"webworker"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictFunctionTypes": true,
|
||||
"strictNullChecks": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"Plugin.d.ts",
|
||||
"Queue.d.ts",
|
||||
"workbox-background-sync-tests.ts"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"extends": "dtslint/dt.json",
|
||||
"rules": {
|
||||
"no-unnecessary-generics": false
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
/* tslint:disable:comment-format no-namespace */
|
||||
|
||||
"use strict";
|
||||
|
||||
import {
|
||||
Plugin,
|
||||
Queue,
|
||||
QueueEntry,
|
||||
QueueOptions,
|
||||
} from "workbox-background-sync";
|
||||
|
||||
//==============================================================================
|
||||
// WorkboxBackgroundSync.Queue
|
||||
//==============================================================================
|
||||
|
||||
export namespace QueueTest {
|
||||
declare const name: string;
|
||||
declare const options: QueueOptions;
|
||||
|
||||
// $ExpectType Queue
|
||||
new Queue(name);
|
||||
// $ExpectType Queue
|
||||
new Queue(name, options);
|
||||
|
||||
declare const queue: Queue;
|
||||
declare const queueEntry: QueueEntry;
|
||||
|
||||
// $ExpectType string
|
||||
queue.name;
|
||||
|
||||
// $ExpectType Promise<QueueEntry<any>[]>
|
||||
queue.getAll();
|
||||
|
||||
// $ExpectType Promise<QueueEntry<any>>
|
||||
queue.popRequest();
|
||||
|
||||
// $ExpectType Promise<void>
|
||||
queue.pushRequest(queueEntry);
|
||||
|
||||
// $ExpectType Promise<void>
|
||||
queue.registerSync();
|
||||
|
||||
// $ExpectType Promise<QueueEntry<any>>
|
||||
queue.shiftRequest();
|
||||
|
||||
// $ExpectType Promise<void>
|
||||
queue.unshiftRequest(queueEntry);
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
// WorkboxBackgroundSync.Plugin
|
||||
//==============================================================================
|
||||
|
||||
export namespace BackgroundSyncPluginTest {
|
||||
declare const name: string;
|
||||
declare const options: QueueOptions;
|
||||
|
||||
// $ExpectType Plugin
|
||||
new Plugin(name);
|
||||
// $ExpectType Plugin
|
||||
new Plugin(name, options);
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
export class BroadcastCacheUpdate {
|
||||
constructor(options?: BroadcastCacheUpdateOptions);
|
||||
notifyIfUpdated(options: BroadcastCacheUpdate.NotifyIfUpdatedOptions): Promise<void>;
|
||||
}
|
||||
|
||||
export namespace BroadcastCacheUpdate {
|
||||
interface NotifyIfUpdatedOptions {
|
||||
cacheName: string;
|
||||
newResponse: Response;
|
||||
oldResponse?: Response;
|
||||
url: string;
|
||||
event?: Event;
|
||||
}
|
||||
}
|
||||
|
||||
export interface BroadcastCacheUpdateOptions {
|
||||
channelName?: string;
|
||||
deferNoticationTimeout?: number;
|
||||
headersToCheck?: string[];
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
import {
|
||||
CacheDidUpdateCallback,
|
||||
WorkboxPlugin,
|
||||
} from "workbox-core/types/WorkboxPlugin";
|
||||
|
||||
import { BroadcastCacheUpdateOptions } from "./BroadcastCacheUpdate";
|
||||
|
||||
export class Plugin implements WorkboxPlugin {
|
||||
constructor(options?: BroadcastCacheUpdateOptions);
|
||||
cacheDidUpdate: CacheDidUpdateCallback;
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
export function broadcastUpdate(options: BroadcastUpdateOptions): Promise<void>;
|
||||
|
||||
export interface BroadcastUpdateOptions {
|
||||
cacheName: string;
|
||||
url: string;
|
||||
channel?: string;
|
||||
}
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
// Type definitions for workbox-broadcast-update 4.3
|
||||
// Project: https://github.com/GoogleChrome/workbox
|
||||
// Definitions by: Jason Kwok <https://github.com/JasonHK>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.3
|
||||
|
||||
export * from "./BroadcastCacheUpdate";
|
||||
export * from "./Plugin";
|
||||
export * from "./broadcastUpdate";
|
||||
@@ -0,0 +1,27 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es2015",
|
||||
"webworker"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictFunctionTypes": true,
|
||||
"strictNullChecks": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"BroadcastCacheUpdate.d.ts",
|
||||
"Plugin.d.ts",
|
||||
"broadcastUpdate.d.ts",
|
||||
"workbox-broadcast-update-tests.ts"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
@@ -0,0 +1,54 @@
|
||||
/* tslint:disable:comment-format no-namespace */
|
||||
|
||||
"use strict";
|
||||
|
||||
import {
|
||||
BroadcastCacheUpdate,
|
||||
BroadcastCacheUpdateOptions,
|
||||
BroadcastUpdateOptions,
|
||||
Plugin,
|
||||
broadcastUpdate,
|
||||
} from "workbox-broadcast-update";
|
||||
|
||||
//==============================================================================
|
||||
// WorkboxBroadcastUpdate.BroadcastCacheUpdate
|
||||
//==============================================================================
|
||||
|
||||
export namespace BroadcastCacheUpdateTest {
|
||||
declare const options: BroadcastCacheUpdateOptions;
|
||||
|
||||
// $ExpectType BroadcastCacheUpdate
|
||||
new BroadcastCacheUpdate();
|
||||
// $ExpectType BroadcastCacheUpdate
|
||||
new BroadcastCacheUpdate(options);
|
||||
|
||||
declare const broadcast: BroadcastCacheUpdate;
|
||||
declare const notifyOptions: BroadcastCacheUpdate.NotifyIfUpdatedOptions;
|
||||
|
||||
// $ExpectType Promise<void>
|
||||
broadcast.notifyIfUpdated(notifyOptions);
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
// WorkboxBroadcastUpdate.Plugin
|
||||
//==============================================================================
|
||||
|
||||
export namespace BroadcastUpdatePluginTest {
|
||||
declare const options: BroadcastCacheUpdateOptions;
|
||||
|
||||
// $ExpectType Plugin
|
||||
new Plugin();
|
||||
// $ExpectType Plugin
|
||||
new Plugin(options);
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
// WorkboxBroadcastUpdate.broadcastUpdate
|
||||
//==============================================================================
|
||||
|
||||
export namespace BroadcastUpdateTest {
|
||||
declare const options: BroadcastUpdateOptions;
|
||||
|
||||
// $ExpectType Promise<void>
|
||||
broadcastUpdate(options);
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
export class CacheableResponse {
|
||||
constructor(config?: CacheableResponseConfig);
|
||||
isResponseCacheable(response: Response): boolean;
|
||||
}
|
||||
|
||||
export interface CacheableResponseConfig {
|
||||
headers?: Record<string, string>;
|
||||
statuses?: number[];
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
import {
|
||||
CacheWillUpdateCallback,
|
||||
WorkboxPlugin,
|
||||
} from "workbox-core/types/WorkboxPlugin";
|
||||
|
||||
import { CacheableResponseConfig } from "./CacheableResponse";
|
||||
|
||||
export class Plugin implements WorkboxPlugin {
|
||||
constructor(config?: CacheableResponseConfig);
|
||||
cacheWillUpdate: CacheWillUpdateCallback;
|
||||
}
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
// Type definitions for workbox-cacheable-response 4.3
|
||||
// Project: https://github.com/GoogleChrome/workbox
|
||||
// Definitions by: Jason Kwok <https://github.com/JasonHK>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.3
|
||||
|
||||
export * from "./CacheableResponse";
|
||||
export * from "./Plugin";
|
||||
@@ -0,0 +1,26 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es2015",
|
||||
"webworker"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictFunctionTypes": true,
|
||||
"strictNullChecks": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"CacheableResponse.d.ts",
|
||||
"Plugin.d.ts",
|
||||
"workbox-cacheable-response-tests.ts"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
@@ -0,0 +1,41 @@
|
||||
/* tslint:disable:comment-format no-namespace */
|
||||
|
||||
"use strict";
|
||||
|
||||
import {
|
||||
CacheableResponse,
|
||||
CacheableResponseConfig,
|
||||
Plugin,
|
||||
} from "workbox-cacheable-response";
|
||||
|
||||
//==============================================================================
|
||||
// WorkboxCacheableResponse.CacheableResponse
|
||||
//==============================================================================
|
||||
|
||||
export namespace CacheableResponseTest {
|
||||
declare const config: CacheableResponseConfig;
|
||||
|
||||
// $ExpectType CacheableResponse
|
||||
new CacheableResponse();
|
||||
// $ExpectType CacheableResponse
|
||||
new CacheableResponse(config);
|
||||
|
||||
declare const cacheable: CacheableResponse;
|
||||
declare const response: Response;
|
||||
|
||||
// $ExpectType boolean
|
||||
cacheable.isResponseCacheable(response);
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
// WorkboxCacheableResponse.Plugin
|
||||
//==============================================================================
|
||||
|
||||
export namespace CacheableResponsePluginTest {
|
||||
declare const config: CacheableResponseConfig;
|
||||
|
||||
// $ExpectType Plugin
|
||||
new Plugin();
|
||||
// $ExpectType Plugin
|
||||
new Plugin(config);
|
||||
}
|
||||
Vendored
+9
@@ -0,0 +1,9 @@
|
||||
export const cacheNames: CacheNames;
|
||||
|
||||
export interface CacheNames {
|
||||
readonly googleAnalytics: string;
|
||||
readonly precache: string;
|
||||
readonly prefix: string;
|
||||
readonly runtime: string;
|
||||
readonly suffix: string;
|
||||
}
|
||||
Vendored
+1
@@ -0,0 +1 @@
|
||||
export function clientsClaim(): void;
|
||||
Vendored
+13
@@ -0,0 +1,13 @@
|
||||
// Type definitions for workbox-core 4.3
|
||||
// Project: https://github.com/GoogleChrome/workbox
|
||||
// Definitions by: Jason Kwok <https://github.com/JasonHK>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.3
|
||||
|
||||
export * from "./cacheNames";
|
||||
export * from "./clientsClaim";
|
||||
export * from "./registerQuotaErrorCallback";
|
||||
export * from "./setCacheNameDetails";
|
||||
export * from "./skipWaiting";
|
||||
|
||||
export { WorkboxPlugin } from "./types/WorkboxPlugin";
|
||||
@@ -0,0 +1 @@
|
||||
export function registerQuotaErrorCallback(callback: () => void): void;
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
export interface CacheNameDetails {
|
||||
googleAnalytics: string;
|
||||
precache: string;
|
||||
prefix: string;
|
||||
runtime: string;
|
||||
suffix: string;
|
||||
}
|
||||
|
||||
export function setCacheNameDetails(details: Partial<CacheNameDetails>): void;
|
||||
Vendored
+1
@@ -0,0 +1 @@
|
||||
export function skipWaiting(): void;
|
||||
@@ -0,0 +1,30 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es2015",
|
||||
"webworker"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictFunctionTypes": true,
|
||||
"strictNullChecks": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"cacheNames.d.ts",
|
||||
"clientsClaim.d.ts",
|
||||
"registerQuotaErrorCallback.d.ts",
|
||||
"setCacheNameDetails.d.ts",
|
||||
"skipWaiting.d.ts",
|
||||
"types/WorkboxPlugin.d.ts",
|
||||
"workbox-core-tests.ts"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
+80
@@ -0,0 +1,80 @@
|
||||
export interface WorkboxPlugin {
|
||||
cacheDidUpdate?: CacheDidUpdateCallback;
|
||||
cacheKeyWillBeUsed?: CacheKeyWillBeUsedCallback;
|
||||
cacheWillUpdate?: CacheWillUpdateCallback;
|
||||
cachedResponseWillBeUsed?: CachedResponseWillBeUsedCallback;
|
||||
fetchDidFail?: FetchDidFailCallback;
|
||||
fetchDidSucceed?: FetchDidSucceedCallback;
|
||||
requestWillFetch?: RequestWillFetchCallback;
|
||||
}
|
||||
|
||||
export interface CacheDidUpdateCallback {
|
||||
(param: CacheDidUpdateCallbackParam): Promise<void>;
|
||||
}
|
||||
|
||||
export interface CacheDidUpdateCallbackParam {
|
||||
cacheName: string;
|
||||
newResponse: Response;
|
||||
oldResponse?: Response | null;
|
||||
request: Request;
|
||||
event?: Event;
|
||||
}
|
||||
|
||||
export interface CacheKeyWillBeUsedCallback {
|
||||
(param: CacheKeyWillBeUsedCallbackParam): Promise<Request | string>;
|
||||
}
|
||||
|
||||
export interface CacheKeyWillBeUsedCallbackParam {
|
||||
request: Request;
|
||||
mode: string;
|
||||
}
|
||||
|
||||
export interface CacheWillUpdateCallback {
|
||||
(param: CacheWillUpdateCallbackParamParam): Promise<Response | undefined>;
|
||||
}
|
||||
|
||||
export interface CacheWillUpdateCallbackParamParam {
|
||||
request: Request;
|
||||
response: Response;
|
||||
event?: ExtendableEvent;
|
||||
}
|
||||
|
||||
export interface CachedResponseWillBeUsedCallback {
|
||||
(param: CachedResponseWillBeUsedCallbackParam): Promise<Response | undefined>;
|
||||
}
|
||||
|
||||
export interface CachedResponseWillBeUsedCallbackParam {
|
||||
cacheName: string;
|
||||
cachedResponse?: Response;
|
||||
matchOptions?: CacheQueryOptions;
|
||||
request: Request;
|
||||
event?: ExtendableEvent;
|
||||
}
|
||||
|
||||
export interface FetchDidFailCallback {
|
||||
(param: FetchDidFailCallbackParam): Promise<void>;
|
||||
}
|
||||
|
||||
export interface FetchDidFailCallbackParam {
|
||||
error: Error;
|
||||
originalRequest: Request;
|
||||
request: Request;
|
||||
event?: ExtendableEvent;
|
||||
}
|
||||
|
||||
export interface FetchDidSucceedCallback {
|
||||
(param: FetchDidSucceedCallbackParam): Promise<Response>;
|
||||
}
|
||||
|
||||
export interface FetchDidSucceedCallbackParam {
|
||||
request: Request;
|
||||
response: Response;
|
||||
}
|
||||
|
||||
export interface RequestWillFetchCallback {
|
||||
(param: RequestWillFetchCallbackParam): Promise<Request | undefined>;
|
||||
}
|
||||
|
||||
export interface RequestWillFetchCallbackParam {
|
||||
request: Request;
|
||||
}
|
||||
@@ -0,0 +1,76 @@
|
||||
/* tslint:disable:comment-format no-namespace */
|
||||
|
||||
"use strict";
|
||||
|
||||
import {
|
||||
CacheNameDetails,
|
||||
cacheNames,
|
||||
clientsClaim,
|
||||
registerQuotaErrorCallback,
|
||||
setCacheNameDetails,
|
||||
skipWaiting,
|
||||
} from "workbox-core";
|
||||
|
||||
//==============================================================================
|
||||
// WorkboxCore.cacheNames
|
||||
//==============================================================================
|
||||
|
||||
export namespace CacheNamesTest {
|
||||
// $ExpectType CacheNames
|
||||
cacheNames;
|
||||
|
||||
// $ExpectType string
|
||||
cacheNames.googleAnalytics;
|
||||
|
||||
// $ExpectType string
|
||||
cacheNames.precache;
|
||||
|
||||
// $ExpectType string
|
||||
cacheNames.prefix;
|
||||
|
||||
// $ExpectType string
|
||||
cacheNames.runtime;
|
||||
|
||||
// $ExpectType string
|
||||
cacheNames.suffix;
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
// WorkboxCore.clientsClaim
|
||||
//==============================================================================
|
||||
|
||||
export namespace ClientsClaimTest {
|
||||
// $ExpectType void
|
||||
clientsClaim();
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
// WorkboxCore.registerQuotaErrorCallback
|
||||
//==============================================================================
|
||||
|
||||
export namespace RegisterQuotaErrorCallbackTest {
|
||||
declare const callback: () => void;
|
||||
|
||||
// $ExpectType void
|
||||
registerQuotaErrorCallback(callback);
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
// WorkboxCore.setCacheNameDetails
|
||||
//==============================================================================
|
||||
|
||||
export namespace SetCacheNameDetailsTest {
|
||||
declare const details: CacheNameDetails;
|
||||
|
||||
// $ExpectType void
|
||||
setCacheNameDetails(details);
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
// WorkboxCore.skipWaiting
|
||||
//==============================================================================
|
||||
|
||||
export namespace SkipWaitingTest {
|
||||
// $ExpectType void
|
||||
skipWaiting();
|
||||
}
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
export class CacheExpiration {
|
||||
constructor(cacheName: string, config?: CacheExpirationConfig);
|
||||
delete(): Promise<void>;
|
||||
expireEntries(): Promise<void>;
|
||||
isURLExpired(url: string): Promise<boolean>;
|
||||
updateTimestamp(url: string): Promise<void>;
|
||||
}
|
||||
|
||||
export interface CacheExpirationConfig {
|
||||
maxAgeSeconds?: number;
|
||||
maxEntries?: number;
|
||||
}
|
||||
Vendored
+18
@@ -0,0 +1,18 @@
|
||||
import {
|
||||
CacheDidUpdateCallback,
|
||||
CachedResponseWillBeUsedCallback,
|
||||
WorkboxPlugin,
|
||||
} from "workbox-core/types/WorkboxPlugin";
|
||||
|
||||
export class Plugin implements WorkboxPlugin {
|
||||
constructor(config?: ExpirationPluginConfig);
|
||||
cacheDidUpdate: CacheDidUpdateCallback;
|
||||
cachedResponseWillBeUsed: CachedResponseWillBeUsedCallback;
|
||||
deleteCacheAndMetadata(): Promise<void>;
|
||||
}
|
||||
|
||||
export interface ExpirationPluginConfig {
|
||||
maxAgeSeconds?: number;
|
||||
maxEntries?: number;
|
||||
purgeOnQuotaError?: boolean;
|
||||
}
|
||||
Vendored
+8
@@ -0,0 +1,8 @@
|
||||
// Type definitions for workbox-expiration 4.3
|
||||
// Project: https://github.com/GoogleChrome/workbox
|
||||
// Definitions by: Jason Kwok <https://github.com/JasonHK>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.3
|
||||
|
||||
export * from "./CacheExpiration";
|
||||
export * from "./Plugin";
|
||||
@@ -0,0 +1,26 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es2015",
|
||||
"webworker"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictFunctionTypes": true,
|
||||
"strictNullChecks": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"CacheExpiration.d.ts",
|
||||
"Plugin.d.ts",
|
||||
"workbox-expiration-tests.ts"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
@@ -0,0 +1,57 @@
|
||||
/* tslint:disable:comment-format no-namespace */
|
||||
|
||||
"use strict";
|
||||
|
||||
import {
|
||||
CacheExpiration,
|
||||
CacheExpirationConfig,
|
||||
ExpirationPluginConfig,
|
||||
Plugin,
|
||||
} from "workbox-expiration";
|
||||
|
||||
//==============================================================================
|
||||
// WorkboxExpiration.CacheExpiration
|
||||
//==============================================================================
|
||||
|
||||
export namespace CacheExpirationTest {
|
||||
declare const cacheName: string;
|
||||
declare const config: CacheExpirationConfig;
|
||||
|
||||
// $ExpectType CacheExpiration
|
||||
new CacheExpiration(cacheName);
|
||||
// $ExpectType CacheExpiration
|
||||
new CacheExpiration(cacheName, config);
|
||||
|
||||
declare const expiration: CacheExpiration;
|
||||
declare const cachedURL: string;
|
||||
|
||||
// $ExpectType Promise<void>
|
||||
expiration.delete();
|
||||
|
||||
// $ExpectType Promise<void>
|
||||
expiration.expireEntries();
|
||||
|
||||
// $ExpectType Promise<boolean>
|
||||
expiration.isURLExpired(cachedURL);
|
||||
|
||||
// $ExpectType Promise<void>
|
||||
expiration.updateTimestamp(cachedURL);
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
// WorkboxExpiration.Plugin
|
||||
//==============================================================================
|
||||
|
||||
export namespace ExpirationPluginTest {
|
||||
declare const config: ExpirationPluginConfig;
|
||||
|
||||
// $ExpectType Plugin
|
||||
new Plugin();
|
||||
// $ExpectType Plugin
|
||||
new Plugin(config);
|
||||
|
||||
declare const plugin: Plugin;
|
||||
|
||||
// $ExpectType Promise<void>
|
||||
plugin.deleteCacheAndMetadata();
|
||||
}
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
// Type definitions for workbox-google-analytics 4.3
|
||||
// Project: https://github.com/GoogleChrome/workbox
|
||||
// Definitions by: Jason Kwok <https://github.com/JasonHK>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.3
|
||||
|
||||
export * from "./initialize";
|
||||
@@ -0,0 +1,7 @@
|
||||
export function initialize(options?: InitializeOptions): void;
|
||||
|
||||
export interface InitializeOptions {
|
||||
cacheName?: string;
|
||||
parameterOverrides?: Record<string, string>;
|
||||
hitFilter?: (params: URLSearchParams) => void;
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es2015",
|
||||
"webworker"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictFunctionTypes": true,
|
||||
"strictNullChecks": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"initialize.d.ts",
|
||||
"workbox-google-analytics-tests.ts"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
@@ -0,0 +1,21 @@
|
||||
/* tslint:disable:comment-format no-namespace */
|
||||
|
||||
"use strict";
|
||||
|
||||
import {
|
||||
InitializeOptions,
|
||||
initialize,
|
||||
} from "workbox-google-analytics";
|
||||
|
||||
//==============================================================================
|
||||
// WorkboxGoogleAnalytics.initialize
|
||||
//==============================================================================
|
||||
|
||||
export namespace InitializeTest {
|
||||
declare const options: InitializeOptions;
|
||||
|
||||
// $ExpectType void
|
||||
initialize();
|
||||
// $ExpectType void
|
||||
initialize(options);
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
export function disable(): void;
|
||||
@@ -0,0 +1 @@
|
||||
export function enable(headerValue?: string): void;
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
// Type definitions for workbox-navigation-preload 4.3
|
||||
// Project: https://github.com/GoogleChrome/workbox
|
||||
// Definitions by: Jason Kwok <https://github.com/JasonHK>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.3
|
||||
|
||||
export * from "./disable";
|
||||
export * from "./enable";
|
||||
export * from "./isSupported";
|
||||
@@ -0,0 +1 @@
|
||||
export function isSupported(): boolean;
|
||||
@@ -0,0 +1,27 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es2015",
|
||||
"webworker"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictFunctionTypes": true,
|
||||
"strictNullChecks": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"disable.d.ts",
|
||||
"enable.d.ts",
|
||||
"isSupported.d.ts",
|
||||
"workbox-navigation-preload-tests.ts"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
@@ -0,0 +1,42 @@
|
||||
/* tslint:disable:comment-format no-namespace */
|
||||
|
||||
"use strict";
|
||||
|
||||
import {
|
||||
disable,
|
||||
enable,
|
||||
isSupported,
|
||||
} from "workbox-navigation-preload";
|
||||
|
||||
declare const headerValue: string;
|
||||
|
||||
//==============================================================================
|
||||
// WorkboxNavigationPreload.disable
|
||||
//==============================================================================
|
||||
|
||||
export namespace DisableTest {
|
||||
// $ExpectType void
|
||||
disable();
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
// WorkboxNavigationPreload.enable
|
||||
//==============================================================================
|
||||
|
||||
export namespace EnableTest {
|
||||
declare const header: string;
|
||||
|
||||
// $ExpectType void
|
||||
enable();
|
||||
// $ExpectType void
|
||||
enable(header);
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
// WorkboxNavigationPreload.isSupported
|
||||
//==============================================================================
|
||||
|
||||
export namespace IsSupportedTest {
|
||||
// $ExpectType boolean
|
||||
isSupported();
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
import { WorkboxPlugin } from "workbox-core/types/WorkboxPlugin";
|
||||
|
||||
import { CleanupResult } from "./types/CleanupResult";
|
||||
import { InstallResult } from "./types/InstallResult";
|
||||
import { PrecacheEntry } from "./types/PrecacheEntry";
|
||||
|
||||
export class PrecacheController {
|
||||
constructor(cacheName?: string);
|
||||
activate(): Promise<CleanupResult>;
|
||||
addToCacheList(entries: Array<string | PrecacheEntry>): void;
|
||||
getCacheKeyForURL(url: string): string;
|
||||
getCachedURLs(): string[];
|
||||
getURLsToCacheKeys(): Record<string, string>;
|
||||
install(options?: PrecacheController.InstallOptions): Promise<InstallResult>;
|
||||
}
|
||||
|
||||
export namespace PrecacheController {
|
||||
interface InstallOptions {
|
||||
event?: FetchEvent;
|
||||
plugins?: WorkboxPlugin[];
|
||||
}
|
||||
}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
import { WorkboxPlugin } from "workbox-core/types/WorkboxPlugin";
|
||||
|
||||
export function addPlugins(newPlugins: WorkboxPlugin[]): void;
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
import { FetchListenerOptions } from "./types/FetchListenerOptions";
|
||||
|
||||
export function addRoute(options?: FetchListenerOptions): void;
|
||||
|
||||
export * from "./types/FetchListenerOptions";
|
||||
@@ -0,0 +1 @@
|
||||
export function cleanupOutdatedCaches(): void;
|
||||
@@ -0,0 +1 @@
|
||||
export function getCacheKeyForURL(url: string): string;
|
||||
Vendored
+18
@@ -0,0 +1,18 @@
|
||||
// Type definitions for workbox-precaching 4.3
|
||||
// Project: https://github.com/GoogleChrome/workbox
|
||||
// Definitions by: Jason Kwok <https://github.com/JasonHK>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.3
|
||||
|
||||
export * from "./PrecacheController";
|
||||
export * from "./addPlugins";
|
||||
export { addRoute } from "./addRoute";
|
||||
export * from "./cleanupOutdatedCaches";
|
||||
export * from "./getCacheKeyForURL";
|
||||
export { precache } from "./precache";
|
||||
export { precacheAndRoute } from "./precacheAndRoute";
|
||||
|
||||
export * from "./types/CleanupResult";
|
||||
export * from "./types/FetchListenerOptions";
|
||||
export * from "./types/PrecacheEntry";
|
||||
export * from "./types/URLManipulation";
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
import { PrecacheEntry } from "./types/PrecacheEntry";
|
||||
|
||||
export function precache(entries: Array<string | PrecacheEntry>): void;
|
||||
|
||||
export * from "./types/PrecacheEntry";
|
||||
@@ -0,0 +1,6 @@
|
||||
import { FetchListenerOptions } from "./types/FetchListenerOptions";
|
||||
import { PrecacheEntry } from "./types/PrecacheEntry";
|
||||
|
||||
export function precacheAndRoute(entries: Array<string | PrecacheEntry>, options?: FetchListenerOptions): void;
|
||||
|
||||
export * from "./types/PrecacheEntry";
|
||||
@@ -0,0 +1,36 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es2015",
|
||||
"webworker"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictFunctionTypes": true,
|
||||
"strictNullChecks": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"PrecacheController.d.ts",
|
||||
"addPlugins.d.ts",
|
||||
"addRoute.d.ts",
|
||||
"cleanupOutdatedCaches.d.ts",
|
||||
"getCacheKeyForURL.d.ts",
|
||||
"precache.d.ts",
|
||||
"precacheAndRoute.d.ts",
|
||||
"types/CleanupResult.d.ts",
|
||||
"types/FetchListenerOptions.d.ts",
|
||||
"types/InstallResult.d.ts",
|
||||
"types/PrecacheEntry.d.ts",
|
||||
"types/URLManipulation.d.ts",
|
||||
"workbox-precaching-tests.ts"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
@@ -0,0 +1,3 @@
|
||||
export interface CleanupResult {
|
||||
deletedCacheRequests: string[];
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
import { URLManipulation } from "./URLManipulation";
|
||||
|
||||
export interface FetchListenerOptions {
|
||||
cleanURLs?: boolean;
|
||||
directoryIndex?: string;
|
||||
ignoreURLParametersMatching?: RegExp[];
|
||||
urlManipulation?: URLManipulation;
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
export interface InstallResult {
|
||||
notUpdatedURLs: string[];
|
||||
updatedURLs: string[];
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
export interface PrecacheEntry {
|
||||
url: string;
|
||||
// integrity?: string;
|
||||
revision?: string;
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
export type URLManipulation = (url: { url: URL }) => URL[];
|
||||
@@ -0,0 +1,123 @@
|
||||
/* tslint:disable:comment-format no-namespace */
|
||||
|
||||
"use strict";
|
||||
|
||||
import { WorkboxPlugin } from "workbox-core/types/WorkboxPlugin";
|
||||
import {
|
||||
FetchListenerOptions,
|
||||
PrecacheController,
|
||||
PrecacheEntry,
|
||||
addPlugins,
|
||||
addRoute,
|
||||
cleanupOutdatedCaches,
|
||||
getCacheKeyForURL,
|
||||
precache,
|
||||
precacheAndRoute
|
||||
} from "workbox-precaching";
|
||||
|
||||
//==============================================================================
|
||||
// WorkboxPrecaching.PrecacheController
|
||||
//==============================================================================
|
||||
|
||||
export namespace PrecacheControllerTest {
|
||||
declare const cacheName: string;
|
||||
|
||||
// $ExpectType PrecacheController
|
||||
new PrecacheController();
|
||||
// $ExpectType PrecacheController
|
||||
new PrecacheController(cacheName);
|
||||
|
||||
declare const controller: PrecacheController;
|
||||
declare const cacheEntries: Array<string | PrecacheEntry>;
|
||||
declare const cachedURL: string;
|
||||
declare const installOptions: PrecacheController.InstallOptions;
|
||||
|
||||
// $ExpectType Promise<CleanupResult>
|
||||
controller.activate();
|
||||
|
||||
// $ExpectType void
|
||||
controller.addToCacheList(cacheEntries);
|
||||
|
||||
// $ExpectType string
|
||||
controller.getCacheKeyForURL(cachedURL);
|
||||
|
||||
// $ExpectType string[]
|
||||
controller.getCachedURLs();
|
||||
|
||||
// $ExpectType Record<string, string>
|
||||
controller.getURLsToCacheKeys();
|
||||
|
||||
// $ExpectType Promise<InstallResult>
|
||||
controller.install();
|
||||
// $ExpectType Promise<InstallResult>
|
||||
controller.install(installOptions);
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
// WorkboxPrecaching.addPlugins
|
||||
//==============================================================================
|
||||
|
||||
export namespace AddPluginsTest {
|
||||
declare const plugins: WorkboxPlugin[];
|
||||
|
||||
// $ExpectType void
|
||||
addPlugins(plugins);
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
// WorkboxPrecaching.addRoute
|
||||
//==============================================================================
|
||||
|
||||
export namespace AddRouteTest {
|
||||
declare const options: FetchListenerOptions;
|
||||
|
||||
// $ExpectType void
|
||||
addRoute();
|
||||
// $ExpectType void
|
||||
addRoute(options);
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
// WorkboxPrecaching.cleanupOutdatedCaches
|
||||
//==============================================================================
|
||||
|
||||
export namespace CleanupOutdatedCachesTest {
|
||||
// $ExpectType void
|
||||
cleanupOutdatedCaches();
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
// WorkboxPrecaching.getCacheKeyForURL
|
||||
//==============================================================================
|
||||
|
||||
export namespace GetCacheKeyForURLTest {
|
||||
declare const url: string;
|
||||
|
||||
// $ExpectType string
|
||||
getCacheKeyForURL(url);
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
// WorkboxPrecaching.precache
|
||||
//==============================================================================
|
||||
|
||||
export namespace PrecacheTest {
|
||||
declare const entries: Array<string | PrecacheEntry>;
|
||||
|
||||
// $ExpectType void
|
||||
precache(entries);
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
// WorkboxPrecaching.precacheAndRoute
|
||||
//==============================================================================
|
||||
|
||||
export namespace PrecacheAndRoute {
|
||||
declare const entries: Array<string | PrecacheEntry>;
|
||||
declare const options: FetchListenerOptions;
|
||||
|
||||
// $ExpectType void
|
||||
precacheAndRoute(entries);
|
||||
// $ExpectType void
|
||||
precacheAndRoute(entries, options);
|
||||
}
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
import { CachedResponseWillBeUsedCallback, WorkboxPlugin } from "workbox-core/types/WorkboxPlugin";
|
||||
|
||||
export class Plugin implements WorkboxPlugin {
|
||||
constructor();
|
||||
cachedResponseWillBeUsed: CachedResponseWillBeUsedCallback;
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
export function createPartialResponse(request: Request, originalResponse: Response): Promise<Response>;
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
// Type definitions for workbox-range-requests 4.3
|
||||
// Project: https://github.com/GoogleChrome/workbox
|
||||
// Definitions by: Jason Kwok <https://github.com/JasonHK>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.3
|
||||
|
||||
export * from "./Plugin";
|
||||
export * from "./createPartialResponse";
|
||||
@@ -0,0 +1,26 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es2015",
|
||||
"webworker"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictFunctionTypes": true,
|
||||
"strictNullChecks": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"Plugin.d.ts",
|
||||
"createPartialResponse.d.ts",
|
||||
"workbox-range-requests-tests.ts"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
@@ -0,0 +1,29 @@
|
||||
/* tslint:disable:comment-format no-namespace */
|
||||
|
||||
"use strict";
|
||||
|
||||
import {
|
||||
Plugin,
|
||||
createPartialResponse,
|
||||
} from "workbox-range-requests";
|
||||
|
||||
//==============================================================================
|
||||
// WorkboxRangeRequests.Plugin
|
||||
//==============================================================================
|
||||
|
||||
export namespace RangeRequestsPluginTest {
|
||||
// $ExpectType Plugin
|
||||
new Plugin();
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
// WorkboxRangeRequests.createPartialResponse
|
||||
//==============================================================================
|
||||
|
||||
export namespace CreatePartialResponseTest {
|
||||
declare const request: Request;
|
||||
declare const response: Response;
|
||||
|
||||
// $ExpectType Promise<Response>
|
||||
createPartialResponse(request, response);
|
||||
}
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
import { Route } from "./Route";
|
||||
|
||||
import { HTTPMethod } from "./types/HTTPMethod";
|
||||
import { RouteHandler } from "./types/RouteHandler";
|
||||
|
||||
export class NavigationRoute extends Route<boolean> {
|
||||
constructor(handler: RouteHandler, options?: NavigationRouteOptions);
|
||||
}
|
||||
|
||||
export interface NavigationRouteOptions {
|
||||
whitelist?: RegExp[];
|
||||
blacklist?: RegExp[];
|
||||
}
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
import { Route } from "./Route";
|
||||
|
||||
import { HTTPMethod } from "./types/HTTPMethod";
|
||||
import { RouteHandler } from "./types/RouteHandler";
|
||||
|
||||
export class RegExpRoute extends Route<string[]> {
|
||||
constructor(regExp: RegExp, handler: RouteHandler, method?: HTTPMethod);
|
||||
}
|
||||
Vendored
+10
@@ -0,0 +1,10 @@
|
||||
import { HTTPMethod } from "./types/HTTPMethod";
|
||||
import { RouteHandler } from "./types/RouteHandler";
|
||||
import { RouteMatchCallback } from "./types/RouteMatchCallback";
|
||||
|
||||
export class Route<MatchReturn = any> {
|
||||
readonly handler: RouteHandler;
|
||||
readonly match: RouteMatchCallback<MatchReturn>;
|
||||
readonly method: HTTPMethod;
|
||||
constructor(match: RouteMatchCallback<MatchReturn>, handler: RouteHandler, method?: HTTPMethod);
|
||||
}
|
||||
Vendored
+39
@@ -0,0 +1,39 @@
|
||||
import { Route } from "./Route";
|
||||
|
||||
import { HTTPMethod } from "./types/HTTPMethod";
|
||||
import { RouteHandler } from "./types/RouteHandler";
|
||||
|
||||
export class Router {
|
||||
constructor();
|
||||
readonly routes: Map<HTTPMethod, Route[]>;
|
||||
addCacheListener(): void;
|
||||
addFetchListener(): void;
|
||||
findMatchingRoute(options: Router.FindMatchingRouteOptions): {} | Router.FindMatchingRouteReturn;
|
||||
handleRequest(options: Router.HandleRequestOptions): Promise<Response | undefined>;
|
||||
registerRoute(route: Route): void;
|
||||
setCatchHandler(handler: RouteHandler): void;
|
||||
setDefaultHandler(handler: RouteHandler): void;
|
||||
unregisterRoute(route: Route): void;
|
||||
}
|
||||
|
||||
export namespace Router {
|
||||
interface FindMatchingRouteOptions extends HandleRequestOptions {
|
||||
url: URL;
|
||||
}
|
||||
|
||||
interface FindMatchingRouteReturn<MatchReturn = any> {
|
||||
params: any; // Exclude<MatchReturn, Falsy> | undefined; <-- TypeScript 2.8
|
||||
route: Route<MatchReturn>;
|
||||
}
|
||||
|
||||
interface HandleRequestOptions {
|
||||
request: Request;
|
||||
event?: FetchEvent;
|
||||
}
|
||||
}
|
||||
|
||||
export {};
|
||||
|
||||
// type Exclude<T, U> = T extends U ? never : T;
|
||||
|
||||
// type Falsy = false | 0 | "" | null | undefined ;
|
||||
Vendored
+18
@@ -0,0 +1,18 @@
|
||||
// Type definitions for workbox-routing 4.3
|
||||
// Project: https://github.com/GoogleChrome/workbox
|
||||
// Definitions by: Jason Kwok <https://github.com/JasonHK>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.3
|
||||
|
||||
export * from "./NavigationRoute";
|
||||
export * from "./RegExpRoute";
|
||||
export * from "./Route";
|
||||
export * from "./Router";
|
||||
export * from "./registerNavigationRoute";
|
||||
export * from "./registerRoute";
|
||||
export * from "./setCatchHandler";
|
||||
export * from "./setDefaultHandler";
|
||||
|
||||
export * from "./types/HTTPMethod";
|
||||
export * from "./types/RouteHandler";
|
||||
export * from "./types/RouteMatchCallback";
|
||||
@@ -0,0 +1,7 @@
|
||||
import { NavigationRoute, NavigationRouteOptions } from "./NavigationRoute";
|
||||
|
||||
export function registerNavigationRoute(cachedAssetUrl: string, options?: RegisterNavigationRouteOptions): NavigationRoute;
|
||||
|
||||
export interface RegisterNavigationRouteOptions extends NavigationRouteOptions {
|
||||
cacheName?: string;
|
||||
}
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
import { RegExpRoute } from "./RegExpRoute";
|
||||
import { Route } from "./Route";
|
||||
|
||||
import { HTTPMethod } from "./types/HTTPMethod";
|
||||
import { RouteHandler } from "./types/RouteHandler";
|
||||
import { RouteMatchCallback } from "./types/RouteMatchCallback";
|
||||
|
||||
export function registerRoute(capture: string, handler?: RouteHandler, method?: HTTPMethod): Route<boolean>;
|
||||
export function registerRoute(capture: RegExp, handler?: RouteHandler, method?: HTTPMethod): RegExpRoute;
|
||||
export function registerRoute<MatchReturn = any>(capture: RouteMatchCallback<MatchReturn> | Route<MatchReturn>, handler?: RouteHandler, method?: HTTPMethod): Route<MatchReturn>;
|
||||
export function registerRoute(capture: RegisterRouteCapture, handler?: RouteHandler, method?: HTTPMethod): Route;
|
||||
|
||||
export type RegisterRouteCapture = string | RegExp | RouteMatchCallback | Route;
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
import { RouteHandler } from "./types/RouteHandler";
|
||||
|
||||
export function setCatchHandler(handler: RouteHandler): void;
|
||||
@@ -0,0 +1,3 @@
|
||||
import { RouteHandler } from "./types/RouteHandler";
|
||||
|
||||
export function setDefaultHandler(handler: RouteHandler): void;
|
||||
@@ -0,0 +1,35 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es2015",
|
||||
"webworker"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictFunctionTypes": true,
|
||||
"strictNullChecks": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"NavigationRoute.d.ts",
|
||||
"RegExpRoute.d.ts",
|
||||
"Route.d.ts",
|
||||
"Router.d.ts",
|
||||
"registerNavigationRoute.d.ts",
|
||||
"registerRoute.d.ts",
|
||||
"setCatchHandler.d.ts",
|
||||
"setDefaultHandler.d.ts",
|
||||
"types/HTTPMethod.d.ts",
|
||||
"types/RouteHandler.d.ts",
|
||||
"types/RouteMatchCallback.d.ts",
|
||||
"workbox-routing-tests.ts"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"extends": "dtslint/dt.json",
|
||||
"rules": {
|
||||
"no-unnecessary-class": false,
|
||||
"no-unnecessary-generics": false
|
||||
}
|
||||
}
|
||||
+1
@@ -0,0 +1 @@
|
||||
export type HTTPMethod = "DELETE" | "GET" | "HEAD" | "PATCH" | "POST" | "PUT";
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
export type RouteHandler = RouteHandlerCallback | RouteHandlerObject;
|
||||
|
||||
export interface RouteHandlerObject {
|
||||
handle: RouteHandlerCallback;
|
||||
}
|
||||
|
||||
export type RouteHandlerCallback = (context: RouteHandlerCallbackContext) => Promise<Response>;
|
||||
|
||||
export interface RouteHandlerCallbackContext {
|
||||
url: URL;
|
||||
event?: FetchEvent;
|
||||
params?: string[] | Record<string, string>;
|
||||
request?: Request;
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
export type RouteMatchCallback<R = any> = (options: RouteMatchCallbackOptions) => R;
|
||||
|
||||
export interface RouteMatchCallbackOptions {
|
||||
url: URL;
|
||||
event?: ExtendableEvent;
|
||||
request?: Request;
|
||||
}
|
||||
@@ -0,0 +1,164 @@
|
||||
/* tslint:disable:comment-format no-namespace */
|
||||
|
||||
"use strict";
|
||||
|
||||
import {
|
||||
HTTPMethod,
|
||||
NavigationRoute,
|
||||
NavigationRouteOptions,
|
||||
RegExpRoute,
|
||||
RegisterNavigationRouteOptions,
|
||||
RegisterRouteCapture,
|
||||
Route,
|
||||
RouteHandler,
|
||||
RouteMatchCallback,
|
||||
Router,
|
||||
registerNavigationRoute,
|
||||
registerRoute,
|
||||
setCatchHandler,
|
||||
setDefaultHandler
|
||||
} from "workbox-routing";
|
||||
|
||||
declare const findMatchingRouteOptions: Router.FindMatchingRouteOptions;
|
||||
declare const handleRequestOptions: Router.HandleRequestOptions;
|
||||
declare const httpMethod: HTTPMethod;
|
||||
declare const routeHandler: RouteHandler;
|
||||
declare const routeMatchCallback: RouteMatchCallback;
|
||||
|
||||
//==============================================================================
|
||||
// WorkboxRouting.NavigationRoute
|
||||
//==============================================================================
|
||||
|
||||
export namespace NavigationRouteTest {
|
||||
declare const handler: RouteHandler;
|
||||
declare const options: NavigationRouteOptions;
|
||||
|
||||
// $ExpectType NavigationRoute
|
||||
new NavigationRoute(handler);
|
||||
// $ExpectType NavigationRoute
|
||||
new NavigationRoute(handler, options);
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
// WorkboxRouting.RegExpRoute
|
||||
//==============================================================================
|
||||
|
||||
export namespace RegExpRouteTest {
|
||||
declare const handler: RouteHandler;
|
||||
declare const method: HTTPMethod;
|
||||
declare const regExp: RegExp;
|
||||
|
||||
// $ExpectType RegExpRoute
|
||||
new RegExpRoute(regExp, handler);
|
||||
// $ExpectType RegExpRoute
|
||||
new RegExpRoute(regExp, handler, method);
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
// WorkboxRouting.Route
|
||||
//==============================================================================
|
||||
|
||||
export namespace RouteTest {
|
||||
declare const handler: RouteHandler;
|
||||
declare const match: RouteMatchCallback;
|
||||
declare const method: HTTPMethod;
|
||||
|
||||
// $ExpectType Route<any>
|
||||
new Route(match, handler);
|
||||
// $ExpectType Route<any>
|
||||
new Route(match, handler, method);
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
// WorkboxRouting.Router
|
||||
//==============================================================================
|
||||
|
||||
export namespace RouterTest {
|
||||
// $ExpectType Router
|
||||
new Router();
|
||||
|
||||
declare const router: Router;
|
||||
declare const findMatchingRouteOptions: Router.FindMatchingRouteOptions;
|
||||
declare const handleRequestOptions: Router.HandleRequestOptions;
|
||||
declare const route: Route;
|
||||
|
||||
// $ExpectType Map<HTTPMethod, Route<any>[]>
|
||||
router.routes;
|
||||
|
||||
// $ExpectType void
|
||||
router.addCacheListener();
|
||||
|
||||
// $ExpectType void
|
||||
router.addFetchListener();
|
||||
|
||||
// $ExpectType {} | FindMatchingRouteReturn<any>
|
||||
router.findMatchingRoute(findMatchingRouteOptions);
|
||||
|
||||
// $ExpectType Promise<Response | undefined>
|
||||
router.handleRequest(handleRequestOptions);
|
||||
|
||||
// $ExpectType void
|
||||
router.registerRoute(route);
|
||||
|
||||
// $ExpectType void
|
||||
router.setCatchHandler(routeHandler);
|
||||
|
||||
// $ExpectType void
|
||||
router.setDefaultHandler(routeHandler);
|
||||
|
||||
// $ExpectType void
|
||||
router.unregisterRoute(route);
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
// WorkboxRouting.registerRoute
|
||||
//==============================================================================
|
||||
|
||||
export namespace RegisterNavigationRouteTest {
|
||||
declare const url: string;
|
||||
declare const options: RegisterNavigationRouteOptions;
|
||||
|
||||
// $ExpectType NavigationRoute
|
||||
registerNavigationRoute(url);
|
||||
// $ExpectType NavigationRoute
|
||||
registerNavigationRoute(url, options);
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
// WorkboxRouting.registerRoute
|
||||
//==============================================================================
|
||||
|
||||
export namespace RegisterRouteTest {
|
||||
declare const capture: RegisterRouteCapture;
|
||||
declare const handler: RouteHandler;
|
||||
declare const method: HTTPMethod;
|
||||
|
||||
// $ExpectType Route<any>
|
||||
registerRoute(capture);
|
||||
// $ExpectType Route<any>
|
||||
registerRoute(capture, handler);
|
||||
// $ExpectType Route<any>
|
||||
registerRoute(capture, handler, method);
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
// WorkboxRouting.setCatchHandler
|
||||
//==============================================================================
|
||||
|
||||
export namespace SetCatchHandler {
|
||||
declare const handler: RouteHandler;
|
||||
|
||||
// $ExpectType void
|
||||
setCatchHandler(handler);
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
// WorkboxRouting.setDefaultHandler
|
||||
//==============================================================================
|
||||
|
||||
export namespace SetDefaultHandler {
|
||||
declare const handler: RouteHandler;
|
||||
|
||||
// $ExpectType void
|
||||
setDefaultHandler(handler);
|
||||
}
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
import { WorkboxPlugin } from "workbox-core/types/WorkboxPlugin";
|
||||
import {
|
||||
RouteHandlerCallback,
|
||||
RouteHandlerObject,
|
||||
} from "workbox-routing";
|
||||
|
||||
import { MakeRequestCallback } from "./types/MakeRequestCallback";
|
||||
|
||||
export class CacheFirst implements RouteHandlerObject {
|
||||
constructor(options?: CacheFirstOptions);
|
||||
handle: RouteHandlerCallback;
|
||||
makeRequest: MakeRequestCallback;
|
||||
}
|
||||
|
||||
export interface CacheFirstOptions {
|
||||
cacheName?: string;
|
||||
fetchOptions?: RequestInit;
|
||||
matchOptions?: CacheQueryOptions;
|
||||
plugins?: WorkboxPlugin[];
|
||||
}
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
import { WorkboxPlugin } from "workbox-core/types/WorkboxPlugin";
|
||||
import {
|
||||
RouteHandlerCallback,
|
||||
RouteHandlerObject,
|
||||
} from "workbox-routing";
|
||||
|
||||
import { MakeRequestCallback } from "./types/MakeRequestCallback";
|
||||
|
||||
export class CacheOnly implements RouteHandlerObject {
|
||||
constructor(options?: CacheOnlyOptions);
|
||||
handle: RouteHandlerCallback;
|
||||
makeRequest: MakeRequestCallback;
|
||||
}
|
||||
|
||||
export interface CacheOnlyOptions {
|
||||
cacheName?: string;
|
||||
matchOptions?: CacheQueryOptions;
|
||||
plugins?: WorkboxPlugin[];
|
||||
}
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
import { WorkboxPlugin } from "workbox-core/types/WorkboxPlugin";
|
||||
import {
|
||||
RouteHandlerCallback,
|
||||
RouteHandlerObject,
|
||||
} from "workbox-routing";
|
||||
|
||||
import { MakeRequestCallback } from "./types/MakeRequestCallback";
|
||||
|
||||
export class NetworkFirst implements RouteHandlerObject {
|
||||
constructor(options?: NetworkFirstOptions);
|
||||
handle: RouteHandlerCallback;
|
||||
makeRequest: MakeRequestCallback;
|
||||
}
|
||||
|
||||
export interface NetworkFirstOptions {
|
||||
cacheName?: string;
|
||||
fetchOptions?: RequestInit;
|
||||
matchOptions?: CacheQueryOptions;
|
||||
networkTimeoutSeconds?: number;
|
||||
plugins?: WorkboxPlugin[];
|
||||
}
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
import { WorkboxPlugin } from "workbox-core/types/WorkboxPlugin";
|
||||
import {
|
||||
RouteHandlerCallback,
|
||||
RouteHandlerObject,
|
||||
} from "workbox-routing";
|
||||
|
||||
import { MakeRequestCallback } from "./types/MakeRequestCallback";
|
||||
|
||||
export class NetworkOnly implements RouteHandlerObject {
|
||||
constructor(options?: NetworkOnlyOptions);
|
||||
handle: RouteHandlerCallback;
|
||||
makeRequest: MakeRequestCallback;
|
||||
}
|
||||
|
||||
export interface NetworkOnlyOptions {
|
||||
cacheName?: string;
|
||||
fetchOptions?: RequestInit;
|
||||
plugins?: WorkboxPlugin[];
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
import { WorkboxPlugin } from "workbox-core/types/WorkboxPlugin";
|
||||
import {
|
||||
RouteHandlerCallback,
|
||||
RouteHandlerObject,
|
||||
} from "workbox-routing";
|
||||
|
||||
import { MakeRequestCallback } from "./types/MakeRequestCallback";
|
||||
|
||||
export class StaleWhileRevalidate implements RouteHandlerObject {
|
||||
constructor(options?: StaleWhileRevalidateOptions);
|
||||
handle: RouteHandlerCallback;
|
||||
makeRequest: MakeRequestCallback;
|
||||
}
|
||||
|
||||
export interface StaleWhileRevalidateOptions {
|
||||
cacheName?: string;
|
||||
fetchOptions?: RequestInit;
|
||||
matchOptions?: CacheQueryOptions;
|
||||
plugins?: WorkboxPlugin[];
|
||||
}
|
||||
Vendored
+13
@@ -0,0 +1,13 @@
|
||||
// Type definitions for workbox-strategies 4.3
|
||||
// Project: https://github.com/GoogleChrome/workbox
|
||||
// Definitions by: Jason Kwok <https://github.com/JasonHK>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.3
|
||||
|
||||
export * from "./CacheFirst";
|
||||
export * from "./CacheOnly";
|
||||
export * from "./NetworkFirst";
|
||||
export * from "./NetworkOnly";
|
||||
export * from "./StaleWhileRevalidate";
|
||||
|
||||
export * from "./types/MakeRequestCallback";
|
||||
@@ -0,0 +1,30 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es2015",
|
||||
"webworker"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictFunctionTypes": true,
|
||||
"strictNullChecks": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"CacheFirst.d.ts",
|
||||
"CacheOnly.d.ts",
|
||||
"NetworkFirst.d.ts",
|
||||
"NetworkOnly.d.ts",
|
||||
"StaleWhileRevalidate.d.ts",
|
||||
"types/MakeRequestCallback.d.ts",
|
||||
"workbox-strategies-tests.ts"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
@@ -0,0 +1,8 @@
|
||||
export interface MakeRequestCallback {
|
||||
(options: MakeRequestCallbackOptions): Promise<Response>;
|
||||
}
|
||||
|
||||
export interface MakeRequestCallbackOptions {
|
||||
request: string | Request;
|
||||
event?: ExtendableEvent;
|
||||
}
|
||||
@@ -0,0 +1,112 @@
|
||||
/* tslint:disable:comment-format no-namespace */
|
||||
|
||||
"use strict";
|
||||
|
||||
import {
|
||||
CacheFirst,
|
||||
CacheFirstOptions,
|
||||
CacheOnly,
|
||||
CacheOnlyOptions,
|
||||
MakeRequestCallbackOptions,
|
||||
NetworkFirst,
|
||||
NetworkFirstOptions,
|
||||
NetworkOnly,
|
||||
NetworkOnlyOptions,
|
||||
StaleWhileRevalidate,
|
||||
StaleWhileRevalidateOptions,
|
||||
} from "workbox-strategies";
|
||||
|
||||
//==============================================================================
|
||||
// WorkboxStrategies.CacheFirst
|
||||
//==============================================================================
|
||||
|
||||
export namespace CacheFirstTest {
|
||||
declare const options: CacheFirstOptions;
|
||||
|
||||
// $ExpectType CacheFirst
|
||||
new CacheFirst();
|
||||
// $ExpectType CacheFirst
|
||||
new CacheFirst(options);
|
||||
|
||||
declare const cacheFirst: CacheFirst;
|
||||
declare const makeRequestOptions: MakeRequestCallbackOptions;
|
||||
|
||||
// $ExpectType Promise<Response>
|
||||
cacheFirst.makeRequest(makeRequestOptions);
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
// WorkboxStrategies.CacheOnly
|
||||
//==============================================================================
|
||||
|
||||
export namespace CacheOnlyTest {
|
||||
declare const options: CacheOnlyOptions;
|
||||
|
||||
// $ExpectType CacheOnly
|
||||
new CacheOnly();
|
||||
// $ExpectType CacheOnly
|
||||
new CacheOnly(options);
|
||||
|
||||
declare const cacheOnly: CacheOnly;
|
||||
declare const makeRequestOptions: MakeRequestCallbackOptions;
|
||||
|
||||
// $ExpectType Promise<Response>
|
||||
cacheOnly.makeRequest(makeRequestOptions);
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
// WorkboxStrategies.NetworkFirst
|
||||
//==============================================================================
|
||||
|
||||
export namespace NetworkFirstTest {
|
||||
declare const options: NetworkFirstOptions;
|
||||
|
||||
// $ExpectType NetworkFirst
|
||||
new NetworkFirst();
|
||||
// $ExpectType NetworkFirst
|
||||
new NetworkFirst(options);
|
||||
|
||||
declare const networkFirst: NetworkFirst;
|
||||
declare const makeRequestOptions: MakeRequestCallbackOptions;
|
||||
|
||||
// $ExpectType Promise<Response>
|
||||
networkFirst.makeRequest(makeRequestOptions);
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
// WorkboxStrategies.NetworkOnly
|
||||
//==============================================================================
|
||||
|
||||
export namespace NetworkOnlyTest {
|
||||
declare const options: NetworkOnlyOptions;
|
||||
|
||||
// $ExpectType NetworkOnly
|
||||
new NetworkOnly();
|
||||
// $ExpectType NetworkOnly
|
||||
new NetworkOnly(options);
|
||||
|
||||
declare const networkOnly: NetworkOnly;
|
||||
declare const makeRequestOptions: MakeRequestCallbackOptions;
|
||||
|
||||
// $ExpectType Promise<Response>
|
||||
networkOnly.makeRequest(makeRequestOptions);
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
// WorkboxStrategies.StaleWhileRevalidateTest
|
||||
//==============================================================================
|
||||
|
||||
export namespace StaleWhileRevalidateTest {
|
||||
declare const options: StaleWhileRevalidateOptions;
|
||||
|
||||
// $ExpectType StaleWhileRevalidate
|
||||
new StaleWhileRevalidate();
|
||||
// $ExpectType StaleWhileRevalidate
|
||||
new StaleWhileRevalidate(options);
|
||||
|
||||
declare const staleWhileRevalidate: StaleWhileRevalidate;
|
||||
declare const makeRequestOptions: MakeRequestCallbackOptions;
|
||||
|
||||
// $ExpectType Promise<Response>
|
||||
staleWhileRevalidate.makeRequest(makeRequestOptions);
|
||||
}
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
import { StreamSource } from "./types/StreamSource";
|
||||
|
||||
export function concatenate(sourcePromises: Array<Promise<StreamSource>>): ConcatenateReturn;
|
||||
|
||||
export interface ConcatenateReturn {
|
||||
done: Promise<void>;
|
||||
stream: ReadableStream;
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
import { StreamSource } from "./types/StreamSource";
|
||||
|
||||
export function concatenateToResponse(sourcePromises: Array<Promise<StreamSource>>, headersInit?: HeadersInit): ConcatenateToResponseReturn;
|
||||
|
||||
export interface ConcatenateToResponseReturn {
|
||||
done: Promise<void>;
|
||||
response: Response;
|
||||
}
|
||||
Vendored
+12
@@ -0,0 +1,12 @@
|
||||
// Type definitions for workbox-streams 4.3
|
||||
// Project: https://github.com/GoogleChrome/workbox
|
||||
// Definitions by: Jason Kwok <https://github.com/JasonHK>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.6
|
||||
|
||||
export * from "./concatenate";
|
||||
export * from "./concatenateToResponse";
|
||||
export * from "./isSupported";
|
||||
export * from "./strategy";
|
||||
|
||||
export * from "./types/StreamSource";
|
||||
+1
@@ -0,0 +1 @@
|
||||
export function isSupported(): boolean;
|
||||
Vendored
+10
@@ -0,0 +1,10 @@
|
||||
import {
|
||||
RouteHandlerCallback,
|
||||
RouteHandlerCallbackContext
|
||||
} from "workbox-routing";
|
||||
|
||||
import { StreamSource } from "./types/StreamSource";
|
||||
|
||||
export function strategy(sourceFunctions: StreamsHandlerCallback[], headersInit?: HeadersInit): RouteHandlerCallback;
|
||||
|
||||
export type StreamsHandlerCallback = (options: RouteHandlerCallbackContext) => Promise<StreamSource> | StreamSource;
|
||||
@@ -0,0 +1,29 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es2015",
|
||||
"webworker"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictFunctionTypes": true,
|
||||
"strictNullChecks": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"concatenate.d.ts",
|
||||
"concatenateToResponse.d.ts",
|
||||
"isSupported.d.ts",
|
||||
"strategy.d.ts",
|
||||
"types/StreamSource.d.ts",
|
||||
"workbox-streams-tests.ts"
|
||||
]
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user