🤖 Merge PR #63682 remove multiple workbox-_ DT packages, resolve versions mismatch by @NivaldoFarias

* chore[next-pwa]: resolve `workbox-build` types package versions mismatch

* chore[next-pwa]: add tests to check type `WebpackConfigOptions`

* chore[next-pwa]: remove `@types/workbox-build` in favour of package types bundle

* fix[next-pwa]: bump minimum Typescript version from `4.6` to `4.9`

* chore[next-pwa]: revert minimin ts version to `4.5`

* fix[next-pwa]: remove stale `workbox-_` DT packages

* deps: remove multiple `workbox-_` DT packages

* deps: remove even MORE `workbox-_` DT packages

* Revert "fix[next-pwa]: remove stale `workbox-_` DT packages"

This reverts commit eb0d61a97b08d2d26cf73dea48824877cc077cde.

* Revert "deps: remove multiple `workbox-_` DT packages"

This reverts commit 9bcdc74673e3652e54686e335e9da87820849b40.

* Revert "deps: remove even MORE `workbox-_` DT packages"

This reverts commit 196038096a43a6e4e1b9a69cedc7d21091c85690.

* revert: remove `workbox-sw` from not-needed packages file

* fix[customize-cra]: add module interop flag; add  lib

* deps[workbox-sw]: add workbox packages to `packages.json`

* chore[workbox-sw]: add tests

* chore: use `@types/` deps to refer to old DT packages types

* chore: remove `esModuleInterop` flag

* chore[customize-cra]: remove `webworker` lib

* fix: correct import statements
This commit is contained in:
Nivaldo Farias
2023-01-02 17:15:03 -03:00
committed by GitHub
parent dc9b44bf72
commit 1dcd97e06e
138 changed files with 117 additions and 4064 deletions

View File

@@ -5975,6 +5975,66 @@
"libraryName": "words-to-numbers",
"asOfVersion": "1.3.0"
},
"workbox-background-sync": {
"libraryName": "workbox-background-sync",
"asOfVersion": "5.0.0"
},
"workbox-broadcast-update": {
"libraryName": "workbox-broadcast-update",
"asOfVersion": "5.0.0"
},
"workbox-build": {
"libraryName": "workbox-build",
"asOfVersion": "5.1.0"
},
"workbox-cacheable-response": {
"libraryName": "workbox-cacheable-response",
"asOfVersion": "5.0.0"
},
"workbox-core": {
"libraryName": "workbox-core",
"asOfVersion": "5.0.0"
},
"workbox-expiration": {
"libraryName": "workbox-expiration",
"asOfVersion": "5.0.0"
},
"workbox-google-analytics": {
"libraryName": "workbox-google-analytics",
"asOfVersion": "5.0.0"
},
"workbox-navigation-preload": {
"libraryName": "workbox-navigation-preload",
"asOfVersion": "5.0.0"
},
"workbox-precaching": {
"libraryName": "workbox-precaching",
"asOfVersion": "5.0.0"
},
"workbox-range-requests": {
"libraryName": "workbox-range-requests",
"asOfVersion": "5.0.0"
},
"workbox-routing": {
"libraryName": "workbox-routing",
"asOfVersion": "5.0.0"
},
"workbox-strategies": {
"libraryName": "workbox-strategies",
"asOfVersion": "5.0.0"
},
"workbox-streams": {
"libraryName": "workbox-streams",
"asOfVersion": "5.0.0"
},
"workbox-webpack-plugin": {
"libraryName": "workbox-webpack-plugin",
"asOfVersion": "6.0.0"
},
"workbox-window": {
"libraryName": "workbox-window",
"asOfVersion": "5.0.0"
},
"wouter": {
"libraryName": "wouter",
"asOfVersion": "2.2.0"

View File

@@ -36,7 +36,11 @@ module.exports = override(
['ag-grid-react$']: path.resolve(__dirname, 'src/shared/agGridWrapper.js'),
}),
adjustWorkbox(wb => ({ ...wb, skipWaiting: true, exclude: (wb.exclude || []).concat('index.html') })),
adjustWorkbox(workbox => ({
...workbox,
skipWaiting: true,
exclude: (workbox.exclude || []).concat('index.html'),
})),
);
module.exports = {

View File

@@ -0,0 +1,6 @@
{
"private": true,
"dependencies": {
"@types/workbox-webpack-plugin": "^5.1.8"
}
}

View File

@@ -2,19 +2,13 @@
// Project: https://github.com/shadowwalker/next-pwa#readme
// Definitions by: Nivaldo Farias <https://github.com/NivaldoFarias>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// Minimum TypeScript Version: 4.6
// Minimum TypeScript Version: 4.5
/// <reference types="react"/>
import type { RuntimeCaching, GenerateSWOptions, InjectManifestOptions } from 'workbox-build';
import type { NextConfig } from 'next';
// match `workbox-build` ^6.5.4 types naming
import type {
RuntimeCachingEntry as RuntimeCaching,
GenerateSWConfig as GenerateSWOptions,
InjectManifestConfig as InjectManifestOptions,
} from 'workbox-build';
declare global {
interface PopStateEventInit extends EventInit {
state?: unknown;

View File

@@ -6,11 +6,16 @@ const withPWA = nextPWA({
dest: 'public',
});
// $ExpectType NextConfig & PWAConfig
const outputConfig = withPWA({});
const errorWithPWA = nextPWA({
dest: 'public',
// @ts-expect-error
register: 'error',
});
// $ExpectType NextConfig & PWAConfig
const outputConfig = withPWA({});
const webpackConfigOptions: nextPWA.WebpackConfigOptions = {
// @ts-expect-error
swDest: true,
};

View File

@@ -1,6 +1,7 @@
{
"private": true,
"dependencies": {
"next": "^12.2.5"
"next": "^12.2.5",
"workbox-build": "^6.5.4"
}
}

View File

@@ -1,11 +0,0 @@
import {
FetchDidFailCallback,
WorkboxPlugin,
} from "workbox-core/types/WorkboxPlugin";
import { QueueOptions } from "./Queue";
export class Plugin implements WorkboxPlugin {
constructor(name: string, options?: QueueOptions);
fetchDidFail: FetchDidFailCallback;
}

View File

@@ -1,29 +0,0 @@
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 QueueOnSyncEvent {
queue: Queue;
}
export interface QueueOnSyncHandler {
(options: QueueOnSyncEvent): void|Promise<void>;
}
export interface QueueOptions {
maxRetentionTime?: number | undefined;
onSync?: QueueOnSyncHandler | undefined;
}
export interface QueueEntry<Metadata = any> {
request: Request;
metadata?: Metadata | undefined;
timestamp?: number | undefined;
}

View File

@@ -1,8 +0,0 @@
// 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";

View File

@@ -1,24 +0,0 @@
{
"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",
"workbox-background-sync-tests.ts"
]
}

View File

@@ -1 +0,0 @@
{ "extends": "@definitelytyped/dtslint/dt.json" }

View File

@@ -1,62 +0,0 @@
/* 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);
}

View File

@@ -1,20 +0,0 @@
export class BroadcastCacheUpdate {
constructor(options?: BroadcastCacheUpdateOptions);
notifyIfUpdated(options: BroadcastCacheUpdate.NotifyIfUpdatedOptions): Promise<void>;
}
export namespace BroadcastCacheUpdate {
interface NotifyIfUpdatedOptions {
cacheName: string;
newResponse: Response;
oldResponse?: Response | undefined;
url: string;
event?: Event | undefined;
}
}
export interface BroadcastCacheUpdateOptions {
channelName?: string | undefined;
deferNoticationTimeout?: number | undefined;
headersToCheck?: string[] | undefined;
}

View File

@@ -1,11 +0,0 @@
import {
CacheDidUpdateCallback,
WorkboxPlugin,
} from "workbox-core/types/WorkboxPlugin";
import { BroadcastCacheUpdateOptions } from "./BroadcastCacheUpdate";
export class Plugin implements WorkboxPlugin {
constructor(options?: BroadcastCacheUpdateOptions);
cacheDidUpdate: CacheDidUpdateCallback;
}

View File

@@ -1,7 +0,0 @@
export function broadcastUpdate(options: BroadcastUpdateOptions): Promise<void>;
export interface BroadcastUpdateOptions {
cacheName: string;
url: string;
channel?: string | undefined;
}

View File

@@ -1,9 +0,0 @@
// 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";

View File

@@ -1,24 +0,0 @@
{
"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",
"workbox-broadcast-update-tests.ts"
]
}

View File

@@ -1 +0,0 @@
{ "extends": "@definitelytyped/dtslint/dt.json" }

View File

@@ -1,54 +0,0 @@
/* 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);
}

View File

@@ -1,150 +0,0 @@
import { RouteHandlerCallback, RouteMatchCallback } from 'workbox-routing';
export interface ManifestEntry {
/**
* The URL to the asset in the manifest.
*/
url: string;
/**
* The revision details for the file. This is a hash generated by node
* based on the file contents.
*/
revision?: string | undefined;
/**
* Integrity metadata that will be used when making the network request
* for the URL. based on the file contents.
*/
integrity?: string | undefined;
}
export type ManifestTransform = (
/**
* The full array of entries, prior to the current transformation.
*/
manifestEntries: ManifestEntry[],
/**
* When used in the webpack plugins, this param
* will be set to the current `compilation`.
*/
compilation?: object,
) => Promise<ManifestTransformResult>;
export interface ManifestTransformResult {
manifest: ManifestEntry[];
warnings: Array<string | undefined>;
}
export interface RuntimeCachingEntry {
/**
* * Either the name of one of the [built-in strategy classes](https://developers.google.com/web/tools/workbox/reference-docs/latest/module-workbox-strategies)
* or custom handler callback to use when the generated route matches.
*/
handler: string | RouteHandlerCallback;
/**
* The value that will be passed to [`registerRoute()`](https://developers.google.com/web/tools/workbox/reference-docs/latest/module-workbox-routing#.registerRoute),
* used to determine whether the generated route will match a given request.
*/
urlPattern: string | RegExp | RouteMatchCallback;
/**
* The [HTTP method](https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods) that
* will match the generated route.
*
* @default 'GET'
*/
method?: string | undefined;
options?: RuntimeCachingEntryOptions | undefined;
}
export interface RuntimeCachingEntryOptions {
backgroundSync?: {
/**
* The `name` property to use when creating the
* [`BackgroundSyncPlugin`](https://developers.google.com/web/tools/workbox/reference-docs/latest/module-workbox-background-sync.BackgroundSyncPlugin).
*/
name?: string | undefined;
/**
* The `options` property to use when creating the
* [`BackgroundSyncPlugin`](https://developers.google.com/web/tools/workbox/reference-docs/latest/module-workbox-background-sync.BackgroundSyncPlugin).
*/
options?: object | undefined;
} | undefined;
broadcastUpdate?: {
/**
* The `channelName` property to use when creating the
* [`BroadcastCacheUpdatePlugin`](https://developers.google.com/web/tools/workbox/reference-docs/latest/module-workbox-broadcast-update.BroadcastUpdatePlugin).
*/
channelName?: string | undefined;
/**
* The `options` property to use when creating the
* [`BroadcastCacheUpdatePlugin`](https://developers.google.com/web/tools/workbox/reference-docs/latest/module-workbox-broadcast-update.BroadcastUpdatePlugin).
*/
options?: object | undefined;
} | undefined;
cacheableResponse?: {
/**
* The `headers` property to use when creating the
* [`CacheableResponsePlugin`](https://developers.google.com/web/tools/workbox/reference-docs/latest/module-workbox-cacheable-response.CacheableResponsePlugin).
*/
headers?: object | undefined;
/**
* The `statuses` property to use when creating the
* [`CacheableResponsePlugin`](https://developers.google.com/web/tools/workbox/reference-docs/latest/module-workbox-cacheable-response.CacheableResponsePlugin).
*/
statuses?: number[] | undefined;
} | undefined;
/**
* The `cacheName` to use when constructing one of the [Workbox strategy classes](https://developers.google.com/web/tools/workbox/reference-docs/latest/module-workbox-strategies.html).
*/
cacheName?: string | undefined;
/**
* The `fetchOptions` property value to use when constructing one of the
* [Workbox strategy classes](https://developers.google.com/web/tools/workbox/reference-docs/latest/module-workbox-strategies.html).
*/
fetchOptions?: object | undefined;
expiration?: {
/**
* The `maxAgeSeconds` property to use when creating the
* [`ExpirationPlugin`](https://developers.google.com/web/tools/workbox/reference-docs/latest/module-workbox-expiration.ExpirationPlugin.html)
*/
maxAgeSeconds?: number | undefined;
/**
* The `maxEntries` property to use when creating the
* [`ExpirationPlugin`](https://developers.google.com/web/tools/workbox/reference-docs/latest/module-workbox-expiration.ExpirationPlugin.html)
*/
maxEntries?: number | undefined;
} | undefined;
/**
* The `matchOptions` property value to use when constructing one of the
* [Workbox strategy classes](https://developers.google.com/web/tools/workbox/reference-docs/latest/module-workbox-strategies.html).
*/
matchOptions?: object | undefined;
/**
* The `networkTimeoutSeconds` property value to use when creating a
* [`NetworkFirst`](https://developers.google.com/web/tools/workbox/reference-docs/latest/module-workbox-strategies.NetworkFirst) strategy.
*/
networkTimeoutSeconds?: number | undefined;
/**
* One or more [additional plugins](https://developers.google.com/web/tools/workbox/guides/using-plugins#custom_plugins)
* to apply to the handler. Useful when you want a plugin that doesn't have a
* "shortcut" configuration.
*/
plugins?: object[] | undefined;
}

View File

@@ -1,266 +0,0 @@
import { ManifestEntry, ManifestTransform, RuntimeCachingEntry } from './_types';
export interface GenerateSWConfig {
/**
* The local directory you wish to match `globPatterns` against. The path is relative to the current directory.
*/
globDirectory: string;
/**
* The path and filename of the service worker file that will be created by the
* build process, relative to the current working directory. It must end in '.js'.
*/
swDest: string;
/**
* A list of entries to be precached, in addition to any entries that are
* generated as part of the build configuration.
*/
additionalManifestEntries?: ManifestEntry[] | undefined;
/**
* The [targets](https://babeljs.io/docs/en/babel-preset-env#targets) to pass to
* `babel-preset-env` when transpiling the service worker bundle.
*
* @default ['chrome >= 56']
*/
babelPresetEnvTargets?: string[] | undefined;
/**
* An optional ID to be prepended to cache names. This is primarily useful for
* local development where multiple sites may be served from the same
* `http://localhost:port` origin.
*/
cacheId?: string | undefined;
/**
* Whether or not Workbox should attempt to identify an delete any precaches
* created by older, incompatible versions.
*
* @default false
*/
cleanupOutdatedCaches?: boolean | undefined;
/**
* Whether or not the service worker should [start controlling](https://developers.google.com/web/fundamentals/primers/service-workers/lifecycle#clientsclaim)
* any existing clients as soon as it activates.
*
* @default false
*/
clientsClaim?: boolean | undefined;
/**
* If a navigation request for a URL ending in `/` fails to match a precached
* URL, this value will be appended to the URL and that will be checked for
* a precache match. This should be set to what your web server is using for
* its directory index.
*
* @default 'index.html'
*/
directoryIndex?: string | undefined;
/**
* Assets that match this will be assumed to be uniquely versioned via their
* URL, and exempted from the normal HTTP cache-busting that's done when
* populating the precache. While not required, it's recommended that if your
* existing build process already inserts a `[hash]` value into each filename,
* you provide a RegExp that will detect that, as it will reduce the bandwidth
* consumed when precaching.
*/
dontCacheBustURLsMatching?: RegExp | undefined;
/**
* Determines whether or not symlinks are followed when generating the precache
* manifest. For more information, see the definition of `follow` in the `glob`
* [documentation](https://github.com/isaacs/node-glob#options).
*
* @default true
*/
globFollow?: boolean | undefined;
/**
* A set of patterns matching files to always exclude when generating the
* precache manifest. For more information, see the definition of `ignore` in the `glob`
* [documentation](https://github.com/isaacs/node-glob#options).
*
* @default ['node_modules/**']
*/
globIgnores?: string[] | undefined;
/**
* Files matching any of these patterns will be included in the precache
* manifest. For more information, see the
* [`glob` primer](https://github.com/isaacs/node-glob#glob-primer).
*
* @default ['**.{js,css,html}']
*/
globPatterns?: string[] | undefined;
/**
* If true, an error reading a directory when generating a precache manifest
* will cause the build to fail. If false, the problematic directory will be
* skipped. For more information, see the definition of `strict` in the `glob`
* [documentation](https://github.com/isaacs/node-glob#options).
*
* @default true
*/
globStrict?: boolean | undefined;
/**
* Any search parameter names that match against one of the RegExp in this array
* will be removed before looking for a precache match. This is useful if your
* users might request URLs that contain, for example, URL parameters used to
* track the source of the traffic.
*
* @default [/^utm_/]
*/
ignoreURLParametersMatching?: RegExp[] | undefined;
/**
* A list of JavaScript files that should be passed to [`importScripts()`](https://developer.mozilla.org/en-US/docs/Web/API/WorkerGlobalScope/importScripts)
* inside the generated service worker file. This is useful when you want to
* let Workbox create your top-level service worker file, but want to include
* some additional code, such as a push event listener.
*/
importScripts?: string[] | undefined;
/**
* Whether the runtime code for the Workbox library should be included in the
* top-level service worker, or split into a separate file that needs to be deployed
* alongside the service worker. Keeping the runtime separate means that users will
* not have to re-download the Workbox code each time your top-level service worker changes.
*
* @default false
*/
inlineWorkboxRuntime?: boolean | undefined;
/**
* One or more functions which will be applied sequentially against the
* generated manifest. If `modifyURLPrefix` or `dontCacheBustURLsMatching` are
* also specified, their corresponding transformations will be applied first.
*/
manifestTransforms?: ManifestTransform[] | undefined;
/**
* This value can be used to determine the maximum size of files that will be
* precached. This prevents you from inadvertently precaching very large files
* that might have accidentally matched one of your patterns.
*
* @default 2097152
*/
maximumFileSizeToCacheInBytes?: number | undefined;
/**
* If set to 'production', then an optimized service worker bundle that excludes
* debugging info will be produced. If not explicitly configured here, the `mode`
* value configured in the current `webpack` compiltion will be used.
*/
mode?: string | undefined;
/**
* A mapping of prefixes that, if present in an entry in the precache manifest,
* will be replaced with the corresponding value. This can be used to, for example,
* remove or add a path prefix from a manifest entry if your web hosting setup
* doesn't match your local filesystem setup. As an alternative with more flexibility,
* you can use the `manifestTransforms` option and provide a function that modifies
* the entries in the manifest using whatever logic you provide.
*/
modifyURLPrefix?: {
[key: string]: string;
} | undefined;
/**
* If specified, all [navigation requests](https://developers.google.com/web/fundamentals/primers/service-workers/high-performance-loading#first_what_are_navigation_requests)
* for URLs that aren't precached will be fulfilled with the HTML at the URL
* provided. You must pass in the URL of an HTML document that is listed in your
* precache manifest. This is meant to be used in a Single Page App scenario, in
* which you want all navigations to use common [App Shell HTML](https://developers.google.com/web/fundamentals/architecture/app-shell).
*/
navigateFallback?: string | undefined;
/**
* An optional array of regular expressions that restricts which URLs the configured
* `navigateFallback` behavior applies to. This is useful if only a subset of
* your site's URLs should be treated as being part of a
* [Single Page App](https://en.wikipedia.org/wiki/Single-page_application). If
* both `navigateFallbackDenylist` and `navigateFallbackAllowlist` are
* configured, the denylist takes precedent.
*/
navigateFallbackDenylist?: RegExp[] | undefined;
/**
* An optional array of regular expressions that restricts which URLs the configured
* `navigateFallback` behavior applies to. This is useful if only a subset of
* your site's URLs should be treated as being part of a
* [Single Page App](https://en.wikipedia.org/wiki/Single-page_application). If
* both `navigateFallbackDenylist` and `navigateFallbackAllowlist` are
* configured, the denylist takes precedent.
*/
navigateFallbackAllowlist?: RegExp[] | undefined;
/**
* Whether or not to enable [navigation preload](https://developers.google.com/web/tools/workbox/modules/workbox-navigation-preload)
* in the generated service worker. When set to true, you must also use
* `runtimeCaching` to set up an appropriate response strategy that will match
* navigation requests, and make use of the preloaded response.
*
* @default false
*/
navigationPreload?: boolean | undefined;
/**
* Controls whether or not to include support for [offline Google Analytics](https://developers.google.com/web/tools/workbox/guides/enable-offline-analytics).
* When `true`, the call to `workbox-google-analytics`'s `initialize()` will be
* added to your generated service worker. When set to an `Object`, that object
* will be passed in to the `initialize()` call, allowing you to customize the
* behavior.
*
* @default false
*/
offlineGoogleAnalytics?: boolean | object | undefined;
runtimeCaching?: RuntimeCachingEntry[] | undefined;
/**
* Whether to add an unconditional call to [`skipWaiting()`](https://developers.google.com/web/tools/workbox/reference-docs/latest/module-workbox-core#.skipWaiting)
* to the generated service worker. If `false`, then a `message` listener will
* be added instead, allowing you to conditionally call `skipWaiting()`.
*
* @default false
*/
skipWaiting?: boolean | undefined;
/**
* Whether to create a sourcemap for the generated service worker files.
*
* @default true
*/
sourcemap?: boolean | undefined;
/**
* If a URL is rendered based on some server-side logic, its contents may depend
* on multiple files or on some other unique string value. The keys in this object
* are server-rendered URLs. If the values are an array of strings, they will be
* interpreted as `glob` patterns, and the contents of any files matching the
* patterns will be used to uniquely version the URL. If used with a single string,
* it will be interpreted as unique versioning information that you've generated
* for a given URL.
*/
templatedURLs?: object | undefined;
}
/**
* A promise that resolves once the service worker and related files
* (indicated by `filePaths`) has been written to `swDest`. The `size` property
* contains the aggregate size of all the precached entries, in bytes, and the
* `count` property contains the total number of precached entries. Any
* non-fatal warning messages will be returned via `warnings`.
*/
export type GenerateSWResult = Promise<{
count: number;
filePaths: string[];
size: number;
warnings: string[];
}>;
export function generateSW(config: GenerateSWConfig): GenerateSWResult;

View File

@@ -1,116 +0,0 @@
import { ManifestEntry, ManifestTransform } from './_types';
export interface GetManifestConfig {
/**
* The local directory you wish to match `globPatterns` against. The path is relative to the current directory.
*/
globDirectory: string;
/**
* A list of entries to be precached, in addition to any entries that are
* generated as part of the build configuration.
*/
additionalManifestEntries?: ManifestEntry[] | undefined;
/**
* Assets that match this will be assumed to be uniquely versioned via their
* URL, and exempted from the normal HTTP cache-busting that's done when
* populating the precache. While not required, it's recommended that if your
* existing build process already inserts a `[hash]` value into each filename,
* you provide a RegExp that will detect that, as it will reduce the bandwidth
* consumed when precaching.
*/
dontCacheBustURLsMatching?: RegExp | undefined;
/**
* Determines whether or not symlinks are followed when generating the precache
* manifest. For more information, see the definition of `follow` in the `glob`
* [documentation](https://github.com/isaacs/node-glob#options).
*
* @default true
*/
globFollow?: boolean | undefined;
/**
* A set of patterns matching files to always exclude when generating the
* precache manifest. For more information, see the definition of `ignore` in the `glob`
* [documentation](https://github.com/isaacs/node-glob#options).
*
* @default ['node_modules/**']
*/
globIgnores?: string[] | undefined;
/**
* Files matching any of these patterns will be included in the precache
* manifest. For more information, see the
* [`glob` primer](https://github.com/isaacs/node-glob#glob-primer).
*
* @default ['**.{js,css,html}']
*/
globPatterns?: string[] | undefined;
/**
* If true, an error reading a directory when generating a precache manifest
* will cause the build to fail. If false, the problematic directory will be
* skipped. For more information, see the definition of `strict` in the `glob`
* [documentation](https://github.com/isaacs/node-glob#options).
*
* @default true
*/
globStrict?: boolean | undefined;
/**
* One or more functions which will be applied sequentially against the
* generated manifest. If `modifyURLPrefix` or `dontCacheBustURLsMatching` are
* also specified, their corresponding transformations will be applied first.
*/
manifestTransforms?: ManifestTransform[] | undefined;
/**
* This value can be used to determine the maximum size of files that will be
* precached. This prevents you from inadvertently precaching very large files
* that might have accidentally matched one of your patterns.
*
* @default 2097152
*/
maximumFileSizeToCacheInBytes?: number | undefined;
/**
* If set to 'production', then an optimized service worker bundle that excludes
* debugging info will be produced. If not explicitly configured here, the `mode`
* value configured in the current `webpack` compiltion will be used.
*/
mode?: string | undefined;
/**
* A mapping of prefixes that, if present in an entry in the precache manifest,
* will be replaced with the corresponding value. This can be used to, for example,
* remove or add a path prefix from a manifest entry if your web hosting setup
* doesn't match your local filesystem setup. As an alternative with more flexibility,
* you can use the `manifestTransforms` option and provide a function that modifies
* the entries in the manifest using whatever logic you provide.
*/
modifyURLPrefix?: {
[key: string]: string;
} | undefined;
/**
* If a URL is rendered based on some server-side logic, its contents may depend
* on multiple files or on some other unique string value. The keys in this object
* are server-rendered URLs. If the values are an array of strings, they will be
* interpreted as `glob` patterns, and the contents of any files matching the
* patterns will be used to uniquely version the URL. If used with a single string,
* it will be interpreted as unique versioning information that you've generated
* for a given URL.
*/
templatedURLs?: object | undefined;
}
export type GetManifestResult = Promise<{
count: number;
filePaths: string[];
size: number;
warnings: string[];
}>;
export function getManifest(config: GetManifestConfig): GetManifestResult;

View File

@@ -1,11 +0,0 @@
// Type definitions for workbox-build 5.0
// Project: https://github.com/GoogleChrome/workbox/tree/master/packages/workbox-build, https://developers.google.com/web/tools/workbox/modules/workbox-build
// Definitions by: Preston Richey <https://github.com/prichey>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
export * from './_types';
export * from './lib/copy-workbox-libraries';
export * from './lib/get-module-url';
export * from './generate-sw';
export * from './get-manifest';
export * from './inject-manifest';

View File

@@ -1,138 +0,0 @@
import { ManifestEntry, ManifestTransform } from './_types';
export interface InjectManifestConfig {
/**
* The local directory you wish to match `globPatterns` against. The path is relative to the current directory.
*/
globDirectory: string;
/**
* The path and filename of the service worker file that will be created by the
* build process, relative to the current working directory. It must end in '.js'.
*/
swDest: string;
/**
* The path and filename of the service worker file that will be created by
* the build process, relative to the current working directory. It must end in '.js'.
*/
swSrc: string;
/**
* A list of entries to be precached, in addition to any entries that are
* generated as part of the build configuration.
*
* @default true
*/
additionalManifestEntries?: ManifestEntry[] | undefined;
/**
* Assets that match this will be assumed to be uniquely versioned via their
* URL, and exempted from the normal HTTP cache-busting that's done when
* populating the precache. While not required, it's recommended that if your
* existing build process already inserts a `[hash]` value into each filename,
* you provide a RegExp that will detect that, as it will reduce the bandwidth
* consumed when precaching.
*/
dontCacheBustURLsMatching?: RegExp | undefined;
/**
* Determines whether or not symlinks are followed when generating the precache
* manifest. For more information, see the definition of `follow` in the `glob`
* [documentation](https://github.com/isaacs/node-glob#options).
*
* @default true
*/
globFollow?: boolean | undefined;
/**
* A set of patterns matching files to always exclude when generating the
* precache manifest. For more information, see the definition of `ignore` in the `glob`
* [documentation](https://github.com/isaacs/node-glob#options).
*
* @default ['node_modules/**']
*/
globIgnores?: string[] | undefined;
/**
* Files matching any of these patterns will be included in the precache
* manifest. For more information, see the
* [`glob` primer](https://github.com/isaacs/node-glob#glob-primer).
*
* @default ['**.{js,css,html}']
*/
globPatterns?: string[] | undefined;
/**
* If true, an error reading a directory when generating a precache manifest
* will cause the build to fail. If false, the problematic directory will be
* skipped. For more information, see the definition of `strict` in the `glob`
* [documentation](https://github.com/isaacs/node-glob#options).
*
* @default true
*/
globStrict?: boolean | undefined;
/**
* The string to find inside of the `swSrc` file. Once found, it will be replaced by
* the generated precache manifest.
*
* @default 'self.__WB_MANIFEST'
*/
injectionPoint?: string | undefined;
/**
* One or more functions which will be applied sequentially against the
* generated manifest. If `modifyURLPrefix` or `dontCacheBustURLsMatching` are
* also specified, their corresponding transformations will be applied first.
*/
manifestTransforms?: ManifestTransform[] | undefined;
/**
* This value can be used to determine the maximum size of files that will be
* precached. This prevents you from inadvertently precaching very large files
* that might have accidentally matched one of your patterns.
*
* @default 2097152
*/
maximumFileSizeToCacheInBytes?: number | undefined;
/**
* If set to 'production', then an optimized service worker bundle that excludes
* debugging info will be produced. If not explicitly configured here, the `mode`
* value configured in the current `webpack` compiltion will be used.
*/
mode?: string | undefined;
/**
* A mapping of prefixes that, if present in an entry in the precache manifest,
* will be replaced with the corresponding value. This can be used to, for example,
* remove or add a path prefix from a manifest entry if your web hosting setup
* doesn't match your local filesystem setup. As an alternative with more flexibility,
* you can use the `manifestTransforms` option and provide a function that modifies
* the entries in the manifest using whatever logic you provide.
*/
modifyURLPrefix?: {
[key: string]: string;
} | undefined;
/**
* If a URL is rendered based on some server-side logic, its contents may depend
* on multiple files or on some other unique string value. The keys in this object
* are server-rendered URLs. If the values are an array of strings, they will be
* interpreted as `glob` patterns, and the contents of any files matching the
* patterns will be used to uniquely version the URL. If used with a single string,
* it will be interpreted as unique versioning information that you've generated
* for a given URL.
*/
templatedURLs?: object | undefined;
}
export type InjectManifestResult = Promise<{
count: number;
filePaths: string[];
size: number;
warnings: string[];
}>;
export function injectManifest(config: InjectManifestConfig): InjectManifestResult;

View File

@@ -1 +0,0 @@
export function copyWorkboxLibraries(destDirectory: string): Promise<string>;

View File

@@ -1 +0,0 @@
export function getModuleURL(moduleName: string, buildType?: string): string;

View File

@@ -1,24 +0,0 @@
{
"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",
"workbox-build-tests.ts"
]
}

