Socket
Socket
Sign inDemoInstall

workbox-build

Package Overview
Dependencies
Maintainers
4
Versions
100
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

workbox-build - npm Package Compare versions

Comparing version 4.0.0-beta.0 to 4.0.0-beta.1

build/lib/check-for-deprecated-options.js

2

build/cdn-details.json

@@ -5,3 +5,3 @@ {

"releasesDir": "releases",
"latestVersion": "4.0.0-beta.0"
"latestVersion": "4.0.0-beta.1"
}

@@ -14,2 +14,4 @@ "use strict";

*/
const checkForDeprecatedOptions = require('../lib/check-for-deprecated-options');
const generateSWStringSchema = require('./options/generate-sw-string-schema');

@@ -43,2 +45,5 @@

_generateSWString = (0, _asyncToGenerator2.default)(function* (config) {
// This check needs to be done before validation, since the deprecated options
// will be renamed.
const deprecationWarnings = checkForDeprecatedOptions(config);
const options = validate(config, generateSWStringSchema);

@@ -52,3 +57,5 @@

manifestEntries
}, options));
}, options)); // Add in any deprecation warnings.
warnings.push(...deprecationWarnings);
return {

@@ -55,0 +62,0 @@ swString,

@@ -18,2 +18,4 @@ "use strict";

const checkForDeprecatedOptions = require('../lib/check-for-deprecated-options');
const copyWorkboxLibraries = require('../lib/copy-workbox-libraries');

@@ -57,2 +59,5 @@

_generateSW = (0, _asyncToGenerator2.default)(function* (config) {
// This check needs to be done before validation, since the deprecated options
// will be renamed.
const deprecationWarnings = checkForDeprecatedOptions(config);
const options = validate(config, generateSWSchema);

@@ -62,4 +67,4 @@ const destDirectory = path.dirname(options.swDest); // Do nothing if importWorkboxFrom is set to 'disabled'. Otherwise, check:

if (options.importWorkboxFrom === 'cdn') {
const cdnUrl = cdnUtils.getModuleUrl('workbox-sw');
options.workboxSWImport = cdnUrl;
const cdnURL = cdnUtils.getModuleURL('workbox-sw');
options.workboxSWImport = cdnURL;
} else if (options.importWorkboxFrom === 'local') {

@@ -87,3 +92,5 @@ // Copy over the dev + prod version of all of the core libraries.

manifestEntries
}, options));
}, options)); // Add in any deprecation warnings.
warnings.push(...deprecationWarnings);
return {

@@ -90,0 +97,0 @@ count,

@@ -14,2 +14,4 @@ "use strict";

*/
const checkForDeprecatedOptions = require('../lib/check-for-deprecated-options');
const getFileManifestEntries = require('../lib/get-file-manifest-entries');

@@ -45,2 +47,5 @@

_getManifest = (0, _asyncToGenerator2.default)(function* (config) {
// This check needs to be done before validation, since the deprecated options
// will be renamed.
const deprecationWarnings = checkForDeprecatedOptions(config);
const options = validate(config, getManifestSchema);

@@ -52,4 +57,6 @@

size = _ref.size,
warnings = _ref.warnings;
warnings = _ref.warnings; // Add in any deprecation warnings.
warnings.push(...deprecationWarnings);
return {

@@ -56,0 +63,0 @@ manifestEntries,

@@ -20,2 +20,4 @@ "use strict";

const checkForDeprecatedOptions = require('../lib/check-for-deprecated-options');
const defaults = require('./options/defaults');

@@ -59,2 +61,5 @@

_injectManifest = (0, _asyncToGenerator2.default)(function* (config) {
// This check needs to be done before validation, since the deprecated options
// will be renamed.
const deprecationWarnings = checkForDeprecatedOptions(config);
const options = validate(config, injectManifestSchema);

@@ -98,3 +103,5 @@

yield fse.writeFile(config.swDest, swFileContents);
yield fse.writeFile(config.swDest, swFileContents); // Add in any deprecation warnings.
warnings.push(...deprecationWarnings);
return {

@@ -101,0 +108,0 @@ count,

@@ -14,7 +14,7 @@ "use strict";

const regExpObject = require('./reg-exp-object'); // Define some common constrains used by all methods.
const regExpObject = require('./reg-exp-object'); // Define some common constraints used by all methods.
module.exports = joi.object().keys({
dontCacheBustUrlsMatching: regExpObject,
dontCacheBustURLsMatching: regExpObject,
globFollow: joi.boolean().default(defaults.globFollow),

@@ -26,6 +26,6 @@ globIgnores: joi.array().items(joi.string()).default(defaults.globIgnores),

maximumFileSizeToCacheInBytes: joi.number().min(1).default(defaults.maximumFileSizeToCacheInBytes),
modifyUrlPrefix: joi.object(),
// templatedUrls is an object where any property name is valid, and the values
modifyURLPrefix: joi.object(),
// 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())])
templatedURLs: joi.object().pattern(/./, [joi.string(), joi.array().items(joi.string())])
});

@@ -23,3 +23,3 @@ "use strict";

directoryIndex: joi.string(),
ignoreUrlParametersMatching: joi.array().items(regExpObject),
ignoreURLParametersMatching: joi.array().items(regExpObject),
navigateFallback: joi.string().default(defaults.navigateFallback),

@@ -31,4 +31,4 @@ navigateFallbackBlacklist: joi.array().items(regExpObject),

method: joi.string().valid('DELETE', 'GET', 'HEAD', 'PATCH', 'POST', 'PUT'),
urlPattern: [regExpObject, joi.string()],
handler: [joi.func(), joi.string().valid('cacheFirst', 'cacheOnly', 'networkFirst', 'networkOnly', 'staleWhileRevalidate')],
urlPattern: [regExpObject, joi.string(), joi.func()],
handler: [joi.func(), joi.string().valid('CacheFirst', 'CacheOnly', 'NetworkFirst', 'NetworkOnly', 'StaleWhileRevalidate')],
options: joi.object().keys({

@@ -60,2 +60,5 @@ backgroundSync: joi.object().keys({

skipWaiting: joi.boolean().default(defaults.skipWaiting)
}).rename('ignoreUrlParametersMatching', 'ignoreURLParametersMatching', {
ignoreUndefined: true,
override: true
});

@@ -17,3 +17,3 @@ "use strict";

importWorkboxFrom: 'cdn',
injectionPointRegexp: /(\.precacheAndRoute\()\s*\[\s*\]\s*(\)|,)/,
injectionPointRegexp: /(precacheAndRoute\()\s*\[\s*\]\s*(\)|,)/,
maximumFileSizeToCacheInBytes: 2 * 1024 * 1024,

@@ -20,0 +20,0 @@ navigateFallback: undefined,

@@ -21,3 +21,3 @@ "use strict";

const _require = require('./lib/cdn-utils'),
getModuleUrl = _require.getModuleUrl;
getModuleURL = _require.getModuleURL;
/**

@@ -46,3 +46,3 @@ * This Node module can be used to generate a list of assets that should be

*
* @property {Array<RegExp>} [ignoreUrlParametersMatching=[/^utm_/]] Any
* @property {Array<RegExp>} [ignoreURLParametersMatching=[/^utm_/]] Any
* search parameter names that match against one of the regex's in this array

@@ -88,4 +88,4 @@ * will be removed before looking for a precache match.

getManifest,
getModuleUrl,
getModuleURL,
injectManifest
};

@@ -20,7 +20,7 @@ "use strict";

const getVersionedCDNUrl = () => {
const getVersionedCDNURL = () => {
return `${getCDNOrigin()}/${cdn.latestVersion}`;
};
const getModuleUrl = (moduleName, buildType) => {
const getModuleURL = (moduleName, buildType) => {
assert(moduleName, errors['no-module-name']);

@@ -37,6 +37,6 @@

return `${getVersionedCDNUrl()}/${moduleName}.${buildType.slice(0, 4)}.js`;
return `${getVersionedCDNURL()}/${moduleName}.${buildType.slice(0, 4)}.js`;
}
return `${getVersionedCDNUrl()}/${moduleName}.js`;
return `${getVersionedCDNURL()}/${moduleName}.js`;
};

@@ -46,3 +46,3 @@

getCDNOrigin,
getModuleUrl
getModuleURL
};

@@ -46,3 +46,3 @@ "use strict";

string.`,
'invalid-dont-cache-bust': ol`The supplied 'dontCacheBustUrlsMatching'
'invalid-dont-cache-bust': ol`The supplied 'dontCacheBustURLsMatching'
parameter must be a RegExp.`,

@@ -60,5 +60,5 @@ 'invalid-exclude-files': 'The excluded files should be an array of strings.',

of strings.`,
'invalid-templated-urls': ol`The 'templatedUrls' value should be an object
'invalid-templated-urls': ol`The 'templatedURLs' value should be an object
that maps URLs to either a string, or to an array of glob patterns.`,
'templated-url-matches-glob': ol`One of the 'templatedUrls' URLs is already
'templated-url-matches-glob': ol`One of the 'templatedURLs' URLs is already
being tracked via 'globPatterns': `,

@@ -69,3 +69,3 @@ 'invalid-glob-ignores': ol`The 'globIgnores' parameter must be an array of

a URL string. This is likely an error with workbox-build.`,
'modify-url-prefix-bad-prefixes': ol`The 'modifyUrlPrefix' parameter must be
'modify-url-prefix-bad-prefixes': ol`The 'modifyURLPrefix' parameter must be
an object with string key value pairs.`,

@@ -83,3 +83,3 @@ 'invalid-inject-manifest-arg': ol`The input to 'injectManifest()' must be an

'bad-template-urls-asset': ol`There was an issue using one of the provided
'templatedUrls'.`,
'templatedURLs'.`,
'invalid-runtime-caching': ol`The 'runtimeCaching' parameter must an an

@@ -89,4 +89,4 @@ array of objects with at least a 'urlPattern' and 'handler'.`,

Please use 'globPatterns' instead.`,
'dynamic-url-deprecated': ol`'dynamicUrlToDependencies' is deprecated.
Please use 'templatedUrls' instead.`,
'dynamic-url-deprecated': ol`'dynamicURLToDependencies' is deprecated.
Please use 'templatedURLs' instead.`,
'urlPattern-is-required': ol`The 'urlPattern' option is required when using

@@ -106,5 +106,5 @@ 'runtimeCaching'.`,

'invalid-network-timeout-seconds': ol`When using networkTimeoutSeconds, you
must set the handler to 'networkFirst'.`,
must set the handler to 'NetworkFirst'.`,
'no-module-name': ol`You must provide a moduleName parameter when calling
getModuleUrl().`
getModuleURL().`
};

@@ -12,5 +12,5 @@ "use strict";

const modifyUrlPrefixTranform = require('./modify-url-prefix-transform');
const modifyURLPrefixTranform = require('./modify-url-prefix-transform');
const noRevisionForUrlsMatchingTransform = require('./no-revision-for-urls-matching-transform');
const noRevisionForURLsMatchingTransform = require('./no-revision-for-urls-matching-transform');
/**

@@ -68,7 +68,7 @@ * A `ManifestTransform` function can be used to modify the modify the `url` or

module.exports = ({
dontCacheBustUrlsMatching,
dontCacheBustURLsMatching,
fileDetails,
manifestTransforms,
maximumFileSizeToCacheInBytes,
modifyUrlPrefix
modifyURLPrefix
}) => {

@@ -91,8 +91,8 @@ let allWarnings = []; // Take the array of fileDetail objects and convert it into an array of

if (modifyUrlPrefix) {
transformsToApply.push(modifyUrlPrefixTranform(modifyUrlPrefix));
if (modifyURLPrefix) {
transformsToApply.push(modifyURLPrefixTranform(modifyURLPrefix));
}
if (dontCacheBustUrlsMatching) {
transformsToApply.push(noRevisionForUrlsMatchingTransform(dontCacheBustUrlsMatching));
if (dontCacheBustURLsMatching) {
transformsToApply.push(noRevisionForURLsMatchingTransform(dontCacheBustURLsMatching));
} // Any additional manifestTransforms that were passed will be applied last.

@@ -99,0 +99,0 @@

@@ -12,3 +12,3 @@ "use strict";

module.exports = (compositeUrl, dependencyDetails) => {
module.exports = (compositeURL, dependencyDetails) => {
let totalSize = 0;

@@ -45,3 +45,3 @@ let compositeHash = '';

return {
file: compositeUrl,
file: compositeURL,
hash: hashOfHashes,

@@ -48,0 +48,0 @@ size: totalSize

@@ -32,3 +32,3 @@ "use strict";

var _ref = (0, _asyncToGenerator2.default)(function* ({
dontCacheBustUrlsMatching,
dontCacheBustURLsMatching,
globDirectory,

@@ -41,5 +41,5 @@ globFollow,

maximumFileSizeToCacheInBytes,
modifyUrlPrefix,
modifyURLPrefix,
swDest,
templatedUrls
templatedURLs
}) {

@@ -84,4 +84,4 @@ const warnings = []; // Initialize to an empty array so that we can still pass something to

if (templatedUrls) {
var _arr = Object.keys(templatedUrls);
if (templatedURLs) {
var _arr = Object.keys(templatedURLs);

@@ -91,3 +91,3 @@ for (var _i = 0; _i < _arr.length; _i++) {

assert(!fileSet.has(url), errors['templated-url-matches-glob']);
const dependencies = templatedUrls[url];
const dependencies = templatedURLs[url];

@@ -121,4 +121,4 @@ if (Array.isArray(dependencies)) {

maximumFileSizeToCacheInBytes,
modifyUrlPrefix,
dontCacheBustUrlsMatching,
modifyURLPrefix,
dontCacheBustURLsMatching,
manifestTransforms

@@ -125,0 +125,0 @@ });

@@ -31,15 +31,15 @@ "use strict";

module.exports = modifyUrlPrefix => {
if (!modifyUrlPrefix || typeof modifyUrlPrefix !== 'object' || Array.isArray(modifyUrlPrefix)) {
module.exports = modifyURLPrefix => {
if (!modifyURLPrefix || typeof modifyURLPrefix !== 'object' || Array.isArray(modifyURLPrefix)) {
throw new Error(errors['modify-url-prefix-bad-prefixes']);
} // If there are no entries in modifyUrlPrefix, just return an identity
} // If there are no entries in modifyURLPrefix, just return an identity
// function as a shortcut.
if (Object.keys(modifyUrlPrefix).length === 0) {
if (Object.keys(modifyURLPrefix).length === 0) {
return entry => entry;
}
Object.keys(modifyUrlPrefix).forEach(key => {
if (typeof modifyUrlPrefix[key] !== 'string') {
Object.keys(modifyURLPrefix).forEach(key => {
if (typeof modifyURLPrefix[key] !== 'string') {
throw new Error(errors['modify-url-prefix-bad-prefixes']);

@@ -49,5 +49,5 @@ }

const safeModifyUrlPrefixes = Object.keys(modifyUrlPrefix).map(escapeRegExp); // Join all the `modifyUrlPrefix` keys so a single regex can be used.
const safeModifyURLPrefixes = Object.keys(modifyURLPrefix).map(escapeRegExp); // Join all the `modifyURLPrefix` keys so a single regex can be used.
const prefixMatchesStrings = safeModifyUrlPrefixes.join('|'); // Add `^` to the front the prefix matches so it only matches the start of
const prefixMatchesStrings = safeModifyURLPrefixes.join('|'); // Add `^` to the front the prefix matches so it only matches the start of
// a string.

@@ -63,3 +63,3 @@

entry.url = entry.url.replace(modifyRegex, match => {
return modifyUrlPrefix[match];
return modifyURLPrefix[match];
});

@@ -66,0 +66,0 @@ return entry;

@@ -24,3 +24,3 @@ "use strict";

directoryIndex,
ignoreUrlParametersMatching,
ignoreURLParametersMatching,
importScripts,

@@ -42,8 +42,8 @@ manifestEntries,

// default behavior, so if it's given, convert it manually.
ignoreUrlParametersMatching: ignoreUrlParametersMatching ? [] : undefined
ignoreURLParametersMatching: ignoreURLParametersMatching ? [] : undefined
};
let precacheOptionsString = JSON.stringify(precacheOptions, null, 2);
if (ignoreUrlParametersMatching) {
precacheOptionsString = precacheOptionsString.replace(`"ignoreUrlParametersMatching": []`, `"ignoreUrlParametersMatching": [` + `${ignoreUrlParametersMatching.join(', ')}]`);
if (ignoreURLParametersMatching) {
precacheOptionsString = precacheOptionsString.replace(`"ignoreURLParametersMatching": []`, `"ignoreURLParametersMatching": [` + `${ignoreURLParametersMatching.join(', ')}]`);
}

@@ -50,0 +50,0 @@

@@ -24,3 +24,3 @@ "use strict";

* @param {Object} options See
* https://googlechrome.github.io/sw-toolbox/api.html#options
* https://googlechromelabs.github.io/sw-toolbox/api.html#options
* @return {string} A JSON string representing the equivalent options.

@@ -92,3 +92,3 @@ *

if ('options' in pluginConfig) {
pluginCode += `, ${JSON.stringify(pluginConfig.options)}`;
pluginCode += `, ${stringifyWithoutComments(pluginConfig.options)}`;
}

@@ -106,3 +106,3 @@

if ('options' in pluginConfig) {
pluginCode += `, ${JSON.stringify(pluginConfig.options)}`;
pluginCode += `, ${stringifyWithoutComments(pluginConfig.options)}`;
}

@@ -118,3 +118,3 @@

{
pluginCode = `new ${pluginString}(${JSON.stringify(pluginConfig)})`;
pluginCode = `new ${pluginString}(${stringifyWithoutComments(pluginConfig)})`;
}

@@ -151,7 +151,6 @@ }

if (entry.options && entry.options.networkTimeoutSeconds && entry.handler !== 'networkFirst') {
if (entry.options && entry.options.networkTimeoutSeconds && entry.handler !== 'NetworkFirst') {
throw new Error(errors['invalid-network-timeout-seconds']);
} // urlPattern might be either a string or a RegExp object.
// If it's a string, it needs to be quoted. If it's a RegExp, it should
// be used as-is.
} // urlPattern might be a string, a RegExp object, or a function.
// If it's a string, it needs to be quoted.

@@ -163,3 +162,3 @@

const optionsString = getOptionsString(entry.options || {});
const strategyString = `workbox.strategies.${entry.handler}(${optionsString})`;
const strategyString = `new workbox.strategies.${entry.handler}(${optionsString})`;
return `workbox.routing.registerRoute(` + `${matcher}, ${strategyString}, '${method}');\n`;

@@ -166,0 +165,0 @@ } else if (typeof entry.handler === 'function') {

@@ -16,4 +16,4 @@ "use strict";

return objectStringify(obj, {
transform: (_obj, _prop, str) => stripComments(str)
transform: (_obj, _prop, str) => typeof _obj[_prop] === 'function' ? stripComments(str) : str
});
};

@@ -30,3 +30,3 @@ "use strict";

handleFetch,
ignoreUrlParametersMatching,
ignoreURLParametersMatching,
importScripts,

@@ -55,3 +55,3 @@ manifestEntries,

handleFetch,
ignoreUrlParametersMatching,
ignoreURLParametersMatching,
importScripts,

@@ -58,0 +58,0 @@ manifestEntries,

@@ -35,4 +35,4 @@ "use strict";

<% if (skipWaiting) { %>workbox.skipWaiting();<% } %>
<% if (clientsClaim) { %>workbox.clientsClaim();<% } %>
<% if (skipWaiting) { %>workbox.core.skipWaiting();<% } %>
<% if (clientsClaim) { %>workbox.core.clientsClaim();<% } %>

@@ -46,7 +46,5 @@ <% if (Array.isArray(manifestEntries)) {%>

self.__precacheManifest = <%= JSON.stringify(manifestEntries, null, 2) %>.concat(self.__precacheManifest || []);
workbox.precaching.suppressWarnings();
workbox.precaching.precacheAndRoute(self.__precacheManifest, <%= precacheOptionsString %>);
<% } else { %>
if (Array.isArray(self.__precacheManifest)) {
workbox.precaching.suppressWarnings();
workbox.precaching.precacheAndRoute(self.__precacheManifest, <%= precacheOptionsString %>);

@@ -53,0 +51,0 @@ }

{
"name": "workbox-build",
"version": "4.0.0-beta.0",
"version": "4.0.0-beta.1",
"description": "A module that integrates into your build process, helping you generate a manifest of local files that workbox-sw should precache.",

@@ -32,15 +32,15 @@ "keywords": [

"strip-comments": "^1.0.2",
"workbox-background-sync": "^4.0.0-beta.0",
"workbox-broadcast-cache-update": "^4.0.0-beta.0",
"workbox-cache-expiration": "^4.0.0-beta.0",
"workbox-cacheable-response": "^4.0.0-beta.0",
"workbox-core": "^4.0.0-beta.0",
"workbox-google-analytics": "^4.0.0-beta.0",
"workbox-navigation-preload": "^4.0.0-beta.0",
"workbox-precaching": "^4.0.0-beta.0",
"workbox-range-requests": "^4.0.0-beta.0",
"workbox-routing": "^4.0.0-beta.0",
"workbox-strategies": "^4.0.0-beta.0",
"workbox-streams": "^4.0.0-beta.0",
"workbox-sw": "^4.0.0-beta.0"
"workbox-background-sync": "^4.0.0-beta.1",
"workbox-broadcast-cache-update": "^4.0.0-beta.1",
"workbox-cache-expiration": "^4.0.0-beta.1",
"workbox-cacheable-response": "^4.0.0-beta.1",
"workbox-core": "^4.0.0-beta.1",
"workbox-google-analytics": "^4.0.0-beta.1",
"workbox-navigation-preload": "^4.0.0-beta.1",
"workbox-precaching": "^4.0.0-beta.1",
"workbox-range-requests": "^4.0.0-beta.1",
"workbox-routing": "^4.0.0-beta.1",
"workbox-strategies": "^4.0.0-beta.1",
"workbox-streams": "^4.0.0-beta.1",
"workbox-sw": "^4.0.0-beta.1"
},

@@ -56,3 +56,3 @@ "main": "build/index.js",

},
"gitHead": "bc90cc4bdb1f8ad435564aa84b0c90acfac611e2"
"gitHead": "dda07c48e184f57ce5dfe3b3e93af316989a0877"
}

@@ -5,3 +5,3 @@ {

"releasesDir": "releases",
"latestVersion": "4.0.0-beta.0"
"latestVersion": "4.0.0-beta.1"
}

@@ -9,2 +9,4 @@ /*

const checkForDeprecatedOptions =
require('../lib/check-for-deprecated-options');
const generateSWStringSchema = require('./options/generate-sw-string-schema');

@@ -29,2 +31,6 @@ const getFileManifestEntries = require('../lib/get-file-manifest-entries');

async function generateSWString(config) {
// This check needs to be done before validation, since the deprecated options
// will be renamed.
const deprecationWarnings = checkForDeprecatedOptions(config);
const options = validate(config, generateSWStringSchema);

@@ -38,2 +44,5 @@

// Add in any deprecation warnings.
warnings.push(...deprecationWarnings);
return {swString, warnings};

@@ -40,0 +49,0 @@ }

@@ -12,2 +12,4 @@ /*

const cdnUtils = require('../lib/cdn-utils');
const checkForDeprecatedOptions =
require('../lib/check-for-deprecated-options');
const copyWorkboxLibraries = require('../lib/copy-workbox-libraries');

@@ -42,2 +44,6 @@ const generateSWSchema = require('./options/generate-sw-schema');

async function generateSW(config) {
// This check needs to be done before validation, since the deprecated options
// will be renamed.
const deprecationWarnings = checkForDeprecatedOptions(config);
const options = validate(config, generateSWSchema);

@@ -49,4 +55,4 @@

if (options.importWorkboxFrom === 'cdn') {
const cdnUrl = cdnUtils.getModuleUrl('workbox-sw');
options.workboxSWImport = cdnUrl;
const cdnURL = cdnUtils.getModuleURL('workbox-sw');
options.workboxSWImport = cdnURL;
} else if (options.importWorkboxFrom === 'local') {

@@ -76,2 +82,5 @@ // Copy over the dev + prod version of all of the core libraries.

// Add in any deprecation warnings.
warnings.push(...deprecationWarnings);
return {count, size, warnings};

@@ -78,0 +87,0 @@ }

@@ -9,2 +9,4 @@ /*

const checkForDeprecatedOptions =
require('../lib/check-for-deprecated-options');
const getFileManifestEntries = require('../lib/get-file-manifest-entries');

@@ -32,2 +34,6 @@ const getManifestSchema = require('./options/get-manifest-schema');

async function getManifest(config) {
// This check needs to be done before validation, since the deprecated options
// will be renamed.
const deprecationWarnings = checkForDeprecatedOptions(config);
const options = validate(config, getManifestSchema);

@@ -37,2 +43,6 @@

await getFileManifestEntries(options);
// Add in any deprecation warnings.
warnings.push(...deprecationWarnings);
return {manifestEntries, count, size, warnings};

@@ -39,0 +49,0 @@ }

@@ -13,2 +13,4 @@ /*

const checkForDeprecatedOptions =
require('../lib/check-for-deprecated-options');
const defaults = require('./options/defaults');

@@ -42,2 +44,6 @@ const errors = require('../lib/errors');

async function injectManifest(config) {
// This check needs to be done before validation, since the deprecated options
// will be renamed.
const deprecationWarnings = checkForDeprecatedOptions(config);
const options = validate(config, injectManifestSchema);

@@ -84,2 +90,5 @@

// Add in any deprecation warnings.
warnings.push(...deprecationWarnings);
return {count, size, warnings};

@@ -86,0 +95,0 @@ }

@@ -14,5 +14,5 @@ /*

// Define some common constrains used by all methods.
// Define some common constraints used by all methods.
module.exports = joi.object().keys({
dontCacheBustUrlsMatching: regExpObject,
dontCacheBustURLsMatching: regExpObject,
globFollow: joi.boolean().default(defaults.globFollow),

@@ -25,7 +25,7 @@ globIgnores: joi.array().items(joi.string()).default(defaults.globIgnores),

.default(defaults.maximumFileSizeToCacheInBytes),
modifyUrlPrefix: joi.object(),
// templatedUrls is an object where any property name is valid, and the values
modifyURLPrefix: joi.object(),
// 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(/./,
templatedURLs: joi.object().pattern(/./,
[joi.string(), joi.array().items(joi.string())]),
});

@@ -20,3 +20,3 @@ /*

directoryIndex: joi.string(),
ignoreUrlParametersMatching: joi.array().items(regExpObject),
ignoreURLParametersMatching: joi.array().items(regExpObject),
navigateFallback: joi.string().default(defaults.navigateFallback),

@@ -36,10 +36,12 @@ navigateFallbackBlacklist: joi.array().items(regExpObject),

),
urlPattern: [regExpObject, joi.string()],
handler: [joi.func(), joi.string().valid(
'cacheFirst',
'cacheOnly',
'networkFirst',
'networkOnly',
'staleWhileRevalidate'
)],
urlPattern: [regExpObject, joi.string(), joi.func()],
handler: [
joi.func(),
joi.string().valid(
'CacheFirst',
'CacheOnly',
'NetworkFirst',
'NetworkOnly',
'StaleWhileRevalidate'),
],
options: joi.object().keys({

@@ -71,2 +73,5 @@ backgroundSync: joi.object().keys({

skipWaiting: joi.boolean().default(defaults.skipWaiting),
}).rename('ignoreUrlParametersMatching', 'ignoreURLParametersMatching', {
ignoreUndefined: true,
override: true,
});

@@ -16,3 +16,3 @@ /*

importWorkboxFrom: 'cdn',
injectionPointRegexp: /(\.precacheAndRoute\()\s*\[\s*\]\s*(\)|,)/,
injectionPointRegexp: /(precacheAndRoute\()\s*\[\s*\]\s*(\)|,)/,
maximumFileSizeToCacheInBytes: 2 * 1024 * 1024,

@@ -19,0 +19,0 @@ navigateFallback: undefined,

@@ -14,3 +14,3 @@ /*

const injectManifest = require('./entry-points/inject-manifest');
const {getModuleUrl} = require('./lib/cdn-utils');
const {getModuleURL} = require('./lib/cdn-utils');

@@ -40,3 +40,3 @@ /**

*
* @property {Array<RegExp>} [ignoreUrlParametersMatching=[/^utm_/]] Any
* @property {Array<RegExp>} [ignoreURLParametersMatching=[/^utm_/]] Any
* search parameter names that match against one of the regex's in this array

@@ -80,4 +80,4 @@ * will be removed before looking for a precache match.

getManifest,
getModuleUrl,
getModuleURL,
injectManifest,
};

@@ -18,7 +18,7 @@ /*

const getVersionedCDNUrl = () => {
const getVersionedCDNURL = () => {
return `${getCDNOrigin()}/${cdn.latestVersion}`;
};
const getModuleUrl = (moduleName, buildType) => {
const getModuleURL = (moduleName, buildType) => {
assert(moduleName, errors['no-module-name']);

@@ -33,5 +33,5 @@

}
return `${getVersionedCDNUrl()}/${moduleName}.${buildType.slice(0, 4)}.js`;
return `${getVersionedCDNURL()}/${moduleName}.${buildType.slice(0, 4)}.js`;
}
return `${getVersionedCDNUrl()}/${moduleName}.js`;
return `${getVersionedCDNURL()}/${moduleName}.js`;
};

@@ -41,3 +41,3 @@

getCDNOrigin,
getModuleUrl,
getModuleURL,
};

@@ -45,3 +45,3 @@ /*

string.`,
'invalid-dont-cache-bust': ol`The supplied 'dontCacheBustUrlsMatching'
'invalid-dont-cache-bust': ol`The supplied 'dontCacheBustURLsMatching'
parameter must be a RegExp.`,

@@ -59,5 +59,5 @@ 'invalid-exclude-files': 'The excluded files should be an array of strings.',

of strings.`,
'invalid-templated-urls': ol`The 'templatedUrls' value should be an object
'invalid-templated-urls': ol`The 'templatedURLs' value should be an object
that maps URLs to either a string, or to an array of glob patterns.`,
'templated-url-matches-glob': ol`One of the 'templatedUrls' URLs is already
'templated-url-matches-glob': ol`One of the 'templatedURLs' URLs is already
being tracked via 'globPatterns': `,

@@ -68,3 +68,3 @@ 'invalid-glob-ignores': ol`The 'globIgnores' parameter must be an array of

a URL string. This is likely an error with workbox-build.`,
'modify-url-prefix-bad-prefixes': ol`The 'modifyUrlPrefix' parameter must be
'modify-url-prefix-bad-prefixes': ol`The 'modifyURLPrefix' parameter must be
an object with string key value pairs.`,

@@ -82,3 +82,3 @@ 'invalid-inject-manifest-arg': ol`The input to 'injectManifest()' must be an

'bad-template-urls-asset': ol`There was an issue using one of the provided
'templatedUrls'.`,
'templatedURLs'.`,
'invalid-runtime-caching': ol`The 'runtimeCaching' parameter must an an

@@ -88,4 +88,4 @@ array of objects with at least a 'urlPattern' and 'handler'.`,

Please use 'globPatterns' instead.`,
'dynamic-url-deprecated': ol`'dynamicUrlToDependencies' is deprecated.
Please use 'templatedUrls' instead.`,
'dynamic-url-deprecated': ol`'dynamicURLToDependencies' is deprecated.
Please use 'templatedURLs' instead.`,
'urlPattern-is-required': ol`The 'urlPattern' option is required when using

@@ -106,5 +106,5 @@ 'runtimeCaching'.`,

'invalid-network-timeout-seconds': ol`When using networkTimeoutSeconds, you
must set the handler to 'networkFirst'.`,
must set the handler to 'NetworkFirst'.`,
'no-module-name': ol`You must provide a moduleName parameter when calling
getModuleUrl().`,
getModuleURL().`,
};

@@ -10,4 +10,4 @@ /*

const maximumSizeTransform = require('./maximum-size-transform');
const modifyUrlPrefixTranform = require('./modify-url-prefix-transform');
const noRevisionForUrlsMatchingTransform =
const modifyURLPrefixTranform = require('./modify-url-prefix-transform');
const noRevisionForURLsMatchingTransform =
require('./no-revision-for-urls-matching-transform');

@@ -66,7 +66,7 @@

module.exports = ({
dontCacheBustUrlsMatching,
dontCacheBustURLsMatching,
fileDetails,
manifestTransforms,
maximumFileSizeToCacheInBytes,
modifyUrlPrefix,
modifyURLPrefix,
}) => {

@@ -91,9 +91,9 @@ let allWarnings = [];

if (modifyUrlPrefix) {
transformsToApply.push(modifyUrlPrefixTranform(modifyUrlPrefix));
if (modifyURLPrefix) {
transformsToApply.push(modifyURLPrefixTranform(modifyURLPrefix));
}
if (dontCacheBustUrlsMatching) {
if (dontCacheBustURLsMatching) {
transformsToApply.push(
noRevisionForUrlsMatchingTransform(dontCacheBustUrlsMatching));
noRevisionForURLsMatchingTransform(dontCacheBustURLsMatching));
}

@@ -100,0 +100,0 @@

@@ -11,3 +11,3 @@ /*

module.exports = (compositeUrl, dependencyDetails) => {
module.exports = (compositeURL, dependencyDetails) => {
let totalSize = 0;

@@ -26,3 +26,3 @@ let compositeHash = '';

return {
file: compositeUrl,
file: compositeURL,
hash: hashOfHashes,

@@ -29,0 +29,0 @@ size: totalSize,

@@ -19,3 +19,3 @@ /*

module.exports = async ({
dontCacheBustUrlsMatching,
dontCacheBustURLsMatching,
globDirectory,

@@ -28,5 +28,5 @@ globFollow,

maximumFileSizeToCacheInBytes,
modifyUrlPrefix,
modifyURLPrefix,
swDest,
templatedUrls,
templatedURLs,
}) => {

@@ -72,7 +72,7 @@ const warnings = [];

if (templatedUrls) {
for (let url of Object.keys(templatedUrls)) {
if (templatedURLs) {
for (let url of Object.keys(templatedURLs)) {
assert(!fileSet.has(url), errors['templated-url-matches-glob']);
const dependencies = templatedUrls[url];
const dependencies = templatedURLs[url];
if (Array.isArray(dependencies)) {

@@ -105,3 +105,3 @@ const details = dependencies.reduce((previous, globPattern) => {

const filteredFiles = filterFiles({fileDetails,
maximumFileSizeToCacheInBytes, modifyUrlPrefix, dontCacheBustUrlsMatching,
maximumFileSizeToCacheInBytes, modifyURLPrefix, dontCacheBustURLsMatching,
manifestTransforms});

@@ -108,0 +108,0 @@

@@ -29,17 +29,17 @@ /*

module.exports = (modifyUrlPrefix) => {
if (!modifyUrlPrefix ||
typeof modifyUrlPrefix !== 'object' ||
Array.isArray(modifyUrlPrefix)) {
module.exports = (modifyURLPrefix) => {
if (!modifyURLPrefix ||
typeof modifyURLPrefix !== 'object' ||
Array.isArray(modifyURLPrefix)) {
throw new Error(errors['modify-url-prefix-bad-prefixes']);
}
// If there are no entries in modifyUrlPrefix, just return an identity
// If there are no entries in modifyURLPrefix, just return an identity
// function as a shortcut.
if (Object.keys(modifyUrlPrefix).length === 0) {
if (Object.keys(modifyURLPrefix).length === 0) {
return (entry) => entry;
}
Object.keys(modifyUrlPrefix).forEach((key) => {
if (typeof modifyUrlPrefix[key] !== 'string') {
Object.keys(modifyURLPrefix).forEach((key) => {
if (typeof modifyURLPrefix[key] !== 'string') {
throw new Error(errors['modify-url-prefix-bad-prefixes']);

@@ -50,5 +50,5 @@ }

// Escape the user input so it's safe to use in a regex.
const safeModifyUrlPrefixes = Object.keys(modifyUrlPrefix).map(escapeRegExp);
// Join all the `modifyUrlPrefix` keys so a single regex can be used.
const prefixMatchesStrings = safeModifyUrlPrefixes.join('|');
const safeModifyURLPrefixes = Object.keys(modifyURLPrefix).map(escapeRegExp);
// Join all the `modifyURLPrefix` keys so a single regex can be used.
const prefixMatchesStrings = safeModifyURLPrefixes.join('|');
// Add `^` to the front the prefix matches so it only matches the start of

@@ -65,3 +65,3 @@ // a string.

entry.url = entry.url.replace(modifyRegex, (match) => {
return modifyUrlPrefix[match];
return modifyURLPrefix[match];
});

@@ -68,0 +68,0 @@

@@ -20,3 +20,3 @@ /*

directoryIndex,
ignoreUrlParametersMatching,
ignoreURLParametersMatching,
importScripts,

@@ -38,3 +38,3 @@ manifestEntries,

// default behavior, so if it's given, convert it manually.
ignoreUrlParametersMatching: ignoreUrlParametersMatching ?
ignoreURLParametersMatching: ignoreURLParametersMatching ?
[] :

@@ -45,7 +45,7 @@ undefined,

let precacheOptionsString = JSON.stringify(precacheOptions, null, 2);
if (ignoreUrlParametersMatching) {
if (ignoreURLParametersMatching) {
precacheOptionsString = precacheOptionsString.replace(
`"ignoreUrlParametersMatching": []`,
`"ignoreUrlParametersMatching": [` +
`${ignoreUrlParametersMatching.join(', ')}]`
`"ignoreURLParametersMatching": []`,
`"ignoreURLParametersMatching": [` +
`${ignoreURLParametersMatching.join(', ')}]`
);

@@ -52,0 +52,0 @@ }

@@ -19,3 +19,3 @@ /*

* @param {Object} options See
* https://googlechrome.github.io/sw-toolbox/api.html#options
* https://googlechromelabs.github.io/sw-toolbox/api.html#options
* @return {string} A JSON string representing the equivalent options.

@@ -36,4 +36,8 @@ *

// passed as options to the handler constructor instead.
const handlerOptionKeys =
['cacheName', 'networkTimeoutSeconds', 'fetchOptions', 'matchOptions'];
const handlerOptionKeys = [
'cacheName',
'networkTimeoutSeconds',
'fetchOptions',
'matchOptions',
];
const handlerOptions = {};

@@ -73,3 +77,3 @@ for (const key of handlerOptionKeys) {

if ('options' in pluginConfig) {
pluginCode += `, ${JSON.stringify(pluginConfig.options)}`;
pluginCode += `, ${stringifyWithoutComments(pluginConfig.options)}`;
}

@@ -85,3 +89,3 @@ pluginCode += `)`;

if ('options' in pluginConfig) {
pluginCode += `, ${JSON.stringify(pluginConfig.options)}`;
pluginCode += `, ${stringifyWithoutComments(pluginConfig.options)}`;
}

@@ -96,3 +100,5 @@ pluginCode += `)`;

default: {
pluginCode = `new ${pluginString}(${JSON.stringify(pluginConfig)})`;
pluginCode = `new ${pluginString}(${stringifyWithoutComments(
pluginConfig
)})`;
}

@@ -130,9 +136,8 @@ }

if (entry.options && entry.options.networkTimeoutSeconds &&
entry.handler !== 'networkFirst') {
entry.handler !== 'NetworkFirst') {
throw new Error(errors['invalid-network-timeout-seconds']);
}
// urlPattern might be either a string or a RegExp object.
// If it's a string, it needs to be quoted. If it's a RegExp, it should
// be used as-is.
// urlPattern might be a string, a RegExp object, or a function.
// If it's a string, it needs to be quoted.
const matcher = typeof entry.urlPattern === 'string' ?

@@ -144,5 +149,4 @@ JSON.stringify(entry.urlPattern) :

const optionsString = getOptionsString(entry.options || {});
const strategyString =
`workbox.strategies.${entry.handler}(${optionsString})`;
`new workbox.strategies.${entry.handler}(${optionsString})`;

@@ -149,0 +153,0 @@ return `workbox.routing.registerRoute(` +

@@ -14,4 +14,5 @@ /*

return objectStringify(obj, {
transform: (_obj, _prop, str) => stripComments(str),
transform: (_obj, _prop, str) =>
typeof _obj[_prop] === 'function' ? stripComments(str) : str,
});
};

@@ -20,3 +20,3 @@ /*

handleFetch,
ignoreUrlParametersMatching,
ignoreURLParametersMatching,
importScripts,

@@ -46,3 +46,3 @@ manifestEntries,

handleFetch,
ignoreUrlParametersMatching,
ignoreURLParametersMatching,
importScripts,

@@ -49,0 +49,0 @@ manifestEntries,

@@ -34,4 +34,4 @@ /*

<% if (skipWaiting) { %>workbox.skipWaiting();<% } %>
<% if (clientsClaim) { %>workbox.clientsClaim();<% } %>
<% if (skipWaiting) { %>workbox.core.skipWaiting();<% } %>
<% if (clientsClaim) { %>workbox.core.clientsClaim();<% } %>

@@ -45,7 +45,5 @@ <% if (Array.isArray(manifestEntries)) {%>

self.__precacheManifest = <%= JSON.stringify(manifestEntries, null, 2) %>.concat(self.__precacheManifest || []);
workbox.precaching.suppressWarnings();
workbox.precaching.precacheAndRoute(self.__precacheManifest, <%= precacheOptionsString %>);
<% } else { %>
if (Array.isArray(self.__precacheManifest)) {
workbox.precaching.suppressWarnings();
workbox.precaching.precacheAndRoute(self.__precacheManifest, <%= precacheOptionsString %>);

@@ -52,0 +50,0 @@ }

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc