WIP - add extractor, generate snippet_data
This commit is contained in:
50
node_modules/workbox-build/build/lib/cdn-utils.js
generated
vendored
Normal file
50
node_modules/workbox-build/build/lib/cdn-utils.js
generated
vendored
Normal file
@ -0,0 +1,50 @@
|
||||
'use strict';
|
||||
|
||||
/*
|
||||
Copyright 2017 Google Inc.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
https://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
var assert = require('assert');
|
||||
|
||||
var cdn = require('../cdn-details.json');
|
||||
var errors = require('./errors');
|
||||
|
||||
var getCDNOrigin = function getCDNOrigin() {
|
||||
return `${cdn.origin}/${cdn.bucketName}/${cdn.releasesDir}`;
|
||||
};
|
||||
|
||||
var getVersionedCDNUrl = function getVersionedCDNUrl() {
|
||||
return `${getCDNOrigin()}/${cdn.latestVersion}`;
|
||||
};
|
||||
|
||||
var getModuleUrl = function getModuleUrl(moduleName, buildType) {
|
||||
assert(moduleName, errors['no-module-name']);
|
||||
|
||||
if (buildType) {
|
||||
var 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
|
||||
};
|
||||
240
node_modules/workbox-build/build/lib/copy-workbox-libraries.js
generated
vendored
Normal file
240
node_modules/workbox-build/build/lib/copy-workbox-libraries.js
generated
vendored
Normal file
@ -0,0 +1,240 @@
|
||||
'use strict';
|
||||
|
||||
var _regenerator = require('babel-runtime/regenerator');
|
||||
|
||||
var _regenerator2 = _interopRequireDefault(_regenerator);
|
||||
|
||||
var _getIterator2 = require('babel-runtime/core-js/get-iterator');
|
||||
|
||||
var _getIterator3 = _interopRequireDefault(_getIterator2);
|
||||
|
||||
var _promise = require('babel-runtime/core-js/promise');
|
||||
|
||||
var _promise2 = _interopRequireDefault(_promise);
|
||||
|
||||
var _keys = require('babel-runtime/core-js/object/keys');
|
||||
|
||||
var _keys2 = _interopRequireDefault(_keys);
|
||||
|
||||
var _asyncToGenerator2 = require('babel-runtime/helpers/asyncToGenerator');
|
||||
|
||||
var _asyncToGenerator3 = _interopRequireDefault(_asyncToGenerator2);
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
/*
|
||||
Copyright 2017 Google Inc.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
https://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
var fse = require('fs-extra');
|
||||
var path = require('path');
|
||||
|
||||
var errors = require('./errors');
|
||||
var useBuildType = require('./use-build-type');
|
||||
|
||||
// Used to filter the libraries to copy based on our package.json dependencies.
|
||||
var WORKBOX_PREFIX = 'workbox-';
|
||||
var BUILD_TYPES = ['dev', 'prod'];
|
||||
|
||||
/**
|
||||
* This copies over a set of runtime libraries used by Workbox into a
|
||||
* local directory, which should be deployed alongside your service worker file.
|
||||
*
|
||||
* As an alternative to deploying these local copies, you could instead use
|
||||
* Workbox from its official CDN URL.
|
||||
*
|
||||
* This method is exposed for the benefit of developers using
|
||||
* [injectManifest()]{@link module:workbox-build.injectManifest} who would
|
||||
* prefer not to use the CDN copies of Workbox. Developers using
|
||||
* [generateSW()]{@link module:workbox-build.generateSW} don't need to
|
||||
* explicitly call this method, as it's called automatically when
|
||||
* `importWorkboxFrom` is set to `local`.
|
||||
*
|
||||
* @param {string} destDirectory The path to the parent directory under which
|
||||
* the new directory of libraries will be created.
|
||||
* @return {Promise<string>} The name of the newly created directory.
|
||||
*
|
||||
* @alias module:workbox-build.copyWorkboxLibraries
|
||||
*/
|
||||
module.exports = function () {
|
||||
var _ref = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee(destDirectory) {
|
||||
var thisPkg, workboxDirectoryName, workboxDirectoryPath, copyPromises, librariesToCopy, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, library, pkg, defaultPathToLibrary, _iteratorNormalCompletion2, _didIteratorError2, _iteratorError2, _iterator2, _step2, buildType, srcPath, destPath;
|
||||
|
||||
return _regenerator2.default.wrap(function _callee$(_context) {
|
||||
while (1) {
|
||||
switch (_context.prev = _context.next) {
|
||||
case 0:
|
||||
thisPkg = 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
|
||||
// care about versioning the dependent libraries.
|
||||
|
||||
workboxDirectoryName = `workbox-v${thisPkg.version}`;
|
||||
workboxDirectoryPath = path.join(destDirectory, workboxDirectoryName);
|
||||
_context.next = 5;
|
||||
return fse.ensureDir(workboxDirectoryPath);
|
||||
|
||||
case 5:
|
||||
copyPromises = [];
|
||||
librariesToCopy = (0, _keys2.default)(thisPkg.dependencies).filter(function (dependency) {
|
||||
return dependency.startsWith(WORKBOX_PREFIX);
|
||||
});
|
||||
_iteratorNormalCompletion = true;
|
||||
_didIteratorError = false;
|
||||
_iteratorError = undefined;
|
||||
_context.prev = 10;
|
||||
_iterator = (0, _getIterator3.default)(librariesToCopy);
|
||||
|
||||
case 12:
|
||||
if (_iteratorNormalCompletion = (_step = _iterator.next()).done) {
|
||||
_context.next = 49;
|
||||
break;
|
||||
}
|
||||
|
||||
library = _step.value;
|
||||
pkg = require(`${library}/package.json`);
|
||||
defaultPathToLibrary = require.resolve(`${library}/${pkg.main}`);
|
||||
_iteratorNormalCompletion2 = true;
|
||||
_didIteratorError2 = false;
|
||||
_iteratorError2 = undefined;
|
||||
_context.prev = 19;
|
||||
_iterator2 = (0, _getIterator3.default)(BUILD_TYPES);
|
||||
|
||||
case 21:
|
||||
if (_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done) {
|
||||
_context.next = 32;
|
||||
break;
|
||||
}
|
||||
|
||||
buildType = _step2.value;
|
||||
|
||||
if (!(library === 'workbox-sw' && buildType === BUILD_TYPES[0])) {
|
||||
_context.next = 25;
|
||||
break;
|
||||
}
|
||||
|
||||
return _context.abrupt('continue', 29);
|
||||
|
||||
case 25:
|
||||
srcPath = useBuildType(defaultPathToLibrary, buildType);
|
||||
destPath = path.join(workboxDirectoryPath, path.basename(srcPath));
|
||||
|
||||
copyPromises.push(fse.copy(srcPath, destPath));
|
||||
copyPromises.push(fse.copy(`${srcPath}.map`, `${destPath}.map`));
|
||||
|
||||
case 29:
|
||||
_iteratorNormalCompletion2 = true;
|
||||
_context.next = 21;
|
||||
break;
|
||||
|
||||
case 32:
|
||||
_context.next = 38;
|
||||
break;
|
||||
|
||||
case 34:
|
||||
_context.prev = 34;
|
||||
_context.t0 = _context['catch'](19);
|
||||
_didIteratorError2 = true;
|
||||
_iteratorError2 = _context.t0;
|
||||
|
||||
case 38:
|
||||
_context.prev = 38;
|
||||
_context.prev = 39;
|
||||
|
||||
if (!_iteratorNormalCompletion2 && _iterator2.return) {
|
||||
_iterator2.return();
|
||||
}
|
||||
|
||||
case 41:
|
||||
_context.prev = 41;
|
||||
|
||||
if (!_didIteratorError2) {
|
||||
_context.next = 44;
|
||||
break;
|
||||
}
|
||||
|
||||
throw _iteratorError2;
|
||||
|
||||
case 44:
|
||||
return _context.finish(41);
|
||||
|
||||
case 45:
|
||||
return _context.finish(38);
|
||||
|
||||
case 46:
|
||||
_iteratorNormalCompletion = true;
|
||||
_context.next = 12;
|
||||
break;
|
||||
|
||||
case 49:
|
||||
_context.next = 55;
|
||||
break;
|
||||
|
||||
case 51:
|
||||
_context.prev = 51;
|
||||
_context.t1 = _context['catch'](10);
|
||||
_didIteratorError = true;
|
||||
_iteratorError = _context.t1;
|
||||
|
||||
case 55:
|
||||
_context.prev = 55;
|
||||
_context.prev = 56;
|
||||
|
||||
if (!_iteratorNormalCompletion && _iterator.return) {
|
||||
_iterator.return();
|
||||
}
|
||||
|
||||
case 58:
|
||||
_context.prev = 58;
|
||||
|
||||
if (!_didIteratorError) {
|
||||
_context.next = 61;
|
||||
break;
|
||||
}
|
||||
|
||||
throw _iteratorError;
|
||||
|
||||
case 61:
|
||||
return _context.finish(58);
|
||||
|
||||
case 62:
|
||||
return _context.finish(55);
|
||||
|
||||
case 63:
|
||||
_context.prev = 63;
|
||||
_context.next = 66;
|
||||
return _promise2.default.all(copyPromises);
|
||||
|
||||
case 66:
|
||||
return _context.abrupt('return', workboxDirectoryName);
|
||||
|
||||
case 69:
|
||||
_context.prev = 69;
|
||||
_context.t2 = _context['catch'](63);
|
||||
throw Error(`${errors['unable-to-copy-workbox-libraries']} ${_context.t2}`);
|
||||
|
||||
case 72:
|
||||
case 'end':
|
||||
return _context.stop();
|
||||
}
|
||||
}
|
||||
}, _callee, undefined, [[10, 51, 55, 63], [19, 34, 38, 46], [39,, 41, 45], [56,, 58, 62], [63, 69]]);
|
||||
}));
|
||||
|
||||
return function (_x) {
|
||||
return _ref.apply(this, arguments);
|
||||
};
|
||||
}();
|
||||
113
node_modules/workbox-build/build/lib/errors.js
generated
vendored
Normal file
113
node_modules/workbox-build/build/lib/errors.js
generated
vendored
Normal file
@ -0,0 +1,113 @@
|
||||
'use strict';
|
||||
|
||||
/*
|
||||
Copyright 2017 Google Inc.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
https://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
var ol = require('common-tags').oneLine;
|
||||
|
||||
module.exports = {
|
||||
'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.`,
|
||||
'invalid-file-manifest-name': ol`The File Manifest Name must have at least one
|
||||
character.`,
|
||||
'unable-to-get-file-manifest-name': 'Unable to get a file manifest name.',
|
||||
'invalid-sw-dest': `The 'swDest' value must be a valid path.`,
|
||||
'unable-to-get-sw-name': 'Unable to get a service worker file name.',
|
||||
'unable-to-get-save-config': ol`An error occurred when asking to save details
|
||||
in a config file.`,
|
||||
'unable-to-get-file-hash': ol`An error occurred when attempting to create a
|
||||
file hash.`,
|
||||
'unable-to-get-file-size': ol`An error occurred when attempting to get a file
|
||||
size.`,
|
||||
'unable-to-glob-files': 'An error occurred when globbing for files.',
|
||||
'unable-to-make-manifest-directory': ol`Unable to make output directory for
|
||||
file manifest.`,
|
||||
'read-manifest-template-failure': 'Unable to read template for file manifest',
|
||||
'populating-manifest-tmpl-failed': ol`An error occurred when populating the
|
||||
file manifest template.`,
|
||||
'manifest-file-write-failure': 'Unable to write the file manifest.',
|
||||
'unable-to-make-sw-directory': ol`Unable to make the directories to output
|
||||
the service worker path.`,
|
||||
'read-sw-template-failure': ol`Unable to read the service worker template
|
||||
file.`,
|
||||
'sw-write-failure': 'Unable to write the service worker file.',
|
||||
'sw-write-failure-directory': ol`Unable to write the service worker file;
|
||||
'swDest' should be a full path to the file, not a path to a directory.`,
|
||||
'unable-to-copy-workbox-libraries': ol`One or more of the Workbox libraries
|
||||
could not be copied over to the destination directory: `,
|
||||
'invalid-generate-sw-input': ol`The input to generateSW() must be an object.`,
|
||||
'invalid-glob-directory': ol`The supplied globDirectory must be a path as a
|
||||
string.`,
|
||||
'invalid-dont-cache-bust': ol`The supplied 'dontCacheBustUrlsMatching'
|
||||
parameter must be a RegExp.`,
|
||||
'invalid-exclude-files': 'The excluded files should be an array of strings.',
|
||||
'invalid-get-manifest-entries-input': ol`The input to
|
||||
'getFileManifestEntries()' must be an object.`,
|
||||
'invalid-manifest-path': ol`The supplied manifest path is not a string with
|
||||
at least one character.`,
|
||||
'invalid-manifest-entries': ol`The manifest entries must be an array of
|
||||
strings or JavaScript objects containing a url parameter.`,
|
||||
'invalid-manifest-format': ol`The value of the 'format' option passed to
|
||||
generateFileManifest() must be either 'iife' (the default) or 'es'.`,
|
||||
'invalid-static-file-globs': ol`The 'globPatterns' value must be an array
|
||||
of strings.`,
|
||||
'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
|
||||
being tracked via 'globPatterns': `,
|
||||
'invalid-glob-ignores': ol`The 'globIgnores' parameter must be an array of
|
||||
glob pattern strings.`,
|
||||
'manifest-entry-bad-url': ol`The generated manifest contains an entry without
|
||||
a URL string. This is likely an error with workbox-build.`,
|
||||
'modify-url-prefix-bad-prefixes': ol`The 'modifyUrlPrefix' parameter must be
|
||||
an object with string key value pairs.`,
|
||||
'invalid-inject-manifest-arg': ol`The input to 'injectManifest()' must be an
|
||||
object.`,
|
||||
'injection-point-not-found': ol`Unable to find a place to inject the manifest.
|
||||
Please ensure that your service worker file contains the following: `,
|
||||
'multiple-injection-points': ol`Please ensure that your 'swSrc' file contains
|
||||
only one match for the RegExp:`,
|
||||
'populating-sw-tmpl-failed': ol`Unable to generate service worker from
|
||||
template.`,
|
||||
'useless-glob-pattern': ol`One of the glob patterns doesn't match any files.
|
||||
Please remove or fix the following: `,
|
||||
'bad-template-urls-asset': ol`There was an issue using one of the provided
|
||||
'templatedUrls'.`,
|
||||
'invalid-runtime-caching': ol`The 'runtimeCaching' parameter must an an
|
||||
array of objects with at least a 'urlPattern' and 'handler'.`,
|
||||
'static-file-globs-deprecated': ol`'staticFileGlobs' is deprecated.
|
||||
Please use 'globPatterns' instead.`,
|
||||
'dynamic-url-deprecated': ol`'dynamicUrlToDependencies' is deprecated.
|
||||
Please use 'templatedUrls' instead.`,
|
||||
'urlPattern-is-required': ol`The 'urlPattern' option is required when using
|
||||
'runtimeCaching'.`,
|
||||
'handler-is-required': ol`The 'handler' option is required when using
|
||||
runtimeCaching.`,
|
||||
'invalid-generate-file-manifest-arg': ol`The input to generateFileManifest()
|
||||
must be an Object.`,
|
||||
'invalid-sw-src': `The 'swSrc' file can't be read.`,
|
||||
'same-src-and-dest': ol`'swSrc' and 'swDest' should not be set to the same ` + `file. Please use a different file path for 'swDest'.`,
|
||||
'only-regexp-routes-supported': ol`Please use a regular expression object as
|
||||
the urlPattern parameter. (Express-style routes are not currently
|
||||
supported.)`,
|
||||
'bad-runtime-caching-config': ol`An unknown configuration option was used
|
||||
with runtimeCaching:`,
|
||||
'invalid-network-timeout-seconds': ol`When using networkTimeoutSeconds, you
|
||||
must set the handler to 'networkFirst'.`,
|
||||
'no-module-name': ol`You must provide a moduleName parameter when calling
|
||||
getModuleUrl().`
|
||||
};
|
||||
183
node_modules/workbox-build/build/lib/filter-files.js
generated
vendored
Normal file
183
node_modules/workbox-build/build/lib/filter-files.js
generated
vendored
Normal file
@ -0,0 +1,183 @@
|
||||
'use strict';
|
||||
|
||||
var _getIterator2 = require('babel-runtime/core-js/get-iterator');
|
||||
|
||||
var _getIterator3 = _interopRequireDefault(_getIterator2);
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
/*
|
||||
Copyright 2017 Google Inc.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
https://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
var maximumSizeTransform = require('./maximum-size-transform');
|
||||
var modifyUrlPrefixTranform = require('./modify-url-prefix-transform');
|
||||
var noRevisionForUrlsMatchingTransform = require('./no-revision-for-urls-matching-transform');
|
||||
|
||||
/**
|
||||
* A `ManifestTransform` function can be used to modify the modify the `url` or
|
||||
* `revision` properties of some or all of the
|
||||
* {@link module:workbox-build#ManifestEntry|ManifestEntries} in the manifest.
|
||||
*
|
||||
* Deleting the `revision` property of an entry will cause
|
||||
* the corresponding `url` to be precached without cache-busting parameters
|
||||
* applied, which is to say, it implies that the URL itself contains
|
||||
* proper versioning info. If the `revision` property is present, it must be
|
||||
* set to a string.
|
||||
*
|
||||
* @example <caption>A transformation that prepended the origin of a CDN for any
|
||||
* URL starting with '/assets/' could be implemented as:</caption>
|
||||
*
|
||||
* const cdnTransform = (manifestEntries) => {
|
||||
* const manifest = manifestEntries.map(entry => {
|
||||
* const cdnOrigin = 'https://example.com';
|
||||
* if (entry.url.startsWith('/assets/')) {
|
||||
* entry.url = cdnOrigin + entry.url;
|
||||
* }
|
||||
* return entry;
|
||||
* });
|
||||
* return {manifest, warnings: []};
|
||||
* };
|
||||
*
|
||||
* @example <caption>A transformation that removes the revision field when the
|
||||
* URL contains an 8-character hash surrounded by '.', indicating that it
|
||||
* already contains revision information:</caption>
|
||||
*
|
||||
* const removeRevisionTransform = (manifestEntries) => {
|
||||
* const manifest = manifestEntries.map(entry => {
|
||||
* const hashRegExp = /\.\w{8}\./;
|
||||
* if (entry.url.match(hashRegExp)) {
|
||||
* delete entry.revision;
|
||||
* }
|
||||
* return entry;
|
||||
* });
|
||||
* return {manifest, warnings: []};
|
||||
* };
|
||||
*
|
||||
* @callback ManifestTransform
|
||||
* @param {Array<module:workbox-build.ManifestEntry>} manifestEntries The full
|
||||
* array of entries, prior to the current transformation.
|
||||
* @return {module:workbox-build.ManifestTransformResult}
|
||||
* The array of entries with the transformation applied, and optionally, any
|
||||
* warnings that should be reported back to the build tool.
|
||||
*
|
||||
* @memberof module:workbox-build
|
||||
*/
|
||||
|
||||
module.exports = function (_ref) {
|
||||
var dontCacheBustUrlsMatching = _ref.dontCacheBustUrlsMatching,
|
||||
fileDetails = _ref.fileDetails,
|
||||
manifestTransforms = _ref.manifestTransforms,
|
||||
maximumFileSizeToCacheInBytes = _ref.maximumFileSizeToCacheInBytes,
|
||||
modifyUrlPrefix = _ref.modifyUrlPrefix;
|
||||
|
||||
var allWarnings = [];
|
||||
|
||||
// Take the array of fileDetail objects and convert it into an array of
|
||||
// {url, revision, size} objects, with \ replaced with /.
|
||||
var normalizedManifest = fileDetails.map(function (fileDetails) {
|
||||
return {
|
||||
url: fileDetails.file.replace(/\\/g, '/'),
|
||||
revision: fileDetails.hash,
|
||||
size: fileDetails.size
|
||||
};
|
||||
});
|
||||
|
||||
var transformsToApply = [];
|
||||
|
||||
if (maximumFileSizeToCacheInBytes) {
|
||||
transformsToApply.push(maximumSizeTransform(maximumFileSizeToCacheInBytes));
|
||||
}
|
||||
|
||||
if (modifyUrlPrefix) {
|
||||
transformsToApply.push(modifyUrlPrefixTranform(modifyUrlPrefix));
|
||||
}
|
||||
|
||||
if (dontCacheBustUrlsMatching) {
|
||||
transformsToApply.push(noRevisionForUrlsMatchingTransform(dontCacheBustUrlsMatching));
|
||||
}
|
||||
|
||||
// Any additional manifestTransforms that were passed will be applied last.
|
||||
transformsToApply = transformsToApply.concat(manifestTransforms || []);
|
||||
|
||||
var transformedManifest = normalizedManifest;
|
||||
var _iteratorNormalCompletion = true;
|
||||
var _didIteratorError = false;
|
||||
var _iteratorError = undefined;
|
||||
|
||||
try {
|
||||
for (var _iterator = (0, _getIterator3.default)(transformsToApply), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
|
||||
var transform = _step.value;
|
||||
|
||||
var _transform = transform(transformedManifest),
|
||||
manifest = _transform.manifest,
|
||||
warnings = _transform.warnings;
|
||||
|
||||
transformedManifest = manifest;
|
||||
allWarnings = allWarnings.concat(warnings || []);
|
||||
}
|
||||
|
||||
// Generate some metadata about the manifest before we clear out the size
|
||||
// properties from each entry.
|
||||
} catch (err) {
|
||||
_didIteratorError = true;
|
||||
_iteratorError = err;
|
||||
} finally {
|
||||
try {
|
||||
if (!_iteratorNormalCompletion && _iterator.return) {
|
||||
_iterator.return();
|
||||
}
|
||||
} finally {
|
||||
if (_didIteratorError) {
|
||||
throw _iteratorError;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var count = transformedManifest.length;
|
||||
var size = 0;
|
||||
var _iteratorNormalCompletion2 = true;
|
||||
var _didIteratorError2 = false;
|
||||
var _iteratorError2 = undefined;
|
||||
|
||||
try {
|
||||
for (var _iterator2 = (0, _getIterator3.default)(transformedManifest), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {
|
||||
var manifestEntry = _step2.value;
|
||||
|
||||
size += manifestEntry.size;
|
||||
delete manifestEntry.size;
|
||||
}
|
||||
} catch (err) {
|
||||
_didIteratorError2 = true;
|
||||
_iteratorError2 = err;
|
||||
} finally {
|
||||
try {
|
||||
if (!_iteratorNormalCompletion2 && _iterator2.return) {
|
||||
_iterator2.return();
|
||||
}
|
||||
} finally {
|
||||
if (_didIteratorError2) {
|
||||
throw _iteratorError2;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
count,
|
||||
size,
|
||||
manifestEntries: transformedManifest,
|
||||
warnings: allWarnings
|
||||
};
|
||||
};
|
||||
66
node_modules/workbox-build/build/lib/get-composite-details.js
generated
vendored
Normal file
66
node_modules/workbox-build/build/lib/get-composite-details.js
generated
vendored
Normal file
@ -0,0 +1,66 @@
|
||||
'use strict';
|
||||
|
||||
var _getIterator2 = require('babel-runtime/core-js/get-iterator');
|
||||
|
||||
var _getIterator3 = _interopRequireDefault(_getIterator2);
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
/*
|
||||
Copyright 2017 Google Inc.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
https://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
var crypto = require('crypto');
|
||||
|
||||
module.exports = function (compositeUrl, dependencyDetails) {
|
||||
var totalSize = 0;
|
||||
var compositeHash = '';
|
||||
|
||||
var _iteratorNormalCompletion = true;
|
||||
var _didIteratorError = false;
|
||||
var _iteratorError = undefined;
|
||||
|
||||
try {
|
||||
for (var _iterator = (0, _getIterator3.default)(dependencyDetails), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
|
||||
var fileDetails = _step.value;
|
||||
|
||||
totalSize += fileDetails.size;
|
||||
compositeHash += fileDetails.hash;
|
||||
}
|
||||
} catch (err) {
|
||||
_didIteratorError = true;
|
||||
_iteratorError = err;
|
||||
} finally {
|
||||
try {
|
||||
if (!_iteratorNormalCompletion && _iterator.return) {
|
||||
_iterator.return();
|
||||
}
|
||||
} finally {
|
||||
if (_didIteratorError) {
|
||||
throw _iteratorError;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var md5 = crypto.createHash('md5');
|
||||
md5.update(compositeHash);
|
||||
var hashOfHashes = md5.digest('hex');
|
||||
|
||||
return {
|
||||
file: compositeUrl,
|
||||
hash: hashOfHashes,
|
||||
size: totalSize
|
||||
};
|
||||
};
|
||||
74
node_modules/workbox-build/build/lib/get-file-details.js
generated
vendored
Normal file
74
node_modules/workbox-build/build/lib/get-file-details.js
generated
vendored
Normal file
@ -0,0 +1,74 @@
|
||||
'use strict';
|
||||
|
||||
var _stringify = require('babel-runtime/core-js/json/stringify');
|
||||
|
||||
var _stringify2 = _interopRequireDefault(_stringify);
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
/*
|
||||
Copyright 2017 Google Inc.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
https://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
var glob = require('glob');
|
||||
var path = require('path');
|
||||
|
||||
var errors = require('./errors');
|
||||
var getFileSize = require('./get-file-size');
|
||||
var getFileHash = require('./get-file-hash');
|
||||
|
||||
module.exports = function (globOptions) {
|
||||
var globDirectory = globOptions.globDirectory,
|
||||
globFollow = globOptions.globFollow,
|
||||
globIgnores = globOptions.globIgnores,
|
||||
globPattern = globOptions.globPattern,
|
||||
globStrict = globOptions.globStrict;
|
||||
|
||||
var globbedFiles = void 0;
|
||||
try {
|
||||
globbedFiles = glob.sync(globPattern, {
|
||||
cwd: globDirectory,
|
||||
follow: globFollow,
|
||||
ignore: globIgnores,
|
||||
strict: globStrict
|
||||
});
|
||||
} catch (err) {
|
||||
throw new Error(errors['unable-to-glob-files'] + ` '${err.message}'`);
|
||||
}
|
||||
|
||||
if (globbedFiles.length === 0) {
|
||||
throw new Error(errors['useless-glob-pattern'] + ' ' + (0, _stringify2.default)({ globDirectory, globPattern, globIgnores }, null, 2));
|
||||
}
|
||||
|
||||
var fileDetails = globbedFiles.map(function (file) {
|
||||
var fullPath = path.join(globDirectory, file);
|
||||
var fileSize = getFileSize(fullPath);
|
||||
if (fileSize === null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
var fileHash = getFileHash(fullPath);
|
||||
return {
|
||||
file: `${path.relative(globDirectory, fullPath)}`,
|
||||
hash: fileHash,
|
||||
size: fileSize
|
||||
};
|
||||
});
|
||||
|
||||
// If !== null, means it's a valid file.
|
||||
return fileDetails.filter(function (details) {
|
||||
return details !== null;
|
||||
});
|
||||
};
|
||||
31
node_modules/workbox-build/build/lib/get-file-hash.js
generated
vendored
Normal file
31
node_modules/workbox-build/build/lib/get-file-hash.js
generated
vendored
Normal file
@ -0,0 +1,31 @@
|
||||
'use strict';
|
||||
|
||||
/*
|
||||
Copyright 2017 Google Inc.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
https://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
var fs = require('fs');
|
||||
|
||||
var getStringHash = require('./get-string-hash');
|
||||
var errors = require('./errors');
|
||||
|
||||
module.exports = function (file) {
|
||||
try {
|
||||
var buffer = fs.readFileSync(file);
|
||||
return getStringHash(buffer);
|
||||
} catch (err) {
|
||||
throw new Error(errors['unable-to-get-file-hash'] + ` '${err.message}'`);
|
||||
}
|
||||
};
|
||||
213
node_modules/workbox-build/build/lib/get-file-manifest-entries.js
generated
vendored
Normal file
213
node_modules/workbox-build/build/lib/get-file-manifest-entries.js
generated
vendored
Normal file
@ -0,0 +1,213 @@
|
||||
'use strict';
|
||||
|
||||
var _regenerator = require('babel-runtime/regenerator');
|
||||
|
||||
var _regenerator2 = _interopRequireDefault(_regenerator);
|
||||
|
||||
var _keys = require('babel-runtime/core-js/object/keys');
|
||||
|
||||
var _keys2 = _interopRequireDefault(_keys);
|
||||
|
||||
var _getIterator2 = require('babel-runtime/core-js/get-iterator');
|
||||
|
||||
var _getIterator3 = _interopRequireDefault(_getIterator2);
|
||||
|
||||
var _stringify = require('babel-runtime/core-js/json/stringify');
|
||||
|
||||
var _stringify2 = _interopRequireDefault(_stringify);
|
||||
|
||||
var _set = require('babel-runtime/core-js/set');
|
||||
|
||||
var _set2 = _interopRequireDefault(_set);
|
||||
|
||||
var _asyncToGenerator2 = require('babel-runtime/helpers/asyncToGenerator');
|
||||
|
||||
var _asyncToGenerator3 = _interopRequireDefault(_asyncToGenerator2);
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
/*
|
||||
Copyright 2017 Google Inc.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
https://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
var assert = require('assert');
|
||||
var path = require('path');
|
||||
|
||||
var errors = require('./errors');
|
||||
var filterFiles = require('./filter-files');
|
||||
var getCompositeDetails = require('./get-composite-details');
|
||||
var getFileDetails = require('./get-file-details');
|
||||
var getStringDetails = require('./get-string-details');
|
||||
|
||||
module.exports = function () {
|
||||
var _ref2 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee(_ref) {
|
||||
var dontCacheBustUrlsMatching = _ref.dontCacheBustUrlsMatching,
|
||||
globDirectory = _ref.globDirectory,
|
||||
globFollow = _ref.globFollow,
|
||||
globIgnores = _ref.globIgnores,
|
||||
globPatterns = _ref.globPatterns,
|
||||
globStrict = _ref.globStrict,
|
||||
manifestTransforms = _ref.manifestTransforms,
|
||||
maximumFileSizeToCacheInBytes = _ref.maximumFileSizeToCacheInBytes,
|
||||
modifyUrlPrefix = _ref.modifyUrlPrefix,
|
||||
swDest = _ref.swDest,
|
||||
templatedUrls = _ref.templatedUrls;
|
||||
|
||||
var warnings, fileDetails, fileSet, _loop, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, url, filteredFiles, _filteredFiles$warnin;
|
||||
|
||||
return _regenerator2.default.wrap(function _callee$(_context) {
|
||||
while (1) {
|
||||
switch (_context.prev = _context.next) {
|
||||
case 0:
|
||||
warnings = [];
|
||||
// Initialize to an empty array so that we can still pass something to
|
||||
// filterFiles() and get a normalized output.
|
||||
|
||||
fileDetails = [];
|
||||
fileSet = new _set2.default();
|
||||
|
||||
|
||||
if (globDirectory) {
|
||||
if (swDest) {
|
||||
// Ensure that we ignore the SW file we're eventually writing to disk.
|
||||
globIgnores.push(`**/${path.basename(swDest)}`);
|
||||
}
|
||||
|
||||
try {
|
||||
fileDetails = globPatterns.reduce(function (accumulated, globPattern) {
|
||||
var globbedFileDetails = getFileDetails({
|
||||
globDirectory,
|
||||
globFollow,
|
||||
globIgnores,
|
||||
globPattern,
|
||||
globStrict
|
||||
});
|
||||
|
||||
globbedFileDetails.forEach(function (fileDetails) {
|
||||
if (fileSet.has(fileDetails.file)) {
|
||||
return;
|
||||
}
|
||||
|
||||
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.
|
||||
warnings.push(error.message);
|
||||
}
|
||||
}
|
||||
|
||||
if (!templatedUrls) {
|
||||
_context.next = 25;
|
||||
break;
|
||||
}
|
||||
|
||||
_loop = function _loop(url) {
|
||||
assert(!fileSet.has(url), errors['templated-url-matches-glob']);
|
||||
|
||||
var dependencies = templatedUrls[url];
|
||||
if (Array.isArray(dependencies)) {
|
||||
var details = dependencies.reduce(function (previous, globPattern) {
|
||||
try {
|
||||
var globbedFileDetails = getFileDetails({
|
||||
globDirectory,
|
||||
globFollow,
|
||||
globIgnores,
|
||||
globPattern,
|
||||
globStrict
|
||||
});
|
||||
return previous.concat(globbedFileDetails);
|
||||
} catch (error) {
|
||||
var debugObj = {};
|
||||
debugObj[url] = dependencies;
|
||||
throw new Error(`${errors['bad-template-urls-asset']} ` + `'${globPattern}' from '${(0, _stringify2.default)(debugObj)}':\n` + error);
|
||||
}
|
||||
}, []);
|
||||
fileDetails.push(getCompositeDetails(url, details));
|
||||
} else if (typeof dependencies === 'string') {
|
||||
fileDetails.push(getStringDetails(url, dependencies));
|
||||
}
|
||||
};
|
||||
|
||||
_iteratorNormalCompletion = true;
|
||||
_didIteratorError = false;
|
||||
_iteratorError = undefined;
|
||||
_context.prev = 9;
|
||||
|
||||
for (_iterator = (0, _getIterator3.default)((0, _keys2.default)(templatedUrls)); !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
|
||||
url = _step.value;
|
||||
|
||||
_loop(url);
|
||||
}
|
||||
_context.next = 17;
|
||||
break;
|
||||
|
||||
case 13:
|
||||
_context.prev = 13;
|
||||
_context.t0 = _context['catch'](9);
|
||||
_didIteratorError = true;
|
||||
_iteratorError = _context.t0;
|
||||
|
||||
case 17:
|
||||
_context.prev = 17;
|
||||
_context.prev = 18;
|
||||
|
||||
if (!_iteratorNormalCompletion && _iterator.return) {
|
||||
_iterator.return();
|
||||
}
|
||||
|
||||
case 20:
|
||||
_context.prev = 20;
|
||||
|
||||
if (!_didIteratorError) {
|
||||
_context.next = 23;
|
||||
break;
|
||||
}
|
||||
|
||||
throw _iteratorError;
|
||||
|
||||
case 23:
|
||||
return _context.finish(20);
|
||||
|
||||
case 24:
|
||||
return _context.finish(17);
|
||||
|
||||
case 25:
|
||||
filteredFiles = filterFiles({ fileDetails,
|
||||
maximumFileSizeToCacheInBytes, modifyUrlPrefix, dontCacheBustUrlsMatching,
|
||||
manifestTransforms });
|
||||
|
||||
|
||||
if (warnings.length > 0) {
|
||||
(_filteredFiles$warnin = filteredFiles.warnings).push.apply(_filteredFiles$warnin, warnings);
|
||||
}
|
||||
|
||||
return _context.abrupt('return', filteredFiles);
|
||||
|
||||
case 28:
|
||||
case 'end':
|
||||
return _context.stop();
|
||||
}
|
||||
}
|
||||
}, _callee, undefined, [[9, 13, 17, 25], [18,, 20, 24]]);
|
||||
}));
|
||||
|
||||
return function (_x) {
|
||||
return _ref2.apply(this, arguments);
|
||||
};
|
||||
}();
|
||||
33
node_modules/workbox-build/build/lib/get-file-size.js
generated
vendored
Normal file
33
node_modules/workbox-build/build/lib/get-file-size.js
generated
vendored
Normal file
@ -0,0 +1,33 @@
|
||||
'use strict';
|
||||
|
||||
/*
|
||||
Copyright 2017 Google Inc.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
https://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
var fs = require('fs');
|
||||
|
||||
var errors = require('./errors');
|
||||
|
||||
module.exports = function (file) {
|
||||
try {
|
||||
var stat = fs.statSync(file);
|
||||
if (!stat.isFile()) {
|
||||
return null;
|
||||
}
|
||||
return stat.size;
|
||||
} catch (err) {
|
||||
throw new Error(errors['unable-to-get-file-size'] + ` '${err.message}'`);
|
||||
}
|
||||
};
|
||||
27
node_modules/workbox-build/build/lib/get-string-details.js
generated
vendored
Normal file
27
node_modules/workbox-build/build/lib/get-string-details.js
generated
vendored
Normal file
@ -0,0 +1,27 @@
|
||||
'use strict';
|
||||
|
||||
/*
|
||||
Copyright 2017 Google Inc.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
https://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
var getStringHash = require('./get-string-hash');
|
||||
|
||||
module.exports = function (url, string) {
|
||||
return {
|
||||
file: url,
|
||||
hash: getStringHash(string),
|
||||
size: string.length
|
||||
};
|
||||
};
|
||||
25
node_modules/workbox-build/build/lib/get-string-hash.js
generated
vendored
Normal file
25
node_modules/workbox-build/build/lib/get-string-hash.js
generated
vendored
Normal file
@ -0,0 +1,25 @@
|
||||
'use strict';
|
||||
|
||||
/*
|
||||
Copyright 2017 Google Inc.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
https://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
var crypto = require('crypto');
|
||||
|
||||
module.exports = function (string) {
|
||||
var md5 = crypto.createHash('md5');
|
||||
md5.update(string);
|
||||
return md5.digest('hex');
|
||||
};
|
||||
35
node_modules/workbox-build/build/lib/maximum-size-transform.js
generated
vendored
Normal file
35
node_modules/workbox-build/build/lib/maximum-size-transform.js
generated
vendored
Normal file
@ -0,0 +1,35 @@
|
||||
'use strict';
|
||||
|
||||
/*
|
||||
Copyright 2017 Google Inc.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
https://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
var prettyBytes = require('pretty-bytes');
|
||||
|
||||
module.exports = function (maximumFileSizeToCacheInBytes) {
|
||||
return function (originalManifest) {
|
||||
var warnings = [];
|
||||
var manifest = originalManifest.filter(function (entry) {
|
||||
if (entry.size <= maximumFileSizeToCacheInBytes) {
|
||||
return true;
|
||||
}
|
||||
|
||||
warnings.push(`${entry.url} is ${prettyBytes(entry.size)}, and won't ` + `be precached. Configure maximumFileSizeToCacheInBytes to change ` + `this limit.`);
|
||||
return false;
|
||||
});
|
||||
|
||||
return { manifest, warnings };
|
||||
};
|
||||
};
|
||||
87
node_modules/workbox-build/build/lib/modify-url-prefix-transform.js
generated
vendored
Normal file
87
node_modules/workbox-build/build/lib/modify-url-prefix-transform.js
generated
vendored
Normal file
@ -0,0 +1,87 @@
|
||||
'use strict';
|
||||
|
||||
var _keys = require('babel-runtime/core-js/object/keys');
|
||||
|
||||
var _keys2 = _interopRequireDefault(_keys);
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
/*
|
||||
Copyright 2017 Google Inc.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
https://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
var errors = require('./errors');
|
||||
|
||||
/**
|
||||
* Escaping user input to be treated as a literal string within a regular
|
||||
* expression can be accomplished by simple replacement.
|
||||
*
|
||||
* From https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions
|
||||
*
|
||||
* @private
|
||||
* @param {string} string The string to be used as part of a regular
|
||||
* expression
|
||||
* @return {string} A string that is safe to use in a regular
|
||||
* expression.
|
||||
*
|
||||
* @private
|
||||
*/
|
||||
var escapeRegExp = function escapeRegExp(string) {
|
||||
return string.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
||||
};
|
||||
|
||||
module.exports = function (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
|
||||
// function as a shortcut.
|
||||
if ((0, _keys2.default)(modifyUrlPrefix).length === 0) {
|
||||
return function (entry) {
|
||||
return entry;
|
||||
};
|
||||
}
|
||||
|
||||
(0, _keys2.default)(modifyUrlPrefix).forEach(function (key) {
|
||||
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.
|
||||
var safeModifyUrlPrefixes = (0, _keys2.default)(modifyUrlPrefix).map(escapeRegExp);
|
||||
// Join all the `modifyUrlPrefix` keys so a single regex can be used.
|
||||
var prefixMatchesStrings = safeModifyUrlPrefixes.join('|');
|
||||
// Add `^` to the front the prefix matches so it only matches the start of
|
||||
// a string.
|
||||
var modifyRegex = new RegExp(`^(${prefixMatchesStrings})`);
|
||||
|
||||
return function (originalManifest) {
|
||||
var manifest = originalManifest.map(function (entry) {
|
||||
if (typeof entry.url !== 'string') {
|
||||
throw new Error(errors['manifest-entry-bad-url']);
|
||||
}
|
||||
|
||||
entry.url = entry.url.replace(modifyRegex, function (match) {
|
||||
return modifyUrlPrefix[match];
|
||||
});
|
||||
|
||||
return entry;
|
||||
});
|
||||
|
||||
return { manifest };
|
||||
};
|
||||
};
|
||||
41
node_modules/workbox-build/build/lib/no-revision-for-urls-matching-transform.js
generated
vendored
Normal file
41
node_modules/workbox-build/build/lib/no-revision-for-urls-matching-transform.js
generated
vendored
Normal file
@ -0,0 +1,41 @@
|
||||
'use strict';
|
||||
|
||||
/*
|
||||
Copyright 2017 Google Inc.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
https://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
var errors = require('./errors');
|
||||
|
||||
module.exports = function (regexp) {
|
||||
if (!(regexp instanceof RegExp)) {
|
||||
throw new Error(errors['invalid-dont-cache-bust']);
|
||||
}
|
||||
|
||||
return function (originalManifest) {
|
||||
var manifest = originalManifest.map(function (entry) {
|
||||
if (typeof entry.url !== 'string') {
|
||||
throw new Error(errors['manifest-entry-bad-url']);
|
||||
}
|
||||
|
||||
if (entry.url.match(regexp)) {
|
||||
delete entry.revision;
|
||||
}
|
||||
|
||||
return entry;
|
||||
});
|
||||
|
||||
return { manifest };
|
||||
};
|
||||
};
|
||||
95
node_modules/workbox-build/build/lib/populate-sw-template.js
generated
vendored
Normal file
95
node_modules/workbox-build/build/lib/populate-sw-template.js
generated
vendored
Normal file
@ -0,0 +1,95 @@
|
||||
'use strict';
|
||||
|
||||
var _stringify = require('babel-runtime/core-js/json/stringify');
|
||||
|
||||
var _stringify2 = _interopRequireDefault(_stringify);
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
/*
|
||||
Copyright 2017 Google Inc.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
https://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
var template = require('lodash.template');
|
||||
var swTemplate = require('../templates/sw-template');
|
||||
|
||||
var errors = require('./errors');
|
||||
var runtimeCachingConverter = require('./runtime-caching-converter');
|
||||
var stringifyWithoutComments = require('./stringify-without-comments');
|
||||
|
||||
module.exports = function (_ref) {
|
||||
var cacheId = _ref.cacheId,
|
||||
clientsClaim = _ref.clientsClaim,
|
||||
directoryIndex = _ref.directoryIndex,
|
||||
ignoreUrlParametersMatching = _ref.ignoreUrlParametersMatching,
|
||||
importScripts = _ref.importScripts,
|
||||
manifestEntries = _ref.manifestEntries,
|
||||
modulePathPrefix = _ref.modulePathPrefix,
|
||||
navigateFallback = _ref.navigateFallback,
|
||||
navigateFallbackBlacklist = _ref.navigateFallbackBlacklist,
|
||||
navigateFallbackWhitelist = _ref.navigateFallbackWhitelist,
|
||||
offlineGoogleAnalytics = _ref.offlineGoogleAnalytics,
|
||||
runtimeCaching = _ref.runtimeCaching,
|
||||
skipWaiting = _ref.skipWaiting,
|
||||
workboxSWImport = _ref.workboxSWImport;
|
||||
|
||||
// These are all options that can be passed to the precacheAndRoute() method.
|
||||
var precacheOptions = {
|
||||
directoryIndex,
|
||||
// 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 ? [] : undefined
|
||||
};
|
||||
|
||||
var precacheOptionsString = (0, _stringify2.default)(precacheOptions, null, 2);
|
||||
if (ignoreUrlParametersMatching) {
|
||||
precacheOptionsString = precacheOptionsString.replace(`"ignoreUrlParametersMatching": []`, `"ignoreUrlParametersMatching": [` + `${ignoreUrlParametersMatching.join(', ')}]`);
|
||||
}
|
||||
|
||||
var offlineAnalyticsConfigString = void 0;
|
||||
if (offlineGoogleAnalytics) {
|
||||
// If offlineGoogleAnalytics is a truthy value, we need to convert it to the
|
||||
// format expected by the template.
|
||||
offlineAnalyticsConfigString = offlineGoogleAnalytics === true ?
|
||||
// If it's the literal value true, then use an empty config string.
|
||||
'{}' :
|
||||
// Otherwise, convert the config object into a more complex string, taking
|
||||
// into account the fact that functions might need to be stringified.
|
||||
stringifyWithoutComments(offlineGoogleAnalytics);
|
||||
}
|
||||
|
||||
try {
|
||||
var populatedTemplate = template(swTemplate)({
|
||||
cacheId,
|
||||
clientsClaim,
|
||||
importScripts,
|
||||
manifestEntries,
|
||||
modulePathPrefix,
|
||||
navigateFallback,
|
||||
navigateFallbackBlacklist,
|
||||
navigateFallbackWhitelist,
|
||||
offlineAnalyticsConfigString,
|
||||
precacheOptionsString,
|
||||
skipWaiting,
|
||||
runtimeCaching: runtimeCachingConverter(runtimeCaching),
|
||||
workboxSWImport
|
||||
});
|
||||
|
||||
// Clean up multiple blank lines.
|
||||
return populatedTemplate.replace(/\n{3,}/g, '\n\n').trim() + '\n';
|
||||
} catch (error) {
|
||||
throw new Error(`${errors['populating-sw-tmpl-failed']} '${error.message}'`);
|
||||
}
|
||||
};
|
||||
230
node_modules/workbox-build/build/lib/runtime-caching-converter.js
generated
vendored
Normal file
230
node_modules/workbox-build/build/lib/runtime-caching-converter.js
generated
vendored
Normal file
@ -0,0 +1,230 @@
|
||||
'use strict';
|
||||
|
||||
var _entries = require('babel-runtime/core-js/object/entries');
|
||||
|
||||
var _entries2 = _interopRequireDefault(_entries);
|
||||
|
||||
var _getIterator2 = require('babel-runtime/core-js/get-iterator');
|
||||
|
||||
var _getIterator3 = _interopRequireDefault(_getIterator2);
|
||||
|
||||
var _stringify = require('babel-runtime/core-js/json/stringify');
|
||||
|
||||
var _stringify2 = _interopRequireDefault(_stringify);
|
||||
|
||||
var _keys = require('babel-runtime/core-js/object/keys');
|
||||
|
||||
var _keys2 = _interopRequireDefault(_keys);
|
||||
|
||||
var _slicedToArray2 = require('babel-runtime/helpers/slicedToArray');
|
||||
|
||||
var _slicedToArray3 = _interopRequireDefault(_slicedToArray2);
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
/*
|
||||
Copyright 2017 Google Inc.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
https://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
var ol = require('common-tags').oneLine;
|
||||
|
||||
var errors = require('./errors');
|
||||
var stringifyWithoutComments = require('./stringify-without-comments');
|
||||
|
||||
/**
|
||||
* Given a set of options that configures `sw-toolbox`'s behavior, convert it
|
||||
* into a string that would configure equivalent `workbox-sw` behavior.
|
||||
*
|
||||
* @param {Object} options See
|
||||
* https://googlechrome.github.io/sw-toolbox/api.html#options
|
||||
* @return {string} A JSON string representing the equivalent options.
|
||||
*
|
||||
* @private
|
||||
*/
|
||||
function getOptionsString() {
|
||||
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
||||
|
||||
var plugins = [];
|
||||
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.
|
||||
var handlerOptionKeys = ['cacheName', 'networkTimeoutSeconds', 'fetchOptions', 'matchOptions'];
|
||||
var handlerOptions = {};
|
||||
var _iteratorNormalCompletion = true;
|
||||
var _didIteratorError = false;
|
||||
var _iteratorError = undefined;
|
||||
|
||||
try {
|
||||
for (var _iterator = (0, _getIterator3.default)(handlerOptionKeys), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
|
||||
var key = _step.value;
|
||||
|
||||
if (key in options) {
|
||||
handlerOptions[key] = options[key];
|
||||
delete options[key];
|
||||
}
|
||||
}
|
||||
} catch (err) {
|
||||
_didIteratorError = true;
|
||||
_iteratorError = err;
|
||||
} finally {
|
||||
try {
|
||||
if (!_iteratorNormalCompletion && _iterator.return) {
|
||||
_iterator.return();
|
||||
}
|
||||
} finally {
|
||||
if (_didIteratorError) {
|
||||
throw _iteratorError;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var pluginsMapping = {
|
||||
backgroundSync: 'workbox.backgroundSync.Plugin',
|
||||
broadcastUpdate: 'workbox.broadcastUpdate.Plugin',
|
||||
expiration: 'workbox.expiration.Plugin',
|
||||
cacheableResponse: 'workbox.cacheableResponse.Plugin'
|
||||
};
|
||||
|
||||
var _iteratorNormalCompletion2 = true;
|
||||
var _didIteratorError2 = false;
|
||||
var _iteratorError2 = undefined;
|
||||
|
||||
try {
|
||||
for (var _iterator2 = (0, _getIterator3.default)((0, _entries2.default)(options)), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {
|
||||
var _ref = _step2.value;
|
||||
|
||||
var _ref2 = (0, _slicedToArray3.default)(_ref, 2);
|
||||
|
||||
var pluginName = _ref2[0];
|
||||
var pluginConfig = _ref2[1];
|
||||
|
||||
// Ensure that we have some valid configuration to pass to Plugin().
|
||||
if ((0, _keys2.default)(pluginConfig).length === 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
var pluginString = pluginsMapping[pluginName];
|
||||
if (!pluginString) {
|
||||
throw new Error(`${errors['bad-runtime-caching-config']} ${pluginName}`);
|
||||
}
|
||||
|
||||
var pluginCode = void 0;
|
||||
switch (pluginName) {
|
||||
// Special case logic for plugins that have a required parameter, and then
|
||||
// an additional optional config parameter.
|
||||
case 'backgroundSync':
|
||||
{
|
||||
var name = pluginConfig.name;
|
||||
pluginCode = `new ${pluginString}(${(0, _stringify2.default)(name)}`;
|
||||
if ('options' in pluginConfig) {
|
||||
pluginCode += `, ${(0, _stringify2.default)(pluginConfig.options)}`;
|
||||
}
|
||||
pluginCode += `)`;
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case 'broadcastUpdate':
|
||||
{
|
||||
var channelName = pluginConfig.channelName;
|
||||
pluginCode = `new ${pluginString}(${(0, _stringify2.default)(channelName)}`;
|
||||
if ('options' in pluginConfig) {
|
||||
pluginCode += `, ${(0, _stringify2.default)(pluginConfig.options)}`;
|
||||
}
|
||||
pluginCode += `)`;
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
// For plugins that just pass in an Object to the constructor, like
|
||||
// expiration and cacheableResponse
|
||||
default:
|
||||
{
|
||||
pluginCode = `new ${pluginString}(${(0, _stringify2.default)(pluginConfig)})`;
|
||||
}
|
||||
}
|
||||
|
||||
plugins.push(pluginCode);
|
||||
}
|
||||
} catch (err) {
|
||||
_didIteratorError2 = true;
|
||||
_iteratorError2 = err;
|
||||
} finally {
|
||||
try {
|
||||
if (!_iteratorNormalCompletion2 && _iterator2.return) {
|
||||
_iterator2.return();
|
||||
}
|
||||
} finally {
|
||||
if (_didIteratorError2) {
|
||||
throw _iteratorError2;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ((0, _keys2.default)(handlerOptions).length > 0 || plugins.length > 0) {
|
||||
var optionsString = (0, _stringify2.default)(handlerOptions).slice(1, -1);
|
||||
return ol`{
|
||||
${optionsString ? optionsString + ',' : ''}
|
||||
plugins: [${plugins.join(', ')}]
|
||||
}`;
|
||||
} else {
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = function () {
|
||||
var runtimeCaching = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
||||
|
||||
return runtimeCaching.map(function (entry) {
|
||||
var method = entry.method || 'GET';
|
||||
|
||||
if (!entry.urlPattern) {
|
||||
throw new Error(errors['urlPattern-is-required']);
|
||||
}
|
||||
|
||||
if (!entry.handler) {
|
||||
throw new Error(errors['handler-is-required']);
|
||||
}
|
||||
|
||||
// This validation logic is a bit too gnarly for joi, so it's manually
|
||||
// implemented here.
|
||||
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.
|
||||
var matcher = typeof entry.urlPattern === 'string' ? (0, _stringify2.default)(entry.urlPattern) : entry.urlPattern;
|
||||
|
||||
if (typeof entry.handler === 'string') {
|
||||
var optionsString = getOptionsString(entry.options || {});
|
||||
|
||||
var strategyString = `workbox.strategies.${entry.handler}(${optionsString})`;
|
||||
|
||||
return `workbox.routing.registerRoute(` + `${matcher}, ${strategyString}, '${method}');\n`;
|
||||
} else if (typeof entry.handler === 'function') {
|
||||
return `workbox.routing.registerRoute(` + `${matcher}, ${entry.handler}, '${method}');\n`;
|
||||
}
|
||||
}).filter(function (entry) {
|
||||
return Boolean(entry);
|
||||
}); // Remove undefined map() return values.
|
||||
};
|
||||
28
node_modules/workbox-build/build/lib/stringify-without-comments.js
generated
vendored
Normal file
28
node_modules/workbox-build/build/lib/stringify-without-comments.js
generated
vendored
Normal file
@ -0,0 +1,28 @@
|
||||
'use strict';
|
||||
|
||||
/*
|
||||
Copyright 2018 Google Inc.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
https://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
var objectStringify = require('stringify-object');
|
||||
var stripComments = require('strip-comments');
|
||||
|
||||
module.exports = function (obj) {
|
||||
return objectStringify(obj, {
|
||||
transform: function transform(_obj, _prop, str) {
|
||||
return stripComments(str);
|
||||
}
|
||||
});
|
||||
};
|
||||
54
node_modules/workbox-build/build/lib/use-build-type.js
generated
vendored
Normal file
54
node_modules/workbox-build/build/lib/use-build-type.js
generated
vendored
Normal file
@ -0,0 +1,54 @@
|
||||
'use strict';
|
||||
|
||||
var _toConsumableArray2 = require('babel-runtime/helpers/toConsumableArray');
|
||||
|
||||
var _toConsumableArray3 = _interopRequireDefault(_toConsumableArray2);
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
/*
|
||||
Copyright 2017 Google Inc.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
https://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
// This is the build type that is expected to be present "by default".
|
||||
var DEFAULT_BUILD_TYPE = 'prod';
|
||||
|
||||
/**
|
||||
* Switches a string from using the "default" build type to an alternative
|
||||
* build type. In practice, this is used to swap out "prod" for "dev" in the
|
||||
* filename of a Workbox library.
|
||||
*
|
||||
* @param {string} source The path to a file, which will normally contain
|
||||
* DEFAULT_BUILD_TYPE somewhere in it.
|
||||
* @param {string} buildType The alternative build type value to swap in.
|
||||
* @return {string} source, with the last occurrence of DEFAULT_BUILD_TYPE
|
||||
* replaced with buildType.
|
||||
* @private
|
||||
*/
|
||||
module.exports = function (source, buildType) {
|
||||
// If we want the DEFAULT_BUILD_TYPE, then just return things as-is.
|
||||
if (buildType === DEFAULT_BUILD_TYPE) {
|
||||
return source;
|
||||
}
|
||||
// Otherwise, look for the last instance of DEFAULT_BUILD_TYPE, and replace it
|
||||
// with the new buildType. This is easier via split/join than RegExp.
|
||||
var parts = source.split(DEFAULT_BUILD_TYPE);
|
||||
// Join the last two split parts with the new buildType. (If parts only has
|
||||
// one item, this will be a no-op.)
|
||||
var replaced = parts.slice(parts.length - 2).join(buildType);
|
||||
// Take the remaining parts, if any exist, and join them with the replaced
|
||||
// part using the DEFAULT_BUILD_TYPE, to restore any other matches as-is.
|
||||
return [].concat((0, _toConsumableArray3.default)(parts.slice(0, parts.length - 2)), [replaced]).join(DEFAULT_BUILD_TYPE);
|
||||
};
|
||||
122
node_modules/workbox-build/build/lib/write-sw-using-default-template.js
generated
vendored
Normal file
122
node_modules/workbox-build/build/lib/write-sw-using-default-template.js
generated
vendored
Normal file
@ -0,0 +1,122 @@
|
||||
'use strict';
|
||||
|
||||
var _regenerator = require('babel-runtime/regenerator');
|
||||
|
||||
var _regenerator2 = _interopRequireDefault(_regenerator);
|
||||
|
||||
var _asyncToGenerator2 = require('babel-runtime/helpers/asyncToGenerator');
|
||||
|
||||
var _asyncToGenerator3 = _interopRequireDefault(_asyncToGenerator2);
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
/*
|
||||
Copyright 2017 Google Inc.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
https://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
var fse = require('fs-extra');
|
||||
var path = require('path');
|
||||
|
||||
var errors = require('./errors');
|
||||
var populateSWTemplate = require('./populate-sw-template');
|
||||
|
||||
module.exports = function () {
|
||||
var _ref2 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee(_ref) {
|
||||
var cacheId = _ref.cacheId,
|
||||
clientsClaim = _ref.clientsClaim,
|
||||
directoryIndex = _ref.directoryIndex,
|
||||
handleFetch = _ref.handleFetch,
|
||||
ignoreUrlParametersMatching = _ref.ignoreUrlParametersMatching,
|
||||
importScripts = _ref.importScripts,
|
||||
manifestEntries = _ref.manifestEntries,
|
||||
modulePathPrefix = _ref.modulePathPrefix,
|
||||
navigateFallback = _ref.navigateFallback,
|
||||
navigateFallbackBlacklist = _ref.navigateFallbackBlacklist,
|
||||
navigateFallbackWhitelist = _ref.navigateFallbackWhitelist,
|
||||
offlineGoogleAnalytics = _ref.offlineGoogleAnalytics,
|
||||
runtimeCaching = _ref.runtimeCaching,
|
||||
skipWaiting = _ref.skipWaiting,
|
||||
swDest = _ref.swDest,
|
||||
workboxSWImport = _ref.workboxSWImport;
|
||||
var populatedTemplate;
|
||||
return _regenerator2.default.wrap(function _callee$(_context) {
|
||||
while (1) {
|
||||
switch (_context.prev = _context.next) {
|
||||
case 0:
|
||||
_context.prev = 0;
|
||||
_context.next = 3;
|
||||
return fse.mkdirp(path.dirname(swDest));
|
||||
|
||||
case 3:
|
||||
_context.next = 8;
|
||||
break;
|
||||
|
||||
case 5:
|
||||
_context.prev = 5;
|
||||
_context.t0 = _context['catch'](0);
|
||||
throw new Error(`${errors['unable-to-make-sw-directory']}. ` + `'${_context.t0.message}'`);
|
||||
|
||||
case 8:
|
||||
populatedTemplate = populateSWTemplate({
|
||||
cacheId,
|
||||
clientsClaim,
|
||||
directoryIndex,
|
||||
handleFetch,
|
||||
ignoreUrlParametersMatching,
|
||||
importScripts,
|
||||
manifestEntries,
|
||||
modulePathPrefix,
|
||||
navigateFallback,
|
||||
navigateFallbackBlacklist,
|
||||
navigateFallbackWhitelist,
|
||||
offlineGoogleAnalytics,
|
||||
runtimeCaching,
|
||||
skipWaiting,
|
||||
workboxSWImport
|
||||
});
|
||||
_context.prev = 9;
|
||||
_context.next = 12;
|
||||
return fse.writeFile(swDest, populatedTemplate);
|
||||
|
||||
case 12:
|
||||
_context.next = 19;
|
||||
break;
|
||||
|
||||
case 14:
|
||||
_context.prev = 14;
|
||||
_context.t1 = _context['catch'](9);
|
||||
|
||||
if (!(_context.t1.code === 'EISDIR')) {
|
||||
_context.next = 18;
|
||||
break;
|
||||
}
|
||||
|
||||
throw new Error(errors['sw-write-failure-directory']);
|
||||
|
||||
case 18:
|
||||
throw new Error(`${errors['sw-write-failure']}. '${_context.t1.message}'`);
|
||||
|
||||
case 19:
|
||||
case 'end':
|
||||
return _context.stop();
|
||||
}
|
||||
}
|
||||
}, _callee, undefined, [[0, 5], [9, 14]]);
|
||||
}));
|
||||
|
||||
return function (_x) {
|
||||
return _ref2.apply(this, arguments);
|
||||
};
|
||||
}();
|
||||
Reference in New Issue
Block a user