View File

@@ -1 +0,0 @@
{ "extends": "@definitelytyped/dtslint/dt.json" }

View File

@@ -1,73 +0,0 @@
/* tslint:disable:comment-format no-namespace */
'use strict';
import {
copyWorkboxLibraries,
injectManifest,
InjectManifestConfig,
InjectManifestResult,
generateSW,
GenerateSWConfig,
GenerateSWResult,
getManifest,
GetManifestConfig,
GetManifestResult,
getModuleURL,
} from 'workbox-build';
//==============================================================================
// WorkboxBuild.copyWorkboxLibraries
//==============================================================================
export namespace CopyWorkboxLibrariesTest {
declare const destDirectory: string;
// $ExpectType Promise<string>
copyWorkboxLibraries(destDirectory);
}
//==============================================================================
// WorkboxBuild.getModuleURL
//==============================================================================
export namespace GetModuleURLTest {
declare const moduleName: string;
declare const buildType: string;
// $ExpectType string
getModuleURL(moduleName, buildType);
}
//==============================================================================
// WorkboxBuild.generateSW
//==============================================================================
export namespace GenerateSWTest {
declare const config: GenerateSWConfig;
let result: GenerateSWResult;
result = generateSW(config);
}
//==============================================================================
// WorkboxBuild.getManifest
//==============================================================================
export namespace GetManifestTest {
declare const config: GetManifestConfig;
let result: GetManifestResult;
result = getManifest(config);
}
//==============================================================================
// WorkboxBuild.injectManifest
//==============================================================================
export namespace InjectManifestTest {
declare const config: InjectManifestConfig;
let result: InjectManifestResult;
result = injectManifest(config);
}

