generate.js
2.98 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
"use strict";
/*
Copyright 2019 Google LLC
Use of this source code is governed by an MIT-style
license that can be found in the LICENSE file or at
https://opensource.org/licenses/MIT.
*/
const joi = require('@hapi/joi');
const defaults = require('../defaults');
const regExpObject = require('../objects/reg-exp');
module.exports = {
babelPresetEnvTargets: joi.array().items(joi.string()).default(defaults.babelPresetEnvTargets),
cacheId: joi.string(),
cleanupOutdatedCaches: joi.boolean().default(defaults.cleanupOutdatedCaches),
clientsClaim: joi.boolean().default(defaults.clientsClaim),
directoryIndex: joi.string(),
disableDevLogs: joi.boolean().default(defaults.disableDevLogs),
ignoreURLParametersMatching: joi.array().items(regExpObject),
importScripts: joi.array().items(joi.string()),
inlineWorkboxRuntime: joi.boolean().default(defaults.inlineWorkboxRuntime),
navigateFallback: joi.string().default(defaults.navigateFallback),
navigateFallbackAllowlist: joi.array().items(regExpObject),
navigateFallbackBlacklist: joi.forbidden().error(new Error('navigateFallbackBlacklist has been renamed navigateFallbackDenylist.')),
navigateFallbackDenylist: joi.array().items(regExpObject),
navigateFallbackWhitelist: joi.forbidden().error(new Error('navigateFallbackWhitelist has been renamed navigateFallbackAllowlist.')),
navigationPreload: joi.boolean().default(defaults.navigationPreload),
offlineGoogleAnalytics: joi.alternatives().try(joi.boolean(), joi.object()).default(defaults.offlineGoogleAnalytics),
runtimeCaching: joi.array().items(joi.object().keys({
method: joi.string().valid('DELETE', 'GET', 'HEAD', 'PATCH', 'POST', 'PUT'),
urlPattern: [regExpObject, joi.string(), joi.func()],
handler: [joi.func(), joi.string().valid('CacheFirst', 'CacheOnly', 'NetworkFirst', 'NetworkOnly', 'StaleWhileRevalidate')],
options: joi.object().keys({
backgroundSync: joi.object().keys({
name: joi.string().required(),
options: joi.object()
}),
broadcastUpdate: joi.object().keys({
channelName: joi.string().required(),
options: joi.object()
}),
cacheableResponse: joi.object().keys({
statuses: joi.array().items(joi.number().min(0).max(599)),
headers: joi.object()
}).or('statuses', 'headers'),
cacheName: joi.string(),
expiration: joi.object().keys({
maxEntries: joi.number().min(1),
maxAgeSeconds: joi.number().min(1),
purgeOnQuotaError: joi.boolean().default(defaults.purgeOnQuotaError)
}).or('maxEntries', 'maxAgeSeconds'),
networkTimeoutSeconds: joi.number().min(1),
plugins: joi.array().items(joi.object()),
fetchOptions: joi.object(),
matchOptions: joi.object()
}).with('expiration', 'cacheName')
}).requiredKeys('urlPattern', 'handler')).when('navigationPreload', {
is: true,
then: joi.required()
}),
skipWaiting: joi.boolean().default(defaults.skipWaiting),
sourcemap: joi.boolean().default(defaults.sourcemap)
};