diff options
Diffstat (limited to 'node_modules/workbox-build/src/entry-points/options')
9 files changed, 306 insertions, 0 deletions
diff --git a/node_modules/workbox-build/src/entry-points/options/base-schema.js b/node_modules/workbox-build/src/entry-points/options/base-schema.js new file mode 100644 index 00000000..12292bfa --- /dev/null +++ b/node_modules/workbox-build/src/entry-points/options/base-schema.js @@ -0,0 +1,37 @@ +/* + 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. +*/ + +const joi = require('joi'); + +const defaults = require('./defaults'); +const regExpObject = require('./reg-exp-object'); + +// Define some common constrains used by all methods. +module.exports = joi.object().keys({ + dontCacheBustUrlsMatching: regExpObject, + globFollow: joi.boolean().default(defaults.globFollow), + globIgnores: joi.array().items(joi.string()).default(defaults.globIgnores), + globPatterns: joi.array().items(joi.string()).default(defaults.globPatterns), + globStrict: joi.boolean().default(defaults.globStrict), + manifestTransforms: joi.array().items(joi.func().arity(1)), + maximumFileSizeToCacheInBytes: joi.number().min(1) + .default(defaults.maximumFileSizeToCacheInBytes), + 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())]), +}); diff --git a/node_modules/workbox-build/src/entry-points/options/common-generate-schema.js b/node_modules/workbox-build/src/entry-points/options/common-generate-schema.js new file mode 100644 index 00000000..69e92843 --- /dev/null +++ b/node_modules/workbox-build/src/entry-points/options/common-generate-schema.js @@ -0,0 +1,77 @@ +/* + 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. +*/ + +const joi = require('joi'); + +const baseSchema = require('./base-schema'); +const defaults = require('./defaults'); +const regExpObject = require('./reg-exp-object'); + +// Add some constraints that apply to both generateSW and generateSWString. +module.exports = baseSchema.keys({ + cacheId: joi.string(), + clientsClaim: joi.boolean().default(defaults.clientsClaim), + directoryIndex: joi.string(), + ignoreUrlParametersMatching: joi.array().items(regExpObject), + navigateFallback: joi.string().default(defaults.navigateFallback), + navigateFallbackBlacklist: joi.array().items(regExpObject), + navigateFallbackWhitelist: joi.array().items(regExpObject), + offlineGoogleAnalytics: joi.alternatives().try(joi.boolean(), joi.object()) + .default(defaults.offlineGoogleAnalytics), + runtimeCaching: joi.array().items(joi.object().keys({ + method: joi.string().valid( + 'DELETE', + 'GET', + 'HEAD', + 'PATCH', + 'POST', + 'PUT' + ), + urlPattern: [regExpObject, joi.string()], + handler: [joi.func(), joi.string().valid( + 'cacheFirst', + 'cacheOnly', + 'networkFirst', + 'networkOnly', + 'staleWhileRevalidate' + )], + options: joi.object().keys({ + backgroundSync: joi.object().keys({ + name: joi.string().required(), + options: joi.object(), + }), + broadcastUpdate: joi.object().keys({ + channelName: joi.string().required(), + options: joi.object(), + }), + cacheableResponse: joi.object().keys({ + statuses: joi.array().items(joi.number().min(0).max(599)), + headers: joi.object(), + }).or('statuses', 'headers'), + cacheName: joi.string(), + expiration: joi.object().keys({ + maxEntries: joi.number().min(1), + maxAgeSeconds: joi.number().min(1), + purgeOnQuotaError: joi.boolean().default(defaults.purgeOnQuotaError), + }).or('maxEntries', 'maxAgeSeconds'), + networkTimeoutSeconds: joi.number().min(1), + plugins: joi.array().items(joi.object()), + fetchOptions: joi.object(), + matchOptions: joi.object(), + }).with('expiration', 'cacheName'), + }).requiredKeys('urlPattern', 'handler')), + skipWaiting: joi.boolean().default(defaults.skipWaiting), +}); diff --git a/node_modules/workbox-build/src/entry-points/options/defaults.js b/node_modules/workbox-build/src/entry-points/options/defaults.js new file mode 100644 index 00000000..7a8bbdb0 --- /dev/null +++ b/node_modules/workbox-build/src/entry-points/options/defaults.js @@ -0,0 +1,30 @@ +/* + 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. +*/ + +module.exports = { + clientsClaim: false, + globFollow: true, + globIgnores: ['**/node_modules/**/*'], + globPatterns: ['**/*.{js,css,html}'], + globStrict: true, + importWorkboxFrom: 'cdn', + injectionPointRegexp: /(\.precacheAndRoute\()\s*\[\s*\]\s*(\)|,)/, + maximumFileSizeToCacheInBytes: 2 * 1024 * 1024, + navigateFallback: undefined, + offlineGoogleAnalytics: false, + purgeOnQuotaError: false, + skipWaiting: false, +}; diff --git a/node_modules/workbox-build/src/entry-points/options/generate-sw-schema.js b/node_modules/workbox-build/src/entry-points/options/generate-sw-schema.js new file mode 100644 index 00000000..64dbaf29 --- /dev/null +++ b/node_modules/workbox-build/src/entry-points/options/generate-sw-schema.js @@ -0,0 +1,32 @@ +/* + 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. +*/ + +const joi = require('joi'); + +const commonGenerateSchema = require('./common-generate-schema'); +const defaults = require('./defaults'); + +// Define some additional constraints. +module.exports = commonGenerateSchema.keys({ + globDirectory: joi.string().required(), + importScripts: joi.array().items(joi.string()), + importWorkboxFrom: joi.string().default(defaults.importWorkboxFrom).valid( + 'cdn', + 'local', + 'disabled' + ), + swDest: joi.string().required(), +}); diff --git a/node_modules/workbox-build/src/entry-points/options/generate-sw-string-schema.js b/node_modules/workbox-build/src/entry-points/options/generate-sw-string-schema.js new file mode 100644 index 00000000..9c1f496c --- /dev/null +++ b/node_modules/workbox-build/src/entry-points/options/generate-sw-string-schema.js @@ -0,0 +1,27 @@ +/* + 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. +*/ + +const joi = require('joi'); + +const commonGenerateSchema = require('./common-generate-schema'); + +// Define some additional constraints. +module.exports = commonGenerateSchema.keys({ + globDirectory: joi.string(), + importScripts: joi.array().items(joi.string()).required(), + modulePathPrefix: joi.string(), + workboxSWImport: joi.string(), +}); diff --git a/node_modules/workbox-build/src/entry-points/options/get-manifest-schema.js b/node_modules/workbox-build/src/entry-points/options/get-manifest-schema.js new file mode 100644 index 00000000..31704c8e --- /dev/null +++ b/node_modules/workbox-build/src/entry-points/options/get-manifest-schema.js @@ -0,0 +1,24 @@ +/* + 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. +*/ + +const joi = require('joi'); + +const baseSchema = require('./base-schema'); + +// Define some additional constraints. +module.exports = baseSchema.keys({ + globDirectory: joi.string(), +}); diff --git a/node_modules/workbox-build/src/entry-points/options/inject-manifest-schema.js b/node_modules/workbox-build/src/entry-points/options/inject-manifest-schema.js new file mode 100644 index 00000000..6f901824 --- /dev/null +++ b/node_modules/workbox-build/src/entry-points/options/inject-manifest-schema.js @@ -0,0 +1,28 @@ +/* + 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. +*/ + +const joi = require('joi'); + +const baseSchema = require('./base-schema'); +const defaults = require('./defaults'); +const regExpObject = require('./reg-exp-object'); + +module.exports = baseSchema.keys({ + globDirectory: joi.string().required(), + injectionPointRegexp: regExpObject.default(defaults.injectionPointRegexp), + swSrc: joi.string().required(), + swDest: joi.string().required(), +}); diff --git a/node_modules/workbox-build/src/entry-points/options/reg-exp-object.js b/node_modules/workbox-build/src/entry-points/options/reg-exp-object.js new file mode 100644 index 00000000..d91fd1a1 --- /dev/null +++ b/node_modules/workbox-build/src/entry-points/options/reg-exp-object.js @@ -0,0 +1,20 @@ +/* + 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. +*/ + +const joi = require('joi'); + +module.exports = joi.object().type(RegExp) + .error(() => 'the value must be a RegExp'); diff --git a/node_modules/workbox-build/src/entry-points/options/validate.js b/node_modules/workbox-build/src/entry-points/options/validate.js new file mode 100644 index 00000000..487e5446 --- /dev/null +++ b/node_modules/workbox-build/src/entry-points/options/validate.js @@ -0,0 +1,31 @@ +/* + 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. +*/ + +module.exports = (options, schema) => { + const {value, error} = schema.validate(options, { + language: { + object: { + allowUnknown: 'is not a supported parameter.', + }, + }, + }); + + if (error) { + throw error; + } + + return value; +}; |