View File

@@ -1,9 +0,0 @@
export class CacheableResponse {
constructor(config?: CacheableResponseConfig);
isResponseCacheable(response: Response): boolean;
}
export interface CacheableResponseConfig {
headers?: Record<string, string> | undefined;
statuses?: number[] | undefined;
}

View File

@@ -1,11 +0,0 @@
import {
CacheWillUpdateCallback,
WorkboxPlugin,
} from "workbox-core/types/WorkboxPlugin";
import { CacheableResponseConfig } from "./CacheableResponse";
export class Plugin implements WorkboxPlugin {
constructor(config?: CacheableResponseConfig);
cacheWillUpdate: CacheWillUpdateCallback;
}

View File

@@ -1,8 +0,0 @@
// 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";

View File

@@ -1,24 +0,0 @@
{
"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",
"workbox-cacheable-response-tests.ts"
]
}

View File

@@ -1 +0,0 @@
{ "extends": "@definitelytyped/dtslint/dt.json" }

View File

@@ -1,41 +0,0 @@
/* 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);
}

View File

@@ -1,9 +0,0 @@
export const cacheNames: CacheNames;
export interface CacheNames {
readonly googleAnalytics: string;
readonly precache: string;
readonly prefix: string;
readonly runtime: string;
readonly suffix: string;
}

View File

@@ -1 +0,0 @@
export function clientsClaim(): void;

View File

@@ -1,13 +0,0 @@
// 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";

View File

@@ -1 +0,0 @@
export function registerQuotaErrorCallback(callback: () => void): void;

View File

@@ -1,9 +0,0 @@
export interface CacheNameDetails {
googleAnalytics: string;
precache: string;
prefix: string;
runtime: string;
suffix: string;
}
export function setCacheNameDetails(details: Partial<CacheNameDetails>): void;

View File

@@ -1 +0,0 @@
export function skipWaiting(): void;

View File

@@ -1,24 +0,0 @@
{
"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",
"workbox-core-tests.ts"
]
}

View File

@@ -1 +0,0 @@
{ "extends": "@definitelytyped/dtslint/dt.json" }

View File

@@ -1,80 +0,0 @@
export interface WorkboxPlugin {
cacheDidUpdate?: CacheDidUpdateCallback | undefined;
cacheKeyWillBeUsed?: CacheKeyWillBeUsedCallback | undefined;
cacheWillUpdate?: CacheWillUpdateCallback | undefined;
cachedResponseWillBeUsed?: CachedResponseWillBeUsedCallback | undefined;
fetchDidFail?: FetchDidFailCallback | undefined;
fetchDidSucceed?: FetchDidSucceedCallback | undefined;
requestWillFetch?: RequestWillFetchCallback | undefined;
}
export interface CacheDidUpdateCallback {
(param: CacheDidUpdateCallbackParam): Promise<void>;
}
export interface CacheDidUpdateCallbackParam {
cacheName: string;
newResponse: Response;
oldResponse?: Response | null | undefined;
request: Request;
event?: Event | undefined;
}
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 | undefined;
}
export interface CachedResponseWillBeUsedCallback {
(param: CachedResponseWillBeUsedCallbackParam): Promise<Response | undefined>;
}
export interface CachedResponseWillBeUsedCallbackParam {
cacheName: string;
cachedResponse?: Response | undefined;
matchOptions?: CacheQueryOptions | undefined;
request: Request;
event?: ExtendableEvent | undefined;
}
export interface FetchDidFailCallback {
(param: FetchDidFailCallbackParam): Promise<void>;
}
export interface FetchDidFailCallbackParam {
error: Error;
originalRequest: Request;
request: Request;
event?: ExtendableEvent | undefined;
}
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;
}

View File

@@ -1,76 +0,0 @@
/* 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();
}

View File

@@ -1,12 +0,0 @@
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 | undefined;
maxEntries?: number | undefined;
}

View File

@@ -1,18 +0,0 @@
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 | undefined;
maxEntries?: number | undefined;
purgeOnQuotaError?: boolean | undefined;
}

View File

@@ -1,8 +0,0 @@
// 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";

View File

@@ -1,24 +0,0 @@
{
"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",
"workbox-expiration-tests.ts"
]
}

View File

@@ -1 +0,0 @@
{ "extends": "@definitelytyped/dtslint/dt.json" }

View File

@@ -1,57 +0,0 @@
/* 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();
}

View File

@@ -1,7 +0,0 @@
// 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";

View File

@@ -1,7 +0,0 @@
export function initialize(options?: InitializeOptions): void;
export interface InitializeOptions {
cacheName?: string | undefined;
parameterOverrides?: Record<string, string> | undefined;
hitFilter?: ((params: URLSearchParams) => void) | undefined;
}

View File

@@ -1,24 +0,0 @@
{
"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",
"workbox-google-analytics-tests.ts"
]
}

View File

@@ -1 +0,0 @@
{ "extends": "@definitelytyped/dtslint/dt.json" }

View File

@@ -1,21 +0,0 @@
/* 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);
}

View File

@@ -1 +0,0 @@
export function disable(): void;

View File

@@ -1 +0,0 @@
export function enable(headerValue?: string): void;

View File

@@ -1,9 +0,0 @@
// 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";

View File

@@ -1 +0,0 @@
export function isSupported(): boolean;

View File

@@ -1,24 +0,0 @@
{
"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",
"workbox-navigation-preload-tests.ts"
]
}

View File

@@ -1 +0,0 @@
{ "extends": "@definitelytyped/dtslint/dt.json" }

View File

@@ -1,42 +0,0 @@
/* 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();
}

View File

@@ -1,22 +0,0 @@
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 | undefined;
plugins?: WorkboxPlugin[] | undefined;
}
}

View File

@@ -1,3 +0,0 @@
import { WorkboxPlugin } from "workbox-core/types/WorkboxPlugin";
export function addPlugins(newPlugins: WorkboxPlugin[]): void;

View File

@@ -1,5 +0,0 @@
import { FetchListenerOptions } from "./types/FetchListenerOptions";
export function addRoute(options?: FetchListenerOptions): void;
export * from "./types/FetchListenerOptions";

View File

@@ -1 +0,0 @@
export function cleanupOutdatedCaches(): void;

View File

@@ -1 +0,0 @@
export function getCacheKeyForURL(url: string): string;

View File

@@ -1,18 +0,0 @@
// 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";

View File

@@ -1,5 +0,0 @@
import { PrecacheEntry } from "./types/PrecacheEntry";
export function precache(entries: Array<string | PrecacheEntry>): void;
export * from "./types/PrecacheEntry";

View File

@@ -1,6 +0,0 @@
import { FetchListenerOptions } from "./types/FetchListenerOptions";
import { PrecacheEntry } from "./types/PrecacheEntry";
export function precacheAndRoute(entries: Array<string | PrecacheEntry>, options?: FetchListenerOptions): void;
export * from "./types/PrecacheEntry";

View File

@@ -1,24 +0,0 @@
{
"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",
"workbox-precaching-tests.ts"
]
}

View File

@@ -1 +0,0 @@
{ "extends": "@definitelytyped/dtslint/dt.json" }

View File

@@ -1,3 +0,0 @@
export interface CleanupResult {
deletedCacheRequests: string[];
}

View File

@@ -1,8 +0,0 @@
import { URLManipulation } from "./URLManipulation";
export interface FetchListenerOptions {
cleanURLs?: boolean | undefined;
directoryIndex?: string | undefined;
ignoreURLParametersMatching?: RegExp[] | undefined;
urlManipulation?: URLManipulation | undefined;
}

View File

@@ -1,4 +0,0 @@
export interface InstallResult {
notUpdatedURLs: string[];
updatedURLs: string[];
}

View File

@@ -1,5 +0,0 @@
export interface PrecacheEntry {
url: string;
// integrity?: string;
revision?: string | undefined;
}

View File

@@ -1 +0,0 @@
export type URLManipulation = (url: { url: URL }) => URL[];

View File

@@ -1,123 +0,0 @@
/* 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);
}

View File

@@ -1,6 +0,0 @@
import { CachedResponseWillBeUsedCallback, WorkboxPlugin } from "workbox-core/types/WorkboxPlugin";
export class Plugin implements WorkboxPlugin {
constructor();
cachedResponseWillBeUsed: CachedResponseWillBeUsedCallback;
}

View File

@@ -1 +0,0 @@
export function createPartialResponse(request: Request, originalResponse: Response): Promise<Response>;

View File

@@ -1,8 +0,0 @@
// 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";

View File

@@ -1,24 +0,0 @@
{
"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",
"workbox-range-requests-tests.ts"
]
}

View File

@@ -1 +0,0 @@
{ "extends": "@definitelytyped/dtslint/dt.json" }

View File

@@ -1,29 +0,0 @@
/* 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);
}

View File

@@ -1,13 +0,0 @@
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[] | undefined;
blacklist?: RegExp[] | undefined;
}

View File

@@ -1,8 +0,0 @@
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);
}

View File

@@ -1,10 +0,0 @@
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);
}

View File

@@ -1,39 +0,0 @@
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 | undefined;
}
}
export {};
// type Exclude<T, U> = T extends U ? never : T;
// type Falsy = false | 0 | "" | null | undefined ;

View File

@@ -1,18 +0,0 @@
// 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";

View File

@@ -1,7 +0,0 @@
import { NavigationRoute, NavigationRouteOptions } from "./NavigationRoute";
export function registerNavigationRoute(cachedAssetUrl: string, options?: RegisterNavigationRouteOptions): NavigationRoute;
export interface RegisterNavigationRouteOptions extends NavigationRouteOptions {
cacheName?: string | undefined;
}

View File

@@ -1,13 +0,0 @@
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;

View File

@@ -1,3 +0,0 @@
import { RouteHandler } from "./types/RouteHandler";
export function setCatchHandler(handler: RouteHandler): void;

View File

@@ -1,3 +0,0 @@
import { RouteHandler } from "./types/RouteHandler";
export function setDefaultHandler(handler: RouteHandler): void;

View File

@@ -1,24 +0,0 @@
{
"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",
"workbox-routing-tests.ts"
]
}

View File

@@ -1 +0,0 @@
{ "extends": "@definitelytyped/dtslint/dt.json" }

View File

@@ -1 +0,0 @@
export type HTTPMethod = "DELETE" | "GET" | "HEAD" | "PATCH" | "POST" | "PUT";

View File

@@ -1,14 +0,0 @@
export type RouteHandler = RouteHandlerCallback | RouteHandlerObject;
export interface RouteHandlerObject {
handle: RouteHandlerCallback;
}
export type RouteHandlerCallback = (context: RouteHandlerCallbackContext) => Promise<Response>;
export interface RouteHandlerCallbackContext {
url: URL;
event?: FetchEvent | undefined;
params?: string[] | Record<string, string> | undefined;
request?: Request | undefined;
}

View File

@@ -1,7 +0,0 @@
export type RouteMatchCallback<R = any> = (options: RouteMatchCallbackOptions) => R;
export interface RouteMatchCallbackOptions {
url: URL;
event?: ExtendableEvent | undefined;
request?: Request | undefined;
}

View File

@@ -1,164 +0,0 @@
/* 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);
}

Some files were not shown because too many files have changed in this diff Show More