From f2009fef719181cd370ff957489c08ebd4cab934 Mon Sep 17 00:00:00 2001 From: Jeff Posnick Date: Wed, 23 Dec 2020 09:25:27 -0500 Subject: [PATCH 01/80] WIP --- package-lock.json | 9 ++ package.json | 1 + .../src/{get-manifest.js => get-manifest.ts} | 18 +-- ...te-details.js => get-composite-details.ts} | 6 +- ...et-file-details.js => get-file-details.ts} | 20 +-- .../{get-file-hash.js => get-file-hash.ts} | 12 +- ...ntries.js => get-file-manifest-entries.ts} | 49 +++---- .../{get-file-size.js => get-file-size.ts} | 8 +- ...tring-details.js => get-string-details.ts} | 10 +- ...{get-string-hash.js => get-string-hash.ts} | 6 +- ...form-manifest.js => transform-manifest.ts} | 16 +-- packages/workbox-build/src/types.ts | 135 ++++++++++++++++++ .../src/ExpirationPlugin.ts | 14 +- .../src/initialize.ts | 2 +- 14 files changed, 223 insertions(+), 83 deletions(-) rename packages/workbox-build/src/{get-manifest.js => get-manifest.ts} (91%) rename packages/workbox-build/src/lib/{get-composite-details.js => get-composite-details.ts} (76%) rename packages/workbox-build/src/lib/{get-file-details.js => get-file-details.ts} (76%) rename packages/workbox-build/src/lib/{get-file-hash.js => get-file-hash.ts} (55%) rename packages/workbox-build/src/lib/{get-file-manifest-entries.js => get-file-manifest-entries.ts} (66%) rename packages/workbox-build/src/lib/{get-file-size.js => get-file-size.ts} (71%) rename packages/workbox-build/src/lib/{get-string-details.js => get-string-details.ts} (51%) rename packages/workbox-build/src/lib/{get-string-hash.js => get-string-hash.ts} (72%) rename packages/workbox-build/src/lib/{transform-manifest.js => transform-manifest.ts} (91%) create mode 100644 packages/workbox-build/src/types.ts diff --git a/package-lock.json b/package-lock.json index 7d70c9d6d..89277250c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -4196,6 +4196,15 @@ "integrity": "sha512-jnqIUKDUqJbDIUxm0Uj7bnlMnRm1T/eZ9N+AVMqhPgzrba2GhGG5o/jCTwmdPK709nEZsGoMzXEDUjcXHa3W0g==", "dev": true }, + "@types/fs-extra": { + "version": "9.0.5", + "resolved": "https://registry.npmjs.org/@types/fs-extra/-/fs-extra-9.0.5.tgz", + "integrity": "sha512-wr3t7wIW1c0A2BIJtdVp4EflriVaVVAsCAIHVzzh8B+GiFv9X1xeJjCs4upRXtzp7kQ6lP5xvskjoD4awJ1ZeA==", + "dev": true, + "requires": { + "@types/node": "*" + } + }, "@types/glob": { "version": "7.1.3", "resolved": "https://registry.npmjs.org/@types/glob/-/glob-7.1.3.tgz", diff --git a/package.json b/package.json index e3c9e8c0d..230c0e797 100644 --- a/package.json +++ b/package.json @@ -49,6 +49,7 @@ "@rollup/plugin-node-resolve": "^9.0.0", "@rollup/plugin-replace": "^2.3.3", "@types/estree": "0.0.45", + "@types/fs-extra": "^9.0.5", "@typescript-eslint/eslint-plugin": "^2.30.0", "@typescript-eslint/parser": "^2.30.0", "acorn": "^8.0.1", diff --git a/packages/workbox-build/src/get-manifest.js b/packages/workbox-build/src/get-manifest.ts similarity index 91% rename from packages/workbox-build/src/get-manifest.js rename to packages/workbox-build/src/get-manifest.ts index 8d3abf590..559c31135 100644 --- a/packages/workbox-build/src/get-manifest.js +++ b/packages/workbox-build/src/get-manifest.ts @@ -6,9 +6,10 @@ https://opensource.org/licenses/MIT. */ -const getFileManifestEntries = require('./lib/get-file-manifest-entries'); -const getManifestSchema = require('./options/schema/get-manifest'); -const validate = require('./lib/validate-options'); +import {BuildResult, GetManifestOptions} from './types'; +import getFileManifestEntries from './lib/get-file-manifest-entries'; +import getManifestSchema from './options/schema/get-manifest'; +import validate from './lib/validate-options'; // eslint-disable-next-line jsdoc/newline-after-description /** @@ -88,13 +89,8 @@ const validate = require('./lib/validate-options'); * * @memberof module:workbox-build */ -async function getManifest(config) { - const options = validate(config, getManifestSchema); +export async function getManifest(config: GetManifestOptions): Promise { + const options: GetManifestOptions = validate(config, getManifestSchema); - const {manifestEntries, count, size, warnings} = - await getFileManifestEntries(options); - - return {manifestEntries, count, size, warnings}; + return await getFileManifestEntries(options); } - -module.exports = getManifest; diff --git a/packages/workbox-build/src/lib/get-composite-details.js b/packages/workbox-build/src/lib/get-composite-details.ts similarity index 76% rename from packages/workbox-build/src/lib/get-composite-details.js rename to packages/workbox-build/src/lib/get-composite-details.ts index 36f3c24c3..3bb0f1568 100644 --- a/packages/workbox-build/src/lib/get-composite-details.js +++ b/packages/workbox-build/src/lib/get-composite-details.ts @@ -6,9 +6,11 @@ https://opensource.org/licenses/MIT. */ -const crypto = require('crypto'); +import crypto from 'crypto'; -module.exports = (compositeURL, dependencyDetails) => { +import {FileDetails} from '../types'; + +export default function(compositeURL: string, dependencyDetails: Array): FileDetails { let totalSize = 0; let compositeHash = ''; diff --git a/packages/workbox-build/src/lib/get-file-details.js b/packages/workbox-build/src/lib/get-file-details.ts similarity index 76% rename from packages/workbox-build/src/lib/get-file-details.js rename to packages/workbox-build/src/lib/get-file-details.ts index a26519fbd..7c91f6519 100644 --- a/packages/workbox-build/src/lib/get-file-details.js +++ b/packages/workbox-build/src/lib/get-file-details.ts @@ -6,22 +6,24 @@ https://opensource.org/licenses/MIT. */ -const glob = require('glob'); -const upath = require('upath'); +import glob from 'glob'; +import upath from 'upath'; -const errors = require('./errors'); -const getFileSize = require('./get-file-size'); -const getFileHash = require('./get-file-hash'); +import errors from './errors'; +import getFileSize from './get-file-size'; +import getFileHash from './get-file-hash'; -module.exports = ({ +import {GlobPartial} from '../types'; + +export default function({ globDirectory, globFollow, globIgnores, globPattern, globStrict, -}) => { - let globbedFiles; - let warning; +}: Omit & {globPattern: string}) { + let globbedFiles: Array; + let warning: string; try { globbedFiles = glob.sync(globPattern, { diff --git a/packages/workbox-build/src/lib/get-file-hash.js b/packages/workbox-build/src/lib/get-file-hash.ts similarity index 55% rename from packages/workbox-build/src/lib/get-file-hash.js rename to packages/workbox-build/src/lib/get-file-hash.ts index 2c3c0cc29..71a35b0da 100644 --- a/packages/workbox-build/src/lib/get-file-hash.js +++ b/packages/workbox-build/src/lib/get-file-hash.ts @@ -6,15 +6,15 @@ https://opensource.org/licenses/MIT. */ -const fs = require('fs'); +import fse from 'fs-extra'; -const getStringHash = require('./get-string-hash'); -const errors = require('./errors'); +import getStringHash from './get-string-hash'; +import errors from './errors'; -module.exports = (file) => { +export default function(file: string): string { try { - const buffer = fs.readFileSync(file); - return getStringHash(buffer); + const str = fse.readFileSync(file, 'utf8'); + return getStringHash(str); } catch (err) { throw new Error(errors['unable-to-get-file-hash'] + ` '${err.message}'`); } diff --git a/packages/workbox-build/src/lib/get-file-manifest-entries.js b/packages/workbox-build/src/lib/get-file-manifest-entries.ts similarity index 66% rename from packages/workbox-build/src/lib/get-file-manifest-entries.js rename to packages/workbox-build/src/lib/get-file-manifest-entries.ts index 681d7f01f..d9a4263f6 100644 --- a/packages/workbox-build/src/lib/get-file-manifest-entries.js +++ b/packages/workbox-build/src/lib/get-file-manifest-entries.ts @@ -6,15 +6,16 @@ https://opensource.org/licenses/MIT. */ -const assert = require('assert'); +import assert from 'assert'; -const errors = require('./errors'); -const transformManifest = require('./transform-manifest'); -const getCompositeDetails = require('./get-composite-details'); -const getFileDetails = require('./get-file-details'); -const getStringDetails = require('./get-string-details'); +import {BuildResult, FileDetails, GetManifestOptions} from '../types'; +import errors from './errors'; +import getCompositeDetails from './get-composite-details'; +import getFileDetails from './get-file-details'; +import getStringDetails from './get-string-details'; +import transformManifest from './transform-manifest'; -module.exports = async ({ +export default async function ({ additionalManifestEntries, dontCacheBustURLsMatching, globDirectory, @@ -25,18 +26,14 @@ module.exports = async ({ manifestTransforms, maximumFileSizeToCacheInBytes, modifyURLPrefix, - swDest, templatedURLs, -}) => { - const warnings = []; - // Initialize to an empty array so that we can still pass something to - // transformManifest() and get a normalized output. - let fileDetails = []; - const fileSet = new Set(); +}: GetManifestOptions): Promise { + const warnings: Array = []; + const allFileDetails = new Map(); if (globDirectory) { try { - fileDetails = globPatterns.reduce((accumulated, globPattern) => { + for (const globPattern of globPatterns) { const {globbedFileDetails, warning} = getFileDetails({ globDirectory, globFollow, @@ -49,16 +46,12 @@ module.exports = async ({ warnings.push(warning); } - globbedFileDetails.forEach((fileDetails) => { - if (fileSet.has(fileDetails.file)) { - return; + for (const details of globbedFileDetails) { + if (!allFileDetails.has(details.file)) { + allFileDetails.set(details.file, details); } - - fileSet.add(fileDetails.file); - accumulated.push(fileDetails); - }); - return accumulated; - }, []); + } + } } catch (error) { // If there's an exception thrown while globbing, then report // it back as a warning, and don't consider it fatal. @@ -68,7 +61,7 @@ module.exports = async ({ if (templatedURLs) { for (const url of Object.keys(templatedURLs)) { - assert(!fileSet.has(url), errors['templated-url-matches-glob']); + assert(!allFileDetails.has(url), errors['templated-url-matches-glob']); const dependencies = templatedURLs[url]; if (Array.isArray(dependencies)) { @@ -95,9 +88,9 @@ module.exports = async ({ error); } }, []); - fileDetails.push(getCompositeDetails(url, details)); + allFileDetails.set(url, getCompositeDetails(url, details)); } else if (typeof dependencies === 'string') { - fileDetails.push(getStringDetails(url, dependencies)); + allFileDetails.set(url, getStringDetails(url, dependencies)); } } } @@ -105,7 +98,7 @@ module.exports = async ({ const transformedManifest = await transformManifest({ additionalManifestEntries, dontCacheBustURLsMatching, - fileDetails, + fileDetails: allFileDetails, manifestTransforms, maximumFileSizeToCacheInBytes, modifyURLPrefix, diff --git a/packages/workbox-build/src/lib/get-file-size.js b/packages/workbox-build/src/lib/get-file-size.ts similarity index 71% rename from packages/workbox-build/src/lib/get-file-size.js rename to packages/workbox-build/src/lib/get-file-size.ts index 5ae5f2f50..3d6eb0993 100644 --- a/packages/workbox-build/src/lib/get-file-size.js +++ b/packages/workbox-build/src/lib/get-file-size.ts @@ -6,13 +6,13 @@ https://opensource.org/licenses/MIT. */ -const fs = require('fs'); +import fse from 'fs-extra'; -const errors = require('./errors'); +import errors from './errors'; -module.exports = (file) => { +export default function(file: string): number { try { - const stat = fs.statSync(file); + const stat = fse.statSync(file); if (!stat.isFile()) { return null; } diff --git a/packages/workbox-build/src/lib/get-string-details.js b/packages/workbox-build/src/lib/get-string-details.ts similarity index 51% rename from packages/workbox-build/src/lib/get-string-details.js rename to packages/workbox-build/src/lib/get-string-details.ts index 20de53d17..63fa52436 100644 --- a/packages/workbox-build/src/lib/get-string-details.js +++ b/packages/workbox-build/src/lib/get-string-details.ts @@ -6,12 +6,14 @@ https://opensource.org/licenses/MIT. */ -const getStringHash = require('./get-string-hash'); +import getStringHash from './get-string-hash'; -module.exports = (url, string) => { +import {FileDetails} from '../types'; + +export default function(url: string, str: string): FileDetails { return { file: url, - hash: getStringHash(string), - size: string.length, + hash: getStringHash(str), + size: str.length, }; }; diff --git a/packages/workbox-build/src/lib/get-string-hash.js b/packages/workbox-build/src/lib/get-string-hash.ts similarity index 72% rename from packages/workbox-build/src/lib/get-string-hash.js rename to packages/workbox-build/src/lib/get-string-hash.ts index d606f78ee..a54917e6e 100644 --- a/packages/workbox-build/src/lib/get-string-hash.js +++ b/packages/workbox-build/src/lib/get-string-hash.ts @@ -6,10 +6,10 @@ https://opensource.org/licenses/MIT. */ -const crypto = require('crypto'); +import crypto from 'crypto'; -module.exports = (string) => { +export default function(str: string): string { const md5 = crypto.createHash('md5'); - md5.update(string); + md5.update(str); return md5.digest('hex'); }; diff --git a/packages/workbox-build/src/lib/transform-manifest.js b/packages/workbox-build/src/lib/transform-manifest.ts similarity index 91% rename from packages/workbox-build/src/lib/transform-manifest.js rename to packages/workbox-build/src/lib/transform-manifest.ts index e8aade57d..477acb074 100644 --- a/packages/workbox-build/src/lib/transform-manifest.js +++ b/packages/workbox-build/src/lib/transform-manifest.ts @@ -6,13 +6,11 @@ https://opensource.org/licenses/MIT. */ -const errors = require('./errors'); -const additionalManifestEntriesTransform = - require('./additional-manifest-entries-transform'); -const maximumSizeTransform = require('./maximum-size-transform'); -const modifyURLPrefixTransform = require('./modify-url-prefix-transform'); -const noRevisionForURLsMatchingTransform = - require('./no-revision-for-urls-matching-transform'); +import errors from './errors'; +import additionalManifestEntriesTransform from './additional-manifest-entries-transform'; +import maximumSizeTransform from './maximum-size-transform'; +import modifyURLPrefixTransform from './modify-url-prefix-transform'; +import noRevisionForURLsMatchingTransform from './no-revision-for-urls-matching-transform'; /** * A `ManifestTransform` function can be used to modify the modify the `url` or @@ -66,7 +64,7 @@ const noRevisionForURLsMatchingTransform = * @memberof module:workbox-build */ -module.exports = async ({ +export default async function ({ additionalManifestEntries, dontCacheBustURLsMatching, fileDetails, @@ -74,7 +72,7 @@ module.exports = async ({ maximumFileSizeToCacheInBytes, modifyURLPrefix, transformParam, -}) => { +}) { let allWarnings = []; // Take the array of fileDetail objects and convert it into an array of diff --git a/packages/workbox-build/src/types.ts b/packages/workbox-build/src/types.ts new file mode 100644 index 000000000..1f34b7657 --- /dev/null +++ b/packages/workbox-build/src/types.ts @@ -0,0 +1,135 @@ +import {BroadcastCacheUpdateOptions} from 'workbox-broadcast-update/BroadcastCacheUpdate'; +import {GoogleAnalyticsInitializeOptions} from 'workbox-google-analytics/initialize'; +import {HTTPMethod} from 'workbox-routing/utils/constants'; +import {QueueOptions} from 'workbox-background-sync/Queue'; +import {RouteHandler, RouteMatchCallback} from 'workbox-core/types'; +import {CacheableResponseOptions} from 'workbox-cacheable-response/CacheableResponse'; +import {ExpirationPluginOptions} from 'workbox-expiration/ExpirationPlugin'; +import {WorkboxPlugin} from 'workbox-core/types'; + +export interface ManifestEntry { + integrity?: string; + revision: string | null; + url: string; +} + +type StrategyName = 'CacheFirst' | 'CacheOnly' | 'NetworkFirst' | 'NetworkOnly' | 'StaleWhileRevalidate'; + +interface RuntimeCaching { + handler: RouteHandler | StrategyName; + method?: HTTPMethod; + options: { + backgroundSync?: { + name: string; + options?: QueueOptions; + }; + broadcastUpdate?: { + // TODO: This option is ignored since we switched to using postMessage(). + // Remove it in the next major release. + channelName?: string; + options: BroadcastCacheUpdateOptions; + }; + cacheableResponse?: CacheableResponseOptions; + cacheName?: string; + expiration?: ExpirationPluginOptions; + networkTimeoutSeconds?: number; + plugins?: Array; + precacheFallback?: { + fallbackURL: string; + }, + fetchOptions: RequestInit; + matchOptions: CacheQueryOptions; + }; + urlPattern: RegExp | string | RouteMatchCallback; +} + +interface BasePartial { + additionalManifestEntries?: Array; + dontCacheBustURLsMatching?: RegExp; + manifestTransforms?: Array<() => {}>; // TODO: Add arity info. + maximumFileSizeToCacheInBytes?: number; + modifyURLPrefix: { + [key: string]: string; + }; +} + +interface GeneratePartial { + babelPresetEnvTargets?: Array; + cacheId?: string; + cleanupOutdatedCaches?: boolean; + clientsClaim?: boolean; + directoryIndex?: string; + disableDevLogs?: boolean; + ignoreURLParametersMatching?: Array; + importScripts?: Array; + inlineWorkboxRuntime?: boolean; + mode?: string; + navigateFallback?: string; + navigateFallbackAllowlist?: Array; + navigateFallbackDenylist?: Array; + navigationPreload?: boolean; + offlineGoogleAnalytics?: boolean | GoogleAnalyticsInitializeOptions; + runtimeCaching: Array; + skipWaiting?: boolean; + sourcemap?: boolean; +} + +export interface GlobPartial { + globDirectory?: string; + globFollow?: boolean; + globIgnores?: Array; + globPatterns?: Array; + globStrict?: boolean; + templatedURLs: { + [key: string]: string | Array; + }; +} + +interface InjectPartial { + injectionPoint?: string; + swSrc: string; +} + +interface WebpackPartial { + chunks?: Array; + exclude?: Array any)>; + excludeChunks?: Array; + include?: Array any)>; + mode?: string; +} + +interface SWDestPartial { + swDest: string; +} + +export type GenerateSWOptions = GlobPartial & GeneratePartial & BasePartial & SWDestPartial; + +export type GetManifestOptions = GlobPartial & BasePartial; + +export type InjectManifestOptions = InjectPartial & GlobPartial & BasePartial & SWDestPartial; + +export type WebpackGenerateSWOptions = WebpackPartial & GeneratePartial & BasePartial & SWDestPartial & { + importScriptsViaChunks: Array; +}; + +export type WebpackInjectManifestOptions = WebpackPartial & InjectPartial & BasePartial & SWDestPartial & { + compileSrc?: boolean; + webpackCompilationPlugins?: Array; +}; + +export interface BuildResult { + count: number, + manifestEntries: Array, + size: number, + warnings: Array +} + +export type BuildResultWithFiles = BuildResult & { + files: Array; +}; + +export interface FileDetails { + file: string; + hash: string; + size: number; +} diff --git a/packages/workbox-expiration/src/ExpirationPlugin.ts b/packages/workbox-expiration/src/ExpirationPlugin.ts index 3a486b7a3..f39eb88fe 100644 --- a/packages/workbox-expiration/src/ExpirationPlugin.ts +++ b/packages/workbox-expiration/src/ExpirationPlugin.ts @@ -19,6 +19,13 @@ import {CacheExpiration} from './CacheExpiration.js'; import './_version.js'; +export interface ExpirationPluginOptions { + maxEntries?: number; + maxAgeSeconds?: number; + matchOptions?: CacheQueryOptions; + purgeOnQuotaError?: boolean; +}; + /** * This plugin can be used in a `workbox-strategy` to regularly enforce a * limit on the age and / or the number of cached requests. @@ -58,12 +65,7 @@ class ExpirationPlugin implements WorkboxPlugin { * @param {boolean} [config.purgeOnQuotaError] Whether to opt this cache in to * automatic deletion if the available storage quota has been exceeded. */ - constructor(config: { - maxEntries?: number; - maxAgeSeconds?: number; - matchOptions?: CacheQueryOptions; - purgeOnQuotaError?: boolean; - } = {}) { + constructor(config: ExpirationPluginOptions = {}) { if (process.env.NODE_ENV !== 'production') { if (!(config.maxEntries || config.maxAgeSeconds)) { throw new WorkboxError('max-entries-or-age-required', { diff --git a/packages/workbox-google-analytics/src/initialize.ts b/packages/workbox-google-analytics/src/initialize.ts index 729eed2bb..5b55e1966 100644 --- a/packages/workbox-google-analytics/src/initialize.ts +++ b/packages/workbox-google-analytics/src/initialize.ts @@ -29,7 +29,7 @@ import { import './_version.js'; -interface GoogleAnalyticsInitializeOptions { +export interface GoogleAnalyticsInitializeOptions { cacheName?: string; parameterOverrides?: {[paramName: string]: string}; hitFilter?: (params: URLSearchParams) => void; From 56c29b0b25a4be48b95023da300909d2eadeabb3 Mon Sep 17 00:00:00 2001 From: Jeff Posnick Date: Wed, 23 Dec 2020 10:26:25 -0500 Subject: [PATCH 02/80] Finished getManifest --- .../src/lib/get-file-manifest-entries.ts | 6 ++---- ...ze-transform.js => maximum-size-transform.ts} | 6 ++++-- ...ansform.js => modify-url-prefix-transform.ts} | 12 ++++++++---- ...> no-revision-for-urls-matching-transform.ts} | 6 ++++-- .../workbox-build/src/lib/transform-manifest.ts | 16 +++++++++++----- packages/workbox-build/src/types.ts | 14 ++++++++++++-- 6 files changed, 41 insertions(+), 19 deletions(-) rename packages/workbox-build/src/lib/{maximum-size-transform.js => maximum-size-transform.ts} (78%) rename packages/workbox-build/src/lib/{modify-url-prefix-transform.js => modify-url-prefix-transform.ts} (86%) rename packages/workbox-build/src/lib/{no-revision-for-urls-matching-transform.js => no-revision-for-urls-matching-transform.ts} (81%) diff --git a/packages/workbox-build/src/lib/get-file-manifest-entries.ts b/packages/workbox-build/src/lib/get-file-manifest-entries.ts index d9a4263f6..0ee1e558d 100644 --- a/packages/workbox-build/src/lib/get-file-manifest-entries.ts +++ b/packages/workbox-build/src/lib/get-file-manifest-entries.ts @@ -98,15 +98,13 @@ export default async function ({ const transformedManifest = await transformManifest({ additionalManifestEntries, dontCacheBustURLsMatching, - fileDetails: allFileDetails, manifestTransforms, maximumFileSizeToCacheInBytes, modifyURLPrefix, + fileDetails: Array.from(allFileDetails.values()), }); - if (warnings.length > 0) { - transformedManifest.warnings.push(...warnings); - } + transformedManifest.warnings.push(...warnings); return transformedManifest; }; diff --git a/packages/workbox-build/src/lib/maximum-size-transform.js b/packages/workbox-build/src/lib/maximum-size-transform.ts similarity index 78% rename from packages/workbox-build/src/lib/maximum-size-transform.js rename to packages/workbox-build/src/lib/maximum-size-transform.ts index 2fc1a9a87..cd98646c6 100644 --- a/packages/workbox-build/src/lib/maximum-size-transform.js +++ b/packages/workbox-build/src/lib/maximum-size-transform.ts @@ -6,9 +6,11 @@ https://opensource.org/licenses/MIT. */ -const prettyBytes = require('pretty-bytes'); +import prettyBytes from 'pretty-bytes'; -module.exports = (maximumFileSizeToCacheInBytes) => { +import {ManifestTransform} from '../types'; + +export default function (maximumFileSizeToCacheInBytes: number): ManifestTransform { return (originalManifest) => { const warnings = []; const manifest = originalManifest.filter((entry) => { diff --git a/packages/workbox-build/src/lib/modify-url-prefix-transform.js b/packages/workbox-build/src/lib/modify-url-prefix-transform.ts similarity index 86% rename from packages/workbox-build/src/lib/modify-url-prefix-transform.js rename to packages/workbox-build/src/lib/modify-url-prefix-transform.ts index 08148d64b..c1c71e004 100644 --- a/packages/workbox-build/src/lib/modify-url-prefix-transform.js +++ b/packages/workbox-build/src/lib/modify-url-prefix-transform.ts @@ -9,7 +9,9 @@ const errors = require('./errors'); const escapeRegExp = require('./escape-regexp'); -module.exports = (modifyURLPrefix) => { +import {ManifestTransform} from '../types'; + +export default function(modifyURLPrefix: {[key: string]: string}): ManifestTransform { if (!modifyURLPrefix || typeof modifyURLPrefix !== 'object' || Array.isArray(modifyURLPrefix)) { @@ -19,14 +21,16 @@ module.exports = (modifyURLPrefix) => { // If there are no entries in modifyURLPrefix, just return an identity // function as a shortcut. if (Object.keys(modifyURLPrefix).length === 0) { - return (entry) => entry; + return (manifest) => { + return {manifest}; + }; } - Object.keys(modifyURLPrefix).forEach((key) => { + for (const key of Object.keys(modifyURLPrefix)) { if (typeof modifyURLPrefix[key] !== 'string') { throw new Error(errors['modify-url-prefix-bad-prefixes']); } - }); + } // Escape the user input so it's safe to use in a regex. const safeModifyURLPrefixes = Object.keys(modifyURLPrefix).map(escapeRegExp); diff --git a/packages/workbox-build/src/lib/no-revision-for-urls-matching-transform.js b/packages/workbox-build/src/lib/no-revision-for-urls-matching-transform.ts similarity index 81% rename from packages/workbox-build/src/lib/no-revision-for-urls-matching-transform.js rename to packages/workbox-build/src/lib/no-revision-for-urls-matching-transform.ts index 0bc21b6d1..563862ea5 100644 --- a/packages/workbox-build/src/lib/no-revision-for-urls-matching-transform.js +++ b/packages/workbox-build/src/lib/no-revision-for-urls-matching-transform.ts @@ -6,9 +6,11 @@ https://opensource.org/licenses/MIT. */ -const errors = require('./errors'); +import errors from './errors'; -module.exports = (regexp) => { +import {ManifestTransform} from '../types'; + +export default function(regexp: RegExp): ManifestTransform { if (!(regexp instanceof RegExp)) { throw new Error(errors['invalid-dont-cache-bust']); } diff --git a/packages/workbox-build/src/lib/transform-manifest.ts b/packages/workbox-build/src/lib/transform-manifest.ts index 477acb074..7830dbe35 100644 --- a/packages/workbox-build/src/lib/transform-manifest.ts +++ b/packages/workbox-build/src/lib/transform-manifest.ts @@ -6,8 +6,9 @@ https://opensource.org/licenses/MIT. */ -import errors from './errors'; +import {BasePartial, FileDetails, ManifestEntry, ManifestTransform} from '../types'; import additionalManifestEntriesTransform from './additional-manifest-entries-transform'; +import errors from './errors'; import maximumSizeTransform from './maximum-size-transform'; import modifyURLPrefixTransform from './modify-url-prefix-transform'; import noRevisionForURLsMatchingTransform from './no-revision-for-urls-matching-transform'; @@ -72,8 +73,13 @@ export default async function ({ maximumFileSizeToCacheInBytes, modifyURLPrefix, transformParam, +}: BasePartial & { + fileDetails: Array; + // When this is called by the webpack plugin, transformParam will be the + // current webpack compilation. + transformParam?: unknown; }) { - let allWarnings = []; + const allWarnings: Array = []; // Take the array of fileDetail objects and convert it into an array of // {url, revision, size} objects, with \ replaced with /. @@ -85,7 +91,7 @@ export default async function ({ }; }); - const transformsToApply = []; + const transformsToApply: Array = []; if (maximumFileSizeToCacheInBytes) { transformsToApply.push(maximumSizeTransform(maximumFileSizeToCacheInBytes)); @@ -119,7 +125,7 @@ export default async function ({ } transformedManifest = result.manifest; - allWarnings = allWarnings.concat(result.warnings || []); + allWarnings.push(...(result.warnings || [])); } // Generate some metadata about the manifest before we clear out the size @@ -134,7 +140,7 @@ export default async function ({ return { count, size, - manifestEntries: transformedManifest, + manifestEntries: transformedManifest as Array, warnings: allWarnings, }; }; diff --git a/packages/workbox-build/src/types.ts b/packages/workbox-build/src/types.ts index 1f34b7657..2ec568724 100644 --- a/packages/workbox-build/src/types.ts +++ b/packages/workbox-build/src/types.ts @@ -43,10 +43,20 @@ interface RuntimeCaching { urlPattern: RegExp | string | RouteMatchCallback; } -interface BasePartial { +export interface ManifestTransformResult { + manifest: Array; + warnings?: Array; +} + +export type ManifestTransform = ( + manifestEntries: Array, + compilation?: unknown +) => Promise | ManifestTransformResult; + +export interface BasePartial { additionalManifestEntries?: Array; dontCacheBustURLsMatching?: RegExp; - manifestTransforms?: Array<() => {}>; // TODO: Add arity info. + manifestTransforms?: Array; maximumFileSizeToCacheInBytes?: number; modifyURLPrefix: { [key: string]: string; From e1f610503041ada3167125ab9eded47ba3d8b8db Mon Sep 17 00:00:00 2001 From: Jeff Posnick Date: Wed, 23 Dec 2020 12:45:32 -0500 Subject: [PATCH 03/80] GenerateSW migrated --- package-lock.json | 596 +----------------- package.json | 2 + .../src/{generate-sw.js => generate-sw.ts} | 20 +- packages/workbox-build/src/get-manifest.ts | 4 +- ...{inject-manifest.js => inject-manifest.ts} | 0 .../src/lib/{bundle.js => bundle.ts} | 48 +- .../src/lib/get-file-manifest-entries.ts | 4 +- ...{module-registry.js => module-registry.ts} | 23 +- ...sw-template.js => populate-sw-template.ts} | 21 +- .../lib/{rebase-path.js => rebase-path.ts} | 9 +- .../workbox-build/src/lib/validate-options.js | 23 - .../workbox-build/src/lib/validate-options.ts | 12 + ....js => write-sw-using-default-template.ts} | 17 +- .../{sw-template.js => sw-template.ts} | 2 +- packages/workbox-build/src/types.ts | 10 +- 15 files changed, 111 insertions(+), 680 deletions(-) rename packages/workbox-build/src/{generate-sw.js => generate-sw.ts} (95%) rename packages/workbox-build/src/{inject-manifest.js => inject-manifest.ts} (100%) rename packages/workbox-build/src/lib/{bundle.js => bundle.ts} (72%) rename packages/workbox-build/src/lib/{module-registry.js => module-registry.ts} (76%) rename packages/workbox-build/src/lib/{populate-sw-template.js => populate-sw-template.ts} (84%) rename packages/workbox-build/src/lib/{rebase-path.js => rebase-path.ts} (82%) delete mode 100644 packages/workbox-build/src/lib/validate-options.js create mode 100644 packages/workbox-build/src/lib/validate-options.ts rename packages/workbox-build/src/lib/{write-sw-using-default-template.js => write-sw-using-default-template.ts} (82%) rename packages/workbox-build/src/templates/{sw-template.js => sw-template.ts} (99%) diff --git a/package-lock.json b/package-lock.json index 89277250c..5e4fb880f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -4158,32 +4158,12 @@ "integrity": "sha512-RbzJvlNzmRq5c3O09UipeuXno4tA1FE6ikOjxZK0tuxVv3412l64l5t1W5pj4+rJq9vpkm/kwiR07aZXnsKPxw==", "dev": true }, - "@types/anymatch": { - "version": "1.3.1", - "resolved": "https://registry.npmjs.org/@types/anymatch/-/anymatch-1.3.1.tgz", - "integrity": "sha512-/+CRPXpBDpo2RK9C68N3b2cOvO0Cf5B9aPijHsoDQTHivnGSObdOF2BRQOYjojWTDy6nQvMjmqRXIxH55VjxxA==", + "@types/common-tags": { + "version": "1.8.0", + "resolved": "https://registry.npmjs.org/@types/common-tags/-/common-tags-1.8.0.tgz", + "integrity": "sha512-htRqZr5qn8EzMelhX/Xmx142z218lLyGaeZ3YR8jlze4TATRU9huKKvuBmAJEW4LCC4pnY1N6JAm6p85fMHjhg==", "dev": true }, - "@types/eslint": { - "version": "7.2.5", - "resolved": "https://registry.npmjs.org/@types/eslint/-/eslint-7.2.5.tgz", - "integrity": "sha512-Dc6ar9x16BdaR3NSxSF7T4IjL9gxxViJq8RmFd+2UAyA+K6ck2W+gUwfgpG/y9TPyUuBL35109bbULpEynvltA==", - "dev": true, - "requires": { - "@types/estree": "*", - "@types/json-schema": "*" - } - }, - "@types/eslint-scope": { - "version": "3.7.0", - "resolved": "https://registry.npmjs.org/@types/eslint-scope/-/eslint-scope-3.7.0.tgz", - "integrity": "sha512-O/ql2+rrCUe2W2rs7wMR+GqPRcgB6UiqN5RhrR5xruFlY7l9YLMn0ZkDzjoHLeiFkR8MCQZVudUuuvQ2BLC9Qw==", - "dev": true, - "requires": { - "@types/eslint": "*", - "@types/estree": "*" - } - }, "@types/eslint-visitor-keys": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/@types/eslint-visitor-keys/-/eslint-visitor-keys-1.0.0.tgz", @@ -4215,18 +4195,18 @@ "@types/node": "*" } }, - "@types/html-minifier-terser": { - "version": "5.1.1", - "resolved": "https://registry.npmjs.org/@types/html-minifier-terser/-/html-minifier-terser-5.1.1.tgz", - "integrity": "sha512-giAlZwstKbmvMk1OO7WXSj4OZ0keXAcl2TQq4LWHiiPH2ByaH7WeUzng+Qej8UPxxv+8lRTuouo0iaNDBuzIBA==", - "dev": true - }, "@types/json-schema": { "version": "7.0.6", "resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.6.tgz", "integrity": "sha512-3c+yGKvVP5Y9TYBEibGNR+kLtijnj7mYrXRg+WpFb2X9xm04g/DXYkfg4hmzJQosc9snFNUPkbYIhu+KAm6jJw==", "dev": true }, + "@types/lodash": { + "version": "4.14.165", + "resolved": "https://registry.npmjs.org/@types/lodash/-/lodash-4.14.165.tgz", + "integrity": "sha512-tjSSOTHhI5mCHTy/OOXYIhi2Wt1qcbHmuXD1Ha7q70CgI/I71afO4XtLb/cVexki1oVYchpul/TOuu3Arcdxrg==", + "dev": true + }, "@types/minimatch": { "version": "3.0.3", "resolved": "https://registry.npmjs.org/@types/minimatch/-/minimatch-3.0.3.tgz", @@ -4266,76 +4246,6 @@ "@types/node": "*" } }, - "@types/source-list-map": { - "version": "0.1.2", - "resolved": "https://registry.npmjs.org/@types/source-list-map/-/source-list-map-0.1.2.tgz", - "integrity": "sha512-K5K+yml8LTo9bWJI/rECfIPrGgxdpeNbj+d53lwN4QjW1MCwlkhUms+gtdzigTeUyBr09+u8BwOIY3MXvHdcsA==", - "dev": true - }, - "@types/tapable": { - "version": "1.0.6", - "resolved": "https://registry.npmjs.org/@types/tapable/-/tapable-1.0.6.tgz", - "integrity": "sha512-W+bw9ds02rAQaMvaLYxAbJ6cvguW/iJXNT6lTssS1ps6QdrMKttqEAMEG/b5CR8TZl3/L7/lH0ZV5nNR1LXikA==", - "dev": true - }, - "@types/uglify-js": { - "version": "3.11.1", - "resolved": "https://registry.npmjs.org/@types/uglify-js/-/uglify-js-3.11.1.tgz", - "integrity": "sha512-7npvPKV+jINLu1SpSYVWG8KvyJBhBa8tmzMMdDoVc2pWUYHN8KIXlPJhjJ4LT97c4dXJA2SHL/q6ADbDriZN+Q==", - "dev": true, - "requires": { - "source-map": "^0.6.1" - }, - "dependencies": { - "source-map": { - "version": "0.6.1", - "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", - "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", - "dev": true - } - } - }, - "@types/webpack": { - "version": "4.41.25", - "resolved": "https://registry.npmjs.org/@types/webpack/-/webpack-4.41.25.tgz", - "integrity": "sha512-cr6kZ+4m9lp86ytQc1jPOJXgINQyz3kLLunZ57jznW+WIAL0JqZbGubQk4GlD42MuQL5JGOABrxdpqqWeovlVQ==", - "dev": true, - "requires": { - "@types/anymatch": "*", - "@types/node": "*", - "@types/tapable": "*", - "@types/uglify-js": "*", - "@types/webpack-sources": "*", - "source-map": "^0.6.0" - }, - "dependencies": { - "source-map": { - "version": "0.6.1", - "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", - "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", - "dev": true - } - } - }, - "@types/webpack-sources": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/@types/webpack-sources/-/webpack-sources-2.0.0.tgz", - "integrity": "sha512-a5kPx98CNFRKQ+wqawroFunvFqv7GHm/3KOI52NY9xWADgc8smu4R6prt4EU/M4QfVjvgBkMqU4fBhw3QfMVkg==", - "dev": true, - "requires": { - "@types/node": "*", - "@types/source-list-map": "*", - "source-map": "^0.7.3" - }, - "dependencies": { - "source-map": { - "version": "0.7.3", - "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.7.3.tgz", - "integrity": "sha512-CkCj6giN3S+n9qrYiBTX5gystlENnRW5jZeNLHpe6aue+SrHcG5VYwujhW9s4dY31mEGsxBDrHR6oI69fTXsaQ==", - "dev": true - } - } - }, "@typescript-eslint/eslint-plugin": { "version": "2.34.0", "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-2.34.0.tgz", @@ -5373,12 +5283,6 @@ "type-is": "~1.6.17" } }, - "boolbase": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/boolbase/-/boolbase-1.0.0.tgz", - "integrity": "sha1-aN/1++YMUes3cl6p4+0xDcwed24=", - "dev": true - }, "brace-expansion": { "version": "1.1.11", "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", @@ -5726,16 +5630,6 @@ "integrity": "sha512-P8BjAsXvZS+VIDUI11hHCQEv74YT67YUi5JJFNWIqL235sBmjX4+qx9Muvls5ivyNENctx46xQLQ3aTuE7ssaQ==", "dev": true }, - "camel-case": { - "version": "4.1.1", - "resolved": "https://registry.npmjs.org/camel-case/-/camel-case-4.1.1.tgz", - "integrity": "sha512-7fa2WcG4fYFkclIvEmxBbTvmibwF2/agfEBc6q3lOpVu0A13ltLsA+Hr/8Hp6kp5f+G7hKi6t8lys6XxP+1K6Q==", - "dev": true, - "requires": { - "pascal-case": "^3.1.1", - "tslib": "^1.10.0" - } - }, "camelcase": { "version": "6.1.0", "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-6.1.0.tgz", @@ -6033,23 +5927,6 @@ } } }, - "clean-css": { - "version": "4.2.3", - "resolved": "https://registry.npmjs.org/clean-css/-/clean-css-4.2.3.tgz", - "integrity": "sha512-VcMWDN54ZN/DS+g58HYL5/n4Zrqe8vHJpGA8KdgUXFU4fuP/aHNw8eld9SyEIyabIMJX/0RaY/fplOo5hYLSFA==", - "dev": true, - "requires": { - "source-map": "~0.6.0" - }, - "dependencies": { - "source-map": { - "version": "0.6.1", - "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", - "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", - "dev": true - } - } - }, "clean-stack": { "version": "2.2.0", "resolved": "https://registry.npmjs.org/clean-stack/-/clean-stack-2.2.0.tgz", @@ -7080,24 +6957,6 @@ "integrity": "sha512-v1plID3y9r/lPhviJ1wrXpLeyUIGAZ2SHNYTEapm7/8A9nLPoyvVp3RK/EPFqn5kEznyWgYZNsRtYYIWbuG8KA==", "dev": true }, - "css-select": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/css-select/-/css-select-1.2.0.tgz", - "integrity": "sha1-KzoRBTnFNV8c2NMUYj6HCxIeyFg=", - "dev": true, - "requires": { - "boolbase": "~1.0.0", - "css-what": "2.1", - "domutils": "1.5.1", - "nth-check": "~1.0.1" - } - }, - "css-what": { - "version": "2.1.3", - "resolved": "https://registry.npmjs.org/css-what/-/css-what-2.1.3.tgz", - "integrity": "sha512-a+EPoD+uZiNfh+5fxw2nO9QwFa6nJe2Or35fGY6Ipw1R3R4AGz1d1TEZrCegvw2YTmZ0jXirGYlzxxpYSHwpEg==", - "dev": true - }, "currently-unhandled": { "version": "0.4.1", "resolved": "https://registry.npmjs.org/currently-unhandled/-/currently-unhandled-0.4.1.tgz", @@ -7564,33 +7423,6 @@ "esutils": "^2.0.2" } }, - "dom-converter": { - "version": "0.2.0", - "resolved": "https://registry.npmjs.org/dom-converter/-/dom-converter-0.2.0.tgz", - "integrity": "sha512-gd3ypIPfOMr9h5jIKq8E3sHOTCjeirnl0WK5ZdS1AW0Odt0b1PaWaHdJ4Qk4klv+YB9aJBS7mESXjFoDQPu6DA==", - "dev": true, - "requires": { - "utila": "~0.4" - } - }, - "dom-serializer": { - "version": "0.2.2", - "resolved": "https://registry.npmjs.org/dom-serializer/-/dom-serializer-0.2.2.tgz", - "integrity": "sha512-2/xPb3ORsQ42nHYiSunXkDjPLBaEj/xTwUO4B7XCZQTRk7EBtTOPaygh10YAAh2OI1Qrp6NWfpAhzswj0ydt9g==", - "dev": true, - "requires": { - "domelementtype": "^2.0.1", - "entities": "^2.0.0" - }, - "dependencies": { - "domelementtype": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/domelementtype/-/domelementtype-2.0.2.tgz", - "integrity": "sha512-wFwTwCVebUrMgGeAwRL/NhZtHAUyT9n9yg4IMDwf10+6iCMxSkVq9MGCVEH+QZWo1nNidy8kNvwmv4zWHDTqvA==", - "dev": true - } - } - }, "dom-urls": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/dom-urls/-/dom-urls-1.1.0.tgz", @@ -7606,41 +7438,6 @@ "integrity": "sha512-jnjyiM6eRyZl2H+W8Q/zLMA481hzi0eszAaBUzIVnmYVDBbnLxVNnfu1HgEBvCbL+71FrxMl3E6lpKH7Ge3OXA==", "dev": true }, - "domelementtype": { - "version": "1.3.1", - "resolved": "https://registry.npmjs.org/domelementtype/-/domelementtype-1.3.1.tgz", - "integrity": "sha512-BSKB+TSpMpFI/HOxCNr1O8aMOTZ8hT3pM3GQ0w/mWRmkhEDSFJkkyzz4XQsBV44BChwGkrDfMyjVD0eA2aFV3w==", - "dev": true - }, - "domhandler": { - "version": "2.4.2", - "resolved": "https://registry.npmjs.org/domhandler/-/domhandler-2.4.2.tgz", - "integrity": "sha512-JiK04h0Ht5u/80fdLMCEmV4zkNh2BcoMFBmZ/91WtYZ8qVXSKjiw7fXMgFPnHcSZgOo3XdinHvmnDUeMf5R4wA==", - "dev": true, - "requires": { - "domelementtype": "1" - } - }, - "domutils": { - "version": "1.5.1", - "resolved": "https://registry.npmjs.org/domutils/-/domutils-1.5.1.tgz", - "integrity": "sha1-3NhIiib1Y9YQeeSMn3t+Mjc2gs8=", - "dev": true, - "requires": { - "dom-serializer": "0", - "domelementtype": "1" - } - }, - "dot-case": { - "version": "3.0.3", - "resolved": "https://registry.npmjs.org/dot-case/-/dot-case-3.0.3.tgz", - "integrity": "sha512-7hwEmg6RiSQfm/GwPL4AAWXKy3YNNZA3oFv2Pdiey0mwkRCPZ9x6SZbkLcn8Ma5PYeVokzoD4Twv2n7LKp5WeA==", - "dev": true, - "requires": { - "no-case": "^3.0.3", - "tslib": "^1.10.0" - } - }, "dot-prop": { "version": "5.3.0", "resolved": "https://registry.npmjs.org/dot-prop/-/dot-prop-5.3.0.tgz", @@ -10544,116 +10341,6 @@ "integrity": "sha512-H2iMtd0I4Mt5eYiapRdIDjp+XzelXQ0tFE4JS7YFwFevXXMmOp9myNrUvCg0D6ws8iqkRPBfKHgbwig1SmlLfg==", "dev": true }, - "html-minifier-terser": { - "version": "5.1.1", - "resolved": "https://registry.npmjs.org/html-minifier-terser/-/html-minifier-terser-5.1.1.tgz", - "integrity": "sha512-ZPr5MNObqnV/T9akshPKbVgyOqLmy+Bxo7juKCfTfnjNniTAMdy4hz21YQqoofMBJD2kdREaqPPdThoR78Tgxg==", - "dev": true, - "requires": { - "camel-case": "^4.1.1", - "clean-css": "^4.2.3", - "commander": "^4.1.1", - "he": "^1.2.0", - "param-case": "^3.0.3", - "relateurl": "^0.2.7", - "terser": "^4.6.3" - } - }, - "html-webpack-plugin-v4": { - "version": "npm:html-webpack-plugin@4.5.0", - "resolved": "https://registry.npmjs.org/html-webpack-plugin/-/html-webpack-plugin-4.5.0.tgz", - "integrity": "sha512-MouoXEYSjTzCrjIxWwg8gxL5fE2X2WZJLmBYXlaJhQUH5K/b5OrqmV7T4dB7iu0xkmJ6JlUuV6fFVtnqbPopZw==", - "dev": true, - "requires": { - "@types/html-minifier-terser": "^5.0.0", - "@types/tapable": "^1.0.5", - "@types/webpack": "^4.41.8", - "html-minifier-terser": "^5.0.1", - "loader-utils": "^1.2.3", - "lodash": "^4.17.15", - "pretty-error": "^2.1.1", - "tapable": "^1.1.3", - "util.promisify": "1.0.0" - }, - "dependencies": { - "json5": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/json5/-/json5-1.0.1.tgz", - "integrity": "sha512-aKS4WQjPenRxiQsC93MNfjx+nbF4PAdYzmd/1JIj8HYzqfbu86beTuNgXDzPknWk0n0uARlyewZo4s++ES36Ow==", - "dev": true, - "requires": { - "minimist": "^1.2.0" - } - }, - "loader-utils": { - "version": "1.4.0", - "resolved": "https://registry.npmjs.org/loader-utils/-/loader-utils-1.4.0.tgz", - "integrity": "sha512-qH0WSMBtn/oHuwjy/NucEgbx5dbxxnxup9s4PVXJUDHZBQY+s0NWA9rJf53RBnQZxfch7euUui7hpoAPvALZdA==", - "dev": true, - "requires": { - "big.js": "^5.2.2", - "emojis-list": "^3.0.0", - "json5": "^1.0.1" - } - } - } - }, - "html-webpack-plugin-v5": { - "version": "npm:html-webpack-plugin@5.0.0-alpha.14", - "resolved": "https://registry.npmjs.org/html-webpack-plugin/-/html-webpack-plugin-5.0.0-alpha.14.tgz", - "integrity": "sha512-7x3KICFD+9060txBWkNsBNIuA+/4VM9pprmlExTEnGysBPzolrnhIZEOc0MkWt8Xiv478l9FiqkfVP5EfN+wzw==", - "dev": true, - "requires": { - "@types/html-minifier-terser": "^5.0.0", - "@types/tapable": "^1.0.5", - "html-minifier-terser": "^5.0.1", - "loader-utils": "2.0.0", - "lodash": "^4.17.20", - "pretty-error": "^2.1.1", - "tapable": "2.0.0" - }, - "dependencies": { - "tapable": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/tapable/-/tapable-2.0.0.tgz", - "integrity": "sha512-bjzn0C0RWoffnNdTzNi7rNDhs1Zlwk2tRXgk8EiHKAOX1Mag3d6T0Y5zNa7l9CJ+EoUne/0UHdwS8tMbkh9zDg==", - "dev": true - } - } - }, - "htmlparser2": { - "version": "3.10.1", - "resolved": "https://registry.npmjs.org/htmlparser2/-/htmlparser2-3.10.1.tgz", - "integrity": "sha512-IgieNijUMbkDovyoKObU1DUhm1iwNYE/fuifEoEHfd1oZKZDaONBSkal7Y01shxsM49R4XaMdGez3WnF9UfiCQ==", - "dev": true, - "requires": { - "domelementtype": "^1.3.1", - "domhandler": "^2.3.0", - "domutils": "^1.5.1", - "entities": "^1.1.1", - "inherits": "^2.0.1", - "readable-stream": "^3.1.1" - }, - "dependencies": { - "entities": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/entities/-/entities-1.1.2.tgz", - "integrity": "sha512-f2LZMYl1Fzu7YSBKg+RoROelpOaNrcGmE9AZubeDfrCEia483oW4MI4VyFd5VNHIgQ/7qm1I0wUHK1eJnn2y2w==", - "dev": true - }, - "readable-stream": { - "version": "3.6.0", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.0.tgz", - "integrity": "sha512-BViHy7LKeTz4oNnkcLJ+lVSL6vpiFeX6/d3oSH8zCW7UxP2onchk+vTGB143xuFjHS3deTgkKoXXymXqymiIdA==", - "dev": true, - "requires": { - "inherits": "^2.0.3", - "string_decoder": "^1.1.1", - "util-deprecate": "^1.0.1" - } - } - } - }, "http-cache-semantics": { "version": "3.8.1", "resolved": "https://registry.npmjs.org/http-cache-semantics/-/http-cache-semantics-3.8.1.tgz", @@ -12289,15 +11976,6 @@ "signal-exit": "^3.0.0" } }, - "lower-case": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/lower-case/-/lower-case-2.0.1.tgz", - "integrity": "sha512-LiWgfDLLb1dwbFQZsSglpRj+1ctGnayXz3Uv0/WO8n558JycT5fg6zkNcnW0G68Nn0aEldTFeEfmjCfmqry/rQ==", - "dev": true, - "requires": { - "tslib": "^1.10.0" - } - }, "lru-cache": { "version": "6.0.0", "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", @@ -13541,16 +13219,6 @@ } } }, - "no-case": { - "version": "3.0.3", - "resolved": "https://registry.npmjs.org/no-case/-/no-case-3.0.3.tgz", - "integrity": "sha512-ehY/mVQCf9BL0gKfsJBvFJen+1V//U+0HQMPrWct40ixE4jnv0bfvxDbWtAHL9EcaPEOJHVVYKoQn1TlZUB8Tw==", - "dev": true, - "requires": { - "lower-case": "^2.0.1", - "tslib": "^1.10.0" - } - }, "node-fetch": { "version": "2.6.1", "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.1.tgz", @@ -13920,15 +13588,6 @@ "set-blocking": "~2.0.0" } }, - "nth-check": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/nth-check/-/nth-check-1.0.2.tgz", - "integrity": "sha512-WeBOdju8SnzPN5vTUJYxYUxLeXpCaVP5i5e0LF8fg7WORF2Wd7wFX/pk0tYZk7s8T+J7VLy0Da6J1+wCT0AtHg==", - "dev": true, - "requires": { - "boolbase": "~1.0.0" - } - }, "number-is-nan": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/number-is-nan/-/number-is-nan-1.0.1.tgz", @@ -14391,16 +14050,6 @@ "readable-stream": "^2.1.5" } }, - "param-case": { - "version": "3.0.3", - "resolved": "https://registry.npmjs.org/param-case/-/param-case-3.0.3.tgz", - "integrity": "sha512-VWBVyimc1+QrzappRs7waeN2YmoZFCGXWASRYX1/rGHtXqEcrGEIDm+jqIwFa2fRXNgQEwrxaYuIrX0WcAguTA==", - "dev": true, - "requires": { - "dot-case": "^3.0.3", - "tslib": "^1.10.0" - } - }, "parent-module": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/parent-module/-/parent-module-2.0.0.tgz", @@ -14492,16 +14141,6 @@ "integrity": "sha512-CiyeOxFT/JZyN5m0z9PfXw4SCBJ6Sygz1Dpl0wqjlhDEGGBP1GnsUVEL0p63hoG1fcj3fHynXi9NYO4nWOL+qQ==", "dev": true }, - "pascal-case": { - "version": "3.1.1", - "resolved": "https://registry.npmjs.org/pascal-case/-/pascal-case-3.1.1.tgz", - "integrity": "sha512-XIeHKqIrsquVTQL2crjq3NfJUxmdLasn3TYOU0VBM+UX2a6ztAWBlJQBePLGY7VHW8+2dRadeIPK5+KImwTxQA==", - "dev": true, - "requires": { - "no-case": "^3.0.3", - "tslib": "^1.10.0" - } - }, "pascalcase": { "version": "0.1.1", "resolved": "https://registry.npmjs.org/pascalcase/-/pascalcase-0.1.1.tgz", @@ -14659,16 +14298,6 @@ "integrity": "sha512-vkcDPrRZo1QZLbn5RLGPpg/WmIQ65qoWWhcGKf/b5eplkkarX0m9z8ppCat4mlOqUsWpyNuYgO3VRyrYHSzX5g==", "dev": true }, - "pretty-error": { - "version": "2.1.2", - "resolved": "https://registry.npmjs.org/pretty-error/-/pretty-error-2.1.2.tgz", - "integrity": "sha512-EY5oDzmsX5wvuynAByrmY0P0hcp+QpnAKbJng2A2MPjVKXCxrDSUkzghVJ4ZGPIv+JC4gX8fPUWscC0RtjsWGw==", - "dev": true, - "requires": { - "lodash": "^4.17.20", - "renderkid": "^2.0.4" - } - }, "pretty-hrtime": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/pretty-hrtime/-/pretty-hrtime-1.0.3.tgz", @@ -15210,12 +14839,6 @@ } } }, - "relateurl": { - "version": "0.2.7", - "resolved": "https://registry.npmjs.org/relateurl/-/relateurl-0.2.7.tgz", - "integrity": "sha1-VNvzd+UUQKypCkzSdGANP/LYiKk=", - "dev": true - }, "release-zalgo": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/release-zalgo/-/release-zalgo-1.0.0.tgz", @@ -15252,36 +14875,6 @@ "integrity": "sha1-wkvOKig62tW8P1jg1IJJuSN52O8=", "dev": true }, - "renderkid": { - "version": "2.0.4", - "resolved": "https://registry.npmjs.org/renderkid/-/renderkid-2.0.4.tgz", - "integrity": "sha512-K2eXrSOJdq+HuKzlcjOlGoOarUu5SDguDEhE7+Ah4zuOWL40j8A/oHvLlLob9PSTNvVnBd+/q0Er1QfpEuem5g==", - "dev": true, - "requires": { - "css-select": "^1.1.0", - "dom-converter": "^0.2", - "htmlparser2": "^3.3.0", - "lodash": "^4.17.20", - "strip-ansi": "^3.0.0" - }, - "dependencies": { - "ansi-regex": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz", - "integrity": "sha1-w7M6te42DYbg5ijwRorn7yfWVN8=", - "dev": true - }, - "strip-ansi": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", - "integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=", - "dev": true, - "requires": { - "ansi-regex": "^2.0.0" - } - } - } - }, "repeat-element": { "version": "1.1.3", "resolved": "https://registry.npmjs.org/repeat-element/-/repeat-element-1.1.3.tgz", @@ -17710,22 +17303,6 @@ "object.getownpropertydescriptors": "^2.0.3" } }, - "util.promisify": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/util.promisify/-/util.promisify-1.0.0.tgz", - "integrity": "sha512-i+6qA2MPhvoKLuxnJNpXAGhg7HphQOSUq2LKMZD0m15EiskXUkMvKdF4Uui0WYeCUGea+o2cw/ZuwehtfsrNkA==", - "dev": true, - "requires": { - "define-properties": "^1.1.2", - "object.getownpropertydescriptors": "^2.0.3" - } - }, - "utila": { - "version": "0.4.0", - "resolved": "https://registry.npmjs.org/utila/-/utila-0.4.0.tgz", - "integrity": "sha1-ihagXURWV6Oupe7MWxKk+lN5dyw=", - "dev": true - }, "utils-merge": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/utils-merge/-/utils-merge-1.0.1.tgz", @@ -18076,159 +17653,6 @@ } } }, - "webpack-v5": { - "version": "npm:webpack@5.9.0", - "resolved": "https://registry.npmjs.org/webpack/-/webpack-5.9.0.tgz", - "integrity": "sha512-YnnqIV/uAS5ZrNpctSv378qV7HmbJ74DL+XfvMxzbX1bV9e7eeT6eEWU4wuUw33CNr/HspBh7R/xQlVjTEyAeA==", - "dev": true, - "requires": { - "@types/eslint-scope": "^3.7.0", - "@types/estree": "^0.0.45", - "@webassemblyjs/ast": "1.9.0", - "@webassemblyjs/helper-module-context": "1.9.0", - "@webassemblyjs/wasm-edit": "1.9.0", - "@webassemblyjs/wasm-parser": "1.9.0", - "acorn": "^8.0.4", - "browserslist": "^4.14.5", - "chrome-trace-event": "^1.0.2", - "enhanced-resolve": "^5.3.1", - "eslint-scope": "^5.1.1", - "events": "^3.2.0", - "glob-to-regexp": "^0.4.1", - "graceful-fs": "^4.2.4", - "json-parse-better-errors": "^1.0.2", - "loader-runner": "^4.1.0", - "mime-types": "^2.1.27", - "neo-async": "^2.6.2", - "pkg-dir": "^4.2.0", - "schema-utils": "^3.0.0", - "tapable": "^2.1.1", - "terser-webpack-plugin": "^5.0.3", - "watchpack": "^2.0.0", - "webpack-sources": "^2.1.1" - }, - "dependencies": { - "commander": { - "version": "2.20.3", - "resolved": "https://registry.npmjs.org/commander/-/commander-2.20.3.tgz", - "integrity": "sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==", - "dev": true - }, - "enhanced-resolve": { - "version": "5.3.2", - "resolved": "https://registry.npmjs.org/enhanced-resolve/-/enhanced-resolve-5.3.2.tgz", - "integrity": "sha512-G28GCrglCAH6+EqMN2D+Q2wCUS1O1vVQJBn8ME2I/Api41YBe4vLWWRBOUbwDH7vwzSZdljxwTRVqnf+sm6XqQ==", - "dev": true, - "requires": { - "graceful-fs": "^4.2.4", - "tapable": "^2.0.0" - } - }, - "glob-to-regexp": { - "version": "0.4.1", - "resolved": "https://registry.npmjs.org/glob-to-regexp/-/glob-to-regexp-0.4.1.tgz", - "integrity": "sha512-lkX1HJXwyMcprw/5YUZc2s7DrpAiHB21/V+E1rHUrVNokkvB6bqMzT0VfV6/86ZNabt1k14YOIaT7nDvOX3Iiw==", - "dev": true - }, - "has-flag": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", - "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", - "dev": true - }, - "jest-worker": { - "version": "26.6.2", - "resolved": "https://registry.npmjs.org/jest-worker/-/jest-worker-26.6.2.tgz", - "integrity": "sha512-KWYVV1c4i+jbMpaBC+U++4Va0cp8OisU185o73T1vo99hqi7w8tSJfUXYswwqqrjzwxa6KpRK54WhPvwf5w6PQ==", - "dev": true, - "requires": { - "@types/node": "*", - "merge-stream": "^2.0.0", - "supports-color": "^7.0.0" - } - }, - "loader-runner": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/loader-runner/-/loader-runner-4.1.0.tgz", - "integrity": "sha512-oR4lB4WvwFoC70ocraKhn5nkKSs23t57h9udUgw8o0iH8hMXeEoRuUgfcvgUwAJ1ZpRqBvcou4N2SMvM1DwMrA==", - "dev": true - }, - "source-map": { - "version": "0.6.1", - "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", - "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", - "dev": true - }, - "supports-color": { - "version": "7.2.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", - "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", - "dev": true, - "requires": { - "has-flag": "^4.0.0" - } - }, - "tapable": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/tapable/-/tapable-2.1.1.tgz", - "integrity": "sha512-Wib1S8m2wdpLbmQz0RBEVosIyvb/ykfKXf3ZIDqvWoMg/zTNm6G/tDSuUM61J1kNCDXWJrLHGSFeMhAG+gAGpQ==", - "dev": true - }, - "terser": { - "version": "5.5.1", - "resolved": "https://registry.npmjs.org/terser/-/terser-5.5.1.tgz", - "integrity": "sha512-6VGWZNVP2KTUcltUQJ25TtNjx/XgdDsBDKGt8nN0MpydU36LmbPPcMBd2kmtZNNGVVDLg44k7GKeHHj+4zPIBQ==", - "dev": true, - "requires": { - "commander": "^2.20.0", - "source-map": "~0.7.2", - "source-map-support": "~0.5.19" - }, - "dependencies": { - "source-map": { - "version": "0.7.3", - "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.7.3.tgz", - "integrity": "sha512-CkCj6giN3S+n9qrYiBTX5gystlENnRW5jZeNLHpe6aue+SrHcG5VYwujhW9s4dY31mEGsxBDrHR6oI69fTXsaQ==", - "dev": true - } - } - }, - "terser-webpack-plugin": { - "version": "5.0.3", - "resolved": "https://registry.npmjs.org/terser-webpack-plugin/-/terser-webpack-plugin-5.0.3.tgz", - "integrity": "sha512-zFdGk8Lh9ZJGPxxPE6jwysOlATWB8GMW8HcfGULWA/nPal+3VdATflQvSBSLQJRCmYZnfFJl6vkRTiwJGNgPiQ==", - "dev": true, - "requires": { - "jest-worker": "^26.6.1", - "p-limit": "^3.0.2", - "schema-utils": "^3.0.0", - "serialize-javascript": "^5.0.1", - "source-map": "^0.6.1", - "terser": "^5.3.8" - } - }, - "watchpack": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/watchpack/-/watchpack-2.0.1.tgz", - "integrity": "sha512-vO8AKGX22ZRo6PiOFM9dC0re8IcKh8Kd/aH2zeqUc6w4/jBGlTy2P7fTC6ekT0NjVeGjgU2dGC5rNstKkeLEQg==", - "dev": true, - "requires": { - "glob-to-regexp": "^0.4.1", - "graceful-fs": "^4.1.2" - } - }, - "webpack-sources": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/webpack-sources/-/webpack-sources-2.2.0.tgz", - "integrity": "sha512-bQsA24JLwcnWGArOKUxYKhX3Mz/nK1Xf6hxullKERyktjNMC4x8koOeaDNTA2fEJ09BdWLbM/iTW0ithREUP0w==", - "dev": true, - "requires": { - "source-list-map": "^2.0.1", - "source-map": "^0.6.1" - } - } - } - }, "whatwg-url": { "version": "7.1.0", "resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-7.1.0.tgz", diff --git a/package.json b/package.json index 230c0e797..160d6edcc 100644 --- a/package.json +++ b/package.json @@ -48,8 +48,10 @@ "@rollup/plugin-multi-entry": "^4.0.0", "@rollup/plugin-node-resolve": "^9.0.0", "@rollup/plugin-replace": "^2.3.3", + "@types/common-tags": "^1.8.0", "@types/estree": "0.0.45", "@types/fs-extra": "^9.0.5", + "@types/lodash": "^4.14.165", "@typescript-eslint/eslint-plugin": "^2.30.0", "@typescript-eslint/parser": "^2.30.0", "acorn": "^8.0.1", diff --git a/packages/workbox-build/src/generate-sw.js b/packages/workbox-build/src/generate-sw.ts similarity index 95% rename from packages/workbox-build/src/generate-sw.js rename to packages/workbox-build/src/generate-sw.ts index 1a60808f1..9fc4e516e 100644 --- a/packages/workbox-build/src/generate-sw.js +++ b/packages/workbox-build/src/generate-sw.ts @@ -6,14 +6,14 @@ https://opensource.org/licenses/MIT. */ -const upath = require('upath'); +import upath from 'upath'; -const generateSWSchema = require('./options/schema/generate-sw'); -const getFileManifestEntries = require('./lib/get-file-manifest-entries'); -const rebasePath = require('./lib/rebase-path'); -const validate = require('./lib/validate-options'); -const writeServiceWorkerUsingDefaultTemplate = - require('./lib/write-sw-using-default-template'); +import {BuildResult, GenerateSWOptions} from './types'; +import generateSWSchema from './options/schema/generate-sw'; +import getFileManifestEntries from './lib/get-file-manifest-entries'; +import rebasePath from './lib/rebase-path'; +import validate from './lib/validate-options'; +import writeServiceWorkerUsingDefaultTemplate from './lib/write-sw-using-default-template'; // eslint-disable-next-line jsdoc/newline-after-description /** @@ -194,8 +194,8 @@ const writeServiceWorkerUsingDefaultTemplate = * * @memberof module:workbox-build */ -async function generateSW(config) { - const options = validate(config, generateSWSchema); +export async function generateSW(config: GenerateSWOptions): Promise { + const options: GenerateSWOptions = validate(config, generateSWSchema); if (options.globDirectory) { // Make sure we leave swDest out of the precache manifest. @@ -225,5 +225,3 @@ async function generateSW(config) { return {count, filePaths, size, warnings}; } - -module.exports = generateSW; diff --git a/packages/workbox-build/src/get-manifest.ts b/packages/workbox-build/src/get-manifest.ts index 559c31135..896522aea 100644 --- a/packages/workbox-build/src/get-manifest.ts +++ b/packages/workbox-build/src/get-manifest.ts @@ -6,7 +6,7 @@ https://opensource.org/licenses/MIT. */ -import {BuildResult, GetManifestOptions} from './types'; +import {GetManifestResult, GetManifestOptions} from './types'; import getFileManifestEntries from './lib/get-file-manifest-entries'; import getManifestSchema from './options/schema/get-manifest'; import validate from './lib/validate-options'; @@ -89,7 +89,7 @@ import validate from './lib/validate-options'; * * @memberof module:workbox-build */ -export async function getManifest(config: GetManifestOptions): Promise { +export async function getManifest(config: GetManifestOptions): Promise { const options: GetManifestOptions = validate(config, getManifestSchema); return await getFileManifestEntries(options); diff --git a/packages/workbox-build/src/inject-manifest.js b/packages/workbox-build/src/inject-manifest.ts similarity index 100% rename from packages/workbox-build/src/inject-manifest.js rename to packages/workbox-build/src/inject-manifest.ts diff --git a/packages/workbox-build/src/lib/bundle.js b/packages/workbox-build/src/lib/bundle.ts similarity index 72% rename from packages/workbox-build/src/lib/bundle.js rename to packages/workbox-build/src/lib/bundle.ts index 28c163f3f..36b0a161a 100644 --- a/packages/workbox-build/src/lib/bundle.js +++ b/packages/workbox-build/src/lib/bundle.ts @@ -6,25 +6,32 @@ https://opensource.org/licenses/MIT. */ -const {babel} = require('@rollup/plugin-babel'); -const {nodeResolve} = require('@rollup/plugin-node-resolve'); -const {rollup} = require('rollup'); -const {terser} = require('rollup-plugin-terser'); -const {writeFile} = require('fs-extra'); -const omt = require('@surma/rollup-plugin-off-main-thread'); -const presetEnv = require('@babel/preset-env'); -const replace = require('@rollup/plugin-replace'); -const tempy = require('tempy'); -const upath = require('upath'); - -module.exports = async ({ +import {babel} from '@rollup/plugin-babel'; +import {nodeResolve} from '@rollup/plugin-node-resolve'; +import {rollup, Plugin} from 'rollup'; +import {terser} from 'rollup-plugin-terser'; +import {writeFile} from 'fs-extra'; +import omt from '@surma/rollup-plugin-off-main-thread'; +import presetEnv from '@babel/preset-env'; +import replace from '@rollup/plugin-replace'; +import tempy from 'tempy'; +import upath from 'upath'; + +import {GeneratePartial, SWDestPartial} from '../types'; + +interface NameAndContents { + contents: string | Uint8Array; + name: string +} + +export default async function({ babelPresetEnvTargets, inlineWorkboxRuntime, mode, sourcemap, swDest, unbundledCode, -}) => { +}: Omit & SWDestPartial & {unbundledCode: string}): Promise> { // We need to write this to the "real" file system, as Rollup won't read from // a custom file system. const {dir, base} = upath.parse(swDest); @@ -61,7 +68,11 @@ module.exports = async ({ })); } - const rollupConfig = { + const rollupConfig: { + input: string; + manualChunks?: (id: string) => string | undefined; + plugins: Array; + } = { plugins, input: temporaryFile, }; @@ -83,9 +94,9 @@ module.exports = async ({ format: inlineWorkboxRuntime ? 'es' : 'amd', }); - const files = []; + const files: Array= []; for (const chunkOrAsset of output) { - if (chunkOrAsset.isAsset) { + if (chunkOrAsset.type === 'asset') { files.push({ name: chunkOrAsset.fileName, contents: chunkOrAsset.source, @@ -116,7 +127,10 @@ module.exports = async ({ file.name = upath.format({ dir, base: file.name, + ext: undefined, + name: undefined, + root: undefined, }); return file; }); -}; +} diff --git a/packages/workbox-build/src/lib/get-file-manifest-entries.ts b/packages/workbox-build/src/lib/get-file-manifest-entries.ts index 0ee1e558d..80d558cb0 100644 --- a/packages/workbox-build/src/lib/get-file-manifest-entries.ts +++ b/packages/workbox-build/src/lib/get-file-manifest-entries.ts @@ -8,7 +8,7 @@ import assert from 'assert'; -import {BuildResult, FileDetails, GetManifestOptions} from '../types'; +import {GetManifestResult, FileDetails, GetManifestOptions} from '../types'; import errors from './errors'; import getCompositeDetails from './get-composite-details'; import getFileDetails from './get-file-details'; @@ -27,7 +27,7 @@ export default async function ({ maximumFileSizeToCacheInBytes, modifyURLPrefix, templatedURLs, -}: GetManifestOptions): Promise { +}: GetManifestOptions): Promise { const warnings: Array = []; const allFileDetails = new Map(); diff --git a/packages/workbox-build/src/lib/module-registry.js b/packages/workbox-build/src/lib/module-registry.ts similarity index 76% rename from packages/workbox-build/src/lib/module-registry.js rename to packages/workbox-build/src/lib/module-registry.ts index f38ad169d..60bdb326d 100644 --- a/packages/workbox-build/src/lib/module-registry.js +++ b/packages/workbox-build/src/lib/module-registry.ts @@ -6,8 +6,8 @@ https://opensource.org/licenses/MIT. */ -const ol = require('common-tags').oneLine; -const upath = require('upath'); +import {oneLine as ol} from 'common-tags'; +import upath from 'upath'; /** * Class for keeping track of which Workbox modules are used by the generated @@ -15,12 +15,13 @@ const upath = require('upath'); * * @private */ -class ModuleRegistry { +export default class ModuleRegistry { + private _modulesUsed: Map; /** * @private */ constructor() { - this.modulesUsed = new Map(); + this._modulesUsed = new Map(); } /** @@ -28,10 +29,10 @@ class ModuleRegistry { * needed for the modules being used. * @private */ - getImportStatements() { - const workboxModuleImports = []; + getImportStatements(): Array { + const workboxModuleImports: Array = []; - for (const [localName, {moduleName, pkg}] of this.modulesUsed) { + for (const [localName, {moduleName, pkg}] of this._modulesUsed) { // By default require.resolve returns the resolved path of the 'main' // field, which might be deeper than the package root. To work around // this, we can find the package's root by resolving its package.json and @@ -53,7 +54,7 @@ class ModuleRegistry { * @return {string} The local variable name that corresponds to that module. * @private */ - getLocalName(pkg, moduleName) { + getLocalName(pkg: string, moduleName: string): string { return `${pkg.replace(/-/g, '_')}_${moduleName}`; } @@ -63,12 +64,10 @@ class ModuleRegistry { * @return {string} The local variable name that corresponds to that module. * @private */ - use(pkg, moduleName) { + use(pkg: string, moduleName: string): string { const localName = this.getLocalName(pkg, moduleName); - this.modulesUsed.set(localName, {moduleName, pkg}); + this._modulesUsed.set(localName, {moduleName, pkg}); return localName; } } - -module.exports = ModuleRegistry; diff --git a/packages/workbox-build/src/lib/populate-sw-template.js b/packages/workbox-build/src/lib/populate-sw-template.ts similarity index 84% rename from packages/workbox-build/src/lib/populate-sw-template.js rename to packages/workbox-build/src/lib/populate-sw-template.ts index 432834a8f..df2023fa7 100644 --- a/packages/workbox-build/src/lib/populate-sw-template.js +++ b/packages/workbox-build/src/lib/populate-sw-template.ts @@ -6,15 +6,16 @@ https://opensource.org/licenses/MIT. */ -const template = require('lodash/template'); -const swTemplate = require('../templates/sw-template'); +import template from 'lodash/template'; +import swTemplate from '../templates/sw-template'; -const errors = require('./errors'); -const ModuleRegistry = require('./module-registry'); -const runtimeCachingConverter = require('./runtime-caching-converter'); -const stringifyWithoutComments = require('./stringify-without-comments'); +import {GeneratePartial, ManifestEntry} from '../types'; +import errors from './errors'; +import ModuleRegistry from './module-registry'; +import runtimeCachingConverter from './runtime-caching-converter'; +import stringifyWithoutComments from './stringify-without-comments'; -module.exports = ({ +export default function({ cacheId, cleanupOutdatedCaches, clientsClaim, @@ -30,7 +31,7 @@ module.exports = ({ offlineGoogleAnalytics, runtimeCaching = [], skipWaiting, -}) => { +}: GeneratePartial & {manifestEntries: Array}): string { // There needs to be at least something to precache, or else runtime caching. if (!(manifestEntries.length > 0 || runtimeCaching.length > 0)) { throw new Error(errors['no-manifest-entries-or-runtime-caching']); @@ -42,7 +43,7 @@ module.exports = ({ // An array of RegExp objects can't be serialized by JSON.stringify()'s // default behavior, so if it's given, convert it manually. ignoreURLParametersMatching: ignoreURLParametersMatching ? - [] : + [] as Array : undefined, }; @@ -55,7 +56,7 @@ module.exports = ({ ); } - let offlineAnalyticsConfigString; + let offlineAnalyticsConfigString: string; if (offlineGoogleAnalytics) { // If offlineGoogleAnalytics is a truthy value, we need to convert it to the // format expected by the template. diff --git a/packages/workbox-build/src/lib/rebase-path.js b/packages/workbox-build/src/lib/rebase-path.ts similarity index 82% rename from packages/workbox-build/src/lib/rebase-path.js rename to packages/workbox-build/src/lib/rebase-path.ts index 5c9215f2a..298a720cf 100644 --- a/packages/workbox-build/src/lib/rebase-path.js +++ b/packages/workbox-build/src/lib/rebase-path.ts @@ -6,9 +6,12 @@ https://opensource.org/licenses/MIT. */ -const upath = require('upath'); +import upath from 'upath'; -module.exports = ({baseDirectory, file}) => { +export default function({ + baseDirectory, + file +}: {baseDirectory: string, file: string}): string { // The initial path is relative to the current directory, so make it absolute. const absolutePath = upath.resolve(file); @@ -19,4 +22,4 @@ module.exports = ({baseDirectory, file}) => { const normalizedPath = upath.normalize(relativePath); return normalizedPath; -}; +} diff --git a/packages/workbox-build/src/lib/validate-options.js b/packages/workbox-build/src/lib/validate-options.js deleted file mode 100644 index a0c388d13..000000000 --- a/packages/workbox-build/src/lib/validate-options.js +++ /dev/null @@ -1,23 +0,0 @@ -/* - Copyright 2019 Google LLC - - Use of this source code is governed by an MIT-style - license that can be found in the LICENSE file or at - https://opensource.org/licenses/MIT. -*/ - -module.exports = (options, schema) => { - const {value, error} = schema.validate(options, { - language: { - object: { - allowUnknown: 'is not a supported parameter.', - }, - }, - }); - - if (error) { - throw error; - } - - return value; -}; diff --git a/packages/workbox-build/src/lib/validate-options.ts b/packages/workbox-build/src/lib/validate-options.ts new file mode 100644 index 000000000..afe6d338f --- /dev/null +++ b/packages/workbox-build/src/lib/validate-options.ts @@ -0,0 +1,12 @@ +/* + Copyright 2019 Google LLC + + Use of this source code is governed by an MIT-style + license that can be found in the LICENSE file or at + https://opensource.org/licenses/MIT. +*/ + +export default function(options: any, schema: any): any { + // TODO: Switch to TypeScript validation. + return options; +} diff --git a/packages/workbox-build/src/lib/write-sw-using-default-template.js b/packages/workbox-build/src/lib/write-sw-using-default-template.ts similarity index 82% rename from packages/workbox-build/src/lib/write-sw-using-default-template.js rename to packages/workbox-build/src/lib/write-sw-using-default-template.ts index 31570b50f..90d0324ca 100644 --- a/packages/workbox-build/src/lib/write-sw-using-default-template.js +++ b/packages/workbox-build/src/lib/write-sw-using-default-template.ts @@ -6,14 +6,15 @@ https://opensource.org/licenses/MIT. */ -const fse = require('fs-extra'); -const upath = require('upath'); +import fse from 'fs-extra'; +import upath from 'upath'; -const bundle = require('./bundle'); -const errors = require('./errors'); -const populateSWTemplate = require('./populate-sw-template'); +import {GenerateSWOptions, ManifestEntry} from '../types'; +import bundle from './bundle'; +import errors from './errors'; +import populateSWTemplate from './populate-sw-template'; -module.exports = async ({ +export default async function({ babelPresetEnvTargets, cacheId, cleanupOutdatedCaches, @@ -34,7 +35,7 @@ module.exports = async ({ skipWaiting, sourcemap, swDest, -}) => { +}: GenerateSWOptions & {manifestEntries: Array}): Promise> { const outputDir = upath.dirname(swDest); try { await fse.mkdirp(outputDir); @@ -71,7 +72,7 @@ module.exports = async ({ unbundledCode, }); - const filePaths = []; + const filePaths: Array = []; for (const file of files) { const filePath = upath.resolve(file.name); diff --git a/packages/workbox-build/src/templates/sw-template.js b/packages/workbox-build/src/templates/sw-template.ts similarity index 99% rename from packages/workbox-build/src/templates/sw-template.js rename to packages/workbox-build/src/templates/sw-template.ts index 0cc6ac47a..b945f16be 100644 --- a/packages/workbox-build/src/templates/sw-template.js +++ b/packages/workbox-build/src/templates/sw-template.ts @@ -6,7 +6,7 @@ https://opensource.org/licenses/MIT. */ -module.exports = `/** +export default `/** * Welcome to your Workbox-powered service worker! * * You'll need to register this file in your web app. diff --git a/packages/workbox-build/src/types.ts b/packages/workbox-build/src/types.ts index 2ec568724..221f93504 100644 --- a/packages/workbox-build/src/types.ts +++ b/packages/workbox-build/src/types.ts @@ -63,7 +63,7 @@ export interface BasePartial { }; } -interface GeneratePartial { +export interface GeneratePartial { babelPresetEnvTargets?: Array; cacheId?: string; cleanupOutdatedCaches?: boolean; @@ -108,7 +108,7 @@ interface WebpackPartial { mode?: string; } -interface SWDestPartial { +export interface SWDestPartial { swDest: string; } @@ -127,15 +127,15 @@ export type WebpackInjectManifestOptions = WebpackPartial & InjectPartial & Base webpackCompilationPlugins?: Array; }; -export interface BuildResult { +export interface GetManifestResult { count: number, manifestEntries: Array, size: number, warnings: Array } -export type BuildResultWithFiles = BuildResult & { - files: Array; +export type BuildResult = Omit & { + filePaths: Array; }; export interface FileDetails { From 5a27e31832eeffdd7d30ef070d793462ab72dacf Mon Sep 17 00:00:00 2001 From: Jeff Posnick Date: Wed, 23 Dec 2020 13:28:18 -0500 Subject: [PATCH 04/80] Getting there --- package-lock.json | 30 +++++++++++-- package.json | 1 + packages/workbox-build/src/generate-sw.ts | 2 +- packages/workbox-build/src/get-manifest.ts | 2 +- .../workbox-build/src/{index.js => index.ts} | 12 ++--- packages/workbox-build/src/inject-manifest.ts | 45 +++++++++---------- packages/workbox-build/src/lib/cdn-utils.js | 40 ----------------- packages/workbox-build/src/lib/cdn-utils.ts | 36 +++++++++++++++ ...libraries.js => copy-workbox-libraries.ts} | 15 ++++--- ...ap.js => replace-and-update-source-map.ts} | 18 +++++--- packages/workbox-build/src/types.ts | 12 +++++ 11 files changed, 125 insertions(+), 88 deletions(-) rename packages/workbox-build/src/{index.js => index.ts} (51%) delete mode 100644 packages/workbox-build/src/lib/cdn-utils.js create mode 100644 packages/workbox-build/src/lib/cdn-utils.ts rename packages/workbox-build/src/lib/{copy-workbox-libraries.js => copy-workbox-libraries.ts} (89%) rename packages/workbox-build/src/lib/{replace-and-update-source-map.js => replace-and-update-source-map.ts} (87%) diff --git a/package-lock.json b/package-lock.json index 5e4fb880f..531ede233 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1130,6 +1130,14 @@ "dev": true, "requires": { "type-fest": "^0.8.1" + }, + "dependencies": { + "type-fest": { + "version": "0.8.1", + "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.8.1.tgz", + "integrity": "sha512-4dbzIzqvjtgiM5rw1k5rEHtBANKmdudhGyBEajN01fEyhaAIhsoKNy6y7+IN93IfpFtwY9iqi7kD+xwKhQsNJA==", + "dev": true + } } }, "ignore": { @@ -7935,6 +7943,14 @@ "dev": true, "requires": { "type-fest": "^0.8.1" + }, + "dependencies": { + "type-fest": { + "version": "0.8.1", + "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.8.1.tgz", + "integrity": "sha512-4dbzIzqvjtgiM5rw1k5rEHtBANKmdudhGyBEajN01fEyhaAIhsoKNy6y7+IN93IfpFtwY9iqi7kD+xwKhQsNJA==", + "dev": true + } } }, "ignore": { @@ -10301,6 +10317,14 @@ "requires": { "is-stream": "^2.0.0", "type-fest": "^0.8.0" + }, + "dependencies": { + "type-fest": { + "version": "0.8.1", + "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.8.1.tgz", + "integrity": "sha512-4dbzIzqvjtgiM5rw1k5rEHtBANKmdudhGyBEajN01fEyhaAIhsoKNy6y7+IN93IfpFtwY9iqi7kD+xwKhQsNJA==", + "dev": true + } } }, "he": { @@ -16971,9 +16995,9 @@ "dev": true }, "type-fest": { - "version": "0.8.1", - "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.8.1.tgz", - "integrity": "sha512-4dbzIzqvjtgiM5rw1k5rEHtBANKmdudhGyBEajN01fEyhaAIhsoKNy6y7+IN93IfpFtwY9iqi7kD+xwKhQsNJA==", + "version": "0.20.2", + "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.20.2.tgz", + "integrity": "sha512-Ne+eE4r0/iWnpAxD852z3A+N0Bt5RN//NjJwRd2VFHEmrywxf5vsZlh4R6lixl6B+wz/8d+maTSAkN1FIkI3LQ==", "dev": true }, "type-is": { diff --git a/package.json b/package.json index 160d6edcc..92ec4c524 100644 --- a/package.json +++ b/package.json @@ -104,6 +104,7 @@ "service-worker-mock": "^1.9.3", "sinon": "^9.0.3", "tempy": "^0.6.0", + "type-fest": "^0.20.2", "typescript": "^3.9.7", "upath": "^1.2.0", "webpack-v4": "npm:webpack@^4.44.2", diff --git a/packages/workbox-build/src/generate-sw.ts b/packages/workbox-build/src/generate-sw.ts index 9fc4e516e..cbdde702d 100644 --- a/packages/workbox-build/src/generate-sw.ts +++ b/packages/workbox-build/src/generate-sw.ts @@ -194,7 +194,7 @@ import writeServiceWorkerUsingDefaultTemplate from './lib/write-sw-using-default * * @memberof module:workbox-build */ -export async function generateSW(config: GenerateSWOptions): Promise { +export default async function(config: GenerateSWOptions): Promise { const options: GenerateSWOptions = validate(config, generateSWSchema); if (options.globDirectory) { diff --git a/packages/workbox-build/src/get-manifest.ts b/packages/workbox-build/src/get-manifest.ts index 896522aea..f34fd5642 100644 --- a/packages/workbox-build/src/get-manifest.ts +++ b/packages/workbox-build/src/get-manifest.ts @@ -89,7 +89,7 @@ import validate from './lib/validate-options'; * * @memberof module:workbox-build */ -export async function getManifest(config: GetManifestOptions): Promise { +export default async function(config: GetManifestOptions): Promise { const options: GetManifestOptions = validate(config, getManifestSchema); return await getFileManifestEntries(options); diff --git a/packages/workbox-build/src/index.js b/packages/workbox-build/src/index.ts similarity index 51% rename from packages/workbox-build/src/index.js rename to packages/workbox-build/src/index.ts index 84317f1c9..3c591555a 100644 --- a/packages/workbox-build/src/index.js +++ b/packages/workbox-build/src/index.ts @@ -6,16 +6,16 @@ https://opensource.org/licenses/MIT. */ -const {getModuleURL} = require('./lib/cdn-utils'); -const copyWorkboxLibraries = require('./lib/copy-workbox-libraries'); -const generateSW = require('./generate-sw'); -const getManifest = require('./get-manifest'); -const injectManifest = require('./inject-manifest'); +import {getModuleURL} from './lib/cdn-utils'; +import copyWorkboxLibraries from './lib/copy-workbox-libraries'; +import generateSW from './generate-sw'; +import getManifest from './get-manifest'; +import injectManifest from './inject-manifest'; /** * @module workbox-build */ -module.exports = { +export default { copyWorkboxLibraries, generateSW, getManifest, diff --git a/packages/workbox-build/src/inject-manifest.ts b/packages/workbox-build/src/inject-manifest.ts index bc922ce07..5ba98987a 100644 --- a/packages/workbox-build/src/inject-manifest.ts +++ b/packages/workbox-build/src/inject-manifest.ts @@ -6,20 +6,21 @@ https://opensource.org/licenses/MIT. */ -const assert = require('assert'); -const fse = require('fs-extra'); -const sourceMapURL = require('source-map-url'); -const stringify = require('fast-json-stable-stringify'); -const upath = require('upath'); - -const errors = require('./lib/errors'); -const escapeRegexp = require('./lib/escape-regexp'); -const getFileManifestEntries = require('./lib/get-file-manifest-entries'); -const injectManifestSchema = require('./options/schema/inject-manifest'); -const rebasePath = require('./lib/rebase-path'); -const replaceAndUpdateSourceMap = - require('./lib/replace-and-update-source-map'); -const validate = require('./lib/validate-options'); +import {RawSourceMap} from 'source-map'; +import assert from 'assert'; +import fse from 'fs-extra'; +import sourceMapURL from 'source-map-url'; +import stringify from 'fast-json-stable-stringify'; +import upath from 'upath'; + +import {BuildResult, InjectManifestOptions} from './types'; +import errors from './lib/errors'; +import escapeRegexp from './lib/escape-regexp'; +import getFileManifestEntries from './lib/get-file-manifest-entries'; +import injectManifestSchema from './options/schema/inject-manifest'; +import rebasePath from './lib/rebase-path'; +import replaceAndUpdateSourceMap from './lib/replace-and-update-source-map'; +import validate from './lib/validate-options'; // eslint-disable-next-line jsdoc/newline-after-description /** @@ -116,8 +117,8 @@ const validate = require('./lib/validate-options'); * * @memberof module:workbox-build */ -async function injectManifest(config) { - const options = validate(config, injectManifestSchema); +export default async function(config: InjectManifestOptions): Promise { + const options: InjectManifestOptions = validate(config, injectManifestSchema); // Make sure we leave swSrc and swDest out of the precache manifest. for (const file of [options.swSrc, options.swDest]) { @@ -131,7 +132,7 @@ async function injectManifest(config) { const {count, size, manifestEntries, warnings} = await getFileManifestEntries(options); - let swFileContents; + let swFileContents: string; try { swFileContents = await fse.readFile(options.swSrc, 'utf8'); } catch (error) { @@ -153,9 +154,9 @@ async function injectManifest(config) { options.injectionPoint); const manifestString = stringify(manifestEntries); - const filesToWrite = {}; + const filesToWrite: {[key: string]: string} = {}; - const url = sourceMapURL.getFrom(swFileContents); + const url: string = sourceMapURL.getFrom(swFileContents); // If our swSrc file contains a sourcemap, we would invalidate that // mapping if we just replaced injectionPoint with the stringified manifest. // Instead, we need to update the swDest contents as well as the sourcemap @@ -166,9 +167,9 @@ async function injectManifest(config) { const sourcemapSrcPath = upath.resolve(upath.dirname(options.swSrc), url); const sourcemapDestPath = upath.resolve(upath.dirname(options.swDest), url); - let originalMap; + let originalMap: RawSourceMap; try { - originalMap = await fse.readJSON(sourcemapSrcPath, 'utf8'); + originalMap = await fse.readJSON(sourcemapSrcPath, {encoding: 'utf8'}); } catch (error) { throw new Error(`${errors['cant-find-sourcemap']} ${error.message}`); } @@ -209,5 +210,3 @@ async function injectManifest(config) { filePaths: Object.keys(filesToWrite).map((f) => upath.resolve(f)), }; } - -module.exports = injectManifest; diff --git a/packages/workbox-build/src/lib/cdn-utils.js b/packages/workbox-build/src/lib/cdn-utils.js deleted file mode 100644 index 8365385b1..000000000 --- a/packages/workbox-build/src/lib/cdn-utils.js +++ /dev/null @@ -1,40 +0,0 @@ -/* - Copyright 2018 Google LLC - - Use of this source code is governed by an MIT-style - license that can be found in the LICENSE file or at - https://opensource.org/licenses/MIT. -*/ - -const assert = require('assert'); - -const cdn = require('../cdn-details.json'); -const errors = require('./errors'); - -const getCDNOrigin = () => { - return `${cdn.origin}/${cdn.bucketName}/${cdn.releasesDir}`; -}; - -const getVersionedCDNURL = () => { - return `${getCDNOrigin()}/${cdn.latestVersion}`; -}; - -const getModuleURL = (moduleName, buildType) => { - assert(moduleName, errors['no-module-name']); - - if (buildType) { - const pkgJson = require(`${moduleName}/package.json`); - if (buildType === 'dev' && pkgJson.workbox.prodOnly) { - // This is not due to a public-facing exception, so just throw an Error(), - // without creating an entry in errors.js. - throw Error(`The 'dev' build of ${moduleName} is not available.`); - } - return `${getVersionedCDNURL()}/${moduleName}.${buildType.slice(0, 4)}.js`; - } - return `${getVersionedCDNURL()}/${moduleName}.js`; -}; - -module.exports = { - getCDNOrigin, - getModuleURL, -}; diff --git a/packages/workbox-build/src/lib/cdn-utils.ts b/packages/workbox-build/src/lib/cdn-utils.ts new file mode 100644 index 000000000..714af77eb --- /dev/null +++ b/packages/workbox-build/src/lib/cdn-utils.ts @@ -0,0 +1,36 @@ +/* + Copyright 2018 Google LLC + + Use of this source code is governed by an MIT-style + license that can be found in the LICENSE file or at + https://opensource.org/licenses/MIT. +*/ + +import assert from 'assert'; + +import {BuildType, WorkboxPackageJSON} from '../types'; +import cdn from '../cdn-details.json'; +import errors from './errors'; + +function getVersionedURL(): string { + return `${getCDNPrefix()}/${cdn.latestVersion}`; +} + +function getCDNPrefix() { + return `${cdn.origin}/${cdn.bucketName}/${cdn.releasesDir}`; +} + +export function getModuleURL(moduleName: string, buildType: BuildType) { + assert(moduleName, errors['no-module-name']); + + if (buildType) { + const pkgJson: WorkboxPackageJSON = require(`${moduleName}/package.json`); + if (buildType === 'dev' && pkgJson.workbox && pkgJson.workbox.prodOnly) { + // This is not due to a public-facing exception, so just throw an Error(), + // without creating an entry in errors.js. + throw Error(`The 'dev' build of ${moduleName} is not available.`); + } + return `${getVersionedURL()}/${moduleName}.${buildType.slice(0, 4)}.js`; + } + return `${getVersionedURL()}/${moduleName}.js`; +} diff --git a/packages/workbox-build/src/lib/copy-workbox-libraries.js b/packages/workbox-build/src/lib/copy-workbox-libraries.ts similarity index 89% rename from packages/workbox-build/src/lib/copy-workbox-libraries.js rename to packages/workbox-build/src/lib/copy-workbox-libraries.ts index ecca3c8da..f89661f01 100644 --- a/packages/workbox-build/src/lib/copy-workbox-libraries.js +++ b/packages/workbox-build/src/lib/copy-workbox-libraries.ts @@ -6,10 +6,11 @@ https://opensource.org/licenses/MIT. */ -const fse = require('fs-extra'); -const upath = require('upath'); -const errors = require('./errors'); +import fse from 'fs-extra'; +import upath from 'upath'; +import {WorkboxPackageJSON} from '../types'; +import errors from './errors'; // Used to filter the libraries to copy based on our package.json dependencies. const WORKBOX_PREFIX = 'workbox-'; @@ -36,8 +37,8 @@ const BUILD_DIR = 'build'; * * @alias module:workbox-build.copyWorkboxLibraries */ -module.exports = async (destDirectory) => { - const thisPkg = require('../../package.json'); +export default async function(destDirectory: string): Promise { + const thisPkg: WorkboxPackageJSON = require('../../package.json'); // Use the version string from workbox-build in the name of the parent // directory. This should be safe, because lerna will bump workbox-build's // pkg.version whenever one of the dependent libraries gets bumped, and we @@ -46,7 +47,7 @@ module.exports = async (destDirectory) => { const workboxDirectoryPath = upath.join(destDirectory, workboxDirectoryName); await fse.ensureDir(workboxDirectoryPath); - const copyPromises = []; + const copyPromises: Array> = []; const librariesToCopy = Object.keys(thisPkg.dependencies).filter( (dependency) => dependency.startsWith(WORKBOX_PREFIX)); @@ -69,4 +70,4 @@ module.exports = async (destDirectory) => { } catch (error) { throw Error(`${errors['unable-to-copy-workbox-libraries']} ${error}`); } -}; +} diff --git a/packages/workbox-build/src/lib/replace-and-update-source-map.js b/packages/workbox-build/src/lib/replace-and-update-source-map.ts similarity index 87% rename from packages/workbox-build/src/lib/replace-and-update-source-map.js rename to packages/workbox-build/src/lib/replace-and-update-source-map.ts index 4fd853b77..537d885b6 100644 --- a/packages/workbox-build/src/lib/replace-and-update-source-map.js +++ b/packages/workbox-build/src/lib/replace-and-update-source-map.ts @@ -6,7 +6,7 @@ https://opensource.org/licenses/MIT. */ -const {SourceMapConsumer, SourceMapGenerator} = require('source-map'); +import {RawSourceMap, SourceMapConsumer, SourceMapGenerator} from 'source-map'; /** * Adapted from https://github.com/nsams/sourcemap-aware-replace, with modern @@ -27,20 +27,26 @@ const {SourceMapConsumer, SourceMapGenerator} = require('source-map'); * * @private */ -async function replaceAndUpdateSourceMap({ +export default async function({ jsFilename, originalMap, originalSource, replaceString, searchString, -}) { +}: { + jsFilename: string; + originalMap: RawSourceMap; + originalSource: string; + replaceString: string; + searchString: string; +}): Promise<{map: string; source: string}> { const generator = new SourceMapGenerator({ file: jsFilename, }); const consumer = await new SourceMapConsumer(originalMap); - let pos; + let pos: number; let src = originalSource; const replacements = []; let lineNum = 0; @@ -92,7 +98,7 @@ async function replaceAndUpdateSourceMap({ consumer.destroy(); - const updatedSourceMap = Object.assign(JSON.parse(generator.toString()), { + const updatedSourceMap: RawSourceMap = Object.assign(JSON.parse(generator.toString()), { names: originalMap.names, sourceRoot: originalMap.sourceRoot, sources: originalMap.sources, @@ -104,5 +110,3 @@ async function replaceAndUpdateSourceMap({ source: src, }; } - -module.exports = replaceAndUpdateSourceMap; diff --git a/packages/workbox-build/src/types.ts b/packages/workbox-build/src/types.ts index 221f93504..73d8650fc 100644 --- a/packages/workbox-build/src/types.ts +++ b/packages/workbox-build/src/types.ts @@ -1,3 +1,5 @@ +import {PackageJson} from 'type-fest'; + import {BroadcastCacheUpdateOptions} from 'workbox-broadcast-update/BroadcastCacheUpdate'; import {GoogleAnalyticsInitializeOptions} from 'workbox-google-analytics/initialize'; import {HTTPMethod} from 'workbox-routing/utils/constants'; @@ -143,3 +145,13 @@ export interface FileDetails { hash: string; size: number; } + +export type BuildType = 'dev' | 'prod'; + +export interface WorkboxPackageJSON extends PackageJson { + workbox?: { + browserNamespace?: string, + packageType?: string; + prodOnly?: boolean; + }; +}; From e6ad7b3511b8ccedf7f5f2129b9552eeb9dc2ae4 Mon Sep 17 00:00:00 2001 From: Jeff Posnick Date: Wed, 23 Dec 2020 17:14:05 -0500 Subject: [PATCH 05/80] WIP --- gulp-tasks/utils/versioned-cdn-url.js | 5 ++--- packages/workbox-build/package.json | 2 +- ... additional-manifest-entries-transform.ts} | 10 +++++---- .../src/lib/{errors.js => errors.ts} | 4 ++-- .../{escape-regexp.js => escape-regexp.ts} | 4 +++- ...verter.js => runtime-caching-converter.ts} | 22 ++++++++++++------- ...ments.js => stringify-without-comments.ts} | 8 +++---- packages/workbox-build/src/types.ts | 8 +++---- packages/workbox-build/tsconfig.json | 15 +++++++++++++ 9 files changed, 51 insertions(+), 27 deletions(-) rename packages/workbox-build/src/lib/{additional-manifest-entries-transform.js => additional-manifest-entries-transform.ts} (82%) rename packages/workbox-build/src/lib/{errors.js => errors.ts} (99%) rename packages/workbox-build/src/lib/{escape-regexp.js => escape-regexp.ts} (74%) rename packages/workbox-build/src/lib/{runtime-caching-converter.js => runtime-caching-converter.ts} (87%) rename packages/workbox-build/src/lib/{stringify-without-comments.js => stringify-without-comments.ts} (56%) create mode 100644 packages/workbox-build/tsconfig.json diff --git a/gulp-tasks/utils/versioned-cdn-url.js b/gulp-tasks/utils/versioned-cdn-url.js index 6acf7d18d..ada229264 100644 --- a/gulp-tasks/utils/versioned-cdn-url.js +++ b/gulp-tasks/utils/versioned-cdn-url.js @@ -6,8 +6,7 @@ https://opensource.org/licenses/MIT. */ -const {getCDNOrigin} = require( - '../../packages/workbox-build/src/lib/cdn-utils'); +const cdn = require('../../packages/workbox-build/src/cdn-details.json'); const lernaPkg = require('../../lerna.json'); -module.exports = () => `${getCDNOrigin()}/${lernaPkg.version}`; +module.exports = () => `${cdn.origin}/${cdn.bucketName}/${cdn.releasesDir}/${lernaPkg.version}`; diff --git a/packages/workbox-build/package.json b/packages/workbox-build/package.json index 429f856d9..c336ec7b2 100644 --- a/packages/workbox-build/package.json +++ b/packages/workbox-build/package.json @@ -60,6 +60,6 @@ }, "main": "build/index.js", "workbox": { - "packageType": "node" + "packageType": "node_ts" } } diff --git a/packages/workbox-build/src/lib/additional-manifest-entries-transform.js b/packages/workbox-build/src/lib/additional-manifest-entries-transform.ts similarity index 82% rename from packages/workbox-build/src/lib/additional-manifest-entries-transform.js rename to packages/workbox-build/src/lib/additional-manifest-entries-transform.ts index 57d474761..0903ecea2 100644 --- a/packages/workbox-build/src/lib/additional-manifest-entries-transform.js +++ b/packages/workbox-build/src/lib/additional-manifest-entries-transform.ts @@ -6,10 +6,12 @@ https://opensource.org/licenses/MIT. */ -const errors = require('./errors'); +import errors from './errors'; -module.exports = (additionalManifestEntries) => { - return (manifest) => { +import {ManifestEntry} from '../types'; + +export default function(additionalManifestEntries: Array) { + return (manifest: Array & {size: number}) => { const warnings = []; const stringEntries = new Set(); @@ -39,4 +41,4 @@ module.exports = (additionalManifestEntries) => { warnings, }; }; -}; +} diff --git a/packages/workbox-build/src/lib/errors.js b/packages/workbox-build/src/lib/errors.ts similarity index 99% rename from packages/workbox-build/src/lib/errors.js rename to packages/workbox-build/src/lib/errors.ts index 52ec8a837..98d464ac5 100644 --- a/packages/workbox-build/src/lib/errors.js +++ b/packages/workbox-build/src/lib/errors.ts @@ -6,9 +6,9 @@ https://opensource.org/licenses/MIT. */ -const ol = require('common-tags').oneLine; +import {oneLine as ol} from 'common-tags'; -module.exports = { +export default { 'unable-to-get-rootdir': `Unable to get the root directory of your web app.`, 'no-extension': ol`Unable to detect a usable extension for a file in your web app directory.`, diff --git a/packages/workbox-build/src/lib/escape-regexp.js b/packages/workbox-build/src/lib/escape-regexp.ts similarity index 74% rename from packages/workbox-build/src/lib/escape-regexp.js rename to packages/workbox-build/src/lib/escape-regexp.ts index 47b109e9a..c95654727 100644 --- a/packages/workbox-build/src/lib/escape-regexp.js +++ b/packages/workbox-build/src/lib/escape-regexp.ts @@ -7,4 +7,6 @@ */ // From https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions -module.exports = (str) => str.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'); +export default function(str: string) { + return str.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'); +} diff --git a/packages/workbox-build/src/lib/runtime-caching-converter.js b/packages/workbox-build/src/lib/runtime-caching-converter.ts similarity index 87% rename from packages/workbox-build/src/lib/runtime-caching-converter.js rename to packages/workbox-build/src/lib/runtime-caching-converter.ts index 97b46c450..b58256873 100644 --- a/packages/workbox-build/src/lib/runtime-caching-converter.js +++ b/packages/workbox-build/src/lib/runtime-caching-converter.ts @@ -6,10 +6,14 @@ https://opensource.org/licenses/MIT. */ -const ol = require('common-tags').oneLine; +import {oneLine as ol} from 'common-tags'; -const errors = require('./errors'); -const stringifyWithoutComments = require('./stringify-without-comments'); +import {RuntimeCaching} from '../types'; +import ModuleRegistry from './module-registry'; +import errors from './errors'; +import stringifyWithoutComments from './stringify-without-comments'; + +type OptionsToRemove = 'cacheName' | 'networkTimeoutSeconds' | 'fetchOptions' | 'matchOptions'; /** * Given a set of options that configures runtime caching behavior, convert it @@ -22,8 +26,8 @@ const stringifyWithoutComments = require('./stringify-without-comments'); * * @private */ -function getOptionsString(moduleRegistry, options = {}) { - let plugins = []; +function getOptionsString(moduleRegistry: ModuleRegistry, options: RuntimeCaching['options'] = {}) { + let plugins: Array = []; if (options.plugins) { // Using libs because JSON.stringify won't handle functions. plugins = options.plugins.map(stringifyWithoutComments); @@ -33,13 +37,13 @@ function getOptionsString(moduleRegistry, options = {}) { // Pull handler-specific config from the options object, since they are // not directly used to construct a plugin instance. If set, need to be // passed as options to the handler constructor instead. - const handlerOptionKeys = [ + const handlerOptionKeys: Array = [ 'cacheName', 'networkTimeoutSeconds', 'fetchOptions', 'matchOptions', ]; - const handlerOptions = {}; + const handlerOptions: {[key: string]: any} = {}; for (const key of handlerOptionKeys) { if (key in options) { handlerOptions[key] = options[key]; @@ -126,7 +130,7 @@ function getOptionsString(moduleRegistry, options = {}) { } } -module.exports = (moduleRegistry, runtimeCaching) => { +module.exports = (moduleRegistry: ModuleRegistry, runtimeCaching: Array) => { return runtimeCaching.map((entry) => { const method = entry.method || 'GET'; @@ -162,5 +166,7 @@ module.exports = (moduleRegistry, runtimeCaching) => { } else if (typeof entry.handler === 'function') { return `${registerRoute}(${matcher}, ${entry.handler}, '${method}');\n`; } + + return undefined; }).filter((entry) => Boolean(entry)); // Remove undefined map() return values. }; diff --git a/packages/workbox-build/src/lib/stringify-without-comments.js b/packages/workbox-build/src/lib/stringify-without-comments.ts similarity index 56% rename from packages/workbox-build/src/lib/stringify-without-comments.js rename to packages/workbox-build/src/lib/stringify-without-comments.ts index 05b11041b..1cc7a7f51 100644 --- a/packages/workbox-build/src/lib/stringify-without-comments.js +++ b/packages/workbox-build/src/lib/stringify-without-comments.ts @@ -6,12 +6,12 @@ https://opensource.org/licenses/MIT. */ -const objectStringify = require('stringify-object'); -const stripComments = require('strip-comments'); +import objectStringify from 'stringify-object'; +import stripComments from 'strip-comments'; -module.exports = (obj) => { +export default function(obj: {[key: string]: any}): string { return objectStringify(obj, { - transform: (_obj, _prop, str) => + transform: (_obj: {[key: string]: any}, _prop: string, str: string) => typeof _obj[_prop] === 'function' ? stripComments(str) : str, }); }; diff --git a/packages/workbox-build/src/types.ts b/packages/workbox-build/src/types.ts index 73d8650fc..62aa5c973 100644 --- a/packages/workbox-build/src/types.ts +++ b/packages/workbox-build/src/types.ts @@ -17,10 +17,10 @@ export interface ManifestEntry { type StrategyName = 'CacheFirst' | 'CacheOnly' | 'NetworkFirst' | 'NetworkOnly' | 'StaleWhileRevalidate'; -interface RuntimeCaching { +export interface RuntimeCaching { handler: RouteHandler | StrategyName; method?: HTTPMethod; - options: { + options?: { backgroundSync?: { name: string; options?: QueueOptions; @@ -39,8 +39,8 @@ interface RuntimeCaching { precacheFallback?: { fallbackURL: string; }, - fetchOptions: RequestInit; - matchOptions: CacheQueryOptions; + fetchOptions?: RequestInit; + matchOptions?: CacheQueryOptions; }; urlPattern: RegExp | string | RouteMatchCallback; } diff --git a/packages/workbox-build/tsconfig.json b/packages/workbox-build/tsconfig.json new file mode 100644 index 000000000..422b24400 --- /dev/null +++ b/packages/workbox-build/tsconfig.json @@ -0,0 +1,15 @@ +{ + "extends": "../../tsconfig", + "compilerOptions": { + "module": "CommonJS", + "outDir": "build", + "resolveJsonModule": true, + "rootDir": "src", + "target": "ES2018", + "tsBuildInfoFile": "./tsconfig.tsbuildinfo" + }, + "include": [ + "src/**/*.ts", + "src/cdn-details.json" + ] +} From b774e0dc5a90a4808bbef04281b2396b0be4fd9a Mon Sep 17 00:00:00 2001 From: Jeff Posnick Date: Wed, 23 Dec 2020 20:20:14 -0500 Subject: [PATCH 06/80] Runtime caching TS --- .../src/lib/runtime-caching-converter.ts | 91 ++++++++----------- 1 file changed, 39 insertions(+), 52 deletions(-) diff --git a/packages/workbox-build/src/lib/runtime-caching-converter.ts b/packages/workbox-build/src/lib/runtime-caching-converter.ts index b58256873..6714efdd4 100644 --- a/packages/workbox-build/src/lib/runtime-caching-converter.ts +++ b/packages/workbox-build/src/lib/runtime-caching-converter.ts @@ -13,8 +13,6 @@ import ModuleRegistry from './module-registry'; import errors from './errors'; import stringifyWithoutComments from './stringify-without-comments'; -type OptionsToRemove = 'cacheName' | 'networkTimeoutSeconds' | 'fetchOptions' | 'matchOptions'; - /** * Given a set of options that configures runtime caching behavior, convert it * to the equivalent Workbox method calls. @@ -27,60 +25,55 @@ type OptionsToRemove = 'cacheName' | 'networkTimeoutSeconds' | 'fetchOptions' | * @private */ function getOptionsString(moduleRegistry: ModuleRegistry, options: RuntimeCaching['options'] = {}) { - let plugins: Array = []; - if (options.plugins) { - // Using libs because JSON.stringify won't handle functions. - plugins = options.plugins.map(stringifyWithoutComments); - delete options.plugins; - } - - // Pull handler-specific config from the options object, since they are - // not directly used to construct a plugin instance. If set, need to be - // passed as options to the handler constructor instead. - const handlerOptionKeys: Array = [ - 'cacheName', - 'networkTimeoutSeconds', - 'fetchOptions', - 'matchOptions', - ]; - const handlerOptions: {[key: string]: any} = {}; - for (const key of handlerOptionKeys) { - if (key in options) { - handlerOptions[key] = options[key]; - delete options[key]; - } - } + const plugins: Array = []; + const handlerOptions: {[key in keyof typeof options]: any} = {}; - for (const [pluginName, pluginConfig] of Object.entries(options)) { - // Ensure that we have some valid configuration to pass to the plugin. - if (Object.keys(pluginConfig).length === 0) { + for (const optionName of Object.keys(options) as Array) { + if (options[optionName] === undefined) { continue; } - let pluginCode; - switch (pluginName) { + switch (optionName) { + // Using a library here because JSON.stringify won't handle functions. + case 'plugins': { + plugins.push(...options.plugins!.map(stringifyWithoutComments)); + break; + } + + // These are the option properties that we want to pull out, so that + // they're passed to the handler constructor. + case 'cacheName': + case 'networkTimeoutSeconds': + case 'fetchOptions': + case 'matchOptions': { + handlerOptions[optionName] = options[optionName]; + break; + } + + // The following cases are all shorthands for creating a plugin with a + // given configuration. case 'backgroundSync': { - const name = pluginConfig.name; + const name = options.backgroundSync!.name; const plugin = moduleRegistry.use( 'workbox-background-sync', 'BackgroundSyncPlugin'); - pluginCode = `new ${plugin}(${JSON.stringify(name)}`; - if ('options' in pluginConfig) { - pluginCode += `, ${stringifyWithoutComments(pluginConfig.options)}`; + let pluginCode = `new ${plugin}(${JSON.stringify(name)}`; + if (options.backgroundSync!.options) { + pluginCode += `, ${stringifyWithoutComments(options.backgroundSync!.options)}`; } pluginCode += `)`; + plugins.push(pluginCode); break; } case 'broadcastUpdate': { - const channelName = pluginConfig.channelName; - const opts = Object.assign({channelName}, pluginConfig.options); + const channelName = options.broadcastUpdate!.channelName; + const opts = Object.assign({channelName}, options.broadcastUpdate!.options); const plugin = moduleRegistry.use( 'workbox-broadcast-update', 'BroadcastUpdatePlugin'); - pluginCode = `new ${plugin}(${stringifyWithoutComments(opts)})`; - + plugins.push(`new ${plugin}(${stringifyWithoutComments(opts)})`); break; } @@ -88,8 +81,7 @@ function getOptionsString(moduleRegistry: ModuleRegistry, options: RuntimeCachin const plugin = moduleRegistry.use( 'workbox-cacheable-response', 'CacheableResponsePlugin'); - pluginCode = `new ${plugin}(${stringifyWithoutComments(pluginConfig)})`; - + plugins.push(`new ${plugin}(${stringifyWithoutComments(options.cacheableResponse!)})`); break; } @@ -97,8 +89,7 @@ function getOptionsString(moduleRegistry: ModuleRegistry, options: RuntimeCachin const plugin = moduleRegistry.use( 'workbox-expiration', 'ExpirationPlugin'); - pluginCode = `new ${plugin}(${stringifyWithoutComments(pluginConfig)})`; - + plugins.push(`new ${plugin}(${stringifyWithoutComments(options.expiration!)})`); break; } @@ -106,17 +97,14 @@ function getOptionsString(moduleRegistry: ModuleRegistry, options: RuntimeCachin const plugin = moduleRegistry.use( 'workbox-precaching', 'PrecacheFallbackPlugin'); - pluginCode = `new ${plugin}(${stringifyWithoutComments(pluginConfig)})`; - + plugins.push(`new ${plugin}(${stringifyWithoutComments(options.precacheFallback!)})`); break; } default: { - throw new Error(errors['bad-runtime-caching-config'] + pluginName); + throw new Error(errors['bad-runtime-caching-config'] + optionName); } } - - plugins.push(pluginCode); } if (Object.keys(handlerOptions).length > 0 || plugins.length > 0) { @@ -130,7 +118,7 @@ function getOptionsString(moduleRegistry: ModuleRegistry, options: RuntimeCachin } } -module.exports = (moduleRegistry: ModuleRegistry, runtimeCaching: Array) => { +export default function(moduleRegistry: ModuleRegistry, runtimeCaching: Array): Array { return runtimeCaching.map((entry) => { const method = entry.method || 'GET'; @@ -142,8 +130,6 @@ module.exports = (moduleRegistry: ModuleRegistry, runtimeCaching: Array Boolean(entry)); // Remove undefined map() return values. + // '' will be filtered out. + return ''; + }).filter((entry) => Boolean(entry)); }; From f1bc1a80154cdb46695a0811f583228d74743630 Mon Sep 17 00:00:00 2001 From: Jeff Posnick Date: Sat, 16 Jan 2021 10:32:32 -0500 Subject: [PATCH 07/80] More WIP --- .gitignore | 2 +- gulp-tasks/build-packages.js | 6 ++- package-lock.json | 53 +++++++++++++++++++ package.json | 3 ++ packages/workbox-build/src/inject-manifest.ts | 2 +- packages/workbox-build/src/lib/bundle.ts | 6 +-- .../workbox-build/src/lib/get-file-details.ts | 2 +- .../workbox-build/src/lib/get-file-size.ts | 2 +- .../src/lib/maximum-size-transform.ts | 2 +- .../src/lib/populate-sw-template.ts | 2 +- .../src/lib/replace-and-update-source-map.ts | 2 +- .../src/rollup-plugin-off-main-thread.d.ts | 1 + .../workbox-build/src/source-map-url.d.ts | 1 + packages/workbox-build/tsconfig.json | 9 ++++ 14 files changed, 81 insertions(+), 12 deletions(-) create mode 100644 packages/workbox-build/src/rollup-plugin-off-main-thread.d.ts create mode 100644 packages/workbox-build/src/source-map-url.d.ts diff --git a/.gitignore b/.gitignore index d7ae53213..91267075b 100644 --- a/.gitignore +++ b/.gitignore @@ -21,7 +21,7 @@ firebase-debug.log # Generated TypeScript files and build data tsconfig.tsbuildinfo packages/workbox-*/**/*.d.ts -!packages/workbox-cli/src/index.d.ts +!packages/workbox-*/src/**/*.d.ts packages/workbox-*/**/*.js !packages/workbox-build/**/*.js !packages/workbox-webpack-plugin/**/*.js diff --git a/gulp-tasks/build-packages.js b/gulp-tasks/build-packages.js index 8fe014ca8..bff44f9da 100644 --- a/gulp-tasks/build-packages.js +++ b/gulp-tasks/build-packages.js @@ -23,9 +23,11 @@ async function cleanPackage(packagePath) { if (await fse.pathExists(upath.join(packagePath, 'src', 'index.ts'))) { // Store the list of deleted files, so we can delete directories after. const deletedPaths = await del([ - upath.join(packagePath, '**/*.+(js|mjs|d.ts)'), + `${packagePath}/**/*.+(js|mjs|d.ts)`, // Don't delete files in node_modules. - '!**/node_modules', '!**/node_modules/**/*', + '!**/node_modules/**/*', + // Don't delete anything under src. + `!${packagePath}/src/**/*`, ]); // Any directories in `deletedPaths` that are top-level directories to the diff --git a/package-lock.json b/package-lock.json index 531ede233..b6d528c50 100644 --- a/package-lock.json +++ b/package-lock.json @@ -4166,6 +4166,53 @@ "integrity": "sha512-RbzJvlNzmRq5c3O09UipeuXno4tA1FE6ikOjxZK0tuxVv3412l64l5t1W5pj4+rJq9vpkm/kwiR07aZXnsKPxw==", "dev": true }, + "@types/babel__core": { + "version": "7.1.12", + "resolved": "https://registry.npmjs.org/@types/babel__core/-/babel__core-7.1.12.tgz", + "integrity": "sha512-wMTHiiTiBAAPebqaPiPDLFA4LYPKr6Ph0Xq/6rq1Ur3v66HXyG+clfR9CNETkD7MQS8ZHvpQOtA53DLws5WAEQ==", + "dev": true, + "requires": { + "@babel/parser": "^7.1.0", + "@babel/types": "^7.0.0", + "@types/babel__generator": "*", + "@types/babel__template": "*", + "@types/babel__traverse": "*" + } + }, + "@types/babel__generator": { + "version": "7.6.2", + "resolved": "https://registry.npmjs.org/@types/babel__generator/-/babel__generator-7.6.2.tgz", + "integrity": "sha512-MdSJnBjl+bdwkLskZ3NGFp9YcXGx5ggLpQQPqtgakVhsWK0hTtNYhjpZLlWQTviGTvF8at+Bvli3jV7faPdgeQ==", + "dev": true, + "requires": { + "@babel/types": "^7.0.0" + } + }, + "@types/babel__preset-env": { + "version": "7.9.1", + "resolved": "https://registry.npmjs.org/@types/babel__preset-env/-/babel__preset-env-7.9.1.tgz", + "integrity": "sha512-kkCHo5fk24m3gcH7oVhRLdw6xGF2tog5rc8/CbXIyTSYSO0NhStjEYCaEmRjs5VB5Jy5Wbj+0QvuGdxuGdvAfQ==", + "dev": true + }, + "@types/babel__template": { + "version": "7.4.0", + "resolved": "https://registry.npmjs.org/@types/babel__template/-/babel__template-7.4.0.tgz", + "integrity": "sha512-NTPErx4/FiPCGScH7foPyr+/1Dkzkni+rHiYHHoTjvwou7AQzJkNeD60A9CXRy+ZEN2B1bggmkTMCDb+Mv5k+A==", + "dev": true, + "requires": { + "@babel/parser": "^7.1.0", + "@babel/types": "^7.0.0" + } + }, + "@types/babel__traverse": { + "version": "7.11.0", + "resolved": "https://registry.npmjs.org/@types/babel__traverse/-/babel__traverse-7.11.0.tgz", + "integrity": "sha512-kSjgDMZONiIfSH1Nxcr5JIRMwUetDki63FSQfpTCz8ogF3Ulqm8+mr5f78dUYs6vMiB6gBusQqfQmBvHZj/lwg==", + "dev": true, + "requires": { + "@babel/types": "^7.3.0" + } + }, "@types/common-tags": { "version": "1.8.0", "resolved": "https://registry.npmjs.org/@types/common-tags/-/common-tags-1.8.0.tgz", @@ -4254,6 +4301,12 @@ "@types/node": "*" } }, + "@types/stringify-object": { + "version": "3.3.0", + "resolved": "https://registry.npmjs.org/@types/stringify-object/-/stringify-object-3.3.0.tgz", + "integrity": "sha512-ryxTolaNg1l809rknW9q9T7wG8QHcjtZX6syJx7kpOLY2qev75VzC9HMVimUxlA1YzjpGsDI29yLjHBotqhUhA==", + "dev": true + }, "@typescript-eslint/eslint-plugin": { "version": "2.34.0", "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-2.34.0.tgz", diff --git a/package.json b/package.json index 92ec4c524..3d3e97754 100644 --- a/package.json +++ b/package.json @@ -48,10 +48,13 @@ "@rollup/plugin-multi-entry": "^4.0.0", "@rollup/plugin-node-resolve": "^9.0.0", "@rollup/plugin-replace": "^2.3.3", + "@types/babel__core": "^7.1.12", + "@types/babel__preset-env": "^7.9.1", "@types/common-tags": "^1.8.0", "@types/estree": "0.0.45", "@types/fs-extra": "^9.0.5", "@types/lodash": "^4.14.165", + "@types/stringify-object": "^3.3.0", "@typescript-eslint/eslint-plugin": "^2.30.0", "@typescript-eslint/parser": "^2.30.0", "acorn": "^8.0.1", diff --git a/packages/workbox-build/src/inject-manifest.ts b/packages/workbox-build/src/inject-manifest.ts index 5ba98987a..a3a4736e0 100644 --- a/packages/workbox-build/src/inject-manifest.ts +++ b/packages/workbox-build/src/inject-manifest.ts @@ -195,7 +195,7 @@ export default async function(config: InjectManifestOptions): Promise & {globPattern: string}) { let globbedFiles: Array; - let warning: string; + let warning = ''; try { globbedFiles = glob.sync(globPattern, { diff --git a/packages/workbox-build/src/lib/get-file-size.ts b/packages/workbox-build/src/lib/get-file-size.ts index 3d6eb0993..eadf72bbc 100644 --- a/packages/workbox-build/src/lib/get-file-size.ts +++ b/packages/workbox-build/src/lib/get-file-size.ts @@ -10,7 +10,7 @@ import fse from 'fs-extra'; import errors from './errors'; -export default function(file: string): number { +export default function(file: string): number | null { try { const stat = fse.statSync(file); if (!stat.isFile()) { diff --git a/packages/workbox-build/src/lib/maximum-size-transform.ts b/packages/workbox-build/src/lib/maximum-size-transform.ts index cd98646c6..bf7cf6401 100644 --- a/packages/workbox-build/src/lib/maximum-size-transform.ts +++ b/packages/workbox-build/src/lib/maximum-size-transform.ts @@ -12,7 +12,7 @@ import {ManifestTransform} from '../types'; export default function (maximumFileSizeToCacheInBytes: number): ManifestTransform { return (originalManifest) => { - const warnings = []; + const warnings: Array = []; const manifest = originalManifest.filter((entry) => { if (entry.size <= maximumFileSizeToCacheInBytes) { return true; diff --git a/packages/workbox-build/src/lib/populate-sw-template.ts b/packages/workbox-build/src/lib/populate-sw-template.ts index df2023fa7..7093be5d7 100644 --- a/packages/workbox-build/src/lib/populate-sw-template.ts +++ b/packages/workbox-build/src/lib/populate-sw-template.ts @@ -56,7 +56,7 @@ export default function({ ); } - let offlineAnalyticsConfigString: string; + let offlineAnalyticsConfigString: string | undefined = undefined; if (offlineGoogleAnalytics) { // If offlineGoogleAnalytics is a truthy value, we need to convert it to the // format expected by the template. diff --git a/packages/workbox-build/src/lib/replace-and-update-source-map.ts b/packages/workbox-build/src/lib/replace-and-update-source-map.ts index 537d885b6..87180df4b 100644 --- a/packages/workbox-build/src/lib/replace-and-update-source-map.ts +++ b/packages/workbox-build/src/lib/replace-and-update-source-map.ts @@ -48,7 +48,7 @@ export default async function({ let pos: number; let src = originalSource; - const replacements = []; + const replacements: Array<{line: number; column: number}> = []; let lineNum = 0; let filePos = 0; diff --git a/packages/workbox-build/src/rollup-plugin-off-main-thread.d.ts b/packages/workbox-build/src/rollup-plugin-off-main-thread.d.ts new file mode 100644 index 000000000..ced888a2c --- /dev/null +++ b/packages/workbox-build/src/rollup-plugin-off-main-thread.d.ts @@ -0,0 +1 @@ +declare module '@surma/rollup-plugin-off-main-thread'; diff --git a/packages/workbox-build/src/source-map-url.d.ts b/packages/workbox-build/src/source-map-url.d.ts new file mode 100644 index 000000000..8958463c8 --- /dev/null +++ b/packages/workbox-build/src/source-map-url.d.ts @@ -0,0 +1 @@ +declare module 'source-map-url'; diff --git a/packages/workbox-build/tsconfig.json b/packages/workbox-build/tsconfig.json index 422b24400..347b3fb93 100644 --- a/packages/workbox-build/tsconfig.json +++ b/packages/workbox-build/tsconfig.json @@ -1,6 +1,7 @@ { "extends": "../../tsconfig", "compilerOptions": { + "allowSyntheticDefaultImports": true, "module": "CommonJS", "outDir": "build", "resolveJsonModule": true, @@ -11,5 +12,13 @@ "include": [ "src/**/*.ts", "src/cdn-details.json" + ], + "references": [ + {"path": "../workbox-background-sync/"}, + {"path": "../workbox-broadcast-update/"}, + {"path": "../workbox-cacheable-response/"}, + {"path": "../workbox-core/"}, + {"path": "../workbox-expiration/"}, + {"path": "../workbox-google-analytics/"} ] } From 85b6affba2d6bf194c20109b4d39c859e316c75b Mon Sep 17 00:00:00 2001 From: Jeff Posnick Date: Sat, 16 Jan 2021 16:18:20 -0500 Subject: [PATCH 08/80] More WIP --- gulp-tasks/build-node-packages.js | 9 + package-lock.json | 242 ++++ package.json | 1 + packages/workbox-build/src/generate-sw.ts | 9 +- packages/workbox-build/src/get-manifest.ts | 7 +- packages/workbox-build/src/inject-manifest.ts | 7 +- .../workbox-build/src/lib/validate-options.ts | 58 +- packages/workbox-build/src/types.guard.ts | 1019 +++++++++++++++++ packages/workbox-build/src/types.ts | 13 +- 9 files changed, 1346 insertions(+), 19 deletions(-) create mode 100644 packages/workbox-build/src/types.guard.ts diff --git a/gulp-tasks/build-node-packages.js b/gulp-tasks/build-node-packages.js index c8ec54d4f..1352a3072 100644 --- a/gulp-tasks/build-node-packages.js +++ b/gulp-tasks/build-node-packages.js @@ -8,6 +8,7 @@ const {parallel} = require('gulp'); const execa = require('execa'); +const fse = require('fs-extra'); const upath = require('upath'); const constants = require('./utils/constants'); @@ -29,6 +30,14 @@ async function buildNodePackage(packagePath) { } async function buildNodeTSPackage(packagePath) { + const typesPath = upath.join(packagePath, 'src', 'types.ts'); + if (fse.existsSync(typesPath)) { + await execa('ts-auto-guard', [typesPath], { + cwd: packagePath, + preferLocal: true, + }); + } + await execa('tsc', ['-b', packagePath], {preferLocal: true}); } diff --git a/package-lock.json b/package-lock.json index b6d528c50..c96b24a89 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1096,6 +1096,16 @@ "to-fast-properties": "^2.0.0" } }, + "@dsherret/to-absolute-glob": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/@dsherret/to-absolute-glob/-/to-absolute-glob-2.0.2.tgz", + "integrity": "sha1-H2R13IvZdM6gei2vOGSzF7HdMyw=", + "dev": true, + "requires": { + "is-absolute": "^1.0.0", + "is-negated-glob": "^1.0.0" + } + }, "@eslint/eslintrc": { "version": "0.1.3", "resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-0.1.3.tgz", @@ -4166,6 +4176,28 @@ "integrity": "sha512-RbzJvlNzmRq5c3O09UipeuXno4tA1FE6ikOjxZK0tuxVv3412l64l5t1W5pj4+rJq9vpkm/kwiR07aZXnsKPxw==", "dev": true }, + "@ts-morph/common": { + "version": "0.6.0", + "resolved": "https://registry.npmjs.org/@ts-morph/common/-/common-0.6.0.tgz", + "integrity": "sha512-pI35nZz5bs3tL3btSVX2cWkAE8rc80F+Fn4TwSC6bQvn7fgn9IyLXVcAfpG6X6NBY5wN9TkSWXn/QYUkBvR/Fw==", + "dev": true, + "requires": { + "@dsherret/to-absolute-glob": "^2.0.2", + "fast-glob": "^3.2.4", + "fs-extra": "^9.0.1", + "is-negated-glob": "^1.0.0", + "multimatch": "^4.0.0", + "typescript": "~4.0.2" + }, + "dependencies": { + "typescript": { + "version": "4.0.5", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.0.5.tgz", + "integrity": "sha512-ywmr/VrTVCmNTJ6iV2LwIrfG1P+lv6luD8sUJs+2eI9NLGigaN+nUQc13iHqisq7bra9lnmUSYqbJvegraBOPQ==", + "dev": true + } + } + }, "@types/babel__core": { "version": "7.1.12", "resolved": "https://registry.npmjs.org/@types/babel__core/-/babel__core-7.1.12.tgz", @@ -4213,6 +4245,18 @@ "@babel/types": "^7.3.0" } }, + "@types/command-line-args": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/@types/command-line-args/-/command-line-args-5.0.0.tgz", + "integrity": "sha512-4eOPXyn5DmP64MCMF8ePDvdlvlzt2a+F8ZaVjqmh2yFCpGjc1kI3kGnCFYX9SCsGTjQcWIyVZ86IHCEyjy/MNg==", + "dev": true + }, + "@types/command-line-usage": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/@types/command-line-usage/-/command-line-usage-5.0.1.tgz", + "integrity": "sha512-/xUgezxxYePeXhg5S04hUjxG9JZi+rJTs1+4NwpYPfSaS7BeDa6tVJkH6lN9Cb6rl8d24Fi2uX0s0Ngg2JT6gg==", + "dev": true + }, "@types/common-tags": { "version": "1.8.0", "resolved": "https://registry.npmjs.org/@types/common-tags/-/common-tags-1.8.0.tgz", @@ -4307,6 +4351,18 @@ "integrity": "sha512-ryxTolaNg1l809rknW9q9T7wG8QHcjtZX6syJx7kpOLY2qev75VzC9HMVimUxlA1YzjpGsDI29yLjHBotqhUhA==", "dev": true }, + "@types/strip-bom": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/@types/strip-bom/-/strip-bom-3.0.0.tgz", + "integrity": "sha1-FKjsOVbC6B7bdSB5CuzyHCkK69I=", + "dev": true + }, + "@types/strip-json-comments": { + "version": "0.0.30", + "resolved": "https://registry.npmjs.org/@types/strip-json-comments/-/strip-json-comments-0.0.30.tgz", + "integrity": "sha512-7NQmHra/JILCd1QqpSzl8+mJRc8ZHz3uDm8YV1Ks9IhK0epEiTw8aIErbvH9PI+6XbqhyIQy3462nEsn7UVzjQ==", + "dev": true + }, "@typescript-eslint/eslint-plugin": { "version": "2.34.0", "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-2.34.0.tgz", @@ -4855,6 +4911,12 @@ "integrity": "sha1-45sJrqne+Gao8gbiiK9jkZuuOcQ=", "dev": true }, + "array-back": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/array-back/-/array-back-3.1.0.tgz", + "integrity": "sha512-TkuxA4UCOvxuDK6NZYXCalszEzj+TLszyASooky+i742l9TqsOdYCMJJupxRic61hwquNtppB3hgcuq9SVSH1Q==", + "dev": true + }, "array-differ": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/array-differ/-/array-differ-3.0.0.tgz", @@ -6070,6 +6132,12 @@ "readable-stream": "^2.3.5" } }, + "code-block-writer": { + "version": "10.1.1", + "resolved": "https://registry.npmjs.org/code-block-writer/-/code-block-writer-10.1.1.tgz", + "integrity": "sha512-67ueh2IRGst/51p0n6FvPrnRjAGHY5F8xdjkgrYE7DDzpJe6qA07RYQ9VcoUeo5ATOjSOiWpSL3SWBRRbempMw==", + "dev": true + }, "code-point-at": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/code-point-at/-/code-point-at-1.1.0.tgz", @@ -6160,6 +6228,55 @@ "integrity": "sha512-mu4KKKNuW8TvkfpW/H88HBPeILubBS6T94BdD1VWBXNXfiyqVtwUCVNO1GeNOBTsIswzsMjWlycYr+77F5b84g==", "dev": true }, + "command-line-args": { + "version": "5.1.1", + "resolved": "https://registry.npmjs.org/command-line-args/-/command-line-args-5.1.1.tgz", + "integrity": "sha512-hL/eG8lrll1Qy1ezvkant+trihbGnaKaeEjj6Scyr3DN+RC7iQ5Rz84IeLERfAWDGo0HBSNAakczwgCilDXnWg==", + "dev": true, + "requires": { + "array-back": "^3.0.1", + "find-replace": "^3.0.0", + "lodash.camelcase": "^4.3.0", + "typical": "^4.0.0" + } + }, + "command-line-usage": { + "version": "6.1.1", + "resolved": "https://registry.npmjs.org/command-line-usage/-/command-line-usage-6.1.1.tgz", + "integrity": "sha512-F59pEuAR9o1SF/bD0dQBDluhpT4jJQNWUHEuVBqpDmCUo6gPjCi+m9fCWnWZVR/oG6cMTUms4h+3NPl74wGXvA==", + "dev": true, + "requires": { + "array-back": "^4.0.1", + "chalk": "^2.4.2", + "table-layout": "^1.0.1", + "typical": "^5.2.0" + }, + "dependencies": { + "array-back": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/array-back/-/array-back-4.0.1.tgz", + "integrity": "sha512-Z/JnaVEXv+A9xabHzN43FiiiWEE7gPCRXMrVmRm00tWbjZRul1iHm7ECzlyNq1p4a4ATXz+G9FJ3GqGOkOV3fg==", + "dev": true + }, + "chalk": { + "version": "2.4.2", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz", + "integrity": "sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==", + "dev": true, + "requires": { + "ansi-styles": "^3.2.1", + "escape-string-regexp": "^1.0.5", + "supports-color": "^5.3.0" + } + }, + "typical": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/typical/-/typical-5.2.0.tgz", + "integrity": "sha512-dvdQgNDNJo+8B2uBQoqdb11eUCE1JQXhvjC/CZtgvZseVd5TYMXnq0+vuUemXbd/Se29cTaUuPX3YIc2xgbvIg==", + "dev": true + } + } + }, "commander": { "version": "4.1.1", "resolved": "https://registry.npmjs.org/commander/-/commander-4.1.1.tgz", @@ -8745,6 +8862,15 @@ } } }, + "find-replace": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/find-replace/-/find-replace-3.0.0.tgz", + "integrity": "sha512-6Tb2myMioCAgv5kfvP5/PkZZ/ntTpVK39fHY7WkWBgvbeE+VHd/tZuZ4mrC+bxh4cfOZeYKVPaJIZtZXV7GNCQ==", + "dev": true, + "requires": { + "array-back": "^3.0.1" + } + }, "find-up": { "version": "4.1.0", "resolved": "https://registry.npmjs.org/find-up/-/find-up-4.1.0.tgz", @@ -11967,6 +12093,12 @@ "integrity": "sha1-DM8tiRZq8Ds2Y8eWU4t1rG4RTZ0=", "dev": true }, + "lodash.camelcase": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/lodash.camelcase/-/lodash.camelcase-4.3.0.tgz", + "integrity": "sha1-soqmKIorn8ZRA1x3EfZathkDMaY=", + "dev": true + }, "lodash.clonedeep": { "version": "4.5.0", "resolved": "https://registry.npmjs.org/lodash.clonedeep/-/lodash.clonedeep-4.5.0.tgz", @@ -14827,6 +14959,12 @@ "strip-indent": "^3.0.0" } }, + "reduce-flatten": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/reduce-flatten/-/reduce-flatten-2.0.0.tgz", + "integrity": "sha512-EJ4UNY/U1t2P/2k6oqotuX2Cc3T6nxJwsM0N0asT7dhrtH1ltUxDn4NalSYmPE2rCkVpcf/X6R0wDwcFpzhd4w==", + "dev": true + }, "regenerate": { "version": "1.4.1", "resolved": "https://registry.npmjs.org/regenerate/-/regenerate-1.4.1.tgz", @@ -16471,6 +16609,32 @@ } } }, + "table-layout": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/table-layout/-/table-layout-1.0.1.tgz", + "integrity": "sha512-dEquqYNJiGwY7iPfZ3wbXDI944iqanTSchrACLL2nOB+1r+h1Nzu2eH+DuPPvWvm5Ry7iAPeFlgEtP5bIp5U7Q==", + "dev": true, + "requires": { + "array-back": "^4.0.1", + "deep-extend": "~0.6.0", + "typical": "^5.2.0", + "wordwrapjs": "^4.0.0" + }, + "dependencies": { + "array-back": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/array-back/-/array-back-4.0.1.tgz", + "integrity": "sha512-Z/JnaVEXv+A9xabHzN43FiiiWEE7gPCRXMrVmRm00tWbjZRul1iHm7ECzlyNq1p4a4ATXz+G9FJ3GqGOkOV3fg==", + "dev": true + }, + "typical": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/typical/-/typical-5.2.0.tgz", + "integrity": "sha512-dvdQgNDNJo+8B2uBQoqdb11eUCE1JQXhvjC/CZtgvZseVd5TYMXnq0+vuUemXbd/Se29cTaUuPX3YIc2xgbvIg==", + "dev": true + } + } + }, "taffydb": { "version": "2.6.2", "resolved": "https://registry.npmjs.org/taffydb/-/taffydb-2.6.2.tgz", @@ -16990,6 +17154,60 @@ "integrity": "sha1-n5up2e+odkw4dpi8v+sshI8RrbM=", "dev": true }, + "ts-auto-guard": { + "version": "1.0.0-alpha.12", + "resolved": "https://registry.npmjs.org/ts-auto-guard/-/ts-auto-guard-1.0.0-alpha.12.tgz", + "integrity": "sha512-VFSysqfBFTFW+nAINh5DtVHM4nDGH9bCLSiBvZVc2LvwG0BW+QKDKkYrxU83DCQVWg7fda5vERqfDm5UnxNUVQ==", + "dev": true, + "requires": { + "@ts-morph/common": "^0.6.0", + "@types/command-line-args": "^5.0.0", + "@types/command-line-usage": "^5.0.1", + "@types/lodash": "^4.14.160", + "command-line-args": "^5.1.1", + "command-line-usage": "^6.1.0", + "lodash": "^4.17.20", + "ts-morph": "^8.1.2", + "tsconfig": "^7.0.0" + } + }, + "ts-morph": { + "version": "8.2.0", + "resolved": "https://registry.npmjs.org/ts-morph/-/ts-morph-8.2.0.tgz", + "integrity": "sha512-NHHWu+7I2/AOZiTni5w3f+xCfIxrkzPCcQbTGa81Yk3pr23a4h9xLLEE6tIGuYIubWjkjr9QVC3ITqgmA5touQ==", + "dev": true, + "requires": { + "@dsherret/to-absolute-glob": "^2.0.2", + "@ts-morph/common": "~0.6.0", + "code-block-writer": "^10.1.0" + } + }, + "tsconfig": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/tsconfig/-/tsconfig-7.0.0.tgz", + "integrity": "sha512-vZXmzPrL+EmC4T/4rVlT2jNVMWCi/O4DIiSj3UHg1OE5kCKbk4mfrXc6dZksLgRM/TZlKnousKH9bbTazUWRRw==", + "dev": true, + "requires": { + "@types/strip-bom": "^3.0.0", + "@types/strip-json-comments": "0.0.30", + "strip-bom": "^3.0.0", + "strip-json-comments": "^2.0.0" + }, + "dependencies": { + "strip-bom": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/strip-bom/-/strip-bom-3.0.0.tgz", + "integrity": "sha1-IzTBjpx1n3vdVv3vfprj1YjmjtM=", + "dev": true + }, + "strip-json-comments": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-2.0.1.tgz", + "integrity": "sha1-PFMZQukIwml8DsNEhYwobHygpgo=", + "dev": true + } + } + }, "tslib": { "version": "1.14.1", "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.14.1.tgz", @@ -17084,6 +17302,12 @@ "integrity": "sha512-BLbiRkiBzAwsjut4x/dsibSTB6yWpwT5qWmC2OfuCg3GgVQCSgMs4vEctYPhsaGtd0AeuuHMkjZ2h2WG8MSzRw==", "dev": true }, + "typical": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/typical/-/typical-4.0.0.tgz", + "integrity": "sha512-VAH4IvQ7BDFYglMd7BPRDfLgxZZX4O4TFcRDA6EN5X7erNJJq+McIEp8np9aVtxrCJ6qx4GTYVfOWNjcqwZgRw==", + "dev": true + }, "uc.micro": { "version": "1.0.6", "resolved": "https://registry.npmjs.org/uc.micro/-/uc.micro-1.0.6.tgz", @@ -17848,6 +18072,24 @@ "integrity": "sha1-J1hIEIkUVqQXHI0CJkQa3pDLyus=", "dev": true }, + "wordwrapjs": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/wordwrapjs/-/wordwrapjs-4.0.0.tgz", + "integrity": "sha512-Svqw723a3R34KvsMgpjFBYCgNOSdcW3mQFK4wIfhGQhtaFVOJmdYoXgi63ne3dTlWgatVcUc7t4HtQ/+bUVIzQ==", + "dev": true, + "requires": { + "reduce-flatten": "^2.0.0", + "typical": "^5.0.0" + }, + "dependencies": { + "typical": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/typical/-/typical-5.2.0.tgz", + "integrity": "sha512-dvdQgNDNJo+8B2uBQoqdb11eUCE1JQXhvjC/CZtgvZseVd5TYMXnq0+vuUemXbd/Se29cTaUuPX3YIc2xgbvIg==", + "dev": true + } + } + }, "worker-farm": { "version": "1.7.0", "resolved": "https://registry.npmjs.org/worker-farm/-/worker-farm-1.7.0.tgz", diff --git a/package.json b/package.json index 3d3e97754..25b6d4eff 100644 --- a/package.json +++ b/package.json @@ -107,6 +107,7 @@ "service-worker-mock": "^1.9.3", "sinon": "^9.0.3", "tempy": "^0.6.0", + "ts-auto-guard": "^1.0.0-alpha.12", "type-fest": "^0.20.2", "typescript": "^3.9.7", "upath": "^1.2.0", diff --git a/packages/workbox-build/src/generate-sw.ts b/packages/workbox-build/src/generate-sw.ts index cbdde702d..a207556f2 100644 --- a/packages/workbox-build/src/generate-sw.ts +++ b/packages/workbox-build/src/generate-sw.ts @@ -8,11 +8,10 @@ import upath from 'upath'; -import {BuildResult, GenerateSWOptions} from './types'; -import generateSWSchema from './options/schema/generate-sw'; +import {BuildResult} from './types'; import getFileManifestEntries from './lib/get-file-manifest-entries'; import rebasePath from './lib/rebase-path'; -import validate from './lib/validate-options'; +import {validateGenerateSWOptions} from './lib/validate-options'; import writeServiceWorkerUsingDefaultTemplate from './lib/write-sw-using-default-template'; // eslint-disable-next-line jsdoc/newline-after-description @@ -194,8 +193,8 @@ import writeServiceWorkerUsingDefaultTemplate from './lib/write-sw-using-default * * @memberof module:workbox-build */ -export default async function(config: GenerateSWOptions): Promise { - const options: GenerateSWOptions = validate(config, generateSWSchema); +export default async function(config: unknown): Promise { + const options = validateGenerateSWOptions(config); if (options.globDirectory) { // Make sure we leave swDest out of the precache manifest. diff --git a/packages/workbox-build/src/get-manifest.ts b/packages/workbox-build/src/get-manifest.ts index f34fd5642..e05ad6690 100644 --- a/packages/workbox-build/src/get-manifest.ts +++ b/packages/workbox-build/src/get-manifest.ts @@ -8,8 +8,7 @@ import {GetManifestResult, GetManifestOptions} from './types'; import getFileManifestEntries from './lib/get-file-manifest-entries'; -import getManifestSchema from './options/schema/get-manifest'; -import validate from './lib/validate-options'; +import {validateGetManifestOptions} from './lib/validate-options'; // eslint-disable-next-line jsdoc/newline-after-description /** @@ -89,8 +88,8 @@ import validate from './lib/validate-options'; * * @memberof module:workbox-build */ -export default async function(config: GetManifestOptions): Promise { - const options: GetManifestOptions = validate(config, getManifestSchema); +export default async function(config: unknown): Promise { + const options = validateGetManifestOptions(config); return await getFileManifestEntries(options); } diff --git a/packages/workbox-build/src/inject-manifest.ts b/packages/workbox-build/src/inject-manifest.ts index a3a4736e0..d7e8f739a 100644 --- a/packages/workbox-build/src/inject-manifest.ts +++ b/packages/workbox-build/src/inject-manifest.ts @@ -17,10 +17,9 @@ import {BuildResult, InjectManifestOptions} from './types'; import errors from './lib/errors'; import escapeRegexp from './lib/escape-regexp'; import getFileManifestEntries from './lib/get-file-manifest-entries'; -import injectManifestSchema from './options/schema/inject-manifest'; import rebasePath from './lib/rebase-path'; import replaceAndUpdateSourceMap from './lib/replace-and-update-source-map'; -import validate from './lib/validate-options'; +import {validateInjectManifestOptions} from './lib/validate-options'; // eslint-disable-next-line jsdoc/newline-after-description /** @@ -117,8 +116,8 @@ import validate from './lib/validate-options'; * * @memberof module:workbox-build */ -export default async function(config: InjectManifestOptions): Promise { - const options: InjectManifestOptions = validate(config, injectManifestSchema); +export default async function(config: unknown): Promise { + const options = validateInjectManifestOptions(config); // Make sure we leave swSrc and swDest out of the precache manifest. for (const file of [options.swSrc, options.swDest]) { diff --git a/packages/workbox-build/src/lib/validate-options.ts b/packages/workbox-build/src/lib/validate-options.ts index afe6d338f..9e28ab83f 100644 --- a/packages/workbox-build/src/lib/validate-options.ts +++ b/packages/workbox-build/src/lib/validate-options.ts @@ -6,7 +6,59 @@ https://opensource.org/licenses/MIT. */ -export default function(options: any, schema: any): any { - // TODO: Switch to TypeScript validation. - return options; +import {isGenerateSWOptions, isGetManifestOptions, isInjectManifestOptions} from '../types.guard'; +import {GenerateSWOptions, GetManifestOptions, InjectManifestOptions} from '../types'; + +const defaults = { + babelPresetEnvTargets: ['chrome >= 56'], + cleanupOutdatedCaches: false, + clientsClaim: false, + compileSrc: true, + disableDevLogs: false, + exclude: [ + /\.map$/, + /^manifest.*\.js$/, + ], + globFollow: true, + globIgnores: ['**/node_modules/**/*'], + globPatterns: ['**/*.{js,css,html}'], + globStrict: true, + injectionPoint: 'self.__WB_MANIFEST', + inlineWorkboxRuntime: false, + maximumFileSizeToCacheInBytes: 2 * 1024 * 1024, + mode: 'production', + navigateFallback: null, + navigationPreload: false, + offlineGoogleAnalytics: false, + purgeOnQuotaError: true, + skipWaiting: false, + sourcemap: true, + swDestFilename: 'service-worker.js', +}; + +export function validateGenerateSWOptions(input: unknown): GenerateSWOptions { + const optionsWithDefaults = Object.assign({}, defaults, input); + if(isGenerateSWOptions(optionsWithDefaults)) { + return optionsWithDefaults; + } else { + throw new Error('Validation failed.'); + } +} + +export function validateGetManifestOptions(input: unknown): GetManifestOptions { + const optionsWithDefaults = Object.assign({}, defaults, input); + if(isGetManifestOptions(optionsWithDefaults)) { + return optionsWithDefaults; + } else { + throw new Error('Validation failed.'); + } +} + +export function validateInjectManifestOptions(input: unknown): InjectManifestOptions { + const optionsWithDefaults = Object.assign({}, defaults, input); + if(isInjectManifestOptions(optionsWithDefaults)) { + return optionsWithDefaults; + } else { + throw new Error('Validation failed.'); + } } diff --git a/packages/workbox-build/src/types.guard.ts b/packages/workbox-build/src/types.guard.ts new file mode 100644 index 000000000..1d0de4d0f --- /dev/null +++ b/packages/workbox-build/src/types.guard.ts @@ -0,0 +1,1019 @@ +/* + * Generated type guards for "types.ts". + * WARNING: Do not manually change this file. + */ +import { GenerateSWOptions, GetManifestOptions, InjectManifestOptions, WebpackGenerateSWOptions, WebpackInjectManifestOptions } from "./types"; + +export function isGenerateSWOptions(obj: any, _argumentName?: string): obj is GenerateSWOptions { + return ( + ((obj !== null && + typeof obj === "object" || + typeof obj === "function") && + (typeof obj.globDirectory === "undefined" || + typeof obj.globDirectory === "string") && + (typeof obj.globFollow === "undefined" || + obj.globFollow === false || + obj.globFollow === true) && + (typeof obj.globIgnores === "undefined" || + Array.isArray(obj.globIgnores) && + obj.globIgnores.every((e: any) => + typeof e === "string" + )) && + (typeof obj.globPatterns === "undefined" || + Array.isArray(obj.globPatterns) && + obj.globPatterns.every((e: any) => + typeof e === "string" + )) && + (typeof obj.globStrict === "undefined" || + obj.globStrict === false || + obj.globStrict === true) && + (obj.templatedURLs !== null && + typeof obj.templatedURLs === "object" || + typeof obj.templatedURLs === "function") || + (obj !== null && + typeof obj === "object" || + typeof obj === "function") && + (typeof obj.babelPresetEnvTargets === "undefined" || + Array.isArray(obj.babelPresetEnvTargets) && + obj.babelPresetEnvTargets.every((e: any) => + typeof e === "string" + )) && + (typeof obj.cacheId === "undefined" || + typeof obj.cacheId === "string") && + (typeof obj.cleanupOutdatedCaches === "undefined" || + obj.cleanupOutdatedCaches === false || + obj.cleanupOutdatedCaches === true) && + (typeof obj.clientsClaim === "undefined" || + obj.clientsClaim === false || + obj.clientsClaim === true) && + (typeof obj.directoryIndex === "undefined" || + typeof obj.directoryIndex === "string") && + (typeof obj.disableDevLogs === "undefined" || + obj.disableDevLogs === false || + obj.disableDevLogs === true) && + (typeof obj.ignoreURLParametersMatching === "undefined" || + Array.isArray(obj.ignoreURLParametersMatching) && + obj.ignoreURLParametersMatching.every((e: any) => + e instanceof RegExp + )) && + (typeof obj.importScripts === "undefined" || + Array.isArray(obj.importScripts) && + obj.importScripts.every((e: any) => + typeof e === "string" + )) && + (typeof obj.inlineWorkboxRuntime === "undefined" || + obj.inlineWorkboxRuntime === false || + obj.inlineWorkboxRuntime === true) && + (typeof obj.mode === "undefined" || + typeof obj.mode === "string") && + (typeof obj.navigateFallback === "undefined" || + typeof obj.navigateFallback === "string") && + (typeof obj.navigateFallbackAllowlist === "undefined" || + Array.isArray(obj.navigateFallbackAllowlist) && + obj.navigateFallbackAllowlist.every((e: any) => + e instanceof RegExp + )) && + (typeof obj.navigateFallbackDenylist === "undefined" || + Array.isArray(obj.navigateFallbackDenylist) && + obj.navigateFallbackDenylist.every((e: any) => + e instanceof RegExp + )) && + (typeof obj.navigationPreload === "undefined" || + obj.navigationPreload === false || + obj.navigationPreload === true) && + (typeof obj.offlineGoogleAnalytics === "undefined" || + obj.offlineGoogleAnalytics === false || + obj.offlineGoogleAnalytics === true || + (obj.offlineGoogleAnalytics !== null && + typeof obj.offlineGoogleAnalytics === "object" || + typeof obj.offlineGoogleAnalytics === "function") && + (typeof obj.offlineGoogleAnalytics.cacheName === "undefined" || + typeof obj.offlineGoogleAnalytics.cacheName === "string") && + (typeof obj.offlineGoogleAnalytics.parameterOverrides === "undefined" || + (obj.offlineGoogleAnalytics.parameterOverrides !== null && + typeof obj.offlineGoogleAnalytics.parameterOverrides === "object" || + typeof obj.offlineGoogleAnalytics.parameterOverrides === "function")) && + (typeof obj.offlineGoogleAnalytics.hitFilter === "undefined" || + (obj.offlineGoogleAnalytics.hitFilter !== null && + typeof obj.offlineGoogleAnalytics.hitFilter === "object" || + typeof obj.offlineGoogleAnalytics.hitFilter === "function"))) && + Array.isArray(obj.runtimeCaching) && + obj.runtimeCaching.every((e: any) => + (e !== null && + typeof e === "object" || + typeof e === "function") && + ((e.handler !== null && + typeof e.handler === "object" || + typeof e.handler === "function") || + (e.handler !== null && + typeof e.handler === "object" || + typeof e.handler === "function") && + (e.handler.handle !== null && + typeof e.handler.handle === "object" || + typeof e.handler.handle === "function") || + e.handler === "CacheFirst" || + e.handler === "CacheOnly" || + e.handler === "NetworkFirst" || + e.handler === "NetworkOnly" || + e.handler === "StaleWhileRevalidate") && + (typeof e.method === "undefined" || + e.method === "DELETE" || + e.method === "GET" || + e.method === "HEAD" || + e.method === "PATCH" || + e.method === "POST" || + e.method === "PUT") && + (typeof e.options === "undefined" || + (e.options !== null && + typeof e.options === "object" || + typeof e.options === "function") && + (typeof e.options.backgroundSync === "undefined" || + (e.options.backgroundSync !== null && + typeof e.options.backgroundSync === "object" || + typeof e.options.backgroundSync === "function") && + typeof e.options.backgroundSync.name === "string" && + (typeof e.options.backgroundSync.options === "undefined" || + (e.options.backgroundSync.options !== null && + typeof e.options.backgroundSync.options === "object" || + typeof e.options.backgroundSync.options === "function") && + (typeof e.options.backgroundSync.options.onSync === "undefined" || + (e.options.backgroundSync.options.onSync !== null && + typeof e.options.backgroundSync.options.onSync === "object" || + typeof e.options.backgroundSync.options.onSync === "function")) && + (typeof e.options.backgroundSync.options.maxRetentionTime === "undefined" || + typeof e.options.backgroundSync.options.maxRetentionTime === "number"))) && + (typeof e.options.broadcastUpdate === "undefined" || + (e.options.broadcastUpdate !== null && + typeof e.options.broadcastUpdate === "object" || + typeof e.options.broadcastUpdate === "function") && + (typeof e.options.broadcastUpdate.channelName === "undefined" || + typeof e.options.broadcastUpdate.channelName === "string") && + (e.options.broadcastUpdate.options !== null && + typeof e.options.broadcastUpdate.options === "object" || + typeof e.options.broadcastUpdate.options === "function") && + (typeof e.options.broadcastUpdate.options.headersToCheck === "undefined" || + Array.isArray(e.options.broadcastUpdate.options.headersToCheck) && + e.options.broadcastUpdate.options.headersToCheck.every((e: any) => + typeof e === "string" + )) && + (typeof e.options.broadcastUpdate.options.generatePayload === "undefined" || + (e.options.broadcastUpdate.options.generatePayload !== null && + typeof e.options.broadcastUpdate.options.generatePayload === "object" || + typeof e.options.broadcastUpdate.options.generatePayload === "function"))) && + (typeof e.options.cacheableResponse === "undefined" || + (e.options.cacheableResponse !== null && + typeof e.options.cacheableResponse === "object" || + typeof e.options.cacheableResponse === "function") && + (typeof e.options.cacheableResponse.statuses === "undefined" || + Array.isArray(e.options.cacheableResponse.statuses) && + e.options.cacheableResponse.statuses.every((e: any) => + typeof e === "number" + )) && + (typeof e.options.cacheableResponse.headers === "undefined" || + (e.options.cacheableResponse.headers !== null && + typeof e.options.cacheableResponse.headers === "object" || + typeof e.options.cacheableResponse.headers === "function"))) && + (typeof e.options.cacheName === "undefined" || + typeof e.options.cacheName === "string") && + (typeof e.options.expiration === "undefined" || + (e.options.expiration !== null && + typeof e.options.expiration === "object" || + typeof e.options.expiration === "function") && + (typeof e.options.expiration.maxEntries === "undefined" || + typeof e.options.expiration.maxEntries === "number") && + (typeof e.options.expiration.maxAgeSeconds === "undefined" || + typeof e.options.expiration.maxAgeSeconds === "number") && + (typeof e.options.expiration.matchOptions === "undefined" || + (e.options.expiration.matchOptions !== null && + typeof e.options.expiration.matchOptions === "object" || + typeof e.options.expiration.matchOptions === "function") && + (typeof e.options.expiration.matchOptions.ignoreMethod === "undefined" || + e.options.expiration.matchOptions.ignoreMethod === false || + e.options.expiration.matchOptions.ignoreMethod === true) && + (typeof e.options.expiration.matchOptions.ignoreSearch === "undefined" || + e.options.expiration.matchOptions.ignoreSearch === false || + e.options.expiration.matchOptions.ignoreSearch === true) && + (typeof e.options.expiration.matchOptions.ignoreVary === "undefined" || + e.options.expiration.matchOptions.ignoreVary === false || + e.options.expiration.matchOptions.ignoreVary === true)) && + (typeof e.options.expiration.purgeOnQuotaError === "undefined" || + e.options.expiration.purgeOnQuotaError === false || + e.options.expiration.purgeOnQuotaError === true)) && + (typeof e.options.networkTimeoutSeconds === "undefined" || + typeof e.options.networkTimeoutSeconds === "number") && + (typeof e.options.plugins === "undefined" || + Array.isArray(e.options.plugins) && + e.options.plugins.every((e: any) => + (e !== null && + typeof e === "object" || + typeof e === "function") && + (typeof e.cacheDidUpdate === "undefined" || + (e.cacheDidUpdate !== null && + typeof e.cacheDidUpdate === "object" || + typeof e.cacheDidUpdate === "function")) && + (typeof e.cachedResponseWillBeUsed === "undefined" || + (e.cachedResponseWillBeUsed !== null && + typeof e.cachedResponseWillBeUsed === "object" || + typeof e.cachedResponseWillBeUsed === "function")) && + (typeof e.cacheKeyWillBeUsed === "undefined" || + (e.cacheKeyWillBeUsed !== null && + typeof e.cacheKeyWillBeUsed === "object" || + typeof e.cacheKeyWillBeUsed === "function")) && + (typeof e.cacheWillUpdate === "undefined" || + (e.cacheWillUpdate !== null && + typeof e.cacheWillUpdate === "object" || + typeof e.cacheWillUpdate === "function")) && + (typeof e.fetchDidFail === "undefined" || + (e.fetchDidFail !== null && + typeof e.fetchDidFail === "object" || + typeof e.fetchDidFail === "function")) && + (typeof e.fetchDidSucceed === "undefined" || + (e.fetchDidSucceed !== null && + typeof e.fetchDidSucceed === "object" || + typeof e.fetchDidSucceed === "function")) && + (typeof e.handlerDidComplete === "undefined" || + (e.handlerDidComplete !== null && + typeof e.handlerDidComplete === "object" || + typeof e.handlerDidComplete === "function")) && + (typeof e.handlerDidError === "undefined" || + (e.handlerDidError !== null && + typeof e.handlerDidError === "object" || + typeof e.handlerDidError === "function")) && + (typeof e.handlerDidRespond === "undefined" || + (e.handlerDidRespond !== null && + typeof e.handlerDidRespond === "object" || + typeof e.handlerDidRespond === "function")) && + (typeof e.handlerWillRespond === "undefined" || + (e.handlerWillRespond !== null && + typeof e.handlerWillRespond === "object" || + typeof e.handlerWillRespond === "function")) && + (typeof e.handlerWillStart === "undefined" || + (e.handlerWillStart !== null && + typeof e.handlerWillStart === "object" || + typeof e.handlerWillStart === "function")) && + (typeof e.requestWillFetch === "undefined" || + (e.requestWillFetch !== null && + typeof e.requestWillFetch === "object" || + typeof e.requestWillFetch === "function")) + )) && + (typeof e.options.precacheFallback === "undefined" || + (e.options.precacheFallback !== null && + typeof e.options.precacheFallback === "object" || + typeof e.options.precacheFallback === "function") && + typeof e.options.precacheFallback.fallbackURL === "string") && + (typeof e.options.fetchOptions === "undefined" || + (e.options.fetchOptions !== null && + typeof e.options.fetchOptions === "object" || + typeof e.options.fetchOptions === "function") && + (typeof e.options.fetchOptions.body === "undefined" || + e.options.fetchOptions.body === null || + typeof e.options.fetchOptions.body === "string" || + e.options.fetchOptions.body instanceof URLSearchParams || + e.options.fetchOptions.body instanceof Blob || + (e.options.fetchOptions.body !== null && + typeof e.options.fetchOptions.body === "object" || + typeof e.options.fetchOptions.body === "function") && + (e.options.fetchOptions.body.buffer instanceof ArrayBuffer || + e.options.fetchOptions.body.buffer instanceof SharedArrayBuffer) && + typeof e.options.fetchOptions.body.byteLength === "number" && + typeof e.options.fetchOptions.body.byteOffset === "number" || + e.options.fetchOptions.body instanceof ArrayBuffer || + e.options.fetchOptions.body instanceof FormData || + e.options.fetchOptions.body instanceof ReadableStream) && + (typeof e.options.fetchOptions.cache === "undefined" || + e.options.fetchOptions.cache === "default" || + e.options.fetchOptions.cache === "force-cache" || + e.options.fetchOptions.cache === "no-cache" || + e.options.fetchOptions.cache === "no-store" || + e.options.fetchOptions.cache === "only-if-cached" || + e.options.fetchOptions.cache === "reload") && + (typeof e.options.fetchOptions.credentials === "undefined" || + e.options.fetchOptions.credentials === "include" || + e.options.fetchOptions.credentials === "omit" || + e.options.fetchOptions.credentials === "same-origin") && + (typeof e.options.fetchOptions.headers === "undefined" || + e.options.fetchOptions.headers instanceof Headers || + Array.isArray(e.options.fetchOptions.headers) && + e.options.fetchOptions.headers.every((e: any) => + Array.isArray(e) && + e.every((e: any) => + typeof e === "string" + ) + ) || + (e.options.fetchOptions.headers !== null && + typeof e.options.fetchOptions.headers === "object" || + typeof e.options.fetchOptions.headers === "function")) && + (typeof e.options.fetchOptions.integrity === "undefined" || + typeof e.options.fetchOptions.integrity === "string") && + (typeof e.options.fetchOptions.keepalive === "undefined" || + e.options.fetchOptions.keepalive === false || + e.options.fetchOptions.keepalive === true) && + (typeof e.options.fetchOptions.method === "undefined" || + typeof e.options.fetchOptions.method === "string") && + (typeof e.options.fetchOptions.mode === "undefined" || + e.options.fetchOptions.mode === "same-origin" || + e.options.fetchOptions.mode === "cors" || + e.options.fetchOptions.mode === "navigate" || + e.options.fetchOptions.mode === "no-cors") && + (typeof e.options.fetchOptions.redirect === "undefined" || + e.options.fetchOptions.redirect === "error" || + e.options.fetchOptions.redirect === "follow" || + e.options.fetchOptions.redirect === "manual") && + (typeof e.options.fetchOptions.referrer === "undefined" || + typeof e.options.fetchOptions.referrer === "string") && + (typeof e.options.fetchOptions.referrerPolicy === "undefined" || + e.options.fetchOptions.referrerPolicy === "" || + e.options.fetchOptions.referrerPolicy === "same-origin" || + e.options.fetchOptions.referrerPolicy === "no-referrer" || + e.options.fetchOptions.referrerPolicy === "no-referrer-when-downgrade" || + e.options.fetchOptions.referrerPolicy === "origin" || + e.options.fetchOptions.referrerPolicy === "origin-when-cross-origin" || + e.options.fetchOptions.referrerPolicy === "strict-origin" || + e.options.fetchOptions.referrerPolicy === "strict-origin-when-cross-origin" || + e.options.fetchOptions.referrerPolicy === "unsafe-url") && + (typeof e.options.fetchOptions.signal === "undefined" || + e.options.fetchOptions.signal === null || + e.options.fetchOptions.signal instanceof AbortSignal)) && + (typeof e.options.matchOptions === "undefined" || + (e.options.matchOptions !== null && + typeof e.options.matchOptions === "object" || + typeof e.options.matchOptions === "function") && + (typeof e.options.matchOptions.ignoreMethod === "undefined" || + e.options.matchOptions.ignoreMethod === false || + e.options.matchOptions.ignoreMethod === true) && + (typeof e.options.matchOptions.ignoreSearch === "undefined" || + e.options.matchOptions.ignoreSearch === false || + e.options.matchOptions.ignoreSearch === true) && + (typeof e.options.matchOptions.ignoreVary === "undefined" || + e.options.matchOptions.ignoreVary === false || + e.options.matchOptions.ignoreVary === true))) && + (typeof e.urlPattern === "string" || + e.urlPattern instanceof RegExp || + (e.urlPattern !== null && + typeof e.urlPattern === "object" || + typeof e.urlPattern === "function")) + ) && + (typeof obj.skipWaiting === "undefined" || + obj.skipWaiting === false || + obj.skipWaiting === true) && + (typeof obj.sourcemap === "undefined" || + obj.sourcemap === false || + obj.sourcemap === true) || + (obj !== null && + typeof obj === "object" || + typeof obj === "function") && + (typeof obj.additionalManifestEntries === "undefined" || + Array.isArray(obj.additionalManifestEntries) && + obj.additionalManifestEntries.every((e: any) => + (typeof e === "string" || + (e !== null && + typeof e === "object" || + typeof e === "function") && + (typeof e.integrity === "undefined" || + typeof e.integrity === "string") && + (e.revision === null || + typeof e.revision === "string") && + typeof e.url === "string") + )) && + (typeof obj.dontCacheBustURLsMatching === "undefined" || + obj.dontCacheBustURLsMatching instanceof RegExp) && + (typeof obj.manifestTransforms === "undefined" || + Array.isArray(obj.manifestTransforms) && + obj.manifestTransforms.every((e: any) => + (e !== null && + typeof e === "object" || + typeof e === "function") + )) && + (typeof obj.maximumFileSizeToCacheInBytes === "undefined" || + typeof obj.maximumFileSizeToCacheInBytes === "number") && + (obj.modifyURLPrefix !== null && + typeof obj.modifyURLPrefix === "object" || + typeof obj.modifyURLPrefix === "function") || + (obj !== null && + typeof obj === "object" || + typeof obj === "function") && + typeof obj.swDest === "string") + ) +} + +export function isGetManifestOptions(obj: any, _argumentName?: string): obj is GetManifestOptions { + return ( + ((obj !== null && + typeof obj === "object" || + typeof obj === "function") && + (typeof obj.globDirectory === "undefined" || + typeof obj.globDirectory === "string") && + (typeof obj.globFollow === "undefined" || + obj.globFollow === false || + obj.globFollow === true) && + (typeof obj.globIgnores === "undefined" || + Array.isArray(obj.globIgnores) && + obj.globIgnores.every((e: any) => + typeof e === "string" + )) && + (typeof obj.globPatterns === "undefined" || + Array.isArray(obj.globPatterns) && + obj.globPatterns.every((e: any) => + typeof e === "string" + )) && + (typeof obj.globStrict === "undefined" || + obj.globStrict === false || + obj.globStrict === true) && + (obj.templatedURLs !== null && + typeof obj.templatedURLs === "object" || + typeof obj.templatedURLs === "function") || + (obj !== null && + typeof obj === "object" || + typeof obj === "function") && + (typeof obj.additionalManifestEntries === "undefined" || + Array.isArray(obj.additionalManifestEntries) && + obj.additionalManifestEntries.every((e: any) => + (typeof e === "string" || + (e !== null && + typeof e === "object" || + typeof e === "function") && + (typeof e.integrity === "undefined" || + typeof e.integrity === "string") && + (e.revision === null || + typeof e.revision === "string") && + typeof e.url === "string") + )) && + (typeof obj.dontCacheBustURLsMatching === "undefined" || + obj.dontCacheBustURLsMatching instanceof RegExp) && + (typeof obj.manifestTransforms === "undefined" || + Array.isArray(obj.manifestTransforms) && + obj.manifestTransforms.every((e: any) => + (e !== null && + typeof e === "object" || + typeof e === "function") + )) && + (typeof obj.maximumFileSizeToCacheInBytes === "undefined" || + typeof obj.maximumFileSizeToCacheInBytes === "number") && + (obj.modifyURLPrefix !== null && + typeof obj.modifyURLPrefix === "object" || + typeof obj.modifyURLPrefix === "function")) + ) +} + +export function isInjectManifestOptions(obj: any, _argumentName?: string): obj is InjectManifestOptions { + return ( + ((obj !== null && + typeof obj === "object" || + typeof obj === "function") && + (typeof obj.injectionPoint === "undefined" || + typeof obj.injectionPoint === "string") && + typeof obj.swSrc === "string" || + (obj !== null && + typeof obj === "object" || + typeof obj === "function") && + (typeof obj.globDirectory === "undefined" || + typeof obj.globDirectory === "string") && + (typeof obj.globFollow === "undefined" || + obj.globFollow === false || + obj.globFollow === true) && + (typeof obj.globIgnores === "undefined" || + Array.isArray(obj.globIgnores) && + obj.globIgnores.every((e: any) => + typeof e === "string" + )) && + (typeof obj.globPatterns === "undefined" || + Array.isArray(obj.globPatterns) && + obj.globPatterns.every((e: any) => + typeof e === "string" + )) && + (typeof obj.globStrict === "undefined" || + obj.globStrict === false || + obj.globStrict === true) && + (obj.templatedURLs !== null && + typeof obj.templatedURLs === "object" || + typeof obj.templatedURLs === "function") || + (obj !== null && + typeof obj === "object" || + typeof obj === "function") && + (typeof obj.additionalManifestEntries === "undefined" || + Array.isArray(obj.additionalManifestEntries) && + obj.additionalManifestEntries.every((e: any) => + (typeof e === "string" || + (e !== null && + typeof e === "object" || + typeof e === "function") && + (typeof e.integrity === "undefined" || + typeof e.integrity === "string") && + (e.revision === null || + typeof e.revision === "string") && + typeof e.url === "string") + )) && + (typeof obj.dontCacheBustURLsMatching === "undefined" || + obj.dontCacheBustURLsMatching instanceof RegExp) && + (typeof obj.manifestTransforms === "undefined" || + Array.isArray(obj.manifestTransforms) && + obj.manifestTransforms.every((e: any) => + (e !== null && + typeof e === "object" || + typeof e === "function") + )) && + (typeof obj.maximumFileSizeToCacheInBytes === "undefined" || + typeof obj.maximumFileSizeToCacheInBytes === "number") && + (obj.modifyURLPrefix !== null && + typeof obj.modifyURLPrefix === "object" || + typeof obj.modifyURLPrefix === "function") || + (obj !== null && + typeof obj === "object" || + typeof obj === "function") && + typeof obj.swDest === "string") + ) +} + +export function isWebpackGenerateSWOptions(obj: any, _argumentName?: string): obj is WebpackGenerateSWOptions { + return ( + ((obj !== null && + typeof obj === "object" || + typeof obj === "function") && + (typeof obj.chunks === "undefined" || + Array.isArray(obj.chunks) && + obj.chunks.every((e: any) => + typeof e === "string" + )) && + (typeof obj.exclude === "undefined" || + Array.isArray(obj.exclude) && + obj.exclude.every((e: any) => + (typeof e === "string" || + e instanceof RegExp || + (e !== null && + typeof e === "object" || + typeof e === "function")) + )) && + (typeof obj.excludeChunks === "undefined" || + Array.isArray(obj.excludeChunks) && + obj.excludeChunks.every((e: any) => + typeof e === "string" + )) && + (typeof obj.include === "undefined" || + Array.isArray(obj.include) && + obj.include.every((e: any) => + (typeof e === "string" || + e instanceof RegExp || + (e !== null && + typeof e === "object" || + typeof e === "function")) + )) && + (typeof obj.mode === "undefined" || + typeof obj.mode === "string") || + (obj !== null && + typeof obj === "object" || + typeof obj === "function") && + (typeof obj.babelPresetEnvTargets === "undefined" || + Array.isArray(obj.babelPresetEnvTargets) && + obj.babelPresetEnvTargets.every((e: any) => + typeof e === "string" + )) && + (typeof obj.cacheId === "undefined" || + typeof obj.cacheId === "string") && + (typeof obj.cleanupOutdatedCaches === "undefined" || + obj.cleanupOutdatedCaches === false || + obj.cleanupOutdatedCaches === true) && + (typeof obj.clientsClaim === "undefined" || + obj.clientsClaim === false || + obj.clientsClaim === true) && + (typeof obj.directoryIndex === "undefined" || + typeof obj.directoryIndex === "string") && + (typeof obj.disableDevLogs === "undefined" || + obj.disableDevLogs === false || + obj.disableDevLogs === true) && + (typeof obj.ignoreURLParametersMatching === "undefined" || + Array.isArray(obj.ignoreURLParametersMatching) && + obj.ignoreURLParametersMatching.every((e: any) => + e instanceof RegExp + )) && + (typeof obj.importScripts === "undefined" || + Array.isArray(obj.importScripts) && + obj.importScripts.every((e: any) => + typeof e === "string" + )) && + (typeof obj.inlineWorkboxRuntime === "undefined" || + obj.inlineWorkboxRuntime === false || + obj.inlineWorkboxRuntime === true) && + (typeof obj.mode === "undefined" || + typeof obj.mode === "string") && + (typeof obj.navigateFallback === "undefined" || + typeof obj.navigateFallback === "string") && + (typeof obj.navigateFallbackAllowlist === "undefined" || + Array.isArray(obj.navigateFallbackAllowlist) && + obj.navigateFallbackAllowlist.every((e: any) => + e instanceof RegExp + )) && + (typeof obj.navigateFallbackDenylist === "undefined" || + Array.isArray(obj.navigateFallbackDenylist) && + obj.navigateFallbackDenylist.every((e: any) => + e instanceof RegExp + )) && + (typeof obj.navigationPreload === "undefined" || + obj.navigationPreload === false || + obj.navigationPreload === true) && + (typeof obj.offlineGoogleAnalytics === "undefined" || + obj.offlineGoogleAnalytics === false || + obj.offlineGoogleAnalytics === true || + (obj.offlineGoogleAnalytics !== null && + typeof obj.offlineGoogleAnalytics === "object" || + typeof obj.offlineGoogleAnalytics === "function") && + (typeof obj.offlineGoogleAnalytics.cacheName === "undefined" || + typeof obj.offlineGoogleAnalytics.cacheName === "string") && + (typeof obj.offlineGoogleAnalytics.parameterOverrides === "undefined" || + (obj.offlineGoogleAnalytics.parameterOverrides !== null && + typeof obj.offlineGoogleAnalytics.parameterOverrides === "object" || + typeof obj.offlineGoogleAnalytics.parameterOverrides === "function")) && + (typeof obj.offlineGoogleAnalytics.hitFilter === "undefined" || + (obj.offlineGoogleAnalytics.hitFilter !== null && + typeof obj.offlineGoogleAnalytics.hitFilter === "object" || + typeof obj.offlineGoogleAnalytics.hitFilter === "function"))) && + Array.isArray(obj.runtimeCaching) && + obj.runtimeCaching.every((e: any) => + (e !== null && + typeof e === "object" || + typeof e === "function") && + ((e.handler !== null && + typeof e.handler === "object" || + typeof e.handler === "function") || + (e.handler !== null && + typeof e.handler === "object" || + typeof e.handler === "function") && + (e.handler.handle !== null && + typeof e.handler.handle === "object" || + typeof e.handler.handle === "function") || + e.handler === "CacheFirst" || + e.handler === "CacheOnly" || + e.handler === "NetworkFirst" || + e.handler === "NetworkOnly" || + e.handler === "StaleWhileRevalidate") && + (typeof e.method === "undefined" || + e.method === "DELETE" || + e.method === "GET" || + e.method === "HEAD" || + e.method === "PATCH" || + e.method === "POST" || + e.method === "PUT") && + (typeof e.options === "undefined" || + (e.options !== null && + typeof e.options === "object" || + typeof e.options === "function") && + (typeof e.options.backgroundSync === "undefined" || + (e.options.backgroundSync !== null && + typeof e.options.backgroundSync === "object" || + typeof e.options.backgroundSync === "function") && + typeof e.options.backgroundSync.name === "string" && + (typeof e.options.backgroundSync.options === "undefined" || + (e.options.backgroundSync.options !== null && + typeof e.options.backgroundSync.options === "object" || + typeof e.options.backgroundSync.options === "function") && + (typeof e.options.backgroundSync.options.onSync === "undefined" || + (e.options.backgroundSync.options.onSync !== null && + typeof e.options.backgroundSync.options.onSync === "object" || + typeof e.options.backgroundSync.options.onSync === "function")) && + (typeof e.options.backgroundSync.options.maxRetentionTime === "undefined" || + typeof e.options.backgroundSync.options.maxRetentionTime === "number"))) && + (typeof e.options.broadcastUpdate === "undefined" || + (e.options.broadcastUpdate !== null && + typeof e.options.broadcastUpdate === "object" || + typeof e.options.broadcastUpdate === "function") && + (typeof e.options.broadcastUpdate.channelName === "undefined" || + typeof e.options.broadcastUpdate.channelName === "string") && + (e.options.broadcastUpdate.options !== null && + typeof e.options.broadcastUpdate.options === "object" || + typeof e.options.broadcastUpdate.options === "function") && + (typeof e.options.broadcastUpdate.options.headersToCheck === "undefined" || + Array.isArray(e.options.broadcastUpdate.options.headersToCheck) && + e.options.broadcastUpdate.options.headersToCheck.every((e: any) => + typeof e === "string" + )) && + (typeof e.options.broadcastUpdate.options.generatePayload === "undefined" || + (e.options.broadcastUpdate.options.generatePayload !== null && + typeof e.options.broadcastUpdate.options.generatePayload === "object" || + typeof e.options.broadcastUpdate.options.generatePayload === "function"))) && + (typeof e.options.cacheableResponse === "undefined" || + (e.options.cacheableResponse !== null && + typeof e.options.cacheableResponse === "object" || + typeof e.options.cacheableResponse === "function") && + (typeof e.options.cacheableResponse.statuses === "undefined" || + Array.isArray(e.options.cacheableResponse.statuses) && + e.options.cacheableResponse.statuses.every((e: any) => + typeof e === "number" + )) && + (typeof e.options.cacheableResponse.headers === "undefined" || + (e.options.cacheableResponse.headers !== null && + typeof e.options.cacheableResponse.headers === "object" || + typeof e.options.cacheableResponse.headers === "function"))) && + (typeof e.options.cacheName === "undefined" || + typeof e.options.cacheName === "string") && + (typeof e.options.expiration === "undefined" || + (e.options.expiration !== null && + typeof e.options.expiration === "object" || + typeof e.options.expiration === "function") && + (typeof e.options.expiration.maxEntries === "undefined" || + typeof e.options.expiration.maxEntries === "number") && + (typeof e.options.expiration.maxAgeSeconds === "undefined" || + typeof e.options.expiration.maxAgeSeconds === "number") && + (typeof e.options.expiration.matchOptions === "undefined" || + (e.options.expiration.matchOptions !== null && + typeof e.options.expiration.matchOptions === "object" || + typeof e.options.expiration.matchOptions === "function") && + (typeof e.options.expiration.matchOptions.ignoreMethod === "undefined" || + e.options.expiration.matchOptions.ignoreMethod === false || + e.options.expiration.matchOptions.ignoreMethod === true) && + (typeof e.options.expiration.matchOptions.ignoreSearch === "undefined" || + e.options.expiration.matchOptions.ignoreSearch === false || + e.options.expiration.matchOptions.ignoreSearch === true) && + (typeof e.options.expiration.matchOptions.ignoreVary === "undefined" || + e.options.expiration.matchOptions.ignoreVary === false || + e.options.expiration.matchOptions.ignoreVary === true)) && + (typeof e.options.expiration.purgeOnQuotaError === "undefined" || + e.options.expiration.purgeOnQuotaError === false || + e.options.expiration.purgeOnQuotaError === true)) && + (typeof e.options.networkTimeoutSeconds === "undefined" || + typeof e.options.networkTimeoutSeconds === "number") && + (typeof e.options.plugins === "undefined" || + Array.isArray(e.options.plugins) && + e.options.plugins.every((e: any) => + (e !== null && + typeof e === "object" || + typeof e === "function") && + (typeof e.cacheDidUpdate === "undefined" || + (e.cacheDidUpdate !== null && + typeof e.cacheDidUpdate === "object" || + typeof e.cacheDidUpdate === "function")) && + (typeof e.cachedResponseWillBeUsed === "undefined" || + (e.cachedResponseWillBeUsed !== null && + typeof e.cachedResponseWillBeUsed === "object" || + typeof e.cachedResponseWillBeUsed === "function")) && + (typeof e.cacheKeyWillBeUsed === "undefined" || + (e.cacheKeyWillBeUsed !== null && + typeof e.cacheKeyWillBeUsed === "object" || + typeof e.cacheKeyWillBeUsed === "function")) && + (typeof e.cacheWillUpdate === "undefined" || + (e.cacheWillUpdate !== null && + typeof e.cacheWillUpdate === "object" || + typeof e.cacheWillUpdate === "function")) && + (typeof e.fetchDidFail === "undefined" || + (e.fetchDidFail !== null && + typeof e.fetchDidFail === "object" || + typeof e.fetchDidFail === "function")) && + (typeof e.fetchDidSucceed === "undefined" || + (e.fetchDidSucceed !== null && + typeof e.fetchDidSucceed === "object" || + typeof e.fetchDidSucceed === "function")) && + (typeof e.handlerDidComplete === "undefined" || + (e.handlerDidComplete !== null && + typeof e.handlerDidComplete === "object" || + typeof e.handlerDidComplete === "function")) && + (typeof e.handlerDidError === "undefined" || + (e.handlerDidError !== null && + typeof e.handlerDidError === "object" || + typeof e.handlerDidError === "function")) && + (typeof e.handlerDidRespond === "undefined" || + (e.handlerDidRespond !== null && + typeof e.handlerDidRespond === "object" || + typeof e.handlerDidRespond === "function")) && + (typeof e.handlerWillRespond === "undefined" || + (e.handlerWillRespond !== null && + typeof e.handlerWillRespond === "object" || + typeof e.handlerWillRespond === "function")) && + (typeof e.handlerWillStart === "undefined" || + (e.handlerWillStart !== null && + typeof e.handlerWillStart === "object" || + typeof e.handlerWillStart === "function")) && + (typeof e.requestWillFetch === "undefined" || + (e.requestWillFetch !== null && + typeof e.requestWillFetch === "object" || + typeof e.requestWillFetch === "function")) + )) && + (typeof e.options.precacheFallback === "undefined" || + (e.options.precacheFallback !== null && + typeof e.options.precacheFallback === "object" || + typeof e.options.precacheFallback === "function") && + typeof e.options.precacheFallback.fallbackURL === "string") && + (typeof e.options.fetchOptions === "undefined" || + (e.options.fetchOptions !== null && + typeof e.options.fetchOptions === "object" || + typeof e.options.fetchOptions === "function") && + (typeof e.options.fetchOptions.body === "undefined" || + e.options.fetchOptions.body === null || + typeof e.options.fetchOptions.body === "string" || + e.options.fetchOptions.body instanceof URLSearchParams || + e.options.fetchOptions.body instanceof Blob || + (e.options.fetchOptions.body !== null && + typeof e.options.fetchOptions.body === "object" || + typeof e.options.fetchOptions.body === "function") && + (e.options.fetchOptions.body.buffer instanceof ArrayBuffer || + e.options.fetchOptions.body.buffer instanceof SharedArrayBuffer) && + typeof e.options.fetchOptions.body.byteLength === "number" && + typeof e.options.fetchOptions.body.byteOffset === "number" || + e.options.fetchOptions.body instanceof ArrayBuffer || + e.options.fetchOptions.body instanceof FormData || + e.options.fetchOptions.body instanceof ReadableStream) && + (typeof e.options.fetchOptions.cache === "undefined" || + e.options.fetchOptions.cache === "default" || + e.options.fetchOptions.cache === "force-cache" || + e.options.fetchOptions.cache === "no-cache" || + e.options.fetchOptions.cache === "no-store" || + e.options.fetchOptions.cache === "only-if-cached" || + e.options.fetchOptions.cache === "reload") && + (typeof e.options.fetchOptions.credentials === "undefined" || + e.options.fetchOptions.credentials === "include" || + e.options.fetchOptions.credentials === "omit" || + e.options.fetchOptions.credentials === "same-origin") && + (typeof e.options.fetchOptions.headers === "undefined" || + e.options.fetchOptions.headers instanceof Headers || + Array.isArray(e.options.fetchOptions.headers) && + e.options.fetchOptions.headers.every((e: any) => + Array.isArray(e) && + e.every((e: any) => + typeof e === "string" + ) + ) || + (e.options.fetchOptions.headers !== null && + typeof e.options.fetchOptions.headers === "object" || + typeof e.options.fetchOptions.headers === "function")) && + (typeof e.options.fetchOptions.integrity === "undefined" || + typeof e.options.fetchOptions.integrity === "string") && + (typeof e.options.fetchOptions.keepalive === "undefined" || + e.options.fetchOptions.keepalive === false || + e.options.fetchOptions.keepalive === true) && + (typeof e.options.fetchOptions.method === "undefined" || + typeof e.options.fetchOptions.method === "string") && + (typeof e.options.fetchOptions.mode === "undefined" || + e.options.fetchOptions.mode === "same-origin" || + e.options.fetchOptions.mode === "cors" || + e.options.fetchOptions.mode === "navigate" || + e.options.fetchOptions.mode === "no-cors") && + (typeof e.options.fetchOptions.redirect === "undefined" || + e.options.fetchOptions.redirect === "error" || + e.options.fetchOptions.redirect === "follow" || + e.options.fetchOptions.redirect === "manual") && + (typeof e.options.fetchOptions.referrer === "undefined" || + typeof e.options.fetchOptions.referrer === "string") && + (typeof e.options.fetchOptions.referrerPolicy === "undefined" || + e.options.fetchOptions.referrerPolicy === "" || + e.options.fetchOptions.referrerPolicy === "same-origin" || + e.options.fetchOptions.referrerPolicy === "no-referrer" || + e.options.fetchOptions.referrerPolicy === "no-referrer-when-downgrade" || + e.options.fetchOptions.referrerPolicy === "origin" || + e.options.fetchOptions.referrerPolicy === "origin-when-cross-origin" || + e.options.fetchOptions.referrerPolicy === "strict-origin" || + e.options.fetchOptions.referrerPolicy === "strict-origin-when-cross-origin" || + e.options.fetchOptions.referrerPolicy === "unsafe-url") && + (typeof e.options.fetchOptions.signal === "undefined" || + e.options.fetchOptions.signal === null || + e.options.fetchOptions.signal instanceof AbortSignal)) && + (typeof e.options.matchOptions === "undefined" || + (e.options.matchOptions !== null && + typeof e.options.matchOptions === "object" || + typeof e.options.matchOptions === "function") && + (typeof e.options.matchOptions.ignoreMethod === "undefined" || + e.options.matchOptions.ignoreMethod === false || + e.options.matchOptions.ignoreMethod === true) && + (typeof e.options.matchOptions.ignoreSearch === "undefined" || + e.options.matchOptions.ignoreSearch === false || + e.options.matchOptions.ignoreSearch === true) && + (typeof e.options.matchOptions.ignoreVary === "undefined" || + e.options.matchOptions.ignoreVary === false || + e.options.matchOptions.ignoreVary === true))) && + (typeof e.urlPattern === "string" || + e.urlPattern instanceof RegExp || + (e.urlPattern !== null && + typeof e.urlPattern === "object" || + typeof e.urlPattern === "function")) + ) && + (typeof obj.skipWaiting === "undefined" || + obj.skipWaiting === false || + obj.skipWaiting === true) && + (typeof obj.sourcemap === "undefined" || + obj.sourcemap === false || + obj.sourcemap === true) || + (obj !== null && + typeof obj === "object" || + typeof obj === "function") && + (typeof obj.additionalManifestEntries === "undefined" || + Array.isArray(obj.additionalManifestEntries) && + obj.additionalManifestEntries.every((e: any) => + (typeof e === "string" || + (e !== null && + typeof e === "object" || + typeof e === "function") && + (typeof e.integrity === "undefined" || + typeof e.integrity === "string") && + (e.revision === null || + typeof e.revision === "string") && + typeof e.url === "string") + )) && + (typeof obj.dontCacheBustURLsMatching === "undefined" || + obj.dontCacheBustURLsMatching instanceof RegExp) && + (typeof obj.manifestTransforms === "undefined" || + Array.isArray(obj.manifestTransforms) && + obj.manifestTransforms.every((e: any) => + (e !== null && + typeof e === "object" || + typeof e === "function") + )) && + (typeof obj.maximumFileSizeToCacheInBytes === "undefined" || + typeof obj.maximumFileSizeToCacheInBytes === "number") && + (obj.modifyURLPrefix !== null && + typeof obj.modifyURLPrefix === "object" || + typeof obj.modifyURLPrefix === "function") || + (obj !== null && + typeof obj === "object" || + typeof obj === "function") && + typeof obj.swDest === "string" || + (obj !== null && + typeof obj === "object" || + typeof obj === "function") && + Array.isArray(obj.importScriptsViaChunks) && + obj.importScriptsViaChunks.every((e: any) => + typeof e === "string" + )) + ) +} + +export function isWebpackInjectManifestOptions(obj: any, _argumentName?: string): obj is WebpackInjectManifestOptions { + return ( + ((obj !== null && + typeof obj === "object" || + typeof obj === "function") && + (typeof obj.chunks === "undefined" || + Array.isArray(obj.chunks) && + obj.chunks.every((e: any) => + typeof e === "string" + )) && + (typeof obj.exclude === "undefined" || + Array.isArray(obj.exclude) && + obj.exclude.every((e: any) => + (typeof e === "string" || + e instanceof RegExp || + (e !== null && + typeof e === "object" || + typeof e === "function")) + )) && + (typeof obj.excludeChunks === "undefined" || + Array.isArray(obj.excludeChunks) && + obj.excludeChunks.every((e: any) => + typeof e === "string" + )) && + (typeof obj.include === "undefined" || + Array.isArray(obj.include) && + obj.include.every((e: any) => + (typeof e === "string" || + e instanceof RegExp || + (e !== null && + typeof e === "object" || + typeof e === "function")) + )) && + (typeof obj.mode === "undefined" || + typeof obj.mode === "string") || + (obj !== null && + typeof obj === "object" || + typeof obj === "function") && + (typeof obj.injectionPoint === "undefined" || + typeof obj.injectionPoint === "string") && + typeof obj.swSrc === "string" || + (obj !== null && + typeof obj === "object" || + typeof obj === "function") && + (typeof obj.additionalManifestEntries === "undefined" || + Array.isArray(obj.additionalManifestEntries) && + obj.additionalManifestEntries.every((e: any) => + (typeof e === "string" || + (e !== null && + typeof e === "object" || + typeof e === "function") && + (typeof e.integrity === "undefined" || + typeof e.integrity === "string") && + (e.revision === null || + typeof e.revision === "string") && + typeof e.url === "string") + )) && + (typeof obj.dontCacheBustURLsMatching === "undefined" || + obj.dontCacheBustURLsMatching instanceof RegExp) && + (typeof obj.manifestTransforms === "undefined" || + Array.isArray(obj.manifestTransforms) && + obj.manifestTransforms.every((e: any) => + (e !== null && + typeof e === "object" || + typeof e === "function") + )) && + (typeof obj.maximumFileSizeToCacheInBytes === "undefined" || + typeof obj.maximumFileSizeToCacheInBytes === "number") && + (obj.modifyURLPrefix !== null && + typeof obj.modifyURLPrefix === "object" || + typeof obj.modifyURLPrefix === "function") || + (obj !== null && + typeof obj === "object" || + typeof obj === "function") && + typeof obj.swDest === "string" || + (obj !== null && + typeof obj === "object" || + typeof obj === "function") && + (typeof obj.compileSrc === "undefined" || + obj.compileSrc === false || + obj.compileSrc === true) && + (typeof obj.webpackCompilationPlugins === "undefined" || + Array.isArray(obj.webpackCompilationPlugins))) + ) +} diff --git a/packages/workbox-build/src/types.ts b/packages/workbox-build/src/types.ts index 62aa5c973..1a9cf80d1 100644 --- a/packages/workbox-build/src/types.ts +++ b/packages/workbox-build/src/types.ts @@ -89,7 +89,7 @@ export interface GeneratePartial { export interface GlobPartial { globDirectory?: string; globFollow?: boolean; - globIgnores?: Array; + globIgnores: Array; globPatterns?: Array; globStrict?: boolean; templatedURLs: { @@ -98,7 +98,7 @@ export interface GlobPartial { } interface InjectPartial { - injectionPoint?: string; + injectionPoint: string; swSrc: string; } @@ -114,16 +114,23 @@ export interface SWDestPartial { swDest: string; } +/** @see {isGenerateSWOptions} ts-auto-guard:type-guard */ export type GenerateSWOptions = GlobPartial & GeneratePartial & BasePartial & SWDestPartial; +/** @see {isGetManifestOptions} ts-auto-guard:type-guard */ export type GetManifestOptions = GlobPartial & BasePartial; -export type InjectManifestOptions = InjectPartial & GlobPartial & BasePartial & SWDestPartial; +/** @see {isInjectManifestOptions} ts-auto-guard:type-guard */ +export type InjectManifestOptions = InjectPartial & Omit & BasePartial & SWDestPartial & { + globDirectory: string; +}; +/** @see {isWebpackGenerateSWOptions} ts-auto-guard:type-guard */ export type WebpackGenerateSWOptions = WebpackPartial & GeneratePartial & BasePartial & SWDestPartial & { importScriptsViaChunks: Array; }; +/** @see {isWebpackInjectManifestOptions} ts-auto-guard:type-guard */ export type WebpackInjectManifestOptions = WebpackPartial & InjectPartial & BasePartial & SWDestPartial & { compileSrc?: boolean; webpackCompilationPlugins?: Array; From 65e69c6e45a05ef80552761592754d0a12ad1107 Mon Sep 17 00:00:00 2001 From: Jeff Posnick Date: Sat, 16 Jan 2021 17:21:36 -0500 Subject: [PATCH 09/80] Validation, type fixes --- packages/workbox-build/src/get-manifest.ts | 2 +- packages/workbox-build/src/inject-manifest.ts | 2 +- .../additional-manifest-entries-transform.ts | 20 +- .../workbox-build/src/lib/get-file-details.ts | 39 +- .../src/lib/get-file-manifest-entries.ts | 66 +-- .../src/lib/transform-manifest.ts | 2 +- packages/workbox-build/src/types.guard.ts | 396 ++---------------- packages/workbox-build/src/types.ts | 2 +- 8 files changed, 115 insertions(+), 414 deletions(-) diff --git a/packages/workbox-build/src/get-manifest.ts b/packages/workbox-build/src/get-manifest.ts index e05ad6690..313ecdc0e 100644 --- a/packages/workbox-build/src/get-manifest.ts +++ b/packages/workbox-build/src/get-manifest.ts @@ -6,7 +6,7 @@ https://opensource.org/licenses/MIT. */ -import {GetManifestResult, GetManifestOptions} from './types'; +import {GetManifestResult} from './types'; import getFileManifestEntries from './lib/get-file-manifest-entries'; import {validateGetManifestOptions} from './lib/validate-options'; diff --git a/packages/workbox-build/src/inject-manifest.ts b/packages/workbox-build/src/inject-manifest.ts index d7e8f739a..0660bc7ca 100644 --- a/packages/workbox-build/src/inject-manifest.ts +++ b/packages/workbox-build/src/inject-manifest.ts @@ -13,7 +13,7 @@ import sourceMapURL from 'source-map-url'; import stringify from 'fast-json-stable-stringify'; import upath from 'upath'; -import {BuildResult, InjectManifestOptions} from './types'; +import {BuildResult} from './types'; import errors from './lib/errors'; import escapeRegexp from './lib/escape-regexp'; import getFileManifestEntries from './lib/get-file-manifest-entries'; diff --git a/packages/workbox-build/src/lib/additional-manifest-entries-transform.ts b/packages/workbox-build/src/lib/additional-manifest-entries-transform.ts index 0903ecea2..e6db5e0cb 100644 --- a/packages/workbox-build/src/lib/additional-manifest-entries-transform.ts +++ b/packages/workbox-build/src/lib/additional-manifest-entries-transform.ts @@ -10,21 +10,27 @@ import errors from './errors'; import {ManifestEntry} from '../types'; -export default function(additionalManifestEntries: Array) { - return (manifest: Array & {size: number}) => { +export default function(additionalManifestEntries: Array) { + return (manifest: Array) => { const warnings = []; const stringEntries = new Set(); for (const additionalEntry of additionalManifestEntries) { - // Warn about either a string or an object that lacks a precache property. + // Warn about either a string or an object that lacks a revision property. // (An object with a revision property set to null is okay.) if (typeof additionalEntry === 'string') { stringEntries.add(additionalEntry); - } else if (additionalEntry && additionalEntry.revision === undefined) { - stringEntries.add(additionalEntry.url); + manifest.push({ + revision: null, + size: 0, + url: additionalEntry, + }); + } else { + if (additionalEntry && additionalEntry.revision === undefined) { + stringEntries.add(additionalEntry.url); + } + manifest.push(Object.assign({size: 0}, additionalEntry)); } - - manifest.push(additionalEntry); } if (stringEntries.size > 0) { diff --git a/packages/workbox-build/src/lib/get-file-details.ts b/packages/workbox-build/src/lib/get-file-details.ts index 7a47f070c..a8d5d689f 100644 --- a/packages/workbox-build/src/lib/get-file-details.ts +++ b/packages/workbox-build/src/lib/get-file-details.ts @@ -15,13 +15,26 @@ import getFileHash from './get-file-hash'; import {GlobPartial} from '../types'; +interface FileDetails { + file: string; + hash: string; + size: number; +}; + export default function({ globDirectory, globFollow, globIgnores, globPattern, globStrict, -}: Omit & {globPattern: string}) { +}: Omit & { + // This will only be called when globDirectory is not undefined. + globDirectory: string; + globPattern: string; +}): { + globbedFileDetails: Array; + warning: string; +} { let globbedFiles: Array; let warning = ''; @@ -41,23 +54,19 @@ export default function({ JSON.stringify({globDirectory, globPattern, globIgnores}, null, 2); } - const fileDetails = globbedFiles.map((file) => { + const globbedFileDetails: Array = []; + for (const file of globbedFiles) { const fullPath = upath.join(globDirectory, file); const fileSize = getFileSize(fullPath); - if (fileSize === null) { - return null; + if (fileSize !== null) { + const fileHash = getFileHash(fullPath); + globbedFileDetails.push({ + file: `${upath.relative(globDirectory, fullPath)}`, + hash: fileHash, + size: fileSize, + }); } - - const fileHash = getFileHash(fullPath); - return { - file: `${upath.relative(globDirectory, fullPath)}`, - hash: fileHash, - size: fileSize, - }; - }); - - // If !== null, means it's a valid file. - const globbedFileDetails = fileDetails.filter((details) => details !== null); + } return {globbedFileDetails, warning}; }; diff --git a/packages/workbox-build/src/lib/get-file-manifest-entries.ts b/packages/workbox-build/src/lib/get-file-manifest-entries.ts index 80d558cb0..55529e933 100644 --- a/packages/workbox-build/src/lib/get-file-manifest-entries.ts +++ b/packages/workbox-build/src/lib/get-file-manifest-entries.ts @@ -47,7 +47,7 @@ export default async function ({ } for (const details of globbedFileDetails) { - if (!allFileDetails.has(details.file)) { + if (details && !allFileDetails.has(details.file)) { allFileDetails.set(details.file, details); } } @@ -57,40 +57,40 @@ export default async function ({ // it back as a warning, and don't consider it fatal. warnings.push(error.message); } - } - - if (templatedURLs) { - for (const url of Object.keys(templatedURLs)) { - assert(!allFileDetails.has(url), errors['templated-url-matches-glob']); - - const dependencies = templatedURLs[url]; - if (Array.isArray(dependencies)) { - const details = dependencies.reduce((previous, globPattern) => { - try { - const {globbedFileDetails, warning} = getFileDetails({ - globDirectory, - globFollow, - globIgnores, - globPattern, - globStrict, - }); - if (warning) { - warnings.push(warning); + if (templatedURLs) { + for (const url of Object.keys(templatedURLs)) { + assert(!allFileDetails.has(url), errors['templated-url-matches-glob']); + + const dependencies = templatedURLs[url]; + if (Array.isArray(dependencies)) { + const details = dependencies.reduce((previous, globPattern) => { + try { + const {globbedFileDetails, warning} = getFileDetails({ + globDirectory, + globFollow, + globIgnores, + globPattern, + globStrict, + }); + + if (warning) { + warnings.push(warning); + } + + return previous.concat(globbedFileDetails); + } catch (error) { + const debugObj: {[key: string]: Array} = {}; + debugObj[url] = dependencies; + throw new Error(`${errors['bad-template-urls-asset']} ` + + `'${globPattern}' from '${JSON.stringify(debugObj)}':\n` + + error); } - - return previous.concat(globbedFileDetails); - } catch (error) { - const debugObj = {}; - debugObj[url] = dependencies; - throw new Error(`${errors['bad-template-urls-asset']} ` + - `'${globPattern}' from '${JSON.stringify(debugObj)}':\n` + - error); - } - }, []); - allFileDetails.set(url, getCompositeDetails(url, details)); - } else if (typeof dependencies === 'string') { - allFileDetails.set(url, getStringDetails(url, dependencies)); + }, []); + allFileDetails.set(url, getCompositeDetails(url, details)); + } else if (typeof dependencies === 'string') { + allFileDetails.set(url, getStringDetails(url, dependencies)); + } } } } diff --git a/packages/workbox-build/src/lib/transform-manifest.ts b/packages/workbox-build/src/lib/transform-manifest.ts index 7830dbe35..748b8cc05 100644 --- a/packages/workbox-build/src/lib/transform-manifest.ts +++ b/packages/workbox-build/src/lib/transform-manifest.ts @@ -117,7 +117,7 @@ export default async function ({ additionalManifestEntriesTransform(additionalManifestEntries)); } - let transformedManifest = normalizedManifest; + let transformedManifest: Array = normalizedManifest; for (const transform of transformsToApply) { const result = await transform(transformedManifest, transformParam); if (!('manifest' in result)) { diff --git a/packages/workbox-build/src/types.guard.ts b/packages/workbox-build/src/types.guard.ts index 1d0de4d0f..7749797f1 100644 --- a/packages/workbox-build/src/types.guard.ts +++ b/packages/workbox-build/src/types.guard.ts @@ -14,16 +14,14 @@ export function isGenerateSWOptions(obj: any, _argumentName?: string): obj is Ge (typeof obj.globFollow === "undefined" || obj.globFollow === false || obj.globFollow === true) && - (typeof obj.globIgnores === "undefined" || - Array.isArray(obj.globIgnores) && - obj.globIgnores.every((e: any) => - typeof e === "string" - )) && - (typeof obj.globPatterns === "undefined" || - Array.isArray(obj.globPatterns) && - obj.globPatterns.every((e: any) => - typeof e === "string" - )) && + Array.isArray(obj.globIgnores) && + obj.globIgnores.every((e: any) => + typeof e === "string" + ) && + Array.isArray(obj.globPatterns) && + obj.globPatterns.every((e: any) => + typeof e === "string" + ) && (typeof obj.globStrict === "undefined" || obj.globStrict === false || obj.globStrict === true) && @@ -81,48 +79,11 @@ export function isGenerateSWOptions(obj: any, _argumentName?: string): obj is Ge (typeof obj.navigationPreload === "undefined" || obj.navigationPreload === false || obj.navigationPreload === true) && - (typeof obj.offlineGoogleAnalytics === "undefined" || - obj.offlineGoogleAnalytics === false || - obj.offlineGoogleAnalytics === true || - (obj.offlineGoogleAnalytics !== null && - typeof obj.offlineGoogleAnalytics === "object" || - typeof obj.offlineGoogleAnalytics === "function") && - (typeof obj.offlineGoogleAnalytics.cacheName === "undefined" || - typeof obj.offlineGoogleAnalytics.cacheName === "string") && - (typeof obj.offlineGoogleAnalytics.parameterOverrides === "undefined" || - (obj.offlineGoogleAnalytics.parameterOverrides !== null && - typeof obj.offlineGoogleAnalytics.parameterOverrides === "object" || - typeof obj.offlineGoogleAnalytics.parameterOverrides === "function")) && - (typeof obj.offlineGoogleAnalytics.hitFilter === "undefined" || - (obj.offlineGoogleAnalytics.hitFilter !== null && - typeof obj.offlineGoogleAnalytics.hitFilter === "object" || - typeof obj.offlineGoogleAnalytics.hitFilter === "function"))) && Array.isArray(obj.runtimeCaching) && obj.runtimeCaching.every((e: any) => (e !== null && typeof e === "object" || typeof e === "function") && - ((e.handler !== null && - typeof e.handler === "object" || - typeof e.handler === "function") || - (e.handler !== null && - typeof e.handler === "object" || - typeof e.handler === "function") && - (e.handler.handle !== null && - typeof e.handler.handle === "object" || - typeof e.handler.handle === "function") || - e.handler === "CacheFirst" || - e.handler === "CacheOnly" || - e.handler === "NetworkFirst" || - e.handler === "NetworkOnly" || - e.handler === "StaleWhileRevalidate") && - (typeof e.method === "undefined" || - e.method === "DELETE" || - e.method === "GET" || - e.method === "HEAD" || - e.method === "PATCH" || - e.method === "POST" || - e.method === "PUT") && (typeof e.options === "undefined" || (e.options !== null && typeof e.options === "object" || @@ -131,131 +92,19 @@ export function isGenerateSWOptions(obj: any, _argumentName?: string): obj is Ge (e.options.backgroundSync !== null && typeof e.options.backgroundSync === "object" || typeof e.options.backgroundSync === "function") && - typeof e.options.backgroundSync.name === "string" && - (typeof e.options.backgroundSync.options === "undefined" || - (e.options.backgroundSync.options !== null && - typeof e.options.backgroundSync.options === "object" || - typeof e.options.backgroundSync.options === "function") && - (typeof e.options.backgroundSync.options.onSync === "undefined" || - (e.options.backgroundSync.options.onSync !== null && - typeof e.options.backgroundSync.options.onSync === "object" || - typeof e.options.backgroundSync.options.onSync === "function")) && - (typeof e.options.backgroundSync.options.maxRetentionTime === "undefined" || - typeof e.options.backgroundSync.options.maxRetentionTime === "number"))) && + typeof e.options.backgroundSync.name === "string") && (typeof e.options.broadcastUpdate === "undefined" || (e.options.broadcastUpdate !== null && typeof e.options.broadcastUpdate === "object" || typeof e.options.broadcastUpdate === "function") && (typeof e.options.broadcastUpdate.channelName === "undefined" || - typeof e.options.broadcastUpdate.channelName === "string") && - (e.options.broadcastUpdate.options !== null && - typeof e.options.broadcastUpdate.options === "object" || - typeof e.options.broadcastUpdate.options === "function") && - (typeof e.options.broadcastUpdate.options.headersToCheck === "undefined" || - Array.isArray(e.options.broadcastUpdate.options.headersToCheck) && - e.options.broadcastUpdate.options.headersToCheck.every((e: any) => - typeof e === "string" - )) && - (typeof e.options.broadcastUpdate.options.generatePayload === "undefined" || - (e.options.broadcastUpdate.options.generatePayload !== null && - typeof e.options.broadcastUpdate.options.generatePayload === "object" || - typeof e.options.broadcastUpdate.options.generatePayload === "function"))) && - (typeof e.options.cacheableResponse === "undefined" || - (e.options.cacheableResponse !== null && - typeof e.options.cacheableResponse === "object" || - typeof e.options.cacheableResponse === "function") && - (typeof e.options.cacheableResponse.statuses === "undefined" || - Array.isArray(e.options.cacheableResponse.statuses) && - e.options.cacheableResponse.statuses.every((e: any) => - typeof e === "number" - )) && - (typeof e.options.cacheableResponse.headers === "undefined" || - (e.options.cacheableResponse.headers !== null && - typeof e.options.cacheableResponse.headers === "object" || - typeof e.options.cacheableResponse.headers === "function"))) && + typeof e.options.broadcastUpdate.channelName === "string")) && (typeof e.options.cacheName === "undefined" || typeof e.options.cacheName === "string") && - (typeof e.options.expiration === "undefined" || - (e.options.expiration !== null && - typeof e.options.expiration === "object" || - typeof e.options.expiration === "function") && - (typeof e.options.expiration.maxEntries === "undefined" || - typeof e.options.expiration.maxEntries === "number") && - (typeof e.options.expiration.maxAgeSeconds === "undefined" || - typeof e.options.expiration.maxAgeSeconds === "number") && - (typeof e.options.expiration.matchOptions === "undefined" || - (e.options.expiration.matchOptions !== null && - typeof e.options.expiration.matchOptions === "object" || - typeof e.options.expiration.matchOptions === "function") && - (typeof e.options.expiration.matchOptions.ignoreMethod === "undefined" || - e.options.expiration.matchOptions.ignoreMethod === false || - e.options.expiration.matchOptions.ignoreMethod === true) && - (typeof e.options.expiration.matchOptions.ignoreSearch === "undefined" || - e.options.expiration.matchOptions.ignoreSearch === false || - e.options.expiration.matchOptions.ignoreSearch === true) && - (typeof e.options.expiration.matchOptions.ignoreVary === "undefined" || - e.options.expiration.matchOptions.ignoreVary === false || - e.options.expiration.matchOptions.ignoreVary === true)) && - (typeof e.options.expiration.purgeOnQuotaError === "undefined" || - e.options.expiration.purgeOnQuotaError === false || - e.options.expiration.purgeOnQuotaError === true)) && (typeof e.options.networkTimeoutSeconds === "undefined" || typeof e.options.networkTimeoutSeconds === "number") && (typeof e.options.plugins === "undefined" || - Array.isArray(e.options.plugins) && - e.options.plugins.every((e: any) => - (e !== null && - typeof e === "object" || - typeof e === "function") && - (typeof e.cacheDidUpdate === "undefined" || - (e.cacheDidUpdate !== null && - typeof e.cacheDidUpdate === "object" || - typeof e.cacheDidUpdate === "function")) && - (typeof e.cachedResponseWillBeUsed === "undefined" || - (e.cachedResponseWillBeUsed !== null && - typeof e.cachedResponseWillBeUsed === "object" || - typeof e.cachedResponseWillBeUsed === "function")) && - (typeof e.cacheKeyWillBeUsed === "undefined" || - (e.cacheKeyWillBeUsed !== null && - typeof e.cacheKeyWillBeUsed === "object" || - typeof e.cacheKeyWillBeUsed === "function")) && - (typeof e.cacheWillUpdate === "undefined" || - (e.cacheWillUpdate !== null && - typeof e.cacheWillUpdate === "object" || - typeof e.cacheWillUpdate === "function")) && - (typeof e.fetchDidFail === "undefined" || - (e.fetchDidFail !== null && - typeof e.fetchDidFail === "object" || - typeof e.fetchDidFail === "function")) && - (typeof e.fetchDidSucceed === "undefined" || - (e.fetchDidSucceed !== null && - typeof e.fetchDidSucceed === "object" || - typeof e.fetchDidSucceed === "function")) && - (typeof e.handlerDidComplete === "undefined" || - (e.handlerDidComplete !== null && - typeof e.handlerDidComplete === "object" || - typeof e.handlerDidComplete === "function")) && - (typeof e.handlerDidError === "undefined" || - (e.handlerDidError !== null && - typeof e.handlerDidError === "object" || - typeof e.handlerDidError === "function")) && - (typeof e.handlerDidRespond === "undefined" || - (e.handlerDidRespond !== null && - typeof e.handlerDidRespond === "object" || - typeof e.handlerDidRespond === "function")) && - (typeof e.handlerWillRespond === "undefined" || - (e.handlerWillRespond !== null && - typeof e.handlerWillRespond === "object" || - typeof e.handlerWillRespond === "function")) && - (typeof e.handlerWillStart === "undefined" || - (e.handlerWillStart !== null && - typeof e.handlerWillStart === "object" || - typeof e.handlerWillStart === "function")) && - (typeof e.requestWillFetch === "undefined" || - (e.requestWillFetch !== null && - typeof e.requestWillFetch === "object" || - typeof e.requestWillFetch === "function")) - )) && + Array.isArray(e.options.plugins)) && (typeof e.options.precacheFallback === "undefined" || (e.options.precacheFallback !== null && typeof e.options.precacheFallback === "object" || @@ -268,7 +117,6 @@ export function isGenerateSWOptions(obj: any, _argumentName?: string): obj is Ge (typeof e.options.fetchOptions.body === "undefined" || e.options.fetchOptions.body === null || typeof e.options.fetchOptions.body === "string" || - e.options.fetchOptions.body instanceof URLSearchParams || e.options.fetchOptions.body instanceof Blob || (e.options.fetchOptions.body !== null && typeof e.options.fetchOptions.body === "object" || @@ -279,6 +127,7 @@ export function isGenerateSWOptions(obj: any, _argumentName?: string): obj is Ge typeof e.options.fetchOptions.body.byteOffset === "number" || e.options.fetchOptions.body instanceof ArrayBuffer || e.options.fetchOptions.body instanceof FormData || + e.options.fetchOptions.body instanceof URLSearchParams || e.options.fetchOptions.body instanceof ReadableStream) && (typeof e.options.fetchOptions.cache === "undefined" || e.options.fetchOptions.cache === "default" || @@ -346,12 +195,7 @@ export function isGenerateSWOptions(obj: any, _argumentName?: string): obj is Ge e.options.matchOptions.ignoreSearch === true) && (typeof e.options.matchOptions.ignoreVary === "undefined" || e.options.matchOptions.ignoreVary === false || - e.options.matchOptions.ignoreVary === true))) && - (typeof e.urlPattern === "string" || - e.urlPattern instanceof RegExp || - (e.urlPattern !== null && - typeof e.urlPattern === "object" || - typeof e.urlPattern === "function")) + e.options.matchOptions.ignoreVary === true))) ) && (typeof obj.skipWaiting === "undefined" || obj.skipWaiting === false || @@ -406,16 +250,14 @@ export function isGetManifestOptions(obj: any, _argumentName?: string): obj is G (typeof obj.globFollow === "undefined" || obj.globFollow === false || obj.globFollow === true) && - (typeof obj.globIgnores === "undefined" || - Array.isArray(obj.globIgnores) && - obj.globIgnores.every((e: any) => - typeof e === "string" - )) && - (typeof obj.globPatterns === "undefined" || - Array.isArray(obj.globPatterns) && - obj.globPatterns.every((e: any) => - typeof e === "string" - )) && + Array.isArray(obj.globIgnores) && + obj.globIgnores.every((e: any) => + typeof e === "string" + ) && + Array.isArray(obj.globPatterns) && + obj.globPatterns.every((e: any) => + typeof e === "string" + ) && (typeof obj.globStrict === "undefined" || obj.globStrict === false || obj.globStrict === true) && @@ -460,27 +302,22 @@ export function isInjectManifestOptions(obj: any, _argumentName?: string): obj i ((obj !== null && typeof obj === "object" || typeof obj === "function") && - (typeof obj.injectionPoint === "undefined" || - typeof obj.injectionPoint === "string") && + typeof obj.injectionPoint === "string" && typeof obj.swSrc === "string" || (obj !== null && typeof obj === "object" || typeof obj === "function") && - (typeof obj.globDirectory === "undefined" || - typeof obj.globDirectory === "string") && (typeof obj.globFollow === "undefined" || obj.globFollow === false || obj.globFollow === true) && - (typeof obj.globIgnores === "undefined" || - Array.isArray(obj.globIgnores) && - obj.globIgnores.every((e: any) => - typeof e === "string" - )) && - (typeof obj.globPatterns === "undefined" || - Array.isArray(obj.globPatterns) && - obj.globPatterns.every((e: any) => - typeof e === "string" - )) && + Array.isArray(obj.globIgnores) && + obj.globIgnores.every((e: any) => + typeof e === "string" + ) && + Array.isArray(obj.globPatterns) && + obj.globPatterns.every((e: any) => + typeof e === "string" + ) && (typeof obj.globStrict === "undefined" || obj.globStrict === false || obj.globStrict === true) && @@ -520,7 +357,11 @@ export function isInjectManifestOptions(obj: any, _argumentName?: string): obj i (obj !== null && typeof obj === "object" || typeof obj === "function") && - typeof obj.swDest === "string") + typeof obj.swDest === "string" || + (obj !== null && + typeof obj === "object" || + typeof obj === "function") && + typeof obj.globDirectory === "string") ) } @@ -610,48 +451,11 @@ export function isWebpackGenerateSWOptions(obj: any, _argumentName?: string): ob (typeof obj.navigationPreload === "undefined" || obj.navigationPreload === false || obj.navigationPreload === true) && - (typeof obj.offlineGoogleAnalytics === "undefined" || - obj.offlineGoogleAnalytics === false || - obj.offlineGoogleAnalytics === true || - (obj.offlineGoogleAnalytics !== null && - typeof obj.offlineGoogleAnalytics === "object" || - typeof obj.offlineGoogleAnalytics === "function") && - (typeof obj.offlineGoogleAnalytics.cacheName === "undefined" || - typeof obj.offlineGoogleAnalytics.cacheName === "string") && - (typeof obj.offlineGoogleAnalytics.parameterOverrides === "undefined" || - (obj.offlineGoogleAnalytics.parameterOverrides !== null && - typeof obj.offlineGoogleAnalytics.parameterOverrides === "object" || - typeof obj.offlineGoogleAnalytics.parameterOverrides === "function")) && - (typeof obj.offlineGoogleAnalytics.hitFilter === "undefined" || - (obj.offlineGoogleAnalytics.hitFilter !== null && - typeof obj.offlineGoogleAnalytics.hitFilter === "object" || - typeof obj.offlineGoogleAnalytics.hitFilter === "function"))) && Array.isArray(obj.runtimeCaching) && obj.runtimeCaching.every((e: any) => (e !== null && typeof e === "object" || typeof e === "function") && - ((e.handler !== null && - typeof e.handler === "object" || - typeof e.handler === "function") || - (e.handler !== null && - typeof e.handler === "object" || - typeof e.handler === "function") && - (e.handler.handle !== null && - typeof e.handler.handle === "object" || - typeof e.handler.handle === "function") || - e.handler === "CacheFirst" || - e.handler === "CacheOnly" || - e.handler === "NetworkFirst" || - e.handler === "NetworkOnly" || - e.handler === "StaleWhileRevalidate") && - (typeof e.method === "undefined" || - e.method === "DELETE" || - e.method === "GET" || - e.method === "HEAD" || - e.method === "PATCH" || - e.method === "POST" || - e.method === "PUT") && (typeof e.options === "undefined" || (e.options !== null && typeof e.options === "object" || @@ -660,131 +464,19 @@ export function isWebpackGenerateSWOptions(obj: any, _argumentName?: string): ob (e.options.backgroundSync !== null && typeof e.options.backgroundSync === "object" || typeof e.options.backgroundSync === "function") && - typeof e.options.backgroundSync.name === "string" && - (typeof e.options.backgroundSync.options === "undefined" || - (e.options.backgroundSync.options !== null && - typeof e.options.backgroundSync.options === "object" || - typeof e.options.backgroundSync.options === "function") && - (typeof e.options.backgroundSync.options.onSync === "undefined" || - (e.options.backgroundSync.options.onSync !== null && - typeof e.options.backgroundSync.options.onSync === "object" || - typeof e.options.backgroundSync.options.onSync === "function")) && - (typeof e.options.backgroundSync.options.maxRetentionTime === "undefined" || - typeof e.options.backgroundSync.options.maxRetentionTime === "number"))) && + typeof e.options.backgroundSync.name === "string") && (typeof e.options.broadcastUpdate === "undefined" || (e.options.broadcastUpdate !== null && typeof e.options.broadcastUpdate === "object" || typeof e.options.broadcastUpdate === "function") && (typeof e.options.broadcastUpdate.channelName === "undefined" || - typeof e.options.broadcastUpdate.channelName === "string") && - (e.options.broadcastUpdate.options !== null && - typeof e.options.broadcastUpdate.options === "object" || - typeof e.options.broadcastUpdate.options === "function") && - (typeof e.options.broadcastUpdate.options.headersToCheck === "undefined" || - Array.isArray(e.options.broadcastUpdate.options.headersToCheck) && - e.options.broadcastUpdate.options.headersToCheck.every((e: any) => - typeof e === "string" - )) && - (typeof e.options.broadcastUpdate.options.generatePayload === "undefined" || - (e.options.broadcastUpdate.options.generatePayload !== null && - typeof e.options.broadcastUpdate.options.generatePayload === "object" || - typeof e.options.broadcastUpdate.options.generatePayload === "function"))) && - (typeof e.options.cacheableResponse === "undefined" || - (e.options.cacheableResponse !== null && - typeof e.options.cacheableResponse === "object" || - typeof e.options.cacheableResponse === "function") && - (typeof e.options.cacheableResponse.statuses === "undefined" || - Array.isArray(e.options.cacheableResponse.statuses) && - e.options.cacheableResponse.statuses.every((e: any) => - typeof e === "number" - )) && - (typeof e.options.cacheableResponse.headers === "undefined" || - (e.options.cacheableResponse.headers !== null && - typeof e.options.cacheableResponse.headers === "object" || - typeof e.options.cacheableResponse.headers === "function"))) && + typeof e.options.broadcastUpdate.channelName === "string")) && (typeof e.options.cacheName === "undefined" || typeof e.options.cacheName === "string") && - (typeof e.options.expiration === "undefined" || - (e.options.expiration !== null && - typeof e.options.expiration === "object" || - typeof e.options.expiration === "function") && - (typeof e.options.expiration.maxEntries === "undefined" || - typeof e.options.expiration.maxEntries === "number") && - (typeof e.options.expiration.maxAgeSeconds === "undefined" || - typeof e.options.expiration.maxAgeSeconds === "number") && - (typeof e.options.expiration.matchOptions === "undefined" || - (e.options.expiration.matchOptions !== null && - typeof e.options.expiration.matchOptions === "object" || - typeof e.options.expiration.matchOptions === "function") && - (typeof e.options.expiration.matchOptions.ignoreMethod === "undefined" || - e.options.expiration.matchOptions.ignoreMethod === false || - e.options.expiration.matchOptions.ignoreMethod === true) && - (typeof e.options.expiration.matchOptions.ignoreSearch === "undefined" || - e.options.expiration.matchOptions.ignoreSearch === false || - e.options.expiration.matchOptions.ignoreSearch === true) && - (typeof e.options.expiration.matchOptions.ignoreVary === "undefined" || - e.options.expiration.matchOptions.ignoreVary === false || - e.options.expiration.matchOptions.ignoreVary === true)) && - (typeof e.options.expiration.purgeOnQuotaError === "undefined" || - e.options.expiration.purgeOnQuotaError === false || - e.options.expiration.purgeOnQuotaError === true)) && (typeof e.options.networkTimeoutSeconds === "undefined" || typeof e.options.networkTimeoutSeconds === "number") && (typeof e.options.plugins === "undefined" || - Array.isArray(e.options.plugins) && - e.options.plugins.every((e: any) => - (e !== null && - typeof e === "object" || - typeof e === "function") && - (typeof e.cacheDidUpdate === "undefined" || - (e.cacheDidUpdate !== null && - typeof e.cacheDidUpdate === "object" || - typeof e.cacheDidUpdate === "function")) && - (typeof e.cachedResponseWillBeUsed === "undefined" || - (e.cachedResponseWillBeUsed !== null && - typeof e.cachedResponseWillBeUsed === "object" || - typeof e.cachedResponseWillBeUsed === "function")) && - (typeof e.cacheKeyWillBeUsed === "undefined" || - (e.cacheKeyWillBeUsed !== null && - typeof e.cacheKeyWillBeUsed === "object" || - typeof e.cacheKeyWillBeUsed === "function")) && - (typeof e.cacheWillUpdate === "undefined" || - (e.cacheWillUpdate !== null && - typeof e.cacheWillUpdate === "object" || - typeof e.cacheWillUpdate === "function")) && - (typeof e.fetchDidFail === "undefined" || - (e.fetchDidFail !== null && - typeof e.fetchDidFail === "object" || - typeof e.fetchDidFail === "function")) && - (typeof e.fetchDidSucceed === "undefined" || - (e.fetchDidSucceed !== null && - typeof e.fetchDidSucceed === "object" || - typeof e.fetchDidSucceed === "function")) && - (typeof e.handlerDidComplete === "undefined" || - (e.handlerDidComplete !== null && - typeof e.handlerDidComplete === "object" || - typeof e.handlerDidComplete === "function")) && - (typeof e.handlerDidError === "undefined" || - (e.handlerDidError !== null && - typeof e.handlerDidError === "object" || - typeof e.handlerDidError === "function")) && - (typeof e.handlerDidRespond === "undefined" || - (e.handlerDidRespond !== null && - typeof e.handlerDidRespond === "object" || - typeof e.handlerDidRespond === "function")) && - (typeof e.handlerWillRespond === "undefined" || - (e.handlerWillRespond !== null && - typeof e.handlerWillRespond === "object" || - typeof e.handlerWillRespond === "function")) && - (typeof e.handlerWillStart === "undefined" || - (e.handlerWillStart !== null && - typeof e.handlerWillStart === "object" || - typeof e.handlerWillStart === "function")) && - (typeof e.requestWillFetch === "undefined" || - (e.requestWillFetch !== null && - typeof e.requestWillFetch === "object" || - typeof e.requestWillFetch === "function")) - )) && + Array.isArray(e.options.plugins)) && (typeof e.options.precacheFallback === "undefined" || (e.options.precacheFallback !== null && typeof e.options.precacheFallback === "object" || @@ -797,7 +489,6 @@ export function isWebpackGenerateSWOptions(obj: any, _argumentName?: string): ob (typeof e.options.fetchOptions.body === "undefined" || e.options.fetchOptions.body === null || typeof e.options.fetchOptions.body === "string" || - e.options.fetchOptions.body instanceof URLSearchParams || e.options.fetchOptions.body instanceof Blob || (e.options.fetchOptions.body !== null && typeof e.options.fetchOptions.body === "object" || @@ -808,6 +499,7 @@ export function isWebpackGenerateSWOptions(obj: any, _argumentName?: string): ob typeof e.options.fetchOptions.body.byteOffset === "number" || e.options.fetchOptions.body instanceof ArrayBuffer || e.options.fetchOptions.body instanceof FormData || + e.options.fetchOptions.body instanceof URLSearchParams || e.options.fetchOptions.body instanceof ReadableStream) && (typeof e.options.fetchOptions.cache === "undefined" || e.options.fetchOptions.cache === "default" || @@ -875,12 +567,7 @@ export function isWebpackGenerateSWOptions(obj: any, _argumentName?: string): ob e.options.matchOptions.ignoreSearch === true) && (typeof e.options.matchOptions.ignoreVary === "undefined" || e.options.matchOptions.ignoreVary === false || - e.options.matchOptions.ignoreVary === true))) && - (typeof e.urlPattern === "string" || - e.urlPattern instanceof RegExp || - (e.urlPattern !== null && - typeof e.urlPattern === "object" || - typeof e.urlPattern === "function")) + e.options.matchOptions.ignoreVary === true))) ) && (typeof obj.skipWaiting === "undefined" || obj.skipWaiting === false || @@ -970,8 +657,7 @@ export function isWebpackInjectManifestOptions(obj: any, _argumentName?: string) (obj !== null && typeof obj === "object" || typeof obj === "function") && - (typeof obj.injectionPoint === "undefined" || - typeof obj.injectionPoint === "string") && + typeof obj.injectionPoint === "string" && typeof obj.swSrc === "string" || (obj !== null && typeof obj === "object" || diff --git a/packages/workbox-build/src/types.ts b/packages/workbox-build/src/types.ts index 1a9cf80d1..730130684 100644 --- a/packages/workbox-build/src/types.ts +++ b/packages/workbox-build/src/types.ts @@ -90,7 +90,7 @@ export interface GlobPartial { globDirectory?: string; globFollow?: boolean; globIgnores: Array; - globPatterns?: Array; + globPatterns: Array; globStrict?: boolean; templatedURLs: { [key: string]: string | Array; From c40c8732cc6783f042603902119b9dfd669a1a32 Mon Sep 17 00:00:00 2001 From: Jeff Posnick Date: Sat, 16 Jan 2021 18:18:37 -0500 Subject: [PATCH 10/80] Builds! --- .../src/lib/copy-workbox-libraries.ts | 2 +- .../src/lib/get-file-manifest-entries.ts | 64 +++++++++---------- .../src/lib/stringify-without-comments.ts | 9 ++- .../workbox-build/src/strip-comments.d.ts | 1 + 4 files changed, 41 insertions(+), 35 deletions(-) create mode 100644 packages/workbox-build/src/strip-comments.d.ts diff --git a/packages/workbox-build/src/lib/copy-workbox-libraries.ts b/packages/workbox-build/src/lib/copy-workbox-libraries.ts index f89661f01..19db61c4f 100644 --- a/packages/workbox-build/src/lib/copy-workbox-libraries.ts +++ b/packages/workbox-build/src/lib/copy-workbox-libraries.ts @@ -48,7 +48,7 @@ export default async function(destDirectory: string): Promise { await fse.ensureDir(workboxDirectoryPath); const copyPromises: Array> = []; - const librariesToCopy = Object.keys(thisPkg.dependencies).filter( + const librariesToCopy = Object.keys(thisPkg.dependencies || {}).filter( (dependency) => dependency.startsWith(WORKBOX_PREFIX)); for (const library of librariesToCopy) { diff --git a/packages/workbox-build/src/lib/get-file-manifest-entries.ts b/packages/workbox-build/src/lib/get-file-manifest-entries.ts index 55529e933..28f1fde49 100644 --- a/packages/workbox-build/src/lib/get-file-manifest-entries.ts +++ b/packages/workbox-build/src/lib/get-file-manifest-entries.ts @@ -57,40 +57,40 @@ export default async function ({ // it back as a warning, and don't consider it fatal. warnings.push(error.message); } + } + + if (globDirectory && templatedURLs) { + for (const url of Object.keys(templatedURLs)) { + assert(!allFileDetails.has(url), errors['templated-url-matches-glob']); + + const dependencies = templatedURLs[url]; + if (Array.isArray(dependencies)) { + const details = dependencies.reduce>((previous, globPattern) => { + try { + const {globbedFileDetails, warning} = getFileDetails({ + globDirectory, + globFollow, + globIgnores, + globPattern, + globStrict, + }); - if (templatedURLs) { - for (const url of Object.keys(templatedURLs)) { - assert(!allFileDetails.has(url), errors['templated-url-matches-glob']); - - const dependencies = templatedURLs[url]; - if (Array.isArray(dependencies)) { - const details = dependencies.reduce((previous, globPattern) => { - try { - const {globbedFileDetails, warning} = getFileDetails({ - globDirectory, - globFollow, - globIgnores, - globPattern, - globStrict, - }); - - if (warning) { - warnings.push(warning); - } - - return previous.concat(globbedFileDetails); - } catch (error) { - const debugObj: {[key: string]: Array} = {}; - debugObj[url] = dependencies; - throw new Error(`${errors['bad-template-urls-asset']} ` + - `'${globPattern}' from '${JSON.stringify(debugObj)}':\n` + - error); + if (warning) { + warnings.push(warning); } - }, []); - allFileDetails.set(url, getCompositeDetails(url, details)); - } else if (typeof dependencies === 'string') { - allFileDetails.set(url, getStringDetails(url, dependencies)); - } + + return previous.concat(globbedFileDetails); + } catch (error) { + const debugObj: {[key: string]: Array} = {}; + debugObj[url] = dependencies; + throw new Error(`${errors['bad-template-urls-asset']} ` + + `'${globPattern}' from '${JSON.stringify(debugObj)}':\n` + + error); + } + }, []); + allFileDetails.set(url, getCompositeDetails(url, details)); + } else if (typeof dependencies === 'string') { + allFileDetails.set(url, getStringDetails(url, dependencies)); } } } diff --git a/packages/workbox-build/src/lib/stringify-without-comments.ts b/packages/workbox-build/src/lib/stringify-without-comments.ts index 1cc7a7f51..2513bbf3c 100644 --- a/packages/workbox-build/src/lib/stringify-without-comments.ts +++ b/packages/workbox-build/src/lib/stringify-without-comments.ts @@ -11,7 +11,12 @@ import stripComments from 'strip-comments'; export default function(obj: {[key: string]: any}): string { return objectStringify(obj, { - transform: (_obj: {[key: string]: any}, _prop: string, str: string) => - typeof _obj[_prop] === 'function' ? stripComments(str) : str, + // See https://github.com/yeoman/stringify-object#transformobject-property-originalresult + transform: (_obj: {[key: string]: any}, _prop, str) => { + if (typeof _prop !== 'symbol' && typeof _obj[_prop] === 'function') { + return stripComments(str); + } + return str; + }, }); }; diff --git a/packages/workbox-build/src/strip-comments.d.ts b/packages/workbox-build/src/strip-comments.d.ts new file mode 100644 index 000000000..3d681f453 --- /dev/null +++ b/packages/workbox-build/src/strip-comments.d.ts @@ -0,0 +1 @@ +declare module 'strip-comments'; From 1e946bffad4bdb7cd620b45c5833fd4c8f0ee353 Mon Sep 17 00:00:00 2001 From: Jeff Posnick Date: Sat, 16 Jan 2021 20:06:40 -0500 Subject: [PATCH 11/80] No default exports --- packages/workbox-build/src/generate-sw.ts | 8 ++++---- packages/workbox-build/src/get-manifest.ts | 2 +- packages/workbox-build/src/index.ts | 2 +- packages/workbox-build/src/inject-manifest.ts | 12 ++++++------ .../lib/additional-manifest-entries-transform.ts | 5 ++--- packages/workbox-build/src/lib/bundle.ts | 2 +- packages/workbox-build/src/lib/cdn-utils.ts | 2 +- .../src/lib/copy-workbox-libraries.ts | 4 ++-- packages/workbox-build/src/lib/errors.ts | 2 +- packages/workbox-build/src/lib/escape-regexp.ts | 2 +- .../workbox-build/src/lib/get-composite-details.ts | 2 +- packages/workbox-build/src/lib/get-file-details.ts | 8 ++++---- packages/workbox-build/src/lib/get-file-hash.ts | 6 +++--- .../src/lib/get-file-manifest-entries.ts | 12 ++++++------ packages/workbox-build/src/lib/get-file-size.ts | 4 ++-- .../workbox-build/src/lib/get-string-details.ts | 5 ++--- packages/workbox-build/src/lib/get-string-hash.ts | 2 +- .../src/lib/maximum-size-transform.ts | 2 +- .../src/lib/modify-url-prefix-transform.ts | 7 +++---- packages/workbox-build/src/lib/module-registry.ts | 2 +- .../lib/no-revision-for-urls-matching-transform.ts | 5 ++--- .../workbox-build/src/lib/populate-sw-template.ts | 10 +++++----- packages/workbox-build/src/lib/rebase-path.ts | 2 +- .../src/lib/replace-and-update-source-map.ts | 2 +- .../src/lib/runtime-caching-converter.ts | 10 +++++----- .../src/lib/stringify-without-comments.ts | 2 +- .../workbox-build/src/lib/transform-manifest.ts | 14 +++++++------- .../src/lib/write-sw-using-default-template.ts | 6 +++--- .../workbox-build/src/templates/sw-template.ts | 2 +- test/workbox-build/node/generate-sw.js | 4 ++-- test/workbox-build/node/get-manifest.js | 2 +- test/workbox-build/node/inject-manifest.js | 4 ++-- .../lib/additional-manifest-entries-transform.js | 4 ++-- test/workbox-build/node/lib/bundle.js | 2 +- test/workbox-build/node/lib/cdn-utils.js | 4 ++-- .../node/lib/copy-workbox-libraries.js | 4 ++-- test/workbox-build/node/lib/escape-regexp.js | 2 +- .../node/lib/get-composite-details.js | 2 +- test/workbox-build/node/lib/get-file-details.js | 4 ++-- test/workbox-build/node/lib/get-file-hash.js | 4 ++-- .../node/lib/get-file-manifest-entries.js | 4 ++-- test/workbox-build/node/lib/get-file-size.js | 4 ++-- test/workbox-build/node/lib/get-string-details.js | 2 +- test/workbox-build/node/lib/get-string-hash.js | 2 +- .../node/lib/modify-url-prefix-transform.js | 4 ++-- test/workbox-build/node/lib/module-registry.js | 2 +- .../lib/no-revision-for-urls-matching-transform.js | 4 ++-- .../workbox-build/node/lib/populate-sw-template.js | 4 ++-- .../node/lib/replace-and-update-source-map.js | 2 +- .../node/lib/runtime-caching-converter.js | 6 +++--- test/workbox-build/node/lib/transform-manifest.js | 2 +- test/workbox-build/node/lib/validate-options.js | 2 +- .../node/lib/write-sw-using-default-template.js | 4 ++-- 53 files changed, 109 insertions(+), 113 deletions(-) diff --git a/packages/workbox-build/src/generate-sw.ts b/packages/workbox-build/src/generate-sw.ts index a207556f2..44ae68b1d 100644 --- a/packages/workbox-build/src/generate-sw.ts +++ b/packages/workbox-build/src/generate-sw.ts @@ -9,10 +9,10 @@ import upath from 'upath'; import {BuildResult} from './types'; -import getFileManifestEntries from './lib/get-file-manifest-entries'; -import rebasePath from './lib/rebase-path'; +import {getFileManifestEntries} from './lib/get-file-manifest-entries'; +import {rebasePath} from './lib/rebase-path'; import {validateGenerateSWOptions} from './lib/validate-options'; -import writeServiceWorkerUsingDefaultTemplate from './lib/write-sw-using-default-template'; +import {writeSWUsingDefaultTemplate} from './lib/write-sw-using-default-template'; // eslint-disable-next-line jsdoc/newline-after-description /** @@ -218,7 +218,7 @@ export default async function(config: unknown): Promise { const {count, size, manifestEntries, warnings} = await getFileManifestEntries(options); - const filePaths = await writeServiceWorkerUsingDefaultTemplate(Object.assign({ + const filePaths = await writeSWUsingDefaultTemplate(Object.assign({ manifestEntries, }, options)); diff --git a/packages/workbox-build/src/get-manifest.ts b/packages/workbox-build/src/get-manifest.ts index 313ecdc0e..c8b24a962 100644 --- a/packages/workbox-build/src/get-manifest.ts +++ b/packages/workbox-build/src/get-manifest.ts @@ -6,8 +6,8 @@ https://opensource.org/licenses/MIT. */ +import {getFileManifestEntries} from './lib/get-file-manifest-entries'; import {GetManifestResult} from './types'; -import getFileManifestEntries from './lib/get-file-manifest-entries'; import {validateGetManifestOptions} from './lib/validate-options'; // eslint-disable-next-line jsdoc/newline-after-description diff --git a/packages/workbox-build/src/index.ts b/packages/workbox-build/src/index.ts index 3c591555a..2c6255107 100644 --- a/packages/workbox-build/src/index.ts +++ b/packages/workbox-build/src/index.ts @@ -6,8 +6,8 @@ https://opensource.org/licenses/MIT. */ +import {copyWorkboxLibraries} from './lib/copy-workbox-libraries'; import {getModuleURL} from './lib/cdn-utils'; -import copyWorkboxLibraries from './lib/copy-workbox-libraries'; import generateSW from './generate-sw'; import getManifest from './get-manifest'; import injectManifest from './inject-manifest'; diff --git a/packages/workbox-build/src/inject-manifest.ts b/packages/workbox-build/src/inject-manifest.ts index 0660bc7ca..10c91a43c 100644 --- a/packages/workbox-build/src/inject-manifest.ts +++ b/packages/workbox-build/src/inject-manifest.ts @@ -14,11 +14,11 @@ import stringify from 'fast-json-stable-stringify'; import upath from 'upath'; import {BuildResult} from './types'; -import errors from './lib/errors'; -import escapeRegexp from './lib/escape-regexp'; -import getFileManifestEntries from './lib/get-file-manifest-entries'; -import rebasePath from './lib/rebase-path'; -import replaceAndUpdateSourceMap from './lib/replace-and-update-source-map'; +import {errors} from './lib/errors'; +import {escapeRegExp} from './lib/escape-regexp'; +import {getFileManifestEntries} from './lib/get-file-manifest-entries'; +import {rebasePath} from './lib/rebase-path'; +import {replaceAndUpdateSourceMap} from './lib/replace-and-update-source-map'; import {validateInjectManifestOptions} from './lib/validate-options'; // eslint-disable-next-line jsdoc/newline-after-description @@ -127,7 +127,7 @@ export default async function(config: unknown): Promise { })); } - const globalRegexp = new RegExp(escapeRegexp(options.injectionPoint), 'g'); + const globalRegexp = new RegExp(escapeRegExp(options.injectionPoint), 'g'); const {count, size, manifestEntries, warnings} = await getFileManifestEntries(options); diff --git a/packages/workbox-build/src/lib/additional-manifest-entries-transform.ts b/packages/workbox-build/src/lib/additional-manifest-entries-transform.ts index e6db5e0cb..b91ab668b 100644 --- a/packages/workbox-build/src/lib/additional-manifest-entries-transform.ts +++ b/packages/workbox-build/src/lib/additional-manifest-entries-transform.ts @@ -6,11 +6,10 @@ https://opensource.org/licenses/MIT. */ -import errors from './errors'; - +import {errors} from './errors'; import {ManifestEntry} from '../types'; -export default function(additionalManifestEntries: Array) { +export function additionalManifestEntriesTransform(additionalManifestEntries: Array) { return (manifest: Array) => { const warnings = []; const stringEntries = new Set(); diff --git a/packages/workbox-build/src/lib/bundle.ts b/packages/workbox-build/src/lib/bundle.ts index f47aaa1bf..6a565ffd7 100644 --- a/packages/workbox-build/src/lib/bundle.ts +++ b/packages/workbox-build/src/lib/bundle.ts @@ -24,7 +24,7 @@ interface NameAndContents { name: string } -export default async function({ +export async function bundle({ babelPresetEnvTargets, inlineWorkboxRuntime, mode, diff --git a/packages/workbox-build/src/lib/cdn-utils.ts b/packages/workbox-build/src/lib/cdn-utils.ts index 714af77eb..9d92f06f3 100644 --- a/packages/workbox-build/src/lib/cdn-utils.ts +++ b/packages/workbox-build/src/lib/cdn-utils.ts @@ -9,8 +9,8 @@ import assert from 'assert'; import {BuildType, WorkboxPackageJSON} from '../types'; +import {errors} from './errors'; import cdn from '../cdn-details.json'; -import errors from './errors'; function getVersionedURL(): string { return `${getCDNPrefix()}/${cdn.latestVersion}`; diff --git a/packages/workbox-build/src/lib/copy-workbox-libraries.ts b/packages/workbox-build/src/lib/copy-workbox-libraries.ts index 19db61c4f..3385aa980 100644 --- a/packages/workbox-build/src/lib/copy-workbox-libraries.ts +++ b/packages/workbox-build/src/lib/copy-workbox-libraries.ts @@ -10,7 +10,7 @@ import fse from 'fs-extra'; import upath from 'upath'; import {WorkboxPackageJSON} from '../types'; -import errors from './errors'; +import {errors} from './errors'; // Used to filter the libraries to copy based on our package.json dependencies. const WORKBOX_PREFIX = 'workbox-'; @@ -37,7 +37,7 @@ const BUILD_DIR = 'build'; * * @alias module:workbox-build.copyWorkboxLibraries */ -export default async function(destDirectory: string): Promise { +export async function copyWorkboxLibraries(destDirectory: string): Promise { const thisPkg: WorkboxPackageJSON = require('../../package.json'); // Use the version string from workbox-build in the name of the parent // directory. This should be safe, because lerna will bump workbox-build's diff --git a/packages/workbox-build/src/lib/errors.ts b/packages/workbox-build/src/lib/errors.ts index 98d464ac5..f166b07e6 100644 --- a/packages/workbox-build/src/lib/errors.ts +++ b/packages/workbox-build/src/lib/errors.ts @@ -8,7 +8,7 @@ import {oneLine as ol} from 'common-tags'; -export default { +export const errors = { 'unable-to-get-rootdir': `Unable to get the root directory of your web app.`, 'no-extension': ol`Unable to detect a usable extension for a file in your web app directory.`, diff --git a/packages/workbox-build/src/lib/escape-regexp.ts b/packages/workbox-build/src/lib/escape-regexp.ts index c95654727..1e4d9f4b9 100644 --- a/packages/workbox-build/src/lib/escape-regexp.ts +++ b/packages/workbox-build/src/lib/escape-regexp.ts @@ -7,6 +7,6 @@ */ // From https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions -export default function(str: string) { +export function escapeRegExp(str: string) { return str.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'); } diff --git a/packages/workbox-build/src/lib/get-composite-details.ts b/packages/workbox-build/src/lib/get-composite-details.ts index 3bb0f1568..c095efa46 100644 --- a/packages/workbox-build/src/lib/get-composite-details.ts +++ b/packages/workbox-build/src/lib/get-composite-details.ts @@ -10,7 +10,7 @@ import crypto from 'crypto'; import {FileDetails} from '../types'; -export default function(compositeURL: string, dependencyDetails: Array): FileDetails { +export function getCompositeDetails(compositeURL: string, dependencyDetails: Array): FileDetails { let totalSize = 0; let compositeHash = ''; diff --git a/packages/workbox-build/src/lib/get-file-details.ts b/packages/workbox-build/src/lib/get-file-details.ts index a8d5d689f..826140286 100644 --- a/packages/workbox-build/src/lib/get-file-details.ts +++ b/packages/workbox-build/src/lib/get-file-details.ts @@ -9,9 +9,9 @@ import glob from 'glob'; import upath from 'upath'; -import errors from './errors'; -import getFileSize from './get-file-size'; -import getFileHash from './get-file-hash'; +import {errors} from './errors'; +import {getFileSize} from './get-file-size'; +import {getFileHash} from './get-file-hash'; import {GlobPartial} from '../types'; @@ -21,7 +21,7 @@ interface FileDetails { size: number; }; -export default function({ +export function getFileDetails({ globDirectory, globFollow, globIgnores, diff --git a/packages/workbox-build/src/lib/get-file-hash.ts b/packages/workbox-build/src/lib/get-file-hash.ts index 71a35b0da..4ff9d1c01 100644 --- a/packages/workbox-build/src/lib/get-file-hash.ts +++ b/packages/workbox-build/src/lib/get-file-hash.ts @@ -8,10 +8,10 @@ import fse from 'fs-extra'; -import getStringHash from './get-string-hash'; -import errors from './errors'; +import {getStringHash} from './get-string-hash'; +import {errors} from './errors'; -export default function(file: string): string { +export function getFileHash(file: string): string { try { const str = fse.readFileSync(file, 'utf8'); return getStringHash(str); diff --git a/packages/workbox-build/src/lib/get-file-manifest-entries.ts b/packages/workbox-build/src/lib/get-file-manifest-entries.ts index 28f1fde49..ddbf38573 100644 --- a/packages/workbox-build/src/lib/get-file-manifest-entries.ts +++ b/packages/workbox-build/src/lib/get-file-manifest-entries.ts @@ -9,13 +9,13 @@ import assert from 'assert'; import {GetManifestResult, FileDetails, GetManifestOptions} from '../types'; -import errors from './errors'; -import getCompositeDetails from './get-composite-details'; -import getFileDetails from './get-file-details'; -import getStringDetails from './get-string-details'; -import transformManifest from './transform-manifest'; +import {errors} from './errors'; +import {getCompositeDetails} from './get-composite-details'; +import {getFileDetails} from './get-file-details'; +import {getStringDetails} from './get-string-details'; +import {transformManifest} from './transform-manifest'; -export default async function ({ +export async function getFileManifestEntries({ additionalManifestEntries, dontCacheBustURLsMatching, globDirectory, diff --git a/packages/workbox-build/src/lib/get-file-size.ts b/packages/workbox-build/src/lib/get-file-size.ts index eadf72bbc..81c9fcb02 100644 --- a/packages/workbox-build/src/lib/get-file-size.ts +++ b/packages/workbox-build/src/lib/get-file-size.ts @@ -8,9 +8,9 @@ import fse from 'fs-extra'; -import errors from './errors'; +import {errors} from './errors'; -export default function(file: string): number | null { +export function getFileSize(file: string): number | null { try { const stat = fse.statSync(file); if (!stat.isFile()) { diff --git a/packages/workbox-build/src/lib/get-string-details.ts b/packages/workbox-build/src/lib/get-string-details.ts index 63fa52436..7351e276b 100644 --- a/packages/workbox-build/src/lib/get-string-details.ts +++ b/packages/workbox-build/src/lib/get-string-details.ts @@ -6,11 +6,10 @@ https://opensource.org/licenses/MIT. */ -import getStringHash from './get-string-hash'; - import {FileDetails} from '../types'; +import {getStringHash} from './get-string-hash'; -export default function(url: string, str: string): FileDetails { +export function getStringDetails(url: string, str: string): FileDetails { return { file: url, hash: getStringHash(str), diff --git a/packages/workbox-build/src/lib/get-string-hash.ts b/packages/workbox-build/src/lib/get-string-hash.ts index a54917e6e..7b065169d 100644 --- a/packages/workbox-build/src/lib/get-string-hash.ts +++ b/packages/workbox-build/src/lib/get-string-hash.ts @@ -8,7 +8,7 @@ import crypto from 'crypto'; -export default function(str: string): string { +export function getStringHash(str: string): string { const md5 = crypto.createHash('md5'); md5.update(str); return md5.digest('hex'); diff --git a/packages/workbox-build/src/lib/maximum-size-transform.ts b/packages/workbox-build/src/lib/maximum-size-transform.ts index bf7cf6401..e1f7a13a5 100644 --- a/packages/workbox-build/src/lib/maximum-size-transform.ts +++ b/packages/workbox-build/src/lib/maximum-size-transform.ts @@ -10,7 +10,7 @@ import prettyBytes from 'pretty-bytes'; import {ManifestTransform} from '../types'; -export default function (maximumFileSizeToCacheInBytes: number): ManifestTransform { +export function maximumSizeTransform(maximumFileSizeToCacheInBytes: number): ManifestTransform { return (originalManifest) => { const warnings: Array = []; const manifest = originalManifest.filter((entry) => { diff --git a/packages/workbox-build/src/lib/modify-url-prefix-transform.ts b/packages/workbox-build/src/lib/modify-url-prefix-transform.ts index c1c71e004..4ced5cc8a 100644 --- a/packages/workbox-build/src/lib/modify-url-prefix-transform.ts +++ b/packages/workbox-build/src/lib/modify-url-prefix-transform.ts @@ -6,12 +6,11 @@ https://opensource.org/licenses/MIT. */ -const errors = require('./errors'); -const escapeRegExp = require('./escape-regexp'); - +import {errors} from './errors'; +import {escapeRegExp} from './escape-regexp'; import {ManifestTransform} from '../types'; -export default function(modifyURLPrefix: {[key: string]: string}): ManifestTransform { +export function modifyURLPrefixTransform(modifyURLPrefix: {[key: string]: string}): ManifestTransform { if (!modifyURLPrefix || typeof modifyURLPrefix !== 'object' || Array.isArray(modifyURLPrefix)) { diff --git a/packages/workbox-build/src/lib/module-registry.ts b/packages/workbox-build/src/lib/module-registry.ts index 60bdb326d..224c8a61a 100644 --- a/packages/workbox-build/src/lib/module-registry.ts +++ b/packages/workbox-build/src/lib/module-registry.ts @@ -15,7 +15,7 @@ import upath from 'upath'; * * @private */ -export default class ModuleRegistry { +export class ModuleRegistry { private _modulesUsed: Map; /** * @private diff --git a/packages/workbox-build/src/lib/no-revision-for-urls-matching-transform.ts b/packages/workbox-build/src/lib/no-revision-for-urls-matching-transform.ts index 563862ea5..4b95320a3 100644 --- a/packages/workbox-build/src/lib/no-revision-for-urls-matching-transform.ts +++ b/packages/workbox-build/src/lib/no-revision-for-urls-matching-transform.ts @@ -6,11 +6,10 @@ https://opensource.org/licenses/MIT. */ -import errors from './errors'; - +import {errors} from './errors'; import {ManifestTransform} from '../types'; -export default function(regexp: RegExp): ManifestTransform { +export function noRevisionForURLsMatchingTransform(regexp: RegExp): ManifestTransform { if (!(regexp instanceof RegExp)) { throw new Error(errors['invalid-dont-cache-bust']); } diff --git a/packages/workbox-build/src/lib/populate-sw-template.ts b/packages/workbox-build/src/lib/populate-sw-template.ts index 7093be5d7..b72fd0f3d 100644 --- a/packages/workbox-build/src/lib/populate-sw-template.ts +++ b/packages/workbox-build/src/lib/populate-sw-template.ts @@ -7,13 +7,13 @@ */ import template from 'lodash/template'; -import swTemplate from '../templates/sw-template'; +import {errors} from './errors'; import {GeneratePartial, ManifestEntry} from '../types'; -import errors from './errors'; -import ModuleRegistry from './module-registry'; -import runtimeCachingConverter from './runtime-caching-converter'; -import stringifyWithoutComments from './stringify-without-comments'; +import {ModuleRegistry} from './module-registry'; +import {runtimeCachingConverter} from './runtime-caching-converter'; +import {stringifyWithoutComments} from './stringify-without-comments'; +import {swTemplate} from '../templates/sw-template'; export default function({ cacheId, diff --git a/packages/workbox-build/src/lib/rebase-path.ts b/packages/workbox-build/src/lib/rebase-path.ts index 298a720cf..916ebac3e 100644 --- a/packages/workbox-build/src/lib/rebase-path.ts +++ b/packages/workbox-build/src/lib/rebase-path.ts @@ -8,7 +8,7 @@ import upath from 'upath'; -export default function({ +export function rebasePath({ baseDirectory, file }: {baseDirectory: string, file: string}): string { diff --git a/packages/workbox-build/src/lib/replace-and-update-source-map.ts b/packages/workbox-build/src/lib/replace-and-update-source-map.ts index 87180df4b..b52311218 100644 --- a/packages/workbox-build/src/lib/replace-and-update-source-map.ts +++ b/packages/workbox-build/src/lib/replace-and-update-source-map.ts @@ -27,7 +27,7 @@ import {RawSourceMap, SourceMapConsumer, SourceMapGenerator} from 'source-map'; * * @private */ -export default async function({ +export async function replaceAndUpdateSourceMap({ jsFilename, originalMap, originalSource, diff --git a/packages/workbox-build/src/lib/runtime-caching-converter.ts b/packages/workbox-build/src/lib/runtime-caching-converter.ts index 6714efdd4..29b6fdcc1 100644 --- a/packages/workbox-build/src/lib/runtime-caching-converter.ts +++ b/packages/workbox-build/src/lib/runtime-caching-converter.ts @@ -8,10 +8,10 @@ import {oneLine as ol} from 'common-tags'; +import {errors} from './errors'; +import {ModuleRegistry} from './module-registry'; import {RuntimeCaching} from '../types'; -import ModuleRegistry from './module-registry'; -import errors from './errors'; -import stringifyWithoutComments from './stringify-without-comments'; +import {stringifyWithoutComments} from './stringify-without-comments'; /** * Given a set of options that configures runtime caching behavior, convert it @@ -118,7 +118,7 @@ function getOptionsString(moduleRegistry: ModuleRegistry, options: RuntimeCachin } } -export default function(moduleRegistry: ModuleRegistry, runtimeCaching: Array): Array { +export function runtimeCachingConverter(moduleRegistry: ModuleRegistry, runtimeCaching: Array): Array { return runtimeCaching.map((entry) => { const method = entry.method || 'GET'; @@ -156,4 +156,4 @@ export default function(moduleRegistry: ModuleRegistry, runtimeCaching: Array Boolean(entry)); -}; +} diff --git a/packages/workbox-build/src/lib/stringify-without-comments.ts b/packages/workbox-build/src/lib/stringify-without-comments.ts index 2513bbf3c..bad179623 100644 --- a/packages/workbox-build/src/lib/stringify-without-comments.ts +++ b/packages/workbox-build/src/lib/stringify-without-comments.ts @@ -9,7 +9,7 @@ import objectStringify from 'stringify-object'; import stripComments from 'strip-comments'; -export default function(obj: {[key: string]: any}): string { +export function stringifyWithoutComments(obj: {[key: string]: any}): string { return objectStringify(obj, { // See https://github.com/yeoman/stringify-object#transformobject-property-originalresult transform: (_obj: {[key: string]: any}, _prop, str) => { diff --git a/packages/workbox-build/src/lib/transform-manifest.ts b/packages/workbox-build/src/lib/transform-manifest.ts index 748b8cc05..497f1a35b 100644 --- a/packages/workbox-build/src/lib/transform-manifest.ts +++ b/packages/workbox-build/src/lib/transform-manifest.ts @@ -7,11 +7,11 @@ */ import {BasePartial, FileDetails, ManifestEntry, ManifestTransform} from '../types'; -import additionalManifestEntriesTransform from './additional-manifest-entries-transform'; -import errors from './errors'; -import maximumSizeTransform from './maximum-size-transform'; -import modifyURLPrefixTransform from './modify-url-prefix-transform'; -import noRevisionForURLsMatchingTransform from './no-revision-for-urls-matching-transform'; +import {additionalManifestEntriesTransform} from './additional-manifest-entries-transform'; +import {errors} from './errors'; +import {maximumSizeTransform} from './maximum-size-transform'; +import {modifyURLPrefixTransform} from './modify-url-prefix-transform'; +import {noRevisionForURLsMatchingTransform} from './no-revision-for-urls-matching-transform'; /** * A `ManifestTransform` function can be used to modify the modify the `url` or @@ -65,7 +65,7 @@ import noRevisionForURLsMatchingTransform from './no-revision-for-urls-matching- * @memberof module:workbox-build */ -export default async function ({ +export async function transformManifest({ additionalManifestEntries, dontCacheBustURLsMatching, fileDetails, @@ -143,4 +143,4 @@ export default async function ({ manifestEntries: transformedManifest as Array, warnings: allWarnings, }; -}; +} diff --git a/packages/workbox-build/src/lib/write-sw-using-default-template.ts b/packages/workbox-build/src/lib/write-sw-using-default-template.ts index 90d0324ca..ef2676e02 100644 --- a/packages/workbox-build/src/lib/write-sw-using-default-template.ts +++ b/packages/workbox-build/src/lib/write-sw-using-default-template.ts @@ -9,12 +9,12 @@ import fse from 'fs-extra'; import upath from 'upath'; +import {bundle} from './bundle'; +import {errors} from './errors'; import {GenerateSWOptions, ManifestEntry} from '../types'; -import bundle from './bundle'; -import errors from './errors'; import populateSWTemplate from './populate-sw-template'; -export default async function({ +export async function writeSWUsingDefaultTemplate({ babelPresetEnvTargets, cacheId, cleanupOutdatedCaches, diff --git a/packages/workbox-build/src/templates/sw-template.ts b/packages/workbox-build/src/templates/sw-template.ts index b945f16be..dacfaef89 100644 --- a/packages/workbox-build/src/templates/sw-template.ts +++ b/packages/workbox-build/src/templates/sw-template.ts @@ -6,7 +6,7 @@ https://opensource.org/licenses/MIT. */ -export default `/** +export const swTemplate = `/** * Welcome to your Workbox-powered service worker! * * You'll need to register this file in your web app. diff --git a/test/workbox-build/node/generate-sw.js b/test/workbox-build/node/generate-sw.js index 866daefca..e0525a3de 100644 --- a/test/workbox-build/node/generate-sw.js +++ b/test/workbox-build/node/generate-sw.js @@ -12,8 +12,8 @@ const upath = require('upath'); const tempy = require('tempy'); const confirmDirectoryContains = require('../../../infra/testing/confirm-directory-contains'); -const errors = require('../../../packages/workbox-build/src/lib/errors'); -const generateSW = require('../../../packages/workbox-build/src/generate-sw'); +const errors = require('../../../packages/workbox-build/build/lib/errors'); +const generateSW = require('../../../packages/workbox-build/build/generate-sw'); const validateServiceWorkerRuntime = require('../../../infra/testing/validator/service-worker-runtime'); describe(`[workbox-build] generate-sw.js (End to End)`, function() { diff --git a/test/workbox-build/node/get-manifest.js b/test/workbox-build/node/get-manifest.js index 855dee7c3..d0f0b9791 100644 --- a/test/workbox-build/node/get-manifest.js +++ b/test/workbox-build/node/get-manifest.js @@ -15,7 +15,7 @@ const tempy = require('tempy'); chai.use(chaiMatchPattern); const {expect} = chai; -const getManifest = require('../../../packages/workbox-build/src/get-manifest'); +const getManifest = require('../../../packages/workbox-build/build/get-manifest'); describe(`[workbox-build] get-manifest.js (End to End)`, function() { const SRC_DIR = upath.join(__dirname, '..', 'static', 'example-project-1'); diff --git a/test/workbox-build/node/inject-manifest.js b/test/workbox-build/node/inject-manifest.js index 7ecd4f5ef..0a25bf0fb 100644 --- a/test/workbox-build/node/inject-manifest.js +++ b/test/workbox-build/node/inject-manifest.js @@ -11,8 +11,8 @@ const fse = require('fs-extra'); const upath = require('upath'); const tempy = require('tempy'); -const errors = require('../../../packages/workbox-build/src/lib/errors'); -const injectManifest = require('../../../packages/workbox-build/src/inject-manifest'); +const errors = require('../../../packages/workbox-build/build/lib/errors'); +const injectManifest = require('../../../packages/workbox-build/build/inject-manifest'); const validateServiceWorkerRuntime = require('../../../infra/testing/validator/service-worker-runtime'); describe(`[workbox-build] inject-manifest.js (End to End)`, function() { diff --git a/test/workbox-build/node/lib/additional-manifest-entries-transform.js b/test/workbox-build/node/lib/additional-manifest-entries-transform.js index 72b611577..e799bf698 100644 --- a/test/workbox-build/node/lib/additional-manifest-entries-transform.js +++ b/test/workbox-build/node/lib/additional-manifest-entries-transform.js @@ -8,8 +8,8 @@ const expect = require('chai').expect; -const errors = require('../../../../packages/workbox-build/src/lib/errors'); -const additionalManifestEntriesTransform = require('../../../../packages/workbox-build/src/lib/additional-manifest-entries-transform'); +const errors = require('../../../../packages/workbox-build/build/lib/errors'); +const additionalManifestEntriesTransform = require('../../../../packages/workbox-build/build/lib/additional-manifest-entries-transform'); describe(`[workbox-build] lib/additional-manifest-entries-transform.js`, function() { function getManifest() { diff --git a/test/workbox-build/node/lib/bundle.js b/test/workbox-build/node/lib/bundle.js index 5da90325e..2b434082f 100644 --- a/test/workbox-build/node/lib/bundle.js +++ b/test/workbox-build/node/lib/bundle.js @@ -11,7 +11,7 @@ const proxyquire = require('proxyquire'); const sinon = require('sinon'); describe(`[workbox-build] lib/bundle.js`, function() { - const MODULE_PATH = '../../../../packages/workbox-build/src/lib/bundle'; + const MODULE_PATH = '../../../../packages/workbox-build/build/lib/bundle'; let bundle; let stubs; diff --git a/test/workbox-build/node/lib/cdn-utils.js b/test/workbox-build/node/lib/cdn-utils.js index b2d046de4..2e03813d0 100644 --- a/test/workbox-build/node/lib/cdn-utils.js +++ b/test/workbox-build/node/lib/cdn-utils.js @@ -8,8 +8,8 @@ const expect = require('chai').expect; -const cdnUtils = require('../../../../packages/workbox-build/src/lib/cdn-utils'); -const errors = require('../../../../packages/workbox-build/src/lib/errors'); +const cdnUtils = require('../../../../packages/workbox-build/build/lib/cdn-utils'); +const errors = require('../../../../packages/workbox-build/build/lib/errors'); describe(`[workbox-build] lib/cdn-utils.js`, function() { const CDN_ORIGIN = 'https://storage.googleapis.com/workbox-cdn/releases'; diff --git a/test/workbox-build/node/lib/copy-workbox-libraries.js b/test/workbox-build/node/lib/copy-workbox-libraries.js index e34b85184..cf45d2088 100644 --- a/test/workbox-build/node/lib/copy-workbox-libraries.js +++ b/test/workbox-build/node/lib/copy-workbox-libraries.js @@ -11,10 +11,10 @@ const upath = require('upath'); const proxyquire = require('proxyquire'); const sinon = require('sinon'); -const errors = require('../../../../packages/workbox-build/src/lib/errors'); +const errors = require('../../../../packages/workbox-build/build/lib/errors'); describe(`[workbox-build] lib/copy-workbox-libraries.js`, function() { - const MODULE_PATH = '../../../../packages/workbox-build/src/lib/copy-workbox-libraries'; + const MODULE_PATH = '../../../../packages/workbox-build/build/lib/copy-workbox-libraries'; const ABSOLUTE_DEST_DIRECTORY = upath.join('/', 'test-dir'); const RELATIVE_DEST_DIRECTORY = upath.join('.', 'test-dir'); diff --git a/test/workbox-build/node/lib/escape-regexp.js b/test/workbox-build/node/lib/escape-regexp.js index 7e5dc5e42..2877a458d 100644 --- a/test/workbox-build/node/lib/escape-regexp.js +++ b/test/workbox-build/node/lib/escape-regexp.js @@ -7,7 +7,7 @@ */ const expect = require('chai').expect; -const escapeRegexp = require('../../../../packages/workbox-build/src/lib/escape-regexp'); +const escapeRegexp = require('../../../../packages/workbox-build/build/lib/escape-regexp'); describe(`[workbox-build] lib/copy-workbox-libraries.js`, function() { const expectedValues = new Map([ diff --git a/test/workbox-build/node/lib/get-composite-details.js b/test/workbox-build/node/lib/get-composite-details.js index ee4d0f01b..d83374ad1 100644 --- a/test/workbox-build/node/lib/get-composite-details.js +++ b/test/workbox-build/node/lib/get-composite-details.js @@ -8,7 +8,7 @@ const expect = require('chai').expect; -const getCompositeDetails = require('../../../../packages/workbox-build/src/lib/get-composite-details'); +const getCompositeDetails = require('../../../../packages/workbox-build/build/lib/get-composite-details'); describe(`[workbox-build] lib/get-composite-details.js`, function() { const URL = '/test'; diff --git a/test/workbox-build/node/lib/get-file-details.js b/test/workbox-build/node/lib/get-file-details.js index 8cc7c5b57..320f854aa 100644 --- a/test/workbox-build/node/lib/get-file-details.js +++ b/test/workbox-build/node/lib/get-file-details.js @@ -10,10 +10,10 @@ const expect = require('chai').expect; const upath = require('upath'); const proxyquire = require('proxyquire'); -const errors = require('../../../../packages/workbox-build/src/lib/errors'); +const errors = require('../../../../packages/workbox-build/build/lib/errors'); describe(`[workbox-build] lib/get-file-details.js`, function() { - const MODULE_PATH = '../../../../packages/workbox-build/src/lib/get-file-details'; + const MODULE_PATH = '../../../../packages/workbox-build/build/lib/get-file-details'; const GLOB_DIRECTORY = './'; const GLOB_PATTERN = 'file*'; const DIRECTORY = 'directory'; diff --git a/test/workbox-build/node/lib/get-file-hash.js b/test/workbox-build/node/lib/get-file-hash.js index cc4934111..da990f3c5 100644 --- a/test/workbox-build/node/lib/get-file-hash.js +++ b/test/workbox-build/node/lib/get-file-hash.js @@ -9,10 +9,10 @@ const expect = require('chai').expect; const proxyquire = require('proxyquire'); -const errors = require('../../../../packages/workbox-build/src/lib/errors'); +const errors = require('../../../../packages/workbox-build/build/lib/errors'); describe(`[workbox-build] lib/get-file-hash.js`, function() { - const MODULE_PATH = '../../../../packages/workbox-build/src/lib/get-file-hash'; + const MODULE_PATH = '../../../../packages/workbox-build/build/lib/get-file-hash'; const FILE = 'file.txt'; it(`should throw when there's a fs.readFileSync() error`, function() { diff --git a/test/workbox-build/node/lib/get-file-manifest-entries.js b/test/workbox-build/node/lib/get-file-manifest-entries.js index cf2521b36..b67bffe43 100644 --- a/test/workbox-build/node/lib/get-file-manifest-entries.js +++ b/test/workbox-build/node/lib/get-file-manifest-entries.js @@ -9,10 +9,10 @@ const expect = require('chai').expect; const proxyquire = require('proxyquire'); -const errors = require('../../../../packages/workbox-build/src/lib/errors'); +const errors = require('../../../../packages/workbox-build/build/lib/errors'); describe(`[workbox-build] Test getFileManifestEntries`, function() { - const MODULE_PATH = '../../../../packages/workbox-build/src/lib/get-file-manifest-entries'; + const MODULE_PATH = '../../../../packages/workbox-build/build/lib/get-file-manifest-entries'; const GLOB_DIRECTORY = './'; const GLOB_PATTERNS = ['invalid*']; const FILE = { diff --git a/test/workbox-build/node/lib/get-file-size.js b/test/workbox-build/node/lib/get-file-size.js index 99cbe1c71..1fec7a317 100644 --- a/test/workbox-build/node/lib/get-file-size.js +++ b/test/workbox-build/node/lib/get-file-size.js @@ -9,10 +9,10 @@ const expect = require('chai').expect; const proxyquire = require('proxyquire'); -const errors = require('../../../../packages/workbox-build/src/lib/errors.js'); +const errors = require('../../../../packages/workbox-build/build/lib/errors.js'); describe(`[workbox-build] lib/get-file-size.js`, function() { - const MODULE_PATH = '../../../../packages/workbox-build/src/lib/get-file-size'; + const MODULE_PATH = '../../../../packages/workbox-build/build/lib/get-file-size'; const FILE = 'file.txt'; it(`should throw when fs.statSync() fails`, function() { diff --git a/test/workbox-build/node/lib/get-string-details.js b/test/workbox-build/node/lib/get-string-details.js index 4d336d5db..ff7d76f8d 100644 --- a/test/workbox-build/node/lib/get-string-details.js +++ b/test/workbox-build/node/lib/get-string-details.js @@ -8,7 +8,7 @@ const expect = require('chai').expect; -const getStringDetails = require('../../../../packages/workbox-build/src/lib/get-string-details'); +const getStringDetails = require('../../../../packages/workbox-build/build/lib/get-string-details'); describe(`[workbox-build] lib/get-string-details.js`, function() { it(`should return the expected details`, function() { diff --git a/test/workbox-build/node/lib/get-string-hash.js b/test/workbox-build/node/lib/get-string-hash.js index c251ba085..ea2554a4d 100644 --- a/test/workbox-build/node/lib/get-string-hash.js +++ b/test/workbox-build/node/lib/get-string-hash.js @@ -8,7 +8,7 @@ const expect = require('chai').expect; -const getStringHash = require('../../../../packages/workbox-build/src/lib/get-string-hash'); +const getStringHash = require('../../../../packages/workbox-build/build/lib/get-string-hash'); describe(`[workbox-build] lib/get-string-hash.js`, function() { it(`should return the expected hashes`, function() { diff --git a/test/workbox-build/node/lib/modify-url-prefix-transform.js b/test/workbox-build/node/lib/modify-url-prefix-transform.js index 7d6f16726..9aa777116 100644 --- a/test/workbox-build/node/lib/modify-url-prefix-transform.js +++ b/test/workbox-build/node/lib/modify-url-prefix-transform.js @@ -8,8 +8,8 @@ const expect = require('chai').expect; -const errors = require('../../../../packages/workbox-build/src/lib/errors'); -const modifyURLPrefix = require('../../../../packages/workbox-build/src/lib/modify-url-prefix-transform'); +const errors = require('../../../../packages/workbox-build/build/lib/errors'); +const modifyURLPrefix = require('../../../../packages/workbox-build/build/lib/modify-url-prefix-transform'); describe(`[workbox-build] lib/modify-url-prefix-transform.js`, function() { function getManifest() { diff --git a/test/workbox-build/node/lib/module-registry.js b/test/workbox-build/node/lib/module-registry.js index e0ae29ae6..77c20f7d2 100644 --- a/test/workbox-build/node/lib/module-registry.js +++ b/test/workbox-build/node/lib/module-registry.js @@ -7,7 +7,7 @@ */ const expect = require('chai').expect; -const ModuleRegistry = require('../../../../packages/workbox-build/src/lib/module-registry'); +const ModuleRegistry = require('../../../../packages/workbox-build/build/lib/module-registry'); const upath = require('upath'); describe(`[workbox-build] lib/module-registry.js`, function() { diff --git a/test/workbox-build/node/lib/no-revision-for-urls-matching-transform.js b/test/workbox-build/node/lib/no-revision-for-urls-matching-transform.js index a54762676..574a67c4d 100644 --- a/test/workbox-build/node/lib/no-revision-for-urls-matching-transform.js +++ b/test/workbox-build/node/lib/no-revision-for-urls-matching-transform.js @@ -8,8 +8,8 @@ const expect = require('chai').expect; -const errors = require('../../../../packages/workbox-build/src/lib/errors'); -const noRevisionForURLsMatching = require('../../../../packages/workbox-build/src/lib/no-revision-for-urls-matching-transform'); +const errors = require('../../../../packages/workbox-build/build/lib/errors'); +const noRevisionForURLsMatching = require('../../../../packages/workbox-build/build/lib/no-revision-for-urls-matching-transform'); describe(`[workbox-build] lib/no-revision-for-urls-matching-transform.js`, function() { const MANIFEST = [{ diff --git a/test/workbox-build/node/lib/populate-sw-template.js b/test/workbox-build/node/lib/populate-sw-template.js index 1c61f01a2..8e5f52a7a 100644 --- a/test/workbox-build/node/lib/populate-sw-template.js +++ b/test/workbox-build/node/lib/populate-sw-template.js @@ -10,10 +10,10 @@ const expect = require('chai').expect; const proxyquire = require('proxyquire'); const sinon = require('sinon'); -const errors = require('../../../../packages/workbox-build/src/lib/errors'); +const errors = require('../../../../packages/workbox-build/build/lib/errors'); describe(`[workbox-build] lib/populate-sw-template.js`, function() { - const MODULE_PATH = '../../../../packages/workbox-build/src/lib/populate-sw-template'; + const MODULE_PATH = '../../../../packages/workbox-build/build/lib/populate-sw-template'; it(`should throw an error if templating fails`, function() { const manifestEntries = ['ignored']; diff --git a/test/workbox-build/node/lib/replace-and-update-source-map.js b/test/workbox-build/node/lib/replace-and-update-source-map.js index 9247e17aa..0141a7756 100644 --- a/test/workbox-build/node/lib/replace-and-update-source-map.js +++ b/test/workbox-build/node/lib/replace-and-update-source-map.js @@ -8,7 +8,7 @@ const expect = require('chai').expect; -const replaceAndUpdateSourceMap = require('../../../../packages/workbox-build/src/lib/replace-and-update-source-map'); +const replaceAndUpdateSourceMap = require('../../../../packages/workbox-build/build/lib/replace-and-update-source-map'); describe(`[workbox-build] lib/replace-and-update-source-map`, function() { // Test case borrowed from https://github.com/Rich-Harris/magic-string/blob/a312519cfe9caa78ade7f09cc2b07459d3d17f4d/test/MagicString.js#L225 diff --git a/test/workbox-build/node/lib/runtime-caching-converter.js b/test/workbox-build/node/lib/runtime-caching-converter.js index 9b7834c47..ff654c6a7 100644 --- a/test/workbox-build/node/lib/runtime-caching-converter.js +++ b/test/workbox-build/node/lib/runtime-caching-converter.js @@ -10,9 +10,9 @@ const expect = require('chai').expect; const sinon = require('sinon'); const vm = require('vm'); -const errors = require('../../../../packages/workbox-build/src/lib/errors'); -const ModuleRegistry = require('../../../../packages/workbox-build/src/lib/module-registry'); -const runtimeCachingConverter = require('../../../../packages/workbox-build/src/lib/runtime-caching-converter'); +const errors = require('../../../../packages/workbox-build/build/lib/errors'); +const ModuleRegistry = require('../../../../packages/workbox-build/build/lib/module-registry'); +const runtimeCachingConverter = require('../../../../packages/workbox-build/build/lib/runtime-caching-converter'); const moduleRegistry = new ModuleRegistry(); diff --git a/test/workbox-build/node/lib/transform-manifest.js b/test/workbox-build/node/lib/transform-manifest.js index e6d8ca226..fc5b786ad 100644 --- a/test/workbox-build/node/lib/transform-manifest.js +++ b/test/workbox-build/node/lib/transform-manifest.js @@ -8,7 +8,7 @@ const expect = require('chai').expect; -const transformManifest = require('../../../../packages/workbox-build/src/lib/transform-manifest'); +const transformManifest = require('../../../../packages/workbox-build/build/lib/transform-manifest'); describe(`[workbox-build] lib/transform-manifest.js`, function() { const MAXIMUM_FILE_SIZE = 1234; diff --git a/test/workbox-build/node/lib/validate-options.js b/test/workbox-build/node/lib/validate-options.js index 028b32d76..4fb3c882d 100644 --- a/test/workbox-build/node/lib/validate-options.js +++ b/test/workbox-build/node/lib/validate-options.js @@ -8,7 +8,7 @@ const expect = require('chai').expect; -const validateOptions = require('../../../../packages/workbox-build/src/lib/validate-options'); +const validateOptions = require('../../../../packages/workbox-build/build/lib/validate-options'); describe(`[workbox-build] entry-points/options/validate.js`, function() { const testOptions = { diff --git a/test/workbox-build/node/lib/write-sw-using-default-template.js b/test/workbox-build/node/lib/write-sw-using-default-template.js index 0f0a2f47e..b3d6b949e 100644 --- a/test/workbox-build/node/lib/write-sw-using-default-template.js +++ b/test/workbox-build/node/lib/write-sw-using-default-template.js @@ -11,10 +11,10 @@ const upath = require('upath'); const proxyquire = require('proxyquire'); const sinon = require('sinon'); -const errors = require('../../../../packages/workbox-build/src/lib/errors'); +const errors = require('../../../../packages/workbox-build/build/lib/errors'); describe(`[workbox-build] lib/write-sw-using-default-template.js`, function() { - const MODULE_PATH = '../../../../packages/workbox-build/src/lib/write-sw-using-default-template'; + const MODULE_PATH = '../../../../packages/workbox-build/build/lib/write-sw-using-default-template'; it(`should reject with an error when fs-extra.mkdirp() fails`, async function() { const writeSWUsingDefaultTemplate = proxyquire(MODULE_PATH, { From 1c2df4ff17cf58ea5bf1f4caa0997f0cf12de4c4 Mon Sep 17 00:00:00 2001 From: Jeff Posnick Date: Wed, 10 Feb 2021 16:23:07 -0500 Subject: [PATCH 12/80] null support in optional strings --- packages/workbox-build/src/types.ts | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/packages/workbox-build/src/types.ts b/packages/workbox-build/src/types.ts index 730130684..a440df932 100644 --- a/packages/workbox-build/src/types.ts +++ b/packages/workbox-build/src/types.ts @@ -32,7 +32,7 @@ export interface RuntimeCaching { options: BroadcastCacheUpdateOptions; }; cacheableResponse?: CacheableResponseOptions; - cacheName?: string; + cacheName?: string | null; expiration?: ExpirationPluginOptions; networkTimeoutSeconds?: number; plugins?: Array; @@ -67,16 +67,16 @@ export interface BasePartial { export interface GeneratePartial { babelPresetEnvTargets?: Array; - cacheId?: string; + cacheId?: string | null; cleanupOutdatedCaches?: boolean; clientsClaim?: boolean; - directoryIndex?: string; + directoryIndex?: string | null; disableDevLogs?: boolean; ignoreURLParametersMatching?: Array; importScripts?: Array; inlineWorkboxRuntime?: boolean; - mode?: string; - navigateFallback?: string; + mode?: string | null; + navigateFallback?: string | null; navigateFallbackAllowlist?: Array; navigateFallbackDenylist?: Array; navigationPreload?: boolean; @@ -87,7 +87,7 @@ export interface GeneratePartial { } export interface GlobPartial { - globDirectory?: string; + globDirectory?: string | null; globFollow?: boolean; globIgnores: Array; globPatterns: Array; @@ -107,7 +107,7 @@ interface WebpackPartial { exclude?: Array any)>; excludeChunks?: Array; include?: Array any)>; - mode?: string; + mode?: string | null; } export interface SWDestPartial { From aa9e454aa5ae7427ff5cef427a718c3629a53f0f Mon Sep 17 00:00:00 2001 From: Jeff Posnick Date: Fri, 30 Apr 2021 11:11:20 -0400 Subject: [PATCH 13/80] Accept string or buffer again --- packages/workbox-build/src/lib/get-file-hash.ts | 4 ++-- packages/workbox-build/src/lib/get-string-hash.ts | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/workbox-build/src/lib/get-file-hash.ts b/packages/workbox-build/src/lib/get-file-hash.ts index 4ff9d1c01..86977e4e5 100644 --- a/packages/workbox-build/src/lib/get-file-hash.ts +++ b/packages/workbox-build/src/lib/get-file-hash.ts @@ -13,8 +13,8 @@ import {errors} from './errors'; export function getFileHash(file: string): string { try { - const str = fse.readFileSync(file, 'utf8'); - return getStringHash(str); + const buffer = fse.readFileSync(file); + return getStringHash(buffer); } catch (err) { throw new Error(errors['unable-to-get-file-hash'] + ` '${err.message}'`); } diff --git a/packages/workbox-build/src/lib/get-string-hash.ts b/packages/workbox-build/src/lib/get-string-hash.ts index 7b065169d..4cfdcb66d 100644 --- a/packages/workbox-build/src/lib/get-string-hash.ts +++ b/packages/workbox-build/src/lib/get-string-hash.ts @@ -8,8 +8,8 @@ import crypto from 'crypto'; -export function getStringHash(str: string): string { +export function getStringHash(input: crypto.BinaryLike): string { const md5 = crypto.createHash('md5'); - md5.update(str); + md5.update(input); return md5.digest('hex'); }; From d67213424fb5f57cb0342c2a0dec5d257c21230c Mon Sep 17 00:00:00 2001 From: Jeff Posnick Date: Wed, 5 May 2021 09:36:26 -0400 Subject: [PATCH 14/80] Fix JSDocs --- packages/workbox-build/src/_types.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/workbox-build/src/_types.js b/packages/workbox-build/src/_types.js index addee892e..59a9dc8b1 100644 --- a/packages/workbox-build/src/_types.js +++ b/packages/workbox-build/src/_types.js @@ -89,13 +89,13 @@ import './_version.mjs'; * property to use when creating the * [`ExpirationPlugin`]{@link module:workbox-expiration.ExpirationPlugin}. * - * @property {number} [options.expiration.maxEntries] The `maxAgeSeconds` + * @property {number} [options.expiration.maxEntries] The `maxEntries` * property to use when creating the * [`ExpirationPlugin`]{@link module:workbox-expiration.ExpirationPlugin}. * * @property {Object} [options.precacheFallback] * - * @property {number} [options.precacheFallback.fallbackURL] The `fallbackURL` + * @property {string} [options.precacheFallback.fallbackURL] The `fallbackURL` * property to use when creating the * [`PrecacheFallbackPlugin`]{@link module:workbox-precaching.PrecacheFallbackPlugin}. * From 7c9c6467350f401c9ec06d6d75962ece50a0f79d Mon Sep 17 00:00:00 2001 From: Jeff Posnick Date: Sun, 23 May 2021 11:55:11 -0400 Subject: [PATCH 15/80] CanIUse update --- package-lock.json | 6 +- packages/workbox-build/src/types.guard.ts | 184 ++++++++++++---------- 2 files changed, 105 insertions(+), 85 deletions(-) diff --git a/package-lock.json b/package-lock.json index 327f99b17..9548991e5 100644 --- a/package-lock.json +++ b/package-lock.json @@ -6029,9 +6029,9 @@ } }, "caniuse-lite": { - "version": "1.0.30001148", - "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001148.tgz", - "integrity": "sha512-E66qcd0KMKZHNJQt9hiLZGE3J4zuTqE1OnU53miEVtylFbwOEmeA5OsRu90noZful+XGSQOni1aT2tiqu/9yYw==", + "version": "1.0.30001228", + "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001228.tgz", + "integrity": "sha512-QQmLOGJ3DEgokHbMSA8cj2a+geXqmnpyOFT0lhQV6P3/YOJvGDEwoedcwxEQ30gJIwIIunHIicunJ2rzK5gB2A==", "dev": true }, "caseless": { diff --git a/packages/workbox-build/src/types.guard.ts b/packages/workbox-build/src/types.guard.ts index 7749797f1..ae9401955 100644 --- a/packages/workbox-build/src/types.guard.ts +++ b/packages/workbox-build/src/types.guard.ts @@ -10,6 +10,7 @@ export function isGenerateSWOptions(obj: any, _argumentName?: string): obj is Ge typeof obj === "object" || typeof obj === "function") && (typeof obj.globDirectory === "undefined" || + obj.globDirectory === null || typeof obj.globDirectory === "string") && (typeof obj.globFollow === "undefined" || obj.globFollow === false || @@ -37,6 +38,7 @@ export function isGenerateSWOptions(obj: any, _argumentName?: string): obj is Ge typeof e === "string" )) && (typeof obj.cacheId === "undefined" || + obj.cacheId === null || typeof obj.cacheId === "string") && (typeof obj.cleanupOutdatedCaches === "undefined" || obj.cleanupOutdatedCaches === false || @@ -45,6 +47,7 @@ export function isGenerateSWOptions(obj: any, _argumentName?: string): obj is Ge obj.clientsClaim === false || obj.clientsClaim === true) && (typeof obj.directoryIndex === "undefined" || + obj.directoryIndex === null || typeof obj.directoryIndex === "string") && (typeof obj.disableDevLogs === "undefined" || obj.disableDevLogs === false || @@ -63,8 +66,10 @@ export function isGenerateSWOptions(obj: any, _argumentName?: string): obj is Ge obj.inlineWorkboxRuntime === false || obj.inlineWorkboxRuntime === true) && (typeof obj.mode === "undefined" || + obj.mode === null || typeof obj.mode === "string") && (typeof obj.navigateFallback === "undefined" || + obj.navigateFallback === null || typeof obj.navigateFallback === "string") && (typeof obj.navigateFallbackAllowlist === "undefined" || Array.isArray(obj.navigateFallbackAllowlist) && @@ -100,6 +105,7 @@ export function isGenerateSWOptions(obj: any, _argumentName?: string): obj is Ge (typeof e.options.broadcastUpdate.channelName === "undefined" || typeof e.options.broadcastUpdate.channelName === "string")) && (typeof e.options.cacheName === "undefined" || + e.options.cacheName === null || typeof e.options.cacheName === "string") && (typeof e.options.networkTimeoutSeconds === "undefined" || typeof e.options.networkTimeoutSeconds === "number") && @@ -151,7 +157,10 @@ export function isGenerateSWOptions(obj: any, _argumentName?: string): obj is Ge ) || (e.options.fetchOptions.headers !== null && typeof e.options.fetchOptions.headers === "object" || - typeof e.options.fetchOptions.headers === "function")) && + typeof e.options.fetchOptions.headers === "function") && + Object.entries(e.options.fetchOptions.headers) + .every(([key, value]) => (typeof value === "string" && + typeof key === "string"))) && (typeof e.options.fetchOptions.integrity === "undefined" || typeof e.options.fetchOptions.integrity === "string") && (typeof e.options.fetchOptions.keepalive === "undefined" || @@ -209,24 +218,24 @@ export function isGenerateSWOptions(obj: any, _argumentName?: string): obj is Ge (typeof obj.additionalManifestEntries === "undefined" || Array.isArray(obj.additionalManifestEntries) && obj.additionalManifestEntries.every((e: any) => - (typeof e === "string" || - (e !== null && - typeof e === "object" || - typeof e === "function") && - (typeof e.integrity === "undefined" || - typeof e.integrity === "string") && - (e.revision === null || - typeof e.revision === "string") && - typeof e.url === "string") + (typeof e === "string" || + (e !== null && + typeof e === "object" || + typeof e === "function") && + (typeof e.integrity === "undefined" || + typeof e.integrity === "string") && + (e.revision === null || + typeof e.revision === "string") && + typeof e.url === "string") )) && (typeof obj.dontCacheBustURLsMatching === "undefined" || obj.dontCacheBustURLsMatching instanceof RegExp) && (typeof obj.manifestTransforms === "undefined" || Array.isArray(obj.manifestTransforms) && obj.manifestTransforms.every((e: any) => - (e !== null && - typeof e === "object" || - typeof e === "function") + (e !== null && + typeof e === "object" || + typeof e === "function") )) && (typeof obj.maximumFileSizeToCacheInBytes === "undefined" || typeof obj.maximumFileSizeToCacheInBytes === "number") && @@ -246,6 +255,7 @@ export function isGetManifestOptions(obj: any, _argumentName?: string): obj is G typeof obj === "object" || typeof obj === "function") && (typeof obj.globDirectory === "undefined" || + obj.globDirectory === null || typeof obj.globDirectory === "string") && (typeof obj.globFollow === "undefined" || obj.globFollow === false || @@ -270,24 +280,24 @@ export function isGetManifestOptions(obj: any, _argumentName?: string): obj is G (typeof obj.additionalManifestEntries === "undefined" || Array.isArray(obj.additionalManifestEntries) && obj.additionalManifestEntries.every((e: any) => - (typeof e === "string" || - (e !== null && - typeof e === "object" || - typeof e === "function") && - (typeof e.integrity === "undefined" || - typeof e.integrity === "string") && - (e.revision === null || - typeof e.revision === "string") && - typeof e.url === "string") + (typeof e === "string" || + (e !== null && + typeof e === "object" || + typeof e === "function") && + (typeof e.integrity === "undefined" || + typeof e.integrity === "string") && + (e.revision === null || + typeof e.revision === "string") && + typeof e.url === "string") )) && (typeof obj.dontCacheBustURLsMatching === "undefined" || obj.dontCacheBustURLsMatching instanceof RegExp) && (typeof obj.manifestTransforms === "undefined" || Array.isArray(obj.manifestTransforms) && obj.manifestTransforms.every((e: any) => - (e !== null && - typeof e === "object" || - typeof e === "function") + (e !== null && + typeof e === "object" || + typeof e === "function") )) && (typeof obj.maximumFileSizeToCacheInBytes === "undefined" || typeof obj.maximumFileSizeToCacheInBytes === "number") && @@ -330,24 +340,24 @@ export function isInjectManifestOptions(obj: any, _argumentName?: string): obj i (typeof obj.additionalManifestEntries === "undefined" || Array.isArray(obj.additionalManifestEntries) && obj.additionalManifestEntries.every((e: any) => - (typeof e === "string" || - (e !== null && - typeof e === "object" || - typeof e === "function") && - (typeof e.integrity === "undefined" || - typeof e.integrity === "string") && - (e.revision === null || - typeof e.revision === "string") && - typeof e.url === "string") + (typeof e === "string" || + (e !== null && + typeof e === "object" || + typeof e === "function") && + (typeof e.integrity === "undefined" || + typeof e.integrity === "string") && + (e.revision === null || + typeof e.revision === "string") && + typeof e.url === "string") )) && (typeof obj.dontCacheBustURLsMatching === "undefined" || obj.dontCacheBustURLsMatching instanceof RegExp) && (typeof obj.manifestTransforms === "undefined" || Array.isArray(obj.manifestTransforms) && obj.manifestTransforms.every((e: any) => - (e !== null && - typeof e === "object" || - typeof e === "function") + (e !== null && + typeof e === "object" || + typeof e === "function") )) && (typeof obj.maximumFileSizeToCacheInBytes === "undefined" || typeof obj.maximumFileSizeToCacheInBytes === "number") && @@ -378,11 +388,11 @@ export function isWebpackGenerateSWOptions(obj: any, _argumentName?: string): ob (typeof obj.exclude === "undefined" || Array.isArray(obj.exclude) && obj.exclude.every((e: any) => - (typeof e === "string" || - e instanceof RegExp || - (e !== null && - typeof e === "object" || - typeof e === "function")) + (typeof e === "string" || + e instanceof RegExp || + (e !== null && + typeof e === "object" || + typeof e === "function")) )) && (typeof obj.excludeChunks === "undefined" || Array.isArray(obj.excludeChunks) && @@ -392,13 +402,14 @@ export function isWebpackGenerateSWOptions(obj: any, _argumentName?: string): ob (typeof obj.include === "undefined" || Array.isArray(obj.include) && obj.include.every((e: any) => - (typeof e === "string" || - e instanceof RegExp || - (e !== null && - typeof e === "object" || - typeof e === "function")) + (typeof e === "string" || + e instanceof RegExp || + (e !== null && + typeof e === "object" || + typeof e === "function")) )) && (typeof obj.mode === "undefined" || + obj.mode === null || typeof obj.mode === "string") || (obj !== null && typeof obj === "object" || @@ -409,6 +420,7 @@ export function isWebpackGenerateSWOptions(obj: any, _argumentName?: string): ob typeof e === "string" )) && (typeof obj.cacheId === "undefined" || + obj.cacheId === null || typeof obj.cacheId === "string") && (typeof obj.cleanupOutdatedCaches === "undefined" || obj.cleanupOutdatedCaches === false || @@ -417,6 +429,7 @@ export function isWebpackGenerateSWOptions(obj: any, _argumentName?: string): ob obj.clientsClaim === false || obj.clientsClaim === true) && (typeof obj.directoryIndex === "undefined" || + obj.directoryIndex === null || typeof obj.directoryIndex === "string") && (typeof obj.disableDevLogs === "undefined" || obj.disableDevLogs === false || @@ -435,8 +448,10 @@ export function isWebpackGenerateSWOptions(obj: any, _argumentName?: string): ob obj.inlineWorkboxRuntime === false || obj.inlineWorkboxRuntime === true) && (typeof obj.mode === "undefined" || + obj.mode === null || typeof obj.mode === "string") && (typeof obj.navigateFallback === "undefined" || + obj.navigateFallback === null || typeof obj.navigateFallback === "string") && (typeof obj.navigateFallbackAllowlist === "undefined" || Array.isArray(obj.navigateFallbackAllowlist) && @@ -472,6 +487,7 @@ export function isWebpackGenerateSWOptions(obj: any, _argumentName?: string): ob (typeof e.options.broadcastUpdate.channelName === "undefined" || typeof e.options.broadcastUpdate.channelName === "string")) && (typeof e.options.cacheName === "undefined" || + e.options.cacheName === null || typeof e.options.cacheName === "string") && (typeof e.options.networkTimeoutSeconds === "undefined" || typeof e.options.networkTimeoutSeconds === "number") && @@ -523,7 +539,10 @@ export function isWebpackGenerateSWOptions(obj: any, _argumentName?: string): ob ) || (e.options.fetchOptions.headers !== null && typeof e.options.fetchOptions.headers === "object" || - typeof e.options.fetchOptions.headers === "function")) && + typeof e.options.fetchOptions.headers === "function") && + Object.entries(e.options.fetchOptions.headers) + .every(([key, value]) => (typeof value === "string" && + typeof key === "string"))) && (typeof e.options.fetchOptions.integrity === "undefined" || typeof e.options.fetchOptions.integrity === "string") && (typeof e.options.fetchOptions.keepalive === "undefined" || @@ -581,24 +600,24 @@ export function isWebpackGenerateSWOptions(obj: any, _argumentName?: string): ob (typeof obj.additionalManifestEntries === "undefined" || Array.isArray(obj.additionalManifestEntries) && obj.additionalManifestEntries.every((e: any) => - (typeof e === "string" || - (e !== null && - typeof e === "object" || - typeof e === "function") && - (typeof e.integrity === "undefined" || - typeof e.integrity === "string") && - (e.revision === null || - typeof e.revision === "string") && - typeof e.url === "string") + (typeof e === "string" || + (e !== null && + typeof e === "object" || + typeof e === "function") && + (typeof e.integrity === "undefined" || + typeof e.integrity === "string") && + (e.revision === null || + typeof e.revision === "string") && + typeof e.url === "string") )) && (typeof obj.dontCacheBustURLsMatching === "undefined" || obj.dontCacheBustURLsMatching instanceof RegExp) && (typeof obj.manifestTransforms === "undefined" || Array.isArray(obj.manifestTransforms) && obj.manifestTransforms.every((e: any) => - (e !== null && - typeof e === "object" || - typeof e === "function") + (e !== null && + typeof e === "object" || + typeof e === "function") )) && (typeof obj.maximumFileSizeToCacheInBytes === "undefined" || typeof obj.maximumFileSizeToCacheInBytes === "number") && @@ -632,11 +651,11 @@ export function isWebpackInjectManifestOptions(obj: any, _argumentName?: string) (typeof obj.exclude === "undefined" || Array.isArray(obj.exclude) && obj.exclude.every((e: any) => - (typeof e === "string" || - e instanceof RegExp || - (e !== null && - typeof e === "object" || - typeof e === "function")) + (typeof e === "string" || + e instanceof RegExp || + (e !== null && + typeof e === "object" || + typeof e === "function")) )) && (typeof obj.excludeChunks === "undefined" || Array.isArray(obj.excludeChunks) && @@ -646,13 +665,14 @@ export function isWebpackInjectManifestOptions(obj: any, _argumentName?: string) (typeof obj.include === "undefined" || Array.isArray(obj.include) && obj.include.every((e: any) => - (typeof e === "string" || - e instanceof RegExp || - (e !== null && - typeof e === "object" || - typeof e === "function")) + (typeof e === "string" || + e instanceof RegExp || + (e !== null && + typeof e === "object" || + typeof e === "function")) )) && (typeof obj.mode === "undefined" || + obj.mode === null || typeof obj.mode === "string") || (obj !== null && typeof obj === "object" || @@ -665,24 +685,24 @@ export function isWebpackInjectManifestOptions(obj: any, _argumentName?: string) (typeof obj.additionalManifestEntries === "undefined" || Array.isArray(obj.additionalManifestEntries) && obj.additionalManifestEntries.every((e: any) => - (typeof e === "string" || - (e !== null && - typeof e === "object" || - typeof e === "function") && - (typeof e.integrity === "undefined" || - typeof e.integrity === "string") && - (e.revision === null || - typeof e.revision === "string") && - typeof e.url === "string") + (typeof e === "string" || + (e !== null && + typeof e === "object" || + typeof e === "function") && + (typeof e.integrity === "undefined" || + typeof e.integrity === "string") && + (e.revision === null || + typeof e.revision === "string") && + typeof e.url === "string") )) && (typeof obj.dontCacheBustURLsMatching === "undefined" || obj.dontCacheBustURLsMatching instanceof RegExp) && (typeof obj.manifestTransforms === "undefined" || Array.isArray(obj.manifestTransforms) && obj.manifestTransforms.every((e: any) => - (e !== null && - typeof e === "object" || - typeof e === "function") + (e !== null && + typeof e === "object" || + typeof e === "function") )) && (typeof obj.maximumFileSizeToCacheInBytes === "undefined" || typeof obj.maximumFileSizeToCacheInBytes === "number") && From b2e0f1926d690184dc3a09037f86ac2224364802 Mon Sep 17 00:00:00 2001 From: Jeff Posnick Date: Sun, 23 May 2021 12:11:00 -0400 Subject: [PATCH 16/80] test/additional-manifest-entries-transform --- packages/workbox-build/src/types.guard.ts | 328 +++++++++++++++++- .../additional-manifest-entries-transform.js | 14 +- 2 files changed, 325 insertions(+), 17 deletions(-) diff --git a/packages/workbox-build/src/types.guard.ts b/packages/workbox-build/src/types.guard.ts index ae9401955..318a1ac07 100644 --- a/packages/workbox-build/src/types.guard.ts +++ b/packages/workbox-build/src/types.guard.ts @@ -84,11 +84,48 @@ export function isGenerateSWOptions(obj: any, _argumentName?: string): obj is Ge (typeof obj.navigationPreload === "undefined" || obj.navigationPreload === false || obj.navigationPreload === true) && + (typeof obj.offlineGoogleAnalytics === "undefined" || + obj.offlineGoogleAnalytics === false || + obj.offlineGoogleAnalytics === true || + (obj.offlineGoogleAnalytics !== null && + typeof obj.offlineGoogleAnalytics === "object" || + typeof obj.offlineGoogleAnalytics === "function") && + (typeof obj.offlineGoogleAnalytics.cacheName === "undefined" || + typeof obj.offlineGoogleAnalytics.cacheName === "string") && + (typeof obj.offlineGoogleAnalytics.parameterOverrides === "undefined" || + (obj.offlineGoogleAnalytics.parameterOverrides !== null && + typeof obj.offlineGoogleAnalytics.parameterOverrides === "object" || + typeof obj.offlineGoogleAnalytics.parameterOverrides === "function")) && + (typeof obj.offlineGoogleAnalytics.hitFilter === "undefined" || + (obj.offlineGoogleAnalytics.hitFilter !== null && + typeof obj.offlineGoogleAnalytics.hitFilter === "object" || + typeof obj.offlineGoogleAnalytics.hitFilter === "function"))) && Array.isArray(obj.runtimeCaching) && obj.runtimeCaching.every((e: any) => (e !== null && typeof e === "object" || typeof e === "function") && + ((e.handler !== null && + typeof e.handler === "object" || + typeof e.handler === "function") || + (e.handler !== null && + typeof e.handler === "object" || + typeof e.handler === "function") && + (e.handler.handle !== null && + typeof e.handler.handle === "object" || + typeof e.handler.handle === "function") || + e.handler === "CacheFirst" || + e.handler === "CacheOnly" || + e.handler === "NetworkFirst" || + e.handler === "NetworkOnly" || + e.handler === "StaleWhileRevalidate") && + (typeof e.method === "undefined" || + e.method === "DELETE" || + e.method === "GET" || + e.method === "HEAD" || + e.method === "PATCH" || + e.method === "POST" || + e.method === "PUT") && (typeof e.options === "undefined" || (e.options !== null && typeof e.options === "object" || @@ -97,20 +134,132 @@ export function isGenerateSWOptions(obj: any, _argumentName?: string): obj is Ge (e.options.backgroundSync !== null && typeof e.options.backgroundSync === "object" || typeof e.options.backgroundSync === "function") && - typeof e.options.backgroundSync.name === "string") && + typeof e.options.backgroundSync.name === "string" && + (typeof e.options.backgroundSync.options === "undefined" || + (e.options.backgroundSync.options !== null && + typeof e.options.backgroundSync.options === "object" || + typeof e.options.backgroundSync.options === "function") && + (typeof e.options.backgroundSync.options.onSync === "undefined" || + (e.options.backgroundSync.options.onSync !== null && + typeof e.options.backgroundSync.options.onSync === "object" || + typeof e.options.backgroundSync.options.onSync === "function")) && + (typeof e.options.backgroundSync.options.maxRetentionTime === "undefined" || + typeof e.options.backgroundSync.options.maxRetentionTime === "number"))) && (typeof e.options.broadcastUpdate === "undefined" || (e.options.broadcastUpdate !== null && typeof e.options.broadcastUpdate === "object" || typeof e.options.broadcastUpdate === "function") && (typeof e.options.broadcastUpdate.channelName === "undefined" || - typeof e.options.broadcastUpdate.channelName === "string")) && + typeof e.options.broadcastUpdate.channelName === "string") && + (e.options.broadcastUpdate.options !== null && + typeof e.options.broadcastUpdate.options === "object" || + typeof e.options.broadcastUpdate.options === "function") && + (typeof e.options.broadcastUpdate.options.headersToCheck === "undefined" || + Array.isArray(e.options.broadcastUpdate.options.headersToCheck) && + e.options.broadcastUpdate.options.headersToCheck.every((e: any) => + typeof e === "string" + )) && + (typeof e.options.broadcastUpdate.options.generatePayload === "undefined" || + (e.options.broadcastUpdate.options.generatePayload !== null && + typeof e.options.broadcastUpdate.options.generatePayload === "object" || + typeof e.options.broadcastUpdate.options.generatePayload === "function"))) && + (typeof e.options.cacheableResponse === "undefined" || + (e.options.cacheableResponse !== null && + typeof e.options.cacheableResponse === "object" || + typeof e.options.cacheableResponse === "function") && + (typeof e.options.cacheableResponse.statuses === "undefined" || + Array.isArray(e.options.cacheableResponse.statuses) && + e.options.cacheableResponse.statuses.every((e: any) => + typeof e === "number" + )) && + (typeof e.options.cacheableResponse.headers === "undefined" || + (e.options.cacheableResponse.headers !== null && + typeof e.options.cacheableResponse.headers === "object" || + typeof e.options.cacheableResponse.headers === "function"))) && (typeof e.options.cacheName === "undefined" || e.options.cacheName === null || typeof e.options.cacheName === "string") && + (typeof e.options.expiration === "undefined" || + (e.options.expiration !== null && + typeof e.options.expiration === "object" || + typeof e.options.expiration === "function") && + (typeof e.options.expiration.maxEntries === "undefined" || + typeof e.options.expiration.maxEntries === "number") && + (typeof e.options.expiration.maxAgeSeconds === "undefined" || + typeof e.options.expiration.maxAgeSeconds === "number") && + (typeof e.options.expiration.matchOptions === "undefined" || + (e.options.expiration.matchOptions !== null && + typeof e.options.expiration.matchOptions === "object" || + typeof e.options.expiration.matchOptions === "function") && + (typeof e.options.expiration.matchOptions.ignoreMethod === "undefined" || + e.options.expiration.matchOptions.ignoreMethod === false || + e.options.expiration.matchOptions.ignoreMethod === true) && + (typeof e.options.expiration.matchOptions.ignoreSearch === "undefined" || + e.options.expiration.matchOptions.ignoreSearch === false || + e.options.expiration.matchOptions.ignoreSearch === true) && + (typeof e.options.expiration.matchOptions.ignoreVary === "undefined" || + e.options.expiration.matchOptions.ignoreVary === false || + e.options.expiration.matchOptions.ignoreVary === true)) && + (typeof e.options.expiration.purgeOnQuotaError === "undefined" || + e.options.expiration.purgeOnQuotaError === false || + e.options.expiration.purgeOnQuotaError === true)) && (typeof e.options.networkTimeoutSeconds === "undefined" || typeof e.options.networkTimeoutSeconds === "number") && (typeof e.options.plugins === "undefined" || - Array.isArray(e.options.plugins)) && + Array.isArray(e.options.plugins) && + e.options.plugins.every((e: any) => + (e !== null && + typeof e === "object" || + typeof e === "function") && + (typeof e.cacheDidUpdate === "undefined" || + (e.cacheDidUpdate !== null && + typeof e.cacheDidUpdate === "object" || + typeof e.cacheDidUpdate === "function")) && + (typeof e.cachedResponseWillBeUsed === "undefined" || + (e.cachedResponseWillBeUsed !== null && + typeof e.cachedResponseWillBeUsed === "object" || + typeof e.cachedResponseWillBeUsed === "function")) && + (typeof e.cacheKeyWillBeUsed === "undefined" || + (e.cacheKeyWillBeUsed !== null && + typeof e.cacheKeyWillBeUsed === "object" || + typeof e.cacheKeyWillBeUsed === "function")) && + (typeof e.cacheWillUpdate === "undefined" || + (e.cacheWillUpdate !== null && + typeof e.cacheWillUpdate === "object" || + typeof e.cacheWillUpdate === "function")) && + (typeof e.fetchDidFail === "undefined" || + (e.fetchDidFail !== null && + typeof e.fetchDidFail === "object" || + typeof e.fetchDidFail === "function")) && + (typeof e.fetchDidSucceed === "undefined" || + (e.fetchDidSucceed !== null && + typeof e.fetchDidSucceed === "object" || + typeof e.fetchDidSucceed === "function")) && + (typeof e.handlerDidComplete === "undefined" || + (e.handlerDidComplete !== null && + typeof e.handlerDidComplete === "object" || + typeof e.handlerDidComplete === "function")) && + (typeof e.handlerDidError === "undefined" || + (e.handlerDidError !== null && + typeof e.handlerDidError === "object" || + typeof e.handlerDidError === "function")) && + (typeof e.handlerDidRespond === "undefined" || + (e.handlerDidRespond !== null && + typeof e.handlerDidRespond === "object" || + typeof e.handlerDidRespond === "function")) && + (typeof e.handlerWillRespond === "undefined" || + (e.handlerWillRespond !== null && + typeof e.handlerWillRespond === "object" || + typeof e.handlerWillRespond === "function")) && + (typeof e.handlerWillStart === "undefined" || + (e.handlerWillStart !== null && + typeof e.handlerWillStart === "object" || + typeof e.handlerWillStart === "function")) && + (typeof e.requestWillFetch === "undefined" || + (e.requestWillFetch !== null && + typeof e.requestWillFetch === "object" || + typeof e.requestWillFetch === "function")) + )) && (typeof e.options.precacheFallback === "undefined" || (e.options.precacheFallback !== null && typeof e.options.precacheFallback === "object" || @@ -123,6 +272,7 @@ export function isGenerateSWOptions(obj: any, _argumentName?: string): obj is Ge (typeof e.options.fetchOptions.body === "undefined" || e.options.fetchOptions.body === null || typeof e.options.fetchOptions.body === "string" || + e.options.fetchOptions.body instanceof URLSearchParams || e.options.fetchOptions.body instanceof Blob || (e.options.fetchOptions.body !== null && typeof e.options.fetchOptions.body === "object" || @@ -133,7 +283,6 @@ export function isGenerateSWOptions(obj: any, _argumentName?: string): obj is Ge typeof e.options.fetchOptions.body.byteOffset === "number" || e.options.fetchOptions.body instanceof ArrayBuffer || e.options.fetchOptions.body instanceof FormData || - e.options.fetchOptions.body instanceof URLSearchParams || e.options.fetchOptions.body instanceof ReadableStream) && (typeof e.options.fetchOptions.cache === "undefined" || e.options.fetchOptions.cache === "default" || @@ -204,7 +353,12 @@ export function isGenerateSWOptions(obj: any, _argumentName?: string): obj is Ge e.options.matchOptions.ignoreSearch === true) && (typeof e.options.matchOptions.ignoreVary === "undefined" || e.options.matchOptions.ignoreVary === false || - e.options.matchOptions.ignoreVary === true))) + e.options.matchOptions.ignoreVary === true))) && + (typeof e.urlPattern === "string" || + e.urlPattern instanceof RegExp || + (e.urlPattern !== null && + typeof e.urlPattern === "object" || + typeof e.urlPattern === "function")) ) && (typeof obj.skipWaiting === "undefined" || obj.skipWaiting === false || @@ -466,11 +620,48 @@ export function isWebpackGenerateSWOptions(obj: any, _argumentName?: string): ob (typeof obj.navigationPreload === "undefined" || obj.navigationPreload === false || obj.navigationPreload === true) && + (typeof obj.offlineGoogleAnalytics === "undefined" || + obj.offlineGoogleAnalytics === false || + obj.offlineGoogleAnalytics === true || + (obj.offlineGoogleAnalytics !== null && + typeof obj.offlineGoogleAnalytics === "object" || + typeof obj.offlineGoogleAnalytics === "function") && + (typeof obj.offlineGoogleAnalytics.cacheName === "undefined" || + typeof obj.offlineGoogleAnalytics.cacheName === "string") && + (typeof obj.offlineGoogleAnalytics.parameterOverrides === "undefined" || + (obj.offlineGoogleAnalytics.parameterOverrides !== null && + typeof obj.offlineGoogleAnalytics.parameterOverrides === "object" || + typeof obj.offlineGoogleAnalytics.parameterOverrides === "function")) && + (typeof obj.offlineGoogleAnalytics.hitFilter === "undefined" || + (obj.offlineGoogleAnalytics.hitFilter !== null && + typeof obj.offlineGoogleAnalytics.hitFilter === "object" || + typeof obj.offlineGoogleAnalytics.hitFilter === "function"))) && Array.isArray(obj.runtimeCaching) && obj.runtimeCaching.every((e: any) => (e !== null && typeof e === "object" || typeof e === "function") && + ((e.handler !== null && + typeof e.handler === "object" || + typeof e.handler === "function") || + (e.handler !== null && + typeof e.handler === "object" || + typeof e.handler === "function") && + (e.handler.handle !== null && + typeof e.handler.handle === "object" || + typeof e.handler.handle === "function") || + e.handler === "CacheFirst" || + e.handler === "CacheOnly" || + e.handler === "NetworkFirst" || + e.handler === "NetworkOnly" || + e.handler === "StaleWhileRevalidate") && + (typeof e.method === "undefined" || + e.method === "DELETE" || + e.method === "GET" || + e.method === "HEAD" || + e.method === "PATCH" || + e.method === "POST" || + e.method === "PUT") && (typeof e.options === "undefined" || (e.options !== null && typeof e.options === "object" || @@ -479,20 +670,132 @@ export function isWebpackGenerateSWOptions(obj: any, _argumentName?: string): ob (e.options.backgroundSync !== null && typeof e.options.backgroundSync === "object" || typeof e.options.backgroundSync === "function") && - typeof e.options.backgroundSync.name === "string") && + typeof e.options.backgroundSync.name === "string" && + (typeof e.options.backgroundSync.options === "undefined" || + (e.options.backgroundSync.options !== null && + typeof e.options.backgroundSync.options === "object" || + typeof e.options.backgroundSync.options === "function") && + (typeof e.options.backgroundSync.options.onSync === "undefined" || + (e.options.backgroundSync.options.onSync !== null && + typeof e.options.backgroundSync.options.onSync === "object" || + typeof e.options.backgroundSync.options.onSync === "function")) && + (typeof e.options.backgroundSync.options.maxRetentionTime === "undefined" || + typeof e.options.backgroundSync.options.maxRetentionTime === "number"))) && (typeof e.options.broadcastUpdate === "undefined" || (e.options.broadcastUpdate !== null && typeof e.options.broadcastUpdate === "object" || typeof e.options.broadcastUpdate === "function") && (typeof e.options.broadcastUpdate.channelName === "undefined" || - typeof e.options.broadcastUpdate.channelName === "string")) && + typeof e.options.broadcastUpdate.channelName === "string") && + (e.options.broadcastUpdate.options !== null && + typeof e.options.broadcastUpdate.options === "object" || + typeof e.options.broadcastUpdate.options === "function") && + (typeof e.options.broadcastUpdate.options.headersToCheck === "undefined" || + Array.isArray(e.options.broadcastUpdate.options.headersToCheck) && + e.options.broadcastUpdate.options.headersToCheck.every((e: any) => + typeof e === "string" + )) && + (typeof e.options.broadcastUpdate.options.generatePayload === "undefined" || + (e.options.broadcastUpdate.options.generatePayload !== null && + typeof e.options.broadcastUpdate.options.generatePayload === "object" || + typeof e.options.broadcastUpdate.options.generatePayload === "function"))) && + (typeof e.options.cacheableResponse === "undefined" || + (e.options.cacheableResponse !== null && + typeof e.options.cacheableResponse === "object" || + typeof e.options.cacheableResponse === "function") && + (typeof e.options.cacheableResponse.statuses === "undefined" || + Array.isArray(e.options.cacheableResponse.statuses) && + e.options.cacheableResponse.statuses.every((e: any) => + typeof e === "number" + )) && + (typeof e.options.cacheableResponse.headers === "undefined" || + (e.options.cacheableResponse.headers !== null && + typeof e.options.cacheableResponse.headers === "object" || + typeof e.options.cacheableResponse.headers === "function"))) && (typeof e.options.cacheName === "undefined" || e.options.cacheName === null || typeof e.options.cacheName === "string") && + (typeof e.options.expiration === "undefined" || + (e.options.expiration !== null && + typeof e.options.expiration === "object" || + typeof e.options.expiration === "function") && + (typeof e.options.expiration.maxEntries === "undefined" || + typeof e.options.expiration.maxEntries === "number") && + (typeof e.options.expiration.maxAgeSeconds === "undefined" || + typeof e.options.expiration.maxAgeSeconds === "number") && + (typeof e.options.expiration.matchOptions === "undefined" || + (e.options.expiration.matchOptions !== null && + typeof e.options.expiration.matchOptions === "object" || + typeof e.options.expiration.matchOptions === "function") && + (typeof e.options.expiration.matchOptions.ignoreMethod === "undefined" || + e.options.expiration.matchOptions.ignoreMethod === false || + e.options.expiration.matchOptions.ignoreMethod === true) && + (typeof e.options.expiration.matchOptions.ignoreSearch === "undefined" || + e.options.expiration.matchOptions.ignoreSearch === false || + e.options.expiration.matchOptions.ignoreSearch === true) && + (typeof e.options.expiration.matchOptions.ignoreVary === "undefined" || + e.options.expiration.matchOptions.ignoreVary === false || + e.options.expiration.matchOptions.ignoreVary === true)) && + (typeof e.options.expiration.purgeOnQuotaError === "undefined" || + e.options.expiration.purgeOnQuotaError === false || + e.options.expiration.purgeOnQuotaError === true)) && (typeof e.options.networkTimeoutSeconds === "undefined" || typeof e.options.networkTimeoutSeconds === "number") && (typeof e.options.plugins === "undefined" || - Array.isArray(e.options.plugins)) && + Array.isArray(e.options.plugins) && + e.options.plugins.every((e: any) => + (e !== null && + typeof e === "object" || + typeof e === "function") && + (typeof e.cacheDidUpdate === "undefined" || + (e.cacheDidUpdate !== null && + typeof e.cacheDidUpdate === "object" || + typeof e.cacheDidUpdate === "function")) && + (typeof e.cachedResponseWillBeUsed === "undefined" || + (e.cachedResponseWillBeUsed !== null && + typeof e.cachedResponseWillBeUsed === "object" || + typeof e.cachedResponseWillBeUsed === "function")) && + (typeof e.cacheKeyWillBeUsed === "undefined" || + (e.cacheKeyWillBeUsed !== null && + typeof e.cacheKeyWillBeUsed === "object" || + typeof e.cacheKeyWillBeUsed === "function")) && + (typeof e.cacheWillUpdate === "undefined" || + (e.cacheWillUpdate !== null && + typeof e.cacheWillUpdate === "object" || + typeof e.cacheWillUpdate === "function")) && + (typeof e.fetchDidFail === "undefined" || + (e.fetchDidFail !== null && + typeof e.fetchDidFail === "object" || + typeof e.fetchDidFail === "function")) && + (typeof e.fetchDidSucceed === "undefined" || + (e.fetchDidSucceed !== null && + typeof e.fetchDidSucceed === "object" || + typeof e.fetchDidSucceed === "function")) && + (typeof e.handlerDidComplete === "undefined" || + (e.handlerDidComplete !== null && + typeof e.handlerDidComplete === "object" || + typeof e.handlerDidComplete === "function")) && + (typeof e.handlerDidError === "undefined" || + (e.handlerDidError !== null && + typeof e.handlerDidError === "object" || + typeof e.handlerDidError === "function")) && + (typeof e.handlerDidRespond === "undefined" || + (e.handlerDidRespond !== null && + typeof e.handlerDidRespond === "object" || + typeof e.handlerDidRespond === "function")) && + (typeof e.handlerWillRespond === "undefined" || + (e.handlerWillRespond !== null && + typeof e.handlerWillRespond === "object" || + typeof e.handlerWillRespond === "function")) && + (typeof e.handlerWillStart === "undefined" || + (e.handlerWillStart !== null && + typeof e.handlerWillStart === "object" || + typeof e.handlerWillStart === "function")) && + (typeof e.requestWillFetch === "undefined" || + (e.requestWillFetch !== null && + typeof e.requestWillFetch === "object" || + typeof e.requestWillFetch === "function")) + )) && (typeof e.options.precacheFallback === "undefined" || (e.options.precacheFallback !== null && typeof e.options.precacheFallback === "object" || @@ -505,6 +808,7 @@ export function isWebpackGenerateSWOptions(obj: any, _argumentName?: string): ob (typeof e.options.fetchOptions.body === "undefined" || e.options.fetchOptions.body === null || typeof e.options.fetchOptions.body === "string" || + e.options.fetchOptions.body instanceof URLSearchParams || e.options.fetchOptions.body instanceof Blob || (e.options.fetchOptions.body !== null && typeof e.options.fetchOptions.body === "object" || @@ -515,7 +819,6 @@ export function isWebpackGenerateSWOptions(obj: any, _argumentName?: string): ob typeof e.options.fetchOptions.body.byteOffset === "number" || e.options.fetchOptions.body instanceof ArrayBuffer || e.options.fetchOptions.body instanceof FormData || - e.options.fetchOptions.body instanceof URLSearchParams || e.options.fetchOptions.body instanceof ReadableStream) && (typeof e.options.fetchOptions.cache === "undefined" || e.options.fetchOptions.cache === "default" || @@ -586,7 +889,12 @@ export function isWebpackGenerateSWOptions(obj: any, _argumentName?: string): ob e.options.matchOptions.ignoreSearch === true) && (typeof e.options.matchOptions.ignoreVary === "undefined" || e.options.matchOptions.ignoreVary === false || - e.options.matchOptions.ignoreVary === true))) + e.options.matchOptions.ignoreVary === true))) && + (typeof e.urlPattern === "string" || + e.urlPattern instanceof RegExp || + (e.urlPattern !== null && + typeof e.urlPattern === "object" || + typeof e.urlPattern === "function")) ) && (typeof obj.skipWaiting === "undefined" || obj.skipWaiting === false || diff --git a/test/workbox-build/node/lib/additional-manifest-entries-transform.js b/test/workbox-build/node/lib/additional-manifest-entries-transform.js index e799bf698..67d0a82c2 100644 --- a/test/workbox-build/node/lib/additional-manifest-entries-transform.js +++ b/test/workbox-build/node/lib/additional-manifest-entries-transform.js @@ -8,10 +8,10 @@ const expect = require('chai').expect; -const errors = require('../../../../packages/workbox-build/build/lib/errors'); -const additionalManifestEntriesTransform = require('../../../../packages/workbox-build/build/lib/additional-manifest-entries-transform'); +const {errors} = require('../../../../packages/workbox-build/build/lib/errors'); +const {additionalManifestEntriesTransform} = require('../../../../packages/workbox-build/build/lib/additional-manifest-entries-transform'); -describe(`[workbox-build] lib/additional-manifest-entries-transform.js`, function() { +describe(`[workbox-build] lib/additional-manifest-entries-transform`, function() { function getManifest() { return [{ url: '/first', @@ -36,8 +36,8 @@ describe(`[workbox-build] lib/additional-manifest-entries-transform.js`, functio expect(transform(getManifest())).to.eql({ manifest: [ {url: '/first', revision: null}, - {url: '/second', revision: null}, - {url: '/third', revision: null}, + {url: '/second', size: 0, revision: null}, + {url: '/third', size: 0, revision: null}, ], warnings: [], }); @@ -52,8 +52,8 @@ describe(`[workbox-build] lib/additional-manifest-entries-transform.js`, functio expect(transform(getManifest())).to.eql({ manifest: [ {url: '/first', revision: null}, - '/second', - {url: '/third'}, + {url: '/second', size: 0, revision: null}, + {url: '/third', size: 0}, ], warnings: [errors['string-entry-warning'] + '\n - /second\n - /third\n'], }); From 06bb97df2d6aa0f096531abd479d0eec69914d57 Mon Sep 17 00:00:00 2001 From: Jeff Posnick Date: Sun, 23 May 2021 15:25:20 -0400 Subject: [PATCH 17/80] lib/bundle --- test/workbox-build/node/lib/bundle.js | 39 +++++++++++++++++---------- 1 file changed, 25 insertions(+), 14 deletions(-) diff --git a/test/workbox-build/node/lib/bundle.js b/test/workbox-build/node/lib/bundle.js index 1ce1c3594..5cd15b8a4 100644 --- a/test/workbox-build/node/lib/bundle.js +++ b/test/workbox-build/node/lib/bundle.js @@ -10,7 +10,7 @@ const expect = require('chai').expect; const proxyquire = require('proxyquire'); const sinon = require('sinon'); -describe(`[workbox-build] lib/bundle.js`, function() { +describe(`[workbox-build] lib/bundle`, function() { const MODULE_PATH = '../../../../packages/workbox-build/build/lib/bundle'; let bundle; let stubs; @@ -19,16 +19,16 @@ describe(`[workbox-build] lib/bundle.js`, function() { const rollupStub = { generate: sinon.stub().resolves({output: [{ fileName: 'asset-filename', - isAsset: true, + type: 'asset', source: 'asset-source', }, { code: 'chunk1-code', fileName: 'chunk1-filename', - isAsset: false, + type: 'chunk', }, { code: 'chunk2-code', fileName: 'chunk2-filename', - isAsset: false, + type: 'chunk', map: 'sourcemap-contents', }]}), }; @@ -40,24 +40,35 @@ describe(`[workbox-build] lib/bundle.js`, function() { writeFile: sinon.stub().resolves(), }, 'upath': { - parse: sinon.stub().returns({base: 'sw.js', dir: ''}), + default: { + format: sinon.stub().callsFake(args => `${args.dir}${args.base}`), + parse: sinon.stub().returns({base: 'sw.js', dir: ''}), + }, }, 'tempy': { - file: sinon.stub().returns('sw.js'), + default: { + file: sinon.stub().returns('sw.js'), + }, }, '@rollup/plugin-node-resolve': sinon.stub(), - '@rollup/plugin-replace': sinon.stub(), - '@rollup/plugin-babel': {babel: sinon.stub()}, + '@rollup/plugin-replace': { + default: sinon.stub(), + }, + '@rollup/plugin-babel': { + babel: sinon.stub(), + }, 'rollup-plugin-terser': { terser: sinon.stub(), }, - '@surma/rollup-plugin-off-main-thread': sinon.stub(), + '@surma/rollup-plugin-off-main-thread': { + default: sinon.stub(), + }, 'rollup': { rollup: sinon.stub().resolves(rollupStub), }, }; - bundle = proxyquire(MODULE_PATH, stubs); + bundle = proxyquire(MODULE_PATH, stubs).bundle; }); it(`should pass 'babelPresetEnvTargets' to @babel/preset-env`, async function() { @@ -71,7 +82,7 @@ describe(`[workbox-build] lib/bundle.js`, function() { babelHelpers: 'bundled', babelrc: false, configFile: false, - presets: [[stubs['@babel/preset-env'], { + presets: [[stubs['@babel/preset-env'].default, { targets: { browsers: babelPresetEnvTargets, }, @@ -86,7 +97,7 @@ describe(`[workbox-build] lib/bundle.js`, function() { }); expect(stubs.rollup.rollup.args[0][0].manualChunks).to.be.a('function'); - expect(stubs['@surma/rollup-plugin-off-main-thread'].calledOnce).to.be.true; + expect(stubs['@surma/rollup-plugin-off-main-thread'].default.calledOnce).to.be.true; }); it(`should not use loadz0r or configure manualChunks when 'inlineWorkboxRuntime' is true`, async function() { @@ -95,7 +106,7 @@ describe(`[workbox-build] lib/bundle.js`, function() { }); expect(stubs.rollup.rollup.args[0][0].manualChunks).not.to.exist; - expect(stubs['@surma/rollup-plugin-off-main-thread'].notCalled).to.be.true; + expect(stubs['@surma/rollup-plugin-off-main-thread'].default.notCalled).to.be.true; }); it(`should replace NODE_ENV with the 'mode' value`, async function() { @@ -104,7 +115,7 @@ describe(`[workbox-build] lib/bundle.js`, function() { mode, }); - expect(stubs['@rollup/plugin-replace'].args).to.eql([[{ + expect(stubs['@rollup/plugin-replace'].default.args).to.eql([[{ 'preventAssignment': true, 'process.env.NODE_ENV': `"${mode}"`, }]]); From 0f6c05adec7e5ab928222dd5c3ac9839fa3c07f1 Mon Sep 17 00:00:00 2001 From: Jeff Posnick Date: Fri, 4 Jun 2021 15:13:01 -0400 Subject: [PATCH 18/80] cdnUtils test --- packages/workbox-build/src/lib/cdn-utils.ts | 6 +- packages/workbox-build/src/types.guard.ts | 328 +------------------- test/workbox-build/node/lib/cdn-utils.js | 7 +- 3 files changed, 14 insertions(+), 327 deletions(-) diff --git a/packages/workbox-build/src/lib/cdn-utils.ts b/packages/workbox-build/src/lib/cdn-utils.ts index 9d92f06f3..7ca2c9efd 100644 --- a/packages/workbox-build/src/lib/cdn-utils.ts +++ b/packages/workbox-build/src/lib/cdn-utils.ts @@ -6,11 +6,11 @@ https://opensource.org/licenses/MIT. */ -import assert from 'assert'; +import {ok} from 'assert'; import {BuildType, WorkboxPackageJSON} from '../types'; import {errors} from './errors'; -import cdn from '../cdn-details.json'; +import * as cdn from '../cdn-details.json'; function getVersionedURL(): string { return `${getCDNPrefix()}/${cdn.latestVersion}`; @@ -21,7 +21,7 @@ function getCDNPrefix() { } export function getModuleURL(moduleName: string, buildType: BuildType) { - assert(moduleName, errors['no-module-name']); + ok(moduleName, errors['no-module-name']); if (buildType) { const pkgJson: WorkboxPackageJSON = require(`${moduleName}/package.json`); diff --git a/packages/workbox-build/src/types.guard.ts b/packages/workbox-build/src/types.guard.ts index 318a1ac07..ae9401955 100644 --- a/packages/workbox-build/src/types.guard.ts +++ b/packages/workbox-build/src/types.guard.ts @@ -84,48 +84,11 @@ export function isGenerateSWOptions(obj: any, _argumentName?: string): obj is Ge (typeof obj.navigationPreload === "undefined" || obj.navigationPreload === false || obj.navigationPreload === true) && - (typeof obj.offlineGoogleAnalytics === "undefined" || - obj.offlineGoogleAnalytics === false || - obj.offlineGoogleAnalytics === true || - (obj.offlineGoogleAnalytics !== null && - typeof obj.offlineGoogleAnalytics === "object" || - typeof obj.offlineGoogleAnalytics === "function") && - (typeof obj.offlineGoogleAnalytics.cacheName === "undefined" || - typeof obj.offlineGoogleAnalytics.cacheName === "string") && - (typeof obj.offlineGoogleAnalytics.parameterOverrides === "undefined" || - (obj.offlineGoogleAnalytics.parameterOverrides !== null && - typeof obj.offlineGoogleAnalytics.parameterOverrides === "object" || - typeof obj.offlineGoogleAnalytics.parameterOverrides === "function")) && - (typeof obj.offlineGoogleAnalytics.hitFilter === "undefined" || - (obj.offlineGoogleAnalytics.hitFilter !== null && - typeof obj.offlineGoogleAnalytics.hitFilter === "object" || - typeof obj.offlineGoogleAnalytics.hitFilter === "function"))) && Array.isArray(obj.runtimeCaching) && obj.runtimeCaching.every((e: any) => (e !== null && typeof e === "object" || typeof e === "function") && - ((e.handler !== null && - typeof e.handler === "object" || - typeof e.handler === "function") || - (e.handler !== null && - typeof e.handler === "object" || - typeof e.handler === "function") && - (e.handler.handle !== null && - typeof e.handler.handle === "object" || - typeof e.handler.handle === "function") || - e.handler === "CacheFirst" || - e.handler === "CacheOnly" || - e.handler === "NetworkFirst" || - e.handler === "NetworkOnly" || - e.handler === "StaleWhileRevalidate") && - (typeof e.method === "undefined" || - e.method === "DELETE" || - e.method === "GET" || - e.method === "HEAD" || - e.method === "PATCH" || - e.method === "POST" || - e.method === "PUT") && (typeof e.options === "undefined" || (e.options !== null && typeof e.options === "object" || @@ -134,132 +97,20 @@ export function isGenerateSWOptions(obj: any, _argumentName?: string): obj is Ge (e.options.backgroundSync !== null && typeof e.options.backgroundSync === "object" || typeof e.options.backgroundSync === "function") && - typeof e.options.backgroundSync.name === "string" && - (typeof e.options.backgroundSync.options === "undefined" || - (e.options.backgroundSync.options !== null && - typeof e.options.backgroundSync.options === "object" || - typeof e.options.backgroundSync.options === "function") && - (typeof e.options.backgroundSync.options.onSync === "undefined" || - (e.options.backgroundSync.options.onSync !== null && - typeof e.options.backgroundSync.options.onSync === "object" || - typeof e.options.backgroundSync.options.onSync === "function")) && - (typeof e.options.backgroundSync.options.maxRetentionTime === "undefined" || - typeof e.options.backgroundSync.options.maxRetentionTime === "number"))) && + typeof e.options.backgroundSync.name === "string") && (typeof e.options.broadcastUpdate === "undefined" || (e.options.broadcastUpdate !== null && typeof e.options.broadcastUpdate === "object" || typeof e.options.broadcastUpdate === "function") && (typeof e.options.broadcastUpdate.channelName === "undefined" || - typeof e.options.broadcastUpdate.channelName === "string") && - (e.options.broadcastUpdate.options !== null && - typeof e.options.broadcastUpdate.options === "object" || - typeof e.options.broadcastUpdate.options === "function") && - (typeof e.options.broadcastUpdate.options.headersToCheck === "undefined" || - Array.isArray(e.options.broadcastUpdate.options.headersToCheck) && - e.options.broadcastUpdate.options.headersToCheck.every((e: any) => - typeof e === "string" - )) && - (typeof e.options.broadcastUpdate.options.generatePayload === "undefined" || - (e.options.broadcastUpdate.options.generatePayload !== null && - typeof e.options.broadcastUpdate.options.generatePayload === "object" || - typeof e.options.broadcastUpdate.options.generatePayload === "function"))) && - (typeof e.options.cacheableResponse === "undefined" || - (e.options.cacheableResponse !== null && - typeof e.options.cacheableResponse === "object" || - typeof e.options.cacheableResponse === "function") && - (typeof e.options.cacheableResponse.statuses === "undefined" || - Array.isArray(e.options.cacheableResponse.statuses) && - e.options.cacheableResponse.statuses.every((e: any) => - typeof e === "number" - )) && - (typeof e.options.cacheableResponse.headers === "undefined" || - (e.options.cacheableResponse.headers !== null && - typeof e.options.cacheableResponse.headers === "object" || - typeof e.options.cacheableResponse.headers === "function"))) && + typeof e.options.broadcastUpdate.channelName === "string")) && (typeof e.options.cacheName === "undefined" || e.options.cacheName === null || typeof e.options.cacheName === "string") && - (typeof e.options.expiration === "undefined" || - (e.options.expiration !== null && - typeof e.options.expiration === "object" || - typeof e.options.expiration === "function") && - (typeof e.options.expiration.maxEntries === "undefined" || - typeof e.options.expiration.maxEntries === "number") && - (typeof e.options.expiration.maxAgeSeconds === "undefined" || - typeof e.options.expiration.maxAgeSeconds === "number") && - (typeof e.options.expiration.matchOptions === "undefined" || - (e.options.expiration.matchOptions !== null && - typeof e.options.expiration.matchOptions === "object" || - typeof e.options.expiration.matchOptions === "function") && - (typeof e.options.expiration.matchOptions.ignoreMethod === "undefined" || - e.options.expiration.matchOptions.ignoreMethod === false || - e.options.expiration.matchOptions.ignoreMethod === true) && - (typeof e.options.expiration.matchOptions.ignoreSearch === "undefined" || - e.options.expiration.matchOptions.ignoreSearch === false || - e.options.expiration.matchOptions.ignoreSearch === true) && - (typeof e.options.expiration.matchOptions.ignoreVary === "undefined" || - e.options.expiration.matchOptions.ignoreVary === false || - e.options.expiration.matchOptions.ignoreVary === true)) && - (typeof e.options.expiration.purgeOnQuotaError === "undefined" || - e.options.expiration.purgeOnQuotaError === false || - e.options.expiration.purgeOnQuotaError === true)) && (typeof e.options.networkTimeoutSeconds === "undefined" || typeof e.options.networkTimeoutSeconds === "number") && (typeof e.options.plugins === "undefined" || - Array.isArray(e.options.plugins) && - e.options.plugins.every((e: any) => - (e !== null && - typeof e === "object" || - typeof e === "function") && - (typeof e.cacheDidUpdate === "undefined" || - (e.cacheDidUpdate !== null && - typeof e.cacheDidUpdate === "object" || - typeof e.cacheDidUpdate === "function")) && - (typeof e.cachedResponseWillBeUsed === "undefined" || - (e.cachedResponseWillBeUsed !== null && - typeof e.cachedResponseWillBeUsed === "object" || - typeof e.cachedResponseWillBeUsed === "function")) && - (typeof e.cacheKeyWillBeUsed === "undefined" || - (e.cacheKeyWillBeUsed !== null && - typeof e.cacheKeyWillBeUsed === "object" || - typeof e.cacheKeyWillBeUsed === "function")) && - (typeof e.cacheWillUpdate === "undefined" || - (e.cacheWillUpdate !== null && - typeof e.cacheWillUpdate === "object" || - typeof e.cacheWillUpdate === "function")) && - (typeof e.fetchDidFail === "undefined" || - (e.fetchDidFail !== null && - typeof e.fetchDidFail === "object" || - typeof e.fetchDidFail === "function")) && - (typeof e.fetchDidSucceed === "undefined" || - (e.fetchDidSucceed !== null && - typeof e.fetchDidSucceed === "object" || - typeof e.fetchDidSucceed === "function")) && - (typeof e.handlerDidComplete === "undefined" || - (e.handlerDidComplete !== null && - typeof e.handlerDidComplete === "object" || - typeof e.handlerDidComplete === "function")) && - (typeof e.handlerDidError === "undefined" || - (e.handlerDidError !== null && - typeof e.handlerDidError === "object" || - typeof e.handlerDidError === "function")) && - (typeof e.handlerDidRespond === "undefined" || - (e.handlerDidRespond !== null && - typeof e.handlerDidRespond === "object" || - typeof e.handlerDidRespond === "function")) && - (typeof e.handlerWillRespond === "undefined" || - (e.handlerWillRespond !== null && - typeof e.handlerWillRespond === "object" || - typeof e.handlerWillRespond === "function")) && - (typeof e.handlerWillStart === "undefined" || - (e.handlerWillStart !== null && - typeof e.handlerWillStart === "object" || - typeof e.handlerWillStart === "function")) && - (typeof e.requestWillFetch === "undefined" || - (e.requestWillFetch !== null && - typeof e.requestWillFetch === "object" || - typeof e.requestWillFetch === "function")) - )) && + Array.isArray(e.options.plugins)) && (typeof e.options.precacheFallback === "undefined" || (e.options.precacheFallback !== null && typeof e.options.precacheFallback === "object" || @@ -272,7 +123,6 @@ export function isGenerateSWOptions(obj: any, _argumentName?: string): obj is Ge (typeof e.options.fetchOptions.body === "undefined" || e.options.fetchOptions.body === null || typeof e.options.fetchOptions.body === "string" || - e.options.fetchOptions.body instanceof URLSearchParams || e.options.fetchOptions.body instanceof Blob || (e.options.fetchOptions.body !== null && typeof e.options.fetchOptions.body === "object" || @@ -283,6 +133,7 @@ export function isGenerateSWOptions(obj: any, _argumentName?: string): obj is Ge typeof e.options.fetchOptions.body.byteOffset === "number" || e.options.fetchOptions.body instanceof ArrayBuffer || e.options.fetchOptions.body instanceof FormData || + e.options.fetchOptions.body instanceof URLSearchParams || e.options.fetchOptions.body instanceof ReadableStream) && (typeof e.options.fetchOptions.cache === "undefined" || e.options.fetchOptions.cache === "default" || @@ -353,12 +204,7 @@ export function isGenerateSWOptions(obj: any, _argumentName?: string): obj is Ge e.options.matchOptions.ignoreSearch === true) && (typeof e.options.matchOptions.ignoreVary === "undefined" || e.options.matchOptions.ignoreVary === false || - e.options.matchOptions.ignoreVary === true))) && - (typeof e.urlPattern === "string" || - e.urlPattern instanceof RegExp || - (e.urlPattern !== null && - typeof e.urlPattern === "object" || - typeof e.urlPattern === "function")) + e.options.matchOptions.ignoreVary === true))) ) && (typeof obj.skipWaiting === "undefined" || obj.skipWaiting === false || @@ -620,48 +466,11 @@ export function isWebpackGenerateSWOptions(obj: any, _argumentName?: string): ob (typeof obj.navigationPreload === "undefined" || obj.navigationPreload === false || obj.navigationPreload === true) && - (typeof obj.offlineGoogleAnalytics === "undefined" || - obj.offlineGoogleAnalytics === false || - obj.offlineGoogleAnalytics === true || - (obj.offlineGoogleAnalytics !== null && - typeof obj.offlineGoogleAnalytics === "object" || - typeof obj.offlineGoogleAnalytics === "function") && - (typeof obj.offlineGoogleAnalytics.cacheName === "undefined" || - typeof obj.offlineGoogleAnalytics.cacheName === "string") && - (typeof obj.offlineGoogleAnalytics.parameterOverrides === "undefined" || - (obj.offlineGoogleAnalytics.parameterOverrides !== null && - typeof obj.offlineGoogleAnalytics.parameterOverrides === "object" || - typeof obj.offlineGoogleAnalytics.parameterOverrides === "function")) && - (typeof obj.offlineGoogleAnalytics.hitFilter === "undefined" || - (obj.offlineGoogleAnalytics.hitFilter !== null && - typeof obj.offlineGoogleAnalytics.hitFilter === "object" || - typeof obj.offlineGoogleAnalytics.hitFilter === "function"))) && Array.isArray(obj.runtimeCaching) && obj.runtimeCaching.every((e: any) => (e !== null && typeof e === "object" || typeof e === "function") && - ((e.handler !== null && - typeof e.handler === "object" || - typeof e.handler === "function") || - (e.handler !== null && - typeof e.handler === "object" || - typeof e.handler === "function") && - (e.handler.handle !== null && - typeof e.handler.handle === "object" || - typeof e.handler.handle === "function") || - e.handler === "CacheFirst" || - e.handler === "CacheOnly" || - e.handler === "NetworkFirst" || - e.handler === "NetworkOnly" || - e.handler === "StaleWhileRevalidate") && - (typeof e.method === "undefined" || - e.method === "DELETE" || - e.method === "GET" || - e.method === "HEAD" || - e.method === "PATCH" || - e.method === "POST" || - e.method === "PUT") && (typeof e.options === "undefined" || (e.options !== null && typeof e.options === "object" || @@ -670,132 +479,20 @@ export function isWebpackGenerateSWOptions(obj: any, _argumentName?: string): ob (e.options.backgroundSync !== null && typeof e.options.backgroundSync === "object" || typeof e.options.backgroundSync === "function") && - typeof e.options.backgroundSync.name === "string" && - (typeof e.options.backgroundSync.options === "undefined" || - (e.options.backgroundSync.options !== null && - typeof e.options.backgroundSync.options === "object" || - typeof e.options.backgroundSync.options === "function") && - (typeof e.options.backgroundSync.options.onSync === "undefined" || - (e.options.backgroundSync.options.onSync !== null && - typeof e.options.backgroundSync.options.onSync === "object" || - typeof e.options.backgroundSync.options.onSync === "function")) && - (typeof e.options.backgroundSync.options.maxRetentionTime === "undefined" || - typeof e.options.backgroundSync.options.maxRetentionTime === "number"))) && + typeof e.options.backgroundSync.name === "string") && (typeof e.options.broadcastUpdate === "undefined" || (e.options.broadcastUpdate !== null && typeof e.options.broadcastUpdate === "object" || typeof e.options.broadcastUpdate === "function") && (typeof e.options.broadcastUpdate.channelName === "undefined" || - typeof e.options.broadcastUpdate.channelName === "string") && - (e.options.broadcastUpdate.options !== null && - typeof e.options.broadcastUpdate.options === "object" || - typeof e.options.broadcastUpdate.options === "function") && - (typeof e.options.broadcastUpdate.options.headersToCheck === "undefined" || - Array.isArray(e.options.broadcastUpdate.options.headersToCheck) && - e.options.broadcastUpdate.options.headersToCheck.every((e: any) => - typeof e === "string" - )) && - (typeof e.options.broadcastUpdate.options.generatePayload === "undefined" || - (e.options.broadcastUpdate.options.generatePayload !== null && - typeof e.options.broadcastUpdate.options.generatePayload === "object" || - typeof e.options.broadcastUpdate.options.generatePayload === "function"))) && - (typeof e.options.cacheableResponse === "undefined" || - (e.options.cacheableResponse !== null && - typeof e.options.cacheableResponse === "object" || - typeof e.options.cacheableResponse === "function") && - (typeof e.options.cacheableResponse.statuses === "undefined" || - Array.isArray(e.options.cacheableResponse.statuses) && - e.options.cacheableResponse.statuses.every((e: any) => - typeof e === "number" - )) && - (typeof e.options.cacheableResponse.headers === "undefined" || - (e.options.cacheableResponse.headers !== null && - typeof e.options.cacheableResponse.headers === "object" || - typeof e.options.cacheableResponse.headers === "function"))) && + typeof e.options.broadcastUpdate.channelName === "string")) && (typeof e.options.cacheName === "undefined" || e.options.cacheName === null || typeof e.options.cacheName === "string") && - (typeof e.options.expiration === "undefined" || - (e.options.expiration !== null && - typeof e.options.expiration === "object" || - typeof e.options.expiration === "function") && - (typeof e.options.expiration.maxEntries === "undefined" || - typeof e.options.expiration.maxEntries === "number") && - (typeof e.options.expiration.maxAgeSeconds === "undefined" || - typeof e.options.expiration.maxAgeSeconds === "number") && - (typeof e.options.expiration.matchOptions === "undefined" || - (e.options.expiration.matchOptions !== null && - typeof e.options.expiration.matchOptions === "object" || - typeof e.options.expiration.matchOptions === "function") && - (typeof e.options.expiration.matchOptions.ignoreMethod === "undefined" || - e.options.expiration.matchOptions.ignoreMethod === false || - e.options.expiration.matchOptions.ignoreMethod === true) && - (typeof e.options.expiration.matchOptions.ignoreSearch === "undefined" || - e.options.expiration.matchOptions.ignoreSearch === false || - e.options.expiration.matchOptions.ignoreSearch === true) && - (typeof e.options.expiration.matchOptions.ignoreVary === "undefined" || - e.options.expiration.matchOptions.ignoreVary === false || - e.options.expiration.matchOptions.ignoreVary === true)) && - (typeof e.options.expiration.purgeOnQuotaError === "undefined" || - e.options.expiration.purgeOnQuotaError === false || - e.options.expiration.purgeOnQuotaError === true)) && (typeof e.options.networkTimeoutSeconds === "undefined" || typeof e.options.networkTimeoutSeconds === "number") && (typeof e.options.plugins === "undefined" || - Array.isArray(e.options.plugins) && - e.options.plugins.every((e: any) => - (e !== null && - typeof e === "object" || - typeof e === "function") && - (typeof e.cacheDidUpdate === "undefined" || - (e.cacheDidUpdate !== null && - typeof e.cacheDidUpdate === "object" || - typeof e.cacheDidUpdate === "function")) && - (typeof e.cachedResponseWillBeUsed === "undefined" || - (e.cachedResponseWillBeUsed !== null && - typeof e.cachedResponseWillBeUsed === "object" || - typeof e.cachedResponseWillBeUsed === "function")) && - (typeof e.cacheKeyWillBeUsed === "undefined" || - (e.cacheKeyWillBeUsed !== null && - typeof e.cacheKeyWillBeUsed === "object" || - typeof e.cacheKeyWillBeUsed === "function")) && - (typeof e.cacheWillUpdate === "undefined" || - (e.cacheWillUpdate !== null && - typeof e.cacheWillUpdate === "object" || - typeof e.cacheWillUpdate === "function")) && - (typeof e.fetchDidFail === "undefined" || - (e.fetchDidFail !== null && - typeof e.fetchDidFail === "object" || - typeof e.fetchDidFail === "function")) && - (typeof e.fetchDidSucceed === "undefined" || - (e.fetchDidSucceed !== null && - typeof e.fetchDidSucceed === "object" || - typeof e.fetchDidSucceed === "function")) && - (typeof e.handlerDidComplete === "undefined" || - (e.handlerDidComplete !== null && - typeof e.handlerDidComplete === "object" || - typeof e.handlerDidComplete === "function")) && - (typeof e.handlerDidError === "undefined" || - (e.handlerDidError !== null && - typeof e.handlerDidError === "object" || - typeof e.handlerDidError === "function")) && - (typeof e.handlerDidRespond === "undefined" || - (e.handlerDidRespond !== null && - typeof e.handlerDidRespond === "object" || - typeof e.handlerDidRespond === "function")) && - (typeof e.handlerWillRespond === "undefined" || - (e.handlerWillRespond !== null && - typeof e.handlerWillRespond === "object" || - typeof e.handlerWillRespond === "function")) && - (typeof e.handlerWillStart === "undefined" || - (e.handlerWillStart !== null && - typeof e.handlerWillStart === "object" || - typeof e.handlerWillStart === "function")) && - (typeof e.requestWillFetch === "undefined" || - (e.requestWillFetch !== null && - typeof e.requestWillFetch === "object" || - typeof e.requestWillFetch === "function")) - )) && + Array.isArray(e.options.plugins)) && (typeof e.options.precacheFallback === "undefined" || (e.options.precacheFallback !== null && typeof e.options.precacheFallback === "object" || @@ -808,7 +505,6 @@ export function isWebpackGenerateSWOptions(obj: any, _argumentName?: string): ob (typeof e.options.fetchOptions.body === "undefined" || e.options.fetchOptions.body === null || typeof e.options.fetchOptions.body === "string" || - e.options.fetchOptions.body instanceof URLSearchParams || e.options.fetchOptions.body instanceof Blob || (e.options.fetchOptions.body !== null && typeof e.options.fetchOptions.body === "object" || @@ -819,6 +515,7 @@ export function isWebpackGenerateSWOptions(obj: any, _argumentName?: string): ob typeof e.options.fetchOptions.body.byteOffset === "number" || e.options.fetchOptions.body instanceof ArrayBuffer || e.options.fetchOptions.body instanceof FormData || + e.options.fetchOptions.body instanceof URLSearchParams || e.options.fetchOptions.body instanceof ReadableStream) && (typeof e.options.fetchOptions.cache === "undefined" || e.options.fetchOptions.cache === "default" || @@ -889,12 +586,7 @@ export function isWebpackGenerateSWOptions(obj: any, _argumentName?: string): ob e.options.matchOptions.ignoreSearch === true) && (typeof e.options.matchOptions.ignoreVary === "undefined" || e.options.matchOptions.ignoreVary === false || - e.options.matchOptions.ignoreVary === true))) && - (typeof e.urlPattern === "string" || - e.urlPattern instanceof RegExp || - (e.urlPattern !== null && - typeof e.urlPattern === "object" || - typeof e.urlPattern === "function")) + e.options.matchOptions.ignoreVary === true))) ) && (typeof obj.skipWaiting === "undefined" || obj.skipWaiting === false || diff --git a/test/workbox-build/node/lib/cdn-utils.js b/test/workbox-build/node/lib/cdn-utils.js index 2e03813d0..706f2417c 100644 --- a/test/workbox-build/node/lib/cdn-utils.js +++ b/test/workbox-build/node/lib/cdn-utils.js @@ -9,16 +9,11 @@ const expect = require('chai').expect; const cdnUtils = require('../../../../packages/workbox-build/build/lib/cdn-utils'); -const errors = require('../../../../packages/workbox-build/build/lib/errors'); +const {errors} = require('../../../../packages/workbox-build/build/lib/errors'); describe(`[workbox-build] lib/cdn-utils.js`, function() { const CDN_ORIGIN = 'https://storage.googleapis.com/workbox-cdn/releases'; - it(`getCDNOrigin() should return the expected base URL`, function() { - const url = cdnUtils.getCDNOrigin(); - expect(url).to.eql(CDN_ORIGIN); - }); - it(`getModuleURL() should throw when moduleName is undefined`, function() { expect( () => cdnUtils.getModuleURL(), From 464f0c3956dace18e3536edc38e6d16ada7a255a Mon Sep 17 00:00:00 2001 From: Jeff Posnick Date: Fri, 4 Jun 2021 16:20:38 -0400 Subject: [PATCH 19/80] Switched to esModuleInterop --- packages/workbox-build/tsconfig.json | 2 +- test/workbox-build/node/lib/bundle.js | 38 ++++++------------- .../node/lib/copy-workbox-libraries.js | 8 ++-- 3 files changed, 16 insertions(+), 32 deletions(-) diff --git a/packages/workbox-build/tsconfig.json b/packages/workbox-build/tsconfig.json index 347b3fb93..c8414f932 100644 --- a/packages/workbox-build/tsconfig.json +++ b/packages/workbox-build/tsconfig.json @@ -1,7 +1,7 @@ { "extends": "../../tsconfig", "compilerOptions": { - "allowSyntheticDefaultImports": true, + "esModuleInterop": true, "module": "CommonJS", "outDir": "build", "resolveJsonModule": true, diff --git a/test/workbox-build/node/lib/bundle.js b/test/workbox-build/node/lib/bundle.js index 5cd15b8a4..737503dc5 100644 --- a/test/workbox-build/node/lib/bundle.js +++ b/test/workbox-build/node/lib/bundle.js @@ -40,29 +40,21 @@ describe(`[workbox-build] lib/bundle`, function() { writeFile: sinon.stub().resolves(), }, 'upath': { - default: { - format: sinon.stub().callsFake(args => `${args.dir}${args.base}`), - parse: sinon.stub().returns({base: 'sw.js', dir: ''}), - }, + format: sinon.stub().callsFake(args => `${args.dir}${args.base}`), + parse: sinon.stub().returns({base: 'sw.js', dir: ''}), }, 'tempy': { - default: { - file: sinon.stub().returns('sw.js'), - }, + file: sinon.stub().returns('sw.js'), }, '@rollup/plugin-node-resolve': sinon.stub(), - '@rollup/plugin-replace': { - default: sinon.stub(), - }, + '@rollup/plugin-replace': sinon.stub(), '@rollup/plugin-babel': { babel: sinon.stub(), }, 'rollup-plugin-terser': { terser: sinon.stub(), }, - '@surma/rollup-plugin-off-main-thread': { - default: sinon.stub(), - }, + '@surma/rollup-plugin-off-main-thread': sinon.stub(), 'rollup': { rollup: sinon.stub().resolves(rollupStub), }, @@ -78,17 +70,9 @@ describe(`[workbox-build] lib/bundle`, function() { babelPresetEnvTargets, }); - expect(stubs['@rollup/plugin-babel'].babel.args).to.eql([[{ - babelHelpers: 'bundled', - babelrc: false, - configFile: false, - presets: [[stubs['@babel/preset-env'].default, { - targets: { - browsers: babelPresetEnvTargets, - }, - loose: true, - }]], - }]]); + // This is ugly, but necessary due to the way babel() is configured. + const babelParams = stubs['@rollup/plugin-babel'].babel.args[0][0]; + expect(babelParams.presets[0][1].targets.browsers).to.eql(babelPresetEnvTargets); }); it(`should use loadz0r and configure manualChunks when 'inlineWorkboxRuntime' is false`, async function() { @@ -97,7 +81,7 @@ describe(`[workbox-build] lib/bundle`, function() { }); expect(stubs.rollup.rollup.args[0][0].manualChunks).to.be.a('function'); - expect(stubs['@surma/rollup-plugin-off-main-thread'].default.calledOnce).to.be.true; + expect(stubs['@surma/rollup-plugin-off-main-thread'].calledOnce).to.be.true; }); it(`should not use loadz0r or configure manualChunks when 'inlineWorkboxRuntime' is true`, async function() { @@ -106,7 +90,7 @@ describe(`[workbox-build] lib/bundle`, function() { }); expect(stubs.rollup.rollup.args[0][0].manualChunks).not.to.exist; - expect(stubs['@surma/rollup-plugin-off-main-thread'].default.notCalled).to.be.true; + expect(stubs['@surma/rollup-plugin-off-main-thread'].notCalled).to.be.true; }); it(`should replace NODE_ENV with the 'mode' value`, async function() { @@ -115,7 +99,7 @@ describe(`[workbox-build] lib/bundle`, function() { mode, }); - expect(stubs['@rollup/plugin-replace'].default.args).to.eql([[{ + expect(stubs['@rollup/plugin-replace'].args).to.eql([[{ 'preventAssignment': true, 'process.env.NODE_ENV': `"${mode}"`, }]]); diff --git a/test/workbox-build/node/lib/copy-workbox-libraries.js b/test/workbox-build/node/lib/copy-workbox-libraries.js index cf45d2088..f1ab5051c 100644 --- a/test/workbox-build/node/lib/copy-workbox-libraries.js +++ b/test/workbox-build/node/lib/copy-workbox-libraries.js @@ -11,7 +11,7 @@ const upath = require('upath'); const proxyquire = require('proxyquire'); const sinon = require('sinon'); -const errors = require('../../../../packages/workbox-build/build/lib/errors'); +const {errors} = require('../../../../packages/workbox-build/build/lib/errors'); describe(`[workbox-build] lib/copy-workbox-libraries.js`, function() { const MODULE_PATH = '../../../../packages/workbox-build/build/lib/copy-workbox-libraries'; @@ -19,10 +19,10 @@ describe(`[workbox-build] lib/copy-workbox-libraries.js`, function() { const RELATIVE_DEST_DIRECTORY = upath.join('.', 'test-dir'); it(`should reject with an error when the copy fails`, async function() { - const copyWorkboxLibraries = proxyquire(MODULE_PATH, { + const {copyWorkboxLibraries} = proxyquire(MODULE_PATH, { 'fs-extra': { ensureDir: sinon.stub().resolves(), - copy: sinon.stub().rejects(), + copy: sinon.stub().rejects('INJECTED_ERROR'), }, }); @@ -39,7 +39,7 @@ describe(`[workbox-build] lib/copy-workbox-libraries.js`, function() { const copyStub = sinon.stub().resolves(); const ensureDirStub = sinon.stub().resolves(); - const copyWorkboxLibraries = proxyquire(MODULE_PATH, { + const {copyWorkboxLibraries} = proxyquire(MODULE_PATH, { 'fs-extra': { copy: copyStub, ensureDir: ensureDirStub, From e5ab8b07ac38d9c62d9a238d5ad69f749a14ac05 Mon Sep 17 00:00:00 2001 From: Jeff Posnick Date: Fri, 4 Jun 2021 17:08:34 -0400 Subject: [PATCH 20/80] Still WIP --- .../src/lib/get-file-manifest-entries.ts | 6 +- test/workbox-build/node/lib/escape-regexp.js | 4 +- .../node/lib/get-composite-details.js | 2 +- .../node/lib/get-file-details.js | 34 ++++++----- test/workbox-build/node/lib/get-file-hash.js | 10 ++-- .../node/lib/get-file-manifest-entries.js | 57 +++++++++++-------- 6 files changed, 65 insertions(+), 48 deletions(-) diff --git a/packages/workbox-build/src/lib/get-file-manifest-entries.ts b/packages/workbox-build/src/lib/get-file-manifest-entries.ts index ddbf38573..8affad331 100644 --- a/packages/workbox-build/src/lib/get-file-manifest-entries.ts +++ b/packages/workbox-build/src/lib/get-file-manifest-entries.ts @@ -21,7 +21,7 @@ export async function getFileManifestEntries({ globDirectory, globFollow, globIgnores, - globPatterns, + globPatterns = [], globStrict, manifestTransforms, maximumFileSizeToCacheInBytes, @@ -88,6 +88,10 @@ export async function getFileManifestEntries({ error); } }, []); + if (details.length === 0) { + throw new Error(`${errors['bad-template-urls-asset']} The glob ` + + `pattern '${dependencies}' did not match anything.`); + } allFileDetails.set(url, getCompositeDetails(url, details)); } else if (typeof dependencies === 'string') { allFileDetails.set(url, getStringDetails(url, dependencies)); diff --git a/test/workbox-build/node/lib/escape-regexp.js b/test/workbox-build/node/lib/escape-regexp.js index 2877a458d..1aa342573 100644 --- a/test/workbox-build/node/lib/escape-regexp.js +++ b/test/workbox-build/node/lib/escape-regexp.js @@ -7,7 +7,7 @@ */ const expect = require('chai').expect; -const escapeRegexp = require('../../../../packages/workbox-build/build/lib/escape-regexp'); +const {escapeRegExp} = require('../../../../packages/workbox-build/build/lib/escape-regexp'); describe(`[workbox-build] lib/copy-workbox-libraries.js`, function() { const expectedValues = new Map([ @@ -19,7 +19,7 @@ describe(`[workbox-build] lib/copy-workbox-libraries.js`, function() { for (const [original, escaped] of expectedValues) { it(`should perform the expected escaping: ${original} => ${escaped}`, async function() { - expect(escapeRegexp(original)).to.eql(escaped); + expect(escapeRegExp(original)).to.eql(escaped); }); } }); diff --git a/test/workbox-build/node/lib/get-composite-details.js b/test/workbox-build/node/lib/get-composite-details.js index d83374ad1..71ea5360d 100644 --- a/test/workbox-build/node/lib/get-composite-details.js +++ b/test/workbox-build/node/lib/get-composite-details.js @@ -8,7 +8,7 @@ const expect = require('chai').expect; -const getCompositeDetails = require('../../../../packages/workbox-build/build/lib/get-composite-details'); +const {getCompositeDetails} = require('../../../../packages/workbox-build/build/lib/get-composite-details'); describe(`[workbox-build] lib/get-composite-details.js`, function() { const URL = '/test'; diff --git a/test/workbox-build/node/lib/get-file-details.js b/test/workbox-build/node/lib/get-file-details.js index 320f854aa..9cea809c6 100644 --- a/test/workbox-build/node/lib/get-file-details.js +++ b/test/workbox-build/node/lib/get-file-details.js @@ -10,7 +10,7 @@ const expect = require('chai').expect; const upath = require('upath'); const proxyquire = require('proxyquire'); -const errors = require('../../../../packages/workbox-build/build/lib/errors'); +const {errors} = require('../../../../packages/workbox-build/build/lib/errors'); describe(`[workbox-build] lib/get-file-details.js`, function() { const MODULE_PATH = '../../../../packages/workbox-build/build/lib/get-file-details'; @@ -23,7 +23,7 @@ describe(`[workbox-build] lib/get-file-details.js`, function() { const HASH = 'example-hash'; it(`should throw when there's a glob.sync() error`, function() { - const getFileDetails = proxyquire(MODULE_PATH, { + const {getFileDetails} = proxyquire(MODULE_PATH, { glob: { sync: () => { throw new Error(); @@ -43,7 +43,7 @@ describe(`[workbox-build] lib/get-file-details.js`, function() { }); it(`should return a warning when the pattern doesn't match anything`, function() { - const getFileDetails = proxyquire(MODULE_PATH, { + const {getFileDetails} = proxyquire(MODULE_PATH, { glob: { sync: () => [], }, @@ -58,23 +58,27 @@ describe(`[workbox-build] lib/get-file-details.js`, function() { }); it(`should return array of file details, without null values`, function() { - const getFileDetails = proxyquire(MODULE_PATH, { + const {getFileDetails} = proxyquire(MODULE_PATH, { 'glob': { sync: () => { return [FILE1, FILE2, DIRECTORY]; }, }, - './get-file-size': (value) => { - if (upath.normalize(value) === upath.normalize(DIRECTORY)) { - return null; - } - return SIZE; + './get-file-size': { + getFileSize: (value) => { + if (upath.normalize(value) === upath.normalize(DIRECTORY)) { + return null; + } + return SIZE; + }, }, - './get-file-hash': (value) => { - if (upath.normalize(value) === upath.normalize(DIRECTORY)) { - throw new Error(`getFileHash(${DIRECTORY}) shouldn't have been called.`); - } - return HASH; + './get-file-hash': { + getFileHash: (value) => { + if (upath.normalize(value) === upath.normalize(DIRECTORY)) { + throw new Error(`getFileHash(${DIRECTORY}) shouldn't have been called.`); + } + return HASH; + }, }, }); @@ -83,7 +87,7 @@ describe(`[workbox-build] lib/get-file-details.js`, function() { globPattern: GLOB_PATTERN, }); - expect(warning).to.be.undefined; + expect(warning).to.eql(''); expect(globbedFileDetails).to.deep.equal([{ file: FILE1, hash: HASH, diff --git a/test/workbox-build/node/lib/get-file-hash.js b/test/workbox-build/node/lib/get-file-hash.js index da990f3c5..d5954ba55 100644 --- a/test/workbox-build/node/lib/get-file-hash.js +++ b/test/workbox-build/node/lib/get-file-hash.js @@ -9,15 +9,15 @@ const expect = require('chai').expect; const proxyquire = require('proxyquire'); -const errors = require('../../../../packages/workbox-build/build/lib/errors'); +const {errors} = require('../../../../packages/workbox-build/build/lib/errors'); describe(`[workbox-build] lib/get-file-hash.js`, function() { const MODULE_PATH = '../../../../packages/workbox-build/build/lib/get-file-hash'; const FILE = 'file.txt'; it(`should throw when there's a fs.readFileSync() error`, function() { - const getFileHash = proxyquire(MODULE_PATH, { - fs: { + const {getFileHash} = proxyquire(MODULE_PATH, { + 'fs-extra': { readFileSync: () => { throw new Error(); }, @@ -36,8 +36,8 @@ describe(`[workbox-build] lib/get-file-hash.js`, function() { const buffer = Buffer.alloc(10); const hashForBuffer = 'a63c90cc3684ad8b0a2176a6a8fe9005'; - const getFileHash = proxyquire(MODULE_PATH, { - fs: { + const {getFileHash} = proxyquire(MODULE_PATH, { + 'fs-extra': { readFileSync: (file) => { if (file !== FILE) { throw new Error(`Unexpected file name: ${file}`); diff --git a/test/workbox-build/node/lib/get-file-manifest-entries.js b/test/workbox-build/node/lib/get-file-manifest-entries.js index b67bffe43..bc04b7bc8 100644 --- a/test/workbox-build/node/lib/get-file-manifest-entries.js +++ b/test/workbox-build/node/lib/get-file-manifest-entries.js @@ -9,7 +9,7 @@ const expect = require('chai').expect; const proxyquire = require('proxyquire'); -const errors = require('../../../../packages/workbox-build/build/lib/errors'); +const {errors} = require('../../../../packages/workbox-build/build/lib/errors'); describe(`[workbox-build] Test getFileManifestEntries`, function() { const MODULE_PATH = '../../../../packages/workbox-build/build/lib/get-file-manifest-entries'; @@ -22,7 +22,7 @@ describe(`[workbox-build] Test getFileManifestEntries`, function() { }; it(`should return empty info when neither globDirectory nor templatedURLs are provided`, async function() { - const getFileManifestEntries = require(MODULE_PATH); + const {getFileManifestEntries} = require(MODULE_PATH); const {count, size, manifestEntries} = await getFileManifestEntries({}); @@ -32,12 +32,14 @@ describe(`[workbox-build] Test getFileManifestEntries`, function() { }); it(`should not return the same file twice`, async function() { - const getFileManifestEntries = proxyquire(MODULE_PATH, { - './get-file-details': () => { - return { - globbedFileDetails: [FILE, FILE], - warning: undefined, - }; + const {getFileManifestEntries} = proxyquire(MODULE_PATH, { + './get-file-details': { + getFileDetails: () => { + return { + globbedFileDetails: [FILE, FILE], + warning: undefined, + }; + }, }, }); @@ -55,12 +57,14 @@ describe(`[workbox-build] Test getFileManifestEntries`, function() { }); it(`should throw when a templatedURL matches a globbed file`, async function() { - const getFileManifestEntries = proxyquire(MODULE_PATH, { - './get-file-details': () => { - return { - globbedFileDetails: [FILE], - warning: undefined, - }; + const {getFileManifestEntries} = proxyquire(MODULE_PATH, { + './get-file-details': { + getFileDetails: () => { + return { + globbedFileDetails: [FILE], + warning: undefined, + }; + }, }, }); @@ -80,9 +84,11 @@ describe(`[workbox-build] Test getFileManifestEntries`, function() { it(`should treat an exception thrown by getFileDetails() as a warning message`, async function() { const warningMessage = 'test warning'; - const getFileManifestEntries = proxyquire(MODULE_PATH, { - './get-file-details': () => { - throw new Error(warningMessage); + const {getFileManifestEntries} = proxyquire(MODULE_PATH, { + './get-file-details': { + getFileDetails: () => { + throw new Error(warningMessage); + }, }, }); @@ -98,10 +104,11 @@ describe(`[workbox-build] Test getFileManifestEntries`, function() { }); it(`should throw when a templatedURL contains a pattern that doesn't match anything`, async function() { - const getFileManifestEntries = require(MODULE_PATH); + const {getFileManifestEntries} = require(MODULE_PATH); try { await getFileManifestEntries({ + globDirectory: GLOB_DIRECTORY, templatedURLs: { [FILE.file]: GLOB_PATTERNS, }, @@ -117,12 +124,14 @@ describe(`[workbox-build] Test getFileManifestEntries`, function() { const url2 = '/path/to/url2'; const stringValue = 'string'; - const getFileManifestEntries = proxyquire(MODULE_PATH, { - './get-file-details': () => { - return { - globbedFileDetails: [FILE], - warning: undefined, - }; + const {getFileManifestEntries} = proxyquire(MODULE_PATH, { + './get-file-details': { + getFileDetails: () => { + return { + globbedFileDetails: [FILE], + warning: undefined, + }; + }, }, }); From a49d5cd41a852c0b635bdb2f3bd02957118a9e25 Mon Sep 17 00:00:00 2001 From: Jeff Posnick Date: Mon, 7 Jun 2021 15:47:02 -0400 Subject: [PATCH 21/80] get-file-size migration --- test/workbox-build/node/lib/get-file-size.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/test/workbox-build/node/lib/get-file-size.js b/test/workbox-build/node/lib/get-file-size.js index 1fec7a317..b1b7ef490 100644 --- a/test/workbox-build/node/lib/get-file-size.js +++ b/test/workbox-build/node/lib/get-file-size.js @@ -9,15 +9,15 @@ const expect = require('chai').expect; const proxyquire = require('proxyquire'); -const errors = require('../../../../packages/workbox-build/build/lib/errors.js'); +const {errors} = require('../../../../packages/workbox-build/build/lib/errors.js'); describe(`[workbox-build] lib/get-file-size.js`, function() { const MODULE_PATH = '../../../../packages/workbox-build/build/lib/get-file-size'; const FILE = 'file.txt'; it(`should throw when fs.statSync() fails`, function() { - const getFileSize = proxyquire(MODULE_PATH, { - fs: { + const {getFileSize} = proxyquire(MODULE_PATH, { + 'fs-extra': { statSync: () => { throw new Error(); }, @@ -33,8 +33,8 @@ describe(`[workbox-build] lib/get-file-size.js`, function() { }); it(`should return null for non-files`, function() { - const getFileSize = proxyquire(MODULE_PATH, { - fs: { + const {getFileSize} = proxyquire(MODULE_PATH, { + 'fs-extra': { statSync: () => { return { isFile: () => false, @@ -50,8 +50,8 @@ describe(`[workbox-build] lib/get-file-size.js`, function() { it(`should return the expected file size`, function() { const expectedSize = 1234; - const getFileSize = proxyquire(MODULE_PATH, { - fs: { + const {getFileSize} = proxyquire(MODULE_PATH, { + 'fs-extra': { statSync: () => { return { isFile: () => true, From b9427d2361791754761031d62b852d6cfb6467b9 Mon Sep 17 00:00:00 2001 From: Jeff Posnick Date: Mon, 7 Jun 2021 15:47:40 -0400 Subject: [PATCH 22/80] get-string-details test migration --- test/workbox-build/node/lib/get-string-details.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/workbox-build/node/lib/get-string-details.js b/test/workbox-build/node/lib/get-string-details.js index ff7d76f8d..6e0d326cc 100644 --- a/test/workbox-build/node/lib/get-string-details.js +++ b/test/workbox-build/node/lib/get-string-details.js @@ -8,7 +8,7 @@ const expect = require('chai').expect; -const getStringDetails = require('../../../../packages/workbox-build/build/lib/get-string-details'); +const {getStringDetails} = require('../../../../packages/workbox-build/build/lib/get-string-details'); describe(`[workbox-build] lib/get-string-details.js`, function() { it(`should return the expected details`, function() { From f364a00446f4f8bdb4fee85e05dc866041a59314 Mon Sep 17 00:00:00 2001 From: Jeff Posnick Date: Mon, 7 Jun 2021 17:42:06 -0400 Subject: [PATCH 23/80] A few more --- test/workbox-build/node/lib/get-string-hash.js | 2 +- .../node/lib/modify-url-prefix-transform.js | 18 +++++++++--------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/test/workbox-build/node/lib/get-string-hash.js b/test/workbox-build/node/lib/get-string-hash.js index ea2554a4d..7c4826235 100644 --- a/test/workbox-build/node/lib/get-string-hash.js +++ b/test/workbox-build/node/lib/get-string-hash.js @@ -8,7 +8,7 @@ const expect = require('chai').expect; -const getStringHash = require('../../../../packages/workbox-build/build/lib/get-string-hash'); +const {getStringHash} = require('../../../../packages/workbox-build/build/lib/get-string-hash'); describe(`[workbox-build] lib/get-string-hash.js`, function() { it(`should return the expected hashes`, function() { diff --git a/test/workbox-build/node/lib/modify-url-prefix-transform.js b/test/workbox-build/node/lib/modify-url-prefix-transform.js index 9aa777116..068f11406 100644 --- a/test/workbox-build/node/lib/modify-url-prefix-transform.js +++ b/test/workbox-build/node/lib/modify-url-prefix-transform.js @@ -8,8 +8,8 @@ const expect = require('chai').expect; -const errors = require('../../../../packages/workbox-build/build/lib/errors'); -const modifyURLPrefix = require('../../../../packages/workbox-build/build/lib/modify-url-prefix-transform'); +const {errors} = require('../../../../packages/workbox-build/build/lib/errors'); +const {modifyURLPrefixTransform} = require('../../../../packages/workbox-build/build/lib/modify-url-prefix-transform'); describe(`[workbox-build] lib/modify-url-prefix-transform.js`, function() { function getManifest() { @@ -35,7 +35,7 @@ describe(`[workbox-build] lib/modify-url-prefix-transform.js`, function() { '/example-2/multi-section/1234': '/example-2-altered/5678', }; - const transform = modifyURLPrefix(modifications); + const transform = modifyURLPrefixTransform(modifications); for (const badInput of badInputs) { expect( () => transform([{url: badInput}]), @@ -43,7 +43,7 @@ describe(`[workbox-build] lib/modify-url-prefix-transform.js`, function() { } }); - it(`should handle bad modifyURLPrefix input`, function() { + it(`should handle bad modifyURLPrefixTransform input`, function() { const badInputs = [ null, undefined, @@ -58,7 +58,7 @@ describe(`[workbox-build] lib/modify-url-prefix-transform.js`, function() { for (const badInput of badInputs) { expect( - () => modifyURLPrefix(badInput), + () => modifyURLPrefixTransform(badInput), ).to.throw(errors['modify-url-prefix-bad-prefixes']); } }); @@ -68,7 +68,7 @@ describe(`[workbox-build] lib/modify-url-prefix-transform.js`, function() { '/first-match': '', }; - const transform = modifyURLPrefix(modifications); + const transform = modifyURLPrefixTransform(modifications); expect(transform(getManifest())).to.eql({manifest: [{ url: '/12345/hello', }, { @@ -81,7 +81,7 @@ describe(`[workbox-build] lib/modify-url-prefix-transform.js`, function() { '': '/public', }; - const transform = modifyURLPrefix(modifications); + const transform = modifyURLPrefixTransform(modifications); expect(transform(getManifest())).to.eql({manifest: [{ url: '/public/first-match/12345/hello', }, { @@ -95,7 +95,7 @@ describe(`[workbox-build] lib/modify-url-prefix-transform.js`, function() { '/second-match': '/third-match', }; - const transform = modifyURLPrefix(modifications); + const transform = modifyURLPrefixTransform(modifications); expect(transform(getManifest())).to.eql({manifest: [{ url: '/second-match/12345/hello', }, { @@ -108,7 +108,7 @@ describe(`[workbox-build] lib/modify-url-prefix-transform.js`, function() { '/hello': '/altered', }; - const transform = modifyURLPrefix(modifications); + const transform = modifyURLPrefixTransform(modifications); expect(transform(getManifest())).to.eql({manifest: getManifest()}); }); }); From 705e8324e4a67c9e5683a95cf3c0a33aa950c94b Mon Sep 17 00:00:00 2001 From: Jeff Posnick Date: Mon, 7 Jun 2021 17:49:17 -0400 Subject: [PATCH 24/80] populateSWTemplate changes --- .../src/lib/populate-sw-template.ts | 2 +- .../lib/write-sw-using-default-template.ts | 2 +- .../workbox-build/node/lib/module-registry.js | 3 +- ...no-revision-for-urls-matching-transform.js | 14 ++++----- .../node/lib/populate-sw-template.js | 30 +++++++++++-------- 5 files changed, 29 insertions(+), 22 deletions(-) diff --git a/packages/workbox-build/src/lib/populate-sw-template.ts b/packages/workbox-build/src/lib/populate-sw-template.ts index b72fd0f3d..a7755b7bf 100644 --- a/packages/workbox-build/src/lib/populate-sw-template.ts +++ b/packages/workbox-build/src/lib/populate-sw-template.ts @@ -15,7 +15,7 @@ import {runtimeCachingConverter} from './runtime-caching-converter'; import {stringifyWithoutComments} from './stringify-without-comments'; import {swTemplate} from '../templates/sw-template'; -export default function({ +export function populateSWTemplate({ cacheId, cleanupOutdatedCaches, clientsClaim, diff --git a/packages/workbox-build/src/lib/write-sw-using-default-template.ts b/packages/workbox-build/src/lib/write-sw-using-default-template.ts index ef2676e02..347ca2502 100644 --- a/packages/workbox-build/src/lib/write-sw-using-default-template.ts +++ b/packages/workbox-build/src/lib/write-sw-using-default-template.ts @@ -12,7 +12,7 @@ import upath from 'upath'; import {bundle} from './bundle'; import {errors} from './errors'; import {GenerateSWOptions, ManifestEntry} from '../types'; -import populateSWTemplate from './populate-sw-template'; +import {populateSWTemplate} from './populate-sw-template'; export async function writeSWUsingDefaultTemplate({ babelPresetEnvTargets, diff --git a/test/workbox-build/node/lib/module-registry.js b/test/workbox-build/node/lib/module-registry.js index 77c20f7d2..0a665515d 100644 --- a/test/workbox-build/node/lib/module-registry.js +++ b/test/workbox-build/node/lib/module-registry.js @@ -7,9 +7,10 @@ */ const expect = require('chai').expect; -const ModuleRegistry = require('../../../../packages/workbox-build/build/lib/module-registry'); const upath = require('upath'); +const {ModuleRegistry} = require('../../../../packages/workbox-build/build/lib/module-registry'); + describe(`[workbox-build] lib/module-registry.js`, function() { let moduleRegistry; // We can't use proxyquire to override require.resolve(), so let's get the diff --git a/test/workbox-build/node/lib/no-revision-for-urls-matching-transform.js b/test/workbox-build/node/lib/no-revision-for-urls-matching-transform.js index 574a67c4d..a536000ff 100644 --- a/test/workbox-build/node/lib/no-revision-for-urls-matching-transform.js +++ b/test/workbox-build/node/lib/no-revision-for-urls-matching-transform.js @@ -8,8 +8,8 @@ const expect = require('chai').expect; -const errors = require('../../../../packages/workbox-build/build/lib/errors'); -const noRevisionForURLsMatching = require('../../../../packages/workbox-build/build/lib/no-revision-for-urls-matching-transform'); +const {errors} = require('../../../../packages/workbox-build/build/lib/errors'); +const {noRevisionForURLsMatchingTransform} = require('../../../../packages/workbox-build/build/lib/no-revision-for-urls-matching-transform'); describe(`[workbox-build] lib/no-revision-for-urls-matching-transform.js`, function() { const MANIFEST = [{ @@ -32,7 +32,7 @@ describe(`[workbox-build] lib/no-revision-for-urls-matching-transform.js`, funct [], ]; - const transform = noRevisionForURLsMatching(/ignored/); + const transform = noRevisionForURLsMatchingTransform(/ignored/); for (const badInput of badInputs) { expect( () => transform([{url: badInput}]), @@ -55,13 +55,13 @@ describe(`[workbox-build] lib/no-revision-for-urls-matching-transform.js`, funct for (const badInput of badInputs) { expect( - () => noRevisionForURLsMatching(badInput), + () => noRevisionForURLsMatchingTransform(badInput), ).to.throw(errors['invalid-dont-cache-bust']); } }); it(`should set revision info to null in a single matching entry`, function() { - const transform = noRevisionForURLsMatching(/first-match/); + const transform = noRevisionForURLsMatchingTransform(/first-match/); expect(transform(MANIFEST)).to.eql({manifest: [{ url: '/first-match/12345/hello', revision: null, @@ -74,7 +74,7 @@ describe(`[workbox-build] lib/no-revision-for-urls-matching-transform.js`, funct }); it(`should set revision info to null in multiple matching entries`, function() { - const transform = noRevisionForURLsMatching(/12345/); + const transform = noRevisionForURLsMatchingTransform(/12345/); expect(transform(MANIFEST)).to.eql({manifest: [{ url: '/first-match/12345/hello', revision: null, @@ -88,7 +88,7 @@ describe(`[workbox-build] lib/no-revision-for-urls-matching-transform.js`, funct }); it(`should do nothing when there's a match for an entry without a revision`, function() { - const transform = noRevisionForURLsMatching(/third-match/); + const transform = noRevisionForURLsMatchingTransform(/third-match/); expect(transform(MANIFEST)).to.eql({manifest: MANIFEST}); }); }); diff --git a/test/workbox-build/node/lib/populate-sw-template.js b/test/workbox-build/node/lib/populate-sw-template.js index 8e5f52a7a..b64f877e3 100644 --- a/test/workbox-build/node/lib/populate-sw-template.js +++ b/test/workbox-build/node/lib/populate-sw-template.js @@ -10,7 +10,7 @@ const expect = require('chai').expect; const proxyquire = require('proxyquire'); const sinon = require('sinon'); -const errors = require('../../../../packages/workbox-build/build/lib/errors'); +const {errors} = require('../../../../packages/workbox-build/build/lib/errors'); describe(`[workbox-build] lib/populate-sw-template.js`, function() { const MODULE_PATH = '../../../../packages/workbox-build/build/lib/populate-sw-template'; @@ -18,7 +18,7 @@ describe(`[workbox-build] lib/populate-sw-template.js`, function() { it(`should throw an error if templating fails`, function() { const manifestEntries = ['ignored']; - const populateSWTemplate = proxyquire(MODULE_PATH, { + const {populateSWTemplate} = proxyquire(MODULE_PATH, { 'lodash/template': () => { throw new Error(); }, @@ -33,7 +33,7 @@ describe(`[workbox-build] lib/populate-sw-template.js`, function() { }); it(`should throw an error if both manifestEntries and runtimeCaching are empty`, function() { - const populateSWTemplate = proxyquire(MODULE_PATH, { + const {populateSWTemplate} = proxyquire(MODULE_PATH, { 'lodash/template': () => {}, }); @@ -53,10 +53,12 @@ describe(`[workbox-build] lib/populate-sw-template.js`, function() { const innerStub = sinon.stub().returns(''); const outerStub = sinon.stub().returns(innerStub); - const populateSWTemplate = proxyquire(MODULE_PATH, { + const {populateSWTemplate} = proxyquire(MODULE_PATH, { 'lodash/template': outerStub, - './runtime-caching-converter': () => runtimeCachingPlaceholder, - '../templates/sw-template': swTemplate, + './runtime-caching-converter': { + runtimeCachingConverter: () => runtimeCachingPlaceholder, + }, + '../templates/sw-template': {swTemplate}, }); populateSWTemplate({manifestEntries}); @@ -113,10 +115,12 @@ describe(`[workbox-build] lib/populate-sw-template.js`, function() { // We need to stub out both of those steps to test the full flow. const templatePopulationStub = sinon.stub().returns(''); const templateCreationStub = sinon.stub().returns(templatePopulationStub); - const populateSWTemplate = proxyquire(MODULE_PATH, { + const {populateSWTemplate} = proxyquire(MODULE_PATH, { 'lodash/template': templateCreationStub, - './runtime-caching-converter': () => runtimeCachingPlaceholder, - '../templates/sw-template': swTemplate, + './runtime-caching-converter': { + runtimeCachingConverter: () => runtimeCachingPlaceholder, + }, + '../templates/sw-template': {swTemplate}, }); populateSWTemplate({ @@ -180,10 +184,12 @@ describe(`[workbox-build] lib/populate-sw-template.js`, function() { const innerStub = sinon.stub().returns(''); const outerStub = sinon.stub().returns(innerStub); - const populateSWTemplate = proxyquire(MODULE_PATH, { + const {populateSWTemplate} = proxyquire(MODULE_PATH, { 'lodash/template': outerStub, - './runtime-caching-converter': () => runtimeCachingPlaceholder, - '../templates/sw-template': swTemplate, + './runtime-caching-converter': { + runtimeCachingConverter: () => runtimeCachingPlaceholder, + }, + '../templates/sw-template': {swTemplate}, }); populateSWTemplate({manifestEntries, offlineGoogleAnalytics}); From 133728664e72a952e5990f893ee9f54f01457ae4 Mon Sep 17 00:00:00 2001 From: Jeff Posnick Date: Tue, 8 Jun 2021 10:44:01 -0400 Subject: [PATCH 25/80] A few more --- .../node/lib/replace-and-update-source-map.js | 2 +- .../node/lib/runtime-caching-converter.js | 6 +-- .../node/lib/transform-manifest.js | 2 +- .../lib/write-sw-using-default-template.js | 40 +++++++++++-------- 4 files changed, 28 insertions(+), 22 deletions(-) diff --git a/test/workbox-build/node/lib/replace-and-update-source-map.js b/test/workbox-build/node/lib/replace-and-update-source-map.js index 0141a7756..4cbcf451b 100644 --- a/test/workbox-build/node/lib/replace-and-update-source-map.js +++ b/test/workbox-build/node/lib/replace-and-update-source-map.js @@ -8,7 +8,7 @@ const expect = require('chai').expect; -const replaceAndUpdateSourceMap = require('../../../../packages/workbox-build/build/lib/replace-and-update-source-map'); +const {replaceAndUpdateSourceMap} = require('../../../../packages/workbox-build/build/lib/replace-and-update-source-map'); describe(`[workbox-build] lib/replace-and-update-source-map`, function() { // Test case borrowed from https://github.com/Rich-Harris/magic-string/blob/a312519cfe9caa78ade7f09cc2b07459d3d17f4d/test/MagicString.js#L225 diff --git a/test/workbox-build/node/lib/runtime-caching-converter.js b/test/workbox-build/node/lib/runtime-caching-converter.js index ff654c6a7..c2cdef607 100644 --- a/test/workbox-build/node/lib/runtime-caching-converter.js +++ b/test/workbox-build/node/lib/runtime-caching-converter.js @@ -10,9 +10,9 @@ const expect = require('chai').expect; const sinon = require('sinon'); const vm = require('vm'); -const errors = require('../../../../packages/workbox-build/build/lib/errors'); -const ModuleRegistry = require('../../../../packages/workbox-build/build/lib/module-registry'); -const runtimeCachingConverter = require('../../../../packages/workbox-build/build/lib/runtime-caching-converter'); +const {errors} = require('../../../../packages/workbox-build/build/lib/errors'); +const {ModuleRegistry} = require('../../../../packages/workbox-build/build/lib/module-registry'); +const {runtimeCachingConverter} = require('../../../../packages/workbox-build/build/lib/runtime-caching-converter'); const moduleRegistry = new ModuleRegistry(); diff --git a/test/workbox-build/node/lib/transform-manifest.js b/test/workbox-build/node/lib/transform-manifest.js index fc5b786ad..720eed4b2 100644 --- a/test/workbox-build/node/lib/transform-manifest.js +++ b/test/workbox-build/node/lib/transform-manifest.js @@ -8,7 +8,7 @@ const expect = require('chai').expect; -const transformManifest = require('../../../../packages/workbox-build/build/lib/transform-manifest'); +const {transformManifest} = require('../../../../packages/workbox-build/build/lib/transform-manifest'); describe(`[workbox-build] lib/transform-manifest.js`, function() { const MAXIMUM_FILE_SIZE = 1234; diff --git a/test/workbox-build/node/lib/write-sw-using-default-template.js b/test/workbox-build/node/lib/write-sw-using-default-template.js index b3d6b949e..67b18b9f8 100644 --- a/test/workbox-build/node/lib/write-sw-using-default-template.js +++ b/test/workbox-build/node/lib/write-sw-using-default-template.js @@ -11,13 +11,13 @@ const upath = require('upath'); const proxyquire = require('proxyquire'); const sinon = require('sinon'); -const errors = require('../../../../packages/workbox-build/build/lib/errors'); +const {errors} = require('../../../../packages/workbox-build/build/lib/errors'); describe(`[workbox-build] lib/write-sw-using-default-template.js`, function() { const MODULE_PATH = '../../../../packages/workbox-build/build/lib/write-sw-using-default-template'; it(`should reject with an error when fs-extra.mkdirp() fails`, async function() { - const writeSWUsingDefaultTemplate = proxyquire(MODULE_PATH, { + const {writeSWUsingDefaultTemplate} = proxyquire(MODULE_PATH, { 'upath': { dirname: () => 'ignored', }, @@ -35,7 +35,7 @@ describe(`[workbox-build] lib/write-sw-using-default-template.js`, function() { }); it(`should reject with an error when fs-extra.writeFile() fails`, async function() { - const writeSWUsingDefaultTemplate = proxyquire(MODULE_PATH, { + const {writeSWUsingDefaultTemplate} = proxyquire(MODULE_PATH, { 'upath': { dirname: () => 'ignored', }, @@ -57,7 +57,7 @@ describe(`[workbox-build] lib/write-sw-using-default-template.js`, function() { const eisdirError = new Error(); eisdirError.code = 'EISDIR'; - const writeSWUsingDefaultTemplate = proxyquire(MODULE_PATH, { + const {writeSWUsingDefaultTemplate} = proxyquire(MODULE_PATH, { 'upath': { dirname: () => 'ignored', }, @@ -66,10 +66,12 @@ describe(`[workbox-build] lib/write-sw-using-default-template.js`, function() { readFile: () => Promise.resolve(), writeFile: () => Promise.reject(eisdirError), }, - './bundle': async () => [{ - name: 'ignored', - contents: 'ignored', - }], + './bundle': { + bundle: async () => [{ + name: 'ignored', + contents: 'ignored', + }], + }, }); try { @@ -89,7 +91,7 @@ describe(`[workbox-build] lib/write-sw-using-default-template.js`, function() { const contents2 = 'contents2'; const writeFileStub = sinon.stub().returns(Promise.resolve()); - const writeSWUsingDefaultTemplate = proxyquire(MODULE_PATH, { + const {writeSWUsingDefaultTemplate} = proxyquire(MODULE_PATH, { 'fs-extra': { mkdirp: (path) => { expect(path).to.eql(expectedPath); @@ -97,14 +99,18 @@ describe(`[workbox-build] lib/write-sw-using-default-template.js`, function() { readFile: () => Promise.resolve(), writeFile: writeFileStub, }, - './bundle': async () => [{ - name: upath.join(expectedPath, file1), - contents: contents1, - }, { - name: upath.join(expectedPath, file2), - contents: contents2, - }], - './populate-sw-template': () => '', + './bundle': { + bundle: async () => [{ + name: upath.join(expectedPath, file1), + contents: contents1, + }, { + name: upath.join(expectedPath, file2), + contents: contents2, + }], + }, + './populate-sw-template': { + populateSWTemplate: () => '', + }, }); await writeSWUsingDefaultTemplate({swDest}); From 6ba9a827c36545613630f03abe4a5dff2a62c693 Mon Sep 17 00:00:00 2001 From: Jeff Posnick Date: Tue, 8 Jun 2021 12:10:01 -0400 Subject: [PATCH 26/80] validate options --- .../node/lib/validate-options.js | 64 ++++++++++--------- 1 file changed, 33 insertions(+), 31 deletions(-) diff --git a/test/workbox-build/node/lib/validate-options.js b/test/workbox-build/node/lib/validate-options.js index 4fb3c882d..187b228bc 100644 --- a/test/workbox-build/node/lib/validate-options.js +++ b/test/workbox-build/node/lib/validate-options.js @@ -7,35 +7,37 @@ */ const expect = require('chai').expect; - -const validateOptions = require('../../../../packages/workbox-build/build/lib/validate-options'); - -describe(`[workbox-build] entry-points/options/validate.js`, function() { - const testOptions = { - ignored: 'test', - }; - - it(`should throw when the call to schema.validate() returns an error`, function() { - const error = 'dummy error'; - const schema = { - validate: (options) => { - expect(options).to.eql(testOptions); - return {error}; - }, - }; - - expect(() => validateOptions(testOptions, schema)).to.throw(error); - }); - - it(`should pass through the value when the call to schema.validate() doesn't return an error`, function() { - const schema = { - validate: (options) => { - expect(options).to.eql(testOptions); - return {value: options}; - }, - }; - - const value = validateOptions(testOptions, schema); - expect(value).to.eql(testOptions); - }); +const proxyquire = require('proxyquire'); + +// The integration tests will exercise the actual validation logic. +describe(`[workbox-build] entry-points/options/validate-options.js`, function() { + const MODULE_PATH = '../../../../packages/workbox-build/build/lib/validate-options'; + const testCases = new Map([ + ['validateGenerateSWOptions', 'isGenerateSWOptions'], + ['validateGetManifestOptions', 'isGetManifestOptions'], + ['validateInjectManifestOptions', 'isInjectManifestOptions'], + ]); + + for (const [func, guardFunc] of testCases) { + it(`${func}() should throw when ${guardFunc}() returns false`, function() { + const validateOptions = proxyquire(MODULE_PATH, { + '../types.guard': { + [guardFunc]: () => false, + }, + }); + + expect(() => validateOptions[func]()).to.throw('Validation failed.'); + }); + + it(`${func}() should return options with defaults when ${guardFunc}() returns true`, function() { + const validateOptions = proxyquire(MODULE_PATH, { + '../types.guard': { + [guardFunc]: () => true, + }, + }); + + const defaultOptions = validateOptions[func](); + expect(defaultOptions).to.be.an('object'); + }); + } }); From 3ccfddefe670bcaa81c5d8fe895387eee2d3d2ad Mon Sep 17 00:00:00 2001 From: Jeff Posnick Date: Tue, 8 Jun 2021 12:13:39 -0400 Subject: [PATCH 27/80] Update ts-auto-guard --- package-lock.json | 24 ++++++++++++------------ package.json | 10 +++++----- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/package-lock.json b/package-lock.json index 9548991e5..c6d3b1862 100644 --- a/package-lock.json +++ b/package-lock.json @@ -4260,9 +4260,9 @@ }, "dependencies": { "picomatch": { - "version": "2.2.3", - "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.2.3.tgz", - "integrity": "sha512-KpELjfwcCDUb9PeigTs2mBJzXUPzAuP2oPcA989He8Rte0+YUAjw1JVedDhuTKPkHjSYzMN3npC9luThGYEKdg==", + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.0.tgz", + "integrity": "sha512-lY1Q/PiJGC2zOv/z391WOTD+Z02bCgsFfvxoXXf6h7kv9o+WmsmzYqrAwY63sNgOxE4xEdq0WyUnXfKeBrSvYw==", "dev": true } } @@ -6520,9 +6520,9 @@ }, "dependencies": { "array-back": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/array-back/-/array-back-4.0.1.tgz", - "integrity": "sha512-Z/JnaVEXv+A9xabHzN43FiiiWEE7gPCRXMrVmRm00tWbjZRul1iHm7ECzlyNq1p4a4ATXz+G9FJ3GqGOkOV3fg==", + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/array-back/-/array-back-4.0.2.tgz", + "integrity": "sha512-NbdMezxqf94cnNfWLL7V/im0Ub+Anbb0IoZhvzie8+4HJ4nMQuzHuy49FkGYCJK2yAloZ3meiB6AVMClbrI1vg==", "dev": true }, "chalk": { @@ -17231,9 +17231,9 @@ }, "dependencies": { "array-back": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/array-back/-/array-back-4.0.1.tgz", - "integrity": "sha512-Z/JnaVEXv+A9xabHzN43FiiiWEE7gPCRXMrVmRm00tWbjZRul1iHm7ECzlyNq1p4a4ATXz+G9FJ3GqGOkOV3fg==", + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/array-back/-/array-back-4.0.2.tgz", + "integrity": "sha512-NbdMezxqf94cnNfWLL7V/im0Ub+Anbb0IoZhvzie8+4HJ4nMQuzHuy49FkGYCJK2yAloZ3meiB6AVMClbrI1vg==", "dev": true }, "typical": { @@ -17764,9 +17764,9 @@ "dev": true }, "ts-auto-guard": { - "version": "1.0.0-alpha.21", - "resolved": "https://registry.npmjs.org/ts-auto-guard/-/ts-auto-guard-1.0.0-alpha.21.tgz", - "integrity": "sha512-oymNml3UZpuu+pofCxBX8jg27noqi0sW//EIPe+/KpO+38MOLLG9lYrruPWjzFD9BYTcPMWmCUvUbntYO2fJQg==", + "version": "1.0.0-alpha.22", + "resolved": "https://registry.npmjs.org/ts-auto-guard/-/ts-auto-guard-1.0.0-alpha.22.tgz", + "integrity": "sha512-haowmeq8mvNztyE53YwwIiGiCRQRQJzfWRGI6c8slRBfET/dF4SIY+72zK4d/Bl3UyVgNZqCvydxSJpd26P15A==", "dev": true, "requires": { "@ts-morph/common": "^0.7.3", diff --git a/package.json b/package.json index be5169f6d..f525d49db 100644 --- a/package.json +++ b/package.json @@ -68,8 +68,8 @@ "body-parser": "^1.19.0", "bytes": "^3.1.0", "camelcase": "^6.0.0", - "chai-match-pattern": "^1.2.0", "chai": "^4.2.0", + "chai-match-pattern": "^1.2.0", "chalk": "^4.1.0", "clear-module": "^4.1.1", "comlink": "^4.3.0", @@ -78,10 +78,10 @@ "coveralls": "^3.1.0", "del": "^5.1.0", "depcheck": "^1.2.0", + "eslint": "^7.6.0", "eslint-config-google": "^0.14.0", "eslint-plugin-header": "^3.0.0", "eslint-plugin-jsdoc": "^30.2.2", - "eslint": "^7.6.0", "execa": "^4.0.3", "express": "^4.17.1", "fs-extra": "^9.0.1", @@ -93,8 +93,8 @@ "html-webpack-plugin-v5": "npm:html-webpack-plugin@^5.0.0-alpha.14", "husky": "^4.2.5", "idb": "^6.0.0", - "jsdoc-baseline": "^0.1.5", "jsdoc": "^3.6.5", + "jsdoc-baseline": "^0.1.5", "lerna": "^3.22.1", "memory-fs": "^0.5.0", "minimist": "^1.2.5", @@ -104,16 +104,16 @@ "nyc": "^15.1.0", "proxyquire": "^2.1.3", "require-dir": "^1.2.0", + "rollup": "^2.43.1", "rollup-plugin-terser": "^7.0.0", "rollup-plugin-typescript2": "^0.27.2", - "rollup": "^2.43.1", "selenium-assistant": "^6.1.0", "semver": "^7.3.2", "serve-index": "^1.9.1", "service-worker-mock": "^1.9.3", "sinon": "^9.0.3", "tempy": "^0.6.0", - "ts-auto-guard": "^1.0.0-alpha.12", + "ts-auto-guard": "^1.0.0-alpha.22", "type-fest": "^0.20.2", "typescript": "^3.9.7", "upath": "^1.2.0", From 9184df044bcd2b556e8d594cde8edd69ab3ba251 Mon Sep 17 00:00:00 2001 From: Jeff Posnick Date: Tue, 8 Jun 2021 12:20:07 -0400 Subject: [PATCH 28/80] Fix dependency-check --- test/workbox-build/node/dependency-check.js | 1 + 1 file changed, 1 insertion(+) diff --git a/test/workbox-build/node/dependency-check.js b/test/workbox-build/node/dependency-check.js index 5308fb930..4b2814234 100644 --- a/test/workbox-build/node/dependency-check.js +++ b/test/workbox-build/node/dependency-check.js @@ -21,6 +21,7 @@ describe(`[workbox-build] Test Dependencies`, function() { ignoreMatches: [ '@babel/preset-env', '@babel/runtime', + 'type-fest', 'workbox-background-sync', 'workbox-broadcast-update', 'workbox-cacheable-response', From 728ca6db2204712959c869e881df5945a3020b1c Mon Sep 17 00:00:00 2001 From: Jeff Posnick Date: Tue, 8 Jun 2021 13:02:43 -0400 Subject: [PATCH 29/80] Swapped the exports --- packages/workbox-build/src/generate-sw.ts | 2 +- packages/workbox-build/src/get-manifest.ts | 2 +- packages/workbox-build/src/index.ts | 6 +++--- packages/workbox-build/src/inject-manifest.ts | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/packages/workbox-build/src/generate-sw.ts b/packages/workbox-build/src/generate-sw.ts index 44ae68b1d..1bb07b58c 100644 --- a/packages/workbox-build/src/generate-sw.ts +++ b/packages/workbox-build/src/generate-sw.ts @@ -193,7 +193,7 @@ import {writeSWUsingDefaultTemplate} from './lib/write-sw-using-default-template * * @memberof module:workbox-build */ -export default async function(config: unknown): Promise { +export async function generateSW(config: unknown): Promise { const options = validateGenerateSWOptions(config); if (options.globDirectory) { diff --git a/packages/workbox-build/src/get-manifest.ts b/packages/workbox-build/src/get-manifest.ts index c8b24a962..447e46584 100644 --- a/packages/workbox-build/src/get-manifest.ts +++ b/packages/workbox-build/src/get-manifest.ts @@ -88,7 +88,7 @@ import {validateGetManifestOptions} from './lib/validate-options'; * * @memberof module:workbox-build */ -export default async function(config: unknown): Promise { +export async function getManifest(config: unknown): Promise { const options = validateGetManifestOptions(config); return await getFileManifestEntries(options); diff --git a/packages/workbox-build/src/index.ts b/packages/workbox-build/src/index.ts index 2c6255107..cb7d32b2a 100644 --- a/packages/workbox-build/src/index.ts +++ b/packages/workbox-build/src/index.ts @@ -8,9 +8,9 @@ import {copyWorkboxLibraries} from './lib/copy-workbox-libraries'; import {getModuleURL} from './lib/cdn-utils'; -import generateSW from './generate-sw'; -import getManifest from './get-manifest'; -import injectManifest from './inject-manifest'; +import {generateSW} from './generate-sw'; +import {getManifest} from './get-manifest'; +import {injectManifest} from './inject-manifest'; /** * @module workbox-build diff --git a/packages/workbox-build/src/inject-manifest.ts b/packages/workbox-build/src/inject-manifest.ts index 10c91a43c..b094fd34c 100644 --- a/packages/workbox-build/src/inject-manifest.ts +++ b/packages/workbox-build/src/inject-manifest.ts @@ -116,7 +116,7 @@ import {validateInjectManifestOptions} from './lib/validate-options'; * * @memberof module:workbox-build */ -export default async function(config: unknown): Promise { +export async function injectManifest(config: unknown): Promise { const options = validateInjectManifestOptions(config); // Make sure we leave swSrc and swDest out of the precache manifest. From 82fbb9406db5b9080e2512cca9af2229cc1b87f3 Mon Sep 17 00:00:00 2001 From: Jeff Posnick Date: Wed, 9 Jun 2021 09:40:20 -0400 Subject: [PATCH 30/80] JSON Schema + ajv --- gulp-tasks/build-node-packages.js | 29 +- gulp-tasks/build-packages.js | 6 +- package-lock.json | 480 ++++-------- package.json | 2 +- packages/workbox-build/package-lock.json | 34 + packages/workbox-build/package.json | 1 + .../src/lib/transform-manifest.ts | 2 +- .../workbox-build/src/lib/validate-options.ts | 105 ++- .../src/schema/GenerateSWOptions.json | 1 + .../src/schema/GetManifestOptions.json | 1 + .../src/schema/InjectManifestOptions.json | 1 + .../src/schema/WebpackGenerateSWOptions.json | 1 + .../schema/WebpackInjectManifestOptions.json | 1 + packages/workbox-build/src/types.guard.ts | 725 ------------------ packages/workbox-build/src/types.ts | 21 +- packages/workbox-build/tsconfig.json | 10 +- tsconfig.json | 3 + 17 files changed, 304 insertions(+), 1119 deletions(-) create mode 100644 packages/workbox-build/src/schema/GenerateSWOptions.json create mode 100644 packages/workbox-build/src/schema/GetManifestOptions.json create mode 100644 packages/workbox-build/src/schema/InjectManifestOptions.json create mode 100644 packages/workbox-build/src/schema/WebpackGenerateSWOptions.json create mode 100644 packages/workbox-build/src/schema/WebpackInjectManifestOptions.json delete mode 100644 packages/workbox-build/src/types.guard.ts diff --git a/gulp-tasks/build-node-packages.js b/gulp-tasks/build-node-packages.js index 1352a3072..714baf83c 100644 --- a/gulp-tasks/build-node-packages.js +++ b/gulp-tasks/build-node-packages.js @@ -9,6 +9,7 @@ const {parallel} = require('gulp'); const execa = require('execa'); const fse = require('fs-extra'); +const TJS = require('typescript-json-schema'); const upath = require('upath'); const constants = require('./utils/constants'); @@ -29,13 +30,29 @@ async function buildNodePackage(packagePath) { ], {preferLocal: true}); } +async function generateWorkboxBuildJSONSchema(packagePath) { + const program = TJS.programFromConfig(upath.join(packagePath, + 'tsconfig.json')); + const generator = TJS.buildGenerator(program); + const optionTypes = [ + 'GenerateSWOptions', + 'GetManifestOptions', + 'InjectManifestOptions', + 'WebpackGenerateSWOptions', + 'WebpackInjectManifestOptions' + ]; + for (const optionType of optionTypes) { + const schema = generator.getSchemaForSymbol(optionType); + await fse.writeJSON(upath.join(packagePath, 'src', 'schema', + `${optionType}.json`), schema); + } +} + async function buildNodeTSPackage(packagePath) { - const typesPath = upath.join(packagePath, 'src', 'types.ts'); - if (fse.existsSync(typesPath)) { - await execa('ts-auto-guard', [typesPath], { - cwd: packagePath, - preferLocal: true, - }); + // Hardcode special logic for workbox-build, as it's the only package + // that requires JSON schema generation. + if (packagePath.endsWith('workbox-build')) { + await generateWorkboxBuildJSONSchema(packagePath); } await execa('tsc', ['-b', packagePath], {preferLocal: true}); diff --git a/gulp-tasks/build-packages.js b/gulp-tasks/build-packages.js index bff44f9da..f9e1c52c1 100644 --- a/gulp-tasks/build-packages.js +++ b/gulp-tasks/build-packages.js @@ -59,12 +59,12 @@ module.exports = { build_packages_clean: cleanSequence(), build_packages: series( cleanSequence(), + // This needs to be a series, not in parallel, so that there isn't a + // race condition with the terser nameCache. + series(build_sw_packages, build_window_packages), parallel( build_node_packages, build_node_ts_packages, - // This needs to be a series, not in parallel, so that there isn't a - // race condition with the terser nameCache. - series(build_sw_packages, build_window_packages), ), ), }; diff --git a/package-lock.json b/package-lock.json index c6d3b1862..2f6167d46 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1096,16 +1096,6 @@ "to-fast-properties": "^2.0.0" } }, - "@dsherret/to-absolute-glob": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/@dsherret/to-absolute-glob/-/to-absolute-glob-2.0.2.tgz", - "integrity": "sha1-H2R13IvZdM6gei2vOGSzF7HdMyw=", - "dev": true, - "requires": { - "is-absolute": "^1.0.0", - "is-negated-glob": "^1.0.0" - } - }, "@eslint/eslintrc": { "version": "0.1.3", "resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-0.1.3.tgz", @@ -4188,115 +4178,6 @@ "integrity": "sha512-RbzJvlNzmRq5c3O09UipeuXno4tA1FE6ikOjxZK0tuxVv3412l64l5t1W5pj4+rJq9vpkm/kwiR07aZXnsKPxw==", "dev": true }, - "@ts-morph/common": { - "version": "0.7.5", - "resolved": "https://registry.npmjs.org/@ts-morph/common/-/common-0.7.5.tgz", - "integrity": "sha512-nlFunSKAsFWI0Ol/uPxJcpVqXxTGNuaWXTmoQDhcnwj1UM4QmBSUVWzqoQ0OzUlqo4sV1gobfFBkMHuZVemMAQ==", - "dev": true, - "requires": { - "@dsherret/to-absolute-glob": "^2.0.2", - "fast-glob": "^3.2.5", - "is-negated-glob": "^1.0.0", - "mkdirp": "^1.0.4", - "multimatch": "^5.0.0", - "typescript": "~4.1.3" - }, - "dependencies": { - "braces": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/braces/-/braces-3.0.2.tgz", - "integrity": "sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A==", - "dev": true, - "requires": { - "fill-range": "^7.0.1" - } - }, - "fast-glob": { - "version": "3.2.5", - "resolved": "https://registry.npmjs.org/fast-glob/-/fast-glob-3.2.5.tgz", - "integrity": "sha512-2DtFcgT68wiTTiwZ2hNdJfcHNke9XOfnwmBRWXhmeKM8rF0TGwmC/Qto3S7RoZKp5cilZbxzO5iTNTQsJ+EeDg==", - "dev": true, - "requires": { - "@nodelib/fs.stat": "^2.0.2", - "@nodelib/fs.walk": "^1.2.3", - "glob-parent": "^5.1.0", - "merge2": "^1.3.0", - "micromatch": "^4.0.2", - "picomatch": "^2.2.1" - } - }, - "fill-range": { - "version": "7.0.1", - "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.0.1.tgz", - "integrity": "sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ==", - "dev": true, - "requires": { - "to-regex-range": "^5.0.1" - } - }, - "glob-parent": { - "version": "5.1.2", - "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.2.tgz", - "integrity": "sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==", - "dev": true, - "requires": { - "is-glob": "^4.0.1" - } - }, - "is-number": { - "version": "7.0.0", - "resolved": "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz", - "integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==", - "dev": true - }, - "micromatch": { - "version": "4.0.4", - "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.4.tgz", - "integrity": "sha512-pRmzw/XUcwXGpD9aI9q/0XOwLNygjETJ8y0ao0wdqprrzDa4YnxLcz7fQRZr8voh8V10kGhABbNcHVk5wHgWwg==", - "dev": true, - "requires": { - "braces": "^3.0.1", - "picomatch": "^2.2.3" - }, - "dependencies": { - "picomatch": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.0.tgz", - "integrity": "sha512-lY1Q/PiJGC2zOv/z391WOTD+Z02bCgsFfvxoXXf6h7kv9o+WmsmzYqrAwY63sNgOxE4xEdq0WyUnXfKeBrSvYw==", - "dev": true - } - } - }, - "multimatch": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/multimatch/-/multimatch-5.0.0.tgz", - "integrity": "sha512-ypMKuglUrZUD99Tk2bUQ+xNQj43lPEfAeX2o9cTteAmShXy2VHDJpuwu1o0xqoKCt9jLVAvwyFKdLTPXKAfJyA==", - "dev": true, - "requires": { - "@types/minimatch": "^3.0.3", - "array-differ": "^3.0.0", - "array-union": "^2.1.0", - "arrify": "^2.0.1", - "minimatch": "^3.0.4" - } - }, - "to-regex-range": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz", - "integrity": "sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==", - "dev": true, - "requires": { - "is-number": "^7.0.0" - } - }, - "typescript": { - "version": "4.1.5", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.1.5.tgz", - "integrity": "sha512-6OSu9PTIzmn9TCDiovULTnET6BgXtDYL4Gg4szY+cGsc3JP1dQL8qvE8kShTRx1NIw4Q9IBHlwODjkjWEtMUyA==", - "dev": true - } - } - }, "@types/anymatch": { "version": "1.3.1", "resolved": "https://registry.npmjs.org/@types/anymatch/-/anymatch-1.3.1.tgz", @@ -4350,18 +4231,6 @@ "@babel/types": "^7.3.0" } }, - "@types/command-line-args": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/@types/command-line-args/-/command-line-args-5.0.0.tgz", - "integrity": "sha512-4eOPXyn5DmP64MCMF8ePDvdlvlzt2a+F8ZaVjqmh2yFCpGjc1kI3kGnCFYX9SCsGTjQcWIyVZ86IHCEyjy/MNg==", - "dev": true - }, - "@types/command-line-usage": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/@types/command-line-usage/-/command-line-usage-5.0.1.tgz", - "integrity": "sha512-/xUgezxxYePeXhg5S04hUjxG9JZi+rJTs1+4NwpYPfSaS7BeDa6tVJkH6lN9Cb6rl8d24Fi2uX0s0Ngg2JT6gg==", - "dev": true - }, "@types/common-tags": { "version": "1.8.0", "resolved": "https://registry.npmjs.org/@types/common-tags/-/common-tags-1.8.0.tgz", @@ -4488,18 +4357,6 @@ "integrity": "sha512-ryxTolaNg1l809rknW9q9T7wG8QHcjtZX6syJx7kpOLY2qev75VzC9HMVimUxlA1YzjpGsDI29yLjHBotqhUhA==", "dev": true }, - "@types/strip-bom": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/@types/strip-bom/-/strip-bom-3.0.0.tgz", - "integrity": "sha1-FKjsOVbC6B7bdSB5CuzyHCkK69I=", - "dev": true - }, - "@types/strip-json-comments": { - "version": "0.0.30", - "resolved": "https://registry.npmjs.org/@types/strip-json-comments/-/strip-json-comments-0.0.30.tgz", - "integrity": "sha512-7NQmHra/JILCd1QqpSzl8+mJRc8ZHz3uDm8YV1Ks9IhK0epEiTw8aIErbvH9PI+6XbqhyIQy3462nEsn7UVzjQ==", - "dev": true - }, "@types/tapable": { "version": "1.0.7", "resolved": "https://registry.npmjs.org/@types/tapable/-/tapable-1.0.7.tgz", @@ -5092,6 +4949,12 @@ "readable-stream": "^2.0.6" } }, + "arg": { + "version": "4.1.3", + "resolved": "https://registry.npmjs.org/arg/-/arg-4.1.3.tgz", + "integrity": "sha512-58S9QDqG0Xx27YwPSt9fJxivjYl432YCwfDMfZ+71RAqUrZef7LrKQZ3LHLOwCS4FLNBplP533Zx895SeOCHvA==", + "dev": true + }, "argparse": { "version": "1.0.10", "resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz", @@ -5137,12 +5000,6 @@ "integrity": "sha1-45sJrqne+Gao8gbiiK9jkZuuOcQ=", "dev": true }, - "array-back": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/array-back/-/array-back-3.1.0.tgz", - "integrity": "sha512-TkuxA4UCOvxuDK6NZYXCalszEzj+TLszyASooky+i742l9TqsOdYCMJJupxRic61hwquNtppB3hgcuq9SVSH1Q==", - "dev": true - }, "array-differ": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/array-differ/-/array-differ-3.0.0.tgz", @@ -6399,12 +6256,6 @@ "readable-stream": "^2.3.5" } }, - "code-block-writer": { - "version": "10.1.1", - "resolved": "https://registry.npmjs.org/code-block-writer/-/code-block-writer-10.1.1.tgz", - "integrity": "sha512-67ueh2IRGst/51p0n6FvPrnRjAGHY5F8xdjkgrYE7DDzpJe6qA07RYQ9VcoUeo5ATOjSOiWpSL3SWBRRbempMw==", - "dev": true - }, "code-point-at": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/code-point-at/-/code-point-at-1.1.0.tgz", @@ -6495,55 +6346,6 @@ "integrity": "sha512-mu4KKKNuW8TvkfpW/H88HBPeILubBS6T94BdD1VWBXNXfiyqVtwUCVNO1GeNOBTsIswzsMjWlycYr+77F5b84g==", "dev": true }, - "command-line-args": { - "version": "5.1.1", - "resolved": "https://registry.npmjs.org/command-line-args/-/command-line-args-5.1.1.tgz", - "integrity": "sha512-hL/eG8lrll1Qy1ezvkant+trihbGnaKaeEjj6Scyr3DN+RC7iQ5Rz84IeLERfAWDGo0HBSNAakczwgCilDXnWg==", - "dev": true, - "requires": { - "array-back": "^3.0.1", - "find-replace": "^3.0.0", - "lodash.camelcase": "^4.3.0", - "typical": "^4.0.0" - } - }, - "command-line-usage": { - "version": "6.1.1", - "resolved": "https://registry.npmjs.org/command-line-usage/-/command-line-usage-6.1.1.tgz", - "integrity": "sha512-F59pEuAR9o1SF/bD0dQBDluhpT4jJQNWUHEuVBqpDmCUo6gPjCi+m9fCWnWZVR/oG6cMTUms4h+3NPl74wGXvA==", - "dev": true, - "requires": { - "array-back": "^4.0.1", - "chalk": "^2.4.2", - "table-layout": "^1.0.1", - "typical": "^5.2.0" - }, - "dependencies": { - "array-back": { - "version": "4.0.2", - "resolved": "https://registry.npmjs.org/array-back/-/array-back-4.0.2.tgz", - "integrity": "sha512-NbdMezxqf94cnNfWLL7V/im0Ub+Anbb0IoZhvzie8+4HJ4nMQuzHuy49FkGYCJK2yAloZ3meiB6AVMClbrI1vg==", - "dev": true - }, - "chalk": { - "version": "2.4.2", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz", - "integrity": "sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==", - "dev": true, - "requires": { - "ansi-styles": "^3.2.1", - "escape-string-regexp": "^1.0.5", - "supports-color": "^5.3.0" - } - }, - "typical": { - "version": "5.2.0", - "resolved": "https://registry.npmjs.org/typical/-/typical-5.2.0.tgz", - "integrity": "sha512-dvdQgNDNJo+8B2uBQoqdb11eUCE1JQXhvjC/CZtgvZseVd5TYMXnq0+vuUemXbd/Se29cTaUuPX3YIc2xgbvIg==", - "dev": true - } - } - }, "commander": { "version": "4.1.1", "resolved": "https://registry.npmjs.org/commander/-/commander-4.1.1.tgz", @@ -7356,6 +7158,12 @@ "sha.js": "^2.4.8" } }, + "create-require": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/create-require/-/create-require-1.1.1.tgz", + "integrity": "sha512-dcKFX3jn0MpIaXjisoRvexIJVEKzaq7z2rZKxf+MSr9TkdmHmsU4m2lcLojrj/FHl8mk5VxMmYA+ftRkP/3oKQ==", + "dev": true + }, "cross-spawn": { "version": "6.0.5", "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-6.0.5.tgz", @@ -9223,15 +9031,6 @@ } } }, - "find-replace": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/find-replace/-/find-replace-3.0.0.tgz", - "integrity": "sha512-6Tb2myMioCAgv5kfvP5/PkZZ/ntTpVK39fHY7WkWBgvbeE+VHd/tZuZ4mrC+bxh4cfOZeYKVPaJIZtZXV7GNCQ==", - "dev": true, - "requires": { - "array-back": "^3.0.1" - } - }, "find-up": { "version": "4.1.0", "resolved": "https://registry.npmjs.org/find-up/-/find-up-4.1.0.tgz", @@ -12260,6 +12059,15 @@ "integrity": "sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg==", "dev": true }, + "json-stable-stringify": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/json-stable-stringify/-/json-stable-stringify-1.0.1.tgz", + "integrity": "sha1-mnWdOcXy/1A/1TAGRu1EX4jE+a8=", + "dev": true, + "requires": { + "jsonify": "~0.0.0" + } + }, "json-stable-stringify-without-jsonify": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/json-stable-stringify-without-jsonify/-/json-stable-stringify-without-jsonify-1.0.1.tgz", @@ -12291,6 +12099,12 @@ "universalify": "^1.0.0" } }, + "jsonify": { + "version": "0.0.0", + "resolved": "https://registry.npmjs.org/jsonify/-/jsonify-0.0.0.tgz", + "integrity": "sha1-LHS27kHZPKUbe1qu6PUDYx0lKnM=", + "dev": true + }, "jsonparse": { "version": "1.3.1", "resolved": "https://registry.npmjs.org/jsonparse/-/jsonparse-1.3.1.tgz", @@ -12577,12 +12391,6 @@ "integrity": "sha1-DM8tiRZq8Ds2Y8eWU4t1rG4RTZ0=", "dev": true }, - "lodash.camelcase": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/lodash.camelcase/-/lodash.camelcase-4.3.0.tgz", - "integrity": "sha1-soqmKIorn8ZRA1x3EfZathkDMaY=", - "dev": true - }, "lodash.clonedeep": { "version": "4.5.0", "resolved": "https://registry.npmjs.org/lodash.clonedeep/-/lodash.clonedeep-4.5.0.tgz", @@ -12728,6 +12536,12 @@ } } }, + "make-error": { + "version": "1.3.6", + "resolved": "https://registry.npmjs.org/make-error/-/make-error-1.3.6.tgz", + "integrity": "sha512-s8UhlNe7vPKomQhC1qFelMokr/Sc3AgNbso3n74mVPA5LTZwkB9NlXf4XPamLxJE8h0gh73rM94xvwRT2CVInw==", + "dev": true + }, "make-fetch-happen": { "version": "5.0.2", "resolved": "https://registry.npmjs.org/make-fetch-happen/-/make-fetch-happen-5.0.2.tgz", @@ -15533,12 +15347,6 @@ "strip-indent": "^3.0.0" } }, - "reduce-flatten": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/reduce-flatten/-/reduce-flatten-2.0.0.tgz", - "integrity": "sha512-EJ4UNY/U1t2P/2k6oqotuX2Cc3T6nxJwsM0N0asT7dhrtH1ltUxDn4NalSYmPE2rCkVpcf/X6R0wDwcFpzhd4w==", - "dev": true - }, "regenerate": { "version": "1.4.1", "resolved": "https://registry.npmjs.org/regenerate/-/regenerate-1.4.1.tgz", @@ -17218,32 +17026,6 @@ } } }, - "table-layout": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/table-layout/-/table-layout-1.0.2.tgz", - "integrity": "sha512-qd/R7n5rQTRFi+Zf2sk5XVVd9UQl6ZkduPFC3S7WEGJAmetDTjY3qPN50eSKzwuzEyQKy5TN2TiZdkIjos2L6A==", - "dev": true, - "requires": { - "array-back": "^4.0.1", - "deep-extend": "~0.6.0", - "typical": "^5.2.0", - "wordwrapjs": "^4.0.0" - }, - "dependencies": { - "array-back": { - "version": "4.0.2", - "resolved": "https://registry.npmjs.org/array-back/-/array-back-4.0.2.tgz", - "integrity": "sha512-NbdMezxqf94cnNfWLL7V/im0Ub+Anbb0IoZhvzie8+4HJ4nMQuzHuy49FkGYCJK2yAloZ3meiB6AVMClbrI1vg==", - "dev": true - }, - "typical": { - "version": "5.2.0", - "resolved": "https://registry.npmjs.org/typical/-/typical-5.2.0.tgz", - "integrity": "sha512-dvdQgNDNJo+8B2uBQoqdb11eUCE1JQXhvjC/CZtgvZseVd5TYMXnq0+vuUemXbd/Se29cTaUuPX3YIc2xgbvIg==", - "dev": true - } - } - }, "taffydb": { "version": "2.6.2", "resolved": "https://registry.npmjs.org/taffydb/-/taffydb-2.6.2.tgz", @@ -17763,58 +17545,18 @@ "integrity": "sha1-n5up2e+odkw4dpi8v+sshI8RrbM=", "dev": true }, - "ts-auto-guard": { - "version": "1.0.0-alpha.22", - "resolved": "https://registry.npmjs.org/ts-auto-guard/-/ts-auto-guard-1.0.0-alpha.22.tgz", - "integrity": "sha512-haowmeq8mvNztyE53YwwIiGiCRQRQJzfWRGI6c8slRBfET/dF4SIY+72zK4d/Bl3UyVgNZqCvydxSJpd26P15A==", + "ts-node": { + "version": "9.1.1", + "resolved": "https://registry.npmjs.org/ts-node/-/ts-node-9.1.1.tgz", + "integrity": "sha512-hPlt7ZACERQGf03M253ytLY3dHbGNGrAq9qIHWUY9XHYl1z7wYngSr3OQ5xmui8o2AaxsONxIzjafLUiWBo1Fg==", "dev": true, "requires": { - "@ts-morph/common": "^0.7.3", - "@types/command-line-args": "^5.0.0", - "@types/command-line-usage": "^5.0.1", - "@types/lodash": "^4.14.160", - "command-line-args": "^5.1.1", - "command-line-usage": "^6.1.0", - "lodash": "^4.17.20", - "ts-morph": "^9.1.0", - "tsconfig": "^7.0.0" - } - }, - "ts-morph": { - "version": "9.1.0", - "resolved": "https://registry.npmjs.org/ts-morph/-/ts-morph-9.1.0.tgz", - "integrity": "sha512-sei4u651MBenr27sD6qLDXN3gZ4thiX71E3qV7SuVtDas0uvK2LtgZkIYUf9DKm/fLJ6AB/+yhRJ1vpEBJgy7Q==", - "dev": true, - "requires": { - "@dsherret/to-absolute-glob": "^2.0.2", - "@ts-morph/common": "~0.7.0", - "code-block-writer": "^10.1.1" - } - }, - "tsconfig": { - "version": "7.0.0", - "resolved": "https://registry.npmjs.org/tsconfig/-/tsconfig-7.0.0.tgz", - "integrity": "sha512-vZXmzPrL+EmC4T/4rVlT2jNVMWCi/O4DIiSj3UHg1OE5kCKbk4mfrXc6dZksLgRM/TZlKnousKH9bbTazUWRRw==", - "dev": true, - "requires": { - "@types/strip-bom": "^3.0.0", - "@types/strip-json-comments": "0.0.30", - "strip-bom": "^3.0.0", - "strip-json-comments": "^2.0.0" - }, - "dependencies": { - "strip-bom": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/strip-bom/-/strip-bom-3.0.0.tgz", - "integrity": "sha1-IzTBjpx1n3vdVv3vfprj1YjmjtM=", - "dev": true - }, - "strip-json-comments": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-2.0.1.tgz", - "integrity": "sha1-PFMZQukIwml8DsNEhYwobHygpgo=", - "dev": true - } + "arg": "^4.1.0", + "create-require": "^1.1.0", + "diff": "^4.0.1", + "make-error": "^1.1.1", + "source-map-support": "^0.5.17", + "yn": "3.1.1" } }, "tslib": { @@ -17911,11 +17653,113 @@ "integrity": "sha512-BLbiRkiBzAwsjut4x/dsibSTB6yWpwT5qWmC2OfuCg3GgVQCSgMs4vEctYPhsaGtd0AeuuHMkjZ2h2WG8MSzRw==", "dev": true }, - "typical": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/typical/-/typical-4.0.0.tgz", - "integrity": "sha512-VAH4IvQ7BDFYglMd7BPRDfLgxZZX4O4TFcRDA6EN5X7erNJJq+McIEp8np9aVtxrCJ6qx4GTYVfOWNjcqwZgRw==", - "dev": true + "typescript-json-schema": { + "version": "0.50.1", + "resolved": "https://registry.npmjs.org/typescript-json-schema/-/typescript-json-schema-0.50.1.tgz", + "integrity": "sha512-GCof/SDoiTDl0qzPonNEV4CHyCsZEIIf+mZtlrjoD8vURCcEzEfa2deRuxYid8Znp/e27eDR7Cjg8jgGrimBCA==", + "dev": true, + "requires": { + "@types/json-schema": "^7.0.7", + "@types/node": "^14.14.33", + "glob": "^7.1.6", + "json-stable-stringify": "^1.0.1", + "ts-node": "^9.1.1", + "typescript": "~4.2.3", + "yargs": "^16.2.0" + }, + "dependencies": { + "@types/json-schema": { + "version": "7.0.7", + "resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.7.tgz", + "integrity": "sha512-cxWFQVseBm6O9Gbw1IWb8r6OS4OhSt3hPZLkFApLjM8TEXROBuQGLAH2i2gZpcXdLBIrpXuTDhH7Vbm1iXmNGA==", + "dev": true + }, + "@types/node": { + "version": "14.17.3", + "resolved": "https://registry.npmjs.org/@types/node/-/node-14.17.3.tgz", + "integrity": "sha512-e6ZowgGJmTuXa3GyaPbTGxX17tnThl2aSSizrFthQ7m9uLGZBXiGhgE55cjRZTF5kjZvYn9EOPOMljdjwbflxw==", + "dev": true + }, + "ansi-styles": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", + "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", + "dev": true, + "requires": { + "color-convert": "^2.0.1" + } + }, + "cliui": { + "version": "7.0.4", + "resolved": "https://registry.npmjs.org/cliui/-/cliui-7.0.4.tgz", + "integrity": "sha512-OcRE68cOsVMXp1Yvonl/fzkQOyjLSu/8bhPDfQt0e0/Eb283TKP20Fs2MqoPsr9SwA595rRCA+QMzYc9nBP+JQ==", + "dev": true, + "requires": { + "string-width": "^4.2.0", + "strip-ansi": "^6.0.0", + "wrap-ansi": "^7.0.0" + } + }, + "color-convert": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", + "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", + "dev": true, + "requires": { + "color-name": "~1.1.4" + } + }, + "color-name": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", + "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", + "dev": true + }, + "typescript": { + "version": "4.2.4", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.2.4.tgz", + "integrity": "sha512-V+evlYHZnQkaz8TRBuxTA92yZBPotr5H+WhQ7bD3hZUndx5tGOa1fuCgeSjxAzM1RiN5IzvadIXTVefuuwZCRg==", + "dev": true + }, + "wrap-ansi": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-7.0.0.tgz", + "integrity": "sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==", + "dev": true, + "requires": { + "ansi-styles": "^4.0.0", + "string-width": "^4.1.0", + "strip-ansi": "^6.0.0" + } + }, + "y18n": { + "version": "5.0.8", + "resolved": "https://registry.npmjs.org/y18n/-/y18n-5.0.8.tgz", + "integrity": "sha512-0pfFzegeDWJHJIAmTLRP2DwHjdF5s7jo9tuztdQxAhINCdvS+3nGINqPd00AphqJR/0LhANUS6/+7SCb98YOfA==", + "dev": true + }, + "yargs": { + "version": "16.2.0", + "resolved": "https://registry.npmjs.org/yargs/-/yargs-16.2.0.tgz", + "integrity": "sha512-D1mvvtDG0L5ft/jGWkLpG1+m0eQxOfaBvTNELraWj22wSVUMWxZUvYgJYcKh6jGGIkJFhH4IZPQhR4TKpc8mBw==", + "dev": true, + "requires": { + "cliui": "^7.0.2", + "escalade": "^3.1.1", + "get-caller-file": "^2.0.5", + "require-directory": "^2.1.1", + "string-width": "^4.2.0", + "y18n": "^5.0.5", + "yargs-parser": "^20.2.2" + } + }, + "yargs-parser": { + "version": "20.2.7", + "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-20.2.7.tgz", + "integrity": "sha512-FiNkvbeHzB/syOjIUxFDCnhSfzAL8R5vs40MgLFBorXACCOAEaWu0gRZl14vG8MR9AOJIZbmkjhusqBYZ3HTHw==", + "dev": true + } + } }, "uc.micro": { "version": "1.0.6", @@ -18993,24 +18837,6 @@ "integrity": "sha1-J1hIEIkUVqQXHI0CJkQa3pDLyus=", "dev": true }, - "wordwrapjs": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/wordwrapjs/-/wordwrapjs-4.0.1.tgz", - "integrity": "sha512-kKlNACbvHrkpIw6oPeYDSmdCTu2hdMHoyXLTcUKala++lx5Y+wjJ/e474Jqv5abnVmwxw08DiTuHmw69lJGksA==", - "dev": true, - "requires": { - "reduce-flatten": "^2.0.0", - "typical": "^5.2.0" - }, - "dependencies": { - "typical": { - "version": "5.2.0", - "resolved": "https://registry.npmjs.org/typical/-/typical-5.2.0.tgz", - "integrity": "sha512-dvdQgNDNJo+8B2uBQoqdb11eUCE1JQXhvjC/CZtgvZseVd5TYMXnq0+vuUemXbd/Se29cTaUuPX3YIc2xgbvIg==", - "dev": true - } - } - }, "worker-farm": { "version": "1.7.0", "resolved": "https://registry.npmjs.org/worker-farm/-/worker-farm-1.7.0.tgz", @@ -19447,6 +19273,12 @@ "fd-slicer": "~1.1.0" } }, + "yn": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/yn/-/yn-3.1.1.tgz", + "integrity": "sha512-Ux4ygGWsu2c7isFWe8Yu1YluJmqVhxqK2cLXNQA5AcC3QfbGNpM7fu0Y8b/z16pXLnFxZYvWhd3fhBY9DLmC6Q==", + "dev": true + }, "yocto-queue": { "version": "0.1.0", "resolved": "https://registry.npmjs.org/yocto-queue/-/yocto-queue-0.1.0.tgz", diff --git a/package.json b/package.json index f525d49db..c4ab7bfbe 100644 --- a/package.json +++ b/package.json @@ -113,9 +113,9 @@ "service-worker-mock": "^1.9.3", "sinon": "^9.0.3", "tempy": "^0.6.0", - "ts-auto-guard": "^1.0.0-alpha.22", "type-fest": "^0.20.2", "typescript": "^3.9.7", + "typescript-json-schema": "^0.50.1", "upath": "^1.2.0", "webpack-v4": "npm:webpack@^4.44.2", "webpack-v5": "npm:webpack@^5.9.0", diff --git a/packages/workbox-build/package-lock.json b/packages/workbox-build/package-lock.json index cb3596e86..7c8e53355 100644 --- a/packages/workbox-build/package-lock.json +++ b/packages/workbox-build/package-lock.json @@ -1055,6 +1055,17 @@ "@types/node": "*" } }, + "ajv": { + "version": "8.6.0", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-8.6.0.tgz", + "integrity": "sha512-cnUG4NSBiM4YFBxgZIj/In3/6KX+rQ2l2YPRVcvAMQGWEPKuXoPIhxzwqh31jA3IPbI4qEOp/5ILI4ynioXsGQ==", + "requires": { + "fast-deep-equal": "^3.1.1", + "json-schema-traverse": "^1.0.0", + "require-from-string": "^2.0.2", + "uri-js": "^4.2.2" + } + }, "ansi-styles": { "version": "3.2.1", "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz", @@ -1234,6 +1245,11 @@ "resolved": "https://registry.npmjs.org/esutils/-/esutils-2.0.3.tgz", "integrity": "sha512-kVscqXk4OCp68SZ0dkgEKVi6/8ij300KBWTJq32P/dYeWTSwK41WyTxalN1eRmA5Z9UU/LX9D7FWSmV9SAYx6g==" }, + "fast-deep-equal": { + "version": "3.1.3", + "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz", + "integrity": "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==" + }, "fast-json-stable-stringify": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/fast-json-stable-stringify/-/fast-json-stable-stringify-2.1.0.tgz", @@ -1402,6 +1418,11 @@ "resolved": "https://registry.npmjs.org/jsesc/-/jsesc-2.5.2.tgz", "integrity": "sha512-OYu7XEzjkCQ3C5Ps3QIZsQfNpqoJyZZA99wd9aWd05NCtC5pWOkShK2mkL6HXQR6/Cy2lbNdPlZBpuQHXE63gA==" }, + "json-schema-traverse": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-1.0.0.tgz", + "integrity": "sha512-NM8/P9n3XjXhIZn1lLhkFaACTOURQXjWhV4BA/RnOv8xvgqtqpAX9IO4mRQxSx1Rlo4tqzeqb0sOlruaOy3dug==" + }, "json5": { "version": "2.1.3", "resolved": "https://registry.npmjs.org/json5/-/json5-2.1.3.tgz", @@ -1602,6 +1623,11 @@ } } }, + "require-from-string": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/require-from-string/-/require-from-string-2.0.2.tgz", + "integrity": "sha512-Xf0nWe6RseziFMu+Ap9biiUbmplq6S9/p+7w7YXP/JBHhrUDDUhwa+vANyubuqfZWTveU//DYVGsDG7RKL/vEw==" + }, "resolve": { "version": "1.17.0", "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.17.0.tgz", @@ -1797,6 +1823,14 @@ "resolved": "https://registry.npmjs.org/upath/-/upath-1.2.0.tgz", "integrity": "sha512-aZwGpamFO61g3OlfT7OQCHqhGnW43ieH9WZeP7QxN/G/jS4jfqUkZxoryvJgVPEcrl5NL/ggHsSmLMHuH64Lhg==" }, + "uri-js": { + "version": "4.4.1", + "resolved": "https://registry.npmjs.org/uri-js/-/uri-js-4.4.1.tgz", + "integrity": "sha512-7rKUyy33Q1yc98pQ1DAmLtwX109F7TIfWlW1Ydo8Wl1ii1SeHieeh0HHfPeL2fMXK6z0s8ecKs9frCuLJvndBg==", + "requires": { + "punycode": "^2.1.0" + } + }, "webidl-conversions": { "version": "4.0.2", "resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-4.0.2.tgz", diff --git a/packages/workbox-build/package.json b/packages/workbox-build/package.json index e959f760e..2e0624555 100644 --- a/packages/workbox-build/package.json +++ b/packages/workbox-build/package.json @@ -28,6 +28,7 @@ "@rollup/plugin-node-resolve": "^11.2.1", "@rollup/plugin-replace": "^2.4.1", "@surma/rollup-plugin-off-main-thread": "^1.4.1", + "ajv": "^8.6.0", "common-tags": "^1.8.0", "fast-json-stable-stringify": "^2.1.0", "fs-extra": "^9.0.1", diff --git a/packages/workbox-build/src/lib/transform-manifest.ts b/packages/workbox-build/src/lib/transform-manifest.ts index 497f1a35b..5800717d2 100644 --- a/packages/workbox-build/src/lib/transform-manifest.ts +++ b/packages/workbox-build/src/lib/transform-manifest.ts @@ -132,7 +132,7 @@ export async function transformManifest({ // properties from each entry. const count = transformedManifest.length; let size = 0; - for (const manifestEntry of transformedManifest) { + for (const manifestEntry of transformedManifest as Array) { size += manifestEntry.size || 0; delete manifestEntry.size; } diff --git a/packages/workbox-build/src/lib/validate-options.ts b/packages/workbox-build/src/lib/validate-options.ts index 9e28ab83f..5af8d4191 100644 --- a/packages/workbox-build/src/lib/validate-options.ts +++ b/packages/workbox-build/src/lib/validate-options.ts @@ -6,59 +6,80 @@ https://opensource.org/licenses/MIT. */ -import {isGenerateSWOptions, isGetManifestOptions, isInjectManifestOptions} from '../types.guard'; +import Ajv, {DefinedError, JSONSchemaType} from 'ajv'; + import {GenerateSWOptions, GetManifestOptions, InjectManifestOptions} from '../types'; -const defaults = { - babelPresetEnvTargets: ['chrome >= 56'], - cleanupOutdatedCaches: false, - clientsClaim: false, - compileSrc: true, - disableDevLogs: false, - exclude: [ - /\.map$/, - /^manifest.*\.js$/, - ], - globFollow: true, - globIgnores: ['**/node_modules/**/*'], - globPatterns: ['**/*.{js,css,html}'], - globStrict: true, - injectionPoint: 'self.__WB_MANIFEST', - inlineWorkboxRuntime: false, - maximumFileSizeToCacheInBytes: 2 * 1024 * 1024, - mode: 'production', - navigateFallback: null, - navigationPreload: false, - offlineGoogleAnalytics: false, - purgeOnQuotaError: true, - skipWaiting: false, - sourcemap: true, - swDestFilename: 'service-worker.js', -}; +const ajv = new Ajv(); + +// const defaults = { +// babelPresetEnvTargets: ['chrome >= 56'], +// cleanupOutdatedCaches: false, +// clientsClaim: false, +// compileSrc: true, +// disableDevLogs: false, +// exclude: [ +// /\.map$/, +// /^manifest.*\.js$/, +// ], +// globFollow: true, +// globIgnores: ['**/node_modules/**/*'], +// globPatterns: ['**/*.{js,css,html}'], +// globStrict: true, +// injectionPoint: 'self.__WB_MANIFEST', +// inlineWorkboxRuntime: false, +// maximumFileSizeToCacheInBytes: 2 * 1024 * 1024, +// mode: 'production', +// navigateFallback: null, +// navigationPreload: false, +// offlineGoogleAnalytics: false, +// purgeOnQuotaError: true, +// skipWaiting: false, +// sourcemap: true, +// swDestFilename: 'service-worker.js', +// }; export function validateGenerateSWOptions(input: unknown): GenerateSWOptions { - const optionsWithDefaults = Object.assign({}, defaults, input); - if(isGenerateSWOptions(optionsWithDefaults)) { - return optionsWithDefaults; - } else { - throw new Error('Validation failed.'); + const jsonSchema: JSONSchemaType = + require(`../schema/GenerateSWOptions.json`); + const validate = ajv.compile(jsonSchema); + if (validate(input)) { + return input; + } + + const errorStrings = []; + for (const err of validate.errors as DefinedError[]) { + errorStrings.push(err.message); } + throw new Error(`Incorrect generateSW options:\n\t${errorStrings.join('\n\t')}`); } export function validateGetManifestOptions(input: unknown): GetManifestOptions { - const optionsWithDefaults = Object.assign({}, defaults, input); - if(isGetManifestOptions(optionsWithDefaults)) { - return optionsWithDefaults; - } else { - throw new Error('Validation failed.'); + const jsonSchema: JSONSchemaType = + require(`../schema/GetManifestOptions.json`); + const validate = ajv.compile(jsonSchema); + if (validate(input)) { + return input; } + + const errorStrings = []; + for (const err of validate.errors as DefinedError[]) { + errorStrings.push(err.message); + } + throw new Error(`Incorrect getManifest options:\n\t${errorStrings.join('\n\t')}`); } export function validateInjectManifestOptions(input: unknown): InjectManifestOptions { - const optionsWithDefaults = Object.assign({}, defaults, input); - if(isInjectManifestOptions(optionsWithDefaults)) { - return optionsWithDefaults; - } else { - throw new Error('Validation failed.'); + const jsonSchema: JSONSchemaType = + require(`../schema/InjectManifestOptions.json`); + const validate = ajv.compile(jsonSchema); + if (validate(input)) { + return input; + } + + const errorStrings = []; + for (const err of validate.errors as DefinedError[]) { + errorStrings.push(err.message); } + throw new Error(`Incorrect injectManifestOptions options:\n\t${errorStrings.join('\n\t')}`); } diff --git a/packages/workbox-build/src/schema/GenerateSWOptions.json b/packages/workbox-build/src/schema/GenerateSWOptions.json new file mode 100644 index 000000000..5ce6b92b8 --- /dev/null +++ b/packages/workbox-build/src/schema/GenerateSWOptions.json @@ -0,0 +1 @@ +{"allOf":[{"$ref":"#/definitions/GlobPartial"},{"$ref":"#/definitions/GeneratePartial"},{"$ref":"#/definitions/BasePartial"},{"$ref":"#/definitions/SWDestPartial"}],"definitions":{"GlobPartial":{"type":"object","properties":{"globDirectory":{"type":["null","string"]},"globFollow":{"type":"boolean"},"globIgnores":{"type":"array","items":{"type":"string"}},"globPatterns":{"type":"array","items":{"type":"string"}},"globStrict":{"type":"boolean"},"templatedURLs":{"type":"object","additionalProperties":{"anyOf":[{"type":"array","items":{"type":"string"}},{"type":"string"}]}}}},"GeneratePartial":{"type":"object","properties":{"babelPresetEnvTargets":{"type":"array","items":{"type":"string"}},"cacheId":{"type":["null","string"]},"cleanupOutdatedCaches":{"type":"boolean"},"clientsClaim":{"type":"boolean"},"directoryIndex":{"type":["null","string"]},"disableDevLogs":{"type":"boolean"},"ignoreURLParametersMatching":{"type":"array","items":{"$ref":"#/definitions/RegExp"}},"importScripts":{"type":"array","items":{"type":"string"}},"inlineWorkboxRuntime":{"type":"boolean"},"mode":{"type":["null","string"]},"navigateFallback":{"type":["null","string"]},"navigateFallbackAllowlist":{"type":"array","items":{"$ref":"#/definitions/RegExp"}},"navigateFallbackDenylist":{"type":"array","items":{"$ref":"#/definitions/RegExp"}},"navigationPreload":{"type":"boolean"},"offlineGoogleAnalytics":{"anyOf":[{"$ref":"#/definitions/GoogleAnalyticsInitializeOptions"},{"type":"boolean"}]},"runtimeCaching":{"type":"array","items":{"$ref":"#/definitions/RuntimeCaching"}},"skipWaiting":{"type":"boolean"},"sourcemap":{"type":"boolean"}}},"RegExp":{"type":"object","properties":{"source":{"type":"string"},"global":{"type":"boolean"},"ignoreCase":{"type":"boolean"},"multiline":{"type":"boolean"},"lastIndex":{"type":"number"},"flags":{"type":"string"},"sticky":{"type":"boolean"},"unicode":{"type":"boolean"},"dotAll":{"type":"boolean"}}},"GoogleAnalyticsInitializeOptions":{"type":"object","properties":{"cacheName":{"type":"string"},"parameterOverrides":{"type":"object","additionalProperties":{"type":"string"}},"hitFilter":{"type":"object"}}},"RuntimeCaching":{"type":"object","properties":{"handler":{"anyOf":[{"$ref":"#/definitions/RouteHandlerCallback"},{"$ref":"#/definitions/RouteHandlerObject"},{"enum":["CacheFirst","CacheOnly","NetworkFirst","NetworkOnly","StaleWhileRevalidate"],"type":"string"}]},"method":{"enum":["DELETE","GET","HEAD","PATCH","POST","PUT"],"type":"string"},"options":{"type":"object","properties":{"backgroundSync":{"type":"object","properties":{"name":{"type":"string"},"options":{"$ref":"#/definitions/QueueOptions"}}},"broadcastUpdate":{"type":"object","properties":{"channelName":{"type":"string"},"options":{"$ref":"#/definitions/BroadcastCacheUpdateOptions"}}},"cacheableResponse":{"$ref":"#/definitions/CacheableResponseOptions"},"cacheName":{"type":["null","string"]},"expiration":{"$ref":"#/definitions/ExpirationPluginOptions"},"networkTimeoutSeconds":{"type":"number"},"plugins":{"type":"array","items":{"$ref":"#/definitions/WorkboxPlugin"}},"precacheFallback":{"type":"object","properties":{"fallbackURL":{"type":"string"}}},"fetchOptions":{"$ref":"#/definitions/RequestInit"},"matchOptions":{"$ref":"#/definitions/CacheQueryOptions"}}},"urlPattern":{"anyOf":[{"$ref":"#/definitions/RegExp"},{"$ref":"#/definitions/RouteMatchCallback"},{"type":"string"}]}}},"RouteHandlerCallback":{"description":"The \"handler\" callback is invoked whenever a `Router` matches a URL/Request\nto a `Route` via its `RouteMatchCallback`. This handler callback should\nreturn a `Promise` that resolves with a `Response`.\n\nIf a non-empty array or object is returned by the `RouteMatchCallback` it\nwill be passed in as this handler's `options.params` argument.","type":"object"},"RouteHandlerObject":{"description":"An object with a `handle` method of type `RouteHandlerCallback`.\n\nA `Route` object can be created with either an `RouteHandlerCallback`\nfunction or this `RouteHandler` object. The benefit of the `RouteHandler`\nis it can be extended (as is done by the `workbox-strategies` package).","type":"object","properties":{"handle":{"$ref":"#/definitions/RouteHandlerCallback"}}},"QueueOptions":{"type":"object","properties":{"onSync":{"$ref":"#/definitions/OnSyncCallback"},"maxRetentionTime":{"type":"number"}}},"OnSyncCallback":{"type":"object"},"BroadcastCacheUpdateOptions":{"type":"object","properties":{"headersToCheck":{"type":"array","items":{"type":"string"}},"generatePayload":{"type":"object"}}},"CacheableResponseOptions":{"type":"object","properties":{"statuses":{"type":"array","items":{"type":"number"}},"headers":{"type":"object","additionalProperties":{"type":"string"}}}},"ExpirationPluginOptions":{"type":"object","properties":{"maxEntries":{"type":"number"},"maxAgeSeconds":{"type":"number"},"matchOptions":{"$ref":"#/definitions/CacheQueryOptions"},"purgeOnQuotaError":{"type":"boolean"}}},"CacheQueryOptions":{"type":"object","properties":{"ignoreMethod":{"type":"boolean"},"ignoreSearch":{"type":"boolean"},"ignoreVary":{"type":"boolean"}}},"WorkboxPlugin":{"description":"An object with optional lifecycle callback properties for the fetch and\ncache operations.","type":"object","properties":{"cacheDidUpdate":{"$ref":"#/definitions/CacheDidUpdateCallback"},"cachedResponseWillBeUsed":{"$ref":"#/definitions/CachedResponseWillBeUsedCallback"},"cacheKeyWillBeUsed":{"$ref":"#/definitions/CacheKeyWillBeUsedCallback"},"cacheWillUpdate":{"$ref":"#/definitions/CacheWillUpdateCallback"},"fetchDidFail":{"$ref":"#/definitions/FetchDidFailCallback"},"fetchDidSucceed":{"$ref":"#/definitions/FetchDidSucceedCallback"},"handlerDidComplete":{"$ref":"#/definitions/HandlerDidCompleteCallback"},"handlerDidError":{"$ref":"#/definitions/HandlerDidErrorCallback"},"handlerDidRespond":{"$ref":"#/definitions/HandlerDidRespondCallback"},"handlerWillRespond":{"$ref":"#/definitions/HandlerWillRespondCallback"},"handlerWillStart":{"$ref":"#/definitions/HandlerWillStartCallback"},"requestWillFetch":{"$ref":"#/definitions/RequestWillFetchCallback"}}},"CacheDidUpdateCallback":{"type":"object"},"CachedResponseWillBeUsedCallback":{"type":"object"},"CacheKeyWillBeUsedCallback":{"type":"object"},"CacheWillUpdateCallback":{"type":"object"},"FetchDidFailCallback":{"type":"object"},"FetchDidSucceedCallback":{"type":"object"},"HandlerDidCompleteCallback":{"type":"object"},"HandlerDidErrorCallback":{"type":"object"},"HandlerDidRespondCallback":{"type":"object"},"HandlerWillRespondCallback":{"type":"object"},"HandlerWillStartCallback":{"type":"object"},"RequestWillFetchCallback":{"type":"object"},"RequestInit":{"type":"object","properties":{"body":{"anyOf":[{"$ref":"#/definitions/ArrayBuffer"},{"$ref":"#/definitions/ArrayBufferView"},{"$ref":"#/definitions/Blob"},{"$ref":"#/definitions/FormData"},{"$ref":"#/definitions/URLSearchParams"},{"$ref":"#/definitions/ReadableStream"},{"type":["null","string"]}]},"cache":{"enum":["default","force-cache","no-cache","no-store","only-if-cached","reload"],"type":"string"},"credentials":{"enum":["include","omit","same-origin"],"type":"string"},"headers":{"anyOf":[{"$ref":"#/definitions/Headers"},{"type":"array","items":{"type":"array","items":{"type":"string"}}},{"$ref":"#/definitions/Record"}]},"integrity":{"type":"string"},"keepalive":{"type":"boolean"},"method":{"type":"string"},"mode":{"enum":["cors","navigate","no-cors","same-origin"],"type":"string"},"redirect":{"enum":["error","follow","manual"],"type":"string"},"referrer":{"type":"string"},"referrerPolicy":{"enum":["","no-referrer","no-referrer-when-downgrade","origin","origin-when-cross-origin","same-origin","strict-origin","strict-origin-when-cross-origin","unsafe-url"],"type":"string"},"signal":{"anyOf":[{"$ref":"#/definitions/AbortSignal"},{"type":"null"}]},"window":{}}},"ArrayBuffer":{"type":"object","properties":{"byteLength":{"type":"number"},"__@toStringTag":{"type":"string"}}},"ArrayBufferView":{"type":"object","properties":{"buffer":{"anyOf":[{"$ref":"#/definitions/ArrayBuffer"},{"$ref":"#/definitions/SharedArrayBuffer"}]},"byteLength":{"type":"number"},"byteOffset":{"type":"number"}}},"SharedArrayBuffer":{"type":"object","properties":{"byteLength":{"type":"number"},"__@species":{"$ref":"#/definitions/SharedArrayBuffer"},"__@toStringTag":{"type":"string","enum":["SharedArrayBuffer"]}}},"Blob":{"type":"object","properties":{"size":{"type":"number"},"type":{"type":"string"}}},"FormData":{"type":"object"},"URLSearchParams":{"type":"object"},"ReadableStream":{"type":"object","properties":{"locked":{"type":"boolean"}}},"Headers":{"type":"object"},"Record":{"type":"object"},"AbortSignal":{"type":"object","properties":{"aborted":{"type":"boolean"},"onabort":{"type":["null","object"]}}},"RouteMatchCallback":{"description":"The \"match\" callback is used to determine if a `Route` should apply for a\nparticular URL and request. When matching occurs in response to a fetch\nevent from the client, the `event` object is also supplied. However, since\nthe match callback can be invoked outside of a fetch event, matching logic\nshould not assume the `event` object will always be available.\nIf the match callback returns a truthy value, the matching route's\n`RouteHandlerCallback` will be invoked immediately. If the value returned\nis a non-empty array or object, that value will be set on the handler's\n`options.params` argument.","type":"object"},"BasePartial":{"type":"object","properties":{"additionalManifestEntries":{"type":"array","items":{"anyOf":[{"$ref":"#/definitions/ManifestEntry"},{"type":"string"}]}},"dontCacheBustURLsMatching":{"$ref":"#/definitions/RegExp"},"manifestTransforms":{"type":"array","items":{"type":"object"}},"maximumFileSizeToCacheInBytes":{"type":"number"},"modifyURLPrefix":{"type":"object","additionalProperties":{"type":"string"}}}},"ManifestEntry":{"type":"object","properties":{"integrity":{"type":"string"},"revision":{"type":["null","string"]},"url":{"type":"string"}}},"SWDestPartial":{"type":"object","properties":{"swDest":{"type":"string"}}}},"$schema":"http://json-schema.org/draft-07/schema#"} diff --git a/packages/workbox-build/src/schema/GetManifestOptions.json b/packages/workbox-build/src/schema/GetManifestOptions.json new file mode 100644 index 000000000..57eb67c0e --- /dev/null +++ b/packages/workbox-build/src/schema/GetManifestOptions.json @@ -0,0 +1 @@ +{"allOf":[{"$ref":"#/definitions/GlobPartial"},{"$ref":"#/definitions/BasePartial"}],"definitions":{"GlobPartial":{"type":"object","properties":{"globDirectory":{"type":["null","string"]},"globFollow":{"type":"boolean"},"globIgnores":{"type":"array","items":{"type":"string"}},"globPatterns":{"type":"array","items":{"type":"string"}},"globStrict":{"type":"boolean"},"templatedURLs":{"type":"object","additionalProperties":{"anyOf":[{"type":"array","items":{"type":"string"}},{"type":"string"}]}}}},"GeneratePartial":{"type":"object","properties":{"babelPresetEnvTargets":{"type":"array","items":{"type":"string"}},"cacheId":{"type":["null","string"]},"cleanupOutdatedCaches":{"type":"boolean"},"clientsClaim":{"type":"boolean"},"directoryIndex":{"type":["null","string"]},"disableDevLogs":{"type":"boolean"},"ignoreURLParametersMatching":{"type":"array","items":{"$ref":"#/definitions/RegExp"}},"importScripts":{"type":"array","items":{"type":"string"}},"inlineWorkboxRuntime":{"type":"boolean"},"mode":{"type":["null","string"]},"navigateFallback":{"type":["null","string"]},"navigateFallbackAllowlist":{"type":"array","items":{"$ref":"#/definitions/RegExp"}},"navigateFallbackDenylist":{"type":"array","items":{"$ref":"#/definitions/RegExp"}},"navigationPreload":{"type":"boolean"},"offlineGoogleAnalytics":{"anyOf":[{"$ref":"#/definitions/GoogleAnalyticsInitializeOptions"},{"type":"boolean"}]},"runtimeCaching":{"type":"array","items":{"$ref":"#/definitions/RuntimeCaching"}},"skipWaiting":{"type":"boolean"},"sourcemap":{"type":"boolean"}}},"RegExp":{"type":"object","properties":{"source":{"type":"string"},"global":{"type":"boolean"},"ignoreCase":{"type":"boolean"},"multiline":{"type":"boolean"},"lastIndex":{"type":"number"},"flags":{"type":"string"},"sticky":{"type":"boolean"},"unicode":{"type":"boolean"},"dotAll":{"type":"boolean"}}},"GoogleAnalyticsInitializeOptions":{"type":"object","properties":{"cacheName":{"type":"string"},"parameterOverrides":{"type":"object","additionalProperties":{"type":"string"}},"hitFilter":{"type":"object"}}},"RuntimeCaching":{"type":"object","properties":{"handler":{"anyOf":[{"$ref":"#/definitions/RouteHandlerCallback"},{"$ref":"#/definitions/RouteHandlerObject"},{"enum":["CacheFirst","CacheOnly","NetworkFirst","NetworkOnly","StaleWhileRevalidate"],"type":"string"}]},"method":{"enum":["DELETE","GET","HEAD","PATCH","POST","PUT"],"type":"string"},"options":{"type":"object","properties":{"backgroundSync":{"type":"object","properties":{"name":{"type":"string"},"options":{"$ref":"#/definitions/QueueOptions"}}},"broadcastUpdate":{"type":"object","properties":{"channelName":{"type":"string"},"options":{"$ref":"#/definitions/BroadcastCacheUpdateOptions"}}},"cacheableResponse":{"$ref":"#/definitions/CacheableResponseOptions"},"cacheName":{"type":["null","string"]},"expiration":{"$ref":"#/definitions/ExpirationPluginOptions"},"networkTimeoutSeconds":{"type":"number"},"plugins":{"type":"array","items":{"$ref":"#/definitions/WorkboxPlugin"}},"precacheFallback":{"type":"object","properties":{"fallbackURL":{"type":"string"}}},"fetchOptions":{"$ref":"#/definitions/RequestInit"},"matchOptions":{"$ref":"#/definitions/CacheQueryOptions"}}},"urlPattern":{"anyOf":[{"$ref":"#/definitions/RegExp"},{"$ref":"#/definitions/RouteMatchCallback"},{"type":"string"}]}}},"RouteHandlerCallback":{"description":"The \"handler\" callback is invoked whenever a `Router` matches a URL/Request\nto a `Route` via its `RouteMatchCallback`. This handler callback should\nreturn a `Promise` that resolves with a `Response`.\n\nIf a non-empty array or object is returned by the `RouteMatchCallback` it\nwill be passed in as this handler's `options.params` argument.","type":"object"},"RouteHandlerObject":{"description":"An object with a `handle` method of type `RouteHandlerCallback`.\n\nA `Route` object can be created with either an `RouteHandlerCallback`\nfunction or this `RouteHandler` object. The benefit of the `RouteHandler`\nis it can be extended (as is done by the `workbox-strategies` package).","type":"object","properties":{"handle":{"$ref":"#/definitions/RouteHandlerCallback"}}},"QueueOptions":{"type":"object","properties":{"onSync":{"$ref":"#/definitions/OnSyncCallback"},"maxRetentionTime":{"type":"number"}}},"OnSyncCallback":{"type":"object"},"BroadcastCacheUpdateOptions":{"type":"object","properties":{"headersToCheck":{"type":"array","items":{"type":"string"}},"generatePayload":{"type":"object"}}},"CacheableResponseOptions":{"type":"object","properties":{"statuses":{"type":"array","items":{"type":"number"}},"headers":{"type":"object","additionalProperties":{"type":"string"}}}},"ExpirationPluginOptions":{"type":"object","properties":{"maxEntries":{"type":"number"},"maxAgeSeconds":{"type":"number"},"matchOptions":{"$ref":"#/definitions/CacheQueryOptions"},"purgeOnQuotaError":{"type":"boolean"}}},"CacheQueryOptions":{"type":"object","properties":{"ignoreMethod":{"type":"boolean"},"ignoreSearch":{"type":"boolean"},"ignoreVary":{"type":"boolean"}}},"WorkboxPlugin":{"description":"An object with optional lifecycle callback properties for the fetch and\ncache operations.","type":"object","properties":{"cacheDidUpdate":{"$ref":"#/definitions/CacheDidUpdateCallback"},"cachedResponseWillBeUsed":{"$ref":"#/definitions/CachedResponseWillBeUsedCallback"},"cacheKeyWillBeUsed":{"$ref":"#/definitions/CacheKeyWillBeUsedCallback"},"cacheWillUpdate":{"$ref":"#/definitions/CacheWillUpdateCallback"},"fetchDidFail":{"$ref":"#/definitions/FetchDidFailCallback"},"fetchDidSucceed":{"$ref":"#/definitions/FetchDidSucceedCallback"},"handlerDidComplete":{"$ref":"#/definitions/HandlerDidCompleteCallback"},"handlerDidError":{"$ref":"#/definitions/HandlerDidErrorCallback"},"handlerDidRespond":{"$ref":"#/definitions/HandlerDidRespondCallback"},"handlerWillRespond":{"$ref":"#/definitions/HandlerWillRespondCallback"},"handlerWillStart":{"$ref":"#/definitions/HandlerWillStartCallback"},"requestWillFetch":{"$ref":"#/definitions/RequestWillFetchCallback"}}},"CacheDidUpdateCallback":{"type":"object"},"CachedResponseWillBeUsedCallback":{"type":"object"},"CacheKeyWillBeUsedCallback":{"type":"object"},"CacheWillUpdateCallback":{"type":"object"},"FetchDidFailCallback":{"type":"object"},"FetchDidSucceedCallback":{"type":"object"},"HandlerDidCompleteCallback":{"type":"object"},"HandlerDidErrorCallback":{"type":"object"},"HandlerDidRespondCallback":{"type":"object"},"HandlerWillRespondCallback":{"type":"object"},"HandlerWillStartCallback":{"type":"object"},"RequestWillFetchCallback":{"type":"object"},"RequestInit":{"type":"object","properties":{"body":{"anyOf":[{"$ref":"#/definitions/ArrayBuffer"},{"$ref":"#/definitions/ArrayBufferView"},{"$ref":"#/definitions/Blob"},{"$ref":"#/definitions/FormData"},{"$ref":"#/definitions/URLSearchParams"},{"$ref":"#/definitions/ReadableStream"},{"type":["null","string"]}]},"cache":{"enum":["default","force-cache","no-cache","no-store","only-if-cached","reload"],"type":"string"},"credentials":{"enum":["include","omit","same-origin"],"type":"string"},"headers":{"anyOf":[{"$ref":"#/definitions/Headers"},{"type":"array","items":{"type":"array","items":{"type":"string"}}},{"$ref":"#/definitions/Record"}]},"integrity":{"type":"string"},"keepalive":{"type":"boolean"},"method":{"type":"string"},"mode":{"enum":["cors","navigate","no-cors","same-origin"],"type":"string"},"redirect":{"enum":["error","follow","manual"],"type":"string"},"referrer":{"type":"string"},"referrerPolicy":{"enum":["","no-referrer","no-referrer-when-downgrade","origin","origin-when-cross-origin","same-origin","strict-origin","strict-origin-when-cross-origin","unsafe-url"],"type":"string"},"signal":{"anyOf":[{"$ref":"#/definitions/AbortSignal"},{"type":"null"}]},"window":{}}},"ArrayBuffer":{"type":"object","properties":{"byteLength":{"type":"number"},"__@toStringTag":{"type":"string"}}},"ArrayBufferView":{"type":"object","properties":{"buffer":{"anyOf":[{"$ref":"#/definitions/ArrayBuffer"},{"$ref":"#/definitions/SharedArrayBuffer"}]},"byteLength":{"type":"number"},"byteOffset":{"type":"number"}}},"SharedArrayBuffer":{"type":"object","properties":{"byteLength":{"type":"number"},"__@species":{"$ref":"#/definitions/SharedArrayBuffer"},"__@toStringTag":{"type":"string","enum":["SharedArrayBuffer"]}}},"Blob":{"type":"object","properties":{"size":{"type":"number"},"type":{"type":"string"}}},"FormData":{"type":"object"},"URLSearchParams":{"type":"object"},"ReadableStream":{"type":"object","properties":{"locked":{"type":"boolean"}}},"Headers":{"type":"object"},"Record":{"type":"object"},"AbortSignal":{"type":"object","properties":{"aborted":{"type":"boolean"},"onabort":{"type":["null","object"]}}},"RouteMatchCallback":{"description":"The \"match\" callback is used to determine if a `Route` should apply for a\nparticular URL and request. When matching occurs in response to a fetch\nevent from the client, the `event` object is also supplied. However, since\nthe match callback can be invoked outside of a fetch event, matching logic\nshould not assume the `event` object will always be available.\nIf the match callback returns a truthy value, the matching route's\n`RouteHandlerCallback` will be invoked immediately. If the value returned\nis a non-empty array or object, that value will be set on the handler's\n`options.params` argument.","type":"object"},"BasePartial":{"type":"object","properties":{"additionalManifestEntries":{"type":"array","items":{"anyOf":[{"$ref":"#/definitions/ManifestEntry"},{"type":"string"}]}},"dontCacheBustURLsMatching":{"$ref":"#/definitions/RegExp"},"manifestTransforms":{"type":"array","items":{"type":"object"}},"maximumFileSizeToCacheInBytes":{"type":"number"},"modifyURLPrefix":{"type":"object","additionalProperties":{"type":"string"}}}},"ManifestEntry":{"type":"object","properties":{"integrity":{"type":"string"},"revision":{"type":["null","string"]},"url":{"type":"string"}}},"SWDestPartial":{"type":"object","properties":{"swDest":{"type":"string"}}}},"$schema":"http://json-schema.org/draft-07/schema#"} diff --git a/packages/workbox-build/src/schema/InjectManifestOptions.json b/packages/workbox-build/src/schema/InjectManifestOptions.json new file mode 100644 index 000000000..521772097 --- /dev/null +++ b/packages/workbox-build/src/schema/InjectManifestOptions.json @@ -0,0 +1 @@ +{"allOf":[{"$ref":"#/definitions/InjectPartial"},{"$ref":"#/definitions/Omit"},{"$ref":"#/definitions/BasePartial"},{"$ref":"#/definitions/SWDestPartial"},{"type":"object","properties":{"globDirectory":{"type":"string"}}}],"definitions":{"GlobPartial":{"type":"object","properties":{"globDirectory":{"type":["null","string"]},"globFollow":{"type":"boolean"},"globIgnores":{"type":"array","items":{"type":"string"}},"globPatterns":{"type":"array","items":{"type":"string"}},"globStrict":{"type":"boolean"},"templatedURLs":{"type":"object","additionalProperties":{"anyOf":[{"type":"array","items":{"type":"string"}},{"type":"string"}]}}}},"GeneratePartial":{"type":"object","properties":{"babelPresetEnvTargets":{"type":"array","items":{"type":"string"}},"cacheId":{"type":["null","string"]},"cleanupOutdatedCaches":{"type":"boolean"},"clientsClaim":{"type":"boolean"},"directoryIndex":{"type":["null","string"]},"disableDevLogs":{"type":"boolean"},"ignoreURLParametersMatching":{"type":"array","items":{"$ref":"#/definitions/RegExp"}},"importScripts":{"type":"array","items":{"type":"string"}},"inlineWorkboxRuntime":{"type":"boolean"},"mode":{"type":["null","string"]},"navigateFallback":{"type":["null","string"]},"navigateFallbackAllowlist":{"type":"array","items":{"$ref":"#/definitions/RegExp"}},"navigateFallbackDenylist":{"type":"array","items":{"$ref":"#/definitions/RegExp"}},"navigationPreload":{"type":"boolean"},"offlineGoogleAnalytics":{"anyOf":[{"$ref":"#/definitions/GoogleAnalyticsInitializeOptions"},{"type":"boolean"}]},"runtimeCaching":{"type":"array","items":{"$ref":"#/definitions/RuntimeCaching"}},"skipWaiting":{"type":"boolean"},"sourcemap":{"type":"boolean"}}},"RegExp":{"type":"object","properties":{"source":{"type":"string"},"global":{"type":"boolean"},"ignoreCase":{"type":"boolean"},"multiline":{"type":"boolean"},"lastIndex":{"type":"number"},"flags":{"type":"string"},"sticky":{"type":"boolean"},"unicode":{"type":"boolean"},"dotAll":{"type":"boolean"}}},"GoogleAnalyticsInitializeOptions":{"type":"object","properties":{"cacheName":{"type":"string"},"parameterOverrides":{"type":"object","additionalProperties":{"type":"string"}},"hitFilter":{"type":"object"}}},"RuntimeCaching":{"type":"object","properties":{"handler":{"anyOf":[{"$ref":"#/definitions/RouteHandlerCallback"},{"$ref":"#/definitions/RouteHandlerObject"},{"enum":["CacheFirst","CacheOnly","NetworkFirst","NetworkOnly","StaleWhileRevalidate"],"type":"string"}]},"method":{"enum":["DELETE","GET","HEAD","PATCH","POST","PUT"],"type":"string"},"options":{"type":"object","properties":{"backgroundSync":{"type":"object","properties":{"name":{"type":"string"},"options":{"$ref":"#/definitions/QueueOptions"}}},"broadcastUpdate":{"type":"object","properties":{"channelName":{"type":"string"},"options":{"$ref":"#/definitions/BroadcastCacheUpdateOptions"}}},"cacheableResponse":{"$ref":"#/definitions/CacheableResponseOptions"},"cacheName":{"type":["null","string"]},"expiration":{"$ref":"#/definitions/ExpirationPluginOptions"},"networkTimeoutSeconds":{"type":"number"},"plugins":{"type":"array","items":{"$ref":"#/definitions/WorkboxPlugin"}},"precacheFallback":{"type":"object","properties":{"fallbackURL":{"type":"string"}}},"fetchOptions":{"$ref":"#/definitions/RequestInit"},"matchOptions":{"$ref":"#/definitions/CacheQueryOptions"}}},"urlPattern":{"anyOf":[{"$ref":"#/definitions/RegExp"},{"$ref":"#/definitions/RouteMatchCallback"},{"type":"string"}]}}},"RouteHandlerCallback":{"description":"The \"handler\" callback is invoked whenever a `Router` matches a URL/Request\nto a `Route` via its `RouteMatchCallback`. This handler callback should\nreturn a `Promise` that resolves with a `Response`.\n\nIf a non-empty array or object is returned by the `RouteMatchCallback` it\nwill be passed in as this handler's `options.params` argument.","type":"object"},"RouteHandlerObject":{"description":"An object with a `handle` method of type `RouteHandlerCallback`.\n\nA `Route` object can be created with either an `RouteHandlerCallback`\nfunction or this `RouteHandler` object. The benefit of the `RouteHandler`\nis it can be extended (as is done by the `workbox-strategies` package).","type":"object","properties":{"handle":{"$ref":"#/definitions/RouteHandlerCallback"}}},"QueueOptions":{"type":"object","properties":{"onSync":{"$ref":"#/definitions/OnSyncCallback"},"maxRetentionTime":{"type":"number"}}},"OnSyncCallback":{"type":"object"},"BroadcastCacheUpdateOptions":{"type":"object","properties":{"headersToCheck":{"type":"array","items":{"type":"string"}},"generatePayload":{"type":"object"}}},"CacheableResponseOptions":{"type":"object","properties":{"statuses":{"type":"array","items":{"type":"number"}},"headers":{"type":"object","additionalProperties":{"type":"string"}}}},"ExpirationPluginOptions":{"type":"object","properties":{"maxEntries":{"type":"number"},"maxAgeSeconds":{"type":"number"},"matchOptions":{"$ref":"#/definitions/CacheQueryOptions"},"purgeOnQuotaError":{"type":"boolean"}}},"CacheQueryOptions":{"type":"object","properties":{"ignoreMethod":{"type":"boolean"},"ignoreSearch":{"type":"boolean"},"ignoreVary":{"type":"boolean"}}},"WorkboxPlugin":{"description":"An object with optional lifecycle callback properties for the fetch and\ncache operations.","type":"object","properties":{"cacheDidUpdate":{"$ref":"#/definitions/CacheDidUpdateCallback"},"cachedResponseWillBeUsed":{"$ref":"#/definitions/CachedResponseWillBeUsedCallback"},"cacheKeyWillBeUsed":{"$ref":"#/definitions/CacheKeyWillBeUsedCallback"},"cacheWillUpdate":{"$ref":"#/definitions/CacheWillUpdateCallback"},"fetchDidFail":{"$ref":"#/definitions/FetchDidFailCallback"},"fetchDidSucceed":{"$ref":"#/definitions/FetchDidSucceedCallback"},"handlerDidComplete":{"$ref":"#/definitions/HandlerDidCompleteCallback"},"handlerDidError":{"$ref":"#/definitions/HandlerDidErrorCallback"},"handlerDidRespond":{"$ref":"#/definitions/HandlerDidRespondCallback"},"handlerWillRespond":{"$ref":"#/definitions/HandlerWillRespondCallback"},"handlerWillStart":{"$ref":"#/definitions/HandlerWillStartCallback"},"requestWillFetch":{"$ref":"#/definitions/RequestWillFetchCallback"}}},"CacheDidUpdateCallback":{"type":"object"},"CachedResponseWillBeUsedCallback":{"type":"object"},"CacheKeyWillBeUsedCallback":{"type":"object"},"CacheWillUpdateCallback":{"type":"object"},"FetchDidFailCallback":{"type":"object"},"FetchDidSucceedCallback":{"type":"object"},"HandlerDidCompleteCallback":{"type":"object"},"HandlerDidErrorCallback":{"type":"object"},"HandlerDidRespondCallback":{"type":"object"},"HandlerWillRespondCallback":{"type":"object"},"HandlerWillStartCallback":{"type":"object"},"RequestWillFetchCallback":{"type":"object"},"RequestInit":{"type":"object","properties":{"body":{"anyOf":[{"$ref":"#/definitions/ArrayBuffer"},{"$ref":"#/definitions/ArrayBufferView"},{"$ref":"#/definitions/Blob"},{"$ref":"#/definitions/FormData"},{"$ref":"#/definitions/URLSearchParams"},{"$ref":"#/definitions/ReadableStream"},{"type":["null","string"]}]},"cache":{"enum":["default","force-cache","no-cache","no-store","only-if-cached","reload"],"type":"string"},"credentials":{"enum":["include","omit","same-origin"],"type":"string"},"headers":{"anyOf":[{"$ref":"#/definitions/Headers"},{"type":"array","items":{"type":"array","items":{"type":"string"}}},{"$ref":"#/definitions/Record"}]},"integrity":{"type":"string"},"keepalive":{"type":"boolean"},"method":{"type":"string"},"mode":{"enum":["cors","navigate","no-cors","same-origin"],"type":"string"},"redirect":{"enum":["error","follow","manual"],"type":"string"},"referrer":{"type":"string"},"referrerPolicy":{"enum":["","no-referrer","no-referrer-when-downgrade","origin","origin-when-cross-origin","same-origin","strict-origin","strict-origin-when-cross-origin","unsafe-url"],"type":"string"},"signal":{"anyOf":[{"$ref":"#/definitions/AbortSignal"},{"type":"null"}]},"window":{}}},"ArrayBuffer":{"type":"object","properties":{"byteLength":{"type":"number"},"__@toStringTag":{"type":"string"}}},"ArrayBufferView":{"type":"object","properties":{"buffer":{"anyOf":[{"$ref":"#/definitions/ArrayBuffer"},{"$ref":"#/definitions/SharedArrayBuffer"}]},"byteLength":{"type":"number"},"byteOffset":{"type":"number"}}},"SharedArrayBuffer":{"type":"object","properties":{"byteLength":{"type":"number"},"__@species":{"$ref":"#/definitions/SharedArrayBuffer"},"__@toStringTag":{"type":"string","enum":["SharedArrayBuffer"]}}},"Blob":{"type":"object","properties":{"size":{"type":"number"},"type":{"type":"string"}}},"FormData":{"type":"object"},"URLSearchParams":{"type":"object"},"ReadableStream":{"type":"object","properties":{"locked":{"type":"boolean"}}},"Headers":{"type":"object"},"Record":{"type":"object"},"AbortSignal":{"type":"object","properties":{"aborted":{"type":"boolean"},"onabort":{"type":["null","object"]}}},"RouteMatchCallback":{"description":"The \"match\" callback is used to determine if a `Route` should apply for a\nparticular URL and request. When matching occurs in response to a fetch\nevent from the client, the `event` object is also supplied. However, since\nthe match callback can be invoked outside of a fetch event, matching logic\nshould not assume the `event` object will always be available.\nIf the match callback returns a truthy value, the matching route's\n`RouteHandlerCallback` will be invoked immediately. If the value returned\nis a non-empty array or object, that value will be set on the handler's\n`options.params` argument.","type":"object"},"BasePartial":{"type":"object","properties":{"additionalManifestEntries":{"type":"array","items":{"anyOf":[{"$ref":"#/definitions/ManifestEntry"},{"type":"string"}]}},"dontCacheBustURLsMatching":{"$ref":"#/definitions/RegExp"},"manifestTransforms":{"type":"array","items":{"type":"object"}},"maximumFileSizeToCacheInBytes":{"type":"number"},"modifyURLPrefix":{"type":"object","additionalProperties":{"type":"string"}}}},"ManifestEntry":{"type":"object","properties":{"integrity":{"type":"string"},"revision":{"type":["null","string"]},"url":{"type":"string"}}},"SWDestPartial":{"type":"object","properties":{"swDest":{"type":"string"}}},"InjectPartial":{"type":"object","properties":{"injectionPoint":{"type":"string"},"swSrc":{"type":"string"}}},"Omit":{"type":"object","properties":{"globFollow":{"type":"boolean"},"globIgnores":{"type":"array","items":{"type":"string"}},"globPatterns":{"type":"array","items":{"type":"string"}},"globStrict":{"type":"boolean"},"templatedURLs":{"type":"object","additionalProperties":{"anyOf":[{"type":"array","items":{"type":"string"}},{"type":"string"}]}}}}},"$schema":"http://json-schema.org/draft-07/schema#"} diff --git a/packages/workbox-build/src/schema/WebpackGenerateSWOptions.json b/packages/workbox-build/src/schema/WebpackGenerateSWOptions.json new file mode 100644 index 000000000..82f7f2053 --- /dev/null +++ b/packages/workbox-build/src/schema/WebpackGenerateSWOptions.json @@ -0,0 +1 @@ +{"allOf":[{"$ref":"#/definitions/WebpackPartial"},{"$ref":"#/definitions/GeneratePartial"},{"$ref":"#/definitions/BasePartial"},{"$ref":"#/definitions/SWDestPartial"},{"type":"object","properties":{"importScriptsViaChunks":{"type":"array","items":{"type":"string"}}}}],"definitions":{"GlobPartial":{"type":"object","properties":{"globDirectory":{"type":["null","string"]},"globFollow":{"type":"boolean"},"globIgnores":{"type":"array","items":{"type":"string"}},"globPatterns":{"type":"array","items":{"type":"string"}},"globStrict":{"type":"boolean"},"templatedURLs":{"type":"object","additionalProperties":{"anyOf":[{"type":"array","items":{"type":"string"}},{"type":"string"}]}}}},"GeneratePartial":{"type":"object","properties":{"babelPresetEnvTargets":{"type":"array","items":{"type":"string"}},"cacheId":{"type":["null","string"]},"cleanupOutdatedCaches":{"type":"boolean"},"clientsClaim":{"type":"boolean"},"directoryIndex":{"type":["null","string"]},"disableDevLogs":{"type":"boolean"},"ignoreURLParametersMatching":{"type":"array","items":{"$ref":"#/definitions/RegExp"}},"importScripts":{"type":"array","items":{"type":"string"}},"inlineWorkboxRuntime":{"type":"boolean"},"mode":{"type":["null","string"]},"navigateFallback":{"type":["null","string"]},"navigateFallbackAllowlist":{"type":"array","items":{"$ref":"#/definitions/RegExp"}},"navigateFallbackDenylist":{"type":"array","items":{"$ref":"#/definitions/RegExp"}},"navigationPreload":{"type":"boolean"},"offlineGoogleAnalytics":{"anyOf":[{"$ref":"#/definitions/GoogleAnalyticsInitializeOptions"},{"type":"boolean"}]},"runtimeCaching":{"type":"array","items":{"$ref":"#/definitions/RuntimeCaching"}},"skipWaiting":{"type":"boolean"},"sourcemap":{"type":"boolean"}}},"RegExp":{"type":"object","properties":{"source":{"type":"string"},"global":{"type":"boolean"},"ignoreCase":{"type":"boolean"},"multiline":{"type":"boolean"},"lastIndex":{"type":"number"},"flags":{"type":"string"},"sticky":{"type":"boolean"},"unicode":{"type":"boolean"},"dotAll":{"type":"boolean"}}},"GoogleAnalyticsInitializeOptions":{"type":"object","properties":{"cacheName":{"type":"string"},"parameterOverrides":{"type":"object","additionalProperties":{"type":"string"}},"hitFilter":{"type":"object"}}},"RuntimeCaching":{"type":"object","properties":{"handler":{"anyOf":[{"$ref":"#/definitions/RouteHandlerCallback"},{"$ref":"#/definitions/RouteHandlerObject"},{"enum":["CacheFirst","CacheOnly","NetworkFirst","NetworkOnly","StaleWhileRevalidate"],"type":"string"}]},"method":{"enum":["DELETE","GET","HEAD","PATCH","POST","PUT"],"type":"string"},"options":{"type":"object","properties":{"backgroundSync":{"type":"object","properties":{"name":{"type":"string"},"options":{"$ref":"#/definitions/QueueOptions"}}},"broadcastUpdate":{"type":"object","properties":{"channelName":{"type":"string"},"options":{"$ref":"#/definitions/BroadcastCacheUpdateOptions"}}},"cacheableResponse":{"$ref":"#/definitions/CacheableResponseOptions"},"cacheName":{"type":["null","string"]},"expiration":{"$ref":"#/definitions/ExpirationPluginOptions"},"networkTimeoutSeconds":{"type":"number"},"plugins":{"type":"array","items":{"$ref":"#/definitions/WorkboxPlugin"}},"precacheFallback":{"type":"object","properties":{"fallbackURL":{"type":"string"}}},"fetchOptions":{"$ref":"#/definitions/RequestInit"},"matchOptions":{"$ref":"#/definitions/CacheQueryOptions"}}},"urlPattern":{"anyOf":[{"$ref":"#/definitions/RegExp"},{"$ref":"#/definitions/RouteMatchCallback"},{"type":"string"}]}}},"RouteHandlerCallback":{"description":"The \"handler\" callback is invoked whenever a `Router` matches a URL/Request\nto a `Route` via its `RouteMatchCallback`. This handler callback should\nreturn a `Promise` that resolves with a `Response`.\n\nIf a non-empty array or object is returned by the `RouteMatchCallback` it\nwill be passed in as this handler's `options.params` argument.","type":"object"},"RouteHandlerObject":{"description":"An object with a `handle` method of type `RouteHandlerCallback`.\n\nA `Route` object can be created with either an `RouteHandlerCallback`\nfunction or this `RouteHandler` object. The benefit of the `RouteHandler`\nis it can be extended (as is done by the `workbox-strategies` package).","type":"object","properties":{"handle":{"$ref":"#/definitions/RouteHandlerCallback"}}},"QueueOptions":{"type":"object","properties":{"onSync":{"$ref":"#/definitions/OnSyncCallback"},"maxRetentionTime":{"type":"number"}}},"OnSyncCallback":{"type":"object"},"BroadcastCacheUpdateOptions":{"type":"object","properties":{"headersToCheck":{"type":"array","items":{"type":"string"}},"generatePayload":{"type":"object"}}},"CacheableResponseOptions":{"type":"object","properties":{"statuses":{"type":"array","items":{"type":"number"}},"headers":{"type":"object","additionalProperties":{"type":"string"}}}},"ExpirationPluginOptions":{"type":"object","properties":{"maxEntries":{"type":"number"},"maxAgeSeconds":{"type":"number"},"matchOptions":{"$ref":"#/definitions/CacheQueryOptions"},"purgeOnQuotaError":{"type":"boolean"}}},"CacheQueryOptions":{"type":"object","properties":{"ignoreMethod":{"type":"boolean"},"ignoreSearch":{"type":"boolean"},"ignoreVary":{"type":"boolean"}}},"WorkboxPlugin":{"description":"An object with optional lifecycle callback properties for the fetch and\ncache operations.","type":"object","properties":{"cacheDidUpdate":{"$ref":"#/definitions/CacheDidUpdateCallback"},"cachedResponseWillBeUsed":{"$ref":"#/definitions/CachedResponseWillBeUsedCallback"},"cacheKeyWillBeUsed":{"$ref":"#/definitions/CacheKeyWillBeUsedCallback"},"cacheWillUpdate":{"$ref":"#/definitions/CacheWillUpdateCallback"},"fetchDidFail":{"$ref":"#/definitions/FetchDidFailCallback"},"fetchDidSucceed":{"$ref":"#/definitions/FetchDidSucceedCallback"},"handlerDidComplete":{"$ref":"#/definitions/HandlerDidCompleteCallback"},"handlerDidError":{"$ref":"#/definitions/HandlerDidErrorCallback"},"handlerDidRespond":{"$ref":"#/definitions/HandlerDidRespondCallback"},"handlerWillRespond":{"$ref":"#/definitions/HandlerWillRespondCallback"},"handlerWillStart":{"$ref":"#/definitions/HandlerWillStartCallback"},"requestWillFetch":{"$ref":"#/definitions/RequestWillFetchCallback"}}},"CacheDidUpdateCallback":{"type":"object"},"CachedResponseWillBeUsedCallback":{"type":"object"},"CacheKeyWillBeUsedCallback":{"type":"object"},"CacheWillUpdateCallback":{"type":"object"},"FetchDidFailCallback":{"type":"object"},"FetchDidSucceedCallback":{"type":"object"},"HandlerDidCompleteCallback":{"type":"object"},"HandlerDidErrorCallback":{"type":"object"},"HandlerDidRespondCallback":{"type":"object"},"HandlerWillRespondCallback":{"type":"object"},"HandlerWillStartCallback":{"type":"object"},"RequestWillFetchCallback":{"type":"object"},"RequestInit":{"type":"object","properties":{"body":{"anyOf":[{"$ref":"#/definitions/ArrayBuffer"},{"$ref":"#/definitions/ArrayBufferView"},{"$ref":"#/definitions/Blob"},{"$ref":"#/definitions/FormData"},{"$ref":"#/definitions/URLSearchParams"},{"$ref":"#/definitions/ReadableStream"},{"type":["null","string"]}]},"cache":{"enum":["default","force-cache","no-cache","no-store","only-if-cached","reload"],"type":"string"},"credentials":{"enum":["include","omit","same-origin"],"type":"string"},"headers":{"anyOf":[{"$ref":"#/definitions/Headers"},{"type":"array","items":{"type":"array","items":{"type":"string"}}},{"$ref":"#/definitions/Record"}]},"integrity":{"type":"string"},"keepalive":{"type":"boolean"},"method":{"type":"string"},"mode":{"enum":["cors","navigate","no-cors","same-origin"],"type":"string"},"redirect":{"enum":["error","follow","manual"],"type":"string"},"referrer":{"type":"string"},"referrerPolicy":{"enum":["","no-referrer","no-referrer-when-downgrade","origin","origin-when-cross-origin","same-origin","strict-origin","strict-origin-when-cross-origin","unsafe-url"],"type":"string"},"signal":{"anyOf":[{"$ref":"#/definitions/AbortSignal"},{"type":"null"}]},"window":{}}},"ArrayBuffer":{"type":"object","properties":{"byteLength":{"type":"number"},"__@toStringTag":{"type":"string"}}},"ArrayBufferView":{"type":"object","properties":{"buffer":{"anyOf":[{"$ref":"#/definitions/ArrayBuffer"},{"$ref":"#/definitions/SharedArrayBuffer"}]},"byteLength":{"type":"number"},"byteOffset":{"type":"number"}}},"SharedArrayBuffer":{"type":"object","properties":{"byteLength":{"type":"number"},"__@species":{"$ref":"#/definitions/SharedArrayBuffer"},"__@toStringTag":{"type":"string","enum":["SharedArrayBuffer"]}}},"Blob":{"type":"object","properties":{"size":{"type":"number"},"type":{"type":"string"}}},"FormData":{"type":"object"},"URLSearchParams":{"type":"object"},"ReadableStream":{"type":"object","properties":{"locked":{"type":"boolean"}}},"Headers":{"type":"object"},"Record":{"type":"object"},"AbortSignal":{"type":"object","properties":{"aborted":{"type":"boolean"},"onabort":{"type":["null","object"]}}},"RouteMatchCallback":{"description":"The \"match\" callback is used to determine if a `Route` should apply for a\nparticular URL and request. When matching occurs in response to a fetch\nevent from the client, the `event` object is also supplied. However, since\nthe match callback can be invoked outside of a fetch event, matching logic\nshould not assume the `event` object will always be available.\nIf the match callback returns a truthy value, the matching route's\n`RouteHandlerCallback` will be invoked immediately. If the value returned\nis a non-empty array or object, that value will be set on the handler's\n`options.params` argument.","type":"object"},"BasePartial":{"type":"object","properties":{"additionalManifestEntries":{"type":"array","items":{"anyOf":[{"$ref":"#/definitions/ManifestEntry"},{"type":"string"}]}},"dontCacheBustURLsMatching":{"$ref":"#/definitions/RegExp"},"manifestTransforms":{"type":"array","items":{"type":"object"}},"maximumFileSizeToCacheInBytes":{"type":"number"},"modifyURLPrefix":{"type":"object","additionalProperties":{"type":"string"}}}},"ManifestEntry":{"type":"object","properties":{"integrity":{"type":"string"},"revision":{"type":["null","string"]},"url":{"type":"string"}}},"SWDestPartial":{"type":"object","properties":{"swDest":{"type":"string"}}},"InjectPartial":{"type":"object","properties":{"injectionPoint":{"type":"string"},"swSrc":{"type":"string"}}},"Omit":{"type":"object","properties":{"globFollow":{"type":"boolean"},"globIgnores":{"type":"array","items":{"type":"string"}},"globPatterns":{"type":"array","items":{"type":"string"}},"globStrict":{"type":"boolean"},"templatedURLs":{"type":"object","additionalProperties":{"anyOf":[{"type":"array","items":{"type":"string"}},{"type":"string"}]}}}},"WebpackPartial":{"type":"object","properties":{"chunks":{"type":"array","items":{"type":"string"}},"exclude":{"type":"array","items":{"anyOf":[{"$ref":"#/definitions/RegExp"},{"type":["string","object"]}]}},"excludeChunks":{"type":"array","items":{"type":"string"}},"include":{"type":"array","items":{"anyOf":[{"$ref":"#/definitions/RegExp"},{"type":["string","object"]}]}},"mode":{"type":["null","string"]}}}},"$schema":"http://json-schema.org/draft-07/schema#"} diff --git a/packages/workbox-build/src/schema/WebpackInjectManifestOptions.json b/packages/workbox-build/src/schema/WebpackInjectManifestOptions.json new file mode 100644 index 000000000..81eb99975 --- /dev/null +++ b/packages/workbox-build/src/schema/WebpackInjectManifestOptions.json @@ -0,0 +1 @@ +{"allOf":[{"$ref":"#/definitions/WebpackPartial"},{"$ref":"#/definitions/InjectPartial"},{"$ref":"#/definitions/BasePartial"},{"$ref":"#/definitions/SWDestPartial"},{"type":"object","properties":{"compileSrc":{"type":"boolean"},"webpackCompilationPlugins":{"type":"array","items":{}}}}],"definitions":{"GlobPartial":{"type":"object","properties":{"globDirectory":{"type":["null","string"]},"globFollow":{"type":"boolean"},"globIgnores":{"type":"array","items":{"type":"string"}},"globPatterns":{"type":"array","items":{"type":"string"}},"globStrict":{"type":"boolean"},"templatedURLs":{"type":"object","additionalProperties":{"anyOf":[{"type":"array","items":{"type":"string"}},{"type":"string"}]}}}},"GeneratePartial":{"type":"object","properties":{"babelPresetEnvTargets":{"type":"array","items":{"type":"string"}},"cacheId":{"type":["null","string"]},"cleanupOutdatedCaches":{"type":"boolean"},"clientsClaim":{"type":"boolean"},"directoryIndex":{"type":["null","string"]},"disableDevLogs":{"type":"boolean"},"ignoreURLParametersMatching":{"type":"array","items":{"$ref":"#/definitions/RegExp"}},"importScripts":{"type":"array","items":{"type":"string"}},"inlineWorkboxRuntime":{"type":"boolean"},"mode":{"type":["null","string"]},"navigateFallback":{"type":["null","string"]},"navigateFallbackAllowlist":{"type":"array","items":{"$ref":"#/definitions/RegExp"}},"navigateFallbackDenylist":{"type":"array","items":{"$ref":"#/definitions/RegExp"}},"navigationPreload":{"type":"boolean"},"offlineGoogleAnalytics":{"anyOf":[{"$ref":"#/definitions/GoogleAnalyticsInitializeOptions"},{"type":"boolean"}]},"runtimeCaching":{"type":"array","items":{"$ref":"#/definitions/RuntimeCaching"}},"skipWaiting":{"type":"boolean"},"sourcemap":{"type":"boolean"}}},"RegExp":{"type":"object","properties":{"source":{"type":"string"},"global":{"type":"boolean"},"ignoreCase":{"type":"boolean"},"multiline":{"type":"boolean"},"lastIndex":{"type":"number"},"flags":{"type":"string"},"sticky":{"type":"boolean"},"unicode":{"type":"boolean"},"dotAll":{"type":"boolean"}}},"GoogleAnalyticsInitializeOptions":{"type":"object","properties":{"cacheName":{"type":"string"},"parameterOverrides":{"type":"object","additionalProperties":{"type":"string"}},"hitFilter":{"type":"object"}}},"RuntimeCaching":{"type":"object","properties":{"handler":{"anyOf":[{"$ref":"#/definitions/RouteHandlerCallback"},{"$ref":"#/definitions/RouteHandlerObject"},{"enum":["CacheFirst","CacheOnly","NetworkFirst","NetworkOnly","StaleWhileRevalidate"],"type":"string"}]},"method":{"enum":["DELETE","GET","HEAD","PATCH","POST","PUT"],"type":"string"},"options":{"type":"object","properties":{"backgroundSync":{"type":"object","properties":{"name":{"type":"string"},"options":{"$ref":"#/definitions/QueueOptions"}}},"broadcastUpdate":{"type":"object","properties":{"channelName":{"type":"string"},"options":{"$ref":"#/definitions/BroadcastCacheUpdateOptions"}}},"cacheableResponse":{"$ref":"#/definitions/CacheableResponseOptions"},"cacheName":{"type":["null","string"]},"expiration":{"$ref":"#/definitions/ExpirationPluginOptions"},"networkTimeoutSeconds":{"type":"number"},"plugins":{"type":"array","items":{"$ref":"#/definitions/WorkboxPlugin"}},"precacheFallback":{"type":"object","properties":{"fallbackURL":{"type":"string"}}},"fetchOptions":{"$ref":"#/definitions/RequestInit"},"matchOptions":{"$ref":"#/definitions/CacheQueryOptions"}}},"urlPattern":{"anyOf":[{"$ref":"#/definitions/RegExp"},{"$ref":"#/definitions/RouteMatchCallback"},{"type":"string"}]}}},"RouteHandlerCallback":{"description":"The \"handler\" callback is invoked whenever a `Router` matches a URL/Request\nto a `Route` via its `RouteMatchCallback`. This handler callback should\nreturn a `Promise` that resolves with a `Response`.\n\nIf a non-empty array or object is returned by the `RouteMatchCallback` it\nwill be passed in as this handler's `options.params` argument.","type":"object"},"RouteHandlerObject":{"description":"An object with a `handle` method of type `RouteHandlerCallback`.\n\nA `Route` object can be created with either an `RouteHandlerCallback`\nfunction or this `RouteHandler` object. The benefit of the `RouteHandler`\nis it can be extended (as is done by the `workbox-strategies` package).","type":"object","properties":{"handle":{"$ref":"#/definitions/RouteHandlerCallback"}}},"QueueOptions":{"type":"object","properties":{"onSync":{"$ref":"#/definitions/OnSyncCallback"},"maxRetentionTime":{"type":"number"}}},"OnSyncCallback":{"type":"object"},"BroadcastCacheUpdateOptions":{"type":"object","properties":{"headersToCheck":{"type":"array","items":{"type":"string"}},"generatePayload":{"type":"object"}}},"CacheableResponseOptions":{"type":"object","properties":{"statuses":{"type":"array","items":{"type":"number"}},"headers":{"type":"object","additionalProperties":{"type":"string"}}}},"ExpirationPluginOptions":{"type":"object","properties":{"maxEntries":{"type":"number"},"maxAgeSeconds":{"type":"number"},"matchOptions":{"$ref":"#/definitions/CacheQueryOptions"},"purgeOnQuotaError":{"type":"boolean"}}},"CacheQueryOptions":{"type":"object","properties":{"ignoreMethod":{"type":"boolean"},"ignoreSearch":{"type":"boolean"},"ignoreVary":{"type":"boolean"}}},"WorkboxPlugin":{"description":"An object with optional lifecycle callback properties for the fetch and\ncache operations.","type":"object","properties":{"cacheDidUpdate":{"$ref":"#/definitions/CacheDidUpdateCallback"},"cachedResponseWillBeUsed":{"$ref":"#/definitions/CachedResponseWillBeUsedCallback"},"cacheKeyWillBeUsed":{"$ref":"#/definitions/CacheKeyWillBeUsedCallback"},"cacheWillUpdate":{"$ref":"#/definitions/CacheWillUpdateCallback"},"fetchDidFail":{"$ref":"#/definitions/FetchDidFailCallback"},"fetchDidSucceed":{"$ref":"#/definitions/FetchDidSucceedCallback"},"handlerDidComplete":{"$ref":"#/definitions/HandlerDidCompleteCallback"},"handlerDidError":{"$ref":"#/definitions/HandlerDidErrorCallback"},"handlerDidRespond":{"$ref":"#/definitions/HandlerDidRespondCallback"},"handlerWillRespond":{"$ref":"#/definitions/HandlerWillRespondCallback"},"handlerWillStart":{"$ref":"#/definitions/HandlerWillStartCallback"},"requestWillFetch":{"$ref":"#/definitions/RequestWillFetchCallback"}}},"CacheDidUpdateCallback":{"type":"object"},"CachedResponseWillBeUsedCallback":{"type":"object"},"CacheKeyWillBeUsedCallback":{"type":"object"},"CacheWillUpdateCallback":{"type":"object"},"FetchDidFailCallback":{"type":"object"},"FetchDidSucceedCallback":{"type":"object"},"HandlerDidCompleteCallback":{"type":"object"},"HandlerDidErrorCallback":{"type":"object"},"HandlerDidRespondCallback":{"type":"object"},"HandlerWillRespondCallback":{"type":"object"},"HandlerWillStartCallback":{"type":"object"},"RequestWillFetchCallback":{"type":"object"},"RequestInit":{"type":"object","properties":{"body":{"anyOf":[{"$ref":"#/definitions/ArrayBuffer"},{"$ref":"#/definitions/ArrayBufferView"},{"$ref":"#/definitions/Blob"},{"$ref":"#/definitions/FormData"},{"$ref":"#/definitions/URLSearchParams"},{"$ref":"#/definitions/ReadableStream"},{"type":["null","string"]}]},"cache":{"enum":["default","force-cache","no-cache","no-store","only-if-cached","reload"],"type":"string"},"credentials":{"enum":["include","omit","same-origin"],"type":"string"},"headers":{"anyOf":[{"$ref":"#/definitions/Headers"},{"type":"array","items":{"type":"array","items":{"type":"string"}}},{"$ref":"#/definitions/Record"}]},"integrity":{"type":"string"},"keepalive":{"type":"boolean"},"method":{"type":"string"},"mode":{"enum":["cors","navigate","no-cors","same-origin"],"type":"string"},"redirect":{"enum":["error","follow","manual"],"type":"string"},"referrer":{"type":"string"},"referrerPolicy":{"enum":["","no-referrer","no-referrer-when-downgrade","origin","origin-when-cross-origin","same-origin","strict-origin","strict-origin-when-cross-origin","unsafe-url"],"type":"string"},"signal":{"anyOf":[{"$ref":"#/definitions/AbortSignal"},{"type":"null"}]},"window":{}}},"ArrayBuffer":{"type":"object","properties":{"byteLength":{"type":"number"},"__@toStringTag":{"type":"string"}}},"ArrayBufferView":{"type":"object","properties":{"buffer":{"anyOf":[{"$ref":"#/definitions/ArrayBuffer"},{"$ref":"#/definitions/SharedArrayBuffer"}]},"byteLength":{"type":"number"},"byteOffset":{"type":"number"}}},"SharedArrayBuffer":{"type":"object","properties":{"byteLength":{"type":"number"},"__@species":{"$ref":"#/definitions/SharedArrayBuffer"},"__@toStringTag":{"type":"string","enum":["SharedArrayBuffer"]}}},"Blob":{"type":"object","properties":{"size":{"type":"number"},"type":{"type":"string"}}},"FormData":{"type":"object"},"URLSearchParams":{"type":"object"},"ReadableStream":{"type":"object","properties":{"locked":{"type":"boolean"}}},"Headers":{"type":"object"},"Record":{"type":"object"},"AbortSignal":{"type":"object","properties":{"aborted":{"type":"boolean"},"onabort":{"type":["null","object"]}}},"RouteMatchCallback":{"description":"The \"match\" callback is used to determine if a `Route` should apply for a\nparticular URL and request. When matching occurs in response to a fetch\nevent from the client, the `event` object is also supplied. However, since\nthe match callback can be invoked outside of a fetch event, matching logic\nshould not assume the `event` object will always be available.\nIf the match callback returns a truthy value, the matching route's\n`RouteHandlerCallback` will be invoked immediately. If the value returned\nis a non-empty array or object, that value will be set on the handler's\n`options.params` argument.","type":"object"},"BasePartial":{"type":"object","properties":{"additionalManifestEntries":{"type":"array","items":{"anyOf":[{"$ref":"#/definitions/ManifestEntry"},{"type":"string"}]}},"dontCacheBustURLsMatching":{"$ref":"#/definitions/RegExp"},"manifestTransforms":{"type":"array","items":{"type":"object"}},"maximumFileSizeToCacheInBytes":{"type":"number"},"modifyURLPrefix":{"type":"object","additionalProperties":{"type":"string"}}}},"ManifestEntry":{"type":"object","properties":{"integrity":{"type":"string"},"revision":{"type":["null","string"]},"url":{"type":"string"}}},"SWDestPartial":{"type":"object","properties":{"swDest":{"type":"string"}}},"InjectPartial":{"type":"object","properties":{"injectionPoint":{"type":"string"},"swSrc":{"type":"string"}}},"Omit":{"type":"object","properties":{"globFollow":{"type":"boolean"},"globIgnores":{"type":"array","items":{"type":"string"}},"globPatterns":{"type":"array","items":{"type":"string"}},"globStrict":{"type":"boolean"},"templatedURLs":{"type":"object","additionalProperties":{"anyOf":[{"type":"array","items":{"type":"string"}},{"type":"string"}]}}}},"WebpackPartial":{"type":"object","properties":{"chunks":{"type":"array","items":{"type":"string"}},"exclude":{"type":"array","items":{"anyOf":[{"$ref":"#/definitions/RegExp"},{"type":["string","object"]}]}},"excludeChunks":{"type":"array","items":{"type":"string"}},"include":{"type":"array","items":{"anyOf":[{"$ref":"#/definitions/RegExp"},{"type":["string","object"]}]}},"mode":{"type":["null","string"]}}}},"$schema":"http://json-schema.org/draft-07/schema#"} diff --git a/packages/workbox-build/src/types.guard.ts b/packages/workbox-build/src/types.guard.ts deleted file mode 100644 index ae9401955..000000000 --- a/packages/workbox-build/src/types.guard.ts +++ /dev/null @@ -1,725 +0,0 @@ -/* - * Generated type guards for "types.ts". - * WARNING: Do not manually change this file. - */ -import { GenerateSWOptions, GetManifestOptions, InjectManifestOptions, WebpackGenerateSWOptions, WebpackInjectManifestOptions } from "./types"; - -export function isGenerateSWOptions(obj: any, _argumentName?: string): obj is GenerateSWOptions { - return ( - ((obj !== null && - typeof obj === "object" || - typeof obj === "function") && - (typeof obj.globDirectory === "undefined" || - obj.globDirectory === null || - typeof obj.globDirectory === "string") && - (typeof obj.globFollow === "undefined" || - obj.globFollow === false || - obj.globFollow === true) && - Array.isArray(obj.globIgnores) && - obj.globIgnores.every((e: any) => - typeof e === "string" - ) && - Array.isArray(obj.globPatterns) && - obj.globPatterns.every((e: any) => - typeof e === "string" - ) && - (typeof obj.globStrict === "undefined" || - obj.globStrict === false || - obj.globStrict === true) && - (obj.templatedURLs !== null && - typeof obj.templatedURLs === "object" || - typeof obj.templatedURLs === "function") || - (obj !== null && - typeof obj === "object" || - typeof obj === "function") && - (typeof obj.babelPresetEnvTargets === "undefined" || - Array.isArray(obj.babelPresetEnvTargets) && - obj.babelPresetEnvTargets.every((e: any) => - typeof e === "string" - )) && - (typeof obj.cacheId === "undefined" || - obj.cacheId === null || - typeof obj.cacheId === "string") && - (typeof obj.cleanupOutdatedCaches === "undefined" || - obj.cleanupOutdatedCaches === false || - obj.cleanupOutdatedCaches === true) && - (typeof obj.clientsClaim === "undefined" || - obj.clientsClaim === false || - obj.clientsClaim === true) && - (typeof obj.directoryIndex === "undefined" || - obj.directoryIndex === null || - typeof obj.directoryIndex === "string") && - (typeof obj.disableDevLogs === "undefined" || - obj.disableDevLogs === false || - obj.disableDevLogs === true) && - (typeof obj.ignoreURLParametersMatching === "undefined" || - Array.isArray(obj.ignoreURLParametersMatching) && - obj.ignoreURLParametersMatching.every((e: any) => - e instanceof RegExp - )) && - (typeof obj.importScripts === "undefined" || - Array.isArray(obj.importScripts) && - obj.importScripts.every((e: any) => - typeof e === "string" - )) && - (typeof obj.inlineWorkboxRuntime === "undefined" || - obj.inlineWorkboxRuntime === false || - obj.inlineWorkboxRuntime === true) && - (typeof obj.mode === "undefined" || - obj.mode === null || - typeof obj.mode === "string") && - (typeof obj.navigateFallback === "undefined" || - obj.navigateFallback === null || - typeof obj.navigateFallback === "string") && - (typeof obj.navigateFallbackAllowlist === "undefined" || - Array.isArray(obj.navigateFallbackAllowlist) && - obj.navigateFallbackAllowlist.every((e: any) => - e instanceof RegExp - )) && - (typeof obj.navigateFallbackDenylist === "undefined" || - Array.isArray(obj.navigateFallbackDenylist) && - obj.navigateFallbackDenylist.every((e: any) => - e instanceof RegExp - )) && - (typeof obj.navigationPreload === "undefined" || - obj.navigationPreload === false || - obj.navigationPreload === true) && - Array.isArray(obj.runtimeCaching) && - obj.runtimeCaching.every((e: any) => - (e !== null && - typeof e === "object" || - typeof e === "function") && - (typeof e.options === "undefined" || - (e.options !== null && - typeof e.options === "object" || - typeof e.options === "function") && - (typeof e.options.backgroundSync === "undefined" || - (e.options.backgroundSync !== null && - typeof e.options.backgroundSync === "object" || - typeof e.options.backgroundSync === "function") && - typeof e.options.backgroundSync.name === "string") && - (typeof e.options.broadcastUpdate === "undefined" || - (e.options.broadcastUpdate !== null && - typeof e.options.broadcastUpdate === "object" || - typeof e.options.broadcastUpdate === "function") && - (typeof e.options.broadcastUpdate.channelName === "undefined" || - typeof e.options.broadcastUpdate.channelName === "string")) && - (typeof e.options.cacheName === "undefined" || - e.options.cacheName === null || - typeof e.options.cacheName === "string") && - (typeof e.options.networkTimeoutSeconds === "undefined" || - typeof e.options.networkTimeoutSeconds === "number") && - (typeof e.options.plugins === "undefined" || - Array.isArray(e.options.plugins)) && - (typeof e.options.precacheFallback === "undefined" || - (e.options.precacheFallback !== null && - typeof e.options.precacheFallback === "object" || - typeof e.options.precacheFallback === "function") && - typeof e.options.precacheFallback.fallbackURL === "string") && - (typeof e.options.fetchOptions === "undefined" || - (e.options.fetchOptions !== null && - typeof e.options.fetchOptions === "object" || - typeof e.options.fetchOptions === "function") && - (typeof e.options.fetchOptions.body === "undefined" || - e.options.fetchOptions.body === null || - typeof e.options.fetchOptions.body === "string" || - e.options.fetchOptions.body instanceof Blob || - (e.options.fetchOptions.body !== null && - typeof e.options.fetchOptions.body === "object" || - typeof e.options.fetchOptions.body === "function") && - (e.options.fetchOptions.body.buffer instanceof ArrayBuffer || - e.options.fetchOptions.body.buffer instanceof SharedArrayBuffer) && - typeof e.options.fetchOptions.body.byteLength === "number" && - typeof e.options.fetchOptions.body.byteOffset === "number" || - e.options.fetchOptions.body instanceof ArrayBuffer || - e.options.fetchOptions.body instanceof FormData || - e.options.fetchOptions.body instanceof URLSearchParams || - e.options.fetchOptions.body instanceof ReadableStream) && - (typeof e.options.fetchOptions.cache === "undefined" || - e.options.fetchOptions.cache === "default" || - e.options.fetchOptions.cache === "force-cache" || - e.options.fetchOptions.cache === "no-cache" || - e.options.fetchOptions.cache === "no-store" || - e.options.fetchOptions.cache === "only-if-cached" || - e.options.fetchOptions.cache === "reload") && - (typeof e.options.fetchOptions.credentials === "undefined" || - e.options.fetchOptions.credentials === "include" || - e.options.fetchOptions.credentials === "omit" || - e.options.fetchOptions.credentials === "same-origin") && - (typeof e.options.fetchOptions.headers === "undefined" || - e.options.fetchOptions.headers instanceof Headers || - Array.isArray(e.options.fetchOptions.headers) && - e.options.fetchOptions.headers.every((e: any) => - Array.isArray(e) && - e.every((e: any) => - typeof e === "string" - ) - ) || - (e.options.fetchOptions.headers !== null && - typeof e.options.fetchOptions.headers === "object" || - typeof e.options.fetchOptions.headers === "function") && - Object.entries(e.options.fetchOptions.headers) - .every(([key, value]) => (typeof value === "string" && - typeof key === "string"))) && - (typeof e.options.fetchOptions.integrity === "undefined" || - typeof e.options.fetchOptions.integrity === "string") && - (typeof e.options.fetchOptions.keepalive === "undefined" || - e.options.fetchOptions.keepalive === false || - e.options.fetchOptions.keepalive === true) && - (typeof e.options.fetchOptions.method === "undefined" || - typeof e.options.fetchOptions.method === "string") && - (typeof e.options.fetchOptions.mode === "undefined" || - e.options.fetchOptions.mode === "same-origin" || - e.options.fetchOptions.mode === "cors" || - e.options.fetchOptions.mode === "navigate" || - e.options.fetchOptions.mode === "no-cors") && - (typeof e.options.fetchOptions.redirect === "undefined" || - e.options.fetchOptions.redirect === "error" || - e.options.fetchOptions.redirect === "follow" || - e.options.fetchOptions.redirect === "manual") && - (typeof e.options.fetchOptions.referrer === "undefined" || - typeof e.options.fetchOptions.referrer === "string") && - (typeof e.options.fetchOptions.referrerPolicy === "undefined" || - e.options.fetchOptions.referrerPolicy === "" || - e.options.fetchOptions.referrerPolicy === "same-origin" || - e.options.fetchOptions.referrerPolicy === "no-referrer" || - e.options.fetchOptions.referrerPolicy === "no-referrer-when-downgrade" || - e.options.fetchOptions.referrerPolicy === "origin" || - e.options.fetchOptions.referrerPolicy === "origin-when-cross-origin" || - e.options.fetchOptions.referrerPolicy === "strict-origin" || - e.options.fetchOptions.referrerPolicy === "strict-origin-when-cross-origin" || - e.options.fetchOptions.referrerPolicy === "unsafe-url") && - (typeof e.options.fetchOptions.signal === "undefined" || - e.options.fetchOptions.signal === null || - e.options.fetchOptions.signal instanceof AbortSignal)) && - (typeof e.options.matchOptions === "undefined" || - (e.options.matchOptions !== null && - typeof e.options.matchOptions === "object" || - typeof e.options.matchOptions === "function") && - (typeof e.options.matchOptions.ignoreMethod === "undefined" || - e.options.matchOptions.ignoreMethod === false || - e.options.matchOptions.ignoreMethod === true) && - (typeof e.options.matchOptions.ignoreSearch === "undefined" || - e.options.matchOptions.ignoreSearch === false || - e.options.matchOptions.ignoreSearch === true) && - (typeof e.options.matchOptions.ignoreVary === "undefined" || - e.options.matchOptions.ignoreVary === false || - e.options.matchOptions.ignoreVary === true))) - ) && - (typeof obj.skipWaiting === "undefined" || - obj.skipWaiting === false || - obj.skipWaiting === true) && - (typeof obj.sourcemap === "undefined" || - obj.sourcemap === false || - obj.sourcemap === true) || - (obj !== null && - typeof obj === "object" || - typeof obj === "function") && - (typeof obj.additionalManifestEntries === "undefined" || - Array.isArray(obj.additionalManifestEntries) && - obj.additionalManifestEntries.every((e: any) => - (typeof e === "string" || - (e !== null && - typeof e === "object" || - typeof e === "function") && - (typeof e.integrity === "undefined" || - typeof e.integrity === "string") && - (e.revision === null || - typeof e.revision === "string") && - typeof e.url === "string") - )) && - (typeof obj.dontCacheBustURLsMatching === "undefined" || - obj.dontCacheBustURLsMatching instanceof RegExp) && - (typeof obj.manifestTransforms === "undefined" || - Array.isArray(obj.manifestTransforms) && - obj.manifestTransforms.every((e: any) => - (e !== null && - typeof e === "object" || - typeof e === "function") - )) && - (typeof obj.maximumFileSizeToCacheInBytes === "undefined" || - typeof obj.maximumFileSizeToCacheInBytes === "number") && - (obj.modifyURLPrefix !== null && - typeof obj.modifyURLPrefix === "object" || - typeof obj.modifyURLPrefix === "function") || - (obj !== null && - typeof obj === "object" || - typeof obj === "function") && - typeof obj.swDest === "string") - ) -} - -export function isGetManifestOptions(obj: any, _argumentName?: string): obj is GetManifestOptions { - return ( - ((obj !== null && - typeof obj === "object" || - typeof obj === "function") && - (typeof obj.globDirectory === "undefined" || - obj.globDirectory === null || - typeof obj.globDirectory === "string") && - (typeof obj.globFollow === "undefined" || - obj.globFollow === false || - obj.globFollow === true) && - Array.isArray(obj.globIgnores) && - obj.globIgnores.every((e: any) => - typeof e === "string" - ) && - Array.isArray(obj.globPatterns) && - obj.globPatterns.every((e: any) => - typeof e === "string" - ) && - (typeof obj.globStrict === "undefined" || - obj.globStrict === false || - obj.globStrict === true) && - (obj.templatedURLs !== null && - typeof obj.templatedURLs === "object" || - typeof obj.templatedURLs === "function") || - (obj !== null && - typeof obj === "object" || - typeof obj === "function") && - (typeof obj.additionalManifestEntries === "undefined" || - Array.isArray(obj.additionalManifestEntries) && - obj.additionalManifestEntries.every((e: any) => - (typeof e === "string" || - (e !== null && - typeof e === "object" || - typeof e === "function") && - (typeof e.integrity === "undefined" || - typeof e.integrity === "string") && - (e.revision === null || - typeof e.revision === "string") && - typeof e.url === "string") - )) && - (typeof obj.dontCacheBustURLsMatching === "undefined" || - obj.dontCacheBustURLsMatching instanceof RegExp) && - (typeof obj.manifestTransforms === "undefined" || - Array.isArray(obj.manifestTransforms) && - obj.manifestTransforms.every((e: any) => - (e !== null && - typeof e === "object" || - typeof e === "function") - )) && - (typeof obj.maximumFileSizeToCacheInBytes === "undefined" || - typeof obj.maximumFileSizeToCacheInBytes === "number") && - (obj.modifyURLPrefix !== null && - typeof obj.modifyURLPrefix === "object" || - typeof obj.modifyURLPrefix === "function")) - ) -} - -export function isInjectManifestOptions(obj: any, _argumentName?: string): obj is InjectManifestOptions { - return ( - ((obj !== null && - typeof obj === "object" || - typeof obj === "function") && - typeof obj.injectionPoint === "string" && - typeof obj.swSrc === "string" || - (obj !== null && - typeof obj === "object" || - typeof obj === "function") && - (typeof obj.globFollow === "undefined" || - obj.globFollow === false || - obj.globFollow === true) && - Array.isArray(obj.globIgnores) && - obj.globIgnores.every((e: any) => - typeof e === "string" - ) && - Array.isArray(obj.globPatterns) && - obj.globPatterns.every((e: any) => - typeof e === "string" - ) && - (typeof obj.globStrict === "undefined" || - obj.globStrict === false || - obj.globStrict === true) && - (obj.templatedURLs !== null && - typeof obj.templatedURLs === "object" || - typeof obj.templatedURLs === "function") || - (obj !== null && - typeof obj === "object" || - typeof obj === "function") && - (typeof obj.additionalManifestEntries === "undefined" || - Array.isArray(obj.additionalManifestEntries) && - obj.additionalManifestEntries.every((e: any) => - (typeof e === "string" || - (e !== null && - typeof e === "object" || - typeof e === "function") && - (typeof e.integrity === "undefined" || - typeof e.integrity === "string") && - (e.revision === null || - typeof e.revision === "string") && - typeof e.url === "string") - )) && - (typeof obj.dontCacheBustURLsMatching === "undefined" || - obj.dontCacheBustURLsMatching instanceof RegExp) && - (typeof obj.manifestTransforms === "undefined" || - Array.isArray(obj.manifestTransforms) && - obj.manifestTransforms.every((e: any) => - (e !== null && - typeof e === "object" || - typeof e === "function") - )) && - (typeof obj.maximumFileSizeToCacheInBytes === "undefined" || - typeof obj.maximumFileSizeToCacheInBytes === "number") && - (obj.modifyURLPrefix !== null && - typeof obj.modifyURLPrefix === "object" || - typeof obj.modifyURLPrefix === "function") || - (obj !== null && - typeof obj === "object" || - typeof obj === "function") && - typeof obj.swDest === "string" || - (obj !== null && - typeof obj === "object" || - typeof obj === "function") && - typeof obj.globDirectory === "string") - ) -} - -export function isWebpackGenerateSWOptions(obj: any, _argumentName?: string): obj is WebpackGenerateSWOptions { - return ( - ((obj !== null && - typeof obj === "object" || - typeof obj === "function") && - (typeof obj.chunks === "undefined" || - Array.isArray(obj.chunks) && - obj.chunks.every((e: any) => - typeof e === "string" - )) && - (typeof obj.exclude === "undefined" || - Array.isArray(obj.exclude) && - obj.exclude.every((e: any) => - (typeof e === "string" || - e instanceof RegExp || - (e !== null && - typeof e === "object" || - typeof e === "function")) - )) && - (typeof obj.excludeChunks === "undefined" || - Array.isArray(obj.excludeChunks) && - obj.excludeChunks.every((e: any) => - typeof e === "string" - )) && - (typeof obj.include === "undefined" || - Array.isArray(obj.include) && - obj.include.every((e: any) => - (typeof e === "string" || - e instanceof RegExp || - (e !== null && - typeof e === "object" || - typeof e === "function")) - )) && - (typeof obj.mode === "undefined" || - obj.mode === null || - typeof obj.mode === "string") || - (obj !== null && - typeof obj === "object" || - typeof obj === "function") && - (typeof obj.babelPresetEnvTargets === "undefined" || - Array.isArray(obj.babelPresetEnvTargets) && - obj.babelPresetEnvTargets.every((e: any) => - typeof e === "string" - )) && - (typeof obj.cacheId === "undefined" || - obj.cacheId === null || - typeof obj.cacheId === "string") && - (typeof obj.cleanupOutdatedCaches === "undefined" || - obj.cleanupOutdatedCaches === false || - obj.cleanupOutdatedCaches === true) && - (typeof obj.clientsClaim === "undefined" || - obj.clientsClaim === false || - obj.clientsClaim === true) && - (typeof obj.directoryIndex === "undefined" || - obj.directoryIndex === null || - typeof obj.directoryIndex === "string") && - (typeof obj.disableDevLogs === "undefined" || - obj.disableDevLogs === false || - obj.disableDevLogs === true) && - (typeof obj.ignoreURLParametersMatching === "undefined" || - Array.isArray(obj.ignoreURLParametersMatching) && - obj.ignoreURLParametersMatching.every((e: any) => - e instanceof RegExp - )) && - (typeof obj.importScripts === "undefined" || - Array.isArray(obj.importScripts) && - obj.importScripts.every((e: any) => - typeof e === "string" - )) && - (typeof obj.inlineWorkboxRuntime === "undefined" || - obj.inlineWorkboxRuntime === false || - obj.inlineWorkboxRuntime === true) && - (typeof obj.mode === "undefined" || - obj.mode === null || - typeof obj.mode === "string") && - (typeof obj.navigateFallback === "undefined" || - obj.navigateFallback === null || - typeof obj.navigateFallback === "string") && - (typeof obj.navigateFallbackAllowlist === "undefined" || - Array.isArray(obj.navigateFallbackAllowlist) && - obj.navigateFallbackAllowlist.every((e: any) => - e instanceof RegExp - )) && - (typeof obj.navigateFallbackDenylist === "undefined" || - Array.isArray(obj.navigateFallbackDenylist) && - obj.navigateFallbackDenylist.every((e: any) => - e instanceof RegExp - )) && - (typeof obj.navigationPreload === "undefined" || - obj.navigationPreload === false || - obj.navigationPreload === true) && - Array.isArray(obj.runtimeCaching) && - obj.runtimeCaching.every((e: any) => - (e !== null && - typeof e === "object" || - typeof e === "function") && - (typeof e.options === "undefined" || - (e.options !== null && - typeof e.options === "object" || - typeof e.options === "function") && - (typeof e.options.backgroundSync === "undefined" || - (e.options.backgroundSync !== null && - typeof e.options.backgroundSync === "object" || - typeof e.options.backgroundSync === "function") && - typeof e.options.backgroundSync.name === "string") && - (typeof e.options.broadcastUpdate === "undefined" || - (e.options.broadcastUpdate !== null && - typeof e.options.broadcastUpdate === "object" || - typeof e.options.broadcastUpdate === "function") && - (typeof e.options.broadcastUpdate.channelName === "undefined" || - typeof e.options.broadcastUpdate.channelName === "string")) && - (typeof e.options.cacheName === "undefined" || - e.options.cacheName === null || - typeof e.options.cacheName === "string") && - (typeof e.options.networkTimeoutSeconds === "undefined" || - typeof e.options.networkTimeoutSeconds === "number") && - (typeof e.options.plugins === "undefined" || - Array.isArray(e.options.plugins)) && - (typeof e.options.precacheFallback === "undefined" || - (e.options.precacheFallback !== null && - typeof e.options.precacheFallback === "object" || - typeof e.options.precacheFallback === "function") && - typeof e.options.precacheFallback.fallbackURL === "string") && - (typeof e.options.fetchOptions === "undefined" || - (e.options.fetchOptions !== null && - typeof e.options.fetchOptions === "object" || - typeof e.options.fetchOptions === "function") && - (typeof e.options.fetchOptions.body === "undefined" || - e.options.fetchOptions.body === null || - typeof e.options.fetchOptions.body === "string" || - e.options.fetchOptions.body instanceof Blob || - (e.options.fetchOptions.body !== null && - typeof e.options.fetchOptions.body === "object" || - typeof e.options.fetchOptions.body === "function") && - (e.options.fetchOptions.body.buffer instanceof ArrayBuffer || - e.options.fetchOptions.body.buffer instanceof SharedArrayBuffer) && - typeof e.options.fetchOptions.body.byteLength === "number" && - typeof e.options.fetchOptions.body.byteOffset === "number" || - e.options.fetchOptions.body instanceof ArrayBuffer || - e.options.fetchOptions.body instanceof FormData || - e.options.fetchOptions.body instanceof URLSearchParams || - e.options.fetchOptions.body instanceof ReadableStream) && - (typeof e.options.fetchOptions.cache === "undefined" || - e.options.fetchOptions.cache === "default" || - e.options.fetchOptions.cache === "force-cache" || - e.options.fetchOptions.cache === "no-cache" || - e.options.fetchOptions.cache === "no-store" || - e.options.fetchOptions.cache === "only-if-cached" || - e.options.fetchOptions.cache === "reload") && - (typeof e.options.fetchOptions.credentials === "undefined" || - e.options.fetchOptions.credentials === "include" || - e.options.fetchOptions.credentials === "omit" || - e.options.fetchOptions.credentials === "same-origin") && - (typeof e.options.fetchOptions.headers === "undefined" || - e.options.fetchOptions.headers instanceof Headers || - Array.isArray(e.options.fetchOptions.headers) && - e.options.fetchOptions.headers.every((e: any) => - Array.isArray(e) && - e.every((e: any) => - typeof e === "string" - ) - ) || - (e.options.fetchOptions.headers !== null && - typeof e.options.fetchOptions.headers === "object" || - typeof e.options.fetchOptions.headers === "function") && - Object.entries(e.options.fetchOptions.headers) - .every(([key, value]) => (typeof value === "string" && - typeof key === "string"))) && - (typeof e.options.fetchOptions.integrity === "undefined" || - typeof e.options.fetchOptions.integrity === "string") && - (typeof e.options.fetchOptions.keepalive === "undefined" || - e.options.fetchOptions.keepalive === false || - e.options.fetchOptions.keepalive === true) && - (typeof e.options.fetchOptions.method === "undefined" || - typeof e.options.fetchOptions.method === "string") && - (typeof e.options.fetchOptions.mode === "undefined" || - e.options.fetchOptions.mode === "same-origin" || - e.options.fetchOptions.mode === "cors" || - e.options.fetchOptions.mode === "navigate" || - e.options.fetchOptions.mode === "no-cors") && - (typeof e.options.fetchOptions.redirect === "undefined" || - e.options.fetchOptions.redirect === "error" || - e.options.fetchOptions.redirect === "follow" || - e.options.fetchOptions.redirect === "manual") && - (typeof e.options.fetchOptions.referrer === "undefined" || - typeof e.options.fetchOptions.referrer === "string") && - (typeof e.options.fetchOptions.referrerPolicy === "undefined" || - e.options.fetchOptions.referrerPolicy === "" || - e.options.fetchOptions.referrerPolicy === "same-origin" || - e.options.fetchOptions.referrerPolicy === "no-referrer" || - e.options.fetchOptions.referrerPolicy === "no-referrer-when-downgrade" || - e.options.fetchOptions.referrerPolicy === "origin" || - e.options.fetchOptions.referrerPolicy === "origin-when-cross-origin" || - e.options.fetchOptions.referrerPolicy === "strict-origin" || - e.options.fetchOptions.referrerPolicy === "strict-origin-when-cross-origin" || - e.options.fetchOptions.referrerPolicy === "unsafe-url") && - (typeof e.options.fetchOptions.signal === "undefined" || - e.options.fetchOptions.signal === null || - e.options.fetchOptions.signal instanceof AbortSignal)) && - (typeof e.options.matchOptions === "undefined" || - (e.options.matchOptions !== null && - typeof e.options.matchOptions === "object" || - typeof e.options.matchOptions === "function") && - (typeof e.options.matchOptions.ignoreMethod === "undefined" || - e.options.matchOptions.ignoreMethod === false || - e.options.matchOptions.ignoreMethod === true) && - (typeof e.options.matchOptions.ignoreSearch === "undefined" || - e.options.matchOptions.ignoreSearch === false || - e.options.matchOptions.ignoreSearch === true) && - (typeof e.options.matchOptions.ignoreVary === "undefined" || - e.options.matchOptions.ignoreVary === false || - e.options.matchOptions.ignoreVary === true))) - ) && - (typeof obj.skipWaiting === "undefined" || - obj.skipWaiting === false || - obj.skipWaiting === true) && - (typeof obj.sourcemap === "undefined" || - obj.sourcemap === false || - obj.sourcemap === true) || - (obj !== null && - typeof obj === "object" || - typeof obj === "function") && - (typeof obj.additionalManifestEntries === "undefined" || - Array.isArray(obj.additionalManifestEntries) && - obj.additionalManifestEntries.every((e: any) => - (typeof e === "string" || - (e !== null && - typeof e === "object" || - typeof e === "function") && - (typeof e.integrity === "undefined" || - typeof e.integrity === "string") && - (e.revision === null || - typeof e.revision === "string") && - typeof e.url === "string") - )) && - (typeof obj.dontCacheBustURLsMatching === "undefined" || - obj.dontCacheBustURLsMatching instanceof RegExp) && - (typeof obj.manifestTransforms === "undefined" || - Array.isArray(obj.manifestTransforms) && - obj.manifestTransforms.every((e: any) => - (e !== null && - typeof e === "object" || - typeof e === "function") - )) && - (typeof obj.maximumFileSizeToCacheInBytes === "undefined" || - typeof obj.maximumFileSizeToCacheInBytes === "number") && - (obj.modifyURLPrefix !== null && - typeof obj.modifyURLPrefix === "object" || - typeof obj.modifyURLPrefix === "function") || - (obj !== null && - typeof obj === "object" || - typeof obj === "function") && - typeof obj.swDest === "string" || - (obj !== null && - typeof obj === "object" || - typeof obj === "function") && - Array.isArray(obj.importScriptsViaChunks) && - obj.importScriptsViaChunks.every((e: any) => - typeof e === "string" - )) - ) -} - -export function isWebpackInjectManifestOptions(obj: any, _argumentName?: string): obj is WebpackInjectManifestOptions { - return ( - ((obj !== null && - typeof obj === "object" || - typeof obj === "function") && - (typeof obj.chunks === "undefined" || - Array.isArray(obj.chunks) && - obj.chunks.every((e: any) => - typeof e === "string" - )) && - (typeof obj.exclude === "undefined" || - Array.isArray(obj.exclude) && - obj.exclude.every((e: any) => - (typeof e === "string" || - e instanceof RegExp || - (e !== null && - typeof e === "object" || - typeof e === "function")) - )) && - (typeof obj.excludeChunks === "undefined" || - Array.isArray(obj.excludeChunks) && - obj.excludeChunks.every((e: any) => - typeof e === "string" - )) && - (typeof obj.include === "undefined" || - Array.isArray(obj.include) && - obj.include.every((e: any) => - (typeof e === "string" || - e instanceof RegExp || - (e !== null && - typeof e === "object" || - typeof e === "function")) - )) && - (typeof obj.mode === "undefined" || - obj.mode === null || - typeof obj.mode === "string") || - (obj !== null && - typeof obj === "object" || - typeof obj === "function") && - typeof obj.injectionPoint === "string" && - typeof obj.swSrc === "string" || - (obj !== null && - typeof obj === "object" || - typeof obj === "function") && - (typeof obj.additionalManifestEntries === "undefined" || - Array.isArray(obj.additionalManifestEntries) && - obj.additionalManifestEntries.every((e: any) => - (typeof e === "string" || - (e !== null && - typeof e === "object" || - typeof e === "function") && - (typeof e.integrity === "undefined" || - typeof e.integrity === "string") && - (e.revision === null || - typeof e.revision === "string") && - typeof e.url === "string") - )) && - (typeof obj.dontCacheBustURLsMatching === "undefined" || - obj.dontCacheBustURLsMatching instanceof RegExp) && - (typeof obj.manifestTransforms === "undefined" || - Array.isArray(obj.manifestTransforms) && - obj.manifestTransforms.every((e: any) => - (e !== null && - typeof e === "object" || - typeof e === "function") - )) && - (typeof obj.maximumFileSizeToCacheInBytes === "undefined" || - typeof obj.maximumFileSizeToCacheInBytes === "number") && - (obj.modifyURLPrefix !== null && - typeof obj.modifyURLPrefix === "object" || - typeof obj.modifyURLPrefix === "function") || - (obj !== null && - typeof obj === "object" || - typeof obj === "function") && - typeof obj.swDest === "string" || - (obj !== null && - typeof obj === "object" || - typeof obj === "function") && - (typeof obj.compileSrc === "undefined" || - obj.compileSrc === false || - obj.compileSrc === true) && - (typeof obj.webpackCompilationPlugins === "undefined" || - Array.isArray(obj.webpackCompilationPlugins))) - ) -} diff --git a/packages/workbox-build/src/types.ts b/packages/workbox-build/src/types.ts index a440df932..01f73fa12 100644 --- a/packages/workbox-build/src/types.ts +++ b/packages/workbox-build/src/types.ts @@ -1,13 +1,13 @@ import {PackageJson} from 'type-fest'; -import {BroadcastCacheUpdateOptions} from 'workbox-broadcast-update/BroadcastCacheUpdate'; -import {GoogleAnalyticsInitializeOptions} from 'workbox-google-analytics/initialize'; -import {HTTPMethod} from 'workbox-routing/utils/constants'; -import {QueueOptions} from 'workbox-background-sync/Queue'; -import {RouteHandler, RouteMatchCallback} from 'workbox-core/types'; -import {CacheableResponseOptions} from 'workbox-cacheable-response/CacheableResponse'; -import {ExpirationPluginOptions} from 'workbox-expiration/ExpirationPlugin'; -import {WorkboxPlugin} from 'workbox-core/types'; +import {BroadcastCacheUpdateOptions} from 'workbox-broadcast-update/BroadcastCacheUpdate.js'; +import {GoogleAnalyticsInitializeOptions} from 'workbox-google-analytics/initialize.js'; +import {HTTPMethod} from 'workbox-routing/utils/constants.js'; +import {QueueOptions} from 'workbox-background-sync/Queue.js'; +import {RouteHandler, RouteMatchCallback} from 'workbox-core/types.js'; +import {CacheableResponseOptions} from 'workbox-cacheable-response/CacheableResponse.js'; +import {ExpirationPluginOptions} from 'workbox-expiration/ExpirationPlugin.js'; +import {WorkboxPlugin} from 'workbox-core/types.js'; export interface ManifestEntry { integrity?: string; @@ -114,23 +114,18 @@ export interface SWDestPartial { swDest: string; } -/** @see {isGenerateSWOptions} ts-auto-guard:type-guard */ export type GenerateSWOptions = GlobPartial & GeneratePartial & BasePartial & SWDestPartial; -/** @see {isGetManifestOptions} ts-auto-guard:type-guard */ export type GetManifestOptions = GlobPartial & BasePartial; -/** @see {isInjectManifestOptions} ts-auto-guard:type-guard */ export type InjectManifestOptions = InjectPartial & Omit & BasePartial & SWDestPartial & { globDirectory: string; }; -/** @see {isWebpackGenerateSWOptions} ts-auto-guard:type-guard */ export type WebpackGenerateSWOptions = WebpackPartial & GeneratePartial & BasePartial & SWDestPartial & { importScriptsViaChunks: Array; }; -/** @see {isWebpackInjectManifestOptions} ts-auto-guard:type-guard */ export type WebpackInjectManifestOptions = WebpackPartial & InjectPartial & BasePartial & SWDestPartial & { compileSrc?: boolean; webpackCompilationPlugins?: Array; diff --git a/packages/workbox-build/tsconfig.json b/packages/workbox-build/tsconfig.json index c8414f932..efc4055bd 100644 --- a/packages/workbox-build/tsconfig.json +++ b/packages/workbox-build/tsconfig.json @@ -3,16 +3,18 @@ "compilerOptions": { "esModuleInterop": true, "module": "CommonJS", - "outDir": "build", + "outDir": "./build", "resolveJsonModule": true, - "rootDir": "src", + "rootDir": "./src", "target": "ES2018", "tsBuildInfoFile": "./tsconfig.tsbuildinfo" }, - "include": [ - "src/**/*.ts", + "files": [ "src/cdn-details.json" ], + "include": [ + "src/**/*.ts" + ], "references": [ {"path": "../workbox-background-sync/"}, {"path": "../workbox-broadcast-update/"}, diff --git a/tsconfig.json b/tsconfig.json index ac129dfed..0b2a24e36 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -21,12 +21,15 @@ "references": [ { "path": "./packages/workbox-broadcast-update/" }, { "path": "./packages/workbox-background-sync/" }, + { "path": "./packages/workbox-build/" }, { "path": "./packages/workbox-cacheable-response/" }, + { "path": "./packages/workbox-cli/" }, { "path": "./packages/workbox-core/" }, { "path": "./packages/workbox-expiration/" }, { "path": "./packages/workbox-navigation-preload/" }, { "path": "./packages/workbox-precaching/" }, { "path": "./packages/workbox-range-requests/" }, + { "path": "./packages/workbox-recipes/" }, { "path": "./packages/workbox-routing/" }, { "path": "./packages/workbox-strategies/" }, { "path": "./packages/workbox-streams/" }, From cd28f020b0b7f647ebf1c42bfa323b3f0b207010 Mon Sep 17 00:00:00 2001 From: Jeff Posnick Date: Wed, 9 Jun 2021 09:56:12 -0400 Subject: [PATCH 31/80] TS 4.1.5 --- package-lock.json | 6 +++--- package.json | 2 +- packages/workbox-core/src/_private/Deferred.ts | 2 +- packages/workbox-strategies/src/StrategyHandler.ts | 2 +- packages/workbox-window/src/Workbox.ts | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/package-lock.json b/package-lock.json index 2f6167d46..84b4ba697 100644 --- a/package-lock.json +++ b/package-lock.json @@ -17648,9 +17648,9 @@ } }, "typescript": { - "version": "3.9.7", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-3.9.7.tgz", - "integrity": "sha512-BLbiRkiBzAwsjut4x/dsibSTB6yWpwT5qWmC2OfuCg3GgVQCSgMs4vEctYPhsaGtd0AeuuHMkjZ2h2WG8MSzRw==", + "version": "4.1.5", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.1.5.tgz", + "integrity": "sha512-6OSu9PTIzmn9TCDiovULTnET6BgXtDYL4Gg4szY+cGsc3JP1dQL8qvE8kShTRx1NIw4Q9IBHlwODjkjWEtMUyA==", "dev": true }, "typescript-json-schema": { diff --git a/package.json b/package.json index c4ab7bfbe..a89a89f97 100644 --- a/package.json +++ b/package.json @@ -114,7 +114,7 @@ "sinon": "^9.0.3", "tempy": "^0.6.0", "type-fest": "^0.20.2", - "typescript": "^3.9.7", + "typescript": "^4.1.5", "typescript-json-schema": "^0.50.1", "upath": "^1.2.0", "webpack-v4": "npm:webpack@^4.44.2", diff --git a/packages/workbox-core/src/_private/Deferred.ts b/packages/workbox-core/src/_private/Deferred.ts index f32512807..b93608ff6 100644 --- a/packages/workbox-core/src/_private/Deferred.ts +++ b/packages/workbox-core/src/_private/Deferred.ts @@ -19,7 +19,7 @@ import '../_version.js'; */ class Deferred { promise: Promise; - resolve!: (value?: T) => void; + resolve!: (value: T) => void; reject!: (reason?: any) => void; /** diff --git a/packages/workbox-strategies/src/StrategyHandler.ts b/packages/workbox-strategies/src/StrategyHandler.ts index 4d8974881..26b1d05c6 100644 --- a/packages/workbox-strategies/src/StrategyHandler.ts +++ b/packages/workbox-strategies/src/StrategyHandler.ts @@ -520,7 +520,7 @@ class StrategyHandler { * `waitUntil()` promises. */ destroy() { - this._handlerDeferred.resolve(); + this._handlerDeferred.resolve(null); } /** diff --git a/packages/workbox-window/src/Workbox.ts b/packages/workbox-window/src/Workbox.ts index b018b4c2c..71558e621 100644 --- a/packages/workbox-window/src/Workbox.ts +++ b/packages/workbox-window/src/Workbox.ts @@ -519,7 +519,7 @@ class Workbox extends WorkboxEventTarget { if (process.env.NODE_ENV !== 'production') { logger.log('Registered service worker now controlling this page.'); } - this._controllingDeferred.resolve(sw); + this._controllingDeferred.resolve(sw!); } } From d258ac191ef4227ab7630003cb0b0df3d1d4e1c6 Mon Sep 17 00:00:00 2001 From: Jeff Posnick Date: Wed, 9 Jun 2021 10:25:16 -0400 Subject: [PATCH 32/80] Getting closer to validation --- gulp-tasks/build-node-packages.js | 2 +- packages/workbox-build/src/lib/validate-options.ts | 2 +- packages/workbox-build/src/schema/GenerateSWOptions.json | 2 +- packages/workbox-build/src/schema/GetManifestOptions.json | 2 +- packages/workbox-build/src/schema/InjectManifestOptions.json | 2 +- .../workbox-build/src/schema/WebpackGenerateSWOptions.json | 2 +- .../src/schema/WebpackInjectManifestOptions.json | 2 +- packages/workbox-build/src/types.ts | 3 +++ packages/workbox-build/tsconfig.json | 3 ++- test/workbox-build/node/lib/validate-options.js | 4 ++-- 10 files changed, 14 insertions(+), 10 deletions(-) diff --git a/gulp-tasks/build-node-packages.js b/gulp-tasks/build-node-packages.js index 714baf83c..4022898b3 100644 --- a/gulp-tasks/build-node-packages.js +++ b/gulp-tasks/build-node-packages.js @@ -33,7 +33,7 @@ async function buildNodePackage(packagePath) { async function generateWorkboxBuildJSONSchema(packagePath) { const program = TJS.programFromConfig(upath.join(packagePath, 'tsconfig.json')); - const generator = TJS.buildGenerator(program); + const generator = TJS.buildGenerator(program, {noExtraProps: true}); const optionTypes = [ 'GenerateSWOptions', 'GetManifestOptions', diff --git a/packages/workbox-build/src/lib/validate-options.ts b/packages/workbox-build/src/lib/validate-options.ts index 5af8d4191..5732a6a87 100644 --- a/packages/workbox-build/src/lib/validate-options.ts +++ b/packages/workbox-build/src/lib/validate-options.ts @@ -10,7 +10,7 @@ import Ajv, {DefinedError, JSONSchemaType} from 'ajv'; import {GenerateSWOptions, GetManifestOptions, InjectManifestOptions} from '../types'; -const ajv = new Ajv(); +const ajv = new Ajv({useDefaults: true}); // const defaults = { // babelPresetEnvTargets: ['chrome >= 56'], diff --git a/packages/workbox-build/src/schema/GenerateSWOptions.json b/packages/workbox-build/src/schema/GenerateSWOptions.json index 5ce6b92b8..62a60bd7c 100644 --- a/packages/workbox-build/src/schema/GenerateSWOptions.json +++ b/packages/workbox-build/src/schema/GenerateSWOptions.json @@ -1 +1 @@ -{"allOf":[{"$ref":"#/definitions/GlobPartial"},{"$ref":"#/definitions/GeneratePartial"},{"$ref":"#/definitions/BasePartial"},{"$ref":"#/definitions/SWDestPartial"}],"definitions":{"GlobPartial":{"type":"object","properties":{"globDirectory":{"type":["null","string"]},"globFollow":{"type":"boolean"},"globIgnores":{"type":"array","items":{"type":"string"}},"globPatterns":{"type":"array","items":{"type":"string"}},"globStrict":{"type":"boolean"},"templatedURLs":{"type":"object","additionalProperties":{"anyOf":[{"type":"array","items":{"type":"string"}},{"type":"string"}]}}}},"GeneratePartial":{"type":"object","properties":{"babelPresetEnvTargets":{"type":"array","items":{"type":"string"}},"cacheId":{"type":["null","string"]},"cleanupOutdatedCaches":{"type":"boolean"},"clientsClaim":{"type":"boolean"},"directoryIndex":{"type":["null","string"]},"disableDevLogs":{"type":"boolean"},"ignoreURLParametersMatching":{"type":"array","items":{"$ref":"#/definitions/RegExp"}},"importScripts":{"type":"array","items":{"type":"string"}},"inlineWorkboxRuntime":{"type":"boolean"},"mode":{"type":["null","string"]},"navigateFallback":{"type":["null","string"]},"navigateFallbackAllowlist":{"type":"array","items":{"$ref":"#/definitions/RegExp"}},"navigateFallbackDenylist":{"type":"array","items":{"$ref":"#/definitions/RegExp"}},"navigationPreload":{"type":"boolean"},"offlineGoogleAnalytics":{"anyOf":[{"$ref":"#/definitions/GoogleAnalyticsInitializeOptions"},{"type":"boolean"}]},"runtimeCaching":{"type":"array","items":{"$ref":"#/definitions/RuntimeCaching"}},"skipWaiting":{"type":"boolean"},"sourcemap":{"type":"boolean"}}},"RegExp":{"type":"object","properties":{"source":{"type":"string"},"global":{"type":"boolean"},"ignoreCase":{"type":"boolean"},"multiline":{"type":"boolean"},"lastIndex":{"type":"number"},"flags":{"type":"string"},"sticky":{"type":"boolean"},"unicode":{"type":"boolean"},"dotAll":{"type":"boolean"}}},"GoogleAnalyticsInitializeOptions":{"type":"object","properties":{"cacheName":{"type":"string"},"parameterOverrides":{"type":"object","additionalProperties":{"type":"string"}},"hitFilter":{"type":"object"}}},"RuntimeCaching":{"type":"object","properties":{"handler":{"anyOf":[{"$ref":"#/definitions/RouteHandlerCallback"},{"$ref":"#/definitions/RouteHandlerObject"},{"enum":["CacheFirst","CacheOnly","NetworkFirst","NetworkOnly","StaleWhileRevalidate"],"type":"string"}]},"method":{"enum":["DELETE","GET","HEAD","PATCH","POST","PUT"],"type":"string"},"options":{"type":"object","properties":{"backgroundSync":{"type":"object","properties":{"name":{"type":"string"},"options":{"$ref":"#/definitions/QueueOptions"}}},"broadcastUpdate":{"type":"object","properties":{"channelName":{"type":"string"},"options":{"$ref":"#/definitions/BroadcastCacheUpdateOptions"}}},"cacheableResponse":{"$ref":"#/definitions/CacheableResponseOptions"},"cacheName":{"type":["null","string"]},"expiration":{"$ref":"#/definitions/ExpirationPluginOptions"},"networkTimeoutSeconds":{"type":"number"},"plugins":{"type":"array","items":{"$ref":"#/definitions/WorkboxPlugin"}},"precacheFallback":{"type":"object","properties":{"fallbackURL":{"type":"string"}}},"fetchOptions":{"$ref":"#/definitions/RequestInit"},"matchOptions":{"$ref":"#/definitions/CacheQueryOptions"}}},"urlPattern":{"anyOf":[{"$ref":"#/definitions/RegExp"},{"$ref":"#/definitions/RouteMatchCallback"},{"type":"string"}]}}},"RouteHandlerCallback":{"description":"The \"handler\" callback is invoked whenever a `Router` matches a URL/Request\nto a `Route` via its `RouteMatchCallback`. This handler callback should\nreturn a `Promise` that resolves with a `Response`.\n\nIf a non-empty array or object is returned by the `RouteMatchCallback` it\nwill be passed in as this handler's `options.params` argument.","type":"object"},"RouteHandlerObject":{"description":"An object with a `handle` method of type `RouteHandlerCallback`.\n\nA `Route` object can be created with either an `RouteHandlerCallback`\nfunction or this `RouteHandler` object. The benefit of the `RouteHandler`\nis it can be extended (as is done by the `workbox-strategies` package).","type":"object","properties":{"handle":{"$ref":"#/definitions/RouteHandlerCallback"}}},"QueueOptions":{"type":"object","properties":{"onSync":{"$ref":"#/definitions/OnSyncCallback"},"maxRetentionTime":{"type":"number"}}},"OnSyncCallback":{"type":"object"},"BroadcastCacheUpdateOptions":{"type":"object","properties":{"headersToCheck":{"type":"array","items":{"type":"string"}},"generatePayload":{"type":"object"}}},"CacheableResponseOptions":{"type":"object","properties":{"statuses":{"type":"array","items":{"type":"number"}},"headers":{"type":"object","additionalProperties":{"type":"string"}}}},"ExpirationPluginOptions":{"type":"object","properties":{"maxEntries":{"type":"number"},"maxAgeSeconds":{"type":"number"},"matchOptions":{"$ref":"#/definitions/CacheQueryOptions"},"purgeOnQuotaError":{"type":"boolean"}}},"CacheQueryOptions":{"type":"object","properties":{"ignoreMethod":{"type":"boolean"},"ignoreSearch":{"type":"boolean"},"ignoreVary":{"type":"boolean"}}},"WorkboxPlugin":{"description":"An object with optional lifecycle callback properties for the fetch and\ncache operations.","type":"object","properties":{"cacheDidUpdate":{"$ref":"#/definitions/CacheDidUpdateCallback"},"cachedResponseWillBeUsed":{"$ref":"#/definitions/CachedResponseWillBeUsedCallback"},"cacheKeyWillBeUsed":{"$ref":"#/definitions/CacheKeyWillBeUsedCallback"},"cacheWillUpdate":{"$ref":"#/definitions/CacheWillUpdateCallback"},"fetchDidFail":{"$ref":"#/definitions/FetchDidFailCallback"},"fetchDidSucceed":{"$ref":"#/definitions/FetchDidSucceedCallback"},"handlerDidComplete":{"$ref":"#/definitions/HandlerDidCompleteCallback"},"handlerDidError":{"$ref":"#/definitions/HandlerDidErrorCallback"},"handlerDidRespond":{"$ref":"#/definitions/HandlerDidRespondCallback"},"handlerWillRespond":{"$ref":"#/definitions/HandlerWillRespondCallback"},"handlerWillStart":{"$ref":"#/definitions/HandlerWillStartCallback"},"requestWillFetch":{"$ref":"#/definitions/RequestWillFetchCallback"}}},"CacheDidUpdateCallback":{"type":"object"},"CachedResponseWillBeUsedCallback":{"type":"object"},"CacheKeyWillBeUsedCallback":{"type":"object"},"CacheWillUpdateCallback":{"type":"object"},"FetchDidFailCallback":{"type":"object"},"FetchDidSucceedCallback":{"type":"object"},"HandlerDidCompleteCallback":{"type":"object"},"HandlerDidErrorCallback":{"type":"object"},"HandlerDidRespondCallback":{"type":"object"},"HandlerWillRespondCallback":{"type":"object"},"HandlerWillStartCallback":{"type":"object"},"RequestWillFetchCallback":{"type":"object"},"RequestInit":{"type":"object","properties":{"body":{"anyOf":[{"$ref":"#/definitions/ArrayBuffer"},{"$ref":"#/definitions/ArrayBufferView"},{"$ref":"#/definitions/Blob"},{"$ref":"#/definitions/FormData"},{"$ref":"#/definitions/URLSearchParams"},{"$ref":"#/definitions/ReadableStream"},{"type":["null","string"]}]},"cache":{"enum":["default","force-cache","no-cache","no-store","only-if-cached","reload"],"type":"string"},"credentials":{"enum":["include","omit","same-origin"],"type":"string"},"headers":{"anyOf":[{"$ref":"#/definitions/Headers"},{"type":"array","items":{"type":"array","items":{"type":"string"}}},{"$ref":"#/definitions/Record"}]},"integrity":{"type":"string"},"keepalive":{"type":"boolean"},"method":{"type":"string"},"mode":{"enum":["cors","navigate","no-cors","same-origin"],"type":"string"},"redirect":{"enum":["error","follow","manual"],"type":"string"},"referrer":{"type":"string"},"referrerPolicy":{"enum":["","no-referrer","no-referrer-when-downgrade","origin","origin-when-cross-origin","same-origin","strict-origin","strict-origin-when-cross-origin","unsafe-url"],"type":"string"},"signal":{"anyOf":[{"$ref":"#/definitions/AbortSignal"},{"type":"null"}]},"window":{}}},"ArrayBuffer":{"type":"object","properties":{"byteLength":{"type":"number"},"__@toStringTag":{"type":"string"}}},"ArrayBufferView":{"type":"object","properties":{"buffer":{"anyOf":[{"$ref":"#/definitions/ArrayBuffer"},{"$ref":"#/definitions/SharedArrayBuffer"}]},"byteLength":{"type":"number"},"byteOffset":{"type":"number"}}},"SharedArrayBuffer":{"type":"object","properties":{"byteLength":{"type":"number"},"__@species":{"$ref":"#/definitions/SharedArrayBuffer"},"__@toStringTag":{"type":"string","enum":["SharedArrayBuffer"]}}},"Blob":{"type":"object","properties":{"size":{"type":"number"},"type":{"type":"string"}}},"FormData":{"type":"object"},"URLSearchParams":{"type":"object"},"ReadableStream":{"type":"object","properties":{"locked":{"type":"boolean"}}},"Headers":{"type":"object"},"Record":{"type":"object"},"AbortSignal":{"type":"object","properties":{"aborted":{"type":"boolean"},"onabort":{"type":["null","object"]}}},"RouteMatchCallback":{"description":"The \"match\" callback is used to determine if a `Route` should apply for a\nparticular URL and request. When matching occurs in response to a fetch\nevent from the client, the `event` object is also supplied. However, since\nthe match callback can be invoked outside of a fetch event, matching logic\nshould not assume the `event` object will always be available.\nIf the match callback returns a truthy value, the matching route's\n`RouteHandlerCallback` will be invoked immediately. If the value returned\nis a non-empty array or object, that value will be set on the handler's\n`options.params` argument.","type":"object"},"BasePartial":{"type":"object","properties":{"additionalManifestEntries":{"type":"array","items":{"anyOf":[{"$ref":"#/definitions/ManifestEntry"},{"type":"string"}]}},"dontCacheBustURLsMatching":{"$ref":"#/definitions/RegExp"},"manifestTransforms":{"type":"array","items":{"type":"object"}},"maximumFileSizeToCacheInBytes":{"type":"number"},"modifyURLPrefix":{"type":"object","additionalProperties":{"type":"string"}}}},"ManifestEntry":{"type":"object","properties":{"integrity":{"type":"string"},"revision":{"type":["null","string"]},"url":{"type":"string"}}},"SWDestPartial":{"type":"object","properties":{"swDest":{"type":"string"}}}},"$schema":"http://json-schema.org/draft-07/schema#"} +{"additionalProperties":false,"type":"object","properties":{"globDirectory":{"type":["null","string"]},"globFollow":{"type":"boolean"},"globIgnores":{"type":"array","items":{"type":"string"}},"globPatterns":{"type":"array","items":{"type":"string"}},"globStrict":{"default":true,"type":"boolean"},"templatedURLs":{"type":"object","additionalProperties":{"anyOf":[{"type":"array","items":{"type":"string"}},{"type":"string"}]}},"babelPresetEnvTargets":{"type":"array","items":{"type":"string"}},"cacheId":{"type":["null","string"]},"cleanupOutdatedCaches":{"type":"boolean"},"clientsClaim":{"type":"boolean"},"directoryIndex":{"type":["null","string"]},"disableDevLogs":{"type":"boolean"},"ignoreURLParametersMatching":{"type":"array","items":{"$ref":"#/definitions/RegExp"}},"importScripts":{"type":"array","items":{"type":"string"}},"inlineWorkboxRuntime":{"type":"boolean"},"mode":{"type":["null","string"]},"navigateFallback":{"type":["null","string"]},"navigateFallbackAllowlist":{"type":"array","items":{"$ref":"#/definitions/RegExp"}},"navigateFallbackDenylist":{"type":"array","items":{"$ref":"#/definitions/RegExp"}},"navigationPreload":{"type":"boolean"},"offlineGoogleAnalytics":{"anyOf":[{"$ref":"#/definitions/GoogleAnalyticsInitializeOptions"},{"type":"boolean"}]},"runtimeCaching":{"type":"array","items":{"$ref":"#/definitions/RuntimeCaching"}},"skipWaiting":{"type":"boolean"},"sourcemap":{"type":"boolean"},"additionalManifestEntries":{"type":"array","items":{"anyOf":[{"$ref":"#/definitions/ManifestEntry"},{"type":"string"}]}},"dontCacheBustURLsMatching":{"$ref":"#/definitions/RegExp"},"manifestTransforms":{"type":"array","items":{"type":"object","additionalProperties":false}},"maximumFileSizeToCacheInBytes":{"type":"number"},"modifyURLPrefix":{"type":"object","additionalProperties":{"type":"string"}},"swDest":{"type":"string"}},"definitions":{"RegExp":{"type":"object","properties":{"source":{"type":"string"},"global":{"type":"boolean"},"ignoreCase":{"type":"boolean"},"multiline":{"type":"boolean"},"lastIndex":{"type":"number"},"flags":{"type":"string"},"sticky":{"type":"boolean"},"unicode":{"type":"boolean"},"dotAll":{"type":"boolean"}},"additionalProperties":false},"GoogleAnalyticsInitializeOptions":{"type":"object","properties":{"cacheName":{"type":"string"},"parameterOverrides":{"type":"object","additionalProperties":{"type":"string"}},"hitFilter":{"type":"object","additionalProperties":false}},"additionalProperties":false},"RuntimeCaching":{"type":"object","properties":{"handler":{"anyOf":[{"$ref":"#/definitions/RouteHandlerCallback"},{"$ref":"#/definitions/RouteHandlerObject"},{"enum":["CacheFirst","CacheOnly","NetworkFirst","NetworkOnly","StaleWhileRevalidate"],"type":"string"}]},"method":{"enum":["DELETE","GET","HEAD","PATCH","POST","PUT"],"type":"string"},"options":{"type":"object","properties":{"backgroundSync":{"type":"object","properties":{"name":{"type":"string"},"options":{"$ref":"#/definitions/QueueOptions"}},"additionalProperties":false},"broadcastUpdate":{"type":"object","properties":{"channelName":{"type":"string"},"options":{"$ref":"#/definitions/BroadcastCacheUpdateOptions"}},"additionalProperties":false},"cacheableResponse":{"$ref":"#/definitions/CacheableResponseOptions"},"cacheName":{"type":["null","string"]},"expiration":{"$ref":"#/definitions/ExpirationPluginOptions"},"networkTimeoutSeconds":{"type":"number"},"plugins":{"type":"array","items":{"$ref":"#/definitions/WorkboxPlugin"}},"precacheFallback":{"type":"object","properties":{"fallbackURL":{"type":"string"}},"additionalProperties":false},"fetchOptions":{"$ref":"#/definitions/RequestInit"},"matchOptions":{"$ref":"#/definitions/CacheQueryOptions"}},"additionalProperties":false},"urlPattern":{"anyOf":[{"$ref":"#/definitions/RegExp"},{"$ref":"#/definitions/RouteMatchCallback"},{"type":"string"}]}},"additionalProperties":false},"RouteHandlerCallback":{"description":"The \"handler\" callback is invoked whenever a `Router` matches a URL/Request\nto a `Route` via its `RouteMatchCallback`. This handler callback should\nreturn a `Promise` that resolves with a `Response`.\n\nIf a non-empty array or object is returned by the `RouteMatchCallback` it\nwill be passed in as this handler's `options.params` argument.","type":"object","additionalProperties":false},"RouteHandlerObject":{"description":"An object with a `handle` method of type `RouteHandlerCallback`.\n\nA `Route` object can be created with either an `RouteHandlerCallback`\nfunction or this `RouteHandler` object. The benefit of the `RouteHandler`\nis it can be extended (as is done by the `workbox-strategies` package).","type":"object","properties":{"handle":{"$ref":"#/definitions/RouteHandlerCallback"}},"additionalProperties":false},"QueueOptions":{"type":"object","properties":{"onSync":{"$ref":"#/definitions/OnSyncCallback"},"maxRetentionTime":{"type":"number"}},"additionalProperties":false},"OnSyncCallback":{"type":"object","additionalProperties":false},"BroadcastCacheUpdateOptions":{"type":"object","properties":{"headersToCheck":{"type":"array","items":{"type":"string"}},"generatePayload":{"type":"object","additionalProperties":false}},"additionalProperties":false},"CacheableResponseOptions":{"type":"object","properties":{"statuses":{"type":"array","items":{"type":"number"}},"headers":{"type":"object","additionalProperties":{"type":"string"}}},"additionalProperties":false},"ExpirationPluginOptions":{"type":"object","properties":{"maxEntries":{"type":"number"},"maxAgeSeconds":{"type":"number"},"matchOptions":{"$ref":"#/definitions/CacheQueryOptions"},"purgeOnQuotaError":{"type":"boolean"}},"additionalProperties":false},"CacheQueryOptions":{"type":"object","properties":{"ignoreMethod":{"type":"boolean"},"ignoreSearch":{"type":"boolean"},"ignoreVary":{"type":"boolean"}},"additionalProperties":false},"WorkboxPlugin":{"description":"An object with optional lifecycle callback properties for the fetch and\ncache operations.","type":"object","properties":{"cacheDidUpdate":{"$ref":"#/definitions/CacheDidUpdateCallback"},"cachedResponseWillBeUsed":{"$ref":"#/definitions/CachedResponseWillBeUsedCallback"},"cacheKeyWillBeUsed":{"$ref":"#/definitions/CacheKeyWillBeUsedCallback"},"cacheWillUpdate":{"$ref":"#/definitions/CacheWillUpdateCallback"},"fetchDidFail":{"$ref":"#/definitions/FetchDidFailCallback"},"fetchDidSucceed":{"$ref":"#/definitions/FetchDidSucceedCallback"},"handlerDidComplete":{"$ref":"#/definitions/HandlerDidCompleteCallback"},"handlerDidError":{"$ref":"#/definitions/HandlerDidErrorCallback"},"handlerDidRespond":{"$ref":"#/definitions/HandlerDidRespondCallback"},"handlerWillRespond":{"$ref":"#/definitions/HandlerWillRespondCallback"},"handlerWillStart":{"$ref":"#/definitions/HandlerWillStartCallback"},"requestWillFetch":{"$ref":"#/definitions/RequestWillFetchCallback"}},"additionalProperties":false},"CacheDidUpdateCallback":{"type":"object","additionalProperties":false},"CachedResponseWillBeUsedCallback":{"type":"object","additionalProperties":false},"CacheKeyWillBeUsedCallback":{"type":"object","additionalProperties":false},"CacheWillUpdateCallback":{"type":"object","additionalProperties":false},"FetchDidFailCallback":{"type":"object","additionalProperties":false},"FetchDidSucceedCallback":{"type":"object","additionalProperties":false},"HandlerDidCompleteCallback":{"type":"object","additionalProperties":false},"HandlerDidErrorCallback":{"type":"object","additionalProperties":false},"HandlerDidRespondCallback":{"type":"object","additionalProperties":false},"HandlerWillRespondCallback":{"type":"object","additionalProperties":false},"HandlerWillStartCallback":{"type":"object","additionalProperties":false},"RequestWillFetchCallback":{"type":"object","additionalProperties":false},"RequestInit":{"type":"object","properties":{"body":{"anyOf":[{"$ref":"#/definitions/ArrayBuffer"},{"$ref":"#/definitions/ArrayBufferView"},{"$ref":"#/definitions/Blob"},{"$ref":"#/definitions/FormData"},{"$ref":"#/definitions/URLSearchParams"},{"$ref":"#/definitions/ReadableStream"},{"type":["null","string"]}]},"cache":{"enum":["default","force-cache","no-cache","no-store","only-if-cached","reload"],"type":"string"},"credentials":{"enum":["include","omit","same-origin"],"type":"string"},"headers":{"anyOf":[{"$ref":"#/definitions/Headers"},{"type":"array","items":{"type":"array","items":{"type":"string"}}},{"$ref":"#/definitions/Record"}]},"integrity":{"type":"string"},"keepalive":{"type":"boolean"},"method":{"type":"string"},"mode":{"enum":["cors","navigate","no-cors","same-origin"],"type":"string"},"redirect":{"enum":["error","follow","manual"],"type":"string"},"referrer":{"type":"string"},"referrerPolicy":{"enum":["","no-referrer","no-referrer-when-downgrade","origin","origin-when-cross-origin","same-origin","strict-origin","strict-origin-when-cross-origin","unsafe-url"],"type":"string"},"signal":{"anyOf":[{"$ref":"#/definitions/AbortSignal"},{"type":"null"}]},"window":{}},"additionalProperties":false},"ArrayBuffer":{"type":"object","properties":{"byteLength":{"type":"number"},"__@toStringTag":{"type":"string"}},"additionalProperties":false},"ArrayBufferView":{"type":"object","properties":{"buffer":{"anyOf":[{"$ref":"#/definitions/ArrayBuffer"},{"$ref":"#/definitions/SharedArrayBuffer"}]},"byteLength":{"type":"number"},"byteOffset":{"type":"number"}},"additionalProperties":false},"SharedArrayBuffer":{"type":"object","properties":{"byteLength":{"type":"number"},"__@species":{"$ref":"#/definitions/SharedArrayBuffer"},"__@toStringTag":{"type":"string","enum":["SharedArrayBuffer"]}},"additionalProperties":false},"Blob":{"type":"object","properties":{"size":{"type":"number"},"type":{"type":"string"}},"additionalProperties":false},"FormData":{"type":"object","additionalProperties":false},"URLSearchParams":{"type":"object","additionalProperties":false},"ReadableStream":{"type":"object","properties":{"locked":{"type":"boolean"}},"additionalProperties":false},"Headers":{"type":"object","additionalProperties":false},"Record":{"type":"object","additionalProperties":false},"AbortSignal":{"type":"object","properties":{"aborted":{"type":"boolean"},"onabort":{"anyOf":[{"type":"object","additionalProperties":false},{"type":"null"}]}},"additionalProperties":false},"RouteMatchCallback":{"description":"The \"match\" callback is used to determine if a `Route` should apply for a\nparticular URL and request. When matching occurs in response to a fetch\nevent from the client, the `event` object is also supplied. However, since\nthe match callback can be invoked outside of a fetch event, matching logic\nshould not assume the `event` object will always be available.\nIf the match callback returns a truthy value, the matching route's\n`RouteHandlerCallback` will be invoked immediately. If the value returned\nis a non-empty array or object, that value will be set on the handler's\n`options.params` argument.","type":"object","additionalProperties":false},"ManifestEntry":{"type":"object","properties":{"integrity":{"type":"string"},"revision":{"type":["null","string"]},"url":{"type":"string"}},"additionalProperties":false}},"$schema":"http://json-schema.org/draft-07/schema#"} diff --git a/packages/workbox-build/src/schema/GetManifestOptions.json b/packages/workbox-build/src/schema/GetManifestOptions.json index 57eb67c0e..68df0ef0d 100644 --- a/packages/workbox-build/src/schema/GetManifestOptions.json +++ b/packages/workbox-build/src/schema/GetManifestOptions.json @@ -1 +1 @@ -{"allOf":[{"$ref":"#/definitions/GlobPartial"},{"$ref":"#/definitions/BasePartial"}],"definitions":{"GlobPartial":{"type":"object","properties":{"globDirectory":{"type":["null","string"]},"globFollow":{"type":"boolean"},"globIgnores":{"type":"array","items":{"type":"string"}},"globPatterns":{"type":"array","items":{"type":"string"}},"globStrict":{"type":"boolean"},"templatedURLs":{"type":"object","additionalProperties":{"anyOf":[{"type":"array","items":{"type":"string"}},{"type":"string"}]}}}},"GeneratePartial":{"type":"object","properties":{"babelPresetEnvTargets":{"type":"array","items":{"type":"string"}},"cacheId":{"type":["null","string"]},"cleanupOutdatedCaches":{"type":"boolean"},"clientsClaim":{"type":"boolean"},"directoryIndex":{"type":["null","string"]},"disableDevLogs":{"type":"boolean"},"ignoreURLParametersMatching":{"type":"array","items":{"$ref":"#/definitions/RegExp"}},"importScripts":{"type":"array","items":{"type":"string"}},"inlineWorkboxRuntime":{"type":"boolean"},"mode":{"type":["null","string"]},"navigateFallback":{"type":["null","string"]},"navigateFallbackAllowlist":{"type":"array","items":{"$ref":"#/definitions/RegExp"}},"navigateFallbackDenylist":{"type":"array","items":{"$ref":"#/definitions/RegExp"}},"navigationPreload":{"type":"boolean"},"offlineGoogleAnalytics":{"anyOf":[{"$ref":"#/definitions/GoogleAnalyticsInitializeOptions"},{"type":"boolean"}]},"runtimeCaching":{"type":"array","items":{"$ref":"#/definitions/RuntimeCaching"}},"skipWaiting":{"type":"boolean"},"sourcemap":{"type":"boolean"}}},"RegExp":{"type":"object","properties":{"source":{"type":"string"},"global":{"type":"boolean"},"ignoreCase":{"type":"boolean"},"multiline":{"type":"boolean"},"lastIndex":{"type":"number"},"flags":{"type":"string"},"sticky":{"type":"boolean"},"unicode":{"type":"boolean"},"dotAll":{"type":"boolean"}}},"GoogleAnalyticsInitializeOptions":{"type":"object","properties":{"cacheName":{"type":"string"},"parameterOverrides":{"type":"object","additionalProperties":{"type":"string"}},"hitFilter":{"type":"object"}}},"RuntimeCaching":{"type":"object","properties":{"handler":{"anyOf":[{"$ref":"#/definitions/RouteHandlerCallback"},{"$ref":"#/definitions/RouteHandlerObject"},{"enum":["CacheFirst","CacheOnly","NetworkFirst","NetworkOnly","StaleWhileRevalidate"],"type":"string"}]},"method":{"enum":["DELETE","GET","HEAD","PATCH","POST","PUT"],"type":"string"},"options":{"type":"object","properties":{"backgroundSync":{"type":"object","properties":{"name":{"type":"string"},"options":{"$ref":"#/definitions/QueueOptions"}}},"broadcastUpdate":{"type":"object","properties":{"channelName":{"type":"string"},"options":{"$ref":"#/definitions/BroadcastCacheUpdateOptions"}}},"cacheableResponse":{"$ref":"#/definitions/CacheableResponseOptions"},"cacheName":{"type":["null","string"]},"expiration":{"$ref":"#/definitions/ExpirationPluginOptions"},"networkTimeoutSeconds":{"type":"number"},"plugins":{"type":"array","items":{"$ref":"#/definitions/WorkboxPlugin"}},"precacheFallback":{"type":"object","properties":{"fallbackURL":{"type":"string"}}},"fetchOptions":{"$ref":"#/definitions/RequestInit"},"matchOptions":{"$ref":"#/definitions/CacheQueryOptions"}}},"urlPattern":{"anyOf":[{"$ref":"#/definitions/RegExp"},{"$ref":"#/definitions/RouteMatchCallback"},{"type":"string"}]}}},"RouteHandlerCallback":{"description":"The \"handler\" callback is invoked whenever a `Router` matches a URL/Request\nto a `Route` via its `RouteMatchCallback`. This handler callback should\nreturn a `Promise` that resolves with a `Response`.\n\nIf a non-empty array or object is returned by the `RouteMatchCallback` it\nwill be passed in as this handler's `options.params` argument.","type":"object"},"RouteHandlerObject":{"description":"An object with a `handle` method of type `RouteHandlerCallback`.\n\nA `Route` object can be created with either an `RouteHandlerCallback`\nfunction or this `RouteHandler` object. The benefit of the `RouteHandler`\nis it can be extended (as is done by the `workbox-strategies` package).","type":"object","properties":{"handle":{"$ref":"#/definitions/RouteHandlerCallback"}}},"QueueOptions":{"type":"object","properties":{"onSync":{"$ref":"#/definitions/OnSyncCallback"},"maxRetentionTime":{"type":"number"}}},"OnSyncCallback":{"type":"object"},"BroadcastCacheUpdateOptions":{"type":"object","properties":{"headersToCheck":{"type":"array","items":{"type":"string"}},"generatePayload":{"type":"object"}}},"CacheableResponseOptions":{"type":"object","properties":{"statuses":{"type":"array","items":{"type":"number"}},"headers":{"type":"object","additionalProperties":{"type":"string"}}}},"ExpirationPluginOptions":{"type":"object","properties":{"maxEntries":{"type":"number"},"maxAgeSeconds":{"type":"number"},"matchOptions":{"$ref":"#/definitions/CacheQueryOptions"},"purgeOnQuotaError":{"type":"boolean"}}},"CacheQueryOptions":{"type":"object","properties":{"ignoreMethod":{"type":"boolean"},"ignoreSearch":{"type":"boolean"},"ignoreVary":{"type":"boolean"}}},"WorkboxPlugin":{"description":"An object with optional lifecycle callback properties for the fetch and\ncache operations.","type":"object","properties":{"cacheDidUpdate":{"$ref":"#/definitions/CacheDidUpdateCallback"},"cachedResponseWillBeUsed":{"$ref":"#/definitions/CachedResponseWillBeUsedCallback"},"cacheKeyWillBeUsed":{"$ref":"#/definitions/CacheKeyWillBeUsedCallback"},"cacheWillUpdate":{"$ref":"#/definitions/CacheWillUpdateCallback"},"fetchDidFail":{"$ref":"#/definitions/FetchDidFailCallback"},"fetchDidSucceed":{"$ref":"#/definitions/FetchDidSucceedCallback"},"handlerDidComplete":{"$ref":"#/definitions/HandlerDidCompleteCallback"},"handlerDidError":{"$ref":"#/definitions/HandlerDidErrorCallback"},"handlerDidRespond":{"$ref":"#/definitions/HandlerDidRespondCallback"},"handlerWillRespond":{"$ref":"#/definitions/HandlerWillRespondCallback"},"handlerWillStart":{"$ref":"#/definitions/HandlerWillStartCallback"},"requestWillFetch":{"$ref":"#/definitions/RequestWillFetchCallback"}}},"CacheDidUpdateCallback":{"type":"object"},"CachedResponseWillBeUsedCallback":{"type":"object"},"CacheKeyWillBeUsedCallback":{"type":"object"},"CacheWillUpdateCallback":{"type":"object"},"FetchDidFailCallback":{"type":"object"},"FetchDidSucceedCallback":{"type":"object"},"HandlerDidCompleteCallback":{"type":"object"},"HandlerDidErrorCallback":{"type":"object"},"HandlerDidRespondCallback":{"type":"object"},"HandlerWillRespondCallback":{"type":"object"},"HandlerWillStartCallback":{"type":"object"},"RequestWillFetchCallback":{"type":"object"},"RequestInit":{"type":"object","properties":{"body":{"anyOf":[{"$ref":"#/definitions/ArrayBuffer"},{"$ref":"#/definitions/ArrayBufferView"},{"$ref":"#/definitions/Blob"},{"$ref":"#/definitions/FormData"},{"$ref":"#/definitions/URLSearchParams"},{"$ref":"#/definitions/ReadableStream"},{"type":["null","string"]}]},"cache":{"enum":["default","force-cache","no-cache","no-store","only-if-cached","reload"],"type":"string"},"credentials":{"enum":["include","omit","same-origin"],"type":"string"},"headers":{"anyOf":[{"$ref":"#/definitions/Headers"},{"type":"array","items":{"type":"array","items":{"type":"string"}}},{"$ref":"#/definitions/Record"}]},"integrity":{"type":"string"},"keepalive":{"type":"boolean"},"method":{"type":"string"},"mode":{"enum":["cors","navigate","no-cors","same-origin"],"type":"string"},"redirect":{"enum":["error","follow","manual"],"type":"string"},"referrer":{"type":"string"},"referrerPolicy":{"enum":["","no-referrer","no-referrer-when-downgrade","origin","origin-when-cross-origin","same-origin","strict-origin","strict-origin-when-cross-origin","unsafe-url"],"type":"string"},"signal":{"anyOf":[{"$ref":"#/definitions/AbortSignal"},{"type":"null"}]},"window":{}}},"ArrayBuffer":{"type":"object","properties":{"byteLength":{"type":"number"},"__@toStringTag":{"type":"string"}}},"ArrayBufferView":{"type":"object","properties":{"buffer":{"anyOf":[{"$ref":"#/definitions/ArrayBuffer"},{"$ref":"#/definitions/SharedArrayBuffer"}]},"byteLength":{"type":"number"},"byteOffset":{"type":"number"}}},"SharedArrayBuffer":{"type":"object","properties":{"byteLength":{"type":"number"},"__@species":{"$ref":"#/definitions/SharedArrayBuffer"},"__@toStringTag":{"type":"string","enum":["SharedArrayBuffer"]}}},"Blob":{"type":"object","properties":{"size":{"type":"number"},"type":{"type":"string"}}},"FormData":{"type":"object"},"URLSearchParams":{"type":"object"},"ReadableStream":{"type":"object","properties":{"locked":{"type":"boolean"}}},"Headers":{"type":"object"},"Record":{"type":"object"},"AbortSignal":{"type":"object","properties":{"aborted":{"type":"boolean"},"onabort":{"type":["null","object"]}}},"RouteMatchCallback":{"description":"The \"match\" callback is used to determine if a `Route` should apply for a\nparticular URL and request. When matching occurs in response to a fetch\nevent from the client, the `event` object is also supplied. However, since\nthe match callback can be invoked outside of a fetch event, matching logic\nshould not assume the `event` object will always be available.\nIf the match callback returns a truthy value, the matching route's\n`RouteHandlerCallback` will be invoked immediately. If the value returned\nis a non-empty array or object, that value will be set on the handler's\n`options.params` argument.","type":"object"},"BasePartial":{"type":"object","properties":{"additionalManifestEntries":{"type":"array","items":{"anyOf":[{"$ref":"#/definitions/ManifestEntry"},{"type":"string"}]}},"dontCacheBustURLsMatching":{"$ref":"#/definitions/RegExp"},"manifestTransforms":{"type":"array","items":{"type":"object"}},"maximumFileSizeToCacheInBytes":{"type":"number"},"modifyURLPrefix":{"type":"object","additionalProperties":{"type":"string"}}}},"ManifestEntry":{"type":"object","properties":{"integrity":{"type":"string"},"revision":{"type":["null","string"]},"url":{"type":"string"}}},"SWDestPartial":{"type":"object","properties":{"swDest":{"type":"string"}}}},"$schema":"http://json-schema.org/draft-07/schema#"} +{"additionalProperties":false,"type":"object","properties":{"globDirectory":{"type":["null","string"]},"globFollow":{"type":"boolean"},"globIgnores":{"type":"array","items":{"type":"string"}},"globPatterns":{"type":"array","items":{"type":"string"}},"globStrict":{"default":true,"type":"boolean"},"templatedURLs":{"type":"object","additionalProperties":{"anyOf":[{"type":"array","items":{"type":"string"}},{"type":"string"}]}},"additionalManifestEntries":{"type":"array","items":{"anyOf":[{"$ref":"#/definitions/ManifestEntry"},{"type":"string"}]}},"dontCacheBustURLsMatching":{"$ref":"#/definitions/RegExp"},"manifestTransforms":{"type":"array","items":{"type":"object","additionalProperties":false}},"maximumFileSizeToCacheInBytes":{"type":"number"},"modifyURLPrefix":{"type":"object","additionalProperties":{"type":"string"}}},"definitions":{"RegExp":{"type":"object","properties":{"source":{"type":"string"},"global":{"type":"boolean"},"ignoreCase":{"type":"boolean"},"multiline":{"type":"boolean"},"lastIndex":{"type":"number"},"flags":{"type":"string"},"sticky":{"type":"boolean"},"unicode":{"type":"boolean"},"dotAll":{"type":"boolean"}},"additionalProperties":false},"GoogleAnalyticsInitializeOptions":{"type":"object","properties":{"cacheName":{"type":"string"},"parameterOverrides":{"type":"object","additionalProperties":{"type":"string"}},"hitFilter":{"type":"object","additionalProperties":false}},"additionalProperties":false},"RuntimeCaching":{"type":"object","properties":{"handler":{"anyOf":[{"$ref":"#/definitions/RouteHandlerCallback"},{"$ref":"#/definitions/RouteHandlerObject"},{"enum":["CacheFirst","CacheOnly","NetworkFirst","NetworkOnly","StaleWhileRevalidate"],"type":"string"}]},"method":{"enum":["DELETE","GET","HEAD","PATCH","POST","PUT"],"type":"string"},"options":{"type":"object","properties":{"backgroundSync":{"type":"object","properties":{"name":{"type":"string"},"options":{"$ref":"#/definitions/QueueOptions"}},"additionalProperties":false},"broadcastUpdate":{"type":"object","properties":{"channelName":{"type":"string"},"options":{"$ref":"#/definitions/BroadcastCacheUpdateOptions"}},"additionalProperties":false},"cacheableResponse":{"$ref":"#/definitions/CacheableResponseOptions"},"cacheName":{"type":["null","string"]},"expiration":{"$ref":"#/definitions/ExpirationPluginOptions"},"networkTimeoutSeconds":{"type":"number"},"plugins":{"type":"array","items":{"$ref":"#/definitions/WorkboxPlugin"}},"precacheFallback":{"type":"object","properties":{"fallbackURL":{"type":"string"}},"additionalProperties":false},"fetchOptions":{"$ref":"#/definitions/RequestInit"},"matchOptions":{"$ref":"#/definitions/CacheQueryOptions"}},"additionalProperties":false},"urlPattern":{"anyOf":[{"$ref":"#/definitions/RegExp"},{"$ref":"#/definitions/RouteMatchCallback"},{"type":"string"}]}},"additionalProperties":false},"RouteHandlerCallback":{"description":"The \"handler\" callback is invoked whenever a `Router` matches a URL/Request\nto a `Route` via its `RouteMatchCallback`. This handler callback should\nreturn a `Promise` that resolves with a `Response`.\n\nIf a non-empty array or object is returned by the `RouteMatchCallback` it\nwill be passed in as this handler's `options.params` argument.","type":"object","additionalProperties":false},"RouteHandlerObject":{"description":"An object with a `handle` method of type `RouteHandlerCallback`.\n\nA `Route` object can be created with either an `RouteHandlerCallback`\nfunction or this `RouteHandler` object. The benefit of the `RouteHandler`\nis it can be extended (as is done by the `workbox-strategies` package).","type":"object","properties":{"handle":{"$ref":"#/definitions/RouteHandlerCallback"}},"additionalProperties":false},"QueueOptions":{"type":"object","properties":{"onSync":{"$ref":"#/definitions/OnSyncCallback"},"maxRetentionTime":{"type":"number"}},"additionalProperties":false},"OnSyncCallback":{"type":"object","additionalProperties":false},"BroadcastCacheUpdateOptions":{"type":"object","properties":{"headersToCheck":{"type":"array","items":{"type":"string"}},"generatePayload":{"type":"object","additionalProperties":false}},"additionalProperties":false},"CacheableResponseOptions":{"type":"object","properties":{"statuses":{"type":"array","items":{"type":"number"}},"headers":{"type":"object","additionalProperties":{"type":"string"}}},"additionalProperties":false},"ExpirationPluginOptions":{"type":"object","properties":{"maxEntries":{"type":"number"},"maxAgeSeconds":{"type":"number"},"matchOptions":{"$ref":"#/definitions/CacheQueryOptions"},"purgeOnQuotaError":{"type":"boolean"}},"additionalProperties":false},"CacheQueryOptions":{"type":"object","properties":{"ignoreMethod":{"type":"boolean"},"ignoreSearch":{"type":"boolean"},"ignoreVary":{"type":"boolean"}},"additionalProperties":false},"WorkboxPlugin":{"description":"An object with optional lifecycle callback properties for the fetch and\ncache operations.","type":"object","properties":{"cacheDidUpdate":{"$ref":"#/definitions/CacheDidUpdateCallback"},"cachedResponseWillBeUsed":{"$ref":"#/definitions/CachedResponseWillBeUsedCallback"},"cacheKeyWillBeUsed":{"$ref":"#/definitions/CacheKeyWillBeUsedCallback"},"cacheWillUpdate":{"$ref":"#/definitions/CacheWillUpdateCallback"},"fetchDidFail":{"$ref":"#/definitions/FetchDidFailCallback"},"fetchDidSucceed":{"$ref":"#/definitions/FetchDidSucceedCallback"},"handlerDidComplete":{"$ref":"#/definitions/HandlerDidCompleteCallback"},"handlerDidError":{"$ref":"#/definitions/HandlerDidErrorCallback"},"handlerDidRespond":{"$ref":"#/definitions/HandlerDidRespondCallback"},"handlerWillRespond":{"$ref":"#/definitions/HandlerWillRespondCallback"},"handlerWillStart":{"$ref":"#/definitions/HandlerWillStartCallback"},"requestWillFetch":{"$ref":"#/definitions/RequestWillFetchCallback"}},"additionalProperties":false},"CacheDidUpdateCallback":{"type":"object","additionalProperties":false},"CachedResponseWillBeUsedCallback":{"type":"object","additionalProperties":false},"CacheKeyWillBeUsedCallback":{"type":"object","additionalProperties":false},"CacheWillUpdateCallback":{"type":"object","additionalProperties":false},"FetchDidFailCallback":{"type":"object","additionalProperties":false},"FetchDidSucceedCallback":{"type":"object","additionalProperties":false},"HandlerDidCompleteCallback":{"type":"object","additionalProperties":false},"HandlerDidErrorCallback":{"type":"object","additionalProperties":false},"HandlerDidRespondCallback":{"type":"object","additionalProperties":false},"HandlerWillRespondCallback":{"type":"object","additionalProperties":false},"HandlerWillStartCallback":{"type":"object","additionalProperties":false},"RequestWillFetchCallback":{"type":"object","additionalProperties":false},"RequestInit":{"type":"object","properties":{"body":{"anyOf":[{"$ref":"#/definitions/ArrayBuffer"},{"$ref":"#/definitions/ArrayBufferView"},{"$ref":"#/definitions/Blob"},{"$ref":"#/definitions/FormData"},{"$ref":"#/definitions/URLSearchParams"},{"$ref":"#/definitions/ReadableStream"},{"type":["null","string"]}]},"cache":{"enum":["default","force-cache","no-cache","no-store","only-if-cached","reload"],"type":"string"},"credentials":{"enum":["include","omit","same-origin"],"type":"string"},"headers":{"anyOf":[{"$ref":"#/definitions/Headers"},{"type":"array","items":{"type":"array","items":{"type":"string"}}},{"$ref":"#/definitions/Record"}]},"integrity":{"type":"string"},"keepalive":{"type":"boolean"},"method":{"type":"string"},"mode":{"enum":["cors","navigate","no-cors","same-origin"],"type":"string"},"redirect":{"enum":["error","follow","manual"],"type":"string"},"referrer":{"type":"string"},"referrerPolicy":{"enum":["","no-referrer","no-referrer-when-downgrade","origin","origin-when-cross-origin","same-origin","strict-origin","strict-origin-when-cross-origin","unsafe-url"],"type":"string"},"signal":{"anyOf":[{"$ref":"#/definitions/AbortSignal"},{"type":"null"}]},"window":{}},"additionalProperties":false},"ArrayBuffer":{"type":"object","properties":{"byteLength":{"type":"number"},"__@toStringTag":{"type":"string"}},"additionalProperties":false},"ArrayBufferView":{"type":"object","properties":{"buffer":{"anyOf":[{"$ref":"#/definitions/ArrayBuffer"},{"$ref":"#/definitions/SharedArrayBuffer"}]},"byteLength":{"type":"number"},"byteOffset":{"type":"number"}},"additionalProperties":false},"SharedArrayBuffer":{"type":"object","properties":{"byteLength":{"type":"number"},"__@species":{"$ref":"#/definitions/SharedArrayBuffer"},"__@toStringTag":{"type":"string","enum":["SharedArrayBuffer"]}},"additionalProperties":false},"Blob":{"type":"object","properties":{"size":{"type":"number"},"type":{"type":"string"}},"additionalProperties":false},"FormData":{"type":"object","additionalProperties":false},"URLSearchParams":{"type":"object","additionalProperties":false},"ReadableStream":{"type":"object","properties":{"locked":{"type":"boolean"}},"additionalProperties":false},"Headers":{"type":"object","additionalProperties":false},"Record":{"type":"object","additionalProperties":false},"AbortSignal":{"type":"object","properties":{"aborted":{"type":"boolean"},"onabort":{"anyOf":[{"type":"object","additionalProperties":false},{"type":"null"}]}},"additionalProperties":false},"RouteMatchCallback":{"description":"The \"match\" callback is used to determine if a `Route` should apply for a\nparticular URL and request. When matching occurs in response to a fetch\nevent from the client, the `event` object is also supplied. However, since\nthe match callback can be invoked outside of a fetch event, matching logic\nshould not assume the `event` object will always be available.\nIf the match callback returns a truthy value, the matching route's\n`RouteHandlerCallback` will be invoked immediately. If the value returned\nis a non-empty array or object, that value will be set on the handler's\n`options.params` argument.","type":"object","additionalProperties":false},"ManifestEntry":{"type":"object","properties":{"integrity":{"type":"string"},"revision":{"type":["null","string"]},"url":{"type":"string"}},"additionalProperties":false}},"$schema":"http://json-schema.org/draft-07/schema#"} diff --git a/packages/workbox-build/src/schema/InjectManifestOptions.json b/packages/workbox-build/src/schema/InjectManifestOptions.json index 521772097..8621ed37b 100644 --- a/packages/workbox-build/src/schema/InjectManifestOptions.json +++ b/packages/workbox-build/src/schema/InjectManifestOptions.json @@ -1 +1 @@ -{"allOf":[{"$ref":"#/definitions/InjectPartial"},{"$ref":"#/definitions/Omit"},{"$ref":"#/definitions/BasePartial"},{"$ref":"#/definitions/SWDestPartial"},{"type":"object","properties":{"globDirectory":{"type":"string"}}}],"definitions":{"GlobPartial":{"type":"object","properties":{"globDirectory":{"type":["null","string"]},"globFollow":{"type":"boolean"},"globIgnores":{"type":"array","items":{"type":"string"}},"globPatterns":{"type":"array","items":{"type":"string"}},"globStrict":{"type":"boolean"},"templatedURLs":{"type":"object","additionalProperties":{"anyOf":[{"type":"array","items":{"type":"string"}},{"type":"string"}]}}}},"GeneratePartial":{"type":"object","properties":{"babelPresetEnvTargets":{"type":"array","items":{"type":"string"}},"cacheId":{"type":["null","string"]},"cleanupOutdatedCaches":{"type":"boolean"},"clientsClaim":{"type":"boolean"},"directoryIndex":{"type":["null","string"]},"disableDevLogs":{"type":"boolean"},"ignoreURLParametersMatching":{"type":"array","items":{"$ref":"#/definitions/RegExp"}},"importScripts":{"type":"array","items":{"type":"string"}},"inlineWorkboxRuntime":{"type":"boolean"},"mode":{"type":["null","string"]},"navigateFallback":{"type":["null","string"]},"navigateFallbackAllowlist":{"type":"array","items":{"$ref":"#/definitions/RegExp"}},"navigateFallbackDenylist":{"type":"array","items":{"$ref":"#/definitions/RegExp"}},"navigationPreload":{"type":"boolean"},"offlineGoogleAnalytics":{"anyOf":[{"$ref":"#/definitions/GoogleAnalyticsInitializeOptions"},{"type":"boolean"}]},"runtimeCaching":{"type":"array","items":{"$ref":"#/definitions/RuntimeCaching"}},"skipWaiting":{"type":"boolean"},"sourcemap":{"type":"boolean"}}},"RegExp":{"type":"object","properties":{"source":{"type":"string"},"global":{"type":"boolean"},"ignoreCase":{"type":"boolean"},"multiline":{"type":"boolean"},"lastIndex":{"type":"number"},"flags":{"type":"string"},"sticky":{"type":"boolean"},"unicode":{"type":"boolean"},"dotAll":{"type":"boolean"}}},"GoogleAnalyticsInitializeOptions":{"type":"object","properties":{"cacheName":{"type":"string"},"parameterOverrides":{"type":"object","additionalProperties":{"type":"string"}},"hitFilter":{"type":"object"}}},"RuntimeCaching":{"type":"object","properties":{"handler":{"anyOf":[{"$ref":"#/definitions/RouteHandlerCallback"},{"$ref":"#/definitions/RouteHandlerObject"},{"enum":["CacheFirst","CacheOnly","NetworkFirst","NetworkOnly","StaleWhileRevalidate"],"type":"string"}]},"method":{"enum":["DELETE","GET","HEAD","PATCH","POST","PUT"],"type":"string"},"options":{"type":"object","properties":{"backgroundSync":{"type":"object","properties":{"name":{"type":"string"},"options":{"$ref":"#/definitions/QueueOptions"}}},"broadcastUpdate":{"type":"object","properties":{"channelName":{"type":"string"},"options":{"$ref":"#/definitions/BroadcastCacheUpdateOptions"}}},"cacheableResponse":{"$ref":"#/definitions/CacheableResponseOptions"},"cacheName":{"type":["null","string"]},"expiration":{"$ref":"#/definitions/ExpirationPluginOptions"},"networkTimeoutSeconds":{"type":"number"},"plugins":{"type":"array","items":{"$ref":"#/definitions/WorkboxPlugin"}},"precacheFallback":{"type":"object","properties":{"fallbackURL":{"type":"string"}}},"fetchOptions":{"$ref":"#/definitions/RequestInit"},"matchOptions":{"$ref":"#/definitions/CacheQueryOptions"}}},"urlPattern":{"anyOf":[{"$ref":"#/definitions/RegExp"},{"$ref":"#/definitions/RouteMatchCallback"},{"type":"string"}]}}},"RouteHandlerCallback":{"description":"The \"handler\" callback is invoked whenever a `Router` matches a URL/Request\nto a `Route` via its `RouteMatchCallback`. This handler callback should\nreturn a `Promise` that resolves with a `Response`.\n\nIf a non-empty array or object is returned by the `RouteMatchCallback` it\nwill be passed in as this handler's `options.params` argument.","type":"object"},"RouteHandlerObject":{"description":"An object with a `handle` method of type `RouteHandlerCallback`.\n\nA `Route` object can be created with either an `RouteHandlerCallback`\nfunction or this `RouteHandler` object. The benefit of the `RouteHandler`\nis it can be extended (as is done by the `workbox-strategies` package).","type":"object","properties":{"handle":{"$ref":"#/definitions/RouteHandlerCallback"}}},"QueueOptions":{"type":"object","properties":{"onSync":{"$ref":"#/definitions/OnSyncCallback"},"maxRetentionTime":{"type":"number"}}},"OnSyncCallback":{"type":"object"},"BroadcastCacheUpdateOptions":{"type":"object","properties":{"headersToCheck":{"type":"array","items":{"type":"string"}},"generatePayload":{"type":"object"}}},"CacheableResponseOptions":{"type":"object","properties":{"statuses":{"type":"array","items":{"type":"number"}},"headers":{"type":"object","additionalProperties":{"type":"string"}}}},"ExpirationPluginOptions":{"type":"object","properties":{"maxEntries":{"type":"number"},"maxAgeSeconds":{"type":"number"},"matchOptions":{"$ref":"#/definitions/CacheQueryOptions"},"purgeOnQuotaError":{"type":"boolean"}}},"CacheQueryOptions":{"type":"object","properties":{"ignoreMethod":{"type":"boolean"},"ignoreSearch":{"type":"boolean"},"ignoreVary":{"type":"boolean"}}},"WorkboxPlugin":{"description":"An object with optional lifecycle callback properties for the fetch and\ncache operations.","type":"object","properties":{"cacheDidUpdate":{"$ref":"#/definitions/CacheDidUpdateCallback"},"cachedResponseWillBeUsed":{"$ref":"#/definitions/CachedResponseWillBeUsedCallback"},"cacheKeyWillBeUsed":{"$ref":"#/definitions/CacheKeyWillBeUsedCallback"},"cacheWillUpdate":{"$ref":"#/definitions/CacheWillUpdateCallback"},"fetchDidFail":{"$ref":"#/definitions/FetchDidFailCallback"},"fetchDidSucceed":{"$ref":"#/definitions/FetchDidSucceedCallback"},"handlerDidComplete":{"$ref":"#/definitions/HandlerDidCompleteCallback"},"handlerDidError":{"$ref":"#/definitions/HandlerDidErrorCallback"},"handlerDidRespond":{"$ref":"#/definitions/HandlerDidRespondCallback"},"handlerWillRespond":{"$ref":"#/definitions/HandlerWillRespondCallback"},"handlerWillStart":{"$ref":"#/definitions/HandlerWillStartCallback"},"requestWillFetch":{"$ref":"#/definitions/RequestWillFetchCallback"}}},"CacheDidUpdateCallback":{"type":"object"},"CachedResponseWillBeUsedCallback":{"type":"object"},"CacheKeyWillBeUsedCallback":{"type":"object"},"CacheWillUpdateCallback":{"type":"object"},"FetchDidFailCallback":{"type":"object"},"FetchDidSucceedCallback":{"type":"object"},"HandlerDidCompleteCallback":{"type":"object"},"HandlerDidErrorCallback":{"type":"object"},"HandlerDidRespondCallback":{"type":"object"},"HandlerWillRespondCallback":{"type":"object"},"HandlerWillStartCallback":{"type":"object"},"RequestWillFetchCallback":{"type":"object"},"RequestInit":{"type":"object","properties":{"body":{"anyOf":[{"$ref":"#/definitions/ArrayBuffer"},{"$ref":"#/definitions/ArrayBufferView"},{"$ref":"#/definitions/Blob"},{"$ref":"#/definitions/FormData"},{"$ref":"#/definitions/URLSearchParams"},{"$ref":"#/definitions/ReadableStream"},{"type":["null","string"]}]},"cache":{"enum":["default","force-cache","no-cache","no-store","only-if-cached","reload"],"type":"string"},"credentials":{"enum":["include","omit","same-origin"],"type":"string"},"headers":{"anyOf":[{"$ref":"#/definitions/Headers"},{"type":"array","items":{"type":"array","items":{"type":"string"}}},{"$ref":"#/definitions/Record"}]},"integrity":{"type":"string"},"keepalive":{"type":"boolean"},"method":{"type":"string"},"mode":{"enum":["cors","navigate","no-cors","same-origin"],"type":"string"},"redirect":{"enum":["error","follow","manual"],"type":"string"},"referrer":{"type":"string"},"referrerPolicy":{"enum":["","no-referrer","no-referrer-when-downgrade","origin","origin-when-cross-origin","same-origin","strict-origin","strict-origin-when-cross-origin","unsafe-url"],"type":"string"},"signal":{"anyOf":[{"$ref":"#/definitions/AbortSignal"},{"type":"null"}]},"window":{}}},"ArrayBuffer":{"type":"object","properties":{"byteLength":{"type":"number"},"__@toStringTag":{"type":"string"}}},"ArrayBufferView":{"type":"object","properties":{"buffer":{"anyOf":[{"$ref":"#/definitions/ArrayBuffer"},{"$ref":"#/definitions/SharedArrayBuffer"}]},"byteLength":{"type":"number"},"byteOffset":{"type":"number"}}},"SharedArrayBuffer":{"type":"object","properties":{"byteLength":{"type":"number"},"__@species":{"$ref":"#/definitions/SharedArrayBuffer"},"__@toStringTag":{"type":"string","enum":["SharedArrayBuffer"]}}},"Blob":{"type":"object","properties":{"size":{"type":"number"},"type":{"type":"string"}}},"FormData":{"type":"object"},"URLSearchParams":{"type":"object"},"ReadableStream":{"type":"object","properties":{"locked":{"type":"boolean"}}},"Headers":{"type":"object"},"Record":{"type":"object"},"AbortSignal":{"type":"object","properties":{"aborted":{"type":"boolean"},"onabort":{"type":["null","object"]}}},"RouteMatchCallback":{"description":"The \"match\" callback is used to determine if a `Route` should apply for a\nparticular URL and request. When matching occurs in response to a fetch\nevent from the client, the `event` object is also supplied. However, since\nthe match callback can be invoked outside of a fetch event, matching logic\nshould not assume the `event` object will always be available.\nIf the match callback returns a truthy value, the matching route's\n`RouteHandlerCallback` will be invoked immediately. If the value returned\nis a non-empty array or object, that value will be set on the handler's\n`options.params` argument.","type":"object"},"BasePartial":{"type":"object","properties":{"additionalManifestEntries":{"type":"array","items":{"anyOf":[{"$ref":"#/definitions/ManifestEntry"},{"type":"string"}]}},"dontCacheBustURLsMatching":{"$ref":"#/definitions/RegExp"},"manifestTransforms":{"type":"array","items":{"type":"object"}},"maximumFileSizeToCacheInBytes":{"type":"number"},"modifyURLPrefix":{"type":"object","additionalProperties":{"type":"string"}}}},"ManifestEntry":{"type":"object","properties":{"integrity":{"type":"string"},"revision":{"type":["null","string"]},"url":{"type":"string"}}},"SWDestPartial":{"type":"object","properties":{"swDest":{"type":"string"}}},"InjectPartial":{"type":"object","properties":{"injectionPoint":{"type":"string"},"swSrc":{"type":"string"}}},"Omit":{"type":"object","properties":{"globFollow":{"type":"boolean"},"globIgnores":{"type":"array","items":{"type":"string"}},"globPatterns":{"type":"array","items":{"type":"string"}},"globStrict":{"type":"boolean"},"templatedURLs":{"type":"object","additionalProperties":{"anyOf":[{"type":"array","items":{"type":"string"}},{"type":"string"}]}}}}},"$schema":"http://json-schema.org/draft-07/schema#"} +{"additionalProperties":false,"type":"object","properties":{"injectionPoint":{"type":"string"},"swSrc":{"type":"string"},"globFollow":{"type":"boolean"},"globIgnores":{"type":"array","items":{"type":"string"}},"globPatterns":{"type":"array","items":{"type":"string"}},"globStrict":{"default":true,"type":"boolean"},"templatedURLs":{"type":"object","additionalProperties":{"anyOf":[{"type":"array","items":{"type":"string"}},{"type":"string"}]}},"additionalManifestEntries":{"type":"array","items":{"anyOf":[{"$ref":"#/definitions/ManifestEntry"},{"type":"string"}]}},"dontCacheBustURLsMatching":{"$ref":"#/definitions/RegExp"},"manifestTransforms":{"type":"array","items":{"type":"object","additionalProperties":false}},"maximumFileSizeToCacheInBytes":{"type":"number"},"modifyURLPrefix":{"type":"object","additionalProperties":{"type":"string"}},"swDest":{"type":"string"},"globDirectory":{"type":"string"}},"definitions":{"RegExp":{"type":"object","properties":{"source":{"type":"string"},"global":{"type":"boolean"},"ignoreCase":{"type":"boolean"},"multiline":{"type":"boolean"},"lastIndex":{"type":"number"},"flags":{"type":"string"},"sticky":{"type":"boolean"},"unicode":{"type":"boolean"},"dotAll":{"type":"boolean"}},"additionalProperties":false},"GoogleAnalyticsInitializeOptions":{"type":"object","properties":{"cacheName":{"type":"string"},"parameterOverrides":{"type":"object","additionalProperties":{"type":"string"}},"hitFilter":{"type":"object","additionalProperties":false}},"additionalProperties":false},"RuntimeCaching":{"type":"object","properties":{"handler":{"anyOf":[{"$ref":"#/definitions/RouteHandlerCallback"},{"$ref":"#/definitions/RouteHandlerObject"},{"enum":["CacheFirst","CacheOnly","NetworkFirst","NetworkOnly","StaleWhileRevalidate"],"type":"string"}]},"method":{"enum":["DELETE","GET","HEAD","PATCH","POST","PUT"],"type":"string"},"options":{"type":"object","properties":{"backgroundSync":{"type":"object","properties":{"name":{"type":"string"},"options":{"$ref":"#/definitions/QueueOptions"}},"additionalProperties":false},"broadcastUpdate":{"type":"object","properties":{"channelName":{"type":"string"},"options":{"$ref":"#/definitions/BroadcastCacheUpdateOptions"}},"additionalProperties":false},"cacheableResponse":{"$ref":"#/definitions/CacheableResponseOptions"},"cacheName":{"type":["null","string"]},"expiration":{"$ref":"#/definitions/ExpirationPluginOptions"},"networkTimeoutSeconds":{"type":"number"},"plugins":{"type":"array","items":{"$ref":"#/definitions/WorkboxPlugin"}},"precacheFallback":{"type":"object","properties":{"fallbackURL":{"type":"string"}},"additionalProperties":false},"fetchOptions":{"$ref":"#/definitions/RequestInit"},"matchOptions":{"$ref":"#/definitions/CacheQueryOptions"}},"additionalProperties":false},"urlPattern":{"anyOf":[{"$ref":"#/definitions/RegExp"},{"$ref":"#/definitions/RouteMatchCallback"},{"type":"string"}]}},"additionalProperties":false},"RouteHandlerCallback":{"description":"The \"handler\" callback is invoked whenever a `Router` matches a URL/Request\nto a `Route` via its `RouteMatchCallback`. This handler callback should\nreturn a `Promise` that resolves with a `Response`.\n\nIf a non-empty array or object is returned by the `RouteMatchCallback` it\nwill be passed in as this handler's `options.params` argument.","type":"object","additionalProperties":false},"RouteHandlerObject":{"description":"An object with a `handle` method of type `RouteHandlerCallback`.\n\nA `Route` object can be created with either an `RouteHandlerCallback`\nfunction or this `RouteHandler` object. The benefit of the `RouteHandler`\nis it can be extended (as is done by the `workbox-strategies` package).","type":"object","properties":{"handle":{"$ref":"#/definitions/RouteHandlerCallback"}},"additionalProperties":false},"QueueOptions":{"type":"object","properties":{"onSync":{"$ref":"#/definitions/OnSyncCallback"},"maxRetentionTime":{"type":"number"}},"additionalProperties":false},"OnSyncCallback":{"type":"object","additionalProperties":false},"BroadcastCacheUpdateOptions":{"type":"object","properties":{"headersToCheck":{"type":"array","items":{"type":"string"}},"generatePayload":{"type":"object","additionalProperties":false}},"additionalProperties":false},"CacheableResponseOptions":{"type":"object","properties":{"statuses":{"type":"array","items":{"type":"number"}},"headers":{"type":"object","additionalProperties":{"type":"string"}}},"additionalProperties":false},"ExpirationPluginOptions":{"type":"object","properties":{"maxEntries":{"type":"number"},"maxAgeSeconds":{"type":"number"},"matchOptions":{"$ref":"#/definitions/CacheQueryOptions"},"purgeOnQuotaError":{"type":"boolean"}},"additionalProperties":false},"CacheQueryOptions":{"type":"object","properties":{"ignoreMethod":{"type":"boolean"},"ignoreSearch":{"type":"boolean"},"ignoreVary":{"type":"boolean"}},"additionalProperties":false},"WorkboxPlugin":{"description":"An object with optional lifecycle callback properties for the fetch and\ncache operations.","type":"object","properties":{"cacheDidUpdate":{"$ref":"#/definitions/CacheDidUpdateCallback"},"cachedResponseWillBeUsed":{"$ref":"#/definitions/CachedResponseWillBeUsedCallback"},"cacheKeyWillBeUsed":{"$ref":"#/definitions/CacheKeyWillBeUsedCallback"},"cacheWillUpdate":{"$ref":"#/definitions/CacheWillUpdateCallback"},"fetchDidFail":{"$ref":"#/definitions/FetchDidFailCallback"},"fetchDidSucceed":{"$ref":"#/definitions/FetchDidSucceedCallback"},"handlerDidComplete":{"$ref":"#/definitions/HandlerDidCompleteCallback"},"handlerDidError":{"$ref":"#/definitions/HandlerDidErrorCallback"},"handlerDidRespond":{"$ref":"#/definitions/HandlerDidRespondCallback"},"handlerWillRespond":{"$ref":"#/definitions/HandlerWillRespondCallback"},"handlerWillStart":{"$ref":"#/definitions/HandlerWillStartCallback"},"requestWillFetch":{"$ref":"#/definitions/RequestWillFetchCallback"}},"additionalProperties":false},"CacheDidUpdateCallback":{"type":"object","additionalProperties":false},"CachedResponseWillBeUsedCallback":{"type":"object","additionalProperties":false},"CacheKeyWillBeUsedCallback":{"type":"object","additionalProperties":false},"CacheWillUpdateCallback":{"type":"object","additionalProperties":false},"FetchDidFailCallback":{"type":"object","additionalProperties":false},"FetchDidSucceedCallback":{"type":"object","additionalProperties":false},"HandlerDidCompleteCallback":{"type":"object","additionalProperties":false},"HandlerDidErrorCallback":{"type":"object","additionalProperties":false},"HandlerDidRespondCallback":{"type":"object","additionalProperties":false},"HandlerWillRespondCallback":{"type":"object","additionalProperties":false},"HandlerWillStartCallback":{"type":"object","additionalProperties":false},"RequestWillFetchCallback":{"type":"object","additionalProperties":false},"RequestInit":{"type":"object","properties":{"body":{"anyOf":[{"$ref":"#/definitions/ArrayBuffer"},{"$ref":"#/definitions/ArrayBufferView"},{"$ref":"#/definitions/Blob"},{"$ref":"#/definitions/FormData"},{"$ref":"#/definitions/URLSearchParams"},{"$ref":"#/definitions/ReadableStream"},{"type":["null","string"]}]},"cache":{"enum":["default","force-cache","no-cache","no-store","only-if-cached","reload"],"type":"string"},"credentials":{"enum":["include","omit","same-origin"],"type":"string"},"headers":{"anyOf":[{"$ref":"#/definitions/Headers"},{"type":"array","items":{"type":"array","items":{"type":"string"}}},{"$ref":"#/definitions/Record"}]},"integrity":{"type":"string"},"keepalive":{"type":"boolean"},"method":{"type":"string"},"mode":{"enum":["cors","navigate","no-cors","same-origin"],"type":"string"},"redirect":{"enum":["error","follow","manual"],"type":"string"},"referrer":{"type":"string"},"referrerPolicy":{"enum":["","no-referrer","no-referrer-when-downgrade","origin","origin-when-cross-origin","same-origin","strict-origin","strict-origin-when-cross-origin","unsafe-url"],"type":"string"},"signal":{"anyOf":[{"$ref":"#/definitions/AbortSignal"},{"type":"null"}]},"window":{}},"additionalProperties":false},"ArrayBuffer":{"type":"object","properties":{"byteLength":{"type":"number"},"__@toStringTag":{"type":"string"}},"additionalProperties":false},"ArrayBufferView":{"type":"object","properties":{"buffer":{"anyOf":[{"$ref":"#/definitions/ArrayBuffer"},{"$ref":"#/definitions/SharedArrayBuffer"}]},"byteLength":{"type":"number"},"byteOffset":{"type":"number"}},"additionalProperties":false},"SharedArrayBuffer":{"type":"object","properties":{"byteLength":{"type":"number"},"__@species":{"$ref":"#/definitions/SharedArrayBuffer"},"__@toStringTag":{"type":"string","enum":["SharedArrayBuffer"]}},"additionalProperties":false},"Blob":{"type":"object","properties":{"size":{"type":"number"},"type":{"type":"string"}},"additionalProperties":false},"FormData":{"type":"object","additionalProperties":false},"URLSearchParams":{"type":"object","additionalProperties":false},"ReadableStream":{"type":"object","properties":{"locked":{"type":"boolean"}},"additionalProperties":false},"Headers":{"type":"object","additionalProperties":false},"Record":{"type":"object","additionalProperties":false},"AbortSignal":{"type":"object","properties":{"aborted":{"type":"boolean"},"onabort":{"anyOf":[{"type":"object","additionalProperties":false},{"type":"null"}]}},"additionalProperties":false},"RouteMatchCallback":{"description":"The \"match\" callback is used to determine if a `Route` should apply for a\nparticular URL and request. When matching occurs in response to a fetch\nevent from the client, the `event` object is also supplied. However, since\nthe match callback can be invoked outside of a fetch event, matching logic\nshould not assume the `event` object will always be available.\nIf the match callback returns a truthy value, the matching route's\n`RouteHandlerCallback` will be invoked immediately. If the value returned\nis a non-empty array or object, that value will be set on the handler's\n`options.params` argument.","type":"object","additionalProperties":false},"ManifestEntry":{"type":"object","properties":{"integrity":{"type":"string"},"revision":{"type":["null","string"]},"url":{"type":"string"}},"additionalProperties":false}},"$schema":"http://json-schema.org/draft-07/schema#"} diff --git a/packages/workbox-build/src/schema/WebpackGenerateSWOptions.json b/packages/workbox-build/src/schema/WebpackGenerateSWOptions.json index 82f7f2053..eac433949 100644 --- a/packages/workbox-build/src/schema/WebpackGenerateSWOptions.json +++ b/packages/workbox-build/src/schema/WebpackGenerateSWOptions.json @@ -1 +1 @@ -{"allOf":[{"$ref":"#/definitions/WebpackPartial"},{"$ref":"#/definitions/GeneratePartial"},{"$ref":"#/definitions/BasePartial"},{"$ref":"#/definitions/SWDestPartial"},{"type":"object","properties":{"importScriptsViaChunks":{"type":"array","items":{"type":"string"}}}}],"definitions":{"GlobPartial":{"type":"object","properties":{"globDirectory":{"type":["null","string"]},"globFollow":{"type":"boolean"},"globIgnores":{"type":"array","items":{"type":"string"}},"globPatterns":{"type":"array","items":{"type":"string"}},"globStrict":{"type":"boolean"},"templatedURLs":{"type":"object","additionalProperties":{"anyOf":[{"type":"array","items":{"type":"string"}},{"type":"string"}]}}}},"GeneratePartial":{"type":"object","properties":{"babelPresetEnvTargets":{"type":"array","items":{"type":"string"}},"cacheId":{"type":["null","string"]},"cleanupOutdatedCaches":{"type":"boolean"},"clientsClaim":{"type":"boolean"},"directoryIndex":{"type":["null","string"]},"disableDevLogs":{"type":"boolean"},"ignoreURLParametersMatching":{"type":"array","items":{"$ref":"#/definitions/RegExp"}},"importScripts":{"type":"array","items":{"type":"string"}},"inlineWorkboxRuntime":{"type":"boolean"},"mode":{"type":["null","string"]},"navigateFallback":{"type":["null","string"]},"navigateFallbackAllowlist":{"type":"array","items":{"$ref":"#/definitions/RegExp"}},"navigateFallbackDenylist":{"type":"array","items":{"$ref":"#/definitions/RegExp"}},"navigationPreload":{"type":"boolean"},"offlineGoogleAnalytics":{"anyOf":[{"$ref":"#/definitions/GoogleAnalyticsInitializeOptions"},{"type":"boolean"}]},"runtimeCaching":{"type":"array","items":{"$ref":"#/definitions/RuntimeCaching"}},"skipWaiting":{"type":"boolean"},"sourcemap":{"type":"boolean"}}},"RegExp":{"type":"object","properties":{"source":{"type":"string"},"global":{"type":"boolean"},"ignoreCase":{"type":"boolean"},"multiline":{"type":"boolean"},"lastIndex":{"type":"number"},"flags":{"type":"string"},"sticky":{"type":"boolean"},"unicode":{"type":"boolean"},"dotAll":{"type":"boolean"}}},"GoogleAnalyticsInitializeOptions":{"type":"object","properties":{"cacheName":{"type":"string"},"parameterOverrides":{"type":"object","additionalProperties":{"type":"string"}},"hitFilter":{"type":"object"}}},"RuntimeCaching":{"type":"object","properties":{"handler":{"anyOf":[{"$ref":"#/definitions/RouteHandlerCallback"},{"$ref":"#/definitions/RouteHandlerObject"},{"enum":["CacheFirst","CacheOnly","NetworkFirst","NetworkOnly","StaleWhileRevalidate"],"type":"string"}]},"method":{"enum":["DELETE","GET","HEAD","PATCH","POST","PUT"],"type":"string"},"options":{"type":"object","properties":{"backgroundSync":{"type":"object","properties":{"name":{"type":"string"},"options":{"$ref":"#/definitions/QueueOptions"}}},"broadcastUpdate":{"type":"object","properties":{"channelName":{"type":"string"},"options":{"$ref":"#/definitions/BroadcastCacheUpdateOptions"}}},"cacheableResponse":{"$ref":"#/definitions/CacheableResponseOptions"},"cacheName":{"type":["null","string"]},"expiration":{"$ref":"#/definitions/ExpirationPluginOptions"},"networkTimeoutSeconds":{"type":"number"},"plugins":{"type":"array","items":{"$ref":"#/definitions/WorkboxPlugin"}},"precacheFallback":{"type":"object","properties":{"fallbackURL":{"type":"string"}}},"fetchOptions":{"$ref":"#/definitions/RequestInit"},"matchOptions":{"$ref":"#/definitions/CacheQueryOptions"}}},"urlPattern":{"anyOf":[{"$ref":"#/definitions/RegExp"},{"$ref":"#/definitions/RouteMatchCallback"},{"type":"string"}]}}},"RouteHandlerCallback":{"description":"The \"handler\" callback is invoked whenever a `Router` matches a URL/Request\nto a `Route` via its `RouteMatchCallback`. This handler callback should\nreturn a `Promise` that resolves with a `Response`.\n\nIf a non-empty array or object is returned by the `RouteMatchCallback` it\nwill be passed in as this handler's `options.params` argument.","type":"object"},"RouteHandlerObject":{"description":"An object with a `handle` method of type `RouteHandlerCallback`.\n\nA `Route` object can be created with either an `RouteHandlerCallback`\nfunction or this `RouteHandler` object. The benefit of the `RouteHandler`\nis it can be extended (as is done by the `workbox-strategies` package).","type":"object","properties":{"handle":{"$ref":"#/definitions/RouteHandlerCallback"}}},"QueueOptions":{"type":"object","properties":{"onSync":{"$ref":"#/definitions/OnSyncCallback"},"maxRetentionTime":{"type":"number"}}},"OnSyncCallback":{"type":"object"},"BroadcastCacheUpdateOptions":{"type":"object","properties":{"headersToCheck":{"type":"array","items":{"type":"string"}},"generatePayload":{"type":"object"}}},"CacheableResponseOptions":{"type":"object","properties":{"statuses":{"type":"array","items":{"type":"number"}},"headers":{"type":"object","additionalProperties":{"type":"string"}}}},"ExpirationPluginOptions":{"type":"object","properties":{"maxEntries":{"type":"number"},"maxAgeSeconds":{"type":"number"},"matchOptions":{"$ref":"#/definitions/CacheQueryOptions"},"purgeOnQuotaError":{"type":"boolean"}}},"CacheQueryOptions":{"type":"object","properties":{"ignoreMethod":{"type":"boolean"},"ignoreSearch":{"type":"boolean"},"ignoreVary":{"type":"boolean"}}},"WorkboxPlugin":{"description":"An object with optional lifecycle callback properties for the fetch and\ncache operations.","type":"object","properties":{"cacheDidUpdate":{"$ref":"#/definitions/CacheDidUpdateCallback"},"cachedResponseWillBeUsed":{"$ref":"#/definitions/CachedResponseWillBeUsedCallback"},"cacheKeyWillBeUsed":{"$ref":"#/definitions/CacheKeyWillBeUsedCallback"},"cacheWillUpdate":{"$ref":"#/definitions/CacheWillUpdateCallback"},"fetchDidFail":{"$ref":"#/definitions/FetchDidFailCallback"},"fetchDidSucceed":{"$ref":"#/definitions/FetchDidSucceedCallback"},"handlerDidComplete":{"$ref":"#/definitions/HandlerDidCompleteCallback"},"handlerDidError":{"$ref":"#/definitions/HandlerDidErrorCallback"},"handlerDidRespond":{"$ref":"#/definitions/HandlerDidRespondCallback"},"handlerWillRespond":{"$ref":"#/definitions/HandlerWillRespondCallback"},"handlerWillStart":{"$ref":"#/definitions/HandlerWillStartCallback"},"requestWillFetch":{"$ref":"#/definitions/RequestWillFetchCallback"}}},"CacheDidUpdateCallback":{"type":"object"},"CachedResponseWillBeUsedCallback":{"type":"object"},"CacheKeyWillBeUsedCallback":{"type":"object"},"CacheWillUpdateCallback":{"type":"object"},"FetchDidFailCallback":{"type":"object"},"FetchDidSucceedCallback":{"type":"object"},"HandlerDidCompleteCallback":{"type":"object"},"HandlerDidErrorCallback":{"type":"object"},"HandlerDidRespondCallback":{"type":"object"},"HandlerWillRespondCallback":{"type":"object"},"HandlerWillStartCallback":{"type":"object"},"RequestWillFetchCallback":{"type":"object"},"RequestInit":{"type":"object","properties":{"body":{"anyOf":[{"$ref":"#/definitions/ArrayBuffer"},{"$ref":"#/definitions/ArrayBufferView"},{"$ref":"#/definitions/Blob"},{"$ref":"#/definitions/FormData"},{"$ref":"#/definitions/URLSearchParams"},{"$ref":"#/definitions/ReadableStream"},{"type":["null","string"]}]},"cache":{"enum":["default","force-cache","no-cache","no-store","only-if-cached","reload"],"type":"string"},"credentials":{"enum":["include","omit","same-origin"],"type":"string"},"headers":{"anyOf":[{"$ref":"#/definitions/Headers"},{"type":"array","items":{"type":"array","items":{"type":"string"}}},{"$ref":"#/definitions/Record"}]},"integrity":{"type":"string"},"keepalive":{"type":"boolean"},"method":{"type":"string"},"mode":{"enum":["cors","navigate","no-cors","same-origin"],"type":"string"},"redirect":{"enum":["error","follow","manual"],"type":"string"},"referrer":{"type":"string"},"referrerPolicy":{"enum":["","no-referrer","no-referrer-when-downgrade","origin","origin-when-cross-origin","same-origin","strict-origin","strict-origin-when-cross-origin","unsafe-url"],"type":"string"},"signal":{"anyOf":[{"$ref":"#/definitions/AbortSignal"},{"type":"null"}]},"window":{}}},"ArrayBuffer":{"type":"object","properties":{"byteLength":{"type":"number"},"__@toStringTag":{"type":"string"}}},"ArrayBufferView":{"type":"object","properties":{"buffer":{"anyOf":[{"$ref":"#/definitions/ArrayBuffer"},{"$ref":"#/definitions/SharedArrayBuffer"}]},"byteLength":{"type":"number"},"byteOffset":{"type":"number"}}},"SharedArrayBuffer":{"type":"object","properties":{"byteLength":{"type":"number"},"__@species":{"$ref":"#/definitions/SharedArrayBuffer"},"__@toStringTag":{"type":"string","enum":["SharedArrayBuffer"]}}},"Blob":{"type":"object","properties":{"size":{"type":"number"},"type":{"type":"string"}}},"FormData":{"type":"object"},"URLSearchParams":{"type":"object"},"ReadableStream":{"type":"object","properties":{"locked":{"type":"boolean"}}},"Headers":{"type":"object"},"Record":{"type":"object"},"AbortSignal":{"type":"object","properties":{"aborted":{"type":"boolean"},"onabort":{"type":["null","object"]}}},"RouteMatchCallback":{"description":"The \"match\" callback is used to determine if a `Route` should apply for a\nparticular URL and request. When matching occurs in response to a fetch\nevent from the client, the `event` object is also supplied. However, since\nthe match callback can be invoked outside of a fetch event, matching logic\nshould not assume the `event` object will always be available.\nIf the match callback returns a truthy value, the matching route's\n`RouteHandlerCallback` will be invoked immediately. If the value returned\nis a non-empty array or object, that value will be set on the handler's\n`options.params` argument.","type":"object"},"BasePartial":{"type":"object","properties":{"additionalManifestEntries":{"type":"array","items":{"anyOf":[{"$ref":"#/definitions/ManifestEntry"},{"type":"string"}]}},"dontCacheBustURLsMatching":{"$ref":"#/definitions/RegExp"},"manifestTransforms":{"type":"array","items":{"type":"object"}},"maximumFileSizeToCacheInBytes":{"type":"number"},"modifyURLPrefix":{"type":"object","additionalProperties":{"type":"string"}}}},"ManifestEntry":{"type":"object","properties":{"integrity":{"type":"string"},"revision":{"type":["null","string"]},"url":{"type":"string"}}},"SWDestPartial":{"type":"object","properties":{"swDest":{"type":"string"}}},"InjectPartial":{"type":"object","properties":{"injectionPoint":{"type":"string"},"swSrc":{"type":"string"}}},"Omit":{"type":"object","properties":{"globFollow":{"type":"boolean"},"globIgnores":{"type":"array","items":{"type":"string"}},"globPatterns":{"type":"array","items":{"type":"string"}},"globStrict":{"type":"boolean"},"templatedURLs":{"type":"object","additionalProperties":{"anyOf":[{"type":"array","items":{"type":"string"}},{"type":"string"}]}}}},"WebpackPartial":{"type":"object","properties":{"chunks":{"type":"array","items":{"type":"string"}},"exclude":{"type":"array","items":{"anyOf":[{"$ref":"#/definitions/RegExp"},{"type":["string","object"]}]}},"excludeChunks":{"type":"array","items":{"type":"string"}},"include":{"type":"array","items":{"anyOf":[{"$ref":"#/definitions/RegExp"},{"type":["string","object"]}]}},"mode":{"type":["null","string"]}}}},"$schema":"http://json-schema.org/draft-07/schema#"} +{"additionalProperties":false,"type":"object","properties":{"chunks":{"type":"array","items":{"type":"string"}},"exclude":{"type":"array","items":{"anyOf":[{"$ref":"#/definitions/RegExp"},{"type":"object","additionalProperties":false},{"type":"string"}]}},"excludeChunks":{"type":"array","items":{"type":"string"}},"include":{"type":"array","items":{"anyOf":[{"$ref":"#/definitions/RegExp"},{"type":"object","additionalProperties":false},{"type":"string"}]}},"mode":{"type":["null","string"]},"babelPresetEnvTargets":{"type":"array","items":{"type":"string"}},"cacheId":{"type":["null","string"]},"cleanupOutdatedCaches":{"type":"boolean"},"clientsClaim":{"type":"boolean"},"directoryIndex":{"type":["null","string"]},"disableDevLogs":{"type":"boolean"},"ignoreURLParametersMatching":{"type":"array","items":{"$ref":"#/definitions/RegExp"}},"importScripts":{"type":"array","items":{"type":"string"}},"inlineWorkboxRuntime":{"type":"boolean"},"navigateFallback":{"type":["null","string"]},"navigateFallbackAllowlist":{"type":"array","items":{"$ref":"#/definitions/RegExp"}},"navigateFallbackDenylist":{"type":"array","items":{"$ref":"#/definitions/RegExp"}},"navigationPreload":{"type":"boolean"},"offlineGoogleAnalytics":{"anyOf":[{"$ref":"#/definitions/GoogleAnalyticsInitializeOptions"},{"type":"boolean"}]},"runtimeCaching":{"type":"array","items":{"$ref":"#/definitions/RuntimeCaching"}},"skipWaiting":{"type":"boolean"},"sourcemap":{"type":"boolean"},"additionalManifestEntries":{"type":"array","items":{"anyOf":[{"$ref":"#/definitions/ManifestEntry"},{"type":"string"}]}},"dontCacheBustURLsMatching":{"$ref":"#/definitions/RegExp"},"manifestTransforms":{"type":"array","items":{"type":"object","additionalProperties":false}},"maximumFileSizeToCacheInBytes":{"type":"number"},"modifyURLPrefix":{"type":"object","additionalProperties":{"type":"string"}},"swDest":{"type":"string"},"importScriptsViaChunks":{"type":"array","items":{"type":"string"}}},"definitions":{"RegExp":{"type":"object","properties":{"source":{"type":"string"},"global":{"type":"boolean"},"ignoreCase":{"type":"boolean"},"multiline":{"type":"boolean"},"lastIndex":{"type":"number"},"flags":{"type":"string"},"sticky":{"type":"boolean"},"unicode":{"type":"boolean"},"dotAll":{"type":"boolean"}},"additionalProperties":false},"GoogleAnalyticsInitializeOptions":{"type":"object","properties":{"cacheName":{"type":"string"},"parameterOverrides":{"type":"object","additionalProperties":{"type":"string"}},"hitFilter":{"type":"object","additionalProperties":false}},"additionalProperties":false},"RuntimeCaching":{"type":"object","properties":{"handler":{"anyOf":[{"$ref":"#/definitions/RouteHandlerCallback"},{"$ref":"#/definitions/RouteHandlerObject"},{"enum":["CacheFirst","CacheOnly","NetworkFirst","NetworkOnly","StaleWhileRevalidate"],"type":"string"}]},"method":{"enum":["DELETE","GET","HEAD","PATCH","POST","PUT"],"type":"string"},"options":{"type":"object","properties":{"backgroundSync":{"type":"object","properties":{"name":{"type":"string"},"options":{"$ref":"#/definitions/QueueOptions"}},"additionalProperties":false},"broadcastUpdate":{"type":"object","properties":{"channelName":{"type":"string"},"options":{"$ref":"#/definitions/BroadcastCacheUpdateOptions"}},"additionalProperties":false},"cacheableResponse":{"$ref":"#/definitions/CacheableResponseOptions"},"cacheName":{"type":["null","string"]},"expiration":{"$ref":"#/definitions/ExpirationPluginOptions"},"networkTimeoutSeconds":{"type":"number"},"plugins":{"type":"array","items":{"$ref":"#/definitions/WorkboxPlugin"}},"precacheFallback":{"type":"object","properties":{"fallbackURL":{"type":"string"}},"additionalProperties":false},"fetchOptions":{"$ref":"#/definitions/RequestInit"},"matchOptions":{"$ref":"#/definitions/CacheQueryOptions"}},"additionalProperties":false},"urlPattern":{"anyOf":[{"$ref":"#/definitions/RegExp"},{"$ref":"#/definitions/RouteMatchCallback"},{"type":"string"}]}},"additionalProperties":false},"RouteHandlerCallback":{"description":"The \"handler\" callback is invoked whenever a `Router` matches a URL/Request\nto a `Route` via its `RouteMatchCallback`. This handler callback should\nreturn a `Promise` that resolves with a `Response`.\n\nIf a non-empty array or object is returned by the `RouteMatchCallback` it\nwill be passed in as this handler's `options.params` argument.","type":"object","additionalProperties":false},"RouteHandlerObject":{"description":"An object with a `handle` method of type `RouteHandlerCallback`.\n\nA `Route` object can be created with either an `RouteHandlerCallback`\nfunction or this `RouteHandler` object. The benefit of the `RouteHandler`\nis it can be extended (as is done by the `workbox-strategies` package).","type":"object","properties":{"handle":{"$ref":"#/definitions/RouteHandlerCallback"}},"additionalProperties":false},"QueueOptions":{"type":"object","properties":{"onSync":{"$ref":"#/definitions/OnSyncCallback"},"maxRetentionTime":{"type":"number"}},"additionalProperties":false},"OnSyncCallback":{"type":"object","additionalProperties":false},"BroadcastCacheUpdateOptions":{"type":"object","properties":{"headersToCheck":{"type":"array","items":{"type":"string"}},"generatePayload":{"type":"object","additionalProperties":false}},"additionalProperties":false},"CacheableResponseOptions":{"type":"object","properties":{"statuses":{"type":"array","items":{"type":"number"}},"headers":{"type":"object","additionalProperties":{"type":"string"}}},"additionalProperties":false},"ExpirationPluginOptions":{"type":"object","properties":{"maxEntries":{"type":"number"},"maxAgeSeconds":{"type":"number"},"matchOptions":{"$ref":"#/definitions/CacheQueryOptions"},"purgeOnQuotaError":{"type":"boolean"}},"additionalProperties":false},"CacheQueryOptions":{"type":"object","properties":{"ignoreMethod":{"type":"boolean"},"ignoreSearch":{"type":"boolean"},"ignoreVary":{"type":"boolean"}},"additionalProperties":false},"WorkboxPlugin":{"description":"An object with optional lifecycle callback properties for the fetch and\ncache operations.","type":"object","properties":{"cacheDidUpdate":{"$ref":"#/definitions/CacheDidUpdateCallback"},"cachedResponseWillBeUsed":{"$ref":"#/definitions/CachedResponseWillBeUsedCallback"},"cacheKeyWillBeUsed":{"$ref":"#/definitions/CacheKeyWillBeUsedCallback"},"cacheWillUpdate":{"$ref":"#/definitions/CacheWillUpdateCallback"},"fetchDidFail":{"$ref":"#/definitions/FetchDidFailCallback"},"fetchDidSucceed":{"$ref":"#/definitions/FetchDidSucceedCallback"},"handlerDidComplete":{"$ref":"#/definitions/HandlerDidCompleteCallback"},"handlerDidError":{"$ref":"#/definitions/HandlerDidErrorCallback"},"handlerDidRespond":{"$ref":"#/definitions/HandlerDidRespondCallback"},"handlerWillRespond":{"$ref":"#/definitions/HandlerWillRespondCallback"},"handlerWillStart":{"$ref":"#/definitions/HandlerWillStartCallback"},"requestWillFetch":{"$ref":"#/definitions/RequestWillFetchCallback"}},"additionalProperties":false},"CacheDidUpdateCallback":{"type":"object","additionalProperties":false},"CachedResponseWillBeUsedCallback":{"type":"object","additionalProperties":false},"CacheKeyWillBeUsedCallback":{"type":"object","additionalProperties":false},"CacheWillUpdateCallback":{"type":"object","additionalProperties":false},"FetchDidFailCallback":{"type":"object","additionalProperties":false},"FetchDidSucceedCallback":{"type":"object","additionalProperties":false},"HandlerDidCompleteCallback":{"type":"object","additionalProperties":false},"HandlerDidErrorCallback":{"type":"object","additionalProperties":false},"HandlerDidRespondCallback":{"type":"object","additionalProperties":false},"HandlerWillRespondCallback":{"type":"object","additionalProperties":false},"HandlerWillStartCallback":{"type":"object","additionalProperties":false},"RequestWillFetchCallback":{"type":"object","additionalProperties":false},"RequestInit":{"type":"object","properties":{"body":{"anyOf":[{"$ref":"#/definitions/ArrayBuffer"},{"$ref":"#/definitions/ArrayBufferView"},{"$ref":"#/definitions/Blob"},{"$ref":"#/definitions/FormData"},{"$ref":"#/definitions/URLSearchParams"},{"$ref":"#/definitions/ReadableStream"},{"type":["null","string"]}]},"cache":{"enum":["default","force-cache","no-cache","no-store","only-if-cached","reload"],"type":"string"},"credentials":{"enum":["include","omit","same-origin"],"type":"string"},"headers":{"anyOf":[{"$ref":"#/definitions/Headers"},{"type":"array","items":{"type":"array","items":{"type":"string"}}},{"$ref":"#/definitions/Record"}]},"integrity":{"type":"string"},"keepalive":{"type":"boolean"},"method":{"type":"string"},"mode":{"enum":["cors","navigate","no-cors","same-origin"],"type":"string"},"redirect":{"enum":["error","follow","manual"],"type":"string"},"referrer":{"type":"string"},"referrerPolicy":{"enum":["","no-referrer","no-referrer-when-downgrade","origin","origin-when-cross-origin","same-origin","strict-origin","strict-origin-when-cross-origin","unsafe-url"],"type":"string"},"signal":{"anyOf":[{"$ref":"#/definitions/AbortSignal"},{"type":"null"}]},"window":{}},"additionalProperties":false},"ArrayBuffer":{"type":"object","properties":{"byteLength":{"type":"number"},"__@toStringTag":{"type":"string"}},"additionalProperties":false},"ArrayBufferView":{"type":"object","properties":{"buffer":{"anyOf":[{"$ref":"#/definitions/ArrayBuffer"},{"$ref":"#/definitions/SharedArrayBuffer"}]},"byteLength":{"type":"number"},"byteOffset":{"type":"number"}},"additionalProperties":false},"SharedArrayBuffer":{"type":"object","properties":{"byteLength":{"type":"number"},"__@species":{"$ref":"#/definitions/SharedArrayBuffer"},"__@toStringTag":{"type":"string","enum":["SharedArrayBuffer"]}},"additionalProperties":false},"Blob":{"type":"object","properties":{"size":{"type":"number"},"type":{"type":"string"}},"additionalProperties":false},"FormData":{"type":"object","additionalProperties":false},"URLSearchParams":{"type":"object","additionalProperties":false},"ReadableStream":{"type":"object","properties":{"locked":{"type":"boolean"}},"additionalProperties":false},"Headers":{"type":"object","additionalProperties":false},"Record":{"type":"object","additionalProperties":false},"AbortSignal":{"type":"object","properties":{"aborted":{"type":"boolean"},"onabort":{"anyOf":[{"type":"object","additionalProperties":false},{"type":"null"}]}},"additionalProperties":false},"RouteMatchCallback":{"description":"The \"match\" callback is used to determine if a `Route` should apply for a\nparticular URL and request. When matching occurs in response to a fetch\nevent from the client, the `event` object is also supplied. However, since\nthe match callback can be invoked outside of a fetch event, matching logic\nshould not assume the `event` object will always be available.\nIf the match callback returns a truthy value, the matching route's\n`RouteHandlerCallback` will be invoked immediately. If the value returned\nis a non-empty array or object, that value will be set on the handler's\n`options.params` argument.","type":"object","additionalProperties":false},"ManifestEntry":{"type":"object","properties":{"integrity":{"type":"string"},"revision":{"type":["null","string"]},"url":{"type":"string"}},"additionalProperties":false}},"$schema":"http://json-schema.org/draft-07/schema#"} diff --git a/packages/workbox-build/src/schema/WebpackInjectManifestOptions.json b/packages/workbox-build/src/schema/WebpackInjectManifestOptions.json index 81eb99975..bd1c33f2f 100644 --- a/packages/workbox-build/src/schema/WebpackInjectManifestOptions.json +++ b/packages/workbox-build/src/schema/WebpackInjectManifestOptions.json @@ -1 +1 @@ -{"allOf":[{"$ref":"#/definitions/WebpackPartial"},{"$ref":"#/definitions/InjectPartial"},{"$ref":"#/definitions/BasePartial"},{"$ref":"#/definitions/SWDestPartial"},{"type":"object","properties":{"compileSrc":{"type":"boolean"},"webpackCompilationPlugins":{"type":"array","items":{}}}}],"definitions":{"GlobPartial":{"type":"object","properties":{"globDirectory":{"type":["null","string"]},"globFollow":{"type":"boolean"},"globIgnores":{"type":"array","items":{"type":"string"}},"globPatterns":{"type":"array","items":{"type":"string"}},"globStrict":{"type":"boolean"},"templatedURLs":{"type":"object","additionalProperties":{"anyOf":[{"type":"array","items":{"type":"string"}},{"type":"string"}]}}}},"GeneratePartial":{"type":"object","properties":{"babelPresetEnvTargets":{"type":"array","items":{"type":"string"}},"cacheId":{"type":["null","string"]},"cleanupOutdatedCaches":{"type":"boolean"},"clientsClaim":{"type":"boolean"},"directoryIndex":{"type":["null","string"]},"disableDevLogs":{"type":"boolean"},"ignoreURLParametersMatching":{"type":"array","items":{"$ref":"#/definitions/RegExp"}},"importScripts":{"type":"array","items":{"type":"string"}},"inlineWorkboxRuntime":{"type":"boolean"},"mode":{"type":["null","string"]},"navigateFallback":{"type":["null","string"]},"navigateFallbackAllowlist":{"type":"array","items":{"$ref":"#/definitions/RegExp"}},"navigateFallbackDenylist":{"type":"array","items":{"$ref":"#/definitions/RegExp"}},"navigationPreload":{"type":"boolean"},"offlineGoogleAnalytics":{"anyOf":[{"$ref":"#/definitions/GoogleAnalyticsInitializeOptions"},{"type":"boolean"}]},"runtimeCaching":{"type":"array","items":{"$ref":"#/definitions/RuntimeCaching"}},"skipWaiting":{"type":"boolean"},"sourcemap":{"type":"boolean"}}},"RegExp":{"type":"object","properties":{"source":{"type":"string"},"global":{"type":"boolean"},"ignoreCase":{"type":"boolean"},"multiline":{"type":"boolean"},"lastIndex":{"type":"number"},"flags":{"type":"string"},"sticky":{"type":"boolean"},"unicode":{"type":"boolean"},"dotAll":{"type":"boolean"}}},"GoogleAnalyticsInitializeOptions":{"type":"object","properties":{"cacheName":{"type":"string"},"parameterOverrides":{"type":"object","additionalProperties":{"type":"string"}},"hitFilter":{"type":"object"}}},"RuntimeCaching":{"type":"object","properties":{"handler":{"anyOf":[{"$ref":"#/definitions/RouteHandlerCallback"},{"$ref":"#/definitions/RouteHandlerObject"},{"enum":["CacheFirst","CacheOnly","NetworkFirst","NetworkOnly","StaleWhileRevalidate"],"type":"string"}]},"method":{"enum":["DELETE","GET","HEAD","PATCH","POST","PUT"],"type":"string"},"options":{"type":"object","properties":{"backgroundSync":{"type":"object","properties":{"name":{"type":"string"},"options":{"$ref":"#/definitions/QueueOptions"}}},"broadcastUpdate":{"type":"object","properties":{"channelName":{"type":"string"},"options":{"$ref":"#/definitions/BroadcastCacheUpdateOptions"}}},"cacheableResponse":{"$ref":"#/definitions/CacheableResponseOptions"},"cacheName":{"type":["null","string"]},"expiration":{"$ref":"#/definitions/ExpirationPluginOptions"},"networkTimeoutSeconds":{"type":"number"},"plugins":{"type":"array","items":{"$ref":"#/definitions/WorkboxPlugin"}},"precacheFallback":{"type":"object","properties":{"fallbackURL":{"type":"string"}}},"fetchOptions":{"$ref":"#/definitions/RequestInit"},"matchOptions":{"$ref":"#/definitions/CacheQueryOptions"}}},"urlPattern":{"anyOf":[{"$ref":"#/definitions/RegExp"},{"$ref":"#/definitions/RouteMatchCallback"},{"type":"string"}]}}},"RouteHandlerCallback":{"description":"The \"handler\" callback is invoked whenever a `Router` matches a URL/Request\nto a `Route` via its `RouteMatchCallback`. This handler callback should\nreturn a `Promise` that resolves with a `Response`.\n\nIf a non-empty array or object is returned by the `RouteMatchCallback` it\nwill be passed in as this handler's `options.params` argument.","type":"object"},"RouteHandlerObject":{"description":"An object with a `handle` method of type `RouteHandlerCallback`.\n\nA `Route` object can be created with either an `RouteHandlerCallback`\nfunction or this `RouteHandler` object. The benefit of the `RouteHandler`\nis it can be extended (as is done by the `workbox-strategies` package).","type":"object","properties":{"handle":{"$ref":"#/definitions/RouteHandlerCallback"}}},"QueueOptions":{"type":"object","properties":{"onSync":{"$ref":"#/definitions/OnSyncCallback"},"maxRetentionTime":{"type":"number"}}},"OnSyncCallback":{"type":"object"},"BroadcastCacheUpdateOptions":{"type":"object","properties":{"headersToCheck":{"type":"array","items":{"type":"string"}},"generatePayload":{"type":"object"}}},"CacheableResponseOptions":{"type":"object","properties":{"statuses":{"type":"array","items":{"type":"number"}},"headers":{"type":"object","additionalProperties":{"type":"string"}}}},"ExpirationPluginOptions":{"type":"object","properties":{"maxEntries":{"type":"number"},"maxAgeSeconds":{"type":"number"},"matchOptions":{"$ref":"#/definitions/CacheQueryOptions"},"purgeOnQuotaError":{"type":"boolean"}}},"CacheQueryOptions":{"type":"object","properties":{"ignoreMethod":{"type":"boolean"},"ignoreSearch":{"type":"boolean"},"ignoreVary":{"type":"boolean"}}},"WorkboxPlugin":{"description":"An object with optional lifecycle callback properties for the fetch and\ncache operations.","type":"object","properties":{"cacheDidUpdate":{"$ref":"#/definitions/CacheDidUpdateCallback"},"cachedResponseWillBeUsed":{"$ref":"#/definitions/CachedResponseWillBeUsedCallback"},"cacheKeyWillBeUsed":{"$ref":"#/definitions/CacheKeyWillBeUsedCallback"},"cacheWillUpdate":{"$ref":"#/definitions/CacheWillUpdateCallback"},"fetchDidFail":{"$ref":"#/definitions/FetchDidFailCallback"},"fetchDidSucceed":{"$ref":"#/definitions/FetchDidSucceedCallback"},"handlerDidComplete":{"$ref":"#/definitions/HandlerDidCompleteCallback"},"handlerDidError":{"$ref":"#/definitions/HandlerDidErrorCallback"},"handlerDidRespond":{"$ref":"#/definitions/HandlerDidRespondCallback"},"handlerWillRespond":{"$ref":"#/definitions/HandlerWillRespondCallback"},"handlerWillStart":{"$ref":"#/definitions/HandlerWillStartCallback"},"requestWillFetch":{"$ref":"#/definitions/RequestWillFetchCallback"}}},"CacheDidUpdateCallback":{"type":"object"},"CachedResponseWillBeUsedCallback":{"type":"object"},"CacheKeyWillBeUsedCallback":{"type":"object"},"CacheWillUpdateCallback":{"type":"object"},"FetchDidFailCallback":{"type":"object"},"FetchDidSucceedCallback":{"type":"object"},"HandlerDidCompleteCallback":{"type":"object"},"HandlerDidErrorCallback":{"type":"object"},"HandlerDidRespondCallback":{"type":"object"},"HandlerWillRespondCallback":{"type":"object"},"HandlerWillStartCallback":{"type":"object"},"RequestWillFetchCallback":{"type":"object"},"RequestInit":{"type":"object","properties":{"body":{"anyOf":[{"$ref":"#/definitions/ArrayBuffer"},{"$ref":"#/definitions/ArrayBufferView"},{"$ref":"#/definitions/Blob"},{"$ref":"#/definitions/FormData"},{"$ref":"#/definitions/URLSearchParams"},{"$ref":"#/definitions/ReadableStream"},{"type":["null","string"]}]},"cache":{"enum":["default","force-cache","no-cache","no-store","only-if-cached","reload"],"type":"string"},"credentials":{"enum":["include","omit","same-origin"],"type":"string"},"headers":{"anyOf":[{"$ref":"#/definitions/Headers"},{"type":"array","items":{"type":"array","items":{"type":"string"}}},{"$ref":"#/definitions/Record"}]},"integrity":{"type":"string"},"keepalive":{"type":"boolean"},"method":{"type":"string"},"mode":{"enum":["cors","navigate","no-cors","same-origin"],"type":"string"},"redirect":{"enum":["error","follow","manual"],"type":"string"},"referrer":{"type":"string"},"referrerPolicy":{"enum":["","no-referrer","no-referrer-when-downgrade","origin","origin-when-cross-origin","same-origin","strict-origin","strict-origin-when-cross-origin","unsafe-url"],"type":"string"},"signal":{"anyOf":[{"$ref":"#/definitions/AbortSignal"},{"type":"null"}]},"window":{}}},"ArrayBuffer":{"type":"object","properties":{"byteLength":{"type":"number"},"__@toStringTag":{"type":"string"}}},"ArrayBufferView":{"type":"object","properties":{"buffer":{"anyOf":[{"$ref":"#/definitions/ArrayBuffer"},{"$ref":"#/definitions/SharedArrayBuffer"}]},"byteLength":{"type":"number"},"byteOffset":{"type":"number"}}},"SharedArrayBuffer":{"type":"object","properties":{"byteLength":{"type":"number"},"__@species":{"$ref":"#/definitions/SharedArrayBuffer"},"__@toStringTag":{"type":"string","enum":["SharedArrayBuffer"]}}},"Blob":{"type":"object","properties":{"size":{"type":"number"},"type":{"type":"string"}}},"FormData":{"type":"object"},"URLSearchParams":{"type":"object"},"ReadableStream":{"type":"object","properties":{"locked":{"type":"boolean"}}},"Headers":{"type":"object"},"Record":{"type":"object"},"AbortSignal":{"type":"object","properties":{"aborted":{"type":"boolean"},"onabort":{"type":["null","object"]}}},"RouteMatchCallback":{"description":"The \"match\" callback is used to determine if a `Route` should apply for a\nparticular URL and request. When matching occurs in response to a fetch\nevent from the client, the `event` object is also supplied. However, since\nthe match callback can be invoked outside of a fetch event, matching logic\nshould not assume the `event` object will always be available.\nIf the match callback returns a truthy value, the matching route's\n`RouteHandlerCallback` will be invoked immediately. If the value returned\nis a non-empty array or object, that value will be set on the handler's\n`options.params` argument.","type":"object"},"BasePartial":{"type":"object","properties":{"additionalManifestEntries":{"type":"array","items":{"anyOf":[{"$ref":"#/definitions/ManifestEntry"},{"type":"string"}]}},"dontCacheBustURLsMatching":{"$ref":"#/definitions/RegExp"},"manifestTransforms":{"type":"array","items":{"type":"object"}},"maximumFileSizeToCacheInBytes":{"type":"number"},"modifyURLPrefix":{"type":"object","additionalProperties":{"type":"string"}}}},"ManifestEntry":{"type":"object","properties":{"integrity":{"type":"string"},"revision":{"type":["null","string"]},"url":{"type":"string"}}},"SWDestPartial":{"type":"object","properties":{"swDest":{"type":"string"}}},"InjectPartial":{"type":"object","properties":{"injectionPoint":{"type":"string"},"swSrc":{"type":"string"}}},"Omit":{"type":"object","properties":{"globFollow":{"type":"boolean"},"globIgnores":{"type":"array","items":{"type":"string"}},"globPatterns":{"type":"array","items":{"type":"string"}},"globStrict":{"type":"boolean"},"templatedURLs":{"type":"object","additionalProperties":{"anyOf":[{"type":"array","items":{"type":"string"}},{"type":"string"}]}}}},"WebpackPartial":{"type":"object","properties":{"chunks":{"type":"array","items":{"type":"string"}},"exclude":{"type":"array","items":{"anyOf":[{"$ref":"#/definitions/RegExp"},{"type":["string","object"]}]}},"excludeChunks":{"type":"array","items":{"type":"string"}},"include":{"type":"array","items":{"anyOf":[{"$ref":"#/definitions/RegExp"},{"type":["string","object"]}]}},"mode":{"type":["null","string"]}}}},"$schema":"http://json-schema.org/draft-07/schema#"} +{"additionalProperties":false,"type":"object","properties":{"chunks":{"type":"array","items":{"type":"string"}},"exclude":{"type":"array","items":{"anyOf":[{"$ref":"#/definitions/RegExp"},{"type":"object","additionalProperties":false},{"type":"string"}]}},"excludeChunks":{"type":"array","items":{"type":"string"}},"include":{"type":"array","items":{"anyOf":[{"$ref":"#/definitions/RegExp"},{"type":"object","additionalProperties":false},{"type":"string"}]}},"mode":{"type":["null","string"]},"injectionPoint":{"type":"string"},"swSrc":{"type":"string"},"additionalManifestEntries":{"type":"array","items":{"anyOf":[{"$ref":"#/definitions/ManifestEntry"},{"type":"string"}]}},"dontCacheBustURLsMatching":{"$ref":"#/definitions/RegExp"},"manifestTransforms":{"type":"array","items":{"type":"object","additionalProperties":false}},"maximumFileSizeToCacheInBytes":{"type":"number"},"modifyURLPrefix":{"type":"object","additionalProperties":{"type":"string"}},"swDest":{"type":"string"},"compileSrc":{"type":"boolean"},"webpackCompilationPlugins":{"type":"array","items":{}}},"definitions":{"RegExp":{"type":"object","properties":{"source":{"type":"string"},"global":{"type":"boolean"},"ignoreCase":{"type":"boolean"},"multiline":{"type":"boolean"},"lastIndex":{"type":"number"},"flags":{"type":"string"},"sticky":{"type":"boolean"},"unicode":{"type":"boolean"},"dotAll":{"type":"boolean"}},"additionalProperties":false},"GoogleAnalyticsInitializeOptions":{"type":"object","properties":{"cacheName":{"type":"string"},"parameterOverrides":{"type":"object","additionalProperties":{"type":"string"}},"hitFilter":{"type":"object","additionalProperties":false}},"additionalProperties":false},"RuntimeCaching":{"type":"object","properties":{"handler":{"anyOf":[{"$ref":"#/definitions/RouteHandlerCallback"},{"$ref":"#/definitions/RouteHandlerObject"},{"enum":["CacheFirst","CacheOnly","NetworkFirst","NetworkOnly","StaleWhileRevalidate"],"type":"string"}]},"method":{"enum":["DELETE","GET","HEAD","PATCH","POST","PUT"],"type":"string"},"options":{"type":"object","properties":{"backgroundSync":{"type":"object","properties":{"name":{"type":"string"},"options":{"$ref":"#/definitions/QueueOptions"}},"additionalProperties":false},"broadcastUpdate":{"type":"object","properties":{"channelName":{"type":"string"},"options":{"$ref":"#/definitions/BroadcastCacheUpdateOptions"}},"additionalProperties":false},"cacheableResponse":{"$ref":"#/definitions/CacheableResponseOptions"},"cacheName":{"type":["null","string"]},"expiration":{"$ref":"#/definitions/ExpirationPluginOptions"},"networkTimeoutSeconds":{"type":"number"},"plugins":{"type":"array","items":{"$ref":"#/definitions/WorkboxPlugin"}},"precacheFallback":{"type":"object","properties":{"fallbackURL":{"type":"string"}},"additionalProperties":false},"fetchOptions":{"$ref":"#/definitions/RequestInit"},"matchOptions":{"$ref":"#/definitions/CacheQueryOptions"}},"additionalProperties":false},"urlPattern":{"anyOf":[{"$ref":"#/definitions/RegExp"},{"$ref":"#/definitions/RouteMatchCallback"},{"type":"string"}]}},"additionalProperties":false},"RouteHandlerCallback":{"description":"The \"handler\" callback is invoked whenever a `Router` matches a URL/Request\nto a `Route` via its `RouteMatchCallback`. This handler callback should\nreturn a `Promise` that resolves with a `Response`.\n\nIf a non-empty array or object is returned by the `RouteMatchCallback` it\nwill be passed in as this handler's `options.params` argument.","type":"object","additionalProperties":false},"RouteHandlerObject":{"description":"An object with a `handle` method of type `RouteHandlerCallback`.\n\nA `Route` object can be created with either an `RouteHandlerCallback`\nfunction or this `RouteHandler` object. The benefit of the `RouteHandler`\nis it can be extended (as is done by the `workbox-strategies` package).","type":"object","properties":{"handle":{"$ref":"#/definitions/RouteHandlerCallback"}},"additionalProperties":false},"QueueOptions":{"type":"object","properties":{"onSync":{"$ref":"#/definitions/OnSyncCallback"},"maxRetentionTime":{"type":"number"}},"additionalProperties":false},"OnSyncCallback":{"type":"object","additionalProperties":false},"BroadcastCacheUpdateOptions":{"type":"object","properties":{"headersToCheck":{"type":"array","items":{"type":"string"}},"generatePayload":{"type":"object","additionalProperties":false}},"additionalProperties":false},"CacheableResponseOptions":{"type":"object","properties":{"statuses":{"type":"array","items":{"type":"number"}},"headers":{"type":"object","additionalProperties":{"type":"string"}}},"additionalProperties":false},"ExpirationPluginOptions":{"type":"object","properties":{"maxEntries":{"type":"number"},"maxAgeSeconds":{"type":"number"},"matchOptions":{"$ref":"#/definitions/CacheQueryOptions"},"purgeOnQuotaError":{"type":"boolean"}},"additionalProperties":false},"CacheQueryOptions":{"type":"object","properties":{"ignoreMethod":{"type":"boolean"},"ignoreSearch":{"type":"boolean"},"ignoreVary":{"type":"boolean"}},"additionalProperties":false},"WorkboxPlugin":{"description":"An object with optional lifecycle callback properties for the fetch and\ncache operations.","type":"object","properties":{"cacheDidUpdate":{"$ref":"#/definitions/CacheDidUpdateCallback"},"cachedResponseWillBeUsed":{"$ref":"#/definitions/CachedResponseWillBeUsedCallback"},"cacheKeyWillBeUsed":{"$ref":"#/definitions/CacheKeyWillBeUsedCallback"},"cacheWillUpdate":{"$ref":"#/definitions/CacheWillUpdateCallback"},"fetchDidFail":{"$ref":"#/definitions/FetchDidFailCallback"},"fetchDidSucceed":{"$ref":"#/definitions/FetchDidSucceedCallback"},"handlerDidComplete":{"$ref":"#/definitions/HandlerDidCompleteCallback"},"handlerDidError":{"$ref":"#/definitions/HandlerDidErrorCallback"},"handlerDidRespond":{"$ref":"#/definitions/HandlerDidRespondCallback"},"handlerWillRespond":{"$ref":"#/definitions/HandlerWillRespondCallback"},"handlerWillStart":{"$ref":"#/definitions/HandlerWillStartCallback"},"requestWillFetch":{"$ref":"#/definitions/RequestWillFetchCallback"}},"additionalProperties":false},"CacheDidUpdateCallback":{"type":"object","additionalProperties":false},"CachedResponseWillBeUsedCallback":{"type":"object","additionalProperties":false},"CacheKeyWillBeUsedCallback":{"type":"object","additionalProperties":false},"CacheWillUpdateCallback":{"type":"object","additionalProperties":false},"FetchDidFailCallback":{"type":"object","additionalProperties":false},"FetchDidSucceedCallback":{"type":"object","additionalProperties":false},"HandlerDidCompleteCallback":{"type":"object","additionalProperties":false},"HandlerDidErrorCallback":{"type":"object","additionalProperties":false},"HandlerDidRespondCallback":{"type":"object","additionalProperties":false},"HandlerWillRespondCallback":{"type":"object","additionalProperties":false},"HandlerWillStartCallback":{"type":"object","additionalProperties":false},"RequestWillFetchCallback":{"type":"object","additionalProperties":false},"RequestInit":{"type":"object","properties":{"body":{"anyOf":[{"$ref":"#/definitions/ArrayBuffer"},{"$ref":"#/definitions/ArrayBufferView"},{"$ref":"#/definitions/Blob"},{"$ref":"#/definitions/FormData"},{"$ref":"#/definitions/URLSearchParams"},{"$ref":"#/definitions/ReadableStream"},{"type":["null","string"]}]},"cache":{"enum":["default","force-cache","no-cache","no-store","only-if-cached","reload"],"type":"string"},"credentials":{"enum":["include","omit","same-origin"],"type":"string"},"headers":{"anyOf":[{"$ref":"#/definitions/Headers"},{"type":"array","items":{"type":"array","items":{"type":"string"}}},{"$ref":"#/definitions/Record"}]},"integrity":{"type":"string"},"keepalive":{"type":"boolean"},"method":{"type":"string"},"mode":{"enum":["cors","navigate","no-cors","same-origin"],"type":"string"},"redirect":{"enum":["error","follow","manual"],"type":"string"},"referrer":{"type":"string"},"referrerPolicy":{"enum":["","no-referrer","no-referrer-when-downgrade","origin","origin-when-cross-origin","same-origin","strict-origin","strict-origin-when-cross-origin","unsafe-url"],"type":"string"},"signal":{"anyOf":[{"$ref":"#/definitions/AbortSignal"},{"type":"null"}]},"window":{}},"additionalProperties":false},"ArrayBuffer":{"type":"object","properties":{"byteLength":{"type":"number"},"__@toStringTag":{"type":"string"}},"additionalProperties":false},"ArrayBufferView":{"type":"object","properties":{"buffer":{"anyOf":[{"$ref":"#/definitions/ArrayBuffer"},{"$ref":"#/definitions/SharedArrayBuffer"}]},"byteLength":{"type":"number"},"byteOffset":{"type":"number"}},"additionalProperties":false},"SharedArrayBuffer":{"type":"object","properties":{"byteLength":{"type":"number"},"__@species":{"$ref":"#/definitions/SharedArrayBuffer"},"__@toStringTag":{"type":"string","enum":["SharedArrayBuffer"]}},"additionalProperties":false},"Blob":{"type":"object","properties":{"size":{"type":"number"},"type":{"type":"string"}},"additionalProperties":false},"FormData":{"type":"object","additionalProperties":false},"URLSearchParams":{"type":"object","additionalProperties":false},"ReadableStream":{"type":"object","properties":{"locked":{"type":"boolean"}},"additionalProperties":false},"Headers":{"type":"object","additionalProperties":false},"Record":{"type":"object","additionalProperties":false},"AbortSignal":{"type":"object","properties":{"aborted":{"type":"boolean"},"onabort":{"anyOf":[{"type":"object","additionalProperties":false},{"type":"null"}]}},"additionalProperties":false},"RouteMatchCallback":{"description":"The \"match\" callback is used to determine if a `Route` should apply for a\nparticular URL and request. When matching occurs in response to a fetch\nevent from the client, the `event` object is also supplied. However, since\nthe match callback can be invoked outside of a fetch event, matching logic\nshould not assume the `event` object will always be available.\nIf the match callback returns a truthy value, the matching route's\n`RouteHandlerCallback` will be invoked immediately. If the value returned\nis a non-empty array or object, that value will be set on the handler's\n`options.params` argument.","type":"object","additionalProperties":false},"ManifestEntry":{"type":"object","properties":{"integrity":{"type":"string"},"revision":{"type":["null","string"]},"url":{"type":"string"}},"additionalProperties":false}},"$schema":"http://json-schema.org/draft-07/schema#"} diff --git a/packages/workbox-build/src/types.ts b/packages/workbox-build/src/types.ts index 01f73fa12..942015777 100644 --- a/packages/workbox-build/src/types.ts +++ b/packages/workbox-build/src/types.ts @@ -91,6 +91,9 @@ export interface GlobPartial { globFollow?: boolean; globIgnores: Array; globPatterns: Array; + /** + * @default true + */ globStrict?: boolean; templatedURLs: { [key: string]: string | Array; diff --git a/packages/workbox-build/tsconfig.json b/packages/workbox-build/tsconfig.json index efc4055bd..ef0306782 100644 --- a/packages/workbox-build/tsconfig.json +++ b/packages/workbox-build/tsconfig.json @@ -13,7 +13,8 @@ "src/cdn-details.json" ], "include": [ - "src/**/*.ts" + "src/**/*.ts", + "src/schema/*.json" ], "references": [ {"path": "../workbox-background-sync/"}, diff --git a/test/workbox-build/node/lib/validate-options.js b/test/workbox-build/node/lib/validate-options.js index 187b228bc..ca64cd246 100644 --- a/test/workbox-build/node/lib/validate-options.js +++ b/test/workbox-build/node/lib/validate-options.js @@ -19,7 +19,7 @@ describe(`[workbox-build] entry-points/options/validate-options.js`, function() ]); for (const [func, guardFunc] of testCases) { - it(`${func}() should throw when ${guardFunc}() returns false`, function() { + it.skip(`${func}() should throw when ${guardFunc}() returns false`, function() { const validateOptions = proxyquire(MODULE_PATH, { '../types.guard': { [guardFunc]: () => false, @@ -29,7 +29,7 @@ describe(`[workbox-build] entry-points/options/validate-options.js`, function() expect(() => validateOptions[func]()).to.throw('Validation failed.'); }); - it(`${func}() should return options with defaults when ${guardFunc}() returns true`, function() { + it.skip(`${func}() should return options with defaults when ${guardFunc}() returns true`, function() { const validateOptions = proxyquire(MODULE_PATH, { '../types.guard': { [guardFunc]: () => true, From 0069bba2d00e692c98c8ca8e6794e3d8500110f7 Mon Sep 17 00:00:00 2001 From: Jeff Posnick Date: Wed, 9 Jun 2021 11:49:01 -0400 Subject: [PATCH 33/80] Some default logic --- packages/workbox-build/src/generate-sw.ts | 4 +- packages/workbox-build/src/inject-manifest.ts | 6 +- .../workbox-build/src/lib/validate-options.ts | 34 +--------- .../src/schema/GenerateSWOptions.json | 2 +- .../src/schema/GetManifestOptions.json | 2 +- .../src/schema/InjectManifestOptions.json | 2 +- .../src/schema/WebpackGenerateSWOptions.json | 2 +- .../schema/WebpackInjectManifestOptions.json | 2 +- packages/workbox-build/src/types.ts | 63 ++++++++++++++++++- 9 files changed, 72 insertions(+), 45 deletions(-) diff --git a/packages/workbox-build/src/generate-sw.ts b/packages/workbox-build/src/generate-sw.ts index 1bb07b58c..5db070d29 100644 --- a/packages/workbox-build/src/generate-sw.ts +++ b/packages/workbox-build/src/generate-sw.ts @@ -198,7 +198,7 @@ export async function generateSW(config: unknown): Promise { if (options.globDirectory) { // Make sure we leave swDest out of the precache manifest. - options.globIgnores.push(rebasePath({ + options.globIgnores!.push(rebasePath({ baseDirectory: options.globDirectory, file: options.swDest, })); @@ -208,7 +208,7 @@ export async function generateSW(config: unknown): Promise { if (!options.inlineWorkboxRuntime) { const swDestDir = upath.dirname(options.swDest); const workboxRuntimeFile = upath.join(swDestDir, 'workbox-*.js'); - options.globIgnores.push(rebasePath({ + options.globIgnores!.push(rebasePath({ baseDirectory: options.globDirectory, file: workboxRuntimeFile, })); diff --git a/packages/workbox-build/src/inject-manifest.ts b/packages/workbox-build/src/inject-manifest.ts index b094fd34c..9d1e133b1 100644 --- a/packages/workbox-build/src/inject-manifest.ts +++ b/packages/workbox-build/src/inject-manifest.ts @@ -121,13 +121,13 @@ export async function injectManifest(config: unknown): Promise { // Make sure we leave swSrc and swDest out of the precache manifest. for (const file of [options.swSrc, options.swDest]) { - options.globIgnores.push(rebasePath({ + options.globIgnores!.push(rebasePath({ file, baseDirectory: options.globDirectory, })); } - const globalRegexp = new RegExp(escapeRegExp(options.injectionPoint), 'g'); + const globalRegexp = new RegExp(escapeRegExp(options.injectionPoint!), 'g'); const {count, size, manifestEntries, warnings} = await getFileManifestEntries(options); @@ -178,7 +178,7 @@ export async function injectManifest(config: unknown): Promise { jsFilename: upath.basename(options.swDest), originalSource: swFileContents, replaceString: manifestString, - searchString: options.injectionPoint, + searchString: options.injectionPoint!, }); filesToWrite[options.swDest] = source; diff --git a/packages/workbox-build/src/lib/validate-options.ts b/packages/workbox-build/src/lib/validate-options.ts index 5732a6a87..29507fb33 100644 --- a/packages/workbox-build/src/lib/validate-options.ts +++ b/packages/workbox-build/src/lib/validate-options.ts @@ -12,33 +12,6 @@ import {GenerateSWOptions, GetManifestOptions, InjectManifestOptions} from '../t const ajv = new Ajv({useDefaults: true}); -// const defaults = { -// babelPresetEnvTargets: ['chrome >= 56'], -// cleanupOutdatedCaches: false, -// clientsClaim: false, -// compileSrc: true, -// disableDevLogs: false, -// exclude: [ -// /\.map$/, -// /^manifest.*\.js$/, -// ], -// globFollow: true, -// globIgnores: ['**/node_modules/**/*'], -// globPatterns: ['**/*.{js,css,html}'], -// globStrict: true, -// injectionPoint: 'self.__WB_MANIFEST', -// inlineWorkboxRuntime: false, -// maximumFileSizeToCacheInBytes: 2 * 1024 * 1024, -// mode: 'production', -// navigateFallback: null, -// navigationPreload: false, -// offlineGoogleAnalytics: false, -// purgeOnQuotaError: true, -// skipWaiting: false, -// sourcemap: true, -// swDestFilename: 'service-worker.js', -// }; - export function validateGenerateSWOptions(input: unknown): GenerateSWOptions { const jsonSchema: JSONSchemaType = require(`../schema/GenerateSWOptions.json`); @@ -62,11 +35,8 @@ export function validateGetManifestOptions(input: unknown): GetManifestOptions { return input; } - const errorStrings = []; - for (const err of validate.errors as DefinedError[]) { - errorStrings.push(err.message); - } - throw new Error(`Incorrect getManifest options:\n\t${errorStrings.join('\n\t')}`); + const errors = validate.errors as DefinedError[]; + throw new Error(JSON.stringify(errors)); } export function validateInjectManifestOptions(input: unknown): InjectManifestOptions { diff --git a/packages/workbox-build/src/schema/GenerateSWOptions.json b/packages/workbox-build/src/schema/GenerateSWOptions.json index 62a60bd7c..6e2d9278b 100644 --- a/packages/workbox-build/src/schema/GenerateSWOptions.json +++ b/packages/workbox-build/src/schema/GenerateSWOptions.json @@ -1 +1 @@ -{"additionalProperties":false,"type":"object","properties":{"globDirectory":{"type":["null","string"]},"globFollow":{"type":"boolean"},"globIgnores":{"type":"array","items":{"type":"string"}},"globPatterns":{"type":"array","items":{"type":"string"}},"globStrict":{"default":true,"type":"boolean"},"templatedURLs":{"type":"object","additionalProperties":{"anyOf":[{"type":"array","items":{"type":"string"}},{"type":"string"}]}},"babelPresetEnvTargets":{"type":"array","items":{"type":"string"}},"cacheId":{"type":["null","string"]},"cleanupOutdatedCaches":{"type":"boolean"},"clientsClaim":{"type":"boolean"},"directoryIndex":{"type":["null","string"]},"disableDevLogs":{"type":"boolean"},"ignoreURLParametersMatching":{"type":"array","items":{"$ref":"#/definitions/RegExp"}},"importScripts":{"type":"array","items":{"type":"string"}},"inlineWorkboxRuntime":{"type":"boolean"},"mode":{"type":["null","string"]},"navigateFallback":{"type":["null","string"]},"navigateFallbackAllowlist":{"type":"array","items":{"$ref":"#/definitions/RegExp"}},"navigateFallbackDenylist":{"type":"array","items":{"$ref":"#/definitions/RegExp"}},"navigationPreload":{"type":"boolean"},"offlineGoogleAnalytics":{"anyOf":[{"$ref":"#/definitions/GoogleAnalyticsInitializeOptions"},{"type":"boolean"}]},"runtimeCaching":{"type":"array","items":{"$ref":"#/definitions/RuntimeCaching"}},"skipWaiting":{"type":"boolean"},"sourcemap":{"type":"boolean"},"additionalManifestEntries":{"type":"array","items":{"anyOf":[{"$ref":"#/definitions/ManifestEntry"},{"type":"string"}]}},"dontCacheBustURLsMatching":{"$ref":"#/definitions/RegExp"},"manifestTransforms":{"type":"array","items":{"type":"object","additionalProperties":false}},"maximumFileSizeToCacheInBytes":{"type":"number"},"modifyURLPrefix":{"type":"object","additionalProperties":{"type":"string"}},"swDest":{"type":"string"}},"definitions":{"RegExp":{"type":"object","properties":{"source":{"type":"string"},"global":{"type":"boolean"},"ignoreCase":{"type":"boolean"},"multiline":{"type":"boolean"},"lastIndex":{"type":"number"},"flags":{"type":"string"},"sticky":{"type":"boolean"},"unicode":{"type":"boolean"},"dotAll":{"type":"boolean"}},"additionalProperties":false},"GoogleAnalyticsInitializeOptions":{"type":"object","properties":{"cacheName":{"type":"string"},"parameterOverrides":{"type":"object","additionalProperties":{"type":"string"}},"hitFilter":{"type":"object","additionalProperties":false}},"additionalProperties":false},"RuntimeCaching":{"type":"object","properties":{"handler":{"anyOf":[{"$ref":"#/definitions/RouteHandlerCallback"},{"$ref":"#/definitions/RouteHandlerObject"},{"enum":["CacheFirst","CacheOnly","NetworkFirst","NetworkOnly","StaleWhileRevalidate"],"type":"string"}]},"method":{"enum":["DELETE","GET","HEAD","PATCH","POST","PUT"],"type":"string"},"options":{"type":"object","properties":{"backgroundSync":{"type":"object","properties":{"name":{"type":"string"},"options":{"$ref":"#/definitions/QueueOptions"}},"additionalProperties":false},"broadcastUpdate":{"type":"object","properties":{"channelName":{"type":"string"},"options":{"$ref":"#/definitions/BroadcastCacheUpdateOptions"}},"additionalProperties":false},"cacheableResponse":{"$ref":"#/definitions/CacheableResponseOptions"},"cacheName":{"type":["null","string"]},"expiration":{"$ref":"#/definitions/ExpirationPluginOptions"},"networkTimeoutSeconds":{"type":"number"},"plugins":{"type":"array","items":{"$ref":"#/definitions/WorkboxPlugin"}},"precacheFallback":{"type":"object","properties":{"fallbackURL":{"type":"string"}},"additionalProperties":false},"fetchOptions":{"$ref":"#/definitions/RequestInit"},"matchOptions":{"$ref":"#/definitions/CacheQueryOptions"}},"additionalProperties":false},"urlPattern":{"anyOf":[{"$ref":"#/definitions/RegExp"},{"$ref":"#/definitions/RouteMatchCallback"},{"type":"string"}]}},"additionalProperties":false},"RouteHandlerCallback":{"description":"The \"handler\" callback is invoked whenever a `Router` matches a URL/Request\nto a `Route` via its `RouteMatchCallback`. This handler callback should\nreturn a `Promise` that resolves with a `Response`.\n\nIf a non-empty array or object is returned by the `RouteMatchCallback` it\nwill be passed in as this handler's `options.params` argument.","type":"object","additionalProperties":false},"RouteHandlerObject":{"description":"An object with a `handle` method of type `RouteHandlerCallback`.\n\nA `Route` object can be created with either an `RouteHandlerCallback`\nfunction or this `RouteHandler` object. The benefit of the `RouteHandler`\nis it can be extended (as is done by the `workbox-strategies` package).","type":"object","properties":{"handle":{"$ref":"#/definitions/RouteHandlerCallback"}},"additionalProperties":false},"QueueOptions":{"type":"object","properties":{"onSync":{"$ref":"#/definitions/OnSyncCallback"},"maxRetentionTime":{"type":"number"}},"additionalProperties":false},"OnSyncCallback":{"type":"object","additionalProperties":false},"BroadcastCacheUpdateOptions":{"type":"object","properties":{"headersToCheck":{"type":"array","items":{"type":"string"}},"generatePayload":{"type":"object","additionalProperties":false}},"additionalProperties":false},"CacheableResponseOptions":{"type":"object","properties":{"statuses":{"type":"array","items":{"type":"number"}},"headers":{"type":"object","additionalProperties":{"type":"string"}}},"additionalProperties":false},"ExpirationPluginOptions":{"type":"object","properties":{"maxEntries":{"type":"number"},"maxAgeSeconds":{"type":"number"},"matchOptions":{"$ref":"#/definitions/CacheQueryOptions"},"purgeOnQuotaError":{"type":"boolean"}},"additionalProperties":false},"CacheQueryOptions":{"type":"object","properties":{"ignoreMethod":{"type":"boolean"},"ignoreSearch":{"type":"boolean"},"ignoreVary":{"type":"boolean"}},"additionalProperties":false},"WorkboxPlugin":{"description":"An object with optional lifecycle callback properties for the fetch and\ncache operations.","type":"object","properties":{"cacheDidUpdate":{"$ref":"#/definitions/CacheDidUpdateCallback"},"cachedResponseWillBeUsed":{"$ref":"#/definitions/CachedResponseWillBeUsedCallback"},"cacheKeyWillBeUsed":{"$ref":"#/definitions/CacheKeyWillBeUsedCallback"},"cacheWillUpdate":{"$ref":"#/definitions/CacheWillUpdateCallback"},"fetchDidFail":{"$ref":"#/definitions/FetchDidFailCallback"},"fetchDidSucceed":{"$ref":"#/definitions/FetchDidSucceedCallback"},"handlerDidComplete":{"$ref":"#/definitions/HandlerDidCompleteCallback"},"handlerDidError":{"$ref":"#/definitions/HandlerDidErrorCallback"},"handlerDidRespond":{"$ref":"#/definitions/HandlerDidRespondCallback"},"handlerWillRespond":{"$ref":"#/definitions/HandlerWillRespondCallback"},"handlerWillStart":{"$ref":"#/definitions/HandlerWillStartCallback"},"requestWillFetch":{"$ref":"#/definitions/RequestWillFetchCallback"}},"additionalProperties":false},"CacheDidUpdateCallback":{"type":"object","additionalProperties":false},"CachedResponseWillBeUsedCallback":{"type":"object","additionalProperties":false},"CacheKeyWillBeUsedCallback":{"type":"object","additionalProperties":false},"CacheWillUpdateCallback":{"type":"object","additionalProperties":false},"FetchDidFailCallback":{"type":"object","additionalProperties":false},"FetchDidSucceedCallback":{"type":"object","additionalProperties":false},"HandlerDidCompleteCallback":{"type":"object","additionalProperties":false},"HandlerDidErrorCallback":{"type":"object","additionalProperties":false},"HandlerDidRespondCallback":{"type":"object","additionalProperties":false},"HandlerWillRespondCallback":{"type":"object","additionalProperties":false},"HandlerWillStartCallback":{"type":"object","additionalProperties":false},"RequestWillFetchCallback":{"type":"object","additionalProperties":false},"RequestInit":{"type":"object","properties":{"body":{"anyOf":[{"$ref":"#/definitions/ArrayBuffer"},{"$ref":"#/definitions/ArrayBufferView"},{"$ref":"#/definitions/Blob"},{"$ref":"#/definitions/FormData"},{"$ref":"#/definitions/URLSearchParams"},{"$ref":"#/definitions/ReadableStream"},{"type":["null","string"]}]},"cache":{"enum":["default","force-cache","no-cache","no-store","only-if-cached","reload"],"type":"string"},"credentials":{"enum":["include","omit","same-origin"],"type":"string"},"headers":{"anyOf":[{"$ref":"#/definitions/Headers"},{"type":"array","items":{"type":"array","items":{"type":"string"}}},{"$ref":"#/definitions/Record"}]},"integrity":{"type":"string"},"keepalive":{"type":"boolean"},"method":{"type":"string"},"mode":{"enum":["cors","navigate","no-cors","same-origin"],"type":"string"},"redirect":{"enum":["error","follow","manual"],"type":"string"},"referrer":{"type":"string"},"referrerPolicy":{"enum":["","no-referrer","no-referrer-when-downgrade","origin","origin-when-cross-origin","same-origin","strict-origin","strict-origin-when-cross-origin","unsafe-url"],"type":"string"},"signal":{"anyOf":[{"$ref":"#/definitions/AbortSignal"},{"type":"null"}]},"window":{}},"additionalProperties":false},"ArrayBuffer":{"type":"object","properties":{"byteLength":{"type":"number"},"__@toStringTag":{"type":"string"}},"additionalProperties":false},"ArrayBufferView":{"type":"object","properties":{"buffer":{"anyOf":[{"$ref":"#/definitions/ArrayBuffer"},{"$ref":"#/definitions/SharedArrayBuffer"}]},"byteLength":{"type":"number"},"byteOffset":{"type":"number"}},"additionalProperties":false},"SharedArrayBuffer":{"type":"object","properties":{"byteLength":{"type":"number"},"__@species":{"$ref":"#/definitions/SharedArrayBuffer"},"__@toStringTag":{"type":"string","enum":["SharedArrayBuffer"]}},"additionalProperties":false},"Blob":{"type":"object","properties":{"size":{"type":"number"},"type":{"type":"string"}},"additionalProperties":false},"FormData":{"type":"object","additionalProperties":false},"URLSearchParams":{"type":"object","additionalProperties":false},"ReadableStream":{"type":"object","properties":{"locked":{"type":"boolean"}},"additionalProperties":false},"Headers":{"type":"object","additionalProperties":false},"Record":{"type":"object","additionalProperties":false},"AbortSignal":{"type":"object","properties":{"aborted":{"type":"boolean"},"onabort":{"anyOf":[{"type":"object","additionalProperties":false},{"type":"null"}]}},"additionalProperties":false},"RouteMatchCallback":{"description":"The \"match\" callback is used to determine if a `Route` should apply for a\nparticular URL and request. When matching occurs in response to a fetch\nevent from the client, the `event` object is also supplied. However, since\nthe match callback can be invoked outside of a fetch event, matching logic\nshould not assume the `event` object will always be available.\nIf the match callback returns a truthy value, the matching route's\n`RouteHandlerCallback` will be invoked immediately. If the value returned\nis a non-empty array or object, that value will be set on the handler's\n`options.params` argument.","type":"object","additionalProperties":false},"ManifestEntry":{"type":"object","properties":{"integrity":{"type":"string"},"revision":{"type":["null","string"]},"url":{"type":"string"}},"additionalProperties":false}},"$schema":"http://json-schema.org/draft-07/schema#"} +{"additionalProperties":false,"type":"object","properties":{"globDirectory":{"type":["null","string"]},"globFollow":{"default":true,"type":"boolean"},"globIgnores":{"default":"['**\\/node_modules\\/**\\/*']","type":"array","items":{"type":"string"}},"globPatterns":{"default":"['**\\/*.{js,css,html}']","type":"array","items":{"type":"string"}},"globStrict":{"default":true,"type":"boolean"},"templatedURLs":{"type":"object","additionalProperties":{"anyOf":[{"type":"array","items":{"type":"string"}},{"type":"string"}]}},"babelPresetEnvTargets":{"default":"['chrome >= 56']","type":"array","items":{"type":"string"}},"cacheId":{"type":["null","string"]},"cleanupOutdatedCaches":{"default":false,"type":"boolean"},"clientsClaim":{"default":false,"type":"boolean"},"directoryIndex":{"type":["null","string"]},"disableDevLogs":{"default":false,"type":"boolean"},"ignoreURLParametersMatching":{"type":"array","items":{"$ref":"#/definitions/RegExp"}},"importScripts":{"type":"array","items":{"type":"string"}},"inlineWorkboxRuntime":{"default":false,"type":"boolean"},"mode":{"default":"'production'","type":["null","string"]},"navigateFallback":{"default":null,"type":["null","string"]},"navigateFallbackAllowlist":{"type":"array","items":{"$ref":"#/definitions/RegExp"}},"navigateFallbackDenylist":{"type":"array","items":{"$ref":"#/definitions/RegExp"}},"navigationPreload":{"default":false,"type":"boolean"},"offlineGoogleAnalytics":{"default":false,"anyOf":[{"$ref":"#/definitions/GoogleAnalyticsInitializeOptions"},{"type":"boolean"}]},"runtimeCaching":{"type":"array","items":{"$ref":"#/definitions/RuntimeCaching"}},"skipWaiting":{"default":false,"type":"boolean"},"sourcemap":{"default":true,"type":"boolean"},"additionalManifestEntries":{"type":"array","items":{"anyOf":[{"$ref":"#/definitions/ManifestEntry"},{"type":"string"}]}},"dontCacheBustURLsMatching":{"$ref":"#/definitions/RegExp"},"manifestTransforms":{"type":"array","items":{"type":"object","additionalProperties":false}},"maximumFileSizeToCacheInBytes":{"default":2097152,"type":"number"},"modifyURLPrefix":{"type":"object","additionalProperties":{"type":"string"}},"swDest":{"default":"'service-worker.js'","type":"string"}},"definitions":{"RegExp":{"type":"object","properties":{"source":{"type":"string"},"global":{"type":"boolean"},"ignoreCase":{"type":"boolean"},"multiline":{"type":"boolean"},"lastIndex":{"type":"number"},"flags":{"type":"string"},"sticky":{"type":"boolean"},"unicode":{"type":"boolean"},"dotAll":{"type":"boolean"}},"additionalProperties":false},"GoogleAnalyticsInitializeOptions":{"type":"object","properties":{"cacheName":{"type":"string"},"parameterOverrides":{"type":"object","additionalProperties":{"type":"string"}},"hitFilter":{"type":"object","additionalProperties":false}},"additionalProperties":false},"RuntimeCaching":{"type":"object","properties":{"handler":{"anyOf":[{"$ref":"#/definitions/RouteHandlerCallback"},{"$ref":"#/definitions/RouteHandlerObject"},{"enum":["CacheFirst","CacheOnly","NetworkFirst","NetworkOnly","StaleWhileRevalidate"],"type":"string"}]},"method":{"enum":["DELETE","GET","HEAD","PATCH","POST","PUT"],"type":"string"},"options":{"type":"object","properties":{"backgroundSync":{"type":"object","properties":{"name":{"type":"string"},"options":{"$ref":"#/definitions/QueueOptions"}},"additionalProperties":false},"broadcastUpdate":{"type":"object","properties":{"channelName":{"type":"string"},"options":{"$ref":"#/definitions/BroadcastCacheUpdateOptions"}},"additionalProperties":false},"cacheableResponse":{"$ref":"#/definitions/CacheableResponseOptions"},"cacheName":{"type":["null","string"]},"expiration":{"$ref":"#/definitions/ExpirationPluginOptions"},"networkTimeoutSeconds":{"type":"number"},"plugins":{"type":"array","items":{"$ref":"#/definitions/WorkboxPlugin"}},"precacheFallback":{"type":"object","properties":{"fallbackURL":{"type":"string"}},"additionalProperties":false},"fetchOptions":{"$ref":"#/definitions/RequestInit"},"matchOptions":{"$ref":"#/definitions/CacheQueryOptions"}},"additionalProperties":false},"urlPattern":{"anyOf":[{"$ref":"#/definitions/RegExp"},{"$ref":"#/definitions/RouteMatchCallback"},{"type":"string"}]}},"additionalProperties":false},"RouteHandlerCallback":{"description":"The \"handler\" callback is invoked whenever a `Router` matches a URL/Request\nto a `Route` via its `RouteMatchCallback`. This handler callback should\nreturn a `Promise` that resolves with a `Response`.\n\nIf a non-empty array or object is returned by the `RouteMatchCallback` it\nwill be passed in as this handler's `options.params` argument.","type":"object","additionalProperties":false},"RouteHandlerObject":{"description":"An object with a `handle` method of type `RouteHandlerCallback`.\n\nA `Route` object can be created with either an `RouteHandlerCallback`\nfunction or this `RouteHandler` object. The benefit of the `RouteHandler`\nis it can be extended (as is done by the `workbox-strategies` package).","type":"object","properties":{"handle":{"$ref":"#/definitions/RouteHandlerCallback"}},"additionalProperties":false},"QueueOptions":{"type":"object","properties":{"onSync":{"$ref":"#/definitions/OnSyncCallback"},"maxRetentionTime":{"type":"number"}},"additionalProperties":false},"OnSyncCallback":{"type":"object","additionalProperties":false},"BroadcastCacheUpdateOptions":{"type":"object","properties":{"headersToCheck":{"type":"array","items":{"type":"string"}},"generatePayload":{"type":"object","additionalProperties":false}},"additionalProperties":false},"CacheableResponseOptions":{"type":"object","properties":{"statuses":{"type":"array","items":{"type":"number"}},"headers":{"type":"object","additionalProperties":{"type":"string"}}},"additionalProperties":false},"ExpirationPluginOptions":{"type":"object","properties":{"maxEntries":{"type":"number"},"maxAgeSeconds":{"type":"number"},"matchOptions":{"$ref":"#/definitions/CacheQueryOptions"},"purgeOnQuotaError":{"type":"boolean"}},"additionalProperties":false},"CacheQueryOptions":{"type":"object","properties":{"ignoreMethod":{"type":"boolean"},"ignoreSearch":{"type":"boolean"},"ignoreVary":{"type":"boolean"}},"additionalProperties":false},"WorkboxPlugin":{"description":"An object with optional lifecycle callback properties for the fetch and\ncache operations.","type":"object","properties":{"cacheDidUpdate":{"$ref":"#/definitions/CacheDidUpdateCallback"},"cachedResponseWillBeUsed":{"$ref":"#/definitions/CachedResponseWillBeUsedCallback"},"cacheKeyWillBeUsed":{"$ref":"#/definitions/CacheKeyWillBeUsedCallback"},"cacheWillUpdate":{"$ref":"#/definitions/CacheWillUpdateCallback"},"fetchDidFail":{"$ref":"#/definitions/FetchDidFailCallback"},"fetchDidSucceed":{"$ref":"#/definitions/FetchDidSucceedCallback"},"handlerDidComplete":{"$ref":"#/definitions/HandlerDidCompleteCallback"},"handlerDidError":{"$ref":"#/definitions/HandlerDidErrorCallback"},"handlerDidRespond":{"$ref":"#/definitions/HandlerDidRespondCallback"},"handlerWillRespond":{"$ref":"#/definitions/HandlerWillRespondCallback"},"handlerWillStart":{"$ref":"#/definitions/HandlerWillStartCallback"},"requestWillFetch":{"$ref":"#/definitions/RequestWillFetchCallback"}},"additionalProperties":false},"CacheDidUpdateCallback":{"type":"object","additionalProperties":false},"CachedResponseWillBeUsedCallback":{"type":"object","additionalProperties":false},"CacheKeyWillBeUsedCallback":{"type":"object","additionalProperties":false},"CacheWillUpdateCallback":{"type":"object","additionalProperties":false},"FetchDidFailCallback":{"type":"object","additionalProperties":false},"FetchDidSucceedCallback":{"type":"object","additionalProperties":false},"HandlerDidCompleteCallback":{"type":"object","additionalProperties":false},"HandlerDidErrorCallback":{"type":"object","additionalProperties":false},"HandlerDidRespondCallback":{"type":"object","additionalProperties":false},"HandlerWillRespondCallback":{"type":"object","additionalProperties":false},"HandlerWillStartCallback":{"type":"object","additionalProperties":false},"RequestWillFetchCallback":{"type":"object","additionalProperties":false},"RequestInit":{"type":"object","properties":{"body":{"anyOf":[{"$ref":"#/definitions/ArrayBuffer"},{"$ref":"#/definitions/ArrayBufferView"},{"$ref":"#/definitions/Blob"},{"$ref":"#/definitions/FormData"},{"$ref":"#/definitions/URLSearchParams"},{"$ref":"#/definitions/ReadableStream"},{"type":["null","string"]}]},"cache":{"enum":["default","force-cache","no-cache","no-store","only-if-cached","reload"],"type":"string"},"credentials":{"enum":["include","omit","same-origin"],"type":"string"},"headers":{"anyOf":[{"$ref":"#/definitions/Headers"},{"type":"array","items":{"type":"array","items":{"type":"string"}}},{"$ref":"#/definitions/Record"}]},"integrity":{"type":"string"},"keepalive":{"type":"boolean"},"method":{"type":"string"},"mode":{"enum":["cors","navigate","no-cors","same-origin"],"type":"string"},"redirect":{"enum":["error","follow","manual"],"type":"string"},"referrer":{"type":"string"},"referrerPolicy":{"enum":["","no-referrer","no-referrer-when-downgrade","origin","origin-when-cross-origin","same-origin","strict-origin","strict-origin-when-cross-origin","unsafe-url"],"type":"string"},"signal":{"anyOf":[{"$ref":"#/definitions/AbortSignal"},{"type":"null"}]},"window":{}},"additionalProperties":false},"ArrayBuffer":{"type":"object","properties":{"byteLength":{"type":"number"},"__@toStringTag":{"type":"string"}},"additionalProperties":false},"ArrayBufferView":{"type":"object","properties":{"buffer":{"anyOf":[{"$ref":"#/definitions/ArrayBuffer"},{"$ref":"#/definitions/SharedArrayBuffer"}]},"byteLength":{"type":"number"},"byteOffset":{"type":"number"}},"additionalProperties":false},"SharedArrayBuffer":{"type":"object","properties":{"byteLength":{"type":"number"},"__@species":{"$ref":"#/definitions/SharedArrayBuffer"},"__@toStringTag":{"type":"string","enum":["SharedArrayBuffer"]}},"additionalProperties":false},"Blob":{"type":"object","properties":{"size":{"type":"number"},"type":{"type":"string"}},"additionalProperties":false},"FormData":{"type":"object","additionalProperties":false},"URLSearchParams":{"type":"object","additionalProperties":false},"ReadableStream":{"type":"object","properties":{"locked":{"type":"boolean"}},"additionalProperties":false},"Headers":{"type":"object","additionalProperties":false},"Record":{"type":"object","additionalProperties":false},"AbortSignal":{"type":"object","properties":{"aborted":{"type":"boolean"},"onabort":{"anyOf":[{"type":"object","additionalProperties":false},{"type":"null"}]}},"additionalProperties":false},"RouteMatchCallback":{"description":"The \"match\" callback is used to determine if a `Route` should apply for a\nparticular URL and request. When matching occurs in response to a fetch\nevent from the client, the `event` object is also supplied. However, since\nthe match callback can be invoked outside of a fetch event, matching logic\nshould not assume the `event` object will always be available.\nIf the match callback returns a truthy value, the matching route's\n`RouteHandlerCallback` will be invoked immediately. If the value returned\nis a non-empty array or object, that value will be set on the handler's\n`options.params` argument.","type":"object","additionalProperties":false},"ManifestEntry":{"type":"object","properties":{"integrity":{"type":"string"},"revision":{"type":["null","string"]},"url":{"type":"string"}},"additionalProperties":false}},"$schema":"http://json-schema.org/draft-07/schema#"} diff --git a/packages/workbox-build/src/schema/GetManifestOptions.json b/packages/workbox-build/src/schema/GetManifestOptions.json index 68df0ef0d..a606b0663 100644 --- a/packages/workbox-build/src/schema/GetManifestOptions.json +++ b/packages/workbox-build/src/schema/GetManifestOptions.json @@ -1 +1 @@ -{"additionalProperties":false,"type":"object","properties":{"globDirectory":{"type":["null","string"]},"globFollow":{"type":"boolean"},"globIgnores":{"type":"array","items":{"type":"string"}},"globPatterns":{"type":"array","items":{"type":"string"}},"globStrict":{"default":true,"type":"boolean"},"templatedURLs":{"type":"object","additionalProperties":{"anyOf":[{"type":"array","items":{"type":"string"}},{"type":"string"}]}},"additionalManifestEntries":{"type":"array","items":{"anyOf":[{"$ref":"#/definitions/ManifestEntry"},{"type":"string"}]}},"dontCacheBustURLsMatching":{"$ref":"#/definitions/RegExp"},"manifestTransforms":{"type":"array","items":{"type":"object","additionalProperties":false}},"maximumFileSizeToCacheInBytes":{"type":"number"},"modifyURLPrefix":{"type":"object","additionalProperties":{"type":"string"}}},"definitions":{"RegExp":{"type":"object","properties":{"source":{"type":"string"},"global":{"type":"boolean"},"ignoreCase":{"type":"boolean"},"multiline":{"type":"boolean"},"lastIndex":{"type":"number"},"flags":{"type":"string"},"sticky":{"type":"boolean"},"unicode":{"type":"boolean"},"dotAll":{"type":"boolean"}},"additionalProperties":false},"GoogleAnalyticsInitializeOptions":{"type":"object","properties":{"cacheName":{"type":"string"},"parameterOverrides":{"type":"object","additionalProperties":{"type":"string"}},"hitFilter":{"type":"object","additionalProperties":false}},"additionalProperties":false},"RuntimeCaching":{"type":"object","properties":{"handler":{"anyOf":[{"$ref":"#/definitions/RouteHandlerCallback"},{"$ref":"#/definitions/RouteHandlerObject"},{"enum":["CacheFirst","CacheOnly","NetworkFirst","NetworkOnly","StaleWhileRevalidate"],"type":"string"}]},"method":{"enum":["DELETE","GET","HEAD","PATCH","POST","PUT"],"type":"string"},"options":{"type":"object","properties":{"backgroundSync":{"type":"object","properties":{"name":{"type":"string"},"options":{"$ref":"#/definitions/QueueOptions"}},"additionalProperties":false},"broadcastUpdate":{"type":"object","properties":{"channelName":{"type":"string"},"options":{"$ref":"#/definitions/BroadcastCacheUpdateOptions"}},"additionalProperties":false},"cacheableResponse":{"$ref":"#/definitions/CacheableResponseOptions"},"cacheName":{"type":["null","string"]},"expiration":{"$ref":"#/definitions/ExpirationPluginOptions"},"networkTimeoutSeconds":{"type":"number"},"plugins":{"type":"array","items":{"$ref":"#/definitions/WorkboxPlugin"}},"precacheFallback":{"type":"object","properties":{"fallbackURL":{"type":"string"}},"additionalProperties":false},"fetchOptions":{"$ref":"#/definitions/RequestInit"},"matchOptions":{"$ref":"#/definitions/CacheQueryOptions"}},"additionalProperties":false},"urlPattern":{"anyOf":[{"$ref":"#/definitions/RegExp"},{"$ref":"#/definitions/RouteMatchCallback"},{"type":"string"}]}},"additionalProperties":false},"RouteHandlerCallback":{"description":"The \"handler\" callback is invoked whenever a `Router` matches a URL/Request\nto a `Route` via its `RouteMatchCallback`. This handler callback should\nreturn a `Promise` that resolves with a `Response`.\n\nIf a non-empty array or object is returned by the `RouteMatchCallback` it\nwill be passed in as this handler's `options.params` argument.","type":"object","additionalProperties":false},"RouteHandlerObject":{"description":"An object with a `handle` method of type `RouteHandlerCallback`.\n\nA `Route` object can be created with either an `RouteHandlerCallback`\nfunction or this `RouteHandler` object. The benefit of the `RouteHandler`\nis it can be extended (as is done by the `workbox-strategies` package).","type":"object","properties":{"handle":{"$ref":"#/definitions/RouteHandlerCallback"}},"additionalProperties":false},"QueueOptions":{"type":"object","properties":{"onSync":{"$ref":"#/definitions/OnSyncCallback"},"maxRetentionTime":{"type":"number"}},"additionalProperties":false},"OnSyncCallback":{"type":"object","additionalProperties":false},"BroadcastCacheUpdateOptions":{"type":"object","properties":{"headersToCheck":{"type":"array","items":{"type":"string"}},"generatePayload":{"type":"object","additionalProperties":false}},"additionalProperties":false},"CacheableResponseOptions":{"type":"object","properties":{"statuses":{"type":"array","items":{"type":"number"}},"headers":{"type":"object","additionalProperties":{"type":"string"}}},"additionalProperties":false},"ExpirationPluginOptions":{"type":"object","properties":{"maxEntries":{"type":"number"},"maxAgeSeconds":{"type":"number"},"matchOptions":{"$ref":"#/definitions/CacheQueryOptions"},"purgeOnQuotaError":{"type":"boolean"}},"additionalProperties":false},"CacheQueryOptions":{"type":"object","properties":{"ignoreMethod":{"type":"boolean"},"ignoreSearch":{"type":"boolean"},"ignoreVary":{"type":"boolean"}},"additionalProperties":false},"WorkboxPlugin":{"description":"An object with optional lifecycle callback properties for the fetch and\ncache operations.","type":"object","properties":{"cacheDidUpdate":{"$ref":"#/definitions/CacheDidUpdateCallback"},"cachedResponseWillBeUsed":{"$ref":"#/definitions/CachedResponseWillBeUsedCallback"},"cacheKeyWillBeUsed":{"$ref":"#/definitions/CacheKeyWillBeUsedCallback"},"cacheWillUpdate":{"$ref":"#/definitions/CacheWillUpdateCallback"},"fetchDidFail":{"$ref":"#/definitions/FetchDidFailCallback"},"fetchDidSucceed":{"$ref":"#/definitions/FetchDidSucceedCallback"},"handlerDidComplete":{"$ref":"#/definitions/HandlerDidCompleteCallback"},"handlerDidError":{"$ref":"#/definitions/HandlerDidErrorCallback"},"handlerDidRespond":{"$ref":"#/definitions/HandlerDidRespondCallback"},"handlerWillRespond":{"$ref":"#/definitions/HandlerWillRespondCallback"},"handlerWillStart":{"$ref":"#/definitions/HandlerWillStartCallback"},"requestWillFetch":{"$ref":"#/definitions/RequestWillFetchCallback"}},"additionalProperties":false},"CacheDidUpdateCallback":{"type":"object","additionalProperties":false},"CachedResponseWillBeUsedCallback":{"type":"object","additionalProperties":false},"CacheKeyWillBeUsedCallback":{"type":"object","additionalProperties":false},"CacheWillUpdateCallback":{"type":"object","additionalProperties":false},"FetchDidFailCallback":{"type":"object","additionalProperties":false},"FetchDidSucceedCallback":{"type":"object","additionalProperties":false},"HandlerDidCompleteCallback":{"type":"object","additionalProperties":false},"HandlerDidErrorCallback":{"type":"object","additionalProperties":false},"HandlerDidRespondCallback":{"type":"object","additionalProperties":false},"HandlerWillRespondCallback":{"type":"object","additionalProperties":false},"HandlerWillStartCallback":{"type":"object","additionalProperties":false},"RequestWillFetchCallback":{"type":"object","additionalProperties":false},"RequestInit":{"type":"object","properties":{"body":{"anyOf":[{"$ref":"#/definitions/ArrayBuffer"},{"$ref":"#/definitions/ArrayBufferView"},{"$ref":"#/definitions/Blob"},{"$ref":"#/definitions/FormData"},{"$ref":"#/definitions/URLSearchParams"},{"$ref":"#/definitions/ReadableStream"},{"type":["null","string"]}]},"cache":{"enum":["default","force-cache","no-cache","no-store","only-if-cached","reload"],"type":"string"},"credentials":{"enum":["include","omit","same-origin"],"type":"string"},"headers":{"anyOf":[{"$ref":"#/definitions/Headers"},{"type":"array","items":{"type":"array","items":{"type":"string"}}},{"$ref":"#/definitions/Record"}]},"integrity":{"type":"string"},"keepalive":{"type":"boolean"},"method":{"type":"string"},"mode":{"enum":["cors","navigate","no-cors","same-origin"],"type":"string"},"redirect":{"enum":["error","follow","manual"],"type":"string"},"referrer":{"type":"string"},"referrerPolicy":{"enum":["","no-referrer","no-referrer-when-downgrade","origin","origin-when-cross-origin","same-origin","strict-origin","strict-origin-when-cross-origin","unsafe-url"],"type":"string"},"signal":{"anyOf":[{"$ref":"#/definitions/AbortSignal"},{"type":"null"}]},"window":{}},"additionalProperties":false},"ArrayBuffer":{"type":"object","properties":{"byteLength":{"type":"number"},"__@toStringTag":{"type":"string"}},"additionalProperties":false},"ArrayBufferView":{"type":"object","properties":{"buffer":{"anyOf":[{"$ref":"#/definitions/ArrayBuffer"},{"$ref":"#/definitions/SharedArrayBuffer"}]},"byteLength":{"type":"number"},"byteOffset":{"type":"number"}},"additionalProperties":false},"SharedArrayBuffer":{"type":"object","properties":{"byteLength":{"type":"number"},"__@species":{"$ref":"#/definitions/SharedArrayBuffer"},"__@toStringTag":{"type":"string","enum":["SharedArrayBuffer"]}},"additionalProperties":false},"Blob":{"type":"object","properties":{"size":{"type":"number"},"type":{"type":"string"}},"additionalProperties":false},"FormData":{"type":"object","additionalProperties":false},"URLSearchParams":{"type":"object","additionalProperties":false},"ReadableStream":{"type":"object","properties":{"locked":{"type":"boolean"}},"additionalProperties":false},"Headers":{"type":"object","additionalProperties":false},"Record":{"type":"object","additionalProperties":false},"AbortSignal":{"type":"object","properties":{"aborted":{"type":"boolean"},"onabort":{"anyOf":[{"type":"object","additionalProperties":false},{"type":"null"}]}},"additionalProperties":false},"RouteMatchCallback":{"description":"The \"match\" callback is used to determine if a `Route` should apply for a\nparticular URL and request. When matching occurs in response to a fetch\nevent from the client, the `event` object is also supplied. However, since\nthe match callback can be invoked outside of a fetch event, matching logic\nshould not assume the `event` object will always be available.\nIf the match callback returns a truthy value, the matching route's\n`RouteHandlerCallback` will be invoked immediately. If the value returned\nis a non-empty array or object, that value will be set on the handler's\n`options.params` argument.","type":"object","additionalProperties":false},"ManifestEntry":{"type":"object","properties":{"integrity":{"type":"string"},"revision":{"type":["null","string"]},"url":{"type":"string"}},"additionalProperties":false}},"$schema":"http://json-schema.org/draft-07/schema#"} +{"additionalProperties":false,"type":"object","properties":{"globDirectory":{"type":["null","string"]},"globFollow":{"default":true,"type":"boolean"},"globIgnores":{"default":"['**\\/node_modules\\/**\\/*']","type":"array","items":{"type":"string"}},"globPatterns":{"default":"['**\\/*.{js,css,html}']","type":"array","items":{"type":"string"}},"globStrict":{"default":true,"type":"boolean"},"templatedURLs":{"type":"object","additionalProperties":{"anyOf":[{"type":"array","items":{"type":"string"}},{"type":"string"}]}},"additionalManifestEntries":{"type":"array","items":{"anyOf":[{"$ref":"#/definitions/ManifestEntry"},{"type":"string"}]}},"dontCacheBustURLsMatching":{"$ref":"#/definitions/RegExp"},"manifestTransforms":{"type":"array","items":{"type":"object","additionalProperties":false}},"maximumFileSizeToCacheInBytes":{"default":2097152,"type":"number"},"modifyURLPrefix":{"type":"object","additionalProperties":{"type":"string"}}},"definitions":{"RegExp":{"type":"object","properties":{"source":{"type":"string"},"global":{"type":"boolean"},"ignoreCase":{"type":"boolean"},"multiline":{"type":"boolean"},"lastIndex":{"type":"number"},"flags":{"type":"string"},"sticky":{"type":"boolean"},"unicode":{"type":"boolean"},"dotAll":{"type":"boolean"}},"additionalProperties":false},"GoogleAnalyticsInitializeOptions":{"type":"object","properties":{"cacheName":{"type":"string"},"parameterOverrides":{"type":"object","additionalProperties":{"type":"string"}},"hitFilter":{"type":"object","additionalProperties":false}},"additionalProperties":false},"RuntimeCaching":{"type":"object","properties":{"handler":{"anyOf":[{"$ref":"#/definitions/RouteHandlerCallback"},{"$ref":"#/definitions/RouteHandlerObject"},{"enum":["CacheFirst","CacheOnly","NetworkFirst","NetworkOnly","StaleWhileRevalidate"],"type":"string"}]},"method":{"enum":["DELETE","GET","HEAD","PATCH","POST","PUT"],"type":"string"},"options":{"type":"object","properties":{"backgroundSync":{"type":"object","properties":{"name":{"type":"string"},"options":{"$ref":"#/definitions/QueueOptions"}},"additionalProperties":false},"broadcastUpdate":{"type":"object","properties":{"channelName":{"type":"string"},"options":{"$ref":"#/definitions/BroadcastCacheUpdateOptions"}},"additionalProperties":false},"cacheableResponse":{"$ref":"#/definitions/CacheableResponseOptions"},"cacheName":{"type":["null","string"]},"expiration":{"$ref":"#/definitions/ExpirationPluginOptions"},"networkTimeoutSeconds":{"type":"number"},"plugins":{"type":"array","items":{"$ref":"#/definitions/WorkboxPlugin"}},"precacheFallback":{"type":"object","properties":{"fallbackURL":{"type":"string"}},"additionalProperties":false},"fetchOptions":{"$ref":"#/definitions/RequestInit"},"matchOptions":{"$ref":"#/definitions/CacheQueryOptions"}},"additionalProperties":false},"urlPattern":{"anyOf":[{"$ref":"#/definitions/RegExp"},{"$ref":"#/definitions/RouteMatchCallback"},{"type":"string"}]}},"additionalProperties":false},"RouteHandlerCallback":{"description":"The \"handler\" callback is invoked whenever a `Router` matches a URL/Request\nto a `Route` via its `RouteMatchCallback`. This handler callback should\nreturn a `Promise` that resolves with a `Response`.\n\nIf a non-empty array or object is returned by the `RouteMatchCallback` it\nwill be passed in as this handler's `options.params` argument.","type":"object","additionalProperties":false},"RouteHandlerObject":{"description":"An object with a `handle` method of type `RouteHandlerCallback`.\n\nA `Route` object can be created with either an `RouteHandlerCallback`\nfunction or this `RouteHandler` object. The benefit of the `RouteHandler`\nis it can be extended (as is done by the `workbox-strategies` package).","type":"object","properties":{"handle":{"$ref":"#/definitions/RouteHandlerCallback"}},"additionalProperties":false},"QueueOptions":{"type":"object","properties":{"onSync":{"$ref":"#/definitions/OnSyncCallback"},"maxRetentionTime":{"type":"number"}},"additionalProperties":false},"OnSyncCallback":{"type":"object","additionalProperties":false},"BroadcastCacheUpdateOptions":{"type":"object","properties":{"headersToCheck":{"type":"array","items":{"type":"string"}},"generatePayload":{"type":"object","additionalProperties":false}},"additionalProperties":false},"CacheableResponseOptions":{"type":"object","properties":{"statuses":{"type":"array","items":{"type":"number"}},"headers":{"type":"object","additionalProperties":{"type":"string"}}},"additionalProperties":false},"ExpirationPluginOptions":{"type":"object","properties":{"maxEntries":{"type":"number"},"maxAgeSeconds":{"type":"number"},"matchOptions":{"$ref":"#/definitions/CacheQueryOptions"},"purgeOnQuotaError":{"type":"boolean"}},"additionalProperties":false},"CacheQueryOptions":{"type":"object","properties":{"ignoreMethod":{"type":"boolean"},"ignoreSearch":{"type":"boolean"},"ignoreVary":{"type":"boolean"}},"additionalProperties":false},"WorkboxPlugin":{"description":"An object with optional lifecycle callback properties for the fetch and\ncache operations.","type":"object","properties":{"cacheDidUpdate":{"$ref":"#/definitions/CacheDidUpdateCallback"},"cachedResponseWillBeUsed":{"$ref":"#/definitions/CachedResponseWillBeUsedCallback"},"cacheKeyWillBeUsed":{"$ref":"#/definitions/CacheKeyWillBeUsedCallback"},"cacheWillUpdate":{"$ref":"#/definitions/CacheWillUpdateCallback"},"fetchDidFail":{"$ref":"#/definitions/FetchDidFailCallback"},"fetchDidSucceed":{"$ref":"#/definitions/FetchDidSucceedCallback"},"handlerDidComplete":{"$ref":"#/definitions/HandlerDidCompleteCallback"},"handlerDidError":{"$ref":"#/definitions/HandlerDidErrorCallback"},"handlerDidRespond":{"$ref":"#/definitions/HandlerDidRespondCallback"},"handlerWillRespond":{"$ref":"#/definitions/HandlerWillRespondCallback"},"handlerWillStart":{"$ref":"#/definitions/HandlerWillStartCallback"},"requestWillFetch":{"$ref":"#/definitions/RequestWillFetchCallback"}},"additionalProperties":false},"CacheDidUpdateCallback":{"type":"object","additionalProperties":false},"CachedResponseWillBeUsedCallback":{"type":"object","additionalProperties":false},"CacheKeyWillBeUsedCallback":{"type":"object","additionalProperties":false},"CacheWillUpdateCallback":{"type":"object","additionalProperties":false},"FetchDidFailCallback":{"type":"object","additionalProperties":false},"FetchDidSucceedCallback":{"type":"object","additionalProperties":false},"HandlerDidCompleteCallback":{"type":"object","additionalProperties":false},"HandlerDidErrorCallback":{"type":"object","additionalProperties":false},"HandlerDidRespondCallback":{"type":"object","additionalProperties":false},"HandlerWillRespondCallback":{"type":"object","additionalProperties":false},"HandlerWillStartCallback":{"type":"object","additionalProperties":false},"RequestWillFetchCallback":{"type":"object","additionalProperties":false},"RequestInit":{"type":"object","properties":{"body":{"anyOf":[{"$ref":"#/definitions/ArrayBuffer"},{"$ref":"#/definitions/ArrayBufferView"},{"$ref":"#/definitions/Blob"},{"$ref":"#/definitions/FormData"},{"$ref":"#/definitions/URLSearchParams"},{"$ref":"#/definitions/ReadableStream"},{"type":["null","string"]}]},"cache":{"enum":["default","force-cache","no-cache","no-store","only-if-cached","reload"],"type":"string"},"credentials":{"enum":["include","omit","same-origin"],"type":"string"},"headers":{"anyOf":[{"$ref":"#/definitions/Headers"},{"type":"array","items":{"type":"array","items":{"type":"string"}}},{"$ref":"#/definitions/Record"}]},"integrity":{"type":"string"},"keepalive":{"type":"boolean"},"method":{"type":"string"},"mode":{"enum":["cors","navigate","no-cors","same-origin"],"type":"string"},"redirect":{"enum":["error","follow","manual"],"type":"string"},"referrer":{"type":"string"},"referrerPolicy":{"enum":["","no-referrer","no-referrer-when-downgrade","origin","origin-when-cross-origin","same-origin","strict-origin","strict-origin-when-cross-origin","unsafe-url"],"type":"string"},"signal":{"anyOf":[{"$ref":"#/definitions/AbortSignal"},{"type":"null"}]},"window":{}},"additionalProperties":false},"ArrayBuffer":{"type":"object","properties":{"byteLength":{"type":"number"},"__@toStringTag":{"type":"string"}},"additionalProperties":false},"ArrayBufferView":{"type":"object","properties":{"buffer":{"anyOf":[{"$ref":"#/definitions/ArrayBuffer"},{"$ref":"#/definitions/SharedArrayBuffer"}]},"byteLength":{"type":"number"},"byteOffset":{"type":"number"}},"additionalProperties":false},"SharedArrayBuffer":{"type":"object","properties":{"byteLength":{"type":"number"},"__@species":{"$ref":"#/definitions/SharedArrayBuffer"},"__@toStringTag":{"type":"string","enum":["SharedArrayBuffer"]}},"additionalProperties":false},"Blob":{"type":"object","properties":{"size":{"type":"number"},"type":{"type":"string"}},"additionalProperties":false},"FormData":{"type":"object","additionalProperties":false},"URLSearchParams":{"type":"object","additionalProperties":false},"ReadableStream":{"type":"object","properties":{"locked":{"type":"boolean"}},"additionalProperties":false},"Headers":{"type":"object","additionalProperties":false},"Record":{"type":"object","additionalProperties":false},"AbortSignal":{"type":"object","properties":{"aborted":{"type":"boolean"},"onabort":{"anyOf":[{"type":"object","additionalProperties":false},{"type":"null"}]}},"additionalProperties":false},"RouteMatchCallback":{"description":"The \"match\" callback is used to determine if a `Route` should apply for a\nparticular URL and request. When matching occurs in response to a fetch\nevent from the client, the `event` object is also supplied. However, since\nthe match callback can be invoked outside of a fetch event, matching logic\nshould not assume the `event` object will always be available.\nIf the match callback returns a truthy value, the matching route's\n`RouteHandlerCallback` will be invoked immediately. If the value returned\nis a non-empty array or object, that value will be set on the handler's\n`options.params` argument.","type":"object","additionalProperties":false},"ManifestEntry":{"type":"object","properties":{"integrity":{"type":"string"},"revision":{"type":["null","string"]},"url":{"type":"string"}},"additionalProperties":false}},"$schema":"http://json-schema.org/draft-07/schema#"} diff --git a/packages/workbox-build/src/schema/InjectManifestOptions.json b/packages/workbox-build/src/schema/InjectManifestOptions.json index 8621ed37b..0de4ea1fc 100644 --- a/packages/workbox-build/src/schema/InjectManifestOptions.json +++ b/packages/workbox-build/src/schema/InjectManifestOptions.json @@ -1 +1 @@ -{"additionalProperties":false,"type":"object","properties":{"injectionPoint":{"type":"string"},"swSrc":{"type":"string"},"globFollow":{"type":"boolean"},"globIgnores":{"type":"array","items":{"type":"string"}},"globPatterns":{"type":"array","items":{"type":"string"}},"globStrict":{"default":true,"type":"boolean"},"templatedURLs":{"type":"object","additionalProperties":{"anyOf":[{"type":"array","items":{"type":"string"}},{"type":"string"}]}},"additionalManifestEntries":{"type":"array","items":{"anyOf":[{"$ref":"#/definitions/ManifestEntry"},{"type":"string"}]}},"dontCacheBustURLsMatching":{"$ref":"#/definitions/RegExp"},"manifestTransforms":{"type":"array","items":{"type":"object","additionalProperties":false}},"maximumFileSizeToCacheInBytes":{"type":"number"},"modifyURLPrefix":{"type":"object","additionalProperties":{"type":"string"}},"swDest":{"type":"string"},"globDirectory":{"type":"string"}},"definitions":{"RegExp":{"type":"object","properties":{"source":{"type":"string"},"global":{"type":"boolean"},"ignoreCase":{"type":"boolean"},"multiline":{"type":"boolean"},"lastIndex":{"type":"number"},"flags":{"type":"string"},"sticky":{"type":"boolean"},"unicode":{"type":"boolean"},"dotAll":{"type":"boolean"}},"additionalProperties":false},"GoogleAnalyticsInitializeOptions":{"type":"object","properties":{"cacheName":{"type":"string"},"parameterOverrides":{"type":"object","additionalProperties":{"type":"string"}},"hitFilter":{"type":"object","additionalProperties":false}},"additionalProperties":false},"RuntimeCaching":{"type":"object","properties":{"handler":{"anyOf":[{"$ref":"#/definitions/RouteHandlerCallback"},{"$ref":"#/definitions/RouteHandlerObject"},{"enum":["CacheFirst","CacheOnly","NetworkFirst","NetworkOnly","StaleWhileRevalidate"],"type":"string"}]},"method":{"enum":["DELETE","GET","HEAD","PATCH","POST","PUT"],"type":"string"},"options":{"type":"object","properties":{"backgroundSync":{"type":"object","properties":{"name":{"type":"string"},"options":{"$ref":"#/definitions/QueueOptions"}},"additionalProperties":false},"broadcastUpdate":{"type":"object","properties":{"channelName":{"type":"string"},"options":{"$ref":"#/definitions/BroadcastCacheUpdateOptions"}},"additionalProperties":false},"cacheableResponse":{"$ref":"#/definitions/CacheableResponseOptions"},"cacheName":{"type":["null","string"]},"expiration":{"$ref":"#/definitions/ExpirationPluginOptions"},"networkTimeoutSeconds":{"type":"number"},"plugins":{"type":"array","items":{"$ref":"#/definitions/WorkboxPlugin"}},"precacheFallback":{"type":"object","properties":{"fallbackURL":{"type":"string"}},"additionalProperties":false},"fetchOptions":{"$ref":"#/definitions/RequestInit"},"matchOptions":{"$ref":"#/definitions/CacheQueryOptions"}},"additionalProperties":false},"urlPattern":{"anyOf":[{"$ref":"#/definitions/RegExp"},{"$ref":"#/definitions/RouteMatchCallback"},{"type":"string"}]}},"additionalProperties":false},"RouteHandlerCallback":{"description":"The \"handler\" callback is invoked whenever a `Router` matches a URL/Request\nto a `Route` via its `RouteMatchCallback`. This handler callback should\nreturn a `Promise` that resolves with a `Response`.\n\nIf a non-empty array or object is returned by the `RouteMatchCallback` it\nwill be passed in as this handler's `options.params` argument.","type":"object","additionalProperties":false},"RouteHandlerObject":{"description":"An object with a `handle` method of type `RouteHandlerCallback`.\n\nA `Route` object can be created with either an `RouteHandlerCallback`\nfunction or this `RouteHandler` object. The benefit of the `RouteHandler`\nis it can be extended (as is done by the `workbox-strategies` package).","type":"object","properties":{"handle":{"$ref":"#/definitions/RouteHandlerCallback"}},"additionalProperties":false},"QueueOptions":{"type":"object","properties":{"onSync":{"$ref":"#/definitions/OnSyncCallback"},"maxRetentionTime":{"type":"number"}},"additionalProperties":false},"OnSyncCallback":{"type":"object","additionalProperties":false},"BroadcastCacheUpdateOptions":{"type":"object","properties":{"headersToCheck":{"type":"array","items":{"type":"string"}},"generatePayload":{"type":"object","additionalProperties":false}},"additionalProperties":false},"CacheableResponseOptions":{"type":"object","properties":{"statuses":{"type":"array","items":{"type":"number"}},"headers":{"type":"object","additionalProperties":{"type":"string"}}},"additionalProperties":false},"ExpirationPluginOptions":{"type":"object","properties":{"maxEntries":{"type":"number"},"maxAgeSeconds":{"type":"number"},"matchOptions":{"$ref":"#/definitions/CacheQueryOptions"},"purgeOnQuotaError":{"type":"boolean"}},"additionalProperties":false},"CacheQueryOptions":{"type":"object","properties":{"ignoreMethod":{"type":"boolean"},"ignoreSearch":{"type":"boolean"},"ignoreVary":{"type":"boolean"}},"additionalProperties":false},"WorkboxPlugin":{"description":"An object with optional lifecycle callback properties for the fetch and\ncache operations.","type":"object","properties":{"cacheDidUpdate":{"$ref":"#/definitions/CacheDidUpdateCallback"},"cachedResponseWillBeUsed":{"$ref":"#/definitions/CachedResponseWillBeUsedCallback"},"cacheKeyWillBeUsed":{"$ref":"#/definitions/CacheKeyWillBeUsedCallback"},"cacheWillUpdate":{"$ref":"#/definitions/CacheWillUpdateCallback"},"fetchDidFail":{"$ref":"#/definitions/FetchDidFailCallback"},"fetchDidSucceed":{"$ref":"#/definitions/FetchDidSucceedCallback"},"handlerDidComplete":{"$ref":"#/definitions/HandlerDidCompleteCallback"},"handlerDidError":{"$ref":"#/definitions/HandlerDidErrorCallback"},"handlerDidRespond":{"$ref":"#/definitions/HandlerDidRespondCallback"},"handlerWillRespond":{"$ref":"#/definitions/HandlerWillRespondCallback"},"handlerWillStart":{"$ref":"#/definitions/HandlerWillStartCallback"},"requestWillFetch":{"$ref":"#/definitions/RequestWillFetchCallback"}},"additionalProperties":false},"CacheDidUpdateCallback":{"type":"object","additionalProperties":false},"CachedResponseWillBeUsedCallback":{"type":"object","additionalProperties":false},"CacheKeyWillBeUsedCallback":{"type":"object","additionalProperties":false},"CacheWillUpdateCallback":{"type":"object","additionalProperties":false},"FetchDidFailCallback":{"type":"object","additionalProperties":false},"FetchDidSucceedCallback":{"type":"object","additionalProperties":false},"HandlerDidCompleteCallback":{"type":"object","additionalProperties":false},"HandlerDidErrorCallback":{"type":"object","additionalProperties":false},"HandlerDidRespondCallback":{"type":"object","additionalProperties":false},"HandlerWillRespondCallback":{"type":"object","additionalProperties":false},"HandlerWillStartCallback":{"type":"object","additionalProperties":false},"RequestWillFetchCallback":{"type":"object","additionalProperties":false},"RequestInit":{"type":"object","properties":{"body":{"anyOf":[{"$ref":"#/definitions/ArrayBuffer"},{"$ref":"#/definitions/ArrayBufferView"},{"$ref":"#/definitions/Blob"},{"$ref":"#/definitions/FormData"},{"$ref":"#/definitions/URLSearchParams"},{"$ref":"#/definitions/ReadableStream"},{"type":["null","string"]}]},"cache":{"enum":["default","force-cache","no-cache","no-store","only-if-cached","reload"],"type":"string"},"credentials":{"enum":["include","omit","same-origin"],"type":"string"},"headers":{"anyOf":[{"$ref":"#/definitions/Headers"},{"type":"array","items":{"type":"array","items":{"type":"string"}}},{"$ref":"#/definitions/Record"}]},"integrity":{"type":"string"},"keepalive":{"type":"boolean"},"method":{"type":"string"},"mode":{"enum":["cors","navigate","no-cors","same-origin"],"type":"string"},"redirect":{"enum":["error","follow","manual"],"type":"string"},"referrer":{"type":"string"},"referrerPolicy":{"enum":["","no-referrer","no-referrer-when-downgrade","origin","origin-when-cross-origin","same-origin","strict-origin","strict-origin-when-cross-origin","unsafe-url"],"type":"string"},"signal":{"anyOf":[{"$ref":"#/definitions/AbortSignal"},{"type":"null"}]},"window":{}},"additionalProperties":false},"ArrayBuffer":{"type":"object","properties":{"byteLength":{"type":"number"},"__@toStringTag":{"type":"string"}},"additionalProperties":false},"ArrayBufferView":{"type":"object","properties":{"buffer":{"anyOf":[{"$ref":"#/definitions/ArrayBuffer"},{"$ref":"#/definitions/SharedArrayBuffer"}]},"byteLength":{"type":"number"},"byteOffset":{"type":"number"}},"additionalProperties":false},"SharedArrayBuffer":{"type":"object","properties":{"byteLength":{"type":"number"},"__@species":{"$ref":"#/definitions/SharedArrayBuffer"},"__@toStringTag":{"type":"string","enum":["SharedArrayBuffer"]}},"additionalProperties":false},"Blob":{"type":"object","properties":{"size":{"type":"number"},"type":{"type":"string"}},"additionalProperties":false},"FormData":{"type":"object","additionalProperties":false},"URLSearchParams":{"type":"object","additionalProperties":false},"ReadableStream":{"type":"object","properties":{"locked":{"type":"boolean"}},"additionalProperties":false},"Headers":{"type":"object","additionalProperties":false},"Record":{"type":"object","additionalProperties":false},"AbortSignal":{"type":"object","properties":{"aborted":{"type":"boolean"},"onabort":{"anyOf":[{"type":"object","additionalProperties":false},{"type":"null"}]}},"additionalProperties":false},"RouteMatchCallback":{"description":"The \"match\" callback is used to determine if a `Route` should apply for a\nparticular URL and request. When matching occurs in response to a fetch\nevent from the client, the `event` object is also supplied. However, since\nthe match callback can be invoked outside of a fetch event, matching logic\nshould not assume the `event` object will always be available.\nIf the match callback returns a truthy value, the matching route's\n`RouteHandlerCallback` will be invoked immediately. If the value returned\nis a non-empty array or object, that value will be set on the handler's\n`options.params` argument.","type":"object","additionalProperties":false},"ManifestEntry":{"type":"object","properties":{"integrity":{"type":"string"},"revision":{"type":["null","string"]},"url":{"type":"string"}},"additionalProperties":false}},"$schema":"http://json-schema.org/draft-07/schema#"} +{"additionalProperties":false,"type":"object","properties":{"injectionPoint":{"default":"'self.__WB_MANIFEST'","type":"string"},"swSrc":{"type":"string"},"globFollow":{"default":true,"type":"boolean"},"globIgnores":{"default":"['**\\/node_modules\\/**\\/*']","type":"array","items":{"type":"string"}},"globPatterns":{"default":"['**\\/*.{js,css,html}']","type":"array","items":{"type":"string"}},"globStrict":{"default":true,"type":"boolean"},"templatedURLs":{"type":"object","additionalProperties":{"anyOf":[{"type":"array","items":{"type":"string"}},{"type":"string"}]}},"additionalManifestEntries":{"type":"array","items":{"anyOf":[{"$ref":"#/definitions/ManifestEntry"},{"type":"string"}]}},"dontCacheBustURLsMatching":{"$ref":"#/definitions/RegExp"},"manifestTransforms":{"type":"array","items":{"type":"object","additionalProperties":false}},"maximumFileSizeToCacheInBytes":{"default":2097152,"type":"number"},"modifyURLPrefix":{"type":"object","additionalProperties":{"type":"string"}},"swDest":{"default":"'service-worker.js'","type":"string"},"globDirectory":{"type":"string"}},"definitions":{"RegExp":{"type":"object","properties":{"source":{"type":"string"},"global":{"type":"boolean"},"ignoreCase":{"type":"boolean"},"multiline":{"type":"boolean"},"lastIndex":{"type":"number"},"flags":{"type":"string"},"sticky":{"type":"boolean"},"unicode":{"type":"boolean"},"dotAll":{"type":"boolean"}},"additionalProperties":false},"GoogleAnalyticsInitializeOptions":{"type":"object","properties":{"cacheName":{"type":"string"},"parameterOverrides":{"type":"object","additionalProperties":{"type":"string"}},"hitFilter":{"type":"object","additionalProperties":false}},"additionalProperties":false},"RuntimeCaching":{"type":"object","properties":{"handler":{"anyOf":[{"$ref":"#/definitions/RouteHandlerCallback"},{"$ref":"#/definitions/RouteHandlerObject"},{"enum":["CacheFirst","CacheOnly","NetworkFirst","NetworkOnly","StaleWhileRevalidate"],"type":"string"}]},"method":{"enum":["DELETE","GET","HEAD","PATCH","POST","PUT"],"type":"string"},"options":{"type":"object","properties":{"backgroundSync":{"type":"object","properties":{"name":{"type":"string"},"options":{"$ref":"#/definitions/QueueOptions"}},"additionalProperties":false},"broadcastUpdate":{"type":"object","properties":{"channelName":{"type":"string"},"options":{"$ref":"#/definitions/BroadcastCacheUpdateOptions"}},"additionalProperties":false},"cacheableResponse":{"$ref":"#/definitions/CacheableResponseOptions"},"cacheName":{"type":["null","string"]},"expiration":{"$ref":"#/definitions/ExpirationPluginOptions"},"networkTimeoutSeconds":{"type":"number"},"plugins":{"type":"array","items":{"$ref":"#/definitions/WorkboxPlugin"}},"precacheFallback":{"type":"object","properties":{"fallbackURL":{"type":"string"}},"additionalProperties":false},"fetchOptions":{"$ref":"#/definitions/RequestInit"},"matchOptions":{"$ref":"#/definitions/CacheQueryOptions"}},"additionalProperties":false},"urlPattern":{"anyOf":[{"$ref":"#/definitions/RegExp"},{"$ref":"#/definitions/RouteMatchCallback"},{"type":"string"}]}},"additionalProperties":false},"RouteHandlerCallback":{"description":"The \"handler\" callback is invoked whenever a `Router` matches a URL/Request\nto a `Route` via its `RouteMatchCallback`. This handler callback should\nreturn a `Promise` that resolves with a `Response`.\n\nIf a non-empty array or object is returned by the `RouteMatchCallback` it\nwill be passed in as this handler's `options.params` argument.","type":"object","additionalProperties":false},"RouteHandlerObject":{"description":"An object with a `handle` method of type `RouteHandlerCallback`.\n\nA `Route` object can be created with either an `RouteHandlerCallback`\nfunction or this `RouteHandler` object. The benefit of the `RouteHandler`\nis it can be extended (as is done by the `workbox-strategies` package).","type":"object","properties":{"handle":{"$ref":"#/definitions/RouteHandlerCallback"}},"additionalProperties":false},"QueueOptions":{"type":"object","properties":{"onSync":{"$ref":"#/definitions/OnSyncCallback"},"maxRetentionTime":{"type":"number"}},"additionalProperties":false},"OnSyncCallback":{"type":"object","additionalProperties":false},"BroadcastCacheUpdateOptions":{"type":"object","properties":{"headersToCheck":{"type":"array","items":{"type":"string"}},"generatePayload":{"type":"object","additionalProperties":false}},"additionalProperties":false},"CacheableResponseOptions":{"type":"object","properties":{"statuses":{"type":"array","items":{"type":"number"}},"headers":{"type":"object","additionalProperties":{"type":"string"}}},"additionalProperties":false},"ExpirationPluginOptions":{"type":"object","properties":{"maxEntries":{"type":"number"},"maxAgeSeconds":{"type":"number"},"matchOptions":{"$ref":"#/definitions/CacheQueryOptions"},"purgeOnQuotaError":{"type":"boolean"}},"additionalProperties":false},"CacheQueryOptions":{"type":"object","properties":{"ignoreMethod":{"type":"boolean"},"ignoreSearch":{"type":"boolean"},"ignoreVary":{"type":"boolean"}},"additionalProperties":false},"WorkboxPlugin":{"description":"An object with optional lifecycle callback properties for the fetch and\ncache operations.","type":"object","properties":{"cacheDidUpdate":{"$ref":"#/definitions/CacheDidUpdateCallback"},"cachedResponseWillBeUsed":{"$ref":"#/definitions/CachedResponseWillBeUsedCallback"},"cacheKeyWillBeUsed":{"$ref":"#/definitions/CacheKeyWillBeUsedCallback"},"cacheWillUpdate":{"$ref":"#/definitions/CacheWillUpdateCallback"},"fetchDidFail":{"$ref":"#/definitions/FetchDidFailCallback"},"fetchDidSucceed":{"$ref":"#/definitions/FetchDidSucceedCallback"},"handlerDidComplete":{"$ref":"#/definitions/HandlerDidCompleteCallback"},"handlerDidError":{"$ref":"#/definitions/HandlerDidErrorCallback"},"handlerDidRespond":{"$ref":"#/definitions/HandlerDidRespondCallback"},"handlerWillRespond":{"$ref":"#/definitions/HandlerWillRespondCallback"},"handlerWillStart":{"$ref":"#/definitions/HandlerWillStartCallback"},"requestWillFetch":{"$ref":"#/definitions/RequestWillFetchCallback"}},"additionalProperties":false},"CacheDidUpdateCallback":{"type":"object","additionalProperties":false},"CachedResponseWillBeUsedCallback":{"type":"object","additionalProperties":false},"CacheKeyWillBeUsedCallback":{"type":"object","additionalProperties":false},"CacheWillUpdateCallback":{"type":"object","additionalProperties":false},"FetchDidFailCallback":{"type":"object","additionalProperties":false},"FetchDidSucceedCallback":{"type":"object","additionalProperties":false},"HandlerDidCompleteCallback":{"type":"object","additionalProperties":false},"HandlerDidErrorCallback":{"type":"object","additionalProperties":false},"HandlerDidRespondCallback":{"type":"object","additionalProperties":false},"HandlerWillRespondCallback":{"type":"object","additionalProperties":false},"HandlerWillStartCallback":{"type":"object","additionalProperties":false},"RequestWillFetchCallback":{"type":"object","additionalProperties":false},"RequestInit":{"type":"object","properties":{"body":{"anyOf":[{"$ref":"#/definitions/ArrayBuffer"},{"$ref":"#/definitions/ArrayBufferView"},{"$ref":"#/definitions/Blob"},{"$ref":"#/definitions/FormData"},{"$ref":"#/definitions/URLSearchParams"},{"$ref":"#/definitions/ReadableStream"},{"type":["null","string"]}]},"cache":{"enum":["default","force-cache","no-cache","no-store","only-if-cached","reload"],"type":"string"},"credentials":{"enum":["include","omit","same-origin"],"type":"string"},"headers":{"anyOf":[{"$ref":"#/definitions/Headers"},{"type":"array","items":{"type":"array","items":{"type":"string"}}},{"$ref":"#/definitions/Record"}]},"integrity":{"type":"string"},"keepalive":{"type":"boolean"},"method":{"type":"string"},"mode":{"enum":["cors","navigate","no-cors","same-origin"],"type":"string"},"redirect":{"enum":["error","follow","manual"],"type":"string"},"referrer":{"type":"string"},"referrerPolicy":{"enum":["","no-referrer","no-referrer-when-downgrade","origin","origin-when-cross-origin","same-origin","strict-origin","strict-origin-when-cross-origin","unsafe-url"],"type":"string"},"signal":{"anyOf":[{"$ref":"#/definitions/AbortSignal"},{"type":"null"}]},"window":{}},"additionalProperties":false},"ArrayBuffer":{"type":"object","properties":{"byteLength":{"type":"number"},"__@toStringTag":{"type":"string"}},"additionalProperties":false},"ArrayBufferView":{"type":"object","properties":{"buffer":{"anyOf":[{"$ref":"#/definitions/ArrayBuffer"},{"$ref":"#/definitions/SharedArrayBuffer"}]},"byteLength":{"type":"number"},"byteOffset":{"type":"number"}},"additionalProperties":false},"SharedArrayBuffer":{"type":"object","properties":{"byteLength":{"type":"number"},"__@species":{"$ref":"#/definitions/SharedArrayBuffer"},"__@toStringTag":{"type":"string","enum":["SharedArrayBuffer"]}},"additionalProperties":false},"Blob":{"type":"object","properties":{"size":{"type":"number"},"type":{"type":"string"}},"additionalProperties":false},"FormData":{"type":"object","additionalProperties":false},"URLSearchParams":{"type":"object","additionalProperties":false},"ReadableStream":{"type":"object","properties":{"locked":{"type":"boolean"}},"additionalProperties":false},"Headers":{"type":"object","additionalProperties":false},"Record":{"type":"object","additionalProperties":false},"AbortSignal":{"type":"object","properties":{"aborted":{"type":"boolean"},"onabort":{"anyOf":[{"type":"object","additionalProperties":false},{"type":"null"}]}},"additionalProperties":false},"RouteMatchCallback":{"description":"The \"match\" callback is used to determine if a `Route` should apply for a\nparticular URL and request. When matching occurs in response to a fetch\nevent from the client, the `event` object is also supplied. However, since\nthe match callback can be invoked outside of a fetch event, matching logic\nshould not assume the `event` object will always be available.\nIf the match callback returns a truthy value, the matching route's\n`RouteHandlerCallback` will be invoked immediately. If the value returned\nis a non-empty array or object, that value will be set on the handler's\n`options.params` argument.","type":"object","additionalProperties":false},"ManifestEntry":{"type":"object","properties":{"integrity":{"type":"string"},"revision":{"type":["null","string"]},"url":{"type":"string"}},"additionalProperties":false}},"$schema":"http://json-schema.org/draft-07/schema#"} diff --git a/packages/workbox-build/src/schema/WebpackGenerateSWOptions.json b/packages/workbox-build/src/schema/WebpackGenerateSWOptions.json index eac433949..67365e397 100644 --- a/packages/workbox-build/src/schema/WebpackGenerateSWOptions.json +++ b/packages/workbox-build/src/schema/WebpackGenerateSWOptions.json @@ -1 +1 @@ -{"additionalProperties":false,"type":"object","properties":{"chunks":{"type":"array","items":{"type":"string"}},"exclude":{"type":"array","items":{"anyOf":[{"$ref":"#/definitions/RegExp"},{"type":"object","additionalProperties":false},{"type":"string"}]}},"excludeChunks":{"type":"array","items":{"type":"string"}},"include":{"type":"array","items":{"anyOf":[{"$ref":"#/definitions/RegExp"},{"type":"object","additionalProperties":false},{"type":"string"}]}},"mode":{"type":["null","string"]},"babelPresetEnvTargets":{"type":"array","items":{"type":"string"}},"cacheId":{"type":["null","string"]},"cleanupOutdatedCaches":{"type":"boolean"},"clientsClaim":{"type":"boolean"},"directoryIndex":{"type":["null","string"]},"disableDevLogs":{"type":"boolean"},"ignoreURLParametersMatching":{"type":"array","items":{"$ref":"#/definitions/RegExp"}},"importScripts":{"type":"array","items":{"type":"string"}},"inlineWorkboxRuntime":{"type":"boolean"},"navigateFallback":{"type":["null","string"]},"navigateFallbackAllowlist":{"type":"array","items":{"$ref":"#/definitions/RegExp"}},"navigateFallbackDenylist":{"type":"array","items":{"$ref":"#/definitions/RegExp"}},"navigationPreload":{"type":"boolean"},"offlineGoogleAnalytics":{"anyOf":[{"$ref":"#/definitions/GoogleAnalyticsInitializeOptions"},{"type":"boolean"}]},"runtimeCaching":{"type":"array","items":{"$ref":"#/definitions/RuntimeCaching"}},"skipWaiting":{"type":"boolean"},"sourcemap":{"type":"boolean"},"additionalManifestEntries":{"type":"array","items":{"anyOf":[{"$ref":"#/definitions/ManifestEntry"},{"type":"string"}]}},"dontCacheBustURLsMatching":{"$ref":"#/definitions/RegExp"},"manifestTransforms":{"type":"array","items":{"type":"object","additionalProperties":false}},"maximumFileSizeToCacheInBytes":{"type":"number"},"modifyURLPrefix":{"type":"object","additionalProperties":{"type":"string"}},"swDest":{"type":"string"},"importScriptsViaChunks":{"type":"array","items":{"type":"string"}}},"definitions":{"RegExp":{"type":"object","properties":{"source":{"type":"string"},"global":{"type":"boolean"},"ignoreCase":{"type":"boolean"},"multiline":{"type":"boolean"},"lastIndex":{"type":"number"},"flags":{"type":"string"},"sticky":{"type":"boolean"},"unicode":{"type":"boolean"},"dotAll":{"type":"boolean"}},"additionalProperties":false},"GoogleAnalyticsInitializeOptions":{"type":"object","properties":{"cacheName":{"type":"string"},"parameterOverrides":{"type":"object","additionalProperties":{"type":"string"}},"hitFilter":{"type":"object","additionalProperties":false}},"additionalProperties":false},"RuntimeCaching":{"type":"object","properties":{"handler":{"anyOf":[{"$ref":"#/definitions/RouteHandlerCallback"},{"$ref":"#/definitions/RouteHandlerObject"},{"enum":["CacheFirst","CacheOnly","NetworkFirst","NetworkOnly","StaleWhileRevalidate"],"type":"string"}]},"method":{"enum":["DELETE","GET","HEAD","PATCH","POST","PUT"],"type":"string"},"options":{"type":"object","properties":{"backgroundSync":{"type":"object","properties":{"name":{"type":"string"},"options":{"$ref":"#/definitions/QueueOptions"}},"additionalProperties":false},"broadcastUpdate":{"type":"object","properties":{"channelName":{"type":"string"},"options":{"$ref":"#/definitions/BroadcastCacheUpdateOptions"}},"additionalProperties":false},"cacheableResponse":{"$ref":"#/definitions/CacheableResponseOptions"},"cacheName":{"type":["null","string"]},"expiration":{"$ref":"#/definitions/ExpirationPluginOptions"},"networkTimeoutSeconds":{"type":"number"},"plugins":{"type":"array","items":{"$ref":"#/definitions/WorkboxPlugin"}},"precacheFallback":{"type":"object","properties":{"fallbackURL":{"type":"string"}},"additionalProperties":false},"fetchOptions":{"$ref":"#/definitions/RequestInit"},"matchOptions":{"$ref":"#/definitions/CacheQueryOptions"}},"additionalProperties":false},"urlPattern":{"anyOf":[{"$ref":"#/definitions/RegExp"},{"$ref":"#/definitions/RouteMatchCallback"},{"type":"string"}]}},"additionalProperties":false},"RouteHandlerCallback":{"description":"The \"handler\" callback is invoked whenever a `Router` matches a URL/Request\nto a `Route` via its `RouteMatchCallback`. This handler callback should\nreturn a `Promise` that resolves with a `Response`.\n\nIf a non-empty array or object is returned by the `RouteMatchCallback` it\nwill be passed in as this handler's `options.params` argument.","type":"object","additionalProperties":false},"RouteHandlerObject":{"description":"An object with a `handle` method of type `RouteHandlerCallback`.\n\nA `Route` object can be created with either an `RouteHandlerCallback`\nfunction or this `RouteHandler` object. The benefit of the `RouteHandler`\nis it can be extended (as is done by the `workbox-strategies` package).","type":"object","properties":{"handle":{"$ref":"#/definitions/RouteHandlerCallback"}},"additionalProperties":false},"QueueOptions":{"type":"object","properties":{"onSync":{"$ref":"#/definitions/OnSyncCallback"},"maxRetentionTime":{"type":"number"}},"additionalProperties":false},"OnSyncCallback":{"type":"object","additionalProperties":false},"BroadcastCacheUpdateOptions":{"type":"object","properties":{"headersToCheck":{"type":"array","items":{"type":"string"}},"generatePayload":{"type":"object","additionalProperties":false}},"additionalProperties":false},"CacheableResponseOptions":{"type":"object","properties":{"statuses":{"type":"array","items":{"type":"number"}},"headers":{"type":"object","additionalProperties":{"type":"string"}}},"additionalProperties":false},"ExpirationPluginOptions":{"type":"object","properties":{"maxEntries":{"type":"number"},"maxAgeSeconds":{"type":"number"},"matchOptions":{"$ref":"#/definitions/CacheQueryOptions"},"purgeOnQuotaError":{"type":"boolean"}},"additionalProperties":false},"CacheQueryOptions":{"type":"object","properties":{"ignoreMethod":{"type":"boolean"},"ignoreSearch":{"type":"boolean"},"ignoreVary":{"type":"boolean"}},"additionalProperties":false},"WorkboxPlugin":{"description":"An object with optional lifecycle callback properties for the fetch and\ncache operations.","type":"object","properties":{"cacheDidUpdate":{"$ref":"#/definitions/CacheDidUpdateCallback"},"cachedResponseWillBeUsed":{"$ref":"#/definitions/CachedResponseWillBeUsedCallback"},"cacheKeyWillBeUsed":{"$ref":"#/definitions/CacheKeyWillBeUsedCallback"},"cacheWillUpdate":{"$ref":"#/definitions/CacheWillUpdateCallback"},"fetchDidFail":{"$ref":"#/definitions/FetchDidFailCallback"},"fetchDidSucceed":{"$ref":"#/definitions/FetchDidSucceedCallback"},"handlerDidComplete":{"$ref":"#/definitions/HandlerDidCompleteCallback"},"handlerDidError":{"$ref":"#/definitions/HandlerDidErrorCallback"},"handlerDidRespond":{"$ref":"#/definitions/HandlerDidRespondCallback"},"handlerWillRespond":{"$ref":"#/definitions/HandlerWillRespondCallback"},"handlerWillStart":{"$ref":"#/definitions/HandlerWillStartCallback"},"requestWillFetch":{"$ref":"#/definitions/RequestWillFetchCallback"}},"additionalProperties":false},"CacheDidUpdateCallback":{"type":"object","additionalProperties":false},"CachedResponseWillBeUsedCallback":{"type":"object","additionalProperties":false},"CacheKeyWillBeUsedCallback":{"type":"object","additionalProperties":false},"CacheWillUpdateCallback":{"type":"object","additionalProperties":false},"FetchDidFailCallback":{"type":"object","additionalProperties":false},"FetchDidSucceedCallback":{"type":"object","additionalProperties":false},"HandlerDidCompleteCallback":{"type":"object","additionalProperties":false},"HandlerDidErrorCallback":{"type":"object","additionalProperties":false},"HandlerDidRespondCallback":{"type":"object","additionalProperties":false},"HandlerWillRespondCallback":{"type":"object","additionalProperties":false},"HandlerWillStartCallback":{"type":"object","additionalProperties":false},"RequestWillFetchCallback":{"type":"object","additionalProperties":false},"RequestInit":{"type":"object","properties":{"body":{"anyOf":[{"$ref":"#/definitions/ArrayBuffer"},{"$ref":"#/definitions/ArrayBufferView"},{"$ref":"#/definitions/Blob"},{"$ref":"#/definitions/FormData"},{"$ref":"#/definitions/URLSearchParams"},{"$ref":"#/definitions/ReadableStream"},{"type":["null","string"]}]},"cache":{"enum":["default","force-cache","no-cache","no-store","only-if-cached","reload"],"type":"string"},"credentials":{"enum":["include","omit","same-origin"],"type":"string"},"headers":{"anyOf":[{"$ref":"#/definitions/Headers"},{"type":"array","items":{"type":"array","items":{"type":"string"}}},{"$ref":"#/definitions/Record"}]},"integrity":{"type":"string"},"keepalive":{"type":"boolean"},"method":{"type":"string"},"mode":{"enum":["cors","navigate","no-cors","same-origin"],"type":"string"},"redirect":{"enum":["error","follow","manual"],"type":"string"},"referrer":{"type":"string"},"referrerPolicy":{"enum":["","no-referrer","no-referrer-when-downgrade","origin","origin-when-cross-origin","same-origin","strict-origin","strict-origin-when-cross-origin","unsafe-url"],"type":"string"},"signal":{"anyOf":[{"$ref":"#/definitions/AbortSignal"},{"type":"null"}]},"window":{}},"additionalProperties":false},"ArrayBuffer":{"type":"object","properties":{"byteLength":{"type":"number"},"__@toStringTag":{"type":"string"}},"additionalProperties":false},"ArrayBufferView":{"type":"object","properties":{"buffer":{"anyOf":[{"$ref":"#/definitions/ArrayBuffer"},{"$ref":"#/definitions/SharedArrayBuffer"}]},"byteLength":{"type":"number"},"byteOffset":{"type":"number"}},"additionalProperties":false},"SharedArrayBuffer":{"type":"object","properties":{"byteLength":{"type":"number"},"__@species":{"$ref":"#/definitions/SharedArrayBuffer"},"__@toStringTag":{"type":"string","enum":["SharedArrayBuffer"]}},"additionalProperties":false},"Blob":{"type":"object","properties":{"size":{"type":"number"},"type":{"type":"string"}},"additionalProperties":false},"FormData":{"type":"object","additionalProperties":false},"URLSearchParams":{"type":"object","additionalProperties":false},"ReadableStream":{"type":"object","properties":{"locked":{"type":"boolean"}},"additionalProperties":false},"Headers":{"type":"object","additionalProperties":false},"Record":{"type":"object","additionalProperties":false},"AbortSignal":{"type":"object","properties":{"aborted":{"type":"boolean"},"onabort":{"anyOf":[{"type":"object","additionalProperties":false},{"type":"null"}]}},"additionalProperties":false},"RouteMatchCallback":{"description":"The \"match\" callback is used to determine if a `Route` should apply for a\nparticular URL and request. When matching occurs in response to a fetch\nevent from the client, the `event` object is also supplied. However, since\nthe match callback can be invoked outside of a fetch event, matching logic\nshould not assume the `event` object will always be available.\nIf the match callback returns a truthy value, the matching route's\n`RouteHandlerCallback` will be invoked immediately. If the value returned\nis a non-empty array or object, that value will be set on the handler's\n`options.params` argument.","type":"object","additionalProperties":false},"ManifestEntry":{"type":"object","properties":{"integrity":{"type":"string"},"revision":{"type":["null","string"]},"url":{"type":"string"}},"additionalProperties":false}},"$schema":"http://json-schema.org/draft-07/schema#"} +{"additionalProperties":false,"type":"object","properties":{"chunks":{"type":"array","items":{"type":"string"}},"exclude":{"default":"[/\\.map$/, /^manifest.*\\.js$/,]","type":"array","items":{"anyOf":[{"$ref":"#/definitions/RegExp"},{"type":"object","additionalProperties":false},{"type":"string"}]}},"excludeChunks":{"type":"array","items":{"type":"string"}},"include":{"type":"array","items":{"anyOf":[{"$ref":"#/definitions/RegExp"},{"type":"object","additionalProperties":false},{"type":"string"}]}},"mode":{"default":"'production'","type":["null","string"]},"babelPresetEnvTargets":{"default":"['chrome >= 56']","type":"array","items":{"type":"string"}},"cacheId":{"type":["null","string"]},"cleanupOutdatedCaches":{"default":false,"type":"boolean"},"clientsClaim":{"default":false,"type":"boolean"},"directoryIndex":{"type":["null","string"]},"disableDevLogs":{"default":false,"type":"boolean"},"ignoreURLParametersMatching":{"type":"array","items":{"$ref":"#/definitions/RegExp"}},"importScripts":{"type":"array","items":{"type":"string"}},"inlineWorkboxRuntime":{"default":false,"type":"boolean"},"navigateFallback":{"default":null,"type":["null","string"]},"navigateFallbackAllowlist":{"type":"array","items":{"$ref":"#/definitions/RegExp"}},"navigateFallbackDenylist":{"type":"array","items":{"$ref":"#/definitions/RegExp"}},"navigationPreload":{"default":false,"type":"boolean"},"offlineGoogleAnalytics":{"default":false,"anyOf":[{"$ref":"#/definitions/GoogleAnalyticsInitializeOptions"},{"type":"boolean"}]},"runtimeCaching":{"type":"array","items":{"$ref":"#/definitions/RuntimeCaching"}},"skipWaiting":{"default":false,"type":"boolean"},"sourcemap":{"default":true,"type":"boolean"},"additionalManifestEntries":{"type":"array","items":{"anyOf":[{"$ref":"#/definitions/ManifestEntry"},{"type":"string"}]}},"dontCacheBustURLsMatching":{"$ref":"#/definitions/RegExp"},"manifestTransforms":{"type":"array","items":{"type":"object","additionalProperties":false}},"maximumFileSizeToCacheInBytes":{"default":2097152,"type":"number"},"modifyURLPrefix":{"type":"object","additionalProperties":{"type":"string"}},"swDest":{"default":"'service-worker.js'","type":"string"},"importScriptsViaChunks":{"type":"array","items":{"type":"string"}}},"definitions":{"RegExp":{"type":"object","properties":{"source":{"type":"string"},"global":{"type":"boolean"},"ignoreCase":{"type":"boolean"},"multiline":{"type":"boolean"},"lastIndex":{"type":"number"},"flags":{"type":"string"},"sticky":{"type":"boolean"},"unicode":{"type":"boolean"},"dotAll":{"type":"boolean"}},"additionalProperties":false},"GoogleAnalyticsInitializeOptions":{"type":"object","properties":{"cacheName":{"type":"string"},"parameterOverrides":{"type":"object","additionalProperties":{"type":"string"}},"hitFilter":{"type":"object","additionalProperties":false}},"additionalProperties":false},"RuntimeCaching":{"type":"object","properties":{"handler":{"anyOf":[{"$ref":"#/definitions/RouteHandlerCallback"},{"$ref":"#/definitions/RouteHandlerObject"},{"enum":["CacheFirst","CacheOnly","NetworkFirst","NetworkOnly","StaleWhileRevalidate"],"type":"string"}]},"method":{"enum":["DELETE","GET","HEAD","PATCH","POST","PUT"],"type":"string"},"options":{"type":"object","properties":{"backgroundSync":{"type":"object","properties":{"name":{"type":"string"},"options":{"$ref":"#/definitions/QueueOptions"}},"additionalProperties":false},"broadcastUpdate":{"type":"object","properties":{"channelName":{"type":"string"},"options":{"$ref":"#/definitions/BroadcastCacheUpdateOptions"}},"additionalProperties":false},"cacheableResponse":{"$ref":"#/definitions/CacheableResponseOptions"},"cacheName":{"type":["null","string"]},"expiration":{"$ref":"#/definitions/ExpirationPluginOptions"},"networkTimeoutSeconds":{"type":"number"},"plugins":{"type":"array","items":{"$ref":"#/definitions/WorkboxPlugin"}},"precacheFallback":{"type":"object","properties":{"fallbackURL":{"type":"string"}},"additionalProperties":false},"fetchOptions":{"$ref":"#/definitions/RequestInit"},"matchOptions":{"$ref":"#/definitions/CacheQueryOptions"}},"additionalProperties":false},"urlPattern":{"anyOf":[{"$ref":"#/definitions/RegExp"},{"$ref":"#/definitions/RouteMatchCallback"},{"type":"string"}]}},"additionalProperties":false},"RouteHandlerCallback":{"description":"The \"handler\" callback is invoked whenever a `Router` matches a URL/Request\nto a `Route` via its `RouteMatchCallback`. This handler callback should\nreturn a `Promise` that resolves with a `Response`.\n\nIf a non-empty array or object is returned by the `RouteMatchCallback` it\nwill be passed in as this handler's `options.params` argument.","type":"object","additionalProperties":false},"RouteHandlerObject":{"description":"An object with a `handle` method of type `RouteHandlerCallback`.\n\nA `Route` object can be created with either an `RouteHandlerCallback`\nfunction or this `RouteHandler` object. The benefit of the `RouteHandler`\nis it can be extended (as is done by the `workbox-strategies` package).","type":"object","properties":{"handle":{"$ref":"#/definitions/RouteHandlerCallback"}},"additionalProperties":false},"QueueOptions":{"type":"object","properties":{"onSync":{"$ref":"#/definitions/OnSyncCallback"},"maxRetentionTime":{"type":"number"}},"additionalProperties":false},"OnSyncCallback":{"type":"object","additionalProperties":false},"BroadcastCacheUpdateOptions":{"type":"object","properties":{"headersToCheck":{"type":"array","items":{"type":"string"}},"generatePayload":{"type":"object","additionalProperties":false}},"additionalProperties":false},"CacheableResponseOptions":{"type":"object","properties":{"statuses":{"type":"array","items":{"type":"number"}},"headers":{"type":"object","additionalProperties":{"type":"string"}}},"additionalProperties":false},"ExpirationPluginOptions":{"type":"object","properties":{"maxEntries":{"type":"number"},"maxAgeSeconds":{"type":"number"},"matchOptions":{"$ref":"#/definitions/CacheQueryOptions"},"purgeOnQuotaError":{"type":"boolean"}},"additionalProperties":false},"CacheQueryOptions":{"type":"object","properties":{"ignoreMethod":{"type":"boolean"},"ignoreSearch":{"type":"boolean"},"ignoreVary":{"type":"boolean"}},"additionalProperties":false},"WorkboxPlugin":{"description":"An object with optional lifecycle callback properties for the fetch and\ncache operations.","type":"object","properties":{"cacheDidUpdate":{"$ref":"#/definitions/CacheDidUpdateCallback"},"cachedResponseWillBeUsed":{"$ref":"#/definitions/CachedResponseWillBeUsedCallback"},"cacheKeyWillBeUsed":{"$ref":"#/definitions/CacheKeyWillBeUsedCallback"},"cacheWillUpdate":{"$ref":"#/definitions/CacheWillUpdateCallback"},"fetchDidFail":{"$ref":"#/definitions/FetchDidFailCallback"},"fetchDidSucceed":{"$ref":"#/definitions/FetchDidSucceedCallback"},"handlerDidComplete":{"$ref":"#/definitions/HandlerDidCompleteCallback"},"handlerDidError":{"$ref":"#/definitions/HandlerDidErrorCallback"},"handlerDidRespond":{"$ref":"#/definitions/HandlerDidRespondCallback"},"handlerWillRespond":{"$ref":"#/definitions/HandlerWillRespondCallback"},"handlerWillStart":{"$ref":"#/definitions/HandlerWillStartCallback"},"requestWillFetch":{"$ref":"#/definitions/RequestWillFetchCallback"}},"additionalProperties":false},"CacheDidUpdateCallback":{"type":"object","additionalProperties":false},"CachedResponseWillBeUsedCallback":{"type":"object","additionalProperties":false},"CacheKeyWillBeUsedCallback":{"type":"object","additionalProperties":false},"CacheWillUpdateCallback":{"type":"object","additionalProperties":false},"FetchDidFailCallback":{"type":"object","additionalProperties":false},"FetchDidSucceedCallback":{"type":"object","additionalProperties":false},"HandlerDidCompleteCallback":{"type":"object","additionalProperties":false},"HandlerDidErrorCallback":{"type":"object","additionalProperties":false},"HandlerDidRespondCallback":{"type":"object","additionalProperties":false},"HandlerWillRespondCallback":{"type":"object","additionalProperties":false},"HandlerWillStartCallback":{"type":"object","additionalProperties":false},"RequestWillFetchCallback":{"type":"object","additionalProperties":false},"RequestInit":{"type":"object","properties":{"body":{"anyOf":[{"$ref":"#/definitions/ArrayBuffer"},{"$ref":"#/definitions/ArrayBufferView"},{"$ref":"#/definitions/Blob"},{"$ref":"#/definitions/FormData"},{"$ref":"#/definitions/URLSearchParams"},{"$ref":"#/definitions/ReadableStream"},{"type":["null","string"]}]},"cache":{"enum":["default","force-cache","no-cache","no-store","only-if-cached","reload"],"type":"string"},"credentials":{"enum":["include","omit","same-origin"],"type":"string"},"headers":{"anyOf":[{"$ref":"#/definitions/Headers"},{"type":"array","items":{"type":"array","items":{"type":"string"}}},{"$ref":"#/definitions/Record"}]},"integrity":{"type":"string"},"keepalive":{"type":"boolean"},"method":{"type":"string"},"mode":{"enum":["cors","navigate","no-cors","same-origin"],"type":"string"},"redirect":{"enum":["error","follow","manual"],"type":"string"},"referrer":{"type":"string"},"referrerPolicy":{"enum":["","no-referrer","no-referrer-when-downgrade","origin","origin-when-cross-origin","same-origin","strict-origin","strict-origin-when-cross-origin","unsafe-url"],"type":"string"},"signal":{"anyOf":[{"$ref":"#/definitions/AbortSignal"},{"type":"null"}]},"window":{}},"additionalProperties":false},"ArrayBuffer":{"type":"object","properties":{"byteLength":{"type":"number"},"__@toStringTag":{"type":"string"}},"additionalProperties":false},"ArrayBufferView":{"type":"object","properties":{"buffer":{"anyOf":[{"$ref":"#/definitions/ArrayBuffer"},{"$ref":"#/definitions/SharedArrayBuffer"}]},"byteLength":{"type":"number"},"byteOffset":{"type":"number"}},"additionalProperties":false},"SharedArrayBuffer":{"type":"object","properties":{"byteLength":{"type":"number"},"__@species":{"$ref":"#/definitions/SharedArrayBuffer"},"__@toStringTag":{"type":"string","enum":["SharedArrayBuffer"]}},"additionalProperties":false},"Blob":{"type":"object","properties":{"size":{"type":"number"},"type":{"type":"string"}},"additionalProperties":false},"FormData":{"type":"object","additionalProperties":false},"URLSearchParams":{"type":"object","additionalProperties":false},"ReadableStream":{"type":"object","properties":{"locked":{"type":"boolean"}},"additionalProperties":false},"Headers":{"type":"object","additionalProperties":false},"Record":{"type":"object","additionalProperties":false},"AbortSignal":{"type":"object","properties":{"aborted":{"type":"boolean"},"onabort":{"anyOf":[{"type":"object","additionalProperties":false},{"type":"null"}]}},"additionalProperties":false},"RouteMatchCallback":{"description":"The \"match\" callback is used to determine if a `Route` should apply for a\nparticular URL and request. When matching occurs in response to a fetch\nevent from the client, the `event` object is also supplied. However, since\nthe match callback can be invoked outside of a fetch event, matching logic\nshould not assume the `event` object will always be available.\nIf the match callback returns a truthy value, the matching route's\n`RouteHandlerCallback` will be invoked immediately. If the value returned\nis a non-empty array or object, that value will be set on the handler's\n`options.params` argument.","type":"object","additionalProperties":false},"ManifestEntry":{"type":"object","properties":{"integrity":{"type":"string"},"revision":{"type":["null","string"]},"url":{"type":"string"}},"additionalProperties":false}},"$schema":"http://json-schema.org/draft-07/schema#"} diff --git a/packages/workbox-build/src/schema/WebpackInjectManifestOptions.json b/packages/workbox-build/src/schema/WebpackInjectManifestOptions.json index bd1c33f2f..6e0475ca1 100644 --- a/packages/workbox-build/src/schema/WebpackInjectManifestOptions.json +++ b/packages/workbox-build/src/schema/WebpackInjectManifestOptions.json @@ -1 +1 @@ -{"additionalProperties":false,"type":"object","properties":{"chunks":{"type":"array","items":{"type":"string"}},"exclude":{"type":"array","items":{"anyOf":[{"$ref":"#/definitions/RegExp"},{"type":"object","additionalProperties":false},{"type":"string"}]}},"excludeChunks":{"type":"array","items":{"type":"string"}},"include":{"type":"array","items":{"anyOf":[{"$ref":"#/definitions/RegExp"},{"type":"object","additionalProperties":false},{"type":"string"}]}},"mode":{"type":["null","string"]},"injectionPoint":{"type":"string"},"swSrc":{"type":"string"},"additionalManifestEntries":{"type":"array","items":{"anyOf":[{"$ref":"#/definitions/ManifestEntry"},{"type":"string"}]}},"dontCacheBustURLsMatching":{"$ref":"#/definitions/RegExp"},"manifestTransforms":{"type":"array","items":{"type":"object","additionalProperties":false}},"maximumFileSizeToCacheInBytes":{"type":"number"},"modifyURLPrefix":{"type":"object","additionalProperties":{"type":"string"}},"swDest":{"type":"string"},"compileSrc":{"type":"boolean"},"webpackCompilationPlugins":{"type":"array","items":{}}},"definitions":{"RegExp":{"type":"object","properties":{"source":{"type":"string"},"global":{"type":"boolean"},"ignoreCase":{"type":"boolean"},"multiline":{"type":"boolean"},"lastIndex":{"type":"number"},"flags":{"type":"string"},"sticky":{"type":"boolean"},"unicode":{"type":"boolean"},"dotAll":{"type":"boolean"}},"additionalProperties":false},"GoogleAnalyticsInitializeOptions":{"type":"object","properties":{"cacheName":{"type":"string"},"parameterOverrides":{"type":"object","additionalProperties":{"type":"string"}},"hitFilter":{"type":"object","additionalProperties":false}},"additionalProperties":false},"RuntimeCaching":{"type":"object","properties":{"handler":{"anyOf":[{"$ref":"#/definitions/RouteHandlerCallback"},{"$ref":"#/definitions/RouteHandlerObject"},{"enum":["CacheFirst","CacheOnly","NetworkFirst","NetworkOnly","StaleWhileRevalidate"],"type":"string"}]},"method":{"enum":["DELETE","GET","HEAD","PATCH","POST","PUT"],"type":"string"},"options":{"type":"object","properties":{"backgroundSync":{"type":"object","properties":{"name":{"type":"string"},"options":{"$ref":"#/definitions/QueueOptions"}},"additionalProperties":false},"broadcastUpdate":{"type":"object","properties":{"channelName":{"type":"string"},"options":{"$ref":"#/definitions/BroadcastCacheUpdateOptions"}},"additionalProperties":false},"cacheableResponse":{"$ref":"#/definitions/CacheableResponseOptions"},"cacheName":{"type":["null","string"]},"expiration":{"$ref":"#/definitions/ExpirationPluginOptions"},"networkTimeoutSeconds":{"type":"number"},"plugins":{"type":"array","items":{"$ref":"#/definitions/WorkboxPlugin"}},"precacheFallback":{"type":"object","properties":{"fallbackURL":{"type":"string"}},"additionalProperties":false},"fetchOptions":{"$ref":"#/definitions/RequestInit"},"matchOptions":{"$ref":"#/definitions/CacheQueryOptions"}},"additionalProperties":false},"urlPattern":{"anyOf":[{"$ref":"#/definitions/RegExp"},{"$ref":"#/definitions/RouteMatchCallback"},{"type":"string"}]}},"additionalProperties":false},"RouteHandlerCallback":{"description":"The \"handler\" callback is invoked whenever a `Router` matches a URL/Request\nto a `Route` via its `RouteMatchCallback`. This handler callback should\nreturn a `Promise` that resolves with a `Response`.\n\nIf a non-empty array or object is returned by the `RouteMatchCallback` it\nwill be passed in as this handler's `options.params` argument.","type":"object","additionalProperties":false},"RouteHandlerObject":{"description":"An object with a `handle` method of type `RouteHandlerCallback`.\n\nA `Route` object can be created with either an `RouteHandlerCallback`\nfunction or this `RouteHandler` object. The benefit of the `RouteHandler`\nis it can be extended (as is done by the `workbox-strategies` package).","type":"object","properties":{"handle":{"$ref":"#/definitions/RouteHandlerCallback"}},"additionalProperties":false},"QueueOptions":{"type":"object","properties":{"onSync":{"$ref":"#/definitions/OnSyncCallback"},"maxRetentionTime":{"type":"number"}},"additionalProperties":false},"OnSyncCallback":{"type":"object","additionalProperties":false},"BroadcastCacheUpdateOptions":{"type":"object","properties":{"headersToCheck":{"type":"array","items":{"type":"string"}},"generatePayload":{"type":"object","additionalProperties":false}},"additionalProperties":false},"CacheableResponseOptions":{"type":"object","properties":{"statuses":{"type":"array","items":{"type":"number"}},"headers":{"type":"object","additionalProperties":{"type":"string"}}},"additionalProperties":false},"ExpirationPluginOptions":{"type":"object","properties":{"maxEntries":{"type":"number"},"maxAgeSeconds":{"type":"number"},"matchOptions":{"$ref":"#/definitions/CacheQueryOptions"},"purgeOnQuotaError":{"type":"boolean"}},"additionalProperties":false},"CacheQueryOptions":{"type":"object","properties":{"ignoreMethod":{"type":"boolean"},"ignoreSearch":{"type":"boolean"},"ignoreVary":{"type":"boolean"}},"additionalProperties":false},"WorkboxPlugin":{"description":"An object with optional lifecycle callback properties for the fetch and\ncache operations.","type":"object","properties":{"cacheDidUpdate":{"$ref":"#/definitions/CacheDidUpdateCallback"},"cachedResponseWillBeUsed":{"$ref":"#/definitions/CachedResponseWillBeUsedCallback"},"cacheKeyWillBeUsed":{"$ref":"#/definitions/CacheKeyWillBeUsedCallback"},"cacheWillUpdate":{"$ref":"#/definitions/CacheWillUpdateCallback"},"fetchDidFail":{"$ref":"#/definitions/FetchDidFailCallback"},"fetchDidSucceed":{"$ref":"#/definitions/FetchDidSucceedCallback"},"handlerDidComplete":{"$ref":"#/definitions/HandlerDidCompleteCallback"},"handlerDidError":{"$ref":"#/definitions/HandlerDidErrorCallback"},"handlerDidRespond":{"$ref":"#/definitions/HandlerDidRespondCallback"},"handlerWillRespond":{"$ref":"#/definitions/HandlerWillRespondCallback"},"handlerWillStart":{"$ref":"#/definitions/HandlerWillStartCallback"},"requestWillFetch":{"$ref":"#/definitions/RequestWillFetchCallback"}},"additionalProperties":false},"CacheDidUpdateCallback":{"type":"object","additionalProperties":false},"CachedResponseWillBeUsedCallback":{"type":"object","additionalProperties":false},"CacheKeyWillBeUsedCallback":{"type":"object","additionalProperties":false},"CacheWillUpdateCallback":{"type":"object","additionalProperties":false},"FetchDidFailCallback":{"type":"object","additionalProperties":false},"FetchDidSucceedCallback":{"type":"object","additionalProperties":false},"HandlerDidCompleteCallback":{"type":"object","additionalProperties":false},"HandlerDidErrorCallback":{"type":"object","additionalProperties":false},"HandlerDidRespondCallback":{"type":"object","additionalProperties":false},"HandlerWillRespondCallback":{"type":"object","additionalProperties":false},"HandlerWillStartCallback":{"type":"object","additionalProperties":false},"RequestWillFetchCallback":{"type":"object","additionalProperties":false},"RequestInit":{"type":"object","properties":{"body":{"anyOf":[{"$ref":"#/definitions/ArrayBuffer"},{"$ref":"#/definitions/ArrayBufferView"},{"$ref":"#/definitions/Blob"},{"$ref":"#/definitions/FormData"},{"$ref":"#/definitions/URLSearchParams"},{"$ref":"#/definitions/ReadableStream"},{"type":["null","string"]}]},"cache":{"enum":["default","force-cache","no-cache","no-store","only-if-cached","reload"],"type":"string"},"credentials":{"enum":["include","omit","same-origin"],"type":"string"},"headers":{"anyOf":[{"$ref":"#/definitions/Headers"},{"type":"array","items":{"type":"array","items":{"type":"string"}}},{"$ref":"#/definitions/Record"}]},"integrity":{"type":"string"},"keepalive":{"type":"boolean"},"method":{"type":"string"},"mode":{"enum":["cors","navigate","no-cors","same-origin"],"type":"string"},"redirect":{"enum":["error","follow","manual"],"type":"string"},"referrer":{"type":"string"},"referrerPolicy":{"enum":["","no-referrer","no-referrer-when-downgrade","origin","origin-when-cross-origin","same-origin","strict-origin","strict-origin-when-cross-origin","unsafe-url"],"type":"string"},"signal":{"anyOf":[{"$ref":"#/definitions/AbortSignal"},{"type":"null"}]},"window":{}},"additionalProperties":false},"ArrayBuffer":{"type":"object","properties":{"byteLength":{"type":"number"},"__@toStringTag":{"type":"string"}},"additionalProperties":false},"ArrayBufferView":{"type":"object","properties":{"buffer":{"anyOf":[{"$ref":"#/definitions/ArrayBuffer"},{"$ref":"#/definitions/SharedArrayBuffer"}]},"byteLength":{"type":"number"},"byteOffset":{"type":"number"}},"additionalProperties":false},"SharedArrayBuffer":{"type":"object","properties":{"byteLength":{"type":"number"},"__@species":{"$ref":"#/definitions/SharedArrayBuffer"},"__@toStringTag":{"type":"string","enum":["SharedArrayBuffer"]}},"additionalProperties":false},"Blob":{"type":"object","properties":{"size":{"type":"number"},"type":{"type":"string"}},"additionalProperties":false},"FormData":{"type":"object","additionalProperties":false},"URLSearchParams":{"type":"object","additionalProperties":false},"ReadableStream":{"type":"object","properties":{"locked":{"type":"boolean"}},"additionalProperties":false},"Headers":{"type":"object","additionalProperties":false},"Record":{"type":"object","additionalProperties":false},"AbortSignal":{"type":"object","properties":{"aborted":{"type":"boolean"},"onabort":{"anyOf":[{"type":"object","additionalProperties":false},{"type":"null"}]}},"additionalProperties":false},"RouteMatchCallback":{"description":"The \"match\" callback is used to determine if a `Route` should apply for a\nparticular URL and request. When matching occurs in response to a fetch\nevent from the client, the `event` object is also supplied. However, since\nthe match callback can be invoked outside of a fetch event, matching logic\nshould not assume the `event` object will always be available.\nIf the match callback returns a truthy value, the matching route's\n`RouteHandlerCallback` will be invoked immediately. If the value returned\nis a non-empty array or object, that value will be set on the handler's\n`options.params` argument.","type":"object","additionalProperties":false},"ManifestEntry":{"type":"object","properties":{"integrity":{"type":"string"},"revision":{"type":["null","string"]},"url":{"type":"string"}},"additionalProperties":false}},"$schema":"http://json-schema.org/draft-07/schema#"} +{"additionalProperties":false,"type":"object","properties":{"chunks":{"type":"array","items":{"type":"string"}},"exclude":{"default":"[/\\.map$/, /^manifest.*\\.js$/,]","type":"array","items":{"anyOf":[{"$ref":"#/definitions/RegExp"},{"type":"object","additionalProperties":false},{"type":"string"}]}},"excludeChunks":{"type":"array","items":{"type":"string"}},"include":{"type":"array","items":{"anyOf":[{"$ref":"#/definitions/RegExp"},{"type":"object","additionalProperties":false},{"type":"string"}]}},"mode":{"type":["null","string"]},"injectionPoint":{"default":"'self.__WB_MANIFEST'","type":"string"},"swSrc":{"type":"string"},"additionalManifestEntries":{"type":"array","items":{"anyOf":[{"$ref":"#/definitions/ManifestEntry"},{"type":"string"}]}},"dontCacheBustURLsMatching":{"$ref":"#/definitions/RegExp"},"manifestTransforms":{"type":"array","items":{"type":"object","additionalProperties":false}},"maximumFileSizeToCacheInBytes":{"default":2097152,"type":"number"},"modifyURLPrefix":{"type":"object","additionalProperties":{"type":"string"}},"swDest":{"default":"'service-worker.js'","type":"string"},"compileSrc":{"default":true,"type":"boolean"},"webpackCompilationPlugins":{"type":"array","items":{}}},"definitions":{"RegExp":{"type":"object","properties":{"source":{"type":"string"},"global":{"type":"boolean"},"ignoreCase":{"type":"boolean"},"multiline":{"type":"boolean"},"lastIndex":{"type":"number"},"flags":{"type":"string"},"sticky":{"type":"boolean"},"unicode":{"type":"boolean"},"dotAll":{"type":"boolean"}},"additionalProperties":false},"GoogleAnalyticsInitializeOptions":{"type":"object","properties":{"cacheName":{"type":"string"},"parameterOverrides":{"type":"object","additionalProperties":{"type":"string"}},"hitFilter":{"type":"object","additionalProperties":false}},"additionalProperties":false},"RuntimeCaching":{"type":"object","properties":{"handler":{"anyOf":[{"$ref":"#/definitions/RouteHandlerCallback"},{"$ref":"#/definitions/RouteHandlerObject"},{"enum":["CacheFirst","CacheOnly","NetworkFirst","NetworkOnly","StaleWhileRevalidate"],"type":"string"}]},"method":{"enum":["DELETE","GET","HEAD","PATCH","POST","PUT"],"type":"string"},"options":{"type":"object","properties":{"backgroundSync":{"type":"object","properties":{"name":{"type":"string"},"options":{"$ref":"#/definitions/QueueOptions"}},"additionalProperties":false},"broadcastUpdate":{"type":"object","properties":{"channelName":{"type":"string"},"options":{"$ref":"#/definitions/BroadcastCacheUpdateOptions"}},"additionalProperties":false},"cacheableResponse":{"$ref":"#/definitions/CacheableResponseOptions"},"cacheName":{"type":["null","string"]},"expiration":{"$ref":"#/definitions/ExpirationPluginOptions"},"networkTimeoutSeconds":{"type":"number"},"plugins":{"type":"array","items":{"$ref":"#/definitions/WorkboxPlugin"}},"precacheFallback":{"type":"object","properties":{"fallbackURL":{"type":"string"}},"additionalProperties":false},"fetchOptions":{"$ref":"#/definitions/RequestInit"},"matchOptions":{"$ref":"#/definitions/CacheQueryOptions"}},"additionalProperties":false},"urlPattern":{"anyOf":[{"$ref":"#/definitions/RegExp"},{"$ref":"#/definitions/RouteMatchCallback"},{"type":"string"}]}},"additionalProperties":false},"RouteHandlerCallback":{"description":"The \"handler\" callback is invoked whenever a `Router` matches a URL/Request\nto a `Route` via its `RouteMatchCallback`. This handler callback should\nreturn a `Promise` that resolves with a `Response`.\n\nIf a non-empty array or object is returned by the `RouteMatchCallback` it\nwill be passed in as this handler's `options.params` argument.","type":"object","additionalProperties":false},"RouteHandlerObject":{"description":"An object with a `handle` method of type `RouteHandlerCallback`.\n\nA `Route` object can be created with either an `RouteHandlerCallback`\nfunction or this `RouteHandler` object. The benefit of the `RouteHandler`\nis it can be extended (as is done by the `workbox-strategies` package).","type":"object","properties":{"handle":{"$ref":"#/definitions/RouteHandlerCallback"}},"additionalProperties":false},"QueueOptions":{"type":"object","properties":{"onSync":{"$ref":"#/definitions/OnSyncCallback"},"maxRetentionTime":{"type":"number"}},"additionalProperties":false},"OnSyncCallback":{"type":"object","additionalProperties":false},"BroadcastCacheUpdateOptions":{"type":"object","properties":{"headersToCheck":{"type":"array","items":{"type":"string"}},"generatePayload":{"type":"object","additionalProperties":false}},"additionalProperties":false},"CacheableResponseOptions":{"type":"object","properties":{"statuses":{"type":"array","items":{"type":"number"}},"headers":{"type":"object","additionalProperties":{"type":"string"}}},"additionalProperties":false},"ExpirationPluginOptions":{"type":"object","properties":{"maxEntries":{"type":"number"},"maxAgeSeconds":{"type":"number"},"matchOptions":{"$ref":"#/definitions/CacheQueryOptions"},"purgeOnQuotaError":{"type":"boolean"}},"additionalProperties":false},"CacheQueryOptions":{"type":"object","properties":{"ignoreMethod":{"type":"boolean"},"ignoreSearch":{"type":"boolean"},"ignoreVary":{"type":"boolean"}},"additionalProperties":false},"WorkboxPlugin":{"description":"An object with optional lifecycle callback properties for the fetch and\ncache operations.","type":"object","properties":{"cacheDidUpdate":{"$ref":"#/definitions/CacheDidUpdateCallback"},"cachedResponseWillBeUsed":{"$ref":"#/definitions/CachedResponseWillBeUsedCallback"},"cacheKeyWillBeUsed":{"$ref":"#/definitions/CacheKeyWillBeUsedCallback"},"cacheWillUpdate":{"$ref":"#/definitions/CacheWillUpdateCallback"},"fetchDidFail":{"$ref":"#/definitions/FetchDidFailCallback"},"fetchDidSucceed":{"$ref":"#/definitions/FetchDidSucceedCallback"},"handlerDidComplete":{"$ref":"#/definitions/HandlerDidCompleteCallback"},"handlerDidError":{"$ref":"#/definitions/HandlerDidErrorCallback"},"handlerDidRespond":{"$ref":"#/definitions/HandlerDidRespondCallback"},"handlerWillRespond":{"$ref":"#/definitions/HandlerWillRespondCallback"},"handlerWillStart":{"$ref":"#/definitions/HandlerWillStartCallback"},"requestWillFetch":{"$ref":"#/definitions/RequestWillFetchCallback"}},"additionalProperties":false},"CacheDidUpdateCallback":{"type":"object","additionalProperties":false},"CachedResponseWillBeUsedCallback":{"type":"object","additionalProperties":false},"CacheKeyWillBeUsedCallback":{"type":"object","additionalProperties":false},"CacheWillUpdateCallback":{"type":"object","additionalProperties":false},"FetchDidFailCallback":{"type":"object","additionalProperties":false},"FetchDidSucceedCallback":{"type":"object","additionalProperties":false},"HandlerDidCompleteCallback":{"type":"object","additionalProperties":false},"HandlerDidErrorCallback":{"type":"object","additionalProperties":false},"HandlerDidRespondCallback":{"type":"object","additionalProperties":false},"HandlerWillRespondCallback":{"type":"object","additionalProperties":false},"HandlerWillStartCallback":{"type":"object","additionalProperties":false},"RequestWillFetchCallback":{"type":"object","additionalProperties":false},"RequestInit":{"type":"object","properties":{"body":{"anyOf":[{"$ref":"#/definitions/ArrayBuffer"},{"$ref":"#/definitions/ArrayBufferView"},{"$ref":"#/definitions/Blob"},{"$ref":"#/definitions/FormData"},{"$ref":"#/definitions/URLSearchParams"},{"$ref":"#/definitions/ReadableStream"},{"type":["null","string"]}]},"cache":{"enum":["default","force-cache","no-cache","no-store","only-if-cached","reload"],"type":"string"},"credentials":{"enum":["include","omit","same-origin"],"type":"string"},"headers":{"anyOf":[{"$ref":"#/definitions/Headers"},{"type":"array","items":{"type":"array","items":{"type":"string"}}},{"$ref":"#/definitions/Record"}]},"integrity":{"type":"string"},"keepalive":{"type":"boolean"},"method":{"type":"string"},"mode":{"enum":["cors","navigate","no-cors","same-origin"],"type":"string"},"redirect":{"enum":["error","follow","manual"],"type":"string"},"referrer":{"type":"string"},"referrerPolicy":{"enum":["","no-referrer","no-referrer-when-downgrade","origin","origin-when-cross-origin","same-origin","strict-origin","strict-origin-when-cross-origin","unsafe-url"],"type":"string"},"signal":{"anyOf":[{"$ref":"#/definitions/AbortSignal"},{"type":"null"}]},"window":{}},"additionalProperties":false},"ArrayBuffer":{"type":"object","properties":{"byteLength":{"type":"number"},"__@toStringTag":{"type":"string"}},"additionalProperties":false},"ArrayBufferView":{"type":"object","properties":{"buffer":{"anyOf":[{"$ref":"#/definitions/ArrayBuffer"},{"$ref":"#/definitions/SharedArrayBuffer"}]},"byteLength":{"type":"number"},"byteOffset":{"type":"number"}},"additionalProperties":false},"SharedArrayBuffer":{"type":"object","properties":{"byteLength":{"type":"number"},"__@species":{"$ref":"#/definitions/SharedArrayBuffer"},"__@toStringTag":{"type":"string","enum":["SharedArrayBuffer"]}},"additionalProperties":false},"Blob":{"type":"object","properties":{"size":{"type":"number"},"type":{"type":"string"}},"additionalProperties":false},"FormData":{"type":"object","additionalProperties":false},"URLSearchParams":{"type":"object","additionalProperties":false},"ReadableStream":{"type":"object","properties":{"locked":{"type":"boolean"}},"additionalProperties":false},"Headers":{"type":"object","additionalProperties":false},"Record":{"type":"object","additionalProperties":false},"AbortSignal":{"type":"object","properties":{"aborted":{"type":"boolean"},"onabort":{"anyOf":[{"type":"object","additionalProperties":false},{"type":"null"}]}},"additionalProperties":false},"RouteMatchCallback":{"description":"The \"match\" callback is used to determine if a `Route` should apply for a\nparticular URL and request. When matching occurs in response to a fetch\nevent from the client, the `event` object is also supplied. However, since\nthe match callback can be invoked outside of a fetch event, matching logic\nshould not assume the `event` object will always be available.\nIf the match callback returns a truthy value, the matching route's\n`RouteHandlerCallback` will be invoked immediately. If the value returned\nis a non-empty array or object, that value will be set on the handler's\n`options.params` argument.","type":"object","additionalProperties":false},"ManifestEntry":{"type":"object","properties":{"integrity":{"type":"string"},"revision":{"type":["null","string"]},"url":{"type":"string"}},"additionalProperties":false}},"$schema":"http://json-schema.org/draft-07/schema#"} diff --git a/packages/workbox-build/src/types.ts b/packages/workbox-build/src/types.ts index 942015777..de0c953fe 100644 --- a/packages/workbox-build/src/types.ts +++ b/packages/workbox-build/src/types.ts @@ -59,6 +59,9 @@ export interface BasePartial { additionalManifestEntries?: Array; dontCacheBustURLsMatching?: RegExp; manifestTransforms?: Array; + /** + * @default 2097152 + */ maximumFileSizeToCacheInBytes?: number; modifyURLPrefix: { [key: string]: string; @@ -66,31 +69,73 @@ export interface BasePartial { } export interface GeneratePartial { + /** + * @default ['chrome >= 56'] + */ babelPresetEnvTargets?: Array; cacheId?: string | null; + /** + * @default false + */ cleanupOutdatedCaches?: boolean; + /** + * @default false + */ clientsClaim?: boolean; directoryIndex?: string | null; + /** + * @default false + */ disableDevLogs?: boolean; ignoreURLParametersMatching?: Array; importScripts?: Array; + /** + * @default false + */ inlineWorkboxRuntime?: boolean; + /** + * @default 'production' + */ mode?: string | null; + /** + * @default null + */ navigateFallback?: string | null; navigateFallbackAllowlist?: Array; navigateFallbackDenylist?: Array; + /** + * @default false + */ navigationPreload?: boolean; + /** + * @default false + */ offlineGoogleAnalytics?: boolean | GoogleAnalyticsInitializeOptions; runtimeCaching: Array; + /** + * @default false + */ skipWaiting?: boolean; + /** + * @default true + */ sourcemap?: boolean; } export interface GlobPartial { globDirectory?: string | null; + /** + * @default true + */ globFollow?: boolean; - globIgnores: Array; - globPatterns: Array; + /** + * @default ['**\/node_modules\/**\/*'] + */ + globIgnores?: Array; + /** + * @default ['**\/*.{js,css,html}'] + */ + globPatterns?: Array; /** * @default true */ @@ -101,12 +146,18 @@ export interface GlobPartial { } interface InjectPartial { - injectionPoint: string; + /** + * @default 'self.__WB_MANIFEST' + */ + injectionPoint?: string; swSrc: string; } interface WebpackPartial { chunks?: Array; + /** + * @default [/\.map$/, /^manifest.*\.js$/,] + */ exclude?: Array any)>; excludeChunks?: Array; include?: Array any)>; @@ -114,6 +165,9 @@ interface WebpackPartial { } export interface SWDestPartial { + /** + * @default 'service-worker.js' + */ swDest: string; } @@ -130,6 +184,9 @@ export type WebpackGenerateSWOptions = WebpackPartial & GeneratePartial & BasePa }; export type WebpackInjectManifestOptions = WebpackPartial & InjectPartial & BasePartial & SWDestPartial & { + /** + * @default true + */ compileSrc?: boolean; webpackCompilationPlugins?: Array; }; From 2f805496537e0f0519b4989c57dfb0b2b24a3c29 Mon Sep 17 00:00:00 2001 From: Jeff Posnick Date: Wed, 9 Jun 2021 14:14:31 -0400 Subject: [PATCH 34/80] Switched default quotes --- .../workbox-build/src/schema/GenerateSWOptions.json | 2 +- .../workbox-build/src/schema/GetManifestOptions.json | 2 +- .../src/schema/InjectManifestOptions.json | 2 +- .../src/schema/WebpackGenerateSWOptions.json | 2 +- .../src/schema/WebpackInjectManifestOptions.json | 2 +- packages/workbox-build/src/types.ts | 12 ++++++------ 6 files changed, 11 insertions(+), 11 deletions(-) diff --git a/packages/workbox-build/src/schema/GenerateSWOptions.json b/packages/workbox-build/src/schema/GenerateSWOptions.json index 6e2d9278b..d8a323c7d 100644 --- a/packages/workbox-build/src/schema/GenerateSWOptions.json +++ b/packages/workbox-build/src/schema/GenerateSWOptions.json @@ -1 +1 @@ -{"additionalProperties":false,"type":"object","properties":{"globDirectory":{"type":["null","string"]},"globFollow":{"default":true,"type":"boolean"},"globIgnores":{"default":"['**\\/node_modules\\/**\\/*']","type":"array","items":{"type":"string"}},"globPatterns":{"default":"['**\\/*.{js,css,html}']","type":"array","items":{"type":"string"}},"globStrict":{"default":true,"type":"boolean"},"templatedURLs":{"type":"object","additionalProperties":{"anyOf":[{"type":"array","items":{"type":"string"}},{"type":"string"}]}},"babelPresetEnvTargets":{"default":"['chrome >= 56']","type":"array","items":{"type":"string"}},"cacheId":{"type":["null","string"]},"cleanupOutdatedCaches":{"default":false,"type":"boolean"},"clientsClaim":{"default":false,"type":"boolean"},"directoryIndex":{"type":["null","string"]},"disableDevLogs":{"default":false,"type":"boolean"},"ignoreURLParametersMatching":{"type":"array","items":{"$ref":"#/definitions/RegExp"}},"importScripts":{"type":"array","items":{"type":"string"}},"inlineWorkboxRuntime":{"default":false,"type":"boolean"},"mode":{"default":"'production'","type":["null","string"]},"navigateFallback":{"default":null,"type":["null","string"]},"navigateFallbackAllowlist":{"type":"array","items":{"$ref":"#/definitions/RegExp"}},"navigateFallbackDenylist":{"type":"array","items":{"$ref":"#/definitions/RegExp"}},"navigationPreload":{"default":false,"type":"boolean"},"offlineGoogleAnalytics":{"default":false,"anyOf":[{"$ref":"#/definitions/GoogleAnalyticsInitializeOptions"},{"type":"boolean"}]},"runtimeCaching":{"type":"array","items":{"$ref":"#/definitions/RuntimeCaching"}},"skipWaiting":{"default":false,"type":"boolean"},"sourcemap":{"default":true,"type":"boolean"},"additionalManifestEntries":{"type":"array","items":{"anyOf":[{"$ref":"#/definitions/ManifestEntry"},{"type":"string"}]}},"dontCacheBustURLsMatching":{"$ref":"#/definitions/RegExp"},"manifestTransforms":{"type":"array","items":{"type":"object","additionalProperties":false}},"maximumFileSizeToCacheInBytes":{"default":2097152,"type":"number"},"modifyURLPrefix":{"type":"object","additionalProperties":{"type":"string"}},"swDest":{"default":"'service-worker.js'","type":"string"}},"definitions":{"RegExp":{"type":"object","properties":{"source":{"type":"string"},"global":{"type":"boolean"},"ignoreCase":{"type":"boolean"},"multiline":{"type":"boolean"},"lastIndex":{"type":"number"},"flags":{"type":"string"},"sticky":{"type":"boolean"},"unicode":{"type":"boolean"},"dotAll":{"type":"boolean"}},"additionalProperties":false},"GoogleAnalyticsInitializeOptions":{"type":"object","properties":{"cacheName":{"type":"string"},"parameterOverrides":{"type":"object","additionalProperties":{"type":"string"}},"hitFilter":{"type":"object","additionalProperties":false}},"additionalProperties":false},"RuntimeCaching":{"type":"object","properties":{"handler":{"anyOf":[{"$ref":"#/definitions/RouteHandlerCallback"},{"$ref":"#/definitions/RouteHandlerObject"},{"enum":["CacheFirst","CacheOnly","NetworkFirst","NetworkOnly","StaleWhileRevalidate"],"type":"string"}]},"method":{"enum":["DELETE","GET","HEAD","PATCH","POST","PUT"],"type":"string"},"options":{"type":"object","properties":{"backgroundSync":{"type":"object","properties":{"name":{"type":"string"},"options":{"$ref":"#/definitions/QueueOptions"}},"additionalProperties":false},"broadcastUpdate":{"type":"object","properties":{"channelName":{"type":"string"},"options":{"$ref":"#/definitions/BroadcastCacheUpdateOptions"}},"additionalProperties":false},"cacheableResponse":{"$ref":"#/definitions/CacheableResponseOptions"},"cacheName":{"type":["null","string"]},"expiration":{"$ref":"#/definitions/ExpirationPluginOptions"},"networkTimeoutSeconds":{"type":"number"},"plugins":{"type":"array","items":{"$ref":"#/definitions/WorkboxPlugin"}},"precacheFallback":{"type":"object","properties":{"fallbackURL":{"type":"string"}},"additionalProperties":false},"fetchOptions":{"$ref":"#/definitions/RequestInit"},"matchOptions":{"$ref":"#/definitions/CacheQueryOptions"}},"additionalProperties":false},"urlPattern":{"anyOf":[{"$ref":"#/definitions/RegExp"},{"$ref":"#/definitions/RouteMatchCallback"},{"type":"string"}]}},"additionalProperties":false},"RouteHandlerCallback":{"description":"The \"handler\" callback is invoked whenever a `Router` matches a URL/Request\nto a `Route` via its `RouteMatchCallback`. This handler callback should\nreturn a `Promise` that resolves with a `Response`.\n\nIf a non-empty array or object is returned by the `RouteMatchCallback` it\nwill be passed in as this handler's `options.params` argument.","type":"object","additionalProperties":false},"RouteHandlerObject":{"description":"An object with a `handle` method of type `RouteHandlerCallback`.\n\nA `Route` object can be created with either an `RouteHandlerCallback`\nfunction or this `RouteHandler` object. The benefit of the `RouteHandler`\nis it can be extended (as is done by the `workbox-strategies` package).","type":"object","properties":{"handle":{"$ref":"#/definitions/RouteHandlerCallback"}},"additionalProperties":false},"QueueOptions":{"type":"object","properties":{"onSync":{"$ref":"#/definitions/OnSyncCallback"},"maxRetentionTime":{"type":"number"}},"additionalProperties":false},"OnSyncCallback":{"type":"object","additionalProperties":false},"BroadcastCacheUpdateOptions":{"type":"object","properties":{"headersToCheck":{"type":"array","items":{"type":"string"}},"generatePayload":{"type":"object","additionalProperties":false}},"additionalProperties":false},"CacheableResponseOptions":{"type":"object","properties":{"statuses":{"type":"array","items":{"type":"number"}},"headers":{"type":"object","additionalProperties":{"type":"string"}}},"additionalProperties":false},"ExpirationPluginOptions":{"type":"object","properties":{"maxEntries":{"type":"number"},"maxAgeSeconds":{"type":"number"},"matchOptions":{"$ref":"#/definitions/CacheQueryOptions"},"purgeOnQuotaError":{"type":"boolean"}},"additionalProperties":false},"CacheQueryOptions":{"type":"object","properties":{"ignoreMethod":{"type":"boolean"},"ignoreSearch":{"type":"boolean"},"ignoreVary":{"type":"boolean"}},"additionalProperties":false},"WorkboxPlugin":{"description":"An object with optional lifecycle callback properties for the fetch and\ncache operations.","type":"object","properties":{"cacheDidUpdate":{"$ref":"#/definitions/CacheDidUpdateCallback"},"cachedResponseWillBeUsed":{"$ref":"#/definitions/CachedResponseWillBeUsedCallback"},"cacheKeyWillBeUsed":{"$ref":"#/definitions/CacheKeyWillBeUsedCallback"},"cacheWillUpdate":{"$ref":"#/definitions/CacheWillUpdateCallback"},"fetchDidFail":{"$ref":"#/definitions/FetchDidFailCallback"},"fetchDidSucceed":{"$ref":"#/definitions/FetchDidSucceedCallback"},"handlerDidComplete":{"$ref":"#/definitions/HandlerDidCompleteCallback"},"handlerDidError":{"$ref":"#/definitions/HandlerDidErrorCallback"},"handlerDidRespond":{"$ref":"#/definitions/HandlerDidRespondCallback"},"handlerWillRespond":{"$ref":"#/definitions/HandlerWillRespondCallback"},"handlerWillStart":{"$ref":"#/definitions/HandlerWillStartCallback"},"requestWillFetch":{"$ref":"#/definitions/RequestWillFetchCallback"}},"additionalProperties":false},"CacheDidUpdateCallback":{"type":"object","additionalProperties":false},"CachedResponseWillBeUsedCallback":{"type":"object","additionalProperties":false},"CacheKeyWillBeUsedCallback":{"type":"object","additionalProperties":false},"CacheWillUpdateCallback":{"type":"object","additionalProperties":false},"FetchDidFailCallback":{"type":"object","additionalProperties":false},"FetchDidSucceedCallback":{"type":"object","additionalProperties":false},"HandlerDidCompleteCallback":{"type":"object","additionalProperties":false},"HandlerDidErrorCallback":{"type":"object","additionalProperties":false},"HandlerDidRespondCallback":{"type":"object","additionalProperties":false},"HandlerWillRespondCallback":{"type":"object","additionalProperties":false},"HandlerWillStartCallback":{"type":"object","additionalProperties":false},"RequestWillFetchCallback":{"type":"object","additionalProperties":false},"RequestInit":{"type":"object","properties":{"body":{"anyOf":[{"$ref":"#/definitions/ArrayBuffer"},{"$ref":"#/definitions/ArrayBufferView"},{"$ref":"#/definitions/Blob"},{"$ref":"#/definitions/FormData"},{"$ref":"#/definitions/URLSearchParams"},{"$ref":"#/definitions/ReadableStream"},{"type":["null","string"]}]},"cache":{"enum":["default","force-cache","no-cache","no-store","only-if-cached","reload"],"type":"string"},"credentials":{"enum":["include","omit","same-origin"],"type":"string"},"headers":{"anyOf":[{"$ref":"#/definitions/Headers"},{"type":"array","items":{"type":"array","items":{"type":"string"}}},{"$ref":"#/definitions/Record"}]},"integrity":{"type":"string"},"keepalive":{"type":"boolean"},"method":{"type":"string"},"mode":{"enum":["cors","navigate","no-cors","same-origin"],"type":"string"},"redirect":{"enum":["error","follow","manual"],"type":"string"},"referrer":{"type":"string"},"referrerPolicy":{"enum":["","no-referrer","no-referrer-when-downgrade","origin","origin-when-cross-origin","same-origin","strict-origin","strict-origin-when-cross-origin","unsafe-url"],"type":"string"},"signal":{"anyOf":[{"$ref":"#/definitions/AbortSignal"},{"type":"null"}]},"window":{}},"additionalProperties":false},"ArrayBuffer":{"type":"object","properties":{"byteLength":{"type":"number"},"__@toStringTag":{"type":"string"}},"additionalProperties":false},"ArrayBufferView":{"type":"object","properties":{"buffer":{"anyOf":[{"$ref":"#/definitions/ArrayBuffer"},{"$ref":"#/definitions/SharedArrayBuffer"}]},"byteLength":{"type":"number"},"byteOffset":{"type":"number"}},"additionalProperties":false},"SharedArrayBuffer":{"type":"object","properties":{"byteLength":{"type":"number"},"__@species":{"$ref":"#/definitions/SharedArrayBuffer"},"__@toStringTag":{"type":"string","enum":["SharedArrayBuffer"]}},"additionalProperties":false},"Blob":{"type":"object","properties":{"size":{"type":"number"},"type":{"type":"string"}},"additionalProperties":false},"FormData":{"type":"object","additionalProperties":false},"URLSearchParams":{"type":"object","additionalProperties":false},"ReadableStream":{"type":"object","properties":{"locked":{"type":"boolean"}},"additionalProperties":false},"Headers":{"type":"object","additionalProperties":false},"Record":{"type":"object","additionalProperties":false},"AbortSignal":{"type":"object","properties":{"aborted":{"type":"boolean"},"onabort":{"anyOf":[{"type":"object","additionalProperties":false},{"type":"null"}]}},"additionalProperties":false},"RouteMatchCallback":{"description":"The \"match\" callback is used to determine if a `Route` should apply for a\nparticular URL and request. When matching occurs in response to a fetch\nevent from the client, the `event` object is also supplied. However, since\nthe match callback can be invoked outside of a fetch event, matching logic\nshould not assume the `event` object will always be available.\nIf the match callback returns a truthy value, the matching route's\n`RouteHandlerCallback` will be invoked immediately. If the value returned\nis a non-empty array or object, that value will be set on the handler's\n`options.params` argument.","type":"object","additionalProperties":false},"ManifestEntry":{"type":"object","properties":{"integrity":{"type":"string"},"revision":{"type":["null","string"]},"url":{"type":"string"}},"additionalProperties":false}},"$schema":"http://json-schema.org/draft-07/schema#"} +{"additionalProperties":false,"type":"object","properties":{"globDirectory":{"type":["null","string"]},"globFollow":{"default":true,"type":"boolean"},"globIgnores":{"default":["**/node_modules/**/*"],"type":"array","items":{"type":"string"}},"globPatterns":{"default":["**/*.{js,css,html}"],"type":"array","items":{"type":"string"}},"globStrict":{"default":true,"type":"boolean"},"templatedURLs":{"type":"object","additionalProperties":{"anyOf":[{"type":"array","items":{"type":"string"}},{"type":"string"}]}},"babelPresetEnvTargets":{"default":["chrome >= 56"],"type":"array","items":{"type":"string"}},"cacheId":{"type":["null","string"]},"cleanupOutdatedCaches":{"default":false,"type":"boolean"},"clientsClaim":{"default":false,"type":"boolean"},"directoryIndex":{"type":["null","string"]},"disableDevLogs":{"default":false,"type":"boolean"},"ignoreURLParametersMatching":{"type":"array","items":{"$ref":"#/definitions/RegExp"}},"importScripts":{"type":"array","items":{"type":"string"}},"inlineWorkboxRuntime":{"default":false,"type":"boolean"},"mode":{"default":"production","type":["null","string"]},"navigateFallback":{"default":null,"type":["null","string"]},"navigateFallbackAllowlist":{"type":"array","items":{"$ref":"#/definitions/RegExp"}},"navigateFallbackDenylist":{"type":"array","items":{"$ref":"#/definitions/RegExp"}},"navigationPreload":{"default":false,"type":"boolean"},"offlineGoogleAnalytics":{"default":false,"anyOf":[{"$ref":"#/definitions/GoogleAnalyticsInitializeOptions"},{"type":"boolean"}]},"runtimeCaching":{"type":"array","items":{"$ref":"#/definitions/RuntimeCaching"}},"skipWaiting":{"default":false,"type":"boolean"},"sourcemap":{"default":true,"type":"boolean"},"additionalManifestEntries":{"type":"array","items":{"anyOf":[{"$ref":"#/definitions/ManifestEntry"},{"type":"string"}]}},"dontCacheBustURLsMatching":{"$ref":"#/definitions/RegExp"},"manifestTransforms":{"type":"array","items":{"type":"object","additionalProperties":false}},"maximumFileSizeToCacheInBytes":{"default":2097152,"type":"number"},"modifyURLPrefix":{"type":"object","additionalProperties":{"type":"string"}},"swDest":{"default":"service-worker.js","type":"string"}},"definitions":{"RegExp":{"type":"object","properties":{"source":{"type":"string"},"global":{"type":"boolean"},"ignoreCase":{"type":"boolean"},"multiline":{"type":"boolean"},"lastIndex":{"type":"number"},"flags":{"type":"string"},"sticky":{"type":"boolean"},"unicode":{"type":"boolean"},"dotAll":{"type":"boolean"}},"additionalProperties":false},"GoogleAnalyticsInitializeOptions":{"type":"object","properties":{"cacheName":{"type":"string"},"parameterOverrides":{"type":"object","additionalProperties":{"type":"string"}},"hitFilter":{"type":"object","additionalProperties":false}},"additionalProperties":false},"RuntimeCaching":{"type":"object","properties":{"handler":{"anyOf":[{"$ref":"#/definitions/RouteHandlerCallback"},{"$ref":"#/definitions/RouteHandlerObject"},{"enum":["CacheFirst","CacheOnly","NetworkFirst","NetworkOnly","StaleWhileRevalidate"],"type":"string"}]},"method":{"enum":["DELETE","GET","HEAD","PATCH","POST","PUT"],"type":"string"},"options":{"type":"object","properties":{"backgroundSync":{"type":"object","properties":{"name":{"type":"string"},"options":{"$ref":"#/definitions/QueueOptions"}},"additionalProperties":false},"broadcastUpdate":{"type":"object","properties":{"channelName":{"type":"string"},"options":{"$ref":"#/definitions/BroadcastCacheUpdateOptions"}},"additionalProperties":false},"cacheableResponse":{"$ref":"#/definitions/CacheableResponseOptions"},"cacheName":{"type":["null","string"]},"expiration":{"$ref":"#/definitions/ExpirationPluginOptions"},"networkTimeoutSeconds":{"type":"number"},"plugins":{"type":"array","items":{"$ref":"#/definitions/WorkboxPlugin"}},"precacheFallback":{"type":"object","properties":{"fallbackURL":{"type":"string"}},"additionalProperties":false},"fetchOptions":{"$ref":"#/definitions/RequestInit"},"matchOptions":{"$ref":"#/definitions/CacheQueryOptions"}},"additionalProperties":false},"urlPattern":{"anyOf":[{"$ref":"#/definitions/RegExp"},{"$ref":"#/definitions/RouteMatchCallback"},{"type":"string"}]}},"additionalProperties":false},"RouteHandlerCallback":{"description":"The \"handler\" callback is invoked whenever a `Router` matches a URL/Request\nto a `Route` via its `RouteMatchCallback`. This handler callback should\nreturn a `Promise` that resolves with a `Response`.\n\nIf a non-empty array or object is returned by the `RouteMatchCallback` it\nwill be passed in as this handler's `options.params` argument.","type":"object","additionalProperties":false},"RouteHandlerObject":{"description":"An object with a `handle` method of type `RouteHandlerCallback`.\n\nA `Route` object can be created with either an `RouteHandlerCallback`\nfunction or this `RouteHandler` object. The benefit of the `RouteHandler`\nis it can be extended (as is done by the `workbox-strategies` package).","type":"object","properties":{"handle":{"$ref":"#/definitions/RouteHandlerCallback"}},"additionalProperties":false},"QueueOptions":{"type":"object","properties":{"onSync":{"$ref":"#/definitions/OnSyncCallback"},"maxRetentionTime":{"type":"number"}},"additionalProperties":false},"OnSyncCallback":{"type":"object","additionalProperties":false},"BroadcastCacheUpdateOptions":{"type":"object","properties":{"headersToCheck":{"type":"array","items":{"type":"string"}},"generatePayload":{"type":"object","additionalProperties":false}},"additionalProperties":false},"CacheableResponseOptions":{"type":"object","properties":{"statuses":{"type":"array","items":{"type":"number"}},"headers":{"type":"object","additionalProperties":{"type":"string"}}},"additionalProperties":false},"ExpirationPluginOptions":{"type":"object","properties":{"maxEntries":{"type":"number"},"maxAgeSeconds":{"type":"number"},"matchOptions":{"$ref":"#/definitions/CacheQueryOptions"},"purgeOnQuotaError":{"type":"boolean"}},"additionalProperties":false},"CacheQueryOptions":{"type":"object","properties":{"ignoreMethod":{"type":"boolean"},"ignoreSearch":{"type":"boolean"},"ignoreVary":{"type":"boolean"}},"additionalProperties":false},"WorkboxPlugin":{"description":"An object with optional lifecycle callback properties for the fetch and\ncache operations.","type":"object","properties":{"cacheDidUpdate":{"$ref":"#/definitions/CacheDidUpdateCallback"},"cachedResponseWillBeUsed":{"$ref":"#/definitions/CachedResponseWillBeUsedCallback"},"cacheKeyWillBeUsed":{"$ref":"#/definitions/CacheKeyWillBeUsedCallback"},"cacheWillUpdate":{"$ref":"#/definitions/CacheWillUpdateCallback"},"fetchDidFail":{"$ref":"#/definitions/FetchDidFailCallback"},"fetchDidSucceed":{"$ref":"#/definitions/FetchDidSucceedCallback"},"handlerDidComplete":{"$ref":"#/definitions/HandlerDidCompleteCallback"},"handlerDidError":{"$ref":"#/definitions/HandlerDidErrorCallback"},"handlerDidRespond":{"$ref":"#/definitions/HandlerDidRespondCallback"},"handlerWillRespond":{"$ref":"#/definitions/HandlerWillRespondCallback"},"handlerWillStart":{"$ref":"#/definitions/HandlerWillStartCallback"},"requestWillFetch":{"$ref":"#/definitions/RequestWillFetchCallback"}},"additionalProperties":false},"CacheDidUpdateCallback":{"type":"object","additionalProperties":false},"CachedResponseWillBeUsedCallback":{"type":"object","additionalProperties":false},"CacheKeyWillBeUsedCallback":{"type":"object","additionalProperties":false},"CacheWillUpdateCallback":{"type":"object","additionalProperties":false},"FetchDidFailCallback":{"type":"object","additionalProperties":false},"FetchDidSucceedCallback":{"type":"object","additionalProperties":false},"HandlerDidCompleteCallback":{"type":"object","additionalProperties":false},"HandlerDidErrorCallback":{"type":"object","additionalProperties":false},"HandlerDidRespondCallback":{"type":"object","additionalProperties":false},"HandlerWillRespondCallback":{"type":"object","additionalProperties":false},"HandlerWillStartCallback":{"type":"object","additionalProperties":false},"RequestWillFetchCallback":{"type":"object","additionalProperties":false},"RequestInit":{"type":"object","properties":{"body":{"anyOf":[{"$ref":"#/definitions/ArrayBuffer"},{"$ref":"#/definitions/ArrayBufferView"},{"$ref":"#/definitions/Blob"},{"$ref":"#/definitions/FormData"},{"$ref":"#/definitions/URLSearchParams"},{"$ref":"#/definitions/ReadableStream"},{"type":["null","string"]}]},"cache":{"enum":["default","force-cache","no-cache","no-store","only-if-cached","reload"],"type":"string"},"credentials":{"enum":["include","omit","same-origin"],"type":"string"},"headers":{"anyOf":[{"$ref":"#/definitions/Headers"},{"type":"array","items":{"type":"array","items":{"type":"string"}}},{"$ref":"#/definitions/Record"}]},"integrity":{"type":"string"},"keepalive":{"type":"boolean"},"method":{"type":"string"},"mode":{"enum":["cors","navigate","no-cors","same-origin"],"type":"string"},"redirect":{"enum":["error","follow","manual"],"type":"string"},"referrer":{"type":"string"},"referrerPolicy":{"enum":["","no-referrer","no-referrer-when-downgrade","origin","origin-when-cross-origin","same-origin","strict-origin","strict-origin-when-cross-origin","unsafe-url"],"type":"string"},"signal":{"anyOf":[{"$ref":"#/definitions/AbortSignal"},{"type":"null"}]},"window":{}},"additionalProperties":false},"ArrayBuffer":{"type":"object","properties":{"byteLength":{"type":"number"},"__@toStringTag":{"type":"string"}},"additionalProperties":false},"ArrayBufferView":{"type":"object","properties":{"buffer":{"anyOf":[{"$ref":"#/definitions/ArrayBuffer"},{"$ref":"#/definitions/SharedArrayBuffer"}]},"byteLength":{"type":"number"},"byteOffset":{"type":"number"}},"additionalProperties":false},"SharedArrayBuffer":{"type":"object","properties":{"byteLength":{"type":"number"},"__@species":{"$ref":"#/definitions/SharedArrayBuffer"},"__@toStringTag":{"type":"string","enum":["SharedArrayBuffer"]}},"additionalProperties":false},"Blob":{"type":"object","properties":{"size":{"type":"number"},"type":{"type":"string"}},"additionalProperties":false},"FormData":{"type":"object","additionalProperties":false},"URLSearchParams":{"type":"object","additionalProperties":false},"ReadableStream":{"type":"object","properties":{"locked":{"type":"boolean"}},"additionalProperties":false},"Headers":{"type":"object","additionalProperties":false},"Record":{"type":"object","additionalProperties":false},"AbortSignal":{"type":"object","properties":{"aborted":{"type":"boolean"},"onabort":{"anyOf":[{"type":"object","additionalProperties":false},{"type":"null"}]}},"additionalProperties":false},"RouteMatchCallback":{"description":"The \"match\" callback is used to determine if a `Route` should apply for a\nparticular URL and request. When matching occurs in response to a fetch\nevent from the client, the `event` object is also supplied. However, since\nthe match callback can be invoked outside of a fetch event, matching logic\nshould not assume the `event` object will always be available.\nIf the match callback returns a truthy value, the matching route's\n`RouteHandlerCallback` will be invoked immediately. If the value returned\nis a non-empty array or object, that value will be set on the handler's\n`options.params` argument.","type":"object","additionalProperties":false},"ManifestEntry":{"type":"object","properties":{"integrity":{"type":"string"},"revision":{"type":["null","string"]},"url":{"type":"string"}},"additionalProperties":false}},"$schema":"http://json-schema.org/draft-07/schema#"} diff --git a/packages/workbox-build/src/schema/GetManifestOptions.json b/packages/workbox-build/src/schema/GetManifestOptions.json index a606b0663..ef796db7d 100644 --- a/packages/workbox-build/src/schema/GetManifestOptions.json +++ b/packages/workbox-build/src/schema/GetManifestOptions.json @@ -1 +1 @@ -{"additionalProperties":false,"type":"object","properties":{"globDirectory":{"type":["null","string"]},"globFollow":{"default":true,"type":"boolean"},"globIgnores":{"default":"['**\\/node_modules\\/**\\/*']","type":"array","items":{"type":"string"}},"globPatterns":{"default":"['**\\/*.{js,css,html}']","type":"array","items":{"type":"string"}},"globStrict":{"default":true,"type":"boolean"},"templatedURLs":{"type":"object","additionalProperties":{"anyOf":[{"type":"array","items":{"type":"string"}},{"type":"string"}]}},"additionalManifestEntries":{"type":"array","items":{"anyOf":[{"$ref":"#/definitions/ManifestEntry"},{"type":"string"}]}},"dontCacheBustURLsMatching":{"$ref":"#/definitions/RegExp"},"manifestTransforms":{"type":"array","items":{"type":"object","additionalProperties":false}},"maximumFileSizeToCacheInBytes":{"default":2097152,"type":"number"},"modifyURLPrefix":{"type":"object","additionalProperties":{"type":"string"}}},"definitions":{"RegExp":{"type":"object","properties":{"source":{"type":"string"},"global":{"type":"boolean"},"ignoreCase":{"type":"boolean"},"multiline":{"type":"boolean"},"lastIndex":{"type":"number"},"flags":{"type":"string"},"sticky":{"type":"boolean"},"unicode":{"type":"boolean"},"dotAll":{"type":"boolean"}},"additionalProperties":false},"GoogleAnalyticsInitializeOptions":{"type":"object","properties":{"cacheName":{"type":"string"},"parameterOverrides":{"type":"object","additionalProperties":{"type":"string"}},"hitFilter":{"type":"object","additionalProperties":false}},"additionalProperties":false},"RuntimeCaching":{"type":"object","properties":{"handler":{"anyOf":[{"$ref":"#/definitions/RouteHandlerCallback"},{"$ref":"#/definitions/RouteHandlerObject"},{"enum":["CacheFirst","CacheOnly","NetworkFirst","NetworkOnly","StaleWhileRevalidate"],"type":"string"}]},"method":{"enum":["DELETE","GET","HEAD","PATCH","POST","PUT"],"type":"string"},"options":{"type":"object","properties":{"backgroundSync":{"type":"object","properties":{"name":{"type":"string"},"options":{"$ref":"#/definitions/QueueOptions"}},"additionalProperties":false},"broadcastUpdate":{"type":"object","properties":{"channelName":{"type":"string"},"options":{"$ref":"#/definitions/BroadcastCacheUpdateOptions"}},"additionalProperties":false},"cacheableResponse":{"$ref":"#/definitions/CacheableResponseOptions"},"cacheName":{"type":["null","string"]},"expiration":{"$ref":"#/definitions/ExpirationPluginOptions"},"networkTimeoutSeconds":{"type":"number"},"plugins":{"type":"array","items":{"$ref":"#/definitions/WorkboxPlugin"}},"precacheFallback":{"type":"object","properties":{"fallbackURL":{"type":"string"}},"additionalProperties":false},"fetchOptions":{"$ref":"#/definitions/RequestInit"},"matchOptions":{"$ref":"#/definitions/CacheQueryOptions"}},"additionalProperties":false},"urlPattern":{"anyOf":[{"$ref":"#/definitions/RegExp"},{"$ref":"#/definitions/RouteMatchCallback"},{"type":"string"}]}},"additionalProperties":false},"RouteHandlerCallback":{"description":"The \"handler\" callback is invoked whenever a `Router` matches a URL/Request\nto a `Route` via its `RouteMatchCallback`. This handler callback should\nreturn a `Promise` that resolves with a `Response`.\n\nIf a non-empty array or object is returned by the `RouteMatchCallback` it\nwill be passed in as this handler's `options.params` argument.","type":"object","additionalProperties":false},"RouteHandlerObject":{"description":"An object with a `handle` method of type `RouteHandlerCallback`.\n\nA `Route` object can be created with either an `RouteHandlerCallback`\nfunction or this `RouteHandler` object. The benefit of the `RouteHandler`\nis it can be extended (as is done by the `workbox-strategies` package).","type":"object","properties":{"handle":{"$ref":"#/definitions/RouteHandlerCallback"}},"additionalProperties":false},"QueueOptions":{"type":"object","properties":{"onSync":{"$ref":"#/definitions/OnSyncCallback"},"maxRetentionTime":{"type":"number"}},"additionalProperties":false},"OnSyncCallback":{"type":"object","additionalProperties":false},"BroadcastCacheUpdateOptions":{"type":"object","properties":{"headersToCheck":{"type":"array","items":{"type":"string"}},"generatePayload":{"type":"object","additionalProperties":false}},"additionalProperties":false},"CacheableResponseOptions":{"type":"object","properties":{"statuses":{"type":"array","items":{"type":"number"}},"headers":{"type":"object","additionalProperties":{"type":"string"}}},"additionalProperties":false},"ExpirationPluginOptions":{"type":"object","properties":{"maxEntries":{"type":"number"},"maxAgeSeconds":{"type":"number"},"matchOptions":{"$ref":"#/definitions/CacheQueryOptions"},"purgeOnQuotaError":{"type":"boolean"}},"additionalProperties":false},"CacheQueryOptions":{"type":"object","properties":{"ignoreMethod":{"type":"boolean"},"ignoreSearch":{"type":"boolean"},"ignoreVary":{"type":"boolean"}},"additionalProperties":false},"WorkboxPlugin":{"description":"An object with optional lifecycle callback properties for the fetch and\ncache operations.","type":"object","properties":{"cacheDidUpdate":{"$ref":"#/definitions/CacheDidUpdateCallback"},"cachedResponseWillBeUsed":{"$ref":"#/definitions/CachedResponseWillBeUsedCallback"},"cacheKeyWillBeUsed":{"$ref":"#/definitions/CacheKeyWillBeUsedCallback"},"cacheWillUpdate":{"$ref":"#/definitions/CacheWillUpdateCallback"},"fetchDidFail":{"$ref":"#/definitions/FetchDidFailCallback"},"fetchDidSucceed":{"$ref":"#/definitions/FetchDidSucceedCallback"},"handlerDidComplete":{"$ref":"#/definitions/HandlerDidCompleteCallback"},"handlerDidError":{"$ref":"#/definitions/HandlerDidErrorCallback"},"handlerDidRespond":{"$ref":"#/definitions/HandlerDidRespondCallback"},"handlerWillRespond":{"$ref":"#/definitions/HandlerWillRespondCallback"},"handlerWillStart":{"$ref":"#/definitions/HandlerWillStartCallback"},"requestWillFetch":{"$ref":"#/definitions/RequestWillFetchCallback"}},"additionalProperties":false},"CacheDidUpdateCallback":{"type":"object","additionalProperties":false},"CachedResponseWillBeUsedCallback":{"type":"object","additionalProperties":false},"CacheKeyWillBeUsedCallback":{"type":"object","additionalProperties":false},"CacheWillUpdateCallback":{"type":"object","additionalProperties":false},"FetchDidFailCallback":{"type":"object","additionalProperties":false},"FetchDidSucceedCallback":{"type":"object","additionalProperties":false},"HandlerDidCompleteCallback":{"type":"object","additionalProperties":false},"HandlerDidErrorCallback":{"type":"object","additionalProperties":false},"HandlerDidRespondCallback":{"type":"object","additionalProperties":false},"HandlerWillRespondCallback":{"type":"object","additionalProperties":false},"HandlerWillStartCallback":{"type":"object","additionalProperties":false},"RequestWillFetchCallback":{"type":"object","additionalProperties":false},"RequestInit":{"type":"object","properties":{"body":{"anyOf":[{"$ref":"#/definitions/ArrayBuffer"},{"$ref":"#/definitions/ArrayBufferView"},{"$ref":"#/definitions/Blob"},{"$ref":"#/definitions/FormData"},{"$ref":"#/definitions/URLSearchParams"},{"$ref":"#/definitions/ReadableStream"},{"type":["null","string"]}]},"cache":{"enum":["default","force-cache","no-cache","no-store","only-if-cached","reload"],"type":"string"},"credentials":{"enum":["include","omit","same-origin"],"type":"string"},"headers":{"anyOf":[{"$ref":"#/definitions/Headers"},{"type":"array","items":{"type":"array","items":{"type":"string"}}},{"$ref":"#/definitions/Record"}]},"integrity":{"type":"string"},"keepalive":{"type":"boolean"},"method":{"type":"string"},"mode":{"enum":["cors","navigate","no-cors","same-origin"],"type":"string"},"redirect":{"enum":["error","follow","manual"],"type":"string"},"referrer":{"type":"string"},"referrerPolicy":{"enum":["","no-referrer","no-referrer-when-downgrade","origin","origin-when-cross-origin","same-origin","strict-origin","strict-origin-when-cross-origin","unsafe-url"],"type":"string"},"signal":{"anyOf":[{"$ref":"#/definitions/AbortSignal"},{"type":"null"}]},"window":{}},"additionalProperties":false},"ArrayBuffer":{"type":"object","properties":{"byteLength":{"type":"number"},"__@toStringTag":{"type":"string"}},"additionalProperties":false},"ArrayBufferView":{"type":"object","properties":{"buffer":{"anyOf":[{"$ref":"#/definitions/ArrayBuffer"},{"$ref":"#/definitions/SharedArrayBuffer"}]},"byteLength":{"type":"number"},"byteOffset":{"type":"number"}},"additionalProperties":false},"SharedArrayBuffer":{"type":"object","properties":{"byteLength":{"type":"number"},"__@species":{"$ref":"#/definitions/SharedArrayBuffer"},"__@toStringTag":{"type":"string","enum":["SharedArrayBuffer"]}},"additionalProperties":false},"Blob":{"type":"object","properties":{"size":{"type":"number"},"type":{"type":"string"}},"additionalProperties":false},"FormData":{"type":"object","additionalProperties":false},"URLSearchParams":{"type":"object","additionalProperties":false},"ReadableStream":{"type":"object","properties":{"locked":{"type":"boolean"}},"additionalProperties":false},"Headers":{"type":"object","additionalProperties":false},"Record":{"type":"object","additionalProperties":false},"AbortSignal":{"type":"object","properties":{"aborted":{"type":"boolean"},"onabort":{"anyOf":[{"type":"object","additionalProperties":false},{"type":"null"}]}},"additionalProperties":false},"RouteMatchCallback":{"description":"The \"match\" callback is used to determine if a `Route` should apply for a\nparticular URL and request. When matching occurs in response to a fetch\nevent from the client, the `event` object is also supplied. However, since\nthe match callback can be invoked outside of a fetch event, matching logic\nshould not assume the `event` object will always be available.\nIf the match callback returns a truthy value, the matching route's\n`RouteHandlerCallback` will be invoked immediately. If the value returned\nis a non-empty array or object, that value will be set on the handler's\n`options.params` argument.","type":"object","additionalProperties":false},"ManifestEntry":{"type":"object","properties":{"integrity":{"type":"string"},"revision":{"type":["null","string"]},"url":{"type":"string"}},"additionalProperties":false}},"$schema":"http://json-schema.org/draft-07/schema#"} +{"additionalProperties":false,"type":"object","properties":{"globDirectory":{"type":["null","string"]},"globFollow":{"default":true,"type":"boolean"},"globIgnores":{"default":["**/node_modules/**/*"],"type":"array","items":{"type":"string"}},"globPatterns":{"default":["**/*.{js,css,html}"],"type":"array","items":{"type":"string"}},"globStrict":{"default":true,"type":"boolean"},"templatedURLs":{"type":"object","additionalProperties":{"anyOf":[{"type":"array","items":{"type":"string"}},{"type":"string"}]}},"additionalManifestEntries":{"type":"array","items":{"anyOf":[{"$ref":"#/definitions/ManifestEntry"},{"type":"string"}]}},"dontCacheBustURLsMatching":{"$ref":"#/definitions/RegExp"},"manifestTransforms":{"type":"array","items":{"type":"object","additionalProperties":false}},"maximumFileSizeToCacheInBytes":{"default":2097152,"type":"number"},"modifyURLPrefix":{"type":"object","additionalProperties":{"type":"string"}}},"definitions":{"RegExp":{"type":"object","properties":{"source":{"type":"string"},"global":{"type":"boolean"},"ignoreCase":{"type":"boolean"},"multiline":{"type":"boolean"},"lastIndex":{"type":"number"},"flags":{"type":"string"},"sticky":{"type":"boolean"},"unicode":{"type":"boolean"},"dotAll":{"type":"boolean"}},"additionalProperties":false},"GoogleAnalyticsInitializeOptions":{"type":"object","properties":{"cacheName":{"type":"string"},"parameterOverrides":{"type":"object","additionalProperties":{"type":"string"}},"hitFilter":{"type":"object","additionalProperties":false}},"additionalProperties":false},"RuntimeCaching":{"type":"object","properties":{"handler":{"anyOf":[{"$ref":"#/definitions/RouteHandlerCallback"},{"$ref":"#/definitions/RouteHandlerObject"},{"enum":["CacheFirst","CacheOnly","NetworkFirst","NetworkOnly","StaleWhileRevalidate"],"type":"string"}]},"method":{"enum":["DELETE","GET","HEAD","PATCH","POST","PUT"],"type":"string"},"options":{"type":"object","properties":{"backgroundSync":{"type":"object","properties":{"name":{"type":"string"},"options":{"$ref":"#/definitions/QueueOptions"}},"additionalProperties":false},"broadcastUpdate":{"type":"object","properties":{"channelName":{"type":"string"},"options":{"$ref":"#/definitions/BroadcastCacheUpdateOptions"}},"additionalProperties":false},"cacheableResponse":{"$ref":"#/definitions/CacheableResponseOptions"},"cacheName":{"type":["null","string"]},"expiration":{"$ref":"#/definitions/ExpirationPluginOptions"},"networkTimeoutSeconds":{"type":"number"},"plugins":{"type":"array","items":{"$ref":"#/definitions/WorkboxPlugin"}},"precacheFallback":{"type":"object","properties":{"fallbackURL":{"type":"string"}},"additionalProperties":false},"fetchOptions":{"$ref":"#/definitions/RequestInit"},"matchOptions":{"$ref":"#/definitions/CacheQueryOptions"}},"additionalProperties":false},"urlPattern":{"anyOf":[{"$ref":"#/definitions/RegExp"},{"$ref":"#/definitions/RouteMatchCallback"},{"type":"string"}]}},"additionalProperties":false},"RouteHandlerCallback":{"description":"The \"handler\" callback is invoked whenever a `Router` matches a URL/Request\nto a `Route` via its `RouteMatchCallback`. This handler callback should\nreturn a `Promise` that resolves with a `Response`.\n\nIf a non-empty array or object is returned by the `RouteMatchCallback` it\nwill be passed in as this handler's `options.params` argument.","type":"object","additionalProperties":false},"RouteHandlerObject":{"description":"An object with a `handle` method of type `RouteHandlerCallback`.\n\nA `Route` object can be created with either an `RouteHandlerCallback`\nfunction or this `RouteHandler` object. The benefit of the `RouteHandler`\nis it can be extended (as is done by the `workbox-strategies` package).","type":"object","properties":{"handle":{"$ref":"#/definitions/RouteHandlerCallback"}},"additionalProperties":false},"QueueOptions":{"type":"object","properties":{"onSync":{"$ref":"#/definitions/OnSyncCallback"},"maxRetentionTime":{"type":"number"}},"additionalProperties":false},"OnSyncCallback":{"type":"object","additionalProperties":false},"BroadcastCacheUpdateOptions":{"type":"object","properties":{"headersToCheck":{"type":"array","items":{"type":"string"}},"generatePayload":{"type":"object","additionalProperties":false}},"additionalProperties":false},"CacheableResponseOptions":{"type":"object","properties":{"statuses":{"type":"array","items":{"type":"number"}},"headers":{"type":"object","additionalProperties":{"type":"string"}}},"additionalProperties":false},"ExpirationPluginOptions":{"type":"object","properties":{"maxEntries":{"type":"number"},"maxAgeSeconds":{"type":"number"},"matchOptions":{"$ref":"#/definitions/CacheQueryOptions"},"purgeOnQuotaError":{"type":"boolean"}},"additionalProperties":false},"CacheQueryOptions":{"type":"object","properties":{"ignoreMethod":{"type":"boolean"},"ignoreSearch":{"type":"boolean"},"ignoreVary":{"type":"boolean"}},"additionalProperties":false},"WorkboxPlugin":{"description":"An object with optional lifecycle callback properties for the fetch and\ncache operations.","type":"object","properties":{"cacheDidUpdate":{"$ref":"#/definitions/CacheDidUpdateCallback"},"cachedResponseWillBeUsed":{"$ref":"#/definitions/CachedResponseWillBeUsedCallback"},"cacheKeyWillBeUsed":{"$ref":"#/definitions/CacheKeyWillBeUsedCallback"},"cacheWillUpdate":{"$ref":"#/definitions/CacheWillUpdateCallback"},"fetchDidFail":{"$ref":"#/definitions/FetchDidFailCallback"},"fetchDidSucceed":{"$ref":"#/definitions/FetchDidSucceedCallback"},"handlerDidComplete":{"$ref":"#/definitions/HandlerDidCompleteCallback"},"handlerDidError":{"$ref":"#/definitions/HandlerDidErrorCallback"},"handlerDidRespond":{"$ref":"#/definitions/HandlerDidRespondCallback"},"handlerWillRespond":{"$ref":"#/definitions/HandlerWillRespondCallback"},"handlerWillStart":{"$ref":"#/definitions/HandlerWillStartCallback"},"requestWillFetch":{"$ref":"#/definitions/RequestWillFetchCallback"}},"additionalProperties":false},"CacheDidUpdateCallback":{"type":"object","additionalProperties":false},"CachedResponseWillBeUsedCallback":{"type":"object","additionalProperties":false},"CacheKeyWillBeUsedCallback":{"type":"object","additionalProperties":false},"CacheWillUpdateCallback":{"type":"object","additionalProperties":false},"FetchDidFailCallback":{"type":"object","additionalProperties":false},"FetchDidSucceedCallback":{"type":"object","additionalProperties":false},"HandlerDidCompleteCallback":{"type":"object","additionalProperties":false},"HandlerDidErrorCallback":{"type":"object","additionalProperties":false},"HandlerDidRespondCallback":{"type":"object","additionalProperties":false},"HandlerWillRespondCallback":{"type":"object","additionalProperties":false},"HandlerWillStartCallback":{"type":"object","additionalProperties":false},"RequestWillFetchCallback":{"type":"object","additionalProperties":false},"RequestInit":{"type":"object","properties":{"body":{"anyOf":[{"$ref":"#/definitions/ArrayBuffer"},{"$ref":"#/definitions/ArrayBufferView"},{"$ref":"#/definitions/Blob"},{"$ref":"#/definitions/FormData"},{"$ref":"#/definitions/URLSearchParams"},{"$ref":"#/definitions/ReadableStream"},{"type":["null","string"]}]},"cache":{"enum":["default","force-cache","no-cache","no-store","only-if-cached","reload"],"type":"string"},"credentials":{"enum":["include","omit","same-origin"],"type":"string"},"headers":{"anyOf":[{"$ref":"#/definitions/Headers"},{"type":"array","items":{"type":"array","items":{"type":"string"}}},{"$ref":"#/definitions/Record"}]},"integrity":{"type":"string"},"keepalive":{"type":"boolean"},"method":{"type":"string"},"mode":{"enum":["cors","navigate","no-cors","same-origin"],"type":"string"},"redirect":{"enum":["error","follow","manual"],"type":"string"},"referrer":{"type":"string"},"referrerPolicy":{"enum":["","no-referrer","no-referrer-when-downgrade","origin","origin-when-cross-origin","same-origin","strict-origin","strict-origin-when-cross-origin","unsafe-url"],"type":"string"},"signal":{"anyOf":[{"$ref":"#/definitions/AbortSignal"},{"type":"null"}]},"window":{}},"additionalProperties":false},"ArrayBuffer":{"type":"object","properties":{"byteLength":{"type":"number"},"__@toStringTag":{"type":"string"}},"additionalProperties":false},"ArrayBufferView":{"type":"object","properties":{"buffer":{"anyOf":[{"$ref":"#/definitions/ArrayBuffer"},{"$ref":"#/definitions/SharedArrayBuffer"}]},"byteLength":{"type":"number"},"byteOffset":{"type":"number"}},"additionalProperties":false},"SharedArrayBuffer":{"type":"object","properties":{"byteLength":{"type":"number"},"__@species":{"$ref":"#/definitions/SharedArrayBuffer"},"__@toStringTag":{"type":"string","enum":["SharedArrayBuffer"]}},"additionalProperties":false},"Blob":{"type":"object","properties":{"size":{"type":"number"},"type":{"type":"string"}},"additionalProperties":false},"FormData":{"type":"object","additionalProperties":false},"URLSearchParams":{"type":"object","additionalProperties":false},"ReadableStream":{"type":"object","properties":{"locked":{"type":"boolean"}},"additionalProperties":false},"Headers":{"type":"object","additionalProperties":false},"Record":{"type":"object","additionalProperties":false},"AbortSignal":{"type":"object","properties":{"aborted":{"type":"boolean"},"onabort":{"anyOf":[{"type":"object","additionalProperties":false},{"type":"null"}]}},"additionalProperties":false},"RouteMatchCallback":{"description":"The \"match\" callback is used to determine if a `Route` should apply for a\nparticular URL and request. When matching occurs in response to a fetch\nevent from the client, the `event` object is also supplied. However, since\nthe match callback can be invoked outside of a fetch event, matching logic\nshould not assume the `event` object will always be available.\nIf the match callback returns a truthy value, the matching route's\n`RouteHandlerCallback` will be invoked immediately. If the value returned\nis a non-empty array or object, that value will be set on the handler's\n`options.params` argument.","type":"object","additionalProperties":false},"ManifestEntry":{"type":"object","properties":{"integrity":{"type":"string"},"revision":{"type":["null","string"]},"url":{"type":"string"}},"additionalProperties":false}},"$schema":"http://json-schema.org/draft-07/schema#"} diff --git a/packages/workbox-build/src/schema/InjectManifestOptions.json b/packages/workbox-build/src/schema/InjectManifestOptions.json index 0de4ea1fc..30c4db43e 100644 --- a/packages/workbox-build/src/schema/InjectManifestOptions.json +++ b/packages/workbox-build/src/schema/InjectManifestOptions.json @@ -1 +1 @@ -{"additionalProperties":false,"type":"object","properties":{"injectionPoint":{"default":"'self.__WB_MANIFEST'","type":"string"},"swSrc":{"type":"string"},"globFollow":{"default":true,"type":"boolean"},"globIgnores":{"default":"['**\\/node_modules\\/**\\/*']","type":"array","items":{"type":"string"}},"globPatterns":{"default":"['**\\/*.{js,css,html}']","type":"array","items":{"type":"string"}},"globStrict":{"default":true,"type":"boolean"},"templatedURLs":{"type":"object","additionalProperties":{"anyOf":[{"type":"array","items":{"type":"string"}},{"type":"string"}]}},"additionalManifestEntries":{"type":"array","items":{"anyOf":[{"$ref":"#/definitions/ManifestEntry"},{"type":"string"}]}},"dontCacheBustURLsMatching":{"$ref":"#/definitions/RegExp"},"manifestTransforms":{"type":"array","items":{"type":"object","additionalProperties":false}},"maximumFileSizeToCacheInBytes":{"default":2097152,"type":"number"},"modifyURLPrefix":{"type":"object","additionalProperties":{"type":"string"}},"swDest":{"default":"'service-worker.js'","type":"string"},"globDirectory":{"type":"string"}},"definitions":{"RegExp":{"type":"object","properties":{"source":{"type":"string"},"global":{"type":"boolean"},"ignoreCase":{"type":"boolean"},"multiline":{"type":"boolean"},"lastIndex":{"type":"number"},"flags":{"type":"string"},"sticky":{"type":"boolean"},"unicode":{"type":"boolean"},"dotAll":{"type":"boolean"}},"additionalProperties":false},"GoogleAnalyticsInitializeOptions":{"type":"object","properties":{"cacheName":{"type":"string"},"parameterOverrides":{"type":"object","additionalProperties":{"type":"string"}},"hitFilter":{"type":"object","additionalProperties":false}},"additionalProperties":false},"RuntimeCaching":{"type":"object","properties":{"handler":{"anyOf":[{"$ref":"#/definitions/RouteHandlerCallback"},{"$ref":"#/definitions/RouteHandlerObject"},{"enum":["CacheFirst","CacheOnly","NetworkFirst","NetworkOnly","StaleWhileRevalidate"],"type":"string"}]},"method":{"enum":["DELETE","GET","HEAD","PATCH","POST","PUT"],"type":"string"},"options":{"type":"object","properties":{"backgroundSync":{"type":"object","properties":{"name":{"type":"string"},"options":{"$ref":"#/definitions/QueueOptions"}},"additionalProperties":false},"broadcastUpdate":{"type":"object","properties":{"channelName":{"type":"string"},"options":{"$ref":"#/definitions/BroadcastCacheUpdateOptions"}},"additionalProperties":false},"cacheableResponse":{"$ref":"#/definitions/CacheableResponseOptions"},"cacheName":{"type":["null","string"]},"expiration":{"$ref":"#/definitions/ExpirationPluginOptions"},"networkTimeoutSeconds":{"type":"number"},"plugins":{"type":"array","items":{"$ref":"#/definitions/WorkboxPlugin"}},"precacheFallback":{"type":"object","properties":{"fallbackURL":{"type":"string"}},"additionalProperties":false},"fetchOptions":{"$ref":"#/definitions/RequestInit"},"matchOptions":{"$ref":"#/definitions/CacheQueryOptions"}},"additionalProperties":false},"urlPattern":{"anyOf":[{"$ref":"#/definitions/RegExp"},{"$ref":"#/definitions/RouteMatchCallback"},{"type":"string"}]}},"additionalProperties":false},"RouteHandlerCallback":{"description":"The \"handler\" callback is invoked whenever a `Router` matches a URL/Request\nto a `Route` via its `RouteMatchCallback`. This handler callback should\nreturn a `Promise` that resolves with a `Response`.\n\nIf a non-empty array or object is returned by the `RouteMatchCallback` it\nwill be passed in as this handler's `options.params` argument.","type":"object","additionalProperties":false},"RouteHandlerObject":{"description":"An object with a `handle` method of type `RouteHandlerCallback`.\n\nA `Route` object can be created with either an `RouteHandlerCallback`\nfunction or this `RouteHandler` object. The benefit of the `RouteHandler`\nis it can be extended (as is done by the `workbox-strategies` package).","type":"object","properties":{"handle":{"$ref":"#/definitions/RouteHandlerCallback"}},"additionalProperties":false},"QueueOptions":{"type":"object","properties":{"onSync":{"$ref":"#/definitions/OnSyncCallback"},"maxRetentionTime":{"type":"number"}},"additionalProperties":false},"OnSyncCallback":{"type":"object","additionalProperties":false},"BroadcastCacheUpdateOptions":{"type":"object","properties":{"headersToCheck":{"type":"array","items":{"type":"string"}},"generatePayload":{"type":"object","additionalProperties":false}},"additionalProperties":false},"CacheableResponseOptions":{"type":"object","properties":{"statuses":{"type":"array","items":{"type":"number"}},"headers":{"type":"object","additionalProperties":{"type":"string"}}},"additionalProperties":false},"ExpirationPluginOptions":{"type":"object","properties":{"maxEntries":{"type":"number"},"maxAgeSeconds":{"type":"number"},"matchOptions":{"$ref":"#/definitions/CacheQueryOptions"},"purgeOnQuotaError":{"type":"boolean"}},"additionalProperties":false},"CacheQueryOptions":{"type":"object","properties":{"ignoreMethod":{"type":"boolean"},"ignoreSearch":{"type":"boolean"},"ignoreVary":{"type":"boolean"}},"additionalProperties":false},"WorkboxPlugin":{"description":"An object with optional lifecycle callback properties for the fetch and\ncache operations.","type":"object","properties":{"cacheDidUpdate":{"$ref":"#/definitions/CacheDidUpdateCallback"},"cachedResponseWillBeUsed":{"$ref":"#/definitions/CachedResponseWillBeUsedCallback"},"cacheKeyWillBeUsed":{"$ref":"#/definitions/CacheKeyWillBeUsedCallback"},"cacheWillUpdate":{"$ref":"#/definitions/CacheWillUpdateCallback"},"fetchDidFail":{"$ref":"#/definitions/FetchDidFailCallback"},"fetchDidSucceed":{"$ref":"#/definitions/FetchDidSucceedCallback"},"handlerDidComplete":{"$ref":"#/definitions/HandlerDidCompleteCallback"},"handlerDidError":{"$ref":"#/definitions/HandlerDidErrorCallback"},"handlerDidRespond":{"$ref":"#/definitions/HandlerDidRespondCallback"},"handlerWillRespond":{"$ref":"#/definitions/HandlerWillRespondCallback"},"handlerWillStart":{"$ref":"#/definitions/HandlerWillStartCallback"},"requestWillFetch":{"$ref":"#/definitions/RequestWillFetchCallback"}},"additionalProperties":false},"CacheDidUpdateCallback":{"type":"object","additionalProperties":false},"CachedResponseWillBeUsedCallback":{"type":"object","additionalProperties":false},"CacheKeyWillBeUsedCallback":{"type":"object","additionalProperties":false},"CacheWillUpdateCallback":{"type":"object","additionalProperties":false},"FetchDidFailCallback":{"type":"object","additionalProperties":false},"FetchDidSucceedCallback":{"type":"object","additionalProperties":false},"HandlerDidCompleteCallback":{"type":"object","additionalProperties":false},"HandlerDidErrorCallback":{"type":"object","additionalProperties":false},"HandlerDidRespondCallback":{"type":"object","additionalProperties":false},"HandlerWillRespondCallback":{"type":"object","additionalProperties":false},"HandlerWillStartCallback":{"type":"object","additionalProperties":false},"RequestWillFetchCallback":{"type":"object","additionalProperties":false},"RequestInit":{"type":"object","properties":{"body":{"anyOf":[{"$ref":"#/definitions/ArrayBuffer"},{"$ref":"#/definitions/ArrayBufferView"},{"$ref":"#/definitions/Blob"},{"$ref":"#/definitions/FormData"},{"$ref":"#/definitions/URLSearchParams"},{"$ref":"#/definitions/ReadableStream"},{"type":["null","string"]}]},"cache":{"enum":["default","force-cache","no-cache","no-store","only-if-cached","reload"],"type":"string"},"credentials":{"enum":["include","omit","same-origin"],"type":"string"},"headers":{"anyOf":[{"$ref":"#/definitions/Headers"},{"type":"array","items":{"type":"array","items":{"type":"string"}}},{"$ref":"#/definitions/Record"}]},"integrity":{"type":"string"},"keepalive":{"type":"boolean"},"method":{"type":"string"},"mode":{"enum":["cors","navigate","no-cors","same-origin"],"type":"string"},"redirect":{"enum":["error","follow","manual"],"type":"string"},"referrer":{"type":"string"},"referrerPolicy":{"enum":["","no-referrer","no-referrer-when-downgrade","origin","origin-when-cross-origin","same-origin","strict-origin","strict-origin-when-cross-origin","unsafe-url"],"type":"string"},"signal":{"anyOf":[{"$ref":"#/definitions/AbortSignal"},{"type":"null"}]},"window":{}},"additionalProperties":false},"ArrayBuffer":{"type":"object","properties":{"byteLength":{"type":"number"},"__@toStringTag":{"type":"string"}},"additionalProperties":false},"ArrayBufferView":{"type":"object","properties":{"buffer":{"anyOf":[{"$ref":"#/definitions/ArrayBuffer"},{"$ref":"#/definitions/SharedArrayBuffer"}]},"byteLength":{"type":"number"},"byteOffset":{"type":"number"}},"additionalProperties":false},"SharedArrayBuffer":{"type":"object","properties":{"byteLength":{"type":"number"},"__@species":{"$ref":"#/definitions/SharedArrayBuffer"},"__@toStringTag":{"type":"string","enum":["SharedArrayBuffer"]}},"additionalProperties":false},"Blob":{"type":"object","properties":{"size":{"type":"number"},"type":{"type":"string"}},"additionalProperties":false},"FormData":{"type":"object","additionalProperties":false},"URLSearchParams":{"type":"object","additionalProperties":false},"ReadableStream":{"type":"object","properties":{"locked":{"type":"boolean"}},"additionalProperties":false},"Headers":{"type":"object","additionalProperties":false},"Record":{"type":"object","additionalProperties":false},"AbortSignal":{"type":"object","properties":{"aborted":{"type":"boolean"},"onabort":{"anyOf":[{"type":"object","additionalProperties":false},{"type":"null"}]}},"additionalProperties":false},"RouteMatchCallback":{"description":"The \"match\" callback is used to determine if a `Route` should apply for a\nparticular URL and request. When matching occurs in response to a fetch\nevent from the client, the `event` object is also supplied. However, since\nthe match callback can be invoked outside of a fetch event, matching logic\nshould not assume the `event` object will always be available.\nIf the match callback returns a truthy value, the matching route's\n`RouteHandlerCallback` will be invoked immediately. If the value returned\nis a non-empty array or object, that value will be set on the handler's\n`options.params` argument.","type":"object","additionalProperties":false},"ManifestEntry":{"type":"object","properties":{"integrity":{"type":"string"},"revision":{"type":["null","string"]},"url":{"type":"string"}},"additionalProperties":false}},"$schema":"http://json-schema.org/draft-07/schema#"} +{"additionalProperties":false,"type":"object","properties":{"injectionPoint":{"default":"self.__WB_MANIFEST","type":"string"},"swSrc":{"type":"string"},"globFollow":{"default":true,"type":"boolean"},"globIgnores":{"default":["**/node_modules/**/*"],"type":"array","items":{"type":"string"}},"globPatterns":{"default":["**/*.{js,css,html}"],"type":"array","items":{"type":"string"}},"globStrict":{"default":true,"type":"boolean"},"templatedURLs":{"type":"object","additionalProperties":{"anyOf":[{"type":"array","items":{"type":"string"}},{"type":"string"}]}},"additionalManifestEntries":{"type":"array","items":{"anyOf":[{"$ref":"#/definitions/ManifestEntry"},{"type":"string"}]}},"dontCacheBustURLsMatching":{"$ref":"#/definitions/RegExp"},"manifestTransforms":{"type":"array","items":{"type":"object","additionalProperties":false}},"maximumFileSizeToCacheInBytes":{"default":2097152,"type":"number"},"modifyURLPrefix":{"type":"object","additionalProperties":{"type":"string"}},"swDest":{"default":"service-worker.js","type":"string"},"globDirectory":{"type":"string"}},"definitions":{"RegExp":{"type":"object","properties":{"source":{"type":"string"},"global":{"type":"boolean"},"ignoreCase":{"type":"boolean"},"multiline":{"type":"boolean"},"lastIndex":{"type":"number"},"flags":{"type":"string"},"sticky":{"type":"boolean"},"unicode":{"type":"boolean"},"dotAll":{"type":"boolean"}},"additionalProperties":false},"GoogleAnalyticsInitializeOptions":{"type":"object","properties":{"cacheName":{"type":"string"},"parameterOverrides":{"type":"object","additionalProperties":{"type":"string"}},"hitFilter":{"type":"object","additionalProperties":false}},"additionalProperties":false},"RuntimeCaching":{"type":"object","properties":{"handler":{"anyOf":[{"$ref":"#/definitions/RouteHandlerCallback"},{"$ref":"#/definitions/RouteHandlerObject"},{"enum":["CacheFirst","CacheOnly","NetworkFirst","NetworkOnly","StaleWhileRevalidate"],"type":"string"}]},"method":{"enum":["DELETE","GET","HEAD","PATCH","POST","PUT"],"type":"string"},"options":{"type":"object","properties":{"backgroundSync":{"type":"object","properties":{"name":{"type":"string"},"options":{"$ref":"#/definitions/QueueOptions"}},"additionalProperties":false},"broadcastUpdate":{"type":"object","properties":{"channelName":{"type":"string"},"options":{"$ref":"#/definitions/BroadcastCacheUpdateOptions"}},"additionalProperties":false},"cacheableResponse":{"$ref":"#/definitions/CacheableResponseOptions"},"cacheName":{"type":["null","string"]},"expiration":{"$ref":"#/definitions/ExpirationPluginOptions"},"networkTimeoutSeconds":{"type":"number"},"plugins":{"type":"array","items":{"$ref":"#/definitions/WorkboxPlugin"}},"precacheFallback":{"type":"object","properties":{"fallbackURL":{"type":"string"}},"additionalProperties":false},"fetchOptions":{"$ref":"#/definitions/RequestInit"},"matchOptions":{"$ref":"#/definitions/CacheQueryOptions"}},"additionalProperties":false},"urlPattern":{"anyOf":[{"$ref":"#/definitions/RegExp"},{"$ref":"#/definitions/RouteMatchCallback"},{"type":"string"}]}},"additionalProperties":false},"RouteHandlerCallback":{"description":"The \"handler\" callback is invoked whenever a `Router` matches a URL/Request\nto a `Route` via its `RouteMatchCallback`. This handler callback should\nreturn a `Promise` that resolves with a `Response`.\n\nIf a non-empty array or object is returned by the `RouteMatchCallback` it\nwill be passed in as this handler's `options.params` argument.","type":"object","additionalProperties":false},"RouteHandlerObject":{"description":"An object with a `handle` method of type `RouteHandlerCallback`.\n\nA `Route` object can be created with either an `RouteHandlerCallback`\nfunction or this `RouteHandler` object. The benefit of the `RouteHandler`\nis it can be extended (as is done by the `workbox-strategies` package).","type":"object","properties":{"handle":{"$ref":"#/definitions/RouteHandlerCallback"}},"additionalProperties":false},"QueueOptions":{"type":"object","properties":{"onSync":{"$ref":"#/definitions/OnSyncCallback"},"maxRetentionTime":{"type":"number"}},"additionalProperties":false},"OnSyncCallback":{"type":"object","additionalProperties":false},"BroadcastCacheUpdateOptions":{"type":"object","properties":{"headersToCheck":{"type":"array","items":{"type":"string"}},"generatePayload":{"type":"object","additionalProperties":false}},"additionalProperties":false},"CacheableResponseOptions":{"type":"object","properties":{"statuses":{"type":"array","items":{"type":"number"}},"headers":{"type":"object","additionalProperties":{"type":"string"}}},"additionalProperties":false},"ExpirationPluginOptions":{"type":"object","properties":{"maxEntries":{"type":"number"},"maxAgeSeconds":{"type":"number"},"matchOptions":{"$ref":"#/definitions/CacheQueryOptions"},"purgeOnQuotaError":{"type":"boolean"}},"additionalProperties":false},"CacheQueryOptions":{"type":"object","properties":{"ignoreMethod":{"type":"boolean"},"ignoreSearch":{"type":"boolean"},"ignoreVary":{"type":"boolean"}},"additionalProperties":false},"WorkboxPlugin":{"description":"An object with optional lifecycle callback properties for the fetch and\ncache operations.","type":"object","properties":{"cacheDidUpdate":{"$ref":"#/definitions/CacheDidUpdateCallback"},"cachedResponseWillBeUsed":{"$ref":"#/definitions/CachedResponseWillBeUsedCallback"},"cacheKeyWillBeUsed":{"$ref":"#/definitions/CacheKeyWillBeUsedCallback"},"cacheWillUpdate":{"$ref":"#/definitions/CacheWillUpdateCallback"},"fetchDidFail":{"$ref":"#/definitions/FetchDidFailCallback"},"fetchDidSucceed":{"$ref":"#/definitions/FetchDidSucceedCallback"},"handlerDidComplete":{"$ref":"#/definitions/HandlerDidCompleteCallback"},"handlerDidError":{"$ref":"#/definitions/HandlerDidErrorCallback"},"handlerDidRespond":{"$ref":"#/definitions/HandlerDidRespondCallback"},"handlerWillRespond":{"$ref":"#/definitions/HandlerWillRespondCallback"},"handlerWillStart":{"$ref":"#/definitions/HandlerWillStartCallback"},"requestWillFetch":{"$ref":"#/definitions/RequestWillFetchCallback"}},"additionalProperties":false},"CacheDidUpdateCallback":{"type":"object","additionalProperties":false},"CachedResponseWillBeUsedCallback":{"type":"object","additionalProperties":false},"CacheKeyWillBeUsedCallback":{"type":"object","additionalProperties":false},"CacheWillUpdateCallback":{"type":"object","additionalProperties":false},"FetchDidFailCallback":{"type":"object","additionalProperties":false},"FetchDidSucceedCallback":{"type":"object","additionalProperties":false},"HandlerDidCompleteCallback":{"type":"object","additionalProperties":false},"HandlerDidErrorCallback":{"type":"object","additionalProperties":false},"HandlerDidRespondCallback":{"type":"object","additionalProperties":false},"HandlerWillRespondCallback":{"type":"object","additionalProperties":false},"HandlerWillStartCallback":{"type":"object","additionalProperties":false},"RequestWillFetchCallback":{"type":"object","additionalProperties":false},"RequestInit":{"type":"object","properties":{"body":{"anyOf":[{"$ref":"#/definitions/ArrayBuffer"},{"$ref":"#/definitions/ArrayBufferView"},{"$ref":"#/definitions/Blob"},{"$ref":"#/definitions/FormData"},{"$ref":"#/definitions/URLSearchParams"},{"$ref":"#/definitions/ReadableStream"},{"type":["null","string"]}]},"cache":{"enum":["default","force-cache","no-cache","no-store","only-if-cached","reload"],"type":"string"},"credentials":{"enum":["include","omit","same-origin"],"type":"string"},"headers":{"anyOf":[{"$ref":"#/definitions/Headers"},{"type":"array","items":{"type":"array","items":{"type":"string"}}},{"$ref":"#/definitions/Record"}]},"integrity":{"type":"string"},"keepalive":{"type":"boolean"},"method":{"type":"string"},"mode":{"enum":["cors","navigate","no-cors","same-origin"],"type":"string"},"redirect":{"enum":["error","follow","manual"],"type":"string"},"referrer":{"type":"string"},"referrerPolicy":{"enum":["","no-referrer","no-referrer-when-downgrade","origin","origin-when-cross-origin","same-origin","strict-origin","strict-origin-when-cross-origin","unsafe-url"],"type":"string"},"signal":{"anyOf":[{"$ref":"#/definitions/AbortSignal"},{"type":"null"}]},"window":{}},"additionalProperties":false},"ArrayBuffer":{"type":"object","properties":{"byteLength":{"type":"number"},"__@toStringTag":{"type":"string"}},"additionalProperties":false},"ArrayBufferView":{"type":"object","properties":{"buffer":{"anyOf":[{"$ref":"#/definitions/ArrayBuffer"},{"$ref":"#/definitions/SharedArrayBuffer"}]},"byteLength":{"type":"number"},"byteOffset":{"type":"number"}},"additionalProperties":false},"SharedArrayBuffer":{"type":"object","properties":{"byteLength":{"type":"number"},"__@species":{"$ref":"#/definitions/SharedArrayBuffer"},"__@toStringTag":{"type":"string","enum":["SharedArrayBuffer"]}},"additionalProperties":false},"Blob":{"type":"object","properties":{"size":{"type":"number"},"type":{"type":"string"}},"additionalProperties":false},"FormData":{"type":"object","additionalProperties":false},"URLSearchParams":{"type":"object","additionalProperties":false},"ReadableStream":{"type":"object","properties":{"locked":{"type":"boolean"}},"additionalProperties":false},"Headers":{"type":"object","additionalProperties":false},"Record":{"type":"object","additionalProperties":false},"AbortSignal":{"type":"object","properties":{"aborted":{"type":"boolean"},"onabort":{"anyOf":[{"type":"object","additionalProperties":false},{"type":"null"}]}},"additionalProperties":false},"RouteMatchCallback":{"description":"The \"match\" callback is used to determine if a `Route` should apply for a\nparticular URL and request. When matching occurs in response to a fetch\nevent from the client, the `event` object is also supplied. However, since\nthe match callback can be invoked outside of a fetch event, matching logic\nshould not assume the `event` object will always be available.\nIf the match callback returns a truthy value, the matching route's\n`RouteHandlerCallback` will be invoked immediately. If the value returned\nis a non-empty array or object, that value will be set on the handler's\n`options.params` argument.","type":"object","additionalProperties":false},"ManifestEntry":{"type":"object","properties":{"integrity":{"type":"string"},"revision":{"type":["null","string"]},"url":{"type":"string"}},"additionalProperties":false}},"$schema":"http://json-schema.org/draft-07/schema#"} diff --git a/packages/workbox-build/src/schema/WebpackGenerateSWOptions.json b/packages/workbox-build/src/schema/WebpackGenerateSWOptions.json index 67365e397..bb3f6f849 100644 --- a/packages/workbox-build/src/schema/WebpackGenerateSWOptions.json +++ b/packages/workbox-build/src/schema/WebpackGenerateSWOptions.json @@ -1 +1 @@ -{"additionalProperties":false,"type":"object","properties":{"chunks":{"type":"array","items":{"type":"string"}},"exclude":{"default":"[/\\.map$/, /^manifest.*\\.js$/,]","type":"array","items":{"anyOf":[{"$ref":"#/definitions/RegExp"},{"type":"object","additionalProperties":false},{"type":"string"}]}},"excludeChunks":{"type":"array","items":{"type":"string"}},"include":{"type":"array","items":{"anyOf":[{"$ref":"#/definitions/RegExp"},{"type":"object","additionalProperties":false},{"type":"string"}]}},"mode":{"default":"'production'","type":["null","string"]},"babelPresetEnvTargets":{"default":"['chrome >= 56']","type":"array","items":{"type":"string"}},"cacheId":{"type":["null","string"]},"cleanupOutdatedCaches":{"default":false,"type":"boolean"},"clientsClaim":{"default":false,"type":"boolean"},"directoryIndex":{"type":["null","string"]},"disableDevLogs":{"default":false,"type":"boolean"},"ignoreURLParametersMatching":{"type":"array","items":{"$ref":"#/definitions/RegExp"}},"importScripts":{"type":"array","items":{"type":"string"}},"inlineWorkboxRuntime":{"default":false,"type":"boolean"},"navigateFallback":{"default":null,"type":["null","string"]},"navigateFallbackAllowlist":{"type":"array","items":{"$ref":"#/definitions/RegExp"}},"navigateFallbackDenylist":{"type":"array","items":{"$ref":"#/definitions/RegExp"}},"navigationPreload":{"default":false,"type":"boolean"},"offlineGoogleAnalytics":{"default":false,"anyOf":[{"$ref":"#/definitions/GoogleAnalyticsInitializeOptions"},{"type":"boolean"}]},"runtimeCaching":{"type":"array","items":{"$ref":"#/definitions/RuntimeCaching"}},"skipWaiting":{"default":false,"type":"boolean"},"sourcemap":{"default":true,"type":"boolean"},"additionalManifestEntries":{"type":"array","items":{"anyOf":[{"$ref":"#/definitions/ManifestEntry"},{"type":"string"}]}},"dontCacheBustURLsMatching":{"$ref":"#/definitions/RegExp"},"manifestTransforms":{"type":"array","items":{"type":"object","additionalProperties":false}},"maximumFileSizeToCacheInBytes":{"default":2097152,"type":"number"},"modifyURLPrefix":{"type":"object","additionalProperties":{"type":"string"}},"swDest":{"default":"'service-worker.js'","type":"string"},"importScriptsViaChunks":{"type":"array","items":{"type":"string"}}},"definitions":{"RegExp":{"type":"object","properties":{"source":{"type":"string"},"global":{"type":"boolean"},"ignoreCase":{"type":"boolean"},"multiline":{"type":"boolean"},"lastIndex":{"type":"number"},"flags":{"type":"string"},"sticky":{"type":"boolean"},"unicode":{"type":"boolean"},"dotAll":{"type":"boolean"}},"additionalProperties":false},"GoogleAnalyticsInitializeOptions":{"type":"object","properties":{"cacheName":{"type":"string"},"parameterOverrides":{"type":"object","additionalProperties":{"type":"string"}},"hitFilter":{"type":"object","additionalProperties":false}},"additionalProperties":false},"RuntimeCaching":{"type":"object","properties":{"handler":{"anyOf":[{"$ref":"#/definitions/RouteHandlerCallback"},{"$ref":"#/definitions/RouteHandlerObject"},{"enum":["CacheFirst","CacheOnly","NetworkFirst","NetworkOnly","StaleWhileRevalidate"],"type":"string"}]},"method":{"enum":["DELETE","GET","HEAD","PATCH","POST","PUT"],"type":"string"},"options":{"type":"object","properties":{"backgroundSync":{"type":"object","properties":{"name":{"type":"string"},"options":{"$ref":"#/definitions/QueueOptions"}},"additionalProperties":false},"broadcastUpdate":{"type":"object","properties":{"channelName":{"type":"string"},"options":{"$ref":"#/definitions/BroadcastCacheUpdateOptions"}},"additionalProperties":false},"cacheableResponse":{"$ref":"#/definitions/CacheableResponseOptions"},"cacheName":{"type":["null","string"]},"expiration":{"$ref":"#/definitions/ExpirationPluginOptions"},"networkTimeoutSeconds":{"type":"number"},"plugins":{"type":"array","items":{"$ref":"#/definitions/WorkboxPlugin"}},"precacheFallback":{"type":"object","properties":{"fallbackURL":{"type":"string"}},"additionalProperties":false},"fetchOptions":{"$ref":"#/definitions/RequestInit"},"matchOptions":{"$ref":"#/definitions/CacheQueryOptions"}},"additionalProperties":false},"urlPattern":{"anyOf":[{"$ref":"#/definitions/RegExp"},{"$ref":"#/definitions/RouteMatchCallback"},{"type":"string"}]}},"additionalProperties":false},"RouteHandlerCallback":{"description":"The \"handler\" callback is invoked whenever a `Router` matches a URL/Request\nto a `Route` via its `RouteMatchCallback`. This handler callback should\nreturn a `Promise` that resolves with a `Response`.\n\nIf a non-empty array or object is returned by the `RouteMatchCallback` it\nwill be passed in as this handler's `options.params` argument.","type":"object","additionalProperties":false},"RouteHandlerObject":{"description":"An object with a `handle` method of type `RouteHandlerCallback`.\n\nA `Route` object can be created with either an `RouteHandlerCallback`\nfunction or this `RouteHandler` object. The benefit of the `RouteHandler`\nis it can be extended (as is done by the `workbox-strategies` package).","type":"object","properties":{"handle":{"$ref":"#/definitions/RouteHandlerCallback"}},"additionalProperties":false},"QueueOptions":{"type":"object","properties":{"onSync":{"$ref":"#/definitions/OnSyncCallback"},"maxRetentionTime":{"type":"number"}},"additionalProperties":false},"OnSyncCallback":{"type":"object","additionalProperties":false},"BroadcastCacheUpdateOptions":{"type":"object","properties":{"headersToCheck":{"type":"array","items":{"type":"string"}},"generatePayload":{"type":"object","additionalProperties":false}},"additionalProperties":false},"CacheableResponseOptions":{"type":"object","properties":{"statuses":{"type":"array","items":{"type":"number"}},"headers":{"type":"object","additionalProperties":{"type":"string"}}},"additionalProperties":false},"ExpirationPluginOptions":{"type":"object","properties":{"maxEntries":{"type":"number"},"maxAgeSeconds":{"type":"number"},"matchOptions":{"$ref":"#/definitions/CacheQueryOptions"},"purgeOnQuotaError":{"type":"boolean"}},"additionalProperties":false},"CacheQueryOptions":{"type":"object","properties":{"ignoreMethod":{"type":"boolean"},"ignoreSearch":{"type":"boolean"},"ignoreVary":{"type":"boolean"}},"additionalProperties":false},"WorkboxPlugin":{"description":"An object with optional lifecycle callback properties for the fetch and\ncache operations.","type":"object","properties":{"cacheDidUpdate":{"$ref":"#/definitions/CacheDidUpdateCallback"},"cachedResponseWillBeUsed":{"$ref":"#/definitions/CachedResponseWillBeUsedCallback"},"cacheKeyWillBeUsed":{"$ref":"#/definitions/CacheKeyWillBeUsedCallback"},"cacheWillUpdate":{"$ref":"#/definitions/CacheWillUpdateCallback"},"fetchDidFail":{"$ref":"#/definitions/FetchDidFailCallback"},"fetchDidSucceed":{"$ref":"#/definitions/FetchDidSucceedCallback"},"handlerDidComplete":{"$ref":"#/definitions/HandlerDidCompleteCallback"},"handlerDidError":{"$ref":"#/definitions/HandlerDidErrorCallback"},"handlerDidRespond":{"$ref":"#/definitions/HandlerDidRespondCallback"},"handlerWillRespond":{"$ref":"#/definitions/HandlerWillRespondCallback"},"handlerWillStart":{"$ref":"#/definitions/HandlerWillStartCallback"},"requestWillFetch":{"$ref":"#/definitions/RequestWillFetchCallback"}},"additionalProperties":false},"CacheDidUpdateCallback":{"type":"object","additionalProperties":false},"CachedResponseWillBeUsedCallback":{"type":"object","additionalProperties":false},"CacheKeyWillBeUsedCallback":{"type":"object","additionalProperties":false},"CacheWillUpdateCallback":{"type":"object","additionalProperties":false},"FetchDidFailCallback":{"type":"object","additionalProperties":false},"FetchDidSucceedCallback":{"type":"object","additionalProperties":false},"HandlerDidCompleteCallback":{"type":"object","additionalProperties":false},"HandlerDidErrorCallback":{"type":"object","additionalProperties":false},"HandlerDidRespondCallback":{"type":"object","additionalProperties":false},"HandlerWillRespondCallback":{"type":"object","additionalProperties":false},"HandlerWillStartCallback":{"type":"object","additionalProperties":false},"RequestWillFetchCallback":{"type":"object","additionalProperties":false},"RequestInit":{"type":"object","properties":{"body":{"anyOf":[{"$ref":"#/definitions/ArrayBuffer"},{"$ref":"#/definitions/ArrayBufferView"},{"$ref":"#/definitions/Blob"},{"$ref":"#/definitions/FormData"},{"$ref":"#/definitions/URLSearchParams"},{"$ref":"#/definitions/ReadableStream"},{"type":["null","string"]}]},"cache":{"enum":["default","force-cache","no-cache","no-store","only-if-cached","reload"],"type":"string"},"credentials":{"enum":["include","omit","same-origin"],"type":"string"},"headers":{"anyOf":[{"$ref":"#/definitions/Headers"},{"type":"array","items":{"type":"array","items":{"type":"string"}}},{"$ref":"#/definitions/Record"}]},"integrity":{"type":"string"},"keepalive":{"type":"boolean"},"method":{"type":"string"},"mode":{"enum":["cors","navigate","no-cors","same-origin"],"type":"string"},"redirect":{"enum":["error","follow","manual"],"type":"string"},"referrer":{"type":"string"},"referrerPolicy":{"enum":["","no-referrer","no-referrer-when-downgrade","origin","origin-when-cross-origin","same-origin","strict-origin","strict-origin-when-cross-origin","unsafe-url"],"type":"string"},"signal":{"anyOf":[{"$ref":"#/definitions/AbortSignal"},{"type":"null"}]},"window":{}},"additionalProperties":false},"ArrayBuffer":{"type":"object","properties":{"byteLength":{"type":"number"},"__@toStringTag":{"type":"string"}},"additionalProperties":false},"ArrayBufferView":{"type":"object","properties":{"buffer":{"anyOf":[{"$ref":"#/definitions/ArrayBuffer"},{"$ref":"#/definitions/SharedArrayBuffer"}]},"byteLength":{"type":"number"},"byteOffset":{"type":"number"}},"additionalProperties":false},"SharedArrayBuffer":{"type":"object","properties":{"byteLength":{"type":"number"},"__@species":{"$ref":"#/definitions/SharedArrayBuffer"},"__@toStringTag":{"type":"string","enum":["SharedArrayBuffer"]}},"additionalProperties":false},"Blob":{"type":"object","properties":{"size":{"type":"number"},"type":{"type":"string"}},"additionalProperties":false},"FormData":{"type":"object","additionalProperties":false},"URLSearchParams":{"type":"object","additionalProperties":false},"ReadableStream":{"type":"object","properties":{"locked":{"type":"boolean"}},"additionalProperties":false},"Headers":{"type":"object","additionalProperties":false},"Record":{"type":"object","additionalProperties":false},"AbortSignal":{"type":"object","properties":{"aborted":{"type":"boolean"},"onabort":{"anyOf":[{"type":"object","additionalProperties":false},{"type":"null"}]}},"additionalProperties":false},"RouteMatchCallback":{"description":"The \"match\" callback is used to determine if a `Route` should apply for a\nparticular URL and request. When matching occurs in response to a fetch\nevent from the client, the `event` object is also supplied. However, since\nthe match callback can be invoked outside of a fetch event, matching logic\nshould not assume the `event` object will always be available.\nIf the match callback returns a truthy value, the matching route's\n`RouteHandlerCallback` will be invoked immediately. If the value returned\nis a non-empty array or object, that value will be set on the handler's\n`options.params` argument.","type":"object","additionalProperties":false},"ManifestEntry":{"type":"object","properties":{"integrity":{"type":"string"},"revision":{"type":["null","string"]},"url":{"type":"string"}},"additionalProperties":false}},"$schema":"http://json-schema.org/draft-07/schema#"} +{"additionalProperties":false,"type":"object","properties":{"chunks":{"type":"array","items":{"type":"string"}},"exclude":{"default":"[/\\.map$/, /^manifest.*\\.js$/,]","type":"array","items":{"anyOf":[{"$ref":"#/definitions/RegExp"},{"type":"object","additionalProperties":false},{"type":"string"}]}},"excludeChunks":{"type":"array","items":{"type":"string"}},"include":{"type":"array","items":{"anyOf":[{"$ref":"#/definitions/RegExp"},{"type":"object","additionalProperties":false},{"type":"string"}]}},"mode":{"default":"production","type":["null","string"]},"babelPresetEnvTargets":{"default":["chrome >= 56"],"type":"array","items":{"type":"string"}},"cacheId":{"type":["null","string"]},"cleanupOutdatedCaches":{"default":false,"type":"boolean"},"clientsClaim":{"default":false,"type":"boolean"},"directoryIndex":{"type":["null","string"]},"disableDevLogs":{"default":false,"type":"boolean"},"ignoreURLParametersMatching":{"type":"array","items":{"$ref":"#/definitions/RegExp"}},"importScripts":{"type":"array","items":{"type":"string"}},"inlineWorkboxRuntime":{"default":false,"type":"boolean"},"navigateFallback":{"default":null,"type":["null","string"]},"navigateFallbackAllowlist":{"type":"array","items":{"$ref":"#/definitions/RegExp"}},"navigateFallbackDenylist":{"type":"array","items":{"$ref":"#/definitions/RegExp"}},"navigationPreload":{"default":false,"type":"boolean"},"offlineGoogleAnalytics":{"default":false,"anyOf":[{"$ref":"#/definitions/GoogleAnalyticsInitializeOptions"},{"type":"boolean"}]},"runtimeCaching":{"type":"array","items":{"$ref":"#/definitions/RuntimeCaching"}},"skipWaiting":{"default":false,"type":"boolean"},"sourcemap":{"default":true,"type":"boolean"},"additionalManifestEntries":{"type":"array","items":{"anyOf":[{"$ref":"#/definitions/ManifestEntry"},{"type":"string"}]}},"dontCacheBustURLsMatching":{"$ref":"#/definitions/RegExp"},"manifestTransforms":{"type":"array","items":{"type":"object","additionalProperties":false}},"maximumFileSizeToCacheInBytes":{"default":2097152,"type":"number"},"modifyURLPrefix":{"type":"object","additionalProperties":{"type":"string"}},"swDest":{"default":"service-worker.js","type":"string"},"importScriptsViaChunks":{"type":"array","items":{"type":"string"}}},"definitions":{"RegExp":{"type":"object","properties":{"source":{"type":"string"},"global":{"type":"boolean"},"ignoreCase":{"type":"boolean"},"multiline":{"type":"boolean"},"lastIndex":{"type":"number"},"flags":{"type":"string"},"sticky":{"type":"boolean"},"unicode":{"type":"boolean"},"dotAll":{"type":"boolean"}},"additionalProperties":false},"GoogleAnalyticsInitializeOptions":{"type":"object","properties":{"cacheName":{"type":"string"},"parameterOverrides":{"type":"object","additionalProperties":{"type":"string"}},"hitFilter":{"type":"object","additionalProperties":false}},"additionalProperties":false},"RuntimeCaching":{"type":"object","properties":{"handler":{"anyOf":[{"$ref":"#/definitions/RouteHandlerCallback"},{"$ref":"#/definitions/RouteHandlerObject"},{"enum":["CacheFirst","CacheOnly","NetworkFirst","NetworkOnly","StaleWhileRevalidate"],"type":"string"}]},"method":{"enum":["DELETE","GET","HEAD","PATCH","POST","PUT"],"type":"string"},"options":{"type":"object","properties":{"backgroundSync":{"type":"object","properties":{"name":{"type":"string"},"options":{"$ref":"#/definitions/QueueOptions"}},"additionalProperties":false},"broadcastUpdate":{"type":"object","properties":{"channelName":{"type":"string"},"options":{"$ref":"#/definitions/BroadcastCacheUpdateOptions"}},"additionalProperties":false},"cacheableResponse":{"$ref":"#/definitions/CacheableResponseOptions"},"cacheName":{"type":["null","string"]},"expiration":{"$ref":"#/definitions/ExpirationPluginOptions"},"networkTimeoutSeconds":{"type":"number"},"plugins":{"type":"array","items":{"$ref":"#/definitions/WorkboxPlugin"}},"precacheFallback":{"type":"object","properties":{"fallbackURL":{"type":"string"}},"additionalProperties":false},"fetchOptions":{"$ref":"#/definitions/RequestInit"},"matchOptions":{"$ref":"#/definitions/CacheQueryOptions"}},"additionalProperties":false},"urlPattern":{"anyOf":[{"$ref":"#/definitions/RegExp"},{"$ref":"#/definitions/RouteMatchCallback"},{"type":"string"}]}},"additionalProperties":false},"RouteHandlerCallback":{"description":"The \"handler\" callback is invoked whenever a `Router` matches a URL/Request\nto a `Route` via its `RouteMatchCallback`. This handler callback should\nreturn a `Promise` that resolves with a `Response`.\n\nIf a non-empty array or object is returned by the `RouteMatchCallback` it\nwill be passed in as this handler's `options.params` argument.","type":"object","additionalProperties":false},"RouteHandlerObject":{"description":"An object with a `handle` method of type `RouteHandlerCallback`.\n\nA `Route` object can be created with either an `RouteHandlerCallback`\nfunction or this `RouteHandler` object. The benefit of the `RouteHandler`\nis it can be extended (as is done by the `workbox-strategies` package).","type":"object","properties":{"handle":{"$ref":"#/definitions/RouteHandlerCallback"}},"additionalProperties":false},"QueueOptions":{"type":"object","properties":{"onSync":{"$ref":"#/definitions/OnSyncCallback"},"maxRetentionTime":{"type":"number"}},"additionalProperties":false},"OnSyncCallback":{"type":"object","additionalProperties":false},"BroadcastCacheUpdateOptions":{"type":"object","properties":{"headersToCheck":{"type":"array","items":{"type":"string"}},"generatePayload":{"type":"object","additionalProperties":false}},"additionalProperties":false},"CacheableResponseOptions":{"type":"object","properties":{"statuses":{"type":"array","items":{"type":"number"}},"headers":{"type":"object","additionalProperties":{"type":"string"}}},"additionalProperties":false},"ExpirationPluginOptions":{"type":"object","properties":{"maxEntries":{"type":"number"},"maxAgeSeconds":{"type":"number"},"matchOptions":{"$ref":"#/definitions/CacheQueryOptions"},"purgeOnQuotaError":{"type":"boolean"}},"additionalProperties":false},"CacheQueryOptions":{"type":"object","properties":{"ignoreMethod":{"type":"boolean"},"ignoreSearch":{"type":"boolean"},"ignoreVary":{"type":"boolean"}},"additionalProperties":false},"WorkboxPlugin":{"description":"An object with optional lifecycle callback properties for the fetch and\ncache operations.","type":"object","properties":{"cacheDidUpdate":{"$ref":"#/definitions/CacheDidUpdateCallback"},"cachedResponseWillBeUsed":{"$ref":"#/definitions/CachedResponseWillBeUsedCallback"},"cacheKeyWillBeUsed":{"$ref":"#/definitions/CacheKeyWillBeUsedCallback"},"cacheWillUpdate":{"$ref":"#/definitions/CacheWillUpdateCallback"},"fetchDidFail":{"$ref":"#/definitions/FetchDidFailCallback"},"fetchDidSucceed":{"$ref":"#/definitions/FetchDidSucceedCallback"},"handlerDidComplete":{"$ref":"#/definitions/HandlerDidCompleteCallback"},"handlerDidError":{"$ref":"#/definitions/HandlerDidErrorCallback"},"handlerDidRespond":{"$ref":"#/definitions/HandlerDidRespondCallback"},"handlerWillRespond":{"$ref":"#/definitions/HandlerWillRespondCallback"},"handlerWillStart":{"$ref":"#/definitions/HandlerWillStartCallback"},"requestWillFetch":{"$ref":"#/definitions/RequestWillFetchCallback"}},"additionalProperties":false},"CacheDidUpdateCallback":{"type":"object","additionalProperties":false},"CachedResponseWillBeUsedCallback":{"type":"object","additionalProperties":false},"CacheKeyWillBeUsedCallback":{"type":"object","additionalProperties":false},"CacheWillUpdateCallback":{"type":"object","additionalProperties":false},"FetchDidFailCallback":{"type":"object","additionalProperties":false},"FetchDidSucceedCallback":{"type":"object","additionalProperties":false},"HandlerDidCompleteCallback":{"type":"object","additionalProperties":false},"HandlerDidErrorCallback":{"type":"object","additionalProperties":false},"HandlerDidRespondCallback":{"type":"object","additionalProperties":false},"HandlerWillRespondCallback":{"type":"object","additionalProperties":false},"HandlerWillStartCallback":{"type":"object","additionalProperties":false},"RequestWillFetchCallback":{"type":"object","additionalProperties":false},"RequestInit":{"type":"object","properties":{"body":{"anyOf":[{"$ref":"#/definitions/ArrayBuffer"},{"$ref":"#/definitions/ArrayBufferView"},{"$ref":"#/definitions/Blob"},{"$ref":"#/definitions/FormData"},{"$ref":"#/definitions/URLSearchParams"},{"$ref":"#/definitions/ReadableStream"},{"type":["null","string"]}]},"cache":{"enum":["default","force-cache","no-cache","no-store","only-if-cached","reload"],"type":"string"},"credentials":{"enum":["include","omit","same-origin"],"type":"string"},"headers":{"anyOf":[{"$ref":"#/definitions/Headers"},{"type":"array","items":{"type":"array","items":{"type":"string"}}},{"$ref":"#/definitions/Record"}]},"integrity":{"type":"string"},"keepalive":{"type":"boolean"},"method":{"type":"string"},"mode":{"enum":["cors","navigate","no-cors","same-origin"],"type":"string"},"redirect":{"enum":["error","follow","manual"],"type":"string"},"referrer":{"type":"string"},"referrerPolicy":{"enum":["","no-referrer","no-referrer-when-downgrade","origin","origin-when-cross-origin","same-origin","strict-origin","strict-origin-when-cross-origin","unsafe-url"],"type":"string"},"signal":{"anyOf":[{"$ref":"#/definitions/AbortSignal"},{"type":"null"}]},"window":{}},"additionalProperties":false},"ArrayBuffer":{"type":"object","properties":{"byteLength":{"type":"number"},"__@toStringTag":{"type":"string"}},"additionalProperties":false},"ArrayBufferView":{"type":"object","properties":{"buffer":{"anyOf":[{"$ref":"#/definitions/ArrayBuffer"},{"$ref":"#/definitions/SharedArrayBuffer"}]},"byteLength":{"type":"number"},"byteOffset":{"type":"number"}},"additionalProperties":false},"SharedArrayBuffer":{"type":"object","properties":{"byteLength":{"type":"number"},"__@species":{"$ref":"#/definitions/SharedArrayBuffer"},"__@toStringTag":{"type":"string","enum":["SharedArrayBuffer"]}},"additionalProperties":false},"Blob":{"type":"object","properties":{"size":{"type":"number"},"type":{"type":"string"}},"additionalProperties":false},"FormData":{"type":"object","additionalProperties":false},"URLSearchParams":{"type":"object","additionalProperties":false},"ReadableStream":{"type":"object","properties":{"locked":{"type":"boolean"}},"additionalProperties":false},"Headers":{"type":"object","additionalProperties":false},"Record":{"type":"object","additionalProperties":false},"AbortSignal":{"type":"object","properties":{"aborted":{"type":"boolean"},"onabort":{"anyOf":[{"type":"object","additionalProperties":false},{"type":"null"}]}},"additionalProperties":false},"RouteMatchCallback":{"description":"The \"match\" callback is used to determine if a `Route` should apply for a\nparticular URL and request. When matching occurs in response to a fetch\nevent from the client, the `event` object is also supplied. However, since\nthe match callback can be invoked outside of a fetch event, matching logic\nshould not assume the `event` object will always be available.\nIf the match callback returns a truthy value, the matching route's\n`RouteHandlerCallback` will be invoked immediately. If the value returned\nis a non-empty array or object, that value will be set on the handler's\n`options.params` argument.","type":"object","additionalProperties":false},"ManifestEntry":{"type":"object","properties":{"integrity":{"type":"string"},"revision":{"type":["null","string"]},"url":{"type":"string"}},"additionalProperties":false}},"$schema":"http://json-schema.org/draft-07/schema#"} diff --git a/packages/workbox-build/src/schema/WebpackInjectManifestOptions.json b/packages/workbox-build/src/schema/WebpackInjectManifestOptions.json index 6e0475ca1..1b8cff05e 100644 --- a/packages/workbox-build/src/schema/WebpackInjectManifestOptions.json +++ b/packages/workbox-build/src/schema/WebpackInjectManifestOptions.json @@ -1 +1 @@ -{"additionalProperties":false,"type":"object","properties":{"chunks":{"type":"array","items":{"type":"string"}},"exclude":{"default":"[/\\.map$/, /^manifest.*\\.js$/,]","type":"array","items":{"anyOf":[{"$ref":"#/definitions/RegExp"},{"type":"object","additionalProperties":false},{"type":"string"}]}},"excludeChunks":{"type":"array","items":{"type":"string"}},"include":{"type":"array","items":{"anyOf":[{"$ref":"#/definitions/RegExp"},{"type":"object","additionalProperties":false},{"type":"string"}]}},"mode":{"type":["null","string"]},"injectionPoint":{"default":"'self.__WB_MANIFEST'","type":"string"},"swSrc":{"type":"string"},"additionalManifestEntries":{"type":"array","items":{"anyOf":[{"$ref":"#/definitions/ManifestEntry"},{"type":"string"}]}},"dontCacheBustURLsMatching":{"$ref":"#/definitions/RegExp"},"manifestTransforms":{"type":"array","items":{"type":"object","additionalProperties":false}},"maximumFileSizeToCacheInBytes":{"default":2097152,"type":"number"},"modifyURLPrefix":{"type":"object","additionalProperties":{"type":"string"}},"swDest":{"default":"'service-worker.js'","type":"string"},"compileSrc":{"default":true,"type":"boolean"},"webpackCompilationPlugins":{"type":"array","items":{}}},"definitions":{"RegExp":{"type":"object","properties":{"source":{"type":"string"},"global":{"type":"boolean"},"ignoreCase":{"type":"boolean"},"multiline":{"type":"boolean"},"lastIndex":{"type":"number"},"flags":{"type":"string"},"sticky":{"type":"boolean"},"unicode":{"type":"boolean"},"dotAll":{"type":"boolean"}},"additionalProperties":false},"GoogleAnalyticsInitializeOptions":{"type":"object","properties":{"cacheName":{"type":"string"},"parameterOverrides":{"type":"object","additionalProperties":{"type":"string"}},"hitFilter":{"type":"object","additionalProperties":false}},"additionalProperties":false},"RuntimeCaching":{"type":"object","properties":{"handler":{"anyOf":[{"$ref":"#/definitions/RouteHandlerCallback"},{"$ref":"#/definitions/RouteHandlerObject"},{"enum":["CacheFirst","CacheOnly","NetworkFirst","NetworkOnly","StaleWhileRevalidate"],"type":"string"}]},"method":{"enum":["DELETE","GET","HEAD","PATCH","POST","PUT"],"type":"string"},"options":{"type":"object","properties":{"backgroundSync":{"type":"object","properties":{"name":{"type":"string"},"options":{"$ref":"#/definitions/QueueOptions"}},"additionalProperties":false},"broadcastUpdate":{"type":"object","properties":{"channelName":{"type":"string"},"options":{"$ref":"#/definitions/BroadcastCacheUpdateOptions"}},"additionalProperties":false},"cacheableResponse":{"$ref":"#/definitions/CacheableResponseOptions"},"cacheName":{"type":["null","string"]},"expiration":{"$ref":"#/definitions/ExpirationPluginOptions"},"networkTimeoutSeconds":{"type":"number"},"plugins":{"type":"array","items":{"$ref":"#/definitions/WorkboxPlugin"}},"precacheFallback":{"type":"object","properties":{"fallbackURL":{"type":"string"}},"additionalProperties":false},"fetchOptions":{"$ref":"#/definitions/RequestInit"},"matchOptions":{"$ref":"#/definitions/CacheQueryOptions"}},"additionalProperties":false},"urlPattern":{"anyOf":[{"$ref":"#/definitions/RegExp"},{"$ref":"#/definitions/RouteMatchCallback"},{"type":"string"}]}},"additionalProperties":false},"RouteHandlerCallback":{"description":"The \"handler\" callback is invoked whenever a `Router` matches a URL/Request\nto a `Route` via its `RouteMatchCallback`. This handler callback should\nreturn a `Promise` that resolves with a `Response`.\n\nIf a non-empty array or object is returned by the `RouteMatchCallback` it\nwill be passed in as this handler's `options.params` argument.","type":"object","additionalProperties":false},"RouteHandlerObject":{"description":"An object with a `handle` method of type `RouteHandlerCallback`.\n\nA `Route` object can be created with either an `RouteHandlerCallback`\nfunction or this `RouteHandler` object. The benefit of the `RouteHandler`\nis it can be extended (as is done by the `workbox-strategies` package).","type":"object","properties":{"handle":{"$ref":"#/definitions/RouteHandlerCallback"}},"additionalProperties":false},"QueueOptions":{"type":"object","properties":{"onSync":{"$ref":"#/definitions/OnSyncCallback"},"maxRetentionTime":{"type":"number"}},"additionalProperties":false},"OnSyncCallback":{"type":"object","additionalProperties":false},"BroadcastCacheUpdateOptions":{"type":"object","properties":{"headersToCheck":{"type":"array","items":{"type":"string"}},"generatePayload":{"type":"object","additionalProperties":false}},"additionalProperties":false},"CacheableResponseOptions":{"type":"object","properties":{"statuses":{"type":"array","items":{"type":"number"}},"headers":{"type":"object","additionalProperties":{"type":"string"}}},"additionalProperties":false},"ExpirationPluginOptions":{"type":"object","properties":{"maxEntries":{"type":"number"},"maxAgeSeconds":{"type":"number"},"matchOptions":{"$ref":"#/definitions/CacheQueryOptions"},"purgeOnQuotaError":{"type":"boolean"}},"additionalProperties":false},"CacheQueryOptions":{"type":"object","properties":{"ignoreMethod":{"type":"boolean"},"ignoreSearch":{"type":"boolean"},"ignoreVary":{"type":"boolean"}},"additionalProperties":false},"WorkboxPlugin":{"description":"An object with optional lifecycle callback properties for the fetch and\ncache operations.","type":"object","properties":{"cacheDidUpdate":{"$ref":"#/definitions/CacheDidUpdateCallback"},"cachedResponseWillBeUsed":{"$ref":"#/definitions/CachedResponseWillBeUsedCallback"},"cacheKeyWillBeUsed":{"$ref":"#/definitions/CacheKeyWillBeUsedCallback"},"cacheWillUpdate":{"$ref":"#/definitions/CacheWillUpdateCallback"},"fetchDidFail":{"$ref":"#/definitions/FetchDidFailCallback"},"fetchDidSucceed":{"$ref":"#/definitions/FetchDidSucceedCallback"},"handlerDidComplete":{"$ref":"#/definitions/HandlerDidCompleteCallback"},"handlerDidError":{"$ref":"#/definitions/HandlerDidErrorCallback"},"handlerDidRespond":{"$ref":"#/definitions/HandlerDidRespondCallback"},"handlerWillRespond":{"$ref":"#/definitions/HandlerWillRespondCallback"},"handlerWillStart":{"$ref":"#/definitions/HandlerWillStartCallback"},"requestWillFetch":{"$ref":"#/definitions/RequestWillFetchCallback"}},"additionalProperties":false},"CacheDidUpdateCallback":{"type":"object","additionalProperties":false},"CachedResponseWillBeUsedCallback":{"type":"object","additionalProperties":false},"CacheKeyWillBeUsedCallback":{"type":"object","additionalProperties":false},"CacheWillUpdateCallback":{"type":"object","additionalProperties":false},"FetchDidFailCallback":{"type":"object","additionalProperties":false},"FetchDidSucceedCallback":{"type":"object","additionalProperties":false},"HandlerDidCompleteCallback":{"type":"object","additionalProperties":false},"HandlerDidErrorCallback":{"type":"object","additionalProperties":false},"HandlerDidRespondCallback":{"type":"object","additionalProperties":false},"HandlerWillRespondCallback":{"type":"object","additionalProperties":false},"HandlerWillStartCallback":{"type":"object","additionalProperties":false},"RequestWillFetchCallback":{"type":"object","additionalProperties":false},"RequestInit":{"type":"object","properties":{"body":{"anyOf":[{"$ref":"#/definitions/ArrayBuffer"},{"$ref":"#/definitions/ArrayBufferView"},{"$ref":"#/definitions/Blob"},{"$ref":"#/definitions/FormData"},{"$ref":"#/definitions/URLSearchParams"},{"$ref":"#/definitions/ReadableStream"},{"type":["null","string"]}]},"cache":{"enum":["default","force-cache","no-cache","no-store","only-if-cached","reload"],"type":"string"},"credentials":{"enum":["include","omit","same-origin"],"type":"string"},"headers":{"anyOf":[{"$ref":"#/definitions/Headers"},{"type":"array","items":{"type":"array","items":{"type":"string"}}},{"$ref":"#/definitions/Record"}]},"integrity":{"type":"string"},"keepalive":{"type":"boolean"},"method":{"type":"string"},"mode":{"enum":["cors","navigate","no-cors","same-origin"],"type":"string"},"redirect":{"enum":["error","follow","manual"],"type":"string"},"referrer":{"type":"string"},"referrerPolicy":{"enum":["","no-referrer","no-referrer-when-downgrade","origin","origin-when-cross-origin","same-origin","strict-origin","strict-origin-when-cross-origin","unsafe-url"],"type":"string"},"signal":{"anyOf":[{"$ref":"#/definitions/AbortSignal"},{"type":"null"}]},"window":{}},"additionalProperties":false},"ArrayBuffer":{"type":"object","properties":{"byteLength":{"type":"number"},"__@toStringTag":{"type":"string"}},"additionalProperties":false},"ArrayBufferView":{"type":"object","properties":{"buffer":{"anyOf":[{"$ref":"#/definitions/ArrayBuffer"},{"$ref":"#/definitions/SharedArrayBuffer"}]},"byteLength":{"type":"number"},"byteOffset":{"type":"number"}},"additionalProperties":false},"SharedArrayBuffer":{"type":"object","properties":{"byteLength":{"type":"number"},"__@species":{"$ref":"#/definitions/SharedArrayBuffer"},"__@toStringTag":{"type":"string","enum":["SharedArrayBuffer"]}},"additionalProperties":false},"Blob":{"type":"object","properties":{"size":{"type":"number"},"type":{"type":"string"}},"additionalProperties":false},"FormData":{"type":"object","additionalProperties":false},"URLSearchParams":{"type":"object","additionalProperties":false},"ReadableStream":{"type":"object","properties":{"locked":{"type":"boolean"}},"additionalProperties":false},"Headers":{"type":"object","additionalProperties":false},"Record":{"type":"object","additionalProperties":false},"AbortSignal":{"type":"object","properties":{"aborted":{"type":"boolean"},"onabort":{"anyOf":[{"type":"object","additionalProperties":false},{"type":"null"}]}},"additionalProperties":false},"RouteMatchCallback":{"description":"The \"match\" callback is used to determine if a `Route` should apply for a\nparticular URL and request. When matching occurs in response to a fetch\nevent from the client, the `event` object is also supplied. However, since\nthe match callback can be invoked outside of a fetch event, matching logic\nshould not assume the `event` object will always be available.\nIf the match callback returns a truthy value, the matching route's\n`RouteHandlerCallback` will be invoked immediately. If the value returned\nis a non-empty array or object, that value will be set on the handler's\n`options.params` argument.","type":"object","additionalProperties":false},"ManifestEntry":{"type":"object","properties":{"integrity":{"type":"string"},"revision":{"type":["null","string"]},"url":{"type":"string"}},"additionalProperties":false}},"$schema":"http://json-schema.org/draft-07/schema#"} +{"additionalProperties":false,"type":"object","properties":{"chunks":{"type":"array","items":{"type":"string"}},"exclude":{"default":"[/\\.map$/, /^manifest.*\\.js$/,]","type":"array","items":{"anyOf":[{"$ref":"#/definitions/RegExp"},{"type":"object","additionalProperties":false},{"type":"string"}]}},"excludeChunks":{"type":"array","items":{"type":"string"}},"include":{"type":"array","items":{"anyOf":[{"$ref":"#/definitions/RegExp"},{"type":"object","additionalProperties":false},{"type":"string"}]}},"mode":{"type":["null","string"]},"injectionPoint":{"default":"self.__WB_MANIFEST","type":"string"},"swSrc":{"type":"string"},"additionalManifestEntries":{"type":"array","items":{"anyOf":[{"$ref":"#/definitions/ManifestEntry"},{"type":"string"}]}},"dontCacheBustURLsMatching":{"$ref":"#/definitions/RegExp"},"manifestTransforms":{"type":"array","items":{"type":"object","additionalProperties":false}},"maximumFileSizeToCacheInBytes":{"default":2097152,"type":"number"},"modifyURLPrefix":{"type":"object","additionalProperties":{"type":"string"}},"swDest":{"default":"service-worker.js","type":"string"},"compileSrc":{"default":true,"type":"boolean"},"webpackCompilationPlugins":{"type":"array","items":{}}},"definitions":{"RegExp":{"type":"object","properties":{"source":{"type":"string"},"global":{"type":"boolean"},"ignoreCase":{"type":"boolean"},"multiline":{"type":"boolean"},"lastIndex":{"type":"number"},"flags":{"type":"string"},"sticky":{"type":"boolean"},"unicode":{"type":"boolean"},"dotAll":{"type":"boolean"}},"additionalProperties":false},"GoogleAnalyticsInitializeOptions":{"type":"object","properties":{"cacheName":{"type":"string"},"parameterOverrides":{"type":"object","additionalProperties":{"type":"string"}},"hitFilter":{"type":"object","additionalProperties":false}},"additionalProperties":false},"RuntimeCaching":{"type":"object","properties":{"handler":{"anyOf":[{"$ref":"#/definitions/RouteHandlerCallback"},{"$ref":"#/definitions/RouteHandlerObject"},{"enum":["CacheFirst","CacheOnly","NetworkFirst","NetworkOnly","StaleWhileRevalidate"],"type":"string"}]},"method":{"enum":["DELETE","GET","HEAD","PATCH","POST","PUT"],"type":"string"},"options":{"type":"object","properties":{"backgroundSync":{"type":"object","properties":{"name":{"type":"string"},"options":{"$ref":"#/definitions/QueueOptions"}},"additionalProperties":false},"broadcastUpdate":{"type":"object","properties":{"channelName":{"type":"string"},"options":{"$ref":"#/definitions/BroadcastCacheUpdateOptions"}},"additionalProperties":false},"cacheableResponse":{"$ref":"#/definitions/CacheableResponseOptions"},"cacheName":{"type":["null","string"]},"expiration":{"$ref":"#/definitions/ExpirationPluginOptions"},"networkTimeoutSeconds":{"type":"number"},"plugins":{"type":"array","items":{"$ref":"#/definitions/WorkboxPlugin"}},"precacheFallback":{"type":"object","properties":{"fallbackURL":{"type":"string"}},"additionalProperties":false},"fetchOptions":{"$ref":"#/definitions/RequestInit"},"matchOptions":{"$ref":"#/definitions/CacheQueryOptions"}},"additionalProperties":false},"urlPattern":{"anyOf":[{"$ref":"#/definitions/RegExp"},{"$ref":"#/definitions/RouteMatchCallback"},{"type":"string"}]}},"additionalProperties":false},"RouteHandlerCallback":{"description":"The \"handler\" callback is invoked whenever a `Router` matches a URL/Request\nto a `Route` via its `RouteMatchCallback`. This handler callback should\nreturn a `Promise` that resolves with a `Response`.\n\nIf a non-empty array or object is returned by the `RouteMatchCallback` it\nwill be passed in as this handler's `options.params` argument.","type":"object","additionalProperties":false},"RouteHandlerObject":{"description":"An object with a `handle` method of type `RouteHandlerCallback`.\n\nA `Route` object can be created with either an `RouteHandlerCallback`\nfunction or this `RouteHandler` object. The benefit of the `RouteHandler`\nis it can be extended (as is done by the `workbox-strategies` package).","type":"object","properties":{"handle":{"$ref":"#/definitions/RouteHandlerCallback"}},"additionalProperties":false},"QueueOptions":{"type":"object","properties":{"onSync":{"$ref":"#/definitions/OnSyncCallback"},"maxRetentionTime":{"type":"number"}},"additionalProperties":false},"OnSyncCallback":{"type":"object","additionalProperties":false},"BroadcastCacheUpdateOptions":{"type":"object","properties":{"headersToCheck":{"type":"array","items":{"type":"string"}},"generatePayload":{"type":"object","additionalProperties":false}},"additionalProperties":false},"CacheableResponseOptions":{"type":"object","properties":{"statuses":{"type":"array","items":{"type":"number"}},"headers":{"type":"object","additionalProperties":{"type":"string"}}},"additionalProperties":false},"ExpirationPluginOptions":{"type":"object","properties":{"maxEntries":{"type":"number"},"maxAgeSeconds":{"type":"number"},"matchOptions":{"$ref":"#/definitions/CacheQueryOptions"},"purgeOnQuotaError":{"type":"boolean"}},"additionalProperties":false},"CacheQueryOptions":{"type":"object","properties":{"ignoreMethod":{"type":"boolean"},"ignoreSearch":{"type":"boolean"},"ignoreVary":{"type":"boolean"}},"additionalProperties":false},"WorkboxPlugin":{"description":"An object with optional lifecycle callback properties for the fetch and\ncache operations.","type":"object","properties":{"cacheDidUpdate":{"$ref":"#/definitions/CacheDidUpdateCallback"},"cachedResponseWillBeUsed":{"$ref":"#/definitions/CachedResponseWillBeUsedCallback"},"cacheKeyWillBeUsed":{"$ref":"#/definitions/CacheKeyWillBeUsedCallback"},"cacheWillUpdate":{"$ref":"#/definitions/CacheWillUpdateCallback"},"fetchDidFail":{"$ref":"#/definitions/FetchDidFailCallback"},"fetchDidSucceed":{"$ref":"#/definitions/FetchDidSucceedCallback"},"handlerDidComplete":{"$ref":"#/definitions/HandlerDidCompleteCallback"},"handlerDidError":{"$ref":"#/definitions/HandlerDidErrorCallback"},"handlerDidRespond":{"$ref":"#/definitions/HandlerDidRespondCallback"},"handlerWillRespond":{"$ref":"#/definitions/HandlerWillRespondCallback"},"handlerWillStart":{"$ref":"#/definitions/HandlerWillStartCallback"},"requestWillFetch":{"$ref":"#/definitions/RequestWillFetchCallback"}},"additionalProperties":false},"CacheDidUpdateCallback":{"type":"object","additionalProperties":false},"CachedResponseWillBeUsedCallback":{"type":"object","additionalProperties":false},"CacheKeyWillBeUsedCallback":{"type":"object","additionalProperties":false},"CacheWillUpdateCallback":{"type":"object","additionalProperties":false},"FetchDidFailCallback":{"type":"object","additionalProperties":false},"FetchDidSucceedCallback":{"type":"object","additionalProperties":false},"HandlerDidCompleteCallback":{"type":"object","additionalProperties":false},"HandlerDidErrorCallback":{"type":"object","additionalProperties":false},"HandlerDidRespondCallback":{"type":"object","additionalProperties":false},"HandlerWillRespondCallback":{"type":"object","additionalProperties":false},"HandlerWillStartCallback":{"type":"object","additionalProperties":false},"RequestWillFetchCallback":{"type":"object","additionalProperties":false},"RequestInit":{"type":"object","properties":{"body":{"anyOf":[{"$ref":"#/definitions/ArrayBuffer"},{"$ref":"#/definitions/ArrayBufferView"},{"$ref":"#/definitions/Blob"},{"$ref":"#/definitions/FormData"},{"$ref":"#/definitions/URLSearchParams"},{"$ref":"#/definitions/ReadableStream"},{"type":["null","string"]}]},"cache":{"enum":["default","force-cache","no-cache","no-store","only-if-cached","reload"],"type":"string"},"credentials":{"enum":["include","omit","same-origin"],"type":"string"},"headers":{"anyOf":[{"$ref":"#/definitions/Headers"},{"type":"array","items":{"type":"array","items":{"type":"string"}}},{"$ref":"#/definitions/Record"}]},"integrity":{"type":"string"},"keepalive":{"type":"boolean"},"method":{"type":"string"},"mode":{"enum":["cors","navigate","no-cors","same-origin"],"type":"string"},"redirect":{"enum":["error","follow","manual"],"type":"string"},"referrer":{"type":"string"},"referrerPolicy":{"enum":["","no-referrer","no-referrer-when-downgrade","origin","origin-when-cross-origin","same-origin","strict-origin","strict-origin-when-cross-origin","unsafe-url"],"type":"string"},"signal":{"anyOf":[{"$ref":"#/definitions/AbortSignal"},{"type":"null"}]},"window":{}},"additionalProperties":false},"ArrayBuffer":{"type":"object","properties":{"byteLength":{"type":"number"},"__@toStringTag":{"type":"string"}},"additionalProperties":false},"ArrayBufferView":{"type":"object","properties":{"buffer":{"anyOf":[{"$ref":"#/definitions/ArrayBuffer"},{"$ref":"#/definitions/SharedArrayBuffer"}]},"byteLength":{"type":"number"},"byteOffset":{"type":"number"}},"additionalProperties":false},"SharedArrayBuffer":{"type":"object","properties":{"byteLength":{"type":"number"},"__@species":{"$ref":"#/definitions/SharedArrayBuffer"},"__@toStringTag":{"type":"string","enum":["SharedArrayBuffer"]}},"additionalProperties":false},"Blob":{"type":"object","properties":{"size":{"type":"number"},"type":{"type":"string"}},"additionalProperties":false},"FormData":{"type":"object","additionalProperties":false},"URLSearchParams":{"type":"object","additionalProperties":false},"ReadableStream":{"type":"object","properties":{"locked":{"type":"boolean"}},"additionalProperties":false},"Headers":{"type":"object","additionalProperties":false},"Record":{"type":"object","additionalProperties":false},"AbortSignal":{"type":"object","properties":{"aborted":{"type":"boolean"},"onabort":{"anyOf":[{"type":"object","additionalProperties":false},{"type":"null"}]}},"additionalProperties":false},"RouteMatchCallback":{"description":"The \"match\" callback is used to determine if a `Route` should apply for a\nparticular URL and request. When matching occurs in response to a fetch\nevent from the client, the `event` object is also supplied. However, since\nthe match callback can be invoked outside of a fetch event, matching logic\nshould not assume the `event` object will always be available.\nIf the match callback returns a truthy value, the matching route's\n`RouteHandlerCallback` will be invoked immediately. If the value returned\nis a non-empty array or object, that value will be set on the handler's\n`options.params` argument.","type":"object","additionalProperties":false},"ManifestEntry":{"type":"object","properties":{"integrity":{"type":"string"},"revision":{"type":["null","string"]},"url":{"type":"string"}},"additionalProperties":false}},"$schema":"http://json-schema.org/draft-07/schema#"} diff --git a/packages/workbox-build/src/types.ts b/packages/workbox-build/src/types.ts index de0c953fe..bf9da9b0b 100644 --- a/packages/workbox-build/src/types.ts +++ b/packages/workbox-build/src/types.ts @@ -70,7 +70,7 @@ export interface BasePartial { export interface GeneratePartial { /** - * @default ['chrome >= 56'] + * @default ["chrome >= 56"] */ babelPresetEnvTargets?: Array; cacheId?: string | null; @@ -94,7 +94,7 @@ export interface GeneratePartial { */ inlineWorkboxRuntime?: boolean; /** - * @default 'production' + * @default "production" */ mode?: string | null; /** @@ -129,11 +129,11 @@ export interface GlobPartial { */ globFollow?: boolean; /** - * @default ['**\/node_modules\/**\/*'] + * @default ["**\/node_modules\/**\/*"] */ globIgnores?: Array; /** - * @default ['**\/*.{js,css,html}'] + * @default ["**\/*.{js,css,html}"] */ globPatterns?: Array; /** @@ -147,7 +147,7 @@ export interface GlobPartial { interface InjectPartial { /** - * @default 'self.__WB_MANIFEST' + * @default "self.__WB_MANIFEST" */ injectionPoint?: string; swSrc: string; @@ -166,7 +166,7 @@ interface WebpackPartial { export interface SWDestPartial { /** - * @default 'service-worker.js' + * @default "service-worker.js" */ swDest: string; } From ed5277537a323a2c48bfc8ac746f72161c6b7c68 Mon Sep 17 00:00:00 2001 From: Jeff Posnick Date: Wed, 9 Jun 2021 14:26:20 -0400 Subject: [PATCH 35/80] Cleanup optional types --- gulp-tasks/build-node-packages.js | 5 ++++- packages/workbox-build/src/lib/validate-options.ts | 14 ++++---------- .../src/schema/GenerateSWOptions.json | 2 +- .../src/schema/GetManifestOptions.json | 2 +- .../src/schema/InjectManifestOptions.json | 2 +- .../src/schema/WebpackGenerateSWOptions.json | 2 +- .../src/schema/WebpackInjectManifestOptions.json | 2 +- packages/workbox-build/src/types.ts | 8 ++++---- 8 files changed, 17 insertions(+), 20 deletions(-) diff --git a/gulp-tasks/build-node-packages.js b/gulp-tasks/build-node-packages.js index 4022898b3..a68a4378b 100644 --- a/gulp-tasks/build-node-packages.js +++ b/gulp-tasks/build-node-packages.js @@ -33,7 +33,10 @@ async function buildNodePackage(packagePath) { async function generateWorkboxBuildJSONSchema(packagePath) { const program = TJS.programFromConfig(upath.join(packagePath, 'tsconfig.json')); - const generator = TJS.buildGenerator(program, {noExtraProps: true}); + const generator = TJS.buildGenerator(program, { + noExtraProps: true, + required: true, + }); const optionTypes = [ 'GenerateSWOptions', 'GetManifestOptions', diff --git a/packages/workbox-build/src/lib/validate-options.ts b/packages/workbox-build/src/lib/validate-options.ts index 29507fb33..f89957ca8 100644 --- a/packages/workbox-build/src/lib/validate-options.ts +++ b/packages/workbox-build/src/lib/validate-options.ts @@ -20,11 +20,8 @@ export function validateGenerateSWOptions(input: unknown): GenerateSWOptions { return input; } - const errorStrings = []; - for (const err of validate.errors as DefinedError[]) { - errorStrings.push(err.message); - } - throw new Error(`Incorrect generateSW options:\n\t${errorStrings.join('\n\t')}`); + const errors = validate.errors as DefinedError[]; + throw new Error(JSON.stringify(errors)); } export function validateGetManifestOptions(input: unknown): GetManifestOptions { @@ -47,9 +44,6 @@ export function validateInjectManifestOptions(input: unknown): InjectManifestOpt return input; } - const errorStrings = []; - for (const err of validate.errors as DefinedError[]) { - errorStrings.push(err.message); - } - throw new Error(`Incorrect injectManifestOptions options:\n\t${errorStrings.join('\n\t')}`); + const errors = validate.errors as DefinedError[]; + throw new Error(JSON.stringify(errors)); } diff --git a/packages/workbox-build/src/schema/GenerateSWOptions.json b/packages/workbox-build/src/schema/GenerateSWOptions.json index d8a323c7d..9f2d0057e 100644 --- a/packages/workbox-build/src/schema/GenerateSWOptions.json +++ b/packages/workbox-build/src/schema/GenerateSWOptions.json @@ -1 +1 @@ -{"additionalProperties":false,"type":"object","properties":{"globDirectory":{"type":["null","string"]},"globFollow":{"default":true,"type":"boolean"},"globIgnores":{"default":["**/node_modules/**/*"],"type":"array","items":{"type":"string"}},"globPatterns":{"default":["**/*.{js,css,html}"],"type":"array","items":{"type":"string"}},"globStrict":{"default":true,"type":"boolean"},"templatedURLs":{"type":"object","additionalProperties":{"anyOf":[{"type":"array","items":{"type":"string"}},{"type":"string"}]}},"babelPresetEnvTargets":{"default":["chrome >= 56"],"type":"array","items":{"type":"string"}},"cacheId":{"type":["null","string"]},"cleanupOutdatedCaches":{"default":false,"type":"boolean"},"clientsClaim":{"default":false,"type":"boolean"},"directoryIndex":{"type":["null","string"]},"disableDevLogs":{"default":false,"type":"boolean"},"ignoreURLParametersMatching":{"type":"array","items":{"$ref":"#/definitions/RegExp"}},"importScripts":{"type":"array","items":{"type":"string"}},"inlineWorkboxRuntime":{"default":false,"type":"boolean"},"mode":{"default":"production","type":["null","string"]},"navigateFallback":{"default":null,"type":["null","string"]},"navigateFallbackAllowlist":{"type":"array","items":{"$ref":"#/definitions/RegExp"}},"navigateFallbackDenylist":{"type":"array","items":{"$ref":"#/definitions/RegExp"}},"navigationPreload":{"default":false,"type":"boolean"},"offlineGoogleAnalytics":{"default":false,"anyOf":[{"$ref":"#/definitions/GoogleAnalyticsInitializeOptions"},{"type":"boolean"}]},"runtimeCaching":{"type":"array","items":{"$ref":"#/definitions/RuntimeCaching"}},"skipWaiting":{"default":false,"type":"boolean"},"sourcemap":{"default":true,"type":"boolean"},"additionalManifestEntries":{"type":"array","items":{"anyOf":[{"$ref":"#/definitions/ManifestEntry"},{"type":"string"}]}},"dontCacheBustURLsMatching":{"$ref":"#/definitions/RegExp"},"manifestTransforms":{"type":"array","items":{"type":"object","additionalProperties":false}},"maximumFileSizeToCacheInBytes":{"default":2097152,"type":"number"},"modifyURLPrefix":{"type":"object","additionalProperties":{"type":"string"}},"swDest":{"default":"service-worker.js","type":"string"}},"definitions":{"RegExp":{"type":"object","properties":{"source":{"type":"string"},"global":{"type":"boolean"},"ignoreCase":{"type":"boolean"},"multiline":{"type":"boolean"},"lastIndex":{"type":"number"},"flags":{"type":"string"},"sticky":{"type":"boolean"},"unicode":{"type":"boolean"},"dotAll":{"type":"boolean"}},"additionalProperties":false},"GoogleAnalyticsInitializeOptions":{"type":"object","properties":{"cacheName":{"type":"string"},"parameterOverrides":{"type":"object","additionalProperties":{"type":"string"}},"hitFilter":{"type":"object","additionalProperties":false}},"additionalProperties":false},"RuntimeCaching":{"type":"object","properties":{"handler":{"anyOf":[{"$ref":"#/definitions/RouteHandlerCallback"},{"$ref":"#/definitions/RouteHandlerObject"},{"enum":["CacheFirst","CacheOnly","NetworkFirst","NetworkOnly","StaleWhileRevalidate"],"type":"string"}]},"method":{"enum":["DELETE","GET","HEAD","PATCH","POST","PUT"],"type":"string"},"options":{"type":"object","properties":{"backgroundSync":{"type":"object","properties":{"name":{"type":"string"},"options":{"$ref":"#/definitions/QueueOptions"}},"additionalProperties":false},"broadcastUpdate":{"type":"object","properties":{"channelName":{"type":"string"},"options":{"$ref":"#/definitions/BroadcastCacheUpdateOptions"}},"additionalProperties":false},"cacheableResponse":{"$ref":"#/definitions/CacheableResponseOptions"},"cacheName":{"type":["null","string"]},"expiration":{"$ref":"#/definitions/ExpirationPluginOptions"},"networkTimeoutSeconds":{"type":"number"},"plugins":{"type":"array","items":{"$ref":"#/definitions/WorkboxPlugin"}},"precacheFallback":{"type":"object","properties":{"fallbackURL":{"type":"string"}},"additionalProperties":false},"fetchOptions":{"$ref":"#/definitions/RequestInit"},"matchOptions":{"$ref":"#/definitions/CacheQueryOptions"}},"additionalProperties":false},"urlPattern":{"anyOf":[{"$ref":"#/definitions/RegExp"},{"$ref":"#/definitions/RouteMatchCallback"},{"type":"string"}]}},"additionalProperties":false},"RouteHandlerCallback":{"description":"The \"handler\" callback is invoked whenever a `Router` matches a URL/Request\nto a `Route` via its `RouteMatchCallback`. This handler callback should\nreturn a `Promise` that resolves with a `Response`.\n\nIf a non-empty array or object is returned by the `RouteMatchCallback` it\nwill be passed in as this handler's `options.params` argument.","type":"object","additionalProperties":false},"RouteHandlerObject":{"description":"An object with a `handle` method of type `RouteHandlerCallback`.\n\nA `Route` object can be created with either an `RouteHandlerCallback`\nfunction or this `RouteHandler` object. The benefit of the `RouteHandler`\nis it can be extended (as is done by the `workbox-strategies` package).","type":"object","properties":{"handle":{"$ref":"#/definitions/RouteHandlerCallback"}},"additionalProperties":false},"QueueOptions":{"type":"object","properties":{"onSync":{"$ref":"#/definitions/OnSyncCallback"},"maxRetentionTime":{"type":"number"}},"additionalProperties":false},"OnSyncCallback":{"type":"object","additionalProperties":false},"BroadcastCacheUpdateOptions":{"type":"object","properties":{"headersToCheck":{"type":"array","items":{"type":"string"}},"generatePayload":{"type":"object","additionalProperties":false}},"additionalProperties":false},"CacheableResponseOptions":{"type":"object","properties":{"statuses":{"type":"array","items":{"type":"number"}},"headers":{"type":"object","additionalProperties":{"type":"string"}}},"additionalProperties":false},"ExpirationPluginOptions":{"type":"object","properties":{"maxEntries":{"type":"number"},"maxAgeSeconds":{"type":"number"},"matchOptions":{"$ref":"#/definitions/CacheQueryOptions"},"purgeOnQuotaError":{"type":"boolean"}},"additionalProperties":false},"CacheQueryOptions":{"type":"object","properties":{"ignoreMethod":{"type":"boolean"},"ignoreSearch":{"type":"boolean"},"ignoreVary":{"type":"boolean"}},"additionalProperties":false},"WorkboxPlugin":{"description":"An object with optional lifecycle callback properties for the fetch and\ncache operations.","type":"object","properties":{"cacheDidUpdate":{"$ref":"#/definitions/CacheDidUpdateCallback"},"cachedResponseWillBeUsed":{"$ref":"#/definitions/CachedResponseWillBeUsedCallback"},"cacheKeyWillBeUsed":{"$ref":"#/definitions/CacheKeyWillBeUsedCallback"},"cacheWillUpdate":{"$ref":"#/definitions/CacheWillUpdateCallback"},"fetchDidFail":{"$ref":"#/definitions/FetchDidFailCallback"},"fetchDidSucceed":{"$ref":"#/definitions/FetchDidSucceedCallback"},"handlerDidComplete":{"$ref":"#/definitions/HandlerDidCompleteCallback"},"handlerDidError":{"$ref":"#/definitions/HandlerDidErrorCallback"},"handlerDidRespond":{"$ref":"#/definitions/HandlerDidRespondCallback"},"handlerWillRespond":{"$ref":"#/definitions/HandlerWillRespondCallback"},"handlerWillStart":{"$ref":"#/definitions/HandlerWillStartCallback"},"requestWillFetch":{"$ref":"#/definitions/RequestWillFetchCallback"}},"additionalProperties":false},"CacheDidUpdateCallback":{"type":"object","additionalProperties":false},"CachedResponseWillBeUsedCallback":{"type":"object","additionalProperties":false},"CacheKeyWillBeUsedCallback":{"type":"object","additionalProperties":false},"CacheWillUpdateCallback":{"type":"object","additionalProperties":false},"FetchDidFailCallback":{"type":"object","additionalProperties":false},"FetchDidSucceedCallback":{"type":"object","additionalProperties":false},"HandlerDidCompleteCallback":{"type":"object","additionalProperties":false},"HandlerDidErrorCallback":{"type":"object","additionalProperties":false},"HandlerDidRespondCallback":{"type":"object","additionalProperties":false},"HandlerWillRespondCallback":{"type":"object","additionalProperties":false},"HandlerWillStartCallback":{"type":"object","additionalProperties":false},"RequestWillFetchCallback":{"type":"object","additionalProperties":false},"RequestInit":{"type":"object","properties":{"body":{"anyOf":[{"$ref":"#/definitions/ArrayBuffer"},{"$ref":"#/definitions/ArrayBufferView"},{"$ref":"#/definitions/Blob"},{"$ref":"#/definitions/FormData"},{"$ref":"#/definitions/URLSearchParams"},{"$ref":"#/definitions/ReadableStream"},{"type":["null","string"]}]},"cache":{"enum":["default","force-cache","no-cache","no-store","only-if-cached","reload"],"type":"string"},"credentials":{"enum":["include","omit","same-origin"],"type":"string"},"headers":{"anyOf":[{"$ref":"#/definitions/Headers"},{"type":"array","items":{"type":"array","items":{"type":"string"}}},{"$ref":"#/definitions/Record"}]},"integrity":{"type":"string"},"keepalive":{"type":"boolean"},"method":{"type":"string"},"mode":{"enum":["cors","navigate","no-cors","same-origin"],"type":"string"},"redirect":{"enum":["error","follow","manual"],"type":"string"},"referrer":{"type":"string"},"referrerPolicy":{"enum":["","no-referrer","no-referrer-when-downgrade","origin","origin-when-cross-origin","same-origin","strict-origin","strict-origin-when-cross-origin","unsafe-url"],"type":"string"},"signal":{"anyOf":[{"$ref":"#/definitions/AbortSignal"},{"type":"null"}]},"window":{}},"additionalProperties":false},"ArrayBuffer":{"type":"object","properties":{"byteLength":{"type":"number"},"__@toStringTag":{"type":"string"}},"additionalProperties":false},"ArrayBufferView":{"type":"object","properties":{"buffer":{"anyOf":[{"$ref":"#/definitions/ArrayBuffer"},{"$ref":"#/definitions/SharedArrayBuffer"}]},"byteLength":{"type":"number"},"byteOffset":{"type":"number"}},"additionalProperties":false},"SharedArrayBuffer":{"type":"object","properties":{"byteLength":{"type":"number"},"__@species":{"$ref":"#/definitions/SharedArrayBuffer"},"__@toStringTag":{"type":"string","enum":["SharedArrayBuffer"]}},"additionalProperties":false},"Blob":{"type":"object","properties":{"size":{"type":"number"},"type":{"type":"string"}},"additionalProperties":false},"FormData":{"type":"object","additionalProperties":false},"URLSearchParams":{"type":"object","additionalProperties":false},"ReadableStream":{"type":"object","properties":{"locked":{"type":"boolean"}},"additionalProperties":false},"Headers":{"type":"object","additionalProperties":false},"Record":{"type":"object","additionalProperties":false},"AbortSignal":{"type":"object","properties":{"aborted":{"type":"boolean"},"onabort":{"anyOf":[{"type":"object","additionalProperties":false},{"type":"null"}]}},"additionalProperties":false},"RouteMatchCallback":{"description":"The \"match\" callback is used to determine if a `Route` should apply for a\nparticular URL and request. When matching occurs in response to a fetch\nevent from the client, the `event` object is also supplied. However, since\nthe match callback can be invoked outside of a fetch event, matching logic\nshould not assume the `event` object will always be available.\nIf the match callback returns a truthy value, the matching route's\n`RouteHandlerCallback` will be invoked immediately. If the value returned\nis a non-empty array or object, that value will be set on the handler's\n`options.params` argument.","type":"object","additionalProperties":false},"ManifestEntry":{"type":"object","properties":{"integrity":{"type":"string"},"revision":{"type":["null","string"]},"url":{"type":"string"}},"additionalProperties":false}},"$schema":"http://json-schema.org/draft-07/schema#"} +{"additionalProperties":false,"type":"object","properties":{"globDirectory":{"type":"string"},"globFollow":{"default":true,"type":"boolean"},"globIgnores":{"default":["**/node_modules/**/*"],"type":"array","items":{"type":"string"}},"globPatterns":{"default":["**/*.{js,css,html}"],"type":"array","items":{"type":"string"}},"globStrict":{"default":true,"type":"boolean"},"templatedURLs":{"type":"object","additionalProperties":{"anyOf":[{"type":"array","items":{"type":"string"}},{"type":"string"}]}},"babelPresetEnvTargets":{"default":["chrome >= 56"],"type":"array","items":{"type":"string"}},"cacheId":{"type":["null","string"]},"cleanupOutdatedCaches":{"default":false,"type":"boolean"},"clientsClaim":{"default":false,"type":"boolean"},"directoryIndex":{"type":["null","string"]},"disableDevLogs":{"default":false,"type":"boolean"},"ignoreURLParametersMatching":{"type":"array","items":{"$ref":"#/definitions/RegExp"}},"importScripts":{"type":"array","items":{"type":"string"}},"inlineWorkboxRuntime":{"default":false,"type":"boolean"},"mode":{"default":"production","type":["null","string"]},"navigateFallback":{"default":null,"type":["null","string"]},"navigateFallbackAllowlist":{"type":"array","items":{"$ref":"#/definitions/RegExp"}},"navigateFallbackDenylist":{"type":"array","items":{"$ref":"#/definitions/RegExp"}},"navigationPreload":{"default":false,"type":"boolean"},"offlineGoogleAnalytics":{"default":false,"anyOf":[{"$ref":"#/definitions/GoogleAnalyticsInitializeOptions"},{"type":"boolean"}]},"runtimeCaching":{"type":"array","items":{"$ref":"#/definitions/RuntimeCaching"}},"skipWaiting":{"default":false,"type":"boolean"},"sourcemap":{"default":true,"type":"boolean"},"additionalManifestEntries":{"type":"array","items":{"anyOf":[{"$ref":"#/definitions/ManifestEntry"},{"type":"string"}]}},"dontCacheBustURLsMatching":{"$ref":"#/definitions/RegExp"},"manifestTransforms":{"type":"array","items":{"type":"object","additionalProperties":false}},"maximumFileSizeToCacheInBytes":{"default":2097152,"type":"number"},"modifyURLPrefix":{"type":"object","additionalProperties":{"type":"string"}},"swDest":{"default":"service-worker.js","type":"string"}},"required":["globDirectory","swDest"],"definitions":{"RegExp":{"type":"object","properties":{"source":{"type":"string"},"global":{"type":"boolean"},"ignoreCase":{"type":"boolean"},"multiline":{"type":"boolean"},"lastIndex":{"type":"number"},"flags":{"type":"string"},"sticky":{"type":"boolean"},"unicode":{"type":"boolean"},"dotAll":{"type":"boolean"}},"additionalProperties":false,"required":["dotAll","flags","global","ignoreCase","lastIndex","multiline","source","sticky","unicode"]},"GoogleAnalyticsInitializeOptions":{"type":"object","properties":{"cacheName":{"type":"string"},"parameterOverrides":{"type":"object","additionalProperties":{"type":"string"}},"hitFilter":{"type":"object","additionalProperties":false}},"additionalProperties":false},"RuntimeCaching":{"type":"object","properties":{"handler":{"anyOf":[{"$ref":"#/definitions/RouteHandlerCallback"},{"$ref":"#/definitions/RouteHandlerObject"},{"enum":["CacheFirst","CacheOnly","NetworkFirst","NetworkOnly","StaleWhileRevalidate"],"type":"string"}]},"method":{"enum":["DELETE","GET","HEAD","PATCH","POST","PUT"],"type":"string"},"options":{"type":"object","properties":{"backgroundSync":{"type":"object","properties":{"name":{"type":"string"},"options":{"$ref":"#/definitions/QueueOptions"}},"additionalProperties":false,"required":["name"]},"broadcastUpdate":{"type":"object","properties":{"channelName":{"type":"string"},"options":{"$ref":"#/definitions/BroadcastCacheUpdateOptions"}},"additionalProperties":false,"required":["options"]},"cacheableResponse":{"$ref":"#/definitions/CacheableResponseOptions"},"cacheName":{"type":["null","string"]},"expiration":{"$ref":"#/definitions/ExpirationPluginOptions"},"networkTimeoutSeconds":{"type":"number"},"plugins":{"type":"array","items":{"$ref":"#/definitions/WorkboxPlugin"}},"precacheFallback":{"type":"object","properties":{"fallbackURL":{"type":"string"}},"additionalProperties":false,"required":["fallbackURL"]},"fetchOptions":{"$ref":"#/definitions/RequestInit"},"matchOptions":{"$ref":"#/definitions/CacheQueryOptions"}},"additionalProperties":false},"urlPattern":{"anyOf":[{"$ref":"#/definitions/RegExp"},{"$ref":"#/definitions/RouteMatchCallback"},{"type":"string"}]}},"additionalProperties":false,"required":["handler","urlPattern"]},"RouteHandlerCallback":{"description":"The \"handler\" callback is invoked whenever a `Router` matches a URL/Request\nto a `Route` via its `RouteMatchCallback`. This handler callback should\nreturn a `Promise` that resolves with a `Response`.\n\nIf a non-empty array or object is returned by the `RouteMatchCallback` it\nwill be passed in as this handler's `options.params` argument.","type":"object","additionalProperties":false},"RouteHandlerObject":{"description":"An object with a `handle` method of type `RouteHandlerCallback`.\n\nA `Route` object can be created with either an `RouteHandlerCallback`\nfunction or this `RouteHandler` object. The benefit of the `RouteHandler`\nis it can be extended (as is done by the `workbox-strategies` package).","type":"object","properties":{"handle":{"$ref":"#/definitions/RouteHandlerCallback"}},"additionalProperties":false,"required":["handle"]},"QueueOptions":{"type":"object","properties":{"onSync":{"$ref":"#/definitions/OnSyncCallback"},"maxRetentionTime":{"type":"number"}},"additionalProperties":false},"OnSyncCallback":{"type":"object","additionalProperties":false},"BroadcastCacheUpdateOptions":{"type":"object","properties":{"headersToCheck":{"type":"array","items":{"type":"string"}},"generatePayload":{"type":"object","additionalProperties":false}},"additionalProperties":false},"CacheableResponseOptions":{"type":"object","properties":{"statuses":{"type":"array","items":{"type":"number"}},"headers":{"type":"object","additionalProperties":{"type":"string"}}},"additionalProperties":false},"ExpirationPluginOptions":{"type":"object","properties":{"maxEntries":{"type":"number"},"maxAgeSeconds":{"type":"number"},"matchOptions":{"$ref":"#/definitions/CacheQueryOptions"},"purgeOnQuotaError":{"type":"boolean"}},"additionalProperties":false},"CacheQueryOptions":{"type":"object","properties":{"ignoreMethod":{"type":"boolean"},"ignoreSearch":{"type":"boolean"},"ignoreVary":{"type":"boolean"}},"additionalProperties":false},"WorkboxPlugin":{"description":"An object with optional lifecycle callback properties for the fetch and\ncache operations.","type":"object","properties":{"cacheDidUpdate":{"$ref":"#/definitions/CacheDidUpdateCallback"},"cachedResponseWillBeUsed":{"$ref":"#/definitions/CachedResponseWillBeUsedCallback"},"cacheKeyWillBeUsed":{"$ref":"#/definitions/CacheKeyWillBeUsedCallback"},"cacheWillUpdate":{"$ref":"#/definitions/CacheWillUpdateCallback"},"fetchDidFail":{"$ref":"#/definitions/FetchDidFailCallback"},"fetchDidSucceed":{"$ref":"#/definitions/FetchDidSucceedCallback"},"handlerDidComplete":{"$ref":"#/definitions/HandlerDidCompleteCallback"},"handlerDidError":{"$ref":"#/definitions/HandlerDidErrorCallback"},"handlerDidRespond":{"$ref":"#/definitions/HandlerDidRespondCallback"},"handlerWillRespond":{"$ref":"#/definitions/HandlerWillRespondCallback"},"handlerWillStart":{"$ref":"#/definitions/HandlerWillStartCallback"},"requestWillFetch":{"$ref":"#/definitions/RequestWillFetchCallback"}},"additionalProperties":false},"CacheDidUpdateCallback":{"type":"object","additionalProperties":false},"CachedResponseWillBeUsedCallback":{"type":"object","additionalProperties":false},"CacheKeyWillBeUsedCallback":{"type":"object","additionalProperties":false},"CacheWillUpdateCallback":{"type":"object","additionalProperties":false},"FetchDidFailCallback":{"type":"object","additionalProperties":false},"FetchDidSucceedCallback":{"type":"object","additionalProperties":false},"HandlerDidCompleteCallback":{"type":"object","additionalProperties":false},"HandlerDidErrorCallback":{"type":"object","additionalProperties":false},"HandlerDidRespondCallback":{"type":"object","additionalProperties":false},"HandlerWillRespondCallback":{"type":"object","additionalProperties":false},"HandlerWillStartCallback":{"type":"object","additionalProperties":false},"RequestWillFetchCallback":{"type":"object","additionalProperties":false},"RequestInit":{"type":"object","properties":{"body":{"anyOf":[{"$ref":"#/definitions/ArrayBuffer"},{"$ref":"#/definitions/ArrayBufferView"},{"$ref":"#/definitions/Blob"},{"$ref":"#/definitions/FormData"},{"$ref":"#/definitions/URLSearchParams"},{"$ref":"#/definitions/ReadableStream"},{"type":["null","string"]}]},"cache":{"enum":["default","force-cache","no-cache","no-store","only-if-cached","reload"],"type":"string"},"credentials":{"enum":["include","omit","same-origin"],"type":"string"},"headers":{"anyOf":[{"$ref":"#/definitions/Headers"},{"type":"array","items":{"type":"array","items":{"type":"string"}}},{"$ref":"#/definitions/Record"}]},"integrity":{"type":"string"},"keepalive":{"type":"boolean"},"method":{"type":"string"},"mode":{"enum":["cors","navigate","no-cors","same-origin"],"type":"string"},"redirect":{"enum":["error","follow","manual"],"type":"string"},"referrer":{"type":"string"},"referrerPolicy":{"enum":["","no-referrer","no-referrer-when-downgrade","origin","origin-when-cross-origin","same-origin","strict-origin","strict-origin-when-cross-origin","unsafe-url"],"type":"string"},"signal":{"anyOf":[{"$ref":"#/definitions/AbortSignal"},{"type":"null"}]},"window":{}},"additionalProperties":false},"ArrayBuffer":{"type":"object","properties":{"byteLength":{"type":"number"},"__@toStringTag":{"type":"string"}},"additionalProperties":false,"required":["__@toStringTag","byteLength"]},"ArrayBufferView":{"type":"object","properties":{"buffer":{"anyOf":[{"$ref":"#/definitions/ArrayBuffer"},{"$ref":"#/definitions/SharedArrayBuffer"}]},"byteLength":{"type":"number"},"byteOffset":{"type":"number"}},"additionalProperties":false,"required":["buffer","byteLength","byteOffset"]},"SharedArrayBuffer":{"type":"object","properties":{"byteLength":{"type":"number"},"__@species":{"$ref":"#/definitions/SharedArrayBuffer"},"__@toStringTag":{"type":"string","enum":["SharedArrayBuffer"]}},"additionalProperties":false,"required":["__@species","__@toStringTag","byteLength"]},"Blob":{"type":"object","properties":{"size":{"type":"number"},"type":{"type":"string"}},"additionalProperties":false,"required":["size","type"]},"FormData":{"type":"object","additionalProperties":false},"URLSearchParams":{"type":"object","additionalProperties":false},"ReadableStream":{"type":"object","properties":{"locked":{"type":"boolean"}},"additionalProperties":false,"required":["locked"]},"Headers":{"type":"object","additionalProperties":false},"Record":{"type":"object","additionalProperties":false},"AbortSignal":{"type":"object","properties":{"aborted":{"type":"boolean"},"onabort":{"anyOf":[{"type":"object","additionalProperties":false},{"type":"null"}]}},"additionalProperties":false,"required":["aborted","onabort"]},"RouteMatchCallback":{"description":"The \"match\" callback is used to determine if a `Route` should apply for a\nparticular URL and request. When matching occurs in response to a fetch\nevent from the client, the `event` object is also supplied. However, since\nthe match callback can be invoked outside of a fetch event, matching logic\nshould not assume the `event` object will always be available.\nIf the match callback returns a truthy value, the matching route's\n`RouteHandlerCallback` will be invoked immediately. If the value returned\nis a non-empty array or object, that value will be set on the handler's\n`options.params` argument.","type":"object","additionalProperties":false},"ManifestEntry":{"type":"object","properties":{"integrity":{"type":"string"},"revision":{"type":["null","string"]},"url":{"type":"string"}},"additionalProperties":false,"required":["revision","url"]}},"$schema":"http://json-schema.org/draft-07/schema#"} diff --git a/packages/workbox-build/src/schema/GetManifestOptions.json b/packages/workbox-build/src/schema/GetManifestOptions.json index ef796db7d..504ae7b38 100644 --- a/packages/workbox-build/src/schema/GetManifestOptions.json +++ b/packages/workbox-build/src/schema/GetManifestOptions.json @@ -1 +1 @@ -{"additionalProperties":false,"type":"object","properties":{"globDirectory":{"type":["null","string"]},"globFollow":{"default":true,"type":"boolean"},"globIgnores":{"default":["**/node_modules/**/*"],"type":"array","items":{"type":"string"}},"globPatterns":{"default":["**/*.{js,css,html}"],"type":"array","items":{"type":"string"}},"globStrict":{"default":true,"type":"boolean"},"templatedURLs":{"type":"object","additionalProperties":{"anyOf":[{"type":"array","items":{"type":"string"}},{"type":"string"}]}},"additionalManifestEntries":{"type":"array","items":{"anyOf":[{"$ref":"#/definitions/ManifestEntry"},{"type":"string"}]}},"dontCacheBustURLsMatching":{"$ref":"#/definitions/RegExp"},"manifestTransforms":{"type":"array","items":{"type":"object","additionalProperties":false}},"maximumFileSizeToCacheInBytes":{"default":2097152,"type":"number"},"modifyURLPrefix":{"type":"object","additionalProperties":{"type":"string"}}},"definitions":{"RegExp":{"type":"object","properties":{"source":{"type":"string"},"global":{"type":"boolean"},"ignoreCase":{"type":"boolean"},"multiline":{"type":"boolean"},"lastIndex":{"type":"number"},"flags":{"type":"string"},"sticky":{"type":"boolean"},"unicode":{"type":"boolean"},"dotAll":{"type":"boolean"}},"additionalProperties":false},"GoogleAnalyticsInitializeOptions":{"type":"object","properties":{"cacheName":{"type":"string"},"parameterOverrides":{"type":"object","additionalProperties":{"type":"string"}},"hitFilter":{"type":"object","additionalProperties":false}},"additionalProperties":false},"RuntimeCaching":{"type":"object","properties":{"handler":{"anyOf":[{"$ref":"#/definitions/RouteHandlerCallback"},{"$ref":"#/definitions/RouteHandlerObject"},{"enum":["CacheFirst","CacheOnly","NetworkFirst","NetworkOnly","StaleWhileRevalidate"],"type":"string"}]},"method":{"enum":["DELETE","GET","HEAD","PATCH","POST","PUT"],"type":"string"},"options":{"type":"object","properties":{"backgroundSync":{"type":"object","properties":{"name":{"type":"string"},"options":{"$ref":"#/definitions/QueueOptions"}},"additionalProperties":false},"broadcastUpdate":{"type":"object","properties":{"channelName":{"type":"string"},"options":{"$ref":"#/definitions/BroadcastCacheUpdateOptions"}},"additionalProperties":false},"cacheableResponse":{"$ref":"#/definitions/CacheableResponseOptions"},"cacheName":{"type":["null","string"]},"expiration":{"$ref":"#/definitions/ExpirationPluginOptions"},"networkTimeoutSeconds":{"type":"number"},"plugins":{"type":"array","items":{"$ref":"#/definitions/WorkboxPlugin"}},"precacheFallback":{"type":"object","properties":{"fallbackURL":{"type":"string"}},"additionalProperties":false},"fetchOptions":{"$ref":"#/definitions/RequestInit"},"matchOptions":{"$ref":"#/definitions/CacheQueryOptions"}},"additionalProperties":false},"urlPattern":{"anyOf":[{"$ref":"#/definitions/RegExp"},{"$ref":"#/definitions/RouteMatchCallback"},{"type":"string"}]}},"additionalProperties":false},"RouteHandlerCallback":{"description":"The \"handler\" callback is invoked whenever a `Router` matches a URL/Request\nto a `Route` via its `RouteMatchCallback`. This handler callback should\nreturn a `Promise` that resolves with a `Response`.\n\nIf a non-empty array or object is returned by the `RouteMatchCallback` it\nwill be passed in as this handler's `options.params` argument.","type":"object","additionalProperties":false},"RouteHandlerObject":{"description":"An object with a `handle` method of type `RouteHandlerCallback`.\n\nA `Route` object can be created with either an `RouteHandlerCallback`\nfunction or this `RouteHandler` object. The benefit of the `RouteHandler`\nis it can be extended (as is done by the `workbox-strategies` package).","type":"object","properties":{"handle":{"$ref":"#/definitions/RouteHandlerCallback"}},"additionalProperties":false},"QueueOptions":{"type":"object","properties":{"onSync":{"$ref":"#/definitions/OnSyncCallback"},"maxRetentionTime":{"type":"number"}},"additionalProperties":false},"OnSyncCallback":{"type":"object","additionalProperties":false},"BroadcastCacheUpdateOptions":{"type":"object","properties":{"headersToCheck":{"type":"array","items":{"type":"string"}},"generatePayload":{"type":"object","additionalProperties":false}},"additionalProperties":false},"CacheableResponseOptions":{"type":"object","properties":{"statuses":{"type":"array","items":{"type":"number"}},"headers":{"type":"object","additionalProperties":{"type":"string"}}},"additionalProperties":false},"ExpirationPluginOptions":{"type":"object","properties":{"maxEntries":{"type":"number"},"maxAgeSeconds":{"type":"number"},"matchOptions":{"$ref":"#/definitions/CacheQueryOptions"},"purgeOnQuotaError":{"type":"boolean"}},"additionalProperties":false},"CacheQueryOptions":{"type":"object","properties":{"ignoreMethod":{"type":"boolean"},"ignoreSearch":{"type":"boolean"},"ignoreVary":{"type":"boolean"}},"additionalProperties":false},"WorkboxPlugin":{"description":"An object with optional lifecycle callback properties for the fetch and\ncache operations.","type":"object","properties":{"cacheDidUpdate":{"$ref":"#/definitions/CacheDidUpdateCallback"},"cachedResponseWillBeUsed":{"$ref":"#/definitions/CachedResponseWillBeUsedCallback"},"cacheKeyWillBeUsed":{"$ref":"#/definitions/CacheKeyWillBeUsedCallback"},"cacheWillUpdate":{"$ref":"#/definitions/CacheWillUpdateCallback"},"fetchDidFail":{"$ref":"#/definitions/FetchDidFailCallback"},"fetchDidSucceed":{"$ref":"#/definitions/FetchDidSucceedCallback"},"handlerDidComplete":{"$ref":"#/definitions/HandlerDidCompleteCallback"},"handlerDidError":{"$ref":"#/definitions/HandlerDidErrorCallback"},"handlerDidRespond":{"$ref":"#/definitions/HandlerDidRespondCallback"},"handlerWillRespond":{"$ref":"#/definitions/HandlerWillRespondCallback"},"handlerWillStart":{"$ref":"#/definitions/HandlerWillStartCallback"},"requestWillFetch":{"$ref":"#/definitions/RequestWillFetchCallback"}},"additionalProperties":false},"CacheDidUpdateCallback":{"type":"object","additionalProperties":false},"CachedResponseWillBeUsedCallback":{"type":"object","additionalProperties":false},"CacheKeyWillBeUsedCallback":{"type":"object","additionalProperties":false},"CacheWillUpdateCallback":{"type":"object","additionalProperties":false},"FetchDidFailCallback":{"type":"object","additionalProperties":false},"FetchDidSucceedCallback":{"type":"object","additionalProperties":false},"HandlerDidCompleteCallback":{"type":"object","additionalProperties":false},"HandlerDidErrorCallback":{"type":"object","additionalProperties":false},"HandlerDidRespondCallback":{"type":"object","additionalProperties":false},"HandlerWillRespondCallback":{"type":"object","additionalProperties":false},"HandlerWillStartCallback":{"type":"object","additionalProperties":false},"RequestWillFetchCallback":{"type":"object","additionalProperties":false},"RequestInit":{"type":"object","properties":{"body":{"anyOf":[{"$ref":"#/definitions/ArrayBuffer"},{"$ref":"#/definitions/ArrayBufferView"},{"$ref":"#/definitions/Blob"},{"$ref":"#/definitions/FormData"},{"$ref":"#/definitions/URLSearchParams"},{"$ref":"#/definitions/ReadableStream"},{"type":["null","string"]}]},"cache":{"enum":["default","force-cache","no-cache","no-store","only-if-cached","reload"],"type":"string"},"credentials":{"enum":["include","omit","same-origin"],"type":"string"},"headers":{"anyOf":[{"$ref":"#/definitions/Headers"},{"type":"array","items":{"type":"array","items":{"type":"string"}}},{"$ref":"#/definitions/Record"}]},"integrity":{"type":"string"},"keepalive":{"type":"boolean"},"method":{"type":"string"},"mode":{"enum":["cors","navigate","no-cors","same-origin"],"type":"string"},"redirect":{"enum":["error","follow","manual"],"type":"string"},"referrer":{"type":"string"},"referrerPolicy":{"enum":["","no-referrer","no-referrer-when-downgrade","origin","origin-when-cross-origin","same-origin","strict-origin","strict-origin-when-cross-origin","unsafe-url"],"type":"string"},"signal":{"anyOf":[{"$ref":"#/definitions/AbortSignal"},{"type":"null"}]},"window":{}},"additionalProperties":false},"ArrayBuffer":{"type":"object","properties":{"byteLength":{"type":"number"},"__@toStringTag":{"type":"string"}},"additionalProperties":false},"ArrayBufferView":{"type":"object","properties":{"buffer":{"anyOf":[{"$ref":"#/definitions/ArrayBuffer"},{"$ref":"#/definitions/SharedArrayBuffer"}]},"byteLength":{"type":"number"},"byteOffset":{"type":"number"}},"additionalProperties":false},"SharedArrayBuffer":{"type":"object","properties":{"byteLength":{"type":"number"},"__@species":{"$ref":"#/definitions/SharedArrayBuffer"},"__@toStringTag":{"type":"string","enum":["SharedArrayBuffer"]}},"additionalProperties":false},"Blob":{"type":"object","properties":{"size":{"type":"number"},"type":{"type":"string"}},"additionalProperties":false},"FormData":{"type":"object","additionalProperties":false},"URLSearchParams":{"type":"object","additionalProperties":false},"ReadableStream":{"type":"object","properties":{"locked":{"type":"boolean"}},"additionalProperties":false},"Headers":{"type":"object","additionalProperties":false},"Record":{"type":"object","additionalProperties":false},"AbortSignal":{"type":"object","properties":{"aborted":{"type":"boolean"},"onabort":{"anyOf":[{"type":"object","additionalProperties":false},{"type":"null"}]}},"additionalProperties":false},"RouteMatchCallback":{"description":"The \"match\" callback is used to determine if a `Route` should apply for a\nparticular URL and request. When matching occurs in response to a fetch\nevent from the client, the `event` object is also supplied. However, since\nthe match callback can be invoked outside of a fetch event, matching logic\nshould not assume the `event` object will always be available.\nIf the match callback returns a truthy value, the matching route's\n`RouteHandlerCallback` will be invoked immediately. If the value returned\nis a non-empty array or object, that value will be set on the handler's\n`options.params` argument.","type":"object","additionalProperties":false},"ManifestEntry":{"type":"object","properties":{"integrity":{"type":"string"},"revision":{"type":["null","string"]},"url":{"type":"string"}},"additionalProperties":false}},"$schema":"http://json-schema.org/draft-07/schema#"} +{"additionalProperties":false,"type":"object","properties":{"globDirectory":{"type":"string"},"globFollow":{"default":true,"type":"boolean"},"globIgnores":{"default":["**/node_modules/**/*"],"type":"array","items":{"type":"string"}},"globPatterns":{"default":["**/*.{js,css,html}"],"type":"array","items":{"type":"string"}},"globStrict":{"default":true,"type":"boolean"},"templatedURLs":{"type":"object","additionalProperties":{"anyOf":[{"type":"array","items":{"type":"string"}},{"type":"string"}]}},"additionalManifestEntries":{"type":"array","items":{"anyOf":[{"$ref":"#/definitions/ManifestEntry"},{"type":"string"}]}},"dontCacheBustURLsMatching":{"$ref":"#/definitions/RegExp"},"manifestTransforms":{"type":"array","items":{"type":"object","additionalProperties":false}},"maximumFileSizeToCacheInBytes":{"default":2097152,"type":"number"},"modifyURLPrefix":{"type":"object","additionalProperties":{"type":"string"}}},"required":["globDirectory"],"definitions":{"RegExp":{"type":"object","properties":{"source":{"type":"string"},"global":{"type":"boolean"},"ignoreCase":{"type":"boolean"},"multiline":{"type":"boolean"},"lastIndex":{"type":"number"},"flags":{"type":"string"},"sticky":{"type":"boolean"},"unicode":{"type":"boolean"},"dotAll":{"type":"boolean"}},"additionalProperties":false,"required":["dotAll","flags","global","ignoreCase","lastIndex","multiline","source","sticky","unicode"]},"GoogleAnalyticsInitializeOptions":{"type":"object","properties":{"cacheName":{"type":"string"},"parameterOverrides":{"type":"object","additionalProperties":{"type":"string"}},"hitFilter":{"type":"object","additionalProperties":false}},"additionalProperties":false},"RuntimeCaching":{"type":"object","properties":{"handler":{"anyOf":[{"$ref":"#/definitions/RouteHandlerCallback"},{"$ref":"#/definitions/RouteHandlerObject"},{"enum":["CacheFirst","CacheOnly","NetworkFirst","NetworkOnly","StaleWhileRevalidate"],"type":"string"}]},"method":{"enum":["DELETE","GET","HEAD","PATCH","POST","PUT"],"type":"string"},"options":{"type":"object","properties":{"backgroundSync":{"type":"object","properties":{"name":{"type":"string"},"options":{"$ref":"#/definitions/QueueOptions"}},"additionalProperties":false,"required":["name"]},"broadcastUpdate":{"type":"object","properties":{"channelName":{"type":"string"},"options":{"$ref":"#/definitions/BroadcastCacheUpdateOptions"}},"additionalProperties":false,"required":["options"]},"cacheableResponse":{"$ref":"#/definitions/CacheableResponseOptions"},"cacheName":{"type":["null","string"]},"expiration":{"$ref":"#/definitions/ExpirationPluginOptions"},"networkTimeoutSeconds":{"type":"number"},"plugins":{"type":"array","items":{"$ref":"#/definitions/WorkboxPlugin"}},"precacheFallback":{"type":"object","properties":{"fallbackURL":{"type":"string"}},"additionalProperties":false,"required":["fallbackURL"]},"fetchOptions":{"$ref":"#/definitions/RequestInit"},"matchOptions":{"$ref":"#/definitions/CacheQueryOptions"}},"additionalProperties":false},"urlPattern":{"anyOf":[{"$ref":"#/definitions/RegExp"},{"$ref":"#/definitions/RouteMatchCallback"},{"type":"string"}]}},"additionalProperties":false,"required":["handler","urlPattern"]},"RouteHandlerCallback":{"description":"The \"handler\" callback is invoked whenever a `Router` matches a URL/Request\nto a `Route` via its `RouteMatchCallback`. This handler callback should\nreturn a `Promise` that resolves with a `Response`.\n\nIf a non-empty array or object is returned by the `RouteMatchCallback` it\nwill be passed in as this handler's `options.params` argument.","type":"object","additionalProperties":false},"RouteHandlerObject":{"description":"An object with a `handle` method of type `RouteHandlerCallback`.\n\nA `Route` object can be created with either an `RouteHandlerCallback`\nfunction or this `RouteHandler` object. The benefit of the `RouteHandler`\nis it can be extended (as is done by the `workbox-strategies` package).","type":"object","properties":{"handle":{"$ref":"#/definitions/RouteHandlerCallback"}},"additionalProperties":false,"required":["handle"]},"QueueOptions":{"type":"object","properties":{"onSync":{"$ref":"#/definitions/OnSyncCallback"},"maxRetentionTime":{"type":"number"}},"additionalProperties":false},"OnSyncCallback":{"type":"object","additionalProperties":false},"BroadcastCacheUpdateOptions":{"type":"object","properties":{"headersToCheck":{"type":"array","items":{"type":"string"}},"generatePayload":{"type":"object","additionalProperties":false}},"additionalProperties":false},"CacheableResponseOptions":{"type":"object","properties":{"statuses":{"type":"array","items":{"type":"number"}},"headers":{"type":"object","additionalProperties":{"type":"string"}}},"additionalProperties":false},"ExpirationPluginOptions":{"type":"object","properties":{"maxEntries":{"type":"number"},"maxAgeSeconds":{"type":"number"},"matchOptions":{"$ref":"#/definitions/CacheQueryOptions"},"purgeOnQuotaError":{"type":"boolean"}},"additionalProperties":false},"CacheQueryOptions":{"type":"object","properties":{"ignoreMethod":{"type":"boolean"},"ignoreSearch":{"type":"boolean"},"ignoreVary":{"type":"boolean"}},"additionalProperties":false},"WorkboxPlugin":{"description":"An object with optional lifecycle callback properties for the fetch and\ncache operations.","type":"object","properties":{"cacheDidUpdate":{"$ref":"#/definitions/CacheDidUpdateCallback"},"cachedResponseWillBeUsed":{"$ref":"#/definitions/CachedResponseWillBeUsedCallback"},"cacheKeyWillBeUsed":{"$ref":"#/definitions/CacheKeyWillBeUsedCallback"},"cacheWillUpdate":{"$ref":"#/definitions/CacheWillUpdateCallback"},"fetchDidFail":{"$ref":"#/definitions/FetchDidFailCallback"},"fetchDidSucceed":{"$ref":"#/definitions/FetchDidSucceedCallback"},"handlerDidComplete":{"$ref":"#/definitions/HandlerDidCompleteCallback"},"handlerDidError":{"$ref":"#/definitions/HandlerDidErrorCallback"},"handlerDidRespond":{"$ref":"#/definitions/HandlerDidRespondCallback"},"handlerWillRespond":{"$ref":"#/definitions/HandlerWillRespondCallback"},"handlerWillStart":{"$ref":"#/definitions/HandlerWillStartCallback"},"requestWillFetch":{"$ref":"#/definitions/RequestWillFetchCallback"}},"additionalProperties":false},"CacheDidUpdateCallback":{"type":"object","additionalProperties":false},"CachedResponseWillBeUsedCallback":{"type":"object","additionalProperties":false},"CacheKeyWillBeUsedCallback":{"type":"object","additionalProperties":false},"CacheWillUpdateCallback":{"type":"object","additionalProperties":false},"FetchDidFailCallback":{"type":"object","additionalProperties":false},"FetchDidSucceedCallback":{"type":"object","additionalProperties":false},"HandlerDidCompleteCallback":{"type":"object","additionalProperties":false},"HandlerDidErrorCallback":{"type":"object","additionalProperties":false},"HandlerDidRespondCallback":{"type":"object","additionalProperties":false},"HandlerWillRespondCallback":{"type":"object","additionalProperties":false},"HandlerWillStartCallback":{"type":"object","additionalProperties":false},"RequestWillFetchCallback":{"type":"object","additionalProperties":false},"RequestInit":{"type":"object","properties":{"body":{"anyOf":[{"$ref":"#/definitions/ArrayBuffer"},{"$ref":"#/definitions/ArrayBufferView"},{"$ref":"#/definitions/Blob"},{"$ref":"#/definitions/FormData"},{"$ref":"#/definitions/URLSearchParams"},{"$ref":"#/definitions/ReadableStream"},{"type":["null","string"]}]},"cache":{"enum":["default","force-cache","no-cache","no-store","only-if-cached","reload"],"type":"string"},"credentials":{"enum":["include","omit","same-origin"],"type":"string"},"headers":{"anyOf":[{"$ref":"#/definitions/Headers"},{"type":"array","items":{"type":"array","items":{"type":"string"}}},{"$ref":"#/definitions/Record"}]},"integrity":{"type":"string"},"keepalive":{"type":"boolean"},"method":{"type":"string"},"mode":{"enum":["cors","navigate","no-cors","same-origin"],"type":"string"},"redirect":{"enum":["error","follow","manual"],"type":"string"},"referrer":{"type":"string"},"referrerPolicy":{"enum":["","no-referrer","no-referrer-when-downgrade","origin","origin-when-cross-origin","same-origin","strict-origin","strict-origin-when-cross-origin","unsafe-url"],"type":"string"},"signal":{"anyOf":[{"$ref":"#/definitions/AbortSignal"},{"type":"null"}]},"window":{}},"additionalProperties":false},"ArrayBuffer":{"type":"object","properties":{"byteLength":{"type":"number"},"__@toStringTag":{"type":"string"}},"additionalProperties":false,"required":["__@toStringTag","byteLength"]},"ArrayBufferView":{"type":"object","properties":{"buffer":{"anyOf":[{"$ref":"#/definitions/ArrayBuffer"},{"$ref":"#/definitions/SharedArrayBuffer"}]},"byteLength":{"type":"number"},"byteOffset":{"type":"number"}},"additionalProperties":false,"required":["buffer","byteLength","byteOffset"]},"SharedArrayBuffer":{"type":"object","properties":{"byteLength":{"type":"number"},"__@species":{"$ref":"#/definitions/SharedArrayBuffer"},"__@toStringTag":{"type":"string","enum":["SharedArrayBuffer"]}},"additionalProperties":false,"required":["__@species","__@toStringTag","byteLength"]},"Blob":{"type":"object","properties":{"size":{"type":"number"},"type":{"type":"string"}},"additionalProperties":false,"required":["size","type"]},"FormData":{"type":"object","additionalProperties":false},"URLSearchParams":{"type":"object","additionalProperties":false},"ReadableStream":{"type":"object","properties":{"locked":{"type":"boolean"}},"additionalProperties":false,"required":["locked"]},"Headers":{"type":"object","additionalProperties":false},"Record":{"type":"object","additionalProperties":false},"AbortSignal":{"type":"object","properties":{"aborted":{"type":"boolean"},"onabort":{"anyOf":[{"type":"object","additionalProperties":false},{"type":"null"}]}},"additionalProperties":false,"required":["aborted","onabort"]},"RouteMatchCallback":{"description":"The \"match\" callback is used to determine if a `Route` should apply for a\nparticular URL and request. When matching occurs in response to a fetch\nevent from the client, the `event` object is also supplied. However, since\nthe match callback can be invoked outside of a fetch event, matching logic\nshould not assume the `event` object will always be available.\nIf the match callback returns a truthy value, the matching route's\n`RouteHandlerCallback` will be invoked immediately. If the value returned\nis a non-empty array or object, that value will be set on the handler's\n`options.params` argument.","type":"object","additionalProperties":false},"ManifestEntry":{"type":"object","properties":{"integrity":{"type":"string"},"revision":{"type":["null","string"]},"url":{"type":"string"}},"additionalProperties":false,"required":["revision","url"]}},"$schema":"http://json-schema.org/draft-07/schema#"} diff --git a/packages/workbox-build/src/schema/InjectManifestOptions.json b/packages/workbox-build/src/schema/InjectManifestOptions.json index 30c4db43e..609984f2c 100644 --- a/packages/workbox-build/src/schema/InjectManifestOptions.json +++ b/packages/workbox-build/src/schema/InjectManifestOptions.json @@ -1 +1 @@ -{"additionalProperties":false,"type":"object","properties":{"injectionPoint":{"default":"self.__WB_MANIFEST","type":"string"},"swSrc":{"type":"string"},"globFollow":{"default":true,"type":"boolean"},"globIgnores":{"default":["**/node_modules/**/*"],"type":"array","items":{"type":"string"}},"globPatterns":{"default":["**/*.{js,css,html}"],"type":"array","items":{"type":"string"}},"globStrict":{"default":true,"type":"boolean"},"templatedURLs":{"type":"object","additionalProperties":{"anyOf":[{"type":"array","items":{"type":"string"}},{"type":"string"}]}},"additionalManifestEntries":{"type":"array","items":{"anyOf":[{"$ref":"#/definitions/ManifestEntry"},{"type":"string"}]}},"dontCacheBustURLsMatching":{"$ref":"#/definitions/RegExp"},"manifestTransforms":{"type":"array","items":{"type":"object","additionalProperties":false}},"maximumFileSizeToCacheInBytes":{"default":2097152,"type":"number"},"modifyURLPrefix":{"type":"object","additionalProperties":{"type":"string"}},"swDest":{"default":"service-worker.js","type":"string"},"globDirectory":{"type":"string"}},"definitions":{"RegExp":{"type":"object","properties":{"source":{"type":"string"},"global":{"type":"boolean"},"ignoreCase":{"type":"boolean"},"multiline":{"type":"boolean"},"lastIndex":{"type":"number"},"flags":{"type":"string"},"sticky":{"type":"boolean"},"unicode":{"type":"boolean"},"dotAll":{"type":"boolean"}},"additionalProperties":false},"GoogleAnalyticsInitializeOptions":{"type":"object","properties":{"cacheName":{"type":"string"},"parameterOverrides":{"type":"object","additionalProperties":{"type":"string"}},"hitFilter":{"type":"object","additionalProperties":false}},"additionalProperties":false},"RuntimeCaching":{"type":"object","properties":{"handler":{"anyOf":[{"$ref":"#/definitions/RouteHandlerCallback"},{"$ref":"#/definitions/RouteHandlerObject"},{"enum":["CacheFirst","CacheOnly","NetworkFirst","NetworkOnly","StaleWhileRevalidate"],"type":"string"}]},"method":{"enum":["DELETE","GET","HEAD","PATCH","POST","PUT"],"type":"string"},"options":{"type":"object","properties":{"backgroundSync":{"type":"object","properties":{"name":{"type":"string"},"options":{"$ref":"#/definitions/QueueOptions"}},"additionalProperties":false},"broadcastUpdate":{"type":"object","properties":{"channelName":{"type":"string"},"options":{"$ref":"#/definitions/BroadcastCacheUpdateOptions"}},"additionalProperties":false},"cacheableResponse":{"$ref":"#/definitions/CacheableResponseOptions"},"cacheName":{"type":["null","string"]},"expiration":{"$ref":"#/definitions/ExpirationPluginOptions"},"networkTimeoutSeconds":{"type":"number"},"plugins":{"type":"array","items":{"$ref":"#/definitions/WorkboxPlugin"}},"precacheFallback":{"type":"object","properties":{"fallbackURL":{"type":"string"}},"additionalProperties":false},"fetchOptions":{"$ref":"#/definitions/RequestInit"},"matchOptions":{"$ref":"#/definitions/CacheQueryOptions"}},"additionalProperties":false},"urlPattern":{"anyOf":[{"$ref":"#/definitions/RegExp"},{"$ref":"#/definitions/RouteMatchCallback"},{"type":"string"}]}},"additionalProperties":false},"RouteHandlerCallback":{"description":"The \"handler\" callback is invoked whenever a `Router` matches a URL/Request\nto a `Route` via its `RouteMatchCallback`. This handler callback should\nreturn a `Promise` that resolves with a `Response`.\n\nIf a non-empty array or object is returned by the `RouteMatchCallback` it\nwill be passed in as this handler's `options.params` argument.","type":"object","additionalProperties":false},"RouteHandlerObject":{"description":"An object with a `handle` method of type `RouteHandlerCallback`.\n\nA `Route` object can be created with either an `RouteHandlerCallback`\nfunction or this `RouteHandler` object. The benefit of the `RouteHandler`\nis it can be extended (as is done by the `workbox-strategies` package).","type":"object","properties":{"handle":{"$ref":"#/definitions/RouteHandlerCallback"}},"additionalProperties":false},"QueueOptions":{"type":"object","properties":{"onSync":{"$ref":"#/definitions/OnSyncCallback"},"maxRetentionTime":{"type":"number"}},"additionalProperties":false},"OnSyncCallback":{"type":"object","additionalProperties":false},"BroadcastCacheUpdateOptions":{"type":"object","properties":{"headersToCheck":{"type":"array","items":{"type":"string"}},"generatePayload":{"type":"object","additionalProperties":false}},"additionalProperties":false},"CacheableResponseOptions":{"type":"object","properties":{"statuses":{"type":"array","items":{"type":"number"}},"headers":{"type":"object","additionalProperties":{"type":"string"}}},"additionalProperties":false},"ExpirationPluginOptions":{"type":"object","properties":{"maxEntries":{"type":"number"},"maxAgeSeconds":{"type":"number"},"matchOptions":{"$ref":"#/definitions/CacheQueryOptions"},"purgeOnQuotaError":{"type":"boolean"}},"additionalProperties":false},"CacheQueryOptions":{"type":"object","properties":{"ignoreMethod":{"type":"boolean"},"ignoreSearch":{"type":"boolean"},"ignoreVary":{"type":"boolean"}},"additionalProperties":false},"WorkboxPlugin":{"description":"An object with optional lifecycle callback properties for the fetch and\ncache operations.","type":"object","properties":{"cacheDidUpdate":{"$ref":"#/definitions/CacheDidUpdateCallback"},"cachedResponseWillBeUsed":{"$ref":"#/definitions/CachedResponseWillBeUsedCallback"},"cacheKeyWillBeUsed":{"$ref":"#/definitions/CacheKeyWillBeUsedCallback"},"cacheWillUpdate":{"$ref":"#/definitions/CacheWillUpdateCallback"},"fetchDidFail":{"$ref":"#/definitions/FetchDidFailCallback"},"fetchDidSucceed":{"$ref":"#/definitions/FetchDidSucceedCallback"},"handlerDidComplete":{"$ref":"#/definitions/HandlerDidCompleteCallback"},"handlerDidError":{"$ref":"#/definitions/HandlerDidErrorCallback"},"handlerDidRespond":{"$ref":"#/definitions/HandlerDidRespondCallback"},"handlerWillRespond":{"$ref":"#/definitions/HandlerWillRespondCallback"},"handlerWillStart":{"$ref":"#/definitions/HandlerWillStartCallback"},"requestWillFetch":{"$ref":"#/definitions/RequestWillFetchCallback"}},"additionalProperties":false},"CacheDidUpdateCallback":{"type":"object","additionalProperties":false},"CachedResponseWillBeUsedCallback":{"type":"object","additionalProperties":false},"CacheKeyWillBeUsedCallback":{"type":"object","additionalProperties":false},"CacheWillUpdateCallback":{"type":"object","additionalProperties":false},"FetchDidFailCallback":{"type":"object","additionalProperties":false},"FetchDidSucceedCallback":{"type":"object","additionalProperties":false},"HandlerDidCompleteCallback":{"type":"object","additionalProperties":false},"HandlerDidErrorCallback":{"type":"object","additionalProperties":false},"HandlerDidRespondCallback":{"type":"object","additionalProperties":false},"HandlerWillRespondCallback":{"type":"object","additionalProperties":false},"HandlerWillStartCallback":{"type":"object","additionalProperties":false},"RequestWillFetchCallback":{"type":"object","additionalProperties":false},"RequestInit":{"type":"object","properties":{"body":{"anyOf":[{"$ref":"#/definitions/ArrayBuffer"},{"$ref":"#/definitions/ArrayBufferView"},{"$ref":"#/definitions/Blob"},{"$ref":"#/definitions/FormData"},{"$ref":"#/definitions/URLSearchParams"},{"$ref":"#/definitions/ReadableStream"},{"type":["null","string"]}]},"cache":{"enum":["default","force-cache","no-cache","no-store","only-if-cached","reload"],"type":"string"},"credentials":{"enum":["include","omit","same-origin"],"type":"string"},"headers":{"anyOf":[{"$ref":"#/definitions/Headers"},{"type":"array","items":{"type":"array","items":{"type":"string"}}},{"$ref":"#/definitions/Record"}]},"integrity":{"type":"string"},"keepalive":{"type":"boolean"},"method":{"type":"string"},"mode":{"enum":["cors","navigate","no-cors","same-origin"],"type":"string"},"redirect":{"enum":["error","follow","manual"],"type":"string"},"referrer":{"type":"string"},"referrerPolicy":{"enum":["","no-referrer","no-referrer-when-downgrade","origin","origin-when-cross-origin","same-origin","strict-origin","strict-origin-when-cross-origin","unsafe-url"],"type":"string"},"signal":{"anyOf":[{"$ref":"#/definitions/AbortSignal"},{"type":"null"}]},"window":{}},"additionalProperties":false},"ArrayBuffer":{"type":"object","properties":{"byteLength":{"type":"number"},"__@toStringTag":{"type":"string"}},"additionalProperties":false},"ArrayBufferView":{"type":"object","properties":{"buffer":{"anyOf":[{"$ref":"#/definitions/ArrayBuffer"},{"$ref":"#/definitions/SharedArrayBuffer"}]},"byteLength":{"type":"number"},"byteOffset":{"type":"number"}},"additionalProperties":false},"SharedArrayBuffer":{"type":"object","properties":{"byteLength":{"type":"number"},"__@species":{"$ref":"#/definitions/SharedArrayBuffer"},"__@toStringTag":{"type":"string","enum":["SharedArrayBuffer"]}},"additionalProperties":false},"Blob":{"type":"object","properties":{"size":{"type":"number"},"type":{"type":"string"}},"additionalProperties":false},"FormData":{"type":"object","additionalProperties":false},"URLSearchParams":{"type":"object","additionalProperties":false},"ReadableStream":{"type":"object","properties":{"locked":{"type":"boolean"}},"additionalProperties":false},"Headers":{"type":"object","additionalProperties":false},"Record":{"type":"object","additionalProperties":false},"AbortSignal":{"type":"object","properties":{"aborted":{"type":"boolean"},"onabort":{"anyOf":[{"type":"object","additionalProperties":false},{"type":"null"}]}},"additionalProperties":false},"RouteMatchCallback":{"description":"The \"match\" callback is used to determine if a `Route` should apply for a\nparticular URL and request. When matching occurs in response to a fetch\nevent from the client, the `event` object is also supplied. However, since\nthe match callback can be invoked outside of a fetch event, matching logic\nshould not assume the `event` object will always be available.\nIf the match callback returns a truthy value, the matching route's\n`RouteHandlerCallback` will be invoked immediately. If the value returned\nis a non-empty array or object, that value will be set on the handler's\n`options.params` argument.","type":"object","additionalProperties":false},"ManifestEntry":{"type":"object","properties":{"integrity":{"type":"string"},"revision":{"type":["null","string"]},"url":{"type":"string"}},"additionalProperties":false}},"$schema":"http://json-schema.org/draft-07/schema#"} +{"additionalProperties":false,"type":"object","properties":{"injectionPoint":{"default":"self.__WB_MANIFEST","type":"string"},"swSrc":{"type":"string"},"globFollow":{"default":true,"type":"boolean"},"globIgnores":{"default":["**/node_modules/**/*"],"type":"array","items":{"type":"string"}},"globPatterns":{"default":["**/*.{js,css,html}"],"type":"array","items":{"type":"string"}},"globStrict":{"default":true,"type":"boolean"},"templatedURLs":{"type":"object","additionalProperties":{"anyOf":[{"type":"array","items":{"type":"string"}},{"type":"string"}]}},"additionalManifestEntries":{"type":"array","items":{"anyOf":[{"$ref":"#/definitions/ManifestEntry"},{"type":"string"}]}},"dontCacheBustURLsMatching":{"$ref":"#/definitions/RegExp"},"manifestTransforms":{"type":"array","items":{"type":"object","additionalProperties":false}},"maximumFileSizeToCacheInBytes":{"default":2097152,"type":"number"},"modifyURLPrefix":{"type":"object","additionalProperties":{"type":"string"}},"swDest":{"default":"service-worker.js","type":"string"},"globDirectory":{"type":"string"}},"required":["globDirectory","swDest","swSrc"],"definitions":{"RegExp":{"type":"object","properties":{"source":{"type":"string"},"global":{"type":"boolean"},"ignoreCase":{"type":"boolean"},"multiline":{"type":"boolean"},"lastIndex":{"type":"number"},"flags":{"type":"string"},"sticky":{"type":"boolean"},"unicode":{"type":"boolean"},"dotAll":{"type":"boolean"}},"additionalProperties":false,"required":["dotAll","flags","global","ignoreCase","lastIndex","multiline","source","sticky","unicode"]},"GoogleAnalyticsInitializeOptions":{"type":"object","properties":{"cacheName":{"type":"string"},"parameterOverrides":{"type":"object","additionalProperties":{"type":"string"}},"hitFilter":{"type":"object","additionalProperties":false}},"additionalProperties":false},"RuntimeCaching":{"type":"object","properties":{"handler":{"anyOf":[{"$ref":"#/definitions/RouteHandlerCallback"},{"$ref":"#/definitions/RouteHandlerObject"},{"enum":["CacheFirst","CacheOnly","NetworkFirst","NetworkOnly","StaleWhileRevalidate"],"type":"string"}]},"method":{"enum":["DELETE","GET","HEAD","PATCH","POST","PUT"],"type":"string"},"options":{"type":"object","properties":{"backgroundSync":{"type":"object","properties":{"name":{"type":"string"},"options":{"$ref":"#/definitions/QueueOptions"}},"additionalProperties":false,"required":["name"]},"broadcastUpdate":{"type":"object","properties":{"channelName":{"type":"string"},"options":{"$ref":"#/definitions/BroadcastCacheUpdateOptions"}},"additionalProperties":false,"required":["options"]},"cacheableResponse":{"$ref":"#/definitions/CacheableResponseOptions"},"cacheName":{"type":["null","string"]},"expiration":{"$ref":"#/definitions/ExpirationPluginOptions"},"networkTimeoutSeconds":{"type":"number"},"plugins":{"type":"array","items":{"$ref":"#/definitions/WorkboxPlugin"}},"precacheFallback":{"type":"object","properties":{"fallbackURL":{"type":"string"}},"additionalProperties":false,"required":["fallbackURL"]},"fetchOptions":{"$ref":"#/definitions/RequestInit"},"matchOptions":{"$ref":"#/definitions/CacheQueryOptions"}},"additionalProperties":false},"urlPattern":{"anyOf":[{"$ref":"#/definitions/RegExp"},{"$ref":"#/definitions/RouteMatchCallback"},{"type":"string"}]}},"additionalProperties":false,"required":["handler","urlPattern"]},"RouteHandlerCallback":{"description":"The \"handler\" callback is invoked whenever a `Router` matches a URL/Request\nto a `Route` via its `RouteMatchCallback`. This handler callback should\nreturn a `Promise` that resolves with a `Response`.\n\nIf a non-empty array or object is returned by the `RouteMatchCallback` it\nwill be passed in as this handler's `options.params` argument.","type":"object","additionalProperties":false},"RouteHandlerObject":{"description":"An object with a `handle` method of type `RouteHandlerCallback`.\n\nA `Route` object can be created with either an `RouteHandlerCallback`\nfunction or this `RouteHandler` object. The benefit of the `RouteHandler`\nis it can be extended (as is done by the `workbox-strategies` package).","type":"object","properties":{"handle":{"$ref":"#/definitions/RouteHandlerCallback"}},"additionalProperties":false,"required":["handle"]},"QueueOptions":{"type":"object","properties":{"onSync":{"$ref":"#/definitions/OnSyncCallback"},"maxRetentionTime":{"type":"number"}},"additionalProperties":false},"OnSyncCallback":{"type":"object","additionalProperties":false},"BroadcastCacheUpdateOptions":{"type":"object","properties":{"headersToCheck":{"type":"array","items":{"type":"string"}},"generatePayload":{"type":"object","additionalProperties":false}},"additionalProperties":false},"CacheableResponseOptions":{"type":"object","properties":{"statuses":{"type":"array","items":{"type":"number"}},"headers":{"type":"object","additionalProperties":{"type":"string"}}},"additionalProperties":false},"ExpirationPluginOptions":{"type":"object","properties":{"maxEntries":{"type":"number"},"maxAgeSeconds":{"type":"number"},"matchOptions":{"$ref":"#/definitions/CacheQueryOptions"},"purgeOnQuotaError":{"type":"boolean"}},"additionalProperties":false},"CacheQueryOptions":{"type":"object","properties":{"ignoreMethod":{"type":"boolean"},"ignoreSearch":{"type":"boolean"},"ignoreVary":{"type":"boolean"}},"additionalProperties":false},"WorkboxPlugin":{"description":"An object with optional lifecycle callback properties for the fetch and\ncache operations.","type":"object","properties":{"cacheDidUpdate":{"$ref":"#/definitions/CacheDidUpdateCallback"},"cachedResponseWillBeUsed":{"$ref":"#/definitions/CachedResponseWillBeUsedCallback"},"cacheKeyWillBeUsed":{"$ref":"#/definitions/CacheKeyWillBeUsedCallback"},"cacheWillUpdate":{"$ref":"#/definitions/CacheWillUpdateCallback"},"fetchDidFail":{"$ref":"#/definitions/FetchDidFailCallback"},"fetchDidSucceed":{"$ref":"#/definitions/FetchDidSucceedCallback"},"handlerDidComplete":{"$ref":"#/definitions/HandlerDidCompleteCallback"},"handlerDidError":{"$ref":"#/definitions/HandlerDidErrorCallback"},"handlerDidRespond":{"$ref":"#/definitions/HandlerDidRespondCallback"},"handlerWillRespond":{"$ref":"#/definitions/HandlerWillRespondCallback"},"handlerWillStart":{"$ref":"#/definitions/HandlerWillStartCallback"},"requestWillFetch":{"$ref":"#/definitions/RequestWillFetchCallback"}},"additionalProperties":false},"CacheDidUpdateCallback":{"type":"object","additionalProperties":false},"CachedResponseWillBeUsedCallback":{"type":"object","additionalProperties":false},"CacheKeyWillBeUsedCallback":{"type":"object","additionalProperties":false},"CacheWillUpdateCallback":{"type":"object","additionalProperties":false},"FetchDidFailCallback":{"type":"object","additionalProperties":false},"FetchDidSucceedCallback":{"type":"object","additionalProperties":false},"HandlerDidCompleteCallback":{"type":"object","additionalProperties":false},"HandlerDidErrorCallback":{"type":"object","additionalProperties":false},"HandlerDidRespondCallback":{"type":"object","additionalProperties":false},"HandlerWillRespondCallback":{"type":"object","additionalProperties":false},"HandlerWillStartCallback":{"type":"object","additionalProperties":false},"RequestWillFetchCallback":{"type":"object","additionalProperties":false},"RequestInit":{"type":"object","properties":{"body":{"anyOf":[{"$ref":"#/definitions/ArrayBuffer"},{"$ref":"#/definitions/ArrayBufferView"},{"$ref":"#/definitions/Blob"},{"$ref":"#/definitions/FormData"},{"$ref":"#/definitions/URLSearchParams"},{"$ref":"#/definitions/ReadableStream"},{"type":["null","string"]}]},"cache":{"enum":["default","force-cache","no-cache","no-store","only-if-cached","reload"],"type":"string"},"credentials":{"enum":["include","omit","same-origin"],"type":"string"},"headers":{"anyOf":[{"$ref":"#/definitions/Headers"},{"type":"array","items":{"type":"array","items":{"type":"string"}}},{"$ref":"#/definitions/Record"}]},"integrity":{"type":"string"},"keepalive":{"type":"boolean"},"method":{"type":"string"},"mode":{"enum":["cors","navigate","no-cors","same-origin"],"type":"string"},"redirect":{"enum":["error","follow","manual"],"type":"string"},"referrer":{"type":"string"},"referrerPolicy":{"enum":["","no-referrer","no-referrer-when-downgrade","origin","origin-when-cross-origin","same-origin","strict-origin","strict-origin-when-cross-origin","unsafe-url"],"type":"string"},"signal":{"anyOf":[{"$ref":"#/definitions/AbortSignal"},{"type":"null"}]},"window":{}},"additionalProperties":false},"ArrayBuffer":{"type":"object","properties":{"byteLength":{"type":"number"},"__@toStringTag":{"type":"string"}},"additionalProperties":false,"required":["__@toStringTag","byteLength"]},"ArrayBufferView":{"type":"object","properties":{"buffer":{"anyOf":[{"$ref":"#/definitions/ArrayBuffer"},{"$ref":"#/definitions/SharedArrayBuffer"}]},"byteLength":{"type":"number"},"byteOffset":{"type":"number"}},"additionalProperties":false,"required":["buffer","byteLength","byteOffset"]},"SharedArrayBuffer":{"type":"object","properties":{"byteLength":{"type":"number"},"__@species":{"$ref":"#/definitions/SharedArrayBuffer"},"__@toStringTag":{"type":"string","enum":["SharedArrayBuffer"]}},"additionalProperties":false,"required":["__@species","__@toStringTag","byteLength"]},"Blob":{"type":"object","properties":{"size":{"type":"number"},"type":{"type":"string"}},"additionalProperties":false,"required":["size","type"]},"FormData":{"type":"object","additionalProperties":false},"URLSearchParams":{"type":"object","additionalProperties":false},"ReadableStream":{"type":"object","properties":{"locked":{"type":"boolean"}},"additionalProperties":false,"required":["locked"]},"Headers":{"type":"object","additionalProperties":false},"Record":{"type":"object","additionalProperties":false},"AbortSignal":{"type":"object","properties":{"aborted":{"type":"boolean"},"onabort":{"anyOf":[{"type":"object","additionalProperties":false},{"type":"null"}]}},"additionalProperties":false,"required":["aborted","onabort"]},"RouteMatchCallback":{"description":"The \"match\" callback is used to determine if a `Route` should apply for a\nparticular URL and request. When matching occurs in response to a fetch\nevent from the client, the `event` object is also supplied. However, since\nthe match callback can be invoked outside of a fetch event, matching logic\nshould not assume the `event` object will always be available.\nIf the match callback returns a truthy value, the matching route's\n`RouteHandlerCallback` will be invoked immediately. If the value returned\nis a non-empty array or object, that value will be set on the handler's\n`options.params` argument.","type":"object","additionalProperties":false},"ManifestEntry":{"type":"object","properties":{"integrity":{"type":"string"},"revision":{"type":["null","string"]},"url":{"type":"string"}},"additionalProperties":false,"required":["revision","url"]}},"$schema":"http://json-schema.org/draft-07/schema#"} diff --git a/packages/workbox-build/src/schema/WebpackGenerateSWOptions.json b/packages/workbox-build/src/schema/WebpackGenerateSWOptions.json index bb3f6f849..8507b76ea 100644 --- a/packages/workbox-build/src/schema/WebpackGenerateSWOptions.json +++ b/packages/workbox-build/src/schema/WebpackGenerateSWOptions.json @@ -1 +1 @@ -{"additionalProperties":false,"type":"object","properties":{"chunks":{"type":"array","items":{"type":"string"}},"exclude":{"default":"[/\\.map$/, /^manifest.*\\.js$/,]","type":"array","items":{"anyOf":[{"$ref":"#/definitions/RegExp"},{"type":"object","additionalProperties":false},{"type":"string"}]}},"excludeChunks":{"type":"array","items":{"type":"string"}},"include":{"type":"array","items":{"anyOf":[{"$ref":"#/definitions/RegExp"},{"type":"object","additionalProperties":false},{"type":"string"}]}},"mode":{"default":"production","type":["null","string"]},"babelPresetEnvTargets":{"default":["chrome >= 56"],"type":"array","items":{"type":"string"}},"cacheId":{"type":["null","string"]},"cleanupOutdatedCaches":{"default":false,"type":"boolean"},"clientsClaim":{"default":false,"type":"boolean"},"directoryIndex":{"type":["null","string"]},"disableDevLogs":{"default":false,"type":"boolean"},"ignoreURLParametersMatching":{"type":"array","items":{"$ref":"#/definitions/RegExp"}},"importScripts":{"type":"array","items":{"type":"string"}},"inlineWorkboxRuntime":{"default":false,"type":"boolean"},"navigateFallback":{"default":null,"type":["null","string"]},"navigateFallbackAllowlist":{"type":"array","items":{"$ref":"#/definitions/RegExp"}},"navigateFallbackDenylist":{"type":"array","items":{"$ref":"#/definitions/RegExp"}},"navigationPreload":{"default":false,"type":"boolean"},"offlineGoogleAnalytics":{"default":false,"anyOf":[{"$ref":"#/definitions/GoogleAnalyticsInitializeOptions"},{"type":"boolean"}]},"runtimeCaching":{"type":"array","items":{"$ref":"#/definitions/RuntimeCaching"}},"skipWaiting":{"default":false,"type":"boolean"},"sourcemap":{"default":true,"type":"boolean"},"additionalManifestEntries":{"type":"array","items":{"anyOf":[{"$ref":"#/definitions/ManifestEntry"},{"type":"string"}]}},"dontCacheBustURLsMatching":{"$ref":"#/definitions/RegExp"},"manifestTransforms":{"type":"array","items":{"type":"object","additionalProperties":false}},"maximumFileSizeToCacheInBytes":{"default":2097152,"type":"number"},"modifyURLPrefix":{"type":"object","additionalProperties":{"type":"string"}},"swDest":{"default":"service-worker.js","type":"string"},"importScriptsViaChunks":{"type":"array","items":{"type":"string"}}},"definitions":{"RegExp":{"type":"object","properties":{"source":{"type":"string"},"global":{"type":"boolean"},"ignoreCase":{"type":"boolean"},"multiline":{"type":"boolean"},"lastIndex":{"type":"number"},"flags":{"type":"string"},"sticky":{"type":"boolean"},"unicode":{"type":"boolean"},"dotAll":{"type":"boolean"}},"additionalProperties":false},"GoogleAnalyticsInitializeOptions":{"type":"object","properties":{"cacheName":{"type":"string"},"parameterOverrides":{"type":"object","additionalProperties":{"type":"string"}},"hitFilter":{"type":"object","additionalProperties":false}},"additionalProperties":false},"RuntimeCaching":{"type":"object","properties":{"handler":{"anyOf":[{"$ref":"#/definitions/RouteHandlerCallback"},{"$ref":"#/definitions/RouteHandlerObject"},{"enum":["CacheFirst","CacheOnly","NetworkFirst","NetworkOnly","StaleWhileRevalidate"],"type":"string"}]},"method":{"enum":["DELETE","GET","HEAD","PATCH","POST","PUT"],"type":"string"},"options":{"type":"object","properties":{"backgroundSync":{"type":"object","properties":{"name":{"type":"string"},"options":{"$ref":"#/definitions/QueueOptions"}},"additionalProperties":false},"broadcastUpdate":{"type":"object","properties":{"channelName":{"type":"string"},"options":{"$ref":"#/definitions/BroadcastCacheUpdateOptions"}},"additionalProperties":false},"cacheableResponse":{"$ref":"#/definitions/CacheableResponseOptions"},"cacheName":{"type":["null","string"]},"expiration":{"$ref":"#/definitions/ExpirationPluginOptions"},"networkTimeoutSeconds":{"type":"number"},"plugins":{"type":"array","items":{"$ref":"#/definitions/WorkboxPlugin"}},"precacheFallback":{"type":"object","properties":{"fallbackURL":{"type":"string"}},"additionalProperties":false},"fetchOptions":{"$ref":"#/definitions/RequestInit"},"matchOptions":{"$ref":"#/definitions/CacheQueryOptions"}},"additionalProperties":false},"urlPattern":{"anyOf":[{"$ref":"#/definitions/RegExp"},{"$ref":"#/definitions/RouteMatchCallback"},{"type":"string"}]}},"additionalProperties":false},"RouteHandlerCallback":{"description":"The \"handler\" callback is invoked whenever a `Router` matches a URL/Request\nto a `Route` via its `RouteMatchCallback`. This handler callback should\nreturn a `Promise` that resolves with a `Response`.\n\nIf a non-empty array or object is returned by the `RouteMatchCallback` it\nwill be passed in as this handler's `options.params` argument.","type":"object","additionalProperties":false},"RouteHandlerObject":{"description":"An object with a `handle` method of type `RouteHandlerCallback`.\n\nA `Route` object can be created with either an `RouteHandlerCallback`\nfunction or this `RouteHandler` object. The benefit of the `RouteHandler`\nis it can be extended (as is done by the `workbox-strategies` package).","type":"object","properties":{"handle":{"$ref":"#/definitions/RouteHandlerCallback"}},"additionalProperties":false},"QueueOptions":{"type":"object","properties":{"onSync":{"$ref":"#/definitions/OnSyncCallback"},"maxRetentionTime":{"type":"number"}},"additionalProperties":false},"OnSyncCallback":{"type":"object","additionalProperties":false},"BroadcastCacheUpdateOptions":{"type":"object","properties":{"headersToCheck":{"type":"array","items":{"type":"string"}},"generatePayload":{"type":"object","additionalProperties":false}},"additionalProperties":false},"CacheableResponseOptions":{"type":"object","properties":{"statuses":{"type":"array","items":{"type":"number"}},"headers":{"type":"object","additionalProperties":{"type":"string"}}},"additionalProperties":false},"ExpirationPluginOptions":{"type":"object","properties":{"maxEntries":{"type":"number"},"maxAgeSeconds":{"type":"number"},"matchOptions":{"$ref":"#/definitions/CacheQueryOptions"},"purgeOnQuotaError":{"type":"boolean"}},"additionalProperties":false},"CacheQueryOptions":{"type":"object","properties":{"ignoreMethod":{"type":"boolean"},"ignoreSearch":{"type":"boolean"},"ignoreVary":{"type":"boolean"}},"additionalProperties":false},"WorkboxPlugin":{"description":"An object with optional lifecycle callback properties for the fetch and\ncache operations.","type":"object","properties":{"cacheDidUpdate":{"$ref":"#/definitions/CacheDidUpdateCallback"},"cachedResponseWillBeUsed":{"$ref":"#/definitions/CachedResponseWillBeUsedCallback"},"cacheKeyWillBeUsed":{"$ref":"#/definitions/CacheKeyWillBeUsedCallback"},"cacheWillUpdate":{"$ref":"#/definitions/CacheWillUpdateCallback"},"fetchDidFail":{"$ref":"#/definitions/FetchDidFailCallback"},"fetchDidSucceed":{"$ref":"#/definitions/FetchDidSucceedCallback"},"handlerDidComplete":{"$ref":"#/definitions/HandlerDidCompleteCallback"},"handlerDidError":{"$ref":"#/definitions/HandlerDidErrorCallback"},"handlerDidRespond":{"$ref":"#/definitions/HandlerDidRespondCallback"},"handlerWillRespond":{"$ref":"#/definitions/HandlerWillRespondCallback"},"handlerWillStart":{"$ref":"#/definitions/HandlerWillStartCallback"},"requestWillFetch":{"$ref":"#/definitions/RequestWillFetchCallback"}},"additionalProperties":false},"CacheDidUpdateCallback":{"type":"object","additionalProperties":false},"CachedResponseWillBeUsedCallback":{"type":"object","additionalProperties":false},"CacheKeyWillBeUsedCallback":{"type":"object","additionalProperties":false},"CacheWillUpdateCallback":{"type":"object","additionalProperties":false},"FetchDidFailCallback":{"type":"object","additionalProperties":false},"FetchDidSucceedCallback":{"type":"object","additionalProperties":false},"HandlerDidCompleteCallback":{"type":"object","additionalProperties":false},"HandlerDidErrorCallback":{"type":"object","additionalProperties":false},"HandlerDidRespondCallback":{"type":"object","additionalProperties":false},"HandlerWillRespondCallback":{"type":"object","additionalProperties":false},"HandlerWillStartCallback":{"type":"object","additionalProperties":false},"RequestWillFetchCallback":{"type":"object","additionalProperties":false},"RequestInit":{"type":"object","properties":{"body":{"anyOf":[{"$ref":"#/definitions/ArrayBuffer"},{"$ref":"#/definitions/ArrayBufferView"},{"$ref":"#/definitions/Blob"},{"$ref":"#/definitions/FormData"},{"$ref":"#/definitions/URLSearchParams"},{"$ref":"#/definitions/ReadableStream"},{"type":["null","string"]}]},"cache":{"enum":["default","force-cache","no-cache","no-store","only-if-cached","reload"],"type":"string"},"credentials":{"enum":["include","omit","same-origin"],"type":"string"},"headers":{"anyOf":[{"$ref":"#/definitions/Headers"},{"type":"array","items":{"type":"array","items":{"type":"string"}}},{"$ref":"#/definitions/Record"}]},"integrity":{"type":"string"},"keepalive":{"type":"boolean"},"method":{"type":"string"},"mode":{"enum":["cors","navigate","no-cors","same-origin"],"type":"string"},"redirect":{"enum":["error","follow","manual"],"type":"string"},"referrer":{"type":"string"},"referrerPolicy":{"enum":["","no-referrer","no-referrer-when-downgrade","origin","origin-when-cross-origin","same-origin","strict-origin","strict-origin-when-cross-origin","unsafe-url"],"type":"string"},"signal":{"anyOf":[{"$ref":"#/definitions/AbortSignal"},{"type":"null"}]},"window":{}},"additionalProperties":false},"ArrayBuffer":{"type":"object","properties":{"byteLength":{"type":"number"},"__@toStringTag":{"type":"string"}},"additionalProperties":false},"ArrayBufferView":{"type":"object","properties":{"buffer":{"anyOf":[{"$ref":"#/definitions/ArrayBuffer"},{"$ref":"#/definitions/SharedArrayBuffer"}]},"byteLength":{"type":"number"},"byteOffset":{"type":"number"}},"additionalProperties":false},"SharedArrayBuffer":{"type":"object","properties":{"byteLength":{"type":"number"},"__@species":{"$ref":"#/definitions/SharedArrayBuffer"},"__@toStringTag":{"type":"string","enum":["SharedArrayBuffer"]}},"additionalProperties":false},"Blob":{"type":"object","properties":{"size":{"type":"number"},"type":{"type":"string"}},"additionalProperties":false},"FormData":{"type":"object","additionalProperties":false},"URLSearchParams":{"type":"object","additionalProperties":false},"ReadableStream":{"type":"object","properties":{"locked":{"type":"boolean"}},"additionalProperties":false},"Headers":{"type":"object","additionalProperties":false},"Record":{"type":"object","additionalProperties":false},"AbortSignal":{"type":"object","properties":{"aborted":{"type":"boolean"},"onabort":{"anyOf":[{"type":"object","additionalProperties":false},{"type":"null"}]}},"additionalProperties":false},"RouteMatchCallback":{"description":"The \"match\" callback is used to determine if a `Route` should apply for a\nparticular URL and request. When matching occurs in response to a fetch\nevent from the client, the `event` object is also supplied. However, since\nthe match callback can be invoked outside of a fetch event, matching logic\nshould not assume the `event` object will always be available.\nIf the match callback returns a truthy value, the matching route's\n`RouteHandlerCallback` will be invoked immediately. If the value returned\nis a non-empty array or object, that value will be set on the handler's\n`options.params` argument.","type":"object","additionalProperties":false},"ManifestEntry":{"type":"object","properties":{"integrity":{"type":"string"},"revision":{"type":["null","string"]},"url":{"type":"string"}},"additionalProperties":false}},"$schema":"http://json-schema.org/draft-07/schema#"} +{"additionalProperties":false,"type":"object","properties":{"chunks":{"type":"array","items":{"type":"string"}},"exclude":{"default":"[/\\.map$/, /^manifest.*\\.js$/,]","type":"array","items":{"anyOf":[{"$ref":"#/definitions/RegExp"},{"type":"object","additionalProperties":false},{"type":"string"}]}},"excludeChunks":{"type":"array","items":{"type":"string"}},"include":{"type":"array","items":{"anyOf":[{"$ref":"#/definitions/RegExp"},{"type":"object","additionalProperties":false},{"type":"string"}]}},"mode":{"default":"production","type":["null","string"]},"babelPresetEnvTargets":{"default":["chrome >= 56"],"type":"array","items":{"type":"string"}},"cacheId":{"type":["null","string"]},"cleanupOutdatedCaches":{"default":false,"type":"boolean"},"clientsClaim":{"default":false,"type":"boolean"},"directoryIndex":{"type":["null","string"]},"disableDevLogs":{"default":false,"type":"boolean"},"ignoreURLParametersMatching":{"type":"array","items":{"$ref":"#/definitions/RegExp"}},"importScripts":{"type":"array","items":{"type":"string"}},"inlineWorkboxRuntime":{"default":false,"type":"boolean"},"navigateFallback":{"default":null,"type":["null","string"]},"navigateFallbackAllowlist":{"type":"array","items":{"$ref":"#/definitions/RegExp"}},"navigateFallbackDenylist":{"type":"array","items":{"$ref":"#/definitions/RegExp"}},"navigationPreload":{"default":false,"type":"boolean"},"offlineGoogleAnalytics":{"default":false,"anyOf":[{"$ref":"#/definitions/GoogleAnalyticsInitializeOptions"},{"type":"boolean"}]},"runtimeCaching":{"type":"array","items":{"$ref":"#/definitions/RuntimeCaching"}},"skipWaiting":{"default":false,"type":"boolean"},"sourcemap":{"default":true,"type":"boolean"},"additionalManifestEntries":{"type":"array","items":{"anyOf":[{"$ref":"#/definitions/ManifestEntry"},{"type":"string"}]}},"dontCacheBustURLsMatching":{"$ref":"#/definitions/RegExp"},"manifestTransforms":{"type":"array","items":{"type":"object","additionalProperties":false}},"maximumFileSizeToCacheInBytes":{"default":2097152,"type":"number"},"modifyURLPrefix":{"type":"object","additionalProperties":{"type":"string"}},"swDest":{"default":"service-worker.js","type":"string"},"importScriptsViaChunks":{"type":"array","items":{"type":"string"}}},"required":["importScriptsViaChunks","swDest"],"definitions":{"RegExp":{"type":"object","properties":{"source":{"type":"string"},"global":{"type":"boolean"},"ignoreCase":{"type":"boolean"},"multiline":{"type":"boolean"},"lastIndex":{"type":"number"},"flags":{"type":"string"},"sticky":{"type":"boolean"},"unicode":{"type":"boolean"},"dotAll":{"type":"boolean"}},"additionalProperties":false,"required":["dotAll","flags","global","ignoreCase","lastIndex","multiline","source","sticky","unicode"]},"GoogleAnalyticsInitializeOptions":{"type":"object","properties":{"cacheName":{"type":"string"},"parameterOverrides":{"type":"object","additionalProperties":{"type":"string"}},"hitFilter":{"type":"object","additionalProperties":false}},"additionalProperties":false},"RuntimeCaching":{"type":"object","properties":{"handler":{"anyOf":[{"$ref":"#/definitions/RouteHandlerCallback"},{"$ref":"#/definitions/RouteHandlerObject"},{"enum":["CacheFirst","CacheOnly","NetworkFirst","NetworkOnly","StaleWhileRevalidate"],"type":"string"}]},"method":{"enum":["DELETE","GET","HEAD","PATCH","POST","PUT"],"type":"string"},"options":{"type":"object","properties":{"backgroundSync":{"type":"object","properties":{"name":{"type":"string"},"options":{"$ref":"#/definitions/QueueOptions"}},"additionalProperties":false,"required":["name"]},"broadcastUpdate":{"type":"object","properties":{"channelName":{"type":"string"},"options":{"$ref":"#/definitions/BroadcastCacheUpdateOptions"}},"additionalProperties":false,"required":["options"]},"cacheableResponse":{"$ref":"#/definitions/CacheableResponseOptions"},"cacheName":{"type":["null","string"]},"expiration":{"$ref":"#/definitions/ExpirationPluginOptions"},"networkTimeoutSeconds":{"type":"number"},"plugins":{"type":"array","items":{"$ref":"#/definitions/WorkboxPlugin"}},"precacheFallback":{"type":"object","properties":{"fallbackURL":{"type":"string"}},"additionalProperties":false,"required":["fallbackURL"]},"fetchOptions":{"$ref":"#/definitions/RequestInit"},"matchOptions":{"$ref":"#/definitions/CacheQueryOptions"}},"additionalProperties":false},"urlPattern":{"anyOf":[{"$ref":"#/definitions/RegExp"},{"$ref":"#/definitions/RouteMatchCallback"},{"type":"string"}]}},"additionalProperties":false,"required":["handler","urlPattern"]},"RouteHandlerCallback":{"description":"The \"handler\" callback is invoked whenever a `Router` matches a URL/Request\nto a `Route` via its `RouteMatchCallback`. This handler callback should\nreturn a `Promise` that resolves with a `Response`.\n\nIf a non-empty array or object is returned by the `RouteMatchCallback` it\nwill be passed in as this handler's `options.params` argument.","type":"object","additionalProperties":false},"RouteHandlerObject":{"description":"An object with a `handle` method of type `RouteHandlerCallback`.\n\nA `Route` object can be created with either an `RouteHandlerCallback`\nfunction or this `RouteHandler` object. The benefit of the `RouteHandler`\nis it can be extended (as is done by the `workbox-strategies` package).","type":"object","properties":{"handle":{"$ref":"#/definitions/RouteHandlerCallback"}},"additionalProperties":false,"required":["handle"]},"QueueOptions":{"type":"object","properties":{"onSync":{"$ref":"#/definitions/OnSyncCallback"},"maxRetentionTime":{"type":"number"}},"additionalProperties":false},"OnSyncCallback":{"type":"object","additionalProperties":false},"BroadcastCacheUpdateOptions":{"type":"object","properties":{"headersToCheck":{"type":"array","items":{"type":"string"}},"generatePayload":{"type":"object","additionalProperties":false}},"additionalProperties":false},"CacheableResponseOptions":{"type":"object","properties":{"statuses":{"type":"array","items":{"type":"number"}},"headers":{"type":"object","additionalProperties":{"type":"string"}}},"additionalProperties":false},"ExpirationPluginOptions":{"type":"object","properties":{"maxEntries":{"type":"number"},"maxAgeSeconds":{"type":"number"},"matchOptions":{"$ref":"#/definitions/CacheQueryOptions"},"purgeOnQuotaError":{"type":"boolean"}},"additionalProperties":false},"CacheQueryOptions":{"type":"object","properties":{"ignoreMethod":{"type":"boolean"},"ignoreSearch":{"type":"boolean"},"ignoreVary":{"type":"boolean"}},"additionalProperties":false},"WorkboxPlugin":{"description":"An object with optional lifecycle callback properties for the fetch and\ncache operations.","type":"object","properties":{"cacheDidUpdate":{"$ref":"#/definitions/CacheDidUpdateCallback"},"cachedResponseWillBeUsed":{"$ref":"#/definitions/CachedResponseWillBeUsedCallback"},"cacheKeyWillBeUsed":{"$ref":"#/definitions/CacheKeyWillBeUsedCallback"},"cacheWillUpdate":{"$ref":"#/definitions/CacheWillUpdateCallback"},"fetchDidFail":{"$ref":"#/definitions/FetchDidFailCallback"},"fetchDidSucceed":{"$ref":"#/definitions/FetchDidSucceedCallback"},"handlerDidComplete":{"$ref":"#/definitions/HandlerDidCompleteCallback"},"handlerDidError":{"$ref":"#/definitions/HandlerDidErrorCallback"},"handlerDidRespond":{"$ref":"#/definitions/HandlerDidRespondCallback"},"handlerWillRespond":{"$ref":"#/definitions/HandlerWillRespondCallback"},"handlerWillStart":{"$ref":"#/definitions/HandlerWillStartCallback"},"requestWillFetch":{"$ref":"#/definitions/RequestWillFetchCallback"}},"additionalProperties":false},"CacheDidUpdateCallback":{"type":"object","additionalProperties":false},"CachedResponseWillBeUsedCallback":{"type":"object","additionalProperties":false},"CacheKeyWillBeUsedCallback":{"type":"object","additionalProperties":false},"CacheWillUpdateCallback":{"type":"object","additionalProperties":false},"FetchDidFailCallback":{"type":"object","additionalProperties":false},"FetchDidSucceedCallback":{"type":"object","additionalProperties":false},"HandlerDidCompleteCallback":{"type":"object","additionalProperties":false},"HandlerDidErrorCallback":{"type":"object","additionalProperties":false},"HandlerDidRespondCallback":{"type":"object","additionalProperties":false},"HandlerWillRespondCallback":{"type":"object","additionalProperties":false},"HandlerWillStartCallback":{"type":"object","additionalProperties":false},"RequestWillFetchCallback":{"type":"object","additionalProperties":false},"RequestInit":{"type":"object","properties":{"body":{"anyOf":[{"$ref":"#/definitions/ArrayBuffer"},{"$ref":"#/definitions/ArrayBufferView"},{"$ref":"#/definitions/Blob"},{"$ref":"#/definitions/FormData"},{"$ref":"#/definitions/URLSearchParams"},{"$ref":"#/definitions/ReadableStream"},{"type":["null","string"]}]},"cache":{"enum":["default","force-cache","no-cache","no-store","only-if-cached","reload"],"type":"string"},"credentials":{"enum":["include","omit","same-origin"],"type":"string"},"headers":{"anyOf":[{"$ref":"#/definitions/Headers"},{"type":"array","items":{"type":"array","items":{"type":"string"}}},{"$ref":"#/definitions/Record"}]},"integrity":{"type":"string"},"keepalive":{"type":"boolean"},"method":{"type":"string"},"mode":{"enum":["cors","navigate","no-cors","same-origin"],"type":"string"},"redirect":{"enum":["error","follow","manual"],"type":"string"},"referrer":{"type":"string"},"referrerPolicy":{"enum":["","no-referrer","no-referrer-when-downgrade","origin","origin-when-cross-origin","same-origin","strict-origin","strict-origin-when-cross-origin","unsafe-url"],"type":"string"},"signal":{"anyOf":[{"$ref":"#/definitions/AbortSignal"},{"type":"null"}]},"window":{}},"additionalProperties":false},"ArrayBuffer":{"type":"object","properties":{"byteLength":{"type":"number"},"__@toStringTag":{"type":"string"}},"additionalProperties":false,"required":["__@toStringTag","byteLength"]},"ArrayBufferView":{"type":"object","properties":{"buffer":{"anyOf":[{"$ref":"#/definitions/ArrayBuffer"},{"$ref":"#/definitions/SharedArrayBuffer"}]},"byteLength":{"type":"number"},"byteOffset":{"type":"number"}},"additionalProperties":false,"required":["buffer","byteLength","byteOffset"]},"SharedArrayBuffer":{"type":"object","properties":{"byteLength":{"type":"number"},"__@species":{"$ref":"#/definitions/SharedArrayBuffer"},"__@toStringTag":{"type":"string","enum":["SharedArrayBuffer"]}},"additionalProperties":false,"required":["__@species","__@toStringTag","byteLength"]},"Blob":{"type":"object","properties":{"size":{"type":"number"},"type":{"type":"string"}},"additionalProperties":false,"required":["size","type"]},"FormData":{"type":"object","additionalProperties":false},"URLSearchParams":{"type":"object","additionalProperties":false},"ReadableStream":{"type":"object","properties":{"locked":{"type":"boolean"}},"additionalProperties":false,"required":["locked"]},"Headers":{"type":"object","additionalProperties":false},"Record":{"type":"object","additionalProperties":false},"AbortSignal":{"type":"object","properties":{"aborted":{"type":"boolean"},"onabort":{"anyOf":[{"type":"object","additionalProperties":false},{"type":"null"}]}},"additionalProperties":false,"required":["aborted","onabort"]},"RouteMatchCallback":{"description":"The \"match\" callback is used to determine if a `Route` should apply for a\nparticular URL and request. When matching occurs in response to a fetch\nevent from the client, the `event` object is also supplied. However, since\nthe match callback can be invoked outside of a fetch event, matching logic\nshould not assume the `event` object will always be available.\nIf the match callback returns a truthy value, the matching route's\n`RouteHandlerCallback` will be invoked immediately. If the value returned\nis a non-empty array or object, that value will be set on the handler's\n`options.params` argument.","type":"object","additionalProperties":false},"ManifestEntry":{"type":"object","properties":{"integrity":{"type":"string"},"revision":{"type":["null","string"]},"url":{"type":"string"}},"additionalProperties":false,"required":["revision","url"]}},"$schema":"http://json-schema.org/draft-07/schema#"} diff --git a/packages/workbox-build/src/schema/WebpackInjectManifestOptions.json b/packages/workbox-build/src/schema/WebpackInjectManifestOptions.json index 1b8cff05e..4198d4227 100644 --- a/packages/workbox-build/src/schema/WebpackInjectManifestOptions.json +++ b/packages/workbox-build/src/schema/WebpackInjectManifestOptions.json @@ -1 +1 @@ -{"additionalProperties":false,"type":"object","properties":{"chunks":{"type":"array","items":{"type":"string"}},"exclude":{"default":"[/\\.map$/, /^manifest.*\\.js$/,]","type":"array","items":{"anyOf":[{"$ref":"#/definitions/RegExp"},{"type":"object","additionalProperties":false},{"type":"string"}]}},"excludeChunks":{"type":"array","items":{"type":"string"}},"include":{"type":"array","items":{"anyOf":[{"$ref":"#/definitions/RegExp"},{"type":"object","additionalProperties":false},{"type":"string"}]}},"mode":{"type":["null","string"]},"injectionPoint":{"default":"self.__WB_MANIFEST","type":"string"},"swSrc":{"type":"string"},"additionalManifestEntries":{"type":"array","items":{"anyOf":[{"$ref":"#/definitions/ManifestEntry"},{"type":"string"}]}},"dontCacheBustURLsMatching":{"$ref":"#/definitions/RegExp"},"manifestTransforms":{"type":"array","items":{"type":"object","additionalProperties":false}},"maximumFileSizeToCacheInBytes":{"default":2097152,"type":"number"},"modifyURLPrefix":{"type":"object","additionalProperties":{"type":"string"}},"swDest":{"default":"service-worker.js","type":"string"},"compileSrc":{"default":true,"type":"boolean"},"webpackCompilationPlugins":{"type":"array","items":{}}},"definitions":{"RegExp":{"type":"object","properties":{"source":{"type":"string"},"global":{"type":"boolean"},"ignoreCase":{"type":"boolean"},"multiline":{"type":"boolean"},"lastIndex":{"type":"number"},"flags":{"type":"string"},"sticky":{"type":"boolean"},"unicode":{"type":"boolean"},"dotAll":{"type":"boolean"}},"additionalProperties":false},"GoogleAnalyticsInitializeOptions":{"type":"object","properties":{"cacheName":{"type":"string"},"parameterOverrides":{"type":"object","additionalProperties":{"type":"string"}},"hitFilter":{"type":"object","additionalProperties":false}},"additionalProperties":false},"RuntimeCaching":{"type":"object","properties":{"handler":{"anyOf":[{"$ref":"#/definitions/RouteHandlerCallback"},{"$ref":"#/definitions/RouteHandlerObject"},{"enum":["CacheFirst","CacheOnly","NetworkFirst","NetworkOnly","StaleWhileRevalidate"],"type":"string"}]},"method":{"enum":["DELETE","GET","HEAD","PATCH","POST","PUT"],"type":"string"},"options":{"type":"object","properties":{"backgroundSync":{"type":"object","properties":{"name":{"type":"string"},"options":{"$ref":"#/definitions/QueueOptions"}},"additionalProperties":false},"broadcastUpdate":{"type":"object","properties":{"channelName":{"type":"string"},"options":{"$ref":"#/definitions/BroadcastCacheUpdateOptions"}},"additionalProperties":false},"cacheableResponse":{"$ref":"#/definitions/CacheableResponseOptions"},"cacheName":{"type":["null","string"]},"expiration":{"$ref":"#/definitions/ExpirationPluginOptions"},"networkTimeoutSeconds":{"type":"number"},"plugins":{"type":"array","items":{"$ref":"#/definitions/WorkboxPlugin"}},"precacheFallback":{"type":"object","properties":{"fallbackURL":{"type":"string"}},"additionalProperties":false},"fetchOptions":{"$ref":"#/definitions/RequestInit"},"matchOptions":{"$ref":"#/definitions/CacheQueryOptions"}},"additionalProperties":false},"urlPattern":{"anyOf":[{"$ref":"#/definitions/RegExp"},{"$ref":"#/definitions/RouteMatchCallback"},{"type":"string"}]}},"additionalProperties":false},"RouteHandlerCallback":{"description":"The \"handler\" callback is invoked whenever a `Router` matches a URL/Request\nto a `Route` via its `RouteMatchCallback`. This handler callback should\nreturn a `Promise` that resolves with a `Response`.\n\nIf a non-empty array or object is returned by the `RouteMatchCallback` it\nwill be passed in as this handler's `options.params` argument.","type":"object","additionalProperties":false},"RouteHandlerObject":{"description":"An object with a `handle` method of type `RouteHandlerCallback`.\n\nA `Route` object can be created with either an `RouteHandlerCallback`\nfunction or this `RouteHandler` object. The benefit of the `RouteHandler`\nis it can be extended (as is done by the `workbox-strategies` package).","type":"object","properties":{"handle":{"$ref":"#/definitions/RouteHandlerCallback"}},"additionalProperties":false},"QueueOptions":{"type":"object","properties":{"onSync":{"$ref":"#/definitions/OnSyncCallback"},"maxRetentionTime":{"type":"number"}},"additionalProperties":false},"OnSyncCallback":{"type":"object","additionalProperties":false},"BroadcastCacheUpdateOptions":{"type":"object","properties":{"headersToCheck":{"type":"array","items":{"type":"string"}},"generatePayload":{"type":"object","additionalProperties":false}},"additionalProperties":false},"CacheableResponseOptions":{"type":"object","properties":{"statuses":{"type":"array","items":{"type":"number"}},"headers":{"type":"object","additionalProperties":{"type":"string"}}},"additionalProperties":false},"ExpirationPluginOptions":{"type":"object","properties":{"maxEntries":{"type":"number"},"maxAgeSeconds":{"type":"number"},"matchOptions":{"$ref":"#/definitions/CacheQueryOptions"},"purgeOnQuotaError":{"type":"boolean"}},"additionalProperties":false},"CacheQueryOptions":{"type":"object","properties":{"ignoreMethod":{"type":"boolean"},"ignoreSearch":{"type":"boolean"},"ignoreVary":{"type":"boolean"}},"additionalProperties":false},"WorkboxPlugin":{"description":"An object with optional lifecycle callback properties for the fetch and\ncache operations.","type":"object","properties":{"cacheDidUpdate":{"$ref":"#/definitions/CacheDidUpdateCallback"},"cachedResponseWillBeUsed":{"$ref":"#/definitions/CachedResponseWillBeUsedCallback"},"cacheKeyWillBeUsed":{"$ref":"#/definitions/CacheKeyWillBeUsedCallback"},"cacheWillUpdate":{"$ref":"#/definitions/CacheWillUpdateCallback"},"fetchDidFail":{"$ref":"#/definitions/FetchDidFailCallback"},"fetchDidSucceed":{"$ref":"#/definitions/FetchDidSucceedCallback"},"handlerDidComplete":{"$ref":"#/definitions/HandlerDidCompleteCallback"},"handlerDidError":{"$ref":"#/definitions/HandlerDidErrorCallback"},"handlerDidRespond":{"$ref":"#/definitions/HandlerDidRespondCallback"},"handlerWillRespond":{"$ref":"#/definitions/HandlerWillRespondCallback"},"handlerWillStart":{"$ref":"#/definitions/HandlerWillStartCallback"},"requestWillFetch":{"$ref":"#/definitions/RequestWillFetchCallback"}},"additionalProperties":false},"CacheDidUpdateCallback":{"type":"object","additionalProperties":false},"CachedResponseWillBeUsedCallback":{"type":"object","additionalProperties":false},"CacheKeyWillBeUsedCallback":{"type":"object","additionalProperties":false},"CacheWillUpdateCallback":{"type":"object","additionalProperties":false},"FetchDidFailCallback":{"type":"object","additionalProperties":false},"FetchDidSucceedCallback":{"type":"object","additionalProperties":false},"HandlerDidCompleteCallback":{"type":"object","additionalProperties":false},"HandlerDidErrorCallback":{"type":"object","additionalProperties":false},"HandlerDidRespondCallback":{"type":"object","additionalProperties":false},"HandlerWillRespondCallback":{"type":"object","additionalProperties":false},"HandlerWillStartCallback":{"type":"object","additionalProperties":false},"RequestWillFetchCallback":{"type":"object","additionalProperties":false},"RequestInit":{"type":"object","properties":{"body":{"anyOf":[{"$ref":"#/definitions/ArrayBuffer"},{"$ref":"#/definitions/ArrayBufferView"},{"$ref":"#/definitions/Blob"},{"$ref":"#/definitions/FormData"},{"$ref":"#/definitions/URLSearchParams"},{"$ref":"#/definitions/ReadableStream"},{"type":["null","string"]}]},"cache":{"enum":["default","force-cache","no-cache","no-store","only-if-cached","reload"],"type":"string"},"credentials":{"enum":["include","omit","same-origin"],"type":"string"},"headers":{"anyOf":[{"$ref":"#/definitions/Headers"},{"type":"array","items":{"type":"array","items":{"type":"string"}}},{"$ref":"#/definitions/Record"}]},"integrity":{"type":"string"},"keepalive":{"type":"boolean"},"method":{"type":"string"},"mode":{"enum":["cors","navigate","no-cors","same-origin"],"type":"string"},"redirect":{"enum":["error","follow","manual"],"type":"string"},"referrer":{"type":"string"},"referrerPolicy":{"enum":["","no-referrer","no-referrer-when-downgrade","origin","origin-when-cross-origin","same-origin","strict-origin","strict-origin-when-cross-origin","unsafe-url"],"type":"string"},"signal":{"anyOf":[{"$ref":"#/definitions/AbortSignal"},{"type":"null"}]},"window":{}},"additionalProperties":false},"ArrayBuffer":{"type":"object","properties":{"byteLength":{"type":"number"},"__@toStringTag":{"type":"string"}},"additionalProperties":false},"ArrayBufferView":{"type":"object","properties":{"buffer":{"anyOf":[{"$ref":"#/definitions/ArrayBuffer"},{"$ref":"#/definitions/SharedArrayBuffer"}]},"byteLength":{"type":"number"},"byteOffset":{"type":"number"}},"additionalProperties":false},"SharedArrayBuffer":{"type":"object","properties":{"byteLength":{"type":"number"},"__@species":{"$ref":"#/definitions/SharedArrayBuffer"},"__@toStringTag":{"type":"string","enum":["SharedArrayBuffer"]}},"additionalProperties":false},"Blob":{"type":"object","properties":{"size":{"type":"number"},"type":{"type":"string"}},"additionalProperties":false},"FormData":{"type":"object","additionalProperties":false},"URLSearchParams":{"type":"object","additionalProperties":false},"ReadableStream":{"type":"object","properties":{"locked":{"type":"boolean"}},"additionalProperties":false},"Headers":{"type":"object","additionalProperties":false},"Record":{"type":"object","additionalProperties":false},"AbortSignal":{"type":"object","properties":{"aborted":{"type":"boolean"},"onabort":{"anyOf":[{"type":"object","additionalProperties":false},{"type":"null"}]}},"additionalProperties":false},"RouteMatchCallback":{"description":"The \"match\" callback is used to determine if a `Route` should apply for a\nparticular URL and request. When matching occurs in response to a fetch\nevent from the client, the `event` object is also supplied. However, since\nthe match callback can be invoked outside of a fetch event, matching logic\nshould not assume the `event` object will always be available.\nIf the match callback returns a truthy value, the matching route's\n`RouteHandlerCallback` will be invoked immediately. If the value returned\nis a non-empty array or object, that value will be set on the handler's\n`options.params` argument.","type":"object","additionalProperties":false},"ManifestEntry":{"type":"object","properties":{"integrity":{"type":"string"},"revision":{"type":["null","string"]},"url":{"type":"string"}},"additionalProperties":false}},"$schema":"http://json-schema.org/draft-07/schema#"} +{"additionalProperties":false,"type":"object","properties":{"chunks":{"type":"array","items":{"type":"string"}},"exclude":{"default":"[/\\.map$/, /^manifest.*\\.js$/,]","type":"array","items":{"anyOf":[{"$ref":"#/definitions/RegExp"},{"type":"object","additionalProperties":false},{"type":"string"}]}},"excludeChunks":{"type":"array","items":{"type":"string"}},"include":{"type":"array","items":{"anyOf":[{"$ref":"#/definitions/RegExp"},{"type":"object","additionalProperties":false},{"type":"string"}]}},"mode":{"type":["null","string"]},"injectionPoint":{"default":"self.__WB_MANIFEST","type":"string"},"swSrc":{"type":"string"},"additionalManifestEntries":{"type":"array","items":{"anyOf":[{"$ref":"#/definitions/ManifestEntry"},{"type":"string"}]}},"dontCacheBustURLsMatching":{"$ref":"#/definitions/RegExp"},"manifestTransforms":{"type":"array","items":{"type":"object","additionalProperties":false}},"maximumFileSizeToCacheInBytes":{"default":2097152,"type":"number"},"modifyURLPrefix":{"type":"object","additionalProperties":{"type":"string"}},"swDest":{"default":"service-worker.js","type":"string"},"compileSrc":{"default":true,"type":"boolean"},"webpackCompilationPlugins":{"type":"array","items":{}}},"required":["swDest","swSrc"],"definitions":{"RegExp":{"type":"object","properties":{"source":{"type":"string"},"global":{"type":"boolean"},"ignoreCase":{"type":"boolean"},"multiline":{"type":"boolean"},"lastIndex":{"type":"number"},"flags":{"type":"string"},"sticky":{"type":"boolean"},"unicode":{"type":"boolean"},"dotAll":{"type":"boolean"}},"additionalProperties":false,"required":["dotAll","flags","global","ignoreCase","lastIndex","multiline","source","sticky","unicode"]},"GoogleAnalyticsInitializeOptions":{"type":"object","properties":{"cacheName":{"type":"string"},"parameterOverrides":{"type":"object","additionalProperties":{"type":"string"}},"hitFilter":{"type":"object","additionalProperties":false}},"additionalProperties":false},"RuntimeCaching":{"type":"object","properties":{"handler":{"anyOf":[{"$ref":"#/definitions/RouteHandlerCallback"},{"$ref":"#/definitions/RouteHandlerObject"},{"enum":["CacheFirst","CacheOnly","NetworkFirst","NetworkOnly","StaleWhileRevalidate"],"type":"string"}]},"method":{"enum":["DELETE","GET","HEAD","PATCH","POST","PUT"],"type":"string"},"options":{"type":"object","properties":{"backgroundSync":{"type":"object","properties":{"name":{"type":"string"},"options":{"$ref":"#/definitions/QueueOptions"}},"additionalProperties":false,"required":["name"]},"broadcastUpdate":{"type":"object","properties":{"channelName":{"type":"string"},"options":{"$ref":"#/definitions/BroadcastCacheUpdateOptions"}},"additionalProperties":false,"required":["options"]},"cacheableResponse":{"$ref":"#/definitions/CacheableResponseOptions"},"cacheName":{"type":["null","string"]},"expiration":{"$ref":"#/definitions/ExpirationPluginOptions"},"networkTimeoutSeconds":{"type":"number"},"plugins":{"type":"array","items":{"$ref":"#/definitions/WorkboxPlugin"}},"precacheFallback":{"type":"object","properties":{"fallbackURL":{"type":"string"}},"additionalProperties":false,"required":["fallbackURL"]},"fetchOptions":{"$ref":"#/definitions/RequestInit"},"matchOptions":{"$ref":"#/definitions/CacheQueryOptions"}},"additionalProperties":false},"urlPattern":{"anyOf":[{"$ref":"#/definitions/RegExp"},{"$ref":"#/definitions/RouteMatchCallback"},{"type":"string"}]}},"additionalProperties":false,"required":["handler","urlPattern"]},"RouteHandlerCallback":{"description":"The \"handler\" callback is invoked whenever a `Router` matches a URL/Request\nto a `Route` via its `RouteMatchCallback`. This handler callback should\nreturn a `Promise` that resolves with a `Response`.\n\nIf a non-empty array or object is returned by the `RouteMatchCallback` it\nwill be passed in as this handler's `options.params` argument.","type":"object","additionalProperties":false},"RouteHandlerObject":{"description":"An object with a `handle` method of type `RouteHandlerCallback`.\n\nA `Route` object can be created with either an `RouteHandlerCallback`\nfunction or this `RouteHandler` object. The benefit of the `RouteHandler`\nis it can be extended (as is done by the `workbox-strategies` package).","type":"object","properties":{"handle":{"$ref":"#/definitions/RouteHandlerCallback"}},"additionalProperties":false,"required":["handle"]},"QueueOptions":{"type":"object","properties":{"onSync":{"$ref":"#/definitions/OnSyncCallback"},"maxRetentionTime":{"type":"number"}},"additionalProperties":false},"OnSyncCallback":{"type":"object","additionalProperties":false},"BroadcastCacheUpdateOptions":{"type":"object","properties":{"headersToCheck":{"type":"array","items":{"type":"string"}},"generatePayload":{"type":"object","additionalProperties":false}},"additionalProperties":false},"CacheableResponseOptions":{"type":"object","properties":{"statuses":{"type":"array","items":{"type":"number"}},"headers":{"type":"object","additionalProperties":{"type":"string"}}},"additionalProperties":false},"ExpirationPluginOptions":{"type":"object","properties":{"maxEntries":{"type":"number"},"maxAgeSeconds":{"type":"number"},"matchOptions":{"$ref":"#/definitions/CacheQueryOptions"},"purgeOnQuotaError":{"type":"boolean"}},"additionalProperties":false},"CacheQueryOptions":{"type":"object","properties":{"ignoreMethod":{"type":"boolean"},"ignoreSearch":{"type":"boolean"},"ignoreVary":{"type":"boolean"}},"additionalProperties":false},"WorkboxPlugin":{"description":"An object with optional lifecycle callback properties for the fetch and\ncache operations.","type":"object","properties":{"cacheDidUpdate":{"$ref":"#/definitions/CacheDidUpdateCallback"},"cachedResponseWillBeUsed":{"$ref":"#/definitions/CachedResponseWillBeUsedCallback"},"cacheKeyWillBeUsed":{"$ref":"#/definitions/CacheKeyWillBeUsedCallback"},"cacheWillUpdate":{"$ref":"#/definitions/CacheWillUpdateCallback"},"fetchDidFail":{"$ref":"#/definitions/FetchDidFailCallback"},"fetchDidSucceed":{"$ref":"#/definitions/FetchDidSucceedCallback"},"handlerDidComplete":{"$ref":"#/definitions/HandlerDidCompleteCallback"},"handlerDidError":{"$ref":"#/definitions/HandlerDidErrorCallback"},"handlerDidRespond":{"$ref":"#/definitions/HandlerDidRespondCallback"},"handlerWillRespond":{"$ref":"#/definitions/HandlerWillRespondCallback"},"handlerWillStart":{"$ref":"#/definitions/HandlerWillStartCallback"},"requestWillFetch":{"$ref":"#/definitions/RequestWillFetchCallback"}},"additionalProperties":false},"CacheDidUpdateCallback":{"type":"object","additionalProperties":false},"CachedResponseWillBeUsedCallback":{"type":"object","additionalProperties":false},"CacheKeyWillBeUsedCallback":{"type":"object","additionalProperties":false},"CacheWillUpdateCallback":{"type":"object","additionalProperties":false},"FetchDidFailCallback":{"type":"object","additionalProperties":false},"FetchDidSucceedCallback":{"type":"object","additionalProperties":false},"HandlerDidCompleteCallback":{"type":"object","additionalProperties":false},"HandlerDidErrorCallback":{"type":"object","additionalProperties":false},"HandlerDidRespondCallback":{"type":"object","additionalProperties":false},"HandlerWillRespondCallback":{"type":"object","additionalProperties":false},"HandlerWillStartCallback":{"type":"object","additionalProperties":false},"RequestWillFetchCallback":{"type":"object","additionalProperties":false},"RequestInit":{"type":"object","properties":{"body":{"anyOf":[{"$ref":"#/definitions/ArrayBuffer"},{"$ref":"#/definitions/ArrayBufferView"},{"$ref":"#/definitions/Blob"},{"$ref":"#/definitions/FormData"},{"$ref":"#/definitions/URLSearchParams"},{"$ref":"#/definitions/ReadableStream"},{"type":["null","string"]}]},"cache":{"enum":["default","force-cache","no-cache","no-store","only-if-cached","reload"],"type":"string"},"credentials":{"enum":["include","omit","same-origin"],"type":"string"},"headers":{"anyOf":[{"$ref":"#/definitions/Headers"},{"type":"array","items":{"type":"array","items":{"type":"string"}}},{"$ref":"#/definitions/Record"}]},"integrity":{"type":"string"},"keepalive":{"type":"boolean"},"method":{"type":"string"},"mode":{"enum":["cors","navigate","no-cors","same-origin"],"type":"string"},"redirect":{"enum":["error","follow","manual"],"type":"string"},"referrer":{"type":"string"},"referrerPolicy":{"enum":["","no-referrer","no-referrer-when-downgrade","origin","origin-when-cross-origin","same-origin","strict-origin","strict-origin-when-cross-origin","unsafe-url"],"type":"string"},"signal":{"anyOf":[{"$ref":"#/definitions/AbortSignal"},{"type":"null"}]},"window":{}},"additionalProperties":false},"ArrayBuffer":{"type":"object","properties":{"byteLength":{"type":"number"},"__@toStringTag":{"type":"string"}},"additionalProperties":false,"required":["__@toStringTag","byteLength"]},"ArrayBufferView":{"type":"object","properties":{"buffer":{"anyOf":[{"$ref":"#/definitions/ArrayBuffer"},{"$ref":"#/definitions/SharedArrayBuffer"}]},"byteLength":{"type":"number"},"byteOffset":{"type":"number"}},"additionalProperties":false,"required":["buffer","byteLength","byteOffset"]},"SharedArrayBuffer":{"type":"object","properties":{"byteLength":{"type":"number"},"__@species":{"$ref":"#/definitions/SharedArrayBuffer"},"__@toStringTag":{"type":"string","enum":["SharedArrayBuffer"]}},"additionalProperties":false,"required":["__@species","__@toStringTag","byteLength"]},"Blob":{"type":"object","properties":{"size":{"type":"number"},"type":{"type":"string"}},"additionalProperties":false,"required":["size","type"]},"FormData":{"type":"object","additionalProperties":false},"URLSearchParams":{"type":"object","additionalProperties":false},"ReadableStream":{"type":"object","properties":{"locked":{"type":"boolean"}},"additionalProperties":false,"required":["locked"]},"Headers":{"type":"object","additionalProperties":false},"Record":{"type":"object","additionalProperties":false},"AbortSignal":{"type":"object","properties":{"aborted":{"type":"boolean"},"onabort":{"anyOf":[{"type":"object","additionalProperties":false},{"type":"null"}]}},"additionalProperties":false,"required":["aborted","onabort"]},"RouteMatchCallback":{"description":"The \"match\" callback is used to determine if a `Route` should apply for a\nparticular URL and request. When matching occurs in response to a fetch\nevent from the client, the `event` object is also supplied. However, since\nthe match callback can be invoked outside of a fetch event, matching logic\nshould not assume the `event` object will always be available.\nIf the match callback returns a truthy value, the matching route's\n`RouteHandlerCallback` will be invoked immediately. If the value returned\nis a non-empty array or object, that value will be set on the handler's\n`options.params` argument.","type":"object","additionalProperties":false},"ManifestEntry":{"type":"object","properties":{"integrity":{"type":"string"},"revision":{"type":["null","string"]},"url":{"type":"string"}},"additionalProperties":false,"required":["revision","url"]}},"$schema":"http://json-schema.org/draft-07/schema#"} diff --git a/packages/workbox-build/src/types.ts b/packages/workbox-build/src/types.ts index bf9da9b0b..ade69ff1e 100644 --- a/packages/workbox-build/src/types.ts +++ b/packages/workbox-build/src/types.ts @@ -63,7 +63,7 @@ export interface BasePartial { * @default 2097152 */ maximumFileSizeToCacheInBytes?: number; - modifyURLPrefix: { + modifyURLPrefix?: { [key: string]: string; }; } @@ -111,7 +111,7 @@ export interface GeneratePartial { * @default false */ offlineGoogleAnalytics?: boolean | GoogleAnalyticsInitializeOptions; - runtimeCaching: Array; + runtimeCaching?: Array; /** * @default false */ @@ -123,7 +123,7 @@ export interface GeneratePartial { } export interface GlobPartial { - globDirectory?: string | null; + globDirectory: string; /** * @default true */ @@ -140,7 +140,7 @@ export interface GlobPartial { * @default true */ globStrict?: boolean; - templatedURLs: { + templatedURLs?: { [key: string]: string | Array; }; } From a8a161c41bcb89a891a1767ee828e2ad7c9391b6 Mon Sep 17 00:00:00 2001 From: Jeff Posnick Date: Wed, 9 Jun 2021 15:30:26 -0400 Subject: [PATCH 36/80] Figuring out errors --- packages/workbox-build/package-lock.json | 125 ++++++++++++++++++ .../workbox-build/src/lib/validate-options.ts | 15 +-- 2 files changed, 132 insertions(+), 8 deletions(-) diff --git a/packages/workbox-build/package-lock.json b/packages/workbox-build/package-lock.json index 7c8e53355..3374dbe72 100644 --- a/packages/workbox-build/package-lock.json +++ b/packages/workbox-build/package-lock.json @@ -1846,6 +1846,131 @@ "webidl-conversions": "^4.0.2" } }, + "workbox-background-sync": { + "version": "6.1.5", + "resolved": "https://registry.npmjs.org/workbox-background-sync/-/workbox-background-sync-6.1.5.tgz", + "integrity": "sha512-VbUmPLsdz+sLzuNxHvMylzyRTiM4q+q7rwLBk3p2mtRL5NZozI8j/KgoGbno96vs84jx4b9zCZMEOIKEUTPf6w==", + "requires": { + "workbox-core": "^6.1.5" + } + }, + "workbox-broadcast-update": { + "version": "6.1.5", + "resolved": "https://registry.npmjs.org/workbox-broadcast-update/-/workbox-broadcast-update-6.1.5.tgz", + "integrity": "sha512-zGrTTs+n4wHpYtqYMqBg6kl/x5j1UrczGCQnODSHTxIDV8GXLb/GtA1BCZdysNxpMmdVSeLmTcgIYAAqWFamrA==", + "requires": { + "workbox-core": "^6.1.5" + } + }, + "workbox-cacheable-response": { + "version": "6.1.5", + "resolved": "https://registry.npmjs.org/workbox-cacheable-response/-/workbox-cacheable-response-6.1.5.tgz", + "integrity": "sha512-x8DC71lO/JCgiaJ194l9le8wc8lFPLgUpDkLhp2si7mXV6S/wZO+8Osvw1LLgYa8YYTWGbhbFhFTXIkEMknIIA==", + "requires": { + "workbox-core": "^6.1.5" + } + }, + "workbox-core": { + "version": "6.1.5", + "resolved": "https://registry.npmjs.org/workbox-core/-/workbox-core-6.1.5.tgz", + "integrity": "sha512-9SOEle7YcJzg3njC0xMSmrPIiFjfsFm9WjwGd5enXmI8Lwk8wLdy63B0nzu5LXoibEmS9k+aWF8EzaKtOWjNSA==" + }, + "workbox-expiration": { + "version": "6.1.5", + "resolved": "https://registry.npmjs.org/workbox-expiration/-/workbox-expiration-6.1.5.tgz", + "integrity": "sha512-6cN+FVbh8fNq56LFKPMchGNKCJeyboHsDuGBqmhDUPvD4uDjsegQpDQzn52VaE0cpywbSIsDF/BSq9E9Yjh5oQ==", + "requires": { + "workbox-core": "^6.1.5" + } + }, + "workbox-google-analytics": { + "version": "6.1.5", + "resolved": "https://registry.npmjs.org/workbox-google-analytics/-/workbox-google-analytics-6.1.5.tgz", + "integrity": "sha512-LYsJ/VxTkYVLxM1uJKXZLz4cJdemidY7kPyAYtKVZ6EiDG89noASqis75/5lhqM1m3HwQfp2DtoPrelKSpSDBA==", + "requires": { + "workbox-background-sync": "^6.1.5", + "workbox-core": "^6.1.5", + "workbox-routing": "^6.1.5", + "workbox-strategies": "^6.1.5" + } + }, + "workbox-navigation-preload": { + "version": "6.1.5", + "resolved": "https://registry.npmjs.org/workbox-navigation-preload/-/workbox-navigation-preload-6.1.5.tgz", + "integrity": "sha512-hDbNcWlffv0uvS21jCAC/mYk7NzaGRSWOQXv1p7bj2aONAX5l699D2ZK4D27G8TO0BaLHUmW/1A5CZcsvweQdg==", + "requires": { + "workbox-core": "^6.1.5" + } + }, + "workbox-precaching": { + "version": "6.1.5", + "resolved": "https://registry.npmjs.org/workbox-precaching/-/workbox-precaching-6.1.5.tgz", + "integrity": "sha512-yhm1kb6wgi141JeM5X7z42XJxCry53tbMLB3NgrxktrZbwbrJF8JILzYy+RFKC9tHC6u2bPmL789GPLT2NCDzw==", + "requires": { + "workbox-core": "^6.1.5", + "workbox-routing": "^6.1.5", + "workbox-strategies": "^6.1.5" + } + }, + "workbox-range-requests": { + "version": "6.1.5", + "resolved": "https://registry.npmjs.org/workbox-range-requests/-/workbox-range-requests-6.1.5.tgz", + "integrity": "sha512-iACChSapzB0yuIum3ascP/+cfBNuZi5DRrE+u4u5mCHigPlwfSWtlaY+y8p+a8EwcDTVTZVtnrGrRnF31SiLqQ==", + "requires": { + "workbox-core": "^6.1.5" + } + }, + "workbox-recipes": { + "version": "6.1.5", + "resolved": "https://registry.npmjs.org/workbox-recipes/-/workbox-recipes-6.1.5.tgz", + "integrity": "sha512-MD1yabHca6O/oj1hrRdfj9cRwhKA5zqIE53rWOAg/dKMMzWQsf9nyRbXRgzK3a13iQvYKuQzURU4Cx58tdnR+Q==", + "requires": { + "workbox-cacheable-response": "^6.1.5", + "workbox-core": "^6.1.5", + "workbox-expiration": "^6.1.5", + "workbox-precaching": "^6.1.5", + "workbox-routing": "^6.1.5", + "workbox-strategies": "^6.1.5" + } + }, + "workbox-routing": { + "version": "6.1.5", + "resolved": "https://registry.npmjs.org/workbox-routing/-/workbox-routing-6.1.5.tgz", + "integrity": "sha512-uC/Ctz+4GXGL42h1WxUNKxqKRik/38uS0NZ6VY/EHqL2F1ObLFqMHUZ4ZYvyQsKdyI82cxusvhJZHOrY0a2fIQ==", + "requires": { + "workbox-core": "^6.1.5" + } + }, + "workbox-strategies": { + "version": "6.1.5", + "resolved": "https://registry.npmjs.org/workbox-strategies/-/workbox-strategies-6.1.5.tgz", + "integrity": "sha512-QhiOn9KT9YGBdbfWOmJT6pXZOIAxaVrs6J6AMYzRpkUegBTEcv36+ZhE/cfHoT0u2fxVtthHnskOQ/snEzaXQw==", + "requires": { + "workbox-core": "^6.1.5" + } + }, + "workbox-streams": { + "version": "6.1.5", + "resolved": "https://registry.npmjs.org/workbox-streams/-/workbox-streams-6.1.5.tgz", + "integrity": "sha512-OI1kLvRHGFXV+soDvs6aEwfBwdAkvPB0mRryqdh3/K17qUj/1gRXc8QtpgU+83xqx/I/ar2bTCIj0KPzI/ChCQ==", + "requires": { + "workbox-core": "^6.1.5", + "workbox-routing": "^6.1.5" + } + }, + "workbox-sw": { + "version": "6.1.5", + "resolved": "https://registry.npmjs.org/workbox-sw/-/workbox-sw-6.1.5.tgz", + "integrity": "sha512-IMDiqxYbKzPorZLGMUMacLB6r76iVQbdTzYthIZoPfy+uFURJFUtqiWQJKg1L+RMyuYXwKXTahCIGkgFs4jBeg==" + }, + "workbox-window": { + "version": "6.1.5", + "resolved": "https://registry.npmjs.org/workbox-window/-/workbox-window-6.1.5.tgz", + "integrity": "sha512-akL0X6mAegai2yypnq78RgfazeqvKbsllRtEI4dnbhPcRINEY1NmecFmsQk8SD+zWLK1gw5OdwAOX+zHSRVmeA==", + "requires": { + "workbox-core": "^6.1.5" + } + }, "wrappy": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", diff --git a/packages/workbox-build/src/lib/validate-options.ts b/packages/workbox-build/src/lib/validate-options.ts index f89957ca8..4e7f5f6c5 100644 --- a/packages/workbox-build/src/lib/validate-options.ts +++ b/packages/workbox-build/src/lib/validate-options.ts @@ -6,11 +6,13 @@ https://opensource.org/licenses/MIT. */ -import Ajv, {DefinedError, JSONSchemaType} from 'ajv'; +import Ajv, {JSONSchemaType} from 'ajv'; import {GenerateSWOptions, GetManifestOptions, InjectManifestOptions} from '../types'; -const ajv = new Ajv({useDefaults: true}); +const ajv = new Ajv({ + useDefaults: true, +}); export function validateGenerateSWOptions(input: unknown): GenerateSWOptions { const jsonSchema: JSONSchemaType = @@ -20,8 +22,7 @@ export function validateGenerateSWOptions(input: unknown): GenerateSWOptions { return input; } - const errors = validate.errors as DefinedError[]; - throw new Error(JSON.stringify(errors)); + throw new Error(JSON.stringify(validate.errors)); } export function validateGetManifestOptions(input: unknown): GetManifestOptions { @@ -32,8 +33,7 @@ export function validateGetManifestOptions(input: unknown): GetManifestOptions { return input; } - const errors = validate.errors as DefinedError[]; - throw new Error(JSON.stringify(errors)); + throw new Error(JSON.stringify(validate.errors)); } export function validateInjectManifestOptions(input: unknown): InjectManifestOptions { @@ -44,6 +44,5 @@ export function validateInjectManifestOptions(input: unknown): InjectManifestOpt return input; } - const errors = validate.errors as DefinedError[]; - throw new Error(JSON.stringify(errors)); + throw new Error(JSON.stringify(validate.errors)); } From 759b196c23eda09f06bcd24fcd788c30c00cd214 Mon Sep 17 00:00:00 2001 From: Jeff Posnick Date: Wed, 9 Jun 2021 15:34:55 -0400 Subject: [PATCH 37/80] Refactor --- .../workbox-build/src/lib/validate-options.ts | 27 ++++++------------- 1 file changed, 8 insertions(+), 19 deletions(-) diff --git a/packages/workbox-build/src/lib/validate-options.ts b/packages/workbox-build/src/lib/validate-options.ts index 4e7f5f6c5..dffa2cfcf 100644 --- a/packages/workbox-build/src/lib/validate-options.ts +++ b/packages/workbox-build/src/lib/validate-options.ts @@ -14,9 +14,8 @@ const ajv = new Ajv({ useDefaults: true, }); -export function validateGenerateSWOptions(input: unknown): GenerateSWOptions { - const jsonSchema: JSONSchemaType = - require(`../schema/GenerateSWOptions.json`); +function validate(input: unknown, schemaFile: string): T { + const jsonSchema: JSONSchemaType = require(schemaFile); const validate = ajv.compile(jsonSchema); if (validate(input)) { return input; @@ -25,24 +24,14 @@ export function validateGenerateSWOptions(input: unknown): GenerateSWOptions { throw new Error(JSON.stringify(validate.errors)); } -export function validateGetManifestOptions(input: unknown): GetManifestOptions { - const jsonSchema: JSONSchemaType = - require(`../schema/GetManifestOptions.json`); - const validate = ajv.compile(jsonSchema); - if (validate(input)) { - return input; - } +export function validateGenerateSWOptions(input: unknown): GenerateSWOptions { + return validate(input, `../schema/GenerateSWOptions.json`); +} - throw new Error(JSON.stringify(validate.errors)); +export function validateGetManifestOptions(input: unknown): GetManifestOptions { + return validate(input, `../schema/GetManifestOptions.json`); } export function validateInjectManifestOptions(input: unknown): InjectManifestOptions { - const jsonSchema: JSONSchemaType = - require(`../schema/InjectManifestOptions.json`); - const validate = ajv.compile(jsonSchema); - if (validate(input)) { - return input; - } - - throw new Error(JSON.stringify(validate.errors)); + return validate(input, `../schema/InjectManifestOptions.json`); } From cdabfc89f811a56e96d9bc858a25a0f8751e30fe Mon Sep 17 00:00:00 2001 From: Jeff Posnick Date: Wed, 9 Jun 2021 15:49:41 -0400 Subject: [PATCH 38/80] Update validate-options test --- .../node/lib/validate-options.js | 44 +++++++++++++------ 1 file changed, 30 insertions(+), 14 deletions(-) diff --git a/test/workbox-build/node/lib/validate-options.js b/test/workbox-build/node/lib/validate-options.js index ca64cd246..2efb71b54 100644 --- a/test/workbox-build/node/lib/validate-options.js +++ b/test/workbox-build/node/lib/validate-options.js @@ -8,35 +8,51 @@ const expect = require('chai').expect; const proxyquire = require('proxyquire'); +const sinon = require('sinon'); + +const INJECTED_ERROR = 'Injected error.'; +class AJVFailsValidation { + compile() { + const stub = sinon.stub().returns(false); + stub.errors = [INJECTED_ERROR]; + return stub; + } +} + +class AJVPassesValidation { + compile() { + return sinon.stub().returns(true); + } +} // The integration tests will exercise the actual validation logic. describe(`[workbox-build] entry-points/options/validate-options.js`, function() { const MODULE_PATH = '../../../../packages/workbox-build/build/lib/validate-options'; - const testCases = new Map([ - ['validateGenerateSWOptions', 'isGenerateSWOptions'], - ['validateGetManifestOptions', 'isGetManifestOptions'], - ['validateInjectManifestOptions', 'isInjectManifestOptions'], - ]); + const testCases = [ + 'validateGenerateSWOptions', + 'validateGetManifestOptions', + 'validateInjectManifestOptions', + ]; - for (const [func, guardFunc] of testCases) { - it.skip(`${func}() should throw when ${guardFunc}() returns false`, function() { + for (const func of testCases) { + it(`${func}() should throw when validation fails`, function() { const validateOptions = proxyquire(MODULE_PATH, { - '../types.guard': { - [guardFunc]: () => false, + 'ajv': { + default: AJVFailsValidation, }, }); - expect(() => validateOptions[func]()).to.throw('Validation failed.'); + expect(() => validateOptions[func]()).to.throw(INJECTED_ERROR); }); - it.skip(`${func}() should return options with defaults when ${guardFunc}() returns true`, function() { + it(`${func}() should not throw when validation passes`, function() { const validateOptions = proxyquire(MODULE_PATH, { - '../types.guard': { - [guardFunc]: () => true, + 'ajv': { + default: AJVPassesValidation, }, }); - const defaultOptions = validateOptions[func](); + const defaultOptions = validateOptions[func]({}); expect(defaultOptions).to.be.an('object'); }); } From 69b9e66c8507d6564d031e5f1b5256076c985fd1 Mon Sep 17 00:00:00 2001 From: Jeff Posnick Date: Wed, 9 Jun 2021 16:17:43 -0400 Subject: [PATCH 39/80] Started integration test migration --- packages/workbox-build/src/lib/validate-options.ts | 6 +++++- test/workbox-build/node/generate-sw.js | 4 ++-- test/workbox-build/node/get-manifest.js | 2 +- test/workbox-build/node/inject-manifest.js | 4 ++-- 4 files changed, 10 insertions(+), 6 deletions(-) diff --git a/packages/workbox-build/src/lib/validate-options.ts b/packages/workbox-build/src/lib/validate-options.ts index dffa2cfcf..1827f8b12 100644 --- a/packages/workbox-build/src/lib/validate-options.ts +++ b/packages/workbox-build/src/lib/validate-options.ts @@ -21,7 +21,11 @@ function validate(input: unknown, schemaFile: string): T { return input; } - throw new Error(JSON.stringify(validate.errors)); + // TODO: Update this code to use better-ajv-errors once + // https://github.com/apideck-libraries/better-ajv-errors/pull/2 is merged. + const error = new Error(JSON.stringify(validate.errors)); + error.name = 'ValidationError'; + throw error; } export function validateGenerateSWOptions(input: unknown): GenerateSWOptions { diff --git a/test/workbox-build/node/generate-sw.js b/test/workbox-build/node/generate-sw.js index e0525a3de..6da7b1d92 100644 --- a/test/workbox-build/node/generate-sw.js +++ b/test/workbox-build/node/generate-sw.js @@ -12,8 +12,8 @@ const upath = require('upath'); const tempy = require('tempy'); const confirmDirectoryContains = require('../../../infra/testing/confirm-directory-contains'); -const errors = require('../../../packages/workbox-build/build/lib/errors'); -const generateSW = require('../../../packages/workbox-build/build/generate-sw'); +const {errors} = require('../../../packages/workbox-build/build/lib/errors'); +const {generateSW} = require('../../../packages/workbox-build/build/generate-sw'); const validateServiceWorkerRuntime = require('../../../infra/testing/validator/service-worker-runtime'); describe(`[workbox-build] generate-sw.js (End to End)`, function() { diff --git a/test/workbox-build/node/get-manifest.js b/test/workbox-build/node/get-manifest.js index d0f0b9791..666f70555 100644 --- a/test/workbox-build/node/get-manifest.js +++ b/test/workbox-build/node/get-manifest.js @@ -15,7 +15,7 @@ const tempy = require('tempy'); chai.use(chaiMatchPattern); const {expect} = chai; -const getManifest = require('../../../packages/workbox-build/build/get-manifest'); +const {getManifest} = require('../../../packages/workbox-build/build/get-manifest'); describe(`[workbox-build] get-manifest.js (End to End)`, function() { const SRC_DIR = upath.join(__dirname, '..', 'static', 'example-project-1'); diff --git a/test/workbox-build/node/inject-manifest.js b/test/workbox-build/node/inject-manifest.js index 0a25bf0fb..15fb8dbca 100644 --- a/test/workbox-build/node/inject-manifest.js +++ b/test/workbox-build/node/inject-manifest.js @@ -11,8 +11,8 @@ const fse = require('fs-extra'); const upath = require('upath'); const tempy = require('tempy'); -const errors = require('../../../packages/workbox-build/build/lib/errors'); -const injectManifest = require('../../../packages/workbox-build/build/inject-manifest'); +const {errors} = require('../../../packages/workbox-build/build/lib/errors'); +const {injectManifest} = require('../../../packages/workbox-build/build/inject-manifest'); const validateServiceWorkerRuntime = require('../../../infra/testing/validator/service-worker-runtime'); describe(`[workbox-build] inject-manifest.js (End to End)`, function() { From 4749d2479699fd7ac2060167ef7a1366da65bd5d Mon Sep 17 00:00:00 2001 From: Jeff Posnick Date: Wed, 9 Jun 2021 16:18:54 -0400 Subject: [PATCH 40/80] Remove joi schema --- .../workbox-build/src/options/defaults.js | 34 ------- .../src/options/objects/manifest-entry.js | 15 ---- .../src/options/objects/reg-exp.js | 11 --- .../src/options/partials/base.js | 23 ----- .../src/options/partials/generate.js | 88 ------------------- .../src/options/partials/glob.js | 23 ----- .../src/options/partials/inject.js | 16 ---- .../src/options/partials/webpack.js | 21 ----- .../src/options/schema/generate-sw.js | 19 ---- .../src/options/schema/get-manifest.js | 16 ---- .../src/options/schema/inject-manifest.js | 19 ---- .../src/options/schema/webpack-generate-sw.js | 21 ----- .../options/schema/webpack-inject-manifest.js | 34 ------- 13 files changed, 340 deletions(-) delete mode 100644 packages/workbox-build/src/options/defaults.js delete mode 100644 packages/workbox-build/src/options/objects/manifest-entry.js delete mode 100644 packages/workbox-build/src/options/objects/reg-exp.js delete mode 100644 packages/workbox-build/src/options/partials/base.js delete mode 100644 packages/workbox-build/src/options/partials/generate.js delete mode 100644 packages/workbox-build/src/options/partials/glob.js delete mode 100644 packages/workbox-build/src/options/partials/inject.js delete mode 100644 packages/workbox-build/src/options/partials/webpack.js delete mode 100644 packages/workbox-build/src/options/schema/generate-sw.js delete mode 100644 packages/workbox-build/src/options/schema/get-manifest.js delete mode 100644 packages/workbox-build/src/options/schema/inject-manifest.js delete mode 100644 packages/workbox-build/src/options/schema/webpack-generate-sw.js delete mode 100644 packages/workbox-build/src/options/schema/webpack-inject-manifest.js diff --git a/packages/workbox-build/src/options/defaults.js b/packages/workbox-build/src/options/defaults.js deleted file mode 100644 index 4cdc4749d..000000000 --- a/packages/workbox-build/src/options/defaults.js +++ /dev/null @@ -1,34 +0,0 @@ -/* - Copyright 2019 Google LLC - - Use of this source code is governed by an MIT-style - license that can be found in the LICENSE file or at - https://opensource.org/licenses/MIT. -*/ - -module.exports = { - babelPresetEnvTargets: ['chrome >= 56'], - cleanupOutdatedCaches: false, - clientsClaim: false, - compileSrc: true, - disableDevLogs: false, - exclude: [ - /\.map$/, - /^manifest.*\.js$/, - ], - globFollow: true, - globIgnores: ['**/node_modules/**/*'], - globPatterns: ['**/*.{js,css,html}'], - globStrict: true, - injectionPoint: 'self.__WB_MANIFEST', - inlineWorkboxRuntime: false, - maximumFileSizeToCacheInBytes: 2 * 1024 * 1024, - mode: 'production', - navigateFallback: null, - navigationPreload: false, - offlineGoogleAnalytics: false, - purgeOnQuotaError: true, - skipWaiting: false, - sourcemap: true, - swDestFilename: 'service-worker.js', -}; diff --git a/packages/workbox-build/src/options/objects/manifest-entry.js b/packages/workbox-build/src/options/objects/manifest-entry.js deleted file mode 100644 index 1c1896331..000000000 --- a/packages/workbox-build/src/options/objects/manifest-entry.js +++ /dev/null @@ -1,15 +0,0 @@ -/* - Copyright 2019 Google LLC - - Use of this source code is governed by an MIT-style - license that can be found in the LICENSE file or at - https://opensource.org/licenses/MIT. -*/ - -const joi = require('@hapi/joi'); - -module.exports = joi.object().keys({ - integrity: joi.string(), - revision: joi.string().required().allow(null), - url: joi.string().required(), -}); diff --git a/packages/workbox-build/src/options/objects/reg-exp.js b/packages/workbox-build/src/options/objects/reg-exp.js deleted file mode 100644 index 643bfe0a1..000000000 --- a/packages/workbox-build/src/options/objects/reg-exp.js +++ /dev/null @@ -1,11 +0,0 @@ -/* - Copyright 2019 Google LLC - - Use of this source code is governed by an MIT-style - license that can be found in the LICENSE file or at - https://opensource.org/licenses/MIT. -*/ - -const joi = require('@hapi/joi'); - -module.exports = joi.object().instance(RegExp); diff --git a/packages/workbox-build/src/options/partials/base.js b/packages/workbox-build/src/options/partials/base.js deleted file mode 100644 index deb96377d..000000000 --- a/packages/workbox-build/src/options/partials/base.js +++ /dev/null @@ -1,23 +0,0 @@ -/* - Copyright 2019 Google LLC - - Use of this source code is governed by an MIT-style - license that can be found in the LICENSE file or at - https://opensource.org/licenses/MIT. -*/ - -const joi = require('@hapi/joi'); - -const defaults = require('../defaults'); -const manifestEntryObject = require('../objects/manifest-entry'); -const regExpObject = require('../objects/reg-exp'); - -module.exports = { - additionalManifestEntries: joi.array() - .items(joi.string(), manifestEntryObject), - dontCacheBustURLsMatching: regExpObject, - manifestTransforms: joi.array().items(joi.func().minArity(1).maxArity(2)), - maximumFileSizeToCacheInBytes: joi.number().min(1) - .default(defaults.maximumFileSizeToCacheInBytes), - modifyURLPrefix: joi.object(), -}; diff --git a/packages/workbox-build/src/options/partials/generate.js b/packages/workbox-build/src/options/partials/generate.js deleted file mode 100644 index fc2a18c9d..000000000 --- a/packages/workbox-build/src/options/partials/generate.js +++ /dev/null @@ -1,88 +0,0 @@ -/* - Copyright 2019 Google LLC - - Use of this source code is governed by an MIT-style - license that can be found in the LICENSE file or at - https://opensource.org/licenses/MIT. -*/ - -const joi = require('@hapi/joi'); - -const defaults = require('../defaults'); -const regExpObject = require('../objects/reg-exp'); - -module.exports = { - babelPresetEnvTargets: joi.array().items(joi.string()) - .default(defaults.babelPresetEnvTargets), - cacheId: joi.string(), - cleanupOutdatedCaches: joi.boolean().default(defaults.cleanupOutdatedCaches), - clientsClaim: joi.boolean().default(defaults.clientsClaim), - directoryIndex: joi.string(), - disableDevLogs: joi.boolean().default(defaults.disableDevLogs), - ignoreURLParametersMatching: joi.array().items(regExpObject), - importScripts: joi.array().items(joi.string()), - inlineWorkboxRuntime: joi.boolean().default(defaults.inlineWorkboxRuntime), - mode: joi.string().default(process.env.NODE_ENV || defaults.mode), - navigateFallback: joi.string().default(defaults.navigateFallback), - navigateFallbackAllowlist: joi.array().items(regExpObject), - navigateFallbackBlacklist: joi.forbidden().error(new Error( - 'navigateFallbackBlacklist has been renamed navigateFallbackDenylist.')), - navigateFallbackDenylist: joi.array().items(regExpObject), - navigateFallbackWhitelist: joi.forbidden().error(new Error( - 'navigateFallbackWhitelist has been renamed navigateFallbackAllowlist.')), - navigationPreload: joi.boolean().default(defaults.navigationPreload), - offlineGoogleAnalytics: joi.alternatives().try(joi.boolean(), joi.object()) - .default(defaults.offlineGoogleAnalytics), - runtimeCaching: joi.array().items(joi.object().keys({ - method: joi.string().valid( - 'DELETE', - 'GET', - 'HEAD', - 'PATCH', - 'POST', - 'PUT', - ), - urlPattern: [regExpObject, joi.string(), joi.func()], - handler: [ - joi.func(), - joi.string().valid( - 'CacheFirst', - 'CacheOnly', - 'NetworkFirst', - 'NetworkOnly', - 'StaleWhileRevalidate'), - ], - options: joi.object().keys({ - backgroundSync: joi.object().keys({ - name: joi.string().required(), - options: joi.object(), - }), - broadcastUpdate: joi.object().keys({ - channelName: joi.string().required(), - options: joi.object(), - }), - cacheableResponse: joi.object().keys({ - statuses: joi.array().items(joi.number().min(0).max(599)), - headers: joi.object(), - }).or('statuses', 'headers'), - cacheName: joi.string(), - expiration: joi.object().keys({ - maxEntries: joi.number().min(1), - maxAgeSeconds: joi.number().min(1), - purgeOnQuotaError: joi.boolean().default(defaults.purgeOnQuotaError), - }).or('maxEntries', 'maxAgeSeconds'), - networkTimeoutSeconds: joi.number().min(1), - plugins: joi.array().items(joi.object()), - precacheFallback: joi.object().keys({ - fallbackURL: joi.string().required(), - }), - fetchOptions: joi.object(), - matchOptions: joi.object(), - }).with('expiration', 'cacheName'), - })).when('navigationPreload', { - is: true, - then: joi.required('runtimeCaching'), - }), - skipWaiting: joi.boolean().default(defaults.skipWaiting), - sourcemap: joi.boolean().default(defaults.sourcemap), -}; diff --git a/packages/workbox-build/src/options/partials/glob.js b/packages/workbox-build/src/options/partials/glob.js deleted file mode 100644 index efe83850d..000000000 --- a/packages/workbox-build/src/options/partials/glob.js +++ /dev/null @@ -1,23 +0,0 @@ -/* - Copyright 2019 Google LLC - - Use of this source code is governed by an MIT-style - license that can be found in the LICENSE file or at - https://opensource.org/licenses/MIT. -*/ - -const joi = require('@hapi/joi'); - -const defaults = require('../defaults'); - -module.exports = { - globDirectory: joi.string(), - globFollow: joi.boolean().default(defaults.globFollow), - globIgnores: joi.array().items(joi.string()).default(defaults.globIgnores), - globPatterns: joi.array().items(joi.string()).default(defaults.globPatterns), - globStrict: joi.boolean().default(defaults.globStrict), - // templatedURLs is an object where any property name is valid, and the values - // can be either a string or an array of strings. - templatedURLs: joi.object() - .pattern(/./, [joi.string(), joi.array().items(joi.string())]), -}; diff --git a/packages/workbox-build/src/options/partials/inject.js b/packages/workbox-build/src/options/partials/inject.js deleted file mode 100644 index e91adf00e..000000000 --- a/packages/workbox-build/src/options/partials/inject.js +++ /dev/null @@ -1,16 +0,0 @@ -/* - Copyright 2019 Google LLC - - Use of this source code is governed by an MIT-style - license that can be found in the LICENSE file or at - https://opensource.org/licenses/MIT. -*/ - -const joi = require('@hapi/joi'); - -const defaults = require('../defaults'); - -module.exports = { - injectionPoint: joi.string().default(defaults.injectionPoint), - swSrc: joi.string().required(), -}; diff --git a/packages/workbox-build/src/options/partials/webpack.js b/packages/workbox-build/src/options/partials/webpack.js deleted file mode 100644 index e530addb9..000000000 --- a/packages/workbox-build/src/options/partials/webpack.js +++ /dev/null @@ -1,21 +0,0 @@ -/* - Copyright 2019 Google LLC - - Use of this source code is governed by an MIT-style - license that can be found in the LICENSE file or at - https://opensource.org/licenses/MIT. -*/ - -const joi = require('@hapi/joi'); - -const defaults = require('../defaults'); -const regExpObject = require('../objects/reg-exp'); - -module.exports = { - chunks: joi.array().items(joi.string()), - exclude: joi.array().items(joi.string(), regExpObject, joi.func().arity(1)) - .default(defaults.exclude), - excludeChunks: joi.array().items(joi.string()), - include: joi.array().items(joi.string(), regExpObject, joi.func().arity(1)), - mode: joi.string().default(process.env.NODE_ENV || defaults.mode), -}; diff --git a/packages/workbox-build/src/options/schema/generate-sw.js b/packages/workbox-build/src/options/schema/generate-sw.js deleted file mode 100644 index 5abbfe3a0..000000000 --- a/packages/workbox-build/src/options/schema/generate-sw.js +++ /dev/null @@ -1,19 +0,0 @@ -/* - Copyright 2019 Google LLC - - Use of this source code is governed by an MIT-style - license that can be found in the LICENSE file or at - https://opensource.org/licenses/MIT. -*/ - -const joi = require('@hapi/joi'); - -const basePartial = require('../partials/base'); -const generatePartial = require('../partials/generate'); -const globPartial = require('../partials/glob'); - -const supportedOptions = Object.assign({ - swDest: joi.string().required().regex(/\.js$/), -}, basePartial, generatePartial, globPartial); - -module.exports = joi.object().keys(supportedOptions); diff --git a/packages/workbox-build/src/options/schema/get-manifest.js b/packages/workbox-build/src/options/schema/get-manifest.js deleted file mode 100644 index c2b5368c1..000000000 --- a/packages/workbox-build/src/options/schema/get-manifest.js +++ /dev/null @@ -1,16 +0,0 @@ -/* - Copyright 2019 Google LLC - - Use of this source code is governed by an MIT-style - license that can be found in the LICENSE file or at - https://opensource.org/licenses/MIT. -*/ - -const joi = require('@hapi/joi'); - -const basePartial = require('../partials/base'); -const globPartial = require('../partials/glob'); - -const supportedOptions = Object.assign({}, basePartial, globPartial); - -module.exports = joi.object().keys(supportedOptions); diff --git a/packages/workbox-build/src/options/schema/inject-manifest.js b/packages/workbox-build/src/options/schema/inject-manifest.js deleted file mode 100644 index ce2708847..000000000 --- a/packages/workbox-build/src/options/schema/inject-manifest.js +++ /dev/null @@ -1,19 +0,0 @@ -/* - Copyright 2019 Google LLC - - Use of this source code is governed by an MIT-style - license that can be found in the LICENSE file or at - https://opensource.org/licenses/MIT. -*/ - -const joi = require('@hapi/joi'); - -const basePartial = require('../partials/base'); -const globPartial = require('../partials/glob'); -const injectPartial = require('../partials/inject'); - -const supportedOptions = Object.assign({ - swDest: joi.string().required().regex(/\.js$/), -}, basePartial, globPartial, injectPartial); - -module.exports = joi.object().keys(supportedOptions); diff --git a/packages/workbox-build/src/options/schema/webpack-generate-sw.js b/packages/workbox-build/src/options/schema/webpack-generate-sw.js deleted file mode 100644 index 21f0ab31a..000000000 --- a/packages/workbox-build/src/options/schema/webpack-generate-sw.js +++ /dev/null @@ -1,21 +0,0 @@ -/* - Copyright 2019 Google LLC - - Use of this source code is governed by an MIT-style - license that can be found in the LICENSE file or at - https://opensource.org/licenses/MIT. -*/ - -const joi = require('@hapi/joi'); - -const basePartial = require('../partials/base'); -const defaults = require('../defaults'); -const generatePartial = require('../partials/generate'); -const webpackPartial = require('../partials/webpack'); - -const supportedOptions = Object.assign({ - importScriptsViaChunks: joi.array().items(joi.string()), - swDest: joi.string().default(defaults.swDestFilename), -}, basePartial, generatePartial, webpackPartial); - -module.exports = joi.object().keys(supportedOptions); diff --git a/packages/workbox-build/src/options/schema/webpack-inject-manifest.js b/packages/workbox-build/src/options/schema/webpack-inject-manifest.js deleted file mode 100644 index 9f91171c4..000000000 --- a/packages/workbox-build/src/options/schema/webpack-inject-manifest.js +++ /dev/null @@ -1,34 +0,0 @@ -/* - Copyright 2019 Google LLC - - Use of this source code is governed by an MIT-style - license that can be found in the LICENSE file or at - https://opensource.org/licenses/MIT. -*/ - -const joi = require('@hapi/joi'); -const upath = require('upath'); - -const basePartial = require('../partials/base'); -const defaults = require('../defaults'); -const injectPartial = require('../partials/inject'); -const webpackPartial = require('../partials/webpack'); - -// See https://github.com/hapijs/joi/blob/v16.0.0-rc2/API.md#anydefaultvalue-description -const swSrcBasename = (context) => { - const {name} = upath.parse(context.swSrc); - // Always use the .js extension when generating a default filename. - return name + '.js'; -}; -swSrcBasename.description = 'derived from the swSrc file name'; - -const supportedOptions = Object.assign({ - compileSrc: joi.boolean().default(defaults.compileSrc), - webpackCompilationPlugins: joi.array().items(joi.object()).when( - 'compileSrc', {is: false, then: joi.forbidden()}), -}, basePartial, injectPartial, webpackPartial); - -module.exports = joi.object().keys(supportedOptions).keys({ - // List this separately, so that the swSrc validation happens first. - swDest: joi.string().default(swSrcBasename), -}); From 48559c8cc06c3abac526046805dc3b0659ebfd0c Mon Sep 17 00:00:00 2001 From: Jeff Posnick Date: Wed, 9 Jun 2021 16:30:49 -0400 Subject: [PATCH 41/80] Fixed some swDest logic --- packages/workbox-build/src/lib/bundle.ts | 4 ++-- .../src/schema/GenerateSWOptions.json | 2 +- .../src/schema/InjectManifestOptions.json | 2 +- .../src/schema/WebpackGenerateSWOptions.json | 2 +- .../src/schema/WebpackInjectManifestOptions.json | 2 +- packages/workbox-build/src/types.ts | 16 ++++++++++------ 6 files changed, 16 insertions(+), 12 deletions(-) diff --git a/packages/workbox-build/src/lib/bundle.ts b/packages/workbox-build/src/lib/bundle.ts index fed365267..6f883f57e 100644 --- a/packages/workbox-build/src/lib/bundle.ts +++ b/packages/workbox-build/src/lib/bundle.ts @@ -17,7 +17,7 @@ import replace from '@rollup/plugin-replace'; import tempy from 'tempy'; import upath from 'upath'; -import {GeneratePartial, SWDestPartial} from '../types'; +import {GeneratePartial, RequiredSWDestPartial} from '../types'; interface NameAndContents { contents: string | Uint8Array; @@ -31,7 +31,7 @@ export async function bundle({ sourcemap, swDest, unbundledCode, -}: Omit & SWDestPartial & {unbundledCode: string}): Promise> { +}: Omit & RequiredSWDestPartial & {unbundledCode: string}): Promise> { // We need to write this to the "real" file system, as Rollup won't read from // a custom file system. const {dir, base} = upath.parse(swDest); diff --git a/packages/workbox-build/src/schema/GenerateSWOptions.json b/packages/workbox-build/src/schema/GenerateSWOptions.json index 9f2d0057e..73a1838a5 100644 --- a/packages/workbox-build/src/schema/GenerateSWOptions.json +++ b/packages/workbox-build/src/schema/GenerateSWOptions.json @@ -1 +1 @@ -{"additionalProperties":false,"type":"object","properties":{"globDirectory":{"type":"string"},"globFollow":{"default":true,"type":"boolean"},"globIgnores":{"default":["**/node_modules/**/*"],"type":"array","items":{"type":"string"}},"globPatterns":{"default":["**/*.{js,css,html}"],"type":"array","items":{"type":"string"}},"globStrict":{"default":true,"type":"boolean"},"templatedURLs":{"type":"object","additionalProperties":{"anyOf":[{"type":"array","items":{"type":"string"}},{"type":"string"}]}},"babelPresetEnvTargets":{"default":["chrome >= 56"],"type":"array","items":{"type":"string"}},"cacheId":{"type":["null","string"]},"cleanupOutdatedCaches":{"default":false,"type":"boolean"},"clientsClaim":{"default":false,"type":"boolean"},"directoryIndex":{"type":["null","string"]},"disableDevLogs":{"default":false,"type":"boolean"},"ignoreURLParametersMatching":{"type":"array","items":{"$ref":"#/definitions/RegExp"}},"importScripts":{"type":"array","items":{"type":"string"}},"inlineWorkboxRuntime":{"default":false,"type":"boolean"},"mode":{"default":"production","type":["null","string"]},"navigateFallback":{"default":null,"type":["null","string"]},"navigateFallbackAllowlist":{"type":"array","items":{"$ref":"#/definitions/RegExp"}},"navigateFallbackDenylist":{"type":"array","items":{"$ref":"#/definitions/RegExp"}},"navigationPreload":{"default":false,"type":"boolean"},"offlineGoogleAnalytics":{"default":false,"anyOf":[{"$ref":"#/definitions/GoogleAnalyticsInitializeOptions"},{"type":"boolean"}]},"runtimeCaching":{"type":"array","items":{"$ref":"#/definitions/RuntimeCaching"}},"skipWaiting":{"default":false,"type":"boolean"},"sourcemap":{"default":true,"type":"boolean"},"additionalManifestEntries":{"type":"array","items":{"anyOf":[{"$ref":"#/definitions/ManifestEntry"},{"type":"string"}]}},"dontCacheBustURLsMatching":{"$ref":"#/definitions/RegExp"},"manifestTransforms":{"type":"array","items":{"type":"object","additionalProperties":false}},"maximumFileSizeToCacheInBytes":{"default":2097152,"type":"number"},"modifyURLPrefix":{"type":"object","additionalProperties":{"type":"string"}},"swDest":{"default":"service-worker.js","type":"string"}},"required":["globDirectory","swDest"],"definitions":{"RegExp":{"type":"object","properties":{"source":{"type":"string"},"global":{"type":"boolean"},"ignoreCase":{"type":"boolean"},"multiline":{"type":"boolean"},"lastIndex":{"type":"number"},"flags":{"type":"string"},"sticky":{"type":"boolean"},"unicode":{"type":"boolean"},"dotAll":{"type":"boolean"}},"additionalProperties":false,"required":["dotAll","flags","global","ignoreCase","lastIndex","multiline","source","sticky","unicode"]},"GoogleAnalyticsInitializeOptions":{"type":"object","properties":{"cacheName":{"type":"string"},"parameterOverrides":{"type":"object","additionalProperties":{"type":"string"}},"hitFilter":{"type":"object","additionalProperties":false}},"additionalProperties":false},"RuntimeCaching":{"type":"object","properties":{"handler":{"anyOf":[{"$ref":"#/definitions/RouteHandlerCallback"},{"$ref":"#/definitions/RouteHandlerObject"},{"enum":["CacheFirst","CacheOnly","NetworkFirst","NetworkOnly","StaleWhileRevalidate"],"type":"string"}]},"method":{"enum":["DELETE","GET","HEAD","PATCH","POST","PUT"],"type":"string"},"options":{"type":"object","properties":{"backgroundSync":{"type":"object","properties":{"name":{"type":"string"},"options":{"$ref":"#/definitions/QueueOptions"}},"additionalProperties":false,"required":["name"]},"broadcastUpdate":{"type":"object","properties":{"channelName":{"type":"string"},"options":{"$ref":"#/definitions/BroadcastCacheUpdateOptions"}},"additionalProperties":false,"required":["options"]},"cacheableResponse":{"$ref":"#/definitions/CacheableResponseOptions"},"cacheName":{"type":["null","string"]},"expiration":{"$ref":"#/definitions/ExpirationPluginOptions"},"networkTimeoutSeconds":{"type":"number"},"plugins":{"type":"array","items":{"$ref":"#/definitions/WorkboxPlugin"}},"precacheFallback":{"type":"object","properties":{"fallbackURL":{"type":"string"}},"additionalProperties":false,"required":["fallbackURL"]},"fetchOptions":{"$ref":"#/definitions/RequestInit"},"matchOptions":{"$ref":"#/definitions/CacheQueryOptions"}},"additionalProperties":false},"urlPattern":{"anyOf":[{"$ref":"#/definitions/RegExp"},{"$ref":"#/definitions/RouteMatchCallback"},{"type":"string"}]}},"additionalProperties":false,"required":["handler","urlPattern"]},"RouteHandlerCallback":{"description":"The \"handler\" callback is invoked whenever a `Router` matches a URL/Request\nto a `Route` via its `RouteMatchCallback`. This handler callback should\nreturn a `Promise` that resolves with a `Response`.\n\nIf a non-empty array or object is returned by the `RouteMatchCallback` it\nwill be passed in as this handler's `options.params` argument.","type":"object","additionalProperties":false},"RouteHandlerObject":{"description":"An object with a `handle` method of type `RouteHandlerCallback`.\n\nA `Route` object can be created with either an `RouteHandlerCallback`\nfunction or this `RouteHandler` object. The benefit of the `RouteHandler`\nis it can be extended (as is done by the `workbox-strategies` package).","type":"object","properties":{"handle":{"$ref":"#/definitions/RouteHandlerCallback"}},"additionalProperties":false,"required":["handle"]},"QueueOptions":{"type":"object","properties":{"onSync":{"$ref":"#/definitions/OnSyncCallback"},"maxRetentionTime":{"type":"number"}},"additionalProperties":false},"OnSyncCallback":{"type":"object","additionalProperties":false},"BroadcastCacheUpdateOptions":{"type":"object","properties":{"headersToCheck":{"type":"array","items":{"type":"string"}},"generatePayload":{"type":"object","additionalProperties":false}},"additionalProperties":false},"CacheableResponseOptions":{"type":"object","properties":{"statuses":{"type":"array","items":{"type":"number"}},"headers":{"type":"object","additionalProperties":{"type":"string"}}},"additionalProperties":false},"ExpirationPluginOptions":{"type":"object","properties":{"maxEntries":{"type":"number"},"maxAgeSeconds":{"type":"number"},"matchOptions":{"$ref":"#/definitions/CacheQueryOptions"},"purgeOnQuotaError":{"type":"boolean"}},"additionalProperties":false},"CacheQueryOptions":{"type":"object","properties":{"ignoreMethod":{"type":"boolean"},"ignoreSearch":{"type":"boolean"},"ignoreVary":{"type":"boolean"}},"additionalProperties":false},"WorkboxPlugin":{"description":"An object with optional lifecycle callback properties for the fetch and\ncache operations.","type":"object","properties":{"cacheDidUpdate":{"$ref":"#/definitions/CacheDidUpdateCallback"},"cachedResponseWillBeUsed":{"$ref":"#/definitions/CachedResponseWillBeUsedCallback"},"cacheKeyWillBeUsed":{"$ref":"#/definitions/CacheKeyWillBeUsedCallback"},"cacheWillUpdate":{"$ref":"#/definitions/CacheWillUpdateCallback"},"fetchDidFail":{"$ref":"#/definitions/FetchDidFailCallback"},"fetchDidSucceed":{"$ref":"#/definitions/FetchDidSucceedCallback"},"handlerDidComplete":{"$ref":"#/definitions/HandlerDidCompleteCallback"},"handlerDidError":{"$ref":"#/definitions/HandlerDidErrorCallback"},"handlerDidRespond":{"$ref":"#/definitions/HandlerDidRespondCallback"},"handlerWillRespond":{"$ref":"#/definitions/HandlerWillRespondCallback"},"handlerWillStart":{"$ref":"#/definitions/HandlerWillStartCallback"},"requestWillFetch":{"$ref":"#/definitions/RequestWillFetchCallback"}},"additionalProperties":false},"CacheDidUpdateCallback":{"type":"object","additionalProperties":false},"CachedResponseWillBeUsedCallback":{"type":"object","additionalProperties":false},"CacheKeyWillBeUsedCallback":{"type":"object","additionalProperties":false},"CacheWillUpdateCallback":{"type":"object","additionalProperties":false},"FetchDidFailCallback":{"type":"object","additionalProperties":false},"FetchDidSucceedCallback":{"type":"object","additionalProperties":false},"HandlerDidCompleteCallback":{"type":"object","additionalProperties":false},"HandlerDidErrorCallback":{"type":"object","additionalProperties":false},"HandlerDidRespondCallback":{"type":"object","additionalProperties":false},"HandlerWillRespondCallback":{"type":"object","additionalProperties":false},"HandlerWillStartCallback":{"type":"object","additionalProperties":false},"RequestWillFetchCallback":{"type":"object","additionalProperties":false},"RequestInit":{"type":"object","properties":{"body":{"anyOf":[{"$ref":"#/definitions/ArrayBuffer"},{"$ref":"#/definitions/ArrayBufferView"},{"$ref":"#/definitions/Blob"},{"$ref":"#/definitions/FormData"},{"$ref":"#/definitions/URLSearchParams"},{"$ref":"#/definitions/ReadableStream"},{"type":["null","string"]}]},"cache":{"enum":["default","force-cache","no-cache","no-store","only-if-cached","reload"],"type":"string"},"credentials":{"enum":["include","omit","same-origin"],"type":"string"},"headers":{"anyOf":[{"$ref":"#/definitions/Headers"},{"type":"array","items":{"type":"array","items":{"type":"string"}}},{"$ref":"#/definitions/Record"}]},"integrity":{"type":"string"},"keepalive":{"type":"boolean"},"method":{"type":"string"},"mode":{"enum":["cors","navigate","no-cors","same-origin"],"type":"string"},"redirect":{"enum":["error","follow","manual"],"type":"string"},"referrer":{"type":"string"},"referrerPolicy":{"enum":["","no-referrer","no-referrer-when-downgrade","origin","origin-when-cross-origin","same-origin","strict-origin","strict-origin-when-cross-origin","unsafe-url"],"type":"string"},"signal":{"anyOf":[{"$ref":"#/definitions/AbortSignal"},{"type":"null"}]},"window":{}},"additionalProperties":false},"ArrayBuffer":{"type":"object","properties":{"byteLength":{"type":"number"},"__@toStringTag":{"type":"string"}},"additionalProperties":false,"required":["__@toStringTag","byteLength"]},"ArrayBufferView":{"type":"object","properties":{"buffer":{"anyOf":[{"$ref":"#/definitions/ArrayBuffer"},{"$ref":"#/definitions/SharedArrayBuffer"}]},"byteLength":{"type":"number"},"byteOffset":{"type":"number"}},"additionalProperties":false,"required":["buffer","byteLength","byteOffset"]},"SharedArrayBuffer":{"type":"object","properties":{"byteLength":{"type":"number"},"__@species":{"$ref":"#/definitions/SharedArrayBuffer"},"__@toStringTag":{"type":"string","enum":["SharedArrayBuffer"]}},"additionalProperties":false,"required":["__@species","__@toStringTag","byteLength"]},"Blob":{"type":"object","properties":{"size":{"type":"number"},"type":{"type":"string"}},"additionalProperties":false,"required":["size","type"]},"FormData":{"type":"object","additionalProperties":false},"URLSearchParams":{"type":"object","additionalProperties":false},"ReadableStream":{"type":"object","properties":{"locked":{"type":"boolean"}},"additionalProperties":false,"required":["locked"]},"Headers":{"type":"object","additionalProperties":false},"Record":{"type":"object","additionalProperties":false},"AbortSignal":{"type":"object","properties":{"aborted":{"type":"boolean"},"onabort":{"anyOf":[{"type":"object","additionalProperties":false},{"type":"null"}]}},"additionalProperties":false,"required":["aborted","onabort"]},"RouteMatchCallback":{"description":"The \"match\" callback is used to determine if a `Route` should apply for a\nparticular URL and request. When matching occurs in response to a fetch\nevent from the client, the `event` object is also supplied. However, since\nthe match callback can be invoked outside of a fetch event, matching logic\nshould not assume the `event` object will always be available.\nIf the match callback returns a truthy value, the matching route's\n`RouteHandlerCallback` will be invoked immediately. If the value returned\nis a non-empty array or object, that value will be set on the handler's\n`options.params` argument.","type":"object","additionalProperties":false},"ManifestEntry":{"type":"object","properties":{"integrity":{"type":"string"},"revision":{"type":["null","string"]},"url":{"type":"string"}},"additionalProperties":false,"required":["revision","url"]}},"$schema":"http://json-schema.org/draft-07/schema#"} +{"additionalProperties":false,"type":"object","properties":{"globDirectory":{"type":"string"},"globFollow":{"default":true,"type":"boolean"},"globIgnores":{"default":["**/node_modules/**/*"],"type":"array","items":{"type":"string"}},"globPatterns":{"default":["**/*.{js,css,html}"],"type":"array","items":{"type":"string"}},"globStrict":{"default":true,"type":"boolean"},"templatedURLs":{"type":"object","additionalProperties":{"anyOf":[{"type":"array","items":{"type":"string"}},{"type":"string"}]}},"babelPresetEnvTargets":{"default":["chrome >= 56"],"type":"array","items":{"type":"string"}},"cacheId":{"type":["null","string"]},"cleanupOutdatedCaches":{"default":false,"type":"boolean"},"clientsClaim":{"default":false,"type":"boolean"},"directoryIndex":{"type":["null","string"]},"disableDevLogs":{"default":false,"type":"boolean"},"ignoreURLParametersMatching":{"type":"array","items":{"$ref":"#/definitions/RegExp"}},"importScripts":{"type":"array","items":{"type":"string"}},"inlineWorkboxRuntime":{"default":false,"type":"boolean"},"mode":{"default":"production","type":["null","string"]},"navigateFallback":{"default":null,"type":["null","string"]},"navigateFallbackAllowlist":{"type":"array","items":{"$ref":"#/definitions/RegExp"}},"navigateFallbackDenylist":{"type":"array","items":{"$ref":"#/definitions/RegExp"}},"navigationPreload":{"default":false,"type":"boolean"},"offlineGoogleAnalytics":{"default":false,"anyOf":[{"$ref":"#/definitions/GoogleAnalyticsInitializeOptions"},{"type":"boolean"}]},"runtimeCaching":{"type":"array","items":{"$ref":"#/definitions/RuntimeCaching"}},"skipWaiting":{"default":false,"type":"boolean"},"sourcemap":{"default":true,"type":"boolean"},"additionalManifestEntries":{"type":"array","items":{"anyOf":[{"$ref":"#/definitions/ManifestEntry"},{"type":"string"}]}},"dontCacheBustURLsMatching":{"$ref":"#/definitions/RegExp"},"manifestTransforms":{"type":"array","items":{"type":"object","additionalProperties":false}},"maximumFileSizeToCacheInBytes":{"default":2097152,"type":"number"},"modifyURLPrefix":{"type":"object","additionalProperties":{"type":"string"}},"swDest":{"type":"string"}},"required":["globDirectory","swDest"],"definitions":{"RegExp":{"type":"object","properties":{"source":{"type":"string"},"global":{"type":"boolean"},"ignoreCase":{"type":"boolean"},"multiline":{"type":"boolean"},"lastIndex":{"type":"number"},"flags":{"type":"string"},"sticky":{"type":"boolean"},"unicode":{"type":"boolean"},"dotAll":{"type":"boolean"}},"additionalProperties":false,"required":["dotAll","flags","global","ignoreCase","lastIndex","multiline","source","sticky","unicode"]},"GoogleAnalyticsInitializeOptions":{"type":"object","properties":{"cacheName":{"type":"string"},"parameterOverrides":{"type":"object","additionalProperties":{"type":"string"}},"hitFilter":{"type":"object","additionalProperties":false}},"additionalProperties":false},"RuntimeCaching":{"type":"object","properties":{"handler":{"anyOf":[{"$ref":"#/definitions/RouteHandlerCallback"},{"$ref":"#/definitions/RouteHandlerObject"},{"enum":["CacheFirst","CacheOnly","NetworkFirst","NetworkOnly","StaleWhileRevalidate"],"type":"string"}]},"method":{"enum":["DELETE","GET","HEAD","PATCH","POST","PUT"],"type":"string"},"options":{"type":"object","properties":{"backgroundSync":{"type":"object","properties":{"name":{"type":"string"},"options":{"$ref":"#/definitions/QueueOptions"}},"additionalProperties":false,"required":["name"]},"broadcastUpdate":{"type":"object","properties":{"channelName":{"type":"string"},"options":{"$ref":"#/definitions/BroadcastCacheUpdateOptions"}},"additionalProperties":false,"required":["options"]},"cacheableResponse":{"$ref":"#/definitions/CacheableResponseOptions"},"cacheName":{"type":["null","string"]},"expiration":{"$ref":"#/definitions/ExpirationPluginOptions"},"networkTimeoutSeconds":{"type":"number"},"plugins":{"type":"array","items":{"$ref":"#/definitions/WorkboxPlugin"}},"precacheFallback":{"type":"object","properties":{"fallbackURL":{"type":"string"}},"additionalProperties":false,"required":["fallbackURL"]},"fetchOptions":{"$ref":"#/definitions/RequestInit"},"matchOptions":{"$ref":"#/definitions/CacheQueryOptions"}},"additionalProperties":false},"urlPattern":{"anyOf":[{"$ref":"#/definitions/RegExp"},{"$ref":"#/definitions/RouteMatchCallback"},{"type":"string"}]}},"additionalProperties":false,"required":["handler","urlPattern"]},"RouteHandlerCallback":{"description":"The \"handler\" callback is invoked whenever a `Router` matches a URL/Request\nto a `Route` via its `RouteMatchCallback`. This handler callback should\nreturn a `Promise` that resolves with a `Response`.\n\nIf a non-empty array or object is returned by the `RouteMatchCallback` it\nwill be passed in as this handler's `options.params` argument.","type":"object","additionalProperties":false},"RouteHandlerObject":{"description":"An object with a `handle` method of type `RouteHandlerCallback`.\n\nA `Route` object can be created with either an `RouteHandlerCallback`\nfunction or this `RouteHandler` object. The benefit of the `RouteHandler`\nis it can be extended (as is done by the `workbox-strategies` package).","type":"object","properties":{"handle":{"$ref":"#/definitions/RouteHandlerCallback"}},"additionalProperties":false,"required":["handle"]},"QueueOptions":{"type":"object","properties":{"onSync":{"$ref":"#/definitions/OnSyncCallback"},"maxRetentionTime":{"type":"number"}},"additionalProperties":false},"OnSyncCallback":{"type":"object","additionalProperties":false},"BroadcastCacheUpdateOptions":{"type":"object","properties":{"headersToCheck":{"type":"array","items":{"type":"string"}},"generatePayload":{"type":"object","additionalProperties":false}},"additionalProperties":false},"CacheableResponseOptions":{"type":"object","properties":{"statuses":{"type":"array","items":{"type":"number"}},"headers":{"type":"object","additionalProperties":{"type":"string"}}},"additionalProperties":false},"ExpirationPluginOptions":{"type":"object","properties":{"maxEntries":{"type":"number"},"maxAgeSeconds":{"type":"number"},"matchOptions":{"$ref":"#/definitions/CacheQueryOptions"},"purgeOnQuotaError":{"type":"boolean"}},"additionalProperties":false},"CacheQueryOptions":{"type":"object","properties":{"ignoreMethod":{"type":"boolean"},"ignoreSearch":{"type":"boolean"},"ignoreVary":{"type":"boolean"}},"additionalProperties":false},"WorkboxPlugin":{"description":"An object with optional lifecycle callback properties for the fetch and\ncache operations.","type":"object","properties":{"cacheDidUpdate":{"$ref":"#/definitions/CacheDidUpdateCallback"},"cachedResponseWillBeUsed":{"$ref":"#/definitions/CachedResponseWillBeUsedCallback"},"cacheKeyWillBeUsed":{"$ref":"#/definitions/CacheKeyWillBeUsedCallback"},"cacheWillUpdate":{"$ref":"#/definitions/CacheWillUpdateCallback"},"fetchDidFail":{"$ref":"#/definitions/FetchDidFailCallback"},"fetchDidSucceed":{"$ref":"#/definitions/FetchDidSucceedCallback"},"handlerDidComplete":{"$ref":"#/definitions/HandlerDidCompleteCallback"},"handlerDidError":{"$ref":"#/definitions/HandlerDidErrorCallback"},"handlerDidRespond":{"$ref":"#/definitions/HandlerDidRespondCallback"},"handlerWillRespond":{"$ref":"#/definitions/HandlerWillRespondCallback"},"handlerWillStart":{"$ref":"#/definitions/HandlerWillStartCallback"},"requestWillFetch":{"$ref":"#/definitions/RequestWillFetchCallback"}},"additionalProperties":false},"CacheDidUpdateCallback":{"type":"object","additionalProperties":false},"CachedResponseWillBeUsedCallback":{"type":"object","additionalProperties":false},"CacheKeyWillBeUsedCallback":{"type":"object","additionalProperties":false},"CacheWillUpdateCallback":{"type":"object","additionalProperties":false},"FetchDidFailCallback":{"type":"object","additionalProperties":false},"FetchDidSucceedCallback":{"type":"object","additionalProperties":false},"HandlerDidCompleteCallback":{"type":"object","additionalProperties":false},"HandlerDidErrorCallback":{"type":"object","additionalProperties":false},"HandlerDidRespondCallback":{"type":"object","additionalProperties":false},"HandlerWillRespondCallback":{"type":"object","additionalProperties":false},"HandlerWillStartCallback":{"type":"object","additionalProperties":false},"RequestWillFetchCallback":{"type":"object","additionalProperties":false},"RequestInit":{"type":"object","properties":{"body":{"anyOf":[{"$ref":"#/definitions/ArrayBuffer"},{"$ref":"#/definitions/ArrayBufferView"},{"$ref":"#/definitions/Blob"},{"$ref":"#/definitions/FormData"},{"$ref":"#/definitions/URLSearchParams"},{"$ref":"#/definitions/ReadableStream"},{"type":["null","string"]}]},"cache":{"enum":["default","force-cache","no-cache","no-store","only-if-cached","reload"],"type":"string"},"credentials":{"enum":["include","omit","same-origin"],"type":"string"},"headers":{"anyOf":[{"$ref":"#/definitions/Headers"},{"type":"array","items":{"type":"array","items":{"type":"string"}}},{"$ref":"#/definitions/Record"}]},"integrity":{"type":"string"},"keepalive":{"type":"boolean"},"method":{"type":"string"},"mode":{"enum":["cors","navigate","no-cors","same-origin"],"type":"string"},"redirect":{"enum":["error","follow","manual"],"type":"string"},"referrer":{"type":"string"},"referrerPolicy":{"enum":["","no-referrer","no-referrer-when-downgrade","origin","origin-when-cross-origin","same-origin","strict-origin","strict-origin-when-cross-origin","unsafe-url"],"type":"string"},"signal":{"anyOf":[{"$ref":"#/definitions/AbortSignal"},{"type":"null"}]},"window":{}},"additionalProperties":false},"ArrayBuffer":{"type":"object","properties":{"byteLength":{"type":"number"},"__@toStringTag":{"type":"string"}},"additionalProperties":false,"required":["__@toStringTag","byteLength"]},"ArrayBufferView":{"type":"object","properties":{"buffer":{"anyOf":[{"$ref":"#/definitions/ArrayBuffer"},{"$ref":"#/definitions/SharedArrayBuffer"}]},"byteLength":{"type":"number"},"byteOffset":{"type":"number"}},"additionalProperties":false,"required":["buffer","byteLength","byteOffset"]},"SharedArrayBuffer":{"type":"object","properties":{"byteLength":{"type":"number"},"__@species":{"$ref":"#/definitions/SharedArrayBuffer"},"__@toStringTag":{"type":"string","enum":["SharedArrayBuffer"]}},"additionalProperties":false,"required":["__@species","__@toStringTag","byteLength"]},"Blob":{"type":"object","properties":{"size":{"type":"number"},"type":{"type":"string"}},"additionalProperties":false,"required":["size","type"]},"FormData":{"type":"object","additionalProperties":false},"URLSearchParams":{"type":"object","additionalProperties":false},"ReadableStream":{"type":"object","properties":{"locked":{"type":"boolean"}},"additionalProperties":false,"required":["locked"]},"Headers":{"type":"object","additionalProperties":false},"Record":{"type":"object","additionalProperties":false},"AbortSignal":{"type":"object","properties":{"aborted":{"type":"boolean"},"onabort":{"anyOf":[{"type":"object","additionalProperties":false},{"type":"null"}]}},"additionalProperties":false,"required":["aborted","onabort"]},"RouteMatchCallback":{"description":"The \"match\" callback is used to determine if a `Route` should apply for a\nparticular URL and request. When matching occurs in response to a fetch\nevent from the client, the `event` object is also supplied. However, since\nthe match callback can be invoked outside of a fetch event, matching logic\nshould not assume the `event` object will always be available.\nIf the match callback returns a truthy value, the matching route's\n`RouteHandlerCallback` will be invoked immediately. If the value returned\nis a non-empty array or object, that value will be set on the handler's\n`options.params` argument.","type":"object","additionalProperties":false},"ManifestEntry":{"type":"object","properties":{"integrity":{"type":"string"},"revision":{"type":["null","string"]},"url":{"type":"string"}},"additionalProperties":false,"required":["revision","url"]}},"$schema":"http://json-schema.org/draft-07/schema#"} diff --git a/packages/workbox-build/src/schema/InjectManifestOptions.json b/packages/workbox-build/src/schema/InjectManifestOptions.json index 609984f2c..1d31fc396 100644 --- a/packages/workbox-build/src/schema/InjectManifestOptions.json +++ b/packages/workbox-build/src/schema/InjectManifestOptions.json @@ -1 +1 @@ -{"additionalProperties":false,"type":"object","properties":{"injectionPoint":{"default":"self.__WB_MANIFEST","type":"string"},"swSrc":{"type":"string"},"globFollow":{"default":true,"type":"boolean"},"globIgnores":{"default":["**/node_modules/**/*"],"type":"array","items":{"type":"string"}},"globPatterns":{"default":["**/*.{js,css,html}"],"type":"array","items":{"type":"string"}},"globStrict":{"default":true,"type":"boolean"},"templatedURLs":{"type":"object","additionalProperties":{"anyOf":[{"type":"array","items":{"type":"string"}},{"type":"string"}]}},"additionalManifestEntries":{"type":"array","items":{"anyOf":[{"$ref":"#/definitions/ManifestEntry"},{"type":"string"}]}},"dontCacheBustURLsMatching":{"$ref":"#/definitions/RegExp"},"manifestTransforms":{"type":"array","items":{"type":"object","additionalProperties":false}},"maximumFileSizeToCacheInBytes":{"default":2097152,"type":"number"},"modifyURLPrefix":{"type":"object","additionalProperties":{"type":"string"}},"swDest":{"default":"service-worker.js","type":"string"},"globDirectory":{"type":"string"}},"required":["globDirectory","swDest","swSrc"],"definitions":{"RegExp":{"type":"object","properties":{"source":{"type":"string"},"global":{"type":"boolean"},"ignoreCase":{"type":"boolean"},"multiline":{"type":"boolean"},"lastIndex":{"type":"number"},"flags":{"type":"string"},"sticky":{"type":"boolean"},"unicode":{"type":"boolean"},"dotAll":{"type":"boolean"}},"additionalProperties":false,"required":["dotAll","flags","global","ignoreCase","lastIndex","multiline","source","sticky","unicode"]},"GoogleAnalyticsInitializeOptions":{"type":"object","properties":{"cacheName":{"type":"string"},"parameterOverrides":{"type":"object","additionalProperties":{"type":"string"}},"hitFilter":{"type":"object","additionalProperties":false}},"additionalProperties":false},"RuntimeCaching":{"type":"object","properties":{"handler":{"anyOf":[{"$ref":"#/definitions/RouteHandlerCallback"},{"$ref":"#/definitions/RouteHandlerObject"},{"enum":["CacheFirst","CacheOnly","NetworkFirst","NetworkOnly","StaleWhileRevalidate"],"type":"string"}]},"method":{"enum":["DELETE","GET","HEAD","PATCH","POST","PUT"],"type":"string"},"options":{"type":"object","properties":{"backgroundSync":{"type":"object","properties":{"name":{"type":"string"},"options":{"$ref":"#/definitions/QueueOptions"}},"additionalProperties":false,"required":["name"]},"broadcastUpdate":{"type":"object","properties":{"channelName":{"type":"string"},"options":{"$ref":"#/definitions/BroadcastCacheUpdateOptions"}},"additionalProperties":false,"required":["options"]},"cacheableResponse":{"$ref":"#/definitions/CacheableResponseOptions"},"cacheName":{"type":["null","string"]},"expiration":{"$ref":"#/definitions/ExpirationPluginOptions"},"networkTimeoutSeconds":{"type":"number"},"plugins":{"type":"array","items":{"$ref":"#/definitions/WorkboxPlugin"}},"precacheFallback":{"type":"object","properties":{"fallbackURL":{"type":"string"}},"additionalProperties":false,"required":["fallbackURL"]},"fetchOptions":{"$ref":"#/definitions/RequestInit"},"matchOptions":{"$ref":"#/definitions/CacheQueryOptions"}},"additionalProperties":false},"urlPattern":{"anyOf":[{"$ref":"#/definitions/RegExp"},{"$ref":"#/definitions/RouteMatchCallback"},{"type":"string"}]}},"additionalProperties":false,"required":["handler","urlPattern"]},"RouteHandlerCallback":{"description":"The \"handler\" callback is invoked whenever a `Router` matches a URL/Request\nto a `Route` via its `RouteMatchCallback`. This handler callback should\nreturn a `Promise` that resolves with a `Response`.\n\nIf a non-empty array or object is returned by the `RouteMatchCallback` it\nwill be passed in as this handler's `options.params` argument.","type":"object","additionalProperties":false},"RouteHandlerObject":{"description":"An object with a `handle` method of type `RouteHandlerCallback`.\n\nA `Route` object can be created with either an `RouteHandlerCallback`\nfunction or this `RouteHandler` object. The benefit of the `RouteHandler`\nis it can be extended (as is done by the `workbox-strategies` package).","type":"object","properties":{"handle":{"$ref":"#/definitions/RouteHandlerCallback"}},"additionalProperties":false,"required":["handle"]},"QueueOptions":{"type":"object","properties":{"onSync":{"$ref":"#/definitions/OnSyncCallback"},"maxRetentionTime":{"type":"number"}},"additionalProperties":false},"OnSyncCallback":{"type":"object","additionalProperties":false},"BroadcastCacheUpdateOptions":{"type":"object","properties":{"headersToCheck":{"type":"array","items":{"type":"string"}},"generatePayload":{"type":"object","additionalProperties":false}},"additionalProperties":false},"CacheableResponseOptions":{"type":"object","properties":{"statuses":{"type":"array","items":{"type":"number"}},"headers":{"type":"object","additionalProperties":{"type":"string"}}},"additionalProperties":false},"ExpirationPluginOptions":{"type":"object","properties":{"maxEntries":{"type":"number"},"maxAgeSeconds":{"type":"number"},"matchOptions":{"$ref":"#/definitions/CacheQueryOptions"},"purgeOnQuotaError":{"type":"boolean"}},"additionalProperties":false},"CacheQueryOptions":{"type":"object","properties":{"ignoreMethod":{"type":"boolean"},"ignoreSearch":{"type":"boolean"},"ignoreVary":{"type":"boolean"}},"additionalProperties":false},"WorkboxPlugin":{"description":"An object with optional lifecycle callback properties for the fetch and\ncache operations.","type":"object","properties":{"cacheDidUpdate":{"$ref":"#/definitions/CacheDidUpdateCallback"},"cachedResponseWillBeUsed":{"$ref":"#/definitions/CachedResponseWillBeUsedCallback"},"cacheKeyWillBeUsed":{"$ref":"#/definitions/CacheKeyWillBeUsedCallback"},"cacheWillUpdate":{"$ref":"#/definitions/CacheWillUpdateCallback"},"fetchDidFail":{"$ref":"#/definitions/FetchDidFailCallback"},"fetchDidSucceed":{"$ref":"#/definitions/FetchDidSucceedCallback"},"handlerDidComplete":{"$ref":"#/definitions/HandlerDidCompleteCallback"},"handlerDidError":{"$ref":"#/definitions/HandlerDidErrorCallback"},"handlerDidRespond":{"$ref":"#/definitions/HandlerDidRespondCallback"},"handlerWillRespond":{"$ref":"#/definitions/HandlerWillRespondCallback"},"handlerWillStart":{"$ref":"#/definitions/HandlerWillStartCallback"},"requestWillFetch":{"$ref":"#/definitions/RequestWillFetchCallback"}},"additionalProperties":false},"CacheDidUpdateCallback":{"type":"object","additionalProperties":false},"CachedResponseWillBeUsedCallback":{"type":"object","additionalProperties":false},"CacheKeyWillBeUsedCallback":{"type":"object","additionalProperties":false},"CacheWillUpdateCallback":{"type":"object","additionalProperties":false},"FetchDidFailCallback":{"type":"object","additionalProperties":false},"FetchDidSucceedCallback":{"type":"object","additionalProperties":false},"HandlerDidCompleteCallback":{"type":"object","additionalProperties":false},"HandlerDidErrorCallback":{"type":"object","additionalProperties":false},"HandlerDidRespondCallback":{"type":"object","additionalProperties":false},"HandlerWillRespondCallback":{"type":"object","additionalProperties":false},"HandlerWillStartCallback":{"type":"object","additionalProperties":false},"RequestWillFetchCallback":{"type":"object","additionalProperties":false},"RequestInit":{"type":"object","properties":{"body":{"anyOf":[{"$ref":"#/definitions/ArrayBuffer"},{"$ref":"#/definitions/ArrayBufferView"},{"$ref":"#/definitions/Blob"},{"$ref":"#/definitions/FormData"},{"$ref":"#/definitions/URLSearchParams"},{"$ref":"#/definitions/ReadableStream"},{"type":["null","string"]}]},"cache":{"enum":["default","force-cache","no-cache","no-store","only-if-cached","reload"],"type":"string"},"credentials":{"enum":["include","omit","same-origin"],"type":"string"},"headers":{"anyOf":[{"$ref":"#/definitions/Headers"},{"type":"array","items":{"type":"array","items":{"type":"string"}}},{"$ref":"#/definitions/Record"}]},"integrity":{"type":"string"},"keepalive":{"type":"boolean"},"method":{"type":"string"},"mode":{"enum":["cors","navigate","no-cors","same-origin"],"type":"string"},"redirect":{"enum":["error","follow","manual"],"type":"string"},"referrer":{"type":"string"},"referrerPolicy":{"enum":["","no-referrer","no-referrer-when-downgrade","origin","origin-when-cross-origin","same-origin","strict-origin","strict-origin-when-cross-origin","unsafe-url"],"type":"string"},"signal":{"anyOf":[{"$ref":"#/definitions/AbortSignal"},{"type":"null"}]},"window":{}},"additionalProperties":false},"ArrayBuffer":{"type":"object","properties":{"byteLength":{"type":"number"},"__@toStringTag":{"type":"string"}},"additionalProperties":false,"required":["__@toStringTag","byteLength"]},"ArrayBufferView":{"type":"object","properties":{"buffer":{"anyOf":[{"$ref":"#/definitions/ArrayBuffer"},{"$ref":"#/definitions/SharedArrayBuffer"}]},"byteLength":{"type":"number"},"byteOffset":{"type":"number"}},"additionalProperties":false,"required":["buffer","byteLength","byteOffset"]},"SharedArrayBuffer":{"type":"object","properties":{"byteLength":{"type":"number"},"__@species":{"$ref":"#/definitions/SharedArrayBuffer"},"__@toStringTag":{"type":"string","enum":["SharedArrayBuffer"]}},"additionalProperties":false,"required":["__@species","__@toStringTag","byteLength"]},"Blob":{"type":"object","properties":{"size":{"type":"number"},"type":{"type":"string"}},"additionalProperties":false,"required":["size","type"]},"FormData":{"type":"object","additionalProperties":false},"URLSearchParams":{"type":"object","additionalProperties":false},"ReadableStream":{"type":"object","properties":{"locked":{"type":"boolean"}},"additionalProperties":false,"required":["locked"]},"Headers":{"type":"object","additionalProperties":false},"Record":{"type":"object","additionalProperties":false},"AbortSignal":{"type":"object","properties":{"aborted":{"type":"boolean"},"onabort":{"anyOf":[{"type":"object","additionalProperties":false},{"type":"null"}]}},"additionalProperties":false,"required":["aborted","onabort"]},"RouteMatchCallback":{"description":"The \"match\" callback is used to determine if a `Route` should apply for a\nparticular URL and request. When matching occurs in response to a fetch\nevent from the client, the `event` object is also supplied. However, since\nthe match callback can be invoked outside of a fetch event, matching logic\nshould not assume the `event` object will always be available.\nIf the match callback returns a truthy value, the matching route's\n`RouteHandlerCallback` will be invoked immediately. If the value returned\nis a non-empty array or object, that value will be set on the handler's\n`options.params` argument.","type":"object","additionalProperties":false},"ManifestEntry":{"type":"object","properties":{"integrity":{"type":"string"},"revision":{"type":["null","string"]},"url":{"type":"string"}},"additionalProperties":false,"required":["revision","url"]}},"$schema":"http://json-schema.org/draft-07/schema#"} +{"additionalProperties":false,"type":"object","properties":{"injectionPoint":{"default":"self.__WB_MANIFEST","type":"string"},"swSrc":{"type":"string"},"globFollow":{"default":true,"type":"boolean"},"globIgnores":{"default":["**/node_modules/**/*"],"type":"array","items":{"type":"string"}},"globPatterns":{"default":["**/*.{js,css,html}"],"type":"array","items":{"type":"string"}},"globStrict":{"default":true,"type":"boolean"},"templatedURLs":{"type":"object","additionalProperties":{"anyOf":[{"type":"array","items":{"type":"string"}},{"type":"string"}]}},"additionalManifestEntries":{"type":"array","items":{"anyOf":[{"$ref":"#/definitions/ManifestEntry"},{"type":"string"}]}},"dontCacheBustURLsMatching":{"$ref":"#/definitions/RegExp"},"manifestTransforms":{"type":"array","items":{"type":"object","additionalProperties":false}},"maximumFileSizeToCacheInBytes":{"default":2097152,"type":"number"},"modifyURLPrefix":{"type":"object","additionalProperties":{"type":"string"}},"swDest":{"type":"string"},"globDirectory":{"type":"string"}},"required":["globDirectory","swDest","swSrc"],"definitions":{"RegExp":{"type":"object","properties":{"source":{"type":"string"},"global":{"type":"boolean"},"ignoreCase":{"type":"boolean"},"multiline":{"type":"boolean"},"lastIndex":{"type":"number"},"flags":{"type":"string"},"sticky":{"type":"boolean"},"unicode":{"type":"boolean"},"dotAll":{"type":"boolean"}},"additionalProperties":false,"required":["dotAll","flags","global","ignoreCase","lastIndex","multiline","source","sticky","unicode"]},"GoogleAnalyticsInitializeOptions":{"type":"object","properties":{"cacheName":{"type":"string"},"parameterOverrides":{"type":"object","additionalProperties":{"type":"string"}},"hitFilter":{"type":"object","additionalProperties":false}},"additionalProperties":false},"RuntimeCaching":{"type":"object","properties":{"handler":{"anyOf":[{"$ref":"#/definitions/RouteHandlerCallback"},{"$ref":"#/definitions/RouteHandlerObject"},{"enum":["CacheFirst","CacheOnly","NetworkFirst","NetworkOnly","StaleWhileRevalidate"],"type":"string"}]},"method":{"enum":["DELETE","GET","HEAD","PATCH","POST","PUT"],"type":"string"},"options":{"type":"object","properties":{"backgroundSync":{"type":"object","properties":{"name":{"type":"string"},"options":{"$ref":"#/definitions/QueueOptions"}},"additionalProperties":false,"required":["name"]},"broadcastUpdate":{"type":"object","properties":{"channelName":{"type":"string"},"options":{"$ref":"#/definitions/BroadcastCacheUpdateOptions"}},"additionalProperties":false,"required":["options"]},"cacheableResponse":{"$ref":"#/definitions/CacheableResponseOptions"},"cacheName":{"type":["null","string"]},"expiration":{"$ref":"#/definitions/ExpirationPluginOptions"},"networkTimeoutSeconds":{"type":"number"},"plugins":{"type":"array","items":{"$ref":"#/definitions/WorkboxPlugin"}},"precacheFallback":{"type":"object","properties":{"fallbackURL":{"type":"string"}},"additionalProperties":false,"required":["fallbackURL"]},"fetchOptions":{"$ref":"#/definitions/RequestInit"},"matchOptions":{"$ref":"#/definitions/CacheQueryOptions"}},"additionalProperties":false},"urlPattern":{"anyOf":[{"$ref":"#/definitions/RegExp"},{"$ref":"#/definitions/RouteMatchCallback"},{"type":"string"}]}},"additionalProperties":false,"required":["handler","urlPattern"]},"RouteHandlerCallback":{"description":"The \"handler\" callback is invoked whenever a `Router` matches a URL/Request\nto a `Route` via its `RouteMatchCallback`. This handler callback should\nreturn a `Promise` that resolves with a `Response`.\n\nIf a non-empty array or object is returned by the `RouteMatchCallback` it\nwill be passed in as this handler's `options.params` argument.","type":"object","additionalProperties":false},"RouteHandlerObject":{"description":"An object with a `handle` method of type `RouteHandlerCallback`.\n\nA `Route` object can be created with either an `RouteHandlerCallback`\nfunction or this `RouteHandler` object. The benefit of the `RouteHandler`\nis it can be extended (as is done by the `workbox-strategies` package).","type":"object","properties":{"handle":{"$ref":"#/definitions/RouteHandlerCallback"}},"additionalProperties":false,"required":["handle"]},"QueueOptions":{"type":"object","properties":{"onSync":{"$ref":"#/definitions/OnSyncCallback"},"maxRetentionTime":{"type":"number"}},"additionalProperties":false},"OnSyncCallback":{"type":"object","additionalProperties":false},"BroadcastCacheUpdateOptions":{"type":"object","properties":{"headersToCheck":{"type":"array","items":{"type":"string"}},"generatePayload":{"type":"object","additionalProperties":false}},"additionalProperties":false},"CacheableResponseOptions":{"type":"object","properties":{"statuses":{"type":"array","items":{"type":"number"}},"headers":{"type":"object","additionalProperties":{"type":"string"}}},"additionalProperties":false},"ExpirationPluginOptions":{"type":"object","properties":{"maxEntries":{"type":"number"},"maxAgeSeconds":{"type":"number"},"matchOptions":{"$ref":"#/definitions/CacheQueryOptions"},"purgeOnQuotaError":{"type":"boolean"}},"additionalProperties":false},"CacheQueryOptions":{"type":"object","properties":{"ignoreMethod":{"type":"boolean"},"ignoreSearch":{"type":"boolean"},"ignoreVary":{"type":"boolean"}},"additionalProperties":false},"WorkboxPlugin":{"description":"An object with optional lifecycle callback properties for the fetch and\ncache operations.","type":"object","properties":{"cacheDidUpdate":{"$ref":"#/definitions/CacheDidUpdateCallback"},"cachedResponseWillBeUsed":{"$ref":"#/definitions/CachedResponseWillBeUsedCallback"},"cacheKeyWillBeUsed":{"$ref":"#/definitions/CacheKeyWillBeUsedCallback"},"cacheWillUpdate":{"$ref":"#/definitions/CacheWillUpdateCallback"},"fetchDidFail":{"$ref":"#/definitions/FetchDidFailCallback"},"fetchDidSucceed":{"$ref":"#/definitions/FetchDidSucceedCallback"},"handlerDidComplete":{"$ref":"#/definitions/HandlerDidCompleteCallback"},"handlerDidError":{"$ref":"#/definitions/HandlerDidErrorCallback"},"handlerDidRespond":{"$ref":"#/definitions/HandlerDidRespondCallback"},"handlerWillRespond":{"$ref":"#/definitions/HandlerWillRespondCallback"},"handlerWillStart":{"$ref":"#/definitions/HandlerWillStartCallback"},"requestWillFetch":{"$ref":"#/definitions/RequestWillFetchCallback"}},"additionalProperties":false},"CacheDidUpdateCallback":{"type":"object","additionalProperties":false},"CachedResponseWillBeUsedCallback":{"type":"object","additionalProperties":false},"CacheKeyWillBeUsedCallback":{"type":"object","additionalProperties":false},"CacheWillUpdateCallback":{"type":"object","additionalProperties":false},"FetchDidFailCallback":{"type":"object","additionalProperties":false},"FetchDidSucceedCallback":{"type":"object","additionalProperties":false},"HandlerDidCompleteCallback":{"type":"object","additionalProperties":false},"HandlerDidErrorCallback":{"type":"object","additionalProperties":false},"HandlerDidRespondCallback":{"type":"object","additionalProperties":false},"HandlerWillRespondCallback":{"type":"object","additionalProperties":false},"HandlerWillStartCallback":{"type":"object","additionalProperties":false},"RequestWillFetchCallback":{"type":"object","additionalProperties":false},"RequestInit":{"type":"object","properties":{"body":{"anyOf":[{"$ref":"#/definitions/ArrayBuffer"},{"$ref":"#/definitions/ArrayBufferView"},{"$ref":"#/definitions/Blob"},{"$ref":"#/definitions/FormData"},{"$ref":"#/definitions/URLSearchParams"},{"$ref":"#/definitions/ReadableStream"},{"type":["null","string"]}]},"cache":{"enum":["default","force-cache","no-cache","no-store","only-if-cached","reload"],"type":"string"},"credentials":{"enum":["include","omit","same-origin"],"type":"string"},"headers":{"anyOf":[{"$ref":"#/definitions/Headers"},{"type":"array","items":{"type":"array","items":{"type":"string"}}},{"$ref":"#/definitions/Record"}]},"integrity":{"type":"string"},"keepalive":{"type":"boolean"},"method":{"type":"string"},"mode":{"enum":["cors","navigate","no-cors","same-origin"],"type":"string"},"redirect":{"enum":["error","follow","manual"],"type":"string"},"referrer":{"type":"string"},"referrerPolicy":{"enum":["","no-referrer","no-referrer-when-downgrade","origin","origin-when-cross-origin","same-origin","strict-origin","strict-origin-when-cross-origin","unsafe-url"],"type":"string"},"signal":{"anyOf":[{"$ref":"#/definitions/AbortSignal"},{"type":"null"}]},"window":{}},"additionalProperties":false},"ArrayBuffer":{"type":"object","properties":{"byteLength":{"type":"number"},"__@toStringTag":{"type":"string"}},"additionalProperties":false,"required":["__@toStringTag","byteLength"]},"ArrayBufferView":{"type":"object","properties":{"buffer":{"anyOf":[{"$ref":"#/definitions/ArrayBuffer"},{"$ref":"#/definitions/SharedArrayBuffer"}]},"byteLength":{"type":"number"},"byteOffset":{"type":"number"}},"additionalProperties":false,"required":["buffer","byteLength","byteOffset"]},"SharedArrayBuffer":{"type":"object","properties":{"byteLength":{"type":"number"},"__@species":{"$ref":"#/definitions/SharedArrayBuffer"},"__@toStringTag":{"type":"string","enum":["SharedArrayBuffer"]}},"additionalProperties":false,"required":["__@species","__@toStringTag","byteLength"]},"Blob":{"type":"object","properties":{"size":{"type":"number"},"type":{"type":"string"}},"additionalProperties":false,"required":["size","type"]},"FormData":{"type":"object","additionalProperties":false},"URLSearchParams":{"type":"object","additionalProperties":false},"ReadableStream":{"type":"object","properties":{"locked":{"type":"boolean"}},"additionalProperties":false,"required":["locked"]},"Headers":{"type":"object","additionalProperties":false},"Record":{"type":"object","additionalProperties":false},"AbortSignal":{"type":"object","properties":{"aborted":{"type":"boolean"},"onabort":{"anyOf":[{"type":"object","additionalProperties":false},{"type":"null"}]}},"additionalProperties":false,"required":["aborted","onabort"]},"RouteMatchCallback":{"description":"The \"match\" callback is used to determine if a `Route` should apply for a\nparticular URL and request. When matching occurs in response to a fetch\nevent from the client, the `event` object is also supplied. However, since\nthe match callback can be invoked outside of a fetch event, matching logic\nshould not assume the `event` object will always be available.\nIf the match callback returns a truthy value, the matching route's\n`RouteHandlerCallback` will be invoked immediately. If the value returned\nis a non-empty array or object, that value will be set on the handler's\n`options.params` argument.","type":"object","additionalProperties":false},"ManifestEntry":{"type":"object","properties":{"integrity":{"type":"string"},"revision":{"type":["null","string"]},"url":{"type":"string"}},"additionalProperties":false,"required":["revision","url"]}},"$schema":"http://json-schema.org/draft-07/schema#"} diff --git a/packages/workbox-build/src/schema/WebpackGenerateSWOptions.json b/packages/workbox-build/src/schema/WebpackGenerateSWOptions.json index 8507b76ea..d0617d7b0 100644 --- a/packages/workbox-build/src/schema/WebpackGenerateSWOptions.json +++ b/packages/workbox-build/src/schema/WebpackGenerateSWOptions.json @@ -1 +1 @@ -{"additionalProperties":false,"type":"object","properties":{"chunks":{"type":"array","items":{"type":"string"}},"exclude":{"default":"[/\\.map$/, /^manifest.*\\.js$/,]","type":"array","items":{"anyOf":[{"$ref":"#/definitions/RegExp"},{"type":"object","additionalProperties":false},{"type":"string"}]}},"excludeChunks":{"type":"array","items":{"type":"string"}},"include":{"type":"array","items":{"anyOf":[{"$ref":"#/definitions/RegExp"},{"type":"object","additionalProperties":false},{"type":"string"}]}},"mode":{"default":"production","type":["null","string"]},"babelPresetEnvTargets":{"default":["chrome >= 56"],"type":"array","items":{"type":"string"}},"cacheId":{"type":["null","string"]},"cleanupOutdatedCaches":{"default":false,"type":"boolean"},"clientsClaim":{"default":false,"type":"boolean"},"directoryIndex":{"type":["null","string"]},"disableDevLogs":{"default":false,"type":"boolean"},"ignoreURLParametersMatching":{"type":"array","items":{"$ref":"#/definitions/RegExp"}},"importScripts":{"type":"array","items":{"type":"string"}},"inlineWorkboxRuntime":{"default":false,"type":"boolean"},"navigateFallback":{"default":null,"type":["null","string"]},"navigateFallbackAllowlist":{"type":"array","items":{"$ref":"#/definitions/RegExp"}},"navigateFallbackDenylist":{"type":"array","items":{"$ref":"#/definitions/RegExp"}},"navigationPreload":{"default":false,"type":"boolean"},"offlineGoogleAnalytics":{"default":false,"anyOf":[{"$ref":"#/definitions/GoogleAnalyticsInitializeOptions"},{"type":"boolean"}]},"runtimeCaching":{"type":"array","items":{"$ref":"#/definitions/RuntimeCaching"}},"skipWaiting":{"default":false,"type":"boolean"},"sourcemap":{"default":true,"type":"boolean"},"additionalManifestEntries":{"type":"array","items":{"anyOf":[{"$ref":"#/definitions/ManifestEntry"},{"type":"string"}]}},"dontCacheBustURLsMatching":{"$ref":"#/definitions/RegExp"},"manifestTransforms":{"type":"array","items":{"type":"object","additionalProperties":false}},"maximumFileSizeToCacheInBytes":{"default":2097152,"type":"number"},"modifyURLPrefix":{"type":"object","additionalProperties":{"type":"string"}},"swDest":{"default":"service-worker.js","type":"string"},"importScriptsViaChunks":{"type":"array","items":{"type":"string"}}},"required":["importScriptsViaChunks","swDest"],"definitions":{"RegExp":{"type":"object","properties":{"source":{"type":"string"},"global":{"type":"boolean"},"ignoreCase":{"type":"boolean"},"multiline":{"type":"boolean"},"lastIndex":{"type":"number"},"flags":{"type":"string"},"sticky":{"type":"boolean"},"unicode":{"type":"boolean"},"dotAll":{"type":"boolean"}},"additionalProperties":false,"required":["dotAll","flags","global","ignoreCase","lastIndex","multiline","source","sticky","unicode"]},"GoogleAnalyticsInitializeOptions":{"type":"object","properties":{"cacheName":{"type":"string"},"parameterOverrides":{"type":"object","additionalProperties":{"type":"string"}},"hitFilter":{"type":"object","additionalProperties":false}},"additionalProperties":false},"RuntimeCaching":{"type":"object","properties":{"handler":{"anyOf":[{"$ref":"#/definitions/RouteHandlerCallback"},{"$ref":"#/definitions/RouteHandlerObject"},{"enum":["CacheFirst","CacheOnly","NetworkFirst","NetworkOnly","StaleWhileRevalidate"],"type":"string"}]},"method":{"enum":["DELETE","GET","HEAD","PATCH","POST","PUT"],"type":"string"},"options":{"type":"object","properties":{"backgroundSync":{"type":"object","properties":{"name":{"type":"string"},"options":{"$ref":"#/definitions/QueueOptions"}},"additionalProperties":false,"required":["name"]},"broadcastUpdate":{"type":"object","properties":{"channelName":{"type":"string"},"options":{"$ref":"#/definitions/BroadcastCacheUpdateOptions"}},"additionalProperties":false,"required":["options"]},"cacheableResponse":{"$ref":"#/definitions/CacheableResponseOptions"},"cacheName":{"type":["null","string"]},"expiration":{"$ref":"#/definitions/ExpirationPluginOptions"},"networkTimeoutSeconds":{"type":"number"},"plugins":{"type":"array","items":{"$ref":"#/definitions/WorkboxPlugin"}},"precacheFallback":{"type":"object","properties":{"fallbackURL":{"type":"string"}},"additionalProperties":false,"required":["fallbackURL"]},"fetchOptions":{"$ref":"#/definitions/RequestInit"},"matchOptions":{"$ref":"#/definitions/CacheQueryOptions"}},"additionalProperties":false},"urlPattern":{"anyOf":[{"$ref":"#/definitions/RegExp"},{"$ref":"#/definitions/RouteMatchCallback"},{"type":"string"}]}},"additionalProperties":false,"required":["handler","urlPattern"]},"RouteHandlerCallback":{"description":"The \"handler\" callback is invoked whenever a `Router` matches a URL/Request\nto a `Route` via its `RouteMatchCallback`. This handler callback should\nreturn a `Promise` that resolves with a `Response`.\n\nIf a non-empty array or object is returned by the `RouteMatchCallback` it\nwill be passed in as this handler's `options.params` argument.","type":"object","additionalProperties":false},"RouteHandlerObject":{"description":"An object with a `handle` method of type `RouteHandlerCallback`.\n\nA `Route` object can be created with either an `RouteHandlerCallback`\nfunction or this `RouteHandler` object. The benefit of the `RouteHandler`\nis it can be extended (as is done by the `workbox-strategies` package).","type":"object","properties":{"handle":{"$ref":"#/definitions/RouteHandlerCallback"}},"additionalProperties":false,"required":["handle"]},"QueueOptions":{"type":"object","properties":{"onSync":{"$ref":"#/definitions/OnSyncCallback"},"maxRetentionTime":{"type":"number"}},"additionalProperties":false},"OnSyncCallback":{"type":"object","additionalProperties":false},"BroadcastCacheUpdateOptions":{"type":"object","properties":{"headersToCheck":{"type":"array","items":{"type":"string"}},"generatePayload":{"type":"object","additionalProperties":false}},"additionalProperties":false},"CacheableResponseOptions":{"type":"object","properties":{"statuses":{"type":"array","items":{"type":"number"}},"headers":{"type":"object","additionalProperties":{"type":"string"}}},"additionalProperties":false},"ExpirationPluginOptions":{"type":"object","properties":{"maxEntries":{"type":"number"},"maxAgeSeconds":{"type":"number"},"matchOptions":{"$ref":"#/definitions/CacheQueryOptions"},"purgeOnQuotaError":{"type":"boolean"}},"additionalProperties":false},"CacheQueryOptions":{"type":"object","properties":{"ignoreMethod":{"type":"boolean"},"ignoreSearch":{"type":"boolean"},"ignoreVary":{"type":"boolean"}},"additionalProperties":false},"WorkboxPlugin":{"description":"An object with optional lifecycle callback properties for the fetch and\ncache operations.","type":"object","properties":{"cacheDidUpdate":{"$ref":"#/definitions/CacheDidUpdateCallback"},"cachedResponseWillBeUsed":{"$ref":"#/definitions/CachedResponseWillBeUsedCallback"},"cacheKeyWillBeUsed":{"$ref":"#/definitions/CacheKeyWillBeUsedCallback"},"cacheWillUpdate":{"$ref":"#/definitions/CacheWillUpdateCallback"},"fetchDidFail":{"$ref":"#/definitions/FetchDidFailCallback"},"fetchDidSucceed":{"$ref":"#/definitions/FetchDidSucceedCallback"},"handlerDidComplete":{"$ref":"#/definitions/HandlerDidCompleteCallback"},"handlerDidError":{"$ref":"#/definitions/HandlerDidErrorCallback"},"handlerDidRespond":{"$ref":"#/definitions/HandlerDidRespondCallback"},"handlerWillRespond":{"$ref":"#/definitions/HandlerWillRespondCallback"},"handlerWillStart":{"$ref":"#/definitions/HandlerWillStartCallback"},"requestWillFetch":{"$ref":"#/definitions/RequestWillFetchCallback"}},"additionalProperties":false},"CacheDidUpdateCallback":{"type":"object","additionalProperties":false},"CachedResponseWillBeUsedCallback":{"type":"object","additionalProperties":false},"CacheKeyWillBeUsedCallback":{"type":"object","additionalProperties":false},"CacheWillUpdateCallback":{"type":"object","additionalProperties":false},"FetchDidFailCallback":{"type":"object","additionalProperties":false},"FetchDidSucceedCallback":{"type":"object","additionalProperties":false},"HandlerDidCompleteCallback":{"type":"object","additionalProperties":false},"HandlerDidErrorCallback":{"type":"object","additionalProperties":false},"HandlerDidRespondCallback":{"type":"object","additionalProperties":false},"HandlerWillRespondCallback":{"type":"object","additionalProperties":false},"HandlerWillStartCallback":{"type":"object","additionalProperties":false},"RequestWillFetchCallback":{"type":"object","additionalProperties":false},"RequestInit":{"type":"object","properties":{"body":{"anyOf":[{"$ref":"#/definitions/ArrayBuffer"},{"$ref":"#/definitions/ArrayBufferView"},{"$ref":"#/definitions/Blob"},{"$ref":"#/definitions/FormData"},{"$ref":"#/definitions/URLSearchParams"},{"$ref":"#/definitions/ReadableStream"},{"type":["null","string"]}]},"cache":{"enum":["default","force-cache","no-cache","no-store","only-if-cached","reload"],"type":"string"},"credentials":{"enum":["include","omit","same-origin"],"type":"string"},"headers":{"anyOf":[{"$ref":"#/definitions/Headers"},{"type":"array","items":{"type":"array","items":{"type":"string"}}},{"$ref":"#/definitions/Record"}]},"integrity":{"type":"string"},"keepalive":{"type":"boolean"},"method":{"type":"string"},"mode":{"enum":["cors","navigate","no-cors","same-origin"],"type":"string"},"redirect":{"enum":["error","follow","manual"],"type":"string"},"referrer":{"type":"string"},"referrerPolicy":{"enum":["","no-referrer","no-referrer-when-downgrade","origin","origin-when-cross-origin","same-origin","strict-origin","strict-origin-when-cross-origin","unsafe-url"],"type":"string"},"signal":{"anyOf":[{"$ref":"#/definitions/AbortSignal"},{"type":"null"}]},"window":{}},"additionalProperties":false},"ArrayBuffer":{"type":"object","properties":{"byteLength":{"type":"number"},"__@toStringTag":{"type":"string"}},"additionalProperties":false,"required":["__@toStringTag","byteLength"]},"ArrayBufferView":{"type":"object","properties":{"buffer":{"anyOf":[{"$ref":"#/definitions/ArrayBuffer"},{"$ref":"#/definitions/SharedArrayBuffer"}]},"byteLength":{"type":"number"},"byteOffset":{"type":"number"}},"additionalProperties":false,"required":["buffer","byteLength","byteOffset"]},"SharedArrayBuffer":{"type":"object","properties":{"byteLength":{"type":"number"},"__@species":{"$ref":"#/definitions/SharedArrayBuffer"},"__@toStringTag":{"type":"string","enum":["SharedArrayBuffer"]}},"additionalProperties":false,"required":["__@species","__@toStringTag","byteLength"]},"Blob":{"type":"object","properties":{"size":{"type":"number"},"type":{"type":"string"}},"additionalProperties":false,"required":["size","type"]},"FormData":{"type":"object","additionalProperties":false},"URLSearchParams":{"type":"object","additionalProperties":false},"ReadableStream":{"type":"object","properties":{"locked":{"type":"boolean"}},"additionalProperties":false,"required":["locked"]},"Headers":{"type":"object","additionalProperties":false},"Record":{"type":"object","additionalProperties":false},"AbortSignal":{"type":"object","properties":{"aborted":{"type":"boolean"},"onabort":{"anyOf":[{"type":"object","additionalProperties":false},{"type":"null"}]}},"additionalProperties":false,"required":["aborted","onabort"]},"RouteMatchCallback":{"description":"The \"match\" callback is used to determine if a `Route` should apply for a\nparticular URL and request. When matching occurs in response to a fetch\nevent from the client, the `event` object is also supplied. However, since\nthe match callback can be invoked outside of a fetch event, matching logic\nshould not assume the `event` object will always be available.\nIf the match callback returns a truthy value, the matching route's\n`RouteHandlerCallback` will be invoked immediately. If the value returned\nis a non-empty array or object, that value will be set on the handler's\n`options.params` argument.","type":"object","additionalProperties":false},"ManifestEntry":{"type":"object","properties":{"integrity":{"type":"string"},"revision":{"type":["null","string"]},"url":{"type":"string"}},"additionalProperties":false,"required":["revision","url"]}},"$schema":"http://json-schema.org/draft-07/schema#"} +{"additionalProperties":false,"type":"object","properties":{"chunks":{"type":"array","items":{"type":"string"}},"exclude":{"default":"[/\\.map$/, /^manifest.*\\.js$/,]","type":"array","items":{"anyOf":[{"$ref":"#/definitions/RegExp"},{"type":"object","additionalProperties":false},{"type":"string"}]}},"excludeChunks":{"type":"array","items":{"type":"string"}},"include":{"type":"array","items":{"anyOf":[{"$ref":"#/definitions/RegExp"},{"type":"object","additionalProperties":false},{"type":"string"}]}},"mode":{"default":"production","type":["null","string"]},"babelPresetEnvTargets":{"default":["chrome >= 56"],"type":"array","items":{"type":"string"}},"cacheId":{"type":["null","string"]},"cleanupOutdatedCaches":{"default":false,"type":"boolean"},"clientsClaim":{"default":false,"type":"boolean"},"directoryIndex":{"type":["null","string"]},"disableDevLogs":{"default":false,"type":"boolean"},"ignoreURLParametersMatching":{"type":"array","items":{"$ref":"#/definitions/RegExp"}},"importScripts":{"type":"array","items":{"type":"string"}},"inlineWorkboxRuntime":{"default":false,"type":"boolean"},"navigateFallback":{"default":null,"type":["null","string"]},"navigateFallbackAllowlist":{"type":"array","items":{"$ref":"#/definitions/RegExp"}},"navigateFallbackDenylist":{"type":"array","items":{"$ref":"#/definitions/RegExp"}},"navigationPreload":{"default":false,"type":"boolean"},"offlineGoogleAnalytics":{"default":false,"anyOf":[{"$ref":"#/definitions/GoogleAnalyticsInitializeOptions"},{"type":"boolean"}]},"runtimeCaching":{"type":"array","items":{"$ref":"#/definitions/RuntimeCaching"}},"skipWaiting":{"default":false,"type":"boolean"},"sourcemap":{"default":true,"type":"boolean"},"additionalManifestEntries":{"type":"array","items":{"anyOf":[{"$ref":"#/definitions/ManifestEntry"},{"type":"string"}]}},"dontCacheBustURLsMatching":{"$ref":"#/definitions/RegExp"},"manifestTransforms":{"type":"array","items":{"type":"object","additionalProperties":false}},"maximumFileSizeToCacheInBytes":{"default":2097152,"type":"number"},"modifyURLPrefix":{"type":"object","additionalProperties":{"type":"string"}},"swDest":{"default":"service-worker.js","type":"string"},"importScriptsViaChunks":{"type":"array","items":{"type":"string"}}},"required":["importScriptsViaChunks"],"definitions":{"RegExp":{"type":"object","properties":{"source":{"type":"string"},"global":{"type":"boolean"},"ignoreCase":{"type":"boolean"},"multiline":{"type":"boolean"},"lastIndex":{"type":"number"},"flags":{"type":"string"},"sticky":{"type":"boolean"},"unicode":{"type":"boolean"},"dotAll":{"type":"boolean"}},"additionalProperties":false,"required":["dotAll","flags","global","ignoreCase","lastIndex","multiline","source","sticky","unicode"]},"GoogleAnalyticsInitializeOptions":{"type":"object","properties":{"cacheName":{"type":"string"},"parameterOverrides":{"type":"object","additionalProperties":{"type":"string"}},"hitFilter":{"type":"object","additionalProperties":false}},"additionalProperties":false},"RuntimeCaching":{"type":"object","properties":{"handler":{"anyOf":[{"$ref":"#/definitions/RouteHandlerCallback"},{"$ref":"#/definitions/RouteHandlerObject"},{"enum":["CacheFirst","CacheOnly","NetworkFirst","NetworkOnly","StaleWhileRevalidate"],"type":"string"}]},"method":{"enum":["DELETE","GET","HEAD","PATCH","POST","PUT"],"type":"string"},"options":{"type":"object","properties":{"backgroundSync":{"type":"object","properties":{"name":{"type":"string"},"options":{"$ref":"#/definitions/QueueOptions"}},"additionalProperties":false,"required":["name"]},"broadcastUpdate":{"type":"object","properties":{"channelName":{"type":"string"},"options":{"$ref":"#/definitions/BroadcastCacheUpdateOptions"}},"additionalProperties":false,"required":["options"]},"cacheableResponse":{"$ref":"#/definitions/CacheableResponseOptions"},"cacheName":{"type":["null","string"]},"expiration":{"$ref":"#/definitions/ExpirationPluginOptions"},"networkTimeoutSeconds":{"type":"number"},"plugins":{"type":"array","items":{"$ref":"#/definitions/WorkboxPlugin"}},"precacheFallback":{"type":"object","properties":{"fallbackURL":{"type":"string"}},"additionalProperties":false,"required":["fallbackURL"]},"fetchOptions":{"$ref":"#/definitions/RequestInit"},"matchOptions":{"$ref":"#/definitions/CacheQueryOptions"}},"additionalProperties":false},"urlPattern":{"anyOf":[{"$ref":"#/definitions/RegExp"},{"$ref":"#/definitions/RouteMatchCallback"},{"type":"string"}]}},"additionalProperties":false,"required":["handler","urlPattern"]},"RouteHandlerCallback":{"description":"The \"handler\" callback is invoked whenever a `Router` matches a URL/Request\nto a `Route` via its `RouteMatchCallback`. This handler callback should\nreturn a `Promise` that resolves with a `Response`.\n\nIf a non-empty array or object is returned by the `RouteMatchCallback` it\nwill be passed in as this handler's `options.params` argument.","type":"object","additionalProperties":false},"RouteHandlerObject":{"description":"An object with a `handle` method of type `RouteHandlerCallback`.\n\nA `Route` object can be created with either an `RouteHandlerCallback`\nfunction or this `RouteHandler` object. The benefit of the `RouteHandler`\nis it can be extended (as is done by the `workbox-strategies` package).","type":"object","properties":{"handle":{"$ref":"#/definitions/RouteHandlerCallback"}},"additionalProperties":false,"required":["handle"]},"QueueOptions":{"type":"object","properties":{"onSync":{"$ref":"#/definitions/OnSyncCallback"},"maxRetentionTime":{"type":"number"}},"additionalProperties":false},"OnSyncCallback":{"type":"object","additionalProperties":false},"BroadcastCacheUpdateOptions":{"type":"object","properties":{"headersToCheck":{"type":"array","items":{"type":"string"}},"generatePayload":{"type":"object","additionalProperties":false}},"additionalProperties":false},"CacheableResponseOptions":{"type":"object","properties":{"statuses":{"type":"array","items":{"type":"number"}},"headers":{"type":"object","additionalProperties":{"type":"string"}}},"additionalProperties":false},"ExpirationPluginOptions":{"type":"object","properties":{"maxEntries":{"type":"number"},"maxAgeSeconds":{"type":"number"},"matchOptions":{"$ref":"#/definitions/CacheQueryOptions"},"purgeOnQuotaError":{"type":"boolean"}},"additionalProperties":false},"CacheQueryOptions":{"type":"object","properties":{"ignoreMethod":{"type":"boolean"},"ignoreSearch":{"type":"boolean"},"ignoreVary":{"type":"boolean"}},"additionalProperties":false},"WorkboxPlugin":{"description":"An object with optional lifecycle callback properties for the fetch and\ncache operations.","type":"object","properties":{"cacheDidUpdate":{"$ref":"#/definitions/CacheDidUpdateCallback"},"cachedResponseWillBeUsed":{"$ref":"#/definitions/CachedResponseWillBeUsedCallback"},"cacheKeyWillBeUsed":{"$ref":"#/definitions/CacheKeyWillBeUsedCallback"},"cacheWillUpdate":{"$ref":"#/definitions/CacheWillUpdateCallback"},"fetchDidFail":{"$ref":"#/definitions/FetchDidFailCallback"},"fetchDidSucceed":{"$ref":"#/definitions/FetchDidSucceedCallback"},"handlerDidComplete":{"$ref":"#/definitions/HandlerDidCompleteCallback"},"handlerDidError":{"$ref":"#/definitions/HandlerDidErrorCallback"},"handlerDidRespond":{"$ref":"#/definitions/HandlerDidRespondCallback"},"handlerWillRespond":{"$ref":"#/definitions/HandlerWillRespondCallback"},"handlerWillStart":{"$ref":"#/definitions/HandlerWillStartCallback"},"requestWillFetch":{"$ref":"#/definitions/RequestWillFetchCallback"}},"additionalProperties":false},"CacheDidUpdateCallback":{"type":"object","additionalProperties":false},"CachedResponseWillBeUsedCallback":{"type":"object","additionalProperties":false},"CacheKeyWillBeUsedCallback":{"type":"object","additionalProperties":false},"CacheWillUpdateCallback":{"type":"object","additionalProperties":false},"FetchDidFailCallback":{"type":"object","additionalProperties":false},"FetchDidSucceedCallback":{"type":"object","additionalProperties":false},"HandlerDidCompleteCallback":{"type":"object","additionalProperties":false},"HandlerDidErrorCallback":{"type":"object","additionalProperties":false},"HandlerDidRespondCallback":{"type":"object","additionalProperties":false},"HandlerWillRespondCallback":{"type":"object","additionalProperties":false},"HandlerWillStartCallback":{"type":"object","additionalProperties":false},"RequestWillFetchCallback":{"type":"object","additionalProperties":false},"RequestInit":{"type":"object","properties":{"body":{"anyOf":[{"$ref":"#/definitions/ArrayBuffer"},{"$ref":"#/definitions/ArrayBufferView"},{"$ref":"#/definitions/Blob"},{"$ref":"#/definitions/FormData"},{"$ref":"#/definitions/URLSearchParams"},{"$ref":"#/definitions/ReadableStream"},{"type":["null","string"]}]},"cache":{"enum":["default","force-cache","no-cache","no-store","only-if-cached","reload"],"type":"string"},"credentials":{"enum":["include","omit","same-origin"],"type":"string"},"headers":{"anyOf":[{"$ref":"#/definitions/Headers"},{"type":"array","items":{"type":"array","items":{"type":"string"}}},{"$ref":"#/definitions/Record"}]},"integrity":{"type":"string"},"keepalive":{"type":"boolean"},"method":{"type":"string"},"mode":{"enum":["cors","navigate","no-cors","same-origin"],"type":"string"},"redirect":{"enum":["error","follow","manual"],"type":"string"},"referrer":{"type":"string"},"referrerPolicy":{"enum":["","no-referrer","no-referrer-when-downgrade","origin","origin-when-cross-origin","same-origin","strict-origin","strict-origin-when-cross-origin","unsafe-url"],"type":"string"},"signal":{"anyOf":[{"$ref":"#/definitions/AbortSignal"},{"type":"null"}]},"window":{}},"additionalProperties":false},"ArrayBuffer":{"type":"object","properties":{"byteLength":{"type":"number"},"__@toStringTag":{"type":"string"}},"additionalProperties":false,"required":["__@toStringTag","byteLength"]},"ArrayBufferView":{"type":"object","properties":{"buffer":{"anyOf":[{"$ref":"#/definitions/ArrayBuffer"},{"$ref":"#/definitions/SharedArrayBuffer"}]},"byteLength":{"type":"number"},"byteOffset":{"type":"number"}},"additionalProperties":false,"required":["buffer","byteLength","byteOffset"]},"SharedArrayBuffer":{"type":"object","properties":{"byteLength":{"type":"number"},"__@species":{"$ref":"#/definitions/SharedArrayBuffer"},"__@toStringTag":{"type":"string","enum":["SharedArrayBuffer"]}},"additionalProperties":false,"required":["__@species","__@toStringTag","byteLength"]},"Blob":{"type":"object","properties":{"size":{"type":"number"},"type":{"type":"string"}},"additionalProperties":false,"required":["size","type"]},"FormData":{"type":"object","additionalProperties":false},"URLSearchParams":{"type":"object","additionalProperties":false},"ReadableStream":{"type":"object","properties":{"locked":{"type":"boolean"}},"additionalProperties":false,"required":["locked"]},"Headers":{"type":"object","additionalProperties":false},"Record":{"type":"object","additionalProperties":false},"AbortSignal":{"type":"object","properties":{"aborted":{"type":"boolean"},"onabort":{"anyOf":[{"type":"object","additionalProperties":false},{"type":"null"}]}},"additionalProperties":false,"required":["aborted","onabort"]},"RouteMatchCallback":{"description":"The \"match\" callback is used to determine if a `Route` should apply for a\nparticular URL and request. When matching occurs in response to a fetch\nevent from the client, the `event` object is also supplied. However, since\nthe match callback can be invoked outside of a fetch event, matching logic\nshould not assume the `event` object will always be available.\nIf the match callback returns a truthy value, the matching route's\n`RouteHandlerCallback` will be invoked immediately. If the value returned\nis a non-empty array or object, that value will be set on the handler's\n`options.params` argument.","type":"object","additionalProperties":false},"ManifestEntry":{"type":"object","properties":{"integrity":{"type":"string"},"revision":{"type":["null","string"]},"url":{"type":"string"}},"additionalProperties":false,"required":["revision","url"]}},"$schema":"http://json-schema.org/draft-07/schema#"} diff --git a/packages/workbox-build/src/schema/WebpackInjectManifestOptions.json b/packages/workbox-build/src/schema/WebpackInjectManifestOptions.json index 4198d4227..6203cfb3d 100644 --- a/packages/workbox-build/src/schema/WebpackInjectManifestOptions.json +++ b/packages/workbox-build/src/schema/WebpackInjectManifestOptions.json @@ -1 +1 @@ -{"additionalProperties":false,"type":"object","properties":{"chunks":{"type":"array","items":{"type":"string"}},"exclude":{"default":"[/\\.map$/, /^manifest.*\\.js$/,]","type":"array","items":{"anyOf":[{"$ref":"#/definitions/RegExp"},{"type":"object","additionalProperties":false},{"type":"string"}]}},"excludeChunks":{"type":"array","items":{"type":"string"}},"include":{"type":"array","items":{"anyOf":[{"$ref":"#/definitions/RegExp"},{"type":"object","additionalProperties":false},{"type":"string"}]}},"mode":{"type":["null","string"]},"injectionPoint":{"default":"self.__WB_MANIFEST","type":"string"},"swSrc":{"type":"string"},"additionalManifestEntries":{"type":"array","items":{"anyOf":[{"$ref":"#/definitions/ManifestEntry"},{"type":"string"}]}},"dontCacheBustURLsMatching":{"$ref":"#/definitions/RegExp"},"manifestTransforms":{"type":"array","items":{"type":"object","additionalProperties":false}},"maximumFileSizeToCacheInBytes":{"default":2097152,"type":"number"},"modifyURLPrefix":{"type":"object","additionalProperties":{"type":"string"}},"swDest":{"default":"service-worker.js","type":"string"},"compileSrc":{"default":true,"type":"boolean"},"webpackCompilationPlugins":{"type":"array","items":{}}},"required":["swDest","swSrc"],"definitions":{"RegExp":{"type":"object","properties":{"source":{"type":"string"},"global":{"type":"boolean"},"ignoreCase":{"type":"boolean"},"multiline":{"type":"boolean"},"lastIndex":{"type":"number"},"flags":{"type":"string"},"sticky":{"type":"boolean"},"unicode":{"type":"boolean"},"dotAll":{"type":"boolean"}},"additionalProperties":false,"required":["dotAll","flags","global","ignoreCase","lastIndex","multiline","source","sticky","unicode"]},"GoogleAnalyticsInitializeOptions":{"type":"object","properties":{"cacheName":{"type":"string"},"parameterOverrides":{"type":"object","additionalProperties":{"type":"string"}},"hitFilter":{"type":"object","additionalProperties":false}},"additionalProperties":false},"RuntimeCaching":{"type":"object","properties":{"handler":{"anyOf":[{"$ref":"#/definitions/RouteHandlerCallback"},{"$ref":"#/definitions/RouteHandlerObject"},{"enum":["CacheFirst","CacheOnly","NetworkFirst","NetworkOnly","StaleWhileRevalidate"],"type":"string"}]},"method":{"enum":["DELETE","GET","HEAD","PATCH","POST","PUT"],"type":"string"},"options":{"type":"object","properties":{"backgroundSync":{"type":"object","properties":{"name":{"type":"string"},"options":{"$ref":"#/definitions/QueueOptions"}},"additionalProperties":false,"required":["name"]},"broadcastUpdate":{"type":"object","properties":{"channelName":{"type":"string"},"options":{"$ref":"#/definitions/BroadcastCacheUpdateOptions"}},"additionalProperties":false,"required":["options"]},"cacheableResponse":{"$ref":"#/definitions/CacheableResponseOptions"},"cacheName":{"type":["null","string"]},"expiration":{"$ref":"#/definitions/ExpirationPluginOptions"},"networkTimeoutSeconds":{"type":"number"},"plugins":{"type":"array","items":{"$ref":"#/definitions/WorkboxPlugin"}},"precacheFallback":{"type":"object","properties":{"fallbackURL":{"type":"string"}},"additionalProperties":false,"required":["fallbackURL"]},"fetchOptions":{"$ref":"#/definitions/RequestInit"},"matchOptions":{"$ref":"#/definitions/CacheQueryOptions"}},"additionalProperties":false},"urlPattern":{"anyOf":[{"$ref":"#/definitions/RegExp"},{"$ref":"#/definitions/RouteMatchCallback"},{"type":"string"}]}},"additionalProperties":false,"required":["handler","urlPattern"]},"RouteHandlerCallback":{"description":"The \"handler\" callback is invoked whenever a `Router` matches a URL/Request\nto a `Route` via its `RouteMatchCallback`. This handler callback should\nreturn a `Promise` that resolves with a `Response`.\n\nIf a non-empty array or object is returned by the `RouteMatchCallback` it\nwill be passed in as this handler's `options.params` argument.","type":"object","additionalProperties":false},"RouteHandlerObject":{"description":"An object with a `handle` method of type `RouteHandlerCallback`.\n\nA `Route` object can be created with either an `RouteHandlerCallback`\nfunction or this `RouteHandler` object. The benefit of the `RouteHandler`\nis it can be extended (as is done by the `workbox-strategies` package).","type":"object","properties":{"handle":{"$ref":"#/definitions/RouteHandlerCallback"}},"additionalProperties":false,"required":["handle"]},"QueueOptions":{"type":"object","properties":{"onSync":{"$ref":"#/definitions/OnSyncCallback"},"maxRetentionTime":{"type":"number"}},"additionalProperties":false},"OnSyncCallback":{"type":"object","additionalProperties":false},"BroadcastCacheUpdateOptions":{"type":"object","properties":{"headersToCheck":{"type":"array","items":{"type":"string"}},"generatePayload":{"type":"object","additionalProperties":false}},"additionalProperties":false},"CacheableResponseOptions":{"type":"object","properties":{"statuses":{"type":"array","items":{"type":"number"}},"headers":{"type":"object","additionalProperties":{"type":"string"}}},"additionalProperties":false},"ExpirationPluginOptions":{"type":"object","properties":{"maxEntries":{"type":"number"},"maxAgeSeconds":{"type":"number"},"matchOptions":{"$ref":"#/definitions/CacheQueryOptions"},"purgeOnQuotaError":{"type":"boolean"}},"additionalProperties":false},"CacheQueryOptions":{"type":"object","properties":{"ignoreMethod":{"type":"boolean"},"ignoreSearch":{"type":"boolean"},"ignoreVary":{"type":"boolean"}},"additionalProperties":false},"WorkboxPlugin":{"description":"An object with optional lifecycle callback properties for the fetch and\ncache operations.","type":"object","properties":{"cacheDidUpdate":{"$ref":"#/definitions/CacheDidUpdateCallback"},"cachedResponseWillBeUsed":{"$ref":"#/definitions/CachedResponseWillBeUsedCallback"},"cacheKeyWillBeUsed":{"$ref":"#/definitions/CacheKeyWillBeUsedCallback"},"cacheWillUpdate":{"$ref":"#/definitions/CacheWillUpdateCallback"},"fetchDidFail":{"$ref":"#/definitions/FetchDidFailCallback"},"fetchDidSucceed":{"$ref":"#/definitions/FetchDidSucceedCallback"},"handlerDidComplete":{"$ref":"#/definitions/HandlerDidCompleteCallback"},"handlerDidError":{"$ref":"#/definitions/HandlerDidErrorCallback"},"handlerDidRespond":{"$ref":"#/definitions/HandlerDidRespondCallback"},"handlerWillRespond":{"$ref":"#/definitions/HandlerWillRespondCallback"},"handlerWillStart":{"$ref":"#/definitions/HandlerWillStartCallback"},"requestWillFetch":{"$ref":"#/definitions/RequestWillFetchCallback"}},"additionalProperties":false},"CacheDidUpdateCallback":{"type":"object","additionalProperties":false},"CachedResponseWillBeUsedCallback":{"type":"object","additionalProperties":false},"CacheKeyWillBeUsedCallback":{"type":"object","additionalProperties":false},"CacheWillUpdateCallback":{"type":"object","additionalProperties":false},"FetchDidFailCallback":{"type":"object","additionalProperties":false},"FetchDidSucceedCallback":{"type":"object","additionalProperties":false},"HandlerDidCompleteCallback":{"type":"object","additionalProperties":false},"HandlerDidErrorCallback":{"type":"object","additionalProperties":false},"HandlerDidRespondCallback":{"type":"object","additionalProperties":false},"HandlerWillRespondCallback":{"type":"object","additionalProperties":false},"HandlerWillStartCallback":{"type":"object","additionalProperties":false},"RequestWillFetchCallback":{"type":"object","additionalProperties":false},"RequestInit":{"type":"object","properties":{"body":{"anyOf":[{"$ref":"#/definitions/ArrayBuffer"},{"$ref":"#/definitions/ArrayBufferView"},{"$ref":"#/definitions/Blob"},{"$ref":"#/definitions/FormData"},{"$ref":"#/definitions/URLSearchParams"},{"$ref":"#/definitions/ReadableStream"},{"type":["null","string"]}]},"cache":{"enum":["default","force-cache","no-cache","no-store","only-if-cached","reload"],"type":"string"},"credentials":{"enum":["include","omit","same-origin"],"type":"string"},"headers":{"anyOf":[{"$ref":"#/definitions/Headers"},{"type":"array","items":{"type":"array","items":{"type":"string"}}},{"$ref":"#/definitions/Record"}]},"integrity":{"type":"string"},"keepalive":{"type":"boolean"},"method":{"type":"string"},"mode":{"enum":["cors","navigate","no-cors","same-origin"],"type":"string"},"redirect":{"enum":["error","follow","manual"],"type":"string"},"referrer":{"type":"string"},"referrerPolicy":{"enum":["","no-referrer","no-referrer-when-downgrade","origin","origin-when-cross-origin","same-origin","strict-origin","strict-origin-when-cross-origin","unsafe-url"],"type":"string"},"signal":{"anyOf":[{"$ref":"#/definitions/AbortSignal"},{"type":"null"}]},"window":{}},"additionalProperties":false},"ArrayBuffer":{"type":"object","properties":{"byteLength":{"type":"number"},"__@toStringTag":{"type":"string"}},"additionalProperties":false,"required":["__@toStringTag","byteLength"]},"ArrayBufferView":{"type":"object","properties":{"buffer":{"anyOf":[{"$ref":"#/definitions/ArrayBuffer"},{"$ref":"#/definitions/SharedArrayBuffer"}]},"byteLength":{"type":"number"},"byteOffset":{"type":"number"}},"additionalProperties":false,"required":["buffer","byteLength","byteOffset"]},"SharedArrayBuffer":{"type":"object","properties":{"byteLength":{"type":"number"},"__@species":{"$ref":"#/definitions/SharedArrayBuffer"},"__@toStringTag":{"type":"string","enum":["SharedArrayBuffer"]}},"additionalProperties":false,"required":["__@species","__@toStringTag","byteLength"]},"Blob":{"type":"object","properties":{"size":{"type":"number"},"type":{"type":"string"}},"additionalProperties":false,"required":["size","type"]},"FormData":{"type":"object","additionalProperties":false},"URLSearchParams":{"type":"object","additionalProperties":false},"ReadableStream":{"type":"object","properties":{"locked":{"type":"boolean"}},"additionalProperties":false,"required":["locked"]},"Headers":{"type":"object","additionalProperties":false},"Record":{"type":"object","additionalProperties":false},"AbortSignal":{"type":"object","properties":{"aborted":{"type":"boolean"},"onabort":{"anyOf":[{"type":"object","additionalProperties":false},{"type":"null"}]}},"additionalProperties":false,"required":["aborted","onabort"]},"RouteMatchCallback":{"description":"The \"match\" callback is used to determine if a `Route` should apply for a\nparticular URL and request. When matching occurs in response to a fetch\nevent from the client, the `event` object is also supplied. However, since\nthe match callback can be invoked outside of a fetch event, matching logic\nshould not assume the `event` object will always be available.\nIf the match callback returns a truthy value, the matching route's\n`RouteHandlerCallback` will be invoked immediately. If the value returned\nis a non-empty array or object, that value will be set on the handler's\n`options.params` argument.","type":"object","additionalProperties":false},"ManifestEntry":{"type":"object","properties":{"integrity":{"type":"string"},"revision":{"type":["null","string"]},"url":{"type":"string"}},"additionalProperties":false,"required":["revision","url"]}},"$schema":"http://json-schema.org/draft-07/schema#"} +{"additionalProperties":false,"type":"object","properties":{"chunks":{"type":"array","items":{"type":"string"}},"exclude":{"default":"[/\\.map$/, /^manifest.*\\.js$/,]","type":"array","items":{"anyOf":[{"$ref":"#/definitions/RegExp"},{"type":"object","additionalProperties":false},{"type":"string"}]}},"excludeChunks":{"type":"array","items":{"type":"string"}},"include":{"type":"array","items":{"anyOf":[{"$ref":"#/definitions/RegExp"},{"type":"object","additionalProperties":false},{"type":"string"}]}},"mode":{"type":["null","string"]},"injectionPoint":{"default":"self.__WB_MANIFEST","type":"string"},"swSrc":{"type":"string"},"additionalManifestEntries":{"type":"array","items":{"anyOf":[{"$ref":"#/definitions/ManifestEntry"},{"type":"string"}]}},"dontCacheBustURLsMatching":{"$ref":"#/definitions/RegExp"},"manifestTransforms":{"type":"array","items":{"type":"object","additionalProperties":false}},"maximumFileSizeToCacheInBytes":{"default":2097152,"type":"number"},"modifyURLPrefix":{"type":"object","additionalProperties":{"type":"string"}},"swDest":{"default":"service-worker.js","type":"string"},"compileSrc":{"default":true,"type":"boolean"},"webpackCompilationPlugins":{"type":"array","items":{}}},"required":["swSrc"],"definitions":{"RegExp":{"type":"object","properties":{"source":{"type":"string"},"global":{"type":"boolean"},"ignoreCase":{"type":"boolean"},"multiline":{"type":"boolean"},"lastIndex":{"type":"number"},"flags":{"type":"string"},"sticky":{"type":"boolean"},"unicode":{"type":"boolean"},"dotAll":{"type":"boolean"}},"additionalProperties":false,"required":["dotAll","flags","global","ignoreCase","lastIndex","multiline","source","sticky","unicode"]},"GoogleAnalyticsInitializeOptions":{"type":"object","properties":{"cacheName":{"type":"string"},"parameterOverrides":{"type":"object","additionalProperties":{"type":"string"}},"hitFilter":{"type":"object","additionalProperties":false}},"additionalProperties":false},"RuntimeCaching":{"type":"object","properties":{"handler":{"anyOf":[{"$ref":"#/definitions/RouteHandlerCallback"},{"$ref":"#/definitions/RouteHandlerObject"},{"enum":["CacheFirst","CacheOnly","NetworkFirst","NetworkOnly","StaleWhileRevalidate"],"type":"string"}]},"method":{"enum":["DELETE","GET","HEAD","PATCH","POST","PUT"],"type":"string"},"options":{"type":"object","properties":{"backgroundSync":{"type":"object","properties":{"name":{"type":"string"},"options":{"$ref":"#/definitions/QueueOptions"}},"additionalProperties":false,"required":["name"]},"broadcastUpdate":{"type":"object","properties":{"channelName":{"type":"string"},"options":{"$ref":"#/definitions/BroadcastCacheUpdateOptions"}},"additionalProperties":false,"required":["options"]},"cacheableResponse":{"$ref":"#/definitions/CacheableResponseOptions"},"cacheName":{"type":["null","string"]},"expiration":{"$ref":"#/definitions/ExpirationPluginOptions"},"networkTimeoutSeconds":{"type":"number"},"plugins":{"type":"array","items":{"$ref":"#/definitions/WorkboxPlugin"}},"precacheFallback":{"type":"object","properties":{"fallbackURL":{"type":"string"}},"additionalProperties":false,"required":["fallbackURL"]},"fetchOptions":{"$ref":"#/definitions/RequestInit"},"matchOptions":{"$ref":"#/definitions/CacheQueryOptions"}},"additionalProperties":false},"urlPattern":{"anyOf":[{"$ref":"#/definitions/RegExp"},{"$ref":"#/definitions/RouteMatchCallback"},{"type":"string"}]}},"additionalProperties":false,"required":["handler","urlPattern"]},"RouteHandlerCallback":{"description":"The \"handler\" callback is invoked whenever a `Router` matches a URL/Request\nto a `Route` via its `RouteMatchCallback`. This handler callback should\nreturn a `Promise` that resolves with a `Response`.\n\nIf a non-empty array or object is returned by the `RouteMatchCallback` it\nwill be passed in as this handler's `options.params` argument.","type":"object","additionalProperties":false},"RouteHandlerObject":{"description":"An object with a `handle` method of type `RouteHandlerCallback`.\n\nA `Route` object can be created with either an `RouteHandlerCallback`\nfunction or this `RouteHandler` object. The benefit of the `RouteHandler`\nis it can be extended (as is done by the `workbox-strategies` package).","type":"object","properties":{"handle":{"$ref":"#/definitions/RouteHandlerCallback"}},"additionalProperties":false,"required":["handle"]},"QueueOptions":{"type":"object","properties":{"onSync":{"$ref":"#/definitions/OnSyncCallback"},"maxRetentionTime":{"type":"number"}},"additionalProperties":false},"OnSyncCallback":{"type":"object","additionalProperties":false},"BroadcastCacheUpdateOptions":{"type":"object","properties":{"headersToCheck":{"type":"array","items":{"type":"string"}},"generatePayload":{"type":"object","additionalProperties":false}},"additionalProperties":false},"CacheableResponseOptions":{"type":"object","properties":{"statuses":{"type":"array","items":{"type":"number"}},"headers":{"type":"object","additionalProperties":{"type":"string"}}},"additionalProperties":false},"ExpirationPluginOptions":{"type":"object","properties":{"maxEntries":{"type":"number"},"maxAgeSeconds":{"type":"number"},"matchOptions":{"$ref":"#/definitions/CacheQueryOptions"},"purgeOnQuotaError":{"type":"boolean"}},"additionalProperties":false},"CacheQueryOptions":{"type":"object","properties":{"ignoreMethod":{"type":"boolean"},"ignoreSearch":{"type":"boolean"},"ignoreVary":{"type":"boolean"}},"additionalProperties":false},"WorkboxPlugin":{"description":"An object with optional lifecycle callback properties for the fetch and\ncache operations.","type":"object","properties":{"cacheDidUpdate":{"$ref":"#/definitions/CacheDidUpdateCallback"},"cachedResponseWillBeUsed":{"$ref":"#/definitions/CachedResponseWillBeUsedCallback"},"cacheKeyWillBeUsed":{"$ref":"#/definitions/CacheKeyWillBeUsedCallback"},"cacheWillUpdate":{"$ref":"#/definitions/CacheWillUpdateCallback"},"fetchDidFail":{"$ref":"#/definitions/FetchDidFailCallback"},"fetchDidSucceed":{"$ref":"#/definitions/FetchDidSucceedCallback"},"handlerDidComplete":{"$ref":"#/definitions/HandlerDidCompleteCallback"},"handlerDidError":{"$ref":"#/definitions/HandlerDidErrorCallback"},"handlerDidRespond":{"$ref":"#/definitions/HandlerDidRespondCallback"},"handlerWillRespond":{"$ref":"#/definitions/HandlerWillRespondCallback"},"handlerWillStart":{"$ref":"#/definitions/HandlerWillStartCallback"},"requestWillFetch":{"$ref":"#/definitions/RequestWillFetchCallback"}},"additionalProperties":false},"CacheDidUpdateCallback":{"type":"object","additionalProperties":false},"CachedResponseWillBeUsedCallback":{"type":"object","additionalProperties":false},"CacheKeyWillBeUsedCallback":{"type":"object","additionalProperties":false},"CacheWillUpdateCallback":{"type":"object","additionalProperties":false},"FetchDidFailCallback":{"type":"object","additionalProperties":false},"FetchDidSucceedCallback":{"type":"object","additionalProperties":false},"HandlerDidCompleteCallback":{"type":"object","additionalProperties":false},"HandlerDidErrorCallback":{"type":"object","additionalProperties":false},"HandlerDidRespondCallback":{"type":"object","additionalProperties":false},"HandlerWillRespondCallback":{"type":"object","additionalProperties":false},"HandlerWillStartCallback":{"type":"object","additionalProperties":false},"RequestWillFetchCallback":{"type":"object","additionalProperties":false},"RequestInit":{"type":"object","properties":{"body":{"anyOf":[{"$ref":"#/definitions/ArrayBuffer"},{"$ref":"#/definitions/ArrayBufferView"},{"$ref":"#/definitions/Blob"},{"$ref":"#/definitions/FormData"},{"$ref":"#/definitions/URLSearchParams"},{"$ref":"#/definitions/ReadableStream"},{"type":["null","string"]}]},"cache":{"enum":["default","force-cache","no-cache","no-store","only-if-cached","reload"],"type":"string"},"credentials":{"enum":["include","omit","same-origin"],"type":"string"},"headers":{"anyOf":[{"$ref":"#/definitions/Headers"},{"type":"array","items":{"type":"array","items":{"type":"string"}}},{"$ref":"#/definitions/Record"}]},"integrity":{"type":"string"},"keepalive":{"type":"boolean"},"method":{"type":"string"},"mode":{"enum":["cors","navigate","no-cors","same-origin"],"type":"string"},"redirect":{"enum":["error","follow","manual"],"type":"string"},"referrer":{"type":"string"},"referrerPolicy":{"enum":["","no-referrer","no-referrer-when-downgrade","origin","origin-when-cross-origin","same-origin","strict-origin","strict-origin-when-cross-origin","unsafe-url"],"type":"string"},"signal":{"anyOf":[{"$ref":"#/definitions/AbortSignal"},{"type":"null"}]},"window":{}},"additionalProperties":false},"ArrayBuffer":{"type":"object","properties":{"byteLength":{"type":"number"},"__@toStringTag":{"type":"string"}},"additionalProperties":false,"required":["__@toStringTag","byteLength"]},"ArrayBufferView":{"type":"object","properties":{"buffer":{"anyOf":[{"$ref":"#/definitions/ArrayBuffer"},{"$ref":"#/definitions/SharedArrayBuffer"}]},"byteLength":{"type":"number"},"byteOffset":{"type":"number"}},"additionalProperties":false,"required":["buffer","byteLength","byteOffset"]},"SharedArrayBuffer":{"type":"object","properties":{"byteLength":{"type":"number"},"__@species":{"$ref":"#/definitions/SharedArrayBuffer"},"__@toStringTag":{"type":"string","enum":["SharedArrayBuffer"]}},"additionalProperties":false,"required":["__@species","__@toStringTag","byteLength"]},"Blob":{"type":"object","properties":{"size":{"type":"number"},"type":{"type":"string"}},"additionalProperties":false,"required":["size","type"]},"FormData":{"type":"object","additionalProperties":false},"URLSearchParams":{"type":"object","additionalProperties":false},"ReadableStream":{"type":"object","properties":{"locked":{"type":"boolean"}},"additionalProperties":false,"required":["locked"]},"Headers":{"type":"object","additionalProperties":false},"Record":{"type":"object","additionalProperties":false},"AbortSignal":{"type":"object","properties":{"aborted":{"type":"boolean"},"onabort":{"anyOf":[{"type":"object","additionalProperties":false},{"type":"null"}]}},"additionalProperties":false,"required":["aborted","onabort"]},"RouteMatchCallback":{"description":"The \"match\" callback is used to determine if a `Route` should apply for a\nparticular URL and request. When matching occurs in response to a fetch\nevent from the client, the `event` object is also supplied. However, since\nthe match callback can be invoked outside of a fetch event, matching logic\nshould not assume the `event` object will always be available.\nIf the match callback returns a truthy value, the matching route's\n`RouteHandlerCallback` will be invoked immediately. If the value returned\nis a non-empty array or object, that value will be set on the handler's\n`options.params` argument.","type":"object","additionalProperties":false},"ManifestEntry":{"type":"object","properties":{"integrity":{"type":"string"},"revision":{"type":["null","string"]},"url":{"type":"string"}},"additionalProperties":false,"required":["revision","url"]}},"$schema":"http://json-schema.org/draft-07/schema#"} diff --git a/packages/workbox-build/src/types.ts b/packages/workbox-build/src/types.ts index ade69ff1e..f46094a31 100644 --- a/packages/workbox-build/src/types.ts +++ b/packages/workbox-build/src/types.ts @@ -164,26 +164,30 @@ interface WebpackPartial { mode?: string | null; } -export interface SWDestPartial { +export interface RequiredSWDestPartial { + swDest: string; +} + +export interface OptionalSWDestPartial { /** * @default "service-worker.js" */ - swDest: string; + swDest?: string; } -export type GenerateSWOptions = GlobPartial & GeneratePartial & BasePartial & SWDestPartial; +export type GenerateSWOptions = GlobPartial & GeneratePartial & BasePartial & RequiredSWDestPartial; export type GetManifestOptions = GlobPartial & BasePartial; -export type InjectManifestOptions = InjectPartial & Omit & BasePartial & SWDestPartial & { +export type InjectManifestOptions = InjectPartial & Omit & BasePartial & RequiredSWDestPartial & { globDirectory: string; }; -export type WebpackGenerateSWOptions = WebpackPartial & GeneratePartial & BasePartial & SWDestPartial & { +export type WebpackGenerateSWOptions = WebpackPartial & GeneratePartial & BasePartial & OptionalSWDestPartial & { importScriptsViaChunks: Array; }; -export type WebpackInjectManifestOptions = WebpackPartial & InjectPartial & BasePartial & SWDestPartial & { +export type WebpackInjectManifestOptions = WebpackPartial & InjectPartial & BasePartial & OptionalSWDestPartial & { /** * @default true */ From fae8a0e15099ef210a00a0248dcad05ae06c70b3 Mon Sep 17 00:00:00 2001 From: Jeff Posnick Date: Wed, 9 Jun 2021 17:51:42 -0400 Subject: [PATCH 42/80] Closer to webpack tests working --- infra/testing/webpack-build-check.js | 2 +- .../workbox-build/src/lib/validate-options.ts | 38 ++++++++++++++++--- .../src/schema/WebpackGenerateSWOptions.json | 2 +- .../schema/WebpackInjectManifestOptions.json | 2 +- packages/workbox-build/src/types.ts | 9 +++-- .../workbox-webpack-plugin/src/generate-sw.js | 7 ++-- .../src/inject-manifest.js | 15 ++++---- 7 files changed, 50 insertions(+), 25 deletions(-) diff --git a/infra/testing/webpack-build-check.js b/infra/testing/webpack-build-check.js index 382d71312..e039407f2 100644 --- a/infra/testing/webpack-build-check.js +++ b/infra/testing/webpack-build-check.js @@ -7,7 +7,7 @@ */ function joinMessages(errorsOrWarnings) { - if ('message' in errorsOrWarnings[0]) { + if (errorsOrWarnings[0].message) { return errorsOrWarnings.map((item) => item.message).join('\n'); } else { return errorsOrWarnings.join('\n'); diff --git a/packages/workbox-build/src/lib/validate-options.ts b/packages/workbox-build/src/lib/validate-options.ts index 1827f8b12..41b5dd7df 100644 --- a/packages/workbox-build/src/lib/validate-options.ts +++ b/packages/workbox-build/src/lib/validate-options.ts @@ -8,17 +8,27 @@ import Ajv, {JSONSchemaType} from 'ajv'; -import {GenerateSWOptions, GetManifestOptions, InjectManifestOptions} from '../types'; +import { + GenerateSWOptions, + GetManifestOptions, + InjectManifestOptions, + WebpackGenerateSWOptions, + WebpackInjectManifestOptions, +} from '../types'; const ajv = new Ajv({ useDefaults: true, }); +const DEFAULT_EXCLUDE_VALUE= [/\.map$/, /^manifest.*\.js$/]; + function validate(input: unknown, schemaFile: string): T { + // Don't mutate input: https://github.com/GoogleChrome/workbox/issues/2158 + const inputCopy = Object.assign({}, input); const jsonSchema: JSONSchemaType = require(schemaFile); const validate = ajv.compile(jsonSchema); - if (validate(input)) { - return input; + if (validate(inputCopy)) { + return inputCopy; } // TODO: Update this code to use better-ajv-errors once @@ -29,13 +39,29 @@ function validate(input: unknown, schemaFile: string): T { } export function validateGenerateSWOptions(input: unknown): GenerateSWOptions { - return validate(input, `../schema/GenerateSWOptions.json`); + return validate(input, '../schema/GenerateSWOptions.json'); } export function validateGetManifestOptions(input: unknown): GetManifestOptions { - return validate(input, `../schema/GetManifestOptions.json`); + return validate(input, '../schema/GetManifestOptions.json'); } export function validateInjectManifestOptions(input: unknown): InjectManifestOptions { - return validate(input, `../schema/InjectManifestOptions.json`); + return validate(input, '../schema/InjectManifestOptions.json'); +} + +// The default exclude: [/\.map$/, /^manifest.*\.js$/] value can't be +// represented in the JSON schema, so manually set it for the webpack options. +export function validateWebpackGenerateSWOptions(input: unknown): WebpackGenerateSWOptions { + const inputWithExcludeDefault = Object.assign({ + exclude: DEFAULT_EXCLUDE_VALUE, + }, input); + return validate(inputWithExcludeDefault, '../schema/WebpackGenerateSWOptions.json'); +} + +export function validateWebpackInjectManifestOptions(input: unknown): WebpackInjectManifestOptions { + const inputWithExcludeDefault = Object.assign({ + exclude: DEFAULT_EXCLUDE_VALUE, + }, input); + return validate(inputWithExcludeDefault, '../schema/WebpackInjectManifestOptions.json'); } diff --git a/packages/workbox-build/src/schema/WebpackGenerateSWOptions.json b/packages/workbox-build/src/schema/WebpackGenerateSWOptions.json index d0617d7b0..d9fe73d09 100644 --- a/packages/workbox-build/src/schema/WebpackGenerateSWOptions.json +++ b/packages/workbox-build/src/schema/WebpackGenerateSWOptions.json @@ -1 +1 @@ -{"additionalProperties":false,"type":"object","properties":{"chunks":{"type":"array","items":{"type":"string"}},"exclude":{"default":"[/\\.map$/, /^manifest.*\\.js$/,]","type":"array","items":{"anyOf":[{"$ref":"#/definitions/RegExp"},{"type":"object","additionalProperties":false},{"type":"string"}]}},"excludeChunks":{"type":"array","items":{"type":"string"}},"include":{"type":"array","items":{"anyOf":[{"$ref":"#/definitions/RegExp"},{"type":"object","additionalProperties":false},{"type":"string"}]}},"mode":{"default":"production","type":["null","string"]},"babelPresetEnvTargets":{"default":["chrome >= 56"],"type":"array","items":{"type":"string"}},"cacheId":{"type":["null","string"]},"cleanupOutdatedCaches":{"default":false,"type":"boolean"},"clientsClaim":{"default":false,"type":"boolean"},"directoryIndex":{"type":["null","string"]},"disableDevLogs":{"default":false,"type":"boolean"},"ignoreURLParametersMatching":{"type":"array","items":{"$ref":"#/definitions/RegExp"}},"importScripts":{"type":"array","items":{"type":"string"}},"inlineWorkboxRuntime":{"default":false,"type":"boolean"},"navigateFallback":{"default":null,"type":["null","string"]},"navigateFallbackAllowlist":{"type":"array","items":{"$ref":"#/definitions/RegExp"}},"navigateFallbackDenylist":{"type":"array","items":{"$ref":"#/definitions/RegExp"}},"navigationPreload":{"default":false,"type":"boolean"},"offlineGoogleAnalytics":{"default":false,"anyOf":[{"$ref":"#/definitions/GoogleAnalyticsInitializeOptions"},{"type":"boolean"}]},"runtimeCaching":{"type":"array","items":{"$ref":"#/definitions/RuntimeCaching"}},"skipWaiting":{"default":false,"type":"boolean"},"sourcemap":{"default":true,"type":"boolean"},"additionalManifestEntries":{"type":"array","items":{"anyOf":[{"$ref":"#/definitions/ManifestEntry"},{"type":"string"}]}},"dontCacheBustURLsMatching":{"$ref":"#/definitions/RegExp"},"manifestTransforms":{"type":"array","items":{"type":"object","additionalProperties":false}},"maximumFileSizeToCacheInBytes":{"default":2097152,"type":"number"},"modifyURLPrefix":{"type":"object","additionalProperties":{"type":"string"}},"swDest":{"default":"service-worker.js","type":"string"},"importScriptsViaChunks":{"type":"array","items":{"type":"string"}}},"required":["importScriptsViaChunks"],"definitions":{"RegExp":{"type":"object","properties":{"source":{"type":"string"},"global":{"type":"boolean"},"ignoreCase":{"type":"boolean"},"multiline":{"type":"boolean"},"lastIndex":{"type":"number"},"flags":{"type":"string"},"sticky":{"type":"boolean"},"unicode":{"type":"boolean"},"dotAll":{"type":"boolean"}},"additionalProperties":false,"required":["dotAll","flags","global","ignoreCase","lastIndex","multiline","source","sticky","unicode"]},"GoogleAnalyticsInitializeOptions":{"type":"object","properties":{"cacheName":{"type":"string"},"parameterOverrides":{"type":"object","additionalProperties":{"type":"string"}},"hitFilter":{"type":"object","additionalProperties":false}},"additionalProperties":false},"RuntimeCaching":{"type":"object","properties":{"handler":{"anyOf":[{"$ref":"#/definitions/RouteHandlerCallback"},{"$ref":"#/definitions/RouteHandlerObject"},{"enum":["CacheFirst","CacheOnly","NetworkFirst","NetworkOnly","StaleWhileRevalidate"],"type":"string"}]},"method":{"enum":["DELETE","GET","HEAD","PATCH","POST","PUT"],"type":"string"},"options":{"type":"object","properties":{"backgroundSync":{"type":"object","properties":{"name":{"type":"string"},"options":{"$ref":"#/definitions/QueueOptions"}},"additionalProperties":false,"required":["name"]},"broadcastUpdate":{"type":"object","properties":{"channelName":{"type":"string"},"options":{"$ref":"#/definitions/BroadcastCacheUpdateOptions"}},"additionalProperties":false,"required":["options"]},"cacheableResponse":{"$ref":"#/definitions/CacheableResponseOptions"},"cacheName":{"type":["null","string"]},"expiration":{"$ref":"#/definitions/ExpirationPluginOptions"},"networkTimeoutSeconds":{"type":"number"},"plugins":{"type":"array","items":{"$ref":"#/definitions/WorkboxPlugin"}},"precacheFallback":{"type":"object","properties":{"fallbackURL":{"type":"string"}},"additionalProperties":false,"required":["fallbackURL"]},"fetchOptions":{"$ref":"#/definitions/RequestInit"},"matchOptions":{"$ref":"#/definitions/CacheQueryOptions"}},"additionalProperties":false},"urlPattern":{"anyOf":[{"$ref":"#/definitions/RegExp"},{"$ref":"#/definitions/RouteMatchCallback"},{"type":"string"}]}},"additionalProperties":false,"required":["handler","urlPattern"]},"RouteHandlerCallback":{"description":"The \"handler\" callback is invoked whenever a `Router` matches a URL/Request\nto a `Route` via its `RouteMatchCallback`. This handler callback should\nreturn a `Promise` that resolves with a `Response`.\n\nIf a non-empty array or object is returned by the `RouteMatchCallback` it\nwill be passed in as this handler's `options.params` argument.","type":"object","additionalProperties":false},"RouteHandlerObject":{"description":"An object with a `handle` method of type `RouteHandlerCallback`.\n\nA `Route` object can be created with either an `RouteHandlerCallback`\nfunction or this `RouteHandler` object. The benefit of the `RouteHandler`\nis it can be extended (as is done by the `workbox-strategies` package).","type":"object","properties":{"handle":{"$ref":"#/definitions/RouteHandlerCallback"}},"additionalProperties":false,"required":["handle"]},"QueueOptions":{"type":"object","properties":{"onSync":{"$ref":"#/definitions/OnSyncCallback"},"maxRetentionTime":{"type":"number"}},"additionalProperties":false},"OnSyncCallback":{"type":"object","additionalProperties":false},"BroadcastCacheUpdateOptions":{"type":"object","properties":{"headersToCheck":{"type":"array","items":{"type":"string"}},"generatePayload":{"type":"object","additionalProperties":false}},"additionalProperties":false},"CacheableResponseOptions":{"type":"object","properties":{"statuses":{"type":"array","items":{"type":"number"}},"headers":{"type":"object","additionalProperties":{"type":"string"}}},"additionalProperties":false},"ExpirationPluginOptions":{"type":"object","properties":{"maxEntries":{"type":"number"},"maxAgeSeconds":{"type":"number"},"matchOptions":{"$ref":"#/definitions/CacheQueryOptions"},"purgeOnQuotaError":{"type":"boolean"}},"additionalProperties":false},"CacheQueryOptions":{"type":"object","properties":{"ignoreMethod":{"type":"boolean"},"ignoreSearch":{"type":"boolean"},"ignoreVary":{"type":"boolean"}},"additionalProperties":false},"WorkboxPlugin":{"description":"An object with optional lifecycle callback properties for the fetch and\ncache operations.","type":"object","properties":{"cacheDidUpdate":{"$ref":"#/definitions/CacheDidUpdateCallback"},"cachedResponseWillBeUsed":{"$ref":"#/definitions/CachedResponseWillBeUsedCallback"},"cacheKeyWillBeUsed":{"$ref":"#/definitions/CacheKeyWillBeUsedCallback"},"cacheWillUpdate":{"$ref":"#/definitions/CacheWillUpdateCallback"},"fetchDidFail":{"$ref":"#/definitions/FetchDidFailCallback"},"fetchDidSucceed":{"$ref":"#/definitions/FetchDidSucceedCallback"},"handlerDidComplete":{"$ref":"#/definitions/HandlerDidCompleteCallback"},"handlerDidError":{"$ref":"#/definitions/HandlerDidErrorCallback"},"handlerDidRespond":{"$ref":"#/definitions/HandlerDidRespondCallback"},"handlerWillRespond":{"$ref":"#/definitions/HandlerWillRespondCallback"},"handlerWillStart":{"$ref":"#/definitions/HandlerWillStartCallback"},"requestWillFetch":{"$ref":"#/definitions/RequestWillFetchCallback"}},"additionalProperties":false},"CacheDidUpdateCallback":{"type":"object","additionalProperties":false},"CachedResponseWillBeUsedCallback":{"type":"object","additionalProperties":false},"CacheKeyWillBeUsedCallback":{"type":"object","additionalProperties":false},"CacheWillUpdateCallback":{"type":"object","additionalProperties":false},"FetchDidFailCallback":{"type":"object","additionalProperties":false},"FetchDidSucceedCallback":{"type":"object","additionalProperties":false},"HandlerDidCompleteCallback":{"type":"object","additionalProperties":false},"HandlerDidErrorCallback":{"type":"object","additionalProperties":false},"HandlerDidRespondCallback":{"type":"object","additionalProperties":false},"HandlerWillRespondCallback":{"type":"object","additionalProperties":false},"HandlerWillStartCallback":{"type":"object","additionalProperties":false},"RequestWillFetchCallback":{"type":"object","additionalProperties":false},"RequestInit":{"type":"object","properties":{"body":{"anyOf":[{"$ref":"#/definitions/ArrayBuffer"},{"$ref":"#/definitions/ArrayBufferView"},{"$ref":"#/definitions/Blob"},{"$ref":"#/definitions/FormData"},{"$ref":"#/definitions/URLSearchParams"},{"$ref":"#/definitions/ReadableStream"},{"type":["null","string"]}]},"cache":{"enum":["default","force-cache","no-cache","no-store","only-if-cached","reload"],"type":"string"},"credentials":{"enum":["include","omit","same-origin"],"type":"string"},"headers":{"anyOf":[{"$ref":"#/definitions/Headers"},{"type":"array","items":{"type":"array","items":{"type":"string"}}},{"$ref":"#/definitions/Record"}]},"integrity":{"type":"string"},"keepalive":{"type":"boolean"},"method":{"type":"string"},"mode":{"enum":["cors","navigate","no-cors","same-origin"],"type":"string"},"redirect":{"enum":["error","follow","manual"],"type":"string"},"referrer":{"type":"string"},"referrerPolicy":{"enum":["","no-referrer","no-referrer-when-downgrade","origin","origin-when-cross-origin","same-origin","strict-origin","strict-origin-when-cross-origin","unsafe-url"],"type":"string"},"signal":{"anyOf":[{"$ref":"#/definitions/AbortSignal"},{"type":"null"}]},"window":{}},"additionalProperties":false},"ArrayBuffer":{"type":"object","properties":{"byteLength":{"type":"number"},"__@toStringTag":{"type":"string"}},"additionalProperties":false,"required":["__@toStringTag","byteLength"]},"ArrayBufferView":{"type":"object","properties":{"buffer":{"anyOf":[{"$ref":"#/definitions/ArrayBuffer"},{"$ref":"#/definitions/SharedArrayBuffer"}]},"byteLength":{"type":"number"},"byteOffset":{"type":"number"}},"additionalProperties":false,"required":["buffer","byteLength","byteOffset"]},"SharedArrayBuffer":{"type":"object","properties":{"byteLength":{"type":"number"},"__@species":{"$ref":"#/definitions/SharedArrayBuffer"},"__@toStringTag":{"type":"string","enum":["SharedArrayBuffer"]}},"additionalProperties":false,"required":["__@species","__@toStringTag","byteLength"]},"Blob":{"type":"object","properties":{"size":{"type":"number"},"type":{"type":"string"}},"additionalProperties":false,"required":["size","type"]},"FormData":{"type":"object","additionalProperties":false},"URLSearchParams":{"type":"object","additionalProperties":false},"ReadableStream":{"type":"object","properties":{"locked":{"type":"boolean"}},"additionalProperties":false,"required":["locked"]},"Headers":{"type":"object","additionalProperties":false},"Record":{"type":"object","additionalProperties":false},"AbortSignal":{"type":"object","properties":{"aborted":{"type":"boolean"},"onabort":{"anyOf":[{"type":"object","additionalProperties":false},{"type":"null"}]}},"additionalProperties":false,"required":["aborted","onabort"]},"RouteMatchCallback":{"description":"The \"match\" callback is used to determine if a `Route` should apply for a\nparticular URL and request. When matching occurs in response to a fetch\nevent from the client, the `event` object is also supplied. However, since\nthe match callback can be invoked outside of a fetch event, matching logic\nshould not assume the `event` object will always be available.\nIf the match callback returns a truthy value, the matching route's\n`RouteHandlerCallback` will be invoked immediately. If the value returned\nis a non-empty array or object, that value will be set on the handler's\n`options.params` argument.","type":"object","additionalProperties":false},"ManifestEntry":{"type":"object","properties":{"integrity":{"type":"string"},"revision":{"type":["null","string"]},"url":{"type":"string"}},"additionalProperties":false,"required":["revision","url"]}},"$schema":"http://json-schema.org/draft-07/schema#"} +{"additionalProperties":false,"type":"object","properties":{"chunks":{"type":"array","items":{"type":"string"}},"exclude":{"type":"array","items":{"anyOf":[{"$ref":"#/definitions/RegExp"},{"type":"object","additionalProperties":false},{"type":"string"}]}},"excludeChunks":{"type":"array","items":{"type":"string"}},"include":{"type":"array","items":{"anyOf":[{"$ref":"#/definitions/RegExp"},{"type":"object","additionalProperties":false},{"type":"string"}]}},"mode":{"default":"production","type":["null","string"]},"babelPresetEnvTargets":{"default":["chrome >= 56"],"type":"array","items":{"type":"string"}},"cacheId":{"type":["null","string"]},"cleanupOutdatedCaches":{"default":false,"type":"boolean"},"clientsClaim":{"default":false,"type":"boolean"},"directoryIndex":{"type":["null","string"]},"disableDevLogs":{"default":false,"type":"boolean"},"ignoreURLParametersMatching":{"type":"array","items":{"$ref":"#/definitions/RegExp"}},"importScripts":{"type":"array","items":{"type":"string"}},"inlineWorkboxRuntime":{"default":false,"type":"boolean"},"navigateFallback":{"default":null,"type":["null","string"]},"navigateFallbackAllowlist":{"type":"array","items":{"$ref":"#/definitions/RegExp"}},"navigateFallbackDenylist":{"type":"array","items":{"$ref":"#/definitions/RegExp"}},"navigationPreload":{"default":false,"type":"boolean"},"offlineGoogleAnalytics":{"default":false,"anyOf":[{"$ref":"#/definitions/GoogleAnalyticsInitializeOptions"},{"type":"boolean"}]},"runtimeCaching":{"type":"array","items":{"$ref":"#/definitions/RuntimeCaching"}},"skipWaiting":{"default":false,"type":"boolean"},"sourcemap":{"default":true,"type":"boolean"},"additionalManifestEntries":{"type":"array","items":{"anyOf":[{"$ref":"#/definitions/ManifestEntry"},{"type":"string"}]}},"dontCacheBustURLsMatching":{"$ref":"#/definitions/RegExp"},"manifestTransforms":{"type":"array","items":{"type":"object","additionalProperties":false}},"maximumFileSizeToCacheInBytes":{"default":2097152,"type":"number"},"modifyURLPrefix":{"type":"object","additionalProperties":{"type":"string"}},"swDest":{"default":"service-worker.js","type":"string"},"importScriptsViaChunks":{"type":"array","items":{"type":"string"}}},"definitions":{"RegExp":{"type":"object","properties":{"source":{"type":"string"},"global":{"type":"boolean"},"ignoreCase":{"type":"boolean"},"multiline":{"type":"boolean"},"lastIndex":{"type":"number"},"flags":{"type":"string"},"sticky":{"type":"boolean"},"unicode":{"type":"boolean"},"dotAll":{"type":"boolean"}},"additionalProperties":false,"required":["dotAll","flags","global","ignoreCase","lastIndex","multiline","source","sticky","unicode"]},"GoogleAnalyticsInitializeOptions":{"type":"object","properties":{"cacheName":{"type":"string"},"parameterOverrides":{"type":"object","additionalProperties":{"type":"string"}},"hitFilter":{"type":"object","additionalProperties":false}},"additionalProperties":false},"RuntimeCaching":{"type":"object","properties":{"handler":{"anyOf":[{"$ref":"#/definitions/RouteHandlerCallback"},{"$ref":"#/definitions/RouteHandlerObject"},{"enum":["CacheFirst","CacheOnly","NetworkFirst","NetworkOnly","StaleWhileRevalidate"],"type":"string"}]},"method":{"enum":["DELETE","GET","HEAD","PATCH","POST","PUT"],"type":"string"},"options":{"type":"object","properties":{"backgroundSync":{"type":"object","properties":{"name":{"type":"string"},"options":{"$ref":"#/definitions/QueueOptions"}},"additionalProperties":false,"required":["name"]},"broadcastUpdate":{"type":"object","properties":{"channelName":{"type":"string"},"options":{"$ref":"#/definitions/BroadcastCacheUpdateOptions"}},"additionalProperties":false,"required":["options"]},"cacheableResponse":{"$ref":"#/definitions/CacheableResponseOptions"},"cacheName":{"type":["null","string"]},"expiration":{"$ref":"#/definitions/ExpirationPluginOptions"},"networkTimeoutSeconds":{"type":"number"},"plugins":{"type":"array","items":{"$ref":"#/definitions/WorkboxPlugin"}},"precacheFallback":{"type":"object","properties":{"fallbackURL":{"type":"string"}},"additionalProperties":false,"required":["fallbackURL"]},"fetchOptions":{"$ref":"#/definitions/RequestInit"},"matchOptions":{"$ref":"#/definitions/CacheQueryOptions"}},"additionalProperties":false},"urlPattern":{"anyOf":[{"$ref":"#/definitions/RegExp"},{"$ref":"#/definitions/RouteMatchCallback"},{"type":"string"}]}},"additionalProperties":false,"required":["handler","urlPattern"]},"RouteHandlerCallback":{"description":"The \"handler\" callback is invoked whenever a `Router` matches a URL/Request\nto a `Route` via its `RouteMatchCallback`. This handler callback should\nreturn a `Promise` that resolves with a `Response`.\n\nIf a non-empty array or object is returned by the `RouteMatchCallback` it\nwill be passed in as this handler's `options.params` argument.","type":"object","additionalProperties":false},"RouteHandlerObject":{"description":"An object with a `handle` method of type `RouteHandlerCallback`.\n\nA `Route` object can be created with either an `RouteHandlerCallback`\nfunction or this `RouteHandler` object. The benefit of the `RouteHandler`\nis it can be extended (as is done by the `workbox-strategies` package).","type":"object","properties":{"handle":{"$ref":"#/definitions/RouteHandlerCallback"}},"additionalProperties":false,"required":["handle"]},"QueueOptions":{"type":"object","properties":{"onSync":{"$ref":"#/definitions/OnSyncCallback"},"maxRetentionTime":{"type":"number"}},"additionalProperties":false},"OnSyncCallback":{"type":"object","additionalProperties":false},"BroadcastCacheUpdateOptions":{"type":"object","properties":{"headersToCheck":{"type":"array","items":{"type":"string"}},"generatePayload":{"type":"object","additionalProperties":false}},"additionalProperties":false},"CacheableResponseOptions":{"type":"object","properties":{"statuses":{"type":"array","items":{"type":"number"}},"headers":{"type":"object","additionalProperties":{"type":"string"}}},"additionalProperties":false},"ExpirationPluginOptions":{"type":"object","properties":{"maxEntries":{"type":"number"},"maxAgeSeconds":{"type":"number"},"matchOptions":{"$ref":"#/definitions/CacheQueryOptions"},"purgeOnQuotaError":{"type":"boolean"}},"additionalProperties":false},"CacheQueryOptions":{"type":"object","properties":{"ignoreMethod":{"type":"boolean"},"ignoreSearch":{"type":"boolean"},"ignoreVary":{"type":"boolean"}},"additionalProperties":false},"WorkboxPlugin":{"description":"An object with optional lifecycle callback properties for the fetch and\ncache operations.","type":"object","properties":{"cacheDidUpdate":{"$ref":"#/definitions/CacheDidUpdateCallback"},"cachedResponseWillBeUsed":{"$ref":"#/definitions/CachedResponseWillBeUsedCallback"},"cacheKeyWillBeUsed":{"$ref":"#/definitions/CacheKeyWillBeUsedCallback"},"cacheWillUpdate":{"$ref":"#/definitions/CacheWillUpdateCallback"},"fetchDidFail":{"$ref":"#/definitions/FetchDidFailCallback"},"fetchDidSucceed":{"$ref":"#/definitions/FetchDidSucceedCallback"},"handlerDidComplete":{"$ref":"#/definitions/HandlerDidCompleteCallback"},"handlerDidError":{"$ref":"#/definitions/HandlerDidErrorCallback"},"handlerDidRespond":{"$ref":"#/definitions/HandlerDidRespondCallback"},"handlerWillRespond":{"$ref":"#/definitions/HandlerWillRespondCallback"},"handlerWillStart":{"$ref":"#/definitions/HandlerWillStartCallback"},"requestWillFetch":{"$ref":"#/definitions/RequestWillFetchCallback"}},"additionalProperties":false},"CacheDidUpdateCallback":{"type":"object","additionalProperties":false},"CachedResponseWillBeUsedCallback":{"type":"object","additionalProperties":false},"CacheKeyWillBeUsedCallback":{"type":"object","additionalProperties":false},"CacheWillUpdateCallback":{"type":"object","additionalProperties":false},"FetchDidFailCallback":{"type":"object","additionalProperties":false},"FetchDidSucceedCallback":{"type":"object","additionalProperties":false},"HandlerDidCompleteCallback":{"type":"object","additionalProperties":false},"HandlerDidErrorCallback":{"type":"object","additionalProperties":false},"HandlerDidRespondCallback":{"type":"object","additionalProperties":false},"HandlerWillRespondCallback":{"type":"object","additionalProperties":false},"HandlerWillStartCallback":{"type":"object","additionalProperties":false},"RequestWillFetchCallback":{"type":"object","additionalProperties":false},"RequestInit":{"type":"object","properties":{"body":{"anyOf":[{"$ref":"#/definitions/ArrayBuffer"},{"$ref":"#/definitions/ArrayBufferView"},{"$ref":"#/definitions/Blob"},{"$ref":"#/definitions/FormData"},{"$ref":"#/definitions/URLSearchParams"},{"$ref":"#/definitions/ReadableStream"},{"type":["null","string"]}]},"cache":{"enum":["default","force-cache","no-cache","no-store","only-if-cached","reload"],"type":"string"},"credentials":{"enum":["include","omit","same-origin"],"type":"string"},"headers":{"anyOf":[{"$ref":"#/definitions/Headers"},{"type":"array","items":{"type":"array","items":{"type":"string"}}},{"$ref":"#/definitions/Record"}]},"integrity":{"type":"string"},"keepalive":{"type":"boolean"},"method":{"type":"string"},"mode":{"enum":["cors","navigate","no-cors","same-origin"],"type":"string"},"redirect":{"enum":["error","follow","manual"],"type":"string"},"referrer":{"type":"string"},"referrerPolicy":{"enum":["","no-referrer","no-referrer-when-downgrade","origin","origin-when-cross-origin","same-origin","strict-origin","strict-origin-when-cross-origin","unsafe-url"],"type":"string"},"signal":{"anyOf":[{"$ref":"#/definitions/AbortSignal"},{"type":"null"}]},"window":{}},"additionalProperties":false},"ArrayBuffer":{"type":"object","properties":{"byteLength":{"type":"number"},"__@toStringTag":{"type":"string"}},"additionalProperties":false,"required":["__@toStringTag","byteLength"]},"ArrayBufferView":{"type":"object","properties":{"buffer":{"anyOf":[{"$ref":"#/definitions/ArrayBuffer"},{"$ref":"#/definitions/SharedArrayBuffer"}]},"byteLength":{"type":"number"},"byteOffset":{"type":"number"}},"additionalProperties":false,"required":["buffer","byteLength","byteOffset"]},"SharedArrayBuffer":{"type":"object","properties":{"byteLength":{"type":"number"},"__@species":{"$ref":"#/definitions/SharedArrayBuffer"},"__@toStringTag":{"type":"string","enum":["SharedArrayBuffer"]}},"additionalProperties":false,"required":["__@species","__@toStringTag","byteLength"]},"Blob":{"type":"object","properties":{"size":{"type":"number"},"type":{"type":"string"}},"additionalProperties":false,"required":["size","type"]},"FormData":{"type":"object","additionalProperties":false},"URLSearchParams":{"type":"object","additionalProperties":false},"ReadableStream":{"type":"object","properties":{"locked":{"type":"boolean"}},"additionalProperties":false,"required":["locked"]},"Headers":{"type":"object","additionalProperties":false},"Record":{"type":"object","additionalProperties":false},"AbortSignal":{"type":"object","properties":{"aborted":{"type":"boolean"},"onabort":{"anyOf":[{"type":"object","additionalProperties":false},{"type":"null"}]}},"additionalProperties":false,"required":["aborted","onabort"]},"RouteMatchCallback":{"description":"The \"match\" callback is used to determine if a `Route` should apply for a\nparticular URL and request. When matching occurs in response to a fetch\nevent from the client, the `event` object is also supplied. However, since\nthe match callback can be invoked outside of a fetch event, matching logic\nshould not assume the `event` object will always be available.\nIf the match callback returns a truthy value, the matching route's\n`RouteHandlerCallback` will be invoked immediately. If the value returned\nis a non-empty array or object, that value will be set on the handler's\n`options.params` argument.","type":"object","additionalProperties":false},"ManifestEntry":{"type":"object","properties":{"integrity":{"type":"string"},"revision":{"type":["null","string"]},"url":{"type":"string"}},"additionalProperties":false,"required":["revision","url"]}},"$schema":"http://json-schema.org/draft-07/schema#"} diff --git a/packages/workbox-build/src/schema/WebpackInjectManifestOptions.json b/packages/workbox-build/src/schema/WebpackInjectManifestOptions.json index 6203cfb3d..086807c13 100644 --- a/packages/workbox-build/src/schema/WebpackInjectManifestOptions.json +++ b/packages/workbox-build/src/schema/WebpackInjectManifestOptions.json @@ -1 +1 @@ -{"additionalProperties":false,"type":"object","properties":{"chunks":{"type":"array","items":{"type":"string"}},"exclude":{"default":"[/\\.map$/, /^manifest.*\\.js$/,]","type":"array","items":{"anyOf":[{"$ref":"#/definitions/RegExp"},{"type":"object","additionalProperties":false},{"type":"string"}]}},"excludeChunks":{"type":"array","items":{"type":"string"}},"include":{"type":"array","items":{"anyOf":[{"$ref":"#/definitions/RegExp"},{"type":"object","additionalProperties":false},{"type":"string"}]}},"mode":{"type":["null","string"]},"injectionPoint":{"default":"self.__WB_MANIFEST","type":"string"},"swSrc":{"type":"string"},"additionalManifestEntries":{"type":"array","items":{"anyOf":[{"$ref":"#/definitions/ManifestEntry"},{"type":"string"}]}},"dontCacheBustURLsMatching":{"$ref":"#/definitions/RegExp"},"manifestTransforms":{"type":"array","items":{"type":"object","additionalProperties":false}},"maximumFileSizeToCacheInBytes":{"default":2097152,"type":"number"},"modifyURLPrefix":{"type":"object","additionalProperties":{"type":"string"}},"swDest":{"default":"service-worker.js","type":"string"},"compileSrc":{"default":true,"type":"boolean"},"webpackCompilationPlugins":{"type":"array","items":{}}},"required":["swSrc"],"definitions":{"RegExp":{"type":"object","properties":{"source":{"type":"string"},"global":{"type":"boolean"},"ignoreCase":{"type":"boolean"},"multiline":{"type":"boolean"},"lastIndex":{"type":"number"},"flags":{"type":"string"},"sticky":{"type":"boolean"},"unicode":{"type":"boolean"},"dotAll":{"type":"boolean"}},"additionalProperties":false,"required":["dotAll","flags","global","ignoreCase","lastIndex","multiline","source","sticky","unicode"]},"GoogleAnalyticsInitializeOptions":{"type":"object","properties":{"cacheName":{"type":"string"},"parameterOverrides":{"type":"object","additionalProperties":{"type":"string"}},"hitFilter":{"type":"object","additionalProperties":false}},"additionalProperties":false},"RuntimeCaching":{"type":"object","properties":{"handler":{"anyOf":[{"$ref":"#/definitions/RouteHandlerCallback"},{"$ref":"#/definitions/RouteHandlerObject"},{"enum":["CacheFirst","CacheOnly","NetworkFirst","NetworkOnly","StaleWhileRevalidate"],"type":"string"}]},"method":{"enum":["DELETE","GET","HEAD","PATCH","POST","PUT"],"type":"string"},"options":{"type":"object","properties":{"backgroundSync":{"type":"object","properties":{"name":{"type":"string"},"options":{"$ref":"#/definitions/QueueOptions"}},"additionalProperties":false,"required":["name"]},"broadcastUpdate":{"type":"object","properties":{"channelName":{"type":"string"},"options":{"$ref":"#/definitions/BroadcastCacheUpdateOptions"}},"additionalProperties":false,"required":["options"]},"cacheableResponse":{"$ref":"#/definitions/CacheableResponseOptions"},"cacheName":{"type":["null","string"]},"expiration":{"$ref":"#/definitions/ExpirationPluginOptions"},"networkTimeoutSeconds":{"type":"number"},"plugins":{"type":"array","items":{"$ref":"#/definitions/WorkboxPlugin"}},"precacheFallback":{"type":"object","properties":{"fallbackURL":{"type":"string"}},"additionalProperties":false,"required":["fallbackURL"]},"fetchOptions":{"$ref":"#/definitions/RequestInit"},"matchOptions":{"$ref":"#/definitions/CacheQueryOptions"}},"additionalProperties":false},"urlPattern":{"anyOf":[{"$ref":"#/definitions/RegExp"},{"$ref":"#/definitions/RouteMatchCallback"},{"type":"string"}]}},"additionalProperties":false,"required":["handler","urlPattern"]},"RouteHandlerCallback":{"description":"The \"handler\" callback is invoked whenever a `Router` matches a URL/Request\nto a `Route` via its `RouteMatchCallback`. This handler callback should\nreturn a `Promise` that resolves with a `Response`.\n\nIf a non-empty array or object is returned by the `RouteMatchCallback` it\nwill be passed in as this handler's `options.params` argument.","type":"object","additionalProperties":false},"RouteHandlerObject":{"description":"An object with a `handle` method of type `RouteHandlerCallback`.\n\nA `Route` object can be created with either an `RouteHandlerCallback`\nfunction or this `RouteHandler` object. The benefit of the `RouteHandler`\nis it can be extended (as is done by the `workbox-strategies` package).","type":"object","properties":{"handle":{"$ref":"#/definitions/RouteHandlerCallback"}},"additionalProperties":false,"required":["handle"]},"QueueOptions":{"type":"object","properties":{"onSync":{"$ref":"#/definitions/OnSyncCallback"},"maxRetentionTime":{"type":"number"}},"additionalProperties":false},"OnSyncCallback":{"type":"object","additionalProperties":false},"BroadcastCacheUpdateOptions":{"type":"object","properties":{"headersToCheck":{"type":"array","items":{"type":"string"}},"generatePayload":{"type":"object","additionalProperties":false}},"additionalProperties":false},"CacheableResponseOptions":{"type":"object","properties":{"statuses":{"type":"array","items":{"type":"number"}},"headers":{"type":"object","additionalProperties":{"type":"string"}}},"additionalProperties":false},"ExpirationPluginOptions":{"type":"object","properties":{"maxEntries":{"type":"number"},"maxAgeSeconds":{"type":"number"},"matchOptions":{"$ref":"#/definitions/CacheQueryOptions"},"purgeOnQuotaError":{"type":"boolean"}},"additionalProperties":false},"CacheQueryOptions":{"type":"object","properties":{"ignoreMethod":{"type":"boolean"},"ignoreSearch":{"type":"boolean"},"ignoreVary":{"type":"boolean"}},"additionalProperties":false},"WorkboxPlugin":{"description":"An object with optional lifecycle callback properties for the fetch and\ncache operations.","type":"object","properties":{"cacheDidUpdate":{"$ref":"#/definitions/CacheDidUpdateCallback"},"cachedResponseWillBeUsed":{"$ref":"#/definitions/CachedResponseWillBeUsedCallback"},"cacheKeyWillBeUsed":{"$ref":"#/definitions/CacheKeyWillBeUsedCallback"},"cacheWillUpdate":{"$ref":"#/definitions/CacheWillUpdateCallback"},"fetchDidFail":{"$ref":"#/definitions/FetchDidFailCallback"},"fetchDidSucceed":{"$ref":"#/definitions/FetchDidSucceedCallback"},"handlerDidComplete":{"$ref":"#/definitions/HandlerDidCompleteCallback"},"handlerDidError":{"$ref":"#/definitions/HandlerDidErrorCallback"},"handlerDidRespond":{"$ref":"#/definitions/HandlerDidRespondCallback"},"handlerWillRespond":{"$ref":"#/definitions/HandlerWillRespondCallback"},"handlerWillStart":{"$ref":"#/definitions/HandlerWillStartCallback"},"requestWillFetch":{"$ref":"#/definitions/RequestWillFetchCallback"}},"additionalProperties":false},"CacheDidUpdateCallback":{"type":"object","additionalProperties":false},"CachedResponseWillBeUsedCallback":{"type":"object","additionalProperties":false},"CacheKeyWillBeUsedCallback":{"type":"object","additionalProperties":false},"CacheWillUpdateCallback":{"type":"object","additionalProperties":false},"FetchDidFailCallback":{"type":"object","additionalProperties":false},"FetchDidSucceedCallback":{"type":"object","additionalProperties":false},"HandlerDidCompleteCallback":{"type":"object","additionalProperties":false},"HandlerDidErrorCallback":{"type":"object","additionalProperties":false},"HandlerDidRespondCallback":{"type":"object","additionalProperties":false},"HandlerWillRespondCallback":{"type":"object","additionalProperties":false},"HandlerWillStartCallback":{"type":"object","additionalProperties":false},"RequestWillFetchCallback":{"type":"object","additionalProperties":false},"RequestInit":{"type":"object","properties":{"body":{"anyOf":[{"$ref":"#/definitions/ArrayBuffer"},{"$ref":"#/definitions/ArrayBufferView"},{"$ref":"#/definitions/Blob"},{"$ref":"#/definitions/FormData"},{"$ref":"#/definitions/URLSearchParams"},{"$ref":"#/definitions/ReadableStream"},{"type":["null","string"]}]},"cache":{"enum":["default","force-cache","no-cache","no-store","only-if-cached","reload"],"type":"string"},"credentials":{"enum":["include","omit","same-origin"],"type":"string"},"headers":{"anyOf":[{"$ref":"#/definitions/Headers"},{"type":"array","items":{"type":"array","items":{"type":"string"}}},{"$ref":"#/definitions/Record"}]},"integrity":{"type":"string"},"keepalive":{"type":"boolean"},"method":{"type":"string"},"mode":{"enum":["cors","navigate","no-cors","same-origin"],"type":"string"},"redirect":{"enum":["error","follow","manual"],"type":"string"},"referrer":{"type":"string"},"referrerPolicy":{"enum":["","no-referrer","no-referrer-when-downgrade","origin","origin-when-cross-origin","same-origin","strict-origin","strict-origin-when-cross-origin","unsafe-url"],"type":"string"},"signal":{"anyOf":[{"$ref":"#/definitions/AbortSignal"},{"type":"null"}]},"window":{}},"additionalProperties":false},"ArrayBuffer":{"type":"object","properties":{"byteLength":{"type":"number"},"__@toStringTag":{"type":"string"}},"additionalProperties":false,"required":["__@toStringTag","byteLength"]},"ArrayBufferView":{"type":"object","properties":{"buffer":{"anyOf":[{"$ref":"#/definitions/ArrayBuffer"},{"$ref":"#/definitions/SharedArrayBuffer"}]},"byteLength":{"type":"number"},"byteOffset":{"type":"number"}},"additionalProperties":false,"required":["buffer","byteLength","byteOffset"]},"SharedArrayBuffer":{"type":"object","properties":{"byteLength":{"type":"number"},"__@species":{"$ref":"#/definitions/SharedArrayBuffer"},"__@toStringTag":{"type":"string","enum":["SharedArrayBuffer"]}},"additionalProperties":false,"required":["__@species","__@toStringTag","byteLength"]},"Blob":{"type":"object","properties":{"size":{"type":"number"},"type":{"type":"string"}},"additionalProperties":false,"required":["size","type"]},"FormData":{"type":"object","additionalProperties":false},"URLSearchParams":{"type":"object","additionalProperties":false},"ReadableStream":{"type":"object","properties":{"locked":{"type":"boolean"}},"additionalProperties":false,"required":["locked"]},"Headers":{"type":"object","additionalProperties":false},"Record":{"type":"object","additionalProperties":false},"AbortSignal":{"type":"object","properties":{"aborted":{"type":"boolean"},"onabort":{"anyOf":[{"type":"object","additionalProperties":false},{"type":"null"}]}},"additionalProperties":false,"required":["aborted","onabort"]},"RouteMatchCallback":{"description":"The \"match\" callback is used to determine if a `Route` should apply for a\nparticular URL and request. When matching occurs in response to a fetch\nevent from the client, the `event` object is also supplied. However, since\nthe match callback can be invoked outside of a fetch event, matching logic\nshould not assume the `event` object will always be available.\nIf the match callback returns a truthy value, the matching route's\n`RouteHandlerCallback` will be invoked immediately. If the value returned\nis a non-empty array or object, that value will be set on the handler's\n`options.params` argument.","type":"object","additionalProperties":false},"ManifestEntry":{"type":"object","properties":{"integrity":{"type":"string"},"revision":{"type":["null","string"]},"url":{"type":"string"}},"additionalProperties":false,"required":["revision","url"]}},"$schema":"http://json-schema.org/draft-07/schema#"} +{"additionalProperties":false,"type":"object","properties":{"chunks":{"type":"array","items":{"type":"string"}},"exclude":{"type":"array","items":{"anyOf":[{"$ref":"#/definitions/RegExp"},{"type":"object","additionalProperties":false},{"type":"string"}]}},"excludeChunks":{"type":"array","items":{"type":"string"}},"include":{"type":"array","items":{"anyOf":[{"$ref":"#/definitions/RegExp"},{"type":"object","additionalProperties":false},{"type":"string"}]}},"mode":{"type":["null","string"]},"injectionPoint":{"default":"self.__WB_MANIFEST","type":"string"},"swSrc":{"type":"string"},"additionalManifestEntries":{"type":"array","items":{"anyOf":[{"$ref":"#/definitions/ManifestEntry"},{"type":"string"}]}},"dontCacheBustURLsMatching":{"$ref":"#/definitions/RegExp"},"manifestTransforms":{"type":"array","items":{"type":"object","additionalProperties":false}},"maximumFileSizeToCacheInBytes":{"default":2097152,"type":"number"},"modifyURLPrefix":{"type":"object","additionalProperties":{"type":"string"}},"swDest":{"default":"service-worker.js","type":"string"},"compileSrc":{"default":true,"type":"boolean"},"webpackCompilationPlugins":{"type":"array","items":{}}},"required":["swSrc"],"definitions":{"RegExp":{"type":"object","properties":{"source":{"type":"string"},"global":{"type":"boolean"},"ignoreCase":{"type":"boolean"},"multiline":{"type":"boolean"},"lastIndex":{"type":"number"},"flags":{"type":"string"},"sticky":{"type":"boolean"},"unicode":{"type":"boolean"},"dotAll":{"type":"boolean"}},"additionalProperties":false,"required":["dotAll","flags","global","ignoreCase","lastIndex","multiline","source","sticky","unicode"]},"GoogleAnalyticsInitializeOptions":{"type":"object","properties":{"cacheName":{"type":"string"},"parameterOverrides":{"type":"object","additionalProperties":{"type":"string"}},"hitFilter":{"type":"object","additionalProperties":false}},"additionalProperties":false},"RuntimeCaching":{"type":"object","properties":{"handler":{"anyOf":[{"$ref":"#/definitions/RouteHandlerCallback"},{"$ref":"#/definitions/RouteHandlerObject"},{"enum":["CacheFirst","CacheOnly","NetworkFirst","NetworkOnly","StaleWhileRevalidate"],"type":"string"}]},"method":{"enum":["DELETE","GET","HEAD","PATCH","POST","PUT"],"type":"string"},"options":{"type":"object","properties":{"backgroundSync":{"type":"object","properties":{"name":{"type":"string"},"options":{"$ref":"#/definitions/QueueOptions"}},"additionalProperties":false,"required":["name"]},"broadcastUpdate":{"type":"object","properties":{"channelName":{"type":"string"},"options":{"$ref":"#/definitions/BroadcastCacheUpdateOptions"}},"additionalProperties":false,"required":["options"]},"cacheableResponse":{"$ref":"#/definitions/CacheableResponseOptions"},"cacheName":{"type":["null","string"]},"expiration":{"$ref":"#/definitions/ExpirationPluginOptions"},"networkTimeoutSeconds":{"type":"number"},"plugins":{"type":"array","items":{"$ref":"#/definitions/WorkboxPlugin"}},"precacheFallback":{"type":"object","properties":{"fallbackURL":{"type":"string"}},"additionalProperties":false,"required":["fallbackURL"]},"fetchOptions":{"$ref":"#/definitions/RequestInit"},"matchOptions":{"$ref":"#/definitions/CacheQueryOptions"}},"additionalProperties":false},"urlPattern":{"anyOf":[{"$ref":"#/definitions/RegExp"},{"$ref":"#/definitions/RouteMatchCallback"},{"type":"string"}]}},"additionalProperties":false,"required":["handler","urlPattern"]},"RouteHandlerCallback":{"description":"The \"handler\" callback is invoked whenever a `Router` matches a URL/Request\nto a `Route` via its `RouteMatchCallback`. This handler callback should\nreturn a `Promise` that resolves with a `Response`.\n\nIf a non-empty array or object is returned by the `RouteMatchCallback` it\nwill be passed in as this handler's `options.params` argument.","type":"object","additionalProperties":false},"RouteHandlerObject":{"description":"An object with a `handle` method of type `RouteHandlerCallback`.\n\nA `Route` object can be created with either an `RouteHandlerCallback`\nfunction or this `RouteHandler` object. The benefit of the `RouteHandler`\nis it can be extended (as is done by the `workbox-strategies` package).","type":"object","properties":{"handle":{"$ref":"#/definitions/RouteHandlerCallback"}},"additionalProperties":false,"required":["handle"]},"QueueOptions":{"type":"object","properties":{"onSync":{"$ref":"#/definitions/OnSyncCallback"},"maxRetentionTime":{"type":"number"}},"additionalProperties":false},"OnSyncCallback":{"type":"object","additionalProperties":false},"BroadcastCacheUpdateOptions":{"type":"object","properties":{"headersToCheck":{"type":"array","items":{"type":"string"}},"generatePayload":{"type":"object","additionalProperties":false}},"additionalProperties":false},"CacheableResponseOptions":{"type":"object","properties":{"statuses":{"type":"array","items":{"type":"number"}},"headers":{"type":"object","additionalProperties":{"type":"string"}}},"additionalProperties":false},"ExpirationPluginOptions":{"type":"object","properties":{"maxEntries":{"type":"number"},"maxAgeSeconds":{"type":"number"},"matchOptions":{"$ref":"#/definitions/CacheQueryOptions"},"purgeOnQuotaError":{"type":"boolean"}},"additionalProperties":false},"CacheQueryOptions":{"type":"object","properties":{"ignoreMethod":{"type":"boolean"},"ignoreSearch":{"type":"boolean"},"ignoreVary":{"type":"boolean"}},"additionalProperties":false},"WorkboxPlugin":{"description":"An object with optional lifecycle callback properties for the fetch and\ncache operations.","type":"object","properties":{"cacheDidUpdate":{"$ref":"#/definitions/CacheDidUpdateCallback"},"cachedResponseWillBeUsed":{"$ref":"#/definitions/CachedResponseWillBeUsedCallback"},"cacheKeyWillBeUsed":{"$ref":"#/definitions/CacheKeyWillBeUsedCallback"},"cacheWillUpdate":{"$ref":"#/definitions/CacheWillUpdateCallback"},"fetchDidFail":{"$ref":"#/definitions/FetchDidFailCallback"},"fetchDidSucceed":{"$ref":"#/definitions/FetchDidSucceedCallback"},"handlerDidComplete":{"$ref":"#/definitions/HandlerDidCompleteCallback"},"handlerDidError":{"$ref":"#/definitions/HandlerDidErrorCallback"},"handlerDidRespond":{"$ref":"#/definitions/HandlerDidRespondCallback"},"handlerWillRespond":{"$ref":"#/definitions/HandlerWillRespondCallback"},"handlerWillStart":{"$ref":"#/definitions/HandlerWillStartCallback"},"requestWillFetch":{"$ref":"#/definitions/RequestWillFetchCallback"}},"additionalProperties":false},"CacheDidUpdateCallback":{"type":"object","additionalProperties":false},"CachedResponseWillBeUsedCallback":{"type":"object","additionalProperties":false},"CacheKeyWillBeUsedCallback":{"type":"object","additionalProperties":false},"CacheWillUpdateCallback":{"type":"object","additionalProperties":false},"FetchDidFailCallback":{"type":"object","additionalProperties":false},"FetchDidSucceedCallback":{"type":"object","additionalProperties":false},"HandlerDidCompleteCallback":{"type":"object","additionalProperties":false},"HandlerDidErrorCallback":{"type":"object","additionalProperties":false},"HandlerDidRespondCallback":{"type":"object","additionalProperties":false},"HandlerWillRespondCallback":{"type":"object","additionalProperties":false},"HandlerWillStartCallback":{"type":"object","additionalProperties":false},"RequestWillFetchCallback":{"type":"object","additionalProperties":false},"RequestInit":{"type":"object","properties":{"body":{"anyOf":[{"$ref":"#/definitions/ArrayBuffer"},{"$ref":"#/definitions/ArrayBufferView"},{"$ref":"#/definitions/Blob"},{"$ref":"#/definitions/FormData"},{"$ref":"#/definitions/URLSearchParams"},{"$ref":"#/definitions/ReadableStream"},{"type":["null","string"]}]},"cache":{"enum":["default","force-cache","no-cache","no-store","only-if-cached","reload"],"type":"string"},"credentials":{"enum":["include","omit","same-origin"],"type":"string"},"headers":{"anyOf":[{"$ref":"#/definitions/Headers"},{"type":"array","items":{"type":"array","items":{"type":"string"}}},{"$ref":"#/definitions/Record"}]},"integrity":{"type":"string"},"keepalive":{"type":"boolean"},"method":{"type":"string"},"mode":{"enum":["cors","navigate","no-cors","same-origin"],"type":"string"},"redirect":{"enum":["error","follow","manual"],"type":"string"},"referrer":{"type":"string"},"referrerPolicy":{"enum":["","no-referrer","no-referrer-when-downgrade","origin","origin-when-cross-origin","same-origin","strict-origin","strict-origin-when-cross-origin","unsafe-url"],"type":"string"},"signal":{"anyOf":[{"$ref":"#/definitions/AbortSignal"},{"type":"null"}]},"window":{}},"additionalProperties":false},"ArrayBuffer":{"type":"object","properties":{"byteLength":{"type":"number"},"__@toStringTag":{"type":"string"}},"additionalProperties":false,"required":["__@toStringTag","byteLength"]},"ArrayBufferView":{"type":"object","properties":{"buffer":{"anyOf":[{"$ref":"#/definitions/ArrayBuffer"},{"$ref":"#/definitions/SharedArrayBuffer"}]},"byteLength":{"type":"number"},"byteOffset":{"type":"number"}},"additionalProperties":false,"required":["buffer","byteLength","byteOffset"]},"SharedArrayBuffer":{"type":"object","properties":{"byteLength":{"type":"number"},"__@species":{"$ref":"#/definitions/SharedArrayBuffer"},"__@toStringTag":{"type":"string","enum":["SharedArrayBuffer"]}},"additionalProperties":false,"required":["__@species","__@toStringTag","byteLength"]},"Blob":{"type":"object","properties":{"size":{"type":"number"},"type":{"type":"string"}},"additionalProperties":false,"required":["size","type"]},"FormData":{"type":"object","additionalProperties":false},"URLSearchParams":{"type":"object","additionalProperties":false},"ReadableStream":{"type":"object","properties":{"locked":{"type":"boolean"}},"additionalProperties":false,"required":["locked"]},"Headers":{"type":"object","additionalProperties":false},"Record":{"type":"object","additionalProperties":false},"AbortSignal":{"type":"object","properties":{"aborted":{"type":"boolean"},"onabort":{"anyOf":[{"type":"object","additionalProperties":false},{"type":"null"}]}},"additionalProperties":false,"required":["aborted","onabort"]},"RouteMatchCallback":{"description":"The \"match\" callback is used to determine if a `Route` should apply for a\nparticular URL and request. When matching occurs in response to a fetch\nevent from the client, the `event` object is also supplied. However, since\nthe match callback can be invoked outside of a fetch event, matching logic\nshould not assume the `event` object will always be available.\nIf the match callback returns a truthy value, the matching route's\n`RouteHandlerCallback` will be invoked immediately. If the value returned\nis a non-empty array or object, that value will be set on the handler's\n`options.params` argument.","type":"object","additionalProperties":false},"ManifestEntry":{"type":"object","properties":{"integrity":{"type":"string"},"revision":{"type":["null","string"]},"url":{"type":"string"}},"additionalProperties":false,"required":["revision","url"]}},"$schema":"http://json-schema.org/draft-07/schema#"} diff --git a/packages/workbox-build/src/types.ts b/packages/workbox-build/src/types.ts index f46094a31..c54c344af 100644 --- a/packages/workbox-build/src/types.ts +++ b/packages/workbox-build/src/types.ts @@ -155,9 +155,10 @@ interface InjectPartial { interface WebpackPartial { chunks?: Array; - /** - * @default [/\.map$/, /^manifest.*\.js$/,] - */ + // We can't use the @default annotation here to assign the value via AJV, as + // an Array can't be serialized into JSON. + // The default value of [/\.map$/, /^manifest.*\.js$/] will be assigned by + // the validation function, and we need to reflect that in the docs. exclude?: Array any)>; excludeChunks?: Array; include?: Array any)>; @@ -184,7 +185,7 @@ export type InjectManifestOptions = InjectPartial & Omit; + importScriptsViaChunks?: Array; }; export type WebpackInjectManifestOptions = WebpackPartial & InjectPartial & BasePartial & OptionalSWDestPartial & { diff --git a/packages/workbox-webpack-plugin/src/generate-sw.js b/packages/workbox-webpack-plugin/src/generate-sw.js index 7395a5669..462dacbad 100644 --- a/packages/workbox-webpack-plugin/src/generate-sw.js +++ b/packages/workbox-webpack-plugin/src/generate-sw.js @@ -6,14 +6,13 @@ https://opensource.org/licenses/MIT. */ +const {validateWebpackGenerateSWOptions} = + require('workbox-build/build/lib/validate-options'); const bundle = require('workbox-build/build/lib/bundle'); const populateSWTemplate = require('workbox-build/build/lib/populate-sw-template'); const prettyBytes = require('pretty-bytes'); -const validate = require('workbox-build/build/lib/validate-options'); const webpack = require('webpack'); -const webpackGenerateSWSchema = require( - 'workbox-build/build/options/schema/webpack-generate-sw'); const getScriptFilesForChunks = require('./lib/get-script-files-for-chunks'); const getManifestEntriesFromCompilation = @@ -272,7 +271,7 @@ class GenerateSW { // emit might be called multiple times; instead of modifying this.config, // use a validated copy. // See https://github.com/GoogleChrome/workbox/issues/2158 - config = validate(this.config, webpackGenerateSWSchema); + config = validateWebpackGenerateSWOptions(this.config); } catch (error) { throw new Error(`Please check your ${this.constructor.name} plugin ` + `configuration:\n${error.message}`); diff --git a/packages/workbox-webpack-plugin/src/inject-manifest.js b/packages/workbox-webpack-plugin/src/inject-manifest.js index 210132c08..d6dbd919b 100644 --- a/packages/workbox-webpack-plugin/src/inject-manifest.js +++ b/packages/workbox-webpack-plugin/src/inject-manifest.js @@ -6,16 +6,15 @@ https://opensource.org/licenses/MIT. */ -const escapeRegexp = require('workbox-build/build/lib/escape-regexp'); +const {validateWebpackInjectManifestOptions} = + require('workbox-build/build/lib/validate-options'); +const {escapeRegExp} = require('workbox-build/build/lib/escape-regexp'); const prettyBytes = require('pretty-bytes'); -const replaceAndUpdateSourceMap = require( - 'workbox-build/build/lib/replace-and-update-source-map'); +const replaceAndUpdateSourceMap = + require('workbox-build/build/lib/replace-and-update-source-map'); const stringify = require('fast-json-stable-stringify'); const upath = require('upath'); -const validate = require('workbox-build/build/lib/validate-options'); const webpack = require('webpack'); -const webpackInjectManifestSchema = require( - 'workbox-build/build/options/schema/webpack-inject-manifest'); const getManifestEntriesFromCompilation = require('./lib/get-manifest-entries-from-compilation'); @@ -250,7 +249,7 @@ class InjectManifest { */ async handleMake(compilation, parentCompiler) { try { - this.config = validate(this.config, webpackInjectManifestSchema); + this.config = validateWebpackInjectManifestOptions(this.config); } catch (error) { throw new Error(`Please check your ${this.constructor.name} plugin ` + `configuration:\n${error.message}`); @@ -301,7 +300,7 @@ class InjectManifest { const swAsset = compilation.getAsset(config.swDest); const swAssetString = swAsset.source.source(); - const globalRegexp = new RegExp(escapeRegexp(config.injectionPoint), 'g'); + const globalRegexp = new RegExp(escapeRegExp(config.injectionPoint), 'g'); const injectionResults = swAssetString.match(globalRegexp); if (!injectionResults) { From f3a4e8b46936ec1dfb7cbfec5b8a2a23c616317b Mon Sep 17 00:00:00 2001 From: Jeff Posnick Date: Wed, 9 Jun 2021 17:54:21 -0400 Subject: [PATCH 43/80] Fix transformManifest usage --- packages/workbox-build/src/types.ts | 16 ++++++++-------- .../lib/get-manifest-entries-from-compilation.js | 2 +- .../node/v4/inject-manifest.js | 2 +- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/packages/workbox-build/src/types.ts b/packages/workbox-build/src/types.ts index c54c344af..c4b52b43a 100644 --- a/packages/workbox-build/src/types.ts +++ b/packages/workbox-build/src/types.ts @@ -1,13 +1,13 @@ import {PackageJson} from 'type-fest'; -import {BroadcastCacheUpdateOptions} from 'workbox-broadcast-update/BroadcastCacheUpdate.js'; -import {GoogleAnalyticsInitializeOptions} from 'workbox-google-analytics/initialize.js'; -import {HTTPMethod} from 'workbox-routing/utils/constants.js'; -import {QueueOptions} from 'workbox-background-sync/Queue.js'; -import {RouteHandler, RouteMatchCallback} from 'workbox-core/types.js'; -import {CacheableResponseOptions} from 'workbox-cacheable-response/CacheableResponse.js'; -import {ExpirationPluginOptions} from 'workbox-expiration/ExpirationPlugin.js'; -import {WorkboxPlugin} from 'workbox-core/types.js'; +import {BroadcastCacheUpdateOptions} from 'workbox-broadcast-update/BroadcastCacheUpdate'; +import {GoogleAnalyticsInitializeOptions} from 'workbox-google-analytics/initialize'; +import {HTTPMethod} from 'workbox-routing/utils/constants'; +import {QueueOptions} from 'workbox-background-sync/Queue'; +import {RouteHandler, RouteMatchCallback} from 'workbox-core/types'; +import {CacheableResponseOptions} from 'workbox-cacheable-response/CacheableResponse'; +import {ExpirationPluginOptions} from 'workbox-expiration/ExpirationPlugin'; +import {WorkboxPlugin} from 'workbox-core/types'; export interface ManifestEntry { integrity?: string; diff --git a/packages/workbox-webpack-plugin/src/lib/get-manifest-entries-from-compilation.js b/packages/workbox-webpack-plugin/src/lib/get-manifest-entries-from-compilation.js index 254150b53..fc5e2d23d 100644 --- a/packages/workbox-webpack-plugin/src/lib/get-manifest-entries-from-compilation.js +++ b/packages/workbox-webpack-plugin/src/lib/get-manifest-entries-from-compilation.js @@ -7,7 +7,7 @@ */ const {matchPart} = require('webpack').ModuleFilenameHelpers; -const transformManifest = require('workbox-build/build/lib/transform-manifest'); +const {transformManifest} = require('workbox-build/build/lib/transform-manifest'); const getAssetHash = require('./get-asset-hash'); const resolveWebpackURL = require('./resolve-webpack-url'); diff --git a/test/workbox-webpack-plugin/node/v4/inject-manifest.js b/test/workbox-webpack-plugin/node/v4/inject-manifest.js index bc58c7c7e..efc953bd7 100644 --- a/test/workbox-webpack-plugin/node/v4/inject-manifest.js +++ b/test/workbox-webpack-plugin/node/v4/inject-manifest.js @@ -1740,7 +1740,7 @@ describe(`[workbox-webpack-plugin] InjectManifest with webpack v4`, function() { }); }); - it(`should support injecting a manifest into a CJS module`, function(done) { + it(`•should support injecting a manifest into a CJS module`, function(done) { const outputDir = tempy.directory(); const config = { From 53aa9a8a44efeb39fa6020fc422c391d85b1785d Mon Sep 17 00:00:00 2001 From: Jeff Posnick Date: Wed, 9 Jun 2021 20:53:06 -0400 Subject: [PATCH 44/80] Use a copy of the exclude array --- packages/workbox-build/src/lib/validate-options.ts | 6 ++++-- test/workbox-webpack-plugin/node/v4/inject-manifest.js | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/packages/workbox-build/src/lib/validate-options.ts b/packages/workbox-build/src/lib/validate-options.ts index 41b5dd7df..2909c7877 100644 --- a/packages/workbox-build/src/lib/validate-options.ts +++ b/packages/workbox-build/src/lib/validate-options.ts @@ -54,14 +54,16 @@ export function validateInjectManifestOptions(input: unknown): InjectManifestOpt // represented in the JSON schema, so manually set it for the webpack options. export function validateWebpackGenerateSWOptions(input: unknown): WebpackGenerateSWOptions { const inputWithExcludeDefault = Object.assign({ - exclude: DEFAULT_EXCLUDE_VALUE, + // Make a copy, as exclude can be mutated when used. + exclude: Array.from(DEFAULT_EXCLUDE_VALUE), }, input); return validate(inputWithExcludeDefault, '../schema/WebpackGenerateSWOptions.json'); } export function validateWebpackInjectManifestOptions(input: unknown): WebpackInjectManifestOptions { const inputWithExcludeDefault = Object.assign({ - exclude: DEFAULT_EXCLUDE_VALUE, + // Make a copy, as exclude can be mutated when used. + exclude: Array.from(DEFAULT_EXCLUDE_VALUE), }, input); return validate(inputWithExcludeDefault, '../schema/WebpackInjectManifestOptions.json'); } diff --git a/test/workbox-webpack-plugin/node/v4/inject-manifest.js b/test/workbox-webpack-plugin/node/v4/inject-manifest.js index efc953bd7..bc58c7c7e 100644 --- a/test/workbox-webpack-plugin/node/v4/inject-manifest.js +++ b/test/workbox-webpack-plugin/node/v4/inject-manifest.js @@ -1740,7 +1740,7 @@ describe(`[workbox-webpack-plugin] InjectManifest with webpack v4`, function() { }); }); - it(`•should support injecting a manifest into a CJS module`, function(done) { + it(`should support injecting a manifest into a CJS module`, function(done) { const outputDir = tempy.directory(); const config = { From acfbefeb6eaf6d785cfdd167472edba5da65922b Mon Sep 17 00:00:00 2001 From: Jeff Posnick Date: Wed, 9 Jun 2021 21:37:05 -0400 Subject: [PATCH 45/80] More include/exclude fun --- .../src/schema/WebpackGenerateSWOptions.json | 2 +- .../src/schema/WebpackInjectManifestOptions.json | 2 +- packages/workbox-build/src/types.ts | 9 +++++++-- packages/workbox-webpack-plugin/src/inject-manifest.js | 7 +++++++ test/workbox-webpack-plugin/node/v4/inject-manifest.js | 9 ++++----- 5 files changed, 20 insertions(+), 9 deletions(-) diff --git a/packages/workbox-build/src/schema/WebpackGenerateSWOptions.json b/packages/workbox-build/src/schema/WebpackGenerateSWOptions.json index d9fe73d09..75dbdbedd 100644 --- a/packages/workbox-build/src/schema/WebpackGenerateSWOptions.json +++ b/packages/workbox-build/src/schema/WebpackGenerateSWOptions.json @@ -1 +1 @@ -{"additionalProperties":false,"type":"object","properties":{"chunks":{"type":"array","items":{"type":"string"}},"exclude":{"type":"array","items":{"anyOf":[{"$ref":"#/definitions/RegExp"},{"type":"object","additionalProperties":false},{"type":"string"}]}},"excludeChunks":{"type":"array","items":{"type":"string"}},"include":{"type":"array","items":{"anyOf":[{"$ref":"#/definitions/RegExp"},{"type":"object","additionalProperties":false},{"type":"string"}]}},"mode":{"default":"production","type":["null","string"]},"babelPresetEnvTargets":{"default":["chrome >= 56"],"type":"array","items":{"type":"string"}},"cacheId":{"type":["null","string"]},"cleanupOutdatedCaches":{"default":false,"type":"boolean"},"clientsClaim":{"default":false,"type":"boolean"},"directoryIndex":{"type":["null","string"]},"disableDevLogs":{"default":false,"type":"boolean"},"ignoreURLParametersMatching":{"type":"array","items":{"$ref":"#/definitions/RegExp"}},"importScripts":{"type":"array","items":{"type":"string"}},"inlineWorkboxRuntime":{"default":false,"type":"boolean"},"navigateFallback":{"default":null,"type":["null","string"]},"navigateFallbackAllowlist":{"type":"array","items":{"$ref":"#/definitions/RegExp"}},"navigateFallbackDenylist":{"type":"array","items":{"$ref":"#/definitions/RegExp"}},"navigationPreload":{"default":false,"type":"boolean"},"offlineGoogleAnalytics":{"default":false,"anyOf":[{"$ref":"#/definitions/GoogleAnalyticsInitializeOptions"},{"type":"boolean"}]},"runtimeCaching":{"type":"array","items":{"$ref":"#/definitions/RuntimeCaching"}},"skipWaiting":{"default":false,"type":"boolean"},"sourcemap":{"default":true,"type":"boolean"},"additionalManifestEntries":{"type":"array","items":{"anyOf":[{"$ref":"#/definitions/ManifestEntry"},{"type":"string"}]}},"dontCacheBustURLsMatching":{"$ref":"#/definitions/RegExp"},"manifestTransforms":{"type":"array","items":{"type":"object","additionalProperties":false}},"maximumFileSizeToCacheInBytes":{"default":2097152,"type":"number"},"modifyURLPrefix":{"type":"object","additionalProperties":{"type":"string"}},"swDest":{"default":"service-worker.js","type":"string"},"importScriptsViaChunks":{"type":"array","items":{"type":"string"}}},"definitions":{"RegExp":{"type":"object","properties":{"source":{"type":"string"},"global":{"type":"boolean"},"ignoreCase":{"type":"boolean"},"multiline":{"type":"boolean"},"lastIndex":{"type":"number"},"flags":{"type":"string"},"sticky":{"type":"boolean"},"unicode":{"type":"boolean"},"dotAll":{"type":"boolean"}},"additionalProperties":false,"required":["dotAll","flags","global","ignoreCase","lastIndex","multiline","source","sticky","unicode"]},"GoogleAnalyticsInitializeOptions":{"type":"object","properties":{"cacheName":{"type":"string"},"parameterOverrides":{"type":"object","additionalProperties":{"type":"string"}},"hitFilter":{"type":"object","additionalProperties":false}},"additionalProperties":false},"RuntimeCaching":{"type":"object","properties":{"handler":{"anyOf":[{"$ref":"#/definitions/RouteHandlerCallback"},{"$ref":"#/definitions/RouteHandlerObject"},{"enum":["CacheFirst","CacheOnly","NetworkFirst","NetworkOnly","StaleWhileRevalidate"],"type":"string"}]},"method":{"enum":["DELETE","GET","HEAD","PATCH","POST","PUT"],"type":"string"},"options":{"type":"object","properties":{"backgroundSync":{"type":"object","properties":{"name":{"type":"string"},"options":{"$ref":"#/definitions/QueueOptions"}},"additionalProperties":false,"required":["name"]},"broadcastUpdate":{"type":"object","properties":{"channelName":{"type":"string"},"options":{"$ref":"#/definitions/BroadcastCacheUpdateOptions"}},"additionalProperties":false,"required":["options"]},"cacheableResponse":{"$ref":"#/definitions/CacheableResponseOptions"},"cacheName":{"type":["null","string"]},"expiration":{"$ref":"#/definitions/ExpirationPluginOptions"},"networkTimeoutSeconds":{"type":"number"},"plugins":{"type":"array","items":{"$ref":"#/definitions/WorkboxPlugin"}},"precacheFallback":{"type":"object","properties":{"fallbackURL":{"type":"string"}},"additionalProperties":false,"required":["fallbackURL"]},"fetchOptions":{"$ref":"#/definitions/RequestInit"},"matchOptions":{"$ref":"#/definitions/CacheQueryOptions"}},"additionalProperties":false},"urlPattern":{"anyOf":[{"$ref":"#/definitions/RegExp"},{"$ref":"#/definitions/RouteMatchCallback"},{"type":"string"}]}},"additionalProperties":false,"required":["handler","urlPattern"]},"RouteHandlerCallback":{"description":"The \"handler\" callback is invoked whenever a `Router` matches a URL/Request\nto a `Route` via its `RouteMatchCallback`. This handler callback should\nreturn a `Promise` that resolves with a `Response`.\n\nIf a non-empty array or object is returned by the `RouteMatchCallback` it\nwill be passed in as this handler's `options.params` argument.","type":"object","additionalProperties":false},"RouteHandlerObject":{"description":"An object with a `handle` method of type `RouteHandlerCallback`.\n\nA `Route` object can be created with either an `RouteHandlerCallback`\nfunction or this `RouteHandler` object. The benefit of the `RouteHandler`\nis it can be extended (as is done by the `workbox-strategies` package).","type":"object","properties":{"handle":{"$ref":"#/definitions/RouteHandlerCallback"}},"additionalProperties":false,"required":["handle"]},"QueueOptions":{"type":"object","properties":{"onSync":{"$ref":"#/definitions/OnSyncCallback"},"maxRetentionTime":{"type":"number"}},"additionalProperties":false},"OnSyncCallback":{"type":"object","additionalProperties":false},"BroadcastCacheUpdateOptions":{"type":"object","properties":{"headersToCheck":{"type":"array","items":{"type":"string"}},"generatePayload":{"type":"object","additionalProperties":false}},"additionalProperties":false},"CacheableResponseOptions":{"type":"object","properties":{"statuses":{"type":"array","items":{"type":"number"}},"headers":{"type":"object","additionalProperties":{"type":"string"}}},"additionalProperties":false},"ExpirationPluginOptions":{"type":"object","properties":{"maxEntries":{"type":"number"},"maxAgeSeconds":{"type":"number"},"matchOptions":{"$ref":"#/definitions/CacheQueryOptions"},"purgeOnQuotaError":{"type":"boolean"}},"additionalProperties":false},"CacheQueryOptions":{"type":"object","properties":{"ignoreMethod":{"type":"boolean"},"ignoreSearch":{"type":"boolean"},"ignoreVary":{"type":"boolean"}},"additionalProperties":false},"WorkboxPlugin":{"description":"An object with optional lifecycle callback properties for the fetch and\ncache operations.","type":"object","properties":{"cacheDidUpdate":{"$ref":"#/definitions/CacheDidUpdateCallback"},"cachedResponseWillBeUsed":{"$ref":"#/definitions/CachedResponseWillBeUsedCallback"},"cacheKeyWillBeUsed":{"$ref":"#/definitions/CacheKeyWillBeUsedCallback"},"cacheWillUpdate":{"$ref":"#/definitions/CacheWillUpdateCallback"},"fetchDidFail":{"$ref":"#/definitions/FetchDidFailCallback"},"fetchDidSucceed":{"$ref":"#/definitions/FetchDidSucceedCallback"},"handlerDidComplete":{"$ref":"#/definitions/HandlerDidCompleteCallback"},"handlerDidError":{"$ref":"#/definitions/HandlerDidErrorCallback"},"handlerDidRespond":{"$ref":"#/definitions/HandlerDidRespondCallback"},"handlerWillRespond":{"$ref":"#/definitions/HandlerWillRespondCallback"},"handlerWillStart":{"$ref":"#/definitions/HandlerWillStartCallback"},"requestWillFetch":{"$ref":"#/definitions/RequestWillFetchCallback"}},"additionalProperties":false},"CacheDidUpdateCallback":{"type":"object","additionalProperties":false},"CachedResponseWillBeUsedCallback":{"type":"object","additionalProperties":false},"CacheKeyWillBeUsedCallback":{"type":"object","additionalProperties":false},"CacheWillUpdateCallback":{"type":"object","additionalProperties":false},"FetchDidFailCallback":{"type":"object","additionalProperties":false},"FetchDidSucceedCallback":{"type":"object","additionalProperties":false},"HandlerDidCompleteCallback":{"type":"object","additionalProperties":false},"HandlerDidErrorCallback":{"type":"object","additionalProperties":false},"HandlerDidRespondCallback":{"type":"object","additionalProperties":false},"HandlerWillRespondCallback":{"type":"object","additionalProperties":false},"HandlerWillStartCallback":{"type":"object","additionalProperties":false},"RequestWillFetchCallback":{"type":"object","additionalProperties":false},"RequestInit":{"type":"object","properties":{"body":{"anyOf":[{"$ref":"#/definitions/ArrayBuffer"},{"$ref":"#/definitions/ArrayBufferView"},{"$ref":"#/definitions/Blob"},{"$ref":"#/definitions/FormData"},{"$ref":"#/definitions/URLSearchParams"},{"$ref":"#/definitions/ReadableStream"},{"type":["null","string"]}]},"cache":{"enum":["default","force-cache","no-cache","no-store","only-if-cached","reload"],"type":"string"},"credentials":{"enum":["include","omit","same-origin"],"type":"string"},"headers":{"anyOf":[{"$ref":"#/definitions/Headers"},{"type":"array","items":{"type":"array","items":{"type":"string"}}},{"$ref":"#/definitions/Record"}]},"integrity":{"type":"string"},"keepalive":{"type":"boolean"},"method":{"type":"string"},"mode":{"enum":["cors","navigate","no-cors","same-origin"],"type":"string"},"redirect":{"enum":["error","follow","manual"],"type":"string"},"referrer":{"type":"string"},"referrerPolicy":{"enum":["","no-referrer","no-referrer-when-downgrade","origin","origin-when-cross-origin","same-origin","strict-origin","strict-origin-when-cross-origin","unsafe-url"],"type":"string"},"signal":{"anyOf":[{"$ref":"#/definitions/AbortSignal"},{"type":"null"}]},"window":{}},"additionalProperties":false},"ArrayBuffer":{"type":"object","properties":{"byteLength":{"type":"number"},"__@toStringTag":{"type":"string"}},"additionalProperties":false,"required":["__@toStringTag","byteLength"]},"ArrayBufferView":{"type":"object","properties":{"buffer":{"anyOf":[{"$ref":"#/definitions/ArrayBuffer"},{"$ref":"#/definitions/SharedArrayBuffer"}]},"byteLength":{"type":"number"},"byteOffset":{"type":"number"}},"additionalProperties":false,"required":["buffer","byteLength","byteOffset"]},"SharedArrayBuffer":{"type":"object","properties":{"byteLength":{"type":"number"},"__@species":{"$ref":"#/definitions/SharedArrayBuffer"},"__@toStringTag":{"type":"string","enum":["SharedArrayBuffer"]}},"additionalProperties":false,"required":["__@species","__@toStringTag","byteLength"]},"Blob":{"type":"object","properties":{"size":{"type":"number"},"type":{"type":"string"}},"additionalProperties":false,"required":["size","type"]},"FormData":{"type":"object","additionalProperties":false},"URLSearchParams":{"type":"object","additionalProperties":false},"ReadableStream":{"type":"object","properties":{"locked":{"type":"boolean"}},"additionalProperties":false,"required":["locked"]},"Headers":{"type":"object","additionalProperties":false},"Record":{"type":"object","additionalProperties":false},"AbortSignal":{"type":"object","properties":{"aborted":{"type":"boolean"},"onabort":{"anyOf":[{"type":"object","additionalProperties":false},{"type":"null"}]}},"additionalProperties":false,"required":["aborted","onabort"]},"RouteMatchCallback":{"description":"The \"match\" callback is used to determine if a `Route` should apply for a\nparticular URL and request. When matching occurs in response to a fetch\nevent from the client, the `event` object is also supplied. However, since\nthe match callback can be invoked outside of a fetch event, matching logic\nshould not assume the `event` object will always be available.\nIf the match callback returns a truthy value, the matching route's\n`RouteHandlerCallback` will be invoked immediately. If the value returned\nis a non-empty array or object, that value will be set on the handler's\n`options.params` argument.","type":"object","additionalProperties":false},"ManifestEntry":{"type":"object","properties":{"integrity":{"type":"string"},"revision":{"type":["null","string"]},"url":{"type":"string"}},"additionalProperties":false,"required":["revision","url"]}},"$schema":"http://json-schema.org/draft-07/schema#"} +{"additionalProperties":false,"type":"object","properties":{"chunks":{"type":"array","items":{"type":"string"}},"exclude":{"type":"array","items":{}},"excludeChunks":{"type":"array","items":{"type":"string"}},"include":{"type":"array","items":{}},"mode":{"default":"production","type":["null","string"]},"babelPresetEnvTargets":{"default":["chrome >= 56"],"type":"array","items":{"type":"string"}},"cacheId":{"type":["null","string"]},"cleanupOutdatedCaches":{"default":false,"type":"boolean"},"clientsClaim":{"default":false,"type":"boolean"},"directoryIndex":{"type":["null","string"]},"disableDevLogs":{"default":false,"type":"boolean"},"ignoreURLParametersMatching":{"type":"array","items":{"$ref":"#/definitions/RegExp"}},"importScripts":{"type":"array","items":{"type":"string"}},"inlineWorkboxRuntime":{"default":false,"type":"boolean"},"navigateFallback":{"default":null,"type":["null","string"]},"navigateFallbackAllowlist":{"type":"array","items":{"$ref":"#/definitions/RegExp"}},"navigateFallbackDenylist":{"type":"array","items":{"$ref":"#/definitions/RegExp"}},"navigationPreload":{"default":false,"type":"boolean"},"offlineGoogleAnalytics":{"default":false,"anyOf":[{"$ref":"#/definitions/GoogleAnalyticsInitializeOptions"},{"type":"boolean"}]},"runtimeCaching":{"type":"array","items":{"$ref":"#/definitions/RuntimeCaching"}},"skipWaiting":{"default":false,"type":"boolean"},"sourcemap":{"default":true,"type":"boolean"},"additionalManifestEntries":{"type":"array","items":{"anyOf":[{"$ref":"#/definitions/ManifestEntry"},{"type":"string"}]}},"dontCacheBustURLsMatching":{"$ref":"#/definitions/RegExp"},"manifestTransforms":{"type":"array","items":{"type":"object","additionalProperties":false}},"maximumFileSizeToCacheInBytes":{"default":2097152,"type":"number"},"modifyURLPrefix":{"type":"object","additionalProperties":{"type":"string"}},"swDest":{"default":"service-worker.js","type":"string"},"importScriptsViaChunks":{"type":"array","items":{"type":"string"}}},"definitions":{"RegExp":{"type":"object","properties":{"source":{"type":"string"},"global":{"type":"boolean"},"ignoreCase":{"type":"boolean"},"multiline":{"type":"boolean"},"lastIndex":{"type":"number"},"flags":{"type":"string"},"sticky":{"type":"boolean"},"unicode":{"type":"boolean"},"dotAll":{"type":"boolean"}},"additionalProperties":false,"required":["dotAll","flags","global","ignoreCase","lastIndex","multiline","source","sticky","unicode"]},"GoogleAnalyticsInitializeOptions":{"type":"object","properties":{"cacheName":{"type":"string"},"parameterOverrides":{"type":"object","additionalProperties":{"type":"string"}},"hitFilter":{"type":"object","additionalProperties":false}},"additionalProperties":false},"RuntimeCaching":{"type":"object","properties":{"handler":{"anyOf":[{"$ref":"#/definitions/RouteHandlerCallback"},{"$ref":"#/definitions/RouteHandlerObject"},{"enum":["CacheFirst","CacheOnly","NetworkFirst","NetworkOnly","StaleWhileRevalidate"],"type":"string"}]},"method":{"enum":["DELETE","GET","HEAD","PATCH","POST","PUT"],"type":"string"},"options":{"type":"object","properties":{"backgroundSync":{"type":"object","properties":{"name":{"type":"string"},"options":{"$ref":"#/definitions/QueueOptions"}},"additionalProperties":false,"required":["name"]},"broadcastUpdate":{"type":"object","properties":{"channelName":{"type":"string"},"options":{"$ref":"#/definitions/BroadcastCacheUpdateOptions"}},"additionalProperties":false,"required":["options"]},"cacheableResponse":{"$ref":"#/definitions/CacheableResponseOptions"},"cacheName":{"type":["null","string"]},"expiration":{"$ref":"#/definitions/ExpirationPluginOptions"},"networkTimeoutSeconds":{"type":"number"},"plugins":{"type":"array","items":{"$ref":"#/definitions/WorkboxPlugin"}},"precacheFallback":{"type":"object","properties":{"fallbackURL":{"type":"string"}},"additionalProperties":false,"required":["fallbackURL"]},"fetchOptions":{"$ref":"#/definitions/RequestInit"},"matchOptions":{"$ref":"#/definitions/CacheQueryOptions"}},"additionalProperties":false},"urlPattern":{"anyOf":[{"$ref":"#/definitions/RegExp"},{"$ref":"#/definitions/RouteMatchCallback"},{"type":"string"}]}},"additionalProperties":false,"required":["handler","urlPattern"]},"RouteHandlerCallback":{"description":"The \"handler\" callback is invoked whenever a `Router` matches a URL/Request\nto a `Route` via its `RouteMatchCallback`. This handler callback should\nreturn a `Promise` that resolves with a `Response`.\n\nIf a non-empty array or object is returned by the `RouteMatchCallback` it\nwill be passed in as this handler's `options.params` argument.","type":"object","additionalProperties":false},"RouteHandlerObject":{"description":"An object with a `handle` method of type `RouteHandlerCallback`.\n\nA `Route` object can be created with either an `RouteHandlerCallback`\nfunction or this `RouteHandler` object. The benefit of the `RouteHandler`\nis it can be extended (as is done by the `workbox-strategies` package).","type":"object","properties":{"handle":{"$ref":"#/definitions/RouteHandlerCallback"}},"additionalProperties":false,"required":["handle"]},"QueueOptions":{"type":"object","properties":{"onSync":{"$ref":"#/definitions/OnSyncCallback"},"maxRetentionTime":{"type":"number"}},"additionalProperties":false},"OnSyncCallback":{"type":"object","additionalProperties":false},"BroadcastCacheUpdateOptions":{"type":"object","properties":{"headersToCheck":{"type":"array","items":{"type":"string"}},"generatePayload":{"type":"object","additionalProperties":false}},"additionalProperties":false},"CacheableResponseOptions":{"type":"object","properties":{"statuses":{"type":"array","items":{"type":"number"}},"headers":{"type":"object","additionalProperties":{"type":"string"}}},"additionalProperties":false},"ExpirationPluginOptions":{"type":"object","properties":{"maxEntries":{"type":"number"},"maxAgeSeconds":{"type":"number"},"matchOptions":{"$ref":"#/definitions/CacheQueryOptions"},"purgeOnQuotaError":{"type":"boolean"}},"additionalProperties":false},"CacheQueryOptions":{"type":"object","properties":{"ignoreMethod":{"type":"boolean"},"ignoreSearch":{"type":"boolean"},"ignoreVary":{"type":"boolean"}},"additionalProperties":false},"WorkboxPlugin":{"description":"An object with optional lifecycle callback properties for the fetch and\ncache operations.","type":"object","properties":{"cacheDidUpdate":{"$ref":"#/definitions/CacheDidUpdateCallback"},"cachedResponseWillBeUsed":{"$ref":"#/definitions/CachedResponseWillBeUsedCallback"},"cacheKeyWillBeUsed":{"$ref":"#/definitions/CacheKeyWillBeUsedCallback"},"cacheWillUpdate":{"$ref":"#/definitions/CacheWillUpdateCallback"},"fetchDidFail":{"$ref":"#/definitions/FetchDidFailCallback"},"fetchDidSucceed":{"$ref":"#/definitions/FetchDidSucceedCallback"},"handlerDidComplete":{"$ref":"#/definitions/HandlerDidCompleteCallback"},"handlerDidError":{"$ref":"#/definitions/HandlerDidErrorCallback"},"handlerDidRespond":{"$ref":"#/definitions/HandlerDidRespondCallback"},"handlerWillRespond":{"$ref":"#/definitions/HandlerWillRespondCallback"},"handlerWillStart":{"$ref":"#/definitions/HandlerWillStartCallback"},"requestWillFetch":{"$ref":"#/definitions/RequestWillFetchCallback"}},"additionalProperties":false},"CacheDidUpdateCallback":{"type":"object","additionalProperties":false},"CachedResponseWillBeUsedCallback":{"type":"object","additionalProperties":false},"CacheKeyWillBeUsedCallback":{"type":"object","additionalProperties":false},"CacheWillUpdateCallback":{"type":"object","additionalProperties":false},"FetchDidFailCallback":{"type":"object","additionalProperties":false},"FetchDidSucceedCallback":{"type":"object","additionalProperties":false},"HandlerDidCompleteCallback":{"type":"object","additionalProperties":false},"HandlerDidErrorCallback":{"type":"object","additionalProperties":false},"HandlerDidRespondCallback":{"type":"object","additionalProperties":false},"HandlerWillRespondCallback":{"type":"object","additionalProperties":false},"HandlerWillStartCallback":{"type":"object","additionalProperties":false},"RequestWillFetchCallback":{"type":"object","additionalProperties":false},"RequestInit":{"type":"object","properties":{"body":{"anyOf":[{"$ref":"#/definitions/ArrayBuffer"},{"$ref":"#/definitions/ArrayBufferView"},{"$ref":"#/definitions/Blob"},{"$ref":"#/definitions/FormData"},{"$ref":"#/definitions/URLSearchParams"},{"$ref":"#/definitions/ReadableStream"},{"type":["null","string"]}]},"cache":{"enum":["default","force-cache","no-cache","no-store","only-if-cached","reload"],"type":"string"},"credentials":{"enum":["include","omit","same-origin"],"type":"string"},"headers":{"anyOf":[{"$ref":"#/definitions/Headers"},{"type":"array","items":{"type":"array","items":{"type":"string"}}},{"$ref":"#/definitions/Record"}]},"integrity":{"type":"string"},"keepalive":{"type":"boolean"},"method":{"type":"string"},"mode":{"enum":["cors","navigate","no-cors","same-origin"],"type":"string"},"redirect":{"enum":["error","follow","manual"],"type":"string"},"referrer":{"type":"string"},"referrerPolicy":{"enum":["","no-referrer","no-referrer-when-downgrade","origin","origin-when-cross-origin","same-origin","strict-origin","strict-origin-when-cross-origin","unsafe-url"],"type":"string"},"signal":{"anyOf":[{"$ref":"#/definitions/AbortSignal"},{"type":"null"}]},"window":{}},"additionalProperties":false},"ArrayBuffer":{"type":"object","properties":{"byteLength":{"type":"number"},"__@toStringTag":{"type":"string"}},"additionalProperties":false,"required":["__@toStringTag","byteLength"]},"ArrayBufferView":{"type":"object","properties":{"buffer":{"anyOf":[{"$ref":"#/definitions/ArrayBuffer"},{"$ref":"#/definitions/SharedArrayBuffer"}]},"byteLength":{"type":"number"},"byteOffset":{"type":"number"}},"additionalProperties":false,"required":["buffer","byteLength","byteOffset"]},"SharedArrayBuffer":{"type":"object","properties":{"byteLength":{"type":"number"},"__@species":{"$ref":"#/definitions/SharedArrayBuffer"},"__@toStringTag":{"type":"string","enum":["SharedArrayBuffer"]}},"additionalProperties":false,"required":["__@species","__@toStringTag","byteLength"]},"Blob":{"type":"object","properties":{"size":{"type":"number"},"type":{"type":"string"}},"additionalProperties":false,"required":["size","type"]},"FormData":{"type":"object","additionalProperties":false},"URLSearchParams":{"type":"object","additionalProperties":false},"ReadableStream":{"type":"object","properties":{"locked":{"type":"boolean"}},"additionalProperties":false,"required":["locked"]},"Headers":{"type":"object","additionalProperties":false},"Record":{"type":"object","additionalProperties":false},"AbortSignal":{"type":"object","properties":{"aborted":{"type":"boolean"},"onabort":{"anyOf":[{"type":"object","additionalProperties":false},{"type":"null"}]}},"additionalProperties":false,"required":["aborted","onabort"]},"RouteMatchCallback":{"description":"The \"match\" callback is used to determine if a `Route` should apply for a\nparticular URL and request. When matching occurs in response to a fetch\nevent from the client, the `event` object is also supplied. However, since\nthe match callback can be invoked outside of a fetch event, matching logic\nshould not assume the `event` object will always be available.\nIf the match callback returns a truthy value, the matching route's\n`RouteHandlerCallback` will be invoked immediately. If the value returned\nis a non-empty array or object, that value will be set on the handler's\n`options.params` argument.","type":"object","additionalProperties":false},"ManifestEntry":{"type":"object","properties":{"integrity":{"type":"string"},"revision":{"type":["null","string"]},"url":{"type":"string"}},"additionalProperties":false,"required":["revision","url"]}},"$schema":"http://json-schema.org/draft-07/schema#"} diff --git a/packages/workbox-build/src/schema/WebpackInjectManifestOptions.json b/packages/workbox-build/src/schema/WebpackInjectManifestOptions.json index 086807c13..a6cc46221 100644 --- a/packages/workbox-build/src/schema/WebpackInjectManifestOptions.json +++ b/packages/workbox-build/src/schema/WebpackInjectManifestOptions.json @@ -1 +1 @@ -{"additionalProperties":false,"type":"object","properties":{"chunks":{"type":"array","items":{"type":"string"}},"exclude":{"type":"array","items":{"anyOf":[{"$ref":"#/definitions/RegExp"},{"type":"object","additionalProperties":false},{"type":"string"}]}},"excludeChunks":{"type":"array","items":{"type":"string"}},"include":{"type":"array","items":{"anyOf":[{"$ref":"#/definitions/RegExp"},{"type":"object","additionalProperties":false},{"type":"string"}]}},"mode":{"type":["null","string"]},"injectionPoint":{"default":"self.__WB_MANIFEST","type":"string"},"swSrc":{"type":"string"},"additionalManifestEntries":{"type":"array","items":{"anyOf":[{"$ref":"#/definitions/ManifestEntry"},{"type":"string"}]}},"dontCacheBustURLsMatching":{"$ref":"#/definitions/RegExp"},"manifestTransforms":{"type":"array","items":{"type":"object","additionalProperties":false}},"maximumFileSizeToCacheInBytes":{"default":2097152,"type":"number"},"modifyURLPrefix":{"type":"object","additionalProperties":{"type":"string"}},"swDest":{"default":"service-worker.js","type":"string"},"compileSrc":{"default":true,"type":"boolean"},"webpackCompilationPlugins":{"type":"array","items":{}}},"required":["swSrc"],"definitions":{"RegExp":{"type":"object","properties":{"source":{"type":"string"},"global":{"type":"boolean"},"ignoreCase":{"type":"boolean"},"multiline":{"type":"boolean"},"lastIndex":{"type":"number"},"flags":{"type":"string"},"sticky":{"type":"boolean"},"unicode":{"type":"boolean"},"dotAll":{"type":"boolean"}},"additionalProperties":false,"required":["dotAll","flags","global","ignoreCase","lastIndex","multiline","source","sticky","unicode"]},"GoogleAnalyticsInitializeOptions":{"type":"object","properties":{"cacheName":{"type":"string"},"parameterOverrides":{"type":"object","additionalProperties":{"type":"string"}},"hitFilter":{"type":"object","additionalProperties":false}},"additionalProperties":false},"RuntimeCaching":{"type":"object","properties":{"handler":{"anyOf":[{"$ref":"#/definitions/RouteHandlerCallback"},{"$ref":"#/definitions/RouteHandlerObject"},{"enum":["CacheFirst","CacheOnly","NetworkFirst","NetworkOnly","StaleWhileRevalidate"],"type":"string"}]},"method":{"enum":["DELETE","GET","HEAD","PATCH","POST","PUT"],"type":"string"},"options":{"type":"object","properties":{"backgroundSync":{"type":"object","properties":{"name":{"type":"string"},"options":{"$ref":"#/definitions/QueueOptions"}},"additionalProperties":false,"required":["name"]},"broadcastUpdate":{"type":"object","properties":{"channelName":{"type":"string"},"options":{"$ref":"#/definitions/BroadcastCacheUpdateOptions"}},"additionalProperties":false,"required":["options"]},"cacheableResponse":{"$ref":"#/definitions/CacheableResponseOptions"},"cacheName":{"type":["null","string"]},"expiration":{"$ref":"#/definitions/ExpirationPluginOptions"},"networkTimeoutSeconds":{"type":"number"},"plugins":{"type":"array","items":{"$ref":"#/definitions/WorkboxPlugin"}},"precacheFallback":{"type":"object","properties":{"fallbackURL":{"type":"string"}},"additionalProperties":false,"required":["fallbackURL"]},"fetchOptions":{"$ref":"#/definitions/RequestInit"},"matchOptions":{"$ref":"#/definitions/CacheQueryOptions"}},"additionalProperties":false},"urlPattern":{"anyOf":[{"$ref":"#/definitions/RegExp"},{"$ref":"#/definitions/RouteMatchCallback"},{"type":"string"}]}},"additionalProperties":false,"required":["handler","urlPattern"]},"RouteHandlerCallback":{"description":"The \"handler\" callback is invoked whenever a `Router` matches a URL/Request\nto a `Route` via its `RouteMatchCallback`. This handler callback should\nreturn a `Promise` that resolves with a `Response`.\n\nIf a non-empty array or object is returned by the `RouteMatchCallback` it\nwill be passed in as this handler's `options.params` argument.","type":"object","additionalProperties":false},"RouteHandlerObject":{"description":"An object with a `handle` method of type `RouteHandlerCallback`.\n\nA `Route` object can be created with either an `RouteHandlerCallback`\nfunction or this `RouteHandler` object. The benefit of the `RouteHandler`\nis it can be extended (as is done by the `workbox-strategies` package).","type":"object","properties":{"handle":{"$ref":"#/definitions/RouteHandlerCallback"}},"additionalProperties":false,"required":["handle"]},"QueueOptions":{"type":"object","properties":{"onSync":{"$ref":"#/definitions/OnSyncCallback"},"maxRetentionTime":{"type":"number"}},"additionalProperties":false},"OnSyncCallback":{"type":"object","additionalProperties":false},"BroadcastCacheUpdateOptions":{"type":"object","properties":{"headersToCheck":{"type":"array","items":{"type":"string"}},"generatePayload":{"type":"object","additionalProperties":false}},"additionalProperties":false},"CacheableResponseOptions":{"type":"object","properties":{"statuses":{"type":"array","items":{"type":"number"}},"headers":{"type":"object","additionalProperties":{"type":"string"}}},"additionalProperties":false},"ExpirationPluginOptions":{"type":"object","properties":{"maxEntries":{"type":"number"},"maxAgeSeconds":{"type":"number"},"matchOptions":{"$ref":"#/definitions/CacheQueryOptions"},"purgeOnQuotaError":{"type":"boolean"}},"additionalProperties":false},"CacheQueryOptions":{"type":"object","properties":{"ignoreMethod":{"type":"boolean"},"ignoreSearch":{"type":"boolean"},"ignoreVary":{"type":"boolean"}},"additionalProperties":false},"WorkboxPlugin":{"description":"An object with optional lifecycle callback properties for the fetch and\ncache operations.","type":"object","properties":{"cacheDidUpdate":{"$ref":"#/definitions/CacheDidUpdateCallback"},"cachedResponseWillBeUsed":{"$ref":"#/definitions/CachedResponseWillBeUsedCallback"},"cacheKeyWillBeUsed":{"$ref":"#/definitions/CacheKeyWillBeUsedCallback"},"cacheWillUpdate":{"$ref":"#/definitions/CacheWillUpdateCallback"},"fetchDidFail":{"$ref":"#/definitions/FetchDidFailCallback"},"fetchDidSucceed":{"$ref":"#/definitions/FetchDidSucceedCallback"},"handlerDidComplete":{"$ref":"#/definitions/HandlerDidCompleteCallback"},"handlerDidError":{"$ref":"#/definitions/HandlerDidErrorCallback"},"handlerDidRespond":{"$ref":"#/definitions/HandlerDidRespondCallback"},"handlerWillRespond":{"$ref":"#/definitions/HandlerWillRespondCallback"},"handlerWillStart":{"$ref":"#/definitions/HandlerWillStartCallback"},"requestWillFetch":{"$ref":"#/definitions/RequestWillFetchCallback"}},"additionalProperties":false},"CacheDidUpdateCallback":{"type":"object","additionalProperties":false},"CachedResponseWillBeUsedCallback":{"type":"object","additionalProperties":false},"CacheKeyWillBeUsedCallback":{"type":"object","additionalProperties":false},"CacheWillUpdateCallback":{"type":"object","additionalProperties":false},"FetchDidFailCallback":{"type":"object","additionalProperties":false},"FetchDidSucceedCallback":{"type":"object","additionalProperties":false},"HandlerDidCompleteCallback":{"type":"object","additionalProperties":false},"HandlerDidErrorCallback":{"type":"object","additionalProperties":false},"HandlerDidRespondCallback":{"type":"object","additionalProperties":false},"HandlerWillRespondCallback":{"type":"object","additionalProperties":false},"HandlerWillStartCallback":{"type":"object","additionalProperties":false},"RequestWillFetchCallback":{"type":"object","additionalProperties":false},"RequestInit":{"type":"object","properties":{"body":{"anyOf":[{"$ref":"#/definitions/ArrayBuffer"},{"$ref":"#/definitions/ArrayBufferView"},{"$ref":"#/definitions/Blob"},{"$ref":"#/definitions/FormData"},{"$ref":"#/definitions/URLSearchParams"},{"$ref":"#/definitions/ReadableStream"},{"type":["null","string"]}]},"cache":{"enum":["default","force-cache","no-cache","no-store","only-if-cached","reload"],"type":"string"},"credentials":{"enum":["include","omit","same-origin"],"type":"string"},"headers":{"anyOf":[{"$ref":"#/definitions/Headers"},{"type":"array","items":{"type":"array","items":{"type":"string"}}},{"$ref":"#/definitions/Record"}]},"integrity":{"type":"string"},"keepalive":{"type":"boolean"},"method":{"type":"string"},"mode":{"enum":["cors","navigate","no-cors","same-origin"],"type":"string"},"redirect":{"enum":["error","follow","manual"],"type":"string"},"referrer":{"type":"string"},"referrerPolicy":{"enum":["","no-referrer","no-referrer-when-downgrade","origin","origin-when-cross-origin","same-origin","strict-origin","strict-origin-when-cross-origin","unsafe-url"],"type":"string"},"signal":{"anyOf":[{"$ref":"#/definitions/AbortSignal"},{"type":"null"}]},"window":{}},"additionalProperties":false},"ArrayBuffer":{"type":"object","properties":{"byteLength":{"type":"number"},"__@toStringTag":{"type":"string"}},"additionalProperties":false,"required":["__@toStringTag","byteLength"]},"ArrayBufferView":{"type":"object","properties":{"buffer":{"anyOf":[{"$ref":"#/definitions/ArrayBuffer"},{"$ref":"#/definitions/SharedArrayBuffer"}]},"byteLength":{"type":"number"},"byteOffset":{"type":"number"}},"additionalProperties":false,"required":["buffer","byteLength","byteOffset"]},"SharedArrayBuffer":{"type":"object","properties":{"byteLength":{"type":"number"},"__@species":{"$ref":"#/definitions/SharedArrayBuffer"},"__@toStringTag":{"type":"string","enum":["SharedArrayBuffer"]}},"additionalProperties":false,"required":["__@species","__@toStringTag","byteLength"]},"Blob":{"type":"object","properties":{"size":{"type":"number"},"type":{"type":"string"}},"additionalProperties":false,"required":["size","type"]},"FormData":{"type":"object","additionalProperties":false},"URLSearchParams":{"type":"object","additionalProperties":false},"ReadableStream":{"type":"object","properties":{"locked":{"type":"boolean"}},"additionalProperties":false,"required":["locked"]},"Headers":{"type":"object","additionalProperties":false},"Record":{"type":"object","additionalProperties":false},"AbortSignal":{"type":"object","properties":{"aborted":{"type":"boolean"},"onabort":{"anyOf":[{"type":"object","additionalProperties":false},{"type":"null"}]}},"additionalProperties":false,"required":["aborted","onabort"]},"RouteMatchCallback":{"description":"The \"match\" callback is used to determine if a `Route` should apply for a\nparticular URL and request. When matching occurs in response to a fetch\nevent from the client, the `event` object is also supplied. However, since\nthe match callback can be invoked outside of a fetch event, matching logic\nshould not assume the `event` object will always be available.\nIf the match callback returns a truthy value, the matching route's\n`RouteHandlerCallback` will be invoked immediately. If the value returned\nis a non-empty array or object, that value will be set on the handler's\n`options.params` argument.","type":"object","additionalProperties":false},"ManifestEntry":{"type":"object","properties":{"integrity":{"type":"string"},"revision":{"type":["null","string"]},"url":{"type":"string"}},"additionalProperties":false,"required":["revision","url"]}},"$schema":"http://json-schema.org/draft-07/schema#"} +{"additionalProperties":false,"type":"object","properties":{"chunks":{"type":"array","items":{"type":"string"}},"exclude":{"type":"array","items":{}},"excludeChunks":{"type":"array","items":{"type":"string"}},"include":{"type":"array","items":{}},"mode":{"type":["null","string"]},"injectionPoint":{"default":"self.__WB_MANIFEST","type":"string"},"swSrc":{"type":"string"},"additionalManifestEntries":{"type":"array","items":{"anyOf":[{"$ref":"#/definitions/ManifestEntry"},{"type":"string"}]}},"dontCacheBustURLsMatching":{"$ref":"#/definitions/RegExp"},"manifestTransforms":{"type":"array","items":{"type":"object","additionalProperties":false}},"maximumFileSizeToCacheInBytes":{"default":2097152,"type":"number"},"modifyURLPrefix":{"type":"object","additionalProperties":{"type":"string"}},"swDest":{"default":"service-worker.js","type":"string"},"compileSrc":{"default":true,"type":"boolean"},"webpackCompilationPlugins":{"type":"array","items":{}}},"required":["swSrc"],"definitions":{"RegExp":{"type":"object","properties":{"source":{"type":"string"},"global":{"type":"boolean"},"ignoreCase":{"type":"boolean"},"multiline":{"type":"boolean"},"lastIndex":{"type":"number"},"flags":{"type":"string"},"sticky":{"type":"boolean"},"unicode":{"type":"boolean"},"dotAll":{"type":"boolean"}},"additionalProperties":false,"required":["dotAll","flags","global","ignoreCase","lastIndex","multiline","source","sticky","unicode"]},"GoogleAnalyticsInitializeOptions":{"type":"object","properties":{"cacheName":{"type":"string"},"parameterOverrides":{"type":"object","additionalProperties":{"type":"string"}},"hitFilter":{"type":"object","additionalProperties":false}},"additionalProperties":false},"RuntimeCaching":{"type":"object","properties":{"handler":{"anyOf":[{"$ref":"#/definitions/RouteHandlerCallback"},{"$ref":"#/definitions/RouteHandlerObject"},{"enum":["CacheFirst","CacheOnly","NetworkFirst","NetworkOnly","StaleWhileRevalidate"],"type":"string"}]},"method":{"enum":["DELETE","GET","HEAD","PATCH","POST","PUT"],"type":"string"},"options":{"type":"object","properties":{"backgroundSync":{"type":"object","properties":{"name":{"type":"string"},"options":{"$ref":"#/definitions/QueueOptions"}},"additionalProperties":false,"required":["name"]},"broadcastUpdate":{"type":"object","properties":{"channelName":{"type":"string"},"options":{"$ref":"#/definitions/BroadcastCacheUpdateOptions"}},"additionalProperties":false,"required":["options"]},"cacheableResponse":{"$ref":"#/definitions/CacheableResponseOptions"},"cacheName":{"type":["null","string"]},"expiration":{"$ref":"#/definitions/ExpirationPluginOptions"},"networkTimeoutSeconds":{"type":"number"},"plugins":{"type":"array","items":{"$ref":"#/definitions/WorkboxPlugin"}},"precacheFallback":{"type":"object","properties":{"fallbackURL":{"type":"string"}},"additionalProperties":false,"required":["fallbackURL"]},"fetchOptions":{"$ref":"#/definitions/RequestInit"},"matchOptions":{"$ref":"#/definitions/CacheQueryOptions"}},"additionalProperties":false},"urlPattern":{"anyOf":[{"$ref":"#/definitions/RegExp"},{"$ref":"#/definitions/RouteMatchCallback"},{"type":"string"}]}},"additionalProperties":false,"required":["handler","urlPattern"]},"RouteHandlerCallback":{"description":"The \"handler\" callback is invoked whenever a `Router` matches a URL/Request\nto a `Route` via its `RouteMatchCallback`. This handler callback should\nreturn a `Promise` that resolves with a `Response`.\n\nIf a non-empty array or object is returned by the `RouteMatchCallback` it\nwill be passed in as this handler's `options.params` argument.","type":"object","additionalProperties":false},"RouteHandlerObject":{"description":"An object with a `handle` method of type `RouteHandlerCallback`.\n\nA `Route` object can be created with either an `RouteHandlerCallback`\nfunction or this `RouteHandler` object. The benefit of the `RouteHandler`\nis it can be extended (as is done by the `workbox-strategies` package).","type":"object","properties":{"handle":{"$ref":"#/definitions/RouteHandlerCallback"}},"additionalProperties":false,"required":["handle"]},"QueueOptions":{"type":"object","properties":{"onSync":{"$ref":"#/definitions/OnSyncCallback"},"maxRetentionTime":{"type":"number"}},"additionalProperties":false},"OnSyncCallback":{"type":"object","additionalProperties":false},"BroadcastCacheUpdateOptions":{"type":"object","properties":{"headersToCheck":{"type":"array","items":{"type":"string"}},"generatePayload":{"type":"object","additionalProperties":false}},"additionalProperties":false},"CacheableResponseOptions":{"type":"object","properties":{"statuses":{"type":"array","items":{"type":"number"}},"headers":{"type":"object","additionalProperties":{"type":"string"}}},"additionalProperties":false},"ExpirationPluginOptions":{"type":"object","properties":{"maxEntries":{"type":"number"},"maxAgeSeconds":{"type":"number"},"matchOptions":{"$ref":"#/definitions/CacheQueryOptions"},"purgeOnQuotaError":{"type":"boolean"}},"additionalProperties":false},"CacheQueryOptions":{"type":"object","properties":{"ignoreMethod":{"type":"boolean"},"ignoreSearch":{"type":"boolean"},"ignoreVary":{"type":"boolean"}},"additionalProperties":false},"WorkboxPlugin":{"description":"An object with optional lifecycle callback properties for the fetch and\ncache operations.","type":"object","properties":{"cacheDidUpdate":{"$ref":"#/definitions/CacheDidUpdateCallback"},"cachedResponseWillBeUsed":{"$ref":"#/definitions/CachedResponseWillBeUsedCallback"},"cacheKeyWillBeUsed":{"$ref":"#/definitions/CacheKeyWillBeUsedCallback"},"cacheWillUpdate":{"$ref":"#/definitions/CacheWillUpdateCallback"},"fetchDidFail":{"$ref":"#/definitions/FetchDidFailCallback"},"fetchDidSucceed":{"$ref":"#/definitions/FetchDidSucceedCallback"},"handlerDidComplete":{"$ref":"#/definitions/HandlerDidCompleteCallback"},"handlerDidError":{"$ref":"#/definitions/HandlerDidErrorCallback"},"handlerDidRespond":{"$ref":"#/definitions/HandlerDidRespondCallback"},"handlerWillRespond":{"$ref":"#/definitions/HandlerWillRespondCallback"},"handlerWillStart":{"$ref":"#/definitions/HandlerWillStartCallback"},"requestWillFetch":{"$ref":"#/definitions/RequestWillFetchCallback"}},"additionalProperties":false},"CacheDidUpdateCallback":{"type":"object","additionalProperties":false},"CachedResponseWillBeUsedCallback":{"type":"object","additionalProperties":false},"CacheKeyWillBeUsedCallback":{"type":"object","additionalProperties":false},"CacheWillUpdateCallback":{"type":"object","additionalProperties":false},"FetchDidFailCallback":{"type":"object","additionalProperties":false},"FetchDidSucceedCallback":{"type":"object","additionalProperties":false},"HandlerDidCompleteCallback":{"type":"object","additionalProperties":false},"HandlerDidErrorCallback":{"type":"object","additionalProperties":false},"HandlerDidRespondCallback":{"type":"object","additionalProperties":false},"HandlerWillRespondCallback":{"type":"object","additionalProperties":false},"HandlerWillStartCallback":{"type":"object","additionalProperties":false},"RequestWillFetchCallback":{"type":"object","additionalProperties":false},"RequestInit":{"type":"object","properties":{"body":{"anyOf":[{"$ref":"#/definitions/ArrayBuffer"},{"$ref":"#/definitions/ArrayBufferView"},{"$ref":"#/definitions/Blob"},{"$ref":"#/definitions/FormData"},{"$ref":"#/definitions/URLSearchParams"},{"$ref":"#/definitions/ReadableStream"},{"type":["null","string"]}]},"cache":{"enum":["default","force-cache","no-cache","no-store","only-if-cached","reload"],"type":"string"},"credentials":{"enum":["include","omit","same-origin"],"type":"string"},"headers":{"anyOf":[{"$ref":"#/definitions/Headers"},{"type":"array","items":{"type":"array","items":{"type":"string"}}},{"$ref":"#/definitions/Record"}]},"integrity":{"type":"string"},"keepalive":{"type":"boolean"},"method":{"type":"string"},"mode":{"enum":["cors","navigate","no-cors","same-origin"],"type":"string"},"redirect":{"enum":["error","follow","manual"],"type":"string"},"referrer":{"type":"string"},"referrerPolicy":{"enum":["","no-referrer","no-referrer-when-downgrade","origin","origin-when-cross-origin","same-origin","strict-origin","strict-origin-when-cross-origin","unsafe-url"],"type":"string"},"signal":{"anyOf":[{"$ref":"#/definitions/AbortSignal"},{"type":"null"}]},"window":{}},"additionalProperties":false},"ArrayBuffer":{"type":"object","properties":{"byteLength":{"type":"number"},"__@toStringTag":{"type":"string"}},"additionalProperties":false,"required":["__@toStringTag","byteLength"]},"ArrayBufferView":{"type":"object","properties":{"buffer":{"anyOf":[{"$ref":"#/definitions/ArrayBuffer"},{"$ref":"#/definitions/SharedArrayBuffer"}]},"byteLength":{"type":"number"},"byteOffset":{"type":"number"}},"additionalProperties":false,"required":["buffer","byteLength","byteOffset"]},"SharedArrayBuffer":{"type":"object","properties":{"byteLength":{"type":"number"},"__@species":{"$ref":"#/definitions/SharedArrayBuffer"},"__@toStringTag":{"type":"string","enum":["SharedArrayBuffer"]}},"additionalProperties":false,"required":["__@species","__@toStringTag","byteLength"]},"Blob":{"type":"object","properties":{"size":{"type":"number"},"type":{"type":"string"}},"additionalProperties":false,"required":["size","type"]},"FormData":{"type":"object","additionalProperties":false},"URLSearchParams":{"type":"object","additionalProperties":false},"ReadableStream":{"type":"object","properties":{"locked":{"type":"boolean"}},"additionalProperties":false,"required":["locked"]},"Headers":{"type":"object","additionalProperties":false},"Record":{"type":"object","additionalProperties":false},"AbortSignal":{"type":"object","properties":{"aborted":{"type":"boolean"},"onabort":{"anyOf":[{"type":"object","additionalProperties":false},{"type":"null"}]}},"additionalProperties":false,"required":["aborted","onabort"]},"RouteMatchCallback":{"description":"The \"match\" callback is used to determine if a `Route` should apply for a\nparticular URL and request. When matching occurs in response to a fetch\nevent from the client, the `event` object is also supplied. However, since\nthe match callback can be invoked outside of a fetch event, matching logic\nshould not assume the `event` object will always be available.\nIf the match callback returns a truthy value, the matching route's\n`RouteHandlerCallback` will be invoked immediately. If the value returned\nis a non-empty array or object, that value will be set on the handler's\n`options.params` argument.","type":"object","additionalProperties":false},"ManifestEntry":{"type":"object","properties":{"integrity":{"type":"string"},"revision":{"type":["null","string"]},"url":{"type":"string"}},"additionalProperties":false,"required":["revision","url"]}},"$schema":"http://json-schema.org/draft-07/schema#"} diff --git a/packages/workbox-build/src/types.ts b/packages/workbox-build/src/types.ts index c4b52b43a..eac26f507 100644 --- a/packages/workbox-build/src/types.ts +++ b/packages/workbox-build/src/types.ts @@ -159,9 +159,11 @@ interface WebpackPartial { // an Array can't be serialized into JSON. // The default value of [/\.map$/, /^manifest.*\.js$/] will be assigned by // the validation function, and we need to reflect that in the docs. - exclude?: Array any)>; + // This and include should probably be typed to `string | RegExp | Function` + // instead of `any`, but that also causes validation problems. + exclude?: Array; excludeChunks?: Array; - include?: Array any)>; + include?: Array; mode?: string | null; } @@ -193,6 +195,9 @@ export type WebpackInjectManifestOptions = WebpackPartial & InjectPartial & Base * @default true */ compileSrc?: boolean; + // This can only be set if compileSrc is true, but that restriction can't be + // represented in TypeScript. It's enforced via custom runtime validation + // logic and needs to be documented. webpackCompilationPlugins?: Array; }; diff --git a/packages/workbox-webpack-plugin/src/inject-manifest.js b/packages/workbox-webpack-plugin/src/inject-manifest.js index d6dbd919b..e984e3fd5 100644 --- a/packages/workbox-webpack-plugin/src/inject-manifest.js +++ b/packages/workbox-webpack-plugin/src/inject-manifest.js @@ -262,6 +262,13 @@ class InjectManifest { await this.performChildCompilation(compilation, parentCompiler); } else { this.addSrcToAssets(compilation, parentCompiler); + // This used to be a fatal error, but just warn at runtime because we + // can't validate it easily. + if (Array.isArray(this.config.webpackCompilationPlugins) && + this.config.webpackCompilationPlugins.length > 0) { + compilation.warnings.push(new Error('compileSrc is false, so the ' + + 'webpackCompilationPlugins option will be ignored.')); + } } } diff --git a/test/workbox-webpack-plugin/node/v4/inject-manifest.js b/test/workbox-webpack-plugin/node/v4/inject-manifest.js index bc58c7c7e..5573500a7 100644 --- a/test/workbox-webpack-plugin/node/v4/inject-manifest.js +++ b/test/workbox-webpack-plugin/node/v4/inject-manifest.js @@ -1663,7 +1663,7 @@ describe(`[workbox-webpack-plugin] InjectManifest with webpack v4`, function() { }); describe(`[workbox-webpack-plugin] Non-compilation scenarios`, function() { - it(`should error when compileSrc is false and webpackCompilationPlugins is used`, function(done) { + it(`should warn when compileSrc is false and webpackCompilationPlugins is used`, function(done) { const outputDir = tempy.directory(); const config = { @@ -1688,11 +1688,10 @@ describe(`[workbox-webpack-plugin] InjectManifest with webpack v4`, function() { try { expect(webpackError).not.to.exist; const statsJson = stats.toJson(); - expect(statsJson.warnings).to.be.empty; - expect(statsJson.errors).to.have.members([ - `Please check your InjectManifest plugin configuration:\n"webpackCompilationPlugins" is not allowed`, + expect(statsJson.errors).to.be.empty; + expect(statsJson.warnings).to.have.members([ + 'compileSrc is false, so the webpackCompilationPlugins option will be ignored.', ]); - done(); } catch (error) { done(error); From afdae9f38ae64395adc547583580ea211ba7b1df Mon Sep 17 00:00:00 2001 From: Jeff Posnick Date: Wed, 9 Jun 2021 21:53:00 -0400 Subject: [PATCH 46/80] swDest default fix --- .../src/schema/WebpackGenerateSWOptions.json | 2 +- .../schema/WebpackInjectManifestOptions.json | 2 +- packages/workbox-build/src/types.ts | 18 +++++++++--------- .../src/inject-manifest.js | 2 ++ 4 files changed, 13 insertions(+), 11 deletions(-) diff --git a/packages/workbox-build/src/schema/WebpackGenerateSWOptions.json b/packages/workbox-build/src/schema/WebpackGenerateSWOptions.json index 75dbdbedd..56ef691ce 100644 --- a/packages/workbox-build/src/schema/WebpackGenerateSWOptions.json +++ b/packages/workbox-build/src/schema/WebpackGenerateSWOptions.json @@ -1 +1 @@ -{"additionalProperties":false,"type":"object","properties":{"chunks":{"type":"array","items":{"type":"string"}},"exclude":{"type":"array","items":{}},"excludeChunks":{"type":"array","items":{"type":"string"}},"include":{"type":"array","items":{}},"mode":{"default":"production","type":["null","string"]},"babelPresetEnvTargets":{"default":["chrome >= 56"],"type":"array","items":{"type":"string"}},"cacheId":{"type":["null","string"]},"cleanupOutdatedCaches":{"default":false,"type":"boolean"},"clientsClaim":{"default":false,"type":"boolean"},"directoryIndex":{"type":["null","string"]},"disableDevLogs":{"default":false,"type":"boolean"},"ignoreURLParametersMatching":{"type":"array","items":{"$ref":"#/definitions/RegExp"}},"importScripts":{"type":"array","items":{"type":"string"}},"inlineWorkboxRuntime":{"default":false,"type":"boolean"},"navigateFallback":{"default":null,"type":["null","string"]},"navigateFallbackAllowlist":{"type":"array","items":{"$ref":"#/definitions/RegExp"}},"navigateFallbackDenylist":{"type":"array","items":{"$ref":"#/definitions/RegExp"}},"navigationPreload":{"default":false,"type":"boolean"},"offlineGoogleAnalytics":{"default":false,"anyOf":[{"$ref":"#/definitions/GoogleAnalyticsInitializeOptions"},{"type":"boolean"}]},"runtimeCaching":{"type":"array","items":{"$ref":"#/definitions/RuntimeCaching"}},"skipWaiting":{"default":false,"type":"boolean"},"sourcemap":{"default":true,"type":"boolean"},"additionalManifestEntries":{"type":"array","items":{"anyOf":[{"$ref":"#/definitions/ManifestEntry"},{"type":"string"}]}},"dontCacheBustURLsMatching":{"$ref":"#/definitions/RegExp"},"manifestTransforms":{"type":"array","items":{"type":"object","additionalProperties":false}},"maximumFileSizeToCacheInBytes":{"default":2097152,"type":"number"},"modifyURLPrefix":{"type":"object","additionalProperties":{"type":"string"}},"swDest":{"default":"service-worker.js","type":"string"},"importScriptsViaChunks":{"type":"array","items":{"type":"string"}}},"definitions":{"RegExp":{"type":"object","properties":{"source":{"type":"string"},"global":{"type":"boolean"},"ignoreCase":{"type":"boolean"},"multiline":{"type":"boolean"},"lastIndex":{"type":"number"},"flags":{"type":"string"},"sticky":{"type":"boolean"},"unicode":{"type":"boolean"},"dotAll":{"type":"boolean"}},"additionalProperties":false,"required":["dotAll","flags","global","ignoreCase","lastIndex","multiline","source","sticky","unicode"]},"GoogleAnalyticsInitializeOptions":{"type":"object","properties":{"cacheName":{"type":"string"},"parameterOverrides":{"type":"object","additionalProperties":{"type":"string"}},"hitFilter":{"type":"object","additionalProperties":false}},"additionalProperties":false},"RuntimeCaching":{"type":"object","properties":{"handler":{"anyOf":[{"$ref":"#/definitions/RouteHandlerCallback"},{"$ref":"#/definitions/RouteHandlerObject"},{"enum":["CacheFirst","CacheOnly","NetworkFirst","NetworkOnly","StaleWhileRevalidate"],"type":"string"}]},"method":{"enum":["DELETE","GET","HEAD","PATCH","POST","PUT"],"type":"string"},"options":{"type":"object","properties":{"backgroundSync":{"type":"object","properties":{"name":{"type":"string"},"options":{"$ref":"#/definitions/QueueOptions"}},"additionalProperties":false,"required":["name"]},"broadcastUpdate":{"type":"object","properties":{"channelName":{"type":"string"},"options":{"$ref":"#/definitions/BroadcastCacheUpdateOptions"}},"additionalProperties":false,"required":["options"]},"cacheableResponse":{"$ref":"#/definitions/CacheableResponseOptions"},"cacheName":{"type":["null","string"]},"expiration":{"$ref":"#/definitions/ExpirationPluginOptions"},"networkTimeoutSeconds":{"type":"number"},"plugins":{"type":"array","items":{"$ref":"#/definitions/WorkboxPlugin"}},"precacheFallback":{"type":"object","properties":{"fallbackURL":{"type":"string"}},"additionalProperties":false,"required":["fallbackURL"]},"fetchOptions":{"$ref":"#/definitions/RequestInit"},"matchOptions":{"$ref":"#/definitions/CacheQueryOptions"}},"additionalProperties":false},"urlPattern":{"anyOf":[{"$ref":"#/definitions/RegExp"},{"$ref":"#/definitions/RouteMatchCallback"},{"type":"string"}]}},"additionalProperties":false,"required":["handler","urlPattern"]},"RouteHandlerCallback":{"description":"The \"handler\" callback is invoked whenever a `Router` matches a URL/Request\nto a `Route` via its `RouteMatchCallback`. This handler callback should\nreturn a `Promise` that resolves with a `Response`.\n\nIf a non-empty array or object is returned by the `RouteMatchCallback` it\nwill be passed in as this handler's `options.params` argument.","type":"object","additionalProperties":false},"RouteHandlerObject":{"description":"An object with a `handle` method of type `RouteHandlerCallback`.\n\nA `Route` object can be created with either an `RouteHandlerCallback`\nfunction or this `RouteHandler` object. The benefit of the `RouteHandler`\nis it can be extended (as is done by the `workbox-strategies` package).","type":"object","properties":{"handle":{"$ref":"#/definitions/RouteHandlerCallback"}},"additionalProperties":false,"required":["handle"]},"QueueOptions":{"type":"object","properties":{"onSync":{"$ref":"#/definitions/OnSyncCallback"},"maxRetentionTime":{"type":"number"}},"additionalProperties":false},"OnSyncCallback":{"type":"object","additionalProperties":false},"BroadcastCacheUpdateOptions":{"type":"object","properties":{"headersToCheck":{"type":"array","items":{"type":"string"}},"generatePayload":{"type":"object","additionalProperties":false}},"additionalProperties":false},"CacheableResponseOptions":{"type":"object","properties":{"statuses":{"type":"array","items":{"type":"number"}},"headers":{"type":"object","additionalProperties":{"type":"string"}}},"additionalProperties":false},"ExpirationPluginOptions":{"type":"object","properties":{"maxEntries":{"type":"number"},"maxAgeSeconds":{"type":"number"},"matchOptions":{"$ref":"#/definitions/CacheQueryOptions"},"purgeOnQuotaError":{"type":"boolean"}},"additionalProperties":false},"CacheQueryOptions":{"type":"object","properties":{"ignoreMethod":{"type":"boolean"},"ignoreSearch":{"type":"boolean"},"ignoreVary":{"type":"boolean"}},"additionalProperties":false},"WorkboxPlugin":{"description":"An object with optional lifecycle callback properties for the fetch and\ncache operations.","type":"object","properties":{"cacheDidUpdate":{"$ref":"#/definitions/CacheDidUpdateCallback"},"cachedResponseWillBeUsed":{"$ref":"#/definitions/CachedResponseWillBeUsedCallback"},"cacheKeyWillBeUsed":{"$ref":"#/definitions/CacheKeyWillBeUsedCallback"},"cacheWillUpdate":{"$ref":"#/definitions/CacheWillUpdateCallback"},"fetchDidFail":{"$ref":"#/definitions/FetchDidFailCallback"},"fetchDidSucceed":{"$ref":"#/definitions/FetchDidSucceedCallback"},"handlerDidComplete":{"$ref":"#/definitions/HandlerDidCompleteCallback"},"handlerDidError":{"$ref":"#/definitions/HandlerDidErrorCallback"},"handlerDidRespond":{"$ref":"#/definitions/HandlerDidRespondCallback"},"handlerWillRespond":{"$ref":"#/definitions/HandlerWillRespondCallback"},"handlerWillStart":{"$ref":"#/definitions/HandlerWillStartCallback"},"requestWillFetch":{"$ref":"#/definitions/RequestWillFetchCallback"}},"additionalProperties":false},"CacheDidUpdateCallback":{"type":"object","additionalProperties":false},"CachedResponseWillBeUsedCallback":{"type":"object","additionalProperties":false},"CacheKeyWillBeUsedCallback":{"type":"object","additionalProperties":false},"CacheWillUpdateCallback":{"type":"object","additionalProperties":false},"FetchDidFailCallback":{"type":"object","additionalProperties":false},"FetchDidSucceedCallback":{"type":"object","additionalProperties":false},"HandlerDidCompleteCallback":{"type":"object","additionalProperties":false},"HandlerDidErrorCallback":{"type":"object","additionalProperties":false},"HandlerDidRespondCallback":{"type":"object","additionalProperties":false},"HandlerWillRespondCallback":{"type":"object","additionalProperties":false},"HandlerWillStartCallback":{"type":"object","additionalProperties":false},"RequestWillFetchCallback":{"type":"object","additionalProperties":false},"RequestInit":{"type":"object","properties":{"body":{"anyOf":[{"$ref":"#/definitions/ArrayBuffer"},{"$ref":"#/definitions/ArrayBufferView"},{"$ref":"#/definitions/Blob"},{"$ref":"#/definitions/FormData"},{"$ref":"#/definitions/URLSearchParams"},{"$ref":"#/definitions/ReadableStream"},{"type":["null","string"]}]},"cache":{"enum":["default","force-cache","no-cache","no-store","only-if-cached","reload"],"type":"string"},"credentials":{"enum":["include","omit","same-origin"],"type":"string"},"headers":{"anyOf":[{"$ref":"#/definitions/Headers"},{"type":"array","items":{"type":"array","items":{"type":"string"}}},{"$ref":"#/definitions/Record"}]},"integrity":{"type":"string"},"keepalive":{"type":"boolean"},"method":{"type":"string"},"mode":{"enum":["cors","navigate","no-cors","same-origin"],"type":"string"},"redirect":{"enum":["error","follow","manual"],"type":"string"},"referrer":{"type":"string"},"referrerPolicy":{"enum":["","no-referrer","no-referrer-when-downgrade","origin","origin-when-cross-origin","same-origin","strict-origin","strict-origin-when-cross-origin","unsafe-url"],"type":"string"},"signal":{"anyOf":[{"$ref":"#/definitions/AbortSignal"},{"type":"null"}]},"window":{}},"additionalProperties":false},"ArrayBuffer":{"type":"object","properties":{"byteLength":{"type":"number"},"__@toStringTag":{"type":"string"}},"additionalProperties":false,"required":["__@toStringTag","byteLength"]},"ArrayBufferView":{"type":"object","properties":{"buffer":{"anyOf":[{"$ref":"#/definitions/ArrayBuffer"},{"$ref":"#/definitions/SharedArrayBuffer"}]},"byteLength":{"type":"number"},"byteOffset":{"type":"number"}},"additionalProperties":false,"required":["buffer","byteLength","byteOffset"]},"SharedArrayBuffer":{"type":"object","properties":{"byteLength":{"type":"number"},"__@species":{"$ref":"#/definitions/SharedArrayBuffer"},"__@toStringTag":{"type":"string","enum":["SharedArrayBuffer"]}},"additionalProperties":false,"required":["__@species","__@toStringTag","byteLength"]},"Blob":{"type":"object","properties":{"size":{"type":"number"},"type":{"type":"string"}},"additionalProperties":false,"required":["size","type"]},"FormData":{"type":"object","additionalProperties":false},"URLSearchParams":{"type":"object","additionalProperties":false},"ReadableStream":{"type":"object","properties":{"locked":{"type":"boolean"}},"additionalProperties":false,"required":["locked"]},"Headers":{"type":"object","additionalProperties":false},"Record":{"type":"object","additionalProperties":false},"AbortSignal":{"type":"object","properties":{"aborted":{"type":"boolean"},"onabort":{"anyOf":[{"type":"object","additionalProperties":false},{"type":"null"}]}},"additionalProperties":false,"required":["aborted","onabort"]},"RouteMatchCallback":{"description":"The \"match\" callback is used to determine if a `Route` should apply for a\nparticular URL and request. When matching occurs in response to a fetch\nevent from the client, the `event` object is also supplied. However, since\nthe match callback can be invoked outside of a fetch event, matching logic\nshould not assume the `event` object will always be available.\nIf the match callback returns a truthy value, the matching route's\n`RouteHandlerCallback` will be invoked immediately. If the value returned\nis a non-empty array or object, that value will be set on the handler's\n`options.params` argument.","type":"object","additionalProperties":false},"ManifestEntry":{"type":"object","properties":{"integrity":{"type":"string"},"revision":{"type":["null","string"]},"url":{"type":"string"}},"additionalProperties":false,"required":["revision","url"]}},"$schema":"http://json-schema.org/draft-07/schema#"} +{"additionalProperties":false,"type":"object","properties":{"chunks":{"type":"array","items":{"type":"string"}},"exclude":{"type":"array","items":{}},"excludeChunks":{"type":"array","items":{"type":"string"}},"include":{"type":"array","items":{}},"mode":{"default":"production","type":["null","string"]},"babelPresetEnvTargets":{"default":["chrome >= 56"],"type":"array","items":{"type":"string"}},"cacheId":{"type":["null","string"]},"cleanupOutdatedCaches":{"default":false,"type":"boolean"},"clientsClaim":{"default":false,"type":"boolean"},"directoryIndex":{"type":["null","string"]},"disableDevLogs":{"default":false,"type":"boolean"},"ignoreURLParametersMatching":{"type":"array","items":{"$ref":"#/definitions/RegExp"}},"importScripts":{"type":"array","items":{"type":"string"}},"inlineWorkboxRuntime":{"default":false,"type":"boolean"},"navigateFallback":{"default":null,"type":["null","string"]},"navigateFallbackAllowlist":{"type":"array","items":{"$ref":"#/definitions/RegExp"}},"navigateFallbackDenylist":{"type":"array","items":{"$ref":"#/definitions/RegExp"}},"navigationPreload":{"default":false,"type":"boolean"},"offlineGoogleAnalytics":{"default":false,"anyOf":[{"$ref":"#/definitions/GoogleAnalyticsInitializeOptions"},{"type":"boolean"}]},"runtimeCaching":{"type":"array","items":{"$ref":"#/definitions/RuntimeCaching"}},"skipWaiting":{"default":false,"type":"boolean"},"sourcemap":{"default":true,"type":"boolean"},"additionalManifestEntries":{"type":"array","items":{"anyOf":[{"$ref":"#/definitions/ManifestEntry"},{"type":"string"}]}},"dontCacheBustURLsMatching":{"$ref":"#/definitions/RegExp"},"manifestTransforms":{"type":"array","items":{"type":"object","additionalProperties":false}},"maximumFileSizeToCacheInBytes":{"default":2097152,"type":"number"},"modifyURLPrefix":{"type":"object","additionalProperties":{"type":"string"}},"importScriptsViaChunks":{"type":"array","items":{"type":"string"}},"swDest":{"default":"service-worker.js","type":"string"}},"definitions":{"RegExp":{"type":"object","properties":{"source":{"type":"string"},"global":{"type":"boolean"},"ignoreCase":{"type":"boolean"},"multiline":{"type":"boolean"},"lastIndex":{"type":"number"},"flags":{"type":"string"},"sticky":{"type":"boolean"},"unicode":{"type":"boolean"},"dotAll":{"type":"boolean"}},"additionalProperties":false,"required":["dotAll","flags","global","ignoreCase","lastIndex","multiline","source","sticky","unicode"]},"GoogleAnalyticsInitializeOptions":{"type":"object","properties":{"cacheName":{"type":"string"},"parameterOverrides":{"type":"object","additionalProperties":{"type":"string"}},"hitFilter":{"type":"object","additionalProperties":false}},"additionalProperties":false},"RuntimeCaching":{"type":"object","properties":{"handler":{"anyOf":[{"$ref":"#/definitions/RouteHandlerCallback"},{"$ref":"#/definitions/RouteHandlerObject"},{"enum":["CacheFirst","CacheOnly","NetworkFirst","NetworkOnly","StaleWhileRevalidate"],"type":"string"}]},"method":{"enum":["DELETE","GET","HEAD","PATCH","POST","PUT"],"type":"string"},"options":{"type":"object","properties":{"backgroundSync":{"type":"object","properties":{"name":{"type":"string"},"options":{"$ref":"#/definitions/QueueOptions"}},"additionalProperties":false,"required":["name"]},"broadcastUpdate":{"type":"object","properties":{"channelName":{"type":"string"},"options":{"$ref":"#/definitions/BroadcastCacheUpdateOptions"}},"additionalProperties":false,"required":["options"]},"cacheableResponse":{"$ref":"#/definitions/CacheableResponseOptions"},"cacheName":{"type":["null","string"]},"expiration":{"$ref":"#/definitions/ExpirationPluginOptions"},"networkTimeoutSeconds":{"type":"number"},"plugins":{"type":"array","items":{"$ref":"#/definitions/WorkboxPlugin"}},"precacheFallback":{"type":"object","properties":{"fallbackURL":{"type":"string"}},"additionalProperties":false,"required":["fallbackURL"]},"fetchOptions":{"$ref":"#/definitions/RequestInit"},"matchOptions":{"$ref":"#/definitions/CacheQueryOptions"}},"additionalProperties":false},"urlPattern":{"anyOf":[{"$ref":"#/definitions/RegExp"},{"$ref":"#/definitions/RouteMatchCallback"},{"type":"string"}]}},"additionalProperties":false,"required":["handler","urlPattern"]},"RouteHandlerCallback":{"description":"The \"handler\" callback is invoked whenever a `Router` matches a URL/Request\nto a `Route` via its `RouteMatchCallback`. This handler callback should\nreturn a `Promise` that resolves with a `Response`.\n\nIf a non-empty array or object is returned by the `RouteMatchCallback` it\nwill be passed in as this handler's `options.params` argument.","type":"object","additionalProperties":false},"RouteHandlerObject":{"description":"An object with a `handle` method of type `RouteHandlerCallback`.\n\nA `Route` object can be created with either an `RouteHandlerCallback`\nfunction or this `RouteHandler` object. The benefit of the `RouteHandler`\nis it can be extended (as is done by the `workbox-strategies` package).","type":"object","properties":{"handle":{"$ref":"#/definitions/RouteHandlerCallback"}},"additionalProperties":false,"required":["handle"]},"QueueOptions":{"type":"object","properties":{"onSync":{"$ref":"#/definitions/OnSyncCallback"},"maxRetentionTime":{"type":"number"}},"additionalProperties":false},"OnSyncCallback":{"type":"object","additionalProperties":false},"BroadcastCacheUpdateOptions":{"type":"object","properties":{"headersToCheck":{"type":"array","items":{"type":"string"}},"generatePayload":{"type":"object","additionalProperties":false}},"additionalProperties":false},"CacheableResponseOptions":{"type":"object","properties":{"statuses":{"type":"array","items":{"type":"number"}},"headers":{"type":"object","additionalProperties":{"type":"string"}}},"additionalProperties":false},"ExpirationPluginOptions":{"type":"object","properties":{"maxEntries":{"type":"number"},"maxAgeSeconds":{"type":"number"},"matchOptions":{"$ref":"#/definitions/CacheQueryOptions"},"purgeOnQuotaError":{"type":"boolean"}},"additionalProperties":false},"CacheQueryOptions":{"type":"object","properties":{"ignoreMethod":{"type":"boolean"},"ignoreSearch":{"type":"boolean"},"ignoreVary":{"type":"boolean"}},"additionalProperties":false},"WorkboxPlugin":{"description":"An object with optional lifecycle callback properties for the fetch and\ncache operations.","type":"object","properties":{"cacheDidUpdate":{"$ref":"#/definitions/CacheDidUpdateCallback"},"cachedResponseWillBeUsed":{"$ref":"#/definitions/CachedResponseWillBeUsedCallback"},"cacheKeyWillBeUsed":{"$ref":"#/definitions/CacheKeyWillBeUsedCallback"},"cacheWillUpdate":{"$ref":"#/definitions/CacheWillUpdateCallback"},"fetchDidFail":{"$ref":"#/definitions/FetchDidFailCallback"},"fetchDidSucceed":{"$ref":"#/definitions/FetchDidSucceedCallback"},"handlerDidComplete":{"$ref":"#/definitions/HandlerDidCompleteCallback"},"handlerDidError":{"$ref":"#/definitions/HandlerDidErrorCallback"},"handlerDidRespond":{"$ref":"#/definitions/HandlerDidRespondCallback"},"handlerWillRespond":{"$ref":"#/definitions/HandlerWillRespondCallback"},"handlerWillStart":{"$ref":"#/definitions/HandlerWillStartCallback"},"requestWillFetch":{"$ref":"#/definitions/RequestWillFetchCallback"}},"additionalProperties":false},"CacheDidUpdateCallback":{"type":"object","additionalProperties":false},"CachedResponseWillBeUsedCallback":{"type":"object","additionalProperties":false},"CacheKeyWillBeUsedCallback":{"type":"object","additionalProperties":false},"CacheWillUpdateCallback":{"type":"object","additionalProperties":false},"FetchDidFailCallback":{"type":"object","additionalProperties":false},"FetchDidSucceedCallback":{"type":"object","additionalProperties":false},"HandlerDidCompleteCallback":{"type":"object","additionalProperties":false},"HandlerDidErrorCallback":{"type":"object","additionalProperties":false},"HandlerDidRespondCallback":{"type":"object","additionalProperties":false},"HandlerWillRespondCallback":{"type":"object","additionalProperties":false},"HandlerWillStartCallback":{"type":"object","additionalProperties":false},"RequestWillFetchCallback":{"type":"object","additionalProperties":false},"RequestInit":{"type":"object","properties":{"body":{"anyOf":[{"$ref":"#/definitions/ArrayBuffer"},{"$ref":"#/definitions/ArrayBufferView"},{"$ref":"#/definitions/Blob"},{"$ref":"#/definitions/FormData"},{"$ref":"#/definitions/URLSearchParams"},{"$ref":"#/definitions/ReadableStream"},{"type":["null","string"]}]},"cache":{"enum":["default","force-cache","no-cache","no-store","only-if-cached","reload"],"type":"string"},"credentials":{"enum":["include","omit","same-origin"],"type":"string"},"headers":{"anyOf":[{"$ref":"#/definitions/Headers"},{"type":"array","items":{"type":"array","items":{"type":"string"}}},{"$ref":"#/definitions/Record"}]},"integrity":{"type":"string"},"keepalive":{"type":"boolean"},"method":{"type":"string"},"mode":{"enum":["cors","navigate","no-cors","same-origin"],"type":"string"},"redirect":{"enum":["error","follow","manual"],"type":"string"},"referrer":{"type":"string"},"referrerPolicy":{"enum":["","no-referrer","no-referrer-when-downgrade","origin","origin-when-cross-origin","same-origin","strict-origin","strict-origin-when-cross-origin","unsafe-url"],"type":"string"},"signal":{"anyOf":[{"$ref":"#/definitions/AbortSignal"},{"type":"null"}]},"window":{}},"additionalProperties":false},"ArrayBuffer":{"type":"object","properties":{"byteLength":{"type":"number"},"__@toStringTag":{"type":"string"}},"additionalProperties":false,"required":["__@toStringTag","byteLength"]},"ArrayBufferView":{"type":"object","properties":{"buffer":{"anyOf":[{"$ref":"#/definitions/ArrayBuffer"},{"$ref":"#/definitions/SharedArrayBuffer"}]},"byteLength":{"type":"number"},"byteOffset":{"type":"number"}},"additionalProperties":false,"required":["buffer","byteLength","byteOffset"]},"SharedArrayBuffer":{"type":"object","properties":{"byteLength":{"type":"number"},"__@species":{"$ref":"#/definitions/SharedArrayBuffer"},"__@toStringTag":{"type":"string","enum":["SharedArrayBuffer"]}},"additionalProperties":false,"required":["__@species","__@toStringTag","byteLength"]},"Blob":{"type":"object","properties":{"size":{"type":"number"},"type":{"type":"string"}},"additionalProperties":false,"required":["size","type"]},"FormData":{"type":"object","additionalProperties":false},"URLSearchParams":{"type":"object","additionalProperties":false},"ReadableStream":{"type":"object","properties":{"locked":{"type":"boolean"}},"additionalProperties":false,"required":["locked"]},"Headers":{"type":"object","additionalProperties":false},"Record":{"type":"object","additionalProperties":false},"AbortSignal":{"type":"object","properties":{"aborted":{"type":"boolean"},"onabort":{"anyOf":[{"type":"object","additionalProperties":false},{"type":"null"}]}},"additionalProperties":false,"required":["aborted","onabort"]},"RouteMatchCallback":{"description":"The \"match\" callback is used to determine if a `Route` should apply for a\nparticular URL and request. When matching occurs in response to a fetch\nevent from the client, the `event` object is also supplied. However, since\nthe match callback can be invoked outside of a fetch event, matching logic\nshould not assume the `event` object will always be available.\nIf the match callback returns a truthy value, the matching route's\n`RouteHandlerCallback` will be invoked immediately. If the value returned\nis a non-empty array or object, that value will be set on the handler's\n`options.params` argument.","type":"object","additionalProperties":false},"ManifestEntry":{"type":"object","properties":{"integrity":{"type":"string"},"revision":{"type":["null","string"]},"url":{"type":"string"}},"additionalProperties":false,"required":["revision","url"]}},"$schema":"http://json-schema.org/draft-07/schema#"} diff --git a/packages/workbox-build/src/schema/WebpackInjectManifestOptions.json b/packages/workbox-build/src/schema/WebpackInjectManifestOptions.json index a6cc46221..7abbd5ca8 100644 --- a/packages/workbox-build/src/schema/WebpackInjectManifestOptions.json +++ b/packages/workbox-build/src/schema/WebpackInjectManifestOptions.json @@ -1 +1 @@ -{"additionalProperties":false,"type":"object","properties":{"chunks":{"type":"array","items":{"type":"string"}},"exclude":{"type":"array","items":{}},"excludeChunks":{"type":"array","items":{"type":"string"}},"include":{"type":"array","items":{}},"mode":{"type":["null","string"]},"injectionPoint":{"default":"self.__WB_MANIFEST","type":"string"},"swSrc":{"type":"string"},"additionalManifestEntries":{"type":"array","items":{"anyOf":[{"$ref":"#/definitions/ManifestEntry"},{"type":"string"}]}},"dontCacheBustURLsMatching":{"$ref":"#/definitions/RegExp"},"manifestTransforms":{"type":"array","items":{"type":"object","additionalProperties":false}},"maximumFileSizeToCacheInBytes":{"default":2097152,"type":"number"},"modifyURLPrefix":{"type":"object","additionalProperties":{"type":"string"}},"swDest":{"default":"service-worker.js","type":"string"},"compileSrc":{"default":true,"type":"boolean"},"webpackCompilationPlugins":{"type":"array","items":{}}},"required":["swSrc"],"definitions":{"RegExp":{"type":"object","properties":{"source":{"type":"string"},"global":{"type":"boolean"},"ignoreCase":{"type":"boolean"},"multiline":{"type":"boolean"},"lastIndex":{"type":"number"},"flags":{"type":"string"},"sticky":{"type":"boolean"},"unicode":{"type":"boolean"},"dotAll":{"type":"boolean"}},"additionalProperties":false,"required":["dotAll","flags","global","ignoreCase","lastIndex","multiline","source","sticky","unicode"]},"GoogleAnalyticsInitializeOptions":{"type":"object","properties":{"cacheName":{"type":"string"},"parameterOverrides":{"type":"object","additionalProperties":{"type":"string"}},"hitFilter":{"type":"object","additionalProperties":false}},"additionalProperties":false},"RuntimeCaching":{"type":"object","properties":{"handler":{"anyOf":[{"$ref":"#/definitions/RouteHandlerCallback"},{"$ref":"#/definitions/RouteHandlerObject"},{"enum":["CacheFirst","CacheOnly","NetworkFirst","NetworkOnly","StaleWhileRevalidate"],"type":"string"}]},"method":{"enum":["DELETE","GET","HEAD","PATCH","POST","PUT"],"type":"string"},"options":{"type":"object","properties":{"backgroundSync":{"type":"object","properties":{"name":{"type":"string"},"options":{"$ref":"#/definitions/QueueOptions"}},"additionalProperties":false,"required":["name"]},"broadcastUpdate":{"type":"object","properties":{"channelName":{"type":"string"},"options":{"$ref":"#/definitions/BroadcastCacheUpdateOptions"}},"additionalProperties":false,"required":["options"]},"cacheableResponse":{"$ref":"#/definitions/CacheableResponseOptions"},"cacheName":{"type":["null","string"]},"expiration":{"$ref":"#/definitions/ExpirationPluginOptions"},"networkTimeoutSeconds":{"type":"number"},"plugins":{"type":"array","items":{"$ref":"#/definitions/WorkboxPlugin"}},"precacheFallback":{"type":"object","properties":{"fallbackURL":{"type":"string"}},"additionalProperties":false,"required":["fallbackURL"]},"fetchOptions":{"$ref":"#/definitions/RequestInit"},"matchOptions":{"$ref":"#/definitions/CacheQueryOptions"}},"additionalProperties":false},"urlPattern":{"anyOf":[{"$ref":"#/definitions/RegExp"},{"$ref":"#/definitions/RouteMatchCallback"},{"type":"string"}]}},"additionalProperties":false,"required":["handler","urlPattern"]},"RouteHandlerCallback":{"description":"The \"handler\" callback is invoked whenever a `Router` matches a URL/Request\nto a `Route` via its `RouteMatchCallback`. This handler callback should\nreturn a `Promise` that resolves with a `Response`.\n\nIf a non-empty array or object is returned by the `RouteMatchCallback` it\nwill be passed in as this handler's `options.params` argument.","type":"object","additionalProperties":false},"RouteHandlerObject":{"description":"An object with a `handle` method of type `RouteHandlerCallback`.\n\nA `Route` object can be created with either an `RouteHandlerCallback`\nfunction or this `RouteHandler` object. The benefit of the `RouteHandler`\nis it can be extended (as is done by the `workbox-strategies` package).","type":"object","properties":{"handle":{"$ref":"#/definitions/RouteHandlerCallback"}},"additionalProperties":false,"required":["handle"]},"QueueOptions":{"type":"object","properties":{"onSync":{"$ref":"#/definitions/OnSyncCallback"},"maxRetentionTime":{"type":"number"}},"additionalProperties":false},"OnSyncCallback":{"type":"object","additionalProperties":false},"BroadcastCacheUpdateOptions":{"type":"object","properties":{"headersToCheck":{"type":"array","items":{"type":"string"}},"generatePayload":{"type":"object","additionalProperties":false}},"additionalProperties":false},"CacheableResponseOptions":{"type":"object","properties":{"statuses":{"type":"array","items":{"type":"number"}},"headers":{"type":"object","additionalProperties":{"type":"string"}}},"additionalProperties":false},"ExpirationPluginOptions":{"type":"object","properties":{"maxEntries":{"type":"number"},"maxAgeSeconds":{"type":"number"},"matchOptions":{"$ref":"#/definitions/CacheQueryOptions"},"purgeOnQuotaError":{"type":"boolean"}},"additionalProperties":false},"CacheQueryOptions":{"type":"object","properties":{"ignoreMethod":{"type":"boolean"},"ignoreSearch":{"type":"boolean"},"ignoreVary":{"type":"boolean"}},"additionalProperties":false},"WorkboxPlugin":{"description":"An object with optional lifecycle callback properties for the fetch and\ncache operations.","type":"object","properties":{"cacheDidUpdate":{"$ref":"#/definitions/CacheDidUpdateCallback"},"cachedResponseWillBeUsed":{"$ref":"#/definitions/CachedResponseWillBeUsedCallback"},"cacheKeyWillBeUsed":{"$ref":"#/definitions/CacheKeyWillBeUsedCallback"},"cacheWillUpdate":{"$ref":"#/definitions/CacheWillUpdateCallback"},"fetchDidFail":{"$ref":"#/definitions/FetchDidFailCallback"},"fetchDidSucceed":{"$ref":"#/definitions/FetchDidSucceedCallback"},"handlerDidComplete":{"$ref":"#/definitions/HandlerDidCompleteCallback"},"handlerDidError":{"$ref":"#/definitions/HandlerDidErrorCallback"},"handlerDidRespond":{"$ref":"#/definitions/HandlerDidRespondCallback"},"handlerWillRespond":{"$ref":"#/definitions/HandlerWillRespondCallback"},"handlerWillStart":{"$ref":"#/definitions/HandlerWillStartCallback"},"requestWillFetch":{"$ref":"#/definitions/RequestWillFetchCallback"}},"additionalProperties":false},"CacheDidUpdateCallback":{"type":"object","additionalProperties":false},"CachedResponseWillBeUsedCallback":{"type":"object","additionalProperties":false},"CacheKeyWillBeUsedCallback":{"type":"object","additionalProperties":false},"CacheWillUpdateCallback":{"type":"object","additionalProperties":false},"FetchDidFailCallback":{"type":"object","additionalProperties":false},"FetchDidSucceedCallback":{"type":"object","additionalProperties":false},"HandlerDidCompleteCallback":{"type":"object","additionalProperties":false},"HandlerDidErrorCallback":{"type":"object","additionalProperties":false},"HandlerDidRespondCallback":{"type":"object","additionalProperties":false},"HandlerWillRespondCallback":{"type":"object","additionalProperties":false},"HandlerWillStartCallback":{"type":"object","additionalProperties":false},"RequestWillFetchCallback":{"type":"object","additionalProperties":false},"RequestInit":{"type":"object","properties":{"body":{"anyOf":[{"$ref":"#/definitions/ArrayBuffer"},{"$ref":"#/definitions/ArrayBufferView"},{"$ref":"#/definitions/Blob"},{"$ref":"#/definitions/FormData"},{"$ref":"#/definitions/URLSearchParams"},{"$ref":"#/definitions/ReadableStream"},{"type":["null","string"]}]},"cache":{"enum":["default","force-cache","no-cache","no-store","only-if-cached","reload"],"type":"string"},"credentials":{"enum":["include","omit","same-origin"],"type":"string"},"headers":{"anyOf":[{"$ref":"#/definitions/Headers"},{"type":"array","items":{"type":"array","items":{"type":"string"}}},{"$ref":"#/definitions/Record"}]},"integrity":{"type":"string"},"keepalive":{"type":"boolean"},"method":{"type":"string"},"mode":{"enum":["cors","navigate","no-cors","same-origin"],"type":"string"},"redirect":{"enum":["error","follow","manual"],"type":"string"},"referrer":{"type":"string"},"referrerPolicy":{"enum":["","no-referrer","no-referrer-when-downgrade","origin","origin-when-cross-origin","same-origin","strict-origin","strict-origin-when-cross-origin","unsafe-url"],"type":"string"},"signal":{"anyOf":[{"$ref":"#/definitions/AbortSignal"},{"type":"null"}]},"window":{}},"additionalProperties":false},"ArrayBuffer":{"type":"object","properties":{"byteLength":{"type":"number"},"__@toStringTag":{"type":"string"}},"additionalProperties":false,"required":["__@toStringTag","byteLength"]},"ArrayBufferView":{"type":"object","properties":{"buffer":{"anyOf":[{"$ref":"#/definitions/ArrayBuffer"},{"$ref":"#/definitions/SharedArrayBuffer"}]},"byteLength":{"type":"number"},"byteOffset":{"type":"number"}},"additionalProperties":false,"required":["buffer","byteLength","byteOffset"]},"SharedArrayBuffer":{"type":"object","properties":{"byteLength":{"type":"number"},"__@species":{"$ref":"#/definitions/SharedArrayBuffer"},"__@toStringTag":{"type":"string","enum":["SharedArrayBuffer"]}},"additionalProperties":false,"required":["__@species","__@toStringTag","byteLength"]},"Blob":{"type":"object","properties":{"size":{"type":"number"},"type":{"type":"string"}},"additionalProperties":false,"required":["size","type"]},"FormData":{"type":"object","additionalProperties":false},"URLSearchParams":{"type":"object","additionalProperties":false},"ReadableStream":{"type":"object","properties":{"locked":{"type":"boolean"}},"additionalProperties":false,"required":["locked"]},"Headers":{"type":"object","additionalProperties":false},"Record":{"type":"object","additionalProperties":false},"AbortSignal":{"type":"object","properties":{"aborted":{"type":"boolean"},"onabort":{"anyOf":[{"type":"object","additionalProperties":false},{"type":"null"}]}},"additionalProperties":false,"required":["aborted","onabort"]},"RouteMatchCallback":{"description":"The \"match\" callback is used to determine if a `Route` should apply for a\nparticular URL and request. When matching occurs in response to a fetch\nevent from the client, the `event` object is also supplied. However, since\nthe match callback can be invoked outside of a fetch event, matching logic\nshould not assume the `event` object will always be available.\nIf the match callback returns a truthy value, the matching route's\n`RouteHandlerCallback` will be invoked immediately. If the value returned\nis a non-empty array or object, that value will be set on the handler's\n`options.params` argument.","type":"object","additionalProperties":false},"ManifestEntry":{"type":"object","properties":{"integrity":{"type":"string"},"revision":{"type":["null","string"]},"url":{"type":"string"}},"additionalProperties":false,"required":["revision","url"]}},"$schema":"http://json-schema.org/draft-07/schema#"} +{"additionalProperties":false,"type":"object","properties":{"chunks":{"type":"array","items":{"type":"string"}},"exclude":{"type":"array","items":{}},"excludeChunks":{"type":"array","items":{"type":"string"}},"include":{"type":"array","items":{}},"mode":{"type":["null","string"]},"injectionPoint":{"default":"self.__WB_MANIFEST","type":"string"},"swSrc":{"type":"string"},"additionalManifestEntries":{"type":"array","items":{"anyOf":[{"$ref":"#/definitions/ManifestEntry"},{"type":"string"}]}},"dontCacheBustURLsMatching":{"$ref":"#/definitions/RegExp"},"manifestTransforms":{"type":"array","items":{"type":"object","additionalProperties":false}},"maximumFileSizeToCacheInBytes":{"default":2097152,"type":"number"},"modifyURLPrefix":{"type":"object","additionalProperties":{"type":"string"}},"compileSrc":{"default":true,"type":"boolean"},"swDest":{"type":"string"},"webpackCompilationPlugins":{"type":"array","items":{}}},"required":["swSrc"],"definitions":{"RegExp":{"type":"object","properties":{"source":{"type":"string"},"global":{"type":"boolean"},"ignoreCase":{"type":"boolean"},"multiline":{"type":"boolean"},"lastIndex":{"type":"number"},"flags":{"type":"string"},"sticky":{"type":"boolean"},"unicode":{"type":"boolean"},"dotAll":{"type":"boolean"}},"additionalProperties":false,"required":["dotAll","flags","global","ignoreCase","lastIndex","multiline","source","sticky","unicode"]},"GoogleAnalyticsInitializeOptions":{"type":"object","properties":{"cacheName":{"type":"string"},"parameterOverrides":{"type":"object","additionalProperties":{"type":"string"}},"hitFilter":{"type":"object","additionalProperties":false}},"additionalProperties":false},"RuntimeCaching":{"type":"object","properties":{"handler":{"anyOf":[{"$ref":"#/definitions/RouteHandlerCallback"},{"$ref":"#/definitions/RouteHandlerObject"},{"enum":["CacheFirst","CacheOnly","NetworkFirst","NetworkOnly","StaleWhileRevalidate"],"type":"string"}]},"method":{"enum":["DELETE","GET","HEAD","PATCH","POST","PUT"],"type":"string"},"options":{"type":"object","properties":{"backgroundSync":{"type":"object","properties":{"name":{"type":"string"},"options":{"$ref":"#/definitions/QueueOptions"}},"additionalProperties":false,"required":["name"]},"broadcastUpdate":{"type":"object","properties":{"channelName":{"type":"string"},"options":{"$ref":"#/definitions/BroadcastCacheUpdateOptions"}},"additionalProperties":false,"required":["options"]},"cacheableResponse":{"$ref":"#/definitions/CacheableResponseOptions"},"cacheName":{"type":["null","string"]},"expiration":{"$ref":"#/definitions/ExpirationPluginOptions"},"networkTimeoutSeconds":{"type":"number"},"plugins":{"type":"array","items":{"$ref":"#/definitions/WorkboxPlugin"}},"precacheFallback":{"type":"object","properties":{"fallbackURL":{"type":"string"}},"additionalProperties":false,"required":["fallbackURL"]},"fetchOptions":{"$ref":"#/definitions/RequestInit"},"matchOptions":{"$ref":"#/definitions/CacheQueryOptions"}},"additionalProperties":false},"urlPattern":{"anyOf":[{"$ref":"#/definitions/RegExp"},{"$ref":"#/definitions/RouteMatchCallback"},{"type":"string"}]}},"additionalProperties":false,"required":["handler","urlPattern"]},"RouteHandlerCallback":{"description":"The \"handler\" callback is invoked whenever a `Router` matches a URL/Request\nto a `Route` via its `RouteMatchCallback`. This handler callback should\nreturn a `Promise` that resolves with a `Response`.\n\nIf a non-empty array or object is returned by the `RouteMatchCallback` it\nwill be passed in as this handler's `options.params` argument.","type":"object","additionalProperties":false},"RouteHandlerObject":{"description":"An object with a `handle` method of type `RouteHandlerCallback`.\n\nA `Route` object can be created with either an `RouteHandlerCallback`\nfunction or this `RouteHandler` object. The benefit of the `RouteHandler`\nis it can be extended (as is done by the `workbox-strategies` package).","type":"object","properties":{"handle":{"$ref":"#/definitions/RouteHandlerCallback"}},"additionalProperties":false,"required":["handle"]},"QueueOptions":{"type":"object","properties":{"onSync":{"$ref":"#/definitions/OnSyncCallback"},"maxRetentionTime":{"type":"number"}},"additionalProperties":false},"OnSyncCallback":{"type":"object","additionalProperties":false},"BroadcastCacheUpdateOptions":{"type":"object","properties":{"headersToCheck":{"type":"array","items":{"type":"string"}},"generatePayload":{"type":"object","additionalProperties":false}},"additionalProperties":false},"CacheableResponseOptions":{"type":"object","properties":{"statuses":{"type":"array","items":{"type":"number"}},"headers":{"type":"object","additionalProperties":{"type":"string"}}},"additionalProperties":false},"ExpirationPluginOptions":{"type":"object","properties":{"maxEntries":{"type":"number"},"maxAgeSeconds":{"type":"number"},"matchOptions":{"$ref":"#/definitions/CacheQueryOptions"},"purgeOnQuotaError":{"type":"boolean"}},"additionalProperties":false},"CacheQueryOptions":{"type":"object","properties":{"ignoreMethod":{"type":"boolean"},"ignoreSearch":{"type":"boolean"},"ignoreVary":{"type":"boolean"}},"additionalProperties":false},"WorkboxPlugin":{"description":"An object with optional lifecycle callback properties for the fetch and\ncache operations.","type":"object","properties":{"cacheDidUpdate":{"$ref":"#/definitions/CacheDidUpdateCallback"},"cachedResponseWillBeUsed":{"$ref":"#/definitions/CachedResponseWillBeUsedCallback"},"cacheKeyWillBeUsed":{"$ref":"#/definitions/CacheKeyWillBeUsedCallback"},"cacheWillUpdate":{"$ref":"#/definitions/CacheWillUpdateCallback"},"fetchDidFail":{"$ref":"#/definitions/FetchDidFailCallback"},"fetchDidSucceed":{"$ref":"#/definitions/FetchDidSucceedCallback"},"handlerDidComplete":{"$ref":"#/definitions/HandlerDidCompleteCallback"},"handlerDidError":{"$ref":"#/definitions/HandlerDidErrorCallback"},"handlerDidRespond":{"$ref":"#/definitions/HandlerDidRespondCallback"},"handlerWillRespond":{"$ref":"#/definitions/HandlerWillRespondCallback"},"handlerWillStart":{"$ref":"#/definitions/HandlerWillStartCallback"},"requestWillFetch":{"$ref":"#/definitions/RequestWillFetchCallback"}},"additionalProperties":false},"CacheDidUpdateCallback":{"type":"object","additionalProperties":false},"CachedResponseWillBeUsedCallback":{"type":"object","additionalProperties":false},"CacheKeyWillBeUsedCallback":{"type":"object","additionalProperties":false},"CacheWillUpdateCallback":{"type":"object","additionalProperties":false},"FetchDidFailCallback":{"type":"object","additionalProperties":false},"FetchDidSucceedCallback":{"type":"object","additionalProperties":false},"HandlerDidCompleteCallback":{"type":"object","additionalProperties":false},"HandlerDidErrorCallback":{"type":"object","additionalProperties":false},"HandlerDidRespondCallback":{"type":"object","additionalProperties":false},"HandlerWillRespondCallback":{"type":"object","additionalProperties":false},"HandlerWillStartCallback":{"type":"object","additionalProperties":false},"RequestWillFetchCallback":{"type":"object","additionalProperties":false},"RequestInit":{"type":"object","properties":{"body":{"anyOf":[{"$ref":"#/definitions/ArrayBuffer"},{"$ref":"#/definitions/ArrayBufferView"},{"$ref":"#/definitions/Blob"},{"$ref":"#/definitions/FormData"},{"$ref":"#/definitions/URLSearchParams"},{"$ref":"#/definitions/ReadableStream"},{"type":["null","string"]}]},"cache":{"enum":["default","force-cache","no-cache","no-store","only-if-cached","reload"],"type":"string"},"credentials":{"enum":["include","omit","same-origin"],"type":"string"},"headers":{"anyOf":[{"$ref":"#/definitions/Headers"},{"type":"array","items":{"type":"array","items":{"type":"string"}}},{"$ref":"#/definitions/Record"}]},"integrity":{"type":"string"},"keepalive":{"type":"boolean"},"method":{"type":"string"},"mode":{"enum":["cors","navigate","no-cors","same-origin"],"type":"string"},"redirect":{"enum":["error","follow","manual"],"type":"string"},"referrer":{"type":"string"},"referrerPolicy":{"enum":["","no-referrer","no-referrer-when-downgrade","origin","origin-when-cross-origin","same-origin","strict-origin","strict-origin-when-cross-origin","unsafe-url"],"type":"string"},"signal":{"anyOf":[{"$ref":"#/definitions/AbortSignal"},{"type":"null"}]},"window":{}},"additionalProperties":false},"ArrayBuffer":{"type":"object","properties":{"byteLength":{"type":"number"},"__@toStringTag":{"type":"string"}},"additionalProperties":false,"required":["__@toStringTag","byteLength"]},"ArrayBufferView":{"type":"object","properties":{"buffer":{"anyOf":[{"$ref":"#/definitions/ArrayBuffer"},{"$ref":"#/definitions/SharedArrayBuffer"}]},"byteLength":{"type":"number"},"byteOffset":{"type":"number"}},"additionalProperties":false,"required":["buffer","byteLength","byteOffset"]},"SharedArrayBuffer":{"type":"object","properties":{"byteLength":{"type":"number"},"__@species":{"$ref":"#/definitions/SharedArrayBuffer"},"__@toStringTag":{"type":"string","enum":["SharedArrayBuffer"]}},"additionalProperties":false,"required":["__@species","__@toStringTag","byteLength"]},"Blob":{"type":"object","properties":{"size":{"type":"number"},"type":{"type":"string"}},"additionalProperties":false,"required":["size","type"]},"FormData":{"type":"object","additionalProperties":false},"URLSearchParams":{"type":"object","additionalProperties":false},"ReadableStream":{"type":"object","properties":{"locked":{"type":"boolean"}},"additionalProperties":false,"required":["locked"]},"Headers":{"type":"object","additionalProperties":false},"Record":{"type":"object","additionalProperties":false},"AbortSignal":{"type":"object","properties":{"aborted":{"type":"boolean"},"onabort":{"anyOf":[{"type":"object","additionalProperties":false},{"type":"null"}]}},"additionalProperties":false,"required":["aborted","onabort"]},"RouteMatchCallback":{"description":"The \"match\" callback is used to determine if a `Route` should apply for a\nparticular URL and request. When matching occurs in response to a fetch\nevent from the client, the `event` object is also supplied. However, since\nthe match callback can be invoked outside of a fetch event, matching logic\nshould not assume the `event` object will always be available.\nIf the match callback returns a truthy value, the matching route's\n`RouteHandlerCallback` will be invoked immediately. If the value returned\nis a non-empty array or object, that value will be set on the handler's\n`options.params` argument.","type":"object","additionalProperties":false},"ManifestEntry":{"type":"object","properties":{"integrity":{"type":"string"},"revision":{"type":["null","string"]},"url":{"type":"string"}},"additionalProperties":false,"required":["revision","url"]}},"$schema":"http://json-schema.org/draft-07/schema#"} diff --git a/packages/workbox-build/src/types.ts b/packages/workbox-build/src/types.ts index eac26f507..37e3d380f 100644 --- a/packages/workbox-build/src/types.ts +++ b/packages/workbox-build/src/types.ts @@ -171,13 +171,6 @@ export interface RequiredSWDestPartial { swDest: string; } -export interface OptionalSWDestPartial { - /** - * @default "service-worker.js" - */ - swDest?: string; -} - export type GenerateSWOptions = GlobPartial & GeneratePartial & BasePartial & RequiredSWDestPartial; export type GetManifestOptions = GlobPartial & BasePartial; @@ -186,15 +179,22 @@ export type InjectManifestOptions = InjectPartial & Omit; + /** + * @default "service-worker.js" + */ + swDest?: string; }; -export type WebpackInjectManifestOptions = WebpackPartial & InjectPartial & BasePartial & OptionalSWDestPartial & { +export type WebpackInjectManifestOptions = WebpackPartial & InjectPartial & BasePartial & { /** * @default true */ compileSrc?: boolean; + // This doesn't have a hardcoded default value; instead, the default will be + // set at runtime to the swSrc basename, with the hardcoded extension .js. + swDest?: string; // This can only be set if compileSrc is true, but that restriction can't be // represented in TypeScript. It's enforced via custom runtime validation // logic and needs to be documented. diff --git a/packages/workbox-webpack-plugin/src/inject-manifest.js b/packages/workbox-webpack-plugin/src/inject-manifest.js index e984e3fd5..846801879 100644 --- a/packages/workbox-webpack-plugin/src/inject-manifest.js +++ b/packages/workbox-webpack-plugin/src/inject-manifest.js @@ -136,6 +136,8 @@ class InjectManifest { // there take precedence over derived properties from the compiler. this.config = Object.assign({ mode: compiler.mode, + // Use swSrc with a hardcoded .js extension, in case swSrc is a .ts file. + swDest: upath.parse(this.config.swSrc).name + '.js', }, this.config); } From 38ac1e6d10108beb2e2951e3bf7c425372e2ab54 Mon Sep 17 00:00:00 2001 From: Jeff Posnick Date: Thu, 10 Jun 2021 10:24:39 -0400 Subject: [PATCH 47/80] Function support? --- gulp-tasks/build-node-packages.js | 1 + packages/workbox-build/package-lock.json | 8 +++++ packages/workbox-build/package.json | 1 + .../workbox-build/src/lib/validate-options.ts | 2 ++ .../src/schema/GenerateSWOptions.json | 2 +- .../src/schema/GetManifestOptions.json | 2 +- .../src/schema/InjectManifestOptions.json | 2 +- .../src/schema/WebpackGenerateSWOptions.json | 2 +- .../schema/WebpackInjectManifestOptions.json | 2 +- packages/workbox-build/src/types.ts | 30 +++++++++++-------- 10 files changed, 35 insertions(+), 17 deletions(-) diff --git a/gulp-tasks/build-node-packages.js b/gulp-tasks/build-node-packages.js index a68a4378b..d9e0d08c7 100644 --- a/gulp-tasks/build-node-packages.js +++ b/gulp-tasks/build-node-packages.js @@ -36,6 +36,7 @@ async function generateWorkboxBuildJSONSchema(packagePath) { const generator = TJS.buildGenerator(program, { noExtraProps: true, required: true, + typeOfKeyword: true, }); const optionTypes = [ 'GenerateSWOptions', diff --git a/packages/workbox-build/package-lock.json b/packages/workbox-build/package-lock.json index 3374dbe72..2681a7c39 100644 --- a/packages/workbox-build/package-lock.json +++ b/packages/workbox-build/package-lock.json @@ -1066,6 +1066,14 @@ "uri-js": "^4.2.2" } }, + "ajv-keywords": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/ajv-keywords/-/ajv-keywords-5.0.0.tgz", + "integrity": "sha512-ULd1QMjRoH6JDNUQIfDLrlE+OgZlFaxyYCjzt58uNuUQtKXt8/U+vK/8Ql0gyn/C5mqZzUWtKMqr/4YquvTrWA==", + "requires": { + "fast-deep-equal": "^3.1.3" + } + }, "ansi-styles": { "version": "3.2.1", "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz", diff --git a/packages/workbox-build/package.json b/packages/workbox-build/package.json index 2e0624555..69fd0d90d 100644 --- a/packages/workbox-build/package.json +++ b/packages/workbox-build/package.json @@ -29,6 +29,7 @@ "@rollup/plugin-replace": "^2.4.1", "@surma/rollup-plugin-off-main-thread": "^1.4.1", "ajv": "^8.6.0", + "ajv-keywords": "^5.0.0", "common-tags": "^1.8.0", "fast-json-stable-stringify": "^2.1.0", "fs-extra": "^9.0.1", diff --git a/packages/workbox-build/src/lib/validate-options.ts b/packages/workbox-build/src/lib/validate-options.ts index 2909c7877..3bab5caf7 100644 --- a/packages/workbox-build/src/lib/validate-options.ts +++ b/packages/workbox-build/src/lib/validate-options.ts @@ -7,6 +7,7 @@ */ import Ajv, {JSONSchemaType} from 'ajv'; +import ajvKeywords from 'ajv-keywords'; import { GenerateSWOptions, @@ -19,6 +20,7 @@ import { const ajv = new Ajv({ useDefaults: true, }); +ajvKeywords(ajv, ['typeof']); const DEFAULT_EXCLUDE_VALUE= [/\.map$/, /^manifest.*\.js$/]; diff --git a/packages/workbox-build/src/schema/GenerateSWOptions.json b/packages/workbox-build/src/schema/GenerateSWOptions.json index 73a1838a5..afa4ea7e5 100644 --- a/packages/workbox-build/src/schema/GenerateSWOptions.json +++ b/packages/workbox-build/src/schema/GenerateSWOptions.json @@ -1 +1 @@ -{"additionalProperties":false,"type":"object","properties":{"globDirectory":{"type":"string"},"globFollow":{"default":true,"type":"boolean"},"globIgnores":{"default":["**/node_modules/**/*"],"type":"array","items":{"type":"string"}},"globPatterns":{"default":["**/*.{js,css,html}"],"type":"array","items":{"type":"string"}},"globStrict":{"default":true,"type":"boolean"},"templatedURLs":{"type":"object","additionalProperties":{"anyOf":[{"type":"array","items":{"type":"string"}},{"type":"string"}]}},"babelPresetEnvTargets":{"default":["chrome >= 56"],"type":"array","items":{"type":"string"}},"cacheId":{"type":["null","string"]},"cleanupOutdatedCaches":{"default":false,"type":"boolean"},"clientsClaim":{"default":false,"type":"boolean"},"directoryIndex":{"type":["null","string"]},"disableDevLogs":{"default":false,"type":"boolean"},"ignoreURLParametersMatching":{"type":"array","items":{"$ref":"#/definitions/RegExp"}},"importScripts":{"type":"array","items":{"type":"string"}},"inlineWorkboxRuntime":{"default":false,"type":"boolean"},"mode":{"default":"production","type":["null","string"]},"navigateFallback":{"default":null,"type":["null","string"]},"navigateFallbackAllowlist":{"type":"array","items":{"$ref":"#/definitions/RegExp"}},"navigateFallbackDenylist":{"type":"array","items":{"$ref":"#/definitions/RegExp"}},"navigationPreload":{"default":false,"type":"boolean"},"offlineGoogleAnalytics":{"default":false,"anyOf":[{"$ref":"#/definitions/GoogleAnalyticsInitializeOptions"},{"type":"boolean"}]},"runtimeCaching":{"type":"array","items":{"$ref":"#/definitions/RuntimeCaching"}},"skipWaiting":{"default":false,"type":"boolean"},"sourcemap":{"default":true,"type":"boolean"},"additionalManifestEntries":{"type":"array","items":{"anyOf":[{"$ref":"#/definitions/ManifestEntry"},{"type":"string"}]}},"dontCacheBustURLsMatching":{"$ref":"#/definitions/RegExp"},"manifestTransforms":{"type":"array","items":{"type":"object","additionalProperties":false}},"maximumFileSizeToCacheInBytes":{"default":2097152,"type":"number"},"modifyURLPrefix":{"type":"object","additionalProperties":{"type":"string"}},"swDest":{"type":"string"}},"required":["globDirectory","swDest"],"definitions":{"RegExp":{"type":"object","properties":{"source":{"type":"string"},"global":{"type":"boolean"},"ignoreCase":{"type":"boolean"},"multiline":{"type":"boolean"},"lastIndex":{"type":"number"},"flags":{"type":"string"},"sticky":{"type":"boolean"},"unicode":{"type":"boolean"},"dotAll":{"type":"boolean"}},"additionalProperties":false,"required":["dotAll","flags","global","ignoreCase","lastIndex","multiline","source","sticky","unicode"]},"GoogleAnalyticsInitializeOptions":{"type":"object","properties":{"cacheName":{"type":"string"},"parameterOverrides":{"type":"object","additionalProperties":{"type":"string"}},"hitFilter":{"type":"object","additionalProperties":false}},"additionalProperties":false},"RuntimeCaching":{"type":"object","properties":{"handler":{"anyOf":[{"$ref":"#/definitions/RouteHandlerCallback"},{"$ref":"#/definitions/RouteHandlerObject"},{"enum":["CacheFirst","CacheOnly","NetworkFirst","NetworkOnly","StaleWhileRevalidate"],"type":"string"}]},"method":{"enum":["DELETE","GET","HEAD","PATCH","POST","PUT"],"type":"string"},"options":{"type":"object","properties":{"backgroundSync":{"type":"object","properties":{"name":{"type":"string"},"options":{"$ref":"#/definitions/QueueOptions"}},"additionalProperties":false,"required":["name"]},"broadcastUpdate":{"type":"object","properties":{"channelName":{"type":"string"},"options":{"$ref":"#/definitions/BroadcastCacheUpdateOptions"}},"additionalProperties":false,"required":["options"]},"cacheableResponse":{"$ref":"#/definitions/CacheableResponseOptions"},"cacheName":{"type":["null","string"]},"expiration":{"$ref":"#/definitions/ExpirationPluginOptions"},"networkTimeoutSeconds":{"type":"number"},"plugins":{"type":"array","items":{"$ref":"#/definitions/WorkboxPlugin"}},"precacheFallback":{"type":"object","properties":{"fallbackURL":{"type":"string"}},"additionalProperties":false,"required":["fallbackURL"]},"fetchOptions":{"$ref":"#/definitions/RequestInit"},"matchOptions":{"$ref":"#/definitions/CacheQueryOptions"}},"additionalProperties":false},"urlPattern":{"anyOf":[{"$ref":"#/definitions/RegExp"},{"$ref":"#/definitions/RouteMatchCallback"},{"type":"string"}]}},"additionalProperties":false,"required":["handler","urlPattern"]},"RouteHandlerCallback":{"description":"The \"handler\" callback is invoked whenever a `Router` matches a URL/Request\nto a `Route` via its `RouteMatchCallback`. This handler callback should\nreturn a `Promise` that resolves with a `Response`.\n\nIf a non-empty array or object is returned by the `RouteMatchCallback` it\nwill be passed in as this handler's `options.params` argument.","type":"object","additionalProperties":false},"RouteHandlerObject":{"description":"An object with a `handle` method of type `RouteHandlerCallback`.\n\nA `Route` object can be created with either an `RouteHandlerCallback`\nfunction or this `RouteHandler` object. The benefit of the `RouteHandler`\nis it can be extended (as is done by the `workbox-strategies` package).","type":"object","properties":{"handle":{"$ref":"#/definitions/RouteHandlerCallback"}},"additionalProperties":false,"required":["handle"]},"QueueOptions":{"type":"object","properties":{"onSync":{"$ref":"#/definitions/OnSyncCallback"},"maxRetentionTime":{"type":"number"}},"additionalProperties":false},"OnSyncCallback":{"type":"object","additionalProperties":false},"BroadcastCacheUpdateOptions":{"type":"object","properties":{"headersToCheck":{"type":"array","items":{"type":"string"}},"generatePayload":{"type":"object","additionalProperties":false}},"additionalProperties":false},"CacheableResponseOptions":{"type":"object","properties":{"statuses":{"type":"array","items":{"type":"number"}},"headers":{"type":"object","additionalProperties":{"type":"string"}}},"additionalProperties":false},"ExpirationPluginOptions":{"type":"object","properties":{"maxEntries":{"type":"number"},"maxAgeSeconds":{"type":"number"},"matchOptions":{"$ref":"#/definitions/CacheQueryOptions"},"purgeOnQuotaError":{"type":"boolean"}},"additionalProperties":false},"CacheQueryOptions":{"type":"object","properties":{"ignoreMethod":{"type":"boolean"},"ignoreSearch":{"type":"boolean"},"ignoreVary":{"type":"boolean"}},"additionalProperties":false},"WorkboxPlugin":{"description":"An object with optional lifecycle callback properties for the fetch and\ncache operations.","type":"object","properties":{"cacheDidUpdate":{"$ref":"#/definitions/CacheDidUpdateCallback"},"cachedResponseWillBeUsed":{"$ref":"#/definitions/CachedResponseWillBeUsedCallback"},"cacheKeyWillBeUsed":{"$ref":"#/definitions/CacheKeyWillBeUsedCallback"},"cacheWillUpdate":{"$ref":"#/definitions/CacheWillUpdateCallback"},"fetchDidFail":{"$ref":"#/definitions/FetchDidFailCallback"},"fetchDidSucceed":{"$ref":"#/definitions/FetchDidSucceedCallback"},"handlerDidComplete":{"$ref":"#/definitions/HandlerDidCompleteCallback"},"handlerDidError":{"$ref":"#/definitions/HandlerDidErrorCallback"},"handlerDidRespond":{"$ref":"#/definitions/HandlerDidRespondCallback"},"handlerWillRespond":{"$ref":"#/definitions/HandlerWillRespondCallback"},"handlerWillStart":{"$ref":"#/definitions/HandlerWillStartCallback"},"requestWillFetch":{"$ref":"#/definitions/RequestWillFetchCallback"}},"additionalProperties":false},"CacheDidUpdateCallback":{"type":"object","additionalProperties":false},"CachedResponseWillBeUsedCallback":{"type":"object","additionalProperties":false},"CacheKeyWillBeUsedCallback":{"type":"object","additionalProperties":false},"CacheWillUpdateCallback":{"type":"object","additionalProperties":false},"FetchDidFailCallback":{"type":"object","additionalProperties":false},"FetchDidSucceedCallback":{"type":"object","additionalProperties":false},"HandlerDidCompleteCallback":{"type":"object","additionalProperties":false},"HandlerDidErrorCallback":{"type":"object","additionalProperties":false},"HandlerDidRespondCallback":{"type":"object","additionalProperties":false},"HandlerWillRespondCallback":{"type":"object","additionalProperties":false},"HandlerWillStartCallback":{"type":"object","additionalProperties":false},"RequestWillFetchCallback":{"type":"object","additionalProperties":false},"RequestInit":{"type":"object","properties":{"body":{"anyOf":[{"$ref":"#/definitions/ArrayBuffer"},{"$ref":"#/definitions/ArrayBufferView"},{"$ref":"#/definitions/Blob"},{"$ref":"#/definitions/FormData"},{"$ref":"#/definitions/URLSearchParams"},{"$ref":"#/definitions/ReadableStream"},{"type":["null","string"]}]},"cache":{"enum":["default","force-cache","no-cache","no-store","only-if-cached","reload"],"type":"string"},"credentials":{"enum":["include","omit","same-origin"],"type":"string"},"headers":{"anyOf":[{"$ref":"#/definitions/Headers"},{"type":"array","items":{"type":"array","items":{"type":"string"}}},{"$ref":"#/definitions/Record"}]},"integrity":{"type":"string"},"keepalive":{"type":"boolean"},"method":{"type":"string"},"mode":{"enum":["cors","navigate","no-cors","same-origin"],"type":"string"},"redirect":{"enum":["error","follow","manual"],"type":"string"},"referrer":{"type":"string"},"referrerPolicy":{"enum":["","no-referrer","no-referrer-when-downgrade","origin","origin-when-cross-origin","same-origin","strict-origin","strict-origin-when-cross-origin","unsafe-url"],"type":"string"},"signal":{"anyOf":[{"$ref":"#/definitions/AbortSignal"},{"type":"null"}]},"window":{}},"additionalProperties":false},"ArrayBuffer":{"type":"object","properties":{"byteLength":{"type":"number"},"__@toStringTag":{"type":"string"}},"additionalProperties":false,"required":["__@toStringTag","byteLength"]},"ArrayBufferView":{"type":"object","properties":{"buffer":{"anyOf":[{"$ref":"#/definitions/ArrayBuffer"},{"$ref":"#/definitions/SharedArrayBuffer"}]},"byteLength":{"type":"number"},"byteOffset":{"type":"number"}},"additionalProperties":false,"required":["buffer","byteLength","byteOffset"]},"SharedArrayBuffer":{"type":"object","properties":{"byteLength":{"type":"number"},"__@species":{"$ref":"#/definitions/SharedArrayBuffer"},"__@toStringTag":{"type":"string","enum":["SharedArrayBuffer"]}},"additionalProperties":false,"required":["__@species","__@toStringTag","byteLength"]},"Blob":{"type":"object","properties":{"size":{"type":"number"},"type":{"type":"string"}},"additionalProperties":false,"required":["size","type"]},"FormData":{"type":"object","additionalProperties":false},"URLSearchParams":{"type":"object","additionalProperties":false},"ReadableStream":{"type":"object","properties":{"locked":{"type":"boolean"}},"additionalProperties":false,"required":["locked"]},"Headers":{"type":"object","additionalProperties":false},"Record":{"type":"object","additionalProperties":false},"AbortSignal":{"type":"object","properties":{"aborted":{"type":"boolean"},"onabort":{"anyOf":[{"type":"object","additionalProperties":false},{"type":"null"}]}},"additionalProperties":false,"required":["aborted","onabort"]},"RouteMatchCallback":{"description":"The \"match\" callback is used to determine if a `Route` should apply for a\nparticular URL and request. When matching occurs in response to a fetch\nevent from the client, the `event` object is also supplied. However, since\nthe match callback can be invoked outside of a fetch event, matching logic\nshould not assume the `event` object will always be available.\nIf the match callback returns a truthy value, the matching route's\n`RouteHandlerCallback` will be invoked immediately. If the value returned\nis a non-empty array or object, that value will be set on the handler's\n`options.params` argument.","type":"object","additionalProperties":false},"ManifestEntry":{"type":"object","properties":{"integrity":{"type":"string"},"revision":{"type":["null","string"]},"url":{"type":"string"}},"additionalProperties":false,"required":["revision","url"]}},"$schema":"http://json-schema.org/draft-07/schema#"} +{"additionalProperties":false,"type":"object","properties":{"globDirectory":{"type":"string"},"globFollow":{"default":true,"type":"boolean"},"globIgnores":{"default":["**/node_modules/**/*"],"type":"array","items":{"type":"string"}},"globPatterns":{"default":["**/*.{js,css,html}"],"type":"array","items":{"type":"string"}},"globStrict":{"default":true,"type":"boolean"},"templatedURLs":{"typeof":"function"},"babelPresetEnvTargets":{"default":["chrome >= 56"],"type":"array","items":{"type":"string"}},"cacheId":{"type":["null","string"]},"cleanupOutdatedCaches":{"default":false,"type":"boolean"},"clientsClaim":{"default":false,"type":"boolean"},"directoryIndex":{"type":["null","string"]},"disableDevLogs":{"default":false,"type":"boolean"},"ignoreURLParametersMatching":{"type":"array","items":{"$ref":"#/definitions/RegExp"}},"importScripts":{"type":"array","items":{"type":"string"}},"inlineWorkboxRuntime":{"default":false,"type":"boolean"},"mode":{"default":"production","type":["null","string"]},"navigateFallback":{"default":null,"type":["null","string"]},"navigateFallbackAllowlist":{"type":"array","items":{"$ref":"#/definitions/RegExp"}},"navigateFallbackDenylist":{"type":"array","items":{"$ref":"#/definitions/RegExp"}},"navigationPreload":{"default":false,"type":"boolean"},"offlineGoogleAnalytics":{"default":false,"anyOf":[{"$ref":"#/definitions/GoogleAnalyticsInitializeOptions"},{"type":"boolean"}]},"runtimeCaching":{"type":"array","items":{"$ref":"#/definitions/RuntimeCaching"}},"skipWaiting":{"default":false,"type":"boolean"},"sourcemap":{"default":true,"type":"boolean"},"swDest":{"type":"string"}},"required":["globDirectory","swDest"],"definitions":{"RegExp":{"type":"object","properties":{"source":{"type":"string"},"global":{"type":"boolean"},"ignoreCase":{"type":"boolean"},"multiline":{"type":"boolean"},"lastIndex":{"type":"number"},"flags":{"type":"string"},"sticky":{"type":"boolean"},"unicode":{"type":"boolean"},"dotAll":{"type":"boolean"}},"additionalProperties":false,"required":["dotAll","flags","global","ignoreCase","lastIndex","multiline","source","sticky","unicode"]},"GoogleAnalyticsInitializeOptions":{"type":"object","properties":{"cacheName":{"type":"string"},"parameterOverrides":{"typeof":"function"},"hitFilter":{"typeof":"function"}},"additionalProperties":false},"RuntimeCaching":{"type":"object","properties":{"handler":{"anyOf":[{"$ref":"#/definitions/RouteHandlerCallback"},{"$ref":"#/definitions/RouteHandlerObject"},{"enum":["CacheFirst","CacheOnly","NetworkFirst","NetworkOnly","StaleWhileRevalidate"],"type":"string"}]},"method":{"enum":["DELETE","GET","HEAD","PATCH","POST","PUT"],"type":"string"},"options":{"typeof":"function"},"urlPattern":{"anyOf":[{"$ref":"#/definitions/RegExp"},{"$ref":"#/definitions/RouteMatchCallback"},{"type":"string"}]}},"additionalProperties":false,"required":["handler","urlPattern"]},"RouteHandlerCallback":{"description":"The \"handler\" callback is invoked whenever a `Router` matches a URL/Request\nto a `Route` via its `RouteMatchCallback`. This handler callback should\nreturn a `Promise` that resolves with a `Response`.\n\nIf a non-empty array or object is returned by the `RouteMatchCallback` it\nwill be passed in as this handler's `options.params` argument.","type":"object","additionalProperties":false},"RouteHandlerObject":{"description":"An object with a `handle` method of type `RouteHandlerCallback`.\n\nA `Route` object can be created with either an `RouteHandlerCallback`\nfunction or this `RouteHandler` object. The benefit of the `RouteHandler`\nis it can be extended (as is done by the `workbox-strategies` package).","type":"object","properties":{"handle":{"$ref":"#/definitions/RouteHandlerCallback"}},"additionalProperties":false,"required":["handle"]},"RouteMatchCallback":{"description":"The \"match\" callback is used to determine if a `Route` should apply for a\nparticular URL and request. When matching occurs in response to a fetch\nevent from the client, the `event` object is also supplied. However, since\nthe match callback can be invoked outside of a fetch event, matching logic\nshould not assume the `event` object will always be available.\nIf the match callback returns a truthy value, the matching route's\n`RouteHandlerCallback` will be invoked immediately. If the value returned\nis a non-empty array or object, that value will be set on the handler's\n`options.params` argument.","type":"object","additionalProperties":false}},"$schema":"http://json-schema.org/draft-07/schema#"} diff --git a/packages/workbox-build/src/schema/GetManifestOptions.json b/packages/workbox-build/src/schema/GetManifestOptions.json index 504ae7b38..5017a5257 100644 --- a/packages/workbox-build/src/schema/GetManifestOptions.json +++ b/packages/workbox-build/src/schema/GetManifestOptions.json @@ -1 +1 @@ -{"additionalProperties":false,"type":"object","properties":{"globDirectory":{"type":"string"},"globFollow":{"default":true,"type":"boolean"},"globIgnores":{"default":["**/node_modules/**/*"],"type":"array","items":{"type":"string"}},"globPatterns":{"default":["**/*.{js,css,html}"],"type":"array","items":{"type":"string"}},"globStrict":{"default":true,"type":"boolean"},"templatedURLs":{"type":"object","additionalProperties":{"anyOf":[{"type":"array","items":{"type":"string"}},{"type":"string"}]}},"additionalManifestEntries":{"type":"array","items":{"anyOf":[{"$ref":"#/definitions/ManifestEntry"},{"type":"string"}]}},"dontCacheBustURLsMatching":{"$ref":"#/definitions/RegExp"},"manifestTransforms":{"type":"array","items":{"type":"object","additionalProperties":false}},"maximumFileSizeToCacheInBytes":{"default":2097152,"type":"number"},"modifyURLPrefix":{"type":"object","additionalProperties":{"type":"string"}}},"required":["globDirectory"],"definitions":{"RegExp":{"type":"object","properties":{"source":{"type":"string"},"global":{"type":"boolean"},"ignoreCase":{"type":"boolean"},"multiline":{"type":"boolean"},"lastIndex":{"type":"number"},"flags":{"type":"string"},"sticky":{"type":"boolean"},"unicode":{"type":"boolean"},"dotAll":{"type":"boolean"}},"additionalProperties":false,"required":["dotAll","flags","global","ignoreCase","lastIndex","multiline","source","sticky","unicode"]},"GoogleAnalyticsInitializeOptions":{"type":"object","properties":{"cacheName":{"type":"string"},"parameterOverrides":{"type":"object","additionalProperties":{"type":"string"}},"hitFilter":{"type":"object","additionalProperties":false}},"additionalProperties":false},"RuntimeCaching":{"type":"object","properties":{"handler":{"anyOf":[{"$ref":"#/definitions/RouteHandlerCallback"},{"$ref":"#/definitions/RouteHandlerObject"},{"enum":["CacheFirst","CacheOnly","NetworkFirst","NetworkOnly","StaleWhileRevalidate"],"type":"string"}]},"method":{"enum":["DELETE","GET","HEAD","PATCH","POST","PUT"],"type":"string"},"options":{"type":"object","properties":{"backgroundSync":{"type":"object","properties":{"name":{"type":"string"},"options":{"$ref":"#/definitions/QueueOptions"}},"additionalProperties":false,"required":["name"]},"broadcastUpdate":{"type":"object","properties":{"channelName":{"type":"string"},"options":{"$ref":"#/definitions/BroadcastCacheUpdateOptions"}},"additionalProperties":false,"required":["options"]},"cacheableResponse":{"$ref":"#/definitions/CacheableResponseOptions"},"cacheName":{"type":["null","string"]},"expiration":{"$ref":"#/definitions/ExpirationPluginOptions"},"networkTimeoutSeconds":{"type":"number"},"plugins":{"type":"array","items":{"$ref":"#/definitions/WorkboxPlugin"}},"precacheFallback":{"type":"object","properties":{"fallbackURL":{"type":"string"}},"additionalProperties":false,"required":["fallbackURL"]},"fetchOptions":{"$ref":"#/definitions/RequestInit"},"matchOptions":{"$ref":"#/definitions/CacheQueryOptions"}},"additionalProperties":false},"urlPattern":{"anyOf":[{"$ref":"#/definitions/RegExp"},{"$ref":"#/definitions/RouteMatchCallback"},{"type":"string"}]}},"additionalProperties":false,"required":["handler","urlPattern"]},"RouteHandlerCallback":{"description":"The \"handler\" callback is invoked whenever a `Router` matches a URL/Request\nto a `Route` via its `RouteMatchCallback`. This handler callback should\nreturn a `Promise` that resolves with a `Response`.\n\nIf a non-empty array or object is returned by the `RouteMatchCallback` it\nwill be passed in as this handler's `options.params` argument.","type":"object","additionalProperties":false},"RouteHandlerObject":{"description":"An object with a `handle` method of type `RouteHandlerCallback`.\n\nA `Route` object can be created with either an `RouteHandlerCallback`\nfunction or this `RouteHandler` object. The benefit of the `RouteHandler`\nis it can be extended (as is done by the `workbox-strategies` package).","type":"object","properties":{"handle":{"$ref":"#/definitions/RouteHandlerCallback"}},"additionalProperties":false,"required":["handle"]},"QueueOptions":{"type":"object","properties":{"onSync":{"$ref":"#/definitions/OnSyncCallback"},"maxRetentionTime":{"type":"number"}},"additionalProperties":false},"OnSyncCallback":{"type":"object","additionalProperties":false},"BroadcastCacheUpdateOptions":{"type":"object","properties":{"headersToCheck":{"type":"array","items":{"type":"string"}},"generatePayload":{"type":"object","additionalProperties":false}},"additionalProperties":false},"CacheableResponseOptions":{"type":"object","properties":{"statuses":{"type":"array","items":{"type":"number"}},"headers":{"type":"object","additionalProperties":{"type":"string"}}},"additionalProperties":false},"ExpirationPluginOptions":{"type":"object","properties":{"maxEntries":{"type":"number"},"maxAgeSeconds":{"type":"number"},"matchOptions":{"$ref":"#/definitions/CacheQueryOptions"},"purgeOnQuotaError":{"type":"boolean"}},"additionalProperties":false},"CacheQueryOptions":{"type":"object","properties":{"ignoreMethod":{"type":"boolean"},"ignoreSearch":{"type":"boolean"},"ignoreVary":{"type":"boolean"}},"additionalProperties":false},"WorkboxPlugin":{"description":"An object with optional lifecycle callback properties for the fetch and\ncache operations.","type":"object","properties":{"cacheDidUpdate":{"$ref":"#/definitions/CacheDidUpdateCallback"},"cachedResponseWillBeUsed":{"$ref":"#/definitions/CachedResponseWillBeUsedCallback"},"cacheKeyWillBeUsed":{"$ref":"#/definitions/CacheKeyWillBeUsedCallback"},"cacheWillUpdate":{"$ref":"#/definitions/CacheWillUpdateCallback"},"fetchDidFail":{"$ref":"#/definitions/FetchDidFailCallback"},"fetchDidSucceed":{"$ref":"#/definitions/FetchDidSucceedCallback"},"handlerDidComplete":{"$ref":"#/definitions/HandlerDidCompleteCallback"},"handlerDidError":{"$ref":"#/definitions/HandlerDidErrorCallback"},"handlerDidRespond":{"$ref":"#/definitions/HandlerDidRespondCallback"},"handlerWillRespond":{"$ref":"#/definitions/HandlerWillRespondCallback"},"handlerWillStart":{"$ref":"#/definitions/HandlerWillStartCallback"},"requestWillFetch":{"$ref":"#/definitions/RequestWillFetchCallback"}},"additionalProperties":false},"CacheDidUpdateCallback":{"type":"object","additionalProperties":false},"CachedResponseWillBeUsedCallback":{"type":"object","additionalProperties":false},"CacheKeyWillBeUsedCallback":{"type":"object","additionalProperties":false},"CacheWillUpdateCallback":{"type":"object","additionalProperties":false},"FetchDidFailCallback":{"type":"object","additionalProperties":false},"FetchDidSucceedCallback":{"type":"object","additionalProperties":false},"HandlerDidCompleteCallback":{"type":"object","additionalProperties":false},"HandlerDidErrorCallback":{"type":"object","additionalProperties":false},"HandlerDidRespondCallback":{"type":"object","additionalProperties":false},"HandlerWillRespondCallback":{"type":"object","additionalProperties":false},"HandlerWillStartCallback":{"type":"object","additionalProperties":false},"RequestWillFetchCallback":{"type":"object","additionalProperties":false},"RequestInit":{"type":"object","properties":{"body":{"anyOf":[{"$ref":"#/definitions/ArrayBuffer"},{"$ref":"#/definitions/ArrayBufferView"},{"$ref":"#/definitions/Blob"},{"$ref":"#/definitions/FormData"},{"$ref":"#/definitions/URLSearchParams"},{"$ref":"#/definitions/ReadableStream"},{"type":["null","string"]}]},"cache":{"enum":["default","force-cache","no-cache","no-store","only-if-cached","reload"],"type":"string"},"credentials":{"enum":["include","omit","same-origin"],"type":"string"},"headers":{"anyOf":[{"$ref":"#/definitions/Headers"},{"type":"array","items":{"type":"array","items":{"type":"string"}}},{"$ref":"#/definitions/Record"}]},"integrity":{"type":"string"},"keepalive":{"type":"boolean"},"method":{"type":"string"},"mode":{"enum":["cors","navigate","no-cors","same-origin"],"type":"string"},"redirect":{"enum":["error","follow","manual"],"type":"string"},"referrer":{"type":"string"},"referrerPolicy":{"enum":["","no-referrer","no-referrer-when-downgrade","origin","origin-when-cross-origin","same-origin","strict-origin","strict-origin-when-cross-origin","unsafe-url"],"type":"string"},"signal":{"anyOf":[{"$ref":"#/definitions/AbortSignal"},{"type":"null"}]},"window":{}},"additionalProperties":false},"ArrayBuffer":{"type":"object","properties":{"byteLength":{"type":"number"},"__@toStringTag":{"type":"string"}},"additionalProperties":false,"required":["__@toStringTag","byteLength"]},"ArrayBufferView":{"type":"object","properties":{"buffer":{"anyOf":[{"$ref":"#/definitions/ArrayBuffer"},{"$ref":"#/definitions/SharedArrayBuffer"}]},"byteLength":{"type":"number"},"byteOffset":{"type":"number"}},"additionalProperties":false,"required":["buffer","byteLength","byteOffset"]},"SharedArrayBuffer":{"type":"object","properties":{"byteLength":{"type":"number"},"__@species":{"$ref":"#/definitions/SharedArrayBuffer"},"__@toStringTag":{"type":"string","enum":["SharedArrayBuffer"]}},"additionalProperties":false,"required":["__@species","__@toStringTag","byteLength"]},"Blob":{"type":"object","properties":{"size":{"type":"number"},"type":{"type":"string"}},"additionalProperties":false,"required":["size","type"]},"FormData":{"type":"object","additionalProperties":false},"URLSearchParams":{"type":"object","additionalProperties":false},"ReadableStream":{"type":"object","properties":{"locked":{"type":"boolean"}},"additionalProperties":false,"required":["locked"]},"Headers":{"type":"object","additionalProperties":false},"Record":{"type":"object","additionalProperties":false},"AbortSignal":{"type":"object","properties":{"aborted":{"type":"boolean"},"onabort":{"anyOf":[{"type":"object","additionalProperties":false},{"type":"null"}]}},"additionalProperties":false,"required":["aborted","onabort"]},"RouteMatchCallback":{"description":"The \"match\" callback is used to determine if a `Route` should apply for a\nparticular URL and request. When matching occurs in response to a fetch\nevent from the client, the `event` object is also supplied. However, since\nthe match callback can be invoked outside of a fetch event, matching logic\nshould not assume the `event` object will always be available.\nIf the match callback returns a truthy value, the matching route's\n`RouteHandlerCallback` will be invoked immediately. If the value returned\nis a non-empty array or object, that value will be set on the handler's\n`options.params` argument.","type":"object","additionalProperties":false},"ManifestEntry":{"type":"object","properties":{"integrity":{"type":"string"},"revision":{"type":["null","string"]},"url":{"type":"string"}},"additionalProperties":false,"required":["revision","url"]}},"$schema":"http://json-schema.org/draft-07/schema#"} +{"additionalProperties":false,"type":"object","properties":{"globDirectory":{"type":"string"},"globFollow":{"default":true,"type":"boolean"},"globIgnores":{"default":["**/node_modules/**/*"],"type":"array","items":{"type":"string"}},"globPatterns":{"default":["**/*.{js,css,html}"],"type":"array","items":{"type":"string"}},"globStrict":{"default":true,"type":"boolean"},"templatedURLs":{"typeof":"function"},"additionalManifestEntries":{"type":"array","items":{"anyOf":[{"$ref":"#/definitions/ManifestEntry"},{"type":"string"}]}},"dontCacheBustURLsMatching":{"$ref":"#/definitions/RegExp"},"manifestTransforms":{"type":"array","items":{"typeof":"function"}},"maximumFileSizeToCacheInBytes":{"default":2097152,"type":"number"},"modifyURLPrefix":{"typeof":"function"}},"required":["globDirectory"],"definitions":{"RegExp":{"type":"object","properties":{"source":{"type":"string"},"global":{"type":"boolean"},"ignoreCase":{"type":"boolean"},"multiline":{"type":"boolean"},"lastIndex":{"type":"number"},"flags":{"type":"string"},"sticky":{"type":"boolean"},"unicode":{"type":"boolean"},"dotAll":{"type":"boolean"}},"additionalProperties":false,"required":["dotAll","flags","global","ignoreCase","lastIndex","multiline","source","sticky","unicode"]},"GoogleAnalyticsInitializeOptions":{"type":"object","properties":{"cacheName":{"type":"string"},"parameterOverrides":{"typeof":"function"},"hitFilter":{"typeof":"function"}},"additionalProperties":false},"RuntimeCaching":{"type":"object","properties":{"handler":{"anyOf":[{"$ref":"#/definitions/RouteHandlerCallback"},{"$ref":"#/definitions/RouteHandlerObject"},{"enum":["CacheFirst","CacheOnly","NetworkFirst","NetworkOnly","StaleWhileRevalidate"],"type":"string"}]},"method":{"enum":["DELETE","GET","HEAD","PATCH","POST","PUT"],"type":"string"},"options":{"typeof":"function"},"urlPattern":{"anyOf":[{"$ref":"#/definitions/RegExp"},{"$ref":"#/definitions/RouteMatchCallback"},{"type":"string"}]}},"additionalProperties":false,"required":["handler","urlPattern"]},"RouteHandlerCallback":{"description":"The \"handler\" callback is invoked whenever a `Router` matches a URL/Request\nto a `Route` via its `RouteMatchCallback`. This handler callback should\nreturn a `Promise` that resolves with a `Response`.\n\nIf a non-empty array or object is returned by the `RouteMatchCallback` it\nwill be passed in as this handler's `options.params` argument.","type":"object","additionalProperties":false},"RouteHandlerObject":{"description":"An object with a `handle` method of type `RouteHandlerCallback`.\n\nA `Route` object can be created with either an `RouteHandlerCallback`\nfunction or this `RouteHandler` object. The benefit of the `RouteHandler`\nis it can be extended (as is done by the `workbox-strategies` package).","type":"object","properties":{"handle":{"$ref":"#/definitions/RouteHandlerCallback"}},"additionalProperties":false,"required":["handle"]},"RouteMatchCallback":{"description":"The \"match\" callback is used to determine if a `Route` should apply for a\nparticular URL and request. When matching occurs in response to a fetch\nevent from the client, the `event` object is also supplied. However, since\nthe match callback can be invoked outside of a fetch event, matching logic\nshould not assume the `event` object will always be available.\nIf the match callback returns a truthy value, the matching route's\n`RouteHandlerCallback` will be invoked immediately. If the value returned\nis a non-empty array or object, that value will be set on the handler's\n`options.params` argument.","type":"object","additionalProperties":false},"ManifestEntry":{"type":"object","properties":{"integrity":{"type":"string"},"revision":{"type":["null","string"]},"url":{"type":"string"}},"additionalProperties":false,"required":["revision","url"]}},"$schema":"http://json-schema.org/draft-07/schema#"} diff --git a/packages/workbox-build/src/schema/InjectManifestOptions.json b/packages/workbox-build/src/schema/InjectManifestOptions.json index 1d31fc396..1836ddc1f 100644 --- a/packages/workbox-build/src/schema/InjectManifestOptions.json +++ b/packages/workbox-build/src/schema/InjectManifestOptions.json @@ -1 +1 @@ -{"additionalProperties":false,"type":"object","properties":{"injectionPoint":{"default":"self.__WB_MANIFEST","type":"string"},"swSrc":{"type":"string"},"globFollow":{"default":true,"type":"boolean"},"globIgnores":{"default":["**/node_modules/**/*"],"type":"array","items":{"type":"string"}},"globPatterns":{"default":["**/*.{js,css,html}"],"type":"array","items":{"type":"string"}},"globStrict":{"default":true,"type":"boolean"},"templatedURLs":{"type":"object","additionalProperties":{"anyOf":[{"type":"array","items":{"type":"string"}},{"type":"string"}]}},"additionalManifestEntries":{"type":"array","items":{"anyOf":[{"$ref":"#/definitions/ManifestEntry"},{"type":"string"}]}},"dontCacheBustURLsMatching":{"$ref":"#/definitions/RegExp"},"manifestTransforms":{"type":"array","items":{"type":"object","additionalProperties":false}},"maximumFileSizeToCacheInBytes":{"default":2097152,"type":"number"},"modifyURLPrefix":{"type":"object","additionalProperties":{"type":"string"}},"swDest":{"type":"string"},"globDirectory":{"type":"string"}},"required":["globDirectory","swDest","swSrc"],"definitions":{"RegExp":{"type":"object","properties":{"source":{"type":"string"},"global":{"type":"boolean"},"ignoreCase":{"type":"boolean"},"multiline":{"type":"boolean"},"lastIndex":{"type":"number"},"flags":{"type":"string"},"sticky":{"type":"boolean"},"unicode":{"type":"boolean"},"dotAll":{"type":"boolean"}},"additionalProperties":false,"required":["dotAll","flags","global","ignoreCase","lastIndex","multiline","source","sticky","unicode"]},"GoogleAnalyticsInitializeOptions":{"type":"object","properties":{"cacheName":{"type":"string"},"parameterOverrides":{"type":"object","additionalProperties":{"type":"string"}},"hitFilter":{"type":"object","additionalProperties":false}},"additionalProperties":false},"RuntimeCaching":{"type":"object","properties":{"handler":{"anyOf":[{"$ref":"#/definitions/RouteHandlerCallback"},{"$ref":"#/definitions/RouteHandlerObject"},{"enum":["CacheFirst","CacheOnly","NetworkFirst","NetworkOnly","StaleWhileRevalidate"],"type":"string"}]},"method":{"enum":["DELETE","GET","HEAD","PATCH","POST","PUT"],"type":"string"},"options":{"type":"object","properties":{"backgroundSync":{"type":"object","properties":{"name":{"type":"string"},"options":{"$ref":"#/definitions/QueueOptions"}},"additionalProperties":false,"required":["name"]},"broadcastUpdate":{"type":"object","properties":{"channelName":{"type":"string"},"options":{"$ref":"#/definitions/BroadcastCacheUpdateOptions"}},"additionalProperties":false,"required":["options"]},"cacheableResponse":{"$ref":"#/definitions/CacheableResponseOptions"},"cacheName":{"type":["null","string"]},"expiration":{"$ref":"#/definitions/ExpirationPluginOptions"},"networkTimeoutSeconds":{"type":"number"},"plugins":{"type":"array","items":{"$ref":"#/definitions/WorkboxPlugin"}},"precacheFallback":{"type":"object","properties":{"fallbackURL":{"type":"string"}},"additionalProperties":false,"required":["fallbackURL"]},"fetchOptions":{"$ref":"#/definitions/RequestInit"},"matchOptions":{"$ref":"#/definitions/CacheQueryOptions"}},"additionalProperties":false},"urlPattern":{"anyOf":[{"$ref":"#/definitions/RegExp"},{"$ref":"#/definitions/RouteMatchCallback"},{"type":"string"}]}},"additionalProperties":false,"required":["handler","urlPattern"]},"RouteHandlerCallback":{"description":"The \"handler\" callback is invoked whenever a `Router` matches a URL/Request\nto a `Route` via its `RouteMatchCallback`. This handler callback should\nreturn a `Promise` that resolves with a `Response`.\n\nIf a non-empty array or object is returned by the `RouteMatchCallback` it\nwill be passed in as this handler's `options.params` argument.","type":"object","additionalProperties":false},"RouteHandlerObject":{"description":"An object with a `handle` method of type `RouteHandlerCallback`.\n\nA `Route` object can be created with either an `RouteHandlerCallback`\nfunction or this `RouteHandler` object. The benefit of the `RouteHandler`\nis it can be extended (as is done by the `workbox-strategies` package).","type":"object","properties":{"handle":{"$ref":"#/definitions/RouteHandlerCallback"}},"additionalProperties":false,"required":["handle"]},"QueueOptions":{"type":"object","properties":{"onSync":{"$ref":"#/definitions/OnSyncCallback"},"maxRetentionTime":{"type":"number"}},"additionalProperties":false},"OnSyncCallback":{"type":"object","additionalProperties":false},"BroadcastCacheUpdateOptions":{"type":"object","properties":{"headersToCheck":{"type":"array","items":{"type":"string"}},"generatePayload":{"type":"object","additionalProperties":false}},"additionalProperties":false},"CacheableResponseOptions":{"type":"object","properties":{"statuses":{"type":"array","items":{"type":"number"}},"headers":{"type":"object","additionalProperties":{"type":"string"}}},"additionalProperties":false},"ExpirationPluginOptions":{"type":"object","properties":{"maxEntries":{"type":"number"},"maxAgeSeconds":{"type":"number"},"matchOptions":{"$ref":"#/definitions/CacheQueryOptions"},"purgeOnQuotaError":{"type":"boolean"}},"additionalProperties":false},"CacheQueryOptions":{"type":"object","properties":{"ignoreMethod":{"type":"boolean"},"ignoreSearch":{"type":"boolean"},"ignoreVary":{"type":"boolean"}},"additionalProperties":false},"WorkboxPlugin":{"description":"An object with optional lifecycle callback properties for the fetch and\ncache operations.","type":"object","properties":{"cacheDidUpdate":{"$ref":"#/definitions/CacheDidUpdateCallback"},"cachedResponseWillBeUsed":{"$ref":"#/definitions/CachedResponseWillBeUsedCallback"},"cacheKeyWillBeUsed":{"$ref":"#/definitions/CacheKeyWillBeUsedCallback"},"cacheWillUpdate":{"$ref":"#/definitions/CacheWillUpdateCallback"},"fetchDidFail":{"$ref":"#/definitions/FetchDidFailCallback"},"fetchDidSucceed":{"$ref":"#/definitions/FetchDidSucceedCallback"},"handlerDidComplete":{"$ref":"#/definitions/HandlerDidCompleteCallback"},"handlerDidError":{"$ref":"#/definitions/HandlerDidErrorCallback"},"handlerDidRespond":{"$ref":"#/definitions/HandlerDidRespondCallback"},"handlerWillRespond":{"$ref":"#/definitions/HandlerWillRespondCallback"},"handlerWillStart":{"$ref":"#/definitions/HandlerWillStartCallback"},"requestWillFetch":{"$ref":"#/definitions/RequestWillFetchCallback"}},"additionalProperties":false},"CacheDidUpdateCallback":{"type":"object","additionalProperties":false},"CachedResponseWillBeUsedCallback":{"type":"object","additionalProperties":false},"CacheKeyWillBeUsedCallback":{"type":"object","additionalProperties":false},"CacheWillUpdateCallback":{"type":"object","additionalProperties":false},"FetchDidFailCallback":{"type":"object","additionalProperties":false},"FetchDidSucceedCallback":{"type":"object","additionalProperties":false},"HandlerDidCompleteCallback":{"type":"object","additionalProperties":false},"HandlerDidErrorCallback":{"type":"object","additionalProperties":false},"HandlerDidRespondCallback":{"type":"object","additionalProperties":false},"HandlerWillRespondCallback":{"type":"object","additionalProperties":false},"HandlerWillStartCallback":{"type":"object","additionalProperties":false},"RequestWillFetchCallback":{"type":"object","additionalProperties":false},"RequestInit":{"type":"object","properties":{"body":{"anyOf":[{"$ref":"#/definitions/ArrayBuffer"},{"$ref":"#/definitions/ArrayBufferView"},{"$ref":"#/definitions/Blob"},{"$ref":"#/definitions/FormData"},{"$ref":"#/definitions/URLSearchParams"},{"$ref":"#/definitions/ReadableStream"},{"type":["null","string"]}]},"cache":{"enum":["default","force-cache","no-cache","no-store","only-if-cached","reload"],"type":"string"},"credentials":{"enum":["include","omit","same-origin"],"type":"string"},"headers":{"anyOf":[{"$ref":"#/definitions/Headers"},{"type":"array","items":{"type":"array","items":{"type":"string"}}},{"$ref":"#/definitions/Record"}]},"integrity":{"type":"string"},"keepalive":{"type":"boolean"},"method":{"type":"string"},"mode":{"enum":["cors","navigate","no-cors","same-origin"],"type":"string"},"redirect":{"enum":["error","follow","manual"],"type":"string"},"referrer":{"type":"string"},"referrerPolicy":{"enum":["","no-referrer","no-referrer-when-downgrade","origin","origin-when-cross-origin","same-origin","strict-origin","strict-origin-when-cross-origin","unsafe-url"],"type":"string"},"signal":{"anyOf":[{"$ref":"#/definitions/AbortSignal"},{"type":"null"}]},"window":{}},"additionalProperties":false},"ArrayBuffer":{"type":"object","properties":{"byteLength":{"type":"number"},"__@toStringTag":{"type":"string"}},"additionalProperties":false,"required":["__@toStringTag","byteLength"]},"ArrayBufferView":{"type":"object","properties":{"buffer":{"anyOf":[{"$ref":"#/definitions/ArrayBuffer"},{"$ref":"#/definitions/SharedArrayBuffer"}]},"byteLength":{"type":"number"},"byteOffset":{"type":"number"}},"additionalProperties":false,"required":["buffer","byteLength","byteOffset"]},"SharedArrayBuffer":{"type":"object","properties":{"byteLength":{"type":"number"},"__@species":{"$ref":"#/definitions/SharedArrayBuffer"},"__@toStringTag":{"type":"string","enum":["SharedArrayBuffer"]}},"additionalProperties":false,"required":["__@species","__@toStringTag","byteLength"]},"Blob":{"type":"object","properties":{"size":{"type":"number"},"type":{"type":"string"}},"additionalProperties":false,"required":["size","type"]},"FormData":{"type":"object","additionalProperties":false},"URLSearchParams":{"type":"object","additionalProperties":false},"ReadableStream":{"type":"object","properties":{"locked":{"type":"boolean"}},"additionalProperties":false,"required":["locked"]},"Headers":{"type":"object","additionalProperties":false},"Record":{"type":"object","additionalProperties":false},"AbortSignal":{"type":"object","properties":{"aborted":{"type":"boolean"},"onabort":{"anyOf":[{"type":"object","additionalProperties":false},{"type":"null"}]}},"additionalProperties":false,"required":["aborted","onabort"]},"RouteMatchCallback":{"description":"The \"match\" callback is used to determine if a `Route` should apply for a\nparticular URL and request. When matching occurs in response to a fetch\nevent from the client, the `event` object is also supplied. However, since\nthe match callback can be invoked outside of a fetch event, matching logic\nshould not assume the `event` object will always be available.\nIf the match callback returns a truthy value, the matching route's\n`RouteHandlerCallback` will be invoked immediately. If the value returned\nis a non-empty array or object, that value will be set on the handler's\n`options.params` argument.","type":"object","additionalProperties":false},"ManifestEntry":{"type":"object","properties":{"integrity":{"type":"string"},"revision":{"type":["null","string"]},"url":{"type":"string"}},"additionalProperties":false,"required":["revision","url"]}},"$schema":"http://json-schema.org/draft-07/schema#"} +{"additionalProperties":false,"type":"object","properties":{"globDirectory":{"type":"string"},"globFollow":{"default":true,"type":"boolean"},"globIgnores":{"default":["**/node_modules/**/*"],"type":"array","items":{"type":"string"}},"globPatterns":{"default":["**/*.{js,css,html}"],"type":"array","items":{"type":"string"}},"globStrict":{"default":true,"type":"boolean"},"templatedURLs":{"typeof":"function"},"additionalManifestEntries":{"type":"array","items":{"anyOf":[{"$ref":"#/definitions/ManifestEntry"},{"type":"string"}]}},"dontCacheBustURLsMatching":{"$ref":"#/definitions/RegExp"},"manifestTransforms":{"type":"array","items":{"typeof":"function"}},"maximumFileSizeToCacheInBytes":{"default":2097152,"type":"number"},"modifyURLPrefix":{"typeof":"function"},"injectionPoint":{"default":"self.__WB_MANIFEST","type":"string"},"swSrc":{"type":"string"},"swDest":{"type":"string"}},"required":["globDirectory","swDest","swSrc"],"definitions":{"RegExp":{"type":"object","properties":{"source":{"type":"string"},"global":{"type":"boolean"},"ignoreCase":{"type":"boolean"},"multiline":{"type":"boolean"},"lastIndex":{"type":"number"},"flags":{"type":"string"},"sticky":{"type":"boolean"},"unicode":{"type":"boolean"},"dotAll":{"type":"boolean"}},"additionalProperties":false,"required":["dotAll","flags","global","ignoreCase","lastIndex","multiline","source","sticky","unicode"]},"GoogleAnalyticsInitializeOptions":{"type":"object","properties":{"cacheName":{"type":"string"},"parameterOverrides":{"typeof":"function"},"hitFilter":{"typeof":"function"}},"additionalProperties":false},"RuntimeCaching":{"type":"object","properties":{"handler":{"anyOf":[{"$ref":"#/definitions/RouteHandlerCallback"},{"$ref":"#/definitions/RouteHandlerObject"},{"enum":["CacheFirst","CacheOnly","NetworkFirst","NetworkOnly","StaleWhileRevalidate"],"type":"string"}]},"method":{"enum":["DELETE","GET","HEAD","PATCH","POST","PUT"],"type":"string"},"options":{"typeof":"function"},"urlPattern":{"anyOf":[{"$ref":"#/definitions/RegExp"},{"$ref":"#/definitions/RouteMatchCallback"},{"type":"string"}]}},"additionalProperties":false,"required":["handler","urlPattern"]},"RouteHandlerCallback":{"description":"The \"handler\" callback is invoked whenever a `Router` matches a URL/Request\nto a `Route` via its `RouteMatchCallback`. This handler callback should\nreturn a `Promise` that resolves with a `Response`.\n\nIf a non-empty array or object is returned by the `RouteMatchCallback` it\nwill be passed in as this handler's `options.params` argument.","type":"object","additionalProperties":false},"RouteHandlerObject":{"description":"An object with a `handle` method of type `RouteHandlerCallback`.\n\nA `Route` object can be created with either an `RouteHandlerCallback`\nfunction or this `RouteHandler` object. The benefit of the `RouteHandler`\nis it can be extended (as is done by the `workbox-strategies` package).","type":"object","properties":{"handle":{"$ref":"#/definitions/RouteHandlerCallback"}},"additionalProperties":false,"required":["handle"]},"RouteMatchCallback":{"description":"The \"match\" callback is used to determine if a `Route` should apply for a\nparticular URL and request. When matching occurs in response to a fetch\nevent from the client, the `event` object is also supplied. However, since\nthe match callback can be invoked outside of a fetch event, matching logic\nshould not assume the `event` object will always be available.\nIf the match callback returns a truthy value, the matching route's\n`RouteHandlerCallback` will be invoked immediately. If the value returned\nis a non-empty array or object, that value will be set on the handler's\n`options.params` argument.","type":"object","additionalProperties":false},"ManifestEntry":{"type":"object","properties":{"integrity":{"type":"string"},"revision":{"type":["null","string"]},"url":{"type":"string"}},"additionalProperties":false,"required":["revision","url"]}},"$schema":"http://json-schema.org/draft-07/schema#"} diff --git a/packages/workbox-build/src/schema/WebpackGenerateSWOptions.json b/packages/workbox-build/src/schema/WebpackGenerateSWOptions.json index 56ef691ce..2dae2f2e8 100644 --- a/packages/workbox-build/src/schema/WebpackGenerateSWOptions.json +++ b/packages/workbox-build/src/schema/WebpackGenerateSWOptions.json @@ -1 +1 @@ -{"additionalProperties":false,"type":"object","properties":{"chunks":{"type":"array","items":{"type":"string"}},"exclude":{"type":"array","items":{}},"excludeChunks":{"type":"array","items":{"type":"string"}},"include":{"type":"array","items":{}},"mode":{"default":"production","type":["null","string"]},"babelPresetEnvTargets":{"default":["chrome >= 56"],"type":"array","items":{"type":"string"}},"cacheId":{"type":["null","string"]},"cleanupOutdatedCaches":{"default":false,"type":"boolean"},"clientsClaim":{"default":false,"type":"boolean"},"directoryIndex":{"type":["null","string"]},"disableDevLogs":{"default":false,"type":"boolean"},"ignoreURLParametersMatching":{"type":"array","items":{"$ref":"#/definitions/RegExp"}},"importScripts":{"type":"array","items":{"type":"string"}},"inlineWorkboxRuntime":{"default":false,"type":"boolean"},"navigateFallback":{"default":null,"type":["null","string"]},"navigateFallbackAllowlist":{"type":"array","items":{"$ref":"#/definitions/RegExp"}},"navigateFallbackDenylist":{"type":"array","items":{"$ref":"#/definitions/RegExp"}},"navigationPreload":{"default":false,"type":"boolean"},"offlineGoogleAnalytics":{"default":false,"anyOf":[{"$ref":"#/definitions/GoogleAnalyticsInitializeOptions"},{"type":"boolean"}]},"runtimeCaching":{"type":"array","items":{"$ref":"#/definitions/RuntimeCaching"}},"skipWaiting":{"default":false,"type":"boolean"},"sourcemap":{"default":true,"type":"boolean"},"additionalManifestEntries":{"type":"array","items":{"anyOf":[{"$ref":"#/definitions/ManifestEntry"},{"type":"string"}]}},"dontCacheBustURLsMatching":{"$ref":"#/definitions/RegExp"},"manifestTransforms":{"type":"array","items":{"type":"object","additionalProperties":false}},"maximumFileSizeToCacheInBytes":{"default":2097152,"type":"number"},"modifyURLPrefix":{"type":"object","additionalProperties":{"type":"string"}},"importScriptsViaChunks":{"type":"array","items":{"type":"string"}},"swDest":{"default":"service-worker.js","type":"string"}},"definitions":{"RegExp":{"type":"object","properties":{"source":{"type":"string"},"global":{"type":"boolean"},"ignoreCase":{"type":"boolean"},"multiline":{"type":"boolean"},"lastIndex":{"type":"number"},"flags":{"type":"string"},"sticky":{"type":"boolean"},"unicode":{"type":"boolean"},"dotAll":{"type":"boolean"}},"additionalProperties":false,"required":["dotAll","flags","global","ignoreCase","lastIndex","multiline","source","sticky","unicode"]},"GoogleAnalyticsInitializeOptions":{"type":"object","properties":{"cacheName":{"type":"string"},"parameterOverrides":{"type":"object","additionalProperties":{"type":"string"}},"hitFilter":{"type":"object","additionalProperties":false}},"additionalProperties":false},"RuntimeCaching":{"type":"object","properties":{"handler":{"anyOf":[{"$ref":"#/definitions/RouteHandlerCallback"},{"$ref":"#/definitions/RouteHandlerObject"},{"enum":["CacheFirst","CacheOnly","NetworkFirst","NetworkOnly","StaleWhileRevalidate"],"type":"string"}]},"method":{"enum":["DELETE","GET","HEAD","PATCH","POST","PUT"],"type":"string"},"options":{"type":"object","properties":{"backgroundSync":{"type":"object","properties":{"name":{"type":"string"},"options":{"$ref":"#/definitions/QueueOptions"}},"additionalProperties":false,"required":["name"]},"broadcastUpdate":{"type":"object","properties":{"channelName":{"type":"string"},"options":{"$ref":"#/definitions/BroadcastCacheUpdateOptions"}},"additionalProperties":false,"required":["options"]},"cacheableResponse":{"$ref":"#/definitions/CacheableResponseOptions"},"cacheName":{"type":["null","string"]},"expiration":{"$ref":"#/definitions/ExpirationPluginOptions"},"networkTimeoutSeconds":{"type":"number"},"plugins":{"type":"array","items":{"$ref":"#/definitions/WorkboxPlugin"}},"precacheFallback":{"type":"object","properties":{"fallbackURL":{"type":"string"}},"additionalProperties":false,"required":["fallbackURL"]},"fetchOptions":{"$ref":"#/definitions/RequestInit"},"matchOptions":{"$ref":"#/definitions/CacheQueryOptions"}},"additionalProperties":false},"urlPattern":{"anyOf":[{"$ref":"#/definitions/RegExp"},{"$ref":"#/definitions/RouteMatchCallback"},{"type":"string"}]}},"additionalProperties":false,"required":["handler","urlPattern"]},"RouteHandlerCallback":{"description":"The \"handler\" callback is invoked whenever a `Router` matches a URL/Request\nto a `Route` via its `RouteMatchCallback`. This handler callback should\nreturn a `Promise` that resolves with a `Response`.\n\nIf a non-empty array or object is returned by the `RouteMatchCallback` it\nwill be passed in as this handler's `options.params` argument.","type":"object","additionalProperties":false},"RouteHandlerObject":{"description":"An object with a `handle` method of type `RouteHandlerCallback`.\n\nA `Route` object can be created with either an `RouteHandlerCallback`\nfunction or this `RouteHandler` object. The benefit of the `RouteHandler`\nis it can be extended (as is done by the `workbox-strategies` package).","type":"object","properties":{"handle":{"$ref":"#/definitions/RouteHandlerCallback"}},"additionalProperties":false,"required":["handle"]},"QueueOptions":{"type":"object","properties":{"onSync":{"$ref":"#/definitions/OnSyncCallback"},"maxRetentionTime":{"type":"number"}},"additionalProperties":false},"OnSyncCallback":{"type":"object","additionalProperties":false},"BroadcastCacheUpdateOptions":{"type":"object","properties":{"headersToCheck":{"type":"array","items":{"type":"string"}},"generatePayload":{"type":"object","additionalProperties":false}},"additionalProperties":false},"CacheableResponseOptions":{"type":"object","properties":{"statuses":{"type":"array","items":{"type":"number"}},"headers":{"type":"object","additionalProperties":{"type":"string"}}},"additionalProperties":false},"ExpirationPluginOptions":{"type":"object","properties":{"maxEntries":{"type":"number"},"maxAgeSeconds":{"type":"number"},"matchOptions":{"$ref":"#/definitions/CacheQueryOptions"},"purgeOnQuotaError":{"type":"boolean"}},"additionalProperties":false},"CacheQueryOptions":{"type":"object","properties":{"ignoreMethod":{"type":"boolean"},"ignoreSearch":{"type":"boolean"},"ignoreVary":{"type":"boolean"}},"additionalProperties":false},"WorkboxPlugin":{"description":"An object with optional lifecycle callback properties for the fetch and\ncache operations.","type":"object","properties":{"cacheDidUpdate":{"$ref":"#/definitions/CacheDidUpdateCallback"},"cachedResponseWillBeUsed":{"$ref":"#/definitions/CachedResponseWillBeUsedCallback"},"cacheKeyWillBeUsed":{"$ref":"#/definitions/CacheKeyWillBeUsedCallback"},"cacheWillUpdate":{"$ref":"#/definitions/CacheWillUpdateCallback"},"fetchDidFail":{"$ref":"#/definitions/FetchDidFailCallback"},"fetchDidSucceed":{"$ref":"#/definitions/FetchDidSucceedCallback"},"handlerDidComplete":{"$ref":"#/definitions/HandlerDidCompleteCallback"},"handlerDidError":{"$ref":"#/definitions/HandlerDidErrorCallback"},"handlerDidRespond":{"$ref":"#/definitions/HandlerDidRespondCallback"},"handlerWillRespond":{"$ref":"#/definitions/HandlerWillRespondCallback"},"handlerWillStart":{"$ref":"#/definitions/HandlerWillStartCallback"},"requestWillFetch":{"$ref":"#/definitions/RequestWillFetchCallback"}},"additionalProperties":false},"CacheDidUpdateCallback":{"type":"object","additionalProperties":false},"CachedResponseWillBeUsedCallback":{"type":"object","additionalProperties":false},"CacheKeyWillBeUsedCallback":{"type":"object","additionalProperties":false},"CacheWillUpdateCallback":{"type":"object","additionalProperties":false},"FetchDidFailCallback":{"type":"object","additionalProperties":false},"FetchDidSucceedCallback":{"type":"object","additionalProperties":false},"HandlerDidCompleteCallback":{"type":"object","additionalProperties":false},"HandlerDidErrorCallback":{"type":"object","additionalProperties":false},"HandlerDidRespondCallback":{"type":"object","additionalProperties":false},"HandlerWillRespondCallback":{"type":"object","additionalProperties":false},"HandlerWillStartCallback":{"type":"object","additionalProperties":false},"RequestWillFetchCallback":{"type":"object","additionalProperties":false},"RequestInit":{"type":"object","properties":{"body":{"anyOf":[{"$ref":"#/definitions/ArrayBuffer"},{"$ref":"#/definitions/ArrayBufferView"},{"$ref":"#/definitions/Blob"},{"$ref":"#/definitions/FormData"},{"$ref":"#/definitions/URLSearchParams"},{"$ref":"#/definitions/ReadableStream"},{"type":["null","string"]}]},"cache":{"enum":["default","force-cache","no-cache","no-store","only-if-cached","reload"],"type":"string"},"credentials":{"enum":["include","omit","same-origin"],"type":"string"},"headers":{"anyOf":[{"$ref":"#/definitions/Headers"},{"type":"array","items":{"type":"array","items":{"type":"string"}}},{"$ref":"#/definitions/Record"}]},"integrity":{"type":"string"},"keepalive":{"type":"boolean"},"method":{"type":"string"},"mode":{"enum":["cors","navigate","no-cors","same-origin"],"type":"string"},"redirect":{"enum":["error","follow","manual"],"type":"string"},"referrer":{"type":"string"},"referrerPolicy":{"enum":["","no-referrer","no-referrer-when-downgrade","origin","origin-when-cross-origin","same-origin","strict-origin","strict-origin-when-cross-origin","unsafe-url"],"type":"string"},"signal":{"anyOf":[{"$ref":"#/definitions/AbortSignal"},{"type":"null"}]},"window":{}},"additionalProperties":false},"ArrayBuffer":{"type":"object","properties":{"byteLength":{"type":"number"},"__@toStringTag":{"type":"string"}},"additionalProperties":false,"required":["__@toStringTag","byteLength"]},"ArrayBufferView":{"type":"object","properties":{"buffer":{"anyOf":[{"$ref":"#/definitions/ArrayBuffer"},{"$ref":"#/definitions/SharedArrayBuffer"}]},"byteLength":{"type":"number"},"byteOffset":{"type":"number"}},"additionalProperties":false,"required":["buffer","byteLength","byteOffset"]},"SharedArrayBuffer":{"type":"object","properties":{"byteLength":{"type":"number"},"__@species":{"$ref":"#/definitions/SharedArrayBuffer"},"__@toStringTag":{"type":"string","enum":["SharedArrayBuffer"]}},"additionalProperties":false,"required":["__@species","__@toStringTag","byteLength"]},"Blob":{"type":"object","properties":{"size":{"type":"number"},"type":{"type":"string"}},"additionalProperties":false,"required":["size","type"]},"FormData":{"type":"object","additionalProperties":false},"URLSearchParams":{"type":"object","additionalProperties":false},"ReadableStream":{"type":"object","properties":{"locked":{"type":"boolean"}},"additionalProperties":false,"required":["locked"]},"Headers":{"type":"object","additionalProperties":false},"Record":{"type":"object","additionalProperties":false},"AbortSignal":{"type":"object","properties":{"aborted":{"type":"boolean"},"onabort":{"anyOf":[{"type":"object","additionalProperties":false},{"type":"null"}]}},"additionalProperties":false,"required":["aborted","onabort"]},"RouteMatchCallback":{"description":"The \"match\" callback is used to determine if a `Route` should apply for a\nparticular URL and request. When matching occurs in response to a fetch\nevent from the client, the `event` object is also supplied. However, since\nthe match callback can be invoked outside of a fetch event, matching logic\nshould not assume the `event` object will always be available.\nIf the match callback returns a truthy value, the matching route's\n`RouteHandlerCallback` will be invoked immediately. If the value returned\nis a non-empty array or object, that value will be set on the handler's\n`options.params` argument.","type":"object","additionalProperties":false},"ManifestEntry":{"type":"object","properties":{"integrity":{"type":"string"},"revision":{"type":["null","string"]},"url":{"type":"string"}},"additionalProperties":false,"required":["revision","url"]}},"$schema":"http://json-schema.org/draft-07/schema#"} +{"additionalProperties":false,"type":"object","properties":{"chunks":{"type":"array","items":{"type":"string"}},"exclude":{"type":"array","items":{}},"excludeChunks":{"type":"array","items":{"type":"string"}},"include":{"type":"array","items":{}},"mode":{"default":"production","type":["null","string"]},"babelPresetEnvTargets":{"default":["chrome >= 56"],"type":"array","items":{"type":"string"}},"cacheId":{"type":["null","string"]},"cleanupOutdatedCaches":{"default":false,"type":"boolean"},"clientsClaim":{"default":false,"type":"boolean"},"directoryIndex":{"type":["null","string"]},"disableDevLogs":{"default":false,"type":"boolean"},"ignoreURLParametersMatching":{"type":"array","items":{"$ref":"#/definitions/RegExp"}},"importScripts":{"type":"array","items":{"type":"string"}},"inlineWorkboxRuntime":{"default":false,"type":"boolean"},"navigateFallback":{"default":null,"type":["null","string"]},"navigateFallbackAllowlist":{"type":"array","items":{"$ref":"#/definitions/RegExp"}},"navigateFallbackDenylist":{"type":"array","items":{"$ref":"#/definitions/RegExp"}},"navigationPreload":{"default":false,"type":"boolean"},"offlineGoogleAnalytics":{"default":false,"anyOf":[{"$ref":"#/definitions/GoogleAnalyticsInitializeOptions"},{"type":"boolean"}]},"runtimeCaching":{"type":"array","items":{"$ref":"#/definitions/RuntimeCaching"}},"skipWaiting":{"default":false,"type":"boolean"},"sourcemap":{"default":true,"type":"boolean"},"additionalManifestEntries":{"type":"array","items":{"anyOf":[{"$ref":"#/definitions/ManifestEntry"},{"type":"string"}]}},"dontCacheBustURLsMatching":{"$ref":"#/definitions/RegExp"},"manifestTransforms":{"type":"array","items":{"typeof":"function"}},"maximumFileSizeToCacheInBytes":{"default":2097152,"type":"number"},"modifyURLPrefix":{"typeof":"function"},"importScriptsViaChunks":{"type":"array","items":{"type":"string"}},"swDest":{"default":"service-worker.js","type":"string"}},"definitions":{"RegExp":{"type":"object","properties":{"source":{"type":"string"},"global":{"type":"boolean"},"ignoreCase":{"type":"boolean"},"multiline":{"type":"boolean"},"lastIndex":{"type":"number"},"flags":{"type":"string"},"sticky":{"type":"boolean"},"unicode":{"type":"boolean"},"dotAll":{"type":"boolean"}},"additionalProperties":false,"required":["dotAll","flags","global","ignoreCase","lastIndex","multiline","source","sticky","unicode"]},"GoogleAnalyticsInitializeOptions":{"type":"object","properties":{"cacheName":{"type":"string"},"parameterOverrides":{"typeof":"function"},"hitFilter":{"typeof":"function"}},"additionalProperties":false},"RuntimeCaching":{"type":"object","properties":{"handler":{"anyOf":[{"$ref":"#/definitions/RouteHandlerCallback"},{"$ref":"#/definitions/RouteHandlerObject"},{"enum":["CacheFirst","CacheOnly","NetworkFirst","NetworkOnly","StaleWhileRevalidate"],"type":"string"}]},"method":{"enum":["DELETE","GET","HEAD","PATCH","POST","PUT"],"type":"string"},"options":{"typeof":"function"},"urlPattern":{"anyOf":[{"$ref":"#/definitions/RegExp"},{"$ref":"#/definitions/RouteMatchCallback"},{"type":"string"}]}},"additionalProperties":false,"required":["handler","urlPattern"]},"RouteHandlerCallback":{"description":"The \"handler\" callback is invoked whenever a `Router` matches a URL/Request\nto a `Route` via its `RouteMatchCallback`. This handler callback should\nreturn a `Promise` that resolves with a `Response`.\n\nIf a non-empty array or object is returned by the `RouteMatchCallback` it\nwill be passed in as this handler's `options.params` argument.","type":"object","additionalProperties":false},"RouteHandlerObject":{"description":"An object with a `handle` method of type `RouteHandlerCallback`.\n\nA `Route` object can be created with either an `RouteHandlerCallback`\nfunction or this `RouteHandler` object. The benefit of the `RouteHandler`\nis it can be extended (as is done by the `workbox-strategies` package).","type":"object","properties":{"handle":{"$ref":"#/definitions/RouteHandlerCallback"}},"additionalProperties":false,"required":["handle"]},"RouteMatchCallback":{"description":"The \"match\" callback is used to determine if a `Route` should apply for a\nparticular URL and request. When matching occurs in response to a fetch\nevent from the client, the `event` object is also supplied. However, since\nthe match callback can be invoked outside of a fetch event, matching logic\nshould not assume the `event` object will always be available.\nIf the match callback returns a truthy value, the matching route's\n`RouteHandlerCallback` will be invoked immediately. If the value returned\nis a non-empty array or object, that value will be set on the handler's\n`options.params` argument.","type":"object","additionalProperties":false},"ManifestEntry":{"type":"object","properties":{"integrity":{"type":"string"},"revision":{"type":["null","string"]},"url":{"type":"string"}},"additionalProperties":false,"required":["revision","url"]}},"$schema":"http://json-schema.org/draft-07/schema#"} diff --git a/packages/workbox-build/src/schema/WebpackInjectManifestOptions.json b/packages/workbox-build/src/schema/WebpackInjectManifestOptions.json index 7abbd5ca8..30356424f 100644 --- a/packages/workbox-build/src/schema/WebpackInjectManifestOptions.json +++ b/packages/workbox-build/src/schema/WebpackInjectManifestOptions.json @@ -1 +1 @@ -{"additionalProperties":false,"type":"object","properties":{"chunks":{"type":"array","items":{"type":"string"}},"exclude":{"type":"array","items":{}},"excludeChunks":{"type":"array","items":{"type":"string"}},"include":{"type":"array","items":{}},"mode":{"type":["null","string"]},"injectionPoint":{"default":"self.__WB_MANIFEST","type":"string"},"swSrc":{"type":"string"},"additionalManifestEntries":{"type":"array","items":{"anyOf":[{"$ref":"#/definitions/ManifestEntry"},{"type":"string"}]}},"dontCacheBustURLsMatching":{"$ref":"#/definitions/RegExp"},"manifestTransforms":{"type":"array","items":{"type":"object","additionalProperties":false}},"maximumFileSizeToCacheInBytes":{"default":2097152,"type":"number"},"modifyURLPrefix":{"type":"object","additionalProperties":{"type":"string"}},"compileSrc":{"default":true,"type":"boolean"},"swDest":{"type":"string"},"webpackCompilationPlugins":{"type":"array","items":{}}},"required":["swSrc"],"definitions":{"RegExp":{"type":"object","properties":{"source":{"type":"string"},"global":{"type":"boolean"},"ignoreCase":{"type":"boolean"},"multiline":{"type":"boolean"},"lastIndex":{"type":"number"},"flags":{"type":"string"},"sticky":{"type":"boolean"},"unicode":{"type":"boolean"},"dotAll":{"type":"boolean"}},"additionalProperties":false,"required":["dotAll","flags","global","ignoreCase","lastIndex","multiline","source","sticky","unicode"]},"GoogleAnalyticsInitializeOptions":{"type":"object","properties":{"cacheName":{"type":"string"},"parameterOverrides":{"type":"object","additionalProperties":{"type":"string"}},"hitFilter":{"type":"object","additionalProperties":false}},"additionalProperties":false},"RuntimeCaching":{"type":"object","properties":{"handler":{"anyOf":[{"$ref":"#/definitions/RouteHandlerCallback"},{"$ref":"#/definitions/RouteHandlerObject"},{"enum":["CacheFirst","CacheOnly","NetworkFirst","NetworkOnly","StaleWhileRevalidate"],"type":"string"}]},"method":{"enum":["DELETE","GET","HEAD","PATCH","POST","PUT"],"type":"string"},"options":{"type":"object","properties":{"backgroundSync":{"type":"object","properties":{"name":{"type":"string"},"options":{"$ref":"#/definitions/QueueOptions"}},"additionalProperties":false,"required":["name"]},"broadcastUpdate":{"type":"object","properties":{"channelName":{"type":"string"},"options":{"$ref":"#/definitions/BroadcastCacheUpdateOptions"}},"additionalProperties":false,"required":["options"]},"cacheableResponse":{"$ref":"#/definitions/CacheableResponseOptions"},"cacheName":{"type":["null","string"]},"expiration":{"$ref":"#/definitions/ExpirationPluginOptions"},"networkTimeoutSeconds":{"type":"number"},"plugins":{"type":"array","items":{"$ref":"#/definitions/WorkboxPlugin"}},"precacheFallback":{"type":"object","properties":{"fallbackURL":{"type":"string"}},"additionalProperties":false,"required":["fallbackURL"]},"fetchOptions":{"$ref":"#/definitions/RequestInit"},"matchOptions":{"$ref":"#/definitions/CacheQueryOptions"}},"additionalProperties":false},"urlPattern":{"anyOf":[{"$ref":"#/definitions/RegExp"},{"$ref":"#/definitions/RouteMatchCallback"},{"type":"string"}]}},"additionalProperties":false,"required":["handler","urlPattern"]},"RouteHandlerCallback":{"description":"The \"handler\" callback is invoked whenever a `Router` matches a URL/Request\nto a `Route` via its `RouteMatchCallback`. This handler callback should\nreturn a `Promise` that resolves with a `Response`.\n\nIf a non-empty array or object is returned by the `RouteMatchCallback` it\nwill be passed in as this handler's `options.params` argument.","type":"object","additionalProperties":false},"RouteHandlerObject":{"description":"An object with a `handle` method of type `RouteHandlerCallback`.\n\nA `Route` object can be created with either an `RouteHandlerCallback`\nfunction or this `RouteHandler` object. The benefit of the `RouteHandler`\nis it can be extended (as is done by the `workbox-strategies` package).","type":"object","properties":{"handle":{"$ref":"#/definitions/RouteHandlerCallback"}},"additionalProperties":false,"required":["handle"]},"QueueOptions":{"type":"object","properties":{"onSync":{"$ref":"#/definitions/OnSyncCallback"},"maxRetentionTime":{"type":"number"}},"additionalProperties":false},"OnSyncCallback":{"type":"object","additionalProperties":false},"BroadcastCacheUpdateOptions":{"type":"object","properties":{"headersToCheck":{"type":"array","items":{"type":"string"}},"generatePayload":{"type":"object","additionalProperties":false}},"additionalProperties":false},"CacheableResponseOptions":{"type":"object","properties":{"statuses":{"type":"array","items":{"type":"number"}},"headers":{"type":"object","additionalProperties":{"type":"string"}}},"additionalProperties":false},"ExpirationPluginOptions":{"type":"object","properties":{"maxEntries":{"type":"number"},"maxAgeSeconds":{"type":"number"},"matchOptions":{"$ref":"#/definitions/CacheQueryOptions"},"purgeOnQuotaError":{"type":"boolean"}},"additionalProperties":false},"CacheQueryOptions":{"type":"object","properties":{"ignoreMethod":{"type":"boolean"},"ignoreSearch":{"type":"boolean"},"ignoreVary":{"type":"boolean"}},"additionalProperties":false},"WorkboxPlugin":{"description":"An object with optional lifecycle callback properties for the fetch and\ncache operations.","type":"object","properties":{"cacheDidUpdate":{"$ref":"#/definitions/CacheDidUpdateCallback"},"cachedResponseWillBeUsed":{"$ref":"#/definitions/CachedResponseWillBeUsedCallback"},"cacheKeyWillBeUsed":{"$ref":"#/definitions/CacheKeyWillBeUsedCallback"},"cacheWillUpdate":{"$ref":"#/definitions/CacheWillUpdateCallback"},"fetchDidFail":{"$ref":"#/definitions/FetchDidFailCallback"},"fetchDidSucceed":{"$ref":"#/definitions/FetchDidSucceedCallback"},"handlerDidComplete":{"$ref":"#/definitions/HandlerDidCompleteCallback"},"handlerDidError":{"$ref":"#/definitions/HandlerDidErrorCallback"},"handlerDidRespond":{"$ref":"#/definitions/HandlerDidRespondCallback"},"handlerWillRespond":{"$ref":"#/definitions/HandlerWillRespondCallback"},"handlerWillStart":{"$ref":"#/definitions/HandlerWillStartCallback"},"requestWillFetch":{"$ref":"#/definitions/RequestWillFetchCallback"}},"additionalProperties":false},"CacheDidUpdateCallback":{"type":"object","additionalProperties":false},"CachedResponseWillBeUsedCallback":{"type":"object","additionalProperties":false},"CacheKeyWillBeUsedCallback":{"type":"object","additionalProperties":false},"CacheWillUpdateCallback":{"type":"object","additionalProperties":false},"FetchDidFailCallback":{"type":"object","additionalProperties":false},"FetchDidSucceedCallback":{"type":"object","additionalProperties":false},"HandlerDidCompleteCallback":{"type":"object","additionalProperties":false},"HandlerDidErrorCallback":{"type":"object","additionalProperties":false},"HandlerDidRespondCallback":{"type":"object","additionalProperties":false},"HandlerWillRespondCallback":{"type":"object","additionalProperties":false},"HandlerWillStartCallback":{"type":"object","additionalProperties":false},"RequestWillFetchCallback":{"type":"object","additionalProperties":false},"RequestInit":{"type":"object","properties":{"body":{"anyOf":[{"$ref":"#/definitions/ArrayBuffer"},{"$ref":"#/definitions/ArrayBufferView"},{"$ref":"#/definitions/Blob"},{"$ref":"#/definitions/FormData"},{"$ref":"#/definitions/URLSearchParams"},{"$ref":"#/definitions/ReadableStream"},{"type":["null","string"]}]},"cache":{"enum":["default","force-cache","no-cache","no-store","only-if-cached","reload"],"type":"string"},"credentials":{"enum":["include","omit","same-origin"],"type":"string"},"headers":{"anyOf":[{"$ref":"#/definitions/Headers"},{"type":"array","items":{"type":"array","items":{"type":"string"}}},{"$ref":"#/definitions/Record"}]},"integrity":{"type":"string"},"keepalive":{"type":"boolean"},"method":{"type":"string"},"mode":{"enum":["cors","navigate","no-cors","same-origin"],"type":"string"},"redirect":{"enum":["error","follow","manual"],"type":"string"},"referrer":{"type":"string"},"referrerPolicy":{"enum":["","no-referrer","no-referrer-when-downgrade","origin","origin-when-cross-origin","same-origin","strict-origin","strict-origin-when-cross-origin","unsafe-url"],"type":"string"},"signal":{"anyOf":[{"$ref":"#/definitions/AbortSignal"},{"type":"null"}]},"window":{}},"additionalProperties":false},"ArrayBuffer":{"type":"object","properties":{"byteLength":{"type":"number"},"__@toStringTag":{"type":"string"}},"additionalProperties":false,"required":["__@toStringTag","byteLength"]},"ArrayBufferView":{"type":"object","properties":{"buffer":{"anyOf":[{"$ref":"#/definitions/ArrayBuffer"},{"$ref":"#/definitions/SharedArrayBuffer"}]},"byteLength":{"type":"number"},"byteOffset":{"type":"number"}},"additionalProperties":false,"required":["buffer","byteLength","byteOffset"]},"SharedArrayBuffer":{"type":"object","properties":{"byteLength":{"type":"number"},"__@species":{"$ref":"#/definitions/SharedArrayBuffer"},"__@toStringTag":{"type":"string","enum":["SharedArrayBuffer"]}},"additionalProperties":false,"required":["__@species","__@toStringTag","byteLength"]},"Blob":{"type":"object","properties":{"size":{"type":"number"},"type":{"type":"string"}},"additionalProperties":false,"required":["size","type"]},"FormData":{"type":"object","additionalProperties":false},"URLSearchParams":{"type":"object","additionalProperties":false},"ReadableStream":{"type":"object","properties":{"locked":{"type":"boolean"}},"additionalProperties":false,"required":["locked"]},"Headers":{"type":"object","additionalProperties":false},"Record":{"type":"object","additionalProperties":false},"AbortSignal":{"type":"object","properties":{"aborted":{"type":"boolean"},"onabort":{"anyOf":[{"type":"object","additionalProperties":false},{"type":"null"}]}},"additionalProperties":false,"required":["aborted","onabort"]},"RouteMatchCallback":{"description":"The \"match\" callback is used to determine if a `Route` should apply for a\nparticular URL and request. When matching occurs in response to a fetch\nevent from the client, the `event` object is also supplied. However, since\nthe match callback can be invoked outside of a fetch event, matching logic\nshould not assume the `event` object will always be available.\nIf the match callback returns a truthy value, the matching route's\n`RouteHandlerCallback` will be invoked immediately. If the value returned\nis a non-empty array or object, that value will be set on the handler's\n`options.params` argument.","type":"object","additionalProperties":false},"ManifestEntry":{"type":"object","properties":{"integrity":{"type":"string"},"revision":{"type":["null","string"]},"url":{"type":"string"}},"additionalProperties":false,"required":["revision","url"]}},"$schema":"http://json-schema.org/draft-07/schema#"} +{"additionalProperties":false,"type":"object","properties":{"chunks":{"type":"array","items":{"type":"string"}},"exclude":{"type":"array","items":{}},"excludeChunks":{"type":"array","items":{"type":"string"}},"include":{"type":"array","items":{}},"mode":{"type":["null","string"]},"injectionPoint":{"default":"self.__WB_MANIFEST","type":"string"},"swSrc":{"type":"string"},"additionalManifestEntries":{"type":"array","items":{"anyOf":[{"$ref":"#/definitions/ManifestEntry"},{"type":"string"}]}},"dontCacheBustURLsMatching":{"$ref":"#/definitions/RegExp"},"manifestTransforms":{"type":"array","items":{"typeof":"function"}},"maximumFileSizeToCacheInBytes":{"default":2097152,"type":"number"},"modifyURLPrefix":{"typeof":"function"},"compileSrc":{"default":true,"type":"boolean"},"swDest":{"type":"string"},"webpackCompilationPlugins":{"type":"array","items":{}}},"required":["swSrc"],"definitions":{"RegExp":{"type":"object","properties":{"source":{"type":"string"},"global":{"type":"boolean"},"ignoreCase":{"type":"boolean"},"multiline":{"type":"boolean"},"lastIndex":{"type":"number"},"flags":{"type":"string"},"sticky":{"type":"boolean"},"unicode":{"type":"boolean"},"dotAll":{"type":"boolean"}},"additionalProperties":false,"required":["dotAll","flags","global","ignoreCase","lastIndex","multiline","source","sticky","unicode"]},"GoogleAnalyticsInitializeOptions":{"type":"object","properties":{"cacheName":{"type":"string"},"parameterOverrides":{"typeof":"function"},"hitFilter":{"typeof":"function"}},"additionalProperties":false},"RuntimeCaching":{"type":"object","properties":{"handler":{"anyOf":[{"$ref":"#/definitions/RouteHandlerCallback"},{"$ref":"#/definitions/RouteHandlerObject"},{"enum":["CacheFirst","CacheOnly","NetworkFirst","NetworkOnly","StaleWhileRevalidate"],"type":"string"}]},"method":{"enum":["DELETE","GET","HEAD","PATCH","POST","PUT"],"type":"string"},"options":{"typeof":"function"},"urlPattern":{"anyOf":[{"$ref":"#/definitions/RegExp"},{"$ref":"#/definitions/RouteMatchCallback"},{"type":"string"}]}},"additionalProperties":false,"required":["handler","urlPattern"]},"RouteHandlerCallback":{"description":"The \"handler\" callback is invoked whenever a `Router` matches a URL/Request\nto a `Route` via its `RouteMatchCallback`. This handler callback should\nreturn a `Promise` that resolves with a `Response`.\n\nIf a non-empty array or object is returned by the `RouteMatchCallback` it\nwill be passed in as this handler's `options.params` argument.","type":"object","additionalProperties":false},"RouteHandlerObject":{"description":"An object with a `handle` method of type `RouteHandlerCallback`.\n\nA `Route` object can be created with either an `RouteHandlerCallback`\nfunction or this `RouteHandler` object. The benefit of the `RouteHandler`\nis it can be extended (as is done by the `workbox-strategies` package).","type":"object","properties":{"handle":{"$ref":"#/definitions/RouteHandlerCallback"}},"additionalProperties":false,"required":["handle"]},"RouteMatchCallback":{"description":"The \"match\" callback is used to determine if a `Route` should apply for a\nparticular URL and request. When matching occurs in response to a fetch\nevent from the client, the `event` object is also supplied. However, since\nthe match callback can be invoked outside of a fetch event, matching logic\nshould not assume the `event` object will always be available.\nIf the match callback returns a truthy value, the matching route's\n`RouteHandlerCallback` will be invoked immediately. If the value returned\nis a non-empty array or object, that value will be set on the handler's\n`options.params` argument.","type":"object","additionalProperties":false},"ManifestEntry":{"type":"object","properties":{"integrity":{"type":"string"},"revision":{"type":["null","string"]},"url":{"type":"string"}},"additionalProperties":false,"required":["revision","url"]}},"$schema":"http://json-schema.org/draft-07/schema#"} diff --git a/packages/workbox-build/src/types.ts b/packages/workbox-build/src/types.ts index 37e3d380f..306a6f7d2 100644 --- a/packages/workbox-build/src/types.ts +++ b/packages/workbox-build/src/types.ts @@ -171,23 +171,15 @@ export interface RequiredSWDestPartial { swDest: string; } -export type GenerateSWOptions = GlobPartial & GeneratePartial & BasePartial & RequiredSWDestPartial; - -export type GetManifestOptions = GlobPartial & BasePartial; - -export type InjectManifestOptions = InjectPartial & Omit & BasePartial & RequiredSWDestPartial & { - globDirectory: string; -}; - -export type WebpackGenerateSWOptions = WebpackPartial & GeneratePartial & BasePartial & { +interface WebpackGenerateSWPartial { importScriptsViaChunks?: Array; /** * @default "service-worker.js" */ swDest?: string; -}; +} -export type WebpackInjectManifestOptions = WebpackPartial & InjectPartial & BasePartial & { +interface WebpackInjectManifestPartial { /** * @default true */ @@ -199,7 +191,21 @@ export type WebpackInjectManifestOptions = WebpackPartial & InjectPartial & Base // represented in TypeScript. It's enforced via custom runtime validation // logic and needs to be documented. webpackCompilationPlugins?: Array; -}; +} + +export type GenerateSWOptions = GlobPartial & GeneratePartial & + RequiredSWDestPartial; + +export type GetManifestOptions = GlobPartial & BasePartial; + +export type InjectManifestOptions = GlobPartial & BasePartial & InjectPartial & + RequiredSWDestPartial; + +export type WebpackGenerateSWOptions = WebpackPartial & GeneratePartial & + BasePartial & WebpackGenerateSWPartial; + +export type WebpackInjectManifestOptions = WebpackPartial & InjectPartial & + BasePartial & WebpackInjectManifestPartial; export interface GetManifestResult { count: number, From 649985f6dddd0c9cca83f3297a01591ca676f835 Mon Sep 17 00:00:00 2001 From: Jeff Posnick Date: Thu, 10 Jun 2021 10:32:47 -0400 Subject: [PATCH 48/80] modifyURLPrefix workaround --- .../src/schema/GenerateSWOptions.json | 2 +- .../src/schema/GetManifestOptions.json | 2 +- .../src/schema/InjectManifestOptions.json | 2 +- .../src/schema/WebpackGenerateSWOptions.json | 2 +- .../schema/WebpackInjectManifestOptions.json | 2 +- packages/workbox-build/src/types.ts | 20 +++++++++---------- 6 files changed, 15 insertions(+), 15 deletions(-) diff --git a/packages/workbox-build/src/schema/GenerateSWOptions.json b/packages/workbox-build/src/schema/GenerateSWOptions.json index afa4ea7e5..8ba3e74d0 100644 --- a/packages/workbox-build/src/schema/GenerateSWOptions.json +++ b/packages/workbox-build/src/schema/GenerateSWOptions.json @@ -1 +1 @@ -{"additionalProperties":false,"type":"object","properties":{"globDirectory":{"type":"string"},"globFollow":{"default":true,"type":"boolean"},"globIgnores":{"default":["**/node_modules/**/*"],"type":"array","items":{"type":"string"}},"globPatterns":{"default":["**/*.{js,css,html}"],"type":"array","items":{"type":"string"}},"globStrict":{"default":true,"type":"boolean"},"templatedURLs":{"typeof":"function"},"babelPresetEnvTargets":{"default":["chrome >= 56"],"type":"array","items":{"type":"string"}},"cacheId":{"type":["null","string"]},"cleanupOutdatedCaches":{"default":false,"type":"boolean"},"clientsClaim":{"default":false,"type":"boolean"},"directoryIndex":{"type":["null","string"]},"disableDevLogs":{"default":false,"type":"boolean"},"ignoreURLParametersMatching":{"type":"array","items":{"$ref":"#/definitions/RegExp"}},"importScripts":{"type":"array","items":{"type":"string"}},"inlineWorkboxRuntime":{"default":false,"type":"boolean"},"mode":{"default":"production","type":["null","string"]},"navigateFallback":{"default":null,"type":["null","string"]},"navigateFallbackAllowlist":{"type":"array","items":{"$ref":"#/definitions/RegExp"}},"navigateFallbackDenylist":{"type":"array","items":{"$ref":"#/definitions/RegExp"}},"navigationPreload":{"default":false,"type":"boolean"},"offlineGoogleAnalytics":{"default":false,"anyOf":[{"$ref":"#/definitions/GoogleAnalyticsInitializeOptions"},{"type":"boolean"}]},"runtimeCaching":{"type":"array","items":{"$ref":"#/definitions/RuntimeCaching"}},"skipWaiting":{"default":false,"type":"boolean"},"sourcemap":{"default":true,"type":"boolean"},"swDest":{"type":"string"}},"required":["globDirectory","swDest"],"definitions":{"RegExp":{"type":"object","properties":{"source":{"type":"string"},"global":{"type":"boolean"},"ignoreCase":{"type":"boolean"},"multiline":{"type":"boolean"},"lastIndex":{"type":"number"},"flags":{"type":"string"},"sticky":{"type":"boolean"},"unicode":{"type":"boolean"},"dotAll":{"type":"boolean"}},"additionalProperties":false,"required":["dotAll","flags","global","ignoreCase","lastIndex","multiline","source","sticky","unicode"]},"GoogleAnalyticsInitializeOptions":{"type":"object","properties":{"cacheName":{"type":"string"},"parameterOverrides":{"typeof":"function"},"hitFilter":{"typeof":"function"}},"additionalProperties":false},"RuntimeCaching":{"type":"object","properties":{"handler":{"anyOf":[{"$ref":"#/definitions/RouteHandlerCallback"},{"$ref":"#/definitions/RouteHandlerObject"},{"enum":["CacheFirst","CacheOnly","NetworkFirst","NetworkOnly","StaleWhileRevalidate"],"type":"string"}]},"method":{"enum":["DELETE","GET","HEAD","PATCH","POST","PUT"],"type":"string"},"options":{"typeof":"function"},"urlPattern":{"anyOf":[{"$ref":"#/definitions/RegExp"},{"$ref":"#/definitions/RouteMatchCallback"},{"type":"string"}]}},"additionalProperties":false,"required":["handler","urlPattern"]},"RouteHandlerCallback":{"description":"The \"handler\" callback is invoked whenever a `Router` matches a URL/Request\nto a `Route` via its `RouteMatchCallback`. This handler callback should\nreturn a `Promise` that resolves with a `Response`.\n\nIf a non-empty array or object is returned by the `RouteMatchCallback` it\nwill be passed in as this handler's `options.params` argument.","type":"object","additionalProperties":false},"RouteHandlerObject":{"description":"An object with a `handle` method of type `RouteHandlerCallback`.\n\nA `Route` object can be created with either an `RouteHandlerCallback`\nfunction or this `RouteHandler` object. The benefit of the `RouteHandler`\nis it can be extended (as is done by the `workbox-strategies` package).","type":"object","properties":{"handle":{"$ref":"#/definitions/RouteHandlerCallback"}},"additionalProperties":false,"required":["handle"]},"RouteMatchCallback":{"description":"The \"match\" callback is used to determine if a `Route` should apply for a\nparticular URL and request. When matching occurs in response to a fetch\nevent from the client, the `event` object is also supplied. However, since\nthe match callback can be invoked outside of a fetch event, matching logic\nshould not assume the `event` object will always be available.\nIf the match callback returns a truthy value, the matching route's\n`RouteHandlerCallback` will be invoked immediately. If the value returned\nis a non-empty array or object, that value will be set on the handler's\n`options.params` argument.","type":"object","additionalProperties":false}},"$schema":"http://json-schema.org/draft-07/schema#"} +{"additionalProperties":false,"type":"object","properties":{"additionalManifestEntries":{"type":"array","items":{"anyOf":[{"$ref":"#/definitions/ManifestEntry"},{"type":"string"}]}},"dontCacheBustURLsMatching":{"$ref":"#/definitions/RegExp"},"manifestTransforms":{"type":"array","items":{"typeof":"function"}},"maximumFileSizeToCacheInBytes":{"default":2097152,"type":"number"},"modifyURLPrefix":{},"globDirectory":{"type":"string"},"globFollow":{"default":true,"type":"boolean"},"globIgnores":{"default":["**/node_modules/**/*"],"type":"array","items":{"type":"string"}},"globPatterns":{"default":["**/*.{js,css,html}"],"type":"array","items":{"type":"string"}},"globStrict":{"default":true,"type":"boolean"},"templatedURLs":{"typeof":"function"},"babelPresetEnvTargets":{"default":["chrome >= 56"],"type":"array","items":{"type":"string"}},"cacheId":{"type":["null","string"]},"cleanupOutdatedCaches":{"default":false,"type":"boolean"},"clientsClaim":{"default":false,"type":"boolean"},"directoryIndex":{"type":["null","string"]},"disableDevLogs":{"default":false,"type":"boolean"},"ignoreURLParametersMatching":{"type":"array","items":{"$ref":"#/definitions/RegExp"}},"importScripts":{"type":"array","items":{"type":"string"}},"inlineWorkboxRuntime":{"default":false,"type":"boolean"},"mode":{"default":"production","type":["null","string"]},"navigateFallback":{"default":null,"type":["null","string"]},"navigateFallbackAllowlist":{"type":"array","items":{"$ref":"#/definitions/RegExp"}},"navigateFallbackDenylist":{"type":"array","items":{"$ref":"#/definitions/RegExp"}},"navigationPreload":{"default":false,"type":"boolean"},"offlineGoogleAnalytics":{"default":false,"anyOf":[{"$ref":"#/definitions/GoogleAnalyticsInitializeOptions"},{"type":"boolean"}]},"runtimeCaching":{"type":"array","items":{"$ref":"#/definitions/RuntimeCaching"}},"skipWaiting":{"default":false,"type":"boolean"},"sourcemap":{"default":true,"type":"boolean"},"swDest":{"type":"string"}},"required":["globDirectory","swDest"],"definitions":{"ManifestEntry":{"type":"object","properties":{"integrity":{"type":"string"},"revision":{"type":["null","string"]},"url":{"type":"string"}},"additionalProperties":false,"required":["revision","url"]},"RegExp":{"type":"object","properties":{"source":{"type":"string"},"global":{"type":"boolean"},"ignoreCase":{"type":"boolean"},"multiline":{"type":"boolean"},"lastIndex":{"type":"number"},"flags":{"type":"string"},"sticky":{"type":"boolean"},"unicode":{"type":"boolean"},"dotAll":{"type":"boolean"}},"additionalProperties":false,"required":["dotAll","flags","global","ignoreCase","lastIndex","multiline","source","sticky","unicode"]},"GoogleAnalyticsInitializeOptions":{"type":"object","properties":{"cacheName":{"type":"string"},"parameterOverrides":{"typeof":"function"},"hitFilter":{"typeof":"function"}},"additionalProperties":false},"RuntimeCaching":{"type":"object","properties":{"handler":{"anyOf":[{"$ref":"#/definitions/RouteHandlerCallback"},{"$ref":"#/definitions/RouteHandlerObject"},{"enum":["CacheFirst","CacheOnly","NetworkFirst","NetworkOnly","StaleWhileRevalidate"],"type":"string"}]},"method":{"enum":["DELETE","GET","HEAD","PATCH","POST","PUT"],"type":"string"},"options":{"typeof":"function"},"urlPattern":{"anyOf":[{"$ref":"#/definitions/RegExp"},{"$ref":"#/definitions/RouteMatchCallback"},{"type":"string"}]}},"additionalProperties":false,"required":["handler","urlPattern"]},"RouteHandlerCallback":{"description":"The \"handler\" callback is invoked whenever a `Router` matches a URL/Request\nto a `Route` via its `RouteMatchCallback`. This handler callback should\nreturn a `Promise` that resolves with a `Response`.\n\nIf a non-empty array or object is returned by the `RouteMatchCallback` it\nwill be passed in as this handler's `options.params` argument.","type":"object","additionalProperties":false},"RouteHandlerObject":{"description":"An object with a `handle` method of type `RouteHandlerCallback`.\n\nA `Route` object can be created with either an `RouteHandlerCallback`\nfunction or this `RouteHandler` object. The benefit of the `RouteHandler`\nis it can be extended (as is done by the `workbox-strategies` package).","type":"object","properties":{"handle":{"$ref":"#/definitions/RouteHandlerCallback"}},"additionalProperties":false,"required":["handle"]},"RouteMatchCallback":{"description":"The \"match\" callback is used to determine if a `Route` should apply for a\nparticular URL and request. When matching occurs in response to a fetch\nevent from the client, the `event` object is also supplied. However, since\nthe match callback can be invoked outside of a fetch event, matching logic\nshould not assume the `event` object will always be available.\nIf the match callback returns a truthy value, the matching route's\n`RouteHandlerCallback` will be invoked immediately. If the value returned\nis a non-empty array or object, that value will be set on the handler's\n`options.params` argument.","type":"object","additionalProperties":false}},"$schema":"http://json-schema.org/draft-07/schema#"} diff --git a/packages/workbox-build/src/schema/GetManifestOptions.json b/packages/workbox-build/src/schema/GetManifestOptions.json index 5017a5257..162d87cb1 100644 --- a/packages/workbox-build/src/schema/GetManifestOptions.json +++ b/packages/workbox-build/src/schema/GetManifestOptions.json @@ -1 +1 @@ -{"additionalProperties":false,"type":"object","properties":{"globDirectory":{"type":"string"},"globFollow":{"default":true,"type":"boolean"},"globIgnores":{"default":["**/node_modules/**/*"],"type":"array","items":{"type":"string"}},"globPatterns":{"default":["**/*.{js,css,html}"],"type":"array","items":{"type":"string"}},"globStrict":{"default":true,"type":"boolean"},"templatedURLs":{"typeof":"function"},"additionalManifestEntries":{"type":"array","items":{"anyOf":[{"$ref":"#/definitions/ManifestEntry"},{"type":"string"}]}},"dontCacheBustURLsMatching":{"$ref":"#/definitions/RegExp"},"manifestTransforms":{"type":"array","items":{"typeof":"function"}},"maximumFileSizeToCacheInBytes":{"default":2097152,"type":"number"},"modifyURLPrefix":{"typeof":"function"}},"required":["globDirectory"],"definitions":{"RegExp":{"type":"object","properties":{"source":{"type":"string"},"global":{"type":"boolean"},"ignoreCase":{"type":"boolean"},"multiline":{"type":"boolean"},"lastIndex":{"type":"number"},"flags":{"type":"string"},"sticky":{"type":"boolean"},"unicode":{"type":"boolean"},"dotAll":{"type":"boolean"}},"additionalProperties":false,"required":["dotAll","flags","global","ignoreCase","lastIndex","multiline","source","sticky","unicode"]},"GoogleAnalyticsInitializeOptions":{"type":"object","properties":{"cacheName":{"type":"string"},"parameterOverrides":{"typeof":"function"},"hitFilter":{"typeof":"function"}},"additionalProperties":false},"RuntimeCaching":{"type":"object","properties":{"handler":{"anyOf":[{"$ref":"#/definitions/RouteHandlerCallback"},{"$ref":"#/definitions/RouteHandlerObject"},{"enum":["CacheFirst","CacheOnly","NetworkFirst","NetworkOnly","StaleWhileRevalidate"],"type":"string"}]},"method":{"enum":["DELETE","GET","HEAD","PATCH","POST","PUT"],"type":"string"},"options":{"typeof":"function"},"urlPattern":{"anyOf":[{"$ref":"#/definitions/RegExp"},{"$ref":"#/definitions/RouteMatchCallback"},{"type":"string"}]}},"additionalProperties":false,"required":["handler","urlPattern"]},"RouteHandlerCallback":{"description":"The \"handler\" callback is invoked whenever a `Router` matches a URL/Request\nto a `Route` via its `RouteMatchCallback`. This handler callback should\nreturn a `Promise` that resolves with a `Response`.\n\nIf a non-empty array or object is returned by the `RouteMatchCallback` it\nwill be passed in as this handler's `options.params` argument.","type":"object","additionalProperties":false},"RouteHandlerObject":{"description":"An object with a `handle` method of type `RouteHandlerCallback`.\n\nA `Route` object can be created with either an `RouteHandlerCallback`\nfunction or this `RouteHandler` object. The benefit of the `RouteHandler`\nis it can be extended (as is done by the `workbox-strategies` package).","type":"object","properties":{"handle":{"$ref":"#/definitions/RouteHandlerCallback"}},"additionalProperties":false,"required":["handle"]},"RouteMatchCallback":{"description":"The \"match\" callback is used to determine if a `Route` should apply for a\nparticular URL and request. When matching occurs in response to a fetch\nevent from the client, the `event` object is also supplied. However, since\nthe match callback can be invoked outside of a fetch event, matching logic\nshould not assume the `event` object will always be available.\nIf the match callback returns a truthy value, the matching route's\n`RouteHandlerCallback` will be invoked immediately. If the value returned\nis a non-empty array or object, that value will be set on the handler's\n`options.params` argument.","type":"object","additionalProperties":false},"ManifestEntry":{"type":"object","properties":{"integrity":{"type":"string"},"revision":{"type":["null","string"]},"url":{"type":"string"}},"additionalProperties":false,"required":["revision","url"]}},"$schema":"http://json-schema.org/draft-07/schema#"} +{"additionalProperties":false,"type":"object","properties":{"additionalManifestEntries":{"type":"array","items":{"anyOf":[{"$ref":"#/definitions/ManifestEntry"},{"type":"string"}]}},"dontCacheBustURLsMatching":{"$ref":"#/definitions/RegExp"},"manifestTransforms":{"type":"array","items":{"typeof":"function"}},"maximumFileSizeToCacheInBytes":{"default":2097152,"type":"number"},"modifyURLPrefix":{},"globDirectory":{"type":"string"},"globFollow":{"default":true,"type":"boolean"},"globIgnores":{"default":["**/node_modules/**/*"],"type":"array","items":{"type":"string"}},"globPatterns":{"default":["**/*.{js,css,html}"],"type":"array","items":{"type":"string"}},"globStrict":{"default":true,"type":"boolean"},"templatedURLs":{"typeof":"function"}},"required":["globDirectory"],"definitions":{"ManifestEntry":{"type":"object","properties":{"integrity":{"type":"string"},"revision":{"type":["null","string"]},"url":{"type":"string"}},"additionalProperties":false,"required":["revision","url"]},"RegExp":{"type":"object","properties":{"source":{"type":"string"},"global":{"type":"boolean"},"ignoreCase":{"type":"boolean"},"multiline":{"type":"boolean"},"lastIndex":{"type":"number"},"flags":{"type":"string"},"sticky":{"type":"boolean"},"unicode":{"type":"boolean"},"dotAll":{"type":"boolean"}},"additionalProperties":false,"required":["dotAll","flags","global","ignoreCase","lastIndex","multiline","source","sticky","unicode"]},"GoogleAnalyticsInitializeOptions":{"type":"object","properties":{"cacheName":{"type":"string"},"parameterOverrides":{"typeof":"function"},"hitFilter":{"typeof":"function"}},"additionalProperties":false},"RuntimeCaching":{"type":"object","properties":{"handler":{"anyOf":[{"$ref":"#/definitions/RouteHandlerCallback"},{"$ref":"#/definitions/RouteHandlerObject"},{"enum":["CacheFirst","CacheOnly","NetworkFirst","NetworkOnly","StaleWhileRevalidate"],"type":"string"}]},"method":{"enum":["DELETE","GET","HEAD","PATCH","POST","PUT"],"type":"string"},"options":{"typeof":"function"},"urlPattern":{"anyOf":[{"$ref":"#/definitions/RegExp"},{"$ref":"#/definitions/RouteMatchCallback"},{"type":"string"}]}},"additionalProperties":false,"required":["handler","urlPattern"]},"RouteHandlerCallback":{"description":"The \"handler\" callback is invoked whenever a `Router` matches a URL/Request\nto a `Route` via its `RouteMatchCallback`. This handler callback should\nreturn a `Promise` that resolves with a `Response`.\n\nIf a non-empty array or object is returned by the `RouteMatchCallback` it\nwill be passed in as this handler's `options.params` argument.","type":"object","additionalProperties":false},"RouteHandlerObject":{"description":"An object with a `handle` method of type `RouteHandlerCallback`.\n\nA `Route` object can be created with either an `RouteHandlerCallback`\nfunction or this `RouteHandler` object. The benefit of the `RouteHandler`\nis it can be extended (as is done by the `workbox-strategies` package).","type":"object","properties":{"handle":{"$ref":"#/definitions/RouteHandlerCallback"}},"additionalProperties":false,"required":["handle"]},"RouteMatchCallback":{"description":"The \"match\" callback is used to determine if a `Route` should apply for a\nparticular URL and request. When matching occurs in response to a fetch\nevent from the client, the `event` object is also supplied. However, since\nthe match callback can be invoked outside of a fetch event, matching logic\nshould not assume the `event` object will always be available.\nIf the match callback returns a truthy value, the matching route's\n`RouteHandlerCallback` will be invoked immediately. If the value returned\nis a non-empty array or object, that value will be set on the handler's\n`options.params` argument.","type":"object","additionalProperties":false}},"$schema":"http://json-schema.org/draft-07/schema#"} diff --git a/packages/workbox-build/src/schema/InjectManifestOptions.json b/packages/workbox-build/src/schema/InjectManifestOptions.json index 1836ddc1f..7785ba3a6 100644 --- a/packages/workbox-build/src/schema/InjectManifestOptions.json +++ b/packages/workbox-build/src/schema/InjectManifestOptions.json @@ -1 +1 @@ -{"additionalProperties":false,"type":"object","properties":{"globDirectory":{"type":"string"},"globFollow":{"default":true,"type":"boolean"},"globIgnores":{"default":["**/node_modules/**/*"],"type":"array","items":{"type":"string"}},"globPatterns":{"default":["**/*.{js,css,html}"],"type":"array","items":{"type":"string"}},"globStrict":{"default":true,"type":"boolean"},"templatedURLs":{"typeof":"function"},"additionalManifestEntries":{"type":"array","items":{"anyOf":[{"$ref":"#/definitions/ManifestEntry"},{"type":"string"}]}},"dontCacheBustURLsMatching":{"$ref":"#/definitions/RegExp"},"manifestTransforms":{"type":"array","items":{"typeof":"function"}},"maximumFileSizeToCacheInBytes":{"default":2097152,"type":"number"},"modifyURLPrefix":{"typeof":"function"},"injectionPoint":{"default":"self.__WB_MANIFEST","type":"string"},"swSrc":{"type":"string"},"swDest":{"type":"string"}},"required":["globDirectory","swDest","swSrc"],"definitions":{"RegExp":{"type":"object","properties":{"source":{"type":"string"},"global":{"type":"boolean"},"ignoreCase":{"type":"boolean"},"multiline":{"type":"boolean"},"lastIndex":{"type":"number"},"flags":{"type":"string"},"sticky":{"type":"boolean"},"unicode":{"type":"boolean"},"dotAll":{"type":"boolean"}},"additionalProperties":false,"required":["dotAll","flags","global","ignoreCase","lastIndex","multiline","source","sticky","unicode"]},"GoogleAnalyticsInitializeOptions":{"type":"object","properties":{"cacheName":{"type":"string"},"parameterOverrides":{"typeof":"function"},"hitFilter":{"typeof":"function"}},"additionalProperties":false},"RuntimeCaching":{"type":"object","properties":{"handler":{"anyOf":[{"$ref":"#/definitions/RouteHandlerCallback"},{"$ref":"#/definitions/RouteHandlerObject"},{"enum":["CacheFirst","CacheOnly","NetworkFirst","NetworkOnly","StaleWhileRevalidate"],"type":"string"}]},"method":{"enum":["DELETE","GET","HEAD","PATCH","POST","PUT"],"type":"string"},"options":{"typeof":"function"},"urlPattern":{"anyOf":[{"$ref":"#/definitions/RegExp"},{"$ref":"#/definitions/RouteMatchCallback"},{"type":"string"}]}},"additionalProperties":false,"required":["handler","urlPattern"]},"RouteHandlerCallback":{"description":"The \"handler\" callback is invoked whenever a `Router` matches a URL/Request\nto a `Route` via its `RouteMatchCallback`. This handler callback should\nreturn a `Promise` that resolves with a `Response`.\n\nIf a non-empty array or object is returned by the `RouteMatchCallback` it\nwill be passed in as this handler's `options.params` argument.","type":"object","additionalProperties":false},"RouteHandlerObject":{"description":"An object with a `handle` method of type `RouteHandlerCallback`.\n\nA `Route` object can be created with either an `RouteHandlerCallback`\nfunction or this `RouteHandler` object. The benefit of the `RouteHandler`\nis it can be extended (as is done by the `workbox-strategies` package).","type":"object","properties":{"handle":{"$ref":"#/definitions/RouteHandlerCallback"}},"additionalProperties":false,"required":["handle"]},"RouteMatchCallback":{"description":"The \"match\" callback is used to determine if a `Route` should apply for a\nparticular URL and request. When matching occurs in response to a fetch\nevent from the client, the `event` object is also supplied. However, since\nthe match callback can be invoked outside of a fetch event, matching logic\nshould not assume the `event` object will always be available.\nIf the match callback returns a truthy value, the matching route's\n`RouteHandlerCallback` will be invoked immediately. If the value returned\nis a non-empty array or object, that value will be set on the handler's\n`options.params` argument.","type":"object","additionalProperties":false},"ManifestEntry":{"type":"object","properties":{"integrity":{"type":"string"},"revision":{"type":["null","string"]},"url":{"type":"string"}},"additionalProperties":false,"required":["revision","url"]}},"$schema":"http://json-schema.org/draft-07/schema#"} +{"additionalProperties":false,"type":"object","properties":{"additionalManifestEntries":{"type":"array","items":{"anyOf":[{"$ref":"#/definitions/ManifestEntry"},{"type":"string"}]}},"dontCacheBustURLsMatching":{"$ref":"#/definitions/RegExp"},"manifestTransforms":{"type":"array","items":{"typeof":"function"}},"maximumFileSizeToCacheInBytes":{"default":2097152,"type":"number"},"modifyURLPrefix":{},"globDirectory":{"type":"string"},"globFollow":{"default":true,"type":"boolean"},"globIgnores":{"default":["**/node_modules/**/*"],"type":"array","items":{"type":"string"}},"globPatterns":{"default":["**/*.{js,css,html}"],"type":"array","items":{"type":"string"}},"globStrict":{"default":true,"type":"boolean"},"templatedURLs":{"typeof":"function"},"injectionPoint":{"default":"self.__WB_MANIFEST","type":"string"},"swSrc":{"type":"string"},"swDest":{"type":"string"}},"required":["globDirectory","swDest","swSrc"],"definitions":{"ManifestEntry":{"type":"object","properties":{"integrity":{"type":"string"},"revision":{"type":["null","string"]},"url":{"type":"string"}},"additionalProperties":false,"required":["revision","url"]},"RegExp":{"type":"object","properties":{"source":{"type":"string"},"global":{"type":"boolean"},"ignoreCase":{"type":"boolean"},"multiline":{"type":"boolean"},"lastIndex":{"type":"number"},"flags":{"type":"string"},"sticky":{"type":"boolean"},"unicode":{"type":"boolean"},"dotAll":{"type":"boolean"}},"additionalProperties":false,"required":["dotAll","flags","global","ignoreCase","lastIndex","multiline","source","sticky","unicode"]},"GoogleAnalyticsInitializeOptions":{"type":"object","properties":{"cacheName":{"type":"string"},"parameterOverrides":{"typeof":"function"},"hitFilter":{"typeof":"function"}},"additionalProperties":false},"RuntimeCaching":{"type":"object","properties":{"handler":{"anyOf":[{"$ref":"#/definitions/RouteHandlerCallback"},{"$ref":"#/definitions/RouteHandlerObject"},{"enum":["CacheFirst","CacheOnly","NetworkFirst","NetworkOnly","StaleWhileRevalidate"],"type":"string"}]},"method":{"enum":["DELETE","GET","HEAD","PATCH","POST","PUT"],"type":"string"},"options":{"typeof":"function"},"urlPattern":{"anyOf":[{"$ref":"#/definitions/RegExp"},{"$ref":"#/definitions/RouteMatchCallback"},{"type":"string"}]}},"additionalProperties":false,"required":["handler","urlPattern"]},"RouteHandlerCallback":{"description":"The \"handler\" callback is invoked whenever a `Router` matches a URL/Request\nto a `Route` via its `RouteMatchCallback`. This handler callback should\nreturn a `Promise` that resolves with a `Response`.\n\nIf a non-empty array or object is returned by the `RouteMatchCallback` it\nwill be passed in as this handler's `options.params` argument.","type":"object","additionalProperties":false},"RouteHandlerObject":{"description":"An object with a `handle` method of type `RouteHandlerCallback`.\n\nA `Route` object can be created with either an `RouteHandlerCallback`\nfunction or this `RouteHandler` object. The benefit of the `RouteHandler`\nis it can be extended (as is done by the `workbox-strategies` package).","type":"object","properties":{"handle":{"$ref":"#/definitions/RouteHandlerCallback"}},"additionalProperties":false,"required":["handle"]},"RouteMatchCallback":{"description":"The \"match\" callback is used to determine if a `Route` should apply for a\nparticular URL and request. When matching occurs in response to a fetch\nevent from the client, the `event` object is also supplied. However, since\nthe match callback can be invoked outside of a fetch event, matching logic\nshould not assume the `event` object will always be available.\nIf the match callback returns a truthy value, the matching route's\n`RouteHandlerCallback` will be invoked immediately. If the value returned\nis a non-empty array or object, that value will be set on the handler's\n`options.params` argument.","type":"object","additionalProperties":false}},"$schema":"http://json-schema.org/draft-07/schema#"} diff --git a/packages/workbox-build/src/schema/WebpackGenerateSWOptions.json b/packages/workbox-build/src/schema/WebpackGenerateSWOptions.json index 2dae2f2e8..9c9aff45e 100644 --- a/packages/workbox-build/src/schema/WebpackGenerateSWOptions.json +++ b/packages/workbox-build/src/schema/WebpackGenerateSWOptions.json @@ -1 +1 @@ -{"additionalProperties":false,"type":"object","properties":{"chunks":{"type":"array","items":{"type":"string"}},"exclude":{"type":"array","items":{}},"excludeChunks":{"type":"array","items":{"type":"string"}},"include":{"type":"array","items":{}},"mode":{"default":"production","type":["null","string"]},"babelPresetEnvTargets":{"default":["chrome >= 56"],"type":"array","items":{"type":"string"}},"cacheId":{"type":["null","string"]},"cleanupOutdatedCaches":{"default":false,"type":"boolean"},"clientsClaim":{"default":false,"type":"boolean"},"directoryIndex":{"type":["null","string"]},"disableDevLogs":{"default":false,"type":"boolean"},"ignoreURLParametersMatching":{"type":"array","items":{"$ref":"#/definitions/RegExp"}},"importScripts":{"type":"array","items":{"type":"string"}},"inlineWorkboxRuntime":{"default":false,"type":"boolean"},"navigateFallback":{"default":null,"type":["null","string"]},"navigateFallbackAllowlist":{"type":"array","items":{"$ref":"#/definitions/RegExp"}},"navigateFallbackDenylist":{"type":"array","items":{"$ref":"#/definitions/RegExp"}},"navigationPreload":{"default":false,"type":"boolean"},"offlineGoogleAnalytics":{"default":false,"anyOf":[{"$ref":"#/definitions/GoogleAnalyticsInitializeOptions"},{"type":"boolean"}]},"runtimeCaching":{"type":"array","items":{"$ref":"#/definitions/RuntimeCaching"}},"skipWaiting":{"default":false,"type":"boolean"},"sourcemap":{"default":true,"type":"boolean"},"additionalManifestEntries":{"type":"array","items":{"anyOf":[{"$ref":"#/definitions/ManifestEntry"},{"type":"string"}]}},"dontCacheBustURLsMatching":{"$ref":"#/definitions/RegExp"},"manifestTransforms":{"type":"array","items":{"typeof":"function"}},"maximumFileSizeToCacheInBytes":{"default":2097152,"type":"number"},"modifyURLPrefix":{"typeof":"function"},"importScriptsViaChunks":{"type":"array","items":{"type":"string"}},"swDest":{"default":"service-worker.js","type":"string"}},"definitions":{"RegExp":{"type":"object","properties":{"source":{"type":"string"},"global":{"type":"boolean"},"ignoreCase":{"type":"boolean"},"multiline":{"type":"boolean"},"lastIndex":{"type":"number"},"flags":{"type":"string"},"sticky":{"type":"boolean"},"unicode":{"type":"boolean"},"dotAll":{"type":"boolean"}},"additionalProperties":false,"required":["dotAll","flags","global","ignoreCase","lastIndex","multiline","source","sticky","unicode"]},"GoogleAnalyticsInitializeOptions":{"type":"object","properties":{"cacheName":{"type":"string"},"parameterOverrides":{"typeof":"function"},"hitFilter":{"typeof":"function"}},"additionalProperties":false},"RuntimeCaching":{"type":"object","properties":{"handler":{"anyOf":[{"$ref":"#/definitions/RouteHandlerCallback"},{"$ref":"#/definitions/RouteHandlerObject"},{"enum":["CacheFirst","CacheOnly","NetworkFirst","NetworkOnly","StaleWhileRevalidate"],"type":"string"}]},"method":{"enum":["DELETE","GET","HEAD","PATCH","POST","PUT"],"type":"string"},"options":{"typeof":"function"},"urlPattern":{"anyOf":[{"$ref":"#/definitions/RegExp"},{"$ref":"#/definitions/RouteMatchCallback"},{"type":"string"}]}},"additionalProperties":false,"required":["handler","urlPattern"]},"RouteHandlerCallback":{"description":"The \"handler\" callback is invoked whenever a `Router` matches a URL/Request\nto a `Route` via its `RouteMatchCallback`. This handler callback should\nreturn a `Promise` that resolves with a `Response`.\n\nIf a non-empty array or object is returned by the `RouteMatchCallback` it\nwill be passed in as this handler's `options.params` argument.","type":"object","additionalProperties":false},"RouteHandlerObject":{"description":"An object with a `handle` method of type `RouteHandlerCallback`.\n\nA `Route` object can be created with either an `RouteHandlerCallback`\nfunction or this `RouteHandler` object. The benefit of the `RouteHandler`\nis it can be extended (as is done by the `workbox-strategies` package).","type":"object","properties":{"handle":{"$ref":"#/definitions/RouteHandlerCallback"}},"additionalProperties":false,"required":["handle"]},"RouteMatchCallback":{"description":"The \"match\" callback is used to determine if a `Route` should apply for a\nparticular URL and request. When matching occurs in response to a fetch\nevent from the client, the `event` object is also supplied. However, since\nthe match callback can be invoked outside of a fetch event, matching logic\nshould not assume the `event` object will always be available.\nIf the match callback returns a truthy value, the matching route's\n`RouteHandlerCallback` will be invoked immediately. If the value returned\nis a non-empty array or object, that value will be set on the handler's\n`options.params` argument.","type":"object","additionalProperties":false},"ManifestEntry":{"type":"object","properties":{"integrity":{"type":"string"},"revision":{"type":["null","string"]},"url":{"type":"string"}},"additionalProperties":false,"required":["revision","url"]}},"$schema":"http://json-schema.org/draft-07/schema#"} +{"additionalProperties":false,"type":"object","properties":{"additionalManifestEntries":{"type":"array","items":{"anyOf":[{"$ref":"#/definitions/ManifestEntry"},{"type":"string"}]}},"dontCacheBustURLsMatching":{"$ref":"#/definitions/RegExp"},"manifestTransforms":{"type":"array","items":{"typeof":"function"}},"maximumFileSizeToCacheInBytes":{"default":2097152,"type":"number"},"modifyURLPrefix":{},"chunks":{"type":"array","items":{"type":"string"}},"exclude":{"type":"array","items":{}},"excludeChunks":{"type":"array","items":{"type":"string"}},"include":{"type":"array","items":{}},"mode":{"default":"production","type":["null","string"]},"babelPresetEnvTargets":{"default":["chrome >= 56"],"type":"array","items":{"type":"string"}},"cacheId":{"type":["null","string"]},"cleanupOutdatedCaches":{"default":false,"type":"boolean"},"clientsClaim":{"default":false,"type":"boolean"},"directoryIndex":{"type":["null","string"]},"disableDevLogs":{"default":false,"type":"boolean"},"ignoreURLParametersMatching":{"type":"array","items":{"$ref":"#/definitions/RegExp"}},"importScripts":{"type":"array","items":{"type":"string"}},"inlineWorkboxRuntime":{"default":false,"type":"boolean"},"navigateFallback":{"default":null,"type":["null","string"]},"navigateFallbackAllowlist":{"type":"array","items":{"$ref":"#/definitions/RegExp"}},"navigateFallbackDenylist":{"type":"array","items":{"$ref":"#/definitions/RegExp"}},"navigationPreload":{"default":false,"type":"boolean"},"offlineGoogleAnalytics":{"default":false,"anyOf":[{"$ref":"#/definitions/GoogleAnalyticsInitializeOptions"},{"type":"boolean"}]},"runtimeCaching":{"type":"array","items":{"$ref":"#/definitions/RuntimeCaching"}},"skipWaiting":{"default":false,"type":"boolean"},"sourcemap":{"default":true,"type":"boolean"},"importScriptsViaChunks":{"type":"array","items":{"type":"string"}},"swDest":{"default":"service-worker.js","type":"string"}},"definitions":{"ManifestEntry":{"type":"object","properties":{"integrity":{"type":"string"},"revision":{"type":["null","string"]},"url":{"type":"string"}},"additionalProperties":false,"required":["revision","url"]},"RegExp":{"type":"object","properties":{"source":{"type":"string"},"global":{"type":"boolean"},"ignoreCase":{"type":"boolean"},"multiline":{"type":"boolean"},"lastIndex":{"type":"number"},"flags":{"type":"string"},"sticky":{"type":"boolean"},"unicode":{"type":"boolean"},"dotAll":{"type":"boolean"}},"additionalProperties":false,"required":["dotAll","flags","global","ignoreCase","lastIndex","multiline","source","sticky","unicode"]},"GoogleAnalyticsInitializeOptions":{"type":"object","properties":{"cacheName":{"type":"string"},"parameterOverrides":{"typeof":"function"},"hitFilter":{"typeof":"function"}},"additionalProperties":false},"RuntimeCaching":{"type":"object","properties":{"handler":{"anyOf":[{"$ref":"#/definitions/RouteHandlerCallback"},{"$ref":"#/definitions/RouteHandlerObject"},{"enum":["CacheFirst","CacheOnly","NetworkFirst","NetworkOnly","StaleWhileRevalidate"],"type":"string"}]},"method":{"enum":["DELETE","GET","HEAD","PATCH","POST","PUT"],"type":"string"},"options":{"typeof":"function"},"urlPattern":{"anyOf":[{"$ref":"#/definitions/RegExp"},{"$ref":"#/definitions/RouteMatchCallback"},{"type":"string"}]}},"additionalProperties":false,"required":["handler","urlPattern"]},"RouteHandlerCallback":{"description":"The \"handler\" callback is invoked whenever a `Router` matches a URL/Request\nto a `Route` via its `RouteMatchCallback`. This handler callback should\nreturn a `Promise` that resolves with a `Response`.\n\nIf a non-empty array or object is returned by the `RouteMatchCallback` it\nwill be passed in as this handler's `options.params` argument.","type":"object","additionalProperties":false},"RouteHandlerObject":{"description":"An object with a `handle` method of type `RouteHandlerCallback`.\n\nA `Route` object can be created with either an `RouteHandlerCallback`\nfunction or this `RouteHandler` object. The benefit of the `RouteHandler`\nis it can be extended (as is done by the `workbox-strategies` package).","type":"object","properties":{"handle":{"$ref":"#/definitions/RouteHandlerCallback"}},"additionalProperties":false,"required":["handle"]},"RouteMatchCallback":{"description":"The \"match\" callback is used to determine if a `Route` should apply for a\nparticular URL and request. When matching occurs in response to a fetch\nevent from the client, the `event` object is also supplied. However, since\nthe match callback can be invoked outside of a fetch event, matching logic\nshould not assume the `event` object will always be available.\nIf the match callback returns a truthy value, the matching route's\n`RouteHandlerCallback` will be invoked immediately. If the value returned\nis a non-empty array or object, that value will be set on the handler's\n`options.params` argument.","type":"object","additionalProperties":false}},"$schema":"http://json-schema.org/draft-07/schema#"} diff --git a/packages/workbox-build/src/schema/WebpackInjectManifestOptions.json b/packages/workbox-build/src/schema/WebpackInjectManifestOptions.json index 30356424f..20e6cd889 100644 --- a/packages/workbox-build/src/schema/WebpackInjectManifestOptions.json +++ b/packages/workbox-build/src/schema/WebpackInjectManifestOptions.json @@ -1 +1 @@ -{"additionalProperties":false,"type":"object","properties":{"chunks":{"type":"array","items":{"type":"string"}},"exclude":{"type":"array","items":{}},"excludeChunks":{"type":"array","items":{"type":"string"}},"include":{"type":"array","items":{}},"mode":{"type":["null","string"]},"injectionPoint":{"default":"self.__WB_MANIFEST","type":"string"},"swSrc":{"type":"string"},"additionalManifestEntries":{"type":"array","items":{"anyOf":[{"$ref":"#/definitions/ManifestEntry"},{"type":"string"}]}},"dontCacheBustURLsMatching":{"$ref":"#/definitions/RegExp"},"manifestTransforms":{"type":"array","items":{"typeof":"function"}},"maximumFileSizeToCacheInBytes":{"default":2097152,"type":"number"},"modifyURLPrefix":{"typeof":"function"},"compileSrc":{"default":true,"type":"boolean"},"swDest":{"type":"string"},"webpackCompilationPlugins":{"type":"array","items":{}}},"required":["swSrc"],"definitions":{"RegExp":{"type":"object","properties":{"source":{"type":"string"},"global":{"type":"boolean"},"ignoreCase":{"type":"boolean"},"multiline":{"type":"boolean"},"lastIndex":{"type":"number"},"flags":{"type":"string"},"sticky":{"type":"boolean"},"unicode":{"type":"boolean"},"dotAll":{"type":"boolean"}},"additionalProperties":false,"required":["dotAll","flags","global","ignoreCase","lastIndex","multiline","source","sticky","unicode"]},"GoogleAnalyticsInitializeOptions":{"type":"object","properties":{"cacheName":{"type":"string"},"parameterOverrides":{"typeof":"function"},"hitFilter":{"typeof":"function"}},"additionalProperties":false},"RuntimeCaching":{"type":"object","properties":{"handler":{"anyOf":[{"$ref":"#/definitions/RouteHandlerCallback"},{"$ref":"#/definitions/RouteHandlerObject"},{"enum":["CacheFirst","CacheOnly","NetworkFirst","NetworkOnly","StaleWhileRevalidate"],"type":"string"}]},"method":{"enum":["DELETE","GET","HEAD","PATCH","POST","PUT"],"type":"string"},"options":{"typeof":"function"},"urlPattern":{"anyOf":[{"$ref":"#/definitions/RegExp"},{"$ref":"#/definitions/RouteMatchCallback"},{"type":"string"}]}},"additionalProperties":false,"required":["handler","urlPattern"]},"RouteHandlerCallback":{"description":"The \"handler\" callback is invoked whenever a `Router` matches a URL/Request\nto a `Route` via its `RouteMatchCallback`. This handler callback should\nreturn a `Promise` that resolves with a `Response`.\n\nIf a non-empty array or object is returned by the `RouteMatchCallback` it\nwill be passed in as this handler's `options.params` argument.","type":"object","additionalProperties":false},"RouteHandlerObject":{"description":"An object with a `handle` method of type `RouteHandlerCallback`.\n\nA `Route` object can be created with either an `RouteHandlerCallback`\nfunction or this `RouteHandler` object. The benefit of the `RouteHandler`\nis it can be extended (as is done by the `workbox-strategies` package).","type":"object","properties":{"handle":{"$ref":"#/definitions/RouteHandlerCallback"}},"additionalProperties":false,"required":["handle"]},"RouteMatchCallback":{"description":"The \"match\" callback is used to determine if a `Route` should apply for a\nparticular URL and request. When matching occurs in response to a fetch\nevent from the client, the `event` object is also supplied. However, since\nthe match callback can be invoked outside of a fetch event, matching logic\nshould not assume the `event` object will always be available.\nIf the match callback returns a truthy value, the matching route's\n`RouteHandlerCallback` will be invoked immediately. If the value returned\nis a non-empty array or object, that value will be set on the handler's\n`options.params` argument.","type":"object","additionalProperties":false},"ManifestEntry":{"type":"object","properties":{"integrity":{"type":"string"},"revision":{"type":["null","string"]},"url":{"type":"string"}},"additionalProperties":false,"required":["revision","url"]}},"$schema":"http://json-schema.org/draft-07/schema#"} +{"additionalProperties":false,"type":"object","properties":{"additionalManifestEntries":{"type":"array","items":{"anyOf":[{"$ref":"#/definitions/ManifestEntry"},{"type":"string"}]}},"dontCacheBustURLsMatching":{"$ref":"#/definitions/RegExp"},"manifestTransforms":{"type":"array","items":{"typeof":"function"}},"maximumFileSizeToCacheInBytes":{"default":2097152,"type":"number"},"modifyURLPrefix":{},"chunks":{"type":"array","items":{"type":"string"}},"exclude":{"type":"array","items":{}},"excludeChunks":{"type":"array","items":{"type":"string"}},"include":{"type":"array","items":{}},"mode":{"type":["null","string"]},"injectionPoint":{"default":"self.__WB_MANIFEST","type":"string"},"swSrc":{"type":"string"},"compileSrc":{"default":true,"type":"boolean"},"swDest":{"type":"string"},"webpackCompilationPlugins":{"type":"array","items":{}}},"required":["swSrc"],"definitions":{"ManifestEntry":{"type":"object","properties":{"integrity":{"type":"string"},"revision":{"type":["null","string"]},"url":{"type":"string"}},"additionalProperties":false,"required":["revision","url"]},"RegExp":{"type":"object","properties":{"source":{"type":"string"},"global":{"type":"boolean"},"ignoreCase":{"type":"boolean"},"multiline":{"type":"boolean"},"lastIndex":{"type":"number"},"flags":{"type":"string"},"sticky":{"type":"boolean"},"unicode":{"type":"boolean"},"dotAll":{"type":"boolean"}},"additionalProperties":false,"required":["dotAll","flags","global","ignoreCase","lastIndex","multiline","source","sticky","unicode"]},"GoogleAnalyticsInitializeOptions":{"type":"object","properties":{"cacheName":{"type":"string"},"parameterOverrides":{"typeof":"function"},"hitFilter":{"typeof":"function"}},"additionalProperties":false},"RuntimeCaching":{"type":"object","properties":{"handler":{"anyOf":[{"$ref":"#/definitions/RouteHandlerCallback"},{"$ref":"#/definitions/RouteHandlerObject"},{"enum":["CacheFirst","CacheOnly","NetworkFirst","NetworkOnly","StaleWhileRevalidate"],"type":"string"}]},"method":{"enum":["DELETE","GET","HEAD","PATCH","POST","PUT"],"type":"string"},"options":{"typeof":"function"},"urlPattern":{"anyOf":[{"$ref":"#/definitions/RegExp"},{"$ref":"#/definitions/RouteMatchCallback"},{"type":"string"}]}},"additionalProperties":false,"required":["handler","urlPattern"]},"RouteHandlerCallback":{"description":"The \"handler\" callback is invoked whenever a `Router` matches a URL/Request\nto a `Route` via its `RouteMatchCallback`. This handler callback should\nreturn a `Promise` that resolves with a `Response`.\n\nIf a non-empty array or object is returned by the `RouteMatchCallback` it\nwill be passed in as this handler's `options.params` argument.","type":"object","additionalProperties":false},"RouteHandlerObject":{"description":"An object with a `handle` method of type `RouteHandlerCallback`.\n\nA `Route` object can be created with either an `RouteHandlerCallback`\nfunction or this `RouteHandler` object. The benefit of the `RouteHandler`\nis it can be extended (as is done by the `workbox-strategies` package).","type":"object","properties":{"handle":{"$ref":"#/definitions/RouteHandlerCallback"}},"additionalProperties":false,"required":["handle"]},"RouteMatchCallback":{"description":"The \"match\" callback is used to determine if a `Route` should apply for a\nparticular URL and request. When matching occurs in response to a fetch\nevent from the client, the `event` object is also supplied. However, since\nthe match callback can be invoked outside of a fetch event, matching logic\nshould not assume the `event` object will always be available.\nIf the match callback returns a truthy value, the matching route's\n`RouteHandlerCallback` will be invoked immediately. If the value returned\nis a non-empty array or object, that value will be set on the handler's\n`options.params` argument.","type":"object","additionalProperties":false}},"$schema":"http://json-schema.org/draft-07/schema#"} diff --git a/packages/workbox-build/src/types.ts b/packages/workbox-build/src/types.ts index 306a6f7d2..50b3f44e7 100644 --- a/packages/workbox-build/src/types.ts +++ b/packages/workbox-build/src/types.ts @@ -63,9 +63,9 @@ export interface BasePartial { * @default 2097152 */ maximumFileSizeToCacheInBytes?: number; - modifyURLPrefix?: { - [key: string]: string; - }; + // This would ideally be {[key: string]: string}, but the JSON Schema + // generator is unhappy with that right now. + modifyURLPrefix?: any; } export interface GeneratePartial { @@ -193,19 +193,19 @@ interface WebpackInjectManifestPartial { webpackCompilationPlugins?: Array; } -export type GenerateSWOptions = GlobPartial & GeneratePartial & +export type GenerateSWOptions = BasePartial & GlobPartial & GeneratePartial & RequiredSWDestPartial; -export type GetManifestOptions = GlobPartial & BasePartial; +export type GetManifestOptions = BasePartial & GlobPartial; -export type InjectManifestOptions = GlobPartial & BasePartial & InjectPartial & +export type InjectManifestOptions = BasePartial & GlobPartial & InjectPartial & RequiredSWDestPartial; -export type WebpackGenerateSWOptions = WebpackPartial & GeneratePartial & - BasePartial & WebpackGenerateSWPartial; +export type WebpackGenerateSWOptions = BasePartial & WebpackPartial & + GeneratePartial & WebpackGenerateSWPartial; -export type WebpackInjectManifestOptions = WebpackPartial & InjectPartial & - BasePartial & WebpackInjectManifestPartial; +export type WebpackInjectManifestOptions = BasePartial & WebpackPartial & + InjectPartial & WebpackInjectManifestPartial; export interface GetManifestResult { count: number, From 6a79eb1ac5ef85e1f79bf14256566d35823cd505 Mon Sep 17 00:00:00 2001 From: Jeff Posnick Date: Thu, 10 Jun 2021 13:18:12 -0400 Subject: [PATCH 49/80] Fix an import --- packages/workbox-webpack-plugin/src/inject-manifest.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/workbox-webpack-plugin/src/inject-manifest.js b/packages/workbox-webpack-plugin/src/inject-manifest.js index 846801879..9fb05ebff 100644 --- a/packages/workbox-webpack-plugin/src/inject-manifest.js +++ b/packages/workbox-webpack-plugin/src/inject-manifest.js @@ -6,12 +6,12 @@ https://opensource.org/licenses/MIT. */ +const {escapeRegExp} = require('workbox-build/build/lib/escape-regexp'); +const {replaceAndUpdateSourceMap} = + require('workbox-build/build/lib/replace-and-update-source-map'); const {validateWebpackInjectManifestOptions} = require('workbox-build/build/lib/validate-options'); -const {escapeRegExp} = require('workbox-build/build/lib/escape-regexp'); const prettyBytes = require('pretty-bytes'); -const replaceAndUpdateSourceMap = - require('workbox-build/build/lib/replace-and-update-source-map'); const stringify = require('fast-json-stable-stringify'); const upath = require('upath'); const webpack = require('webpack'); From 1f780ac0dd1fc632f769dfcf72ca9b6030a91391 Mon Sep 17 00:00:00 2001 From: Jeff Posnick Date: Thu, 10 Jun 2021 14:20:44 -0400 Subject: [PATCH 50/80] Improve error messages --- packages/workbox-build/package-lock.json | 20 +++++++++ packages/workbox-build/package.json | 1 + .../workbox-build/src/lib/validate-options.ts | 44 +++++++++++++------ 3 files changed, 52 insertions(+), 13 deletions(-) diff --git a/packages/workbox-build/package-lock.json b/packages/workbox-build/package-lock.json index 2681a7c39..8f24f758c 100644 --- a/packages/workbox-build/package-lock.json +++ b/packages/workbox-build/package-lock.json @@ -4,6 +4,16 @@ "lockfileVersion": 1, "requires": true, "dependencies": { + "@apideck/better-ajv-errors": { + "version": "0.2.4", + "resolved": "https://registry.npmjs.org/@apideck/better-ajv-errors/-/better-ajv-errors-0.2.4.tgz", + "integrity": "sha512-scZfMrs2MhqtaHgBhVif2YsrFmSUZ9BxryilZWLnafQYCLCx6l/lu+BIPlCJZ+s9JucUn7YdtnsVPb27oXKRjQ==", + "requires": { + "json-schema": "^0.3.0", + "jsonpointer": "^4.1.0", + "leven": "^3.1.0" + } + }, "@babel/code-frame": { "version": "7.10.4", "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.10.4.tgz", @@ -1426,6 +1436,11 @@ "resolved": "https://registry.npmjs.org/jsesc/-/jsesc-2.5.2.tgz", "integrity": "sha512-OYu7XEzjkCQ3C5Ps3QIZsQfNpqoJyZZA99wd9aWd05NCtC5pWOkShK2mkL6HXQR6/Cy2lbNdPlZBpuQHXE63gA==" }, + "json-schema": { + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/json-schema/-/json-schema-0.3.0.tgz", + "integrity": "sha512-TYfxx36xfl52Rf1LU9HyWSLGPdYLL+SQ8/E/0yVyKG8wCCDaSrhPap0vEdlsZWRaS6tnKKLPGiEJGiREVC8kxQ==" + }, "json-schema-traverse": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-1.0.0.tgz", @@ -1448,6 +1463,11 @@ "universalify": "^1.0.0" } }, + "jsonpointer": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/jsonpointer/-/jsonpointer-4.1.0.tgz", + "integrity": "sha512-CXcRvMyTlnR53xMcKnuMzfCA5i/nfblTnnr74CZb6C4vG39eu6w51t7nKmU5MfLfbTgGItliNyjO/ciNPDqClg==" + }, "leven": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/leven/-/leven-3.1.0.tgz", diff --git a/packages/workbox-build/package.json b/packages/workbox-build/package.json index 69fd0d90d..0e2711aaa 100644 --- a/packages/workbox-build/package.json +++ b/packages/workbox-build/package.json @@ -20,6 +20,7 @@ "bugs": "https://github.com/GoogleChrome/workbox/issues", "homepage": "https://github.com/GoogleChrome/workbox", "dependencies": { + "@apideck/better-ajv-errors": "^0.2.4", "@babel/core": "^7.11.1", "@babel/preset-env": "^7.11.0", "@babel/runtime": "^7.11.2", diff --git a/packages/workbox-build/src/lib/validate-options.ts b/packages/workbox-build/src/lib/validate-options.ts index 3bab5caf7..0b1b2ac94 100644 --- a/packages/workbox-build/src/lib/validate-options.ts +++ b/packages/workbox-build/src/lib/validate-options.ts @@ -6,6 +6,8 @@ https://opensource.org/licenses/MIT. */ +import {betterAjvErrors} from '@apideck/better-ajv-errors'; +import {oneLine as ol} from 'common-tags'; import Ajv, {JSONSchemaType} from 'ajv'; import ajvKeywords from 'ajv-keywords'; @@ -17,6 +19,9 @@ import { WebpackInjectManifestOptions, } from '../types'; +type MethodNames = 'GenerateSW' | 'GetManifest' | 'InjectManifest' | + 'WebpackGenerateSW' | 'WebpackInjectManifest'; + const ajv = new Ajv({ useDefaults: true, }); @@ -24,42 +29,55 @@ ajvKeywords(ajv, ['typeof']); const DEFAULT_EXCLUDE_VALUE= [/\.map$/, /^manifest.*\.js$/]; -function validate(input: unknown, schemaFile: string): T { +export class WorkboxConfigError extends Error { + constructor(message?: string) { + super(message); + Object.setPrototypeOf(this, new.target.prototype); + } +} + +function validate(input: unknown, methodName: MethodNames): T { // Don't mutate input: https://github.com/GoogleChrome/workbox/issues/2158 const inputCopy = Object.assign({}, input); - const jsonSchema: JSONSchemaType = require(schemaFile); + const jsonSchema: JSONSchemaType = require(`../schema/${methodName}Options.json`); const validate = ajv.compile(jsonSchema); if (validate(inputCopy)) { return inputCopy; } - // TODO: Update this code to use better-ajv-errors once - // https://github.com/apideck-libraries/better-ajv-errors/pull/2 is merged. - const error = new Error(JSON.stringify(validate.errors)); - error.name = 'ValidationError'; - throw error; + const betterErrors = betterAjvErrors({ + basePath: methodName, + data: input, + errors: validate.errors, + // This is needed as JSONSchema6 is expected, but JSONSchemaType works. + schema: jsonSchema as any, + }); + const messages = betterErrors.map((err) => ol`[${err.path}] ${err.message}. + ${err.suggestion ? err.suggestion : ''}`); + + throw new WorkboxConfigError(messages.join('\n\n')); } export function validateGenerateSWOptions(input: unknown): GenerateSWOptions { - return validate(input, '../schema/GenerateSWOptions.json'); + return validate(input, 'GenerateSW'); } export function validateGetManifestOptions(input: unknown): GetManifestOptions { - return validate(input, '../schema/GetManifestOptions.json'); + return validate(input, 'GetManifest'); } export function validateInjectManifestOptions(input: unknown): InjectManifestOptions { - return validate(input, '../schema/InjectManifestOptions.json'); + return validate(input, 'InjectManifest'); } -// The default exclude: [/\.map$/, /^manifest.*\.js$/] value can't be +// The default `exclude: [/\.map$/, /^manifest.*\.js$/]` value can't be // represented in the JSON schema, so manually set it for the webpack options. export function validateWebpackGenerateSWOptions(input: unknown): WebpackGenerateSWOptions { const inputWithExcludeDefault = Object.assign({ // Make a copy, as exclude can be mutated when used. exclude: Array.from(DEFAULT_EXCLUDE_VALUE), }, input); - return validate(inputWithExcludeDefault, '../schema/WebpackGenerateSWOptions.json'); + return validate(inputWithExcludeDefault, 'WebpackGenerateSW'); } export function validateWebpackInjectManifestOptions(input: unknown): WebpackInjectManifestOptions { @@ -67,5 +85,5 @@ export function validateWebpackInjectManifestOptions(input: unknown): WebpackInj // Make a copy, as exclude can be mutated when used. exclude: Array.from(DEFAULT_EXCLUDE_VALUE), }, input); - return validate(inputWithExcludeDefault, '../schema/WebpackInjectManifestOptions.json'); + return validate(inputWithExcludeDefault, 'WebpackInjectManifest'); } From 311b1d63d495aec5bc88eadaebe7355835c7e56f Mon Sep 17 00:00:00 2001 From: Jeff Posnick Date: Thu, 10 Jun 2021 14:22:45 -0400 Subject: [PATCH 51/80] Fix test string --- test/workbox-webpack-plugin/node/v4/inject-manifest.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/workbox-webpack-plugin/node/v4/inject-manifest.js b/test/workbox-webpack-plugin/node/v4/inject-manifest.js index 5573500a7..0aeceb7eb 100644 --- a/test/workbox-webpack-plugin/node/v4/inject-manifest.js +++ b/test/workbox-webpack-plugin/node/v4/inject-manifest.js @@ -72,7 +72,7 @@ describe(`[workbox-webpack-plugin] InjectManifest with webpack v4`, function() { const statsJson = stats.toJson(); expect(statsJson.warnings).to.be.empty; expect(statsJson.errors).to.have.members([ - `Please check your InjectManifest plugin configuration:\n"invalid" is not allowed`, + `Please check your InjectManifest plugin configuration:\n[WebpackInjectManifest] 'invalid' property is not expected to be here. Did you mean property 'include'?`, ]); done(); From 4475aeca56e297176fdd84ce838182765874fddc Mon Sep 17 00:00:00 2001 From: Jeff Posnick Date: Thu, 10 Jun 2021 14:35:12 -0400 Subject: [PATCH 52/80] New validation unit test --- .../node/lib/validate-options.js | 27 ++++++++++++++++--- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/test/workbox-build/node/lib/validate-options.js b/test/workbox-build/node/lib/validate-options.js index 2efb71b54..041c02cdc 100644 --- a/test/workbox-build/node/lib/validate-options.js +++ b/test/workbox-build/node/lib/validate-options.js @@ -10,19 +10,24 @@ const expect = require('chai').expect; const proxyquire = require('proxyquire'); const sinon = require('sinon'); -const INJECTED_ERROR = 'Injected error.'; class AJVFailsValidation { compile() { const stub = sinon.stub().returns(false); - stub.errors = [INJECTED_ERROR]; + stub.errors = []; return stub; } + addKeyword() { + // no-op + } } class AJVPassesValidation { compile() { return sinon.stub().returns(true); } + addKeyword() { + // no-op + } } // The integration tests will exercise the actual validation logic. @@ -40,9 +45,23 @@ describe(`[workbox-build] entry-points/options/validate-options.js`, function() 'ajv': { default: AJVFailsValidation, }, + '@apideck/better-ajv-errors': { + betterAjvErrors: sinon.stub().returns([{ + message: 'message1', + path: 'path1', + suggestion: 'suggestion1', + }, { + message: 'message2', + path: 'path2', + suggestion: 'suggestion2', + }]), + }, }); - - expect(() => validateOptions[func]()).to.throw(INJECTED_ERROR); + + expect(() => validateOptions[func]()).to.throw( + validateOptions.WorkboxConfigError, + `[path1] message1. suggestion1\n\n[path2] message2. suggestion2` + ); }); it(`${func}() should not throw when validation passes`, function() { From ad68accf475f4ecbafb017de61112576dd50c912 Mon Sep 17 00:00:00 2001 From: Jeff Posnick Date: Thu, 10 Jun 2021 15:14:38 -0400 Subject: [PATCH 53/80] getManifest working --- package-lock.json | 9 +++++ package.json | 1 + .../src/schema/GenerateSWOptions.json | 2 +- .../src/schema/GetManifestOptions.json | 2 +- .../src/schema/InjectManifestOptions.json | 2 +- packages/workbox-build/src/types.ts | 10 ++--- test/workbox-build/node/get-manifest.js | 38 ++++++++----------- 7 files changed, 33 insertions(+), 31 deletions(-) diff --git a/package-lock.json b/package-lock.json index 84b4ba697..c4636b335 100644 --- a/package-lock.json +++ b/package-lock.json @@ -5920,6 +5920,15 @@ "type-detect": "^4.0.5" } }, + "chai-as-promised": { + "version": "7.1.1", + "resolved": "https://registry.npmjs.org/chai-as-promised/-/chai-as-promised-7.1.1.tgz", + "integrity": "sha512-azL6xMoi+uxu6z4rhWQ1jbdUhOMhis2PvscD/xjLqNMkv3BPPp2JyyuTHOrf9BOosGpNQ11v6BKv/g57RXbiaA==", + "dev": true, + "requires": { + "check-error": "^1.0.2" + } + }, "chai-match-pattern": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/chai-match-pattern/-/chai-match-pattern-1.2.0.tgz", diff --git a/package.json b/package.json index a89a89f97..59c59357e 100644 --- a/package.json +++ b/package.json @@ -69,6 +69,7 @@ "bytes": "^3.1.0", "camelcase": "^6.0.0", "chai": "^4.2.0", + "chai-as-promised": "^7.1.1", "chai-match-pattern": "^1.2.0", "chalk": "^4.1.0", "clear-module": "^4.1.1", diff --git a/packages/workbox-build/src/schema/GenerateSWOptions.json b/packages/workbox-build/src/schema/GenerateSWOptions.json index 8ba3e74d0..a77bcebf0 100644 --- a/packages/workbox-build/src/schema/GenerateSWOptions.json +++ b/packages/workbox-build/src/schema/GenerateSWOptions.json @@ -1 +1 @@ -{"additionalProperties":false,"type":"object","properties":{"additionalManifestEntries":{"type":"array","items":{"anyOf":[{"$ref":"#/definitions/ManifestEntry"},{"type":"string"}]}},"dontCacheBustURLsMatching":{"$ref":"#/definitions/RegExp"},"manifestTransforms":{"type":"array","items":{"typeof":"function"}},"maximumFileSizeToCacheInBytes":{"default":2097152,"type":"number"},"modifyURLPrefix":{},"globDirectory":{"type":"string"},"globFollow":{"default":true,"type":"boolean"},"globIgnores":{"default":["**/node_modules/**/*"],"type":"array","items":{"type":"string"}},"globPatterns":{"default":["**/*.{js,css,html}"],"type":"array","items":{"type":"string"}},"globStrict":{"default":true,"type":"boolean"},"templatedURLs":{"typeof":"function"},"babelPresetEnvTargets":{"default":["chrome >= 56"],"type":"array","items":{"type":"string"}},"cacheId":{"type":["null","string"]},"cleanupOutdatedCaches":{"default":false,"type":"boolean"},"clientsClaim":{"default":false,"type":"boolean"},"directoryIndex":{"type":["null","string"]},"disableDevLogs":{"default":false,"type":"boolean"},"ignoreURLParametersMatching":{"type":"array","items":{"$ref":"#/definitions/RegExp"}},"importScripts":{"type":"array","items":{"type":"string"}},"inlineWorkboxRuntime":{"default":false,"type":"boolean"},"mode":{"default":"production","type":["null","string"]},"navigateFallback":{"default":null,"type":["null","string"]},"navigateFallbackAllowlist":{"type":"array","items":{"$ref":"#/definitions/RegExp"}},"navigateFallbackDenylist":{"type":"array","items":{"$ref":"#/definitions/RegExp"}},"navigationPreload":{"default":false,"type":"boolean"},"offlineGoogleAnalytics":{"default":false,"anyOf":[{"$ref":"#/definitions/GoogleAnalyticsInitializeOptions"},{"type":"boolean"}]},"runtimeCaching":{"type":"array","items":{"$ref":"#/definitions/RuntimeCaching"}},"skipWaiting":{"default":false,"type":"boolean"},"sourcemap":{"default":true,"type":"boolean"},"swDest":{"type":"string"}},"required":["globDirectory","swDest"],"definitions":{"ManifestEntry":{"type":"object","properties":{"integrity":{"type":"string"},"revision":{"type":["null","string"]},"url":{"type":"string"}},"additionalProperties":false,"required":["revision","url"]},"RegExp":{"type":"object","properties":{"source":{"type":"string"},"global":{"type":"boolean"},"ignoreCase":{"type":"boolean"},"multiline":{"type":"boolean"},"lastIndex":{"type":"number"},"flags":{"type":"string"},"sticky":{"type":"boolean"},"unicode":{"type":"boolean"},"dotAll":{"type":"boolean"}},"additionalProperties":false,"required":["dotAll","flags","global","ignoreCase","lastIndex","multiline","source","sticky","unicode"]},"GoogleAnalyticsInitializeOptions":{"type":"object","properties":{"cacheName":{"type":"string"},"parameterOverrides":{"typeof":"function"},"hitFilter":{"typeof":"function"}},"additionalProperties":false},"RuntimeCaching":{"type":"object","properties":{"handler":{"anyOf":[{"$ref":"#/definitions/RouteHandlerCallback"},{"$ref":"#/definitions/RouteHandlerObject"},{"enum":["CacheFirst","CacheOnly","NetworkFirst","NetworkOnly","StaleWhileRevalidate"],"type":"string"}]},"method":{"enum":["DELETE","GET","HEAD","PATCH","POST","PUT"],"type":"string"},"options":{"typeof":"function"},"urlPattern":{"anyOf":[{"$ref":"#/definitions/RegExp"},{"$ref":"#/definitions/RouteMatchCallback"},{"type":"string"}]}},"additionalProperties":false,"required":["handler","urlPattern"]},"RouteHandlerCallback":{"description":"The \"handler\" callback is invoked whenever a `Router` matches a URL/Request\nto a `Route` via its `RouteMatchCallback`. This handler callback should\nreturn a `Promise` that resolves with a `Response`.\n\nIf a non-empty array or object is returned by the `RouteMatchCallback` it\nwill be passed in as this handler's `options.params` argument.","type":"object","additionalProperties":false},"RouteHandlerObject":{"description":"An object with a `handle` method of type `RouteHandlerCallback`.\n\nA `Route` object can be created with either an `RouteHandlerCallback`\nfunction or this `RouteHandler` object. The benefit of the `RouteHandler`\nis it can be extended (as is done by the `workbox-strategies` package).","type":"object","properties":{"handle":{"$ref":"#/definitions/RouteHandlerCallback"}},"additionalProperties":false,"required":["handle"]},"RouteMatchCallback":{"description":"The \"match\" callback is used to determine if a `Route` should apply for a\nparticular URL and request. When matching occurs in response to a fetch\nevent from the client, the `event` object is also supplied. However, since\nthe match callback can be invoked outside of a fetch event, matching logic\nshould not assume the `event` object will always be available.\nIf the match callback returns a truthy value, the matching route's\n`RouteHandlerCallback` will be invoked immediately. If the value returned\nis a non-empty array or object, that value will be set on the handler's\n`options.params` argument.","type":"object","additionalProperties":false}},"$schema":"http://json-schema.org/draft-07/schema#"} +{"additionalProperties":false,"type":"object","properties":{"additionalManifestEntries":{"type":"array","items":{"anyOf":[{"$ref":"#/definitions/ManifestEntry"},{"type":"string"}]}},"dontCacheBustURLsMatching":{"$ref":"#/definitions/RegExp"},"manifestTransforms":{"type":"array","items":{"typeof":"function"}},"maximumFileSizeToCacheInBytes":{"default":2097152,"type":"number"},"modifyURLPrefix":{},"globDirectory":{"type":"string"},"globFollow":{"default":true,"type":"boolean"},"globIgnores":{"default":["**/node_modules/**/*"],"type":"array","items":{"type":"string"}},"globPatterns":{"default":["**/*.{js,css,html}"],"type":"array","items":{"type":"string"}},"globStrict":{"default":true,"type":"boolean"},"templatedURLs":{},"babelPresetEnvTargets":{"default":["chrome >= 56"],"type":"array","items":{"type":"string"}},"cacheId":{"type":["null","string"]},"cleanupOutdatedCaches":{"default":false,"type":"boolean"},"clientsClaim":{"default":false,"type":"boolean"},"directoryIndex":{"type":["null","string"]},"disableDevLogs":{"default":false,"type":"boolean"},"ignoreURLParametersMatching":{"type":"array","items":{"$ref":"#/definitions/RegExp"}},"importScripts":{"type":"array","items":{"type":"string"}},"inlineWorkboxRuntime":{"default":false,"type":"boolean"},"mode":{"default":"production","type":["null","string"]},"navigateFallback":{"default":null,"type":["null","string"]},"navigateFallbackAllowlist":{"type":"array","items":{"$ref":"#/definitions/RegExp"}},"navigateFallbackDenylist":{"type":"array","items":{"$ref":"#/definitions/RegExp"}},"navigationPreload":{"default":false,"type":"boolean"},"offlineGoogleAnalytics":{"default":false,"anyOf":[{"$ref":"#/definitions/GoogleAnalyticsInitializeOptions"},{"type":"boolean"}]},"runtimeCaching":{"type":"array","items":{"$ref":"#/definitions/RuntimeCaching"}},"skipWaiting":{"default":false,"type":"boolean"},"sourcemap":{"default":true,"type":"boolean"},"swDest":{"type":"string"}},"required":["globDirectory","swDest"],"definitions":{"ManifestEntry":{"type":"object","properties":{"integrity":{"type":"string"},"revision":{"type":["null","string"]},"url":{"type":"string"}},"additionalProperties":false,"required":["revision","url"]},"RegExp":{"type":"object","properties":{"source":{"type":"string"},"global":{"type":"boolean"},"ignoreCase":{"type":"boolean"},"multiline":{"type":"boolean"},"lastIndex":{"type":"number"},"flags":{"type":"string"},"sticky":{"type":"boolean"},"unicode":{"type":"boolean"},"dotAll":{"type":"boolean"}},"additionalProperties":false,"required":["dotAll","flags","global","ignoreCase","lastIndex","multiline","source","sticky","unicode"]},"GoogleAnalyticsInitializeOptions":{"type":"object","properties":{"cacheName":{"type":"string"},"parameterOverrides":{"typeof":"function"},"hitFilter":{"typeof":"function"}},"additionalProperties":false},"RuntimeCaching":{"type":"object","properties":{"handler":{"anyOf":[{"$ref":"#/definitions/RouteHandlerCallback"},{"$ref":"#/definitions/RouteHandlerObject"},{"enum":["CacheFirst","CacheOnly","NetworkFirst","NetworkOnly","StaleWhileRevalidate"],"type":"string"}]},"method":{"enum":["DELETE","GET","HEAD","PATCH","POST","PUT"],"type":"string"},"options":{"typeof":"function"},"urlPattern":{"anyOf":[{"$ref":"#/definitions/RegExp"},{"$ref":"#/definitions/RouteMatchCallback"},{"type":"string"}]}},"additionalProperties":false,"required":["handler","urlPattern"]},"RouteHandlerCallback":{"description":"The \"handler\" callback is invoked whenever a `Router` matches a URL/Request\nto a `Route` via its `RouteMatchCallback`. This handler callback should\nreturn a `Promise` that resolves with a `Response`.\n\nIf a non-empty array or object is returned by the `RouteMatchCallback` it\nwill be passed in as this handler's `options.params` argument.","type":"object","additionalProperties":false},"RouteHandlerObject":{"description":"An object with a `handle` method of type `RouteHandlerCallback`.\n\nA `Route` object can be created with either an `RouteHandlerCallback`\nfunction or this `RouteHandler` object. The benefit of the `RouteHandler`\nis it can be extended (as is done by the `workbox-strategies` package).","type":"object","properties":{"handle":{"$ref":"#/definitions/RouteHandlerCallback"}},"additionalProperties":false,"required":["handle"]},"RouteMatchCallback":{"description":"The \"match\" callback is used to determine if a `Route` should apply for a\nparticular URL and request. When matching occurs in response to a fetch\nevent from the client, the `event` object is also supplied. However, since\nthe match callback can be invoked outside of a fetch event, matching logic\nshould not assume the `event` object will always be available.\nIf the match callback returns a truthy value, the matching route's\n`RouteHandlerCallback` will be invoked immediately. If the value returned\nis a non-empty array or object, that value will be set on the handler's\n`options.params` argument.","type":"object","additionalProperties":false}},"$schema":"http://json-schema.org/draft-07/schema#"} diff --git a/packages/workbox-build/src/schema/GetManifestOptions.json b/packages/workbox-build/src/schema/GetManifestOptions.json index 162d87cb1..afdc0f1d1 100644 --- a/packages/workbox-build/src/schema/GetManifestOptions.json +++ b/packages/workbox-build/src/schema/GetManifestOptions.json @@ -1 +1 @@ -{"additionalProperties":false,"type":"object","properties":{"additionalManifestEntries":{"type":"array","items":{"anyOf":[{"$ref":"#/definitions/ManifestEntry"},{"type":"string"}]}},"dontCacheBustURLsMatching":{"$ref":"#/definitions/RegExp"},"manifestTransforms":{"type":"array","items":{"typeof":"function"}},"maximumFileSizeToCacheInBytes":{"default":2097152,"type":"number"},"modifyURLPrefix":{},"globDirectory":{"type":"string"},"globFollow":{"default":true,"type":"boolean"},"globIgnores":{"default":["**/node_modules/**/*"],"type":"array","items":{"type":"string"}},"globPatterns":{"default":["**/*.{js,css,html}"],"type":"array","items":{"type":"string"}},"globStrict":{"default":true,"type":"boolean"},"templatedURLs":{"typeof":"function"}},"required":["globDirectory"],"definitions":{"ManifestEntry":{"type":"object","properties":{"integrity":{"type":"string"},"revision":{"type":["null","string"]},"url":{"type":"string"}},"additionalProperties":false,"required":["revision","url"]},"RegExp":{"type":"object","properties":{"source":{"type":"string"},"global":{"type":"boolean"},"ignoreCase":{"type":"boolean"},"multiline":{"type":"boolean"},"lastIndex":{"type":"number"},"flags":{"type":"string"},"sticky":{"type":"boolean"},"unicode":{"type":"boolean"},"dotAll":{"type":"boolean"}},"additionalProperties":false,"required":["dotAll","flags","global","ignoreCase","lastIndex","multiline","source","sticky","unicode"]},"GoogleAnalyticsInitializeOptions":{"type":"object","properties":{"cacheName":{"type":"string"},"parameterOverrides":{"typeof":"function"},"hitFilter":{"typeof":"function"}},"additionalProperties":false},"RuntimeCaching":{"type":"object","properties":{"handler":{"anyOf":[{"$ref":"#/definitions/RouteHandlerCallback"},{"$ref":"#/definitions/RouteHandlerObject"},{"enum":["CacheFirst","CacheOnly","NetworkFirst","NetworkOnly","StaleWhileRevalidate"],"type":"string"}]},"method":{"enum":["DELETE","GET","HEAD","PATCH","POST","PUT"],"type":"string"},"options":{"typeof":"function"},"urlPattern":{"anyOf":[{"$ref":"#/definitions/RegExp"},{"$ref":"#/definitions/RouteMatchCallback"},{"type":"string"}]}},"additionalProperties":false,"required":["handler","urlPattern"]},"RouteHandlerCallback":{"description":"The \"handler\" callback is invoked whenever a `Router` matches a URL/Request\nto a `Route` via its `RouteMatchCallback`. This handler callback should\nreturn a `Promise` that resolves with a `Response`.\n\nIf a non-empty array or object is returned by the `RouteMatchCallback` it\nwill be passed in as this handler's `options.params` argument.","type":"object","additionalProperties":false},"RouteHandlerObject":{"description":"An object with a `handle` method of type `RouteHandlerCallback`.\n\nA `Route` object can be created with either an `RouteHandlerCallback`\nfunction or this `RouteHandler` object. The benefit of the `RouteHandler`\nis it can be extended (as is done by the `workbox-strategies` package).","type":"object","properties":{"handle":{"$ref":"#/definitions/RouteHandlerCallback"}},"additionalProperties":false,"required":["handle"]},"RouteMatchCallback":{"description":"The \"match\" callback is used to determine if a `Route` should apply for a\nparticular URL and request. When matching occurs in response to a fetch\nevent from the client, the `event` object is also supplied. However, since\nthe match callback can be invoked outside of a fetch event, matching logic\nshould not assume the `event` object will always be available.\nIf the match callback returns a truthy value, the matching route's\n`RouteHandlerCallback` will be invoked immediately. If the value returned\nis a non-empty array or object, that value will be set on the handler's\n`options.params` argument.","type":"object","additionalProperties":false}},"$schema":"http://json-schema.org/draft-07/schema#"} +{"additionalProperties":false,"type":"object","properties":{"additionalManifestEntries":{"type":"array","items":{"anyOf":[{"$ref":"#/definitions/ManifestEntry"},{"type":"string"}]}},"dontCacheBustURLsMatching":{"$ref":"#/definitions/RegExp"},"manifestTransforms":{"type":"array","items":{"typeof":"function"}},"maximumFileSizeToCacheInBytes":{"default":2097152,"type":"number"},"modifyURLPrefix":{},"globDirectory":{"type":"string"},"globFollow":{"default":true,"type":"boolean"},"globIgnores":{"default":["**/node_modules/**/*"],"type":"array","items":{"type":"string"}},"globPatterns":{"default":["**/*.{js,css,html}"],"type":"array","items":{"type":"string"}},"globStrict":{"default":true,"type":"boolean"},"templatedURLs":{}},"required":["globDirectory"],"definitions":{"ManifestEntry":{"type":"object","properties":{"integrity":{"type":"string"},"revision":{"type":["null","string"]},"url":{"type":"string"}},"additionalProperties":false,"required":["revision","url"]},"RegExp":{"type":"object","properties":{"source":{"type":"string"},"global":{"type":"boolean"},"ignoreCase":{"type":"boolean"},"multiline":{"type":"boolean"},"lastIndex":{"type":"number"},"flags":{"type":"string"},"sticky":{"type":"boolean"},"unicode":{"type":"boolean"},"dotAll":{"type":"boolean"}},"additionalProperties":false,"required":["dotAll","flags","global","ignoreCase","lastIndex","multiline","source","sticky","unicode"]},"GoogleAnalyticsInitializeOptions":{"type":"object","properties":{"cacheName":{"type":"string"},"parameterOverrides":{"typeof":"function"},"hitFilter":{"typeof":"function"}},"additionalProperties":false},"RuntimeCaching":{"type":"object","properties":{"handler":{"anyOf":[{"$ref":"#/definitions/RouteHandlerCallback"},{"$ref":"#/definitions/RouteHandlerObject"},{"enum":["CacheFirst","CacheOnly","NetworkFirst","NetworkOnly","StaleWhileRevalidate"],"type":"string"}]},"method":{"enum":["DELETE","GET","HEAD","PATCH","POST","PUT"],"type":"string"},"options":{"typeof":"function"},"urlPattern":{"anyOf":[{"$ref":"#/definitions/RegExp"},{"$ref":"#/definitions/RouteMatchCallback"},{"type":"string"}]}},"additionalProperties":false,"required":["handler","urlPattern"]},"RouteHandlerCallback":{"description":"The \"handler\" callback is invoked whenever a `Router` matches a URL/Request\nto a `Route` via its `RouteMatchCallback`. This handler callback should\nreturn a `Promise` that resolves with a `Response`.\n\nIf a non-empty array or object is returned by the `RouteMatchCallback` it\nwill be passed in as this handler's `options.params` argument.","type":"object","additionalProperties":false},"RouteHandlerObject":{"description":"An object with a `handle` method of type `RouteHandlerCallback`.\n\nA `Route` object can be created with either an `RouteHandlerCallback`\nfunction or this `RouteHandler` object. The benefit of the `RouteHandler`\nis it can be extended (as is done by the `workbox-strategies` package).","type":"object","properties":{"handle":{"$ref":"#/definitions/RouteHandlerCallback"}},"additionalProperties":false,"required":["handle"]},"RouteMatchCallback":{"description":"The \"match\" callback is used to determine if a `Route` should apply for a\nparticular URL and request. When matching occurs in response to a fetch\nevent from the client, the `event` object is also supplied. However, since\nthe match callback can be invoked outside of a fetch event, matching logic\nshould not assume the `event` object will always be available.\nIf the match callback returns a truthy value, the matching route's\n`RouteHandlerCallback` will be invoked immediately. If the value returned\nis a non-empty array or object, that value will be set on the handler's\n`options.params` argument.","type":"object","additionalProperties":false}},"$schema":"http://json-schema.org/draft-07/schema#"} diff --git a/packages/workbox-build/src/schema/InjectManifestOptions.json b/packages/workbox-build/src/schema/InjectManifestOptions.json index 7785ba3a6..6e6a09d18 100644 --- a/packages/workbox-build/src/schema/InjectManifestOptions.json +++ b/packages/workbox-build/src/schema/InjectManifestOptions.json @@ -1 +1 @@ -{"additionalProperties":false,"type":"object","properties":{"additionalManifestEntries":{"type":"array","items":{"anyOf":[{"$ref":"#/definitions/ManifestEntry"},{"type":"string"}]}},"dontCacheBustURLsMatching":{"$ref":"#/definitions/RegExp"},"manifestTransforms":{"type":"array","items":{"typeof":"function"}},"maximumFileSizeToCacheInBytes":{"default":2097152,"type":"number"},"modifyURLPrefix":{},"globDirectory":{"type":"string"},"globFollow":{"default":true,"type":"boolean"},"globIgnores":{"default":["**/node_modules/**/*"],"type":"array","items":{"type":"string"}},"globPatterns":{"default":["**/*.{js,css,html}"],"type":"array","items":{"type":"string"}},"globStrict":{"default":true,"type":"boolean"},"templatedURLs":{"typeof":"function"},"injectionPoint":{"default":"self.__WB_MANIFEST","type":"string"},"swSrc":{"type":"string"},"swDest":{"type":"string"}},"required":["globDirectory","swDest","swSrc"],"definitions":{"ManifestEntry":{"type":"object","properties":{"integrity":{"type":"string"},"revision":{"type":["null","string"]},"url":{"type":"string"}},"additionalProperties":false,"required":["revision","url"]},"RegExp":{"type":"object","properties":{"source":{"type":"string"},"global":{"type":"boolean"},"ignoreCase":{"type":"boolean"},"multiline":{"type":"boolean"},"lastIndex":{"type":"number"},"flags":{"type":"string"},"sticky":{"type":"boolean"},"unicode":{"type":"boolean"},"dotAll":{"type":"boolean"}},"additionalProperties":false,"required":["dotAll","flags","global","ignoreCase","lastIndex","multiline","source","sticky","unicode"]},"GoogleAnalyticsInitializeOptions":{"type":"object","properties":{"cacheName":{"type":"string"},"parameterOverrides":{"typeof":"function"},"hitFilter":{"typeof":"function"}},"additionalProperties":false},"RuntimeCaching":{"type":"object","properties":{"handler":{"anyOf":[{"$ref":"#/definitions/RouteHandlerCallback"},{"$ref":"#/definitions/RouteHandlerObject"},{"enum":["CacheFirst","CacheOnly","NetworkFirst","NetworkOnly","StaleWhileRevalidate"],"type":"string"}]},"method":{"enum":["DELETE","GET","HEAD","PATCH","POST","PUT"],"type":"string"},"options":{"typeof":"function"},"urlPattern":{"anyOf":[{"$ref":"#/definitions/RegExp"},{"$ref":"#/definitions/RouteMatchCallback"},{"type":"string"}]}},"additionalProperties":false,"required":["handler","urlPattern"]},"RouteHandlerCallback":{"description":"The \"handler\" callback is invoked whenever a `Router` matches a URL/Request\nto a `Route` via its `RouteMatchCallback`. This handler callback should\nreturn a `Promise` that resolves with a `Response`.\n\nIf a non-empty array or object is returned by the `RouteMatchCallback` it\nwill be passed in as this handler's `options.params` argument.","type":"object","additionalProperties":false},"RouteHandlerObject":{"description":"An object with a `handle` method of type `RouteHandlerCallback`.\n\nA `Route` object can be created with either an `RouteHandlerCallback`\nfunction or this `RouteHandler` object. The benefit of the `RouteHandler`\nis it can be extended (as is done by the `workbox-strategies` package).","type":"object","properties":{"handle":{"$ref":"#/definitions/RouteHandlerCallback"}},"additionalProperties":false,"required":["handle"]},"RouteMatchCallback":{"description":"The \"match\" callback is used to determine if a `Route` should apply for a\nparticular URL and request. When matching occurs in response to a fetch\nevent from the client, the `event` object is also supplied. However, since\nthe match callback can be invoked outside of a fetch event, matching logic\nshould not assume the `event` object will always be available.\nIf the match callback returns a truthy value, the matching route's\n`RouteHandlerCallback` will be invoked immediately. If the value returned\nis a non-empty array or object, that value will be set on the handler's\n`options.params` argument.","type":"object","additionalProperties":false}},"$schema":"http://json-schema.org/draft-07/schema#"} +{"additionalProperties":false,"type":"object","properties":{"additionalManifestEntries":{"type":"array","items":{"anyOf":[{"$ref":"#/definitions/ManifestEntry"},{"type":"string"}]}},"dontCacheBustURLsMatching":{"$ref":"#/definitions/RegExp"},"manifestTransforms":{"type":"array","items":{"typeof":"function"}},"maximumFileSizeToCacheInBytes":{"default":2097152,"type":"number"},"modifyURLPrefix":{},"globDirectory":{"type":"string"},"globFollow":{"default":true,"type":"boolean"},"globIgnores":{"default":["**/node_modules/**/*"],"type":"array","items":{"type":"string"}},"globPatterns":{"default":["**/*.{js,css,html}"],"type":"array","items":{"type":"string"}},"globStrict":{"default":true,"type":"boolean"},"templatedURLs":{},"injectionPoint":{"default":"self.__WB_MANIFEST","type":"string"},"swSrc":{"type":"string"},"swDest":{"type":"string"}},"required":["globDirectory","swDest","swSrc"],"definitions":{"ManifestEntry":{"type":"object","properties":{"integrity":{"type":"string"},"revision":{"type":["null","string"]},"url":{"type":"string"}},"additionalProperties":false,"required":["revision","url"]},"RegExp":{"type":"object","properties":{"source":{"type":"string"},"global":{"type":"boolean"},"ignoreCase":{"type":"boolean"},"multiline":{"type":"boolean"},"lastIndex":{"type":"number"},"flags":{"type":"string"},"sticky":{"type":"boolean"},"unicode":{"type":"boolean"},"dotAll":{"type":"boolean"}},"additionalProperties":false,"required":["dotAll","flags","global","ignoreCase","lastIndex","multiline","source","sticky","unicode"]},"GoogleAnalyticsInitializeOptions":{"type":"object","properties":{"cacheName":{"type":"string"},"parameterOverrides":{"typeof":"function"},"hitFilter":{"typeof":"function"}},"additionalProperties":false},"RuntimeCaching":{"type":"object","properties":{"handler":{"anyOf":[{"$ref":"#/definitions/RouteHandlerCallback"},{"$ref":"#/definitions/RouteHandlerObject"},{"enum":["CacheFirst","CacheOnly","NetworkFirst","NetworkOnly","StaleWhileRevalidate"],"type":"string"}]},"method":{"enum":["DELETE","GET","HEAD","PATCH","POST","PUT"],"type":"string"},"options":{"typeof":"function"},"urlPattern":{"anyOf":[{"$ref":"#/definitions/RegExp"},{"$ref":"#/definitions/RouteMatchCallback"},{"type":"string"}]}},"additionalProperties":false,"required":["handler","urlPattern"]},"RouteHandlerCallback":{"description":"The \"handler\" callback is invoked whenever a `Router` matches a URL/Request\nto a `Route` via its `RouteMatchCallback`. This handler callback should\nreturn a `Promise` that resolves with a `Response`.\n\nIf a non-empty array or object is returned by the `RouteMatchCallback` it\nwill be passed in as this handler's `options.params` argument.","type":"object","additionalProperties":false},"RouteHandlerObject":{"description":"An object with a `handle` method of type `RouteHandlerCallback`.\n\nA `Route` object can be created with either an `RouteHandlerCallback`\nfunction or this `RouteHandler` object. The benefit of the `RouteHandler`\nis it can be extended (as is done by the `workbox-strategies` package).","type":"object","properties":{"handle":{"$ref":"#/definitions/RouteHandlerCallback"}},"additionalProperties":false,"required":["handle"]},"RouteMatchCallback":{"description":"The \"match\" callback is used to determine if a `Route` should apply for a\nparticular URL and request. When matching occurs in response to a fetch\nevent from the client, the `event` object is also supplied. However, since\nthe match callback can be invoked outside of a fetch event, matching logic\nshould not assume the `event` object will always be available.\nIf the match callback returns a truthy value, the matching route's\n`RouteHandlerCallback` will be invoked immediately. If the value returned\nis a non-empty array or object, that value will be set on the handler's\n`options.params` argument.","type":"object","additionalProperties":false}},"$schema":"http://json-schema.org/draft-07/schema#"} diff --git a/packages/workbox-build/src/types.ts b/packages/workbox-build/src/types.ts index 50b3f44e7..f29f35c5d 100644 --- a/packages/workbox-build/src/types.ts +++ b/packages/workbox-build/src/types.ts @@ -63,8 +63,8 @@ export interface BasePartial { * @default 2097152 */ maximumFileSizeToCacheInBytes?: number; - // This would ideally be {[key: string]: string}, but the JSON Schema - // generator is unhappy with that right now. + // https://github.com/YousefED/typescript-json-schema/issues/424 + // This would ideally be {[key: string]: string} modifyURLPrefix?: any; } @@ -140,9 +140,9 @@ export interface GlobPartial { * @default true */ globStrict?: boolean; - templatedURLs?: { - [key: string]: string | Array; - }; + // https://github.com/YousefED/typescript-json-schema/issues/424 + // This would ideally be {[key: string]: string | Array} + templatedURLs?: any; } interface InjectPartial { diff --git a/test/workbox-build/node/get-manifest.js b/test/workbox-build/node/get-manifest.js index 666f70555..16322b70e 100644 --- a/test/workbox-build/node/get-manifest.js +++ b/test/workbox-build/node/get-manifest.js @@ -7,15 +7,18 @@ */ const chai = require('chai'); +const chaiAsPromised = require('chai-as-promised'); const chaiMatchPattern = require('chai-match-pattern'); const fse = require('fs-extra'); const upath = require('upath'); const tempy = require('tempy'); +chai.use(chaiAsPromised); chai.use(chaiMatchPattern); const {expect} = chai; const {getManifest} = require('../../../packages/workbox-build/build/get-manifest'); +const {WorkboxConfigError} = require('../../../packages/workbox-build/build/lib/validate-options'); describe(`[workbox-build] get-manifest.js (End to End)`, function() { const SRC_DIR = upath.join(__dirname, '..', 'static', 'example-project-1'); @@ -53,34 +56,28 @@ describe(`[workbox-build] get-manifest.js (End to End)`, function() { describe('[workbox-build] unsupported parameters', function() { for (const unsupportedParam of UNSUPPORTED_PARAMS) { - it(`should reject with a ValidationError when '${unsupportedParam}' is present`, async function() { + it(`should fail validation when '${unsupportedParam}' is present`, async function() { const options = Object.assign({}, BASE_OPTIONS); options[unsupportedParam] = unsupportedParam; - try { - await getManifest(options); - throw new Error('Unexpected success.'); - } catch (error) { - expect(error.name).to.eql('ValidationError'); - expect(error.details[0].context.key).to.eql(unsupportedParam); - } + await expect(getManifest(options)).to.eventually.be.rejectedWith( + WorkboxConfigError, unsupportedParam); }); } }); describe('[workbox-build] invalid parameter values', function() { for (const param of SUPPORTED_PARAMS) { - it(`should reject with a ValidationError when '${param}' is null`, async function() { + it(`should fail validation when '${param}' is null`, async function() { + if (['modifyURLPrefix', 'templatedURLs'].includes(param)) { + // https://github.com/YousefED/typescript-json-schema/issues/424 + this.skip(); + } const options = Object.assign({}, BASE_OPTIONS); options[param] = null; - try { - await getManifest(options); - throw new Error('Unexpected success.'); - } catch (error) { - expect(error.name).to.eql('ValidationError'); - expect(error.details[0].context.key).to.eql(param); - } + await expect(getManifest(options)).to.eventually.be.rejectedWith( + WorkboxConfigError, param); }); } }); @@ -330,13 +327,8 @@ describe(`[workbox-build] get-manifest.js (End to End)`, function() { [option]: value, }); - try { - await getManifest(options); - throw new Error('Unexpected success.'); - } catch (error) { - expect(error.name).to.eql('ValidationError'); - expect(error.details[0].context.key).to.eql(option); - } + await expect(getManifest(options)).to.eventually.be.rejectedWith( + WorkboxConfigError, option); }); } }); From 19c207a92cad8a3f430c0dda985a67325f5f6ef4 Mon Sep 17 00:00:00 2001 From: Jeff Posnick Date: Thu, 10 Jun 2021 16:13:47 -0400 Subject: [PATCH 54/80] Working through generateSW --- package-lock.json | 6 +- packages/workbox-build/src/lib/errors.ts | 2 + .../workbox-build/src/lib/validate-options.ts | 19 ++++- .../src/schema/GenerateSWOptions.json | 2 +- .../src/schema/WebpackGenerateSWOptions.json | 2 +- packages/workbox-build/src/types.ts | 2 + test/workbox-build/node/generate-sw.js | 77 ++++++++----------- test/workbox-build/node/get-manifest.js | 4 +- 8 files changed, 61 insertions(+), 53 deletions(-) diff --git a/package-lock.json b/package-lock.json index c4636b335..3088fafae 100644 --- a/package-lock.json +++ b/package-lock.json @@ -5886,9 +5886,9 @@ } }, "caniuse-lite": { - "version": "1.0.30001228", - "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001228.tgz", - "integrity": "sha512-QQmLOGJ3DEgokHbMSA8cj2a+geXqmnpyOFT0lhQV6P3/YOJvGDEwoedcwxEQ30gJIwIIunHIicunJ2rzK5gB2A==", + "version": "1.0.30001236", + "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001236.tgz", + "integrity": "sha512-o0PRQSrSCGJKCPZcgMzl5fUaj5xHe8qA2m4QRvnyY4e1lITqoNkr7q/Oh1NcpGSy0Th97UZ35yoKcINPoq7YOQ==", "dev": true }, "caseless": { diff --git a/packages/workbox-build/src/lib/errors.ts b/packages/workbox-build/src/lib/errors.ts index f166b07e6..1a591d8bb 100644 --- a/packages/workbox-build/src/lib/errors.ts +++ b/packages/workbox-build/src/lib/errors.ts @@ -114,4 +114,6 @@ export const errors = { runtimeCaching option.`, 'cant-find-sourcemap': ol`The swSrc file refers to a sourcemap that can't be opened:`, + 'nav-preload-runtime-caching': ol`When using navigationPreload, you must also + configure a runtimeCaching route that will use the preloaded response.`, }; diff --git a/packages/workbox-build/src/lib/validate-options.ts b/packages/workbox-build/src/lib/validate-options.ts index 0b1b2ac94..089f91239 100644 --- a/packages/workbox-build/src/lib/validate-options.ts +++ b/packages/workbox-build/src/lib/validate-options.ts @@ -11,6 +11,8 @@ import {oneLine as ol} from 'common-tags'; import Ajv, {JSONSchemaType} from 'ajv'; import ajvKeywords from 'ajv-keywords'; +import {errors} from './errors'; + import { GenerateSWOptions, GetManifestOptions, @@ -58,8 +60,19 @@ function validate(input: unknown, methodName: MethodNames): T { throw new WorkboxConfigError(messages.join('\n\n')); } +function ensureValidNavigationPreloadConfig( + options: GenerateSWOptions | WebpackGenerateSWOptions, +): void { + if (options.navigationPreload && + (!Array.isArray(options.runtimeCaching) || + options.runtimeCaching.length === 0)) { + throw new WorkboxConfigError(errors['nav-preload-runtime-caching']); + } +} export function validateGenerateSWOptions(input: unknown): GenerateSWOptions { - return validate(input, 'GenerateSW'); + const validatedOptions = validate(input, 'GenerateSW'); + ensureValidNavigationPreloadConfig(validatedOptions); + return validatedOptions; } export function validateGetManifestOptions(input: unknown): GetManifestOptions { @@ -77,7 +90,9 @@ export function validateWebpackGenerateSWOptions(input: unknown): WebpackGenerat // Make a copy, as exclude can be mutated when used. exclude: Array.from(DEFAULT_EXCLUDE_VALUE), }, input); - return validate(inputWithExcludeDefault, 'WebpackGenerateSW'); + const validatedOptions = validate(inputWithExcludeDefault, 'WebpackGenerateSW'); + ensureValidNavigationPreloadConfig(validatedOptions); + return validatedOptions; } export function validateWebpackInjectManifestOptions(input: unknown): WebpackInjectManifestOptions { diff --git a/packages/workbox-build/src/schema/GenerateSWOptions.json b/packages/workbox-build/src/schema/GenerateSWOptions.json index a77bcebf0..67a36d628 100644 --- a/packages/workbox-build/src/schema/GenerateSWOptions.json +++ b/packages/workbox-build/src/schema/GenerateSWOptions.json @@ -1 +1 @@ -{"additionalProperties":false,"type":"object","properties":{"additionalManifestEntries":{"type":"array","items":{"anyOf":[{"$ref":"#/definitions/ManifestEntry"},{"type":"string"}]}},"dontCacheBustURLsMatching":{"$ref":"#/definitions/RegExp"},"manifestTransforms":{"type":"array","items":{"typeof":"function"}},"maximumFileSizeToCacheInBytes":{"default":2097152,"type":"number"},"modifyURLPrefix":{},"globDirectory":{"type":"string"},"globFollow":{"default":true,"type":"boolean"},"globIgnores":{"default":["**/node_modules/**/*"],"type":"array","items":{"type":"string"}},"globPatterns":{"default":["**/*.{js,css,html}"],"type":"array","items":{"type":"string"}},"globStrict":{"default":true,"type":"boolean"},"templatedURLs":{},"babelPresetEnvTargets":{"default":["chrome >= 56"],"type":"array","items":{"type":"string"}},"cacheId":{"type":["null","string"]},"cleanupOutdatedCaches":{"default":false,"type":"boolean"},"clientsClaim":{"default":false,"type":"boolean"},"directoryIndex":{"type":["null","string"]},"disableDevLogs":{"default":false,"type":"boolean"},"ignoreURLParametersMatching":{"type":"array","items":{"$ref":"#/definitions/RegExp"}},"importScripts":{"type":"array","items":{"type":"string"}},"inlineWorkboxRuntime":{"default":false,"type":"boolean"},"mode":{"default":"production","type":["null","string"]},"navigateFallback":{"default":null,"type":["null","string"]},"navigateFallbackAllowlist":{"type":"array","items":{"$ref":"#/definitions/RegExp"}},"navigateFallbackDenylist":{"type":"array","items":{"$ref":"#/definitions/RegExp"}},"navigationPreload":{"default":false,"type":"boolean"},"offlineGoogleAnalytics":{"default":false,"anyOf":[{"$ref":"#/definitions/GoogleAnalyticsInitializeOptions"},{"type":"boolean"}]},"runtimeCaching":{"type":"array","items":{"$ref":"#/definitions/RuntimeCaching"}},"skipWaiting":{"default":false,"type":"boolean"},"sourcemap":{"default":true,"type":"boolean"},"swDest":{"type":"string"}},"required":["globDirectory","swDest"],"definitions":{"ManifestEntry":{"type":"object","properties":{"integrity":{"type":"string"},"revision":{"type":["null","string"]},"url":{"type":"string"}},"additionalProperties":false,"required":["revision","url"]},"RegExp":{"type":"object","properties":{"source":{"type":"string"},"global":{"type":"boolean"},"ignoreCase":{"type":"boolean"},"multiline":{"type":"boolean"},"lastIndex":{"type":"number"},"flags":{"type":"string"},"sticky":{"type":"boolean"},"unicode":{"type":"boolean"},"dotAll":{"type":"boolean"}},"additionalProperties":false,"required":["dotAll","flags","global","ignoreCase","lastIndex","multiline","source","sticky","unicode"]},"GoogleAnalyticsInitializeOptions":{"type":"object","properties":{"cacheName":{"type":"string"},"parameterOverrides":{"typeof":"function"},"hitFilter":{"typeof":"function"}},"additionalProperties":false},"RuntimeCaching":{"type":"object","properties":{"handler":{"anyOf":[{"$ref":"#/definitions/RouteHandlerCallback"},{"$ref":"#/definitions/RouteHandlerObject"},{"enum":["CacheFirst","CacheOnly","NetworkFirst","NetworkOnly","StaleWhileRevalidate"],"type":"string"}]},"method":{"enum":["DELETE","GET","HEAD","PATCH","POST","PUT"],"type":"string"},"options":{"typeof":"function"},"urlPattern":{"anyOf":[{"$ref":"#/definitions/RegExp"},{"$ref":"#/definitions/RouteMatchCallback"},{"type":"string"}]}},"additionalProperties":false,"required":["handler","urlPattern"]},"RouteHandlerCallback":{"description":"The \"handler\" callback is invoked whenever a `Router` matches a URL/Request\nto a `Route` via its `RouteMatchCallback`. This handler callback should\nreturn a `Promise` that resolves with a `Response`.\n\nIf a non-empty array or object is returned by the `RouteMatchCallback` it\nwill be passed in as this handler's `options.params` argument.","type":"object","additionalProperties":false},"RouteHandlerObject":{"description":"An object with a `handle` method of type `RouteHandlerCallback`.\n\nA `Route` object can be created with either an `RouteHandlerCallback`\nfunction or this `RouteHandler` object. The benefit of the `RouteHandler`\nis it can be extended (as is done by the `workbox-strategies` package).","type":"object","properties":{"handle":{"$ref":"#/definitions/RouteHandlerCallback"}},"additionalProperties":false,"required":["handle"]},"RouteMatchCallback":{"description":"The \"match\" callback is used to determine if a `Route` should apply for a\nparticular URL and request. When matching occurs in response to a fetch\nevent from the client, the `event` object is also supplied. However, since\nthe match callback can be invoked outside of a fetch event, matching logic\nshould not assume the `event` object will always be available.\nIf the match callback returns a truthy value, the matching route's\n`RouteHandlerCallback` will be invoked immediately. If the value returned\nis a non-empty array or object, that value will be set on the handler's\n`options.params` argument.","type":"object","additionalProperties":false}},"$schema":"http://json-schema.org/draft-07/schema#"} +{"additionalProperties":false,"type":"object","properties":{"additionalManifestEntries":{"type":"array","items":{"anyOf":[{"$ref":"#/definitions/ManifestEntry"},{"type":"string"}]}},"dontCacheBustURLsMatching":{"$ref":"#/definitions/RegExp"},"manifestTransforms":{"type":"array","items":{"typeof":"function"}},"maximumFileSizeToCacheInBytes":{"default":2097152,"type":"number"},"modifyURLPrefix":{},"globDirectory":{"type":"string"},"globFollow":{"default":true,"type":"boolean"},"globIgnores":{"default":["**/node_modules/**/*"],"type":"array","items":{"type":"string"}},"globPatterns":{"default":["**/*.{js,css,html}"],"type":"array","items":{"type":"string"}},"globStrict":{"default":true,"type":"boolean"},"templatedURLs":{},"babelPresetEnvTargets":{"default":["chrome >= 56"],"type":"array","items":{"type":"string"}},"cacheId":{"type":["null","string"]},"cleanupOutdatedCaches":{"default":false,"type":"boolean"},"clientsClaim":{"default":false,"type":"boolean"},"directoryIndex":{"type":["null","string"]},"disableDevLogs":{"default":false,"type":"boolean"},"ignoreURLParametersMatching":{"type":"array","items":{"$ref":"#/definitions/RegExp"}},"importScripts":{"type":"array","items":{"type":"string"}},"inlineWorkboxRuntime":{"default":false,"type":"boolean"},"mode":{"default":"production","type":["null","string"]},"navigateFallback":{"default":null,"type":["null","string"]},"navigateFallbackAllowlist":{"type":"array","items":{"$ref":"#/definitions/RegExp"}},"navigateFallbackDenylist":{"type":"array","items":{"$ref":"#/definitions/RegExp"}},"navigationPreload":{"description":"navigationPreload is only valid when runtimeCaching is configured. However,\nthis can't be expressed via TypeScript, so it's enforced via runtime logic.","default":false,"type":"boolean"},"offlineGoogleAnalytics":{"default":false,"anyOf":[{"$ref":"#/definitions/GoogleAnalyticsInitializeOptions"},{"type":"boolean"}]},"runtimeCaching":{"type":"array","items":{"$ref":"#/definitions/RuntimeCaching"}},"skipWaiting":{"default":false,"type":"boolean"},"sourcemap":{"default":true,"type":"boolean"},"swDest":{"type":"string"}},"required":["globDirectory","swDest"],"definitions":{"ManifestEntry":{"type":"object","properties":{"integrity":{"type":"string"},"revision":{"type":["null","string"]},"url":{"type":"string"}},"additionalProperties":false,"required":["revision","url"]},"RegExp":{"type":"object","properties":{"source":{"type":"string"},"global":{"type":"boolean"},"ignoreCase":{"type":"boolean"},"multiline":{"type":"boolean"},"lastIndex":{"type":"number"},"flags":{"type":"string"},"sticky":{"type":"boolean"},"unicode":{"type":"boolean"},"dotAll":{"type":"boolean"}},"additionalProperties":false,"required":["dotAll","flags","global","ignoreCase","lastIndex","multiline","source","sticky","unicode"]},"GoogleAnalyticsInitializeOptions":{"type":"object","properties":{"cacheName":{"type":"string"},"parameterOverrides":{"typeof":"function"},"hitFilter":{"typeof":"function"}},"additionalProperties":false},"RuntimeCaching":{"type":"object","properties":{"handler":{"anyOf":[{"$ref":"#/definitions/RouteHandlerCallback"},{"$ref":"#/definitions/RouteHandlerObject"},{"enum":["CacheFirst","CacheOnly","NetworkFirst","NetworkOnly","StaleWhileRevalidate"],"type":"string"}]},"method":{"enum":["DELETE","GET","HEAD","PATCH","POST","PUT"],"type":"string"},"options":{"typeof":"function"},"urlPattern":{"anyOf":[{"$ref":"#/definitions/RegExp"},{"$ref":"#/definitions/RouteMatchCallback"},{"type":"string"}]}},"additionalProperties":false,"required":["handler","urlPattern"]},"RouteHandlerCallback":{"description":"The \"handler\" callback is invoked whenever a `Router` matches a URL/Request\nto a `Route` via its `RouteMatchCallback`. This handler callback should\nreturn a `Promise` that resolves with a `Response`.\n\nIf a non-empty array or object is returned by the `RouteMatchCallback` it\nwill be passed in as this handler's `options.params` argument.","type":"object","additionalProperties":false},"RouteHandlerObject":{"description":"An object with a `handle` method of type `RouteHandlerCallback`.\n\nA `Route` object can be created with either an `RouteHandlerCallback`\nfunction or this `RouteHandler` object. The benefit of the `RouteHandler`\nis it can be extended (as is done by the `workbox-strategies` package).","type":"object","properties":{"handle":{"$ref":"#/definitions/RouteHandlerCallback"}},"additionalProperties":false,"required":["handle"]},"RouteMatchCallback":{"description":"The \"match\" callback is used to determine if a `Route` should apply for a\nparticular URL and request. When matching occurs in response to a fetch\nevent from the client, the `event` object is also supplied. However, since\nthe match callback can be invoked outside of a fetch event, matching logic\nshould not assume the `event` object will always be available.\nIf the match callback returns a truthy value, the matching route's\n`RouteHandlerCallback` will be invoked immediately. If the value returned\nis a non-empty array or object, that value will be set on the handler's\n`options.params` argument.","type":"object","additionalProperties":false}},"$schema":"http://json-schema.org/draft-07/schema#"} diff --git a/packages/workbox-build/src/schema/WebpackGenerateSWOptions.json b/packages/workbox-build/src/schema/WebpackGenerateSWOptions.json index 9c9aff45e..abb407008 100644 --- a/packages/workbox-build/src/schema/WebpackGenerateSWOptions.json +++ b/packages/workbox-build/src/schema/WebpackGenerateSWOptions.json @@ -1 +1 @@ -{"additionalProperties":false,"type":"object","properties":{"additionalManifestEntries":{"type":"array","items":{"anyOf":[{"$ref":"#/definitions/ManifestEntry"},{"type":"string"}]}},"dontCacheBustURLsMatching":{"$ref":"#/definitions/RegExp"},"manifestTransforms":{"type":"array","items":{"typeof":"function"}},"maximumFileSizeToCacheInBytes":{"default":2097152,"type":"number"},"modifyURLPrefix":{},"chunks":{"type":"array","items":{"type":"string"}},"exclude":{"type":"array","items":{}},"excludeChunks":{"type":"array","items":{"type":"string"}},"include":{"type":"array","items":{}},"mode":{"default":"production","type":["null","string"]},"babelPresetEnvTargets":{"default":["chrome >= 56"],"type":"array","items":{"type":"string"}},"cacheId":{"type":["null","string"]},"cleanupOutdatedCaches":{"default":false,"type":"boolean"},"clientsClaim":{"default":false,"type":"boolean"},"directoryIndex":{"type":["null","string"]},"disableDevLogs":{"default":false,"type":"boolean"},"ignoreURLParametersMatching":{"type":"array","items":{"$ref":"#/definitions/RegExp"}},"importScripts":{"type":"array","items":{"type":"string"}},"inlineWorkboxRuntime":{"default":false,"type":"boolean"},"navigateFallback":{"default":null,"type":["null","string"]},"navigateFallbackAllowlist":{"type":"array","items":{"$ref":"#/definitions/RegExp"}},"navigateFallbackDenylist":{"type":"array","items":{"$ref":"#/definitions/RegExp"}},"navigationPreload":{"default":false,"type":"boolean"},"offlineGoogleAnalytics":{"default":false,"anyOf":[{"$ref":"#/definitions/GoogleAnalyticsInitializeOptions"},{"type":"boolean"}]},"runtimeCaching":{"type":"array","items":{"$ref":"#/definitions/RuntimeCaching"}},"skipWaiting":{"default":false,"type":"boolean"},"sourcemap":{"default":true,"type":"boolean"},"importScriptsViaChunks":{"type":"array","items":{"type":"string"}},"swDest":{"default":"service-worker.js","type":"string"}},"definitions":{"ManifestEntry":{"type":"object","properties":{"integrity":{"type":"string"},"revision":{"type":["null","string"]},"url":{"type":"string"}},"additionalProperties":false,"required":["revision","url"]},"RegExp":{"type":"object","properties":{"source":{"type":"string"},"global":{"type":"boolean"},"ignoreCase":{"type":"boolean"},"multiline":{"type":"boolean"},"lastIndex":{"type":"number"},"flags":{"type":"string"},"sticky":{"type":"boolean"},"unicode":{"type":"boolean"},"dotAll":{"type":"boolean"}},"additionalProperties":false,"required":["dotAll","flags","global","ignoreCase","lastIndex","multiline","source","sticky","unicode"]},"GoogleAnalyticsInitializeOptions":{"type":"object","properties":{"cacheName":{"type":"string"},"parameterOverrides":{"typeof":"function"},"hitFilter":{"typeof":"function"}},"additionalProperties":false},"RuntimeCaching":{"type":"object","properties":{"handler":{"anyOf":[{"$ref":"#/definitions/RouteHandlerCallback"},{"$ref":"#/definitions/RouteHandlerObject"},{"enum":["CacheFirst","CacheOnly","NetworkFirst","NetworkOnly","StaleWhileRevalidate"],"type":"string"}]},"method":{"enum":["DELETE","GET","HEAD","PATCH","POST","PUT"],"type":"string"},"options":{"typeof":"function"},"urlPattern":{"anyOf":[{"$ref":"#/definitions/RegExp"},{"$ref":"#/definitions/RouteMatchCallback"},{"type":"string"}]}},"additionalProperties":false,"required":["handler","urlPattern"]},"RouteHandlerCallback":{"description":"The \"handler\" callback is invoked whenever a `Router` matches a URL/Request\nto a `Route` via its `RouteMatchCallback`. This handler callback should\nreturn a `Promise` that resolves with a `Response`.\n\nIf a non-empty array or object is returned by the `RouteMatchCallback` it\nwill be passed in as this handler's `options.params` argument.","type":"object","additionalProperties":false},"RouteHandlerObject":{"description":"An object with a `handle` method of type `RouteHandlerCallback`.\n\nA `Route` object can be created with either an `RouteHandlerCallback`\nfunction or this `RouteHandler` object. The benefit of the `RouteHandler`\nis it can be extended (as is done by the `workbox-strategies` package).","type":"object","properties":{"handle":{"$ref":"#/definitions/RouteHandlerCallback"}},"additionalProperties":false,"required":["handle"]},"RouteMatchCallback":{"description":"The \"match\" callback is used to determine if a `Route` should apply for a\nparticular URL and request. When matching occurs in response to a fetch\nevent from the client, the `event` object is also supplied. However, since\nthe match callback can be invoked outside of a fetch event, matching logic\nshould not assume the `event` object will always be available.\nIf the match callback returns a truthy value, the matching route's\n`RouteHandlerCallback` will be invoked immediately. If the value returned\nis a non-empty array or object, that value will be set on the handler's\n`options.params` argument.","type":"object","additionalProperties":false}},"$schema":"http://json-schema.org/draft-07/schema#"} +{"additionalProperties":false,"type":"object","properties":{"additionalManifestEntries":{"type":"array","items":{"anyOf":[{"$ref":"#/definitions/ManifestEntry"},{"type":"string"}]}},"dontCacheBustURLsMatching":{"$ref":"#/definitions/RegExp"},"manifestTransforms":{"type":"array","items":{"typeof":"function"}},"maximumFileSizeToCacheInBytes":{"default":2097152,"type":"number"},"modifyURLPrefix":{},"chunks":{"type":"array","items":{"type":"string"}},"exclude":{"type":"array","items":{}},"excludeChunks":{"type":"array","items":{"type":"string"}},"include":{"type":"array","items":{}},"mode":{"default":"production","type":["null","string"]},"babelPresetEnvTargets":{"default":["chrome >= 56"],"type":"array","items":{"type":"string"}},"cacheId":{"type":["null","string"]},"cleanupOutdatedCaches":{"default":false,"type":"boolean"},"clientsClaim":{"default":false,"type":"boolean"},"directoryIndex":{"type":["null","string"]},"disableDevLogs":{"default":false,"type":"boolean"},"ignoreURLParametersMatching":{"type":"array","items":{"$ref":"#/definitions/RegExp"}},"importScripts":{"type":"array","items":{"type":"string"}},"inlineWorkboxRuntime":{"default":false,"type":"boolean"},"navigateFallback":{"default":null,"type":["null","string"]},"navigateFallbackAllowlist":{"type":"array","items":{"$ref":"#/definitions/RegExp"}},"navigateFallbackDenylist":{"type":"array","items":{"$ref":"#/definitions/RegExp"}},"navigationPreload":{"description":"navigationPreload is only valid when runtimeCaching is configured. However,\nthis can't be expressed via TypeScript, so it's enforced via runtime logic.","default":false,"type":"boolean"},"offlineGoogleAnalytics":{"default":false,"anyOf":[{"$ref":"#/definitions/GoogleAnalyticsInitializeOptions"},{"type":"boolean"}]},"runtimeCaching":{"type":"array","items":{"$ref":"#/definitions/RuntimeCaching"}},"skipWaiting":{"default":false,"type":"boolean"},"sourcemap":{"default":true,"type":"boolean"},"importScriptsViaChunks":{"type":"array","items":{"type":"string"}},"swDest":{"default":"service-worker.js","type":"string"}},"definitions":{"ManifestEntry":{"type":"object","properties":{"integrity":{"type":"string"},"revision":{"type":["null","string"]},"url":{"type":"string"}},"additionalProperties":false,"required":["revision","url"]},"RegExp":{"type":"object","properties":{"source":{"type":"string"},"global":{"type":"boolean"},"ignoreCase":{"type":"boolean"},"multiline":{"type":"boolean"},"lastIndex":{"type":"number"},"flags":{"type":"string"},"sticky":{"type":"boolean"},"unicode":{"type":"boolean"},"dotAll":{"type":"boolean"}},"additionalProperties":false,"required":["dotAll","flags","global","ignoreCase","lastIndex","multiline","source","sticky","unicode"]},"GoogleAnalyticsInitializeOptions":{"type":"object","properties":{"cacheName":{"type":"string"},"parameterOverrides":{"typeof":"function"},"hitFilter":{"typeof":"function"}},"additionalProperties":false},"RuntimeCaching":{"type":"object","properties":{"handler":{"anyOf":[{"$ref":"#/definitions/RouteHandlerCallback"},{"$ref":"#/definitions/RouteHandlerObject"},{"enum":["CacheFirst","CacheOnly","NetworkFirst","NetworkOnly","StaleWhileRevalidate"],"type":"string"}]},"method":{"enum":["DELETE","GET","HEAD","PATCH","POST","PUT"],"type":"string"},"options":{"typeof":"function"},"urlPattern":{"anyOf":[{"$ref":"#/definitions/RegExp"},{"$ref":"#/definitions/RouteMatchCallback"},{"type":"string"}]}},"additionalProperties":false,"required":["handler","urlPattern"]},"RouteHandlerCallback":{"description":"The \"handler\" callback is invoked whenever a `Router` matches a URL/Request\nto a `Route` via its `RouteMatchCallback`. This handler callback should\nreturn a `Promise` that resolves with a `Response`.\n\nIf a non-empty array or object is returned by the `RouteMatchCallback` it\nwill be passed in as this handler's `options.params` argument.","type":"object","additionalProperties":false},"RouteHandlerObject":{"description":"An object with a `handle` method of type `RouteHandlerCallback`.\n\nA `Route` object can be created with either an `RouteHandlerCallback`\nfunction or this `RouteHandler` object. The benefit of the `RouteHandler`\nis it can be extended (as is done by the `workbox-strategies` package).","type":"object","properties":{"handle":{"$ref":"#/definitions/RouteHandlerCallback"}},"additionalProperties":false,"required":["handle"]},"RouteMatchCallback":{"description":"The \"match\" callback is used to determine if a `Route` should apply for a\nparticular URL and request. When matching occurs in response to a fetch\nevent from the client, the `event` object is also supplied. However, since\nthe match callback can be invoked outside of a fetch event, matching logic\nshould not assume the `event` object will always be available.\nIf the match callback returns a truthy value, the matching route's\n`RouteHandlerCallback` will be invoked immediately. If the value returned\nis a non-empty array or object, that value will be set on the handler's\n`options.params` argument.","type":"object","additionalProperties":false}},"$schema":"http://json-schema.org/draft-07/schema#"} diff --git a/packages/workbox-build/src/types.ts b/packages/workbox-build/src/types.ts index f29f35c5d..2eb270bb3 100644 --- a/packages/workbox-build/src/types.ts +++ b/packages/workbox-build/src/types.ts @@ -104,6 +104,8 @@ export interface GeneratePartial { navigateFallbackAllowlist?: Array; navigateFallbackDenylist?: Array; /** + * navigationPreload is only valid when runtimeCaching is configured. However, + * this can't be expressed via TypeScript, so it's enforced via runtime logic. * @default false */ navigationPreload?: boolean; diff --git a/test/workbox-build/node/generate-sw.js b/test/workbox-build/node/generate-sw.js index 6da7b1d92..f505a0155 100644 --- a/test/workbox-build/node/generate-sw.js +++ b/test/workbox-build/node/generate-sw.js @@ -6,16 +6,21 @@ https://opensource.org/licenses/MIT. */ -const expect = require('chai').expect; +const chai = require('chai'); +const chaiAsPromised = require('chai-as-promised'); const fse = require('fs-extra'); const upath = require('upath'); const tempy = require('tempy'); -const confirmDirectoryContains = require('../../../infra/testing/confirm-directory-contains'); const {errors} = require('../../../packages/workbox-build/build/lib/errors'); const {generateSW} = require('../../../packages/workbox-build/build/generate-sw'); +const {WorkboxConfigError} = require('../../../packages/workbox-build/build/lib/validate-options'); +const confirmDirectoryContains = require('../../../infra/testing/confirm-directory-contains'); const validateServiceWorkerRuntime = require('../../../infra/testing/validator/service-worker-runtime'); +chai.use(chaiAsPromised); +const {expect} = chai; + describe(`[workbox-build] generate-sw.js (End to End)`, function() { const GLOB_DIR = upath.join(__dirname, '..', 'static', 'example-project-1'); const BASE_OPTIONS = { @@ -64,64 +69,50 @@ describe(`[workbox-build] generate-sw.js (End to End)`, function() { describe('[workbox-build] required parameters', function() { for (const requiredParam of REQUIRED_PARAMS) { - it(`should reject with a ValidationError when '${requiredParam}' is missing`, async function() { + it(`should fail validation when '${requiredParam}' is missing`, async function() { const options = Object.assign({}, BASE_OPTIONS); delete options[requiredParam]; - try { - await generateSW(options); - throw new Error('Unexpected success.'); - } catch (error) { - expect(error.name).to.eql('ValidationError', error.message); - expect(error.details[0].context.key).to.eql(requiredParam); - } + await expect(generateSW(options)).to.eventually.be.rejectedWith( + WorkboxConfigError, requiredParam); }); } }); describe('[workbox-build] unsupported parameters', function() { for (const unsupportedParam of UNSUPPORTED_PARAMS) { - it(`should reject with a ValidationError when '${unsupportedParam}' is present`, async function() { + it(`should fail validation when '${unsupportedParam}' is present`, async function() { const options = Object.assign({}, BASE_OPTIONS); options[unsupportedParam] = unsupportedParam; - try { - await generateSW(options); - throw new Error('Unexpected success.'); - } catch (error) { - expect(error.name).to.eql('ValidationError', error.message); - expect(error.details[0].context.key).to.eql(unsupportedParam); - } + await expect(generateSW(options)).to.eventually.be.rejectedWith( + WorkboxConfigError, unsupportedParam); }); } }); describe('[workbox-build] invalid parameter values', function() { for (const param of SUPPORTED_PARAMS) { - it(`should reject with a ValidationError when '${param}' is null`, async function() { - const options = Object.assign({}, BASE_OPTIONS); - options[param] = null; - - try { - await generateSW(options); - throw new Error('Unexpected success.'); - } catch (error) { - expect(error.name).to.eql('ValidationError', error.message); - expect(error.details[0].context.key).to.eql(param); + it(`should fail validation when '${param}' is an unexpected value`, async function() { + if (['modifyURLPrefix', 'templatedURLs'].includes(param)) { + // https://github.com/YousefED/typescript-json-schema/issues/424 + this.skip(); } + const options = Object.assign({}, BASE_OPTIONS); + options[param] = () => {}; + + await expect(generateSW(options)).to.eventually.be.rejectedWith( + WorkboxConfigError, param); }); } it(`should reject when there are no manifest entries or runtimeCaching`, async function() { const options = Object.assign({}, BASE_OPTIONS); - delete options.globDirectory; + // This temporary directory will be empty. + options.globDirectory = tempy.directory(); - try { - await generateSW(options); - throw new Error('Unexpected success.'); - } catch (error) { - expect(error.message).to.eql(errors['no-manifest-entries-or-runtime-caching']); - } + await expect(generateSW(options)).to.eventually.be.rejectedWith( + errors['no-manifest-entries-or-runtime-caching']); }); }); @@ -362,7 +353,10 @@ describe(`[workbox-build] generate-sw.js (End to End)`, function() { }, { url: 'webpackEntry.js', revision: /^[0-9a-f]{32}$/, - }, '/one', { + }, { + revision: null, + url: '/one', + }, { revision: null, url: '/two', }, { @@ -1082,17 +1076,12 @@ describe(`[workbox-build] generate-sw.js (End to End)`, function() { it(`should reject with a ValidationError when 'navigationPreload' is true and 'runtimeCaching' is invalid`, async function() { const options = Object.assign({}, BASE_OPTIONS, { - runtimeCaching: 'invalid', + runtimeCaching: undefined, navigationPreload: true, }); - try { - await generateSW(options); - throw new Error('Unexpected success.'); - } catch (error) { - expect(error.name).to.eql('ValidationError', error.message); - expect(error.details[0].context.key).to.eql('runtimeCaching'); - } + await expect(generateSW(options)).to.eventually.be.rejectedWith( + WorkboxConfigError, errors['nav-preload-runtime-caching']); }); it(`should generate when 'navigationPreload' is true and 'runtimeCaching' is valid`, async function() { diff --git a/test/workbox-build/node/get-manifest.js b/test/workbox-build/node/get-manifest.js index 16322b70e..61fb09d4c 100644 --- a/test/workbox-build/node/get-manifest.js +++ b/test/workbox-build/node/get-manifest.js @@ -68,13 +68,13 @@ describe(`[workbox-build] get-manifest.js (End to End)`, function() { describe('[workbox-build] invalid parameter values', function() { for (const param of SUPPORTED_PARAMS) { - it(`should fail validation when '${param}' is null`, async function() { + it(`should fail validation when '${param}' is an unexpected value`, async function() { if (['modifyURLPrefix', 'templatedURLs'].includes(param)) { // https://github.com/YousefED/typescript-json-schema/issues/424 this.skip(); } const options = Object.assign({}, BASE_OPTIONS); - options[param] = null; + options[param] = () => {}; await expect(getManifest(options)).to.eventually.be.rejectedWith( WorkboxConfigError, param); From 7d895fc1bfeac7c5d0aaa1df247f49c0d08477fd Mon Sep 17 00:00:00 2001 From: Jeff Posnick Date: Mon, 14 Jun 2021 14:20:05 -0400 Subject: [PATCH 55/80] Function massaging --- gulp-tasks/build-node-packages.js | 13 ++++++++++++- .../src/schema/GenerateSWOptions.json | 2 +- .../src/schema/GetManifestOptions.json | 2 +- .../src/schema/InjectManifestOptions.json | 2 +- .../src/schema/WebpackGenerateSWOptions.json | 2 +- .../schema/WebpackInjectManifestOptions.json | 2 +- packages/workbox-build/src/types.ts | 18 ++++++++---------- 7 files changed, 25 insertions(+), 16 deletions(-) diff --git a/gulp-tasks/build-node-packages.js b/gulp-tasks/build-node-packages.js index d9e0d08c7..b19b5839f 100644 --- a/gulp-tasks/build-node-packages.js +++ b/gulp-tasks/build-node-packages.js @@ -36,7 +36,6 @@ async function generateWorkboxBuildJSONSchema(packagePath) { const generator = TJS.buildGenerator(program, { noExtraProps: true, required: true, - typeOfKeyword: true, }); const optionTypes = [ 'GenerateSWOptions', @@ -47,6 +46,18 @@ async function generateWorkboxBuildJSONSchema(packagePath) { ]; for (const optionType of optionTypes) { const schema = generator.getSchemaForSymbol(optionType); + // Ideally, we'd set typeOfKeyword so that functions could be represented. + // Instead, we need to hardcode a few overrides to deal with functions. + // See https://github.com/YousefED/typescript-json-schema/issues/424 + if (schema.properties.manifestTransforms) { + schema.properties.manifestTransforms.items = {typeof: 'function'}; + } + if (schema.properties.exclude) { + schema.properties.exclude.items.anyOf.push({typeof: 'function'}); + } + if (schema.properties.include) { + schema.properties.include.items.anyOf.push({typeof: 'function'}); + } await fse.writeJSON(upath.join(packagePath, 'src', 'schema', `${optionType}.json`), schema); } diff --git a/packages/workbox-build/src/schema/GenerateSWOptions.json b/packages/workbox-build/src/schema/GenerateSWOptions.json index 67a36d628..12fa8d492 100644 --- a/packages/workbox-build/src/schema/GenerateSWOptions.json +++ b/packages/workbox-build/src/schema/GenerateSWOptions.json @@ -1 +1 @@ -{"additionalProperties":false,"type":"object","properties":{"additionalManifestEntries":{"type":"array","items":{"anyOf":[{"$ref":"#/definitions/ManifestEntry"},{"type":"string"}]}},"dontCacheBustURLsMatching":{"$ref":"#/definitions/RegExp"},"manifestTransforms":{"type":"array","items":{"typeof":"function"}},"maximumFileSizeToCacheInBytes":{"default":2097152,"type":"number"},"modifyURLPrefix":{},"globDirectory":{"type":"string"},"globFollow":{"default":true,"type":"boolean"},"globIgnores":{"default":["**/node_modules/**/*"],"type":"array","items":{"type":"string"}},"globPatterns":{"default":["**/*.{js,css,html}"],"type":"array","items":{"type":"string"}},"globStrict":{"default":true,"type":"boolean"},"templatedURLs":{},"babelPresetEnvTargets":{"default":["chrome >= 56"],"type":"array","items":{"type":"string"}},"cacheId":{"type":["null","string"]},"cleanupOutdatedCaches":{"default":false,"type":"boolean"},"clientsClaim":{"default":false,"type":"boolean"},"directoryIndex":{"type":["null","string"]},"disableDevLogs":{"default":false,"type":"boolean"},"ignoreURLParametersMatching":{"type":"array","items":{"$ref":"#/definitions/RegExp"}},"importScripts":{"type":"array","items":{"type":"string"}},"inlineWorkboxRuntime":{"default":false,"type":"boolean"},"mode":{"default":"production","type":["null","string"]},"navigateFallback":{"default":null,"type":["null","string"]},"navigateFallbackAllowlist":{"type":"array","items":{"$ref":"#/definitions/RegExp"}},"navigateFallbackDenylist":{"type":"array","items":{"$ref":"#/definitions/RegExp"}},"navigationPreload":{"description":"navigationPreload is only valid when runtimeCaching is configured. However,\nthis can't be expressed via TypeScript, so it's enforced via runtime logic.","default":false,"type":"boolean"},"offlineGoogleAnalytics":{"default":false,"anyOf":[{"$ref":"#/definitions/GoogleAnalyticsInitializeOptions"},{"type":"boolean"}]},"runtimeCaching":{"type":"array","items":{"$ref":"#/definitions/RuntimeCaching"}},"skipWaiting":{"default":false,"type":"boolean"},"sourcemap":{"default":true,"type":"boolean"},"swDest":{"type":"string"}},"required":["globDirectory","swDest"],"definitions":{"ManifestEntry":{"type":"object","properties":{"integrity":{"type":"string"},"revision":{"type":["null","string"]},"url":{"type":"string"}},"additionalProperties":false,"required":["revision","url"]},"RegExp":{"type":"object","properties":{"source":{"type":"string"},"global":{"type":"boolean"},"ignoreCase":{"type":"boolean"},"multiline":{"type":"boolean"},"lastIndex":{"type":"number"},"flags":{"type":"string"},"sticky":{"type":"boolean"},"unicode":{"type":"boolean"},"dotAll":{"type":"boolean"}},"additionalProperties":false,"required":["dotAll","flags","global","ignoreCase","lastIndex","multiline","source","sticky","unicode"]},"GoogleAnalyticsInitializeOptions":{"type":"object","properties":{"cacheName":{"type":"string"},"parameterOverrides":{"typeof":"function"},"hitFilter":{"typeof":"function"}},"additionalProperties":false},"RuntimeCaching":{"type":"object","properties":{"handler":{"anyOf":[{"$ref":"#/definitions/RouteHandlerCallback"},{"$ref":"#/definitions/RouteHandlerObject"},{"enum":["CacheFirst","CacheOnly","NetworkFirst","NetworkOnly","StaleWhileRevalidate"],"type":"string"}]},"method":{"enum":["DELETE","GET","HEAD","PATCH","POST","PUT"],"type":"string"},"options":{"typeof":"function"},"urlPattern":{"anyOf":[{"$ref":"#/definitions/RegExp"},{"$ref":"#/definitions/RouteMatchCallback"},{"type":"string"}]}},"additionalProperties":false,"required":["handler","urlPattern"]},"RouteHandlerCallback":{"description":"The \"handler\" callback is invoked whenever a `Router` matches a URL/Request\nto a `Route` via its `RouteMatchCallback`. This handler callback should\nreturn a `Promise` that resolves with a `Response`.\n\nIf a non-empty array or object is returned by the `RouteMatchCallback` it\nwill be passed in as this handler's `options.params` argument.","type":"object","additionalProperties":false},"RouteHandlerObject":{"description":"An object with a `handle` method of type `RouteHandlerCallback`.\n\nA `Route` object can be created with either an `RouteHandlerCallback`\nfunction or this `RouteHandler` object. The benefit of the `RouteHandler`\nis it can be extended (as is done by the `workbox-strategies` package).","type":"object","properties":{"handle":{"$ref":"#/definitions/RouteHandlerCallback"}},"additionalProperties":false,"required":["handle"]},"RouteMatchCallback":{"description":"The \"match\" callback is used to determine if a `Route` should apply for a\nparticular URL and request. When matching occurs in response to a fetch\nevent from the client, the `event` object is also supplied. However, since\nthe match callback can be invoked outside of a fetch event, matching logic\nshould not assume the `event` object will always be available.\nIf the match callback returns a truthy value, the matching route's\n`RouteHandlerCallback` will be invoked immediately. If the value returned\nis a non-empty array or object, that value will be set on the handler's\n`options.params` argument.","type":"object","additionalProperties":false}},"$schema":"http://json-schema.org/draft-07/schema#"} +{"additionalProperties":false,"type":"object","properties":{"additionalManifestEntries":{"type":"array","items":{"anyOf":[{"$ref":"#/definitions/ManifestEntry"},{"type":"string"}]}},"dontCacheBustURLsMatching":{"$ref":"#/definitions/RegExp"},"manifestTransforms":{"type":"array","items":{"typeof":"function"}},"maximumFileSizeToCacheInBytes":{"default":2097152,"type":"number"},"modifyURLPrefix":{"type":"object","additionalProperties":{"type":"string"}},"globDirectory":{"type":"string"},"globFollow":{"default":true,"type":"boolean"},"globIgnores":{"default":["**/node_modules/**/*"],"type":"array","items":{"type":"string"}},"globPatterns":{"default":["**/*.{js,css,html}"],"type":"array","items":{"type":"string"}},"globStrict":{"default":true,"type":"boolean"},"templatedURLs":{"type":"object","additionalProperties":{"anyOf":[{"type":"array","items":{"type":"string"}},{"type":"string"}]}},"babelPresetEnvTargets":{"default":["chrome >= 56"],"type":"array","items":{"type":"string"}},"cacheId":{"type":["null","string"]},"cleanupOutdatedCaches":{"default":false,"type":"boolean"},"clientsClaim":{"default":false,"type":"boolean"},"directoryIndex":{"type":["null","string"]},"disableDevLogs":{"default":false,"type":"boolean"},"ignoreURLParametersMatching":{"type":"array","items":{"$ref":"#/definitions/RegExp"}},"importScripts":{"type":"array","items":{"type":"string"}},"inlineWorkboxRuntime":{"default":false,"type":"boolean"},"mode":{"default":"production","type":["null","string"]},"navigateFallback":{"default":null,"type":["null","string"]},"navigateFallbackAllowlist":{"type":"array","items":{"$ref":"#/definitions/RegExp"}},"navigateFallbackDenylist":{"type":"array","items":{"$ref":"#/definitions/RegExp"}},"navigationPreload":{"description":"navigationPreload is only valid when runtimeCaching is configured. However,\nthis can't be expressed via TypeScript, so it's enforced via runtime logic.","default":false,"type":"boolean"},"offlineGoogleAnalytics":{"default":false,"anyOf":[{"$ref":"#/definitions/GoogleAnalyticsInitializeOptions"},{"type":"boolean"}]},"runtimeCaching":{"type":"array","items":{"$ref":"#/definitions/RuntimeCaching"}},"skipWaiting":{"default":false,"type":"boolean"},"sourcemap":{"default":true,"type":"boolean"},"swDest":{"type":"string"}},"required":["globDirectory","swDest"],"definitions":{"ManifestEntry":{"type":"object","properties":{"integrity":{"type":"string"},"revision":{"type":["null","string"]},"url":{"type":"string"}},"additionalProperties":false,"required":["revision","url"]},"RegExp":{"type":"object","properties":{"source":{"type":"string"},"global":{"type":"boolean"},"ignoreCase":{"type":"boolean"},"multiline":{"type":"boolean"},"lastIndex":{"type":"number"},"flags":{"type":"string"},"sticky":{"type":"boolean"},"unicode":{"type":"boolean"},"dotAll":{"type":"boolean"}},"additionalProperties":false,"required":["dotAll","flags","global","ignoreCase","lastIndex","multiline","source","sticky","unicode"]},"GoogleAnalyticsInitializeOptions":{"type":"object","properties":{"cacheName":{"type":"string"},"parameterOverrides":{"type":"object","additionalProperties":{"type":"string"}},"hitFilter":{"type":"object","additionalProperties":false}},"additionalProperties":false},"RuntimeCaching":{"type":"object","properties":{"handler":{"anyOf":[{"$ref":"#/definitions/RouteHandlerCallback"},{"$ref":"#/definitions/RouteHandlerObject"},{"enum":["CacheFirst","CacheOnly","NetworkFirst","NetworkOnly","StaleWhileRevalidate"],"type":"string"}]},"method":{"enum":["DELETE","GET","HEAD","PATCH","POST","PUT"],"type":"string"},"options":{"type":"object","properties":{"backgroundSync":{"type":"object","properties":{"name":{"type":"string"},"options":{"$ref":"#/definitions/QueueOptions"}},"additionalProperties":false,"required":["name"]},"broadcastUpdate":{"type":"object","properties":{"channelName":{"type":"string"},"options":{"$ref":"#/definitions/BroadcastCacheUpdateOptions"}},"additionalProperties":false,"required":["options"]},"cacheableResponse":{"$ref":"#/definitions/CacheableResponseOptions"},"cacheName":{"type":["null","string"]},"expiration":{"$ref":"#/definitions/ExpirationPluginOptions"},"networkTimeoutSeconds":{"type":"number"},"plugins":{"type":"array","items":{"$ref":"#/definitions/WorkboxPlugin"}},"precacheFallback":{"type":"object","properties":{"fallbackURL":{"type":"string"}},"additionalProperties":false,"required":["fallbackURL"]},"fetchOptions":{"$ref":"#/definitions/RequestInit"},"matchOptions":{"$ref":"#/definitions/CacheQueryOptions"}},"additionalProperties":false},"urlPattern":{"anyOf":[{"$ref":"#/definitions/RegExp"},{"$ref":"#/definitions/RouteMatchCallback"},{"type":"string"}]}},"additionalProperties":false,"required":["handler","urlPattern"]},"RouteHandlerCallback":{"description":"The \"handler\" callback is invoked whenever a `Router` matches a URL/Request\nto a `Route` via its `RouteMatchCallback`. This handler callback should\nreturn a `Promise` that resolves with a `Response`.\n\nIf a non-empty array or object is returned by the `RouteMatchCallback` it\nwill be passed in as this handler's `options.params` argument.","type":"object","additionalProperties":false},"RouteHandlerObject":{"description":"An object with a `handle` method of type `RouteHandlerCallback`.\n\nA `Route` object can be created with either an `RouteHandlerCallback`\nfunction or this `RouteHandler` object. The benefit of the `RouteHandler`\nis it can be extended (as is done by the `workbox-strategies` package).","type":"object","properties":{"handle":{"$ref":"#/definitions/RouteHandlerCallback"}},"additionalProperties":false,"required":["handle"]},"QueueOptions":{"type":"object","properties":{"onSync":{"$ref":"#/definitions/OnSyncCallback"},"maxRetentionTime":{"type":"number"}},"additionalProperties":false},"OnSyncCallback":{"type":"object","additionalProperties":false},"BroadcastCacheUpdateOptions":{"type":"object","properties":{"headersToCheck":{"type":"array","items":{"type":"string"}},"generatePayload":{"type":"object","additionalProperties":false}},"additionalProperties":false},"CacheableResponseOptions":{"type":"object","properties":{"statuses":{"type":"array","items":{"type":"number"}},"headers":{"type":"object","additionalProperties":{"type":"string"}}},"additionalProperties":false},"ExpirationPluginOptions":{"type":"object","properties":{"maxEntries":{"type":"number"},"maxAgeSeconds":{"type":"number"},"matchOptions":{"$ref":"#/definitions/CacheQueryOptions"},"purgeOnQuotaError":{"type":"boolean"}},"additionalProperties":false},"CacheQueryOptions":{"type":"object","properties":{"ignoreMethod":{"type":"boolean"},"ignoreSearch":{"type":"boolean"},"ignoreVary":{"type":"boolean"}},"additionalProperties":false},"WorkboxPlugin":{"description":"An object with optional lifecycle callback properties for the fetch and\ncache operations.","type":"object","properties":{"cacheDidUpdate":{"$ref":"#/definitions/CacheDidUpdateCallback"},"cachedResponseWillBeUsed":{"$ref":"#/definitions/CachedResponseWillBeUsedCallback"},"cacheKeyWillBeUsed":{"$ref":"#/definitions/CacheKeyWillBeUsedCallback"},"cacheWillUpdate":{"$ref":"#/definitions/CacheWillUpdateCallback"},"fetchDidFail":{"$ref":"#/definitions/FetchDidFailCallback"},"fetchDidSucceed":{"$ref":"#/definitions/FetchDidSucceedCallback"},"handlerDidComplete":{"$ref":"#/definitions/HandlerDidCompleteCallback"},"handlerDidError":{"$ref":"#/definitions/HandlerDidErrorCallback"},"handlerDidRespond":{"$ref":"#/definitions/HandlerDidRespondCallback"},"handlerWillRespond":{"$ref":"#/definitions/HandlerWillRespondCallback"},"handlerWillStart":{"$ref":"#/definitions/HandlerWillStartCallback"},"requestWillFetch":{"$ref":"#/definitions/RequestWillFetchCallback"}},"additionalProperties":false},"CacheDidUpdateCallback":{"type":"object","additionalProperties":false},"CachedResponseWillBeUsedCallback":{"type":"object","additionalProperties":false},"CacheKeyWillBeUsedCallback":{"type":"object","additionalProperties":false},"CacheWillUpdateCallback":{"type":"object","additionalProperties":false},"FetchDidFailCallback":{"type":"object","additionalProperties":false},"FetchDidSucceedCallback":{"type":"object","additionalProperties":false},"HandlerDidCompleteCallback":{"type":"object","additionalProperties":false},"HandlerDidErrorCallback":{"type":"object","additionalProperties":false},"HandlerDidRespondCallback":{"type":"object","additionalProperties":false},"HandlerWillRespondCallback":{"type":"object","additionalProperties":false},"HandlerWillStartCallback":{"type":"object","additionalProperties":false},"RequestWillFetchCallback":{"type":"object","additionalProperties":false},"RequestInit":{"type":"object","properties":{"body":{"anyOf":[{"$ref":"#/definitions/ArrayBuffer"},{"$ref":"#/definitions/ArrayBufferView"},{"$ref":"#/definitions/Blob"},{"$ref":"#/definitions/FormData"},{"$ref":"#/definitions/URLSearchParams"},{"$ref":"#/definitions/ReadableStream"},{"type":["null","string"]}]},"cache":{"enum":["default","force-cache","no-cache","no-store","only-if-cached","reload"],"type":"string"},"credentials":{"enum":["include","omit","same-origin"],"type":"string"},"headers":{"anyOf":[{"$ref":"#/definitions/Headers"},{"type":"array","items":{"type":"array","items":{"type":"string"}}},{"$ref":"#/definitions/Record"}]},"integrity":{"type":"string"},"keepalive":{"type":"boolean"},"method":{"type":"string"},"mode":{"enum":["cors","navigate","no-cors","same-origin"],"type":"string"},"redirect":{"enum":["error","follow","manual"],"type":"string"},"referrer":{"type":"string"},"referrerPolicy":{"enum":["","no-referrer","no-referrer-when-downgrade","origin","origin-when-cross-origin","same-origin","strict-origin","strict-origin-when-cross-origin","unsafe-url"],"type":"string"},"signal":{"anyOf":[{"$ref":"#/definitions/AbortSignal"},{"type":"null"}]},"window":{}},"additionalProperties":false},"ArrayBuffer":{"type":"object","properties":{"byteLength":{"type":"number"},"__@toStringTag":{"type":"string"}},"additionalProperties":false,"required":["__@toStringTag","byteLength"]},"ArrayBufferView":{"type":"object","properties":{"buffer":{"anyOf":[{"$ref":"#/definitions/ArrayBuffer"},{"$ref":"#/definitions/SharedArrayBuffer"}]},"byteLength":{"type":"number"},"byteOffset":{"type":"number"}},"additionalProperties":false,"required":["buffer","byteLength","byteOffset"]},"SharedArrayBuffer":{"type":"object","properties":{"byteLength":{"type":"number"},"__@species":{"$ref":"#/definitions/SharedArrayBuffer"},"__@toStringTag":{"type":"string","enum":["SharedArrayBuffer"]}},"additionalProperties":false,"required":["__@species","__@toStringTag","byteLength"]},"Blob":{"type":"object","properties":{"size":{"type":"number"},"type":{"type":"string"}},"additionalProperties":false,"required":["size","type"]},"FormData":{"type":"object","additionalProperties":false},"URLSearchParams":{"type":"object","additionalProperties":false},"ReadableStream":{"type":"object","properties":{"locked":{"type":"boolean"}},"additionalProperties":false,"required":["locked"]},"Headers":{"type":"object","additionalProperties":false},"Record":{"type":"object","additionalProperties":false},"AbortSignal":{"type":"object","properties":{"aborted":{"type":"boolean"},"onabort":{"anyOf":[{"type":"object","additionalProperties":false},{"type":"null"}]}},"additionalProperties":false,"required":["aborted","onabort"]},"RouteMatchCallback":{"description":"The \"match\" callback is used to determine if a `Route` should apply for a\nparticular URL and request. When matching occurs in response to a fetch\nevent from the client, the `event` object is also supplied. However, since\nthe match callback can be invoked outside of a fetch event, matching logic\nshould not assume the `event` object will always be available.\nIf the match callback returns a truthy value, the matching route's\n`RouteHandlerCallback` will be invoked immediately. If the value returned\nis a non-empty array or object, that value will be set on the handler's\n`options.params` argument.","type":"object","additionalProperties":false}},"$schema":"http://json-schema.org/draft-07/schema#"} diff --git a/packages/workbox-build/src/schema/GetManifestOptions.json b/packages/workbox-build/src/schema/GetManifestOptions.json index afdc0f1d1..6fa6d0164 100644 --- a/packages/workbox-build/src/schema/GetManifestOptions.json +++ b/packages/workbox-build/src/schema/GetManifestOptions.json @@ -1 +1 @@ -{"additionalProperties":false,"type":"object","properties":{"additionalManifestEntries":{"type":"array","items":{"anyOf":[{"$ref":"#/definitions/ManifestEntry"},{"type":"string"}]}},"dontCacheBustURLsMatching":{"$ref":"#/definitions/RegExp"},"manifestTransforms":{"type":"array","items":{"typeof":"function"}},"maximumFileSizeToCacheInBytes":{"default":2097152,"type":"number"},"modifyURLPrefix":{},"globDirectory":{"type":"string"},"globFollow":{"default":true,"type":"boolean"},"globIgnores":{"default":["**/node_modules/**/*"],"type":"array","items":{"type":"string"}},"globPatterns":{"default":["**/*.{js,css,html}"],"type":"array","items":{"type":"string"}},"globStrict":{"default":true,"type":"boolean"},"templatedURLs":{}},"required":["globDirectory"],"definitions":{"ManifestEntry":{"type":"object","properties":{"integrity":{"type":"string"},"revision":{"type":["null","string"]},"url":{"type":"string"}},"additionalProperties":false,"required":["revision","url"]},"RegExp":{"type":"object","properties":{"source":{"type":"string"},"global":{"type":"boolean"},"ignoreCase":{"type":"boolean"},"multiline":{"type":"boolean"},"lastIndex":{"type":"number"},"flags":{"type":"string"},"sticky":{"type":"boolean"},"unicode":{"type":"boolean"},"dotAll":{"type":"boolean"}},"additionalProperties":false,"required":["dotAll","flags","global","ignoreCase","lastIndex","multiline","source","sticky","unicode"]},"GoogleAnalyticsInitializeOptions":{"type":"object","properties":{"cacheName":{"type":"string"},"parameterOverrides":{"typeof":"function"},"hitFilter":{"typeof":"function"}},"additionalProperties":false},"RuntimeCaching":{"type":"object","properties":{"handler":{"anyOf":[{"$ref":"#/definitions/RouteHandlerCallback"},{"$ref":"#/definitions/RouteHandlerObject"},{"enum":["CacheFirst","CacheOnly","NetworkFirst","NetworkOnly","StaleWhileRevalidate"],"type":"string"}]},"method":{"enum":["DELETE","GET","HEAD","PATCH","POST","PUT"],"type":"string"},"options":{"typeof":"function"},"urlPattern":{"anyOf":[{"$ref":"#/definitions/RegExp"},{"$ref":"#/definitions/RouteMatchCallback"},{"type":"string"}]}},"additionalProperties":false,"required":["handler","urlPattern"]},"RouteHandlerCallback":{"description":"The \"handler\" callback is invoked whenever a `Router` matches a URL/Request\nto a `Route` via its `RouteMatchCallback`. This handler callback should\nreturn a `Promise` that resolves with a `Response`.\n\nIf a non-empty array or object is returned by the `RouteMatchCallback` it\nwill be passed in as this handler's `options.params` argument.","type":"object","additionalProperties":false},"RouteHandlerObject":{"description":"An object with a `handle` method of type `RouteHandlerCallback`.\n\nA `Route` object can be created with either an `RouteHandlerCallback`\nfunction or this `RouteHandler` object. The benefit of the `RouteHandler`\nis it can be extended (as is done by the `workbox-strategies` package).","type":"object","properties":{"handle":{"$ref":"#/definitions/RouteHandlerCallback"}},"additionalProperties":false,"required":["handle"]},"RouteMatchCallback":{"description":"The \"match\" callback is used to determine if a `Route` should apply for a\nparticular URL and request. When matching occurs in response to a fetch\nevent from the client, the `event` object is also supplied. However, since\nthe match callback can be invoked outside of a fetch event, matching logic\nshould not assume the `event` object will always be available.\nIf the match callback returns a truthy value, the matching route's\n`RouteHandlerCallback` will be invoked immediately. If the value returned\nis a non-empty array or object, that value will be set on the handler's\n`options.params` argument.","type":"object","additionalProperties":false}},"$schema":"http://json-schema.org/draft-07/schema#"} +{"additionalProperties":false,"type":"object","properties":{"additionalManifestEntries":{"type":"array","items":{"anyOf":[{"$ref":"#/definitions/ManifestEntry"},{"type":"string"}]}},"dontCacheBustURLsMatching":{"$ref":"#/definitions/RegExp"},"manifestTransforms":{"type":"array","items":{"typeof":"function"}},"maximumFileSizeToCacheInBytes":{"default":2097152,"type":"number"},"modifyURLPrefix":{"type":"object","additionalProperties":{"type":"string"}},"globDirectory":{"type":"string"},"globFollow":{"default":true,"type":"boolean"},"globIgnores":{"default":["**/node_modules/**/*"],"type":"array","items":{"type":"string"}},"globPatterns":{"default":["**/*.{js,css,html}"],"type":"array","items":{"type":"string"}},"globStrict":{"default":true,"type":"boolean"},"templatedURLs":{"type":"object","additionalProperties":{"anyOf":[{"type":"array","items":{"type":"string"}},{"type":"string"}]}}},"required":["globDirectory"],"definitions":{"ManifestEntry":{"type":"object","properties":{"integrity":{"type":"string"},"revision":{"type":["null","string"]},"url":{"type":"string"}},"additionalProperties":false,"required":["revision","url"]},"RegExp":{"type":"object","properties":{"source":{"type":"string"},"global":{"type":"boolean"},"ignoreCase":{"type":"boolean"},"multiline":{"type":"boolean"},"lastIndex":{"type":"number"},"flags":{"type":"string"},"sticky":{"type":"boolean"},"unicode":{"type":"boolean"},"dotAll":{"type":"boolean"}},"additionalProperties":false,"required":["dotAll","flags","global","ignoreCase","lastIndex","multiline","source","sticky","unicode"]},"GoogleAnalyticsInitializeOptions":{"type":"object","properties":{"cacheName":{"type":"string"},"parameterOverrides":{"type":"object","additionalProperties":{"type":"string"}},"hitFilter":{"type":"object","additionalProperties":false}},"additionalProperties":false},"RuntimeCaching":{"type":"object","properties":{"handler":{"anyOf":[{"$ref":"#/definitions/RouteHandlerCallback"},{"$ref":"#/definitions/RouteHandlerObject"},{"enum":["CacheFirst","CacheOnly","NetworkFirst","NetworkOnly","StaleWhileRevalidate"],"type":"string"}]},"method":{"enum":["DELETE","GET","HEAD","PATCH","POST","PUT"],"type":"string"},"options":{"type":"object","properties":{"backgroundSync":{"type":"object","properties":{"name":{"type":"string"},"options":{"$ref":"#/definitions/QueueOptions"}},"additionalProperties":false,"required":["name"]},"broadcastUpdate":{"type":"object","properties":{"channelName":{"type":"string"},"options":{"$ref":"#/definitions/BroadcastCacheUpdateOptions"}},"additionalProperties":false,"required":["options"]},"cacheableResponse":{"$ref":"#/definitions/CacheableResponseOptions"},"cacheName":{"type":["null","string"]},"expiration":{"$ref":"#/definitions/ExpirationPluginOptions"},"networkTimeoutSeconds":{"type":"number"},"plugins":{"type":"array","items":{"$ref":"#/definitions/WorkboxPlugin"}},"precacheFallback":{"type":"object","properties":{"fallbackURL":{"type":"string"}},"additionalProperties":false,"required":["fallbackURL"]},"fetchOptions":{"$ref":"#/definitions/RequestInit"},"matchOptions":{"$ref":"#/definitions/CacheQueryOptions"}},"additionalProperties":false},"urlPattern":{"anyOf":[{"$ref":"#/definitions/RegExp"},{"$ref":"#/definitions/RouteMatchCallback"},{"type":"string"}]}},"additionalProperties":false,"required":["handler","urlPattern"]},"RouteHandlerCallback":{"description":"The \"handler\" callback is invoked whenever a `Router` matches a URL/Request\nto a `Route` via its `RouteMatchCallback`. This handler callback should\nreturn a `Promise` that resolves with a `Response`.\n\nIf a non-empty array or object is returned by the `RouteMatchCallback` it\nwill be passed in as this handler's `options.params` argument.","type":"object","additionalProperties":false},"RouteHandlerObject":{"description":"An object with a `handle` method of type `RouteHandlerCallback`.\n\nA `Route` object can be created with either an `RouteHandlerCallback`\nfunction or this `RouteHandler` object. The benefit of the `RouteHandler`\nis it can be extended (as is done by the `workbox-strategies` package).","type":"object","properties":{"handle":{"$ref":"#/definitions/RouteHandlerCallback"}},"additionalProperties":false,"required":["handle"]},"QueueOptions":{"type":"object","properties":{"onSync":{"$ref":"#/definitions/OnSyncCallback"},"maxRetentionTime":{"type":"number"}},"additionalProperties":false},"OnSyncCallback":{"type":"object","additionalProperties":false},"BroadcastCacheUpdateOptions":{"type":"object","properties":{"headersToCheck":{"type":"array","items":{"type":"string"}},"generatePayload":{"type":"object","additionalProperties":false}},"additionalProperties":false},"CacheableResponseOptions":{"type":"object","properties":{"statuses":{"type":"array","items":{"type":"number"}},"headers":{"type":"object","additionalProperties":{"type":"string"}}},"additionalProperties":false},"ExpirationPluginOptions":{"type":"object","properties":{"maxEntries":{"type":"number"},"maxAgeSeconds":{"type":"number"},"matchOptions":{"$ref":"#/definitions/CacheQueryOptions"},"purgeOnQuotaError":{"type":"boolean"}},"additionalProperties":false},"CacheQueryOptions":{"type":"object","properties":{"ignoreMethod":{"type":"boolean"},"ignoreSearch":{"type":"boolean"},"ignoreVary":{"type":"boolean"}},"additionalProperties":false},"WorkboxPlugin":{"description":"An object with optional lifecycle callback properties for the fetch and\ncache operations.","type":"object","properties":{"cacheDidUpdate":{"$ref":"#/definitions/CacheDidUpdateCallback"},"cachedResponseWillBeUsed":{"$ref":"#/definitions/CachedResponseWillBeUsedCallback"},"cacheKeyWillBeUsed":{"$ref":"#/definitions/CacheKeyWillBeUsedCallback"},"cacheWillUpdate":{"$ref":"#/definitions/CacheWillUpdateCallback"},"fetchDidFail":{"$ref":"#/definitions/FetchDidFailCallback"},"fetchDidSucceed":{"$ref":"#/definitions/FetchDidSucceedCallback"},"handlerDidComplete":{"$ref":"#/definitions/HandlerDidCompleteCallback"},"handlerDidError":{"$ref":"#/definitions/HandlerDidErrorCallback"},"handlerDidRespond":{"$ref":"#/definitions/HandlerDidRespondCallback"},"handlerWillRespond":{"$ref":"#/definitions/HandlerWillRespondCallback"},"handlerWillStart":{"$ref":"#/definitions/HandlerWillStartCallback"},"requestWillFetch":{"$ref":"#/definitions/RequestWillFetchCallback"}},"additionalProperties":false},"CacheDidUpdateCallback":{"type":"object","additionalProperties":false},"CachedResponseWillBeUsedCallback":{"type":"object","additionalProperties":false},"CacheKeyWillBeUsedCallback":{"type":"object","additionalProperties":false},"CacheWillUpdateCallback":{"type":"object","additionalProperties":false},"FetchDidFailCallback":{"type":"object","additionalProperties":false},"FetchDidSucceedCallback":{"type":"object","additionalProperties":false},"HandlerDidCompleteCallback":{"type":"object","additionalProperties":false},"HandlerDidErrorCallback":{"type":"object","additionalProperties":false},"HandlerDidRespondCallback":{"type":"object","additionalProperties":false},"HandlerWillRespondCallback":{"type":"object","additionalProperties":false},"HandlerWillStartCallback":{"type":"object","additionalProperties":false},"RequestWillFetchCallback":{"type":"object","additionalProperties":false},"RequestInit":{"type":"object","properties":{"body":{"anyOf":[{"$ref":"#/definitions/ArrayBuffer"},{"$ref":"#/definitions/ArrayBufferView"},{"$ref":"#/definitions/Blob"},{"$ref":"#/definitions/FormData"},{"$ref":"#/definitions/URLSearchParams"},{"$ref":"#/definitions/ReadableStream"},{"type":["null","string"]}]},"cache":{"enum":["default","force-cache","no-cache","no-store","only-if-cached","reload"],"type":"string"},"credentials":{"enum":["include","omit","same-origin"],"type":"string"},"headers":{"anyOf":[{"$ref":"#/definitions/Headers"},{"type":"array","items":{"type":"array","items":{"type":"string"}}},{"$ref":"#/definitions/Record"}]},"integrity":{"type":"string"},"keepalive":{"type":"boolean"},"method":{"type":"string"},"mode":{"enum":["cors","navigate","no-cors","same-origin"],"type":"string"},"redirect":{"enum":["error","follow","manual"],"type":"string"},"referrer":{"type":"string"},"referrerPolicy":{"enum":["","no-referrer","no-referrer-when-downgrade","origin","origin-when-cross-origin","same-origin","strict-origin","strict-origin-when-cross-origin","unsafe-url"],"type":"string"},"signal":{"anyOf":[{"$ref":"#/definitions/AbortSignal"},{"type":"null"}]},"window":{}},"additionalProperties":false},"ArrayBuffer":{"type":"object","properties":{"byteLength":{"type":"number"},"__@toStringTag":{"type":"string"}},"additionalProperties":false,"required":["__@toStringTag","byteLength"]},"ArrayBufferView":{"type":"object","properties":{"buffer":{"anyOf":[{"$ref":"#/definitions/ArrayBuffer"},{"$ref":"#/definitions/SharedArrayBuffer"}]},"byteLength":{"type":"number"},"byteOffset":{"type":"number"}},"additionalProperties":false,"required":["buffer","byteLength","byteOffset"]},"SharedArrayBuffer":{"type":"object","properties":{"byteLength":{"type":"number"},"__@species":{"$ref":"#/definitions/SharedArrayBuffer"},"__@toStringTag":{"type":"string","enum":["SharedArrayBuffer"]}},"additionalProperties":false,"required":["__@species","__@toStringTag","byteLength"]},"Blob":{"type":"object","properties":{"size":{"type":"number"},"type":{"type":"string"}},"additionalProperties":false,"required":["size","type"]},"FormData":{"type":"object","additionalProperties":false},"URLSearchParams":{"type":"object","additionalProperties":false},"ReadableStream":{"type":"object","properties":{"locked":{"type":"boolean"}},"additionalProperties":false,"required":["locked"]},"Headers":{"type":"object","additionalProperties":false},"Record":{"type":"object","additionalProperties":false},"AbortSignal":{"type":"object","properties":{"aborted":{"type":"boolean"},"onabort":{"anyOf":[{"type":"object","additionalProperties":false},{"type":"null"}]}},"additionalProperties":false,"required":["aborted","onabort"]},"RouteMatchCallback":{"description":"The \"match\" callback is used to determine if a `Route` should apply for a\nparticular URL and request. When matching occurs in response to a fetch\nevent from the client, the `event` object is also supplied. However, since\nthe match callback can be invoked outside of a fetch event, matching logic\nshould not assume the `event` object will always be available.\nIf the match callback returns a truthy value, the matching route's\n`RouteHandlerCallback` will be invoked immediately. If the value returned\nis a non-empty array or object, that value will be set on the handler's\n`options.params` argument.","type":"object","additionalProperties":false}},"$schema":"http://json-schema.org/draft-07/schema#"} diff --git a/packages/workbox-build/src/schema/InjectManifestOptions.json b/packages/workbox-build/src/schema/InjectManifestOptions.json index 6e6a09d18..474c288df 100644 --- a/packages/workbox-build/src/schema/InjectManifestOptions.json +++ b/packages/workbox-build/src/schema/InjectManifestOptions.json @@ -1 +1 @@ -{"additionalProperties":false,"type":"object","properties":{"additionalManifestEntries":{"type":"array","items":{"anyOf":[{"$ref":"#/definitions/ManifestEntry"},{"type":"string"}]}},"dontCacheBustURLsMatching":{"$ref":"#/definitions/RegExp"},"manifestTransforms":{"type":"array","items":{"typeof":"function"}},"maximumFileSizeToCacheInBytes":{"default":2097152,"type":"number"},"modifyURLPrefix":{},"globDirectory":{"type":"string"},"globFollow":{"default":true,"type":"boolean"},"globIgnores":{"default":["**/node_modules/**/*"],"type":"array","items":{"type":"string"}},"globPatterns":{"default":["**/*.{js,css,html}"],"type":"array","items":{"type":"string"}},"globStrict":{"default":true,"type":"boolean"},"templatedURLs":{},"injectionPoint":{"default":"self.__WB_MANIFEST","type":"string"},"swSrc":{"type":"string"},"swDest":{"type":"string"}},"required":["globDirectory","swDest","swSrc"],"definitions":{"ManifestEntry":{"type":"object","properties":{"integrity":{"type":"string"},"revision":{"type":["null","string"]},"url":{"type":"string"}},"additionalProperties":false,"required":["revision","url"]},"RegExp":{"type":"object","properties":{"source":{"type":"string"},"global":{"type":"boolean"},"ignoreCase":{"type":"boolean"},"multiline":{"type":"boolean"},"lastIndex":{"type":"number"},"flags":{"type":"string"},"sticky":{"type":"boolean"},"unicode":{"type":"boolean"},"dotAll":{"type":"boolean"}},"additionalProperties":false,"required":["dotAll","flags","global","ignoreCase","lastIndex","multiline","source","sticky","unicode"]},"GoogleAnalyticsInitializeOptions":{"type":"object","properties":{"cacheName":{"type":"string"},"parameterOverrides":{"typeof":"function"},"hitFilter":{"typeof":"function"}},"additionalProperties":false},"RuntimeCaching":{"type":"object","properties":{"handler":{"anyOf":[{"$ref":"#/definitions/RouteHandlerCallback"},{"$ref":"#/definitions/RouteHandlerObject"},{"enum":["CacheFirst","CacheOnly","NetworkFirst","NetworkOnly","StaleWhileRevalidate"],"type":"string"}]},"method":{"enum":["DELETE","GET","HEAD","PATCH","POST","PUT"],"type":"string"},"options":{"typeof":"function"},"urlPattern":{"anyOf":[{"$ref":"#/definitions/RegExp"},{"$ref":"#/definitions/RouteMatchCallback"},{"type":"string"}]}},"additionalProperties":false,"required":["handler","urlPattern"]},"RouteHandlerCallback":{"description":"The \"handler\" callback is invoked whenever a `Router` matches a URL/Request\nto a `Route` via its `RouteMatchCallback`. This handler callback should\nreturn a `Promise` that resolves with a `Response`.\n\nIf a non-empty array or object is returned by the `RouteMatchCallback` it\nwill be passed in as this handler's `options.params` argument.","type":"object","additionalProperties":false},"RouteHandlerObject":{"description":"An object with a `handle` method of type `RouteHandlerCallback`.\n\nA `Route` object can be created with either an `RouteHandlerCallback`\nfunction or this `RouteHandler` object. The benefit of the `RouteHandler`\nis it can be extended (as is done by the `workbox-strategies` package).","type":"object","properties":{"handle":{"$ref":"#/definitions/RouteHandlerCallback"}},"additionalProperties":false,"required":["handle"]},"RouteMatchCallback":{"description":"The \"match\" callback is used to determine if a `Route` should apply for a\nparticular URL and request. When matching occurs in response to a fetch\nevent from the client, the `event` object is also supplied. However, since\nthe match callback can be invoked outside of a fetch event, matching logic\nshould not assume the `event` object will always be available.\nIf the match callback returns a truthy value, the matching route's\n`RouteHandlerCallback` will be invoked immediately. If the value returned\nis a non-empty array or object, that value will be set on the handler's\n`options.params` argument.","type":"object","additionalProperties":false}},"$schema":"http://json-schema.org/draft-07/schema#"} +{"additionalProperties":false,"type":"object","properties":{"additionalManifestEntries":{"type":"array","items":{"anyOf":[{"$ref":"#/definitions/ManifestEntry"},{"type":"string"}]}},"dontCacheBustURLsMatching":{"$ref":"#/definitions/RegExp"},"manifestTransforms":{"type":"array","items":{"typeof":"function"}},"maximumFileSizeToCacheInBytes":{"default":2097152,"type":"number"},"modifyURLPrefix":{"type":"object","additionalProperties":{"type":"string"}},"globDirectory":{"type":"string"},"globFollow":{"default":true,"type":"boolean"},"globIgnores":{"default":["**/node_modules/**/*"],"type":"array","items":{"type":"string"}},"globPatterns":{"default":["**/*.{js,css,html}"],"type":"array","items":{"type":"string"}},"globStrict":{"default":true,"type":"boolean"},"templatedURLs":{"type":"object","additionalProperties":{"anyOf":[{"type":"array","items":{"type":"string"}},{"type":"string"}]}},"injectionPoint":{"default":"self.__WB_MANIFEST","type":"string"},"swSrc":{"type":"string"},"swDest":{"type":"string"}},"required":["globDirectory","swDest","swSrc"],"definitions":{"ManifestEntry":{"type":"object","properties":{"integrity":{"type":"string"},"revision":{"type":["null","string"]},"url":{"type":"string"}},"additionalProperties":false,"required":["revision","url"]},"RegExp":{"type":"object","properties":{"source":{"type":"string"},"global":{"type":"boolean"},"ignoreCase":{"type":"boolean"},"multiline":{"type":"boolean"},"lastIndex":{"type":"number"},"flags":{"type":"string"},"sticky":{"type":"boolean"},"unicode":{"type":"boolean"},"dotAll":{"type":"boolean"}},"additionalProperties":false,"required":["dotAll","flags","global","ignoreCase","lastIndex","multiline","source","sticky","unicode"]},"GoogleAnalyticsInitializeOptions":{"type":"object","properties":{"cacheName":{"type":"string"},"parameterOverrides":{"type":"object","additionalProperties":{"type":"string"}},"hitFilter":{"type":"object","additionalProperties":false}},"additionalProperties":false},"RuntimeCaching":{"type":"object","properties":{"handler":{"anyOf":[{"$ref":"#/definitions/RouteHandlerCallback"},{"$ref":"#/definitions/RouteHandlerObject"},{"enum":["CacheFirst","CacheOnly","NetworkFirst","NetworkOnly","StaleWhileRevalidate"],"type":"string"}]},"method":{"enum":["DELETE","GET","HEAD","PATCH","POST","PUT"],"type":"string"},"options":{"type":"object","properties":{"backgroundSync":{"type":"object","properties":{"name":{"type":"string"},"options":{"$ref":"#/definitions/QueueOptions"}},"additionalProperties":false,"required":["name"]},"broadcastUpdate":{"type":"object","properties":{"channelName":{"type":"string"},"options":{"$ref":"#/definitions/BroadcastCacheUpdateOptions"}},"additionalProperties":false,"required":["options"]},"cacheableResponse":{"$ref":"#/definitions/CacheableResponseOptions"},"cacheName":{"type":["null","string"]},"expiration":{"$ref":"#/definitions/ExpirationPluginOptions"},"networkTimeoutSeconds":{"type":"number"},"plugins":{"type":"array","items":{"$ref":"#/definitions/WorkboxPlugin"}},"precacheFallback":{"type":"object","properties":{"fallbackURL":{"type":"string"}},"additionalProperties":false,"required":["fallbackURL"]},"fetchOptions":{"$ref":"#/definitions/RequestInit"},"matchOptions":{"$ref":"#/definitions/CacheQueryOptions"}},"additionalProperties":false},"urlPattern":{"anyOf":[{"$ref":"#/definitions/RegExp"},{"$ref":"#/definitions/RouteMatchCallback"},{"type":"string"}]}},"additionalProperties":false,"required":["handler","urlPattern"]},"RouteHandlerCallback":{"description":"The \"handler\" callback is invoked whenever a `Router` matches a URL/Request\nto a `Route` via its `RouteMatchCallback`. This handler callback should\nreturn a `Promise` that resolves with a `Response`.\n\nIf a non-empty array or object is returned by the `RouteMatchCallback` it\nwill be passed in as this handler's `options.params` argument.","type":"object","additionalProperties":false},"RouteHandlerObject":{"description":"An object with a `handle` method of type `RouteHandlerCallback`.\n\nA `Route` object can be created with either an `RouteHandlerCallback`\nfunction or this `RouteHandler` object. The benefit of the `RouteHandler`\nis it can be extended (as is done by the `workbox-strategies` package).","type":"object","properties":{"handle":{"$ref":"#/definitions/RouteHandlerCallback"}},"additionalProperties":false,"required":["handle"]},"QueueOptions":{"type":"object","properties":{"onSync":{"$ref":"#/definitions/OnSyncCallback"},"maxRetentionTime":{"type":"number"}},"additionalProperties":false},"OnSyncCallback":{"type":"object","additionalProperties":false},"BroadcastCacheUpdateOptions":{"type":"object","properties":{"headersToCheck":{"type":"array","items":{"type":"string"}},"generatePayload":{"type":"object","additionalProperties":false}},"additionalProperties":false},"CacheableResponseOptions":{"type":"object","properties":{"statuses":{"type":"array","items":{"type":"number"}},"headers":{"type":"object","additionalProperties":{"type":"string"}}},"additionalProperties":false},"ExpirationPluginOptions":{"type":"object","properties":{"maxEntries":{"type":"number"},"maxAgeSeconds":{"type":"number"},"matchOptions":{"$ref":"#/definitions/CacheQueryOptions"},"purgeOnQuotaError":{"type":"boolean"}},"additionalProperties":false},"CacheQueryOptions":{"type":"object","properties":{"ignoreMethod":{"type":"boolean"},"ignoreSearch":{"type":"boolean"},"ignoreVary":{"type":"boolean"}},"additionalProperties":false},"WorkboxPlugin":{"description":"An object with optional lifecycle callback properties for the fetch and\ncache operations.","type":"object","properties":{"cacheDidUpdate":{"$ref":"#/definitions/CacheDidUpdateCallback"},"cachedResponseWillBeUsed":{"$ref":"#/definitions/CachedResponseWillBeUsedCallback"},"cacheKeyWillBeUsed":{"$ref":"#/definitions/CacheKeyWillBeUsedCallback"},"cacheWillUpdate":{"$ref":"#/definitions/CacheWillUpdateCallback"},"fetchDidFail":{"$ref":"#/definitions/FetchDidFailCallback"},"fetchDidSucceed":{"$ref":"#/definitions/FetchDidSucceedCallback"},"handlerDidComplete":{"$ref":"#/definitions/HandlerDidCompleteCallback"},"handlerDidError":{"$ref":"#/definitions/HandlerDidErrorCallback"},"handlerDidRespond":{"$ref":"#/definitions/HandlerDidRespondCallback"},"handlerWillRespond":{"$ref":"#/definitions/HandlerWillRespondCallback"},"handlerWillStart":{"$ref":"#/definitions/HandlerWillStartCallback"},"requestWillFetch":{"$ref":"#/definitions/RequestWillFetchCallback"}},"additionalProperties":false},"CacheDidUpdateCallback":{"type":"object","additionalProperties":false},"CachedResponseWillBeUsedCallback":{"type":"object","additionalProperties":false},"CacheKeyWillBeUsedCallback":{"type":"object","additionalProperties":false},"CacheWillUpdateCallback":{"type":"object","additionalProperties":false},"FetchDidFailCallback":{"type":"object","additionalProperties":false},"FetchDidSucceedCallback":{"type":"object","additionalProperties":false},"HandlerDidCompleteCallback":{"type":"object","additionalProperties":false},"HandlerDidErrorCallback":{"type":"object","additionalProperties":false},"HandlerDidRespondCallback":{"type":"object","additionalProperties":false},"HandlerWillRespondCallback":{"type":"object","additionalProperties":false},"HandlerWillStartCallback":{"type":"object","additionalProperties":false},"RequestWillFetchCallback":{"type":"object","additionalProperties":false},"RequestInit":{"type":"object","properties":{"body":{"anyOf":[{"$ref":"#/definitions/ArrayBuffer"},{"$ref":"#/definitions/ArrayBufferView"},{"$ref":"#/definitions/Blob"},{"$ref":"#/definitions/FormData"},{"$ref":"#/definitions/URLSearchParams"},{"$ref":"#/definitions/ReadableStream"},{"type":["null","string"]}]},"cache":{"enum":["default","force-cache","no-cache","no-store","only-if-cached","reload"],"type":"string"},"credentials":{"enum":["include","omit","same-origin"],"type":"string"},"headers":{"anyOf":[{"$ref":"#/definitions/Headers"},{"type":"array","items":{"type":"array","items":{"type":"string"}}},{"$ref":"#/definitions/Record"}]},"integrity":{"type":"string"},"keepalive":{"type":"boolean"},"method":{"type":"string"},"mode":{"enum":["cors","navigate","no-cors","same-origin"],"type":"string"},"redirect":{"enum":["error","follow","manual"],"type":"string"},"referrer":{"type":"string"},"referrerPolicy":{"enum":["","no-referrer","no-referrer-when-downgrade","origin","origin-when-cross-origin","same-origin","strict-origin","strict-origin-when-cross-origin","unsafe-url"],"type":"string"},"signal":{"anyOf":[{"$ref":"#/definitions/AbortSignal"},{"type":"null"}]},"window":{}},"additionalProperties":false},"ArrayBuffer":{"type":"object","properties":{"byteLength":{"type":"number"},"__@toStringTag":{"type":"string"}},"additionalProperties":false,"required":["__@toStringTag","byteLength"]},"ArrayBufferView":{"type":"object","properties":{"buffer":{"anyOf":[{"$ref":"#/definitions/ArrayBuffer"},{"$ref":"#/definitions/SharedArrayBuffer"}]},"byteLength":{"type":"number"},"byteOffset":{"type":"number"}},"additionalProperties":false,"required":["buffer","byteLength","byteOffset"]},"SharedArrayBuffer":{"type":"object","properties":{"byteLength":{"type":"number"},"__@species":{"$ref":"#/definitions/SharedArrayBuffer"},"__@toStringTag":{"type":"string","enum":["SharedArrayBuffer"]}},"additionalProperties":false,"required":["__@species","__@toStringTag","byteLength"]},"Blob":{"type":"object","properties":{"size":{"type":"number"},"type":{"type":"string"}},"additionalProperties":false,"required":["size","type"]},"FormData":{"type":"object","additionalProperties":false},"URLSearchParams":{"type":"object","additionalProperties":false},"ReadableStream":{"type":"object","properties":{"locked":{"type":"boolean"}},"additionalProperties":false,"required":["locked"]},"Headers":{"type":"object","additionalProperties":false},"Record":{"type":"object","additionalProperties":false},"AbortSignal":{"type":"object","properties":{"aborted":{"type":"boolean"},"onabort":{"anyOf":[{"type":"object","additionalProperties":false},{"type":"null"}]}},"additionalProperties":false,"required":["aborted","onabort"]},"RouteMatchCallback":{"description":"The \"match\" callback is used to determine if a `Route` should apply for a\nparticular URL and request. When matching occurs in response to a fetch\nevent from the client, the `event` object is also supplied. However, since\nthe match callback can be invoked outside of a fetch event, matching logic\nshould not assume the `event` object will always be available.\nIf the match callback returns a truthy value, the matching route's\n`RouteHandlerCallback` will be invoked immediately. If the value returned\nis a non-empty array or object, that value will be set on the handler's\n`options.params` argument.","type":"object","additionalProperties":false}},"$schema":"http://json-schema.org/draft-07/schema#"} diff --git a/packages/workbox-build/src/schema/WebpackGenerateSWOptions.json b/packages/workbox-build/src/schema/WebpackGenerateSWOptions.json index abb407008..4027e2433 100644 --- a/packages/workbox-build/src/schema/WebpackGenerateSWOptions.json +++ b/packages/workbox-build/src/schema/WebpackGenerateSWOptions.json @@ -1 +1 @@ -{"additionalProperties":false,"type":"object","properties":{"additionalManifestEntries":{"type":"array","items":{"anyOf":[{"$ref":"#/definitions/ManifestEntry"},{"type":"string"}]}},"dontCacheBustURLsMatching":{"$ref":"#/definitions/RegExp"},"manifestTransforms":{"type":"array","items":{"typeof":"function"}},"maximumFileSizeToCacheInBytes":{"default":2097152,"type":"number"},"modifyURLPrefix":{},"chunks":{"type":"array","items":{"type":"string"}},"exclude":{"type":"array","items":{}},"excludeChunks":{"type":"array","items":{"type":"string"}},"include":{"type":"array","items":{}},"mode":{"default":"production","type":["null","string"]},"babelPresetEnvTargets":{"default":["chrome >= 56"],"type":"array","items":{"type":"string"}},"cacheId":{"type":["null","string"]},"cleanupOutdatedCaches":{"default":false,"type":"boolean"},"clientsClaim":{"default":false,"type":"boolean"},"directoryIndex":{"type":["null","string"]},"disableDevLogs":{"default":false,"type":"boolean"},"ignoreURLParametersMatching":{"type":"array","items":{"$ref":"#/definitions/RegExp"}},"importScripts":{"type":"array","items":{"type":"string"}},"inlineWorkboxRuntime":{"default":false,"type":"boolean"},"navigateFallback":{"default":null,"type":["null","string"]},"navigateFallbackAllowlist":{"type":"array","items":{"$ref":"#/definitions/RegExp"}},"navigateFallbackDenylist":{"type":"array","items":{"$ref":"#/definitions/RegExp"}},"navigationPreload":{"description":"navigationPreload is only valid when runtimeCaching is configured. However,\nthis can't be expressed via TypeScript, so it's enforced via runtime logic.","default":false,"type":"boolean"},"offlineGoogleAnalytics":{"default":false,"anyOf":[{"$ref":"#/definitions/GoogleAnalyticsInitializeOptions"},{"type":"boolean"}]},"runtimeCaching":{"type":"array","items":{"$ref":"#/definitions/RuntimeCaching"}},"skipWaiting":{"default":false,"type":"boolean"},"sourcemap":{"default":true,"type":"boolean"},"importScriptsViaChunks":{"type":"array","items":{"type":"string"}},"swDest":{"default":"service-worker.js","type":"string"}},"definitions":{"ManifestEntry":{"type":"object","properties":{"integrity":{"type":"string"},"revision":{"type":["null","string"]},"url":{"type":"string"}},"additionalProperties":false,"required":["revision","url"]},"RegExp":{"type":"object","properties":{"source":{"type":"string"},"global":{"type":"boolean"},"ignoreCase":{"type":"boolean"},"multiline":{"type":"boolean"},"lastIndex":{"type":"number"},"flags":{"type":"string"},"sticky":{"type":"boolean"},"unicode":{"type":"boolean"},"dotAll":{"type":"boolean"}},"additionalProperties":false,"required":["dotAll","flags","global","ignoreCase","lastIndex","multiline","source","sticky","unicode"]},"GoogleAnalyticsInitializeOptions":{"type":"object","properties":{"cacheName":{"type":"string"},"parameterOverrides":{"typeof":"function"},"hitFilter":{"typeof":"function"}},"additionalProperties":false},"RuntimeCaching":{"type":"object","properties":{"handler":{"anyOf":[{"$ref":"#/definitions/RouteHandlerCallback"},{"$ref":"#/definitions/RouteHandlerObject"},{"enum":["CacheFirst","CacheOnly","NetworkFirst","NetworkOnly","StaleWhileRevalidate"],"type":"string"}]},"method":{"enum":["DELETE","GET","HEAD","PATCH","POST","PUT"],"type":"string"},"options":{"typeof":"function"},"urlPattern":{"anyOf":[{"$ref":"#/definitions/RegExp"},{"$ref":"#/definitions/RouteMatchCallback"},{"type":"string"}]}},"additionalProperties":false,"required":["handler","urlPattern"]},"RouteHandlerCallback":{"description":"The \"handler\" callback is invoked whenever a `Router` matches a URL/Request\nto a `Route` via its `RouteMatchCallback`. This handler callback should\nreturn a `Promise` that resolves with a `Response`.\n\nIf a non-empty array or object is returned by the `RouteMatchCallback` it\nwill be passed in as this handler's `options.params` argument.","type":"object","additionalProperties":false},"RouteHandlerObject":{"description":"An object with a `handle` method of type `RouteHandlerCallback`.\n\nA `Route` object can be created with either an `RouteHandlerCallback`\nfunction or this `RouteHandler` object. The benefit of the `RouteHandler`\nis it can be extended (as is done by the `workbox-strategies` package).","type":"object","properties":{"handle":{"$ref":"#/definitions/RouteHandlerCallback"}},"additionalProperties":false,"required":["handle"]},"RouteMatchCallback":{"description":"The \"match\" callback is used to determine if a `Route` should apply for a\nparticular URL and request. When matching occurs in response to a fetch\nevent from the client, the `event` object is also supplied. However, since\nthe match callback can be invoked outside of a fetch event, matching logic\nshould not assume the `event` object will always be available.\nIf the match callback returns a truthy value, the matching route's\n`RouteHandlerCallback` will be invoked immediately. If the value returned\nis a non-empty array or object, that value will be set on the handler's\n`options.params` argument.","type":"object","additionalProperties":false}},"$schema":"http://json-schema.org/draft-07/schema#"} +{"additionalProperties":false,"type":"object","properties":{"additionalManifestEntries":{"type":"array","items":{"anyOf":[{"$ref":"#/definitions/ManifestEntry"},{"type":"string"}]}},"dontCacheBustURLsMatching":{"$ref":"#/definitions/RegExp"},"manifestTransforms":{"type":"array","items":{"typeof":"function"}},"maximumFileSizeToCacheInBytes":{"default":2097152,"type":"number"},"modifyURLPrefix":{"type":"object","additionalProperties":{"type":"string"}},"chunks":{"type":"array","items":{"type":"string"}},"exclude":{"type":"array","items":{"anyOf":[{"$ref":"#/definitions/RegExp"},{"type":"string"},{"typeof":"function"}]}},"excludeChunks":{"type":"array","items":{"type":"string"}},"include":{"type":"array","items":{"anyOf":[{"$ref":"#/definitions/RegExp"},{"type":"string"},{"typeof":"function"}]}},"mode":{"default":"production","type":["null","string"]},"babelPresetEnvTargets":{"default":["chrome >= 56"],"type":"array","items":{"type":"string"}},"cacheId":{"type":["null","string"]},"cleanupOutdatedCaches":{"default":false,"type":"boolean"},"clientsClaim":{"default":false,"type":"boolean"},"directoryIndex":{"type":["null","string"]},"disableDevLogs":{"default":false,"type":"boolean"},"ignoreURLParametersMatching":{"type":"array","items":{"$ref":"#/definitions/RegExp"}},"importScripts":{"type":"array","items":{"type":"string"}},"inlineWorkboxRuntime":{"default":false,"type":"boolean"},"navigateFallback":{"default":null,"type":["null","string"]},"navigateFallbackAllowlist":{"type":"array","items":{"$ref":"#/definitions/RegExp"}},"navigateFallbackDenylist":{"type":"array","items":{"$ref":"#/definitions/RegExp"}},"navigationPreload":{"description":"navigationPreload is only valid when runtimeCaching is configured. However,\nthis can't be expressed via TypeScript, so it's enforced via runtime logic.","default":false,"type":"boolean"},"offlineGoogleAnalytics":{"default":false,"anyOf":[{"$ref":"#/definitions/GoogleAnalyticsInitializeOptions"},{"type":"boolean"}]},"runtimeCaching":{"type":"array","items":{"$ref":"#/definitions/RuntimeCaching"}},"skipWaiting":{"default":false,"type":"boolean"},"sourcemap":{"default":true,"type":"boolean"},"importScriptsViaChunks":{"type":"array","items":{"type":"string"}},"swDest":{"default":"service-worker.js","type":"string"}},"definitions":{"ManifestEntry":{"type":"object","properties":{"integrity":{"type":"string"},"revision":{"type":["null","string"]},"url":{"type":"string"}},"additionalProperties":false,"required":["revision","url"]},"RegExp":{"type":"object","properties":{"source":{"type":"string"},"global":{"type":"boolean"},"ignoreCase":{"type":"boolean"},"multiline":{"type":"boolean"},"lastIndex":{"type":"number"},"flags":{"type":"string"},"sticky":{"type":"boolean"},"unicode":{"type":"boolean"},"dotAll":{"type":"boolean"}},"additionalProperties":false,"required":["dotAll","flags","global","ignoreCase","lastIndex","multiline","source","sticky","unicode"]},"GoogleAnalyticsInitializeOptions":{"type":"object","properties":{"cacheName":{"type":"string"},"parameterOverrides":{"type":"object","additionalProperties":{"type":"string"}},"hitFilter":{"type":"object","additionalProperties":false}},"additionalProperties":false},"RuntimeCaching":{"type":"object","properties":{"handler":{"anyOf":[{"$ref":"#/definitions/RouteHandlerCallback"},{"$ref":"#/definitions/RouteHandlerObject"},{"enum":["CacheFirst","CacheOnly","NetworkFirst","NetworkOnly","StaleWhileRevalidate"],"type":"string"}]},"method":{"enum":["DELETE","GET","HEAD","PATCH","POST","PUT"],"type":"string"},"options":{"type":"object","properties":{"backgroundSync":{"type":"object","properties":{"name":{"type":"string"},"options":{"$ref":"#/definitions/QueueOptions"}},"additionalProperties":false,"required":["name"]},"broadcastUpdate":{"type":"object","properties":{"channelName":{"type":"string"},"options":{"$ref":"#/definitions/BroadcastCacheUpdateOptions"}},"additionalProperties":false,"required":["options"]},"cacheableResponse":{"$ref":"#/definitions/CacheableResponseOptions"},"cacheName":{"type":["null","string"]},"expiration":{"$ref":"#/definitions/ExpirationPluginOptions"},"networkTimeoutSeconds":{"type":"number"},"plugins":{"type":"array","items":{"$ref":"#/definitions/WorkboxPlugin"}},"precacheFallback":{"type":"object","properties":{"fallbackURL":{"type":"string"}},"additionalProperties":false,"required":["fallbackURL"]},"fetchOptions":{"$ref":"#/definitions/RequestInit"},"matchOptions":{"$ref":"#/definitions/CacheQueryOptions"}},"additionalProperties":false},"urlPattern":{"anyOf":[{"$ref":"#/definitions/RegExp"},{"$ref":"#/definitions/RouteMatchCallback"},{"type":"string"}]}},"additionalProperties":false,"required":["handler","urlPattern"]},"RouteHandlerCallback":{"description":"The \"handler\" callback is invoked whenever a `Router` matches a URL/Request\nto a `Route` via its `RouteMatchCallback`. This handler callback should\nreturn a `Promise` that resolves with a `Response`.\n\nIf a non-empty array or object is returned by the `RouteMatchCallback` it\nwill be passed in as this handler's `options.params` argument.","type":"object","additionalProperties":false},"RouteHandlerObject":{"description":"An object with a `handle` method of type `RouteHandlerCallback`.\n\nA `Route` object can be created with either an `RouteHandlerCallback`\nfunction or this `RouteHandler` object. The benefit of the `RouteHandler`\nis it can be extended (as is done by the `workbox-strategies` package).","type":"object","properties":{"handle":{"$ref":"#/definitions/RouteHandlerCallback"}},"additionalProperties":false,"required":["handle"]},"QueueOptions":{"type":"object","properties":{"onSync":{"$ref":"#/definitions/OnSyncCallback"},"maxRetentionTime":{"type":"number"}},"additionalProperties":false},"OnSyncCallback":{"type":"object","additionalProperties":false},"BroadcastCacheUpdateOptions":{"type":"object","properties":{"headersToCheck":{"type":"array","items":{"type":"string"}},"generatePayload":{"type":"object","additionalProperties":false}},"additionalProperties":false},"CacheableResponseOptions":{"type":"object","properties":{"statuses":{"type":"array","items":{"type":"number"}},"headers":{"type":"object","additionalProperties":{"type":"string"}}},"additionalProperties":false},"ExpirationPluginOptions":{"type":"object","properties":{"maxEntries":{"type":"number"},"maxAgeSeconds":{"type":"number"},"matchOptions":{"$ref":"#/definitions/CacheQueryOptions"},"purgeOnQuotaError":{"type":"boolean"}},"additionalProperties":false},"CacheQueryOptions":{"type":"object","properties":{"ignoreMethod":{"type":"boolean"},"ignoreSearch":{"type":"boolean"},"ignoreVary":{"type":"boolean"}},"additionalProperties":false},"WorkboxPlugin":{"description":"An object with optional lifecycle callback properties for the fetch and\ncache operations.","type":"object","properties":{"cacheDidUpdate":{"$ref":"#/definitions/CacheDidUpdateCallback"},"cachedResponseWillBeUsed":{"$ref":"#/definitions/CachedResponseWillBeUsedCallback"},"cacheKeyWillBeUsed":{"$ref":"#/definitions/CacheKeyWillBeUsedCallback"},"cacheWillUpdate":{"$ref":"#/definitions/CacheWillUpdateCallback"},"fetchDidFail":{"$ref":"#/definitions/FetchDidFailCallback"},"fetchDidSucceed":{"$ref":"#/definitions/FetchDidSucceedCallback"},"handlerDidComplete":{"$ref":"#/definitions/HandlerDidCompleteCallback"},"handlerDidError":{"$ref":"#/definitions/HandlerDidErrorCallback"},"handlerDidRespond":{"$ref":"#/definitions/HandlerDidRespondCallback"},"handlerWillRespond":{"$ref":"#/definitions/HandlerWillRespondCallback"},"handlerWillStart":{"$ref":"#/definitions/HandlerWillStartCallback"},"requestWillFetch":{"$ref":"#/definitions/RequestWillFetchCallback"}},"additionalProperties":false},"CacheDidUpdateCallback":{"type":"object","additionalProperties":false},"CachedResponseWillBeUsedCallback":{"type":"object","additionalProperties":false},"CacheKeyWillBeUsedCallback":{"type":"object","additionalProperties":false},"CacheWillUpdateCallback":{"type":"object","additionalProperties":false},"FetchDidFailCallback":{"type":"object","additionalProperties":false},"FetchDidSucceedCallback":{"type":"object","additionalProperties":false},"HandlerDidCompleteCallback":{"type":"object","additionalProperties":false},"HandlerDidErrorCallback":{"type":"object","additionalProperties":false},"HandlerDidRespondCallback":{"type":"object","additionalProperties":false},"HandlerWillRespondCallback":{"type":"object","additionalProperties":false},"HandlerWillStartCallback":{"type":"object","additionalProperties":false},"RequestWillFetchCallback":{"type":"object","additionalProperties":false},"RequestInit":{"type":"object","properties":{"body":{"anyOf":[{"$ref":"#/definitions/ArrayBuffer"},{"$ref":"#/definitions/ArrayBufferView"},{"$ref":"#/definitions/Blob"},{"$ref":"#/definitions/FormData"},{"$ref":"#/definitions/URLSearchParams"},{"$ref":"#/definitions/ReadableStream"},{"type":["null","string"]}]},"cache":{"enum":["default","force-cache","no-cache","no-store","only-if-cached","reload"],"type":"string"},"credentials":{"enum":["include","omit","same-origin"],"type":"string"},"headers":{"anyOf":[{"$ref":"#/definitions/Headers"},{"type":"array","items":{"type":"array","items":{"type":"string"}}},{"$ref":"#/definitions/Record"}]},"integrity":{"type":"string"},"keepalive":{"type":"boolean"},"method":{"type":"string"},"mode":{"enum":["cors","navigate","no-cors","same-origin"],"type":"string"},"redirect":{"enum":["error","follow","manual"],"type":"string"},"referrer":{"type":"string"},"referrerPolicy":{"enum":["","no-referrer","no-referrer-when-downgrade","origin","origin-when-cross-origin","same-origin","strict-origin","strict-origin-when-cross-origin","unsafe-url"],"type":"string"},"signal":{"anyOf":[{"$ref":"#/definitions/AbortSignal"},{"type":"null"}]},"window":{}},"additionalProperties":false},"ArrayBuffer":{"type":"object","properties":{"byteLength":{"type":"number"},"__@toStringTag":{"type":"string"}},"additionalProperties":false,"required":["__@toStringTag","byteLength"]},"ArrayBufferView":{"type":"object","properties":{"buffer":{"anyOf":[{"$ref":"#/definitions/ArrayBuffer"},{"$ref":"#/definitions/SharedArrayBuffer"}]},"byteLength":{"type":"number"},"byteOffset":{"type":"number"}},"additionalProperties":false,"required":["buffer","byteLength","byteOffset"]},"SharedArrayBuffer":{"type":"object","properties":{"byteLength":{"type":"number"},"__@species":{"$ref":"#/definitions/SharedArrayBuffer"},"__@toStringTag":{"type":"string","enum":["SharedArrayBuffer"]}},"additionalProperties":false,"required":["__@species","__@toStringTag","byteLength"]},"Blob":{"type":"object","properties":{"size":{"type":"number"},"type":{"type":"string"}},"additionalProperties":false,"required":["size","type"]},"FormData":{"type":"object","additionalProperties":false},"URLSearchParams":{"type":"object","additionalProperties":false},"ReadableStream":{"type":"object","properties":{"locked":{"type":"boolean"}},"additionalProperties":false,"required":["locked"]},"Headers":{"type":"object","additionalProperties":false},"Record":{"type":"object","additionalProperties":false},"AbortSignal":{"type":"object","properties":{"aborted":{"type":"boolean"},"onabort":{"anyOf":[{"type":"object","additionalProperties":false},{"type":"null"}]}},"additionalProperties":false,"required":["aborted","onabort"]},"RouteMatchCallback":{"description":"The \"match\" callback is used to determine if a `Route` should apply for a\nparticular URL and request. When matching occurs in response to a fetch\nevent from the client, the `event` object is also supplied. However, since\nthe match callback can be invoked outside of a fetch event, matching logic\nshould not assume the `event` object will always be available.\nIf the match callback returns a truthy value, the matching route's\n`RouteHandlerCallback` will be invoked immediately. If the value returned\nis a non-empty array or object, that value will be set on the handler's\n`options.params` argument.","type":"object","additionalProperties":false}},"$schema":"http://json-schema.org/draft-07/schema#"} diff --git a/packages/workbox-build/src/schema/WebpackInjectManifestOptions.json b/packages/workbox-build/src/schema/WebpackInjectManifestOptions.json index 20e6cd889..769a58517 100644 --- a/packages/workbox-build/src/schema/WebpackInjectManifestOptions.json +++ b/packages/workbox-build/src/schema/WebpackInjectManifestOptions.json @@ -1 +1 @@ -{"additionalProperties":false,"type":"object","properties":{"additionalManifestEntries":{"type":"array","items":{"anyOf":[{"$ref":"#/definitions/ManifestEntry"},{"type":"string"}]}},"dontCacheBustURLsMatching":{"$ref":"#/definitions/RegExp"},"manifestTransforms":{"type":"array","items":{"typeof":"function"}},"maximumFileSizeToCacheInBytes":{"default":2097152,"type":"number"},"modifyURLPrefix":{},"chunks":{"type":"array","items":{"type":"string"}},"exclude":{"type":"array","items":{}},"excludeChunks":{"type":"array","items":{"type":"string"}},"include":{"type":"array","items":{}},"mode":{"type":["null","string"]},"injectionPoint":{"default":"self.__WB_MANIFEST","type":"string"},"swSrc":{"type":"string"},"compileSrc":{"default":true,"type":"boolean"},"swDest":{"type":"string"},"webpackCompilationPlugins":{"type":"array","items":{}}},"required":["swSrc"],"definitions":{"ManifestEntry":{"type":"object","properties":{"integrity":{"type":"string"},"revision":{"type":["null","string"]},"url":{"type":"string"}},"additionalProperties":false,"required":["revision","url"]},"RegExp":{"type":"object","properties":{"source":{"type":"string"},"global":{"type":"boolean"},"ignoreCase":{"type":"boolean"},"multiline":{"type":"boolean"},"lastIndex":{"type":"number"},"flags":{"type":"string"},"sticky":{"type":"boolean"},"unicode":{"type":"boolean"},"dotAll":{"type":"boolean"}},"additionalProperties":false,"required":["dotAll","flags","global","ignoreCase","lastIndex","multiline","source","sticky","unicode"]},"GoogleAnalyticsInitializeOptions":{"type":"object","properties":{"cacheName":{"type":"string"},"parameterOverrides":{"typeof":"function"},"hitFilter":{"typeof":"function"}},"additionalProperties":false},"RuntimeCaching":{"type":"object","properties":{"handler":{"anyOf":[{"$ref":"#/definitions/RouteHandlerCallback"},{"$ref":"#/definitions/RouteHandlerObject"},{"enum":["CacheFirst","CacheOnly","NetworkFirst","NetworkOnly","StaleWhileRevalidate"],"type":"string"}]},"method":{"enum":["DELETE","GET","HEAD","PATCH","POST","PUT"],"type":"string"},"options":{"typeof":"function"},"urlPattern":{"anyOf":[{"$ref":"#/definitions/RegExp"},{"$ref":"#/definitions/RouteMatchCallback"},{"type":"string"}]}},"additionalProperties":false,"required":["handler","urlPattern"]},"RouteHandlerCallback":{"description":"The \"handler\" callback is invoked whenever a `Router` matches a URL/Request\nto a `Route` via its `RouteMatchCallback`. This handler callback should\nreturn a `Promise` that resolves with a `Response`.\n\nIf a non-empty array or object is returned by the `RouteMatchCallback` it\nwill be passed in as this handler's `options.params` argument.","type":"object","additionalProperties":false},"RouteHandlerObject":{"description":"An object with a `handle` method of type `RouteHandlerCallback`.\n\nA `Route` object can be created with either an `RouteHandlerCallback`\nfunction or this `RouteHandler` object. The benefit of the `RouteHandler`\nis it can be extended (as is done by the `workbox-strategies` package).","type":"object","properties":{"handle":{"$ref":"#/definitions/RouteHandlerCallback"}},"additionalProperties":false,"required":["handle"]},"RouteMatchCallback":{"description":"The \"match\" callback is used to determine if a `Route` should apply for a\nparticular URL and request. When matching occurs in response to a fetch\nevent from the client, the `event` object is also supplied. However, since\nthe match callback can be invoked outside of a fetch event, matching logic\nshould not assume the `event` object will always be available.\nIf the match callback returns a truthy value, the matching route's\n`RouteHandlerCallback` will be invoked immediately. If the value returned\nis a non-empty array or object, that value will be set on the handler's\n`options.params` argument.","type":"object","additionalProperties":false}},"$schema":"http://json-schema.org/draft-07/schema#"} +{"additionalProperties":false,"type":"object","properties":{"additionalManifestEntries":{"type":"array","items":{"anyOf":[{"$ref":"#/definitions/ManifestEntry"},{"type":"string"}]}},"dontCacheBustURLsMatching":{"$ref":"#/definitions/RegExp"},"manifestTransforms":{"type":"array","items":{"typeof":"function"}},"maximumFileSizeToCacheInBytes":{"default":2097152,"type":"number"},"modifyURLPrefix":{"type":"object","additionalProperties":{"type":"string"}},"chunks":{"type":"array","items":{"type":"string"}},"exclude":{"type":"array","items":{"anyOf":[{"$ref":"#/definitions/RegExp"},{"type":"string"},{"typeof":"function"}]}},"excludeChunks":{"type":"array","items":{"type":"string"}},"include":{"type":"array","items":{"anyOf":[{"$ref":"#/definitions/RegExp"},{"type":"string"},{"typeof":"function"}]}},"mode":{"type":["null","string"]},"injectionPoint":{"default":"self.__WB_MANIFEST","type":"string"},"swSrc":{"type":"string"},"compileSrc":{"default":true,"type":"boolean"},"swDest":{"type":"string"},"webpackCompilationPlugins":{"type":"array","items":{}}},"required":["swSrc"],"definitions":{"ManifestEntry":{"type":"object","properties":{"integrity":{"type":"string"},"revision":{"type":["null","string"]},"url":{"type":"string"}},"additionalProperties":false,"required":["revision","url"]},"RegExp":{"type":"object","properties":{"source":{"type":"string"},"global":{"type":"boolean"},"ignoreCase":{"type":"boolean"},"multiline":{"type":"boolean"},"lastIndex":{"type":"number"},"flags":{"type":"string"},"sticky":{"type":"boolean"},"unicode":{"type":"boolean"},"dotAll":{"type":"boolean"}},"additionalProperties":false,"required":["dotAll","flags","global","ignoreCase","lastIndex","multiline","source","sticky","unicode"]},"GoogleAnalyticsInitializeOptions":{"type":"object","properties":{"cacheName":{"type":"string"},"parameterOverrides":{"type":"object","additionalProperties":{"type":"string"}},"hitFilter":{"type":"object","additionalProperties":false}},"additionalProperties":false},"RuntimeCaching":{"type":"object","properties":{"handler":{"anyOf":[{"$ref":"#/definitions/RouteHandlerCallback"},{"$ref":"#/definitions/RouteHandlerObject"},{"enum":["CacheFirst","CacheOnly","NetworkFirst","NetworkOnly","StaleWhileRevalidate"],"type":"string"}]},"method":{"enum":["DELETE","GET","HEAD","PATCH","POST","PUT"],"type":"string"},"options":{"type":"object","properties":{"backgroundSync":{"type":"object","properties":{"name":{"type":"string"},"options":{"$ref":"#/definitions/QueueOptions"}},"additionalProperties":false,"required":["name"]},"broadcastUpdate":{"type":"object","properties":{"channelName":{"type":"string"},"options":{"$ref":"#/definitions/BroadcastCacheUpdateOptions"}},"additionalProperties":false,"required":["options"]},"cacheableResponse":{"$ref":"#/definitions/CacheableResponseOptions"},"cacheName":{"type":["null","string"]},"expiration":{"$ref":"#/definitions/ExpirationPluginOptions"},"networkTimeoutSeconds":{"type":"number"},"plugins":{"type":"array","items":{"$ref":"#/definitions/WorkboxPlugin"}},"precacheFallback":{"type":"object","properties":{"fallbackURL":{"type":"string"}},"additionalProperties":false,"required":["fallbackURL"]},"fetchOptions":{"$ref":"#/definitions/RequestInit"},"matchOptions":{"$ref":"#/definitions/CacheQueryOptions"}},"additionalProperties":false},"urlPattern":{"anyOf":[{"$ref":"#/definitions/RegExp"},{"$ref":"#/definitions/RouteMatchCallback"},{"type":"string"}]}},"additionalProperties":false,"required":["handler","urlPattern"]},"RouteHandlerCallback":{"description":"The \"handler\" callback is invoked whenever a `Router` matches a URL/Request\nto a `Route` via its `RouteMatchCallback`. This handler callback should\nreturn a `Promise` that resolves with a `Response`.\n\nIf a non-empty array or object is returned by the `RouteMatchCallback` it\nwill be passed in as this handler's `options.params` argument.","type":"object","additionalProperties":false},"RouteHandlerObject":{"description":"An object with a `handle` method of type `RouteHandlerCallback`.\n\nA `Route` object can be created with either an `RouteHandlerCallback`\nfunction or this `RouteHandler` object. The benefit of the `RouteHandler`\nis it can be extended (as is done by the `workbox-strategies` package).","type":"object","properties":{"handle":{"$ref":"#/definitions/RouteHandlerCallback"}},"additionalProperties":false,"required":["handle"]},"QueueOptions":{"type":"object","properties":{"onSync":{"$ref":"#/definitions/OnSyncCallback"},"maxRetentionTime":{"type":"number"}},"additionalProperties":false},"OnSyncCallback":{"type":"object","additionalProperties":false},"BroadcastCacheUpdateOptions":{"type":"object","properties":{"headersToCheck":{"type":"array","items":{"type":"string"}},"generatePayload":{"type":"object","additionalProperties":false}},"additionalProperties":false},"CacheableResponseOptions":{"type":"object","properties":{"statuses":{"type":"array","items":{"type":"number"}},"headers":{"type":"object","additionalProperties":{"type":"string"}}},"additionalProperties":false},"ExpirationPluginOptions":{"type":"object","properties":{"maxEntries":{"type":"number"},"maxAgeSeconds":{"type":"number"},"matchOptions":{"$ref":"#/definitions/CacheQueryOptions"},"purgeOnQuotaError":{"type":"boolean"}},"additionalProperties":false},"CacheQueryOptions":{"type":"object","properties":{"ignoreMethod":{"type":"boolean"},"ignoreSearch":{"type":"boolean"},"ignoreVary":{"type":"boolean"}},"additionalProperties":false},"WorkboxPlugin":{"description":"An object with optional lifecycle callback properties for the fetch and\ncache operations.","type":"object","properties":{"cacheDidUpdate":{"$ref":"#/definitions/CacheDidUpdateCallback"},"cachedResponseWillBeUsed":{"$ref":"#/definitions/CachedResponseWillBeUsedCallback"},"cacheKeyWillBeUsed":{"$ref":"#/definitions/CacheKeyWillBeUsedCallback"},"cacheWillUpdate":{"$ref":"#/definitions/CacheWillUpdateCallback"},"fetchDidFail":{"$ref":"#/definitions/FetchDidFailCallback"},"fetchDidSucceed":{"$ref":"#/definitions/FetchDidSucceedCallback"},"handlerDidComplete":{"$ref":"#/definitions/HandlerDidCompleteCallback"},"handlerDidError":{"$ref":"#/definitions/HandlerDidErrorCallback"},"handlerDidRespond":{"$ref":"#/definitions/HandlerDidRespondCallback"},"handlerWillRespond":{"$ref":"#/definitions/HandlerWillRespondCallback"},"handlerWillStart":{"$ref":"#/definitions/HandlerWillStartCallback"},"requestWillFetch":{"$ref":"#/definitions/RequestWillFetchCallback"}},"additionalProperties":false},"CacheDidUpdateCallback":{"type":"object","additionalProperties":false},"CachedResponseWillBeUsedCallback":{"type":"object","additionalProperties":false},"CacheKeyWillBeUsedCallback":{"type":"object","additionalProperties":false},"CacheWillUpdateCallback":{"type":"object","additionalProperties":false},"FetchDidFailCallback":{"type":"object","additionalProperties":false},"FetchDidSucceedCallback":{"type":"object","additionalProperties":false},"HandlerDidCompleteCallback":{"type":"object","additionalProperties":false},"HandlerDidErrorCallback":{"type":"object","additionalProperties":false},"HandlerDidRespondCallback":{"type":"object","additionalProperties":false},"HandlerWillRespondCallback":{"type":"object","additionalProperties":false},"HandlerWillStartCallback":{"type":"object","additionalProperties":false},"RequestWillFetchCallback":{"type":"object","additionalProperties":false},"RequestInit":{"type":"object","properties":{"body":{"anyOf":[{"$ref":"#/definitions/ArrayBuffer"},{"$ref":"#/definitions/ArrayBufferView"},{"$ref":"#/definitions/Blob"},{"$ref":"#/definitions/FormData"},{"$ref":"#/definitions/URLSearchParams"},{"$ref":"#/definitions/ReadableStream"},{"type":["null","string"]}]},"cache":{"enum":["default","force-cache","no-cache","no-store","only-if-cached","reload"],"type":"string"},"credentials":{"enum":["include","omit","same-origin"],"type":"string"},"headers":{"anyOf":[{"$ref":"#/definitions/Headers"},{"type":"array","items":{"type":"array","items":{"type":"string"}}},{"$ref":"#/definitions/Record"}]},"integrity":{"type":"string"},"keepalive":{"type":"boolean"},"method":{"type":"string"},"mode":{"enum":["cors","navigate","no-cors","same-origin"],"type":"string"},"redirect":{"enum":["error","follow","manual"],"type":"string"},"referrer":{"type":"string"},"referrerPolicy":{"enum":["","no-referrer","no-referrer-when-downgrade","origin","origin-when-cross-origin","same-origin","strict-origin","strict-origin-when-cross-origin","unsafe-url"],"type":"string"},"signal":{"anyOf":[{"$ref":"#/definitions/AbortSignal"},{"type":"null"}]},"window":{}},"additionalProperties":false},"ArrayBuffer":{"type":"object","properties":{"byteLength":{"type":"number"},"__@toStringTag":{"type":"string"}},"additionalProperties":false,"required":["__@toStringTag","byteLength"]},"ArrayBufferView":{"type":"object","properties":{"buffer":{"anyOf":[{"$ref":"#/definitions/ArrayBuffer"},{"$ref":"#/definitions/SharedArrayBuffer"}]},"byteLength":{"type":"number"},"byteOffset":{"type":"number"}},"additionalProperties":false,"required":["buffer","byteLength","byteOffset"]},"SharedArrayBuffer":{"type":"object","properties":{"byteLength":{"type":"number"},"__@species":{"$ref":"#/definitions/SharedArrayBuffer"},"__@toStringTag":{"type":"string","enum":["SharedArrayBuffer"]}},"additionalProperties":false,"required":["__@species","__@toStringTag","byteLength"]},"Blob":{"type":"object","properties":{"size":{"type":"number"},"type":{"type":"string"}},"additionalProperties":false,"required":["size","type"]},"FormData":{"type":"object","additionalProperties":false},"URLSearchParams":{"type":"object","additionalProperties":false},"ReadableStream":{"type":"object","properties":{"locked":{"type":"boolean"}},"additionalProperties":false,"required":["locked"]},"Headers":{"type":"object","additionalProperties":false},"Record":{"type":"object","additionalProperties":false},"AbortSignal":{"type":"object","properties":{"aborted":{"type":"boolean"},"onabort":{"anyOf":[{"type":"object","additionalProperties":false},{"type":"null"}]}},"additionalProperties":false,"required":["aborted","onabort"]},"RouteMatchCallback":{"description":"The \"match\" callback is used to determine if a `Route` should apply for a\nparticular URL and request. When matching occurs in response to a fetch\nevent from the client, the `event` object is also supplied. However, since\nthe match callback can be invoked outside of a fetch event, matching logic\nshould not assume the `event` object will always be available.\nIf the match callback returns a truthy value, the matching route's\n`RouteHandlerCallback` will be invoked immediately. If the value returned\nis a non-empty array or object, that value will be set on the handler's\n`options.params` argument.","type":"object","additionalProperties":false}},"$schema":"http://json-schema.org/draft-07/schema#"} diff --git a/packages/workbox-build/src/types.ts b/packages/workbox-build/src/types.ts index 2eb270bb3..6af8090c5 100644 --- a/packages/workbox-build/src/types.ts +++ b/packages/workbox-build/src/types.ts @@ -63,9 +63,9 @@ export interface BasePartial { * @default 2097152 */ maximumFileSizeToCacheInBytes?: number; - // https://github.com/YousefED/typescript-json-schema/issues/424 - // This would ideally be {[key: string]: string} - modifyURLPrefix?: any; + modifyURLPrefix?: { + [key: string]: string, + }; } export interface GeneratePartial { @@ -142,9 +142,9 @@ export interface GlobPartial { * @default true */ globStrict?: boolean; - // https://github.com/YousefED/typescript-json-schema/issues/424 - // This would ideally be {[key: string]: string | Array} - templatedURLs?: any; + templatedURLs?: { + [key: string]: string | Array; + }; } interface InjectPartial { @@ -161,11 +161,9 @@ interface WebpackPartial { // an Array can't be serialized into JSON. // The default value of [/\.map$/, /^manifest.*\.js$/] will be assigned by // the validation function, and we need to reflect that in the docs. - // This and include should probably be typed to `string | RegExp | Function` - // instead of `any`, but that also causes validation problems. - exclude?: Array; + exclude?: Array; excludeChunks?: Array; - include?: Array; + include?: Array; mode?: string | null; } From fb4aa3ecdb8fb80700d06c2bd39c84379f20770b Mon Sep 17 00:00:00 2001 From: Jeff Posnick Date: Mon, 14 Jun 2021 14:28:46 -0400 Subject: [PATCH 56/80] Cleanup of exclude/include --- gulp-tasks/build-node-packages.js | 12 ++++++++++-- .../src/schema/WebpackGenerateSWOptions.json | 2 +- .../src/schema/WebpackInjectManifestOptions.json | 2 +- packages/workbox-build/src/types.ts | 4 ++-- 4 files changed, 14 insertions(+), 6 deletions(-) diff --git a/gulp-tasks/build-node-packages.js b/gulp-tasks/build-node-packages.js index b19b5839f..26d9234be 100644 --- a/gulp-tasks/build-node-packages.js +++ b/gulp-tasks/build-node-packages.js @@ -53,10 +53,18 @@ async function generateWorkboxBuildJSONSchema(packagePath) { schema.properties.manifestTransforms.items = {typeof: 'function'}; } if (schema.properties.exclude) { - schema.properties.exclude.items.anyOf.push({typeof: 'function'}); + schema.properties.exclude.items.anyOf = [ + {'$ref': '#/definitions/RegExp'}, + {type: 'string'}, + {typeof: 'function'}, + ] } if (schema.properties.include) { - schema.properties.include.items.anyOf.push({typeof: 'function'}); + schema.properties.include.items.anyOf = [ + {'$ref': '#/definitions/RegExp'}, + {type: 'string'}, + {typeof: 'function'}, + ] } await fse.writeJSON(upath.join(packagePath, 'src', 'schema', `${optionType}.json`), schema); diff --git a/packages/workbox-build/src/schema/WebpackGenerateSWOptions.json b/packages/workbox-build/src/schema/WebpackGenerateSWOptions.json index 4027e2433..5d0b74252 100644 --- a/packages/workbox-build/src/schema/WebpackGenerateSWOptions.json +++ b/packages/workbox-build/src/schema/WebpackGenerateSWOptions.json @@ -1 +1 @@ -{"additionalProperties":false,"type":"object","properties":{"additionalManifestEntries":{"type":"array","items":{"anyOf":[{"$ref":"#/definitions/ManifestEntry"},{"type":"string"}]}},"dontCacheBustURLsMatching":{"$ref":"#/definitions/RegExp"},"manifestTransforms":{"type":"array","items":{"typeof":"function"}},"maximumFileSizeToCacheInBytes":{"default":2097152,"type":"number"},"modifyURLPrefix":{"type":"object","additionalProperties":{"type":"string"}},"chunks":{"type":"array","items":{"type":"string"}},"exclude":{"type":"array","items":{"anyOf":[{"$ref":"#/definitions/RegExp"},{"type":"string"},{"typeof":"function"}]}},"excludeChunks":{"type":"array","items":{"type":"string"}},"include":{"type":"array","items":{"anyOf":[{"$ref":"#/definitions/RegExp"},{"type":"string"},{"typeof":"function"}]}},"mode":{"default":"production","type":["null","string"]},"babelPresetEnvTargets":{"default":["chrome >= 56"],"type":"array","items":{"type":"string"}},"cacheId":{"type":["null","string"]},"cleanupOutdatedCaches":{"default":false,"type":"boolean"},"clientsClaim":{"default":false,"type":"boolean"},"directoryIndex":{"type":["null","string"]},"disableDevLogs":{"default":false,"type":"boolean"},"ignoreURLParametersMatching":{"type":"array","items":{"$ref":"#/definitions/RegExp"}},"importScripts":{"type":"array","items":{"type":"string"}},"inlineWorkboxRuntime":{"default":false,"type":"boolean"},"navigateFallback":{"default":null,"type":["null","string"]},"navigateFallbackAllowlist":{"type":"array","items":{"$ref":"#/definitions/RegExp"}},"navigateFallbackDenylist":{"type":"array","items":{"$ref":"#/definitions/RegExp"}},"navigationPreload":{"description":"navigationPreload is only valid when runtimeCaching is configured. However,\nthis can't be expressed via TypeScript, so it's enforced via runtime logic.","default":false,"type":"boolean"},"offlineGoogleAnalytics":{"default":false,"anyOf":[{"$ref":"#/definitions/GoogleAnalyticsInitializeOptions"},{"type":"boolean"}]},"runtimeCaching":{"type":"array","items":{"$ref":"#/definitions/RuntimeCaching"}},"skipWaiting":{"default":false,"type":"boolean"},"sourcemap":{"default":true,"type":"boolean"},"importScriptsViaChunks":{"type":"array","items":{"type":"string"}},"swDest":{"default":"service-worker.js","type":"string"}},"definitions":{"ManifestEntry":{"type":"object","properties":{"integrity":{"type":"string"},"revision":{"type":["null","string"]},"url":{"type":"string"}},"additionalProperties":false,"required":["revision","url"]},"RegExp":{"type":"object","properties":{"source":{"type":"string"},"global":{"type":"boolean"},"ignoreCase":{"type":"boolean"},"multiline":{"type":"boolean"},"lastIndex":{"type":"number"},"flags":{"type":"string"},"sticky":{"type":"boolean"},"unicode":{"type":"boolean"},"dotAll":{"type":"boolean"}},"additionalProperties":false,"required":["dotAll","flags","global","ignoreCase","lastIndex","multiline","source","sticky","unicode"]},"GoogleAnalyticsInitializeOptions":{"type":"object","properties":{"cacheName":{"type":"string"},"parameterOverrides":{"type":"object","additionalProperties":{"type":"string"}},"hitFilter":{"type":"object","additionalProperties":false}},"additionalProperties":false},"RuntimeCaching":{"type":"object","properties":{"handler":{"anyOf":[{"$ref":"#/definitions/RouteHandlerCallback"},{"$ref":"#/definitions/RouteHandlerObject"},{"enum":["CacheFirst","CacheOnly","NetworkFirst","NetworkOnly","StaleWhileRevalidate"],"type":"string"}]},"method":{"enum":["DELETE","GET","HEAD","PATCH","POST","PUT"],"type":"string"},"options":{"type":"object","properties":{"backgroundSync":{"type":"object","properties":{"name":{"type":"string"},"options":{"$ref":"#/definitions/QueueOptions"}},"additionalProperties":false,"required":["name"]},"broadcastUpdate":{"type":"object","properties":{"channelName":{"type":"string"},"options":{"$ref":"#/definitions/BroadcastCacheUpdateOptions"}},"additionalProperties":false,"required":["options"]},"cacheableResponse":{"$ref":"#/definitions/CacheableResponseOptions"},"cacheName":{"type":["null","string"]},"expiration":{"$ref":"#/definitions/ExpirationPluginOptions"},"networkTimeoutSeconds":{"type":"number"},"plugins":{"type":"array","items":{"$ref":"#/definitions/WorkboxPlugin"}},"precacheFallback":{"type":"object","properties":{"fallbackURL":{"type":"string"}},"additionalProperties":false,"required":["fallbackURL"]},"fetchOptions":{"$ref":"#/definitions/RequestInit"},"matchOptions":{"$ref":"#/definitions/CacheQueryOptions"}},"additionalProperties":false},"urlPattern":{"anyOf":[{"$ref":"#/definitions/RegExp"},{"$ref":"#/definitions/RouteMatchCallback"},{"type":"string"}]}},"additionalProperties":false,"required":["handler","urlPattern"]},"RouteHandlerCallback":{"description":"The \"handler\" callback is invoked whenever a `Router` matches a URL/Request\nto a `Route` via its `RouteMatchCallback`. This handler callback should\nreturn a `Promise` that resolves with a `Response`.\n\nIf a non-empty array or object is returned by the `RouteMatchCallback` it\nwill be passed in as this handler's `options.params` argument.","type":"object","additionalProperties":false},"RouteHandlerObject":{"description":"An object with a `handle` method of type `RouteHandlerCallback`.\n\nA `Route` object can be created with either an `RouteHandlerCallback`\nfunction or this `RouteHandler` object. The benefit of the `RouteHandler`\nis it can be extended (as is done by the `workbox-strategies` package).","type":"object","properties":{"handle":{"$ref":"#/definitions/RouteHandlerCallback"}},"additionalProperties":false,"required":["handle"]},"QueueOptions":{"type":"object","properties":{"onSync":{"$ref":"#/definitions/OnSyncCallback"},"maxRetentionTime":{"type":"number"}},"additionalProperties":false},"OnSyncCallback":{"type":"object","additionalProperties":false},"BroadcastCacheUpdateOptions":{"type":"object","properties":{"headersToCheck":{"type":"array","items":{"type":"string"}},"generatePayload":{"type":"object","additionalProperties":false}},"additionalProperties":false},"CacheableResponseOptions":{"type":"object","properties":{"statuses":{"type":"array","items":{"type":"number"}},"headers":{"type":"object","additionalProperties":{"type":"string"}}},"additionalProperties":false},"ExpirationPluginOptions":{"type":"object","properties":{"maxEntries":{"type":"number"},"maxAgeSeconds":{"type":"number"},"matchOptions":{"$ref":"#/definitions/CacheQueryOptions"},"purgeOnQuotaError":{"type":"boolean"}},"additionalProperties":false},"CacheQueryOptions":{"type":"object","properties":{"ignoreMethod":{"type":"boolean"},"ignoreSearch":{"type":"boolean"},"ignoreVary":{"type":"boolean"}},"additionalProperties":false},"WorkboxPlugin":{"description":"An object with optional lifecycle callback properties for the fetch and\ncache operations.","type":"object","properties":{"cacheDidUpdate":{"$ref":"#/definitions/CacheDidUpdateCallback"},"cachedResponseWillBeUsed":{"$ref":"#/definitions/CachedResponseWillBeUsedCallback"},"cacheKeyWillBeUsed":{"$ref":"#/definitions/CacheKeyWillBeUsedCallback"},"cacheWillUpdate":{"$ref":"#/definitions/CacheWillUpdateCallback"},"fetchDidFail":{"$ref":"#/definitions/FetchDidFailCallback"},"fetchDidSucceed":{"$ref":"#/definitions/FetchDidSucceedCallback"},"handlerDidComplete":{"$ref":"#/definitions/HandlerDidCompleteCallback"},"handlerDidError":{"$ref":"#/definitions/HandlerDidErrorCallback"},"handlerDidRespond":{"$ref":"#/definitions/HandlerDidRespondCallback"},"handlerWillRespond":{"$ref":"#/definitions/HandlerWillRespondCallback"},"handlerWillStart":{"$ref":"#/definitions/HandlerWillStartCallback"},"requestWillFetch":{"$ref":"#/definitions/RequestWillFetchCallback"}},"additionalProperties":false},"CacheDidUpdateCallback":{"type":"object","additionalProperties":false},"CachedResponseWillBeUsedCallback":{"type":"object","additionalProperties":false},"CacheKeyWillBeUsedCallback":{"type":"object","additionalProperties":false},"CacheWillUpdateCallback":{"type":"object","additionalProperties":false},"FetchDidFailCallback":{"type":"object","additionalProperties":false},"FetchDidSucceedCallback":{"type":"object","additionalProperties":false},"HandlerDidCompleteCallback":{"type":"object","additionalProperties":false},"HandlerDidErrorCallback":{"type":"object","additionalProperties":false},"HandlerDidRespondCallback":{"type":"object","additionalProperties":false},"HandlerWillRespondCallback":{"type":"object","additionalProperties":false},"HandlerWillStartCallback":{"type":"object","additionalProperties":false},"RequestWillFetchCallback":{"type":"object","additionalProperties":false},"RequestInit":{"type":"object","properties":{"body":{"anyOf":[{"$ref":"#/definitions/ArrayBuffer"},{"$ref":"#/definitions/ArrayBufferView"},{"$ref":"#/definitions/Blob"},{"$ref":"#/definitions/FormData"},{"$ref":"#/definitions/URLSearchParams"},{"$ref":"#/definitions/ReadableStream"},{"type":["null","string"]}]},"cache":{"enum":["default","force-cache","no-cache","no-store","only-if-cached","reload"],"type":"string"},"credentials":{"enum":["include","omit","same-origin"],"type":"string"},"headers":{"anyOf":[{"$ref":"#/definitions/Headers"},{"type":"array","items":{"type":"array","items":{"type":"string"}}},{"$ref":"#/definitions/Record"}]},"integrity":{"type":"string"},"keepalive":{"type":"boolean"},"method":{"type":"string"},"mode":{"enum":["cors","navigate","no-cors","same-origin"],"type":"string"},"redirect":{"enum":["error","follow","manual"],"type":"string"},"referrer":{"type":"string"},"referrerPolicy":{"enum":["","no-referrer","no-referrer-when-downgrade","origin","origin-when-cross-origin","same-origin","strict-origin","strict-origin-when-cross-origin","unsafe-url"],"type":"string"},"signal":{"anyOf":[{"$ref":"#/definitions/AbortSignal"},{"type":"null"}]},"window":{}},"additionalProperties":false},"ArrayBuffer":{"type":"object","properties":{"byteLength":{"type":"number"},"__@toStringTag":{"type":"string"}},"additionalProperties":false,"required":["__@toStringTag","byteLength"]},"ArrayBufferView":{"type":"object","properties":{"buffer":{"anyOf":[{"$ref":"#/definitions/ArrayBuffer"},{"$ref":"#/definitions/SharedArrayBuffer"}]},"byteLength":{"type":"number"},"byteOffset":{"type":"number"}},"additionalProperties":false,"required":["buffer","byteLength","byteOffset"]},"SharedArrayBuffer":{"type":"object","properties":{"byteLength":{"type":"number"},"__@species":{"$ref":"#/definitions/SharedArrayBuffer"},"__@toStringTag":{"type":"string","enum":["SharedArrayBuffer"]}},"additionalProperties":false,"required":["__@species","__@toStringTag","byteLength"]},"Blob":{"type":"object","properties":{"size":{"type":"number"},"type":{"type":"string"}},"additionalProperties":false,"required":["size","type"]},"FormData":{"type":"object","additionalProperties":false},"URLSearchParams":{"type":"object","additionalProperties":false},"ReadableStream":{"type":"object","properties":{"locked":{"type":"boolean"}},"additionalProperties":false,"required":["locked"]},"Headers":{"type":"object","additionalProperties":false},"Record":{"type":"object","additionalProperties":false},"AbortSignal":{"type":"object","properties":{"aborted":{"type":"boolean"},"onabort":{"anyOf":[{"type":"object","additionalProperties":false},{"type":"null"}]}},"additionalProperties":false,"required":["aborted","onabort"]},"RouteMatchCallback":{"description":"The \"match\" callback is used to determine if a `Route` should apply for a\nparticular URL and request. When matching occurs in response to a fetch\nevent from the client, the `event` object is also supplied. However, since\nthe match callback can be invoked outside of a fetch event, matching logic\nshould not assume the `event` object will always be available.\nIf the match callback returns a truthy value, the matching route's\n`RouteHandlerCallback` will be invoked immediately. If the value returned\nis a non-empty array or object, that value will be set on the handler's\n`options.params` argument.","type":"object","additionalProperties":false}},"$schema":"http://json-schema.org/draft-07/schema#"} +{"additionalProperties":false,"type":"object","properties":{"additionalManifestEntries":{"type":"array","items":{"anyOf":[{"$ref":"#/definitions/ManifestEntry"},{"type":"string"}]}},"dontCacheBustURLsMatching":{"$ref":"#/definitions/RegExp"},"manifestTransforms":{"type":"array","items":{"typeof":"function"}},"maximumFileSizeToCacheInBytes":{"default":2097152,"type":"number"},"modifyURLPrefix":{"type":"object","additionalProperties":{"type":"string"}},"chunks":{"type":"array","items":{"type":"string"}},"exclude":{"default":"[/\\.map$/, /^manifest.*\\.js$/]","type":"array","items":{"anyOf":[{"$ref":"#/definitions/RegExp"},{"type":"string"},{"typeof":"function"}]}},"excludeChunks":{"type":"array","items":{"type":"string"}},"include":{"type":"array","items":{"anyOf":[{"$ref":"#/definitions/RegExp"},{"type":"string"},{"typeof":"function"}]}},"mode":{"default":"production","type":["null","string"]},"babelPresetEnvTargets":{"default":["chrome >= 56"],"type":"array","items":{"type":"string"}},"cacheId":{"type":["null","string"]},"cleanupOutdatedCaches":{"default":false,"type":"boolean"},"clientsClaim":{"default":false,"type":"boolean"},"directoryIndex":{"type":["null","string"]},"disableDevLogs":{"default":false,"type":"boolean"},"ignoreURLParametersMatching":{"type":"array","items":{"$ref":"#/definitions/RegExp"}},"importScripts":{"type":"array","items":{"type":"string"}},"inlineWorkboxRuntime":{"default":false,"type":"boolean"},"navigateFallback":{"default":null,"type":["null","string"]},"navigateFallbackAllowlist":{"type":"array","items":{"$ref":"#/definitions/RegExp"}},"navigateFallbackDenylist":{"type":"array","items":{"$ref":"#/definitions/RegExp"}},"navigationPreload":{"description":"navigationPreload is only valid when runtimeCaching is configured. However,\nthis can't be expressed via TypeScript, so it's enforced via runtime logic.","default":false,"type":"boolean"},"offlineGoogleAnalytics":{"default":false,"anyOf":[{"$ref":"#/definitions/GoogleAnalyticsInitializeOptions"},{"type":"boolean"}]},"runtimeCaching":{"type":"array","items":{"$ref":"#/definitions/RuntimeCaching"}},"skipWaiting":{"default":false,"type":"boolean"},"sourcemap":{"default":true,"type":"boolean"},"importScriptsViaChunks":{"type":"array","items":{"type":"string"}},"swDest":{"default":"service-worker.js","type":"string"}},"definitions":{"ManifestEntry":{"type":"object","properties":{"integrity":{"type":"string"},"revision":{"type":["null","string"]},"url":{"type":"string"}},"additionalProperties":false,"required":["revision","url"]},"RegExp":{"type":"object","properties":{"source":{"type":"string"},"global":{"type":"boolean"},"ignoreCase":{"type":"boolean"},"multiline":{"type":"boolean"},"lastIndex":{"type":"number"},"flags":{"type":"string"},"sticky":{"type":"boolean"},"unicode":{"type":"boolean"},"dotAll":{"type":"boolean"}},"additionalProperties":false,"required":["dotAll","flags","global","ignoreCase","lastIndex","multiline","source","sticky","unicode"]},"GoogleAnalyticsInitializeOptions":{"type":"object","properties":{"cacheName":{"type":"string"},"parameterOverrides":{"type":"object","additionalProperties":{"type":"string"}},"hitFilter":{"type":"object","additionalProperties":false}},"additionalProperties":false},"RuntimeCaching":{"type":"object","properties":{"handler":{"anyOf":[{"$ref":"#/definitions/RouteHandlerCallback"},{"$ref":"#/definitions/RouteHandlerObject"},{"enum":["CacheFirst","CacheOnly","NetworkFirst","NetworkOnly","StaleWhileRevalidate"],"type":"string"}]},"method":{"enum":["DELETE","GET","HEAD","PATCH","POST","PUT"],"type":"string"},"options":{"type":"object","properties":{"backgroundSync":{"type":"object","properties":{"name":{"type":"string"},"options":{"$ref":"#/definitions/QueueOptions"}},"additionalProperties":false,"required":["name"]},"broadcastUpdate":{"type":"object","properties":{"channelName":{"type":"string"},"options":{"$ref":"#/definitions/BroadcastCacheUpdateOptions"}},"additionalProperties":false,"required":["options"]},"cacheableResponse":{"$ref":"#/definitions/CacheableResponseOptions"},"cacheName":{"type":["null","string"]},"expiration":{"$ref":"#/definitions/ExpirationPluginOptions"},"networkTimeoutSeconds":{"type":"number"},"plugins":{"type":"array","items":{"$ref":"#/definitions/WorkboxPlugin"}},"precacheFallback":{"type":"object","properties":{"fallbackURL":{"type":"string"}},"additionalProperties":false,"required":["fallbackURL"]},"fetchOptions":{"$ref":"#/definitions/RequestInit"},"matchOptions":{"$ref":"#/definitions/CacheQueryOptions"}},"additionalProperties":false},"urlPattern":{"anyOf":[{"$ref":"#/definitions/RegExp"},{"$ref":"#/definitions/RouteMatchCallback"},{"type":"string"}]}},"additionalProperties":false,"required":["handler","urlPattern"]},"RouteHandlerCallback":{"description":"The \"handler\" callback is invoked whenever a `Router` matches a URL/Request\nto a `Route` via its `RouteMatchCallback`. This handler callback should\nreturn a `Promise` that resolves with a `Response`.\n\nIf a non-empty array or object is returned by the `RouteMatchCallback` it\nwill be passed in as this handler's `options.params` argument.","type":"object","additionalProperties":false},"RouteHandlerObject":{"description":"An object with a `handle` method of type `RouteHandlerCallback`.\n\nA `Route` object can be created with either an `RouteHandlerCallback`\nfunction or this `RouteHandler` object. The benefit of the `RouteHandler`\nis it can be extended (as is done by the `workbox-strategies` package).","type":"object","properties":{"handle":{"$ref":"#/definitions/RouteHandlerCallback"}},"additionalProperties":false,"required":["handle"]},"QueueOptions":{"type":"object","properties":{"onSync":{"$ref":"#/definitions/OnSyncCallback"},"maxRetentionTime":{"type":"number"}},"additionalProperties":false},"OnSyncCallback":{"type":"object","additionalProperties":false},"BroadcastCacheUpdateOptions":{"type":"object","properties":{"headersToCheck":{"type":"array","items":{"type":"string"}},"generatePayload":{"type":"object","additionalProperties":false}},"additionalProperties":false},"CacheableResponseOptions":{"type":"object","properties":{"statuses":{"type":"array","items":{"type":"number"}},"headers":{"type":"object","additionalProperties":{"type":"string"}}},"additionalProperties":false},"ExpirationPluginOptions":{"type":"object","properties":{"maxEntries":{"type":"number"},"maxAgeSeconds":{"type":"number"},"matchOptions":{"$ref":"#/definitions/CacheQueryOptions"},"purgeOnQuotaError":{"type":"boolean"}},"additionalProperties":false},"CacheQueryOptions":{"type":"object","properties":{"ignoreMethod":{"type":"boolean"},"ignoreSearch":{"type":"boolean"},"ignoreVary":{"type":"boolean"}},"additionalProperties":false},"WorkboxPlugin":{"description":"An object with optional lifecycle callback properties for the fetch and\ncache operations.","type":"object","properties":{"cacheDidUpdate":{"$ref":"#/definitions/CacheDidUpdateCallback"},"cachedResponseWillBeUsed":{"$ref":"#/definitions/CachedResponseWillBeUsedCallback"},"cacheKeyWillBeUsed":{"$ref":"#/definitions/CacheKeyWillBeUsedCallback"},"cacheWillUpdate":{"$ref":"#/definitions/CacheWillUpdateCallback"},"fetchDidFail":{"$ref":"#/definitions/FetchDidFailCallback"},"fetchDidSucceed":{"$ref":"#/definitions/FetchDidSucceedCallback"},"handlerDidComplete":{"$ref":"#/definitions/HandlerDidCompleteCallback"},"handlerDidError":{"$ref":"#/definitions/HandlerDidErrorCallback"},"handlerDidRespond":{"$ref":"#/definitions/HandlerDidRespondCallback"},"handlerWillRespond":{"$ref":"#/definitions/HandlerWillRespondCallback"},"handlerWillStart":{"$ref":"#/definitions/HandlerWillStartCallback"},"requestWillFetch":{"$ref":"#/definitions/RequestWillFetchCallback"}},"additionalProperties":false},"CacheDidUpdateCallback":{"type":"object","additionalProperties":false},"CachedResponseWillBeUsedCallback":{"type":"object","additionalProperties":false},"CacheKeyWillBeUsedCallback":{"type":"object","additionalProperties":false},"CacheWillUpdateCallback":{"type":"object","additionalProperties":false},"FetchDidFailCallback":{"type":"object","additionalProperties":false},"FetchDidSucceedCallback":{"type":"object","additionalProperties":false},"HandlerDidCompleteCallback":{"type":"object","additionalProperties":false},"HandlerDidErrorCallback":{"type":"object","additionalProperties":false},"HandlerDidRespondCallback":{"type":"object","additionalProperties":false},"HandlerWillRespondCallback":{"type":"object","additionalProperties":false},"HandlerWillStartCallback":{"type":"object","additionalProperties":false},"RequestWillFetchCallback":{"type":"object","additionalProperties":false},"RequestInit":{"type":"object","properties":{"body":{"anyOf":[{"$ref":"#/definitions/ArrayBuffer"},{"$ref":"#/definitions/ArrayBufferView"},{"$ref":"#/definitions/Blob"},{"$ref":"#/definitions/FormData"},{"$ref":"#/definitions/URLSearchParams"},{"$ref":"#/definitions/ReadableStream"},{"type":["null","string"]}]},"cache":{"enum":["default","force-cache","no-cache","no-store","only-if-cached","reload"],"type":"string"},"credentials":{"enum":["include","omit","same-origin"],"type":"string"},"headers":{"anyOf":[{"$ref":"#/definitions/Headers"},{"type":"array","items":{"type":"array","items":{"type":"string"}}},{"$ref":"#/definitions/Record"}]},"integrity":{"type":"string"},"keepalive":{"type":"boolean"},"method":{"type":"string"},"mode":{"enum":["cors","navigate","no-cors","same-origin"],"type":"string"},"redirect":{"enum":["error","follow","manual"],"type":"string"},"referrer":{"type":"string"},"referrerPolicy":{"enum":["","no-referrer","no-referrer-when-downgrade","origin","origin-when-cross-origin","same-origin","strict-origin","strict-origin-when-cross-origin","unsafe-url"],"type":"string"},"signal":{"anyOf":[{"$ref":"#/definitions/AbortSignal"},{"type":"null"}]},"window":{}},"additionalProperties":false},"ArrayBuffer":{"type":"object","properties":{"byteLength":{"type":"number"},"__@toStringTag":{"type":"string"}},"additionalProperties":false,"required":["__@toStringTag","byteLength"]},"ArrayBufferView":{"type":"object","properties":{"buffer":{"anyOf":[{"$ref":"#/definitions/ArrayBuffer"},{"$ref":"#/definitions/SharedArrayBuffer"}]},"byteLength":{"type":"number"},"byteOffset":{"type":"number"}},"additionalProperties":false,"required":["buffer","byteLength","byteOffset"]},"SharedArrayBuffer":{"type":"object","properties":{"byteLength":{"type":"number"},"__@species":{"$ref":"#/definitions/SharedArrayBuffer"},"__@toStringTag":{"type":"string","enum":["SharedArrayBuffer"]}},"additionalProperties":false,"required":["__@species","__@toStringTag","byteLength"]},"Blob":{"type":"object","properties":{"size":{"type":"number"},"type":{"type":"string"}},"additionalProperties":false,"required":["size","type"]},"FormData":{"type":"object","additionalProperties":false},"URLSearchParams":{"type":"object","additionalProperties":false},"ReadableStream":{"type":"object","properties":{"locked":{"type":"boolean"}},"additionalProperties":false,"required":["locked"]},"Headers":{"type":"object","additionalProperties":false},"Record":{"type":"object","additionalProperties":false},"AbortSignal":{"type":"object","properties":{"aborted":{"type":"boolean"},"onabort":{"anyOf":[{"type":"object","additionalProperties":false},{"type":"null"}]}},"additionalProperties":false,"required":["aborted","onabort"]},"RouteMatchCallback":{"description":"The \"match\" callback is used to determine if a `Route` should apply for a\nparticular URL and request. When matching occurs in response to a fetch\nevent from the client, the `event` object is also supplied. However, since\nthe match callback can be invoked outside of a fetch event, matching logic\nshould not assume the `event` object will always be available.\nIf the match callback returns a truthy value, the matching route's\n`RouteHandlerCallback` will be invoked immediately. If the value returned\nis a non-empty array or object, that value will be set on the handler's\n`options.params` argument.","type":"object","additionalProperties":false}},"$schema":"http://json-schema.org/draft-07/schema#"} diff --git a/packages/workbox-build/src/schema/WebpackInjectManifestOptions.json b/packages/workbox-build/src/schema/WebpackInjectManifestOptions.json index 769a58517..773947114 100644 --- a/packages/workbox-build/src/schema/WebpackInjectManifestOptions.json +++ b/packages/workbox-build/src/schema/WebpackInjectManifestOptions.json @@ -1 +1 @@ -{"additionalProperties":false,"type":"object","properties":{"additionalManifestEntries":{"type":"array","items":{"anyOf":[{"$ref":"#/definitions/ManifestEntry"},{"type":"string"}]}},"dontCacheBustURLsMatching":{"$ref":"#/definitions/RegExp"},"manifestTransforms":{"type":"array","items":{"typeof":"function"}},"maximumFileSizeToCacheInBytes":{"default":2097152,"type":"number"},"modifyURLPrefix":{"type":"object","additionalProperties":{"type":"string"}},"chunks":{"type":"array","items":{"type":"string"}},"exclude":{"type":"array","items":{"anyOf":[{"$ref":"#/definitions/RegExp"},{"type":"string"},{"typeof":"function"}]}},"excludeChunks":{"type":"array","items":{"type":"string"}},"include":{"type":"array","items":{"anyOf":[{"$ref":"#/definitions/RegExp"},{"type":"string"},{"typeof":"function"}]}},"mode":{"type":["null","string"]},"injectionPoint":{"default":"self.__WB_MANIFEST","type":"string"},"swSrc":{"type":"string"},"compileSrc":{"default":true,"type":"boolean"},"swDest":{"type":"string"},"webpackCompilationPlugins":{"type":"array","items":{}}},"required":["swSrc"],"definitions":{"ManifestEntry":{"type":"object","properties":{"integrity":{"type":"string"},"revision":{"type":["null","string"]},"url":{"type":"string"}},"additionalProperties":false,"required":["revision","url"]},"RegExp":{"type":"object","properties":{"source":{"type":"string"},"global":{"type":"boolean"},"ignoreCase":{"type":"boolean"},"multiline":{"type":"boolean"},"lastIndex":{"type":"number"},"flags":{"type":"string"},"sticky":{"type":"boolean"},"unicode":{"type":"boolean"},"dotAll":{"type":"boolean"}},"additionalProperties":false,"required":["dotAll","flags","global","ignoreCase","lastIndex","multiline","source","sticky","unicode"]},"GoogleAnalyticsInitializeOptions":{"type":"object","properties":{"cacheName":{"type":"string"},"parameterOverrides":{"type":"object","additionalProperties":{"type":"string"}},"hitFilter":{"type":"object","additionalProperties":false}},"additionalProperties":false},"RuntimeCaching":{"type":"object","properties":{"handler":{"anyOf":[{"$ref":"#/definitions/RouteHandlerCallback"},{"$ref":"#/definitions/RouteHandlerObject"},{"enum":["CacheFirst","CacheOnly","NetworkFirst","NetworkOnly","StaleWhileRevalidate"],"type":"string"}]},"method":{"enum":["DELETE","GET","HEAD","PATCH","POST","PUT"],"type":"string"},"options":{"type":"object","properties":{"backgroundSync":{"type":"object","properties":{"name":{"type":"string"},"options":{"$ref":"#/definitions/QueueOptions"}},"additionalProperties":false,"required":["name"]},"broadcastUpdate":{"type":"object","properties":{"channelName":{"type":"string"},"options":{"$ref":"#/definitions/BroadcastCacheUpdateOptions"}},"additionalProperties":false,"required":["options"]},"cacheableResponse":{"$ref":"#/definitions/CacheableResponseOptions"},"cacheName":{"type":["null","string"]},"expiration":{"$ref":"#/definitions/ExpirationPluginOptions"},"networkTimeoutSeconds":{"type":"number"},"plugins":{"type":"array","items":{"$ref":"#/definitions/WorkboxPlugin"}},"precacheFallback":{"type":"object","properties":{"fallbackURL":{"type":"string"}},"additionalProperties":false,"required":["fallbackURL"]},"fetchOptions":{"$ref":"#/definitions/RequestInit"},"matchOptions":{"$ref":"#/definitions/CacheQueryOptions"}},"additionalProperties":false},"urlPattern":{"anyOf":[{"$ref":"#/definitions/RegExp"},{"$ref":"#/definitions/RouteMatchCallback"},{"type":"string"}]}},"additionalProperties":false,"required":["handler","urlPattern"]},"RouteHandlerCallback":{"description":"The \"handler\" callback is invoked whenever a `Router` matches a URL/Request\nto a `Route` via its `RouteMatchCallback`. This handler callback should\nreturn a `Promise` that resolves with a `Response`.\n\nIf a non-empty array or object is returned by the `RouteMatchCallback` it\nwill be passed in as this handler's `options.params` argument.","type":"object","additionalProperties":false},"RouteHandlerObject":{"description":"An object with a `handle` method of type `RouteHandlerCallback`.\n\nA `Route` object can be created with either an `RouteHandlerCallback`\nfunction or this `RouteHandler` object. The benefit of the `RouteHandler`\nis it can be extended (as is done by the `workbox-strategies` package).","type":"object","properties":{"handle":{"$ref":"#/definitions/RouteHandlerCallback"}},"additionalProperties":false,"required":["handle"]},"QueueOptions":{"type":"object","properties":{"onSync":{"$ref":"#/definitions/OnSyncCallback"},"maxRetentionTime":{"type":"number"}},"additionalProperties":false},"OnSyncCallback":{"type":"object","additionalProperties":false},"BroadcastCacheUpdateOptions":{"type":"object","properties":{"headersToCheck":{"type":"array","items":{"type":"string"}},"generatePayload":{"type":"object","additionalProperties":false}},"additionalProperties":false},"CacheableResponseOptions":{"type":"object","properties":{"statuses":{"type":"array","items":{"type":"number"}},"headers":{"type":"object","additionalProperties":{"type":"string"}}},"additionalProperties":false},"ExpirationPluginOptions":{"type":"object","properties":{"maxEntries":{"type":"number"},"maxAgeSeconds":{"type":"number"},"matchOptions":{"$ref":"#/definitions/CacheQueryOptions"},"purgeOnQuotaError":{"type":"boolean"}},"additionalProperties":false},"CacheQueryOptions":{"type":"object","properties":{"ignoreMethod":{"type":"boolean"},"ignoreSearch":{"type":"boolean"},"ignoreVary":{"type":"boolean"}},"additionalProperties":false},"WorkboxPlugin":{"description":"An object with optional lifecycle callback properties for the fetch and\ncache operations.","type":"object","properties":{"cacheDidUpdate":{"$ref":"#/definitions/CacheDidUpdateCallback"},"cachedResponseWillBeUsed":{"$ref":"#/definitions/CachedResponseWillBeUsedCallback"},"cacheKeyWillBeUsed":{"$ref":"#/definitions/CacheKeyWillBeUsedCallback"},"cacheWillUpdate":{"$ref":"#/definitions/CacheWillUpdateCallback"},"fetchDidFail":{"$ref":"#/definitions/FetchDidFailCallback"},"fetchDidSucceed":{"$ref":"#/definitions/FetchDidSucceedCallback"},"handlerDidComplete":{"$ref":"#/definitions/HandlerDidCompleteCallback"},"handlerDidError":{"$ref":"#/definitions/HandlerDidErrorCallback"},"handlerDidRespond":{"$ref":"#/definitions/HandlerDidRespondCallback"},"handlerWillRespond":{"$ref":"#/definitions/HandlerWillRespondCallback"},"handlerWillStart":{"$ref":"#/definitions/HandlerWillStartCallback"},"requestWillFetch":{"$ref":"#/definitions/RequestWillFetchCallback"}},"additionalProperties":false},"CacheDidUpdateCallback":{"type":"object","additionalProperties":false},"CachedResponseWillBeUsedCallback":{"type":"object","additionalProperties":false},"CacheKeyWillBeUsedCallback":{"type":"object","additionalProperties":false},"CacheWillUpdateCallback":{"type":"object","additionalProperties":false},"FetchDidFailCallback":{"type":"object","additionalProperties":false},"FetchDidSucceedCallback":{"type":"object","additionalProperties":false},"HandlerDidCompleteCallback":{"type":"object","additionalProperties":false},"HandlerDidErrorCallback":{"type":"object","additionalProperties":false},"HandlerDidRespondCallback":{"type":"object","additionalProperties":false},"HandlerWillRespondCallback":{"type":"object","additionalProperties":false},"HandlerWillStartCallback":{"type":"object","additionalProperties":false},"RequestWillFetchCallback":{"type":"object","additionalProperties":false},"RequestInit":{"type":"object","properties":{"body":{"anyOf":[{"$ref":"#/definitions/ArrayBuffer"},{"$ref":"#/definitions/ArrayBufferView"},{"$ref":"#/definitions/Blob"},{"$ref":"#/definitions/FormData"},{"$ref":"#/definitions/URLSearchParams"},{"$ref":"#/definitions/ReadableStream"},{"type":["null","string"]}]},"cache":{"enum":["default","force-cache","no-cache","no-store","only-if-cached","reload"],"type":"string"},"credentials":{"enum":["include","omit","same-origin"],"type":"string"},"headers":{"anyOf":[{"$ref":"#/definitions/Headers"},{"type":"array","items":{"type":"array","items":{"type":"string"}}},{"$ref":"#/definitions/Record"}]},"integrity":{"type":"string"},"keepalive":{"type":"boolean"},"method":{"type":"string"},"mode":{"enum":["cors","navigate","no-cors","same-origin"],"type":"string"},"redirect":{"enum":["error","follow","manual"],"type":"string"},"referrer":{"type":"string"},"referrerPolicy":{"enum":["","no-referrer","no-referrer-when-downgrade","origin","origin-when-cross-origin","same-origin","strict-origin","strict-origin-when-cross-origin","unsafe-url"],"type":"string"},"signal":{"anyOf":[{"$ref":"#/definitions/AbortSignal"},{"type":"null"}]},"window":{}},"additionalProperties":false},"ArrayBuffer":{"type":"object","properties":{"byteLength":{"type":"number"},"__@toStringTag":{"type":"string"}},"additionalProperties":false,"required":["__@toStringTag","byteLength"]},"ArrayBufferView":{"type":"object","properties":{"buffer":{"anyOf":[{"$ref":"#/definitions/ArrayBuffer"},{"$ref":"#/definitions/SharedArrayBuffer"}]},"byteLength":{"type":"number"},"byteOffset":{"type":"number"}},"additionalProperties":false,"required":["buffer","byteLength","byteOffset"]},"SharedArrayBuffer":{"type":"object","properties":{"byteLength":{"type":"number"},"__@species":{"$ref":"#/definitions/SharedArrayBuffer"},"__@toStringTag":{"type":"string","enum":["SharedArrayBuffer"]}},"additionalProperties":false,"required":["__@species","__@toStringTag","byteLength"]},"Blob":{"type":"object","properties":{"size":{"type":"number"},"type":{"type":"string"}},"additionalProperties":false,"required":["size","type"]},"FormData":{"type":"object","additionalProperties":false},"URLSearchParams":{"type":"object","additionalProperties":false},"ReadableStream":{"type":"object","properties":{"locked":{"type":"boolean"}},"additionalProperties":false,"required":["locked"]},"Headers":{"type":"object","additionalProperties":false},"Record":{"type":"object","additionalProperties":false},"AbortSignal":{"type":"object","properties":{"aborted":{"type":"boolean"},"onabort":{"anyOf":[{"type":"object","additionalProperties":false},{"type":"null"}]}},"additionalProperties":false,"required":["aborted","onabort"]},"RouteMatchCallback":{"description":"The \"match\" callback is used to determine if a `Route` should apply for a\nparticular URL and request. When matching occurs in response to a fetch\nevent from the client, the `event` object is also supplied. However, since\nthe match callback can be invoked outside of a fetch event, matching logic\nshould not assume the `event` object will always be available.\nIf the match callback returns a truthy value, the matching route's\n`RouteHandlerCallback` will be invoked immediately. If the value returned\nis a non-empty array or object, that value will be set on the handler's\n`options.params` argument.","type":"object","additionalProperties":false}},"$schema":"http://json-schema.org/draft-07/schema#"} +{"additionalProperties":false,"type":"object","properties":{"additionalManifestEntries":{"type":"array","items":{"anyOf":[{"$ref":"#/definitions/ManifestEntry"},{"type":"string"}]}},"dontCacheBustURLsMatching":{"$ref":"#/definitions/RegExp"},"manifestTransforms":{"type":"array","items":{"typeof":"function"}},"maximumFileSizeToCacheInBytes":{"default":2097152,"type":"number"},"modifyURLPrefix":{"type":"object","additionalProperties":{"type":"string"}},"chunks":{"type":"array","items":{"type":"string"}},"exclude":{"default":"[/\\.map$/, /^manifest.*\\.js$/]","type":"array","items":{"anyOf":[{"$ref":"#/definitions/RegExp"},{"type":"string"},{"typeof":"function"}]}},"excludeChunks":{"type":"array","items":{"type":"string"}},"include":{"type":"array","items":{"anyOf":[{"$ref":"#/definitions/RegExp"},{"type":"string"},{"typeof":"function"}]}},"mode":{"type":["null","string"]},"injectionPoint":{"default":"self.__WB_MANIFEST","type":"string"},"swSrc":{"type":"string"},"compileSrc":{"default":true,"type":"boolean"},"swDest":{"type":"string"},"webpackCompilationPlugins":{"type":"array","items":{}}},"required":["swSrc"],"definitions":{"ManifestEntry":{"type":"object","properties":{"integrity":{"type":"string"},"revision":{"type":["null","string"]},"url":{"type":"string"}},"additionalProperties":false,"required":["revision","url"]},"RegExp":{"type":"object","properties":{"source":{"type":"string"},"global":{"type":"boolean"},"ignoreCase":{"type":"boolean"},"multiline":{"type":"boolean"},"lastIndex":{"type":"number"},"flags":{"type":"string"},"sticky":{"type":"boolean"},"unicode":{"type":"boolean"},"dotAll":{"type":"boolean"}},"additionalProperties":false,"required":["dotAll","flags","global","ignoreCase","lastIndex","multiline","source","sticky","unicode"]},"GoogleAnalyticsInitializeOptions":{"type":"object","properties":{"cacheName":{"type":"string"},"parameterOverrides":{"type":"object","additionalProperties":{"type":"string"}},"hitFilter":{"type":"object","additionalProperties":false}},"additionalProperties":false},"RuntimeCaching":{"type":"object","properties":{"handler":{"anyOf":[{"$ref":"#/definitions/RouteHandlerCallback"},{"$ref":"#/definitions/RouteHandlerObject"},{"enum":["CacheFirst","CacheOnly","NetworkFirst","NetworkOnly","StaleWhileRevalidate"],"type":"string"}]},"method":{"enum":["DELETE","GET","HEAD","PATCH","POST","PUT"],"type":"string"},"options":{"type":"object","properties":{"backgroundSync":{"type":"object","properties":{"name":{"type":"string"},"options":{"$ref":"#/definitions/QueueOptions"}},"additionalProperties":false,"required":["name"]},"broadcastUpdate":{"type":"object","properties":{"channelName":{"type":"string"},"options":{"$ref":"#/definitions/BroadcastCacheUpdateOptions"}},"additionalProperties":false,"required":["options"]},"cacheableResponse":{"$ref":"#/definitions/CacheableResponseOptions"},"cacheName":{"type":["null","string"]},"expiration":{"$ref":"#/definitions/ExpirationPluginOptions"},"networkTimeoutSeconds":{"type":"number"},"plugins":{"type":"array","items":{"$ref":"#/definitions/WorkboxPlugin"}},"precacheFallback":{"type":"object","properties":{"fallbackURL":{"type":"string"}},"additionalProperties":false,"required":["fallbackURL"]},"fetchOptions":{"$ref":"#/definitions/RequestInit"},"matchOptions":{"$ref":"#/definitions/CacheQueryOptions"}},"additionalProperties":false},"urlPattern":{"anyOf":[{"$ref":"#/definitions/RegExp"},{"$ref":"#/definitions/RouteMatchCallback"},{"type":"string"}]}},"additionalProperties":false,"required":["handler","urlPattern"]},"RouteHandlerCallback":{"description":"The \"handler\" callback is invoked whenever a `Router` matches a URL/Request\nto a `Route` via its `RouteMatchCallback`. This handler callback should\nreturn a `Promise` that resolves with a `Response`.\n\nIf a non-empty array or object is returned by the `RouteMatchCallback` it\nwill be passed in as this handler's `options.params` argument.","type":"object","additionalProperties":false},"RouteHandlerObject":{"description":"An object with a `handle` method of type `RouteHandlerCallback`.\n\nA `Route` object can be created with either an `RouteHandlerCallback`\nfunction or this `RouteHandler` object. The benefit of the `RouteHandler`\nis it can be extended (as is done by the `workbox-strategies` package).","type":"object","properties":{"handle":{"$ref":"#/definitions/RouteHandlerCallback"}},"additionalProperties":false,"required":["handle"]},"QueueOptions":{"type":"object","properties":{"onSync":{"$ref":"#/definitions/OnSyncCallback"},"maxRetentionTime":{"type":"number"}},"additionalProperties":false},"OnSyncCallback":{"type":"object","additionalProperties":false},"BroadcastCacheUpdateOptions":{"type":"object","properties":{"headersToCheck":{"type":"array","items":{"type":"string"}},"generatePayload":{"type":"object","additionalProperties":false}},"additionalProperties":false},"CacheableResponseOptions":{"type":"object","properties":{"statuses":{"type":"array","items":{"type":"number"}},"headers":{"type":"object","additionalProperties":{"type":"string"}}},"additionalProperties":false},"ExpirationPluginOptions":{"type":"object","properties":{"maxEntries":{"type":"number"},"maxAgeSeconds":{"type":"number"},"matchOptions":{"$ref":"#/definitions/CacheQueryOptions"},"purgeOnQuotaError":{"type":"boolean"}},"additionalProperties":false},"CacheQueryOptions":{"type":"object","properties":{"ignoreMethod":{"type":"boolean"},"ignoreSearch":{"type":"boolean"},"ignoreVary":{"type":"boolean"}},"additionalProperties":false},"WorkboxPlugin":{"description":"An object with optional lifecycle callback properties for the fetch and\ncache operations.","type":"object","properties":{"cacheDidUpdate":{"$ref":"#/definitions/CacheDidUpdateCallback"},"cachedResponseWillBeUsed":{"$ref":"#/definitions/CachedResponseWillBeUsedCallback"},"cacheKeyWillBeUsed":{"$ref":"#/definitions/CacheKeyWillBeUsedCallback"},"cacheWillUpdate":{"$ref":"#/definitions/CacheWillUpdateCallback"},"fetchDidFail":{"$ref":"#/definitions/FetchDidFailCallback"},"fetchDidSucceed":{"$ref":"#/definitions/FetchDidSucceedCallback"},"handlerDidComplete":{"$ref":"#/definitions/HandlerDidCompleteCallback"},"handlerDidError":{"$ref":"#/definitions/HandlerDidErrorCallback"},"handlerDidRespond":{"$ref":"#/definitions/HandlerDidRespondCallback"},"handlerWillRespond":{"$ref":"#/definitions/HandlerWillRespondCallback"},"handlerWillStart":{"$ref":"#/definitions/HandlerWillStartCallback"},"requestWillFetch":{"$ref":"#/definitions/RequestWillFetchCallback"}},"additionalProperties":false},"CacheDidUpdateCallback":{"type":"object","additionalProperties":false},"CachedResponseWillBeUsedCallback":{"type":"object","additionalProperties":false},"CacheKeyWillBeUsedCallback":{"type":"object","additionalProperties":false},"CacheWillUpdateCallback":{"type":"object","additionalProperties":false},"FetchDidFailCallback":{"type":"object","additionalProperties":false},"FetchDidSucceedCallback":{"type":"object","additionalProperties":false},"HandlerDidCompleteCallback":{"type":"object","additionalProperties":false},"HandlerDidErrorCallback":{"type":"object","additionalProperties":false},"HandlerDidRespondCallback":{"type":"object","additionalProperties":false},"HandlerWillRespondCallback":{"type":"object","additionalProperties":false},"HandlerWillStartCallback":{"type":"object","additionalProperties":false},"RequestWillFetchCallback":{"type":"object","additionalProperties":false},"RequestInit":{"type":"object","properties":{"body":{"anyOf":[{"$ref":"#/definitions/ArrayBuffer"},{"$ref":"#/definitions/ArrayBufferView"},{"$ref":"#/definitions/Blob"},{"$ref":"#/definitions/FormData"},{"$ref":"#/definitions/URLSearchParams"},{"$ref":"#/definitions/ReadableStream"},{"type":["null","string"]}]},"cache":{"enum":["default","force-cache","no-cache","no-store","only-if-cached","reload"],"type":"string"},"credentials":{"enum":["include","omit","same-origin"],"type":"string"},"headers":{"anyOf":[{"$ref":"#/definitions/Headers"},{"type":"array","items":{"type":"array","items":{"type":"string"}}},{"$ref":"#/definitions/Record"}]},"integrity":{"type":"string"},"keepalive":{"type":"boolean"},"method":{"type":"string"},"mode":{"enum":["cors","navigate","no-cors","same-origin"],"type":"string"},"redirect":{"enum":["error","follow","manual"],"type":"string"},"referrer":{"type":"string"},"referrerPolicy":{"enum":["","no-referrer","no-referrer-when-downgrade","origin","origin-when-cross-origin","same-origin","strict-origin","strict-origin-when-cross-origin","unsafe-url"],"type":"string"},"signal":{"anyOf":[{"$ref":"#/definitions/AbortSignal"},{"type":"null"}]},"window":{}},"additionalProperties":false},"ArrayBuffer":{"type":"object","properties":{"byteLength":{"type":"number"},"__@toStringTag":{"type":"string"}},"additionalProperties":false,"required":["__@toStringTag","byteLength"]},"ArrayBufferView":{"type":"object","properties":{"buffer":{"anyOf":[{"$ref":"#/definitions/ArrayBuffer"},{"$ref":"#/definitions/SharedArrayBuffer"}]},"byteLength":{"type":"number"},"byteOffset":{"type":"number"}},"additionalProperties":false,"required":["buffer","byteLength","byteOffset"]},"SharedArrayBuffer":{"type":"object","properties":{"byteLength":{"type":"number"},"__@species":{"$ref":"#/definitions/SharedArrayBuffer"},"__@toStringTag":{"type":"string","enum":["SharedArrayBuffer"]}},"additionalProperties":false,"required":["__@species","__@toStringTag","byteLength"]},"Blob":{"type":"object","properties":{"size":{"type":"number"},"type":{"type":"string"}},"additionalProperties":false,"required":["size","type"]},"FormData":{"type":"object","additionalProperties":false},"URLSearchParams":{"type":"object","additionalProperties":false},"ReadableStream":{"type":"object","properties":{"locked":{"type":"boolean"}},"additionalProperties":false,"required":["locked"]},"Headers":{"type":"object","additionalProperties":false},"Record":{"type":"object","additionalProperties":false},"AbortSignal":{"type":"object","properties":{"aborted":{"type":"boolean"},"onabort":{"anyOf":[{"type":"object","additionalProperties":false},{"type":"null"}]}},"additionalProperties":false,"required":["aborted","onabort"]},"RouteMatchCallback":{"description":"The \"match\" callback is used to determine if a `Route` should apply for a\nparticular URL and request. When matching occurs in response to a fetch\nevent from the client, the `event` object is also supplied. However, since\nthe match callback can be invoked outside of a fetch event, matching logic\nshould not assume the `event` object will always be available.\nIf the match callback returns a truthy value, the matching route's\n`RouteHandlerCallback` will be invoked immediately. If the value returned\nis a non-empty array or object, that value will be set on the handler's\n`options.params` argument.","type":"object","additionalProperties":false}},"$schema":"http://json-schema.org/draft-07/schema#"} diff --git a/packages/workbox-build/src/types.ts b/packages/workbox-build/src/types.ts index 6af8090c5..16205a65f 100644 --- a/packages/workbox-build/src/types.ts +++ b/packages/workbox-build/src/types.ts @@ -161,9 +161,9 @@ interface WebpackPartial { // an Array can't be serialized into JSON. // The default value of [/\.map$/, /^manifest.*\.js$/] will be assigned by // the validation function, and we need to reflect that in the docs. - exclude?: Array; + exclude?: Array boolean)>; excludeChunks?: Array; - include?: Array; + include?: Array boolean)>; mode?: string | null; } From a856e6b7cfb80803b263f20dc4c35e858c0a56e9 Mon Sep 17 00:00:00 2001 From: Jeff Posnick Date: Mon, 14 Jun 2021 14:49:03 -0400 Subject: [PATCH 57/80] Fix a few more gSW tests --- test/workbox-build/node/generate-sw.js | 33 ++++++------------------- test/workbox-build/node/get-manifest.js | 4 --- 2 files changed, 8 insertions(+), 29 deletions(-) diff --git a/test/workbox-build/node/generate-sw.js b/test/workbox-build/node/generate-sw.js index f505a0155..80a4c2d12 100644 --- a/test/workbox-build/node/generate-sw.js +++ b/test/workbox-build/node/generate-sw.js @@ -94,10 +94,6 @@ describe(`[workbox-build] generate-sw.js (End to End)`, function() { describe('[workbox-build] invalid parameter values', function() { for (const param of SUPPORTED_PARAMS) { it(`should fail validation when '${param}' is an unexpected value`, async function() { - if (['modifyURLPrefix', 'templatedURLs'].includes(param)) { - // https://github.com/YousefED/typescript-json-schema/issues/424 - this.skip(); - } const options = Object.assign({}, BASE_OPTIONS); options[param] = () => {}; @@ -689,12 +685,8 @@ describe(`[workbox-build] generate-sw.js (End to End)`, function() { runtimeCaching: [{handler}], }); - try { - await generateSW(options); - throw new Error('Unexpected success.'); - } catch (error) { - expect(error.message).to.include(errors['urlPattern-is-required']); - } + await expect(generateSW(options)).to.eventually.be.rejectedWith( + WorkboxConfigError, 'urlPattern'); }); it(`should reject when 'handler' is missing from 'runtimeCaching'`, async function() { @@ -703,12 +695,8 @@ describe(`[workbox-build] generate-sw.js (End to End)`, function() { runtimeCaching: [{urlPattern}], }); - try { - await generateSW(options); - throw new Error('Unexpected success.'); - } catch (error) { - expect(error.message).to.include(errors['handler-is-required']); - } + await expect(generateSW(options)).to.eventually.be.rejectedWith( + WorkboxConfigError, 'handler'); }); it(`should reject when 'handler' is not a valid strategy name`, async function() { @@ -1060,21 +1048,16 @@ describe(`[workbox-build] generate-sw.js (End to End)`, function() { }); describe(`[workbox-build] behavior with 'navigationPreload'`, function() { - it(`should reject with a ValidationError when 'navigationPreload' is true and 'runtimeCaching' is undefined`, async function() { + it(`should reject when 'navigationPreload' is true and 'runtimeCaching' is undefined`, async function() { const options = Object.assign({}, BASE_OPTIONS, { navigationPreload: true, }); - try { - await generateSW(options); - throw new Error('Unexpected success.'); - } catch (error) { - expect(error.name).to.eql('ValidationError', error.message); - expect(error.details[0].context.key).to.eql('runtimeCaching'); - } + await expect(generateSW(options)).to.eventually.be.rejectedWith( + WorkboxConfigError, errors['nav-preload-runtime-caching']); }); - it(`should reject with a ValidationError when 'navigationPreload' is true and 'runtimeCaching' is invalid`, async function() { + it(`should reject when 'navigationPreload' is true and 'runtimeCaching' is invalid`, async function() { const options = Object.assign({}, BASE_OPTIONS, { runtimeCaching: undefined, navigationPreload: true, diff --git a/test/workbox-build/node/get-manifest.js b/test/workbox-build/node/get-manifest.js index 61fb09d4c..d7af9a573 100644 --- a/test/workbox-build/node/get-manifest.js +++ b/test/workbox-build/node/get-manifest.js @@ -69,10 +69,6 @@ describe(`[workbox-build] get-manifest.js (End to End)`, function() { describe('[workbox-build] invalid parameter values', function() { for (const param of SUPPORTED_PARAMS) { it(`should fail validation when '${param}' is an unexpected value`, async function() { - if (['modifyURLPrefix', 'templatedURLs'].includes(param)) { - // https://github.com/YousefED/typescript-json-schema/issues/424 - this.skip(); - } const options = Object.assign({}, BASE_OPTIONS); options[param] = () => {}; From 3945e8bfe88800e1572394172a4bbef0b7d6da41 Mon Sep 17 00:00:00 2001 From: Jeff Posnick Date: Mon, 14 Jun 2021 15:05:13 -0400 Subject: [PATCH 58/80] RouteMatchCallback function --- gulp-tasks/build-node-packages.js | 4 ++++ packages/workbox-build/src/schema/GenerateSWOptions.json | 2 +- packages/workbox-build/src/schema/GetManifestOptions.json | 2 +- packages/workbox-build/src/schema/InjectManifestOptions.json | 2 +- .../workbox-build/src/schema/WebpackGenerateSWOptions.json | 2 +- .../src/schema/WebpackInjectManifestOptions.json | 2 +- 6 files changed, 9 insertions(+), 5 deletions(-) diff --git a/gulp-tasks/build-node-packages.js b/gulp-tasks/build-node-packages.js index 26d9234be..35f395bd0 100644 --- a/gulp-tasks/build-node-packages.js +++ b/gulp-tasks/build-node-packages.js @@ -66,6 +66,10 @@ async function generateWorkboxBuildJSONSchema(packagePath) { {typeof: 'function'}, ] } + if (schema.definitions.RouteMatchCallback) { + delete schema.definitions.RouteMatchCallback.type; + schema.definitions.RouteMatchCallback.typeof = 'function'; + } await fse.writeJSON(upath.join(packagePath, 'src', 'schema', `${optionType}.json`), schema); } diff --git a/packages/workbox-build/src/schema/GenerateSWOptions.json b/packages/workbox-build/src/schema/GenerateSWOptions.json index 12fa8d492..3bf3aa002 100644 --- a/packages/workbox-build/src/schema/GenerateSWOptions.json +++ b/packages/workbox-build/src/schema/GenerateSWOptions.json @@ -1 +1 @@ -{"additionalProperties":false,"type":"object","properties":{"additionalManifestEntries":{"type":"array","items":{"anyOf":[{"$ref":"#/definitions/ManifestEntry"},{"type":"string"}]}},"dontCacheBustURLsMatching":{"$ref":"#/definitions/RegExp"},"manifestTransforms":{"type":"array","items":{"typeof":"function"}},"maximumFileSizeToCacheInBytes":{"default":2097152,"type":"number"},"modifyURLPrefix":{"type":"object","additionalProperties":{"type":"string"}},"globDirectory":{"type":"string"},"globFollow":{"default":true,"type":"boolean"},"globIgnores":{"default":["**/node_modules/**/*"],"type":"array","items":{"type":"string"}},"globPatterns":{"default":["**/*.{js,css,html}"],"type":"array","items":{"type":"string"}},"globStrict":{"default":true,"type":"boolean"},"templatedURLs":{"type":"object","additionalProperties":{"anyOf":[{"type":"array","items":{"type":"string"}},{"type":"string"}]}},"babelPresetEnvTargets":{"default":["chrome >= 56"],"type":"array","items":{"type":"string"}},"cacheId":{"type":["null","string"]},"cleanupOutdatedCaches":{"default":false,"type":"boolean"},"clientsClaim":{"default":false,"type":"boolean"},"directoryIndex":{"type":["null","string"]},"disableDevLogs":{"default":false,"type":"boolean"},"ignoreURLParametersMatching":{"type":"array","items":{"$ref":"#/definitions/RegExp"}},"importScripts":{"type":"array","items":{"type":"string"}},"inlineWorkboxRuntime":{"default":false,"type":"boolean"},"mode":{"default":"production","type":["null","string"]},"navigateFallback":{"default":null,"type":["null","string"]},"navigateFallbackAllowlist":{"type":"array","items":{"$ref":"#/definitions/RegExp"}},"navigateFallbackDenylist":{"type":"array","items":{"$ref":"#/definitions/RegExp"}},"navigationPreload":{"description":"navigationPreload is only valid when runtimeCaching is configured. However,\nthis can't be expressed via TypeScript, so it's enforced via runtime logic.","default":false,"type":"boolean"},"offlineGoogleAnalytics":{"default":false,"anyOf":[{"$ref":"#/definitions/GoogleAnalyticsInitializeOptions"},{"type":"boolean"}]},"runtimeCaching":{"type":"array","items":{"$ref":"#/definitions/RuntimeCaching"}},"skipWaiting":{"default":false,"type":"boolean"},"sourcemap":{"default":true,"type":"boolean"},"swDest":{"type":"string"}},"required":["globDirectory","swDest"],"definitions":{"ManifestEntry":{"type":"object","properties":{"integrity":{"type":"string"},"revision":{"type":["null","string"]},"url":{"type":"string"}},"additionalProperties":false,"required":["revision","url"]},"RegExp":{"type":"object","properties":{"source":{"type":"string"},"global":{"type":"boolean"},"ignoreCase":{"type":"boolean"},"multiline":{"type":"boolean"},"lastIndex":{"type":"number"},"flags":{"type":"string"},"sticky":{"type":"boolean"},"unicode":{"type":"boolean"},"dotAll":{"type":"boolean"}},"additionalProperties":false,"required":["dotAll","flags","global","ignoreCase","lastIndex","multiline","source","sticky","unicode"]},"GoogleAnalyticsInitializeOptions":{"type":"object","properties":{"cacheName":{"type":"string"},"parameterOverrides":{"type":"object","additionalProperties":{"type":"string"}},"hitFilter":{"type":"object","additionalProperties":false}},"additionalProperties":false},"RuntimeCaching":{"type":"object","properties":{"handler":{"anyOf":[{"$ref":"#/definitions/RouteHandlerCallback"},{"$ref":"#/definitions/RouteHandlerObject"},{"enum":["CacheFirst","CacheOnly","NetworkFirst","NetworkOnly","StaleWhileRevalidate"],"type":"string"}]},"method":{"enum":["DELETE","GET","HEAD","PATCH","POST","PUT"],"type":"string"},"options":{"type":"object","properties":{"backgroundSync":{"type":"object","properties":{"name":{"type":"string"},"options":{"$ref":"#/definitions/QueueOptions"}},"additionalProperties":false,"required":["name"]},"broadcastUpdate":{"type":"object","properties":{"channelName":{"type":"string"},"options":{"$ref":"#/definitions/BroadcastCacheUpdateOptions"}},"additionalProperties":false,"required":["options"]},"cacheableResponse":{"$ref":"#/definitions/CacheableResponseOptions"},"cacheName":{"type":["null","string"]},"expiration":{"$ref":"#/definitions/ExpirationPluginOptions"},"networkTimeoutSeconds":{"type":"number"},"plugins":{"type":"array","items":{"$ref":"#/definitions/WorkboxPlugin"}},"precacheFallback":{"type":"object","properties":{"fallbackURL":{"type":"string"}},"additionalProperties":false,"required":["fallbackURL"]},"fetchOptions":{"$ref":"#/definitions/RequestInit"},"matchOptions":{"$ref":"#/definitions/CacheQueryOptions"}},"additionalProperties":false},"urlPattern":{"anyOf":[{"$ref":"#/definitions/RegExp"},{"$ref":"#/definitions/RouteMatchCallback"},{"type":"string"}]}},"additionalProperties":false,"required":["handler","urlPattern"]},"RouteHandlerCallback":{"description":"The \"handler\" callback is invoked whenever a `Router` matches a URL/Request\nto a `Route` via its `RouteMatchCallback`. This handler callback should\nreturn a `Promise` that resolves with a `Response`.\n\nIf a non-empty array or object is returned by the `RouteMatchCallback` it\nwill be passed in as this handler's `options.params` argument.","type":"object","additionalProperties":false},"RouteHandlerObject":{"description":"An object with a `handle` method of type `RouteHandlerCallback`.\n\nA `Route` object can be created with either an `RouteHandlerCallback`\nfunction or this `RouteHandler` object. The benefit of the `RouteHandler`\nis it can be extended (as is done by the `workbox-strategies` package).","type":"object","properties":{"handle":{"$ref":"#/definitions/RouteHandlerCallback"}},"additionalProperties":false,"required":["handle"]},"QueueOptions":{"type":"object","properties":{"onSync":{"$ref":"#/definitions/OnSyncCallback"},"maxRetentionTime":{"type":"number"}},"additionalProperties":false},"OnSyncCallback":{"type":"object","additionalProperties":false},"BroadcastCacheUpdateOptions":{"type":"object","properties":{"headersToCheck":{"type":"array","items":{"type":"string"}},"generatePayload":{"type":"object","additionalProperties":false}},"additionalProperties":false},"CacheableResponseOptions":{"type":"object","properties":{"statuses":{"type":"array","items":{"type":"number"}},"headers":{"type":"object","additionalProperties":{"type":"string"}}},"additionalProperties":false},"ExpirationPluginOptions":{"type":"object","properties":{"maxEntries":{"type":"number"},"maxAgeSeconds":{"type":"number"},"matchOptions":{"$ref":"#/definitions/CacheQueryOptions"},"purgeOnQuotaError":{"type":"boolean"}},"additionalProperties":false},"CacheQueryOptions":{"type":"object","properties":{"ignoreMethod":{"type":"boolean"},"ignoreSearch":{"type":"boolean"},"ignoreVary":{"type":"boolean"}},"additionalProperties":false},"WorkboxPlugin":{"description":"An object with optional lifecycle callback properties for the fetch and\ncache operations.","type":"object","properties":{"cacheDidUpdate":{"$ref":"#/definitions/CacheDidUpdateCallback"},"cachedResponseWillBeUsed":{"$ref":"#/definitions/CachedResponseWillBeUsedCallback"},"cacheKeyWillBeUsed":{"$ref":"#/definitions/CacheKeyWillBeUsedCallback"},"cacheWillUpdate":{"$ref":"#/definitions/CacheWillUpdateCallback"},"fetchDidFail":{"$ref":"#/definitions/FetchDidFailCallback"},"fetchDidSucceed":{"$ref":"#/definitions/FetchDidSucceedCallback"},"handlerDidComplete":{"$ref":"#/definitions/HandlerDidCompleteCallback"},"handlerDidError":{"$ref":"#/definitions/HandlerDidErrorCallback"},"handlerDidRespond":{"$ref":"#/definitions/HandlerDidRespondCallback"},"handlerWillRespond":{"$ref":"#/definitions/HandlerWillRespondCallback"},"handlerWillStart":{"$ref":"#/definitions/HandlerWillStartCallback"},"requestWillFetch":{"$ref":"#/definitions/RequestWillFetchCallback"}},"additionalProperties":false},"CacheDidUpdateCallback":{"type":"object","additionalProperties":false},"CachedResponseWillBeUsedCallback":{"type":"object","additionalProperties":false},"CacheKeyWillBeUsedCallback":{"type":"object","additionalProperties":false},"CacheWillUpdateCallback":{"type":"object","additionalProperties":false},"FetchDidFailCallback":{"type":"object","additionalProperties":false},"FetchDidSucceedCallback":{"type":"object","additionalProperties":false},"HandlerDidCompleteCallback":{"type":"object","additionalProperties":false},"HandlerDidErrorCallback":{"type":"object","additionalProperties":false},"HandlerDidRespondCallback":{"type":"object","additionalProperties":false},"HandlerWillRespondCallback":{"type":"object","additionalProperties":false},"HandlerWillStartCallback":{"type":"object","additionalProperties":false},"RequestWillFetchCallback":{"type":"object","additionalProperties":false},"RequestInit":{"type":"object","properties":{"body":{"anyOf":[{"$ref":"#/definitions/ArrayBuffer"},{"$ref":"#/definitions/ArrayBufferView"},{"$ref":"#/definitions/Blob"},{"$ref":"#/definitions/FormData"},{"$ref":"#/definitions/URLSearchParams"},{"$ref":"#/definitions/ReadableStream"},{"type":["null","string"]}]},"cache":{"enum":["default","force-cache","no-cache","no-store","only-if-cached","reload"],"type":"string"},"credentials":{"enum":["include","omit","same-origin"],"type":"string"},"headers":{"anyOf":[{"$ref":"#/definitions/Headers"},{"type":"array","items":{"type":"array","items":{"type":"string"}}},{"$ref":"#/definitions/Record"}]},"integrity":{"type":"string"},"keepalive":{"type":"boolean"},"method":{"type":"string"},"mode":{"enum":["cors","navigate","no-cors","same-origin"],"type":"string"},"redirect":{"enum":["error","follow","manual"],"type":"string"},"referrer":{"type":"string"},"referrerPolicy":{"enum":["","no-referrer","no-referrer-when-downgrade","origin","origin-when-cross-origin","same-origin","strict-origin","strict-origin-when-cross-origin","unsafe-url"],"type":"string"},"signal":{"anyOf":[{"$ref":"#/definitions/AbortSignal"},{"type":"null"}]},"window":{}},"additionalProperties":false},"ArrayBuffer":{"type":"object","properties":{"byteLength":{"type":"number"},"__@toStringTag":{"type":"string"}},"additionalProperties":false,"required":["__@toStringTag","byteLength"]},"ArrayBufferView":{"type":"object","properties":{"buffer":{"anyOf":[{"$ref":"#/definitions/ArrayBuffer"},{"$ref":"#/definitions/SharedArrayBuffer"}]},"byteLength":{"type":"number"},"byteOffset":{"type":"number"}},"additionalProperties":false,"required":["buffer","byteLength","byteOffset"]},"SharedArrayBuffer":{"type":"object","properties":{"byteLength":{"type":"number"},"__@species":{"$ref":"#/definitions/SharedArrayBuffer"},"__@toStringTag":{"type":"string","enum":["SharedArrayBuffer"]}},"additionalProperties":false,"required":["__@species","__@toStringTag","byteLength"]},"Blob":{"type":"object","properties":{"size":{"type":"number"},"type":{"type":"string"}},"additionalProperties":false,"required":["size","type"]},"FormData":{"type":"object","additionalProperties":false},"URLSearchParams":{"type":"object","additionalProperties":false},"ReadableStream":{"type":"object","properties":{"locked":{"type":"boolean"}},"additionalProperties":false,"required":["locked"]},"Headers":{"type":"object","additionalProperties":false},"Record":{"type":"object","additionalProperties":false},"AbortSignal":{"type":"object","properties":{"aborted":{"type":"boolean"},"onabort":{"anyOf":[{"type":"object","additionalProperties":false},{"type":"null"}]}},"additionalProperties":false,"required":["aborted","onabort"]},"RouteMatchCallback":{"description":"The \"match\" callback is used to determine if a `Route` should apply for a\nparticular URL and request. When matching occurs in response to a fetch\nevent from the client, the `event` object is also supplied. However, since\nthe match callback can be invoked outside of a fetch event, matching logic\nshould not assume the `event` object will always be available.\nIf the match callback returns a truthy value, the matching route's\n`RouteHandlerCallback` will be invoked immediately. If the value returned\nis a non-empty array or object, that value will be set on the handler's\n`options.params` argument.","type":"object","additionalProperties":false}},"$schema":"http://json-schema.org/draft-07/schema#"} +{"additionalProperties":false,"type":"object","properties":{"additionalManifestEntries":{"type":"array","items":{"anyOf":[{"$ref":"#/definitions/ManifestEntry"},{"type":"string"}]}},"dontCacheBustURLsMatching":{"$ref":"#/definitions/RegExp"},"manifestTransforms":{"type":"array","items":{"typeof":"function"}},"maximumFileSizeToCacheInBytes":{"default":2097152,"type":"number"},"modifyURLPrefix":{"type":"object","additionalProperties":{"type":"string"}},"globDirectory":{"type":"string"},"globFollow":{"default":true,"type":"boolean"},"globIgnores":{"default":["**/node_modules/**/*"],"type":"array","items":{"type":"string"}},"globPatterns":{"default":["**/*.{js,css,html}"],"type":"array","items":{"type":"string"}},"globStrict":{"default":true,"type":"boolean"},"templatedURLs":{"type":"object","additionalProperties":{"anyOf":[{"type":"array","items":{"type":"string"}},{"type":"string"}]}},"babelPresetEnvTargets":{"default":["chrome >= 56"],"type":"array","items":{"type":"string"}},"cacheId":{"type":["null","string"]},"cleanupOutdatedCaches":{"default":false,"type":"boolean"},"clientsClaim":{"default":false,"type":"boolean"},"directoryIndex":{"type":["null","string"]},"disableDevLogs":{"default":false,"type":"boolean"},"ignoreURLParametersMatching":{"type":"array","items":{"$ref":"#/definitions/RegExp"}},"importScripts":{"type":"array","items":{"type":"string"}},"inlineWorkboxRuntime":{"default":false,"type":"boolean"},"mode":{"default":"production","type":["null","string"]},"navigateFallback":{"default":null,"type":["null","string"]},"navigateFallbackAllowlist":{"type":"array","items":{"$ref":"#/definitions/RegExp"}},"navigateFallbackDenylist":{"type":"array","items":{"$ref":"#/definitions/RegExp"}},"navigationPreload":{"description":"navigationPreload is only valid when runtimeCaching is configured. However,\nthis can't be expressed via TypeScript, so it's enforced via runtime logic.","default":false,"type":"boolean"},"offlineGoogleAnalytics":{"default":false,"anyOf":[{"$ref":"#/definitions/GoogleAnalyticsInitializeOptions"},{"type":"boolean"}]},"runtimeCaching":{"type":"array","items":{"$ref":"#/definitions/RuntimeCaching"}},"skipWaiting":{"default":false,"type":"boolean"},"sourcemap":{"default":true,"type":"boolean"},"swDest":{"type":"string"}},"required":["globDirectory","swDest"],"definitions":{"ManifestEntry":{"type":"object","properties":{"integrity":{"type":"string"},"revision":{"type":["null","string"]},"url":{"type":"string"}},"additionalProperties":false,"required":["revision","url"]},"RegExp":{"type":"object","properties":{"source":{"type":"string"},"global":{"type":"boolean"},"ignoreCase":{"type":"boolean"},"multiline":{"type":"boolean"},"lastIndex":{"type":"number"},"flags":{"type":"string"},"sticky":{"type":"boolean"},"unicode":{"type":"boolean"},"dotAll":{"type":"boolean"}},"additionalProperties":false,"required":["dotAll","flags","global","ignoreCase","lastIndex","multiline","source","sticky","unicode"]},"GoogleAnalyticsInitializeOptions":{"type":"object","properties":{"cacheName":{"type":"string"},"parameterOverrides":{"type":"object","additionalProperties":{"type":"string"}},"hitFilter":{"type":"object","additionalProperties":false}},"additionalProperties":false},"RuntimeCaching":{"type":"object","properties":{"handler":{"anyOf":[{"$ref":"#/definitions/RouteHandlerCallback"},{"$ref":"#/definitions/RouteHandlerObject"},{"enum":["CacheFirst","CacheOnly","NetworkFirst","NetworkOnly","StaleWhileRevalidate"],"type":"string"}]},"method":{"enum":["DELETE","GET","HEAD","PATCH","POST","PUT"],"type":"string"},"options":{"type":"object","properties":{"backgroundSync":{"type":"object","properties":{"name":{"type":"string"},"options":{"$ref":"#/definitions/QueueOptions"}},"additionalProperties":false,"required":["name"]},"broadcastUpdate":{"type":"object","properties":{"channelName":{"type":"string"},"options":{"$ref":"#/definitions/BroadcastCacheUpdateOptions"}},"additionalProperties":false,"required":["options"]},"cacheableResponse":{"$ref":"#/definitions/CacheableResponseOptions"},"cacheName":{"type":["null","string"]},"expiration":{"$ref":"#/definitions/ExpirationPluginOptions"},"networkTimeoutSeconds":{"type":"number"},"plugins":{"type":"array","items":{"$ref":"#/definitions/WorkboxPlugin"}},"precacheFallback":{"type":"object","properties":{"fallbackURL":{"type":"string"}},"additionalProperties":false,"required":["fallbackURL"]},"fetchOptions":{"$ref":"#/definitions/RequestInit"},"matchOptions":{"$ref":"#/definitions/CacheQueryOptions"}},"additionalProperties":false},"urlPattern":{"anyOf":[{"$ref":"#/definitions/RegExp"},{"$ref":"#/definitions/RouteMatchCallback"},{"type":"string"}]}},"additionalProperties":false,"required":["handler","urlPattern"]},"RouteHandlerCallback":{"description":"The \"handler\" callback is invoked whenever a `Router` matches a URL/Request\nto a `Route` via its `RouteMatchCallback`. This handler callback should\nreturn a `Promise` that resolves with a `Response`.\n\nIf a non-empty array or object is returned by the `RouteMatchCallback` it\nwill be passed in as this handler's `options.params` argument.","type":"object","additionalProperties":false},"RouteHandlerObject":{"description":"An object with a `handle` method of type `RouteHandlerCallback`.\n\nA `Route` object can be created with either an `RouteHandlerCallback`\nfunction or this `RouteHandler` object. The benefit of the `RouteHandler`\nis it can be extended (as is done by the `workbox-strategies` package).","type":"object","properties":{"handle":{"$ref":"#/definitions/RouteHandlerCallback"}},"additionalProperties":false,"required":["handle"]},"QueueOptions":{"type":"object","properties":{"onSync":{"$ref":"#/definitions/OnSyncCallback"},"maxRetentionTime":{"type":"number"}},"additionalProperties":false},"OnSyncCallback":{"type":"object","additionalProperties":false},"BroadcastCacheUpdateOptions":{"type":"object","properties":{"headersToCheck":{"type":"array","items":{"type":"string"}},"generatePayload":{"type":"object","additionalProperties":false}},"additionalProperties":false},"CacheableResponseOptions":{"type":"object","properties":{"statuses":{"type":"array","items":{"type":"number"}},"headers":{"type":"object","additionalProperties":{"type":"string"}}},"additionalProperties":false},"ExpirationPluginOptions":{"type":"object","properties":{"maxEntries":{"type":"number"},"maxAgeSeconds":{"type":"number"},"matchOptions":{"$ref":"#/definitions/CacheQueryOptions"},"purgeOnQuotaError":{"type":"boolean"}},"additionalProperties":false},"CacheQueryOptions":{"type":"object","properties":{"ignoreMethod":{"type":"boolean"},"ignoreSearch":{"type":"boolean"},"ignoreVary":{"type":"boolean"}},"additionalProperties":false},"WorkboxPlugin":{"description":"An object with optional lifecycle callback properties for the fetch and\ncache operations.","type":"object","properties":{"cacheDidUpdate":{"$ref":"#/definitions/CacheDidUpdateCallback"},"cachedResponseWillBeUsed":{"$ref":"#/definitions/CachedResponseWillBeUsedCallback"},"cacheKeyWillBeUsed":{"$ref":"#/definitions/CacheKeyWillBeUsedCallback"},"cacheWillUpdate":{"$ref":"#/definitions/CacheWillUpdateCallback"},"fetchDidFail":{"$ref":"#/definitions/FetchDidFailCallback"},"fetchDidSucceed":{"$ref":"#/definitions/FetchDidSucceedCallback"},"handlerDidComplete":{"$ref":"#/definitions/HandlerDidCompleteCallback"},"handlerDidError":{"$ref":"#/definitions/HandlerDidErrorCallback"},"handlerDidRespond":{"$ref":"#/definitions/HandlerDidRespondCallback"},"handlerWillRespond":{"$ref":"#/definitions/HandlerWillRespondCallback"},"handlerWillStart":{"$ref":"#/definitions/HandlerWillStartCallback"},"requestWillFetch":{"$ref":"#/definitions/RequestWillFetchCallback"}},"additionalProperties":false},"CacheDidUpdateCallback":{"type":"object","additionalProperties":false},"CachedResponseWillBeUsedCallback":{"type":"object","additionalProperties":false},"CacheKeyWillBeUsedCallback":{"type":"object","additionalProperties":false},"CacheWillUpdateCallback":{"type":"object","additionalProperties":false},"FetchDidFailCallback":{"type":"object","additionalProperties":false},"FetchDidSucceedCallback":{"type":"object","additionalProperties":false},"HandlerDidCompleteCallback":{"type":"object","additionalProperties":false},"HandlerDidErrorCallback":{"type":"object","additionalProperties":false},"HandlerDidRespondCallback":{"type":"object","additionalProperties":false},"HandlerWillRespondCallback":{"type":"object","additionalProperties":false},"HandlerWillStartCallback":{"type":"object","additionalProperties":false},"RequestWillFetchCallback":{"type":"object","additionalProperties":false},"RequestInit":{"type":"object","properties":{"body":{"anyOf":[{"$ref":"#/definitions/ArrayBuffer"},{"$ref":"#/definitions/ArrayBufferView"},{"$ref":"#/definitions/Blob"},{"$ref":"#/definitions/FormData"},{"$ref":"#/definitions/URLSearchParams"},{"$ref":"#/definitions/ReadableStream"},{"type":["null","string"]}]},"cache":{"enum":["default","force-cache","no-cache","no-store","only-if-cached","reload"],"type":"string"},"credentials":{"enum":["include","omit","same-origin"],"type":"string"},"headers":{"anyOf":[{"$ref":"#/definitions/Headers"},{"type":"array","items":{"type":"array","items":{"type":"string"}}},{"$ref":"#/definitions/Record"}]},"integrity":{"type":"string"},"keepalive":{"type":"boolean"},"method":{"type":"string"},"mode":{"enum":["cors","navigate","no-cors","same-origin"],"type":"string"},"redirect":{"enum":["error","follow","manual"],"type":"string"},"referrer":{"type":"string"},"referrerPolicy":{"enum":["","no-referrer","no-referrer-when-downgrade","origin","origin-when-cross-origin","same-origin","strict-origin","strict-origin-when-cross-origin","unsafe-url"],"type":"string"},"signal":{"anyOf":[{"$ref":"#/definitions/AbortSignal"},{"type":"null"}]},"window":{}},"additionalProperties":false},"ArrayBuffer":{"type":"object","properties":{"byteLength":{"type":"number"},"__@toStringTag":{"type":"string"}},"additionalProperties":false,"required":["__@toStringTag","byteLength"]},"ArrayBufferView":{"type":"object","properties":{"buffer":{"anyOf":[{"$ref":"#/definitions/ArrayBuffer"},{"$ref":"#/definitions/SharedArrayBuffer"}]},"byteLength":{"type":"number"},"byteOffset":{"type":"number"}},"additionalProperties":false,"required":["buffer","byteLength","byteOffset"]},"SharedArrayBuffer":{"type":"object","properties":{"byteLength":{"type":"number"},"__@species":{"$ref":"#/definitions/SharedArrayBuffer"},"__@toStringTag":{"type":"string","enum":["SharedArrayBuffer"]}},"additionalProperties":false,"required":["__@species","__@toStringTag","byteLength"]},"Blob":{"type":"object","properties":{"size":{"type":"number"},"type":{"type":"string"}},"additionalProperties":false,"required":["size","type"]},"FormData":{"type":"object","additionalProperties":false},"URLSearchParams":{"type":"object","additionalProperties":false},"ReadableStream":{"type":"object","properties":{"locked":{"type":"boolean"}},"additionalProperties":false,"required":["locked"]},"Headers":{"type":"object","additionalProperties":false},"Record":{"type":"object","additionalProperties":false},"AbortSignal":{"type":"object","properties":{"aborted":{"type":"boolean"},"onabort":{"anyOf":[{"type":"object","additionalProperties":false},{"type":"null"}]}},"additionalProperties":false,"required":["aborted","onabort"]},"RouteMatchCallback":{"description":"The \"match\" callback is used to determine if a `Route` should apply for a\nparticular URL and request. When matching occurs in response to a fetch\nevent from the client, the `event` object is also supplied. However, since\nthe match callback can be invoked outside of a fetch event, matching logic\nshould not assume the `event` object will always be available.\nIf the match callback returns a truthy value, the matching route's\n`RouteHandlerCallback` will be invoked immediately. If the value returned\nis a non-empty array or object, that value will be set on the handler's\n`options.params` argument.","additionalProperties":false,"typeof":"function"}},"$schema":"http://json-schema.org/draft-07/schema#"} diff --git a/packages/workbox-build/src/schema/GetManifestOptions.json b/packages/workbox-build/src/schema/GetManifestOptions.json index 6fa6d0164..aaefd62ff 100644 --- a/packages/workbox-build/src/schema/GetManifestOptions.json +++ b/packages/workbox-build/src/schema/GetManifestOptions.json @@ -1 +1 @@ -{"additionalProperties":false,"type":"object","properties":{"additionalManifestEntries":{"type":"array","items":{"anyOf":[{"$ref":"#/definitions/ManifestEntry"},{"type":"string"}]}},"dontCacheBustURLsMatching":{"$ref":"#/definitions/RegExp"},"manifestTransforms":{"type":"array","items":{"typeof":"function"}},"maximumFileSizeToCacheInBytes":{"default":2097152,"type":"number"},"modifyURLPrefix":{"type":"object","additionalProperties":{"type":"string"}},"globDirectory":{"type":"string"},"globFollow":{"default":true,"type":"boolean"},"globIgnores":{"default":["**/node_modules/**/*"],"type":"array","items":{"type":"string"}},"globPatterns":{"default":["**/*.{js,css,html}"],"type":"array","items":{"type":"string"}},"globStrict":{"default":true,"type":"boolean"},"templatedURLs":{"type":"object","additionalProperties":{"anyOf":[{"type":"array","items":{"type":"string"}},{"type":"string"}]}}},"required":["globDirectory"],"definitions":{"ManifestEntry":{"type":"object","properties":{"integrity":{"type":"string"},"revision":{"type":["null","string"]},"url":{"type":"string"}},"additionalProperties":false,"required":["revision","url"]},"RegExp":{"type":"object","properties":{"source":{"type":"string"},"global":{"type":"boolean"},"ignoreCase":{"type":"boolean"},"multiline":{"type":"boolean"},"lastIndex":{"type":"number"},"flags":{"type":"string"},"sticky":{"type":"boolean"},"unicode":{"type":"boolean"},"dotAll":{"type":"boolean"}},"additionalProperties":false,"required":["dotAll","flags","global","ignoreCase","lastIndex","multiline","source","sticky","unicode"]},"GoogleAnalyticsInitializeOptions":{"type":"object","properties":{"cacheName":{"type":"string"},"parameterOverrides":{"type":"object","additionalProperties":{"type":"string"}},"hitFilter":{"type":"object","additionalProperties":false}},"additionalProperties":false},"RuntimeCaching":{"type":"object","properties":{"handler":{"anyOf":[{"$ref":"#/definitions/RouteHandlerCallback"},{"$ref":"#/definitions/RouteHandlerObject"},{"enum":["CacheFirst","CacheOnly","NetworkFirst","NetworkOnly","StaleWhileRevalidate"],"type":"string"}]},"method":{"enum":["DELETE","GET","HEAD","PATCH","POST","PUT"],"type":"string"},"options":{"type":"object","properties":{"backgroundSync":{"type":"object","properties":{"name":{"type":"string"},"options":{"$ref":"#/definitions/QueueOptions"}},"additionalProperties":false,"required":["name"]},"broadcastUpdate":{"type":"object","properties":{"channelName":{"type":"string"},"options":{"$ref":"#/definitions/BroadcastCacheUpdateOptions"}},"additionalProperties":false,"required":["options"]},"cacheableResponse":{"$ref":"#/definitions/CacheableResponseOptions"},"cacheName":{"type":["null","string"]},"expiration":{"$ref":"#/definitions/ExpirationPluginOptions"},"networkTimeoutSeconds":{"type":"number"},"plugins":{"type":"array","items":{"$ref":"#/definitions/WorkboxPlugin"}},"precacheFallback":{"type":"object","properties":{"fallbackURL":{"type":"string"}},"additionalProperties":false,"required":["fallbackURL"]},"fetchOptions":{"$ref":"#/definitions/RequestInit"},"matchOptions":{"$ref":"#/definitions/CacheQueryOptions"}},"additionalProperties":false},"urlPattern":{"anyOf":[{"$ref":"#/definitions/RegExp"},{"$ref":"#/definitions/RouteMatchCallback"},{"type":"string"}]}},"additionalProperties":false,"required":["handler","urlPattern"]},"RouteHandlerCallback":{"description":"The \"handler\" callback is invoked whenever a `Router` matches a URL/Request\nto a `Route` via its `RouteMatchCallback`. This handler callback should\nreturn a `Promise` that resolves with a `Response`.\n\nIf a non-empty array or object is returned by the `RouteMatchCallback` it\nwill be passed in as this handler's `options.params` argument.","type":"object","additionalProperties":false},"RouteHandlerObject":{"description":"An object with a `handle` method of type `RouteHandlerCallback`.\n\nA `Route` object can be created with either an `RouteHandlerCallback`\nfunction or this `RouteHandler` object. The benefit of the `RouteHandler`\nis it can be extended (as is done by the `workbox-strategies` package).","type":"object","properties":{"handle":{"$ref":"#/definitions/RouteHandlerCallback"}},"additionalProperties":false,"required":["handle"]},"QueueOptions":{"type":"object","properties":{"onSync":{"$ref":"#/definitions/OnSyncCallback"},"maxRetentionTime":{"type":"number"}},"additionalProperties":false},"OnSyncCallback":{"type":"object","additionalProperties":false},"BroadcastCacheUpdateOptions":{"type":"object","properties":{"headersToCheck":{"type":"array","items":{"type":"string"}},"generatePayload":{"type":"object","additionalProperties":false}},"additionalProperties":false},"CacheableResponseOptions":{"type":"object","properties":{"statuses":{"type":"array","items":{"type":"number"}},"headers":{"type":"object","additionalProperties":{"type":"string"}}},"additionalProperties":false},"ExpirationPluginOptions":{"type":"object","properties":{"maxEntries":{"type":"number"},"maxAgeSeconds":{"type":"number"},"matchOptions":{"$ref":"#/definitions/CacheQueryOptions"},"purgeOnQuotaError":{"type":"boolean"}},"additionalProperties":false},"CacheQueryOptions":{"type":"object","properties":{"ignoreMethod":{"type":"boolean"},"ignoreSearch":{"type":"boolean"},"ignoreVary":{"type":"boolean"}},"additionalProperties":false},"WorkboxPlugin":{"description":"An object with optional lifecycle callback properties for the fetch and\ncache operations.","type":"object","properties":{"cacheDidUpdate":{"$ref":"#/definitions/CacheDidUpdateCallback"},"cachedResponseWillBeUsed":{"$ref":"#/definitions/CachedResponseWillBeUsedCallback"},"cacheKeyWillBeUsed":{"$ref":"#/definitions/CacheKeyWillBeUsedCallback"},"cacheWillUpdate":{"$ref":"#/definitions/CacheWillUpdateCallback"},"fetchDidFail":{"$ref":"#/definitions/FetchDidFailCallback"},"fetchDidSucceed":{"$ref":"#/definitions/FetchDidSucceedCallback"},"handlerDidComplete":{"$ref":"#/definitions/HandlerDidCompleteCallback"},"handlerDidError":{"$ref":"#/definitions/HandlerDidErrorCallback"},"handlerDidRespond":{"$ref":"#/definitions/HandlerDidRespondCallback"},"handlerWillRespond":{"$ref":"#/definitions/HandlerWillRespondCallback"},"handlerWillStart":{"$ref":"#/definitions/HandlerWillStartCallback"},"requestWillFetch":{"$ref":"#/definitions/RequestWillFetchCallback"}},"additionalProperties":false},"CacheDidUpdateCallback":{"type":"object","additionalProperties":false},"CachedResponseWillBeUsedCallback":{"type":"object","additionalProperties":false},"CacheKeyWillBeUsedCallback":{"type":"object","additionalProperties":false},"CacheWillUpdateCallback":{"type":"object","additionalProperties":false},"FetchDidFailCallback":{"type":"object","additionalProperties":false},"FetchDidSucceedCallback":{"type":"object","additionalProperties":false},"HandlerDidCompleteCallback":{"type":"object","additionalProperties":false},"HandlerDidErrorCallback":{"type":"object","additionalProperties":false},"HandlerDidRespondCallback":{"type":"object","additionalProperties":false},"HandlerWillRespondCallback":{"type":"object","additionalProperties":false},"HandlerWillStartCallback":{"type":"object","additionalProperties":false},"RequestWillFetchCallback":{"type":"object","additionalProperties":false},"RequestInit":{"type":"object","properties":{"body":{"anyOf":[{"$ref":"#/definitions/ArrayBuffer"},{"$ref":"#/definitions/ArrayBufferView"},{"$ref":"#/definitions/Blob"},{"$ref":"#/definitions/FormData"},{"$ref":"#/definitions/URLSearchParams"},{"$ref":"#/definitions/ReadableStream"},{"type":["null","string"]}]},"cache":{"enum":["default","force-cache","no-cache","no-store","only-if-cached","reload"],"type":"string"},"credentials":{"enum":["include","omit","same-origin"],"type":"string"},"headers":{"anyOf":[{"$ref":"#/definitions/Headers"},{"type":"array","items":{"type":"array","items":{"type":"string"}}},{"$ref":"#/definitions/Record"}]},"integrity":{"type":"string"},"keepalive":{"type":"boolean"},"method":{"type":"string"},"mode":{"enum":["cors","navigate","no-cors","same-origin"],"type":"string"},"redirect":{"enum":["error","follow","manual"],"type":"string"},"referrer":{"type":"string"},"referrerPolicy":{"enum":["","no-referrer","no-referrer-when-downgrade","origin","origin-when-cross-origin","same-origin","strict-origin","strict-origin-when-cross-origin","unsafe-url"],"type":"string"},"signal":{"anyOf":[{"$ref":"#/definitions/AbortSignal"},{"type":"null"}]},"window":{}},"additionalProperties":false},"ArrayBuffer":{"type":"object","properties":{"byteLength":{"type":"number"},"__@toStringTag":{"type":"string"}},"additionalProperties":false,"required":["__@toStringTag","byteLength"]},"ArrayBufferView":{"type":"object","properties":{"buffer":{"anyOf":[{"$ref":"#/definitions/ArrayBuffer"},{"$ref":"#/definitions/SharedArrayBuffer"}]},"byteLength":{"type":"number"},"byteOffset":{"type":"number"}},"additionalProperties":false,"required":["buffer","byteLength","byteOffset"]},"SharedArrayBuffer":{"type":"object","properties":{"byteLength":{"type":"number"},"__@species":{"$ref":"#/definitions/SharedArrayBuffer"},"__@toStringTag":{"type":"string","enum":["SharedArrayBuffer"]}},"additionalProperties":false,"required":["__@species","__@toStringTag","byteLength"]},"Blob":{"type":"object","properties":{"size":{"type":"number"},"type":{"type":"string"}},"additionalProperties":false,"required":["size","type"]},"FormData":{"type":"object","additionalProperties":false},"URLSearchParams":{"type":"object","additionalProperties":false},"ReadableStream":{"type":"object","properties":{"locked":{"type":"boolean"}},"additionalProperties":false,"required":["locked"]},"Headers":{"type":"object","additionalProperties":false},"Record":{"type":"object","additionalProperties":false},"AbortSignal":{"type":"object","properties":{"aborted":{"type":"boolean"},"onabort":{"anyOf":[{"type":"object","additionalProperties":false},{"type":"null"}]}},"additionalProperties":false,"required":["aborted","onabort"]},"RouteMatchCallback":{"description":"The \"match\" callback is used to determine if a `Route` should apply for a\nparticular URL and request. When matching occurs in response to a fetch\nevent from the client, the `event` object is also supplied. However, since\nthe match callback can be invoked outside of a fetch event, matching logic\nshould not assume the `event` object will always be available.\nIf the match callback returns a truthy value, the matching route's\n`RouteHandlerCallback` will be invoked immediately. If the value returned\nis a non-empty array or object, that value will be set on the handler's\n`options.params` argument.","type":"object","additionalProperties":false}},"$schema":"http://json-schema.org/draft-07/schema#"} +{"additionalProperties":false,"type":"object","properties":{"additionalManifestEntries":{"type":"array","items":{"anyOf":[{"$ref":"#/definitions/ManifestEntry"},{"type":"string"}]}},"dontCacheBustURLsMatching":{"$ref":"#/definitions/RegExp"},"manifestTransforms":{"type":"array","items":{"typeof":"function"}},"maximumFileSizeToCacheInBytes":{"default":2097152,"type":"number"},"modifyURLPrefix":{"type":"object","additionalProperties":{"type":"string"}},"globDirectory":{"type":"string"},"globFollow":{"default":true,"type":"boolean"},"globIgnores":{"default":["**/node_modules/**/*"],"type":"array","items":{"type":"string"}},"globPatterns":{"default":["**/*.{js,css,html}"],"type":"array","items":{"type":"string"}},"globStrict":{"default":true,"type":"boolean"},"templatedURLs":{"type":"object","additionalProperties":{"anyOf":[{"type":"array","items":{"type":"string"}},{"type":"string"}]}}},"required":["globDirectory"],"definitions":{"ManifestEntry":{"type":"object","properties":{"integrity":{"type":"string"},"revision":{"type":["null","string"]},"url":{"type":"string"}},"additionalProperties":false,"required":["revision","url"]},"RegExp":{"type":"object","properties":{"source":{"type":"string"},"global":{"type":"boolean"},"ignoreCase":{"type":"boolean"},"multiline":{"type":"boolean"},"lastIndex":{"type":"number"},"flags":{"type":"string"},"sticky":{"type":"boolean"},"unicode":{"type":"boolean"},"dotAll":{"type":"boolean"}},"additionalProperties":false,"required":["dotAll","flags","global","ignoreCase","lastIndex","multiline","source","sticky","unicode"]},"GoogleAnalyticsInitializeOptions":{"type":"object","properties":{"cacheName":{"type":"string"},"parameterOverrides":{"type":"object","additionalProperties":{"type":"string"}},"hitFilter":{"type":"object","additionalProperties":false}},"additionalProperties":false},"RuntimeCaching":{"type":"object","properties":{"handler":{"anyOf":[{"$ref":"#/definitions/RouteHandlerCallback"},{"$ref":"#/definitions/RouteHandlerObject"},{"enum":["CacheFirst","CacheOnly","NetworkFirst","NetworkOnly","StaleWhileRevalidate"],"type":"string"}]},"method":{"enum":["DELETE","GET","HEAD","PATCH","POST","PUT"],"type":"string"},"options":{"type":"object","properties":{"backgroundSync":{"type":"object","properties":{"name":{"type":"string"},"options":{"$ref":"#/definitions/QueueOptions"}},"additionalProperties":false,"required":["name"]},"broadcastUpdate":{"type":"object","properties":{"channelName":{"type":"string"},"options":{"$ref":"#/definitions/BroadcastCacheUpdateOptions"}},"additionalProperties":false,"required":["options"]},"cacheableResponse":{"$ref":"#/definitions/CacheableResponseOptions"},"cacheName":{"type":["null","string"]},"expiration":{"$ref":"#/definitions/ExpirationPluginOptions"},"networkTimeoutSeconds":{"type":"number"},"plugins":{"type":"array","items":{"$ref":"#/definitions/WorkboxPlugin"}},"precacheFallback":{"type":"object","properties":{"fallbackURL":{"type":"string"}},"additionalProperties":false,"required":["fallbackURL"]},"fetchOptions":{"$ref":"#/definitions/RequestInit"},"matchOptions":{"$ref":"#/definitions/CacheQueryOptions"}},"additionalProperties":false},"urlPattern":{"anyOf":[{"$ref":"#/definitions/RegExp"},{"$ref":"#/definitions/RouteMatchCallback"},{"type":"string"}]}},"additionalProperties":false,"required":["handler","urlPattern"]},"RouteHandlerCallback":{"description":"The \"handler\" callback is invoked whenever a `Router` matches a URL/Request\nto a `Route` via its `RouteMatchCallback`. This handler callback should\nreturn a `Promise` that resolves with a `Response`.\n\nIf a non-empty array or object is returned by the `RouteMatchCallback` it\nwill be passed in as this handler's `options.params` argument.","type":"object","additionalProperties":false},"RouteHandlerObject":{"description":"An object with a `handle` method of type `RouteHandlerCallback`.\n\nA `Route` object can be created with either an `RouteHandlerCallback`\nfunction or this `RouteHandler` object. The benefit of the `RouteHandler`\nis it can be extended (as is done by the `workbox-strategies` package).","type":"object","properties":{"handle":{"$ref":"#/definitions/RouteHandlerCallback"}},"additionalProperties":false,"required":["handle"]},"QueueOptions":{"type":"object","properties":{"onSync":{"$ref":"#/definitions/OnSyncCallback"},"maxRetentionTime":{"type":"number"}},"additionalProperties":false},"OnSyncCallback":{"type":"object","additionalProperties":false},"BroadcastCacheUpdateOptions":{"type":"object","properties":{"headersToCheck":{"type":"array","items":{"type":"string"}},"generatePayload":{"type":"object","additionalProperties":false}},"additionalProperties":false},"CacheableResponseOptions":{"type":"object","properties":{"statuses":{"type":"array","items":{"type":"number"}},"headers":{"type":"object","additionalProperties":{"type":"string"}}},"additionalProperties":false},"ExpirationPluginOptions":{"type":"object","properties":{"maxEntries":{"type":"number"},"maxAgeSeconds":{"type":"number"},"matchOptions":{"$ref":"#/definitions/CacheQueryOptions"},"purgeOnQuotaError":{"type":"boolean"}},"additionalProperties":false},"CacheQueryOptions":{"type":"object","properties":{"ignoreMethod":{"type":"boolean"},"ignoreSearch":{"type":"boolean"},"ignoreVary":{"type":"boolean"}},"additionalProperties":false},"WorkboxPlugin":{"description":"An object with optional lifecycle callback properties for the fetch and\ncache operations.","type":"object","properties":{"cacheDidUpdate":{"$ref":"#/definitions/CacheDidUpdateCallback"},"cachedResponseWillBeUsed":{"$ref":"#/definitions/CachedResponseWillBeUsedCallback"},"cacheKeyWillBeUsed":{"$ref":"#/definitions/CacheKeyWillBeUsedCallback"},"cacheWillUpdate":{"$ref":"#/definitions/CacheWillUpdateCallback"},"fetchDidFail":{"$ref":"#/definitions/FetchDidFailCallback"},"fetchDidSucceed":{"$ref":"#/definitions/FetchDidSucceedCallback"},"handlerDidComplete":{"$ref":"#/definitions/HandlerDidCompleteCallback"},"handlerDidError":{"$ref":"#/definitions/HandlerDidErrorCallback"},"handlerDidRespond":{"$ref":"#/definitions/HandlerDidRespondCallback"},"handlerWillRespond":{"$ref":"#/definitions/HandlerWillRespondCallback"},"handlerWillStart":{"$ref":"#/definitions/HandlerWillStartCallback"},"requestWillFetch":{"$ref":"#/definitions/RequestWillFetchCallback"}},"additionalProperties":false},"CacheDidUpdateCallback":{"type":"object","additionalProperties":false},"CachedResponseWillBeUsedCallback":{"type":"object","additionalProperties":false},"CacheKeyWillBeUsedCallback":{"type":"object","additionalProperties":false},"CacheWillUpdateCallback":{"type":"object","additionalProperties":false},"FetchDidFailCallback":{"type":"object","additionalProperties":false},"FetchDidSucceedCallback":{"type":"object","additionalProperties":false},"HandlerDidCompleteCallback":{"type":"object","additionalProperties":false},"HandlerDidErrorCallback":{"type":"object","additionalProperties":false},"HandlerDidRespondCallback":{"type":"object","additionalProperties":false},"HandlerWillRespondCallback":{"type":"object","additionalProperties":false},"HandlerWillStartCallback":{"type":"object","additionalProperties":false},"RequestWillFetchCallback":{"type":"object","additionalProperties":false},"RequestInit":{"type":"object","properties":{"body":{"anyOf":[{"$ref":"#/definitions/ArrayBuffer"},{"$ref":"#/definitions/ArrayBufferView"},{"$ref":"#/definitions/Blob"},{"$ref":"#/definitions/FormData"},{"$ref":"#/definitions/URLSearchParams"},{"$ref":"#/definitions/ReadableStream"},{"type":["null","string"]}]},"cache":{"enum":["default","force-cache","no-cache","no-store","only-if-cached","reload"],"type":"string"},"credentials":{"enum":["include","omit","same-origin"],"type":"string"},"headers":{"anyOf":[{"$ref":"#/definitions/Headers"},{"type":"array","items":{"type":"array","items":{"type":"string"}}},{"$ref":"#/definitions/Record"}]},"integrity":{"type":"string"},"keepalive":{"type":"boolean"},"method":{"type":"string"},"mode":{"enum":["cors","navigate","no-cors","same-origin"],"type":"string"},"redirect":{"enum":["error","follow","manual"],"type":"string"},"referrer":{"type":"string"},"referrerPolicy":{"enum":["","no-referrer","no-referrer-when-downgrade","origin","origin-when-cross-origin","same-origin","strict-origin","strict-origin-when-cross-origin","unsafe-url"],"type":"string"},"signal":{"anyOf":[{"$ref":"#/definitions/AbortSignal"},{"type":"null"}]},"window":{}},"additionalProperties":false},"ArrayBuffer":{"type":"object","properties":{"byteLength":{"type":"number"},"__@toStringTag":{"type":"string"}},"additionalProperties":false,"required":["__@toStringTag","byteLength"]},"ArrayBufferView":{"type":"object","properties":{"buffer":{"anyOf":[{"$ref":"#/definitions/ArrayBuffer"},{"$ref":"#/definitions/SharedArrayBuffer"}]},"byteLength":{"type":"number"},"byteOffset":{"type":"number"}},"additionalProperties":false,"required":["buffer","byteLength","byteOffset"]},"SharedArrayBuffer":{"type":"object","properties":{"byteLength":{"type":"number"},"__@species":{"$ref":"#/definitions/SharedArrayBuffer"},"__@toStringTag":{"type":"string","enum":["SharedArrayBuffer"]}},"additionalProperties":false,"required":["__@species","__@toStringTag","byteLength"]},"Blob":{"type":"object","properties":{"size":{"type":"number"},"type":{"type":"string"}},"additionalProperties":false,"required":["size","type"]},"FormData":{"type":"object","additionalProperties":false},"URLSearchParams":{"type":"object","additionalProperties":false},"ReadableStream":{"type":"object","properties":{"locked":{"type":"boolean"}},"additionalProperties":false,"required":["locked"]},"Headers":{"type":"object","additionalProperties":false},"Record":{"type":"object","additionalProperties":false},"AbortSignal":{"type":"object","properties":{"aborted":{"type":"boolean"},"onabort":{"anyOf":[{"type":"object","additionalProperties":false},{"type":"null"}]}},"additionalProperties":false,"required":["aborted","onabort"]},"RouteMatchCallback":{"description":"The \"match\" callback is used to determine if a `Route` should apply for a\nparticular URL and request. When matching occurs in response to a fetch\nevent from the client, the `event` object is also supplied. However, since\nthe match callback can be invoked outside of a fetch event, matching logic\nshould not assume the `event` object will always be available.\nIf the match callback returns a truthy value, the matching route's\n`RouteHandlerCallback` will be invoked immediately. If the value returned\nis a non-empty array or object, that value will be set on the handler's\n`options.params` argument.","additionalProperties":false,"typeof":"function"}},"$schema":"http://json-schema.org/draft-07/schema#"} diff --git a/packages/workbox-build/src/schema/InjectManifestOptions.json b/packages/workbox-build/src/schema/InjectManifestOptions.json index 474c288df..56650898e 100644 --- a/packages/workbox-build/src/schema/InjectManifestOptions.json +++ b/packages/workbox-build/src/schema/InjectManifestOptions.json @@ -1 +1 @@ -{"additionalProperties":false,"type":"object","properties":{"additionalManifestEntries":{"type":"array","items":{"anyOf":[{"$ref":"#/definitions/ManifestEntry"},{"type":"string"}]}},"dontCacheBustURLsMatching":{"$ref":"#/definitions/RegExp"},"manifestTransforms":{"type":"array","items":{"typeof":"function"}},"maximumFileSizeToCacheInBytes":{"default":2097152,"type":"number"},"modifyURLPrefix":{"type":"object","additionalProperties":{"type":"string"}},"globDirectory":{"type":"string"},"globFollow":{"default":true,"type":"boolean"},"globIgnores":{"default":["**/node_modules/**/*"],"type":"array","items":{"type":"string"}},"globPatterns":{"default":["**/*.{js,css,html}"],"type":"array","items":{"type":"string"}},"globStrict":{"default":true,"type":"boolean"},"templatedURLs":{"type":"object","additionalProperties":{"anyOf":[{"type":"array","items":{"type":"string"}},{"type":"string"}]}},"injectionPoint":{"default":"self.__WB_MANIFEST","type":"string"},"swSrc":{"type":"string"},"swDest":{"type":"string"}},"required":["globDirectory","swDest","swSrc"],"definitions":{"ManifestEntry":{"type":"object","properties":{"integrity":{"type":"string"},"revision":{"type":["null","string"]},"url":{"type":"string"}},"additionalProperties":false,"required":["revision","url"]},"RegExp":{"type":"object","properties":{"source":{"type":"string"},"global":{"type":"boolean"},"ignoreCase":{"type":"boolean"},"multiline":{"type":"boolean"},"lastIndex":{"type":"number"},"flags":{"type":"string"},"sticky":{"type":"boolean"},"unicode":{"type":"boolean"},"dotAll":{"type":"boolean"}},"additionalProperties":false,"required":["dotAll","flags","global","ignoreCase","lastIndex","multiline","source","sticky","unicode"]},"GoogleAnalyticsInitializeOptions":{"type":"object","properties":{"cacheName":{"type":"string"},"parameterOverrides":{"type":"object","additionalProperties":{"type":"string"}},"hitFilter":{"type":"object","additionalProperties":false}},"additionalProperties":false},"RuntimeCaching":{"type":"object","properties":{"handler":{"anyOf":[{"$ref":"#/definitions/RouteHandlerCallback"},{"$ref":"#/definitions/RouteHandlerObject"},{"enum":["CacheFirst","CacheOnly","NetworkFirst","NetworkOnly","StaleWhileRevalidate"],"type":"string"}]},"method":{"enum":["DELETE","GET","HEAD","PATCH","POST","PUT"],"type":"string"},"options":{"type":"object","properties":{"backgroundSync":{"type":"object","properties":{"name":{"type":"string"},"options":{"$ref":"#/definitions/QueueOptions"}},"additionalProperties":false,"required":["name"]},"broadcastUpdate":{"type":"object","properties":{"channelName":{"type":"string"},"options":{"$ref":"#/definitions/BroadcastCacheUpdateOptions"}},"additionalProperties":false,"required":["options"]},"cacheableResponse":{"$ref":"#/definitions/CacheableResponseOptions"},"cacheName":{"type":["null","string"]},"expiration":{"$ref":"#/definitions/ExpirationPluginOptions"},"networkTimeoutSeconds":{"type":"number"},"plugins":{"type":"array","items":{"$ref":"#/definitions/WorkboxPlugin"}},"precacheFallback":{"type":"object","properties":{"fallbackURL":{"type":"string"}},"additionalProperties":false,"required":["fallbackURL"]},"fetchOptions":{"$ref":"#/definitions/RequestInit"},"matchOptions":{"$ref":"#/definitions/CacheQueryOptions"}},"additionalProperties":false},"urlPattern":{"anyOf":[{"$ref":"#/definitions/RegExp"},{"$ref":"#/definitions/RouteMatchCallback"},{"type":"string"}]}},"additionalProperties":false,"required":["handler","urlPattern"]},"RouteHandlerCallback":{"description":"The \"handler\" callback is invoked whenever a `Router` matches a URL/Request\nto a `Route` via its `RouteMatchCallback`. This handler callback should\nreturn a `Promise` that resolves with a `Response`.\n\nIf a non-empty array or object is returned by the `RouteMatchCallback` it\nwill be passed in as this handler's `options.params` argument.","type":"object","additionalProperties":false},"RouteHandlerObject":{"description":"An object with a `handle` method of type `RouteHandlerCallback`.\n\nA `Route` object can be created with either an `RouteHandlerCallback`\nfunction or this `RouteHandler` object. The benefit of the `RouteHandler`\nis it can be extended (as is done by the `workbox-strategies` package).","type":"object","properties":{"handle":{"$ref":"#/definitions/RouteHandlerCallback"}},"additionalProperties":false,"required":["handle"]},"QueueOptions":{"type":"object","properties":{"onSync":{"$ref":"#/definitions/OnSyncCallback"},"maxRetentionTime":{"type":"number"}},"additionalProperties":false},"OnSyncCallback":{"type":"object","additionalProperties":false},"BroadcastCacheUpdateOptions":{"type":"object","properties":{"headersToCheck":{"type":"array","items":{"type":"string"}},"generatePayload":{"type":"object","additionalProperties":false}},"additionalProperties":false},"CacheableResponseOptions":{"type":"object","properties":{"statuses":{"type":"array","items":{"type":"number"}},"headers":{"type":"object","additionalProperties":{"type":"string"}}},"additionalProperties":false},"ExpirationPluginOptions":{"type":"object","properties":{"maxEntries":{"type":"number"},"maxAgeSeconds":{"type":"number"},"matchOptions":{"$ref":"#/definitions/CacheQueryOptions"},"purgeOnQuotaError":{"type":"boolean"}},"additionalProperties":false},"CacheQueryOptions":{"type":"object","properties":{"ignoreMethod":{"type":"boolean"},"ignoreSearch":{"type":"boolean"},"ignoreVary":{"type":"boolean"}},"additionalProperties":false},"WorkboxPlugin":{"description":"An object with optional lifecycle callback properties for the fetch and\ncache operations.","type":"object","properties":{"cacheDidUpdate":{"$ref":"#/definitions/CacheDidUpdateCallback"},"cachedResponseWillBeUsed":{"$ref":"#/definitions/CachedResponseWillBeUsedCallback"},"cacheKeyWillBeUsed":{"$ref":"#/definitions/CacheKeyWillBeUsedCallback"},"cacheWillUpdate":{"$ref":"#/definitions/CacheWillUpdateCallback"},"fetchDidFail":{"$ref":"#/definitions/FetchDidFailCallback"},"fetchDidSucceed":{"$ref":"#/definitions/FetchDidSucceedCallback"},"handlerDidComplete":{"$ref":"#/definitions/HandlerDidCompleteCallback"},"handlerDidError":{"$ref":"#/definitions/HandlerDidErrorCallback"},"handlerDidRespond":{"$ref":"#/definitions/HandlerDidRespondCallback"},"handlerWillRespond":{"$ref":"#/definitions/HandlerWillRespondCallback"},"handlerWillStart":{"$ref":"#/definitions/HandlerWillStartCallback"},"requestWillFetch":{"$ref":"#/definitions/RequestWillFetchCallback"}},"additionalProperties":false},"CacheDidUpdateCallback":{"type":"object","additionalProperties":false},"CachedResponseWillBeUsedCallback":{"type":"object","additionalProperties":false},"CacheKeyWillBeUsedCallback":{"type":"object","additionalProperties":false},"CacheWillUpdateCallback":{"type":"object","additionalProperties":false},"FetchDidFailCallback":{"type":"object","additionalProperties":false},"FetchDidSucceedCallback":{"type":"object","additionalProperties":false},"HandlerDidCompleteCallback":{"type":"object","additionalProperties":false},"HandlerDidErrorCallback":{"type":"object","additionalProperties":false},"HandlerDidRespondCallback":{"type":"object","additionalProperties":false},"HandlerWillRespondCallback":{"type":"object","additionalProperties":false},"HandlerWillStartCallback":{"type":"object","additionalProperties":false},"RequestWillFetchCallback":{"type":"object","additionalProperties":false},"RequestInit":{"type":"object","properties":{"body":{"anyOf":[{"$ref":"#/definitions/ArrayBuffer"},{"$ref":"#/definitions/ArrayBufferView"},{"$ref":"#/definitions/Blob"},{"$ref":"#/definitions/FormData"},{"$ref":"#/definitions/URLSearchParams"},{"$ref":"#/definitions/ReadableStream"},{"type":["null","string"]}]},"cache":{"enum":["default","force-cache","no-cache","no-store","only-if-cached","reload"],"type":"string"},"credentials":{"enum":["include","omit","same-origin"],"type":"string"},"headers":{"anyOf":[{"$ref":"#/definitions/Headers"},{"type":"array","items":{"type":"array","items":{"type":"string"}}},{"$ref":"#/definitions/Record"}]},"integrity":{"type":"string"},"keepalive":{"type":"boolean"},"method":{"type":"string"},"mode":{"enum":["cors","navigate","no-cors","same-origin"],"type":"string"},"redirect":{"enum":["error","follow","manual"],"type":"string"},"referrer":{"type":"string"},"referrerPolicy":{"enum":["","no-referrer","no-referrer-when-downgrade","origin","origin-when-cross-origin","same-origin","strict-origin","strict-origin-when-cross-origin","unsafe-url"],"type":"string"},"signal":{"anyOf":[{"$ref":"#/definitions/AbortSignal"},{"type":"null"}]},"window":{}},"additionalProperties":false},"ArrayBuffer":{"type":"object","properties":{"byteLength":{"type":"number"},"__@toStringTag":{"type":"string"}},"additionalProperties":false,"required":["__@toStringTag","byteLength"]},"ArrayBufferView":{"type":"object","properties":{"buffer":{"anyOf":[{"$ref":"#/definitions/ArrayBuffer"},{"$ref":"#/definitions/SharedArrayBuffer"}]},"byteLength":{"type":"number"},"byteOffset":{"type":"number"}},"additionalProperties":false,"required":["buffer","byteLength","byteOffset"]},"SharedArrayBuffer":{"type":"object","properties":{"byteLength":{"type":"number"},"__@species":{"$ref":"#/definitions/SharedArrayBuffer"},"__@toStringTag":{"type":"string","enum":["SharedArrayBuffer"]}},"additionalProperties":false,"required":["__@species","__@toStringTag","byteLength"]},"Blob":{"type":"object","properties":{"size":{"type":"number"},"type":{"type":"string"}},"additionalProperties":false,"required":["size","type"]},"FormData":{"type":"object","additionalProperties":false},"URLSearchParams":{"type":"object","additionalProperties":false},"ReadableStream":{"type":"object","properties":{"locked":{"type":"boolean"}},"additionalProperties":false,"required":["locked"]},"Headers":{"type":"object","additionalProperties":false},"Record":{"type":"object","additionalProperties":false},"AbortSignal":{"type":"object","properties":{"aborted":{"type":"boolean"},"onabort":{"anyOf":[{"type":"object","additionalProperties":false},{"type":"null"}]}},"additionalProperties":false,"required":["aborted","onabort"]},"RouteMatchCallback":{"description":"The \"match\" callback is used to determine if a `Route` should apply for a\nparticular URL and request. When matching occurs in response to a fetch\nevent from the client, the `event` object is also supplied. However, since\nthe match callback can be invoked outside of a fetch event, matching logic\nshould not assume the `event` object will always be available.\nIf the match callback returns a truthy value, the matching route's\n`RouteHandlerCallback` will be invoked immediately. If the value returned\nis a non-empty array or object, that value will be set on the handler's\n`options.params` argument.","type":"object","additionalProperties":false}},"$schema":"http://json-schema.org/draft-07/schema#"} +{"additionalProperties":false,"type":"object","properties":{"additionalManifestEntries":{"type":"array","items":{"anyOf":[{"$ref":"#/definitions/ManifestEntry"},{"type":"string"}]}},"dontCacheBustURLsMatching":{"$ref":"#/definitions/RegExp"},"manifestTransforms":{"type":"array","items":{"typeof":"function"}},"maximumFileSizeToCacheInBytes":{"default":2097152,"type":"number"},"modifyURLPrefix":{"type":"object","additionalProperties":{"type":"string"}},"globDirectory":{"type":"string"},"globFollow":{"default":true,"type":"boolean"},"globIgnores":{"default":["**/node_modules/**/*"],"type":"array","items":{"type":"string"}},"globPatterns":{"default":["**/*.{js,css,html}"],"type":"array","items":{"type":"string"}},"globStrict":{"default":true,"type":"boolean"},"templatedURLs":{"type":"object","additionalProperties":{"anyOf":[{"type":"array","items":{"type":"string"}},{"type":"string"}]}},"injectionPoint":{"default":"self.__WB_MANIFEST","type":"string"},"swSrc":{"type":"string"},"swDest":{"type":"string"}},"required":["globDirectory","swDest","swSrc"],"definitions":{"ManifestEntry":{"type":"object","properties":{"integrity":{"type":"string"},"revision":{"type":["null","string"]},"url":{"type":"string"}},"additionalProperties":false,"required":["revision","url"]},"RegExp":{"type":"object","properties":{"source":{"type":"string"},"global":{"type":"boolean"},"ignoreCase":{"type":"boolean"},"multiline":{"type":"boolean"},"lastIndex":{"type":"number"},"flags":{"type":"string"},"sticky":{"type":"boolean"},"unicode":{"type":"boolean"},"dotAll":{"type":"boolean"}},"additionalProperties":false,"required":["dotAll","flags","global","ignoreCase","lastIndex","multiline","source","sticky","unicode"]},"GoogleAnalyticsInitializeOptions":{"type":"object","properties":{"cacheName":{"type":"string"},"parameterOverrides":{"type":"object","additionalProperties":{"type":"string"}},"hitFilter":{"type":"object","additionalProperties":false}},"additionalProperties":false},"RuntimeCaching":{"type":"object","properties":{"handler":{"anyOf":[{"$ref":"#/definitions/RouteHandlerCallback"},{"$ref":"#/definitions/RouteHandlerObject"},{"enum":["CacheFirst","CacheOnly","NetworkFirst","NetworkOnly","StaleWhileRevalidate"],"type":"string"}]},"method":{"enum":["DELETE","GET","HEAD","PATCH","POST","PUT"],"type":"string"},"options":{"type":"object","properties":{"backgroundSync":{"type":"object","properties":{"name":{"type":"string"},"options":{"$ref":"#/definitions/QueueOptions"}},"additionalProperties":false,"required":["name"]},"broadcastUpdate":{"type":"object","properties":{"channelName":{"type":"string"},"options":{"$ref":"#/definitions/BroadcastCacheUpdateOptions"}},"additionalProperties":false,"required":["options"]},"cacheableResponse":{"$ref":"#/definitions/CacheableResponseOptions"},"cacheName":{"type":["null","string"]},"expiration":{"$ref":"#/definitions/ExpirationPluginOptions"},"networkTimeoutSeconds":{"type":"number"},"plugins":{"type":"array","items":{"$ref":"#/definitions/WorkboxPlugin"}},"precacheFallback":{"type":"object","properties":{"fallbackURL":{"type":"string"}},"additionalProperties":false,"required":["fallbackURL"]},"fetchOptions":{"$ref":"#/definitions/RequestInit"},"matchOptions":{"$ref":"#/definitions/CacheQueryOptions"}},"additionalProperties":false},"urlPattern":{"anyOf":[{"$ref":"#/definitions/RegExp"},{"$ref":"#/definitions/RouteMatchCallback"},{"type":"string"}]}},"additionalProperties":false,"required":["handler","urlPattern"]},"RouteHandlerCallback":{"description":"The \"handler\" callback is invoked whenever a `Router` matches a URL/Request\nto a `Route` via its `RouteMatchCallback`. This handler callback should\nreturn a `Promise` that resolves with a `Response`.\n\nIf a non-empty array or object is returned by the `RouteMatchCallback` it\nwill be passed in as this handler's `options.params` argument.","type":"object","additionalProperties":false},"RouteHandlerObject":{"description":"An object with a `handle` method of type `RouteHandlerCallback`.\n\nA `Route` object can be created with either an `RouteHandlerCallback`\nfunction or this `RouteHandler` object. The benefit of the `RouteHandler`\nis it can be extended (as is done by the `workbox-strategies` package).","type":"object","properties":{"handle":{"$ref":"#/definitions/RouteHandlerCallback"}},"additionalProperties":false,"required":["handle"]},"QueueOptions":{"type":"object","properties":{"onSync":{"$ref":"#/definitions/OnSyncCallback"},"maxRetentionTime":{"type":"number"}},"additionalProperties":false},"OnSyncCallback":{"type":"object","additionalProperties":false},"BroadcastCacheUpdateOptions":{"type":"object","properties":{"headersToCheck":{"type":"array","items":{"type":"string"}},"generatePayload":{"type":"object","additionalProperties":false}},"additionalProperties":false},"CacheableResponseOptions":{"type":"object","properties":{"statuses":{"type":"array","items":{"type":"number"}},"headers":{"type":"object","additionalProperties":{"type":"string"}}},"additionalProperties":false},"ExpirationPluginOptions":{"type":"object","properties":{"maxEntries":{"type":"number"},"maxAgeSeconds":{"type":"number"},"matchOptions":{"$ref":"#/definitions/CacheQueryOptions"},"purgeOnQuotaError":{"type":"boolean"}},"additionalProperties":false},"CacheQueryOptions":{"type":"object","properties":{"ignoreMethod":{"type":"boolean"},"ignoreSearch":{"type":"boolean"},"ignoreVary":{"type":"boolean"}},"additionalProperties":false},"WorkboxPlugin":{"description":"An object with optional lifecycle callback properties for the fetch and\ncache operations.","type":"object","properties":{"cacheDidUpdate":{"$ref":"#/definitions/CacheDidUpdateCallback"},"cachedResponseWillBeUsed":{"$ref":"#/definitions/CachedResponseWillBeUsedCallback"},"cacheKeyWillBeUsed":{"$ref":"#/definitions/CacheKeyWillBeUsedCallback"},"cacheWillUpdate":{"$ref":"#/definitions/CacheWillUpdateCallback"},"fetchDidFail":{"$ref":"#/definitions/FetchDidFailCallback"},"fetchDidSucceed":{"$ref":"#/definitions/FetchDidSucceedCallback"},"handlerDidComplete":{"$ref":"#/definitions/HandlerDidCompleteCallback"},"handlerDidError":{"$ref":"#/definitions/HandlerDidErrorCallback"},"handlerDidRespond":{"$ref":"#/definitions/HandlerDidRespondCallback"},"handlerWillRespond":{"$ref":"#/definitions/HandlerWillRespondCallback"},"handlerWillStart":{"$ref":"#/definitions/HandlerWillStartCallback"},"requestWillFetch":{"$ref":"#/definitions/RequestWillFetchCallback"}},"additionalProperties":false},"CacheDidUpdateCallback":{"type":"object","additionalProperties":false},"CachedResponseWillBeUsedCallback":{"type":"object","additionalProperties":false},"CacheKeyWillBeUsedCallback":{"type":"object","additionalProperties":false},"CacheWillUpdateCallback":{"type":"object","additionalProperties":false},"FetchDidFailCallback":{"type":"object","additionalProperties":false},"FetchDidSucceedCallback":{"type":"object","additionalProperties":false},"HandlerDidCompleteCallback":{"type":"object","additionalProperties":false},"HandlerDidErrorCallback":{"type":"object","additionalProperties":false},"HandlerDidRespondCallback":{"type":"object","additionalProperties":false},"HandlerWillRespondCallback":{"type":"object","additionalProperties":false},"HandlerWillStartCallback":{"type":"object","additionalProperties":false},"RequestWillFetchCallback":{"type":"object","additionalProperties":false},"RequestInit":{"type":"object","properties":{"body":{"anyOf":[{"$ref":"#/definitions/ArrayBuffer"},{"$ref":"#/definitions/ArrayBufferView"},{"$ref":"#/definitions/Blob"},{"$ref":"#/definitions/FormData"},{"$ref":"#/definitions/URLSearchParams"},{"$ref":"#/definitions/ReadableStream"},{"type":["null","string"]}]},"cache":{"enum":["default","force-cache","no-cache","no-store","only-if-cached","reload"],"type":"string"},"credentials":{"enum":["include","omit","same-origin"],"type":"string"},"headers":{"anyOf":[{"$ref":"#/definitions/Headers"},{"type":"array","items":{"type":"array","items":{"type":"string"}}},{"$ref":"#/definitions/Record"}]},"integrity":{"type":"string"},"keepalive":{"type":"boolean"},"method":{"type":"string"},"mode":{"enum":["cors","navigate","no-cors","same-origin"],"type":"string"},"redirect":{"enum":["error","follow","manual"],"type":"string"},"referrer":{"type":"string"},"referrerPolicy":{"enum":["","no-referrer","no-referrer-when-downgrade","origin","origin-when-cross-origin","same-origin","strict-origin","strict-origin-when-cross-origin","unsafe-url"],"type":"string"},"signal":{"anyOf":[{"$ref":"#/definitions/AbortSignal"},{"type":"null"}]},"window":{}},"additionalProperties":false},"ArrayBuffer":{"type":"object","properties":{"byteLength":{"type":"number"},"__@toStringTag":{"type":"string"}},"additionalProperties":false,"required":["__@toStringTag","byteLength"]},"ArrayBufferView":{"type":"object","properties":{"buffer":{"anyOf":[{"$ref":"#/definitions/ArrayBuffer"},{"$ref":"#/definitions/SharedArrayBuffer"}]},"byteLength":{"type":"number"},"byteOffset":{"type":"number"}},"additionalProperties":false,"required":["buffer","byteLength","byteOffset"]},"SharedArrayBuffer":{"type":"object","properties":{"byteLength":{"type":"number"},"__@species":{"$ref":"#/definitions/SharedArrayBuffer"},"__@toStringTag":{"type":"string","enum":["SharedArrayBuffer"]}},"additionalProperties":false,"required":["__@species","__@toStringTag","byteLength"]},"Blob":{"type":"object","properties":{"size":{"type":"number"},"type":{"type":"string"}},"additionalProperties":false,"required":["size","type"]},"FormData":{"type":"object","additionalProperties":false},"URLSearchParams":{"type":"object","additionalProperties":false},"ReadableStream":{"type":"object","properties":{"locked":{"type":"boolean"}},"additionalProperties":false,"required":["locked"]},"Headers":{"type":"object","additionalProperties":false},"Record":{"type":"object","additionalProperties":false},"AbortSignal":{"type":"object","properties":{"aborted":{"type":"boolean"},"onabort":{"anyOf":[{"type":"object","additionalProperties":false},{"type":"null"}]}},"additionalProperties":false,"required":["aborted","onabort"]},"RouteMatchCallback":{"description":"The \"match\" callback is used to determine if a `Route` should apply for a\nparticular URL and request. When matching occurs in response to a fetch\nevent from the client, the `event` object is also supplied. However, since\nthe match callback can be invoked outside of a fetch event, matching logic\nshould not assume the `event` object will always be available.\nIf the match callback returns a truthy value, the matching route's\n`RouteHandlerCallback` will be invoked immediately. If the value returned\nis a non-empty array or object, that value will be set on the handler's\n`options.params` argument.","additionalProperties":false,"typeof":"function"}},"$schema":"http://json-schema.org/draft-07/schema#"} diff --git a/packages/workbox-build/src/schema/WebpackGenerateSWOptions.json b/packages/workbox-build/src/schema/WebpackGenerateSWOptions.json index 5d0b74252..5a4c8626c 100644 --- a/packages/workbox-build/src/schema/WebpackGenerateSWOptions.json +++ b/packages/workbox-build/src/schema/WebpackGenerateSWOptions.json @@ -1 +1 @@ -{"additionalProperties":false,"type":"object","properties":{"additionalManifestEntries":{"type":"array","items":{"anyOf":[{"$ref":"#/definitions/ManifestEntry"},{"type":"string"}]}},"dontCacheBustURLsMatching":{"$ref":"#/definitions/RegExp"},"manifestTransforms":{"type":"array","items":{"typeof":"function"}},"maximumFileSizeToCacheInBytes":{"default":2097152,"type":"number"},"modifyURLPrefix":{"type":"object","additionalProperties":{"type":"string"}},"chunks":{"type":"array","items":{"type":"string"}},"exclude":{"default":"[/\\.map$/, /^manifest.*\\.js$/]","type":"array","items":{"anyOf":[{"$ref":"#/definitions/RegExp"},{"type":"string"},{"typeof":"function"}]}},"excludeChunks":{"type":"array","items":{"type":"string"}},"include":{"type":"array","items":{"anyOf":[{"$ref":"#/definitions/RegExp"},{"type":"string"},{"typeof":"function"}]}},"mode":{"default":"production","type":["null","string"]},"babelPresetEnvTargets":{"default":["chrome >= 56"],"type":"array","items":{"type":"string"}},"cacheId":{"type":["null","string"]},"cleanupOutdatedCaches":{"default":false,"type":"boolean"},"clientsClaim":{"default":false,"type":"boolean"},"directoryIndex":{"type":["null","string"]},"disableDevLogs":{"default":false,"type":"boolean"},"ignoreURLParametersMatching":{"type":"array","items":{"$ref":"#/definitions/RegExp"}},"importScripts":{"type":"array","items":{"type":"string"}},"inlineWorkboxRuntime":{"default":false,"type":"boolean"},"navigateFallback":{"default":null,"type":["null","string"]},"navigateFallbackAllowlist":{"type":"array","items":{"$ref":"#/definitions/RegExp"}},"navigateFallbackDenylist":{"type":"array","items":{"$ref":"#/definitions/RegExp"}},"navigationPreload":{"description":"navigationPreload is only valid when runtimeCaching is configured. However,\nthis can't be expressed via TypeScript, so it's enforced via runtime logic.","default":false,"type":"boolean"},"offlineGoogleAnalytics":{"default":false,"anyOf":[{"$ref":"#/definitions/GoogleAnalyticsInitializeOptions"},{"type":"boolean"}]},"runtimeCaching":{"type":"array","items":{"$ref":"#/definitions/RuntimeCaching"}},"skipWaiting":{"default":false,"type":"boolean"},"sourcemap":{"default":true,"type":"boolean"},"importScriptsViaChunks":{"type":"array","items":{"type":"string"}},"swDest":{"default":"service-worker.js","type":"string"}},"definitions":{"ManifestEntry":{"type":"object","properties":{"integrity":{"type":"string"},"revision":{"type":["null","string"]},"url":{"type":"string"}},"additionalProperties":false,"required":["revision","url"]},"RegExp":{"type":"object","properties":{"source":{"type":"string"},"global":{"type":"boolean"},"ignoreCase":{"type":"boolean"},"multiline":{"type":"boolean"},"lastIndex":{"type":"number"},"flags":{"type":"string"},"sticky":{"type":"boolean"},"unicode":{"type":"boolean"},"dotAll":{"type":"boolean"}},"additionalProperties":false,"required":["dotAll","flags","global","ignoreCase","lastIndex","multiline","source","sticky","unicode"]},"GoogleAnalyticsInitializeOptions":{"type":"object","properties":{"cacheName":{"type":"string"},"parameterOverrides":{"type":"object","additionalProperties":{"type":"string"}},"hitFilter":{"type":"object","additionalProperties":false}},"additionalProperties":false},"RuntimeCaching":{"type":"object","properties":{"handler":{"anyOf":[{"$ref":"#/definitions/RouteHandlerCallback"},{"$ref":"#/definitions/RouteHandlerObject"},{"enum":["CacheFirst","CacheOnly","NetworkFirst","NetworkOnly","StaleWhileRevalidate"],"type":"string"}]},"method":{"enum":["DELETE","GET","HEAD","PATCH","POST","PUT"],"type":"string"},"options":{"type":"object","properties":{"backgroundSync":{"type":"object","properties":{"name":{"type":"string"},"options":{"$ref":"#/definitions/QueueOptions"}},"additionalProperties":false,"required":["name"]},"broadcastUpdate":{"type":"object","properties":{"channelName":{"type":"string"},"options":{"$ref":"#/definitions/BroadcastCacheUpdateOptions"}},"additionalProperties":false,"required":["options"]},"cacheableResponse":{"$ref":"#/definitions/CacheableResponseOptions"},"cacheName":{"type":["null","string"]},"expiration":{"$ref":"#/definitions/ExpirationPluginOptions"},"networkTimeoutSeconds":{"type":"number"},"plugins":{"type":"array","items":{"$ref":"#/definitions/WorkboxPlugin"}},"precacheFallback":{"type":"object","properties":{"fallbackURL":{"type":"string"}},"additionalProperties":false,"required":["fallbackURL"]},"fetchOptions":{"$ref":"#/definitions/RequestInit"},"matchOptions":{"$ref":"#/definitions/CacheQueryOptions"}},"additionalProperties":false},"urlPattern":{"anyOf":[{"$ref":"#/definitions/RegExp"},{"$ref":"#/definitions/RouteMatchCallback"},{"type":"string"}]}},"additionalProperties":false,"required":["handler","urlPattern"]},"RouteHandlerCallback":{"description":"The \"handler\" callback is invoked whenever a `Router` matches a URL/Request\nto a `Route` via its `RouteMatchCallback`. This handler callback should\nreturn a `Promise` that resolves with a `Response`.\n\nIf a non-empty array or object is returned by the `RouteMatchCallback` it\nwill be passed in as this handler's `options.params` argument.","type":"object","additionalProperties":false},"RouteHandlerObject":{"description":"An object with a `handle` method of type `RouteHandlerCallback`.\n\nA `Route` object can be created with either an `RouteHandlerCallback`\nfunction or this `RouteHandler` object. The benefit of the `RouteHandler`\nis it can be extended (as is done by the `workbox-strategies` package).","type":"object","properties":{"handle":{"$ref":"#/definitions/RouteHandlerCallback"}},"additionalProperties":false,"required":["handle"]},"QueueOptions":{"type":"object","properties":{"onSync":{"$ref":"#/definitions/OnSyncCallback"},"maxRetentionTime":{"type":"number"}},"additionalProperties":false},"OnSyncCallback":{"type":"object","additionalProperties":false},"BroadcastCacheUpdateOptions":{"type":"object","properties":{"headersToCheck":{"type":"array","items":{"type":"string"}},"generatePayload":{"type":"object","additionalProperties":false}},"additionalProperties":false},"CacheableResponseOptions":{"type":"object","properties":{"statuses":{"type":"array","items":{"type":"number"}},"headers":{"type":"object","additionalProperties":{"type":"string"}}},"additionalProperties":false},"ExpirationPluginOptions":{"type":"object","properties":{"maxEntries":{"type":"number"},"maxAgeSeconds":{"type":"number"},"matchOptions":{"$ref":"#/definitions/CacheQueryOptions"},"purgeOnQuotaError":{"type":"boolean"}},"additionalProperties":false},"CacheQueryOptions":{"type":"object","properties":{"ignoreMethod":{"type":"boolean"},"ignoreSearch":{"type":"boolean"},"ignoreVary":{"type":"boolean"}},"additionalProperties":false},"WorkboxPlugin":{"description":"An object with optional lifecycle callback properties for the fetch and\ncache operations.","type":"object","properties":{"cacheDidUpdate":{"$ref":"#/definitions/CacheDidUpdateCallback"},"cachedResponseWillBeUsed":{"$ref":"#/definitions/CachedResponseWillBeUsedCallback"},"cacheKeyWillBeUsed":{"$ref":"#/definitions/CacheKeyWillBeUsedCallback"},"cacheWillUpdate":{"$ref":"#/definitions/CacheWillUpdateCallback"},"fetchDidFail":{"$ref":"#/definitions/FetchDidFailCallback"},"fetchDidSucceed":{"$ref":"#/definitions/FetchDidSucceedCallback"},"handlerDidComplete":{"$ref":"#/definitions/HandlerDidCompleteCallback"},"handlerDidError":{"$ref":"#/definitions/HandlerDidErrorCallback"},"handlerDidRespond":{"$ref":"#/definitions/HandlerDidRespondCallback"},"handlerWillRespond":{"$ref":"#/definitions/HandlerWillRespondCallback"},"handlerWillStart":{"$ref":"#/definitions/HandlerWillStartCallback"},"requestWillFetch":{"$ref":"#/definitions/RequestWillFetchCallback"}},"additionalProperties":false},"CacheDidUpdateCallback":{"type":"object","additionalProperties":false},"CachedResponseWillBeUsedCallback":{"type":"object","additionalProperties":false},"CacheKeyWillBeUsedCallback":{"type":"object","additionalProperties":false},"CacheWillUpdateCallback":{"type":"object","additionalProperties":false},"FetchDidFailCallback":{"type":"object","additionalProperties":false},"FetchDidSucceedCallback":{"type":"object","additionalProperties":false},"HandlerDidCompleteCallback":{"type":"object","additionalProperties":false},"HandlerDidErrorCallback":{"type":"object","additionalProperties":false},"HandlerDidRespondCallback":{"type":"object","additionalProperties":false},"HandlerWillRespondCallback":{"type":"object","additionalProperties":false},"HandlerWillStartCallback":{"type":"object","additionalProperties":false},"RequestWillFetchCallback":{"type":"object","additionalProperties":false},"RequestInit":{"type":"object","properties":{"body":{"anyOf":[{"$ref":"#/definitions/ArrayBuffer"},{"$ref":"#/definitions/ArrayBufferView"},{"$ref":"#/definitions/Blob"},{"$ref":"#/definitions/FormData"},{"$ref":"#/definitions/URLSearchParams"},{"$ref":"#/definitions/ReadableStream"},{"type":["null","string"]}]},"cache":{"enum":["default","force-cache","no-cache","no-store","only-if-cached","reload"],"type":"string"},"credentials":{"enum":["include","omit","same-origin"],"type":"string"},"headers":{"anyOf":[{"$ref":"#/definitions/Headers"},{"type":"array","items":{"type":"array","items":{"type":"string"}}},{"$ref":"#/definitions/Record"}]},"integrity":{"type":"string"},"keepalive":{"type":"boolean"},"method":{"type":"string"},"mode":{"enum":["cors","navigate","no-cors","same-origin"],"type":"string"},"redirect":{"enum":["error","follow","manual"],"type":"string"},"referrer":{"type":"string"},"referrerPolicy":{"enum":["","no-referrer","no-referrer-when-downgrade","origin","origin-when-cross-origin","same-origin","strict-origin","strict-origin-when-cross-origin","unsafe-url"],"type":"string"},"signal":{"anyOf":[{"$ref":"#/definitions/AbortSignal"},{"type":"null"}]},"window":{}},"additionalProperties":false},"ArrayBuffer":{"type":"object","properties":{"byteLength":{"type":"number"},"__@toStringTag":{"type":"string"}},"additionalProperties":false,"required":["__@toStringTag","byteLength"]},"ArrayBufferView":{"type":"object","properties":{"buffer":{"anyOf":[{"$ref":"#/definitions/ArrayBuffer"},{"$ref":"#/definitions/SharedArrayBuffer"}]},"byteLength":{"type":"number"},"byteOffset":{"type":"number"}},"additionalProperties":false,"required":["buffer","byteLength","byteOffset"]},"SharedArrayBuffer":{"type":"object","properties":{"byteLength":{"type":"number"},"__@species":{"$ref":"#/definitions/SharedArrayBuffer"},"__@toStringTag":{"type":"string","enum":["SharedArrayBuffer"]}},"additionalProperties":false,"required":["__@species","__@toStringTag","byteLength"]},"Blob":{"type":"object","properties":{"size":{"type":"number"},"type":{"type":"string"}},"additionalProperties":false,"required":["size","type"]},"FormData":{"type":"object","additionalProperties":false},"URLSearchParams":{"type":"object","additionalProperties":false},"ReadableStream":{"type":"object","properties":{"locked":{"type":"boolean"}},"additionalProperties":false,"required":["locked"]},"Headers":{"type":"object","additionalProperties":false},"Record":{"type":"object","additionalProperties":false},"AbortSignal":{"type":"object","properties":{"aborted":{"type":"boolean"},"onabort":{"anyOf":[{"type":"object","additionalProperties":false},{"type":"null"}]}},"additionalProperties":false,"required":["aborted","onabort"]},"RouteMatchCallback":{"description":"The \"match\" callback is used to determine if a `Route` should apply for a\nparticular URL and request. When matching occurs in response to a fetch\nevent from the client, the `event` object is also supplied. However, since\nthe match callback can be invoked outside of a fetch event, matching logic\nshould not assume the `event` object will always be available.\nIf the match callback returns a truthy value, the matching route's\n`RouteHandlerCallback` will be invoked immediately. If the value returned\nis a non-empty array or object, that value will be set on the handler's\n`options.params` argument.","type":"object","additionalProperties":false}},"$schema":"http://json-schema.org/draft-07/schema#"} +{"additionalProperties":false,"type":"object","properties":{"additionalManifestEntries":{"type":"array","items":{"anyOf":[{"$ref":"#/definitions/ManifestEntry"},{"type":"string"}]}},"dontCacheBustURLsMatching":{"$ref":"#/definitions/RegExp"},"manifestTransforms":{"type":"array","items":{"typeof":"function"}},"maximumFileSizeToCacheInBytes":{"default":2097152,"type":"number"},"modifyURLPrefix":{"type":"object","additionalProperties":{"type":"string"}},"chunks":{"type":"array","items":{"type":"string"}},"exclude":{"type":"array","items":{"anyOf":[{"$ref":"#/definitions/RegExp"},{"type":"string"},{"typeof":"function"}]}},"excludeChunks":{"type":"array","items":{"type":"string"}},"include":{"type":"array","items":{"anyOf":[{"$ref":"#/definitions/RegExp"},{"type":"string"},{"typeof":"function"}]}},"mode":{"default":"production","type":["null","string"]},"babelPresetEnvTargets":{"default":["chrome >= 56"],"type":"array","items":{"type":"string"}},"cacheId":{"type":["null","string"]},"cleanupOutdatedCaches":{"default":false,"type":"boolean"},"clientsClaim":{"default":false,"type":"boolean"},"directoryIndex":{"type":["null","string"]},"disableDevLogs":{"default":false,"type":"boolean"},"ignoreURLParametersMatching":{"type":"array","items":{"$ref":"#/definitions/RegExp"}},"importScripts":{"type":"array","items":{"type":"string"}},"inlineWorkboxRuntime":{"default":false,"type":"boolean"},"navigateFallback":{"default":null,"type":["null","string"]},"navigateFallbackAllowlist":{"type":"array","items":{"$ref":"#/definitions/RegExp"}},"navigateFallbackDenylist":{"type":"array","items":{"$ref":"#/definitions/RegExp"}},"navigationPreload":{"description":"navigationPreload is only valid when runtimeCaching is configured. However,\nthis can't be expressed via TypeScript, so it's enforced via runtime logic.","default":false,"type":"boolean"},"offlineGoogleAnalytics":{"default":false,"anyOf":[{"$ref":"#/definitions/GoogleAnalyticsInitializeOptions"},{"type":"boolean"}]},"runtimeCaching":{"type":"array","items":{"$ref":"#/definitions/RuntimeCaching"}},"skipWaiting":{"default":false,"type":"boolean"},"sourcemap":{"default":true,"type":"boolean"},"importScriptsViaChunks":{"type":"array","items":{"type":"string"}},"swDest":{"default":"service-worker.js","type":"string"}},"definitions":{"ManifestEntry":{"type":"object","properties":{"integrity":{"type":"string"},"revision":{"type":["null","string"]},"url":{"type":"string"}},"additionalProperties":false,"required":["revision","url"]},"RegExp":{"type":"object","properties":{"source":{"type":"string"},"global":{"type":"boolean"},"ignoreCase":{"type":"boolean"},"multiline":{"type":"boolean"},"lastIndex":{"type":"number"},"flags":{"type":"string"},"sticky":{"type":"boolean"},"unicode":{"type":"boolean"},"dotAll":{"type":"boolean"}},"additionalProperties":false,"required":["dotAll","flags","global","ignoreCase","lastIndex","multiline","source","sticky","unicode"]},"GoogleAnalyticsInitializeOptions":{"type":"object","properties":{"cacheName":{"type":"string"},"parameterOverrides":{"type":"object","additionalProperties":{"type":"string"}},"hitFilter":{"type":"object","additionalProperties":false}},"additionalProperties":false},"RuntimeCaching":{"type":"object","properties":{"handler":{"anyOf":[{"$ref":"#/definitions/RouteHandlerCallback"},{"$ref":"#/definitions/RouteHandlerObject"},{"enum":["CacheFirst","CacheOnly","NetworkFirst","NetworkOnly","StaleWhileRevalidate"],"type":"string"}]},"method":{"enum":["DELETE","GET","HEAD","PATCH","POST","PUT"],"type":"string"},"options":{"type":"object","properties":{"backgroundSync":{"type":"object","properties":{"name":{"type":"string"},"options":{"$ref":"#/definitions/QueueOptions"}},"additionalProperties":false,"required":["name"]},"broadcastUpdate":{"type":"object","properties":{"channelName":{"type":"string"},"options":{"$ref":"#/definitions/BroadcastCacheUpdateOptions"}},"additionalProperties":false,"required":["options"]},"cacheableResponse":{"$ref":"#/definitions/CacheableResponseOptions"},"cacheName":{"type":["null","string"]},"expiration":{"$ref":"#/definitions/ExpirationPluginOptions"},"networkTimeoutSeconds":{"type":"number"},"plugins":{"type":"array","items":{"$ref":"#/definitions/WorkboxPlugin"}},"precacheFallback":{"type":"object","properties":{"fallbackURL":{"type":"string"}},"additionalProperties":false,"required":["fallbackURL"]},"fetchOptions":{"$ref":"#/definitions/RequestInit"},"matchOptions":{"$ref":"#/definitions/CacheQueryOptions"}},"additionalProperties":false},"urlPattern":{"anyOf":[{"$ref":"#/definitions/RegExp"},{"$ref":"#/definitions/RouteMatchCallback"},{"type":"string"}]}},"additionalProperties":false,"required":["handler","urlPattern"]},"RouteHandlerCallback":{"description":"The \"handler\" callback is invoked whenever a `Router` matches a URL/Request\nto a `Route` via its `RouteMatchCallback`. This handler callback should\nreturn a `Promise` that resolves with a `Response`.\n\nIf a non-empty array or object is returned by the `RouteMatchCallback` it\nwill be passed in as this handler's `options.params` argument.","type":"object","additionalProperties":false},"RouteHandlerObject":{"description":"An object with a `handle` method of type `RouteHandlerCallback`.\n\nA `Route` object can be created with either an `RouteHandlerCallback`\nfunction or this `RouteHandler` object. The benefit of the `RouteHandler`\nis it can be extended (as is done by the `workbox-strategies` package).","type":"object","properties":{"handle":{"$ref":"#/definitions/RouteHandlerCallback"}},"additionalProperties":false,"required":["handle"]},"QueueOptions":{"type":"object","properties":{"onSync":{"$ref":"#/definitions/OnSyncCallback"},"maxRetentionTime":{"type":"number"}},"additionalProperties":false},"OnSyncCallback":{"type":"object","additionalProperties":false},"BroadcastCacheUpdateOptions":{"type":"object","properties":{"headersToCheck":{"type":"array","items":{"type":"string"}},"generatePayload":{"type":"object","additionalProperties":false}},"additionalProperties":false},"CacheableResponseOptions":{"type":"object","properties":{"statuses":{"type":"array","items":{"type":"number"}},"headers":{"type":"object","additionalProperties":{"type":"string"}}},"additionalProperties":false},"ExpirationPluginOptions":{"type":"object","properties":{"maxEntries":{"type":"number"},"maxAgeSeconds":{"type":"number"},"matchOptions":{"$ref":"#/definitions/CacheQueryOptions"},"purgeOnQuotaError":{"type":"boolean"}},"additionalProperties":false},"CacheQueryOptions":{"type":"object","properties":{"ignoreMethod":{"type":"boolean"},"ignoreSearch":{"type":"boolean"},"ignoreVary":{"type":"boolean"}},"additionalProperties":false},"WorkboxPlugin":{"description":"An object with optional lifecycle callback properties for the fetch and\ncache operations.","type":"object","properties":{"cacheDidUpdate":{"$ref":"#/definitions/CacheDidUpdateCallback"},"cachedResponseWillBeUsed":{"$ref":"#/definitions/CachedResponseWillBeUsedCallback"},"cacheKeyWillBeUsed":{"$ref":"#/definitions/CacheKeyWillBeUsedCallback"},"cacheWillUpdate":{"$ref":"#/definitions/CacheWillUpdateCallback"},"fetchDidFail":{"$ref":"#/definitions/FetchDidFailCallback"},"fetchDidSucceed":{"$ref":"#/definitions/FetchDidSucceedCallback"},"handlerDidComplete":{"$ref":"#/definitions/HandlerDidCompleteCallback"},"handlerDidError":{"$ref":"#/definitions/HandlerDidErrorCallback"},"handlerDidRespond":{"$ref":"#/definitions/HandlerDidRespondCallback"},"handlerWillRespond":{"$ref":"#/definitions/HandlerWillRespondCallback"},"handlerWillStart":{"$ref":"#/definitions/HandlerWillStartCallback"},"requestWillFetch":{"$ref":"#/definitions/RequestWillFetchCallback"}},"additionalProperties":false},"CacheDidUpdateCallback":{"type":"object","additionalProperties":false},"CachedResponseWillBeUsedCallback":{"type":"object","additionalProperties":false},"CacheKeyWillBeUsedCallback":{"type":"object","additionalProperties":false},"CacheWillUpdateCallback":{"type":"object","additionalProperties":false},"FetchDidFailCallback":{"type":"object","additionalProperties":false},"FetchDidSucceedCallback":{"type":"object","additionalProperties":false},"HandlerDidCompleteCallback":{"type":"object","additionalProperties":false},"HandlerDidErrorCallback":{"type":"object","additionalProperties":false},"HandlerDidRespondCallback":{"type":"object","additionalProperties":false},"HandlerWillRespondCallback":{"type":"object","additionalProperties":false},"HandlerWillStartCallback":{"type":"object","additionalProperties":false},"RequestWillFetchCallback":{"type":"object","additionalProperties":false},"RequestInit":{"type":"object","properties":{"body":{"anyOf":[{"$ref":"#/definitions/ArrayBuffer"},{"$ref":"#/definitions/ArrayBufferView"},{"$ref":"#/definitions/Blob"},{"$ref":"#/definitions/FormData"},{"$ref":"#/definitions/URLSearchParams"},{"$ref":"#/definitions/ReadableStream"},{"type":["null","string"]}]},"cache":{"enum":["default","force-cache","no-cache","no-store","only-if-cached","reload"],"type":"string"},"credentials":{"enum":["include","omit","same-origin"],"type":"string"},"headers":{"anyOf":[{"$ref":"#/definitions/Headers"},{"type":"array","items":{"type":"array","items":{"type":"string"}}},{"$ref":"#/definitions/Record"}]},"integrity":{"type":"string"},"keepalive":{"type":"boolean"},"method":{"type":"string"},"mode":{"enum":["cors","navigate","no-cors","same-origin"],"type":"string"},"redirect":{"enum":["error","follow","manual"],"type":"string"},"referrer":{"type":"string"},"referrerPolicy":{"enum":["","no-referrer","no-referrer-when-downgrade","origin","origin-when-cross-origin","same-origin","strict-origin","strict-origin-when-cross-origin","unsafe-url"],"type":"string"},"signal":{"anyOf":[{"$ref":"#/definitions/AbortSignal"},{"type":"null"}]},"window":{}},"additionalProperties":false},"ArrayBuffer":{"type":"object","properties":{"byteLength":{"type":"number"},"__@toStringTag":{"type":"string"}},"additionalProperties":false,"required":["__@toStringTag","byteLength"]},"ArrayBufferView":{"type":"object","properties":{"buffer":{"anyOf":[{"$ref":"#/definitions/ArrayBuffer"},{"$ref":"#/definitions/SharedArrayBuffer"}]},"byteLength":{"type":"number"},"byteOffset":{"type":"number"}},"additionalProperties":false,"required":["buffer","byteLength","byteOffset"]},"SharedArrayBuffer":{"type":"object","properties":{"byteLength":{"type":"number"},"__@species":{"$ref":"#/definitions/SharedArrayBuffer"},"__@toStringTag":{"type":"string","enum":["SharedArrayBuffer"]}},"additionalProperties":false,"required":["__@species","__@toStringTag","byteLength"]},"Blob":{"type":"object","properties":{"size":{"type":"number"},"type":{"type":"string"}},"additionalProperties":false,"required":["size","type"]},"FormData":{"type":"object","additionalProperties":false},"URLSearchParams":{"type":"object","additionalProperties":false},"ReadableStream":{"type":"object","properties":{"locked":{"type":"boolean"}},"additionalProperties":false,"required":["locked"]},"Headers":{"type":"object","additionalProperties":false},"Record":{"type":"object","additionalProperties":false},"AbortSignal":{"type":"object","properties":{"aborted":{"type":"boolean"},"onabort":{"anyOf":[{"type":"object","additionalProperties":false},{"type":"null"}]}},"additionalProperties":false,"required":["aborted","onabort"]},"RouteMatchCallback":{"description":"The \"match\" callback is used to determine if a `Route` should apply for a\nparticular URL and request. When matching occurs in response to a fetch\nevent from the client, the `event` object is also supplied. However, since\nthe match callback can be invoked outside of a fetch event, matching logic\nshould not assume the `event` object will always be available.\nIf the match callback returns a truthy value, the matching route's\n`RouteHandlerCallback` will be invoked immediately. If the value returned\nis a non-empty array or object, that value will be set on the handler's\n`options.params` argument.","additionalProperties":false,"typeof":"function"}},"$schema":"http://json-schema.org/draft-07/schema#"} diff --git a/packages/workbox-build/src/schema/WebpackInjectManifestOptions.json b/packages/workbox-build/src/schema/WebpackInjectManifestOptions.json index 773947114..eae42863d 100644 --- a/packages/workbox-build/src/schema/WebpackInjectManifestOptions.json +++ b/packages/workbox-build/src/schema/WebpackInjectManifestOptions.json @@ -1 +1 @@ -{"additionalProperties":false,"type":"object","properties":{"additionalManifestEntries":{"type":"array","items":{"anyOf":[{"$ref":"#/definitions/ManifestEntry"},{"type":"string"}]}},"dontCacheBustURLsMatching":{"$ref":"#/definitions/RegExp"},"manifestTransforms":{"type":"array","items":{"typeof":"function"}},"maximumFileSizeToCacheInBytes":{"default":2097152,"type":"number"},"modifyURLPrefix":{"type":"object","additionalProperties":{"type":"string"}},"chunks":{"type":"array","items":{"type":"string"}},"exclude":{"default":"[/\\.map$/, /^manifest.*\\.js$/]","type":"array","items":{"anyOf":[{"$ref":"#/definitions/RegExp"},{"type":"string"},{"typeof":"function"}]}},"excludeChunks":{"type":"array","items":{"type":"string"}},"include":{"type":"array","items":{"anyOf":[{"$ref":"#/definitions/RegExp"},{"type":"string"},{"typeof":"function"}]}},"mode":{"type":["null","string"]},"injectionPoint":{"default":"self.__WB_MANIFEST","type":"string"},"swSrc":{"type":"string"},"compileSrc":{"default":true,"type":"boolean"},"swDest":{"type":"string"},"webpackCompilationPlugins":{"type":"array","items":{}}},"required":["swSrc"],"definitions":{"ManifestEntry":{"type":"object","properties":{"integrity":{"type":"string"},"revision":{"type":["null","string"]},"url":{"type":"string"}},"additionalProperties":false,"required":["revision","url"]},"RegExp":{"type":"object","properties":{"source":{"type":"string"},"global":{"type":"boolean"},"ignoreCase":{"type":"boolean"},"multiline":{"type":"boolean"},"lastIndex":{"type":"number"},"flags":{"type":"string"},"sticky":{"type":"boolean"},"unicode":{"type":"boolean"},"dotAll":{"type":"boolean"}},"additionalProperties":false,"required":["dotAll","flags","global","ignoreCase","lastIndex","multiline","source","sticky","unicode"]},"GoogleAnalyticsInitializeOptions":{"type":"object","properties":{"cacheName":{"type":"string"},"parameterOverrides":{"type":"object","additionalProperties":{"type":"string"}},"hitFilter":{"type":"object","additionalProperties":false}},"additionalProperties":false},"RuntimeCaching":{"type":"object","properties":{"handler":{"anyOf":[{"$ref":"#/definitions/RouteHandlerCallback"},{"$ref":"#/definitions/RouteHandlerObject"},{"enum":["CacheFirst","CacheOnly","NetworkFirst","NetworkOnly","StaleWhileRevalidate"],"type":"string"}]},"method":{"enum":["DELETE","GET","HEAD","PATCH","POST","PUT"],"type":"string"},"options":{"type":"object","properties":{"backgroundSync":{"type":"object","properties":{"name":{"type":"string"},"options":{"$ref":"#/definitions/QueueOptions"}},"additionalProperties":false,"required":["name"]},"broadcastUpdate":{"type":"object","properties":{"channelName":{"type":"string"},"options":{"$ref":"#/definitions/BroadcastCacheUpdateOptions"}},"additionalProperties":false,"required":["options"]},"cacheableResponse":{"$ref":"#/definitions/CacheableResponseOptions"},"cacheName":{"type":["null","string"]},"expiration":{"$ref":"#/definitions/ExpirationPluginOptions"},"networkTimeoutSeconds":{"type":"number"},"plugins":{"type":"array","items":{"$ref":"#/definitions/WorkboxPlugin"}},"precacheFallback":{"type":"object","properties":{"fallbackURL":{"type":"string"}},"additionalProperties":false,"required":["fallbackURL"]},"fetchOptions":{"$ref":"#/definitions/RequestInit"},"matchOptions":{"$ref":"#/definitions/CacheQueryOptions"}},"additionalProperties":false},"urlPattern":{"anyOf":[{"$ref":"#/definitions/RegExp"},{"$ref":"#/definitions/RouteMatchCallback"},{"type":"string"}]}},"additionalProperties":false,"required":["handler","urlPattern"]},"RouteHandlerCallback":{"description":"The \"handler\" callback is invoked whenever a `Router` matches a URL/Request\nto a `Route` via its `RouteMatchCallback`. This handler callback should\nreturn a `Promise` that resolves with a `Response`.\n\nIf a non-empty array or object is returned by the `RouteMatchCallback` it\nwill be passed in as this handler's `options.params` argument.","type":"object","additionalProperties":false},"RouteHandlerObject":{"description":"An object with a `handle` method of type `RouteHandlerCallback`.\n\nA `Route` object can be created with either an `RouteHandlerCallback`\nfunction or this `RouteHandler` object. The benefit of the `RouteHandler`\nis it can be extended (as is done by the `workbox-strategies` package).","type":"object","properties":{"handle":{"$ref":"#/definitions/RouteHandlerCallback"}},"additionalProperties":false,"required":["handle"]},"QueueOptions":{"type":"object","properties":{"onSync":{"$ref":"#/definitions/OnSyncCallback"},"maxRetentionTime":{"type":"number"}},"additionalProperties":false},"OnSyncCallback":{"type":"object","additionalProperties":false},"BroadcastCacheUpdateOptions":{"type":"object","properties":{"headersToCheck":{"type":"array","items":{"type":"string"}},"generatePayload":{"type":"object","additionalProperties":false}},"additionalProperties":false},"CacheableResponseOptions":{"type":"object","properties":{"statuses":{"type":"array","items":{"type":"number"}},"headers":{"type":"object","additionalProperties":{"type":"string"}}},"additionalProperties":false},"ExpirationPluginOptions":{"type":"object","properties":{"maxEntries":{"type":"number"},"maxAgeSeconds":{"type":"number"},"matchOptions":{"$ref":"#/definitions/CacheQueryOptions"},"purgeOnQuotaError":{"type":"boolean"}},"additionalProperties":false},"CacheQueryOptions":{"type":"object","properties":{"ignoreMethod":{"type":"boolean"},"ignoreSearch":{"type":"boolean"},"ignoreVary":{"type":"boolean"}},"additionalProperties":false},"WorkboxPlugin":{"description":"An object with optional lifecycle callback properties for the fetch and\ncache operations.","type":"object","properties":{"cacheDidUpdate":{"$ref":"#/definitions/CacheDidUpdateCallback"},"cachedResponseWillBeUsed":{"$ref":"#/definitions/CachedResponseWillBeUsedCallback"},"cacheKeyWillBeUsed":{"$ref":"#/definitions/CacheKeyWillBeUsedCallback"},"cacheWillUpdate":{"$ref":"#/definitions/CacheWillUpdateCallback"},"fetchDidFail":{"$ref":"#/definitions/FetchDidFailCallback"},"fetchDidSucceed":{"$ref":"#/definitions/FetchDidSucceedCallback"},"handlerDidComplete":{"$ref":"#/definitions/HandlerDidCompleteCallback"},"handlerDidError":{"$ref":"#/definitions/HandlerDidErrorCallback"},"handlerDidRespond":{"$ref":"#/definitions/HandlerDidRespondCallback"},"handlerWillRespond":{"$ref":"#/definitions/HandlerWillRespondCallback"},"handlerWillStart":{"$ref":"#/definitions/HandlerWillStartCallback"},"requestWillFetch":{"$ref":"#/definitions/RequestWillFetchCallback"}},"additionalProperties":false},"CacheDidUpdateCallback":{"type":"object","additionalProperties":false},"CachedResponseWillBeUsedCallback":{"type":"object","additionalProperties":false},"CacheKeyWillBeUsedCallback":{"type":"object","additionalProperties":false},"CacheWillUpdateCallback":{"type":"object","additionalProperties":false},"FetchDidFailCallback":{"type":"object","additionalProperties":false},"FetchDidSucceedCallback":{"type":"object","additionalProperties":false},"HandlerDidCompleteCallback":{"type":"object","additionalProperties":false},"HandlerDidErrorCallback":{"type":"object","additionalProperties":false},"HandlerDidRespondCallback":{"type":"object","additionalProperties":false},"HandlerWillRespondCallback":{"type":"object","additionalProperties":false},"HandlerWillStartCallback":{"type":"object","additionalProperties":false},"RequestWillFetchCallback":{"type":"object","additionalProperties":false},"RequestInit":{"type":"object","properties":{"body":{"anyOf":[{"$ref":"#/definitions/ArrayBuffer"},{"$ref":"#/definitions/ArrayBufferView"},{"$ref":"#/definitions/Blob"},{"$ref":"#/definitions/FormData"},{"$ref":"#/definitions/URLSearchParams"},{"$ref":"#/definitions/ReadableStream"},{"type":["null","string"]}]},"cache":{"enum":["default","force-cache","no-cache","no-store","only-if-cached","reload"],"type":"string"},"credentials":{"enum":["include","omit","same-origin"],"type":"string"},"headers":{"anyOf":[{"$ref":"#/definitions/Headers"},{"type":"array","items":{"type":"array","items":{"type":"string"}}},{"$ref":"#/definitions/Record"}]},"integrity":{"type":"string"},"keepalive":{"type":"boolean"},"method":{"type":"string"},"mode":{"enum":["cors","navigate","no-cors","same-origin"],"type":"string"},"redirect":{"enum":["error","follow","manual"],"type":"string"},"referrer":{"type":"string"},"referrerPolicy":{"enum":["","no-referrer","no-referrer-when-downgrade","origin","origin-when-cross-origin","same-origin","strict-origin","strict-origin-when-cross-origin","unsafe-url"],"type":"string"},"signal":{"anyOf":[{"$ref":"#/definitions/AbortSignal"},{"type":"null"}]},"window":{}},"additionalProperties":false},"ArrayBuffer":{"type":"object","properties":{"byteLength":{"type":"number"},"__@toStringTag":{"type":"string"}},"additionalProperties":false,"required":["__@toStringTag","byteLength"]},"ArrayBufferView":{"type":"object","properties":{"buffer":{"anyOf":[{"$ref":"#/definitions/ArrayBuffer"},{"$ref":"#/definitions/SharedArrayBuffer"}]},"byteLength":{"type":"number"},"byteOffset":{"type":"number"}},"additionalProperties":false,"required":["buffer","byteLength","byteOffset"]},"SharedArrayBuffer":{"type":"object","properties":{"byteLength":{"type":"number"},"__@species":{"$ref":"#/definitions/SharedArrayBuffer"},"__@toStringTag":{"type":"string","enum":["SharedArrayBuffer"]}},"additionalProperties":false,"required":["__@species","__@toStringTag","byteLength"]},"Blob":{"type":"object","properties":{"size":{"type":"number"},"type":{"type":"string"}},"additionalProperties":false,"required":["size","type"]},"FormData":{"type":"object","additionalProperties":false},"URLSearchParams":{"type":"object","additionalProperties":false},"ReadableStream":{"type":"object","properties":{"locked":{"type":"boolean"}},"additionalProperties":false,"required":["locked"]},"Headers":{"type":"object","additionalProperties":false},"Record":{"type":"object","additionalProperties":false},"AbortSignal":{"type":"object","properties":{"aborted":{"type":"boolean"},"onabort":{"anyOf":[{"type":"object","additionalProperties":false},{"type":"null"}]}},"additionalProperties":false,"required":["aborted","onabort"]},"RouteMatchCallback":{"description":"The \"match\" callback is used to determine if a `Route` should apply for a\nparticular URL and request. When matching occurs in response to a fetch\nevent from the client, the `event` object is also supplied. However, since\nthe match callback can be invoked outside of a fetch event, matching logic\nshould not assume the `event` object will always be available.\nIf the match callback returns a truthy value, the matching route's\n`RouteHandlerCallback` will be invoked immediately. If the value returned\nis a non-empty array or object, that value will be set on the handler's\n`options.params` argument.","type":"object","additionalProperties":false}},"$schema":"http://json-schema.org/draft-07/schema#"} +{"additionalProperties":false,"type":"object","properties":{"additionalManifestEntries":{"type":"array","items":{"anyOf":[{"$ref":"#/definitions/ManifestEntry"},{"type":"string"}]}},"dontCacheBustURLsMatching":{"$ref":"#/definitions/RegExp"},"manifestTransforms":{"type":"array","items":{"typeof":"function"}},"maximumFileSizeToCacheInBytes":{"default":2097152,"type":"number"},"modifyURLPrefix":{"type":"object","additionalProperties":{"type":"string"}},"chunks":{"type":"array","items":{"type":"string"}},"exclude":{"type":"array","items":{"anyOf":[{"$ref":"#/definitions/RegExp"},{"type":"string"},{"typeof":"function"}]}},"excludeChunks":{"type":"array","items":{"type":"string"}},"include":{"type":"array","items":{"anyOf":[{"$ref":"#/definitions/RegExp"},{"type":"string"},{"typeof":"function"}]}},"mode":{"type":["null","string"]},"injectionPoint":{"default":"self.__WB_MANIFEST","type":"string"},"swSrc":{"type":"string"},"compileSrc":{"default":true,"type":"boolean"},"swDest":{"type":"string"},"webpackCompilationPlugins":{"type":"array","items":{}}},"required":["swSrc"],"definitions":{"ManifestEntry":{"type":"object","properties":{"integrity":{"type":"string"},"revision":{"type":["null","string"]},"url":{"type":"string"}},"additionalProperties":false,"required":["revision","url"]},"RegExp":{"type":"object","properties":{"source":{"type":"string"},"global":{"type":"boolean"},"ignoreCase":{"type":"boolean"},"multiline":{"type":"boolean"},"lastIndex":{"type":"number"},"flags":{"type":"string"},"sticky":{"type":"boolean"},"unicode":{"type":"boolean"},"dotAll":{"type":"boolean"}},"additionalProperties":false,"required":["dotAll","flags","global","ignoreCase","lastIndex","multiline","source","sticky","unicode"]},"GoogleAnalyticsInitializeOptions":{"type":"object","properties":{"cacheName":{"type":"string"},"parameterOverrides":{"type":"object","additionalProperties":{"type":"string"}},"hitFilter":{"type":"object","additionalProperties":false}},"additionalProperties":false},"RuntimeCaching":{"type":"object","properties":{"handler":{"anyOf":[{"$ref":"#/definitions/RouteHandlerCallback"},{"$ref":"#/definitions/RouteHandlerObject"},{"enum":["CacheFirst","CacheOnly","NetworkFirst","NetworkOnly","StaleWhileRevalidate"],"type":"string"}]},"method":{"enum":["DELETE","GET","HEAD","PATCH","POST","PUT"],"type":"string"},"options":{"type":"object","properties":{"backgroundSync":{"type":"object","properties":{"name":{"type":"string"},"options":{"$ref":"#/definitions/QueueOptions"}},"additionalProperties":false,"required":["name"]},"broadcastUpdate":{"type":"object","properties":{"channelName":{"type":"string"},"options":{"$ref":"#/definitions/BroadcastCacheUpdateOptions"}},"additionalProperties":false,"required":["options"]},"cacheableResponse":{"$ref":"#/definitions/CacheableResponseOptions"},"cacheName":{"type":["null","string"]},"expiration":{"$ref":"#/definitions/ExpirationPluginOptions"},"networkTimeoutSeconds":{"type":"number"},"plugins":{"type":"array","items":{"$ref":"#/definitions/WorkboxPlugin"}},"precacheFallback":{"type":"object","properties":{"fallbackURL":{"type":"string"}},"additionalProperties":false,"required":["fallbackURL"]},"fetchOptions":{"$ref":"#/definitions/RequestInit"},"matchOptions":{"$ref":"#/definitions/CacheQueryOptions"}},"additionalProperties":false},"urlPattern":{"anyOf":[{"$ref":"#/definitions/RegExp"},{"$ref":"#/definitions/RouteMatchCallback"},{"type":"string"}]}},"additionalProperties":false,"required":["handler","urlPattern"]},"RouteHandlerCallback":{"description":"The \"handler\" callback is invoked whenever a `Router` matches a URL/Request\nto a `Route` via its `RouteMatchCallback`. This handler callback should\nreturn a `Promise` that resolves with a `Response`.\n\nIf a non-empty array or object is returned by the `RouteMatchCallback` it\nwill be passed in as this handler's `options.params` argument.","type":"object","additionalProperties":false},"RouteHandlerObject":{"description":"An object with a `handle` method of type `RouteHandlerCallback`.\n\nA `Route` object can be created with either an `RouteHandlerCallback`\nfunction or this `RouteHandler` object. The benefit of the `RouteHandler`\nis it can be extended (as is done by the `workbox-strategies` package).","type":"object","properties":{"handle":{"$ref":"#/definitions/RouteHandlerCallback"}},"additionalProperties":false,"required":["handle"]},"QueueOptions":{"type":"object","properties":{"onSync":{"$ref":"#/definitions/OnSyncCallback"},"maxRetentionTime":{"type":"number"}},"additionalProperties":false},"OnSyncCallback":{"type":"object","additionalProperties":false},"BroadcastCacheUpdateOptions":{"type":"object","properties":{"headersToCheck":{"type":"array","items":{"type":"string"}},"generatePayload":{"type":"object","additionalProperties":false}},"additionalProperties":false},"CacheableResponseOptions":{"type":"object","properties":{"statuses":{"type":"array","items":{"type":"number"}},"headers":{"type":"object","additionalProperties":{"type":"string"}}},"additionalProperties":false},"ExpirationPluginOptions":{"type":"object","properties":{"maxEntries":{"type":"number"},"maxAgeSeconds":{"type":"number"},"matchOptions":{"$ref":"#/definitions/CacheQueryOptions"},"purgeOnQuotaError":{"type":"boolean"}},"additionalProperties":false},"CacheQueryOptions":{"type":"object","properties":{"ignoreMethod":{"type":"boolean"},"ignoreSearch":{"type":"boolean"},"ignoreVary":{"type":"boolean"}},"additionalProperties":false},"WorkboxPlugin":{"description":"An object with optional lifecycle callback properties for the fetch and\ncache operations.","type":"object","properties":{"cacheDidUpdate":{"$ref":"#/definitions/CacheDidUpdateCallback"},"cachedResponseWillBeUsed":{"$ref":"#/definitions/CachedResponseWillBeUsedCallback"},"cacheKeyWillBeUsed":{"$ref":"#/definitions/CacheKeyWillBeUsedCallback"},"cacheWillUpdate":{"$ref":"#/definitions/CacheWillUpdateCallback"},"fetchDidFail":{"$ref":"#/definitions/FetchDidFailCallback"},"fetchDidSucceed":{"$ref":"#/definitions/FetchDidSucceedCallback"},"handlerDidComplete":{"$ref":"#/definitions/HandlerDidCompleteCallback"},"handlerDidError":{"$ref":"#/definitions/HandlerDidErrorCallback"},"handlerDidRespond":{"$ref":"#/definitions/HandlerDidRespondCallback"},"handlerWillRespond":{"$ref":"#/definitions/HandlerWillRespondCallback"},"handlerWillStart":{"$ref":"#/definitions/HandlerWillStartCallback"},"requestWillFetch":{"$ref":"#/definitions/RequestWillFetchCallback"}},"additionalProperties":false},"CacheDidUpdateCallback":{"type":"object","additionalProperties":false},"CachedResponseWillBeUsedCallback":{"type":"object","additionalProperties":false},"CacheKeyWillBeUsedCallback":{"type":"object","additionalProperties":false},"CacheWillUpdateCallback":{"type":"object","additionalProperties":false},"FetchDidFailCallback":{"type":"object","additionalProperties":false},"FetchDidSucceedCallback":{"type":"object","additionalProperties":false},"HandlerDidCompleteCallback":{"type":"object","additionalProperties":false},"HandlerDidErrorCallback":{"type":"object","additionalProperties":false},"HandlerDidRespondCallback":{"type":"object","additionalProperties":false},"HandlerWillRespondCallback":{"type":"object","additionalProperties":false},"HandlerWillStartCallback":{"type":"object","additionalProperties":false},"RequestWillFetchCallback":{"type":"object","additionalProperties":false},"RequestInit":{"type":"object","properties":{"body":{"anyOf":[{"$ref":"#/definitions/ArrayBuffer"},{"$ref":"#/definitions/ArrayBufferView"},{"$ref":"#/definitions/Blob"},{"$ref":"#/definitions/FormData"},{"$ref":"#/definitions/URLSearchParams"},{"$ref":"#/definitions/ReadableStream"},{"type":["null","string"]}]},"cache":{"enum":["default","force-cache","no-cache","no-store","only-if-cached","reload"],"type":"string"},"credentials":{"enum":["include","omit","same-origin"],"type":"string"},"headers":{"anyOf":[{"$ref":"#/definitions/Headers"},{"type":"array","items":{"type":"array","items":{"type":"string"}}},{"$ref":"#/definitions/Record"}]},"integrity":{"type":"string"},"keepalive":{"type":"boolean"},"method":{"type":"string"},"mode":{"enum":["cors","navigate","no-cors","same-origin"],"type":"string"},"redirect":{"enum":["error","follow","manual"],"type":"string"},"referrer":{"type":"string"},"referrerPolicy":{"enum":["","no-referrer","no-referrer-when-downgrade","origin","origin-when-cross-origin","same-origin","strict-origin","strict-origin-when-cross-origin","unsafe-url"],"type":"string"},"signal":{"anyOf":[{"$ref":"#/definitions/AbortSignal"},{"type":"null"}]},"window":{}},"additionalProperties":false},"ArrayBuffer":{"type":"object","properties":{"byteLength":{"type":"number"},"__@toStringTag":{"type":"string"}},"additionalProperties":false,"required":["__@toStringTag","byteLength"]},"ArrayBufferView":{"type":"object","properties":{"buffer":{"anyOf":[{"$ref":"#/definitions/ArrayBuffer"},{"$ref":"#/definitions/SharedArrayBuffer"}]},"byteLength":{"type":"number"},"byteOffset":{"type":"number"}},"additionalProperties":false,"required":["buffer","byteLength","byteOffset"]},"SharedArrayBuffer":{"type":"object","properties":{"byteLength":{"type":"number"},"__@species":{"$ref":"#/definitions/SharedArrayBuffer"},"__@toStringTag":{"type":"string","enum":["SharedArrayBuffer"]}},"additionalProperties":false,"required":["__@species","__@toStringTag","byteLength"]},"Blob":{"type":"object","properties":{"size":{"type":"number"},"type":{"type":"string"}},"additionalProperties":false,"required":["size","type"]},"FormData":{"type":"object","additionalProperties":false},"URLSearchParams":{"type":"object","additionalProperties":false},"ReadableStream":{"type":"object","properties":{"locked":{"type":"boolean"}},"additionalProperties":false,"required":["locked"]},"Headers":{"type":"object","additionalProperties":false},"Record":{"type":"object","additionalProperties":false},"AbortSignal":{"type":"object","properties":{"aborted":{"type":"boolean"},"onabort":{"anyOf":[{"type":"object","additionalProperties":false},{"type":"null"}]}},"additionalProperties":false,"required":["aborted","onabort"]},"RouteMatchCallback":{"description":"The \"match\" callback is used to determine if a `Route` should apply for a\nparticular URL and request. When matching occurs in response to a fetch\nevent from the client, the `event` object is also supplied. However, since\nthe match callback can be invoked outside of a fetch event, matching logic\nshould not assume the `event` object will always be available.\nIf the match callback returns a truthy value, the matching route's\n`RouteHandlerCallback` will be invoked immediately. If the value returned\nis a non-empty array or object, that value will be set on the handler's\n`options.params` argument.","additionalProperties":false,"typeof":"function"}},"$schema":"http://json-schema.org/draft-07/schema#"} From aed3f6a34b5c347befb6361e2e7ab115f27d6f94 Mon Sep 17 00:00:00 2001 From: Jeff Posnick Date: Mon, 14 Jun 2021 15:25:58 -0400 Subject: [PATCH 59/80] Expiration w/cacheName check --- packages/workbox-build/src/lib/errors.ts | 2 ++ .../workbox-build/src/lib/validate-options.ts | 13 +++++++++++++ test/workbox-build/node/generate-sw.js | 18 ++++-------------- 3 files changed, 19 insertions(+), 14 deletions(-) diff --git a/packages/workbox-build/src/lib/errors.ts b/packages/workbox-build/src/lib/errors.ts index 1a591d8bb..11eb82f4a 100644 --- a/packages/workbox-build/src/lib/errors.ts +++ b/packages/workbox-build/src/lib/errors.ts @@ -116,4 +116,6 @@ export const errors = { opened:`, 'nav-preload-runtime-caching': ol`When using navigationPreload, you must also configure a runtimeCaching route that will use the preloaded response.`, + 'cache-name-required': ol`When using cache expiration, you must also + configure a custom cacheName.`, }; diff --git a/packages/workbox-build/src/lib/validate-options.ts b/packages/workbox-build/src/lib/validate-options.ts index 089f91239..2023779ff 100644 --- a/packages/workbox-build/src/lib/validate-options.ts +++ b/packages/workbox-build/src/lib/validate-options.ts @@ -69,9 +69,21 @@ function ensureValidNavigationPreloadConfig( throw new WorkboxConfigError(errors['nav-preload-runtime-caching']); } } + +function ensureValidCacheExpiration( + options: GenerateSWOptions | WebpackGenerateSWOptions, +): void { + for (const runtimeCaching of options.runtimeCaching || []) { + if (runtimeCaching.options?.expiration && !runtimeCaching.options?.cacheName) { + throw new WorkboxConfigError(errors['cache-name-required']); + } + } +} + export function validateGenerateSWOptions(input: unknown): GenerateSWOptions { const validatedOptions = validate(input, 'GenerateSW'); ensureValidNavigationPreloadConfig(validatedOptions); + ensureValidCacheExpiration(validatedOptions); return validatedOptions; } @@ -92,6 +104,7 @@ export function validateWebpackGenerateSWOptions(input: unknown): WebpackGenerat }, input); const validatedOptions = validate(inputWithExcludeDefault, 'WebpackGenerateSW'); ensureValidNavigationPreloadConfig(validatedOptions); + ensureValidCacheExpiration(validatedOptions); return validatedOptions; } diff --git a/test/workbox-build/node/generate-sw.js b/test/workbox-build/node/generate-sw.js index 80a4c2d12..4e8fb186e 100644 --- a/test/workbox-build/node/generate-sw.js +++ b/test/workbox-build/node/generate-sw.js @@ -708,13 +708,8 @@ describe(`[workbox-build] generate-sw.js (End to End)`, function() { }], }); - try { - await generateSW(options); - throw new Error('Unexpected success.'); - } catch (error) { - expect(error.name).to.eql('ValidationError', error.message); - expect(error.details[0].context.key).to.eql('handler'); - } + await expect(generateSW(options)).to.eventually.be.rejectedWith( + WorkboxConfigError, 'handler'); }); // See https://github.com/GoogleChrome/workbox/issues/2078 @@ -996,13 +991,8 @@ describe(`[workbox-build] generate-sw.js (End to End)`, function() { }], }); - try { - await generateSW(options); - throw new Error('Unexpected success.'); - } catch (error) { - expect(error.name).to.eql('ValidationError', error.message); - expect(error.details[0].context.main).to.eql('expiration'); - } + await expect(generateSW(options)).to.eventually.be.rejectedWith( + WorkboxConfigError, errors['cache-name-required']); }); it(`should ignore swDest and workbox-*.js when generating manifest entries`, async function() { From a534b138ab96d78cd6fe9f945f04fe264ca567c1 Mon Sep 17 00:00:00 2001 From: Jeff Posnick Date: Mon, 14 Jun 2021 16:01:19 -0400 Subject: [PATCH 60/80] Optional globDirectory --- packages/workbox-build/src/generate-sw.ts | 26 +++++++++--- .../src/lib/get-file-manifest-entries.ts | 42 +++++++++---------- .../workbox-build/src/lib/validate-options.ts | 11 +++++ .../src/schema/GenerateSWOptions.json | 2 +- .../src/schema/GetManifestOptions.json | 2 +- .../src/schema/InjectManifestOptions.json | 2 +- packages/workbox-build/src/types.ts | 19 +++++++-- 7 files changed, 69 insertions(+), 35 deletions(-) diff --git a/packages/workbox-build/src/generate-sw.ts b/packages/workbox-build/src/generate-sw.ts index 5db070d29..a1f4b2547 100644 --- a/packages/workbox-build/src/generate-sw.ts +++ b/packages/workbox-build/src/generate-sw.ts @@ -8,7 +8,7 @@ import upath from 'upath'; -import {BuildResult} from './types'; +import {BuildResult, GetManifestOptions} from './types'; import {getFileManifestEntries} from './lib/get-file-manifest-entries'; import {rebasePath} from './lib/rebase-path'; import {validateGenerateSWOptions} from './lib/validate-options'; @@ -195,6 +195,7 @@ import {writeSWUsingDefaultTemplate} from './lib/write-sw-using-default-template */ export async function generateSW(config: unknown): Promise { const options = validateGenerateSWOptions(config); + let entriesResult; if (options.globDirectory) { // Make sure we leave swDest out of the precache manifest. @@ -213,14 +214,27 @@ export async function generateSW(config: unknown): Promise { file: workboxRuntimeFile, })); } - } - const {count, size, manifestEntries, warnings} = - await getFileManifestEntries(options); + // We've previously asserted that options.globDirectory is set, so this + // should be a safe cast. + entriesResult = await getFileManifestEntries(options as GetManifestOptions); + } else { + entriesResult = { + count: 0, + manifestEntries: [], + size: 0, + warnings: [], + }; + } const filePaths = await writeSWUsingDefaultTemplate(Object.assign({ - manifestEntries, + manifestEntries: entriesResult.manifestEntries, }, options)); - return {count, filePaths, size, warnings}; + return { + filePaths, + count: entriesResult.count, + size: entriesResult.size, + warnings: entriesResult.warnings, + }; } diff --git a/packages/workbox-build/src/lib/get-file-manifest-entries.ts b/packages/workbox-build/src/lib/get-file-manifest-entries.ts index 8affad331..9677850f7 100644 --- a/packages/workbox-build/src/lib/get-file-manifest-entries.ts +++ b/packages/workbox-build/src/lib/get-file-manifest-entries.ts @@ -31,35 +31,33 @@ export async function getFileManifestEntries({ const warnings: Array = []; const allFileDetails = new Map(); - if (globDirectory) { - try { - for (const globPattern of globPatterns) { - const {globbedFileDetails, warning} = getFileDetails({ - globDirectory, - globFollow, - globIgnores, - globPattern, - globStrict, - }); + try { + for (const globPattern of globPatterns) { + const {globbedFileDetails, warning} = getFileDetails({ + globDirectory, + globFollow, + globIgnores, + globPattern, + globStrict, + }); - if (warning) { - warnings.push(warning); - } + if (warning) { + warnings.push(warning); + } - for (const details of globbedFileDetails) { - if (details && !allFileDetails.has(details.file)) { - allFileDetails.set(details.file, details); - } + for (const details of globbedFileDetails) { + if (details && !allFileDetails.has(details.file)) { + allFileDetails.set(details.file, details); } } - } catch (error) { - // If there's an exception thrown while globbing, then report - // it back as a warning, and don't consider it fatal. - warnings.push(error.message); } + } catch (error) { + // If there's an exception thrown while globbing, then report + // it back as a warning, and don't consider it fatal. + warnings.push(error.message); } - if (globDirectory && templatedURLs) { + if (templatedURLs) { for (const url of Object.keys(templatedURLs)) { assert(!allFileDetails.has(url), errors['templated-url-matches-glob']); diff --git a/packages/workbox-build/src/lib/validate-options.ts b/packages/workbox-build/src/lib/validate-options.ts index 2023779ff..dcf0f0283 100644 --- a/packages/workbox-build/src/lib/validate-options.ts +++ b/packages/workbox-build/src/lib/validate-options.ts @@ -80,10 +80,21 @@ function ensureValidCacheExpiration( } } +function ensureValidRuntimeCachingOrGlobDirectory( + options: GenerateSWOptions, +): void { + if (!options.globDirectory && + (!Array.isArray(options.runtimeCaching) || + options.runtimeCaching.length === 0)) { + throw new WorkboxConfigError(errors['no-manifest-entries-or-runtime-caching']); + } +} + export function validateGenerateSWOptions(input: unknown): GenerateSWOptions { const validatedOptions = validate(input, 'GenerateSW'); ensureValidNavigationPreloadConfig(validatedOptions); ensureValidCacheExpiration(validatedOptions); + ensureValidRuntimeCachingOrGlobDirectory(validatedOptions); return validatedOptions; } diff --git a/packages/workbox-build/src/schema/GenerateSWOptions.json b/packages/workbox-build/src/schema/GenerateSWOptions.json index 3bf3aa002..712191912 100644 --- a/packages/workbox-build/src/schema/GenerateSWOptions.json +++ b/packages/workbox-build/src/schema/GenerateSWOptions.json @@ -1 +1 @@ -{"additionalProperties":false,"type":"object","properties":{"additionalManifestEntries":{"type":"array","items":{"anyOf":[{"$ref":"#/definitions/ManifestEntry"},{"type":"string"}]}},"dontCacheBustURLsMatching":{"$ref":"#/definitions/RegExp"},"manifestTransforms":{"type":"array","items":{"typeof":"function"}},"maximumFileSizeToCacheInBytes":{"default":2097152,"type":"number"},"modifyURLPrefix":{"type":"object","additionalProperties":{"type":"string"}},"globDirectory":{"type":"string"},"globFollow":{"default":true,"type":"boolean"},"globIgnores":{"default":["**/node_modules/**/*"],"type":"array","items":{"type":"string"}},"globPatterns":{"default":["**/*.{js,css,html}"],"type":"array","items":{"type":"string"}},"globStrict":{"default":true,"type":"boolean"},"templatedURLs":{"type":"object","additionalProperties":{"anyOf":[{"type":"array","items":{"type":"string"}},{"type":"string"}]}},"babelPresetEnvTargets":{"default":["chrome >= 56"],"type":"array","items":{"type":"string"}},"cacheId":{"type":["null","string"]},"cleanupOutdatedCaches":{"default":false,"type":"boolean"},"clientsClaim":{"default":false,"type":"boolean"},"directoryIndex":{"type":["null","string"]},"disableDevLogs":{"default":false,"type":"boolean"},"ignoreURLParametersMatching":{"type":"array","items":{"$ref":"#/definitions/RegExp"}},"importScripts":{"type":"array","items":{"type":"string"}},"inlineWorkboxRuntime":{"default":false,"type":"boolean"},"mode":{"default":"production","type":["null","string"]},"navigateFallback":{"default":null,"type":["null","string"]},"navigateFallbackAllowlist":{"type":"array","items":{"$ref":"#/definitions/RegExp"}},"navigateFallbackDenylist":{"type":"array","items":{"$ref":"#/definitions/RegExp"}},"navigationPreload":{"description":"navigationPreload is only valid when runtimeCaching is configured. However,\nthis can't be expressed via TypeScript, so it's enforced via runtime logic.","default":false,"type":"boolean"},"offlineGoogleAnalytics":{"default":false,"anyOf":[{"$ref":"#/definitions/GoogleAnalyticsInitializeOptions"},{"type":"boolean"}]},"runtimeCaching":{"type":"array","items":{"$ref":"#/definitions/RuntimeCaching"}},"skipWaiting":{"default":false,"type":"boolean"},"sourcemap":{"default":true,"type":"boolean"},"swDest":{"type":"string"}},"required":["globDirectory","swDest"],"definitions":{"ManifestEntry":{"type":"object","properties":{"integrity":{"type":"string"},"revision":{"type":["null","string"]},"url":{"type":"string"}},"additionalProperties":false,"required":["revision","url"]},"RegExp":{"type":"object","properties":{"source":{"type":"string"},"global":{"type":"boolean"},"ignoreCase":{"type":"boolean"},"multiline":{"type":"boolean"},"lastIndex":{"type":"number"},"flags":{"type":"string"},"sticky":{"type":"boolean"},"unicode":{"type":"boolean"},"dotAll":{"type":"boolean"}},"additionalProperties":false,"required":["dotAll","flags","global","ignoreCase","lastIndex","multiline","source","sticky","unicode"]},"GoogleAnalyticsInitializeOptions":{"type":"object","properties":{"cacheName":{"type":"string"},"parameterOverrides":{"type":"object","additionalProperties":{"type":"string"}},"hitFilter":{"type":"object","additionalProperties":false}},"additionalProperties":false},"RuntimeCaching":{"type":"object","properties":{"handler":{"anyOf":[{"$ref":"#/definitions/RouteHandlerCallback"},{"$ref":"#/definitions/RouteHandlerObject"},{"enum":["CacheFirst","CacheOnly","NetworkFirst","NetworkOnly","StaleWhileRevalidate"],"type":"string"}]},"method":{"enum":["DELETE","GET","HEAD","PATCH","POST","PUT"],"type":"string"},"options":{"type":"object","properties":{"backgroundSync":{"type":"object","properties":{"name":{"type":"string"},"options":{"$ref":"#/definitions/QueueOptions"}},"additionalProperties":false,"required":["name"]},"broadcastUpdate":{"type":"object","properties":{"channelName":{"type":"string"},"options":{"$ref":"#/definitions/BroadcastCacheUpdateOptions"}},"additionalProperties":false,"required":["options"]},"cacheableResponse":{"$ref":"#/definitions/CacheableResponseOptions"},"cacheName":{"type":["null","string"]},"expiration":{"$ref":"#/definitions/ExpirationPluginOptions"},"networkTimeoutSeconds":{"type":"number"},"plugins":{"type":"array","items":{"$ref":"#/definitions/WorkboxPlugin"}},"precacheFallback":{"type":"object","properties":{"fallbackURL":{"type":"string"}},"additionalProperties":false,"required":["fallbackURL"]},"fetchOptions":{"$ref":"#/definitions/RequestInit"},"matchOptions":{"$ref":"#/definitions/CacheQueryOptions"}},"additionalProperties":false},"urlPattern":{"anyOf":[{"$ref":"#/definitions/RegExp"},{"$ref":"#/definitions/RouteMatchCallback"},{"type":"string"}]}},"additionalProperties":false,"required":["handler","urlPattern"]},"RouteHandlerCallback":{"description":"The \"handler\" callback is invoked whenever a `Router` matches a URL/Request\nto a `Route` via its `RouteMatchCallback`. This handler callback should\nreturn a `Promise` that resolves with a `Response`.\n\nIf a non-empty array or object is returned by the `RouteMatchCallback` it\nwill be passed in as this handler's `options.params` argument.","type":"object","additionalProperties":false},"RouteHandlerObject":{"description":"An object with a `handle` method of type `RouteHandlerCallback`.\n\nA `Route` object can be created with either an `RouteHandlerCallback`\nfunction or this `RouteHandler` object. The benefit of the `RouteHandler`\nis it can be extended (as is done by the `workbox-strategies` package).","type":"object","properties":{"handle":{"$ref":"#/definitions/RouteHandlerCallback"}},"additionalProperties":false,"required":["handle"]},"QueueOptions":{"type":"object","properties":{"onSync":{"$ref":"#/definitions/OnSyncCallback"},"maxRetentionTime":{"type":"number"}},"additionalProperties":false},"OnSyncCallback":{"type":"object","additionalProperties":false},"BroadcastCacheUpdateOptions":{"type":"object","properties":{"headersToCheck":{"type":"array","items":{"type":"string"}},"generatePayload":{"type":"object","additionalProperties":false}},"additionalProperties":false},"CacheableResponseOptions":{"type":"object","properties":{"statuses":{"type":"array","items":{"type":"number"}},"headers":{"type":"object","additionalProperties":{"type":"string"}}},"additionalProperties":false},"ExpirationPluginOptions":{"type":"object","properties":{"maxEntries":{"type":"number"},"maxAgeSeconds":{"type":"number"},"matchOptions":{"$ref":"#/definitions/CacheQueryOptions"},"purgeOnQuotaError":{"type":"boolean"}},"additionalProperties":false},"CacheQueryOptions":{"type":"object","properties":{"ignoreMethod":{"type":"boolean"},"ignoreSearch":{"type":"boolean"},"ignoreVary":{"type":"boolean"}},"additionalProperties":false},"WorkboxPlugin":{"description":"An object with optional lifecycle callback properties for the fetch and\ncache operations.","type":"object","properties":{"cacheDidUpdate":{"$ref":"#/definitions/CacheDidUpdateCallback"},"cachedResponseWillBeUsed":{"$ref":"#/definitions/CachedResponseWillBeUsedCallback"},"cacheKeyWillBeUsed":{"$ref":"#/definitions/CacheKeyWillBeUsedCallback"},"cacheWillUpdate":{"$ref":"#/definitions/CacheWillUpdateCallback"},"fetchDidFail":{"$ref":"#/definitions/FetchDidFailCallback"},"fetchDidSucceed":{"$ref":"#/definitions/FetchDidSucceedCallback"},"handlerDidComplete":{"$ref":"#/definitions/HandlerDidCompleteCallback"},"handlerDidError":{"$ref":"#/definitions/HandlerDidErrorCallback"},"handlerDidRespond":{"$ref":"#/definitions/HandlerDidRespondCallback"},"handlerWillRespond":{"$ref":"#/definitions/HandlerWillRespondCallback"},"handlerWillStart":{"$ref":"#/definitions/HandlerWillStartCallback"},"requestWillFetch":{"$ref":"#/definitions/RequestWillFetchCallback"}},"additionalProperties":false},"CacheDidUpdateCallback":{"type":"object","additionalProperties":false},"CachedResponseWillBeUsedCallback":{"type":"object","additionalProperties":false},"CacheKeyWillBeUsedCallback":{"type":"object","additionalProperties":false},"CacheWillUpdateCallback":{"type":"object","additionalProperties":false},"FetchDidFailCallback":{"type":"object","additionalProperties":false},"FetchDidSucceedCallback":{"type":"object","additionalProperties":false},"HandlerDidCompleteCallback":{"type":"object","additionalProperties":false},"HandlerDidErrorCallback":{"type":"object","additionalProperties":false},"HandlerDidRespondCallback":{"type":"object","additionalProperties":false},"HandlerWillRespondCallback":{"type":"object","additionalProperties":false},"HandlerWillStartCallback":{"type":"object","additionalProperties":false},"RequestWillFetchCallback":{"type":"object","additionalProperties":false},"RequestInit":{"type":"object","properties":{"body":{"anyOf":[{"$ref":"#/definitions/ArrayBuffer"},{"$ref":"#/definitions/ArrayBufferView"},{"$ref":"#/definitions/Blob"},{"$ref":"#/definitions/FormData"},{"$ref":"#/definitions/URLSearchParams"},{"$ref":"#/definitions/ReadableStream"},{"type":["null","string"]}]},"cache":{"enum":["default","force-cache","no-cache","no-store","only-if-cached","reload"],"type":"string"},"credentials":{"enum":["include","omit","same-origin"],"type":"string"},"headers":{"anyOf":[{"$ref":"#/definitions/Headers"},{"type":"array","items":{"type":"array","items":{"type":"string"}}},{"$ref":"#/definitions/Record"}]},"integrity":{"type":"string"},"keepalive":{"type":"boolean"},"method":{"type":"string"},"mode":{"enum":["cors","navigate","no-cors","same-origin"],"type":"string"},"redirect":{"enum":["error","follow","manual"],"type":"string"},"referrer":{"type":"string"},"referrerPolicy":{"enum":["","no-referrer","no-referrer-when-downgrade","origin","origin-when-cross-origin","same-origin","strict-origin","strict-origin-when-cross-origin","unsafe-url"],"type":"string"},"signal":{"anyOf":[{"$ref":"#/definitions/AbortSignal"},{"type":"null"}]},"window":{}},"additionalProperties":false},"ArrayBuffer":{"type":"object","properties":{"byteLength":{"type":"number"},"__@toStringTag":{"type":"string"}},"additionalProperties":false,"required":["__@toStringTag","byteLength"]},"ArrayBufferView":{"type":"object","properties":{"buffer":{"anyOf":[{"$ref":"#/definitions/ArrayBuffer"},{"$ref":"#/definitions/SharedArrayBuffer"}]},"byteLength":{"type":"number"},"byteOffset":{"type":"number"}},"additionalProperties":false,"required":["buffer","byteLength","byteOffset"]},"SharedArrayBuffer":{"type":"object","properties":{"byteLength":{"type":"number"},"__@species":{"$ref":"#/definitions/SharedArrayBuffer"},"__@toStringTag":{"type":"string","enum":["SharedArrayBuffer"]}},"additionalProperties":false,"required":["__@species","__@toStringTag","byteLength"]},"Blob":{"type":"object","properties":{"size":{"type":"number"},"type":{"type":"string"}},"additionalProperties":false,"required":["size","type"]},"FormData":{"type":"object","additionalProperties":false},"URLSearchParams":{"type":"object","additionalProperties":false},"ReadableStream":{"type":"object","properties":{"locked":{"type":"boolean"}},"additionalProperties":false,"required":["locked"]},"Headers":{"type":"object","additionalProperties":false},"Record":{"type":"object","additionalProperties":false},"AbortSignal":{"type":"object","properties":{"aborted":{"type":"boolean"},"onabort":{"anyOf":[{"type":"object","additionalProperties":false},{"type":"null"}]}},"additionalProperties":false,"required":["aborted","onabort"]},"RouteMatchCallback":{"description":"The \"match\" callback is used to determine if a `Route` should apply for a\nparticular URL and request. When matching occurs in response to a fetch\nevent from the client, the `event` object is also supplied. However, since\nthe match callback can be invoked outside of a fetch event, matching logic\nshould not assume the `event` object will always be available.\nIf the match callback returns a truthy value, the matching route's\n`RouteHandlerCallback` will be invoked immediately. If the value returned\nis a non-empty array or object, that value will be set on the handler's\n`options.params` argument.","additionalProperties":false,"typeof":"function"}},"$schema":"http://json-schema.org/draft-07/schema#"} +{"additionalProperties":false,"type":"object","properties":{"additionalManifestEntries":{"type":"array","items":{"anyOf":[{"$ref":"#/definitions/ManifestEntry"},{"type":"string"}]}},"dontCacheBustURLsMatching":{"$ref":"#/definitions/RegExp"},"manifestTransforms":{"type":"array","items":{"typeof":"function"}},"maximumFileSizeToCacheInBytes":{"default":2097152,"type":"number"},"modifyURLPrefix":{"type":"object","additionalProperties":{"type":"string"}},"globFollow":{"default":true,"type":"boolean"},"globIgnores":{"default":["**/node_modules/**/*"],"type":"array","items":{"type":"string"}},"globPatterns":{"default":["**/*.{js,css,html}"],"type":"array","items":{"type":"string"}},"globStrict":{"default":true,"type":"boolean"},"templatedURLs":{"type":"object","additionalProperties":{"anyOf":[{"type":"array","items":{"type":"string"}},{"type":"string"}]}},"babelPresetEnvTargets":{"default":["chrome >= 56"],"type":"array","items":{"type":"string"}},"cacheId":{"type":["null","string"]},"cleanupOutdatedCaches":{"default":false,"type":"boolean"},"clientsClaim":{"default":false,"type":"boolean"},"directoryIndex":{"type":["null","string"]},"disableDevLogs":{"default":false,"type":"boolean"},"ignoreURLParametersMatching":{"type":"array","items":{"$ref":"#/definitions/RegExp"}},"importScripts":{"type":"array","items":{"type":"string"}},"inlineWorkboxRuntime":{"default":false,"type":"boolean"},"mode":{"default":"production","type":["null","string"]},"navigateFallback":{"default":null,"type":["null","string"]},"navigateFallbackAllowlist":{"type":"array","items":{"$ref":"#/definitions/RegExp"}},"navigateFallbackDenylist":{"type":"array","items":{"$ref":"#/definitions/RegExp"}},"navigationPreload":{"description":"navigationPreload is only valid when runtimeCaching is configured. However,\nthis can't be expressed via TypeScript, so it's enforced via runtime logic.","default":false,"type":"boolean"},"offlineGoogleAnalytics":{"default":false,"anyOf":[{"$ref":"#/definitions/GoogleAnalyticsInitializeOptions"},{"type":"boolean"}]},"runtimeCaching":{"type":"array","items":{"$ref":"#/definitions/RuntimeCaching"}},"skipWaiting":{"default":false,"type":"boolean"},"sourcemap":{"default":true,"type":"boolean"},"swDest":{"type":"string"},"globDirectory":{"type":"string"}},"required":["swDest"],"definitions":{"ManifestEntry":{"type":"object","properties":{"integrity":{"type":"string"},"revision":{"type":["null","string"]},"url":{"type":"string"}},"additionalProperties":false,"required":["revision","url"]},"RegExp":{"type":"object","properties":{"source":{"type":"string"},"global":{"type":"boolean"},"ignoreCase":{"type":"boolean"},"multiline":{"type":"boolean"},"lastIndex":{"type":"number"},"flags":{"type":"string"},"sticky":{"type":"boolean"},"unicode":{"type":"boolean"},"dotAll":{"type":"boolean"}},"additionalProperties":false,"required":["dotAll","flags","global","ignoreCase","lastIndex","multiline","source","sticky","unicode"]},"GoogleAnalyticsInitializeOptions":{"type":"object","properties":{"cacheName":{"type":"string"},"parameterOverrides":{"type":"object","additionalProperties":{"type":"string"}},"hitFilter":{"type":"object","additionalProperties":false}},"additionalProperties":false},"RuntimeCaching":{"type":"object","properties":{"handler":{"anyOf":[{"$ref":"#/definitions/RouteHandlerCallback"},{"$ref":"#/definitions/RouteHandlerObject"},{"enum":["CacheFirst","CacheOnly","NetworkFirst","NetworkOnly","StaleWhileRevalidate"],"type":"string"}]},"method":{"enum":["DELETE","GET","HEAD","PATCH","POST","PUT"],"type":"string"},"options":{"type":"object","properties":{"backgroundSync":{"type":"object","properties":{"name":{"type":"string"},"options":{"$ref":"#/definitions/QueueOptions"}},"additionalProperties":false,"required":["name"]},"broadcastUpdate":{"type":"object","properties":{"channelName":{"type":"string"},"options":{"$ref":"#/definitions/BroadcastCacheUpdateOptions"}},"additionalProperties":false,"required":["options"]},"cacheableResponse":{"$ref":"#/definitions/CacheableResponseOptions"},"cacheName":{"type":["null","string"]},"expiration":{"$ref":"#/definitions/ExpirationPluginOptions"},"networkTimeoutSeconds":{"type":"number"},"plugins":{"type":"array","items":{"$ref":"#/definitions/WorkboxPlugin"}},"precacheFallback":{"type":"object","properties":{"fallbackURL":{"type":"string"}},"additionalProperties":false,"required":["fallbackURL"]},"fetchOptions":{"$ref":"#/definitions/RequestInit"},"matchOptions":{"$ref":"#/definitions/CacheQueryOptions"}},"additionalProperties":false},"urlPattern":{"anyOf":[{"$ref":"#/definitions/RegExp"},{"$ref":"#/definitions/RouteMatchCallback"},{"type":"string"}]}},"additionalProperties":false,"required":["handler","urlPattern"]},"RouteHandlerCallback":{"description":"The \"handler\" callback is invoked whenever a `Router` matches a URL/Request\nto a `Route` via its `RouteMatchCallback`. This handler callback should\nreturn a `Promise` that resolves with a `Response`.\n\nIf a non-empty array or object is returned by the `RouteMatchCallback` it\nwill be passed in as this handler's `options.params` argument.","type":"object","additionalProperties":false},"RouteHandlerObject":{"description":"An object with a `handle` method of type `RouteHandlerCallback`.\n\nA `Route` object can be created with either an `RouteHandlerCallback`\nfunction or this `RouteHandler` object. The benefit of the `RouteHandler`\nis it can be extended (as is done by the `workbox-strategies` package).","type":"object","properties":{"handle":{"$ref":"#/definitions/RouteHandlerCallback"}},"additionalProperties":false,"required":["handle"]},"QueueOptions":{"type":"object","properties":{"onSync":{"$ref":"#/definitions/OnSyncCallback"},"maxRetentionTime":{"type":"number"}},"additionalProperties":false},"OnSyncCallback":{"type":"object","additionalProperties":false},"BroadcastCacheUpdateOptions":{"type":"object","properties":{"headersToCheck":{"type":"array","items":{"type":"string"}},"generatePayload":{"type":"object","additionalProperties":false}},"additionalProperties":false},"CacheableResponseOptions":{"type":"object","properties":{"statuses":{"type":"array","items":{"type":"number"}},"headers":{"type":"object","additionalProperties":{"type":"string"}}},"additionalProperties":false},"ExpirationPluginOptions":{"type":"object","properties":{"maxEntries":{"type":"number"},"maxAgeSeconds":{"type":"number"},"matchOptions":{"$ref":"#/definitions/CacheQueryOptions"},"purgeOnQuotaError":{"type":"boolean"}},"additionalProperties":false},"CacheQueryOptions":{"type":"object","properties":{"ignoreMethod":{"type":"boolean"},"ignoreSearch":{"type":"boolean"},"ignoreVary":{"type":"boolean"}},"additionalProperties":false},"WorkboxPlugin":{"description":"An object with optional lifecycle callback properties for the fetch and\ncache operations.","type":"object","properties":{"cacheDidUpdate":{"$ref":"#/definitions/CacheDidUpdateCallback"},"cachedResponseWillBeUsed":{"$ref":"#/definitions/CachedResponseWillBeUsedCallback"},"cacheKeyWillBeUsed":{"$ref":"#/definitions/CacheKeyWillBeUsedCallback"},"cacheWillUpdate":{"$ref":"#/definitions/CacheWillUpdateCallback"},"fetchDidFail":{"$ref":"#/definitions/FetchDidFailCallback"},"fetchDidSucceed":{"$ref":"#/definitions/FetchDidSucceedCallback"},"handlerDidComplete":{"$ref":"#/definitions/HandlerDidCompleteCallback"},"handlerDidError":{"$ref":"#/definitions/HandlerDidErrorCallback"},"handlerDidRespond":{"$ref":"#/definitions/HandlerDidRespondCallback"},"handlerWillRespond":{"$ref":"#/definitions/HandlerWillRespondCallback"},"handlerWillStart":{"$ref":"#/definitions/HandlerWillStartCallback"},"requestWillFetch":{"$ref":"#/definitions/RequestWillFetchCallback"}},"additionalProperties":false},"CacheDidUpdateCallback":{"type":"object","additionalProperties":false},"CachedResponseWillBeUsedCallback":{"type":"object","additionalProperties":false},"CacheKeyWillBeUsedCallback":{"type":"object","additionalProperties":false},"CacheWillUpdateCallback":{"type":"object","additionalProperties":false},"FetchDidFailCallback":{"type":"object","additionalProperties":false},"FetchDidSucceedCallback":{"type":"object","additionalProperties":false},"HandlerDidCompleteCallback":{"type":"object","additionalProperties":false},"HandlerDidErrorCallback":{"type":"object","additionalProperties":false},"HandlerDidRespondCallback":{"type":"object","additionalProperties":false},"HandlerWillRespondCallback":{"type":"object","additionalProperties":false},"HandlerWillStartCallback":{"type":"object","additionalProperties":false},"RequestWillFetchCallback":{"type":"object","additionalProperties":false},"RequestInit":{"type":"object","properties":{"body":{"anyOf":[{"$ref":"#/definitions/ArrayBuffer"},{"$ref":"#/definitions/ArrayBufferView"},{"$ref":"#/definitions/Blob"},{"$ref":"#/definitions/FormData"},{"$ref":"#/definitions/URLSearchParams"},{"$ref":"#/definitions/ReadableStream"},{"type":["null","string"]}]},"cache":{"enum":["default","force-cache","no-cache","no-store","only-if-cached","reload"],"type":"string"},"credentials":{"enum":["include","omit","same-origin"],"type":"string"},"headers":{"anyOf":[{"$ref":"#/definitions/Headers"},{"type":"array","items":{"type":"array","items":{"type":"string"}}},{"$ref":"#/definitions/Record"}]},"integrity":{"type":"string"},"keepalive":{"type":"boolean"},"method":{"type":"string"},"mode":{"enum":["cors","navigate","no-cors","same-origin"],"type":"string"},"redirect":{"enum":["error","follow","manual"],"type":"string"},"referrer":{"type":"string"},"referrerPolicy":{"enum":["","no-referrer","no-referrer-when-downgrade","origin","origin-when-cross-origin","same-origin","strict-origin","strict-origin-when-cross-origin","unsafe-url"],"type":"string"},"signal":{"anyOf":[{"$ref":"#/definitions/AbortSignal"},{"type":"null"}]},"window":{}},"additionalProperties":false},"ArrayBuffer":{"type":"object","properties":{"byteLength":{"type":"number"},"__@toStringTag":{"type":"string"}},"additionalProperties":false,"required":["__@toStringTag","byteLength"]},"ArrayBufferView":{"type":"object","properties":{"buffer":{"anyOf":[{"$ref":"#/definitions/ArrayBuffer"},{"$ref":"#/definitions/SharedArrayBuffer"}]},"byteLength":{"type":"number"},"byteOffset":{"type":"number"}},"additionalProperties":false,"required":["buffer","byteLength","byteOffset"]},"SharedArrayBuffer":{"type":"object","properties":{"byteLength":{"type":"number"},"__@species":{"$ref":"#/definitions/SharedArrayBuffer"},"__@toStringTag":{"type":"string","enum":["SharedArrayBuffer"]}},"additionalProperties":false,"required":["__@species","__@toStringTag","byteLength"]},"Blob":{"type":"object","properties":{"size":{"type":"number"},"type":{"type":"string"}},"additionalProperties":false,"required":["size","type"]},"FormData":{"type":"object","additionalProperties":false},"URLSearchParams":{"type":"object","additionalProperties":false},"ReadableStream":{"type":"object","properties":{"locked":{"type":"boolean"}},"additionalProperties":false,"required":["locked"]},"Headers":{"type":"object","additionalProperties":false},"Record":{"type":"object","additionalProperties":false},"AbortSignal":{"type":"object","properties":{"aborted":{"type":"boolean"},"onabort":{"anyOf":[{"type":"object","additionalProperties":false},{"type":"null"}]}},"additionalProperties":false,"required":["aborted","onabort"]},"RouteMatchCallback":{"description":"The \"match\" callback is used to determine if a `Route` should apply for a\nparticular URL and request. When matching occurs in response to a fetch\nevent from the client, the `event` object is also supplied. However, since\nthe match callback can be invoked outside of a fetch event, matching logic\nshould not assume the `event` object will always be available.\nIf the match callback returns a truthy value, the matching route's\n`RouteHandlerCallback` will be invoked immediately. If the value returned\nis a non-empty array or object, that value will be set on the handler's\n`options.params` argument.","additionalProperties":false,"typeof":"function"}},"$schema":"http://json-schema.org/draft-07/schema#"} diff --git a/packages/workbox-build/src/schema/GetManifestOptions.json b/packages/workbox-build/src/schema/GetManifestOptions.json index aaefd62ff..d088aa5e0 100644 --- a/packages/workbox-build/src/schema/GetManifestOptions.json +++ b/packages/workbox-build/src/schema/GetManifestOptions.json @@ -1 +1 @@ -{"additionalProperties":false,"type":"object","properties":{"additionalManifestEntries":{"type":"array","items":{"anyOf":[{"$ref":"#/definitions/ManifestEntry"},{"type":"string"}]}},"dontCacheBustURLsMatching":{"$ref":"#/definitions/RegExp"},"manifestTransforms":{"type":"array","items":{"typeof":"function"}},"maximumFileSizeToCacheInBytes":{"default":2097152,"type":"number"},"modifyURLPrefix":{"type":"object","additionalProperties":{"type":"string"}},"globDirectory":{"type":"string"},"globFollow":{"default":true,"type":"boolean"},"globIgnores":{"default":["**/node_modules/**/*"],"type":"array","items":{"type":"string"}},"globPatterns":{"default":["**/*.{js,css,html}"],"type":"array","items":{"type":"string"}},"globStrict":{"default":true,"type":"boolean"},"templatedURLs":{"type":"object","additionalProperties":{"anyOf":[{"type":"array","items":{"type":"string"}},{"type":"string"}]}}},"required":["globDirectory"],"definitions":{"ManifestEntry":{"type":"object","properties":{"integrity":{"type":"string"},"revision":{"type":["null","string"]},"url":{"type":"string"}},"additionalProperties":false,"required":["revision","url"]},"RegExp":{"type":"object","properties":{"source":{"type":"string"},"global":{"type":"boolean"},"ignoreCase":{"type":"boolean"},"multiline":{"type":"boolean"},"lastIndex":{"type":"number"},"flags":{"type":"string"},"sticky":{"type":"boolean"},"unicode":{"type":"boolean"},"dotAll":{"type":"boolean"}},"additionalProperties":false,"required":["dotAll","flags","global","ignoreCase","lastIndex","multiline","source","sticky","unicode"]},"GoogleAnalyticsInitializeOptions":{"type":"object","properties":{"cacheName":{"type":"string"},"parameterOverrides":{"type":"object","additionalProperties":{"type":"string"}},"hitFilter":{"type":"object","additionalProperties":false}},"additionalProperties":false},"RuntimeCaching":{"type":"object","properties":{"handler":{"anyOf":[{"$ref":"#/definitions/RouteHandlerCallback"},{"$ref":"#/definitions/RouteHandlerObject"},{"enum":["CacheFirst","CacheOnly","NetworkFirst","NetworkOnly","StaleWhileRevalidate"],"type":"string"}]},"method":{"enum":["DELETE","GET","HEAD","PATCH","POST","PUT"],"type":"string"},"options":{"type":"object","properties":{"backgroundSync":{"type":"object","properties":{"name":{"type":"string"},"options":{"$ref":"#/definitions/QueueOptions"}},"additionalProperties":false,"required":["name"]},"broadcastUpdate":{"type":"object","properties":{"channelName":{"type":"string"},"options":{"$ref":"#/definitions/BroadcastCacheUpdateOptions"}},"additionalProperties":false,"required":["options"]},"cacheableResponse":{"$ref":"#/definitions/CacheableResponseOptions"},"cacheName":{"type":["null","string"]},"expiration":{"$ref":"#/definitions/ExpirationPluginOptions"},"networkTimeoutSeconds":{"type":"number"},"plugins":{"type":"array","items":{"$ref":"#/definitions/WorkboxPlugin"}},"precacheFallback":{"type":"object","properties":{"fallbackURL":{"type":"string"}},"additionalProperties":false,"required":["fallbackURL"]},"fetchOptions":{"$ref":"#/definitions/RequestInit"},"matchOptions":{"$ref":"#/definitions/CacheQueryOptions"}},"additionalProperties":false},"urlPattern":{"anyOf":[{"$ref":"#/definitions/RegExp"},{"$ref":"#/definitions/RouteMatchCallback"},{"type":"string"}]}},"additionalProperties":false,"required":["handler","urlPattern"]},"RouteHandlerCallback":{"description":"The \"handler\" callback is invoked whenever a `Router` matches a URL/Request\nto a `Route` via its `RouteMatchCallback`. This handler callback should\nreturn a `Promise` that resolves with a `Response`.\n\nIf a non-empty array or object is returned by the `RouteMatchCallback` it\nwill be passed in as this handler's `options.params` argument.","type":"object","additionalProperties":false},"RouteHandlerObject":{"description":"An object with a `handle` method of type `RouteHandlerCallback`.\n\nA `Route` object can be created with either an `RouteHandlerCallback`\nfunction or this `RouteHandler` object. The benefit of the `RouteHandler`\nis it can be extended (as is done by the `workbox-strategies` package).","type":"object","properties":{"handle":{"$ref":"#/definitions/RouteHandlerCallback"}},"additionalProperties":false,"required":["handle"]},"QueueOptions":{"type":"object","properties":{"onSync":{"$ref":"#/definitions/OnSyncCallback"},"maxRetentionTime":{"type":"number"}},"additionalProperties":false},"OnSyncCallback":{"type":"object","additionalProperties":false},"BroadcastCacheUpdateOptions":{"type":"object","properties":{"headersToCheck":{"type":"array","items":{"type":"string"}},"generatePayload":{"type":"object","additionalProperties":false}},"additionalProperties":false},"CacheableResponseOptions":{"type":"object","properties":{"statuses":{"type":"array","items":{"type":"number"}},"headers":{"type":"object","additionalProperties":{"type":"string"}}},"additionalProperties":false},"ExpirationPluginOptions":{"type":"object","properties":{"maxEntries":{"type":"number"},"maxAgeSeconds":{"type":"number"},"matchOptions":{"$ref":"#/definitions/CacheQueryOptions"},"purgeOnQuotaError":{"type":"boolean"}},"additionalProperties":false},"CacheQueryOptions":{"type":"object","properties":{"ignoreMethod":{"type":"boolean"},"ignoreSearch":{"type":"boolean"},"ignoreVary":{"type":"boolean"}},"additionalProperties":false},"WorkboxPlugin":{"description":"An object with optional lifecycle callback properties for the fetch and\ncache operations.","type":"object","properties":{"cacheDidUpdate":{"$ref":"#/definitions/CacheDidUpdateCallback"},"cachedResponseWillBeUsed":{"$ref":"#/definitions/CachedResponseWillBeUsedCallback"},"cacheKeyWillBeUsed":{"$ref":"#/definitions/CacheKeyWillBeUsedCallback"},"cacheWillUpdate":{"$ref":"#/definitions/CacheWillUpdateCallback"},"fetchDidFail":{"$ref":"#/definitions/FetchDidFailCallback"},"fetchDidSucceed":{"$ref":"#/definitions/FetchDidSucceedCallback"},"handlerDidComplete":{"$ref":"#/definitions/HandlerDidCompleteCallback"},"handlerDidError":{"$ref":"#/definitions/HandlerDidErrorCallback"},"handlerDidRespond":{"$ref":"#/definitions/HandlerDidRespondCallback"},"handlerWillRespond":{"$ref":"#/definitions/HandlerWillRespondCallback"},"handlerWillStart":{"$ref":"#/definitions/HandlerWillStartCallback"},"requestWillFetch":{"$ref":"#/definitions/RequestWillFetchCallback"}},"additionalProperties":false},"CacheDidUpdateCallback":{"type":"object","additionalProperties":false},"CachedResponseWillBeUsedCallback":{"type":"object","additionalProperties":false},"CacheKeyWillBeUsedCallback":{"type":"object","additionalProperties":false},"CacheWillUpdateCallback":{"type":"object","additionalProperties":false},"FetchDidFailCallback":{"type":"object","additionalProperties":false},"FetchDidSucceedCallback":{"type":"object","additionalProperties":false},"HandlerDidCompleteCallback":{"type":"object","additionalProperties":false},"HandlerDidErrorCallback":{"type":"object","additionalProperties":false},"HandlerDidRespondCallback":{"type":"object","additionalProperties":false},"HandlerWillRespondCallback":{"type":"object","additionalProperties":false},"HandlerWillStartCallback":{"type":"object","additionalProperties":false},"RequestWillFetchCallback":{"type":"object","additionalProperties":false},"RequestInit":{"type":"object","properties":{"body":{"anyOf":[{"$ref":"#/definitions/ArrayBuffer"},{"$ref":"#/definitions/ArrayBufferView"},{"$ref":"#/definitions/Blob"},{"$ref":"#/definitions/FormData"},{"$ref":"#/definitions/URLSearchParams"},{"$ref":"#/definitions/ReadableStream"},{"type":["null","string"]}]},"cache":{"enum":["default","force-cache","no-cache","no-store","only-if-cached","reload"],"type":"string"},"credentials":{"enum":["include","omit","same-origin"],"type":"string"},"headers":{"anyOf":[{"$ref":"#/definitions/Headers"},{"type":"array","items":{"type":"array","items":{"type":"string"}}},{"$ref":"#/definitions/Record"}]},"integrity":{"type":"string"},"keepalive":{"type":"boolean"},"method":{"type":"string"},"mode":{"enum":["cors","navigate","no-cors","same-origin"],"type":"string"},"redirect":{"enum":["error","follow","manual"],"type":"string"},"referrer":{"type":"string"},"referrerPolicy":{"enum":["","no-referrer","no-referrer-when-downgrade","origin","origin-when-cross-origin","same-origin","strict-origin","strict-origin-when-cross-origin","unsafe-url"],"type":"string"},"signal":{"anyOf":[{"$ref":"#/definitions/AbortSignal"},{"type":"null"}]},"window":{}},"additionalProperties":false},"ArrayBuffer":{"type":"object","properties":{"byteLength":{"type":"number"},"__@toStringTag":{"type":"string"}},"additionalProperties":false,"required":["__@toStringTag","byteLength"]},"ArrayBufferView":{"type":"object","properties":{"buffer":{"anyOf":[{"$ref":"#/definitions/ArrayBuffer"},{"$ref":"#/definitions/SharedArrayBuffer"}]},"byteLength":{"type":"number"},"byteOffset":{"type":"number"}},"additionalProperties":false,"required":["buffer","byteLength","byteOffset"]},"SharedArrayBuffer":{"type":"object","properties":{"byteLength":{"type":"number"},"__@species":{"$ref":"#/definitions/SharedArrayBuffer"},"__@toStringTag":{"type":"string","enum":["SharedArrayBuffer"]}},"additionalProperties":false,"required":["__@species","__@toStringTag","byteLength"]},"Blob":{"type":"object","properties":{"size":{"type":"number"},"type":{"type":"string"}},"additionalProperties":false,"required":["size","type"]},"FormData":{"type":"object","additionalProperties":false},"URLSearchParams":{"type":"object","additionalProperties":false},"ReadableStream":{"type":"object","properties":{"locked":{"type":"boolean"}},"additionalProperties":false,"required":["locked"]},"Headers":{"type":"object","additionalProperties":false},"Record":{"type":"object","additionalProperties":false},"AbortSignal":{"type":"object","properties":{"aborted":{"type":"boolean"},"onabort":{"anyOf":[{"type":"object","additionalProperties":false},{"type":"null"}]}},"additionalProperties":false,"required":["aborted","onabort"]},"RouteMatchCallback":{"description":"The \"match\" callback is used to determine if a `Route` should apply for a\nparticular URL and request. When matching occurs in response to a fetch\nevent from the client, the `event` object is also supplied. However, since\nthe match callback can be invoked outside of a fetch event, matching logic\nshould not assume the `event` object will always be available.\nIf the match callback returns a truthy value, the matching route's\n`RouteHandlerCallback` will be invoked immediately. If the value returned\nis a non-empty array or object, that value will be set on the handler's\n`options.params` argument.","additionalProperties":false,"typeof":"function"}},"$schema":"http://json-schema.org/draft-07/schema#"} +{"additionalProperties":false,"type":"object","properties":{"additionalManifestEntries":{"type":"array","items":{"anyOf":[{"$ref":"#/definitions/ManifestEntry"},{"type":"string"}]}},"dontCacheBustURLsMatching":{"$ref":"#/definitions/RegExp"},"manifestTransforms":{"type":"array","items":{"typeof":"function"}},"maximumFileSizeToCacheInBytes":{"default":2097152,"type":"number"},"modifyURLPrefix":{"type":"object","additionalProperties":{"type":"string"}},"globFollow":{"default":true,"type":"boolean"},"globIgnores":{"default":["**/node_modules/**/*"],"type":"array","items":{"type":"string"}},"globPatterns":{"default":["**/*.{js,css,html}"],"type":"array","items":{"type":"string"}},"globStrict":{"default":true,"type":"boolean"},"templatedURLs":{"type":"object","additionalProperties":{"anyOf":[{"type":"array","items":{"type":"string"}},{"type":"string"}]}},"globDirectory":{"type":"string"}},"required":["globDirectory"],"definitions":{"ManifestEntry":{"type":"object","properties":{"integrity":{"type":"string"},"revision":{"type":["null","string"]},"url":{"type":"string"}},"additionalProperties":false,"required":["revision","url"]},"RegExp":{"type":"object","properties":{"source":{"type":"string"},"global":{"type":"boolean"},"ignoreCase":{"type":"boolean"},"multiline":{"type":"boolean"},"lastIndex":{"type":"number"},"flags":{"type":"string"},"sticky":{"type":"boolean"},"unicode":{"type":"boolean"},"dotAll":{"type":"boolean"}},"additionalProperties":false,"required":["dotAll","flags","global","ignoreCase","lastIndex","multiline","source","sticky","unicode"]},"GoogleAnalyticsInitializeOptions":{"type":"object","properties":{"cacheName":{"type":"string"},"parameterOverrides":{"type":"object","additionalProperties":{"type":"string"}},"hitFilter":{"type":"object","additionalProperties":false}},"additionalProperties":false},"RuntimeCaching":{"type":"object","properties":{"handler":{"anyOf":[{"$ref":"#/definitions/RouteHandlerCallback"},{"$ref":"#/definitions/RouteHandlerObject"},{"enum":["CacheFirst","CacheOnly","NetworkFirst","NetworkOnly","StaleWhileRevalidate"],"type":"string"}]},"method":{"enum":["DELETE","GET","HEAD","PATCH","POST","PUT"],"type":"string"},"options":{"type":"object","properties":{"backgroundSync":{"type":"object","properties":{"name":{"type":"string"},"options":{"$ref":"#/definitions/QueueOptions"}},"additionalProperties":false,"required":["name"]},"broadcastUpdate":{"type":"object","properties":{"channelName":{"type":"string"},"options":{"$ref":"#/definitions/BroadcastCacheUpdateOptions"}},"additionalProperties":false,"required":["options"]},"cacheableResponse":{"$ref":"#/definitions/CacheableResponseOptions"},"cacheName":{"type":["null","string"]},"expiration":{"$ref":"#/definitions/ExpirationPluginOptions"},"networkTimeoutSeconds":{"type":"number"},"plugins":{"type":"array","items":{"$ref":"#/definitions/WorkboxPlugin"}},"precacheFallback":{"type":"object","properties":{"fallbackURL":{"type":"string"}},"additionalProperties":false,"required":["fallbackURL"]},"fetchOptions":{"$ref":"#/definitions/RequestInit"},"matchOptions":{"$ref":"#/definitions/CacheQueryOptions"}},"additionalProperties":false},"urlPattern":{"anyOf":[{"$ref":"#/definitions/RegExp"},{"$ref":"#/definitions/RouteMatchCallback"},{"type":"string"}]}},"additionalProperties":false,"required":["handler","urlPattern"]},"RouteHandlerCallback":{"description":"The \"handler\" callback is invoked whenever a `Router` matches a URL/Request\nto a `Route` via its `RouteMatchCallback`. This handler callback should\nreturn a `Promise` that resolves with a `Response`.\n\nIf a non-empty array or object is returned by the `RouteMatchCallback` it\nwill be passed in as this handler's `options.params` argument.","type":"object","additionalProperties":false},"RouteHandlerObject":{"description":"An object with a `handle` method of type `RouteHandlerCallback`.\n\nA `Route` object can be created with either an `RouteHandlerCallback`\nfunction or this `RouteHandler` object. The benefit of the `RouteHandler`\nis it can be extended (as is done by the `workbox-strategies` package).","type":"object","properties":{"handle":{"$ref":"#/definitions/RouteHandlerCallback"}},"additionalProperties":false,"required":["handle"]},"QueueOptions":{"type":"object","properties":{"onSync":{"$ref":"#/definitions/OnSyncCallback"},"maxRetentionTime":{"type":"number"}},"additionalProperties":false},"OnSyncCallback":{"type":"object","additionalProperties":false},"BroadcastCacheUpdateOptions":{"type":"object","properties":{"headersToCheck":{"type":"array","items":{"type":"string"}},"generatePayload":{"type":"object","additionalProperties":false}},"additionalProperties":false},"CacheableResponseOptions":{"type":"object","properties":{"statuses":{"type":"array","items":{"type":"number"}},"headers":{"type":"object","additionalProperties":{"type":"string"}}},"additionalProperties":false},"ExpirationPluginOptions":{"type":"object","properties":{"maxEntries":{"type":"number"},"maxAgeSeconds":{"type":"number"},"matchOptions":{"$ref":"#/definitions/CacheQueryOptions"},"purgeOnQuotaError":{"type":"boolean"}},"additionalProperties":false},"CacheQueryOptions":{"type":"object","properties":{"ignoreMethod":{"type":"boolean"},"ignoreSearch":{"type":"boolean"},"ignoreVary":{"type":"boolean"}},"additionalProperties":false},"WorkboxPlugin":{"description":"An object with optional lifecycle callback properties for the fetch and\ncache operations.","type":"object","properties":{"cacheDidUpdate":{"$ref":"#/definitions/CacheDidUpdateCallback"},"cachedResponseWillBeUsed":{"$ref":"#/definitions/CachedResponseWillBeUsedCallback"},"cacheKeyWillBeUsed":{"$ref":"#/definitions/CacheKeyWillBeUsedCallback"},"cacheWillUpdate":{"$ref":"#/definitions/CacheWillUpdateCallback"},"fetchDidFail":{"$ref":"#/definitions/FetchDidFailCallback"},"fetchDidSucceed":{"$ref":"#/definitions/FetchDidSucceedCallback"},"handlerDidComplete":{"$ref":"#/definitions/HandlerDidCompleteCallback"},"handlerDidError":{"$ref":"#/definitions/HandlerDidErrorCallback"},"handlerDidRespond":{"$ref":"#/definitions/HandlerDidRespondCallback"},"handlerWillRespond":{"$ref":"#/definitions/HandlerWillRespondCallback"},"handlerWillStart":{"$ref":"#/definitions/HandlerWillStartCallback"},"requestWillFetch":{"$ref":"#/definitions/RequestWillFetchCallback"}},"additionalProperties":false},"CacheDidUpdateCallback":{"type":"object","additionalProperties":false},"CachedResponseWillBeUsedCallback":{"type":"object","additionalProperties":false},"CacheKeyWillBeUsedCallback":{"type":"object","additionalProperties":false},"CacheWillUpdateCallback":{"type":"object","additionalProperties":false},"FetchDidFailCallback":{"type":"object","additionalProperties":false},"FetchDidSucceedCallback":{"type":"object","additionalProperties":false},"HandlerDidCompleteCallback":{"type":"object","additionalProperties":false},"HandlerDidErrorCallback":{"type":"object","additionalProperties":false},"HandlerDidRespondCallback":{"type":"object","additionalProperties":false},"HandlerWillRespondCallback":{"type":"object","additionalProperties":false},"HandlerWillStartCallback":{"type":"object","additionalProperties":false},"RequestWillFetchCallback":{"type":"object","additionalProperties":false},"RequestInit":{"type":"object","properties":{"body":{"anyOf":[{"$ref":"#/definitions/ArrayBuffer"},{"$ref":"#/definitions/ArrayBufferView"},{"$ref":"#/definitions/Blob"},{"$ref":"#/definitions/FormData"},{"$ref":"#/definitions/URLSearchParams"},{"$ref":"#/definitions/ReadableStream"},{"type":["null","string"]}]},"cache":{"enum":["default","force-cache","no-cache","no-store","only-if-cached","reload"],"type":"string"},"credentials":{"enum":["include","omit","same-origin"],"type":"string"},"headers":{"anyOf":[{"$ref":"#/definitions/Headers"},{"type":"array","items":{"type":"array","items":{"type":"string"}}},{"$ref":"#/definitions/Record"}]},"integrity":{"type":"string"},"keepalive":{"type":"boolean"},"method":{"type":"string"},"mode":{"enum":["cors","navigate","no-cors","same-origin"],"type":"string"},"redirect":{"enum":["error","follow","manual"],"type":"string"},"referrer":{"type":"string"},"referrerPolicy":{"enum":["","no-referrer","no-referrer-when-downgrade","origin","origin-when-cross-origin","same-origin","strict-origin","strict-origin-when-cross-origin","unsafe-url"],"type":"string"},"signal":{"anyOf":[{"$ref":"#/definitions/AbortSignal"},{"type":"null"}]},"window":{}},"additionalProperties":false},"ArrayBuffer":{"type":"object","properties":{"byteLength":{"type":"number"},"__@toStringTag":{"type":"string"}},"additionalProperties":false,"required":["__@toStringTag","byteLength"]},"ArrayBufferView":{"type":"object","properties":{"buffer":{"anyOf":[{"$ref":"#/definitions/ArrayBuffer"},{"$ref":"#/definitions/SharedArrayBuffer"}]},"byteLength":{"type":"number"},"byteOffset":{"type":"number"}},"additionalProperties":false,"required":["buffer","byteLength","byteOffset"]},"SharedArrayBuffer":{"type":"object","properties":{"byteLength":{"type":"number"},"__@species":{"$ref":"#/definitions/SharedArrayBuffer"},"__@toStringTag":{"type":"string","enum":["SharedArrayBuffer"]}},"additionalProperties":false,"required":["__@species","__@toStringTag","byteLength"]},"Blob":{"type":"object","properties":{"size":{"type":"number"},"type":{"type":"string"}},"additionalProperties":false,"required":["size","type"]},"FormData":{"type":"object","additionalProperties":false},"URLSearchParams":{"type":"object","additionalProperties":false},"ReadableStream":{"type":"object","properties":{"locked":{"type":"boolean"}},"additionalProperties":false,"required":["locked"]},"Headers":{"type":"object","additionalProperties":false},"Record":{"type":"object","additionalProperties":false},"AbortSignal":{"type":"object","properties":{"aborted":{"type":"boolean"},"onabort":{"anyOf":[{"type":"object","additionalProperties":false},{"type":"null"}]}},"additionalProperties":false,"required":["aborted","onabort"]},"RouteMatchCallback":{"description":"The \"match\" callback is used to determine if a `Route` should apply for a\nparticular URL and request. When matching occurs in response to a fetch\nevent from the client, the `event` object is also supplied. However, since\nthe match callback can be invoked outside of a fetch event, matching logic\nshould not assume the `event` object will always be available.\nIf the match callback returns a truthy value, the matching route's\n`RouteHandlerCallback` will be invoked immediately. If the value returned\nis a non-empty array or object, that value will be set on the handler's\n`options.params` argument.","additionalProperties":false,"typeof":"function"}},"$schema":"http://json-schema.org/draft-07/schema#"} diff --git a/packages/workbox-build/src/schema/InjectManifestOptions.json b/packages/workbox-build/src/schema/InjectManifestOptions.json index 56650898e..e2659edfb 100644 --- a/packages/workbox-build/src/schema/InjectManifestOptions.json +++ b/packages/workbox-build/src/schema/InjectManifestOptions.json @@ -1 +1 @@ -{"additionalProperties":false,"type":"object","properties":{"additionalManifestEntries":{"type":"array","items":{"anyOf":[{"$ref":"#/definitions/ManifestEntry"},{"type":"string"}]}},"dontCacheBustURLsMatching":{"$ref":"#/definitions/RegExp"},"manifestTransforms":{"type":"array","items":{"typeof":"function"}},"maximumFileSizeToCacheInBytes":{"default":2097152,"type":"number"},"modifyURLPrefix":{"type":"object","additionalProperties":{"type":"string"}},"globDirectory":{"type":"string"},"globFollow":{"default":true,"type":"boolean"},"globIgnores":{"default":["**/node_modules/**/*"],"type":"array","items":{"type":"string"}},"globPatterns":{"default":["**/*.{js,css,html}"],"type":"array","items":{"type":"string"}},"globStrict":{"default":true,"type":"boolean"},"templatedURLs":{"type":"object","additionalProperties":{"anyOf":[{"type":"array","items":{"type":"string"}},{"type":"string"}]}},"injectionPoint":{"default":"self.__WB_MANIFEST","type":"string"},"swSrc":{"type":"string"},"swDest":{"type":"string"}},"required":["globDirectory","swDest","swSrc"],"definitions":{"ManifestEntry":{"type":"object","properties":{"integrity":{"type":"string"},"revision":{"type":["null","string"]},"url":{"type":"string"}},"additionalProperties":false,"required":["revision","url"]},"RegExp":{"type":"object","properties":{"source":{"type":"string"},"global":{"type":"boolean"},"ignoreCase":{"type":"boolean"},"multiline":{"type":"boolean"},"lastIndex":{"type":"number"},"flags":{"type":"string"},"sticky":{"type":"boolean"},"unicode":{"type":"boolean"},"dotAll":{"type":"boolean"}},"additionalProperties":false,"required":["dotAll","flags","global","ignoreCase","lastIndex","multiline","source","sticky","unicode"]},"GoogleAnalyticsInitializeOptions":{"type":"object","properties":{"cacheName":{"type":"string"},"parameterOverrides":{"type":"object","additionalProperties":{"type":"string"}},"hitFilter":{"type":"object","additionalProperties":false}},"additionalProperties":false},"RuntimeCaching":{"type":"object","properties":{"handler":{"anyOf":[{"$ref":"#/definitions/RouteHandlerCallback"},{"$ref":"#/definitions/RouteHandlerObject"},{"enum":["CacheFirst","CacheOnly","NetworkFirst","NetworkOnly","StaleWhileRevalidate"],"type":"string"}]},"method":{"enum":["DELETE","GET","HEAD","PATCH","POST","PUT"],"type":"string"},"options":{"type":"object","properties":{"backgroundSync":{"type":"object","properties":{"name":{"type":"string"},"options":{"$ref":"#/definitions/QueueOptions"}},"additionalProperties":false,"required":["name"]},"broadcastUpdate":{"type":"object","properties":{"channelName":{"type":"string"},"options":{"$ref":"#/definitions/BroadcastCacheUpdateOptions"}},"additionalProperties":false,"required":["options"]},"cacheableResponse":{"$ref":"#/definitions/CacheableResponseOptions"},"cacheName":{"type":["null","string"]},"expiration":{"$ref":"#/definitions/ExpirationPluginOptions"},"networkTimeoutSeconds":{"type":"number"},"plugins":{"type":"array","items":{"$ref":"#/definitions/WorkboxPlugin"}},"precacheFallback":{"type":"object","properties":{"fallbackURL":{"type":"string"}},"additionalProperties":false,"required":["fallbackURL"]},"fetchOptions":{"$ref":"#/definitions/RequestInit"},"matchOptions":{"$ref":"#/definitions/CacheQueryOptions"}},"additionalProperties":false},"urlPattern":{"anyOf":[{"$ref":"#/definitions/RegExp"},{"$ref":"#/definitions/RouteMatchCallback"},{"type":"string"}]}},"additionalProperties":false,"required":["handler","urlPattern"]},"RouteHandlerCallback":{"description":"The \"handler\" callback is invoked whenever a `Router` matches a URL/Request\nto a `Route` via its `RouteMatchCallback`. This handler callback should\nreturn a `Promise` that resolves with a `Response`.\n\nIf a non-empty array or object is returned by the `RouteMatchCallback` it\nwill be passed in as this handler's `options.params` argument.","type":"object","additionalProperties":false},"RouteHandlerObject":{"description":"An object with a `handle` method of type `RouteHandlerCallback`.\n\nA `Route` object can be created with either an `RouteHandlerCallback`\nfunction or this `RouteHandler` object. The benefit of the `RouteHandler`\nis it can be extended (as is done by the `workbox-strategies` package).","type":"object","properties":{"handle":{"$ref":"#/definitions/RouteHandlerCallback"}},"additionalProperties":false,"required":["handle"]},"QueueOptions":{"type":"object","properties":{"onSync":{"$ref":"#/definitions/OnSyncCallback"},"maxRetentionTime":{"type":"number"}},"additionalProperties":false},"OnSyncCallback":{"type":"object","additionalProperties":false},"BroadcastCacheUpdateOptions":{"type":"object","properties":{"headersToCheck":{"type":"array","items":{"type":"string"}},"generatePayload":{"type":"object","additionalProperties":false}},"additionalProperties":false},"CacheableResponseOptions":{"type":"object","properties":{"statuses":{"type":"array","items":{"type":"number"}},"headers":{"type":"object","additionalProperties":{"type":"string"}}},"additionalProperties":false},"ExpirationPluginOptions":{"type":"object","properties":{"maxEntries":{"type":"number"},"maxAgeSeconds":{"type":"number"},"matchOptions":{"$ref":"#/definitions/CacheQueryOptions"},"purgeOnQuotaError":{"type":"boolean"}},"additionalProperties":false},"CacheQueryOptions":{"type":"object","properties":{"ignoreMethod":{"type":"boolean"},"ignoreSearch":{"type":"boolean"},"ignoreVary":{"type":"boolean"}},"additionalProperties":false},"WorkboxPlugin":{"description":"An object with optional lifecycle callback properties for the fetch and\ncache operations.","type":"object","properties":{"cacheDidUpdate":{"$ref":"#/definitions/CacheDidUpdateCallback"},"cachedResponseWillBeUsed":{"$ref":"#/definitions/CachedResponseWillBeUsedCallback"},"cacheKeyWillBeUsed":{"$ref":"#/definitions/CacheKeyWillBeUsedCallback"},"cacheWillUpdate":{"$ref":"#/definitions/CacheWillUpdateCallback"},"fetchDidFail":{"$ref":"#/definitions/FetchDidFailCallback"},"fetchDidSucceed":{"$ref":"#/definitions/FetchDidSucceedCallback"},"handlerDidComplete":{"$ref":"#/definitions/HandlerDidCompleteCallback"},"handlerDidError":{"$ref":"#/definitions/HandlerDidErrorCallback"},"handlerDidRespond":{"$ref":"#/definitions/HandlerDidRespondCallback"},"handlerWillRespond":{"$ref":"#/definitions/HandlerWillRespondCallback"},"handlerWillStart":{"$ref":"#/definitions/HandlerWillStartCallback"},"requestWillFetch":{"$ref":"#/definitions/RequestWillFetchCallback"}},"additionalProperties":false},"CacheDidUpdateCallback":{"type":"object","additionalProperties":false},"CachedResponseWillBeUsedCallback":{"type":"object","additionalProperties":false},"CacheKeyWillBeUsedCallback":{"type":"object","additionalProperties":false},"CacheWillUpdateCallback":{"type":"object","additionalProperties":false},"FetchDidFailCallback":{"type":"object","additionalProperties":false},"FetchDidSucceedCallback":{"type":"object","additionalProperties":false},"HandlerDidCompleteCallback":{"type":"object","additionalProperties":false},"HandlerDidErrorCallback":{"type":"object","additionalProperties":false},"HandlerDidRespondCallback":{"type":"object","additionalProperties":false},"HandlerWillRespondCallback":{"type":"object","additionalProperties":false},"HandlerWillStartCallback":{"type":"object","additionalProperties":false},"RequestWillFetchCallback":{"type":"object","additionalProperties":false},"RequestInit":{"type":"object","properties":{"body":{"anyOf":[{"$ref":"#/definitions/ArrayBuffer"},{"$ref":"#/definitions/ArrayBufferView"},{"$ref":"#/definitions/Blob"},{"$ref":"#/definitions/FormData"},{"$ref":"#/definitions/URLSearchParams"},{"$ref":"#/definitions/ReadableStream"},{"type":["null","string"]}]},"cache":{"enum":["default","force-cache","no-cache","no-store","only-if-cached","reload"],"type":"string"},"credentials":{"enum":["include","omit","same-origin"],"type":"string"},"headers":{"anyOf":[{"$ref":"#/definitions/Headers"},{"type":"array","items":{"type":"array","items":{"type":"string"}}},{"$ref":"#/definitions/Record"}]},"integrity":{"type":"string"},"keepalive":{"type":"boolean"},"method":{"type":"string"},"mode":{"enum":["cors","navigate","no-cors","same-origin"],"type":"string"},"redirect":{"enum":["error","follow","manual"],"type":"string"},"referrer":{"type":"string"},"referrerPolicy":{"enum":["","no-referrer","no-referrer-when-downgrade","origin","origin-when-cross-origin","same-origin","strict-origin","strict-origin-when-cross-origin","unsafe-url"],"type":"string"},"signal":{"anyOf":[{"$ref":"#/definitions/AbortSignal"},{"type":"null"}]},"window":{}},"additionalProperties":false},"ArrayBuffer":{"type":"object","properties":{"byteLength":{"type":"number"},"__@toStringTag":{"type":"string"}},"additionalProperties":false,"required":["__@toStringTag","byteLength"]},"ArrayBufferView":{"type":"object","properties":{"buffer":{"anyOf":[{"$ref":"#/definitions/ArrayBuffer"},{"$ref":"#/definitions/SharedArrayBuffer"}]},"byteLength":{"type":"number"},"byteOffset":{"type":"number"}},"additionalProperties":false,"required":["buffer","byteLength","byteOffset"]},"SharedArrayBuffer":{"type":"object","properties":{"byteLength":{"type":"number"},"__@species":{"$ref":"#/definitions/SharedArrayBuffer"},"__@toStringTag":{"type":"string","enum":["SharedArrayBuffer"]}},"additionalProperties":false,"required":["__@species","__@toStringTag","byteLength"]},"Blob":{"type":"object","properties":{"size":{"type":"number"},"type":{"type":"string"}},"additionalProperties":false,"required":["size","type"]},"FormData":{"type":"object","additionalProperties":false},"URLSearchParams":{"type":"object","additionalProperties":false},"ReadableStream":{"type":"object","properties":{"locked":{"type":"boolean"}},"additionalProperties":false,"required":["locked"]},"Headers":{"type":"object","additionalProperties":false},"Record":{"type":"object","additionalProperties":false},"AbortSignal":{"type":"object","properties":{"aborted":{"type":"boolean"},"onabort":{"anyOf":[{"type":"object","additionalProperties":false},{"type":"null"}]}},"additionalProperties":false,"required":["aborted","onabort"]},"RouteMatchCallback":{"description":"The \"match\" callback is used to determine if a `Route` should apply for a\nparticular URL and request. When matching occurs in response to a fetch\nevent from the client, the `event` object is also supplied. However, since\nthe match callback can be invoked outside of a fetch event, matching logic\nshould not assume the `event` object will always be available.\nIf the match callback returns a truthy value, the matching route's\n`RouteHandlerCallback` will be invoked immediately. If the value returned\nis a non-empty array or object, that value will be set on the handler's\n`options.params` argument.","additionalProperties":false,"typeof":"function"}},"$schema":"http://json-schema.org/draft-07/schema#"} +{"additionalProperties":false,"type":"object","properties":{"additionalManifestEntries":{"type":"array","items":{"anyOf":[{"$ref":"#/definitions/ManifestEntry"},{"type":"string"}]}},"dontCacheBustURLsMatching":{"$ref":"#/definitions/RegExp"},"manifestTransforms":{"type":"array","items":{"typeof":"function"}},"maximumFileSizeToCacheInBytes":{"default":2097152,"type":"number"},"modifyURLPrefix":{"type":"object","additionalProperties":{"type":"string"}},"globFollow":{"default":true,"type":"boolean"},"globIgnores":{"default":["**/node_modules/**/*"],"type":"array","items":{"type":"string"}},"globPatterns":{"default":["**/*.{js,css,html}"],"type":"array","items":{"type":"string"}},"globStrict":{"default":true,"type":"boolean"},"templatedURLs":{"type":"object","additionalProperties":{"anyOf":[{"type":"array","items":{"type":"string"}},{"type":"string"}]}},"injectionPoint":{"default":"self.__WB_MANIFEST","type":"string"},"swSrc":{"type":"string"},"swDest":{"type":"string"},"globDirectory":{"type":"string"}},"required":["globDirectory","swDest","swSrc"],"definitions":{"ManifestEntry":{"type":"object","properties":{"integrity":{"type":"string"},"revision":{"type":["null","string"]},"url":{"type":"string"}},"additionalProperties":false,"required":["revision","url"]},"RegExp":{"type":"object","properties":{"source":{"type":"string"},"global":{"type":"boolean"},"ignoreCase":{"type":"boolean"},"multiline":{"type":"boolean"},"lastIndex":{"type":"number"},"flags":{"type":"string"},"sticky":{"type":"boolean"},"unicode":{"type":"boolean"},"dotAll":{"type":"boolean"}},"additionalProperties":false,"required":["dotAll","flags","global","ignoreCase","lastIndex","multiline","source","sticky","unicode"]},"GoogleAnalyticsInitializeOptions":{"type":"object","properties":{"cacheName":{"type":"string"},"parameterOverrides":{"type":"object","additionalProperties":{"type":"string"}},"hitFilter":{"type":"object","additionalProperties":false}},"additionalProperties":false},"RuntimeCaching":{"type":"object","properties":{"handler":{"anyOf":[{"$ref":"#/definitions/RouteHandlerCallback"},{"$ref":"#/definitions/RouteHandlerObject"},{"enum":["CacheFirst","CacheOnly","NetworkFirst","NetworkOnly","StaleWhileRevalidate"],"type":"string"}]},"method":{"enum":["DELETE","GET","HEAD","PATCH","POST","PUT"],"type":"string"},"options":{"type":"object","properties":{"backgroundSync":{"type":"object","properties":{"name":{"type":"string"},"options":{"$ref":"#/definitions/QueueOptions"}},"additionalProperties":false,"required":["name"]},"broadcastUpdate":{"type":"object","properties":{"channelName":{"type":"string"},"options":{"$ref":"#/definitions/BroadcastCacheUpdateOptions"}},"additionalProperties":false,"required":["options"]},"cacheableResponse":{"$ref":"#/definitions/CacheableResponseOptions"},"cacheName":{"type":["null","string"]},"expiration":{"$ref":"#/definitions/ExpirationPluginOptions"},"networkTimeoutSeconds":{"type":"number"},"plugins":{"type":"array","items":{"$ref":"#/definitions/WorkboxPlugin"}},"precacheFallback":{"type":"object","properties":{"fallbackURL":{"type":"string"}},"additionalProperties":false,"required":["fallbackURL"]},"fetchOptions":{"$ref":"#/definitions/RequestInit"},"matchOptions":{"$ref":"#/definitions/CacheQueryOptions"}},"additionalProperties":false},"urlPattern":{"anyOf":[{"$ref":"#/definitions/RegExp"},{"$ref":"#/definitions/RouteMatchCallback"},{"type":"string"}]}},"additionalProperties":false,"required":["handler","urlPattern"]},"RouteHandlerCallback":{"description":"The \"handler\" callback is invoked whenever a `Router` matches a URL/Request\nto a `Route` via its `RouteMatchCallback`. This handler callback should\nreturn a `Promise` that resolves with a `Response`.\n\nIf a non-empty array or object is returned by the `RouteMatchCallback` it\nwill be passed in as this handler's `options.params` argument.","type":"object","additionalProperties":false},"RouteHandlerObject":{"description":"An object with a `handle` method of type `RouteHandlerCallback`.\n\nA `Route` object can be created with either an `RouteHandlerCallback`\nfunction or this `RouteHandler` object. The benefit of the `RouteHandler`\nis it can be extended (as is done by the `workbox-strategies` package).","type":"object","properties":{"handle":{"$ref":"#/definitions/RouteHandlerCallback"}},"additionalProperties":false,"required":["handle"]},"QueueOptions":{"type":"object","properties":{"onSync":{"$ref":"#/definitions/OnSyncCallback"},"maxRetentionTime":{"type":"number"}},"additionalProperties":false},"OnSyncCallback":{"type":"object","additionalProperties":false},"BroadcastCacheUpdateOptions":{"type":"object","properties":{"headersToCheck":{"type":"array","items":{"type":"string"}},"generatePayload":{"type":"object","additionalProperties":false}},"additionalProperties":false},"CacheableResponseOptions":{"type":"object","properties":{"statuses":{"type":"array","items":{"type":"number"}},"headers":{"type":"object","additionalProperties":{"type":"string"}}},"additionalProperties":false},"ExpirationPluginOptions":{"type":"object","properties":{"maxEntries":{"type":"number"},"maxAgeSeconds":{"type":"number"},"matchOptions":{"$ref":"#/definitions/CacheQueryOptions"},"purgeOnQuotaError":{"type":"boolean"}},"additionalProperties":false},"CacheQueryOptions":{"type":"object","properties":{"ignoreMethod":{"type":"boolean"},"ignoreSearch":{"type":"boolean"},"ignoreVary":{"type":"boolean"}},"additionalProperties":false},"WorkboxPlugin":{"description":"An object with optional lifecycle callback properties for the fetch and\ncache operations.","type":"object","properties":{"cacheDidUpdate":{"$ref":"#/definitions/CacheDidUpdateCallback"},"cachedResponseWillBeUsed":{"$ref":"#/definitions/CachedResponseWillBeUsedCallback"},"cacheKeyWillBeUsed":{"$ref":"#/definitions/CacheKeyWillBeUsedCallback"},"cacheWillUpdate":{"$ref":"#/definitions/CacheWillUpdateCallback"},"fetchDidFail":{"$ref":"#/definitions/FetchDidFailCallback"},"fetchDidSucceed":{"$ref":"#/definitions/FetchDidSucceedCallback"},"handlerDidComplete":{"$ref":"#/definitions/HandlerDidCompleteCallback"},"handlerDidError":{"$ref":"#/definitions/HandlerDidErrorCallback"},"handlerDidRespond":{"$ref":"#/definitions/HandlerDidRespondCallback"},"handlerWillRespond":{"$ref":"#/definitions/HandlerWillRespondCallback"},"handlerWillStart":{"$ref":"#/definitions/HandlerWillStartCallback"},"requestWillFetch":{"$ref":"#/definitions/RequestWillFetchCallback"}},"additionalProperties":false},"CacheDidUpdateCallback":{"type":"object","additionalProperties":false},"CachedResponseWillBeUsedCallback":{"type":"object","additionalProperties":false},"CacheKeyWillBeUsedCallback":{"type":"object","additionalProperties":false},"CacheWillUpdateCallback":{"type":"object","additionalProperties":false},"FetchDidFailCallback":{"type":"object","additionalProperties":false},"FetchDidSucceedCallback":{"type":"object","additionalProperties":false},"HandlerDidCompleteCallback":{"type":"object","additionalProperties":false},"HandlerDidErrorCallback":{"type":"object","additionalProperties":false},"HandlerDidRespondCallback":{"type":"object","additionalProperties":false},"HandlerWillRespondCallback":{"type":"object","additionalProperties":false},"HandlerWillStartCallback":{"type":"object","additionalProperties":false},"RequestWillFetchCallback":{"type":"object","additionalProperties":false},"RequestInit":{"type":"object","properties":{"body":{"anyOf":[{"$ref":"#/definitions/ArrayBuffer"},{"$ref":"#/definitions/ArrayBufferView"},{"$ref":"#/definitions/Blob"},{"$ref":"#/definitions/FormData"},{"$ref":"#/definitions/URLSearchParams"},{"$ref":"#/definitions/ReadableStream"},{"type":["null","string"]}]},"cache":{"enum":["default","force-cache","no-cache","no-store","only-if-cached","reload"],"type":"string"},"credentials":{"enum":["include","omit","same-origin"],"type":"string"},"headers":{"anyOf":[{"$ref":"#/definitions/Headers"},{"type":"array","items":{"type":"array","items":{"type":"string"}}},{"$ref":"#/definitions/Record"}]},"integrity":{"type":"string"},"keepalive":{"type":"boolean"},"method":{"type":"string"},"mode":{"enum":["cors","navigate","no-cors","same-origin"],"type":"string"},"redirect":{"enum":["error","follow","manual"],"type":"string"},"referrer":{"type":"string"},"referrerPolicy":{"enum":["","no-referrer","no-referrer-when-downgrade","origin","origin-when-cross-origin","same-origin","strict-origin","strict-origin-when-cross-origin","unsafe-url"],"type":"string"},"signal":{"anyOf":[{"$ref":"#/definitions/AbortSignal"},{"type":"null"}]},"window":{}},"additionalProperties":false},"ArrayBuffer":{"type":"object","properties":{"byteLength":{"type":"number"},"__@toStringTag":{"type":"string"}},"additionalProperties":false,"required":["__@toStringTag","byteLength"]},"ArrayBufferView":{"type":"object","properties":{"buffer":{"anyOf":[{"$ref":"#/definitions/ArrayBuffer"},{"$ref":"#/definitions/SharedArrayBuffer"}]},"byteLength":{"type":"number"},"byteOffset":{"type":"number"}},"additionalProperties":false,"required":["buffer","byteLength","byteOffset"]},"SharedArrayBuffer":{"type":"object","properties":{"byteLength":{"type":"number"},"__@species":{"$ref":"#/definitions/SharedArrayBuffer"},"__@toStringTag":{"type":"string","enum":["SharedArrayBuffer"]}},"additionalProperties":false,"required":["__@species","__@toStringTag","byteLength"]},"Blob":{"type":"object","properties":{"size":{"type":"number"},"type":{"type":"string"}},"additionalProperties":false,"required":["size","type"]},"FormData":{"type":"object","additionalProperties":false},"URLSearchParams":{"type":"object","additionalProperties":false},"ReadableStream":{"type":"object","properties":{"locked":{"type":"boolean"}},"additionalProperties":false,"required":["locked"]},"Headers":{"type":"object","additionalProperties":false},"Record":{"type":"object","additionalProperties":false},"AbortSignal":{"type":"object","properties":{"aborted":{"type":"boolean"},"onabort":{"anyOf":[{"type":"object","additionalProperties":false},{"type":"null"}]}},"additionalProperties":false,"required":["aborted","onabort"]},"RouteMatchCallback":{"description":"The \"match\" callback is used to determine if a `Route` should apply for a\nparticular URL and request. When matching occurs in response to a fetch\nevent from the client, the `event` object is also supplied. However, since\nthe match callback can be invoked outside of a fetch event, matching logic\nshould not assume the `event` object will always be available.\nIf the match callback returns a truthy value, the matching route's\n`RouteHandlerCallback` will be invoked immediately. If the value returned\nis a non-empty array or object, that value will be set on the handler's\n`options.params` argument.","additionalProperties":false,"typeof":"function"}},"$schema":"http://json-schema.org/draft-07/schema#"} diff --git a/packages/workbox-build/src/types.ts b/packages/workbox-build/src/types.ts index 16205a65f..d5b021300 100644 --- a/packages/workbox-build/src/types.ts +++ b/packages/workbox-build/src/types.ts @@ -124,8 +124,18 @@ export interface GeneratePartial { sourcemap?: boolean; } -export interface GlobPartial { +// This needs to be set when using GetManifest or InjectManifest, but is +// optional when using GenerateSW if runtimeCaching is also used. This is +// enforced via runtime validation, and needs to be documented. +export interface RequiredGlobDirectoryPartial { globDirectory: string; +} + +export interface OptionalGlobDirectoryPartial { + globDirectory?: string; +} + +export interface GlobPartial { /** * @default true */ @@ -194,12 +204,13 @@ interface WebpackInjectManifestPartial { } export type GenerateSWOptions = BasePartial & GlobPartial & GeneratePartial & - RequiredSWDestPartial; + RequiredSWDestPartial & OptionalGlobDirectoryPartial -export type GetManifestOptions = BasePartial & GlobPartial; +export type GetManifestOptions = BasePartial & GlobPartial & + RequiredGlobDirectoryPartial; export type InjectManifestOptions = BasePartial & GlobPartial & InjectPartial & - RequiredSWDestPartial; + RequiredSWDestPartial & RequiredGlobDirectoryPartial; export type WebpackGenerateSWOptions = BasePartial & WebpackPartial & GeneratePartial & WebpackGenerateSWPartial; From dfafd9e0e6ff5eb09edbadf7de1bb67c78bf4f7c Mon Sep 17 00:00:00 2001 From: Jeff Posnick Date: Mon, 14 Jun 2021 16:06:34 -0400 Subject: [PATCH 61/80] InjectManifest tests --- test/workbox-build/node/inject-manifest.js | 81 +++++++--------------- 1 file changed, 25 insertions(+), 56 deletions(-) diff --git a/test/workbox-build/node/inject-manifest.js b/test/workbox-build/node/inject-manifest.js index 15fb8dbca..85cf98583 100644 --- a/test/workbox-build/node/inject-manifest.js +++ b/test/workbox-build/node/inject-manifest.js @@ -6,15 +6,20 @@ https://opensource.org/licenses/MIT. */ -const expect = require('chai').expect; +const chai = require('chai'); +const chaiAsPromised = require('chai-as-promised'); const fse = require('fs-extra'); const upath = require('upath'); const tempy = require('tempy'); const {errors} = require('../../../packages/workbox-build/build/lib/errors'); const {injectManifest} = require('../../../packages/workbox-build/build/inject-manifest'); +const {WorkboxConfigError} = require('../../../packages/workbox-build/build/lib/validate-options'); const validateServiceWorkerRuntime = require('../../../infra/testing/validator/service-worker-runtime'); +chai.use(chaiAsPromised); +const {expect} = chai; + describe(`[workbox-build] inject-manifest.js (End to End)`, function() { const GLOB_DIR = upath.join(__dirname, '..', 'static', 'example-project-1'); const SW_SRC_DIR = upath.join(__dirname, '..', 'static', 'sw-injections'); @@ -57,51 +62,36 @@ describe(`[workbox-build] inject-manifest.js (End to End)`, function() { describe('[workbox-build] required parameters', function() { for (const requiredParam of REQUIRED_PARAMS) { - it(`should reject with a ValidationError when '${requiredParam}' is missing`, async function() { + it(`should reject when '${requiredParam}' is missing`, async function() { const options = Object.assign({}, BASE_OPTIONS); delete options[requiredParam]; - try { - await injectManifest(options); - throw new Error('Unexpected success.'); - } catch (error) { - expect(error.name).to.eql('ValidationError'); - expect(error.details[0].context.key).to.eql(requiredParam); - } + await expect(injectManifest(options)).to.eventually.be.rejectedWith( + WorkboxConfigError, requiredParam); }); } }); describe('[workbox-build] unsupported parameters', function() { for (const unsupportedParam of UNSUPPORTED_PARAMS) { - it(`should reject with a ValidationError when '${unsupportedParam}' is present`, async function() { + it(`should reject when '${unsupportedParam}' is present`, async function() { const options = Object.assign({}, BASE_OPTIONS); options[unsupportedParam] = unsupportedParam; - try { - await injectManifest(options); - throw new Error('Unexpected success.'); - } catch (error) { - expect(error.name).to.eql('ValidationError'); - expect(error.details[0].context.key).to.eql(unsupportedParam); - } + await expect(injectManifest(options)).to.eventually.be.rejectedWith( + WorkboxConfigError, unsupportedParam); }); } }); describe('[workbox-build] invalid parameter values', function() { for (const param of SUPPORTED_PARAMS) { - it(`should reject with a ValidationError when '${param}' is null`, async function() { + it(`should reject when '${param}' is null`, async function() { const options = Object.assign({}, BASE_OPTIONS); options[param] = null; - try { - await injectManifest(options); - throw new Error('Unexpected success.'); - } catch (error) { - expect(error.name).to.eql('ValidationError'); - expect(error.details[0].context.key).to.eql(param); - } + await expect(injectManifest(options)).to.eventually.be.rejectedWith( + WorkboxConfigError, param); }); } }); @@ -112,12 +102,8 @@ describe(`[workbox-build] inject-manifest.js (End to End)`, function() { swSrc: 'DOES_NOT_EXIST', }); - try { - await injectManifest(options); - throw new Error('Unexpected success.'); - } catch (error) { - expect(error.message).to.have.string(errors['invalid-sw-src']); - } + await expect(injectManifest(options)).to.eventually.be.rejectedWith( + errors['invalid-sw-src']); }); it(`should throw the expected error when there is no match for 'injectionPoint'`, async function() { @@ -125,12 +111,8 @@ describe(`[workbox-build] inject-manifest.js (End to End)`, function() { swSrc: upath.join(SW_SRC_DIR, 'bad-no-injection.js'), }); - try { - await injectManifest(options); - throw new Error('Unexpected success.'); - } catch (error) { - expect(error.message).to.have.string(errors['injection-point-not-found']); - } + await expect(injectManifest(options)).to.eventually.be.rejectedWith( + errors['injection-point-not-found']); }); it(`should throw the expected error when there is no match for 'injectionPoint' and 'swSrc' and 'swDest' are the same`, async function() { @@ -140,12 +122,8 @@ describe(`[workbox-build] inject-manifest.js (End to End)`, function() { swDest: swFile, }); - try { - await injectManifest(options); - throw new Error('Unexpected success.'); - } catch (error) { - expect(error.message).to.have.string(errors['same-src-and-dest']); - } + await expect(injectManifest(options)).to.eventually.be.rejectedWith( + errors['same-src-and-dest']); }); it(`should throw the expected error when there are multiple matches for 'injectionPoint'`, async function() { @@ -153,12 +131,8 @@ describe(`[workbox-build] inject-manifest.js (End to End)`, function() { swSrc: upath.join(SW_SRC_DIR, 'bad-multiple-injection.js'), }); - try { - await injectManifest(options); - throw new Error('Unexpected success.'); - } catch (error) { - expect(error.message).to.have.string(errors['multiple-injection-points']); - } + await expect(injectManifest(options)).to.eventually.be.rejectedWith( + errors['multiple-injection-points']); }); }); @@ -450,13 +424,8 @@ describe(`[workbox-build] inject-manifest.js (End to End)`, function() { [option]: value, }); - try { - await injectManifest(options); - throw new Error('Unexpected success.'); - } catch (error) { - expect(error.name).to.eql('ValidationError'); - expect(error.details[0].context.key).to.eql(option); - } + await expect(injectManifest(options)).to.eventually.be.rejectedWith( + WorkboxConfigError, option); }); } }); From d50d4db173cc0afbc12e4a6fd5eaf8f842dc5119 Mon Sep 17 00:00:00 2001 From: Jeff Posnick Date: Mon, 14 Jun 2021 16:07:24 -0400 Subject: [PATCH 62/80] Test cleanup --- test/workbox-build/node/generate-sw.js | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/test/workbox-build/node/generate-sw.js b/test/workbox-build/node/generate-sw.js index 4e8fb186e..2536abb10 100644 --- a/test/workbox-build/node/generate-sw.js +++ b/test/workbox-build/node/generate-sw.js @@ -917,12 +917,8 @@ describe(`[workbox-build] generate-sw.js (End to End)`, function() { swDest, }); - try { - await generateSW(options); - throw new Error('Unexpected success.'); - } catch (error) { - expect(error.message).to.include(errors['invalid-network-timeout-seconds']); - } + await expect(generateSW(options)).to.eventually.be.rejectedWith( + errors['invalid-network-timeout-seconds']); }); it(`should support 'networkTimeoutSeconds' when handler is 'NetworkFirst'`, async function() { From 25cfa2f0bef822e728c728a6e58ede0622c767f6 Mon Sep 17 00:00:00 2001 From: Jeff Posnick Date: Mon, 14 Jun 2021 16:08:36 -0400 Subject: [PATCH 63/80] Fix a test --- test/workbox-build/node/lib/validate-options.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/test/workbox-build/node/lib/validate-options.js b/test/workbox-build/node/lib/validate-options.js index 041c02cdc..26cf17776 100644 --- a/test/workbox-build/node/lib/validate-options.js +++ b/test/workbox-build/node/lib/validate-options.js @@ -71,7 +71,9 @@ describe(`[workbox-build] entry-points/options/validate-options.js`, function() }, }); - const defaultOptions = validateOptions[func]({}); + const defaultOptions = validateOptions[func]({ + globDirectory: '.', + }); expect(defaultOptions).to.be.an('object'); }); } From 0cca50742b9dde67b727d5a860e29ebb6c616951 Mon Sep 17 00:00:00 2001 From: Jeff Posnick Date: Mon, 14 Jun 2021 16:20:08 -0400 Subject: [PATCH 64/80] Fix a config modification --- gulp-tasks/build-node-packages.js | 1 + packages/workbox-build/src/schema/GenerateSWOptions.json | 2 +- packages/workbox-build/src/schema/GetManifestOptions.json | 2 +- packages/workbox-build/src/schema/InjectManifestOptions.json | 2 +- .../workbox-build/src/schema/WebpackGenerateSWOptions.json | 2 +- .../src/schema/WebpackInjectManifestOptions.json | 2 +- packages/workbox-webpack-plugin/src/generate-sw.js | 4 ++-- test/workbox-webpack-plugin/node/v4/generate-sw.js | 2 +- 8 files changed, 9 insertions(+), 8 deletions(-) diff --git a/gulp-tasks/build-node-packages.js b/gulp-tasks/build-node-packages.js index 35f395bd0..393280a00 100644 --- a/gulp-tasks/build-node-packages.js +++ b/gulp-tasks/build-node-packages.js @@ -68,6 +68,7 @@ async function generateWorkboxBuildJSONSchema(packagePath) { } if (schema.definitions.RouteMatchCallback) { delete schema.definitions.RouteMatchCallback.type; + delete schema.definitions.RouteMatchCallback.additionalProperties; schema.definitions.RouteMatchCallback.typeof = 'function'; } await fse.writeJSON(upath.join(packagePath, 'src', 'schema', diff --git a/packages/workbox-build/src/schema/GenerateSWOptions.json b/packages/workbox-build/src/schema/GenerateSWOptions.json index 712191912..d8378a4af 100644 --- a/packages/workbox-build/src/schema/GenerateSWOptions.json +++ b/packages/workbox-build/src/schema/GenerateSWOptions.json @@ -1 +1 @@ -{"additionalProperties":false,"type":"object","properties":{"additionalManifestEntries":{"type":"array","items":{"anyOf":[{"$ref":"#/definitions/ManifestEntry"},{"type":"string"}]}},"dontCacheBustURLsMatching":{"$ref":"#/definitions/RegExp"},"manifestTransforms":{"type":"array","items":{"typeof":"function"}},"maximumFileSizeToCacheInBytes":{"default":2097152,"type":"number"},"modifyURLPrefix":{"type":"object","additionalProperties":{"type":"string"}},"globFollow":{"default":true,"type":"boolean"},"globIgnores":{"default":["**/node_modules/**/*"],"type":"array","items":{"type":"string"}},"globPatterns":{"default":["**/*.{js,css,html}"],"type":"array","items":{"type":"string"}},"globStrict":{"default":true,"type":"boolean"},"templatedURLs":{"type":"object","additionalProperties":{"anyOf":[{"type":"array","items":{"type":"string"}},{"type":"string"}]}},"babelPresetEnvTargets":{"default":["chrome >= 56"],"type":"array","items":{"type":"string"}},"cacheId":{"type":["null","string"]},"cleanupOutdatedCaches":{"default":false,"type":"boolean"},"clientsClaim":{"default":false,"type":"boolean"},"directoryIndex":{"type":["null","string"]},"disableDevLogs":{"default":false,"type":"boolean"},"ignoreURLParametersMatching":{"type":"array","items":{"$ref":"#/definitions/RegExp"}},"importScripts":{"type":"array","items":{"type":"string"}},"inlineWorkboxRuntime":{"default":false,"type":"boolean"},"mode":{"default":"production","type":["null","string"]},"navigateFallback":{"default":null,"type":["null","string"]},"navigateFallbackAllowlist":{"type":"array","items":{"$ref":"#/definitions/RegExp"}},"navigateFallbackDenylist":{"type":"array","items":{"$ref":"#/definitions/RegExp"}},"navigationPreload":{"description":"navigationPreload is only valid when runtimeCaching is configured. However,\nthis can't be expressed via TypeScript, so it's enforced via runtime logic.","default":false,"type":"boolean"},"offlineGoogleAnalytics":{"default":false,"anyOf":[{"$ref":"#/definitions/GoogleAnalyticsInitializeOptions"},{"type":"boolean"}]},"runtimeCaching":{"type":"array","items":{"$ref":"#/definitions/RuntimeCaching"}},"skipWaiting":{"default":false,"type":"boolean"},"sourcemap":{"default":true,"type":"boolean"},"swDest":{"type":"string"},"globDirectory":{"type":"string"}},"required":["swDest"],"definitions":{"ManifestEntry":{"type":"object","properties":{"integrity":{"type":"string"},"revision":{"type":["null","string"]},"url":{"type":"string"}},"additionalProperties":false,"required":["revision","url"]},"RegExp":{"type":"object","properties":{"source":{"type":"string"},"global":{"type":"boolean"},"ignoreCase":{"type":"boolean"},"multiline":{"type":"boolean"},"lastIndex":{"type":"number"},"flags":{"type":"string"},"sticky":{"type":"boolean"},"unicode":{"type":"boolean"},"dotAll":{"type":"boolean"}},"additionalProperties":false,"required":["dotAll","flags","global","ignoreCase","lastIndex","multiline","source","sticky","unicode"]},"GoogleAnalyticsInitializeOptions":{"type":"object","properties":{"cacheName":{"type":"string"},"parameterOverrides":{"type":"object","additionalProperties":{"type":"string"}},"hitFilter":{"type":"object","additionalProperties":false}},"additionalProperties":false},"RuntimeCaching":{"type":"object","properties":{"handler":{"anyOf":[{"$ref":"#/definitions/RouteHandlerCallback"},{"$ref":"#/definitions/RouteHandlerObject"},{"enum":["CacheFirst","CacheOnly","NetworkFirst","NetworkOnly","StaleWhileRevalidate"],"type":"string"}]},"method":{"enum":["DELETE","GET","HEAD","PATCH","POST","PUT"],"type":"string"},"options":{"type":"object","properties":{"backgroundSync":{"type":"object","properties":{"name":{"type":"string"},"options":{"$ref":"#/definitions/QueueOptions"}},"additionalProperties":false,"required":["name"]},"broadcastUpdate":{"type":"object","properties":{"channelName":{"type":"string"},"options":{"$ref":"#/definitions/BroadcastCacheUpdateOptions"}},"additionalProperties":false,"required":["options"]},"cacheableResponse":{"$ref":"#/definitions/CacheableResponseOptions"},"cacheName":{"type":["null","string"]},"expiration":{"$ref":"#/definitions/ExpirationPluginOptions"},"networkTimeoutSeconds":{"type":"number"},"plugins":{"type":"array","items":{"$ref":"#/definitions/WorkboxPlugin"}},"precacheFallback":{"type":"object","properties":{"fallbackURL":{"type":"string"}},"additionalProperties":false,"required":["fallbackURL"]},"fetchOptions":{"$ref":"#/definitions/RequestInit"},"matchOptions":{"$ref":"#/definitions/CacheQueryOptions"}},"additionalProperties":false},"urlPattern":{"anyOf":[{"$ref":"#/definitions/RegExp"},{"$ref":"#/definitions/RouteMatchCallback"},{"type":"string"}]}},"additionalProperties":false,"required":["handler","urlPattern"]},"RouteHandlerCallback":{"description":"The \"handler\" callback is invoked whenever a `Router` matches a URL/Request\nto a `Route` via its `RouteMatchCallback`. This handler callback should\nreturn a `Promise` that resolves with a `Response`.\n\nIf a non-empty array or object is returned by the `RouteMatchCallback` it\nwill be passed in as this handler's `options.params` argument.","type":"object","additionalProperties":false},"RouteHandlerObject":{"description":"An object with a `handle` method of type `RouteHandlerCallback`.\n\nA `Route` object can be created with either an `RouteHandlerCallback`\nfunction or this `RouteHandler` object. The benefit of the `RouteHandler`\nis it can be extended (as is done by the `workbox-strategies` package).","type":"object","properties":{"handle":{"$ref":"#/definitions/RouteHandlerCallback"}},"additionalProperties":false,"required":["handle"]},"QueueOptions":{"type":"object","properties":{"onSync":{"$ref":"#/definitions/OnSyncCallback"},"maxRetentionTime":{"type":"number"}},"additionalProperties":false},"OnSyncCallback":{"type":"object","additionalProperties":false},"BroadcastCacheUpdateOptions":{"type":"object","properties":{"headersToCheck":{"type":"array","items":{"type":"string"}},"generatePayload":{"type":"object","additionalProperties":false}},"additionalProperties":false},"CacheableResponseOptions":{"type":"object","properties":{"statuses":{"type":"array","items":{"type":"number"}},"headers":{"type":"object","additionalProperties":{"type":"string"}}},"additionalProperties":false},"ExpirationPluginOptions":{"type":"object","properties":{"maxEntries":{"type":"number"},"maxAgeSeconds":{"type":"number"},"matchOptions":{"$ref":"#/definitions/CacheQueryOptions"},"purgeOnQuotaError":{"type":"boolean"}},"additionalProperties":false},"CacheQueryOptions":{"type":"object","properties":{"ignoreMethod":{"type":"boolean"},"ignoreSearch":{"type":"boolean"},"ignoreVary":{"type":"boolean"}},"additionalProperties":false},"WorkboxPlugin":{"description":"An object with optional lifecycle callback properties for the fetch and\ncache operations.","type":"object","properties":{"cacheDidUpdate":{"$ref":"#/definitions/CacheDidUpdateCallback"},"cachedResponseWillBeUsed":{"$ref":"#/definitions/CachedResponseWillBeUsedCallback"},"cacheKeyWillBeUsed":{"$ref":"#/definitions/CacheKeyWillBeUsedCallback"},"cacheWillUpdate":{"$ref":"#/definitions/CacheWillUpdateCallback"},"fetchDidFail":{"$ref":"#/definitions/FetchDidFailCallback"},"fetchDidSucceed":{"$ref":"#/definitions/FetchDidSucceedCallback"},"handlerDidComplete":{"$ref":"#/definitions/HandlerDidCompleteCallback"},"handlerDidError":{"$ref":"#/definitions/HandlerDidErrorCallback"},"handlerDidRespond":{"$ref":"#/definitions/HandlerDidRespondCallback"},"handlerWillRespond":{"$ref":"#/definitions/HandlerWillRespondCallback"},"handlerWillStart":{"$ref":"#/definitions/HandlerWillStartCallback"},"requestWillFetch":{"$ref":"#/definitions/RequestWillFetchCallback"}},"additionalProperties":false},"CacheDidUpdateCallback":{"type":"object","additionalProperties":false},"CachedResponseWillBeUsedCallback":{"type":"object","additionalProperties":false},"CacheKeyWillBeUsedCallback":{"type":"object","additionalProperties":false},"CacheWillUpdateCallback":{"type":"object","additionalProperties":false},"FetchDidFailCallback":{"type":"object","additionalProperties":false},"FetchDidSucceedCallback":{"type":"object","additionalProperties":false},"HandlerDidCompleteCallback":{"type":"object","additionalProperties":false},"HandlerDidErrorCallback":{"type":"object","additionalProperties":false},"HandlerDidRespondCallback":{"type":"object","additionalProperties":false},"HandlerWillRespondCallback":{"type":"object","additionalProperties":false},"HandlerWillStartCallback":{"type":"object","additionalProperties":false},"RequestWillFetchCallback":{"type":"object","additionalProperties":false},"RequestInit":{"type":"object","properties":{"body":{"anyOf":[{"$ref":"#/definitions/ArrayBuffer"},{"$ref":"#/definitions/ArrayBufferView"},{"$ref":"#/definitions/Blob"},{"$ref":"#/definitions/FormData"},{"$ref":"#/definitions/URLSearchParams"},{"$ref":"#/definitions/ReadableStream"},{"type":["null","string"]}]},"cache":{"enum":["default","force-cache","no-cache","no-store","only-if-cached","reload"],"type":"string"},"credentials":{"enum":["include","omit","same-origin"],"type":"string"},"headers":{"anyOf":[{"$ref":"#/definitions/Headers"},{"type":"array","items":{"type":"array","items":{"type":"string"}}},{"$ref":"#/definitions/Record"}]},"integrity":{"type":"string"},"keepalive":{"type":"boolean"},"method":{"type":"string"},"mode":{"enum":["cors","navigate","no-cors","same-origin"],"type":"string"},"redirect":{"enum":["error","follow","manual"],"type":"string"},"referrer":{"type":"string"},"referrerPolicy":{"enum":["","no-referrer","no-referrer-when-downgrade","origin","origin-when-cross-origin","same-origin","strict-origin","strict-origin-when-cross-origin","unsafe-url"],"type":"string"},"signal":{"anyOf":[{"$ref":"#/definitions/AbortSignal"},{"type":"null"}]},"window":{}},"additionalProperties":false},"ArrayBuffer":{"type":"object","properties":{"byteLength":{"type":"number"},"__@toStringTag":{"type":"string"}},"additionalProperties":false,"required":["__@toStringTag","byteLength"]},"ArrayBufferView":{"type":"object","properties":{"buffer":{"anyOf":[{"$ref":"#/definitions/ArrayBuffer"},{"$ref":"#/definitions/SharedArrayBuffer"}]},"byteLength":{"type":"number"},"byteOffset":{"type":"number"}},"additionalProperties":false,"required":["buffer","byteLength","byteOffset"]},"SharedArrayBuffer":{"type":"object","properties":{"byteLength":{"type":"number"},"__@species":{"$ref":"#/definitions/SharedArrayBuffer"},"__@toStringTag":{"type":"string","enum":["SharedArrayBuffer"]}},"additionalProperties":false,"required":["__@species","__@toStringTag","byteLength"]},"Blob":{"type":"object","properties":{"size":{"type":"number"},"type":{"type":"string"}},"additionalProperties":false,"required":["size","type"]},"FormData":{"type":"object","additionalProperties":false},"URLSearchParams":{"type":"object","additionalProperties":false},"ReadableStream":{"type":"object","properties":{"locked":{"type":"boolean"}},"additionalProperties":false,"required":["locked"]},"Headers":{"type":"object","additionalProperties":false},"Record":{"type":"object","additionalProperties":false},"AbortSignal":{"type":"object","properties":{"aborted":{"type":"boolean"},"onabort":{"anyOf":[{"type":"object","additionalProperties":false},{"type":"null"}]}},"additionalProperties":false,"required":["aborted","onabort"]},"RouteMatchCallback":{"description":"The \"match\" callback is used to determine if a `Route` should apply for a\nparticular URL and request. When matching occurs in response to a fetch\nevent from the client, the `event` object is also supplied. However, since\nthe match callback can be invoked outside of a fetch event, matching logic\nshould not assume the `event` object will always be available.\nIf the match callback returns a truthy value, the matching route's\n`RouteHandlerCallback` will be invoked immediately. If the value returned\nis a non-empty array or object, that value will be set on the handler's\n`options.params` argument.","additionalProperties":false,"typeof":"function"}},"$schema":"http://json-schema.org/draft-07/schema#"} +{"additionalProperties":false,"type":"object","properties":{"additionalManifestEntries":{"type":"array","items":{"anyOf":[{"$ref":"#/definitions/ManifestEntry"},{"type":"string"}]}},"dontCacheBustURLsMatching":{"$ref":"#/definitions/RegExp"},"manifestTransforms":{"type":"array","items":{"typeof":"function"}},"maximumFileSizeToCacheInBytes":{"default":2097152,"type":"number"},"modifyURLPrefix":{"type":"object","additionalProperties":{"type":"string"}},"globFollow":{"default":true,"type":"boolean"},"globIgnores":{"default":["**/node_modules/**/*"],"type":"array","items":{"type":"string"}},"globPatterns":{"default":["**/*.{js,css,html}"],"type":"array","items":{"type":"string"}},"globStrict":{"default":true,"type":"boolean"},"templatedURLs":{"type":"object","additionalProperties":{"anyOf":[{"type":"array","items":{"type":"string"}},{"type":"string"}]}},"babelPresetEnvTargets":{"default":["chrome >= 56"],"type":"array","items":{"type":"string"}},"cacheId":{"type":["null","string"]},"cleanupOutdatedCaches":{"default":false,"type":"boolean"},"clientsClaim":{"default":false,"type":"boolean"},"directoryIndex":{"type":["null","string"]},"disableDevLogs":{"default":false,"type":"boolean"},"ignoreURLParametersMatching":{"type":"array","items":{"$ref":"#/definitions/RegExp"}},"importScripts":{"type":"array","items":{"type":"string"}},"inlineWorkboxRuntime":{"default":false,"type":"boolean"},"mode":{"default":"production","type":["null","string"]},"navigateFallback":{"default":null,"type":["null","string"]},"navigateFallbackAllowlist":{"type":"array","items":{"$ref":"#/definitions/RegExp"}},"navigateFallbackDenylist":{"type":"array","items":{"$ref":"#/definitions/RegExp"}},"navigationPreload":{"description":"navigationPreload is only valid when runtimeCaching is configured. However,\nthis can't be expressed via TypeScript, so it's enforced via runtime logic.","default":false,"type":"boolean"},"offlineGoogleAnalytics":{"default":false,"anyOf":[{"$ref":"#/definitions/GoogleAnalyticsInitializeOptions"},{"type":"boolean"}]},"runtimeCaching":{"type":"array","items":{"$ref":"#/definitions/RuntimeCaching"}},"skipWaiting":{"default":false,"type":"boolean"},"sourcemap":{"default":true,"type":"boolean"},"swDest":{"type":"string"},"globDirectory":{"type":"string"}},"required":["swDest"],"definitions":{"ManifestEntry":{"type":"object","properties":{"integrity":{"type":"string"},"revision":{"type":["null","string"]},"url":{"type":"string"}},"additionalProperties":false,"required":["revision","url"]},"RegExp":{"type":"object","properties":{"source":{"type":"string"},"global":{"type":"boolean"},"ignoreCase":{"type":"boolean"},"multiline":{"type":"boolean"},"lastIndex":{"type":"number"},"flags":{"type":"string"},"sticky":{"type":"boolean"},"unicode":{"type":"boolean"},"dotAll":{"type":"boolean"}},"additionalProperties":false,"required":["dotAll","flags","global","ignoreCase","lastIndex","multiline","source","sticky","unicode"]},"GoogleAnalyticsInitializeOptions":{"type":"object","properties":{"cacheName":{"type":"string"},"parameterOverrides":{"type":"object","additionalProperties":{"type":"string"}},"hitFilter":{"type":"object","additionalProperties":false}},"additionalProperties":false},"RuntimeCaching":{"type":"object","properties":{"handler":{"anyOf":[{"$ref":"#/definitions/RouteHandlerCallback"},{"$ref":"#/definitions/RouteHandlerObject"},{"enum":["CacheFirst","CacheOnly","NetworkFirst","NetworkOnly","StaleWhileRevalidate"],"type":"string"}]},"method":{"enum":["DELETE","GET","HEAD","PATCH","POST","PUT"],"type":"string"},"options":{"type":"object","properties":{"backgroundSync":{"type":"object","properties":{"name":{"type":"string"},"options":{"$ref":"#/definitions/QueueOptions"}},"additionalProperties":false,"required":["name"]},"broadcastUpdate":{"type":"object","properties":{"channelName":{"type":"string"},"options":{"$ref":"#/definitions/BroadcastCacheUpdateOptions"}},"additionalProperties":false,"required":["options"]},"cacheableResponse":{"$ref":"#/definitions/CacheableResponseOptions"},"cacheName":{"type":["null","string"]},"expiration":{"$ref":"#/definitions/ExpirationPluginOptions"},"networkTimeoutSeconds":{"type":"number"},"plugins":{"type":"array","items":{"$ref":"#/definitions/WorkboxPlugin"}},"precacheFallback":{"type":"object","properties":{"fallbackURL":{"type":"string"}},"additionalProperties":false,"required":["fallbackURL"]},"fetchOptions":{"$ref":"#/definitions/RequestInit"},"matchOptions":{"$ref":"#/definitions/CacheQueryOptions"}},"additionalProperties":false},"urlPattern":{"anyOf":[{"$ref":"#/definitions/RegExp"},{"$ref":"#/definitions/RouteMatchCallback"},{"type":"string"}]}},"additionalProperties":false,"required":["handler","urlPattern"]},"RouteHandlerCallback":{"description":"The \"handler\" callback is invoked whenever a `Router` matches a URL/Request\nto a `Route` via its `RouteMatchCallback`. This handler callback should\nreturn a `Promise` that resolves with a `Response`.\n\nIf a non-empty array or object is returned by the `RouteMatchCallback` it\nwill be passed in as this handler's `options.params` argument.","type":"object","additionalProperties":false},"RouteHandlerObject":{"description":"An object with a `handle` method of type `RouteHandlerCallback`.\n\nA `Route` object can be created with either an `RouteHandlerCallback`\nfunction or this `RouteHandler` object. The benefit of the `RouteHandler`\nis it can be extended (as is done by the `workbox-strategies` package).","type":"object","properties":{"handle":{"$ref":"#/definitions/RouteHandlerCallback"}},"additionalProperties":false,"required":["handle"]},"QueueOptions":{"type":"object","properties":{"onSync":{"$ref":"#/definitions/OnSyncCallback"},"maxRetentionTime":{"type":"number"}},"additionalProperties":false},"OnSyncCallback":{"type":"object","additionalProperties":false},"BroadcastCacheUpdateOptions":{"type":"object","properties":{"headersToCheck":{"type":"array","items":{"type":"string"}},"generatePayload":{"type":"object","additionalProperties":false}},"additionalProperties":false},"CacheableResponseOptions":{"type":"object","properties":{"statuses":{"type":"array","items":{"type":"number"}},"headers":{"type":"object","additionalProperties":{"type":"string"}}},"additionalProperties":false},"ExpirationPluginOptions":{"type":"object","properties":{"maxEntries":{"type":"number"},"maxAgeSeconds":{"type":"number"},"matchOptions":{"$ref":"#/definitions/CacheQueryOptions"},"purgeOnQuotaError":{"type":"boolean"}},"additionalProperties":false},"CacheQueryOptions":{"type":"object","properties":{"ignoreMethod":{"type":"boolean"},"ignoreSearch":{"type":"boolean"},"ignoreVary":{"type":"boolean"}},"additionalProperties":false},"WorkboxPlugin":{"description":"An object with optional lifecycle callback properties for the fetch and\ncache operations.","type":"object","properties":{"cacheDidUpdate":{"$ref":"#/definitions/CacheDidUpdateCallback"},"cachedResponseWillBeUsed":{"$ref":"#/definitions/CachedResponseWillBeUsedCallback"},"cacheKeyWillBeUsed":{"$ref":"#/definitions/CacheKeyWillBeUsedCallback"},"cacheWillUpdate":{"$ref":"#/definitions/CacheWillUpdateCallback"},"fetchDidFail":{"$ref":"#/definitions/FetchDidFailCallback"},"fetchDidSucceed":{"$ref":"#/definitions/FetchDidSucceedCallback"},"handlerDidComplete":{"$ref":"#/definitions/HandlerDidCompleteCallback"},"handlerDidError":{"$ref":"#/definitions/HandlerDidErrorCallback"},"handlerDidRespond":{"$ref":"#/definitions/HandlerDidRespondCallback"},"handlerWillRespond":{"$ref":"#/definitions/HandlerWillRespondCallback"},"handlerWillStart":{"$ref":"#/definitions/HandlerWillStartCallback"},"requestWillFetch":{"$ref":"#/definitions/RequestWillFetchCallback"}},"additionalProperties":false},"CacheDidUpdateCallback":{"type":"object","additionalProperties":false},"CachedResponseWillBeUsedCallback":{"type":"object","additionalProperties":false},"CacheKeyWillBeUsedCallback":{"type":"object","additionalProperties":false},"CacheWillUpdateCallback":{"type":"object","additionalProperties":false},"FetchDidFailCallback":{"type":"object","additionalProperties":false},"FetchDidSucceedCallback":{"type":"object","additionalProperties":false},"HandlerDidCompleteCallback":{"type":"object","additionalProperties":false},"HandlerDidErrorCallback":{"type":"object","additionalProperties":false},"HandlerDidRespondCallback":{"type":"object","additionalProperties":false},"HandlerWillRespondCallback":{"type":"object","additionalProperties":false},"HandlerWillStartCallback":{"type":"object","additionalProperties":false},"RequestWillFetchCallback":{"type":"object","additionalProperties":false},"RequestInit":{"type":"object","properties":{"body":{"anyOf":[{"$ref":"#/definitions/ArrayBuffer"},{"$ref":"#/definitions/ArrayBufferView"},{"$ref":"#/definitions/Blob"},{"$ref":"#/definitions/FormData"},{"$ref":"#/definitions/URLSearchParams"},{"$ref":"#/definitions/ReadableStream"},{"type":["null","string"]}]},"cache":{"enum":["default","force-cache","no-cache","no-store","only-if-cached","reload"],"type":"string"},"credentials":{"enum":["include","omit","same-origin"],"type":"string"},"headers":{"anyOf":[{"$ref":"#/definitions/Headers"},{"type":"array","items":{"type":"array","items":{"type":"string"}}},{"$ref":"#/definitions/Record"}]},"integrity":{"type":"string"},"keepalive":{"type":"boolean"},"method":{"type":"string"},"mode":{"enum":["cors","navigate","no-cors","same-origin"],"type":"string"},"redirect":{"enum":["error","follow","manual"],"type":"string"},"referrer":{"type":"string"},"referrerPolicy":{"enum":["","no-referrer","no-referrer-when-downgrade","origin","origin-when-cross-origin","same-origin","strict-origin","strict-origin-when-cross-origin","unsafe-url"],"type":"string"},"signal":{"anyOf":[{"$ref":"#/definitions/AbortSignal"},{"type":"null"}]},"window":{}},"additionalProperties":false},"ArrayBuffer":{"type":"object","properties":{"byteLength":{"type":"number"},"__@toStringTag":{"type":"string"}},"additionalProperties":false,"required":["__@toStringTag","byteLength"]},"ArrayBufferView":{"type":"object","properties":{"buffer":{"anyOf":[{"$ref":"#/definitions/ArrayBuffer"},{"$ref":"#/definitions/SharedArrayBuffer"}]},"byteLength":{"type":"number"},"byteOffset":{"type":"number"}},"additionalProperties":false,"required":["buffer","byteLength","byteOffset"]},"SharedArrayBuffer":{"type":"object","properties":{"byteLength":{"type":"number"},"__@species":{"$ref":"#/definitions/SharedArrayBuffer"},"__@toStringTag":{"type":"string","enum":["SharedArrayBuffer"]}},"additionalProperties":false,"required":["__@species","__@toStringTag","byteLength"]},"Blob":{"type":"object","properties":{"size":{"type":"number"},"type":{"type":"string"}},"additionalProperties":false,"required":["size","type"]},"FormData":{"type":"object","additionalProperties":false},"URLSearchParams":{"type":"object","additionalProperties":false},"ReadableStream":{"type":"object","properties":{"locked":{"type":"boolean"}},"additionalProperties":false,"required":["locked"]},"Headers":{"type":"object","additionalProperties":false},"Record":{"type":"object","additionalProperties":false},"AbortSignal":{"type":"object","properties":{"aborted":{"type":"boolean"},"onabort":{"anyOf":[{"type":"object","additionalProperties":false},{"type":"null"}]}},"additionalProperties":false,"required":["aborted","onabort"]},"RouteMatchCallback":{"description":"The \"match\" callback is used to determine if a `Route` should apply for a\nparticular URL and request. When matching occurs in response to a fetch\nevent from the client, the `event` object is also supplied. However, since\nthe match callback can be invoked outside of a fetch event, matching logic\nshould not assume the `event` object will always be available.\nIf the match callback returns a truthy value, the matching route's\n`RouteHandlerCallback` will be invoked immediately. If the value returned\nis a non-empty array or object, that value will be set on the handler's\n`options.params` argument.","typeof":"function"}},"$schema":"http://json-schema.org/draft-07/schema#"} diff --git a/packages/workbox-build/src/schema/GetManifestOptions.json b/packages/workbox-build/src/schema/GetManifestOptions.json index d088aa5e0..9eb30d29a 100644 --- a/packages/workbox-build/src/schema/GetManifestOptions.json +++ b/packages/workbox-build/src/schema/GetManifestOptions.json @@ -1 +1 @@ -{"additionalProperties":false,"type":"object","properties":{"additionalManifestEntries":{"type":"array","items":{"anyOf":[{"$ref":"#/definitions/ManifestEntry"},{"type":"string"}]}},"dontCacheBustURLsMatching":{"$ref":"#/definitions/RegExp"},"manifestTransforms":{"type":"array","items":{"typeof":"function"}},"maximumFileSizeToCacheInBytes":{"default":2097152,"type":"number"},"modifyURLPrefix":{"type":"object","additionalProperties":{"type":"string"}},"globFollow":{"default":true,"type":"boolean"},"globIgnores":{"default":["**/node_modules/**/*"],"type":"array","items":{"type":"string"}},"globPatterns":{"default":["**/*.{js,css,html}"],"type":"array","items":{"type":"string"}},"globStrict":{"default":true,"type":"boolean"},"templatedURLs":{"type":"object","additionalProperties":{"anyOf":[{"type":"array","items":{"type":"string"}},{"type":"string"}]}},"globDirectory":{"type":"string"}},"required":["globDirectory"],"definitions":{"ManifestEntry":{"type":"object","properties":{"integrity":{"type":"string"},"revision":{"type":["null","string"]},"url":{"type":"string"}},"additionalProperties":false,"required":["revision","url"]},"RegExp":{"type":"object","properties":{"source":{"type":"string"},"global":{"type":"boolean"},"ignoreCase":{"type":"boolean"},"multiline":{"type":"boolean"},"lastIndex":{"type":"number"},"flags":{"type":"string"},"sticky":{"type":"boolean"},"unicode":{"type":"boolean"},"dotAll":{"type":"boolean"}},"additionalProperties":false,"required":["dotAll","flags","global","ignoreCase","lastIndex","multiline","source","sticky","unicode"]},"GoogleAnalyticsInitializeOptions":{"type":"object","properties":{"cacheName":{"type":"string"},"parameterOverrides":{"type":"object","additionalProperties":{"type":"string"}},"hitFilter":{"type":"object","additionalProperties":false}},"additionalProperties":false},"RuntimeCaching":{"type":"object","properties":{"handler":{"anyOf":[{"$ref":"#/definitions/RouteHandlerCallback"},{"$ref":"#/definitions/RouteHandlerObject"},{"enum":["CacheFirst","CacheOnly","NetworkFirst","NetworkOnly","StaleWhileRevalidate"],"type":"string"}]},"method":{"enum":["DELETE","GET","HEAD","PATCH","POST","PUT"],"type":"string"},"options":{"type":"object","properties":{"backgroundSync":{"type":"object","properties":{"name":{"type":"string"},"options":{"$ref":"#/definitions/QueueOptions"}},"additionalProperties":false,"required":["name"]},"broadcastUpdate":{"type":"object","properties":{"channelName":{"type":"string"},"options":{"$ref":"#/definitions/BroadcastCacheUpdateOptions"}},"additionalProperties":false,"required":["options"]},"cacheableResponse":{"$ref":"#/definitions/CacheableResponseOptions"},"cacheName":{"type":["null","string"]},"expiration":{"$ref":"#/definitions/ExpirationPluginOptions"},"networkTimeoutSeconds":{"type":"number"},"plugins":{"type":"array","items":{"$ref":"#/definitions/WorkboxPlugin"}},"precacheFallback":{"type":"object","properties":{"fallbackURL":{"type":"string"}},"additionalProperties":false,"required":["fallbackURL"]},"fetchOptions":{"$ref":"#/definitions/RequestInit"},"matchOptions":{"$ref":"#/definitions/CacheQueryOptions"}},"additionalProperties":false},"urlPattern":{"anyOf":[{"$ref":"#/definitions/RegExp"},{"$ref":"#/definitions/RouteMatchCallback"},{"type":"string"}]}},"additionalProperties":false,"required":["handler","urlPattern"]},"RouteHandlerCallback":{"description":"The \"handler\" callback is invoked whenever a `Router` matches a URL/Request\nto a `Route` via its `RouteMatchCallback`. This handler callback should\nreturn a `Promise` that resolves with a `Response`.\n\nIf a non-empty array or object is returned by the `RouteMatchCallback` it\nwill be passed in as this handler's `options.params` argument.","type":"object","additionalProperties":false},"RouteHandlerObject":{"description":"An object with a `handle` method of type `RouteHandlerCallback`.\n\nA `Route` object can be created with either an `RouteHandlerCallback`\nfunction or this `RouteHandler` object. The benefit of the `RouteHandler`\nis it can be extended (as is done by the `workbox-strategies` package).","type":"object","properties":{"handle":{"$ref":"#/definitions/RouteHandlerCallback"}},"additionalProperties":false,"required":["handle"]},"QueueOptions":{"type":"object","properties":{"onSync":{"$ref":"#/definitions/OnSyncCallback"},"maxRetentionTime":{"type":"number"}},"additionalProperties":false},"OnSyncCallback":{"type":"object","additionalProperties":false},"BroadcastCacheUpdateOptions":{"type":"object","properties":{"headersToCheck":{"type":"array","items":{"type":"string"}},"generatePayload":{"type":"object","additionalProperties":false}},"additionalProperties":false},"CacheableResponseOptions":{"type":"object","properties":{"statuses":{"type":"array","items":{"type":"number"}},"headers":{"type":"object","additionalProperties":{"type":"string"}}},"additionalProperties":false},"ExpirationPluginOptions":{"type":"object","properties":{"maxEntries":{"type":"number"},"maxAgeSeconds":{"type":"number"},"matchOptions":{"$ref":"#/definitions/CacheQueryOptions"},"purgeOnQuotaError":{"type":"boolean"}},"additionalProperties":false},"CacheQueryOptions":{"type":"object","properties":{"ignoreMethod":{"type":"boolean"},"ignoreSearch":{"type":"boolean"},"ignoreVary":{"type":"boolean"}},"additionalProperties":false},"WorkboxPlugin":{"description":"An object with optional lifecycle callback properties for the fetch and\ncache operations.","type":"object","properties":{"cacheDidUpdate":{"$ref":"#/definitions/CacheDidUpdateCallback"},"cachedResponseWillBeUsed":{"$ref":"#/definitions/CachedResponseWillBeUsedCallback"},"cacheKeyWillBeUsed":{"$ref":"#/definitions/CacheKeyWillBeUsedCallback"},"cacheWillUpdate":{"$ref":"#/definitions/CacheWillUpdateCallback"},"fetchDidFail":{"$ref":"#/definitions/FetchDidFailCallback"},"fetchDidSucceed":{"$ref":"#/definitions/FetchDidSucceedCallback"},"handlerDidComplete":{"$ref":"#/definitions/HandlerDidCompleteCallback"},"handlerDidError":{"$ref":"#/definitions/HandlerDidErrorCallback"},"handlerDidRespond":{"$ref":"#/definitions/HandlerDidRespondCallback"},"handlerWillRespond":{"$ref":"#/definitions/HandlerWillRespondCallback"},"handlerWillStart":{"$ref":"#/definitions/HandlerWillStartCallback"},"requestWillFetch":{"$ref":"#/definitions/RequestWillFetchCallback"}},"additionalProperties":false},"CacheDidUpdateCallback":{"type":"object","additionalProperties":false},"CachedResponseWillBeUsedCallback":{"type":"object","additionalProperties":false},"CacheKeyWillBeUsedCallback":{"type":"object","additionalProperties":false},"CacheWillUpdateCallback":{"type":"object","additionalProperties":false},"FetchDidFailCallback":{"type":"object","additionalProperties":false},"FetchDidSucceedCallback":{"type":"object","additionalProperties":false},"HandlerDidCompleteCallback":{"type":"object","additionalProperties":false},"HandlerDidErrorCallback":{"type":"object","additionalProperties":false},"HandlerDidRespondCallback":{"type":"object","additionalProperties":false},"HandlerWillRespondCallback":{"type":"object","additionalProperties":false},"HandlerWillStartCallback":{"type":"object","additionalProperties":false},"RequestWillFetchCallback":{"type":"object","additionalProperties":false},"RequestInit":{"type":"object","properties":{"body":{"anyOf":[{"$ref":"#/definitions/ArrayBuffer"},{"$ref":"#/definitions/ArrayBufferView"},{"$ref":"#/definitions/Blob"},{"$ref":"#/definitions/FormData"},{"$ref":"#/definitions/URLSearchParams"},{"$ref":"#/definitions/ReadableStream"},{"type":["null","string"]}]},"cache":{"enum":["default","force-cache","no-cache","no-store","only-if-cached","reload"],"type":"string"},"credentials":{"enum":["include","omit","same-origin"],"type":"string"},"headers":{"anyOf":[{"$ref":"#/definitions/Headers"},{"type":"array","items":{"type":"array","items":{"type":"string"}}},{"$ref":"#/definitions/Record"}]},"integrity":{"type":"string"},"keepalive":{"type":"boolean"},"method":{"type":"string"},"mode":{"enum":["cors","navigate","no-cors","same-origin"],"type":"string"},"redirect":{"enum":["error","follow","manual"],"type":"string"},"referrer":{"type":"string"},"referrerPolicy":{"enum":["","no-referrer","no-referrer-when-downgrade","origin","origin-when-cross-origin","same-origin","strict-origin","strict-origin-when-cross-origin","unsafe-url"],"type":"string"},"signal":{"anyOf":[{"$ref":"#/definitions/AbortSignal"},{"type":"null"}]},"window":{}},"additionalProperties":false},"ArrayBuffer":{"type":"object","properties":{"byteLength":{"type":"number"},"__@toStringTag":{"type":"string"}},"additionalProperties":false,"required":["__@toStringTag","byteLength"]},"ArrayBufferView":{"type":"object","properties":{"buffer":{"anyOf":[{"$ref":"#/definitions/ArrayBuffer"},{"$ref":"#/definitions/SharedArrayBuffer"}]},"byteLength":{"type":"number"},"byteOffset":{"type":"number"}},"additionalProperties":false,"required":["buffer","byteLength","byteOffset"]},"SharedArrayBuffer":{"type":"object","properties":{"byteLength":{"type":"number"},"__@species":{"$ref":"#/definitions/SharedArrayBuffer"},"__@toStringTag":{"type":"string","enum":["SharedArrayBuffer"]}},"additionalProperties":false,"required":["__@species","__@toStringTag","byteLength"]},"Blob":{"type":"object","properties":{"size":{"type":"number"},"type":{"type":"string"}},"additionalProperties":false,"required":["size","type"]},"FormData":{"type":"object","additionalProperties":false},"URLSearchParams":{"type":"object","additionalProperties":false},"ReadableStream":{"type":"object","properties":{"locked":{"type":"boolean"}},"additionalProperties":false,"required":["locked"]},"Headers":{"type":"object","additionalProperties":false},"Record":{"type":"object","additionalProperties":false},"AbortSignal":{"type":"object","properties":{"aborted":{"type":"boolean"},"onabort":{"anyOf":[{"type":"object","additionalProperties":false},{"type":"null"}]}},"additionalProperties":false,"required":["aborted","onabort"]},"RouteMatchCallback":{"description":"The \"match\" callback is used to determine if a `Route` should apply for a\nparticular URL and request. When matching occurs in response to a fetch\nevent from the client, the `event` object is also supplied. However, since\nthe match callback can be invoked outside of a fetch event, matching logic\nshould not assume the `event` object will always be available.\nIf the match callback returns a truthy value, the matching route's\n`RouteHandlerCallback` will be invoked immediately. If the value returned\nis a non-empty array or object, that value will be set on the handler's\n`options.params` argument.","additionalProperties":false,"typeof":"function"}},"$schema":"http://json-schema.org/draft-07/schema#"} +{"additionalProperties":false,"type":"object","properties":{"additionalManifestEntries":{"type":"array","items":{"anyOf":[{"$ref":"#/definitions/ManifestEntry"},{"type":"string"}]}},"dontCacheBustURLsMatching":{"$ref":"#/definitions/RegExp"},"manifestTransforms":{"type":"array","items":{"typeof":"function"}},"maximumFileSizeToCacheInBytes":{"default":2097152,"type":"number"},"modifyURLPrefix":{"type":"object","additionalProperties":{"type":"string"}},"globFollow":{"default":true,"type":"boolean"},"globIgnores":{"default":["**/node_modules/**/*"],"type":"array","items":{"type":"string"}},"globPatterns":{"default":["**/*.{js,css,html}"],"type":"array","items":{"type":"string"}},"globStrict":{"default":true,"type":"boolean"},"templatedURLs":{"type":"object","additionalProperties":{"anyOf":[{"type":"array","items":{"type":"string"}},{"type":"string"}]}},"globDirectory":{"type":"string"}},"required":["globDirectory"],"definitions":{"ManifestEntry":{"type":"object","properties":{"integrity":{"type":"string"},"revision":{"type":["null","string"]},"url":{"type":"string"}},"additionalProperties":false,"required":["revision","url"]},"RegExp":{"type":"object","properties":{"source":{"type":"string"},"global":{"type":"boolean"},"ignoreCase":{"type":"boolean"},"multiline":{"type":"boolean"},"lastIndex":{"type":"number"},"flags":{"type":"string"},"sticky":{"type":"boolean"},"unicode":{"type":"boolean"},"dotAll":{"type":"boolean"}},"additionalProperties":false,"required":["dotAll","flags","global","ignoreCase","lastIndex","multiline","source","sticky","unicode"]},"GoogleAnalyticsInitializeOptions":{"type":"object","properties":{"cacheName":{"type":"string"},"parameterOverrides":{"type":"object","additionalProperties":{"type":"string"}},"hitFilter":{"type":"object","additionalProperties":false}},"additionalProperties":false},"RuntimeCaching":{"type":"object","properties":{"handler":{"anyOf":[{"$ref":"#/definitions/RouteHandlerCallback"},{"$ref":"#/definitions/RouteHandlerObject"},{"enum":["CacheFirst","CacheOnly","NetworkFirst","NetworkOnly","StaleWhileRevalidate"],"type":"string"}]},"method":{"enum":["DELETE","GET","HEAD","PATCH","POST","PUT"],"type":"string"},"options":{"type":"object","properties":{"backgroundSync":{"type":"object","properties":{"name":{"type":"string"},"options":{"$ref":"#/definitions/QueueOptions"}},"additionalProperties":false,"required":["name"]},"broadcastUpdate":{"type":"object","properties":{"channelName":{"type":"string"},"options":{"$ref":"#/definitions/BroadcastCacheUpdateOptions"}},"additionalProperties":false,"required":["options"]},"cacheableResponse":{"$ref":"#/definitions/CacheableResponseOptions"},"cacheName":{"type":["null","string"]},"expiration":{"$ref":"#/definitions/ExpirationPluginOptions"},"networkTimeoutSeconds":{"type":"number"},"plugins":{"type":"array","items":{"$ref":"#/definitions/WorkboxPlugin"}},"precacheFallback":{"type":"object","properties":{"fallbackURL":{"type":"string"}},"additionalProperties":false,"required":["fallbackURL"]},"fetchOptions":{"$ref":"#/definitions/RequestInit"},"matchOptions":{"$ref":"#/definitions/CacheQueryOptions"}},"additionalProperties":false},"urlPattern":{"anyOf":[{"$ref":"#/definitions/RegExp"},{"$ref":"#/definitions/RouteMatchCallback"},{"type":"string"}]}},"additionalProperties":false,"required":["handler","urlPattern"]},"RouteHandlerCallback":{"description":"The \"handler\" callback is invoked whenever a `Router` matches a URL/Request\nto a `Route` via its `RouteMatchCallback`. This handler callback should\nreturn a `Promise` that resolves with a `Response`.\n\nIf a non-empty array or object is returned by the `RouteMatchCallback` it\nwill be passed in as this handler's `options.params` argument.","type":"object","additionalProperties":false},"RouteHandlerObject":{"description":"An object with a `handle` method of type `RouteHandlerCallback`.\n\nA `Route` object can be created with either an `RouteHandlerCallback`\nfunction or this `RouteHandler` object. The benefit of the `RouteHandler`\nis it can be extended (as is done by the `workbox-strategies` package).","type":"object","properties":{"handle":{"$ref":"#/definitions/RouteHandlerCallback"}},"additionalProperties":false,"required":["handle"]},"QueueOptions":{"type":"object","properties":{"onSync":{"$ref":"#/definitions/OnSyncCallback"},"maxRetentionTime":{"type":"number"}},"additionalProperties":false},"OnSyncCallback":{"type":"object","additionalProperties":false},"BroadcastCacheUpdateOptions":{"type":"object","properties":{"headersToCheck":{"type":"array","items":{"type":"string"}},"generatePayload":{"type":"object","additionalProperties":false}},"additionalProperties":false},"CacheableResponseOptions":{"type":"object","properties":{"statuses":{"type":"array","items":{"type":"number"}},"headers":{"type":"object","additionalProperties":{"type":"string"}}},"additionalProperties":false},"ExpirationPluginOptions":{"type":"object","properties":{"maxEntries":{"type":"number"},"maxAgeSeconds":{"type":"number"},"matchOptions":{"$ref":"#/definitions/CacheQueryOptions"},"purgeOnQuotaError":{"type":"boolean"}},"additionalProperties":false},"CacheQueryOptions":{"type":"object","properties":{"ignoreMethod":{"type":"boolean"},"ignoreSearch":{"type":"boolean"},"ignoreVary":{"type":"boolean"}},"additionalProperties":false},"WorkboxPlugin":{"description":"An object with optional lifecycle callback properties for the fetch and\ncache operations.","type":"object","properties":{"cacheDidUpdate":{"$ref":"#/definitions/CacheDidUpdateCallback"},"cachedResponseWillBeUsed":{"$ref":"#/definitions/CachedResponseWillBeUsedCallback"},"cacheKeyWillBeUsed":{"$ref":"#/definitions/CacheKeyWillBeUsedCallback"},"cacheWillUpdate":{"$ref":"#/definitions/CacheWillUpdateCallback"},"fetchDidFail":{"$ref":"#/definitions/FetchDidFailCallback"},"fetchDidSucceed":{"$ref":"#/definitions/FetchDidSucceedCallback"},"handlerDidComplete":{"$ref":"#/definitions/HandlerDidCompleteCallback"},"handlerDidError":{"$ref":"#/definitions/HandlerDidErrorCallback"},"handlerDidRespond":{"$ref":"#/definitions/HandlerDidRespondCallback"},"handlerWillRespond":{"$ref":"#/definitions/HandlerWillRespondCallback"},"handlerWillStart":{"$ref":"#/definitions/HandlerWillStartCallback"},"requestWillFetch":{"$ref":"#/definitions/RequestWillFetchCallback"}},"additionalProperties":false},"CacheDidUpdateCallback":{"type":"object","additionalProperties":false},"CachedResponseWillBeUsedCallback":{"type":"object","additionalProperties":false},"CacheKeyWillBeUsedCallback":{"type":"object","additionalProperties":false},"CacheWillUpdateCallback":{"type":"object","additionalProperties":false},"FetchDidFailCallback":{"type":"object","additionalProperties":false},"FetchDidSucceedCallback":{"type":"object","additionalProperties":false},"HandlerDidCompleteCallback":{"type":"object","additionalProperties":false},"HandlerDidErrorCallback":{"type":"object","additionalProperties":false},"HandlerDidRespondCallback":{"type":"object","additionalProperties":false},"HandlerWillRespondCallback":{"type":"object","additionalProperties":false},"HandlerWillStartCallback":{"type":"object","additionalProperties":false},"RequestWillFetchCallback":{"type":"object","additionalProperties":false},"RequestInit":{"type":"object","properties":{"body":{"anyOf":[{"$ref":"#/definitions/ArrayBuffer"},{"$ref":"#/definitions/ArrayBufferView"},{"$ref":"#/definitions/Blob"},{"$ref":"#/definitions/FormData"},{"$ref":"#/definitions/URLSearchParams"},{"$ref":"#/definitions/ReadableStream"},{"type":["null","string"]}]},"cache":{"enum":["default","force-cache","no-cache","no-store","only-if-cached","reload"],"type":"string"},"credentials":{"enum":["include","omit","same-origin"],"type":"string"},"headers":{"anyOf":[{"$ref":"#/definitions/Headers"},{"type":"array","items":{"type":"array","items":{"type":"string"}}},{"$ref":"#/definitions/Record"}]},"integrity":{"type":"string"},"keepalive":{"type":"boolean"},"method":{"type":"string"},"mode":{"enum":["cors","navigate","no-cors","same-origin"],"type":"string"},"redirect":{"enum":["error","follow","manual"],"type":"string"},"referrer":{"type":"string"},"referrerPolicy":{"enum":["","no-referrer","no-referrer-when-downgrade","origin","origin-when-cross-origin","same-origin","strict-origin","strict-origin-when-cross-origin","unsafe-url"],"type":"string"},"signal":{"anyOf":[{"$ref":"#/definitions/AbortSignal"},{"type":"null"}]},"window":{}},"additionalProperties":false},"ArrayBuffer":{"type":"object","properties":{"byteLength":{"type":"number"},"__@toStringTag":{"type":"string"}},"additionalProperties":false,"required":["__@toStringTag","byteLength"]},"ArrayBufferView":{"type":"object","properties":{"buffer":{"anyOf":[{"$ref":"#/definitions/ArrayBuffer"},{"$ref":"#/definitions/SharedArrayBuffer"}]},"byteLength":{"type":"number"},"byteOffset":{"type":"number"}},"additionalProperties":false,"required":["buffer","byteLength","byteOffset"]},"SharedArrayBuffer":{"type":"object","properties":{"byteLength":{"type":"number"},"__@species":{"$ref":"#/definitions/SharedArrayBuffer"},"__@toStringTag":{"type":"string","enum":["SharedArrayBuffer"]}},"additionalProperties":false,"required":["__@species","__@toStringTag","byteLength"]},"Blob":{"type":"object","properties":{"size":{"type":"number"},"type":{"type":"string"}},"additionalProperties":false,"required":["size","type"]},"FormData":{"type":"object","additionalProperties":false},"URLSearchParams":{"type":"object","additionalProperties":false},"ReadableStream":{"type":"object","properties":{"locked":{"type":"boolean"}},"additionalProperties":false,"required":["locked"]},"Headers":{"type":"object","additionalProperties":false},"Record":{"type":"object","additionalProperties":false},"AbortSignal":{"type":"object","properties":{"aborted":{"type":"boolean"},"onabort":{"anyOf":[{"type":"object","additionalProperties":false},{"type":"null"}]}},"additionalProperties":false,"required":["aborted","onabort"]},"RouteMatchCallback":{"description":"The \"match\" callback is used to determine if a `Route` should apply for a\nparticular URL and request. When matching occurs in response to a fetch\nevent from the client, the `event` object is also supplied. However, since\nthe match callback can be invoked outside of a fetch event, matching logic\nshould not assume the `event` object will always be available.\nIf the match callback returns a truthy value, the matching route's\n`RouteHandlerCallback` will be invoked immediately. If the value returned\nis a non-empty array or object, that value will be set on the handler's\n`options.params` argument.","typeof":"function"}},"$schema":"http://json-schema.org/draft-07/schema#"} diff --git a/packages/workbox-build/src/schema/InjectManifestOptions.json b/packages/workbox-build/src/schema/InjectManifestOptions.json index e2659edfb..fc12f138e 100644 --- a/packages/workbox-build/src/schema/InjectManifestOptions.json +++ b/packages/workbox-build/src/schema/InjectManifestOptions.json @@ -1 +1 @@ -{"additionalProperties":false,"type":"object","properties":{"additionalManifestEntries":{"type":"array","items":{"anyOf":[{"$ref":"#/definitions/ManifestEntry"},{"type":"string"}]}},"dontCacheBustURLsMatching":{"$ref":"#/definitions/RegExp"},"manifestTransforms":{"type":"array","items":{"typeof":"function"}},"maximumFileSizeToCacheInBytes":{"default":2097152,"type":"number"},"modifyURLPrefix":{"type":"object","additionalProperties":{"type":"string"}},"globFollow":{"default":true,"type":"boolean"},"globIgnores":{"default":["**/node_modules/**/*"],"type":"array","items":{"type":"string"}},"globPatterns":{"default":["**/*.{js,css,html}"],"type":"array","items":{"type":"string"}},"globStrict":{"default":true,"type":"boolean"},"templatedURLs":{"type":"object","additionalProperties":{"anyOf":[{"type":"array","items":{"type":"string"}},{"type":"string"}]}},"injectionPoint":{"default":"self.__WB_MANIFEST","type":"string"},"swSrc":{"type":"string"},"swDest":{"type":"string"},"globDirectory":{"type":"string"}},"required":["globDirectory","swDest","swSrc"],"definitions":{"ManifestEntry":{"type":"object","properties":{"integrity":{"type":"string"},"revision":{"type":["null","string"]},"url":{"type":"string"}},"additionalProperties":false,"required":["revision","url"]},"RegExp":{"type":"object","properties":{"source":{"type":"string"},"global":{"type":"boolean"},"ignoreCase":{"type":"boolean"},"multiline":{"type":"boolean"},"lastIndex":{"type":"number"},"flags":{"type":"string"},"sticky":{"type":"boolean"},"unicode":{"type":"boolean"},"dotAll":{"type":"boolean"}},"additionalProperties":false,"required":["dotAll","flags","global","ignoreCase","lastIndex","multiline","source","sticky","unicode"]},"GoogleAnalyticsInitializeOptions":{"type":"object","properties":{"cacheName":{"type":"string"},"parameterOverrides":{"type":"object","additionalProperties":{"type":"string"}},"hitFilter":{"type":"object","additionalProperties":false}},"additionalProperties":false},"RuntimeCaching":{"type":"object","properties":{"handler":{"anyOf":[{"$ref":"#/definitions/RouteHandlerCallback"},{"$ref":"#/definitions/RouteHandlerObject"},{"enum":["CacheFirst","CacheOnly","NetworkFirst","NetworkOnly","StaleWhileRevalidate"],"type":"string"}]},"method":{"enum":["DELETE","GET","HEAD","PATCH","POST","PUT"],"type":"string"},"options":{"type":"object","properties":{"backgroundSync":{"type":"object","properties":{"name":{"type":"string"},"options":{"$ref":"#/definitions/QueueOptions"}},"additionalProperties":false,"required":["name"]},"broadcastUpdate":{"type":"object","properties":{"channelName":{"type":"string"},"options":{"$ref":"#/definitions/BroadcastCacheUpdateOptions"}},"additionalProperties":false,"required":["options"]},"cacheableResponse":{"$ref":"#/definitions/CacheableResponseOptions"},"cacheName":{"type":["null","string"]},"expiration":{"$ref":"#/definitions/ExpirationPluginOptions"},"networkTimeoutSeconds":{"type":"number"},"plugins":{"type":"array","items":{"$ref":"#/definitions/WorkboxPlugin"}},"precacheFallback":{"type":"object","properties":{"fallbackURL":{"type":"string"}},"additionalProperties":false,"required":["fallbackURL"]},"fetchOptions":{"$ref":"#/definitions/RequestInit"},"matchOptions":{"$ref":"#/definitions/CacheQueryOptions"}},"additionalProperties":false},"urlPattern":{"anyOf":[{"$ref":"#/definitions/RegExp"},{"$ref":"#/definitions/RouteMatchCallback"},{"type":"string"}]}},"additionalProperties":false,"required":["handler","urlPattern"]},"RouteHandlerCallback":{"description":"The \"handler\" callback is invoked whenever a `Router` matches a URL/Request\nto a `Route` via its `RouteMatchCallback`. This handler callback should\nreturn a `Promise` that resolves with a `Response`.\n\nIf a non-empty array or object is returned by the `RouteMatchCallback` it\nwill be passed in as this handler's `options.params` argument.","type":"object","additionalProperties":false},"RouteHandlerObject":{"description":"An object with a `handle` method of type `RouteHandlerCallback`.\n\nA `Route` object can be created with either an `RouteHandlerCallback`\nfunction or this `RouteHandler` object. The benefit of the `RouteHandler`\nis it can be extended (as is done by the `workbox-strategies` package).","type":"object","properties":{"handle":{"$ref":"#/definitions/RouteHandlerCallback"}},"additionalProperties":false,"required":["handle"]},"QueueOptions":{"type":"object","properties":{"onSync":{"$ref":"#/definitions/OnSyncCallback"},"maxRetentionTime":{"type":"number"}},"additionalProperties":false},"OnSyncCallback":{"type":"object","additionalProperties":false},"BroadcastCacheUpdateOptions":{"type":"object","properties":{"headersToCheck":{"type":"array","items":{"type":"string"}},"generatePayload":{"type":"object","additionalProperties":false}},"additionalProperties":false},"CacheableResponseOptions":{"type":"object","properties":{"statuses":{"type":"array","items":{"type":"number"}},"headers":{"type":"object","additionalProperties":{"type":"string"}}},"additionalProperties":false},"ExpirationPluginOptions":{"type":"object","properties":{"maxEntries":{"type":"number"},"maxAgeSeconds":{"type":"number"},"matchOptions":{"$ref":"#/definitions/CacheQueryOptions"},"purgeOnQuotaError":{"type":"boolean"}},"additionalProperties":false},"CacheQueryOptions":{"type":"object","properties":{"ignoreMethod":{"type":"boolean"},"ignoreSearch":{"type":"boolean"},"ignoreVary":{"type":"boolean"}},"additionalProperties":false},"WorkboxPlugin":{"description":"An object with optional lifecycle callback properties for the fetch and\ncache operations.","type":"object","properties":{"cacheDidUpdate":{"$ref":"#/definitions/CacheDidUpdateCallback"},"cachedResponseWillBeUsed":{"$ref":"#/definitions/CachedResponseWillBeUsedCallback"},"cacheKeyWillBeUsed":{"$ref":"#/definitions/CacheKeyWillBeUsedCallback"},"cacheWillUpdate":{"$ref":"#/definitions/CacheWillUpdateCallback"},"fetchDidFail":{"$ref":"#/definitions/FetchDidFailCallback"},"fetchDidSucceed":{"$ref":"#/definitions/FetchDidSucceedCallback"},"handlerDidComplete":{"$ref":"#/definitions/HandlerDidCompleteCallback"},"handlerDidError":{"$ref":"#/definitions/HandlerDidErrorCallback"},"handlerDidRespond":{"$ref":"#/definitions/HandlerDidRespondCallback"},"handlerWillRespond":{"$ref":"#/definitions/HandlerWillRespondCallback"},"handlerWillStart":{"$ref":"#/definitions/HandlerWillStartCallback"},"requestWillFetch":{"$ref":"#/definitions/RequestWillFetchCallback"}},"additionalProperties":false},"CacheDidUpdateCallback":{"type":"object","additionalProperties":false},"CachedResponseWillBeUsedCallback":{"type":"object","additionalProperties":false},"CacheKeyWillBeUsedCallback":{"type":"object","additionalProperties":false},"CacheWillUpdateCallback":{"type":"object","additionalProperties":false},"FetchDidFailCallback":{"type":"object","additionalProperties":false},"FetchDidSucceedCallback":{"type":"object","additionalProperties":false},"HandlerDidCompleteCallback":{"type":"object","additionalProperties":false},"HandlerDidErrorCallback":{"type":"object","additionalProperties":false},"HandlerDidRespondCallback":{"type":"object","additionalProperties":false},"HandlerWillRespondCallback":{"type":"object","additionalProperties":false},"HandlerWillStartCallback":{"type":"object","additionalProperties":false},"RequestWillFetchCallback":{"type":"object","additionalProperties":false},"RequestInit":{"type":"object","properties":{"body":{"anyOf":[{"$ref":"#/definitions/ArrayBuffer"},{"$ref":"#/definitions/ArrayBufferView"},{"$ref":"#/definitions/Blob"},{"$ref":"#/definitions/FormData"},{"$ref":"#/definitions/URLSearchParams"},{"$ref":"#/definitions/ReadableStream"},{"type":["null","string"]}]},"cache":{"enum":["default","force-cache","no-cache","no-store","only-if-cached","reload"],"type":"string"},"credentials":{"enum":["include","omit","same-origin"],"type":"string"},"headers":{"anyOf":[{"$ref":"#/definitions/Headers"},{"type":"array","items":{"type":"array","items":{"type":"string"}}},{"$ref":"#/definitions/Record"}]},"integrity":{"type":"string"},"keepalive":{"type":"boolean"},"method":{"type":"string"},"mode":{"enum":["cors","navigate","no-cors","same-origin"],"type":"string"},"redirect":{"enum":["error","follow","manual"],"type":"string"},"referrer":{"type":"string"},"referrerPolicy":{"enum":["","no-referrer","no-referrer-when-downgrade","origin","origin-when-cross-origin","same-origin","strict-origin","strict-origin-when-cross-origin","unsafe-url"],"type":"string"},"signal":{"anyOf":[{"$ref":"#/definitions/AbortSignal"},{"type":"null"}]},"window":{}},"additionalProperties":false},"ArrayBuffer":{"type":"object","properties":{"byteLength":{"type":"number"},"__@toStringTag":{"type":"string"}},"additionalProperties":false,"required":["__@toStringTag","byteLength"]},"ArrayBufferView":{"type":"object","properties":{"buffer":{"anyOf":[{"$ref":"#/definitions/ArrayBuffer"},{"$ref":"#/definitions/SharedArrayBuffer"}]},"byteLength":{"type":"number"},"byteOffset":{"type":"number"}},"additionalProperties":false,"required":["buffer","byteLength","byteOffset"]},"SharedArrayBuffer":{"type":"object","properties":{"byteLength":{"type":"number"},"__@species":{"$ref":"#/definitions/SharedArrayBuffer"},"__@toStringTag":{"type":"string","enum":["SharedArrayBuffer"]}},"additionalProperties":false,"required":["__@species","__@toStringTag","byteLength"]},"Blob":{"type":"object","properties":{"size":{"type":"number"},"type":{"type":"string"}},"additionalProperties":false,"required":["size","type"]},"FormData":{"type":"object","additionalProperties":false},"URLSearchParams":{"type":"object","additionalProperties":false},"ReadableStream":{"type":"object","properties":{"locked":{"type":"boolean"}},"additionalProperties":false,"required":["locked"]},"Headers":{"type":"object","additionalProperties":false},"Record":{"type":"object","additionalProperties":false},"AbortSignal":{"type":"object","properties":{"aborted":{"type":"boolean"},"onabort":{"anyOf":[{"type":"object","additionalProperties":false},{"type":"null"}]}},"additionalProperties":false,"required":["aborted","onabort"]},"RouteMatchCallback":{"description":"The \"match\" callback is used to determine if a `Route` should apply for a\nparticular URL and request. When matching occurs in response to a fetch\nevent from the client, the `event` object is also supplied. However, since\nthe match callback can be invoked outside of a fetch event, matching logic\nshould not assume the `event` object will always be available.\nIf the match callback returns a truthy value, the matching route's\n`RouteHandlerCallback` will be invoked immediately. If the value returned\nis a non-empty array or object, that value will be set on the handler's\n`options.params` argument.","additionalProperties":false,"typeof":"function"}},"$schema":"http://json-schema.org/draft-07/schema#"} +{"additionalProperties":false,"type":"object","properties":{"additionalManifestEntries":{"type":"array","items":{"anyOf":[{"$ref":"#/definitions/ManifestEntry"},{"type":"string"}]}},"dontCacheBustURLsMatching":{"$ref":"#/definitions/RegExp"},"manifestTransforms":{"type":"array","items":{"typeof":"function"}},"maximumFileSizeToCacheInBytes":{"default":2097152,"type":"number"},"modifyURLPrefix":{"type":"object","additionalProperties":{"type":"string"}},"globFollow":{"default":true,"type":"boolean"},"globIgnores":{"default":["**/node_modules/**/*"],"type":"array","items":{"type":"string"}},"globPatterns":{"default":["**/*.{js,css,html}"],"type":"array","items":{"type":"string"}},"globStrict":{"default":true,"type":"boolean"},"templatedURLs":{"type":"object","additionalProperties":{"anyOf":[{"type":"array","items":{"type":"string"}},{"type":"string"}]}},"injectionPoint":{"default":"self.__WB_MANIFEST","type":"string"},"swSrc":{"type":"string"},"swDest":{"type":"string"},"globDirectory":{"type":"string"}},"required":["globDirectory","swDest","swSrc"],"definitions":{"ManifestEntry":{"type":"object","properties":{"integrity":{"type":"string"},"revision":{"type":["null","string"]},"url":{"type":"string"}},"additionalProperties":false,"required":["revision","url"]},"RegExp":{"type":"object","properties":{"source":{"type":"string"},"global":{"type":"boolean"},"ignoreCase":{"type":"boolean"},"multiline":{"type":"boolean"},"lastIndex":{"type":"number"},"flags":{"type":"string"},"sticky":{"type":"boolean"},"unicode":{"type":"boolean"},"dotAll":{"type":"boolean"}},"additionalProperties":false,"required":["dotAll","flags","global","ignoreCase","lastIndex","multiline","source","sticky","unicode"]},"GoogleAnalyticsInitializeOptions":{"type":"object","properties":{"cacheName":{"type":"string"},"parameterOverrides":{"type":"object","additionalProperties":{"type":"string"}},"hitFilter":{"type":"object","additionalProperties":false}},"additionalProperties":false},"RuntimeCaching":{"type":"object","properties":{"handler":{"anyOf":[{"$ref":"#/definitions/RouteHandlerCallback"},{"$ref":"#/definitions/RouteHandlerObject"},{"enum":["CacheFirst","CacheOnly","NetworkFirst","NetworkOnly","StaleWhileRevalidate"],"type":"string"}]},"method":{"enum":["DELETE","GET","HEAD","PATCH","POST","PUT"],"type":"string"},"options":{"type":"object","properties":{"backgroundSync":{"type":"object","properties":{"name":{"type":"string"},"options":{"$ref":"#/definitions/QueueOptions"}},"additionalProperties":false,"required":["name"]},"broadcastUpdate":{"type":"object","properties":{"channelName":{"type":"string"},"options":{"$ref":"#/definitions/BroadcastCacheUpdateOptions"}},"additionalProperties":false,"required":["options"]},"cacheableResponse":{"$ref":"#/definitions/CacheableResponseOptions"},"cacheName":{"type":["null","string"]},"expiration":{"$ref":"#/definitions/ExpirationPluginOptions"},"networkTimeoutSeconds":{"type":"number"},"plugins":{"type":"array","items":{"$ref":"#/definitions/WorkboxPlugin"}},"precacheFallback":{"type":"object","properties":{"fallbackURL":{"type":"string"}},"additionalProperties":false,"required":["fallbackURL"]},"fetchOptions":{"$ref":"#/definitions/RequestInit"},"matchOptions":{"$ref":"#/definitions/CacheQueryOptions"}},"additionalProperties":false},"urlPattern":{"anyOf":[{"$ref":"#/definitions/RegExp"},{"$ref":"#/definitions/RouteMatchCallback"},{"type":"string"}]}},"additionalProperties":false,"required":["handler","urlPattern"]},"RouteHandlerCallback":{"description":"The \"handler\" callback is invoked whenever a `Router` matches a URL/Request\nto a `Route` via its `RouteMatchCallback`. This handler callback should\nreturn a `Promise` that resolves with a `Response`.\n\nIf a non-empty array or object is returned by the `RouteMatchCallback` it\nwill be passed in as this handler's `options.params` argument.","type":"object","additionalProperties":false},"RouteHandlerObject":{"description":"An object with a `handle` method of type `RouteHandlerCallback`.\n\nA `Route` object can be created with either an `RouteHandlerCallback`\nfunction or this `RouteHandler` object. The benefit of the `RouteHandler`\nis it can be extended (as is done by the `workbox-strategies` package).","type":"object","properties":{"handle":{"$ref":"#/definitions/RouteHandlerCallback"}},"additionalProperties":false,"required":["handle"]},"QueueOptions":{"type":"object","properties":{"onSync":{"$ref":"#/definitions/OnSyncCallback"},"maxRetentionTime":{"type":"number"}},"additionalProperties":false},"OnSyncCallback":{"type":"object","additionalProperties":false},"BroadcastCacheUpdateOptions":{"type":"object","properties":{"headersToCheck":{"type":"array","items":{"type":"string"}},"generatePayload":{"type":"object","additionalProperties":false}},"additionalProperties":false},"CacheableResponseOptions":{"type":"object","properties":{"statuses":{"type":"array","items":{"type":"number"}},"headers":{"type":"object","additionalProperties":{"type":"string"}}},"additionalProperties":false},"ExpirationPluginOptions":{"type":"object","properties":{"maxEntries":{"type":"number"},"maxAgeSeconds":{"type":"number"},"matchOptions":{"$ref":"#/definitions/CacheQueryOptions"},"purgeOnQuotaError":{"type":"boolean"}},"additionalProperties":false},"CacheQueryOptions":{"type":"object","properties":{"ignoreMethod":{"type":"boolean"},"ignoreSearch":{"type":"boolean"},"ignoreVary":{"type":"boolean"}},"additionalProperties":false},"WorkboxPlugin":{"description":"An object with optional lifecycle callback properties for the fetch and\ncache operations.","type":"object","properties":{"cacheDidUpdate":{"$ref":"#/definitions/CacheDidUpdateCallback"},"cachedResponseWillBeUsed":{"$ref":"#/definitions/CachedResponseWillBeUsedCallback"},"cacheKeyWillBeUsed":{"$ref":"#/definitions/CacheKeyWillBeUsedCallback"},"cacheWillUpdate":{"$ref":"#/definitions/CacheWillUpdateCallback"},"fetchDidFail":{"$ref":"#/definitions/FetchDidFailCallback"},"fetchDidSucceed":{"$ref":"#/definitions/FetchDidSucceedCallback"},"handlerDidComplete":{"$ref":"#/definitions/HandlerDidCompleteCallback"},"handlerDidError":{"$ref":"#/definitions/HandlerDidErrorCallback"},"handlerDidRespond":{"$ref":"#/definitions/HandlerDidRespondCallback"},"handlerWillRespond":{"$ref":"#/definitions/HandlerWillRespondCallback"},"handlerWillStart":{"$ref":"#/definitions/HandlerWillStartCallback"},"requestWillFetch":{"$ref":"#/definitions/RequestWillFetchCallback"}},"additionalProperties":false},"CacheDidUpdateCallback":{"type":"object","additionalProperties":false},"CachedResponseWillBeUsedCallback":{"type":"object","additionalProperties":false},"CacheKeyWillBeUsedCallback":{"type":"object","additionalProperties":false},"CacheWillUpdateCallback":{"type":"object","additionalProperties":false},"FetchDidFailCallback":{"type":"object","additionalProperties":false},"FetchDidSucceedCallback":{"type":"object","additionalProperties":false},"HandlerDidCompleteCallback":{"type":"object","additionalProperties":false},"HandlerDidErrorCallback":{"type":"object","additionalProperties":false},"HandlerDidRespondCallback":{"type":"object","additionalProperties":false},"HandlerWillRespondCallback":{"type":"object","additionalProperties":false},"HandlerWillStartCallback":{"type":"object","additionalProperties":false},"RequestWillFetchCallback":{"type":"object","additionalProperties":false},"RequestInit":{"type":"object","properties":{"body":{"anyOf":[{"$ref":"#/definitions/ArrayBuffer"},{"$ref":"#/definitions/ArrayBufferView"},{"$ref":"#/definitions/Blob"},{"$ref":"#/definitions/FormData"},{"$ref":"#/definitions/URLSearchParams"},{"$ref":"#/definitions/ReadableStream"},{"type":["null","string"]}]},"cache":{"enum":["default","force-cache","no-cache","no-store","only-if-cached","reload"],"type":"string"},"credentials":{"enum":["include","omit","same-origin"],"type":"string"},"headers":{"anyOf":[{"$ref":"#/definitions/Headers"},{"type":"array","items":{"type":"array","items":{"type":"string"}}},{"$ref":"#/definitions/Record"}]},"integrity":{"type":"string"},"keepalive":{"type":"boolean"},"method":{"type":"string"},"mode":{"enum":["cors","navigate","no-cors","same-origin"],"type":"string"},"redirect":{"enum":["error","follow","manual"],"type":"string"},"referrer":{"type":"string"},"referrerPolicy":{"enum":["","no-referrer","no-referrer-when-downgrade","origin","origin-when-cross-origin","same-origin","strict-origin","strict-origin-when-cross-origin","unsafe-url"],"type":"string"},"signal":{"anyOf":[{"$ref":"#/definitions/AbortSignal"},{"type":"null"}]},"window":{}},"additionalProperties":false},"ArrayBuffer":{"type":"object","properties":{"byteLength":{"type":"number"},"__@toStringTag":{"type":"string"}},"additionalProperties":false,"required":["__@toStringTag","byteLength"]},"ArrayBufferView":{"type":"object","properties":{"buffer":{"anyOf":[{"$ref":"#/definitions/ArrayBuffer"},{"$ref":"#/definitions/SharedArrayBuffer"}]},"byteLength":{"type":"number"},"byteOffset":{"type":"number"}},"additionalProperties":false,"required":["buffer","byteLength","byteOffset"]},"SharedArrayBuffer":{"type":"object","properties":{"byteLength":{"type":"number"},"__@species":{"$ref":"#/definitions/SharedArrayBuffer"},"__@toStringTag":{"type":"string","enum":["SharedArrayBuffer"]}},"additionalProperties":false,"required":["__@species","__@toStringTag","byteLength"]},"Blob":{"type":"object","properties":{"size":{"type":"number"},"type":{"type":"string"}},"additionalProperties":false,"required":["size","type"]},"FormData":{"type":"object","additionalProperties":false},"URLSearchParams":{"type":"object","additionalProperties":false},"ReadableStream":{"type":"object","properties":{"locked":{"type":"boolean"}},"additionalProperties":false,"required":["locked"]},"Headers":{"type":"object","additionalProperties":false},"Record":{"type":"object","additionalProperties":false},"AbortSignal":{"type":"object","properties":{"aborted":{"type":"boolean"},"onabort":{"anyOf":[{"type":"object","additionalProperties":false},{"type":"null"}]}},"additionalProperties":false,"required":["aborted","onabort"]},"RouteMatchCallback":{"description":"The \"match\" callback is used to determine if a `Route` should apply for a\nparticular URL and request. When matching occurs in response to a fetch\nevent from the client, the `event` object is also supplied. However, since\nthe match callback can be invoked outside of a fetch event, matching logic\nshould not assume the `event` object will always be available.\nIf the match callback returns a truthy value, the matching route's\n`RouteHandlerCallback` will be invoked immediately. If the value returned\nis a non-empty array or object, that value will be set on the handler's\n`options.params` argument.","typeof":"function"}},"$schema":"http://json-schema.org/draft-07/schema#"} diff --git a/packages/workbox-build/src/schema/WebpackGenerateSWOptions.json b/packages/workbox-build/src/schema/WebpackGenerateSWOptions.json index 5a4c8626c..16a3f1c00 100644 --- a/packages/workbox-build/src/schema/WebpackGenerateSWOptions.json +++ b/packages/workbox-build/src/schema/WebpackGenerateSWOptions.json @@ -1 +1 @@ -{"additionalProperties":false,"type":"object","properties":{"additionalManifestEntries":{"type":"array","items":{"anyOf":[{"$ref":"#/definitions/ManifestEntry"},{"type":"string"}]}},"dontCacheBustURLsMatching":{"$ref":"#/definitions/RegExp"},"manifestTransforms":{"type":"array","items":{"typeof":"function"}},"maximumFileSizeToCacheInBytes":{"default":2097152,"type":"number"},"modifyURLPrefix":{"type":"object","additionalProperties":{"type":"string"}},"chunks":{"type":"array","items":{"type":"string"}},"exclude":{"type":"array","items":{"anyOf":[{"$ref":"#/definitions/RegExp"},{"type":"string"},{"typeof":"function"}]}},"excludeChunks":{"type":"array","items":{"type":"string"}},"include":{"type":"array","items":{"anyOf":[{"$ref":"#/definitions/RegExp"},{"type":"string"},{"typeof":"function"}]}},"mode":{"default":"production","type":["null","string"]},"babelPresetEnvTargets":{"default":["chrome >= 56"],"type":"array","items":{"type":"string"}},"cacheId":{"type":["null","string"]},"cleanupOutdatedCaches":{"default":false,"type":"boolean"},"clientsClaim":{"default":false,"type":"boolean"},"directoryIndex":{"type":["null","string"]},"disableDevLogs":{"default":false,"type":"boolean"},"ignoreURLParametersMatching":{"type":"array","items":{"$ref":"#/definitions/RegExp"}},"importScripts":{"type":"array","items":{"type":"string"}},"inlineWorkboxRuntime":{"default":false,"type":"boolean"},"navigateFallback":{"default":null,"type":["null","string"]},"navigateFallbackAllowlist":{"type":"array","items":{"$ref":"#/definitions/RegExp"}},"navigateFallbackDenylist":{"type":"array","items":{"$ref":"#/definitions/RegExp"}},"navigationPreload":{"description":"navigationPreload is only valid when runtimeCaching is configured. However,\nthis can't be expressed via TypeScript, so it's enforced via runtime logic.","default":false,"type":"boolean"},"offlineGoogleAnalytics":{"default":false,"anyOf":[{"$ref":"#/definitions/GoogleAnalyticsInitializeOptions"},{"type":"boolean"}]},"runtimeCaching":{"type":"array","items":{"$ref":"#/definitions/RuntimeCaching"}},"skipWaiting":{"default":false,"type":"boolean"},"sourcemap":{"default":true,"type":"boolean"},"importScriptsViaChunks":{"type":"array","items":{"type":"string"}},"swDest":{"default":"service-worker.js","type":"string"}},"definitions":{"ManifestEntry":{"type":"object","properties":{"integrity":{"type":"string"},"revision":{"type":["null","string"]},"url":{"type":"string"}},"additionalProperties":false,"required":["revision","url"]},"RegExp":{"type":"object","properties":{"source":{"type":"string"},"global":{"type":"boolean"},"ignoreCase":{"type":"boolean"},"multiline":{"type":"boolean"},"lastIndex":{"type":"number"},"flags":{"type":"string"},"sticky":{"type":"boolean"},"unicode":{"type":"boolean"},"dotAll":{"type":"boolean"}},"additionalProperties":false,"required":["dotAll","flags","global","ignoreCase","lastIndex","multiline","source","sticky","unicode"]},"GoogleAnalyticsInitializeOptions":{"type":"object","properties":{"cacheName":{"type":"string"},"parameterOverrides":{"type":"object","additionalProperties":{"type":"string"}},"hitFilter":{"type":"object","additionalProperties":false}},"additionalProperties":false},"RuntimeCaching":{"type":"object","properties":{"handler":{"anyOf":[{"$ref":"#/definitions/RouteHandlerCallback"},{"$ref":"#/definitions/RouteHandlerObject"},{"enum":["CacheFirst","CacheOnly","NetworkFirst","NetworkOnly","StaleWhileRevalidate"],"type":"string"}]},"method":{"enum":["DELETE","GET","HEAD","PATCH","POST","PUT"],"type":"string"},"options":{"type":"object","properties":{"backgroundSync":{"type":"object","properties":{"name":{"type":"string"},"options":{"$ref":"#/definitions/QueueOptions"}},"additionalProperties":false,"required":["name"]},"broadcastUpdate":{"type":"object","properties":{"channelName":{"type":"string"},"options":{"$ref":"#/definitions/BroadcastCacheUpdateOptions"}},"additionalProperties":false,"required":["options"]},"cacheableResponse":{"$ref":"#/definitions/CacheableResponseOptions"},"cacheName":{"type":["null","string"]},"expiration":{"$ref":"#/definitions/ExpirationPluginOptions"},"networkTimeoutSeconds":{"type":"number"},"plugins":{"type":"array","items":{"$ref":"#/definitions/WorkboxPlugin"}},"precacheFallback":{"type":"object","properties":{"fallbackURL":{"type":"string"}},"additionalProperties":false,"required":["fallbackURL"]},"fetchOptions":{"$ref":"#/definitions/RequestInit"},"matchOptions":{"$ref":"#/definitions/CacheQueryOptions"}},"additionalProperties":false},"urlPattern":{"anyOf":[{"$ref":"#/definitions/RegExp"},{"$ref":"#/definitions/RouteMatchCallback"},{"type":"string"}]}},"additionalProperties":false,"required":["handler","urlPattern"]},"RouteHandlerCallback":{"description":"The \"handler\" callback is invoked whenever a `Router` matches a URL/Request\nto a `Route` via its `RouteMatchCallback`. This handler callback should\nreturn a `Promise` that resolves with a `Response`.\n\nIf a non-empty array or object is returned by the `RouteMatchCallback` it\nwill be passed in as this handler's `options.params` argument.","type":"object","additionalProperties":false},"RouteHandlerObject":{"description":"An object with a `handle` method of type `RouteHandlerCallback`.\n\nA `Route` object can be created with either an `RouteHandlerCallback`\nfunction or this `RouteHandler` object. The benefit of the `RouteHandler`\nis it can be extended (as is done by the `workbox-strategies` package).","type":"object","properties":{"handle":{"$ref":"#/definitions/RouteHandlerCallback"}},"additionalProperties":false,"required":["handle"]},"QueueOptions":{"type":"object","properties":{"onSync":{"$ref":"#/definitions/OnSyncCallback"},"maxRetentionTime":{"type":"number"}},"additionalProperties":false},"OnSyncCallback":{"type":"object","additionalProperties":false},"BroadcastCacheUpdateOptions":{"type":"object","properties":{"headersToCheck":{"type":"array","items":{"type":"string"}},"generatePayload":{"type":"object","additionalProperties":false}},"additionalProperties":false},"CacheableResponseOptions":{"type":"object","properties":{"statuses":{"type":"array","items":{"type":"number"}},"headers":{"type":"object","additionalProperties":{"type":"string"}}},"additionalProperties":false},"ExpirationPluginOptions":{"type":"object","properties":{"maxEntries":{"type":"number"},"maxAgeSeconds":{"type":"number"},"matchOptions":{"$ref":"#/definitions/CacheQueryOptions"},"purgeOnQuotaError":{"type":"boolean"}},"additionalProperties":false},"CacheQueryOptions":{"type":"object","properties":{"ignoreMethod":{"type":"boolean"},"ignoreSearch":{"type":"boolean"},"ignoreVary":{"type":"boolean"}},"additionalProperties":false},"WorkboxPlugin":{"description":"An object with optional lifecycle callback properties for the fetch and\ncache operations.","type":"object","properties":{"cacheDidUpdate":{"$ref":"#/definitions/CacheDidUpdateCallback"},"cachedResponseWillBeUsed":{"$ref":"#/definitions/CachedResponseWillBeUsedCallback"},"cacheKeyWillBeUsed":{"$ref":"#/definitions/CacheKeyWillBeUsedCallback"},"cacheWillUpdate":{"$ref":"#/definitions/CacheWillUpdateCallback"},"fetchDidFail":{"$ref":"#/definitions/FetchDidFailCallback"},"fetchDidSucceed":{"$ref":"#/definitions/FetchDidSucceedCallback"},"handlerDidComplete":{"$ref":"#/definitions/HandlerDidCompleteCallback"},"handlerDidError":{"$ref":"#/definitions/HandlerDidErrorCallback"},"handlerDidRespond":{"$ref":"#/definitions/HandlerDidRespondCallback"},"handlerWillRespond":{"$ref":"#/definitions/HandlerWillRespondCallback"},"handlerWillStart":{"$ref":"#/definitions/HandlerWillStartCallback"},"requestWillFetch":{"$ref":"#/definitions/RequestWillFetchCallback"}},"additionalProperties":false},"CacheDidUpdateCallback":{"type":"object","additionalProperties":false},"CachedResponseWillBeUsedCallback":{"type":"object","additionalProperties":false},"CacheKeyWillBeUsedCallback":{"type":"object","additionalProperties":false},"CacheWillUpdateCallback":{"type":"object","additionalProperties":false},"FetchDidFailCallback":{"type":"object","additionalProperties":false},"FetchDidSucceedCallback":{"type":"object","additionalProperties":false},"HandlerDidCompleteCallback":{"type":"object","additionalProperties":false},"HandlerDidErrorCallback":{"type":"object","additionalProperties":false},"HandlerDidRespondCallback":{"type":"object","additionalProperties":false},"HandlerWillRespondCallback":{"type":"object","additionalProperties":false},"HandlerWillStartCallback":{"type":"object","additionalProperties":false},"RequestWillFetchCallback":{"type":"object","additionalProperties":false},"RequestInit":{"type":"object","properties":{"body":{"anyOf":[{"$ref":"#/definitions/ArrayBuffer"},{"$ref":"#/definitions/ArrayBufferView"},{"$ref":"#/definitions/Blob"},{"$ref":"#/definitions/FormData"},{"$ref":"#/definitions/URLSearchParams"},{"$ref":"#/definitions/ReadableStream"},{"type":["null","string"]}]},"cache":{"enum":["default","force-cache","no-cache","no-store","only-if-cached","reload"],"type":"string"},"credentials":{"enum":["include","omit","same-origin"],"type":"string"},"headers":{"anyOf":[{"$ref":"#/definitions/Headers"},{"type":"array","items":{"type":"array","items":{"type":"string"}}},{"$ref":"#/definitions/Record"}]},"integrity":{"type":"string"},"keepalive":{"type":"boolean"},"method":{"type":"string"},"mode":{"enum":["cors","navigate","no-cors","same-origin"],"type":"string"},"redirect":{"enum":["error","follow","manual"],"type":"string"},"referrer":{"type":"string"},"referrerPolicy":{"enum":["","no-referrer","no-referrer-when-downgrade","origin","origin-when-cross-origin","same-origin","strict-origin","strict-origin-when-cross-origin","unsafe-url"],"type":"string"},"signal":{"anyOf":[{"$ref":"#/definitions/AbortSignal"},{"type":"null"}]},"window":{}},"additionalProperties":false},"ArrayBuffer":{"type":"object","properties":{"byteLength":{"type":"number"},"__@toStringTag":{"type":"string"}},"additionalProperties":false,"required":["__@toStringTag","byteLength"]},"ArrayBufferView":{"type":"object","properties":{"buffer":{"anyOf":[{"$ref":"#/definitions/ArrayBuffer"},{"$ref":"#/definitions/SharedArrayBuffer"}]},"byteLength":{"type":"number"},"byteOffset":{"type":"number"}},"additionalProperties":false,"required":["buffer","byteLength","byteOffset"]},"SharedArrayBuffer":{"type":"object","properties":{"byteLength":{"type":"number"},"__@species":{"$ref":"#/definitions/SharedArrayBuffer"},"__@toStringTag":{"type":"string","enum":["SharedArrayBuffer"]}},"additionalProperties":false,"required":["__@species","__@toStringTag","byteLength"]},"Blob":{"type":"object","properties":{"size":{"type":"number"},"type":{"type":"string"}},"additionalProperties":false,"required":["size","type"]},"FormData":{"type":"object","additionalProperties":false},"URLSearchParams":{"type":"object","additionalProperties":false},"ReadableStream":{"type":"object","properties":{"locked":{"type":"boolean"}},"additionalProperties":false,"required":["locked"]},"Headers":{"type":"object","additionalProperties":false},"Record":{"type":"object","additionalProperties":false},"AbortSignal":{"type":"object","properties":{"aborted":{"type":"boolean"},"onabort":{"anyOf":[{"type":"object","additionalProperties":false},{"type":"null"}]}},"additionalProperties":false,"required":["aborted","onabort"]},"RouteMatchCallback":{"description":"The \"match\" callback is used to determine if a `Route` should apply for a\nparticular URL and request. When matching occurs in response to a fetch\nevent from the client, the `event` object is also supplied. However, since\nthe match callback can be invoked outside of a fetch event, matching logic\nshould not assume the `event` object will always be available.\nIf the match callback returns a truthy value, the matching route's\n`RouteHandlerCallback` will be invoked immediately. If the value returned\nis a non-empty array or object, that value will be set on the handler's\n`options.params` argument.","additionalProperties":false,"typeof":"function"}},"$schema":"http://json-schema.org/draft-07/schema#"} +{"additionalProperties":false,"type":"object","properties":{"additionalManifestEntries":{"type":"array","items":{"anyOf":[{"$ref":"#/definitions/ManifestEntry"},{"type":"string"}]}},"dontCacheBustURLsMatching":{"$ref":"#/definitions/RegExp"},"manifestTransforms":{"type":"array","items":{"typeof":"function"}},"maximumFileSizeToCacheInBytes":{"default":2097152,"type":"number"},"modifyURLPrefix":{"type":"object","additionalProperties":{"type":"string"}},"chunks":{"type":"array","items":{"type":"string"}},"exclude":{"type":"array","items":{"anyOf":[{"$ref":"#/definitions/RegExp"},{"type":"string"},{"typeof":"function"}]}},"excludeChunks":{"type":"array","items":{"type":"string"}},"include":{"type":"array","items":{"anyOf":[{"$ref":"#/definitions/RegExp"},{"type":"string"},{"typeof":"function"}]}},"mode":{"default":"production","type":["null","string"]},"babelPresetEnvTargets":{"default":["chrome >= 56"],"type":"array","items":{"type":"string"}},"cacheId":{"type":["null","string"]},"cleanupOutdatedCaches":{"default":false,"type":"boolean"},"clientsClaim":{"default":false,"type":"boolean"},"directoryIndex":{"type":["null","string"]},"disableDevLogs":{"default":false,"type":"boolean"},"ignoreURLParametersMatching":{"type":"array","items":{"$ref":"#/definitions/RegExp"}},"importScripts":{"type":"array","items":{"type":"string"}},"inlineWorkboxRuntime":{"default":false,"type":"boolean"},"navigateFallback":{"default":null,"type":["null","string"]},"navigateFallbackAllowlist":{"type":"array","items":{"$ref":"#/definitions/RegExp"}},"navigateFallbackDenylist":{"type":"array","items":{"$ref":"#/definitions/RegExp"}},"navigationPreload":{"description":"navigationPreload is only valid when runtimeCaching is configured. However,\nthis can't be expressed via TypeScript, so it's enforced via runtime logic.","default":false,"type":"boolean"},"offlineGoogleAnalytics":{"default":false,"anyOf":[{"$ref":"#/definitions/GoogleAnalyticsInitializeOptions"},{"type":"boolean"}]},"runtimeCaching":{"type":"array","items":{"$ref":"#/definitions/RuntimeCaching"}},"skipWaiting":{"default":false,"type":"boolean"},"sourcemap":{"default":true,"type":"boolean"},"importScriptsViaChunks":{"type":"array","items":{"type":"string"}},"swDest":{"default":"service-worker.js","type":"string"}},"definitions":{"ManifestEntry":{"type":"object","properties":{"integrity":{"type":"string"},"revision":{"type":["null","string"]},"url":{"type":"string"}},"additionalProperties":false,"required":["revision","url"]},"RegExp":{"type":"object","properties":{"source":{"type":"string"},"global":{"type":"boolean"},"ignoreCase":{"type":"boolean"},"multiline":{"type":"boolean"},"lastIndex":{"type":"number"},"flags":{"type":"string"},"sticky":{"type":"boolean"},"unicode":{"type":"boolean"},"dotAll":{"type":"boolean"}},"additionalProperties":false,"required":["dotAll","flags","global","ignoreCase","lastIndex","multiline","source","sticky","unicode"]},"GoogleAnalyticsInitializeOptions":{"type":"object","properties":{"cacheName":{"type":"string"},"parameterOverrides":{"type":"object","additionalProperties":{"type":"string"}},"hitFilter":{"type":"object","additionalProperties":false}},"additionalProperties":false},"RuntimeCaching":{"type":"object","properties":{"handler":{"anyOf":[{"$ref":"#/definitions/RouteHandlerCallback"},{"$ref":"#/definitions/RouteHandlerObject"},{"enum":["CacheFirst","CacheOnly","NetworkFirst","NetworkOnly","StaleWhileRevalidate"],"type":"string"}]},"method":{"enum":["DELETE","GET","HEAD","PATCH","POST","PUT"],"type":"string"},"options":{"type":"object","properties":{"backgroundSync":{"type":"object","properties":{"name":{"type":"string"},"options":{"$ref":"#/definitions/QueueOptions"}},"additionalProperties":false,"required":["name"]},"broadcastUpdate":{"type":"object","properties":{"channelName":{"type":"string"},"options":{"$ref":"#/definitions/BroadcastCacheUpdateOptions"}},"additionalProperties":false,"required":["options"]},"cacheableResponse":{"$ref":"#/definitions/CacheableResponseOptions"},"cacheName":{"type":["null","string"]},"expiration":{"$ref":"#/definitions/ExpirationPluginOptions"},"networkTimeoutSeconds":{"type":"number"},"plugins":{"type":"array","items":{"$ref":"#/definitions/WorkboxPlugin"}},"precacheFallback":{"type":"object","properties":{"fallbackURL":{"type":"string"}},"additionalProperties":false,"required":["fallbackURL"]},"fetchOptions":{"$ref":"#/definitions/RequestInit"},"matchOptions":{"$ref":"#/definitions/CacheQueryOptions"}},"additionalProperties":false},"urlPattern":{"anyOf":[{"$ref":"#/definitions/RegExp"},{"$ref":"#/definitions/RouteMatchCallback"},{"type":"string"}]}},"additionalProperties":false,"required":["handler","urlPattern"]},"RouteHandlerCallback":{"description":"The \"handler\" callback is invoked whenever a `Router` matches a URL/Request\nto a `Route` via its `RouteMatchCallback`. This handler callback should\nreturn a `Promise` that resolves with a `Response`.\n\nIf a non-empty array or object is returned by the `RouteMatchCallback` it\nwill be passed in as this handler's `options.params` argument.","type":"object","additionalProperties":false},"RouteHandlerObject":{"description":"An object with a `handle` method of type `RouteHandlerCallback`.\n\nA `Route` object can be created with either an `RouteHandlerCallback`\nfunction or this `RouteHandler` object. The benefit of the `RouteHandler`\nis it can be extended (as is done by the `workbox-strategies` package).","type":"object","properties":{"handle":{"$ref":"#/definitions/RouteHandlerCallback"}},"additionalProperties":false,"required":["handle"]},"QueueOptions":{"type":"object","properties":{"onSync":{"$ref":"#/definitions/OnSyncCallback"},"maxRetentionTime":{"type":"number"}},"additionalProperties":false},"OnSyncCallback":{"type":"object","additionalProperties":false},"BroadcastCacheUpdateOptions":{"type":"object","properties":{"headersToCheck":{"type":"array","items":{"type":"string"}},"generatePayload":{"type":"object","additionalProperties":false}},"additionalProperties":false},"CacheableResponseOptions":{"type":"object","properties":{"statuses":{"type":"array","items":{"type":"number"}},"headers":{"type":"object","additionalProperties":{"type":"string"}}},"additionalProperties":false},"ExpirationPluginOptions":{"type":"object","properties":{"maxEntries":{"type":"number"},"maxAgeSeconds":{"type":"number"},"matchOptions":{"$ref":"#/definitions/CacheQueryOptions"},"purgeOnQuotaError":{"type":"boolean"}},"additionalProperties":false},"CacheQueryOptions":{"type":"object","properties":{"ignoreMethod":{"type":"boolean"},"ignoreSearch":{"type":"boolean"},"ignoreVary":{"type":"boolean"}},"additionalProperties":false},"WorkboxPlugin":{"description":"An object with optional lifecycle callback properties for the fetch and\ncache operations.","type":"object","properties":{"cacheDidUpdate":{"$ref":"#/definitions/CacheDidUpdateCallback"},"cachedResponseWillBeUsed":{"$ref":"#/definitions/CachedResponseWillBeUsedCallback"},"cacheKeyWillBeUsed":{"$ref":"#/definitions/CacheKeyWillBeUsedCallback"},"cacheWillUpdate":{"$ref":"#/definitions/CacheWillUpdateCallback"},"fetchDidFail":{"$ref":"#/definitions/FetchDidFailCallback"},"fetchDidSucceed":{"$ref":"#/definitions/FetchDidSucceedCallback"},"handlerDidComplete":{"$ref":"#/definitions/HandlerDidCompleteCallback"},"handlerDidError":{"$ref":"#/definitions/HandlerDidErrorCallback"},"handlerDidRespond":{"$ref":"#/definitions/HandlerDidRespondCallback"},"handlerWillRespond":{"$ref":"#/definitions/HandlerWillRespondCallback"},"handlerWillStart":{"$ref":"#/definitions/HandlerWillStartCallback"},"requestWillFetch":{"$ref":"#/definitions/RequestWillFetchCallback"}},"additionalProperties":false},"CacheDidUpdateCallback":{"type":"object","additionalProperties":false},"CachedResponseWillBeUsedCallback":{"type":"object","additionalProperties":false},"CacheKeyWillBeUsedCallback":{"type":"object","additionalProperties":false},"CacheWillUpdateCallback":{"type":"object","additionalProperties":false},"FetchDidFailCallback":{"type":"object","additionalProperties":false},"FetchDidSucceedCallback":{"type":"object","additionalProperties":false},"HandlerDidCompleteCallback":{"type":"object","additionalProperties":false},"HandlerDidErrorCallback":{"type":"object","additionalProperties":false},"HandlerDidRespondCallback":{"type":"object","additionalProperties":false},"HandlerWillRespondCallback":{"type":"object","additionalProperties":false},"HandlerWillStartCallback":{"type":"object","additionalProperties":false},"RequestWillFetchCallback":{"type":"object","additionalProperties":false},"RequestInit":{"type":"object","properties":{"body":{"anyOf":[{"$ref":"#/definitions/ArrayBuffer"},{"$ref":"#/definitions/ArrayBufferView"},{"$ref":"#/definitions/Blob"},{"$ref":"#/definitions/FormData"},{"$ref":"#/definitions/URLSearchParams"},{"$ref":"#/definitions/ReadableStream"},{"type":["null","string"]}]},"cache":{"enum":["default","force-cache","no-cache","no-store","only-if-cached","reload"],"type":"string"},"credentials":{"enum":["include","omit","same-origin"],"type":"string"},"headers":{"anyOf":[{"$ref":"#/definitions/Headers"},{"type":"array","items":{"type":"array","items":{"type":"string"}}},{"$ref":"#/definitions/Record"}]},"integrity":{"type":"string"},"keepalive":{"type":"boolean"},"method":{"type":"string"},"mode":{"enum":["cors","navigate","no-cors","same-origin"],"type":"string"},"redirect":{"enum":["error","follow","manual"],"type":"string"},"referrer":{"type":"string"},"referrerPolicy":{"enum":["","no-referrer","no-referrer-when-downgrade","origin","origin-when-cross-origin","same-origin","strict-origin","strict-origin-when-cross-origin","unsafe-url"],"type":"string"},"signal":{"anyOf":[{"$ref":"#/definitions/AbortSignal"},{"type":"null"}]},"window":{}},"additionalProperties":false},"ArrayBuffer":{"type":"object","properties":{"byteLength":{"type":"number"},"__@toStringTag":{"type":"string"}},"additionalProperties":false,"required":["__@toStringTag","byteLength"]},"ArrayBufferView":{"type":"object","properties":{"buffer":{"anyOf":[{"$ref":"#/definitions/ArrayBuffer"},{"$ref":"#/definitions/SharedArrayBuffer"}]},"byteLength":{"type":"number"},"byteOffset":{"type":"number"}},"additionalProperties":false,"required":["buffer","byteLength","byteOffset"]},"SharedArrayBuffer":{"type":"object","properties":{"byteLength":{"type":"number"},"__@species":{"$ref":"#/definitions/SharedArrayBuffer"},"__@toStringTag":{"type":"string","enum":["SharedArrayBuffer"]}},"additionalProperties":false,"required":["__@species","__@toStringTag","byteLength"]},"Blob":{"type":"object","properties":{"size":{"type":"number"},"type":{"type":"string"}},"additionalProperties":false,"required":["size","type"]},"FormData":{"type":"object","additionalProperties":false},"URLSearchParams":{"type":"object","additionalProperties":false},"ReadableStream":{"type":"object","properties":{"locked":{"type":"boolean"}},"additionalProperties":false,"required":["locked"]},"Headers":{"type":"object","additionalProperties":false},"Record":{"type":"object","additionalProperties":false},"AbortSignal":{"type":"object","properties":{"aborted":{"type":"boolean"},"onabort":{"anyOf":[{"type":"object","additionalProperties":false},{"type":"null"}]}},"additionalProperties":false,"required":["aborted","onabort"]},"RouteMatchCallback":{"description":"The \"match\" callback is used to determine if a `Route` should apply for a\nparticular URL and request. When matching occurs in response to a fetch\nevent from the client, the `event` object is also supplied. However, since\nthe match callback can be invoked outside of a fetch event, matching logic\nshould not assume the `event` object will always be available.\nIf the match callback returns a truthy value, the matching route's\n`RouteHandlerCallback` will be invoked immediately. If the value returned\nis a non-empty array or object, that value will be set on the handler's\n`options.params` argument.","typeof":"function"}},"$schema":"http://json-schema.org/draft-07/schema#"} diff --git a/packages/workbox-build/src/schema/WebpackInjectManifestOptions.json b/packages/workbox-build/src/schema/WebpackInjectManifestOptions.json index eae42863d..fb1e922f3 100644 --- a/packages/workbox-build/src/schema/WebpackInjectManifestOptions.json +++ b/packages/workbox-build/src/schema/WebpackInjectManifestOptions.json @@ -1 +1 @@ -{"additionalProperties":false,"type":"object","properties":{"additionalManifestEntries":{"type":"array","items":{"anyOf":[{"$ref":"#/definitions/ManifestEntry"},{"type":"string"}]}},"dontCacheBustURLsMatching":{"$ref":"#/definitions/RegExp"},"manifestTransforms":{"type":"array","items":{"typeof":"function"}},"maximumFileSizeToCacheInBytes":{"default":2097152,"type":"number"},"modifyURLPrefix":{"type":"object","additionalProperties":{"type":"string"}},"chunks":{"type":"array","items":{"type":"string"}},"exclude":{"type":"array","items":{"anyOf":[{"$ref":"#/definitions/RegExp"},{"type":"string"},{"typeof":"function"}]}},"excludeChunks":{"type":"array","items":{"type":"string"}},"include":{"type":"array","items":{"anyOf":[{"$ref":"#/definitions/RegExp"},{"type":"string"},{"typeof":"function"}]}},"mode":{"type":["null","string"]},"injectionPoint":{"default":"self.__WB_MANIFEST","type":"string"},"swSrc":{"type":"string"},"compileSrc":{"default":true,"type":"boolean"},"swDest":{"type":"string"},"webpackCompilationPlugins":{"type":"array","items":{}}},"required":["swSrc"],"definitions":{"ManifestEntry":{"type":"object","properties":{"integrity":{"type":"string"},"revision":{"type":["null","string"]},"url":{"type":"string"}},"additionalProperties":false,"required":["revision","url"]},"RegExp":{"type":"object","properties":{"source":{"type":"string"},"global":{"type":"boolean"},"ignoreCase":{"type":"boolean"},"multiline":{"type":"boolean"},"lastIndex":{"type":"number"},"flags":{"type":"string"},"sticky":{"type":"boolean"},"unicode":{"type":"boolean"},"dotAll":{"type":"boolean"}},"additionalProperties":false,"required":["dotAll","flags","global","ignoreCase","lastIndex","multiline","source","sticky","unicode"]},"GoogleAnalyticsInitializeOptions":{"type":"object","properties":{"cacheName":{"type":"string"},"parameterOverrides":{"type":"object","additionalProperties":{"type":"string"}},"hitFilter":{"type":"object","additionalProperties":false}},"additionalProperties":false},"RuntimeCaching":{"type":"object","properties":{"handler":{"anyOf":[{"$ref":"#/definitions/RouteHandlerCallback"},{"$ref":"#/definitions/RouteHandlerObject"},{"enum":["CacheFirst","CacheOnly","NetworkFirst","NetworkOnly","StaleWhileRevalidate"],"type":"string"}]},"method":{"enum":["DELETE","GET","HEAD","PATCH","POST","PUT"],"type":"string"},"options":{"type":"object","properties":{"backgroundSync":{"type":"object","properties":{"name":{"type":"string"},"options":{"$ref":"#/definitions/QueueOptions"}},"additionalProperties":false,"required":["name"]},"broadcastUpdate":{"type":"object","properties":{"channelName":{"type":"string"},"options":{"$ref":"#/definitions/BroadcastCacheUpdateOptions"}},"additionalProperties":false,"required":["options"]},"cacheableResponse":{"$ref":"#/definitions/CacheableResponseOptions"},"cacheName":{"type":["null","string"]},"expiration":{"$ref":"#/definitions/ExpirationPluginOptions"},"networkTimeoutSeconds":{"type":"number"},"plugins":{"type":"array","items":{"$ref":"#/definitions/WorkboxPlugin"}},"precacheFallback":{"type":"object","properties":{"fallbackURL":{"type":"string"}},"additionalProperties":false,"required":["fallbackURL"]},"fetchOptions":{"$ref":"#/definitions/RequestInit"},"matchOptions":{"$ref":"#/definitions/CacheQueryOptions"}},"additionalProperties":false},"urlPattern":{"anyOf":[{"$ref":"#/definitions/RegExp"},{"$ref":"#/definitions/RouteMatchCallback"},{"type":"string"}]}},"additionalProperties":false,"required":["handler","urlPattern"]},"RouteHandlerCallback":{"description":"The \"handler\" callback is invoked whenever a `Router` matches a URL/Request\nto a `Route` via its `RouteMatchCallback`. This handler callback should\nreturn a `Promise` that resolves with a `Response`.\n\nIf a non-empty array or object is returned by the `RouteMatchCallback` it\nwill be passed in as this handler's `options.params` argument.","type":"object","additionalProperties":false},"RouteHandlerObject":{"description":"An object with a `handle` method of type `RouteHandlerCallback`.\n\nA `Route` object can be created with either an `RouteHandlerCallback`\nfunction or this `RouteHandler` object. The benefit of the `RouteHandler`\nis it can be extended (as is done by the `workbox-strategies` package).","type":"object","properties":{"handle":{"$ref":"#/definitions/RouteHandlerCallback"}},"additionalProperties":false,"required":["handle"]},"QueueOptions":{"type":"object","properties":{"onSync":{"$ref":"#/definitions/OnSyncCallback"},"maxRetentionTime":{"type":"number"}},"additionalProperties":false},"OnSyncCallback":{"type":"object","additionalProperties":false},"BroadcastCacheUpdateOptions":{"type":"object","properties":{"headersToCheck":{"type":"array","items":{"type":"string"}},"generatePayload":{"type":"object","additionalProperties":false}},"additionalProperties":false},"CacheableResponseOptions":{"type":"object","properties":{"statuses":{"type":"array","items":{"type":"number"}},"headers":{"type":"object","additionalProperties":{"type":"string"}}},"additionalProperties":false},"ExpirationPluginOptions":{"type":"object","properties":{"maxEntries":{"type":"number"},"maxAgeSeconds":{"type":"number"},"matchOptions":{"$ref":"#/definitions/CacheQueryOptions"},"purgeOnQuotaError":{"type":"boolean"}},"additionalProperties":false},"CacheQueryOptions":{"type":"object","properties":{"ignoreMethod":{"type":"boolean"},"ignoreSearch":{"type":"boolean"},"ignoreVary":{"type":"boolean"}},"additionalProperties":false},"WorkboxPlugin":{"description":"An object with optional lifecycle callback properties for the fetch and\ncache operations.","type":"object","properties":{"cacheDidUpdate":{"$ref":"#/definitions/CacheDidUpdateCallback"},"cachedResponseWillBeUsed":{"$ref":"#/definitions/CachedResponseWillBeUsedCallback"},"cacheKeyWillBeUsed":{"$ref":"#/definitions/CacheKeyWillBeUsedCallback"},"cacheWillUpdate":{"$ref":"#/definitions/CacheWillUpdateCallback"},"fetchDidFail":{"$ref":"#/definitions/FetchDidFailCallback"},"fetchDidSucceed":{"$ref":"#/definitions/FetchDidSucceedCallback"},"handlerDidComplete":{"$ref":"#/definitions/HandlerDidCompleteCallback"},"handlerDidError":{"$ref":"#/definitions/HandlerDidErrorCallback"},"handlerDidRespond":{"$ref":"#/definitions/HandlerDidRespondCallback"},"handlerWillRespond":{"$ref":"#/definitions/HandlerWillRespondCallback"},"handlerWillStart":{"$ref":"#/definitions/HandlerWillStartCallback"},"requestWillFetch":{"$ref":"#/definitions/RequestWillFetchCallback"}},"additionalProperties":false},"CacheDidUpdateCallback":{"type":"object","additionalProperties":false},"CachedResponseWillBeUsedCallback":{"type":"object","additionalProperties":false},"CacheKeyWillBeUsedCallback":{"type":"object","additionalProperties":false},"CacheWillUpdateCallback":{"type":"object","additionalProperties":false},"FetchDidFailCallback":{"type":"object","additionalProperties":false},"FetchDidSucceedCallback":{"type":"object","additionalProperties":false},"HandlerDidCompleteCallback":{"type":"object","additionalProperties":false},"HandlerDidErrorCallback":{"type":"object","additionalProperties":false},"HandlerDidRespondCallback":{"type":"object","additionalProperties":false},"HandlerWillRespondCallback":{"type":"object","additionalProperties":false},"HandlerWillStartCallback":{"type":"object","additionalProperties":false},"RequestWillFetchCallback":{"type":"object","additionalProperties":false},"RequestInit":{"type":"object","properties":{"body":{"anyOf":[{"$ref":"#/definitions/ArrayBuffer"},{"$ref":"#/definitions/ArrayBufferView"},{"$ref":"#/definitions/Blob"},{"$ref":"#/definitions/FormData"},{"$ref":"#/definitions/URLSearchParams"},{"$ref":"#/definitions/ReadableStream"},{"type":["null","string"]}]},"cache":{"enum":["default","force-cache","no-cache","no-store","only-if-cached","reload"],"type":"string"},"credentials":{"enum":["include","omit","same-origin"],"type":"string"},"headers":{"anyOf":[{"$ref":"#/definitions/Headers"},{"type":"array","items":{"type":"array","items":{"type":"string"}}},{"$ref":"#/definitions/Record"}]},"integrity":{"type":"string"},"keepalive":{"type":"boolean"},"method":{"type":"string"},"mode":{"enum":["cors","navigate","no-cors","same-origin"],"type":"string"},"redirect":{"enum":["error","follow","manual"],"type":"string"},"referrer":{"type":"string"},"referrerPolicy":{"enum":["","no-referrer","no-referrer-when-downgrade","origin","origin-when-cross-origin","same-origin","strict-origin","strict-origin-when-cross-origin","unsafe-url"],"type":"string"},"signal":{"anyOf":[{"$ref":"#/definitions/AbortSignal"},{"type":"null"}]},"window":{}},"additionalProperties":false},"ArrayBuffer":{"type":"object","properties":{"byteLength":{"type":"number"},"__@toStringTag":{"type":"string"}},"additionalProperties":false,"required":["__@toStringTag","byteLength"]},"ArrayBufferView":{"type":"object","properties":{"buffer":{"anyOf":[{"$ref":"#/definitions/ArrayBuffer"},{"$ref":"#/definitions/SharedArrayBuffer"}]},"byteLength":{"type":"number"},"byteOffset":{"type":"number"}},"additionalProperties":false,"required":["buffer","byteLength","byteOffset"]},"SharedArrayBuffer":{"type":"object","properties":{"byteLength":{"type":"number"},"__@species":{"$ref":"#/definitions/SharedArrayBuffer"},"__@toStringTag":{"type":"string","enum":["SharedArrayBuffer"]}},"additionalProperties":false,"required":["__@species","__@toStringTag","byteLength"]},"Blob":{"type":"object","properties":{"size":{"type":"number"},"type":{"type":"string"}},"additionalProperties":false,"required":["size","type"]},"FormData":{"type":"object","additionalProperties":false},"URLSearchParams":{"type":"object","additionalProperties":false},"ReadableStream":{"type":"object","properties":{"locked":{"type":"boolean"}},"additionalProperties":false,"required":["locked"]},"Headers":{"type":"object","additionalProperties":false},"Record":{"type":"object","additionalProperties":false},"AbortSignal":{"type":"object","properties":{"aborted":{"type":"boolean"},"onabort":{"anyOf":[{"type":"object","additionalProperties":false},{"type":"null"}]}},"additionalProperties":false,"required":["aborted","onabort"]},"RouteMatchCallback":{"description":"The \"match\" callback is used to determine if a `Route` should apply for a\nparticular URL and request. When matching occurs in response to a fetch\nevent from the client, the `event` object is also supplied. However, since\nthe match callback can be invoked outside of a fetch event, matching logic\nshould not assume the `event` object will always be available.\nIf the match callback returns a truthy value, the matching route's\n`RouteHandlerCallback` will be invoked immediately. If the value returned\nis a non-empty array or object, that value will be set on the handler's\n`options.params` argument.","additionalProperties":false,"typeof":"function"}},"$schema":"http://json-schema.org/draft-07/schema#"} +{"additionalProperties":false,"type":"object","properties":{"additionalManifestEntries":{"type":"array","items":{"anyOf":[{"$ref":"#/definitions/ManifestEntry"},{"type":"string"}]}},"dontCacheBustURLsMatching":{"$ref":"#/definitions/RegExp"},"manifestTransforms":{"type":"array","items":{"typeof":"function"}},"maximumFileSizeToCacheInBytes":{"default":2097152,"type":"number"},"modifyURLPrefix":{"type":"object","additionalProperties":{"type":"string"}},"chunks":{"type":"array","items":{"type":"string"}},"exclude":{"type":"array","items":{"anyOf":[{"$ref":"#/definitions/RegExp"},{"type":"string"},{"typeof":"function"}]}},"excludeChunks":{"type":"array","items":{"type":"string"}},"include":{"type":"array","items":{"anyOf":[{"$ref":"#/definitions/RegExp"},{"type":"string"},{"typeof":"function"}]}},"mode":{"type":["null","string"]},"injectionPoint":{"default":"self.__WB_MANIFEST","type":"string"},"swSrc":{"type":"string"},"compileSrc":{"default":true,"type":"boolean"},"swDest":{"type":"string"},"webpackCompilationPlugins":{"type":"array","items":{}}},"required":["swSrc"],"definitions":{"ManifestEntry":{"type":"object","properties":{"integrity":{"type":"string"},"revision":{"type":["null","string"]},"url":{"type":"string"}},"additionalProperties":false,"required":["revision","url"]},"RegExp":{"type":"object","properties":{"source":{"type":"string"},"global":{"type":"boolean"},"ignoreCase":{"type":"boolean"},"multiline":{"type":"boolean"},"lastIndex":{"type":"number"},"flags":{"type":"string"},"sticky":{"type":"boolean"},"unicode":{"type":"boolean"},"dotAll":{"type":"boolean"}},"additionalProperties":false,"required":["dotAll","flags","global","ignoreCase","lastIndex","multiline","source","sticky","unicode"]},"GoogleAnalyticsInitializeOptions":{"type":"object","properties":{"cacheName":{"type":"string"},"parameterOverrides":{"type":"object","additionalProperties":{"type":"string"}},"hitFilter":{"type":"object","additionalProperties":false}},"additionalProperties":false},"RuntimeCaching":{"type":"object","properties":{"handler":{"anyOf":[{"$ref":"#/definitions/RouteHandlerCallback"},{"$ref":"#/definitions/RouteHandlerObject"},{"enum":["CacheFirst","CacheOnly","NetworkFirst","NetworkOnly","StaleWhileRevalidate"],"type":"string"}]},"method":{"enum":["DELETE","GET","HEAD","PATCH","POST","PUT"],"type":"string"},"options":{"type":"object","properties":{"backgroundSync":{"type":"object","properties":{"name":{"type":"string"},"options":{"$ref":"#/definitions/QueueOptions"}},"additionalProperties":false,"required":["name"]},"broadcastUpdate":{"type":"object","properties":{"channelName":{"type":"string"},"options":{"$ref":"#/definitions/BroadcastCacheUpdateOptions"}},"additionalProperties":false,"required":["options"]},"cacheableResponse":{"$ref":"#/definitions/CacheableResponseOptions"},"cacheName":{"type":["null","string"]},"expiration":{"$ref":"#/definitions/ExpirationPluginOptions"},"networkTimeoutSeconds":{"type":"number"},"plugins":{"type":"array","items":{"$ref":"#/definitions/WorkboxPlugin"}},"precacheFallback":{"type":"object","properties":{"fallbackURL":{"type":"string"}},"additionalProperties":false,"required":["fallbackURL"]},"fetchOptions":{"$ref":"#/definitions/RequestInit"},"matchOptions":{"$ref":"#/definitions/CacheQueryOptions"}},"additionalProperties":false},"urlPattern":{"anyOf":[{"$ref":"#/definitions/RegExp"},{"$ref":"#/definitions/RouteMatchCallback"},{"type":"string"}]}},"additionalProperties":false,"required":["handler","urlPattern"]},"RouteHandlerCallback":{"description":"The \"handler\" callback is invoked whenever a `Router` matches a URL/Request\nto a `Route` via its `RouteMatchCallback`. This handler callback should\nreturn a `Promise` that resolves with a `Response`.\n\nIf a non-empty array or object is returned by the `RouteMatchCallback` it\nwill be passed in as this handler's `options.params` argument.","type":"object","additionalProperties":false},"RouteHandlerObject":{"description":"An object with a `handle` method of type `RouteHandlerCallback`.\n\nA `Route` object can be created with either an `RouteHandlerCallback`\nfunction or this `RouteHandler` object. The benefit of the `RouteHandler`\nis it can be extended (as is done by the `workbox-strategies` package).","type":"object","properties":{"handle":{"$ref":"#/definitions/RouteHandlerCallback"}},"additionalProperties":false,"required":["handle"]},"QueueOptions":{"type":"object","properties":{"onSync":{"$ref":"#/definitions/OnSyncCallback"},"maxRetentionTime":{"type":"number"}},"additionalProperties":false},"OnSyncCallback":{"type":"object","additionalProperties":false},"BroadcastCacheUpdateOptions":{"type":"object","properties":{"headersToCheck":{"type":"array","items":{"type":"string"}},"generatePayload":{"type":"object","additionalProperties":false}},"additionalProperties":false},"CacheableResponseOptions":{"type":"object","properties":{"statuses":{"type":"array","items":{"type":"number"}},"headers":{"type":"object","additionalProperties":{"type":"string"}}},"additionalProperties":false},"ExpirationPluginOptions":{"type":"object","properties":{"maxEntries":{"type":"number"},"maxAgeSeconds":{"type":"number"},"matchOptions":{"$ref":"#/definitions/CacheQueryOptions"},"purgeOnQuotaError":{"type":"boolean"}},"additionalProperties":false},"CacheQueryOptions":{"type":"object","properties":{"ignoreMethod":{"type":"boolean"},"ignoreSearch":{"type":"boolean"},"ignoreVary":{"type":"boolean"}},"additionalProperties":false},"WorkboxPlugin":{"description":"An object with optional lifecycle callback properties for the fetch and\ncache operations.","type":"object","properties":{"cacheDidUpdate":{"$ref":"#/definitions/CacheDidUpdateCallback"},"cachedResponseWillBeUsed":{"$ref":"#/definitions/CachedResponseWillBeUsedCallback"},"cacheKeyWillBeUsed":{"$ref":"#/definitions/CacheKeyWillBeUsedCallback"},"cacheWillUpdate":{"$ref":"#/definitions/CacheWillUpdateCallback"},"fetchDidFail":{"$ref":"#/definitions/FetchDidFailCallback"},"fetchDidSucceed":{"$ref":"#/definitions/FetchDidSucceedCallback"},"handlerDidComplete":{"$ref":"#/definitions/HandlerDidCompleteCallback"},"handlerDidError":{"$ref":"#/definitions/HandlerDidErrorCallback"},"handlerDidRespond":{"$ref":"#/definitions/HandlerDidRespondCallback"},"handlerWillRespond":{"$ref":"#/definitions/HandlerWillRespondCallback"},"handlerWillStart":{"$ref":"#/definitions/HandlerWillStartCallback"},"requestWillFetch":{"$ref":"#/definitions/RequestWillFetchCallback"}},"additionalProperties":false},"CacheDidUpdateCallback":{"type":"object","additionalProperties":false},"CachedResponseWillBeUsedCallback":{"type":"object","additionalProperties":false},"CacheKeyWillBeUsedCallback":{"type":"object","additionalProperties":false},"CacheWillUpdateCallback":{"type":"object","additionalProperties":false},"FetchDidFailCallback":{"type":"object","additionalProperties":false},"FetchDidSucceedCallback":{"type":"object","additionalProperties":false},"HandlerDidCompleteCallback":{"type":"object","additionalProperties":false},"HandlerDidErrorCallback":{"type":"object","additionalProperties":false},"HandlerDidRespondCallback":{"type":"object","additionalProperties":false},"HandlerWillRespondCallback":{"type":"object","additionalProperties":false},"HandlerWillStartCallback":{"type":"object","additionalProperties":false},"RequestWillFetchCallback":{"type":"object","additionalProperties":false},"RequestInit":{"type":"object","properties":{"body":{"anyOf":[{"$ref":"#/definitions/ArrayBuffer"},{"$ref":"#/definitions/ArrayBufferView"},{"$ref":"#/definitions/Blob"},{"$ref":"#/definitions/FormData"},{"$ref":"#/definitions/URLSearchParams"},{"$ref":"#/definitions/ReadableStream"},{"type":["null","string"]}]},"cache":{"enum":["default","force-cache","no-cache","no-store","only-if-cached","reload"],"type":"string"},"credentials":{"enum":["include","omit","same-origin"],"type":"string"},"headers":{"anyOf":[{"$ref":"#/definitions/Headers"},{"type":"array","items":{"type":"array","items":{"type":"string"}}},{"$ref":"#/definitions/Record"}]},"integrity":{"type":"string"},"keepalive":{"type":"boolean"},"method":{"type":"string"},"mode":{"enum":["cors","navigate","no-cors","same-origin"],"type":"string"},"redirect":{"enum":["error","follow","manual"],"type":"string"},"referrer":{"type":"string"},"referrerPolicy":{"enum":["","no-referrer","no-referrer-when-downgrade","origin","origin-when-cross-origin","same-origin","strict-origin","strict-origin-when-cross-origin","unsafe-url"],"type":"string"},"signal":{"anyOf":[{"$ref":"#/definitions/AbortSignal"},{"type":"null"}]},"window":{}},"additionalProperties":false},"ArrayBuffer":{"type":"object","properties":{"byteLength":{"type":"number"},"__@toStringTag":{"type":"string"}},"additionalProperties":false,"required":["__@toStringTag","byteLength"]},"ArrayBufferView":{"type":"object","properties":{"buffer":{"anyOf":[{"$ref":"#/definitions/ArrayBuffer"},{"$ref":"#/definitions/SharedArrayBuffer"}]},"byteLength":{"type":"number"},"byteOffset":{"type":"number"}},"additionalProperties":false,"required":["buffer","byteLength","byteOffset"]},"SharedArrayBuffer":{"type":"object","properties":{"byteLength":{"type":"number"},"__@species":{"$ref":"#/definitions/SharedArrayBuffer"},"__@toStringTag":{"type":"string","enum":["SharedArrayBuffer"]}},"additionalProperties":false,"required":["__@species","__@toStringTag","byteLength"]},"Blob":{"type":"object","properties":{"size":{"type":"number"},"type":{"type":"string"}},"additionalProperties":false,"required":["size","type"]},"FormData":{"type":"object","additionalProperties":false},"URLSearchParams":{"type":"object","additionalProperties":false},"ReadableStream":{"type":"object","properties":{"locked":{"type":"boolean"}},"additionalProperties":false,"required":["locked"]},"Headers":{"type":"object","additionalProperties":false},"Record":{"type":"object","additionalProperties":false},"AbortSignal":{"type":"object","properties":{"aborted":{"type":"boolean"},"onabort":{"anyOf":[{"type":"object","additionalProperties":false},{"type":"null"}]}},"additionalProperties":false,"required":["aborted","onabort"]},"RouteMatchCallback":{"description":"The \"match\" callback is used to determine if a `Route` should apply for a\nparticular URL and request. When matching occurs in response to a fetch\nevent from the client, the `event` object is also supplied. However, since\nthe match callback can be invoked outside of a fetch event, matching logic\nshould not assume the `event` object will always be available.\nIf the match callback returns a truthy value, the matching route's\n`RouteHandlerCallback` will be invoked immediately. If the value returned\nis a non-empty array or object, that value will be set on the handler's\n`options.params` argument.","typeof":"function"}},"$schema":"http://json-schema.org/draft-07/schema#"} diff --git a/packages/workbox-webpack-plugin/src/generate-sw.js b/packages/workbox-webpack-plugin/src/generate-sw.js index 462dacbad..d68ec5aba 100644 --- a/packages/workbox-webpack-plugin/src/generate-sw.js +++ b/packages/workbox-webpack-plugin/src/generate-sw.js @@ -8,8 +8,8 @@ const {validateWebpackGenerateSWOptions} = require('workbox-build/build/lib/validate-options'); -const bundle = require('workbox-build/build/lib/bundle'); -const populateSWTemplate = +const {bundle} = require('workbox-build/build/lib/bundle'); +const {populateSWTemplate} = require('workbox-build/build/lib/populate-sw-template'); const prettyBytes = require('pretty-bytes'); const webpack = require('webpack'); diff --git a/test/workbox-webpack-plugin/node/v4/generate-sw.js b/test/workbox-webpack-plugin/node/v4/generate-sw.js index 3191c3c9f..0bbcc3911 100644 --- a/test/workbox-webpack-plugin/node/v4/generate-sw.js +++ b/test/workbox-webpack-plugin/node/v4/generate-sw.js @@ -66,7 +66,7 @@ describe(`[workbox-webpack-plugin] GenerateSW with webpack v4`, function() { const statsJson = stats.toJson(); expect(statsJson.warnings).to.be.empty; expect(statsJson.errors).to.have.members([ - `Please check your GenerateSW plugin configuration:\n"invalid" is not allowed`, + `Please check your GenerateSW plugin configuration:\n[WebpackGenerateSW] 'invalid' property is not expected to be here. Did you mean property 'include'?`, ]); done(); From 935ca5efa289eb8fce1fe9a34a63edcd99061422 Mon Sep 17 00:00:00 2001 From: Jeff Posnick Date: Mon, 14 Jun 2021 16:27:37 -0400 Subject: [PATCH 65/80] v5 injectmanifest test --- .../node/v5/inject-manifest.js | 86 +++++++++---------- 1 file changed, 43 insertions(+), 43 deletions(-) diff --git a/test/workbox-webpack-plugin/node/v5/inject-manifest.js b/test/workbox-webpack-plugin/node/v5/inject-manifest.js index 1463f0f42..d864d8193 100644 --- a/test/workbox-webpack-plugin/node/v5/inject-manifest.js +++ b/test/workbox-webpack-plugin/node/v5/inject-manifest.js @@ -71,7 +71,7 @@ describe(`[workbox-webpack-plugin] InjectManifest with webpack v5`, function() { const statsJson = stats.toJson(); expect(statsJson.warnings).to.be.empty; expect(statsJson.errors[0].message).to.eql( - `Please check your InjectManifest plugin configuration:\n"invalid" is not allowed`, + `Please check your InjectManifest plugin configuration:\n[WebpackInjectManifest] \'invalid\' property is not expected to be here. Did you mean property \'include\'?`, ); done(); @@ -1632,7 +1632,7 @@ describe(`[workbox-webpack-plugin] InjectManifest with webpack v5`, function() { new InjectManifest({ compileSrc: false, swDest: 'injected-manifest.json', - swSrc: upath.join(__dirname, '..', 'static', 'injected-manifest.json'), + swSrc: upath.join(__dirname, '..', '..', 'static', 'injected-manifest.json'), webpackCompilationPlugins: [{}], }), ], @@ -1643,9 +1643,9 @@ describe(`[workbox-webpack-plugin] InjectManifest with webpack v5`, function() { try { expect(webpackError).not.to.exist; const statsJson = stats.toJson(); - expect(statsJson.warnings).to.be.empty; - expect(statsJson.errors[0].message).to.eql( - `Please check your InjectManifest plugin configuration:\n"webpackCompilationPlugins" is not allowed`, + expect(statsJson.errors).to.be.empty; + expect(statsJson.warnings[0].message).to.eql( + 'compileSrc is false, so the webpackCompilationPlugins option will be ignored.', ); done(); @@ -1694,45 +1694,45 @@ describe(`[workbox-webpack-plugin] InjectManifest with webpack v5`, function() { } }); }); - }); - it(`should support injecting a manifest into a CJS module`, function(done) { - const outputDir = tempy.directory(); - - const config = { - mode: 'production', - entry: upath.join(SRC_DIR, WEBPACK_ENTRY_FILENAME), - output: { - filename: '[name].[contenthash:20].js', - path: outputDir, - }, - plugins: [ - new InjectManifest({ - compileSrc: false, - swDest: 'injected-manifest.js', - swSrc: upath.join(__dirname, '..', '..', 'static', 'injected-manifest.js'), - }), - ], - }; - - const compiler = webpack(config); - compiler.run(async (webpackError, stats) => { - try { - webpackBuildCheck(webpackError, stats); - - const files = await globby('**', {cwd: outputDir}); - expect(files).to.have.length(2); - - const manifest = require(upath.join(outputDir, 'injected-manifest.js')); - expect(manifest).to.matchPattern([{ - revision: null, - url: /^main\.[0-9a-f]{20}\.js$/, - }]); - - done(); - } catch (error) { - done(error); - } + it(`should support injecting a manifest into a CJS module`, function(done) { + const outputDir = tempy.directory(); + + const config = { + mode: 'production', + entry: upath.join(SRC_DIR, WEBPACK_ENTRY_FILENAME), + output: { + filename: '[name].[contenthash:20].js', + path: outputDir, + }, + plugins: [ + new InjectManifest({ + compileSrc: false, + swDest: 'injected-manifest.js', + swSrc: upath.join(__dirname, '..', '..', 'static', 'injected-manifest.js'), + }), + ], + }; + + const compiler = webpack(config); + compiler.run(async (webpackError, stats) => { + try { + webpackBuildCheck(webpackError, stats); + + const files = await globby('**', {cwd: outputDir}); + expect(files).to.have.length(2); + + const manifest = require(upath.join(outputDir, 'injected-manifest.js')); + expect(manifest).to.matchPattern([{ + revision: null, + url: /^main\.[0-9a-f]{20}\.js$/, + }]); + + done(); + } catch (error) { + done(error); + } + }); }); }); }); From 781e92da995f8e605a2757d615797fe378134c96 Mon Sep 17 00:00:00 2001 From: Jeff Posnick Date: Mon, 14 Jun 2021 16:57:52 -0400 Subject: [PATCH 66/80] esModuleInterop support --- packages/workbox-build/package.json | 1 - packages/workbox-cli/src/app.ts | 16 +++---- packages/workbox-cli/src/bin.ts | 4 +- .../src/lib/questions/ask-config-location.ts | 2 +- .../lib/questions/ask-extensions-to-cache.ts | 8 ++-- .../src/lib/questions/ask-root-of-web-app.ts | 6 +-- .../questions/ask-start_url-query-params.ts | 2 +- .../src/lib/questions/ask-sw-dest.ts | 4 +- packages/workbox-cli/src/lib/run-wizard.ts | 4 +- packages/workbox-cli/tsconfig.json | 1 + test/workbox-cli/node/app.js | 46 ++++++++----------- 11 files changed, 42 insertions(+), 52 deletions(-) diff --git a/packages/workbox-build/package.json b/packages/workbox-build/package.json index 0e2711aaa..a565bb3e0 100644 --- a/packages/workbox-build/package.json +++ b/packages/workbox-build/package.json @@ -24,7 +24,6 @@ "@babel/core": "^7.11.1", "@babel/preset-env": "^7.11.0", "@babel/runtime": "^7.11.2", - "@hapi/joi": "^16.1.8", "@rollup/plugin-babel": "^5.2.0", "@rollup/plugin-node-resolve": "^11.2.1", "@rollup/plugin-replace": "^2.4.1", diff --git a/packages/workbox-cli/src/app.ts b/packages/workbox-cli/src/app.ts index 6502039d2..41266690c 100644 --- a/packages/workbox-cli/src/app.ts +++ b/packages/workbox-cli/src/app.ts @@ -7,12 +7,12 @@ */ import {oneLine as ol} from 'common-tags'; -import * as assert from 'assert'; -import * as meow from 'meow'; -import * as prettyBytes from 'pretty-bytes'; -import * as upath from 'upath'; -import * as watch from 'glob-watcher'; -import * as workboxBuild from 'workbox-build'; +import assert from 'assert'; +import GlobWatcher from 'glob-watcher'; +import meow from 'meow'; +import prettyBytes from 'pretty-bytes'; +import upath from 'upath'; +import workboxBuild from 'workbox-build'; import {constants} from './lib/constants.js'; import {errors} from './lib/errors.js'; @@ -114,7 +114,7 @@ export const app = async (params: meow.Result) => { // Determine whether we're in --watch mode, or one-off mode. if (params.flags && params.flags.watch) { - const options: watch.WatchOptions = {ignoreInitial: false} + const options: GlobWatcher.WatchOptions = {ignoreInitial: false}; if (config.globIgnores) { options.ignored = config.globIgnores; } @@ -123,7 +123,7 @@ export const app = async (params: meow.Result) => { } if (config.globPatterns) { - watch(config.globPatterns, options, + GlobWatcher(config.globPatterns, options, () => runBuildCommand({command, config, watch: true})); } diff --git a/packages/workbox-cli/src/bin.ts b/packages/workbox-cli/src/bin.ts index 8c3cbfe62..0018d710c 100755 --- a/packages/workbox-cli/src/bin.ts +++ b/packages/workbox-cli/src/bin.ts @@ -9,8 +9,8 @@ */ -import * as meow from 'meow' -import * as updateNotifier from 'update-notifier'; +import meow from 'meow' +import updateNotifier from 'update-notifier'; import {app} from './app'; import {cleanupStackTrace} from './lib/cleanup-stack-trace.js'; diff --git a/packages/workbox-cli/src/lib/questions/ask-config-location.ts b/packages/workbox-cli/src/lib/questions/ask-config-location.ts index 696b34b83..a4a762246 100644 --- a/packages/workbox-cli/src/lib/questions/ask-config-location.ts +++ b/packages/workbox-cli/src/lib/questions/ask-config-location.ts @@ -6,7 +6,7 @@ https://opensource.org/licenses/MIT. */ -import * as assert from 'assert'; +import assert from 'assert'; import {prompt} from 'inquirer'; import {oneLine as ol} from 'common-tags'; diff --git a/packages/workbox-cli/src/lib/questions/ask-extensions-to-cache.ts b/packages/workbox-cli/src/lib/questions/ask-extensions-to-cache.ts index 15d5ca63f..e895b55b2 100644 --- a/packages/workbox-cli/src/lib/questions/ask-extensions-to-cache.ts +++ b/packages/workbox-cli/src/lib/questions/ask-extensions-to-cache.ts @@ -6,11 +6,11 @@ https://opensource.org/licenses/MIT. */ -import * as assert from 'assert'; +import assert from 'assert'; import {prompt} from 'inquirer'; -import * as glob from 'glob'; -import * as ora from 'ora'; -import * as upath from 'upath'; +import glob from 'glob'; +import ora from 'ora'; +import upath from 'upath'; import {errors} from '../errors'; import {constants} from '../constants'; diff --git a/packages/workbox-cli/src/lib/questions/ask-root-of-web-app.ts b/packages/workbox-cli/src/lib/questions/ask-root-of-web-app.ts index ecd0a6d22..1c893aac9 100644 --- a/packages/workbox-cli/src/lib/questions/ask-root-of-web-app.ts +++ b/packages/workbox-cli/src/lib/questions/ask-root-of-web-app.ts @@ -6,9 +6,9 @@ https://opensource.org/licenses/MIT. */ -import * as assert from 'assert'; -import * as fse from 'fs-extra'; -import * as glob from 'glob'; +import assert from 'assert'; +import fse from 'fs-extra'; +import glob from 'glob'; import {prompt, Separator} from 'inquirer'; import {oneLine as ol} from 'common-tags'; diff --git a/packages/workbox-cli/src/lib/questions/ask-start_url-query-params.ts b/packages/workbox-cli/src/lib/questions/ask-start_url-query-params.ts index d9c90fcd6..6090a9f6c 100644 --- a/packages/workbox-cli/src/lib/questions/ask-start_url-query-params.ts +++ b/packages/workbox-cli/src/lib/questions/ask-start_url-query-params.ts @@ -6,7 +6,7 @@ https://opensource.org/licenses/MIT. */ -import * as assert from 'assert'; +import assert from 'assert'; import {prompt} from 'inquirer'; import {oneLine as ol} from 'common-tags'; diff --git a/packages/workbox-cli/src/lib/questions/ask-sw-dest.ts b/packages/workbox-cli/src/lib/questions/ask-sw-dest.ts index c5145438a..714a1b2b6 100644 --- a/packages/workbox-cli/src/lib/questions/ask-sw-dest.ts +++ b/packages/workbox-cli/src/lib/questions/ask-sw-dest.ts @@ -6,9 +6,9 @@ https://opensource.org/licenses/MIT. */ -import * as assert from 'assert'; +import assert from 'assert'; import {prompt} from 'inquirer'; -import * as upath from 'upath'; +import upath from 'upath'; import {errors} from '../errors'; diff --git a/packages/workbox-cli/src/lib/run-wizard.ts b/packages/workbox-cli/src/lib/run-wizard.ts index 41a3f2a0b..cdb2d9b8d 100644 --- a/packages/workbox-cli/src/lib/run-wizard.ts +++ b/packages/workbox-cli/src/lib/run-wizard.ts @@ -6,9 +6,9 @@ https://opensource.org/licenses/MIT. */ -import * as fse from 'fs-extra'; +import fse from 'fs-extra'; import {oneLine as ol} from 'common-tags'; -import * as stringifyObject from 'stringify-object'; +import stringifyObject from 'stringify-object'; import {askQuestions} from './questions/ask-questions'; import {logger} from './logger'; diff --git a/packages/workbox-cli/tsconfig.json b/packages/workbox-cli/tsconfig.json index 9b3e27942..e764ed999 100644 --- a/packages/workbox-cli/tsconfig.json +++ b/packages/workbox-cli/tsconfig.json @@ -1,6 +1,7 @@ { "extends": "../../tsconfig", "compilerOptions": { + "esModuleInterop": true, "module": "CommonJS", "outDir": "build", "rootDir": "src", diff --git a/test/workbox-cli/node/app.js b/test/workbox-cli/node/app.js index e281b2ec4..37f9e8876 100644 --- a/test/workbox-cli/node/app.js +++ b/test/workbox-cli/node/app.js @@ -6,14 +6,18 @@ https://opensource.org/licenses/MIT. */ -const expect = require('chai').expect; -const upath = require('upath'); +const chai = require('chai'); +const chaiAsPromised = require('chai-as-promised'); const proxyquire = require('proxyquire'); const sinon = require('sinon'); +const upath = require('upath'); const {constants} = require('../../../packages/workbox-cli/build/lib/constants'); const {errors} = require('../../../packages/workbox-cli/build/lib/errors'); +chai.use(chaiAsPromised); +const {expect} = chai; + describe(`[workbox-cli] app.js`, function() { const MODULE_PATH = '../../../packages/workbox-cli/build/app'; const PROXIED_CONFIG_FILE = upath.resolve(process.cwd(), '/will/be/proxied'); @@ -43,31 +47,18 @@ describe(`[workbox-cli] app.js`, function() { const {app} = require(MODULE_PATH); it(`should reject when both parameters are missing`, async function() { - try { - await app(); - throw new Error('Unexpected success.'); - } catch (error) { - expect(error.message).to.have.string(errors['missing-input']); - } + await expect(app()).to.eventually.be.rejectedWith( + errors['missing-input']); }); it(`should reject when the command is unknown and options is present`, async function() { - try { - await app({input: [UNKNOWN_COMMAND, PROXIED_CONFIG_FILE]}); - throw new Error('Unexpected success.'); - } catch (error) { - expect(error.message).to.have.string(errors['unknown-command']); - expect(error.message).to.have.string(UNKNOWN_COMMAND); - } + await expect(app({input: [UNKNOWN_COMMAND, PROXIED_CONFIG_FILE]})).to + .eventually.be.rejectedWith(errors['unknown-command']); }); it(`should reject when the command parameter is copyLibraries and options is missing`, async function() { - try { - await app({input: ['copyLibraries']}); - throw new Error('Unexpected success.'); - } catch (error) { - expect(error.message).to.have.string(errors['missing-dest-dir-param']); - } + await expect(app({input: ['copyLibraries']})).to + .eventually.be.rejectedWith(errors['missing-dest-dir-param']); }); for (const command of WORKBOX_BUILD_COMMANDS) { @@ -108,7 +99,10 @@ describe(`[workbox-cli] app.js`, function() { it(`should reject with a validation error when workbox-build.${command}(${JSON.stringify(config)}) is called`, async function() { const {app} = proxyquire(MODULE_PATH, { './lib/logger': { - logger: {log: sinon.stub()}, + logger: { + error: sinon.stub(), + log: sinon.stub(), + }, }, './lib/read-config': { readConfig: (options) => { @@ -118,12 +112,8 @@ describe(`[workbox-cli] app.js`, function() { }, }); - try { - await app({input: [command, PROXIED_CONFIG_FILE]}); - throw new Error('Unexpected success.'); - } catch (error) { - expect(error.message).to.have.string(errors['config-validation-failed']); - } + await expect(app({input: [command, PROXIED_CONFIG_FILE]})).to + .eventually.be.rejectedWith(errors['config-validation-failed']); }); } From a7ef09d490fe73b0cba7c45403dcc7b44d156f39 Mon Sep 17 00:00:00 2001 From: Jeff Posnick Date: Tue, 15 Jun 2021 11:16:59 -0400 Subject: [PATCH 67/80] Fixes for proxied build --- packages/workbox-build/src/index.ts | 3 ++ packages/workbox-cli/src/app.ts | 49 +++++++++-------------- packages/workbox-cli/tsconfig.json | 3 ++ test/workbox-cli/node/app.js | 61 ++++++++++++++++------------- 4 files changed, 57 insertions(+), 59 deletions(-) diff --git a/packages/workbox-build/src/index.ts b/packages/workbox-build/src/index.ts index cb7d32b2a..7b79bf5c9 100644 --- a/packages/workbox-build/src/index.ts +++ b/packages/workbox-build/src/index.ts @@ -12,6 +12,7 @@ import {generateSW} from './generate-sw'; import {getManifest} from './get-manifest'; import {injectManifest} from './inject-manifest'; + /** * @module workbox-build */ @@ -22,3 +23,5 @@ export default { getModuleURL, injectManifest, }; + +export * from './types'; diff --git a/packages/workbox-cli/src/app.ts b/packages/workbox-cli/src/app.ts index 41266690c..dc142efea 100644 --- a/packages/workbox-cli/src/app.ts +++ b/packages/workbox-cli/src/app.ts @@ -22,51 +22,38 @@ import {runWizard} from './lib/run-wizard.js'; import {SupportedFlags} from './bin.js' interface BuildCommand { - command: 'generateSW'|'injectManifest'; + command: 'generateSW' | 'injectManifest'; config: any; watch: boolean; } - /** * Runs the specified build command with the provided configuration. * * @param {Object} options */ async function runBuildCommand({command, config, watch}: BuildCommand) { - try { - const {count, filePaths, size, warnings} = - await workboxBuild[command](config); - + const {count, filePaths, size, warnings} = await workboxBuild[command](config); - for (const warning of warnings) { - logger.warn(warning); - } + for (const warning of warnings) { + logger.warn(warning); + } - if (filePaths.length === 1) { - logger.log(`The service worker file was written to ${config.swDest}`); - } else { - const message = filePaths - .sort() - .map((filePath) => ` • ${filePath}`) - .join(`\n`); - logger.log(`The service worker files were written to:\n${message}`); - } + if (filePaths.length === 1) { + logger.log(`The service worker file was written to ${config.swDest}`); + } else { + const message = filePaths + .sort() + .map((filePath) => ` • ${filePath}`) + .join(`\n`); + logger.log(`The service worker files were written to:\n${message}`); + } - logger.log(`The service worker will precache ${count} URLs, ` + - `totaling ${prettyBytes(size)}.`); + logger.log(`The service worker will precache ${count} URLs, ` + + `totaling ${prettyBytes(size)}.`); - if (watch) { - logger.log(`\nWatching for changes...`); - } - } catch (error) { - // See https://github.com/hapijs/joi/blob/v11.3.4/API.md#errors - if (typeof error.annotate === 'function') { - throw new Error( - `${errors['config-validation-failed']}\n${error.annotate()}`); - } - logger.error(errors['workbox-build-runtime-error']); - throw error; + if (watch) { + logger.log(`\nWatching for changes...`); } } diff --git a/packages/workbox-cli/tsconfig.json b/packages/workbox-cli/tsconfig.json index e764ed999..b44a33c62 100644 --- a/packages/workbox-cli/tsconfig.json +++ b/packages/workbox-cli/tsconfig.json @@ -10,5 +10,8 @@ }, "include": [ "src/**/*.ts" + ], + "references": [ + {"path": "../workbox-build/"}, ] } diff --git a/test/workbox-cli/node/app.js b/test/workbox-cli/node/app.js index 37f9e8876..41bce26f0 100644 --- a/test/workbox-cli/node/app.js +++ b/test/workbox-cli/node/app.js @@ -14,6 +14,7 @@ const upath = require('upath'); const {constants} = require('../../../packages/workbox-cli/build/lib/constants'); const {errors} = require('../../../packages/workbox-cli/build/lib/errors'); +const {WorkboxConfigError} = require('../../../packages/workbox-build/build/lib/validate-options'); chai.use(chaiAsPromised); const {expect} = chai; @@ -23,7 +24,10 @@ describe(`[workbox-cli] app.js`, function() { const PROXIED_CONFIG_FILE = upath.resolve(process.cwd(), '/will/be/proxied'); const PROXIED_DEST_DIR = upath.resolve(process.cwd(), 'build'); const PROXIED_ERROR = new Error('proxied error message'); - const PROXIED_CONFIG = {}; + const PROXIED_CONFIG = { + globDirectory: '.', + swDest: 'sw.js', + }; const INVALID_CONFIG_FILE = upath.resolve(process.cwd(), upath.join('does', 'not', 'exist')); const UNKNOWN_COMMAND = 'unknown-command'; const WORKBOX_BUILD_COMMANDS = [ @@ -96,7 +100,7 @@ describe(`[workbox-cli] app.js`, function() { ]; for (const config of badConfigs) { - it(`should reject with a validation error when workbox-build.${command}(${JSON.stringify(config)}) is called`, async function() { + it(`should reject with a WorkboxConfigError when workbox-build.${command}(${JSON.stringify(config)}) is called`, async function() { const {app} = proxyquire(MODULE_PATH, { './lib/logger': { logger: { @@ -113,17 +117,15 @@ describe(`[workbox-cli] app.js`, function() { }); await expect(app({input: [command, PROXIED_CONFIG_FILE]})).to - .eventually.be.rejectedWith(errors['config-validation-failed']); + .eventually.be.rejectedWith(WorkboxConfigError); }); } it(`should reject with a generic runtime error when the workbox-build.${command}() rejects for any other reason`, async function() { - const loggerErrorStub = sinon.stub(); const {app} = proxyquire(MODULE_PATH, { './lib/logger': { logger: { log: sinon.stub(), - error: loggerErrorStub, }, }, './lib/read-config': { @@ -133,23 +135,17 @@ describe(`[workbox-cli] app.js`, function() { }, }, 'workbox-build': { - [command]: (config) => { - expect(config).to.eql(PROXIED_CONFIG); - throw PROXIED_ERROR; + default: { + [command]: (config) => { + expect(config).to.eql(PROXIED_CONFIG); + throw PROXIED_ERROR; + }, }, }, }); - try { - await app({input: [command, PROXIED_CONFIG_FILE]}); - throw new Error('Unexpected success.'); - } catch (error) { - expect(loggerErrorStub.calledOnce).to.be.true; - expect( - loggerErrorStub.alwaysCalledWithExactly(errors['workbox-build-runtime-error']), - ).to.be.true; - expect(error).to.eql(PROXIED_ERROR); - } + await expect(app({input: [command, PROXIED_CONFIG_FILE]})).to + .eventually.be.rejectedWith(PROXIED_ERROR); }); } }); @@ -171,8 +167,10 @@ describe(`[workbox-cli] app.js`, function() { }, }, 'workbox-build': { - [command]: () => { - return WORKBOX_BUILD_NO_WARNINGS_RETURN_VALUE; + default: { + [command]: () => { + return WORKBOX_BUILD_NO_WARNINGS_RETURN_VALUE; + }, }, }, }); @@ -198,9 +196,11 @@ describe(`[workbox-cli] app.js`, function() { }, }, 'workbox-build': { - [command]: () => { - return WORKBOX_BUILD_WITH_WARNINGS_RETURN_VALUE; - }, + default: { + [command]: () => { + return WORKBOX_BUILD_WITH_WARNINGS_RETURN_VALUE; + }, + } }, }); @@ -222,11 +222,14 @@ describe(`[workbox-cli] app.js`, function() { './lib/logger': { logger: { log: loggerLogStub, + error: loggerLogStub, }, }, 'workbox-build': { - [command]: () => { - return WORKBOX_BUILD_NO_WARNINGS_RETURN_VALUE; + default: { + [command]: () => { + return WORKBOX_BUILD_NO_WARNINGS_RETURN_VALUE; + }, }, }, }); @@ -245,9 +248,11 @@ describe(`[workbox-cli] app.js`, function() { }, }, 'workbox-build': { - copyWorkboxLibraries: (destDir) => { - expect(destDir).to.eql(PROXIED_DEST_DIR); - return upath.join(destDir, 'workbox'); + default: { + copyWorkboxLibraries: (destDir) => { + expect(destDir).to.eql(PROXIED_DEST_DIR); + return upath.join(destDir, 'workbox'); + }, }, }, }); From d812352b0583f38854998a26ab70488946939e6c Mon Sep 17 00:00:00 2001 From: Jeff Posnick Date: Tue, 15 Jun 2021 11:32:15 -0400 Subject: [PATCH 68/80] Final tweaks --- packages/workbox-cli/src/lib/logger.ts | 2 +- test/workbox-webpack-plugin/node/v5/generate-sw.js | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/workbox-cli/src/lib/logger.ts b/packages/workbox-cli/src/lib/logger.ts index 866e66a5f..d4fb4b2da 100644 --- a/packages/workbox-cli/src/lib/logger.ts +++ b/packages/workbox-cli/src/lib/logger.ts @@ -6,7 +6,7 @@ https://opensource.org/licenses/MIT. */ -import * as chalk from 'chalk'; +import chalk from 'chalk'; export const logger = { debug: (...args: string[]) => console.log(chalk.gray(...args)), diff --git a/test/workbox-webpack-plugin/node/v5/generate-sw.js b/test/workbox-webpack-plugin/node/v5/generate-sw.js index 8af930f70..3a2be09bb 100644 --- a/test/workbox-webpack-plugin/node/v5/generate-sw.js +++ b/test/workbox-webpack-plugin/node/v5/generate-sw.js @@ -65,7 +65,9 @@ describe(`[workbox-webpack-plugin] GenerateSW with webpack v5`, function() { const statsJson = stats.toJson(); expect(statsJson.warnings).to.be.empty; expect(statsJson.errors).to.have.length(1); - expect(statsJson.errors[0].message).to.eql(`Please check your GenerateSW plugin configuration:\n"invalid" is not allowed`); + expect(statsJson.errors[0].message).to.eql( + `Please check your GenerateSW plugin configuration:\n[WebpackGenerateSW] \'invalid\' property is not expected to be here. Did you mean property \'include\'?` + ); done(); } catch (error) { From 3ec8ddc5eb247dad6bc6c6e5169a25e98a7bec1c Mon Sep 17 00:00:00 2001 From: Jeff Posnick Date: Wed, 16 Jun 2021 10:07:35 -0400 Subject: [PATCH 69/80] Linting --- gulp-tasks/build-node-packages.js | 10 ++++----- gulp-tasks/utils/versioned-cdn-url.js | 3 ++- .../get-manifest-entries-from-compilation.js | 3 ++- test/workbox-build/node/generate-sw.js | 22 +++++++++---------- test/workbox-build/node/get-manifest.js | 6 ++--- test/workbox-build/node/inject-manifest.js | 16 +++++++------- test/workbox-build/node/lib/bundle.js | 4 ++-- .../node/lib/validate-options.js | 8 +++---- test/workbox-cli/node/app.js | 12 +++++----- .../node/v5/generate-sw.js | 2 +- .../node/v5/inject-manifest.js | 14 ++++++------ 11 files changed, 51 insertions(+), 49 deletions(-) diff --git a/gulp-tasks/build-node-packages.js b/gulp-tasks/build-node-packages.js index 393280a00..2a5a4bf09 100644 --- a/gulp-tasks/build-node-packages.js +++ b/gulp-tasks/build-node-packages.js @@ -32,7 +32,7 @@ async function buildNodePackage(packagePath) { async function generateWorkboxBuildJSONSchema(packagePath) { const program = TJS.programFromConfig(upath.join(packagePath, - 'tsconfig.json')); + 'tsconfig.json')); const generator = TJS.buildGenerator(program, { noExtraProps: true, required: true, @@ -42,7 +42,7 @@ async function generateWorkboxBuildJSONSchema(packagePath) { 'GetManifestOptions', 'InjectManifestOptions', 'WebpackGenerateSWOptions', - 'WebpackInjectManifestOptions' + 'WebpackInjectManifestOptions', ]; for (const optionType of optionTypes) { const schema = generator.getSchemaForSymbol(optionType); @@ -57,14 +57,14 @@ async function generateWorkboxBuildJSONSchema(packagePath) { {'$ref': '#/definitions/RegExp'}, {type: 'string'}, {typeof: 'function'}, - ] + ]; } if (schema.properties.include) { schema.properties.include.items.anyOf = [ {'$ref': '#/definitions/RegExp'}, {type: 'string'}, {typeof: 'function'}, - ] + ]; } if (schema.definitions.RouteMatchCallback) { delete schema.definitions.RouteMatchCallback.type; @@ -72,7 +72,7 @@ async function generateWorkboxBuildJSONSchema(packagePath) { schema.definitions.RouteMatchCallback.typeof = 'function'; } await fse.writeJSON(upath.join(packagePath, 'src', 'schema', - `${optionType}.json`), schema); + `${optionType}.json`), schema); } } diff --git a/gulp-tasks/utils/versioned-cdn-url.js b/gulp-tasks/utils/versioned-cdn-url.js index ada229264..b1d04bb26 100644 --- a/gulp-tasks/utils/versioned-cdn-url.js +++ b/gulp-tasks/utils/versioned-cdn-url.js @@ -9,4 +9,5 @@ const cdn = require('../../packages/workbox-build/src/cdn-details.json'); const lernaPkg = require('../../lerna.json'); -module.exports = () => `${cdn.origin}/${cdn.bucketName}/${cdn.releasesDir}/${lernaPkg.version}`; +module.exports = () => `${cdn.origin}/${cdn.bucketName}/${cdn.releasesDir}` + + `/${lernaPkg.version}`; diff --git a/packages/workbox-webpack-plugin/src/lib/get-manifest-entries-from-compilation.js b/packages/workbox-webpack-plugin/src/lib/get-manifest-entries-from-compilation.js index fc5e2d23d..a911230b7 100644 --- a/packages/workbox-webpack-plugin/src/lib/get-manifest-entries-from-compilation.js +++ b/packages/workbox-webpack-plugin/src/lib/get-manifest-entries-from-compilation.js @@ -7,7 +7,8 @@ */ const {matchPart} = require('webpack').ModuleFilenameHelpers; -const {transformManifest} = require('workbox-build/build/lib/transform-manifest'); +const {transformManifest} = + require('workbox-build/build/lib/transform-manifest'); const getAssetHash = require('./get-asset-hash'); const resolveWebpackURL = require('./resolve-webpack-url'); diff --git a/test/workbox-build/node/generate-sw.js b/test/workbox-build/node/generate-sw.js index 2536abb10..263de0cb7 100644 --- a/test/workbox-build/node/generate-sw.js +++ b/test/workbox-build/node/generate-sw.js @@ -74,7 +74,7 @@ describe(`[workbox-build] generate-sw.js (End to End)`, function() { delete options[requiredParam]; await expect(generateSW(options)).to.eventually.be.rejectedWith( - WorkboxConfigError, requiredParam); + WorkboxConfigError, requiredParam); }); } }); @@ -86,7 +86,7 @@ describe(`[workbox-build] generate-sw.js (End to End)`, function() { options[unsupportedParam] = unsupportedParam; await expect(generateSW(options)).to.eventually.be.rejectedWith( - WorkboxConfigError, unsupportedParam); + WorkboxConfigError, unsupportedParam); }); } }); @@ -98,7 +98,7 @@ describe(`[workbox-build] generate-sw.js (End to End)`, function() { options[param] = () => {}; await expect(generateSW(options)).to.eventually.be.rejectedWith( - WorkboxConfigError, param); + WorkboxConfigError, param); }); } @@ -108,7 +108,7 @@ describe(`[workbox-build] generate-sw.js (End to End)`, function() { options.globDirectory = tempy.directory(); await expect(generateSW(options)).to.eventually.be.rejectedWith( - errors['no-manifest-entries-or-runtime-caching']); + errors['no-manifest-entries-or-runtime-caching']); }); }); @@ -686,7 +686,7 @@ describe(`[workbox-build] generate-sw.js (End to End)`, function() { }); await expect(generateSW(options)).to.eventually.be.rejectedWith( - WorkboxConfigError, 'urlPattern'); + WorkboxConfigError, 'urlPattern'); }); it(`should reject when 'handler' is missing from 'runtimeCaching'`, async function() { @@ -696,7 +696,7 @@ describe(`[workbox-build] generate-sw.js (End to End)`, function() { }); await expect(generateSW(options)).to.eventually.be.rejectedWith( - WorkboxConfigError, 'handler'); + WorkboxConfigError, 'handler'); }); it(`should reject when 'handler' is not a valid strategy name`, async function() { @@ -709,7 +709,7 @@ describe(`[workbox-build] generate-sw.js (End to End)`, function() { }); await expect(generateSW(options)).to.eventually.be.rejectedWith( - WorkboxConfigError, 'handler'); + WorkboxConfigError, 'handler'); }); // See https://github.com/GoogleChrome/workbox/issues/2078 @@ -918,7 +918,7 @@ describe(`[workbox-build] generate-sw.js (End to End)`, function() { }); await expect(generateSW(options)).to.eventually.be.rejectedWith( - errors['invalid-network-timeout-seconds']); + errors['invalid-network-timeout-seconds']); }); it(`should support 'networkTimeoutSeconds' when handler is 'NetworkFirst'`, async function() { @@ -988,7 +988,7 @@ describe(`[workbox-build] generate-sw.js (End to End)`, function() { }); await expect(generateSW(options)).to.eventually.be.rejectedWith( - WorkboxConfigError, errors['cache-name-required']); + WorkboxConfigError, errors['cache-name-required']); }); it(`should ignore swDest and workbox-*.js when generating manifest entries`, async function() { @@ -1040,7 +1040,7 @@ describe(`[workbox-build] generate-sw.js (End to End)`, function() { }); await expect(generateSW(options)).to.eventually.be.rejectedWith( - WorkboxConfigError, errors['nav-preload-runtime-caching']); + WorkboxConfigError, errors['nav-preload-runtime-caching']); }); it(`should reject when 'navigationPreload' is true and 'runtimeCaching' is invalid`, async function() { @@ -1050,7 +1050,7 @@ describe(`[workbox-build] generate-sw.js (End to End)`, function() { }); await expect(generateSW(options)).to.eventually.be.rejectedWith( - WorkboxConfigError, errors['nav-preload-runtime-caching']); + WorkboxConfigError, errors['nav-preload-runtime-caching']); }); it(`should generate when 'navigationPreload' is true and 'runtimeCaching' is valid`, async function() { diff --git a/test/workbox-build/node/get-manifest.js b/test/workbox-build/node/get-manifest.js index d7af9a573..6c8cd0f26 100644 --- a/test/workbox-build/node/get-manifest.js +++ b/test/workbox-build/node/get-manifest.js @@ -61,7 +61,7 @@ describe(`[workbox-build] get-manifest.js (End to End)`, function() { options[unsupportedParam] = unsupportedParam; await expect(getManifest(options)).to.eventually.be.rejectedWith( - WorkboxConfigError, unsupportedParam); + WorkboxConfigError, unsupportedParam); }); } }); @@ -73,7 +73,7 @@ describe(`[workbox-build] get-manifest.js (End to End)`, function() { options[param] = () => {}; await expect(getManifest(options)).to.eventually.be.rejectedWith( - WorkboxConfigError, param); + WorkboxConfigError, param); }); } }); @@ -324,7 +324,7 @@ describe(`[workbox-build] get-manifest.js (End to End)`, function() { }); await expect(getManifest(options)).to.eventually.be.rejectedWith( - WorkboxConfigError, option); + WorkboxConfigError, option); }); } }); diff --git a/test/workbox-build/node/inject-manifest.js b/test/workbox-build/node/inject-manifest.js index 85cf98583..1af047230 100644 --- a/test/workbox-build/node/inject-manifest.js +++ b/test/workbox-build/node/inject-manifest.js @@ -67,7 +67,7 @@ describe(`[workbox-build] inject-manifest.js (End to End)`, function() { delete options[requiredParam]; await expect(injectManifest(options)).to.eventually.be.rejectedWith( - WorkboxConfigError, requiredParam); + WorkboxConfigError, requiredParam); }); } }); @@ -79,7 +79,7 @@ describe(`[workbox-build] inject-manifest.js (End to End)`, function() { options[unsupportedParam] = unsupportedParam; await expect(injectManifest(options)).to.eventually.be.rejectedWith( - WorkboxConfigError, unsupportedParam); + WorkboxConfigError, unsupportedParam); }); } }); @@ -91,7 +91,7 @@ describe(`[workbox-build] inject-manifest.js (End to End)`, function() { options[param] = null; await expect(injectManifest(options)).to.eventually.be.rejectedWith( - WorkboxConfigError, param); + WorkboxConfigError, param); }); } }); @@ -103,7 +103,7 @@ describe(`[workbox-build] inject-manifest.js (End to End)`, function() { }); await expect(injectManifest(options)).to.eventually.be.rejectedWith( - errors['invalid-sw-src']); + errors['invalid-sw-src']); }); it(`should throw the expected error when there is no match for 'injectionPoint'`, async function() { @@ -112,7 +112,7 @@ describe(`[workbox-build] inject-manifest.js (End to End)`, function() { }); await expect(injectManifest(options)).to.eventually.be.rejectedWith( - errors['injection-point-not-found']); + errors['injection-point-not-found']); }); it(`should throw the expected error when there is no match for 'injectionPoint' and 'swSrc' and 'swDest' are the same`, async function() { @@ -123,7 +123,7 @@ describe(`[workbox-build] inject-manifest.js (End to End)`, function() { }); await expect(injectManifest(options)).to.eventually.be.rejectedWith( - errors['same-src-and-dest']); + errors['same-src-and-dest']); }); it(`should throw the expected error when there are multiple matches for 'injectionPoint'`, async function() { @@ -132,7 +132,7 @@ describe(`[workbox-build] inject-manifest.js (End to End)`, function() { }); await expect(injectManifest(options)).to.eventually.be.rejectedWith( - errors['multiple-injection-points']); + errors['multiple-injection-points']); }); }); @@ -425,7 +425,7 @@ describe(`[workbox-build] inject-manifest.js (End to End)`, function() { }); await expect(injectManifest(options)).to.eventually.be.rejectedWith( - WorkboxConfigError, option); + WorkboxConfigError, option); }); } }); diff --git a/test/workbox-build/node/lib/bundle.js b/test/workbox-build/node/lib/bundle.js index 737503dc5..c30360de1 100644 --- a/test/workbox-build/node/lib/bundle.js +++ b/test/workbox-build/node/lib/bundle.js @@ -40,7 +40,7 @@ describe(`[workbox-build] lib/bundle`, function() { writeFile: sinon.stub().resolves(), }, 'upath': { - format: sinon.stub().callsFake(args => `${args.dir}${args.base}`), + format: sinon.stub().callsFake((args) => `${args.dir}${args.base}`), parse: sinon.stub().returns({base: 'sw.js', dir: ''}), }, 'tempy': { @@ -49,7 +49,7 @@ describe(`[workbox-build] lib/bundle`, function() { '@rollup/plugin-node-resolve': sinon.stub(), '@rollup/plugin-replace': sinon.stub(), '@rollup/plugin-babel': { - babel: sinon.stub(), + babel: sinon.stub(), }, 'rollup-plugin-terser': { terser: sinon.stub(), diff --git a/test/workbox-build/node/lib/validate-options.js b/test/workbox-build/node/lib/validate-options.js index 26cf17776..e0b12b22f 100644 --- a/test/workbox-build/node/lib/validate-options.js +++ b/test/workbox-build/node/lib/validate-options.js @@ -59,18 +59,18 @@ describe(`[workbox-build] entry-points/options/validate-options.js`, function() }); expect(() => validateOptions[func]()).to.throw( - validateOptions.WorkboxConfigError, - `[path1] message1. suggestion1\n\n[path2] message2. suggestion2` + validateOptions.WorkboxConfigError, + `[path1] message1. suggestion1\n\n[path2] message2. suggestion2`, ); }); - + it(`${func}() should not throw when validation passes`, function() { const validateOptions = proxyquire(MODULE_PATH, { 'ajv': { default: AJVPassesValidation, }, }); - + const defaultOptions = validateOptions[func]({ globDirectory: '.', }); diff --git a/test/workbox-cli/node/app.js b/test/workbox-cli/node/app.js index 41bce26f0..f1029e3a3 100644 --- a/test/workbox-cli/node/app.js +++ b/test/workbox-cli/node/app.js @@ -52,17 +52,17 @@ describe(`[workbox-cli] app.js`, function() { it(`should reject when both parameters are missing`, async function() { await expect(app()).to.eventually.be.rejectedWith( - errors['missing-input']); + errors['missing-input']); }); it(`should reject when the command is unknown and options is present`, async function() { await expect(app({input: [UNKNOWN_COMMAND, PROXIED_CONFIG_FILE]})).to - .eventually.be.rejectedWith(errors['unknown-command']); + .eventually.be.rejectedWith(errors['unknown-command']); }); it(`should reject when the command parameter is copyLibraries and options is missing`, async function() { await expect(app({input: ['copyLibraries']})).to - .eventually.be.rejectedWith(errors['missing-dest-dir-param']); + .eventually.be.rejectedWith(errors['missing-dest-dir-param']); }); for (const command of WORKBOX_BUILD_COMMANDS) { @@ -117,7 +117,7 @@ describe(`[workbox-cli] app.js`, function() { }); await expect(app({input: [command, PROXIED_CONFIG_FILE]})).to - .eventually.be.rejectedWith(WorkboxConfigError); + .eventually.be.rejectedWith(WorkboxConfigError); }); } @@ -145,7 +145,7 @@ describe(`[workbox-cli] app.js`, function() { }); await expect(app({input: [command, PROXIED_CONFIG_FILE]})).to - .eventually.be.rejectedWith(PROXIED_ERROR); + .eventually.be.rejectedWith(PROXIED_ERROR); }); } }); @@ -200,7 +200,7 @@ describe(`[workbox-cli] app.js`, function() { [command]: () => { return WORKBOX_BUILD_WITH_WARNINGS_RETURN_VALUE; }, - } + }, }, }); diff --git a/test/workbox-webpack-plugin/node/v5/generate-sw.js b/test/workbox-webpack-plugin/node/v5/generate-sw.js index 3a2be09bb..c46b469ae 100644 --- a/test/workbox-webpack-plugin/node/v5/generate-sw.js +++ b/test/workbox-webpack-plugin/node/v5/generate-sw.js @@ -66,7 +66,7 @@ describe(`[workbox-webpack-plugin] GenerateSW with webpack v5`, function() { expect(statsJson.warnings).to.be.empty; expect(statsJson.errors).to.have.length(1); expect(statsJson.errors[0].message).to.eql( - `Please check your GenerateSW plugin configuration:\n[WebpackGenerateSW] \'invalid\' property is not expected to be here. Did you mean property \'include\'?` + `Please check your GenerateSW plugin configuration:\n[WebpackGenerateSW] 'invalid' property is not expected to be here. Did you mean property 'include'?`, ); done(); diff --git a/test/workbox-webpack-plugin/node/v5/inject-manifest.js b/test/workbox-webpack-plugin/node/v5/inject-manifest.js index d864d8193..45f56bcb6 100644 --- a/test/workbox-webpack-plugin/node/v5/inject-manifest.js +++ b/test/workbox-webpack-plugin/node/v5/inject-manifest.js @@ -71,7 +71,7 @@ describe(`[workbox-webpack-plugin] InjectManifest with webpack v5`, function() { const statsJson = stats.toJson(); expect(statsJson.warnings).to.be.empty; expect(statsJson.errors[0].message).to.eql( - `Please check your InjectManifest plugin configuration:\n[WebpackInjectManifest] \'invalid\' property is not expected to be here. Did you mean property \'include\'?`, + `Please check your InjectManifest plugin configuration:\n[WebpackInjectManifest] 'invalid' property is not expected to be here. Did you mean property 'include'?`, ); done(); @@ -1645,7 +1645,7 @@ describe(`[workbox-webpack-plugin] InjectManifest with webpack v5`, function() { const statsJson = stats.toJson(); expect(statsJson.errors).to.be.empty; expect(statsJson.warnings[0].message).to.eql( - 'compileSrc is false, so the webpackCompilationPlugins option will be ignored.', + 'compileSrc is false, so the webpackCompilationPlugins option will be ignored.', ); done(); @@ -1697,7 +1697,7 @@ describe(`[workbox-webpack-plugin] InjectManifest with webpack v5`, function() { it(`should support injecting a manifest into a CJS module`, function(done) { const outputDir = tempy.directory(); - + const config = { mode: 'production', entry: upath.join(SRC_DIR, WEBPACK_ENTRY_FILENAME), @@ -1713,21 +1713,21 @@ describe(`[workbox-webpack-plugin] InjectManifest with webpack v5`, function() { }), ], }; - + const compiler = webpack(config); compiler.run(async (webpackError, stats) => { try { webpackBuildCheck(webpackError, stats); - + const files = await globby('**', {cwd: outputDir}); expect(files).to.have.length(2); - + const manifest = require(upath.join(outputDir, 'injected-manifest.js')); expect(manifest).to.matchPattern([{ revision: null, url: /^main\.[0-9a-f]{20}\.js$/, }]); - + done(); } catch (error) { done(error); From a9eee0f39a1b9ba15bc0754ca4082c088fe4aec3 Mon Sep 17 00:00:00 2001 From: Jeff Posnick Date: Wed, 16 Jun 2021 10:18:24 -0400 Subject: [PATCH 70/80] Automated linting fixes --- packages/workbox-build/src/lib/bundle.ts | 2 +- .../src/lib/get-composite-details.ts | 2 +- .../workbox-build/src/lib/get-file-details.ts | 4 ++-- packages/workbox-build/src/lib/get-file-hash.ts | 2 +- .../src/lib/get-file-manifest-entries.ts | 2 +- packages/workbox-build/src/lib/get-file-size.ts | 2 +- .../workbox-build/src/lib/get-string-details.ts | 2 +- .../workbox-build/src/lib/get-string-hash.ts | 2 +- .../src/lib/maximum-size-transform.ts | 2 +- .../src/lib/modify-url-prefix-transform.ts | 2 +- .../workbox-build/src/lib/module-registry.ts | 2 +- .../no-revision-for-urls-matching-transform.ts | 2 +- .../src/lib/populate-sw-template.ts | 2 +- packages/workbox-build/src/lib/rebase-path.ts | 2 +- .../src/lib/replace-and-update-source-map.ts | 2 +- .../src/lib/stringify-without-comments.ts | 2 +- .../src/lib/write-sw-using-default-template.ts | 2 +- packages/workbox-build/src/types.ts | 16 ++++++++-------- .../workbox-expiration/src/ExpirationPlugin.ts | 2 +- 19 files changed, 27 insertions(+), 27 deletions(-) diff --git a/packages/workbox-build/src/lib/bundle.ts b/packages/workbox-build/src/lib/bundle.ts index 6f883f57e..555acd2ae 100644 --- a/packages/workbox-build/src/lib/bundle.ts +++ b/packages/workbox-build/src/lib/bundle.ts @@ -21,7 +21,7 @@ import {GeneratePartial, RequiredSWDestPartial} from '../types'; interface NameAndContents { contents: string | Uint8Array; - name: string + name: string; } export async function bundle({ diff --git a/packages/workbox-build/src/lib/get-composite-details.ts b/packages/workbox-build/src/lib/get-composite-details.ts index c095efa46..3412bec74 100644 --- a/packages/workbox-build/src/lib/get-composite-details.ts +++ b/packages/workbox-build/src/lib/get-composite-details.ts @@ -28,4 +28,4 @@ export function getCompositeDetails(compositeURL: string, dependencyDetails: Arr hash: hashOfHashes, size: totalSize, }; -}; +} diff --git a/packages/workbox-build/src/lib/get-file-details.ts b/packages/workbox-build/src/lib/get-file-details.ts index 826140286..010c28f6d 100644 --- a/packages/workbox-build/src/lib/get-file-details.ts +++ b/packages/workbox-build/src/lib/get-file-details.ts @@ -19,7 +19,7 @@ interface FileDetails { file: string; hash: string; size: number; -}; +} export function getFileDetails({ globDirectory, @@ -69,4 +69,4 @@ export function getFileDetails({ } return {globbedFileDetails, warning}; -}; +} diff --git a/packages/workbox-build/src/lib/get-file-hash.ts b/packages/workbox-build/src/lib/get-file-hash.ts index 86977e4e5..550ae4435 100644 --- a/packages/workbox-build/src/lib/get-file-hash.ts +++ b/packages/workbox-build/src/lib/get-file-hash.ts @@ -18,4 +18,4 @@ export function getFileHash(file: string): string { } catch (err) { throw new Error(errors['unable-to-get-file-hash'] + ` '${err.message}'`); } -}; +} diff --git a/packages/workbox-build/src/lib/get-file-manifest-entries.ts b/packages/workbox-build/src/lib/get-file-manifest-entries.ts index 9677850f7..08e95abed 100644 --- a/packages/workbox-build/src/lib/get-file-manifest-entries.ts +++ b/packages/workbox-build/src/lib/get-file-manifest-entries.ts @@ -109,4 +109,4 @@ export async function getFileManifestEntries({ transformedManifest.warnings.push(...warnings); return transformedManifest; -}; +} diff --git a/packages/workbox-build/src/lib/get-file-size.ts b/packages/workbox-build/src/lib/get-file-size.ts index 81c9fcb02..6379e2681 100644 --- a/packages/workbox-build/src/lib/get-file-size.ts +++ b/packages/workbox-build/src/lib/get-file-size.ts @@ -20,4 +20,4 @@ export function getFileSize(file: string): number | null { } catch (err) { throw new Error(errors['unable-to-get-file-size'] + ` '${err.message}'`); } -}; +} diff --git a/packages/workbox-build/src/lib/get-string-details.ts b/packages/workbox-build/src/lib/get-string-details.ts index 7351e276b..141863e84 100644 --- a/packages/workbox-build/src/lib/get-string-details.ts +++ b/packages/workbox-build/src/lib/get-string-details.ts @@ -15,4 +15,4 @@ export function getStringDetails(url: string, str: string): FileDetails { hash: getStringHash(str), size: str.length, }; -}; +} diff --git a/packages/workbox-build/src/lib/get-string-hash.ts b/packages/workbox-build/src/lib/get-string-hash.ts index 4cfdcb66d..5ce1a5c1c 100644 --- a/packages/workbox-build/src/lib/get-string-hash.ts +++ b/packages/workbox-build/src/lib/get-string-hash.ts @@ -12,4 +12,4 @@ export function getStringHash(input: crypto.BinaryLike): string { const md5 = crypto.createHash('md5'); md5.update(input); return md5.digest('hex'); -}; +} diff --git a/packages/workbox-build/src/lib/maximum-size-transform.ts b/packages/workbox-build/src/lib/maximum-size-transform.ts index e1f7a13a5..fb56d9047 100644 --- a/packages/workbox-build/src/lib/maximum-size-transform.ts +++ b/packages/workbox-build/src/lib/maximum-size-transform.ts @@ -26,4 +26,4 @@ export function maximumSizeTransform(maximumFileSizeToCacheInBytes: number): Man return {manifest, warnings}; }; -}; +} diff --git a/packages/workbox-build/src/lib/modify-url-prefix-transform.ts b/packages/workbox-build/src/lib/modify-url-prefix-transform.ts index 4ced5cc8a..ea82dbb67 100644 --- a/packages/workbox-build/src/lib/modify-url-prefix-transform.ts +++ b/packages/workbox-build/src/lib/modify-url-prefix-transform.ts @@ -54,4 +54,4 @@ export function modifyURLPrefixTransform(modifyURLPrefix: {[key: string]: string return {manifest}; }; -}; +} diff --git a/packages/workbox-build/src/lib/module-registry.ts b/packages/workbox-build/src/lib/module-registry.ts index 224c8a61a..b3dbb1174 100644 --- a/packages/workbox-build/src/lib/module-registry.ts +++ b/packages/workbox-build/src/lib/module-registry.ts @@ -16,7 +16,7 @@ import upath from 'upath'; * @private */ export class ModuleRegistry { - private _modulesUsed: Map; + private readonly _modulesUsed: Map; /** * @private */ diff --git a/packages/workbox-build/src/lib/no-revision-for-urls-matching-transform.ts b/packages/workbox-build/src/lib/no-revision-for-urls-matching-transform.ts index 4b95320a3..71b4a872d 100644 --- a/packages/workbox-build/src/lib/no-revision-for-urls-matching-transform.ts +++ b/packages/workbox-build/src/lib/no-revision-for-urls-matching-transform.ts @@ -29,4 +29,4 @@ export function noRevisionForURLsMatchingTransform(regexp: RegExp): ManifestTran return {manifest}; }; -}; +} diff --git a/packages/workbox-build/src/lib/populate-sw-template.ts b/packages/workbox-build/src/lib/populate-sw-template.ts index a7755b7bf..cb84f0d17 100644 --- a/packages/workbox-build/src/lib/populate-sw-template.ts +++ b/packages/workbox-build/src/lib/populate-sw-template.ts @@ -98,4 +98,4 @@ export function populateSWTemplate({ throw new Error( `${errors['populating-sw-tmpl-failed']} '${error.message}'`); } -}; +} diff --git a/packages/workbox-build/src/lib/rebase-path.ts b/packages/workbox-build/src/lib/rebase-path.ts index 916ebac3e..3755b3094 100644 --- a/packages/workbox-build/src/lib/rebase-path.ts +++ b/packages/workbox-build/src/lib/rebase-path.ts @@ -11,7 +11,7 @@ import upath from 'upath'; export function rebasePath({ baseDirectory, file -}: {baseDirectory: string, file: string}): string { +}: {baseDirectory: string; file: string}): string { // The initial path is relative to the current directory, so make it absolute. const absolutePath = upath.resolve(file); diff --git a/packages/workbox-build/src/lib/replace-and-update-source-map.ts b/packages/workbox-build/src/lib/replace-and-update-source-map.ts index b52311218..244721371 100644 --- a/packages/workbox-build/src/lib/replace-and-update-source-map.ts +++ b/packages/workbox-build/src/lib/replace-and-update-source-map.ts @@ -71,7 +71,7 @@ export async function replaceAndUpdateSourceMap({ consumer.eachMapping((mapping) => { for (const replacement of replacements) { - if (replacement.line == mapping.generatedLine && + if (replacement.line === mapping.generatedLine && mapping.generatedColumn > replacement.column) { const offset = searchString.length - replaceString.length; mapping.generatedColumn -= offset; diff --git a/packages/workbox-build/src/lib/stringify-without-comments.ts b/packages/workbox-build/src/lib/stringify-without-comments.ts index bad179623..1694cd68a 100644 --- a/packages/workbox-build/src/lib/stringify-without-comments.ts +++ b/packages/workbox-build/src/lib/stringify-without-comments.ts @@ -19,4 +19,4 @@ export function stringifyWithoutComments(obj: {[key: string]: any}): string { return str; }, }); -}; +} diff --git a/packages/workbox-build/src/lib/write-sw-using-default-template.ts b/packages/workbox-build/src/lib/write-sw-using-default-template.ts index 347ca2502..ceed58436 100644 --- a/packages/workbox-build/src/lib/write-sw-using-default-template.ts +++ b/packages/workbox-build/src/lib/write-sw-using-default-template.ts @@ -88,4 +88,4 @@ export async function writeSWUsingDefaultTemplate({ } throw new Error(`${errors['sw-write-failure']} '${error.message}'`); } -}; +} diff --git a/packages/workbox-build/src/types.ts b/packages/workbox-build/src/types.ts index d5b021300..c95c29871 100644 --- a/packages/workbox-build/src/types.ts +++ b/packages/workbox-build/src/types.ts @@ -38,7 +38,7 @@ export interface RuntimeCaching { plugins?: Array; precacheFallback?: { fallbackURL: string; - }, + }; fetchOptions?: RequestInit; matchOptions?: CacheQueryOptions; }; @@ -64,7 +64,7 @@ export interface BasePartial { */ maximumFileSizeToCacheInBytes?: number; modifyURLPrefix?: { - [key: string]: string, + [key: string]: string; }; } @@ -219,10 +219,10 @@ export type WebpackInjectManifestOptions = BasePartial & WebpackPartial & InjectPartial & WebpackInjectManifestPartial; export interface GetManifestResult { - count: number, - manifestEntries: Array, - size: number, - warnings: Array + count: number; + manifestEntries: Array; + size: number; + warnings: Array; } export type BuildResult = Omit & { @@ -239,8 +239,8 @@ export type BuildType = 'dev' | 'prod'; export interface WorkboxPackageJSON extends PackageJson { workbox?: { - browserNamespace?: string, + browserNamespace?: string; packageType?: string; prodOnly?: boolean; }; -}; +} diff --git a/packages/workbox-expiration/src/ExpirationPlugin.ts b/packages/workbox-expiration/src/ExpirationPlugin.ts index f39eb88fe..713b26e5b 100644 --- a/packages/workbox-expiration/src/ExpirationPlugin.ts +++ b/packages/workbox-expiration/src/ExpirationPlugin.ts @@ -24,7 +24,7 @@ export interface ExpirationPluginOptions { maxAgeSeconds?: number; matchOptions?: CacheQueryOptions; purgeOnQuotaError?: boolean; -}; +} /** * This plugin can be used in a `workbox-strategy` to regularly enforce a From 6a71bb2007cbd167df3c1ac200907945b7b98eee Mon Sep 17 00:00:00 2001 From: Jeff Posnick Date: Wed, 16 Jun 2021 10:21:54 -0400 Subject: [PATCH 71/80] Tweak linting rules --- typescript.eslintrc.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/typescript.eslintrc.js b/typescript.eslintrc.js index bebb7b91b..8b896ac3c 100644 --- a/typescript.eslintrc.js +++ b/typescript.eslintrc.js @@ -7,6 +7,7 @@ module.exports = { }, plugins: [ '@typescript-eslint', + 'jsdoc', ], extends: [ 'eslint:recommended', @@ -25,7 +26,9 @@ module.exports = { '@typescript-eslint/no-misused-promises': 'off', '@typescript-eslint/no-non-null-assertion': 'off', '@typescript-eslint/no-use-before-define': 'off', + '@typescript-eslint/no-var-requires': 'off', '@typescript-eslint/prefer-readonly': 'error', + '@typescript-eslint/prefer-regexp-exec': 'off', '@typescript-eslint/require-await': 'off', '@typescript-eslint/unbound-method': 'off', 'block-scoped-var': 'error', From 76bc6598e7fac5ab8f89b25a462229bf5dee1e5a Mon Sep 17 00:00:00 2001 From: Jeffrey Posnick Date: Wed, 16 Jun 2021 10:28:49 -0400 Subject: [PATCH 72/80] Update packages/workbox-build/src/lib/get-file-details.ts Co-authored-by: Adriana Jara <32825533+tropicadri@users.noreply.github.com> --- packages/workbox-build/src/lib/get-file-details.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/workbox-build/src/lib/get-file-details.ts b/packages/workbox-build/src/lib/get-file-details.ts index 010c28f6d..40b7c0434 100644 --- a/packages/workbox-build/src/lib/get-file-details.ts +++ b/packages/workbox-build/src/lib/get-file-details.ts @@ -1,5 +1,5 @@ /* - Copyright 2018 Google LLC + Copyright 2021 Google LLC Use of this source code is governed by an MIT-style license that can be found in the LICENSE file or at From 14cc0ad56a86f55bf64a46046cb71c3e14562b26 Mon Sep 17 00:00:00 2001 From: Jeffrey Posnick Date: Wed, 16 Jun 2021 10:28:55 -0400 Subject: [PATCH 73/80] Update test/workbox-build/node/generate-sw.js Co-authored-by: Adriana Jara <32825533+tropicadri@users.noreply.github.com> --- test/workbox-build/node/generate-sw.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/workbox-build/node/generate-sw.js b/test/workbox-build/node/generate-sw.js index 263de0cb7..b19cfd68b 100644 --- a/test/workbox-build/node/generate-sw.js +++ b/test/workbox-build/node/generate-sw.js @@ -1043,7 +1043,7 @@ describe(`[workbox-build] generate-sw.js (End to End)`, function() { WorkboxConfigError, errors['nav-preload-runtime-caching']); }); - it(`should reject when 'navigationPreload' is true and 'runtimeCaching' is invalid`, async function() { + it(`should reject when 'navigationPreload' is true and 'runtimeCaching' is undefined`, async function() { const options = Object.assign({}, BASE_OPTIONS, { runtimeCaching: undefined, navigationPreload: true, From 8816a4dc3fec432a150c68286409d932e2a663f7 Mon Sep 17 00:00:00 2001 From: Jeffrey Posnick Date: Wed, 16 Jun 2021 10:29:09 -0400 Subject: [PATCH 74/80] Update packages/workbox-build/src/lib/additional-manifest-entries-transform.ts Co-authored-by: Adriana Jara <32825533+tropicadri@users.noreply.github.com> --- .../src/lib/additional-manifest-entries-transform.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/workbox-build/src/lib/additional-manifest-entries-transform.ts b/packages/workbox-build/src/lib/additional-manifest-entries-transform.ts index b91ab668b..c9408a8f0 100644 --- a/packages/workbox-build/src/lib/additional-manifest-entries-transform.ts +++ b/packages/workbox-build/src/lib/additional-manifest-entries-transform.ts @@ -12,7 +12,7 @@ import {ManifestEntry} from '../types'; export function additionalManifestEntriesTransform(additionalManifestEntries: Array) { return (manifest: Array) => { const warnings = []; - const stringEntries = new Set(); + const stringEntries = new Set(); for (const additionalEntry of additionalManifestEntries) { // Warn about either a string or an object that lacks a revision property. From 207bb4f4ca849ebf88a7f36a478e18887bb4510b Mon Sep 17 00:00:00 2001 From: Jeffrey Posnick Date: Wed, 16 Jun 2021 10:29:18 -0400 Subject: [PATCH 75/80] Update packages/workbox-build/src/lib/additional-manifest-entries-transform.ts Co-authored-by: Adriana Jara <32825533+tropicadri@users.noreply.github.com> --- .../src/lib/additional-manifest-entries-transform.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/workbox-build/src/lib/additional-manifest-entries-transform.ts b/packages/workbox-build/src/lib/additional-manifest-entries-transform.ts index c9408a8f0..763b1391b 100644 --- a/packages/workbox-build/src/lib/additional-manifest-entries-transform.ts +++ b/packages/workbox-build/src/lib/additional-manifest-entries-transform.ts @@ -11,7 +11,7 @@ import {ManifestEntry} from '../types'; export function additionalManifestEntriesTransform(additionalManifestEntries: Array) { return (manifest: Array) => { - const warnings = []; + const warnings : Array = []; const stringEntries = new Set(); for (const additionalEntry of additionalManifestEntries) { From 19a3ff3ef770c59be5847b2e43a47ddb1fe5c6ca Mon Sep 17 00:00:00 2001 From: Jeffrey Posnick Date: Wed, 16 Jun 2021 10:29:24 -0400 Subject: [PATCH 76/80] Update packages/workbox-build/src/lib/cdn-utils.ts Co-authored-by: Adriana Jara <32825533+tropicadri@users.noreply.github.com> --- packages/workbox-build/src/lib/cdn-utils.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/workbox-build/src/lib/cdn-utils.ts b/packages/workbox-build/src/lib/cdn-utils.ts index 7ca2c9efd..33ab081ef 100644 --- a/packages/workbox-build/src/lib/cdn-utils.ts +++ b/packages/workbox-build/src/lib/cdn-utils.ts @@ -1,5 +1,5 @@ /* - Copyright 2018 Google LLC + Copyright 2021 Google LLC Use of this source code is governed by an MIT-style license that can be found in the LICENSE file or at From 4e363bd3f822b19e28969d47cb5eb12dec2d43b3 Mon Sep 17 00:00:00 2001 From: Jeffrey Posnick Date: Wed, 16 Jun 2021 10:29:29 -0400 Subject: [PATCH 77/80] Update packages/workbox-build/src/lib/get-file-manifest-entries.ts Co-authored-by: Adriana Jara <32825533+tropicadri@users.noreply.github.com> --- packages/workbox-build/src/lib/get-file-manifest-entries.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/workbox-build/src/lib/get-file-manifest-entries.ts b/packages/workbox-build/src/lib/get-file-manifest-entries.ts index 08e95abed..521345a66 100644 --- a/packages/workbox-build/src/lib/get-file-manifest-entries.ts +++ b/packages/workbox-build/src/lib/get-file-manifest-entries.ts @@ -1,5 +1,5 @@ /* - Copyright 2018 Google LLC + Copyright 2021 Google LLC Use of this source code is governed by an MIT-style license that can be found in the LICENSE file or at From c0669416cc88b3b73238eac362bcb807abca97fd Mon Sep 17 00:00:00 2001 From: Jeffrey Posnick Date: Wed, 16 Jun 2021 10:29:35 -0400 Subject: [PATCH 78/80] Update packages/workbox-build/src/lib/stringify-without-comments.ts Co-authored-by: Adriana Jara <32825533+tropicadri@users.noreply.github.com> --- packages/workbox-build/src/lib/stringify-without-comments.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/workbox-build/src/lib/stringify-without-comments.ts b/packages/workbox-build/src/lib/stringify-without-comments.ts index 1694cd68a..b1b8d03ae 100644 --- a/packages/workbox-build/src/lib/stringify-without-comments.ts +++ b/packages/workbox-build/src/lib/stringify-without-comments.ts @@ -1,5 +1,5 @@ /* - Copyright 2018 Google LLC + Copyright 2021 Google LLC Use of this source code is governed by an MIT-style license that can be found in the LICENSE file or at From 4caaaeb000fa6a3444dc6662a5bf80215e1edced Mon Sep 17 00:00:00 2001 From: Jeffrey Posnick Date: Wed, 16 Jun 2021 10:29:40 -0400 Subject: [PATCH 79/80] Update packages/workbox-build/src/lib/validate-options.ts Co-authored-by: Adriana Jara <32825533+tropicadri@users.noreply.github.com> --- packages/workbox-build/src/lib/validate-options.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/workbox-build/src/lib/validate-options.ts b/packages/workbox-build/src/lib/validate-options.ts index dcf0f0283..13407b1a8 100644 --- a/packages/workbox-build/src/lib/validate-options.ts +++ b/packages/workbox-build/src/lib/validate-options.ts @@ -1,5 +1,5 @@ /* - Copyright 2019 Google LLC + Copyright 2021 Google LLC Use of this source code is governed by an MIT-style license that can be found in the LICENSE file or at From 4af8d17290e6f433fa5b7efac02efc8c664f5096 Mon Sep 17 00:00:00 2001 From: Jeffrey Posnick Date: Thu, 17 Jun 2021 09:41:35 -0400 Subject: [PATCH 80/80] Update packages/workbox-build/src/lib/additional-manifest-entries-transform.ts Co-authored-by: Adriana Jara <32825533+tropicadri@users.noreply.github.com> --- .../src/lib/additional-manifest-entries-transform.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/workbox-build/src/lib/additional-manifest-entries-transform.ts b/packages/workbox-build/src/lib/additional-manifest-entries-transform.ts index 763b1391b..6780a8bde 100644 --- a/packages/workbox-build/src/lib/additional-manifest-entries-transform.ts +++ b/packages/workbox-build/src/lib/additional-manifest-entries-transform.ts @@ -11,7 +11,7 @@ import {ManifestEntry} from '../types'; export function additionalManifestEntriesTransform(additionalManifestEntries: Array) { return (manifest: Array) => { - const warnings : Array = []; + const warnings: Array = []; const stringEntries = new Set(); for (const additionalEntry of additionalManifestEntries) {