Brunobkr commited on
Commit
8dc226e
·
verified ·
1 Parent(s): fe96dee

Upload folder using huggingface_hub (part 53)

Browse files
This view is limited to 50 files because it contains too many changes.   See raw diff
Files changed (50) hide show
  1. tools/ui/node_modules/workbox-build/build/index.d.ts +10 -0
  2. tools/ui/node_modules/workbox-build/build/index.js +35 -0
  3. tools/ui/node_modules/workbox-build/build/inject-manifest.d.ts +30 -0
  4. tools/ui/node_modules/workbox-build/build/inject-manifest.js +133 -0
  5. tools/ui/node_modules/workbox-build/build/lib/additional-manifest-entries-transform.d.ts +13 -0
  6. tools/ui/node_modules/workbox-build/build/lib/additional-manifest-entries-transform.js +47 -0
  7. tools/ui/node_modules/workbox-build/build/lib/bundle.d.ts +9 -0
  8. tools/ui/node_modules/workbox-build/build/lib/bundle.js +133 -0
  9. tools/ui/node_modules/workbox-build/build/lib/cdn-utils.d.ts +2 -0
  10. tools/ui/node_modules/workbox-build/build/lib/cdn-utils.js +57 -0
  11. tools/ui/node_modules/workbox-build/build/lib/copy-workbox-libraries.d.ts +20 -0
  12. tools/ui/node_modules/workbox-build/build/lib/copy-workbox-libraries.js +69 -0
  13. tools/ui/node_modules/workbox-build/build/lib/errors.d.ts +61 -0
  14. tools/ui/node_modules/workbox-build/build/lib/errors.js +125 -0
  15. tools/ui/node_modules/workbox-build/build/lib/escape-regexp.d.ts +1 -0
  16. tools/ui/node_modules/workbox-build/build/lib/escape-regexp.js +15 -0
  17. tools/ui/node_modules/workbox-build/build/lib/get-composite-details.d.ts +2 -0
  18. tools/ui/node_modules/workbox-build/build/lib/get-composite-details.js +31 -0
  19. tools/ui/node_modules/workbox-build/build/lib/get-file-details.d.ts +14 -0
  20. tools/ui/node_modules/workbox-build/build/lib/get-file-details.js +54 -0
  21. tools/ui/node_modules/workbox-build/build/lib/get-file-hash.d.ts +1 -0
  22. tools/ui/node_modules/workbox-build/build/lib/get-file-hash.js +27 -0
  23. tools/ui/node_modules/workbox-build/build/lib/get-file-manifest-entries.d.ts +2 -0
  24. tools/ui/node_modules/workbox-build/build/lib/get-file-manifest-entries.js +96 -0
  25. tools/ui/node_modules/workbox-build/build/lib/get-file-size.d.ts +1 -0
  26. tools/ui/node_modules/workbox-build/build/lib/get-file-size.js +29 -0
  27. tools/ui/node_modules/workbox-build/build/lib/get-source-map-url.d.ts +1 -0
  28. tools/ui/node_modules/workbox-build/build/lib/get-source-map-url.js +32 -0
  29. tools/ui/node_modules/workbox-build/build/lib/get-string-details.d.ts +2 -0
  30. tools/ui/node_modules/workbox-build/build/lib/get-string-details.js +19 -0
  31. tools/ui/node_modules/workbox-build/build/lib/get-string-hash.d.ts +3 -0
  32. tools/ui/node_modules/workbox-build/build/lib/get-string-hash.js +20 -0
  33. tools/ui/node_modules/workbox-build/build/lib/maximum-size-transform.d.ts +2 -0
  34. tools/ui/node_modules/workbox-build/build/lib/maximum-size-transform.js +30 -0
  35. tools/ui/node_modules/workbox-build/build/lib/modify-url-prefix-transform.d.ts +4 -0
  36. tools/ui/node_modules/workbox-build/build/lib/modify-url-prefix-transform.js +51 -0
  37. tools/ui/node_modules/workbox-build/build/lib/module-registry.d.ts +33 -0
  38. tools/ui/node_modules/workbox-build/build/lib/module-registry.js +70 -0
  39. tools/ui/node_modules/workbox-build/build/lib/no-revision-for-urls-matching-transform.d.ts +2 -0
  40. tools/ui/node_modules/workbox-build/build/lib/no-revision-for-urls-matching-transform.js +29 -0
  41. tools/ui/node_modules/workbox-build/build/lib/populate-sw-template.d.ts +4 -0
  42. tools/ui/node_modules/workbox-build/build/lib/populate-sw-template.js +80 -0
  43. tools/ui/node_modules/workbox-build/build/lib/rebase-path.d.ts +4 -0
  44. tools/ui/node_modules/workbox-build/build/lib/rebase-path.js +24 -0
  45. tools/ui/node_modules/workbox-build/build/lib/replace-and-update-source-map.d.ts +30 -0
  46. tools/ui/node_modules/workbox-build/build/lib/replace-and-update-source-map.js +98 -0
  47. tools/ui/node_modules/workbox-build/build/lib/runtime-caching-converter.d.ts +3 -0
  48. tools/ui/node_modules/workbox-build/build/lib/runtime-caching-converter.js +142 -0
  49. tools/ui/node_modules/workbox-build/build/lib/stringify-without-comments.d.ts +3 -0
  50. tools/ui/node_modules/workbox-build/build/lib/stringify-without-comments.js +28 -0
tools/ui/node_modules/workbox-build/build/index.d.ts ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ import { copyWorkboxLibraries } from './lib/copy-workbox-libraries';
2
+ import { getModuleURL } from './lib/cdn-utils';
3
+ import { generateSW } from './generate-sw';
4
+ import { getManifest } from './get-manifest';
5
+ import { injectManifest } from './inject-manifest';
6
+ /**
7
+ * @module workbox-build
8
+ */
9
+ export { copyWorkboxLibraries, generateSW, getManifest, getModuleURL, injectManifest, };
10
+ export * from './types';
tools/ui/node_modules/workbox-build/build/index.js ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ "use strict";
2
+ /*
3
+ Copyright 2018 Google LLC
4
+
5
+ Use of this source code is governed by an MIT-style
6
+ license that can be found in the LICENSE file or at
7
+ https://opensource.org/licenses/MIT.
8
+ */
9
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ var desc = Object.getOwnPropertyDescriptor(m, k);
12
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
13
+ desc = { enumerable: true, get: function() { return m[k]; } };
14
+ }
15
+ Object.defineProperty(o, k2, desc);
16
+ }) : (function(o, m, k, k2) {
17
+ if (k2 === undefined) k2 = k;
18
+ o[k2] = m[k];
19
+ }));
20
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
21
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
22
+ };
23
+ Object.defineProperty(exports, "__esModule", { value: true });
24
+ exports.injectManifest = exports.getModuleURL = exports.getManifest = exports.generateSW = exports.copyWorkboxLibraries = void 0;
25
+ const copy_workbox_libraries_1 = require("./lib/copy-workbox-libraries");
26
+ Object.defineProperty(exports, "copyWorkboxLibraries", { enumerable: true, get: function () { return copy_workbox_libraries_1.copyWorkboxLibraries; } });
27
+ const cdn_utils_1 = require("./lib/cdn-utils");
28
+ Object.defineProperty(exports, "getModuleURL", { enumerable: true, get: function () { return cdn_utils_1.getModuleURL; } });
29
+ const generate_sw_1 = require("./generate-sw");
30
+ Object.defineProperty(exports, "generateSW", { enumerable: true, get: function () { return generate_sw_1.generateSW; } });
31
+ const get_manifest_1 = require("./get-manifest");
32
+ Object.defineProperty(exports, "getManifest", { enumerable: true, get: function () { return get_manifest_1.getManifest; } });
33
+ const inject_manifest_1 = require("./inject-manifest");
34
+ Object.defineProperty(exports, "injectManifest", { enumerable: true, get: function () { return inject_manifest_1.injectManifest; } });
35
+ __exportStar(require("./types"), exports);
tools/ui/node_modules/workbox-build/build/inject-manifest.d.ts ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { BuildResult, InjectManifestOptions } from './types';
2
+ /**
3
+ * This method creates a list of URLs to precache, referred to as a "precache
4
+ * manifest", based on the options you provide.
5
+ *
6
+ * The manifest is injected into the `swSrc` file, and the placeholder string
7
+ * `injectionPoint` determines where in the file the manifest should go.
8
+ *
9
+ * The final service worker file, with the manifest injected, is written to
10
+ * disk at `swDest`.
11
+ *
12
+ * This method will not compile or bundle your `swSrc` file; it just handles
13
+ * injecting the manifest.
14
+ *
15
+ * ```
16
+ * // The following lists some common options; see the rest of the documentation
17
+ * // for the full set of options and defaults.
18
+ * const {count, size, warnings} = await injectManifest({
19
+ * dontCacheBustURLsMatching: [new RegExp('...')],
20
+ * globDirectory: '...',
21
+ * globPatterns: ['...', '...'],
22
+ * maximumFileSizeToCacheInBytes: ...,
23
+ * swDest: '...',
24
+ * swSrc: '...',
25
+ * });
26
+ * ```
27
+ *
28
+ * @memberof workbox-build
29
+ */
30
+ export declare function injectManifest(config: InjectManifestOptions): Promise<BuildResult>;
tools/ui/node_modules/workbox-build/build/inject-manifest.js ADDED
@@ -0,0 +1,133 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ "use strict";
2
+ /*
3
+ Copyright 2018 Google LLC
4
+
5
+ Use of this source code is governed by an MIT-style
6
+ license that can be found in the LICENSE file or at
7
+ https://opensource.org/licenses/MIT.
8
+ */
9
+ var __importDefault = (this && this.__importDefault) || function (mod) {
10
+ return (mod && mod.__esModule) ? mod : { "default": mod };
11
+ };
12
+ Object.defineProperty(exports, "__esModule", { value: true });
13
+ exports.injectManifest = void 0;
14
+ const assert_1 = __importDefault(require("assert"));
15
+ const fs_extra_1 = __importDefault(require("fs-extra"));
16
+ const fast_json_stable_stringify_1 = __importDefault(require("fast-json-stable-stringify"));
17
+ const upath_1 = __importDefault(require("upath"));
18
+ const errors_1 = require("./lib/errors");
19
+ const escape_regexp_1 = require("./lib/escape-regexp");
20
+ const get_file_manifest_entries_1 = require("./lib/get-file-manifest-entries");
21
+ const get_source_map_url_1 = require("./lib/get-source-map-url");
22
+ const rebase_path_1 = require("./lib/rebase-path");
23
+ const replace_and_update_source_map_1 = require("./lib/replace-and-update-source-map");
24
+ const translate_url_to_sourcemap_paths_1 = require("./lib/translate-url-to-sourcemap-paths");
25
+ const validate_options_1 = require("./lib/validate-options");
26
+ /**
27
+ * This method creates a list of URLs to precache, referred to as a "precache
28
+ * manifest", based on the options you provide.
29
+ *
30
+ * The manifest is injected into the `swSrc` file, and the placeholder string
31
+ * `injectionPoint` determines where in the file the manifest should go.
32
+ *
33
+ * The final service worker file, with the manifest injected, is written to
34
+ * disk at `swDest`.
35
+ *
36
+ * This method will not compile or bundle your `swSrc` file; it just handles
37
+ * injecting the manifest.
38
+ *
39
+ * ```
40
+ * // The following lists some common options; see the rest of the documentation
41
+ * // for the full set of options and defaults.
42
+ * const {count, size, warnings} = await injectManifest({
43
+ * dontCacheBustURLsMatching: [new RegExp('...')],
44
+ * globDirectory: '...',
45
+ * globPatterns: ['...', '...'],
46
+ * maximumFileSizeToCacheInBytes: ...,
47
+ * swDest: '...',
48
+ * swSrc: '...',
49
+ * });
50
+ * ```
51
+ *
52
+ * @memberof workbox-build
53
+ */
54
+ async function injectManifest(config) {
55
+ const options = (0, validate_options_1.validateInjectManifestOptions)(config);
56
+ // Make sure we leave swSrc and swDest out of the precache manifest.
57
+ for (const file of [options.swSrc, options.swDest]) {
58
+ options.globIgnores.push((0, rebase_path_1.rebasePath)({
59
+ file,
60
+ baseDirectory: options.globDirectory,
61
+ }));
62
+ }
63
+ const globalRegexp = new RegExp((0, escape_regexp_1.escapeRegExp)(options.injectionPoint), 'g');
64
+ const { count, size, manifestEntries, warnings } = await (0, get_file_manifest_entries_1.getFileManifestEntries)(options);
65
+ let swFileContents;
66
+ try {
67
+ swFileContents = await fs_extra_1.default.readFile(options.swSrc, 'utf8');
68
+ }
69
+ catch (error) {
70
+ throw new Error(`${errors_1.errors['invalid-sw-src']} ${error instanceof Error && error.message ? error.message : ''}`);
71
+ }
72
+ const injectionResults = swFileContents.match(globalRegexp);
73
+ // See https://github.com/GoogleChrome/workbox/issues/2230
74
+ const injectionPoint = options.injectionPoint ? options.injectionPoint : '';
75
+ if (!injectionResults) {
76
+ if (upath_1.default.resolve(options.swSrc) === upath_1.default.resolve(options.swDest)) {
77
+ throw new Error(`${errors_1.errors['same-src-and-dest']} ${injectionPoint}`);
78
+ }
79
+ throw new Error(`${errors_1.errors['injection-point-not-found']} ${injectionPoint}`);
80
+ }
81
+ (0, assert_1.default)(injectionResults.length === 1, `${errors_1.errors['multiple-injection-points']} ${injectionPoint}`);
82
+ const manifestString = (0, fast_json_stable_stringify_1.default)(manifestEntries);
83
+ const filesToWrite = {};
84
+ const url = (0, get_source_map_url_1.getSourceMapURL)(swFileContents);
85
+ // See https://github.com/GoogleChrome/workbox/issues/2957
86
+ const { destPath, srcPath, warning } = (0, translate_url_to_sourcemap_paths_1.translateURLToSourcemapPaths)(url, options.swSrc, options.swDest);
87
+ if (warning) {
88
+ warnings.push(warning);
89
+ }
90
+ // If our swSrc file contains a sourcemap, we would invalidate that
91
+ // mapping if we just replaced injectionPoint with the stringified manifest.
92
+ // Instead, we need to update the swDest contents as well as the sourcemap
93
+ // (assuming it's a real file, not a data: URL) at the same time.
94
+ // See https://github.com/GoogleChrome/workbox/issues/2235
95
+ // and https://github.com/GoogleChrome/workbox/issues/2648
96
+ if (srcPath && destPath) {
97
+ const originalMap = (await fs_extra_1.default.readJSON(srcPath, {
98
+ encoding: 'utf8',
99
+ }));
100
+ const { map, source } = await (0, replace_and_update_source_map_1.replaceAndUpdateSourceMap)({
101
+ originalMap,
102
+ jsFilename: upath_1.default.basename(options.swDest),
103
+ originalSource: swFileContents,
104
+ replaceString: manifestString,
105
+ searchString: options.injectionPoint,
106
+ });
107
+ filesToWrite[options.swDest] = source;
108
+ filesToWrite[destPath] = map;
109
+ }
110
+ else {
111
+ // If there's no sourcemap associated with swSrc, a simple string
112
+ // replacement will suffice.
113
+ filesToWrite[options.swDest] = swFileContents.replace(globalRegexp, manifestString);
114
+ }
115
+ for (const [file, contents] of Object.entries(filesToWrite)) {
116
+ try {
117
+ await fs_extra_1.default.mkdirp(upath_1.default.dirname(file));
118
+ }
119
+ catch (error) {
120
+ throw new Error(errors_1.errors['unable-to-make-sw-directory'] +
121
+ ` '${error instanceof Error && error.message ? error.message : ''}'`);
122
+ }
123
+ await fs_extra_1.default.writeFile(file, contents);
124
+ }
125
+ return {
126
+ count,
127
+ size,
128
+ warnings,
129
+ // Use upath.resolve() to make all the paths absolute.
130
+ filePaths: Object.keys(filesToWrite).map((f) => upath_1.default.resolve(f)),
131
+ };
132
+ }
133
+ exports.injectManifest = injectManifest;
tools/ui/node_modules/workbox-build/build/lib/additional-manifest-entries-transform.d.ts ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { ManifestEntry } from '../types';
2
+ type AdditionalManifestEntriesTransform = {
3
+ (manifest: Array<ManifestEntry & {
4
+ size: number;
5
+ }>): {
6
+ manifest: Array<ManifestEntry & {
7
+ size: number;
8
+ }>;
9
+ warnings: string[];
10
+ };
11
+ };
12
+ export declare function additionalManifestEntriesTransform(additionalManifestEntries: Array<ManifestEntry | string>): AdditionalManifestEntriesTransform;
13
+ export {};
tools/ui/node_modules/workbox-build/build/lib/additional-manifest-entries-transform.js ADDED
@@ -0,0 +1,47 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ "use strict";
2
+ /*
3
+ Copyright 2019 Google LLC
4
+
5
+ Use of this source code is governed by an MIT-style
6
+ license that can be found in the LICENSE file or at
7
+ https://opensource.org/licenses/MIT.
8
+ */
9
+ Object.defineProperty(exports, "__esModule", { value: true });
10
+ exports.additionalManifestEntriesTransform = void 0;
11
+ const errors_1 = require("./errors");
12
+ function additionalManifestEntriesTransform(additionalManifestEntries) {
13
+ return (manifest) => {
14
+ const warnings = [];
15
+ const stringEntries = new Set();
16
+ for (const additionalEntry of additionalManifestEntries) {
17
+ // Warn about either a string or an object that lacks a revision property.
18
+ // (An object with a revision property set to null is okay.)
19
+ if (typeof additionalEntry === 'string') {
20
+ stringEntries.add(additionalEntry);
21
+ manifest.push({
22
+ revision: null,
23
+ size: 0,
24
+ url: additionalEntry,
25
+ });
26
+ }
27
+ else {
28
+ if (additionalEntry && additionalEntry.revision === undefined) {
29
+ stringEntries.add(additionalEntry.url);
30
+ }
31
+ manifest.push(Object.assign({ size: 0 }, additionalEntry));
32
+ }
33
+ }
34
+ if (stringEntries.size > 0) {
35
+ let urls = '\n';
36
+ for (const stringEntry of stringEntries) {
37
+ urls += ` - ${stringEntry}\n`;
38
+ }
39
+ warnings.push(errors_1.errors['string-entry-warning'] + urls);
40
+ }
41
+ return {
42
+ manifest,
43
+ warnings,
44
+ };
45
+ };
46
+ }
47
+ exports.additionalManifestEntriesTransform = additionalManifestEntriesTransform;
tools/ui/node_modules/workbox-build/build/lib/bundle.d.ts ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
 
1
+ import { GeneratePartial, RequiredSWDestPartial } from '../types';
2
+ interface NameAndContents {
3
+ contents: string | Uint8Array;
4
+ name: string;
5
+ }
6
+ export declare function bundle({ babelPresetEnvTargets, inlineWorkboxRuntime, mode, sourcemap, swDest, unbundledCode, }: Omit<GeneratePartial, 'runtimeCaching'> & RequiredSWDestPartial & {
7
+ unbundledCode: string;
8
+ }): Promise<Array<NameAndContents>>;
9
+ export {};
tools/ui/node_modules/workbox-build/build/lib/bundle.js ADDED
@@ -0,0 +1,133 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ "use strict";
2
+ /*
3
+ Copyright 2019 Google LLC
4
+
5
+ Use of this source code is governed by an MIT-style
6
+ license that can be found in the LICENSE file or at
7
+ https://opensource.org/licenses/MIT.
8
+ */
9
+ var __importDefault = (this && this.__importDefault) || function (mod) {
10
+ return (mod && mod.__esModule) ? mod : { "default": mod };
11
+ };
12
+ Object.defineProperty(exports, "__esModule", { value: true });
13
+ exports.bundle = void 0;
14
+ const plugin_babel_1 = require("@rollup/plugin-babel");
15
+ const plugin_node_resolve_1 = require("@rollup/plugin-node-resolve");
16
+ const rollup_1 = require("rollup");
17
+ const plugin_terser_1 = __importDefault(require("@rollup/plugin-terser"));
18
+ const fs_extra_1 = require("fs-extra");
19
+ const rollup_plugin_off_main_thread_1 = __importDefault(require("@trickfilm400/rollup-plugin-off-main-thread"));
20
+ const preset_env_1 = __importDefault(require("@babel/preset-env"));
21
+ const plugin_replace_1 = __importDefault(require("@rollup/plugin-replace"));
22
+ const tempy_1 = __importDefault(require("tempy"));
23
+ const upath_1 = __importDefault(require("upath"));
24
+ async function bundle({ babelPresetEnvTargets, inlineWorkboxRuntime, mode, sourcemap, swDest, unbundledCode, }) {
25
+ // We need to write this to the "real" file system, as Rollup won't read from
26
+ // a custom file system.
27
+ const { dir, base } = upath_1.default.parse(swDest);
28
+ const temporaryFile = tempy_1.default.file({ name: base });
29
+ await (0, fs_extra_1.writeFile)(temporaryFile, unbundledCode);
30
+ const plugins = [
31
+ (0, plugin_node_resolve_1.nodeResolve)(),
32
+ (0, plugin_replace_1.default)({
33
+ // See https://github.com/GoogleChrome/workbox/issues/2769
34
+ 'preventAssignment': true,
35
+ 'process.env.NODE_ENV': JSON.stringify(mode),
36
+ }),
37
+ (0, plugin_babel_1.babel)({
38
+ babelHelpers: 'bundled',
39
+ // Disable the logic that checks for local Babel config files:
40
+ // https://github.com/GoogleChrome/workbox/issues/2111
41
+ babelrc: false,
42
+ configFile: false,
43
+ presets: [
44
+ [
45
+ preset_env_1.default,
46
+ {
47
+ targets: {
48
+ browsers: babelPresetEnvTargets,
49
+ },
50
+ loose: true,
51
+ },
52
+ ],
53
+ ],
54
+ }),
55
+ ];
56
+ if (mode === 'production') {
57
+ plugins.push((0, plugin_terser_1.default)({
58
+ mangle: {
59
+ toplevel: true,
60
+ properties: {
61
+ regex: /(^_|_$)/,
62
+ },
63
+ },
64
+ }));
65
+ }
66
+ const rollupConfig = {
67
+ plugins,
68
+ input: temporaryFile,
69
+ };
70
+ // Rollup will inline the runtime by default. If we don't want that, we need
71
+ // to add in some additional config.
72
+ if (!inlineWorkboxRuntime) {
73
+ // No lint for omt(), library has no types.
74
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-call
75
+ rollupConfig.plugins.unshift((0, rollup_plugin_off_main_thread_1.default)());
76
+ }
77
+ const bundle = await (0, rollup_1.rollup)(rollupConfig);
78
+ const outputOptions = {
79
+ sourcemap,
80
+ // Using an external Workbox runtime requires 'amd'.
81
+ format: inlineWorkboxRuntime ? 'es' : 'amd',
82
+ };
83
+ if (!inlineWorkboxRuntime) {
84
+ outputOptions.manualChunks = (id) => {
85
+ return id.includes('workbox') ? 'workbox' : undefined;
86
+ };
87
+ outputOptions.hashCharacters = 'hex';
88
+ }
89
+ const { output } = await bundle.generate(outputOptions);
90
+ const files = [];
91
+ for (const chunkOrAsset of output) {
92
+ if (chunkOrAsset.type === 'asset') {
93
+ if (!files.some((f) => f.name === chunkOrAsset.fileName)) {
94
+ files.push({
95
+ name: chunkOrAsset.fileName,
96
+ contents: chunkOrAsset.source,
97
+ });
98
+ }
99
+ }
100
+ else {
101
+ let code = chunkOrAsset.code;
102
+ if (chunkOrAsset.map) {
103
+ const sourceMapFile = chunkOrAsset.fileName + '.map';
104
+ code += `//# sourceMappingURL=${sourceMapFile}\n`;
105
+ if (!files.some((f) => f.name === sourceMapFile)) {
106
+ files.push({
107
+ name: sourceMapFile,
108
+ contents: chunkOrAsset.map.toString(),
109
+ });
110
+ }
111
+ }
112
+ if (!files.some((f) => f.name === chunkOrAsset.fileName)) {
113
+ files.push({
114
+ name: chunkOrAsset.fileName,
115
+ contents: code,
116
+ });
117
+ }
118
+ }
119
+ }
120
+ // Make sure that if there was a directory portion included in swDest, it's
121
+ // preprended to all of the generated files.
122
+ return files.map((file) => {
123
+ file.name = upath_1.default.format({
124
+ dir,
125
+ base: file.name,
126
+ ext: '',
127
+ name: '',
128
+ root: '',
129
+ });
130
+ return file;
131
+ });
132
+ }
133
+ exports.bundle = bundle;
tools/ui/node_modules/workbox-build/build/lib/cdn-utils.d.ts ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ import { BuildType } from '../types';
2
+ export declare function getModuleURL(moduleName: string, buildType: BuildType): string;
tools/ui/node_modules/workbox-build/build/lib/cdn-utils.js ADDED
@@ -0,0 +1,57 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ "use strict";
2
+ /*
3
+ Copyright 2021 Google LLC
4
+
5
+ Use of this source code is governed by an MIT-style
6
+ license that can be found in the LICENSE file or at
7
+ https://opensource.org/licenses/MIT.
8
+ */
9
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ var desc = Object.getOwnPropertyDescriptor(m, k);
12
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
13
+ desc = { enumerable: true, get: function() { return m[k]; } };
14
+ }
15
+ Object.defineProperty(o, k2, desc);
16
+ }) : (function(o, m, k, k2) {
17
+ if (k2 === undefined) k2 = k;
18
+ o[k2] = m[k];
19
+ }));
20
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
21
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
22
+ }) : function(o, v) {
23
+ o["default"] = v;
24
+ });
25
+ var __importStar = (this && this.__importStar) || function (mod) {
26
+ if (mod && mod.__esModule) return mod;
27
+ var result = {};
28
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
29
+ __setModuleDefault(result, mod);
30
+ return result;
31
+ };
32
+ Object.defineProperty(exports, "__esModule", { value: true });
33
+ exports.getModuleURL = void 0;
34
+ const assert_1 = require("assert");
35
+ const errors_1 = require("./errors");
36
+ const cdn = __importStar(require("../cdn-details.json"));
37
+ function getVersionedURL() {
38
+ return `${getCDNPrefix()}/${cdn.latestVersion}`;
39
+ }
40
+ function getCDNPrefix() {
41
+ return `${cdn.origin}/${cdn.bucketName}/${cdn.releasesDir}`;
42
+ }
43
+ function getModuleURL(moduleName, buildType) {
44
+ (0, assert_1.ok)(moduleName, errors_1.errors['no-module-name']);
45
+ if (buildType) {
46
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
47
+ const pkgJson = require(`${moduleName}/package.json`);
48
+ if (buildType === 'dev' && pkgJson.workbox && pkgJson.workbox.prodOnly) {
49
+ // This is not due to a public-facing exception, so just throw an Error(),
50
+ // without creating an entry in errors.js.
51
+ throw Error(`The 'dev' build of ${moduleName} is not available.`);
52
+ }
53
+ return `${getVersionedURL()}/${moduleName}.${buildType.slice(0, 4)}.js`;
54
+ }
55
+ return `${getVersionedURL()}/${moduleName}.js`;
56
+ }
57
+ exports.getModuleURL = getModuleURL;
tools/ui/node_modules/workbox-build/build/lib/copy-workbox-libraries.d.ts ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * This copies over a set of runtime libraries used by Workbox into a
3
+ * local directory, which should be deployed alongside your service worker file.
4
+ *
5
+ * As an alternative to deploying these local copies, you could instead use
6
+ * Workbox from its official CDN URL.
7
+ *
8
+ * This method is exposed for the benefit of developers using
9
+ * {@link workbox-build.injectManifest} who would
10
+ * prefer not to use the CDN copies of Workbox. Developers using
11
+ * {@link workbox-build.generateSW} don't need to
12
+ * explicitly call this method.
13
+ *
14
+ * @param {string} destDirectory The path to the parent directory under which
15
+ * the new directory of libraries will be created.
16
+ * @return {Promise<string>} The name of the newly created directory.
17
+ *
18
+ * @alias workbox-build.copyWorkboxLibraries
19
+ */
20
+ export declare function copyWorkboxLibraries(destDirectory: string): Promise<string>;
tools/ui/node_modules/workbox-build/build/lib/copy-workbox-libraries.js ADDED
@@ -0,0 +1,69 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ "use strict";
2
+ /*
3
+ Copyright 2018 Google LLC
4
+
5
+ Use of this source code is governed by an MIT-style
6
+ license that can be found in the LICENSE file or at
7
+ https://opensource.org/licenses/MIT.
8
+ */
9
+ var __importDefault = (this && this.__importDefault) || function (mod) {
10
+ return (mod && mod.__esModule) ? mod : { "default": mod };
11
+ };
12
+ Object.defineProperty(exports, "__esModule", { value: true });
13
+ exports.copyWorkboxLibraries = void 0;
14
+ const fs_extra_1 = __importDefault(require("fs-extra"));
15
+ const upath_1 = __importDefault(require("upath"));
16
+ const errors_1 = require("./errors");
17
+ // Used to filter the libraries to copy based on our package.json dependencies.
18
+ const WORKBOX_PREFIX = 'workbox-';
19
+ // The directory within each package containing the final bundles.
20
+ const BUILD_DIR = 'build';
21
+ /**
22
+ * This copies over a set of runtime libraries used by Workbox into a
23
+ * local directory, which should be deployed alongside your service worker file.
24
+ *
25
+ * As an alternative to deploying these local copies, you could instead use
26
+ * Workbox from its official CDN URL.
27
+ *
28
+ * This method is exposed for the benefit of developers using
29
+ * {@link workbox-build.injectManifest} who would
30
+ * prefer not to use the CDN copies of Workbox. Developers using
31
+ * {@link workbox-build.generateSW} don't need to
32
+ * explicitly call this method.
33
+ *
34
+ * @param {string} destDirectory The path to the parent directory under which
35
+ * the new directory of libraries will be created.
36
+ * @return {Promise<string>} The name of the newly created directory.
37
+ *
38
+ * @alias workbox-build.copyWorkboxLibraries
39
+ */
40
+ async function copyWorkboxLibraries(destDirectory) {
41
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
42
+ const thisPkg = require('../../package.json');
43
+ // Use the version string from workbox-build in the name of the parent
44
+ // directory. This should be safe, because lerna will bump workbox-build's
45
+ // pkg.version whenever one of the dependent libraries gets bumped, and we
46
+ // care about versioning the dependent libraries.
47
+ const workboxDirectoryName = `workbox-v${thisPkg.version ? thisPkg.version : ''}`;
48
+ const workboxDirectoryPath = upath_1.default.join(destDirectory, workboxDirectoryName);
49
+ await fs_extra_1.default.ensureDir(workboxDirectoryPath);
50
+ const copyPromises = [];
51
+ const librariesToCopy = Object.keys(thisPkg.dependencies || {}).filter((dependency) => dependency.startsWith(WORKBOX_PREFIX));
52
+ for (const library of librariesToCopy) {
53
+ // Get the path to the package on the user's filesystem by require-ing
54
+ // the package's `package.json` file via the node resolution algorithm.
55
+ const libraryPath = upath_1.default.dirname(require.resolve(`${library}/package.json`));
56
+ const buildPath = upath_1.default.join(libraryPath, BUILD_DIR);
57
+ // fse.copy() copies all the files in a directory, not the directory itself.
58
+ // See https://github.com/jprichardson/node-fs-extra/blob/master/docs/copy.md#copysrc-dest-options-callback
59
+ copyPromises.push(fs_extra_1.default.copy(buildPath, workboxDirectoryPath));
60
+ }
61
+ try {
62
+ await Promise.all(copyPromises);
63
+ return workboxDirectoryName;
64
+ }
65
+ catch (error) {
66
+ throw Error(`${errors_1.errors['unable-to-copy-workbox-libraries']} ${error instanceof Error ? error.toString() : ''}`);
67
+ }
68
+ }
69
+ exports.copyWorkboxLibraries = copyWorkboxLibraries;
tools/ui/node_modules/workbox-build/build/lib/errors.d.ts ADDED
@@ -0,0 +1,61 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ export declare const errors: {
2
+ 'unable-to-get-rootdir': string;
3
+ 'no-extension': string;
4
+ 'invalid-file-manifest-name': string;
5
+ 'unable-to-get-file-manifest-name': string;
6
+ 'invalid-sw-dest': string;
7
+ 'unable-to-get-sw-name': string;
8
+ 'unable-to-get-save-config': string;
9
+ 'unable-to-get-file-hash': string;
10
+ 'unable-to-get-file-size': string;
11
+ 'unable-to-glob-files': string;
12
+ 'unable-to-make-manifest-directory': string;
13
+ 'read-manifest-template-failure': string;
14
+ 'populating-manifest-tmpl-failed': string;
15
+ 'manifest-file-write-failure': string;
16
+ 'unable-to-make-sw-directory': string;
17
+ 'read-sw-template-failure': string;
18
+ 'sw-write-failure': string;
19
+ 'sw-write-failure-directory': string;
20
+ 'unable-to-copy-workbox-libraries': string;
21
+ 'invalid-generate-sw-input': string;
22
+ 'invalid-glob-directory': string;
23
+ 'invalid-dont-cache-bust': string;
24
+ 'invalid-exclude-files': string;
25
+ 'invalid-get-manifest-entries-input': string;
26
+ 'invalid-manifest-path': string;
27
+ 'invalid-manifest-entries': string;
28
+ 'invalid-manifest-format': string;
29
+ 'invalid-static-file-globs': string;
30
+ 'invalid-templated-urls': string;
31
+ 'templated-url-matches-glob': string;
32
+ 'invalid-glob-ignores': string;
33
+ 'manifest-entry-bad-url': string;
34
+ 'modify-url-prefix-bad-prefixes': string;
35
+ 'invalid-inject-manifest-arg': string;
36
+ 'injection-point-not-found': string;
37
+ 'multiple-injection-points': string;
38
+ 'populating-sw-tmpl-failed': string;
39
+ 'useless-glob-pattern': string;
40
+ 'bad-template-urls-asset': string;
41
+ 'invalid-runtime-caching': string;
42
+ 'static-file-globs-deprecated': string;
43
+ 'dynamic-url-deprecated': string;
44
+ 'urlPattern-is-required': string;
45
+ 'handler-is-required': string;
46
+ 'invalid-generate-file-manifest-arg': string;
47
+ 'invalid-sw-src': string;
48
+ 'same-src-and-dest': string;
49
+ 'only-regexp-routes-supported': string;
50
+ 'bad-runtime-caching-config': string;
51
+ 'invalid-network-timeout-seconds': string;
52
+ 'no-module-name': string;
53
+ 'bad-manifest-transforms-return-value': string;
54
+ 'string-entry-warning': string;
55
+ 'no-manifest-entries-or-runtime-caching': string;
56
+ 'cant-find-sourcemap': string;
57
+ 'nav-preload-runtime-caching': string;
58
+ 'cache-name-required': string;
59
+ 'manifest-transforms': string;
60
+ 'invalid-handler-string': string;
61
+ };
tools/ui/node_modules/workbox-build/build/lib/errors.js ADDED
@@ -0,0 +1,125 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ "use strict";
2
+ /*
3
+ Copyright 2018 Google LLC
4
+
5
+ Use of this source code is governed by an MIT-style
6
+ license that can be found in the LICENSE file or at
7
+ https://opensource.org/licenses/MIT.
8
+ */
9
+ Object.defineProperty(exports, "__esModule", { value: true });
10
+ exports.errors = void 0;
11
+ const common_tags_1 = require("common-tags");
12
+ exports.errors = {
13
+ 'unable-to-get-rootdir': `Unable to get the root directory of your web app.`,
14
+ 'no-extension': (0, common_tags_1.oneLine) `Unable to detect a usable extension for a file in your web
15
+ app directory.`,
16
+ 'invalid-file-manifest-name': (0, common_tags_1.oneLine) `The File Manifest Name must have at least one
17
+ character.`,
18
+ 'unable-to-get-file-manifest-name': 'Unable to get a file manifest name.',
19
+ 'invalid-sw-dest': `The 'swDest' value must be a valid path.`,
20
+ 'unable-to-get-sw-name': 'Unable to get a service worker file name.',
21
+ 'unable-to-get-save-config': (0, common_tags_1.oneLine) `An error occurred when asking to save details
22
+ in a config file.`,
23
+ 'unable-to-get-file-hash': (0, common_tags_1.oneLine) `An error occurred when attempting to create a
24
+ file hash.`,
25
+ 'unable-to-get-file-size': (0, common_tags_1.oneLine) `An error occurred when attempting to get a file
26
+ size.`,
27
+ 'unable-to-glob-files': 'An error occurred when globbing for files.',
28
+ 'unable-to-make-manifest-directory': (0, common_tags_1.oneLine) `Unable to make output directory for
29
+ file manifest.`,
30
+ 'read-manifest-template-failure': 'Unable to read template for file manifest',
31
+ 'populating-manifest-tmpl-failed': (0, common_tags_1.oneLine) `An error occurred when populating the
32
+ file manifest template.`,
33
+ 'manifest-file-write-failure': 'Unable to write the file manifest.',
34
+ 'unable-to-make-sw-directory': (0, common_tags_1.oneLine) `Unable to make the directories to output
35
+ the service worker path.`,
36
+ 'read-sw-template-failure': (0, common_tags_1.oneLine) `Unable to read the service worker template
37
+ file.`,
38
+ 'sw-write-failure': 'Unable to write the service worker file.',
39
+ 'sw-write-failure-directory': (0, common_tags_1.oneLine) `Unable to write the service worker file;
40
+ 'swDest' should be a full path to the file, not a path to a directory.`,
41
+ 'unable-to-copy-workbox-libraries': (0, common_tags_1.oneLine) `One or more of the Workbox libraries
42
+ could not be copied over to the destination directory: `,
43
+ 'invalid-generate-sw-input': (0, common_tags_1.oneLine) `The input to generateSW() must be an object.`,
44
+ 'invalid-glob-directory': (0, common_tags_1.oneLine) `The supplied globDirectory must be a path as a
45
+ string.`,
46
+ 'invalid-dont-cache-bust': (0, common_tags_1.oneLine) `The supplied 'dontCacheBustURLsMatching'
47
+ parameter must be a RegExp.`,
48
+ 'invalid-exclude-files': 'The excluded files should be an array of strings.',
49
+ 'invalid-get-manifest-entries-input': (0, common_tags_1.oneLine) `The input to
50
+ 'getFileManifestEntries()' must be an object.`,
51
+ 'invalid-manifest-path': (0, common_tags_1.oneLine) `The supplied manifest path is not a string with
52
+ at least one character.`,
53
+ 'invalid-manifest-entries': (0, common_tags_1.oneLine) `The manifest entries must be an array of
54
+ strings or JavaScript objects containing a url parameter.`,
55
+ 'invalid-manifest-format': (0, common_tags_1.oneLine) `The value of the 'format' option passed to
56
+ generateFileManifest() must be either 'iife' (the default) or 'es'.`,
57
+ 'invalid-static-file-globs': (0, common_tags_1.oneLine) `The 'globPatterns' value must be an array
58
+ of strings.`,
59
+ 'invalid-templated-urls': (0, common_tags_1.oneLine) `The 'templatedURLs' value should be an object
60
+ that maps URLs to either a string, or to an array of glob patterns.`,
61
+ 'templated-url-matches-glob': (0, common_tags_1.oneLine) `One of the 'templatedURLs' URLs is already
62
+ being tracked via 'globPatterns': `,
63
+ 'invalid-glob-ignores': (0, common_tags_1.oneLine) `The 'globIgnores' parameter must be an array of
64
+ glob pattern strings.`,
65
+ 'manifest-entry-bad-url': (0, common_tags_1.oneLine) `The generated manifest contains an entry without
66
+ a URL string. This is likely an error with workbox-build.`,
67
+ 'modify-url-prefix-bad-prefixes': (0, common_tags_1.oneLine) `The 'modifyURLPrefix' parameter must be
68
+ an object with string key value pairs.`,
69
+ 'invalid-inject-manifest-arg': (0, common_tags_1.oneLine) `The input to 'injectManifest()' must be an
70
+ object.`,
71
+ 'injection-point-not-found': (0, common_tags_1.oneLine) `Unable to find a place to inject the manifest.
72
+ Please ensure that your service worker file contains the following: `,
73
+ 'multiple-injection-points': (0, common_tags_1.oneLine) `Please ensure that your 'swSrc' file contains
74
+ only one match for the following: `,
75
+ 'populating-sw-tmpl-failed': (0, common_tags_1.oneLine) `Unable to generate service worker from
76
+ template.`,
77
+ 'useless-glob-pattern': (0, common_tags_1.oneLine) `One of the glob patterns doesn't match any files.
78
+ Please remove or fix the following: `,
79
+ 'bad-template-urls-asset': (0, common_tags_1.oneLine) `There was an issue using one of the provided
80
+ 'templatedURLs'.`,
81
+ 'invalid-runtime-caching': (0, common_tags_1.oneLine) `The 'runtimeCaching' parameter must an an
82
+ array of objects with at least a 'urlPattern' and 'handler'.`,
83
+ 'static-file-globs-deprecated': (0, common_tags_1.oneLine) `'staticFileGlobs' is deprecated.
84
+ Please use 'globPatterns' instead.`,
85
+ 'dynamic-url-deprecated': (0, common_tags_1.oneLine) `'dynamicURLToDependencies' is deprecated.
86
+ Please use 'templatedURLs' instead.`,
87
+ 'urlPattern-is-required': (0, common_tags_1.oneLine) `The 'urlPattern' option is required when using
88
+ 'runtimeCaching'.`,
89
+ 'handler-is-required': (0, common_tags_1.oneLine) `The 'handler' option is required when using
90
+ runtimeCaching.`,
91
+ 'invalid-generate-file-manifest-arg': (0, common_tags_1.oneLine) `The input to generateFileManifest()
92
+ must be an Object.`,
93
+ 'invalid-sw-src': `The 'swSrc' file can't be read.`,
94
+ 'same-src-and-dest': (0, common_tags_1.oneLine) `Unable to find a place to inject the manifest. This is
95
+ likely because swSrc and swDest are configured to the same file.
96
+ Please ensure that your swSrc file contains the following:`,
97
+ 'only-regexp-routes-supported': (0, common_tags_1.oneLine) `Please use a regular expression object as
98
+ the urlPattern parameter. (Express-style routes are not currently
99
+ supported.)`,
100
+ 'bad-runtime-caching-config': (0, common_tags_1.oneLine) `An unknown configuration option was used
101
+ with runtimeCaching: `,
102
+ 'invalid-network-timeout-seconds': (0, common_tags_1.oneLine) `When using networkTimeoutSeconds, you
103
+ must set the handler to 'NetworkFirst'.`,
104
+ 'no-module-name': (0, common_tags_1.oneLine) `You must provide a moduleName parameter when calling
105
+ getModuleURL().`,
106
+ 'bad-manifest-transforms-return-value': (0, common_tags_1.oneLine) `The return value from a
107
+ manifestTransform should be an object with 'manifest' and optionally
108
+ 'warnings' properties.`,
109
+ 'string-entry-warning': (0, common_tags_1.oneLine) `Some items were passed to additionalManifestEntries
110
+ without revisioning info. This is generally NOT safe. Learn more at
111
+ https://bit.ly/wb-precache.`,
112
+ 'no-manifest-entries-or-runtime-caching': (0, common_tags_1.oneLine) `Couldn't find configuration for
113
+ either precaching or runtime caching. Please ensure that the various glob
114
+ options are set to match one or more files, and/or configure the
115
+ runtimeCaching option.`,
116
+ 'cant-find-sourcemap': (0, common_tags_1.oneLine) `The swSrc file refers to a sourcemap that can't be
117
+ opened:`,
118
+ 'nav-preload-runtime-caching': (0, common_tags_1.oneLine) `When using navigationPreload, you must also
119
+ configure a runtimeCaching route that will use the preloaded response.`,
120
+ 'cache-name-required': (0, common_tags_1.oneLine) `When using cache expiration, you must also
121
+ configure a custom cacheName.`,
122
+ 'manifest-transforms': (0, common_tags_1.oneLine) `When using manifestTransforms, you must provide
123
+ an array of functions.`,
124
+ 'invalid-handler-string': (0, common_tags_1.oneLine) `The handler name provided is not valid: `,
125
+ };
tools/ui/node_modules/workbox-build/build/lib/escape-regexp.d.ts ADDED
@@ -0,0 +1 @@
 
 
1
+ export declare function escapeRegExp(str: string): string;
tools/ui/node_modules/workbox-build/build/lib/escape-regexp.js ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ "use strict";
2
+ /*
3
+ Copyright 2019 Google LLC
4
+
5
+ Use of this source code is governed by an MIT-style
6
+ license that can be found in the LICENSE file or at
7
+ https://opensource.org/licenses/MIT.
8
+ */
9
+ Object.defineProperty(exports, "__esModule", { value: true });
10
+ exports.escapeRegExp = void 0;
11
+ // From https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions
12
+ function escapeRegExp(str) {
13
+ return str.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
14
+ }
15
+ exports.escapeRegExp = escapeRegExp;
tools/ui/node_modules/workbox-build/build/lib/get-composite-details.d.ts ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ import { FileDetails } from '../types';
2
+ export declare function getCompositeDetails(compositeURL: string, dependencyDetails: Array<FileDetails>): FileDetails;
tools/ui/node_modules/workbox-build/build/lib/get-composite-details.js ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ "use strict";
2
+ /*
3
+ Copyright 2018 Google LLC
4
+
5
+ Use of this source code is governed by an MIT-style
6
+ license that can be found in the LICENSE file or at
7
+ https://opensource.org/licenses/MIT.
8
+ */
9
+ var __importDefault = (this && this.__importDefault) || function (mod) {
10
+ return (mod && mod.__esModule) ? mod : { "default": mod };
11
+ };
12
+ Object.defineProperty(exports, "__esModule", { value: true });
13
+ exports.getCompositeDetails = void 0;
14
+ const crypto_1 = __importDefault(require("crypto"));
15
+ function getCompositeDetails(compositeURL, dependencyDetails) {
16
+ let totalSize = 0;
17
+ let compositeHash = '';
18
+ for (const fileDetails of dependencyDetails) {
19
+ totalSize += fileDetails.size;
20
+ compositeHash += fileDetails.hash;
21
+ }
22
+ const md5 = crypto_1.default.createHash('md5');
23
+ md5.update(compositeHash);
24
+ const hashOfHashes = md5.digest('hex');
25
+ return {
26
+ file: compositeURL,
27
+ hash: hashOfHashes,
28
+ size: totalSize,
29
+ };
30
+ }
31
+ exports.getCompositeDetails = getCompositeDetails;
tools/ui/node_modules/workbox-build/build/lib/get-file-details.d.ts ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { GlobPartial } from '../types';
2
+ interface FileDetails {
3
+ file: string;
4
+ hash: string;
5
+ size: number;
6
+ }
7
+ export declare function getFileDetails({ globDirectory, globFollow, globIgnores, globPattern, }: Omit<GlobPartial, 'globDirectory' | 'globPatterns' | 'templatedURLs'> & {
8
+ globDirectory: string;
9
+ globPattern: string;
10
+ }): {
11
+ globbedFileDetails: Array<FileDetails>;
12
+ warning: string;
13
+ };
14
+ export {};
tools/ui/node_modules/workbox-build/build/lib/get-file-details.js ADDED
@@ -0,0 +1,54 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ "use strict";
2
+ /*
3
+ Copyright 2021 Google LLC
4
+
5
+ Use of this source code is governed by an MIT-style
6
+ license that can be found in the LICENSE file or at
7
+ https://opensource.org/licenses/MIT.
8
+ */
9
+ var __importDefault = (this && this.__importDefault) || function (mod) {
10
+ return (mod && mod.__esModule) ? mod : { "default": mod };
11
+ };
12
+ Object.defineProperty(exports, "__esModule", { value: true });
13
+ exports.getFileDetails = void 0;
14
+ const glob_1 = require("glob");
15
+ const upath_1 = __importDefault(require("upath"));
16
+ const errors_1 = require("./errors");
17
+ const get_file_size_1 = require("./get-file-size");
18
+ const get_file_hash_1 = require("./get-file-hash");
19
+ function getFileDetails({ globDirectory, globFollow, globIgnores, globPattern, }) {
20
+ let globbedFiles;
21
+ let warning = '';
22
+ try {
23
+ globbedFiles = (0, glob_1.globSync)(globPattern, {
24
+ cwd: globDirectory,
25
+ follow: globFollow,
26
+ ignore: globIgnores,
27
+ });
28
+ }
29
+ catch (err) {
30
+ throw new Error(errors_1.errors['unable-to-glob-files'] +
31
+ ` '${err instanceof Error && err.message ? err.message : ''}'`);
32
+ }
33
+ if (globbedFiles.length === 0) {
34
+ warning =
35
+ errors_1.errors['useless-glob-pattern'] +
36
+ ' ' +
37
+ JSON.stringify({ globDirectory, globPattern, globIgnores }, null, 2);
38
+ }
39
+ const globbedFileDetails = [];
40
+ for (const file of globbedFiles) {
41
+ const fullPath = upath_1.default.join(globDirectory, file);
42
+ const fileSize = (0, get_file_size_1.getFileSize)(fullPath);
43
+ if (fileSize !== null) {
44
+ const fileHash = (0, get_file_hash_1.getFileHash)(fullPath);
45
+ globbedFileDetails.push({
46
+ file: `${upath_1.default.relative(globDirectory, fullPath)}`,
47
+ hash: fileHash,
48
+ size: fileSize,
49
+ });
50
+ }
51
+ }
52
+ return { globbedFileDetails, warning };
53
+ }
54
+ exports.getFileDetails = getFileDetails;
tools/ui/node_modules/workbox-build/build/lib/get-file-hash.d.ts ADDED
@@ -0,0 +1 @@
 
 
1
+ export declare function getFileHash(file: string): string;
tools/ui/node_modules/workbox-build/build/lib/get-file-hash.js ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ "use strict";
2
+ /*
3
+ Copyright 2018 Google LLC
4
+
5
+ Use of this source code is governed by an MIT-style
6
+ license that can be found in the LICENSE file or at
7
+ https://opensource.org/licenses/MIT.
8
+ */
9
+ var __importDefault = (this && this.__importDefault) || function (mod) {
10
+ return (mod && mod.__esModule) ? mod : { "default": mod };
11
+ };
12
+ Object.defineProperty(exports, "__esModule", { value: true });
13
+ exports.getFileHash = void 0;
14
+ const fs_extra_1 = __importDefault(require("fs-extra"));
15
+ const get_string_hash_1 = require("./get-string-hash");
16
+ const errors_1 = require("./errors");
17
+ function getFileHash(file) {
18
+ try {
19
+ const buffer = fs_extra_1.default.readFileSync(file);
20
+ return (0, get_string_hash_1.getStringHash)(buffer);
21
+ }
22
+ catch (err) {
23
+ throw new Error(errors_1.errors['unable-to-get-file-hash'] +
24
+ ` '${err instanceof Error && err.message ? err.message : ''}'`);
25
+ }
26
+ }
27
+ exports.getFileHash = getFileHash;
tools/ui/node_modules/workbox-build/build/lib/get-file-manifest-entries.d.ts ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ import { GetManifestResult, GetManifestOptions } from '../types';
2
+ export declare function getFileManifestEntries({ additionalManifestEntries, dontCacheBustURLsMatching, globDirectory, globFollow, globIgnores, globPatterns, manifestTransforms, maximumFileSizeToCacheInBytes, modifyURLPrefix, templatedURLs, }: GetManifestOptions): Promise<GetManifestResult>;
tools/ui/node_modules/workbox-build/build/lib/get-file-manifest-entries.js ADDED
@@ -0,0 +1,96 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ "use strict";
2
+ /*
3
+ Copyright 2021 Google LLC
4
+
5
+ Use of this source code is governed by an MIT-style
6
+ license that can be found in the LICENSE file or at
7
+ https://opensource.org/licenses/MIT.
8
+ */
9
+ var __importDefault = (this && this.__importDefault) || function (mod) {
10
+ return (mod && mod.__esModule) ? mod : { "default": mod };
11
+ };
12
+ Object.defineProperty(exports, "__esModule", { value: true });
13
+ exports.getFileManifestEntries = void 0;
14
+ const assert_1 = __importDefault(require("assert"));
15
+ const errors_1 = require("./errors");
16
+ const get_composite_details_1 = require("./get-composite-details");
17
+ const get_file_details_1 = require("./get-file-details");
18
+ const get_string_details_1 = require("./get-string-details");
19
+ const transform_manifest_1 = require("./transform-manifest");
20
+ async function getFileManifestEntries({ additionalManifestEntries, dontCacheBustURLsMatching, globDirectory, globFollow, globIgnores, globPatterns = [], manifestTransforms, maximumFileSizeToCacheInBytes, modifyURLPrefix, templatedURLs, }) {
21
+ const warnings = [];
22
+ const allFileDetails = new Map();
23
+ try {
24
+ for (const globPattern of globPatterns) {
25
+ const { globbedFileDetails, warning } = (0, get_file_details_1.getFileDetails)({
26
+ globDirectory,
27
+ globFollow,
28
+ globIgnores,
29
+ globPattern,
30
+ });
31
+ if (warning) {
32
+ warnings.push(warning);
33
+ }
34
+ for (const details of globbedFileDetails) {
35
+ if (details && !allFileDetails.has(details.file)) {
36
+ allFileDetails.set(details.file, details);
37
+ }
38
+ }
39
+ }
40
+ }
41
+ catch (error) {
42
+ // If there's an exception thrown while globbing, then report
43
+ // it back as a warning, and don't consider it fatal.
44
+ if (error instanceof Error && error.message) {
45
+ warnings.push(error.message);
46
+ }
47
+ }
48
+ if (templatedURLs) {
49
+ for (const url of Object.keys(templatedURLs)) {
50
+ (0, assert_1.default)(!allFileDetails.has(url), errors_1.errors['templated-url-matches-glob']);
51
+ const dependencies = templatedURLs[url];
52
+ if (Array.isArray(dependencies)) {
53
+ const details = dependencies.reduce((previous, globPattern) => {
54
+ try {
55
+ const { globbedFileDetails, warning } = (0, get_file_details_1.getFileDetails)({
56
+ globDirectory,
57
+ globFollow,
58
+ globIgnores,
59
+ globPattern,
60
+ });
61
+ if (warning) {
62
+ warnings.push(warning);
63
+ }
64
+ return previous.concat(globbedFileDetails);
65
+ }
66
+ catch (error) {
67
+ const debugObj = {};
68
+ debugObj[url] = dependencies;
69
+ throw new Error(`${errors_1.errors['bad-template-urls-asset']} ` +
70
+ `'${globPattern}' from '${JSON.stringify(debugObj)}':\n` +
71
+ `${error instanceof Error ? error.toString() : ''}`);
72
+ }
73
+ }, []);
74
+ if (details.length === 0) {
75
+ throw new Error(`${errors_1.errors['bad-template-urls-asset']} The glob ` +
76
+ `pattern '${dependencies.toString()}' did not match anything.`);
77
+ }
78
+ allFileDetails.set(url, (0, get_composite_details_1.getCompositeDetails)(url, details));
79
+ }
80
+ else if (typeof dependencies === 'string') {
81
+ allFileDetails.set(url, (0, get_string_details_1.getStringDetails)(url, dependencies));
82
+ }
83
+ }
84
+ }
85
+ const transformedManifest = await (0, transform_manifest_1.transformManifest)({
86
+ additionalManifestEntries,
87
+ dontCacheBustURLsMatching,
88
+ manifestTransforms,
89
+ maximumFileSizeToCacheInBytes,
90
+ modifyURLPrefix,
91
+ fileDetails: Array.from(allFileDetails.values()),
92
+ });
93
+ transformedManifest.warnings.push(...warnings);
94
+ return transformedManifest;
95
+ }
96
+ exports.getFileManifestEntries = getFileManifestEntries;
tools/ui/node_modules/workbox-build/build/lib/get-file-size.d.ts ADDED
@@ -0,0 +1 @@
 
 
1
+ export declare function getFileSize(file: string): number | null;
tools/ui/node_modules/workbox-build/build/lib/get-file-size.js ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ "use strict";
2
+ /*
3
+ Copyright 2018 Google LLC
4
+
5
+ Use of this source code is governed by an MIT-style
6
+ license that can be found in the LICENSE file or at
7
+ https://opensource.org/licenses/MIT.
8
+ */
9
+ var __importDefault = (this && this.__importDefault) || function (mod) {
10
+ return (mod && mod.__esModule) ? mod : { "default": mod };
11
+ };
12
+ Object.defineProperty(exports, "__esModule", { value: true });
13
+ exports.getFileSize = void 0;
14
+ const fs_extra_1 = __importDefault(require("fs-extra"));
15
+ const errors_1 = require("./errors");
16
+ function getFileSize(file) {
17
+ try {
18
+ const stat = fs_extra_1.default.statSync(file);
19
+ if (!stat.isFile()) {
20
+ return null;
21
+ }
22
+ return stat.size;
23
+ }
24
+ catch (err) {
25
+ throw new Error(errors_1.errors['unable-to-get-file-size'] +
26
+ ` '${err instanceof Error && err.message ? err.message : ''}'`);
27
+ }
28
+ }
29
+ exports.getFileSize = getFileSize;
tools/ui/node_modules/workbox-build/build/lib/get-source-map-url.d.ts ADDED
@@ -0,0 +1 @@
 
 
1
+ export declare function getSourceMapURL(srcContents: string): string | null;
tools/ui/node_modules/workbox-build/build/lib/get-source-map-url.js ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ "use strict";
2
+ /*
3
+ Copyright 2022 Google LLC
4
+
5
+ Use of this source code is governed by an MIT-style
6
+ license that can be found in the LICENSE file or at
7
+ https://opensource.org/licenses/MIT.
8
+ */
9
+ Object.defineProperty(exports, "__esModule", { value: true });
10
+ exports.getSourceMapURL = void 0;
11
+ // Adapted from https://github.com/lydell/source-map-url/blob/master/source-map-url.js
12
+ // See https://github.com/GoogleChrome/workbox/issues/3019
13
+ const innerRegex = /[#@] sourceMappingURL=([^\s'"]*)/;
14
+ const regex = RegExp('(?:' +
15
+ '/\\*' +
16
+ '(?:\\s*\r?\n(?://)?)?' +
17
+ '(?:' +
18
+ innerRegex.source +
19
+ ')' +
20
+ '\\s*' +
21
+ '\\*/' +
22
+ '|' +
23
+ '//(?:' +
24
+ innerRegex.source +
25
+ ')' +
26
+ ')' +
27
+ '\\s*');
28
+ function getSourceMapURL(srcContents) {
29
+ const match = srcContents.match(regex);
30
+ return match ? match[1] || match[2] || '' : null;
31
+ }
32
+ exports.getSourceMapURL = getSourceMapURL;
tools/ui/node_modules/workbox-build/build/lib/get-string-details.d.ts ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ import { FileDetails } from '../types';
2
+ export declare function getStringDetails(url: string, str: string): FileDetails;
tools/ui/node_modules/workbox-build/build/lib/get-string-details.js ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ "use strict";
2
+ /*
3
+ Copyright 2018 Google LLC
4
+
5
+ Use of this source code is governed by an MIT-style
6
+ license that can be found in the LICENSE file or at
7
+ https://opensource.org/licenses/MIT.
8
+ */
9
+ Object.defineProperty(exports, "__esModule", { value: true });
10
+ exports.getStringDetails = void 0;
11
+ const get_string_hash_1 = require("./get-string-hash");
12
+ function getStringDetails(url, str) {
13
+ return {
14
+ file: url,
15
+ hash: (0, get_string_hash_1.getStringHash)(str),
16
+ size: str.length,
17
+ };
18
+ }
19
+ exports.getStringDetails = getStringDetails;
tools/ui/node_modules/workbox-build/build/lib/get-string-hash.d.ts ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ /// <reference types="node" />
2
+ import crypto from 'crypto';
3
+ export declare function getStringHash(input: crypto.BinaryLike): string;
tools/ui/node_modules/workbox-build/build/lib/get-string-hash.js ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ "use strict";
2
+ /*
3
+ Copyright 2018 Google LLC
4
+
5
+ Use of this source code is governed by an MIT-style
6
+ license that can be found in the LICENSE file or at
7
+ https://opensource.org/licenses/MIT.
8
+ */
9
+ var __importDefault = (this && this.__importDefault) || function (mod) {
10
+ return (mod && mod.__esModule) ? mod : { "default": mod };
11
+ };
12
+ Object.defineProperty(exports, "__esModule", { value: true });
13
+ exports.getStringHash = void 0;
14
+ const crypto_1 = __importDefault(require("crypto"));
15
+ function getStringHash(input) {
16
+ const md5 = crypto_1.default.createHash('md5');
17
+ md5.update(input);
18
+ return md5.digest('hex');
19
+ }
20
+ exports.getStringHash = getStringHash;
tools/ui/node_modules/workbox-build/build/lib/maximum-size-transform.d.ts ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ import { ManifestTransform } from '../types';
2
+ export declare function maximumSizeTransform(maximumFileSizeToCacheInBytes: number): ManifestTransform;
tools/ui/node_modules/workbox-build/build/lib/maximum-size-transform.js ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ "use strict";
2
+ /*
3
+ Copyright 2018 Google LLC
4
+
5
+ Use of this source code is governed by an MIT-style
6
+ license that can be found in the LICENSE file or at
7
+ https://opensource.org/licenses/MIT.
8
+ */
9
+ var __importDefault = (this && this.__importDefault) || function (mod) {
10
+ return (mod && mod.__esModule) ? mod : { "default": mod };
11
+ };
12
+ Object.defineProperty(exports, "__esModule", { value: true });
13
+ exports.maximumSizeTransform = void 0;
14
+ const pretty_bytes_1 = __importDefault(require("pretty-bytes"));
15
+ function maximumSizeTransform(maximumFileSizeToCacheInBytes) {
16
+ return (originalManifest) => {
17
+ const warnings = [];
18
+ const manifest = originalManifest.filter((entry) => {
19
+ if (entry.size <= maximumFileSizeToCacheInBytes) {
20
+ return true;
21
+ }
22
+ warnings.push(`${entry.url} is ${(0, pretty_bytes_1.default)(entry.size)}, and won't ` +
23
+ `be precached. Configure maximumFileSizeToCacheInBytes to change ` +
24
+ `this limit.`);
25
+ return false;
26
+ });
27
+ return { manifest, warnings };
28
+ };
29
+ }
30
+ exports.maximumSizeTransform = maximumSizeTransform;
tools/ui/node_modules/workbox-build/build/lib/modify-url-prefix-transform.d.ts ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ import { ManifestTransform } from '../types';
2
+ export declare function modifyURLPrefixTransform(modifyURLPrefix: {
3
+ [key: string]: string;
4
+ }): ManifestTransform;
tools/ui/node_modules/workbox-build/build/lib/modify-url-prefix-transform.js ADDED
@@ -0,0 +1,51 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ "use strict";
2
+ /*
3
+ Copyright 2018 Google LLC
4
+
5
+ Use of this source code is governed by an MIT-style
6
+ license that can be found in the LICENSE file or at
7
+ https://opensource.org/licenses/MIT.
8
+ */
9
+ Object.defineProperty(exports, "__esModule", { value: true });
10
+ exports.modifyURLPrefixTransform = void 0;
11
+ const errors_1 = require("./errors");
12
+ const escape_regexp_1 = require("./escape-regexp");
13
+ function modifyURLPrefixTransform(modifyURLPrefix) {
14
+ if (!modifyURLPrefix ||
15
+ typeof modifyURLPrefix !== 'object' ||
16
+ Array.isArray(modifyURLPrefix)) {
17
+ throw new Error(errors_1.errors['modify-url-prefix-bad-prefixes']);
18
+ }
19
+ // If there are no entries in modifyURLPrefix, just return an identity
20
+ // function as a shortcut.
21
+ if (Object.keys(modifyURLPrefix).length === 0) {
22
+ return (manifest) => {
23
+ return { manifest };
24
+ };
25
+ }
26
+ for (const key of Object.keys(modifyURLPrefix)) {
27
+ if (typeof modifyURLPrefix[key] !== 'string') {
28
+ throw new Error(errors_1.errors['modify-url-prefix-bad-prefixes']);
29
+ }
30
+ }
31
+ // Escape the user input so it's safe to use in a regex.
32
+ const safeModifyURLPrefixes = Object.keys(modifyURLPrefix).map(escape_regexp_1.escapeRegExp);
33
+ // Join all the `modifyURLPrefix` keys so a single regex can be used.
34
+ const prefixMatchesStrings = safeModifyURLPrefixes.join('|');
35
+ // Add `^` to the front the prefix matches so it only matches the start of
36
+ // a string.
37
+ const modifyRegex = new RegExp(`^(${prefixMatchesStrings})`);
38
+ return (originalManifest) => {
39
+ const manifest = originalManifest.map((entry) => {
40
+ if (typeof entry.url !== 'string') {
41
+ throw new Error(errors_1.errors['manifest-entry-bad-url']);
42
+ }
43
+ entry.url = entry.url.replace(modifyRegex, (match) => {
44
+ return modifyURLPrefix[match];
45
+ });
46
+ return entry;
47
+ });
48
+ return { manifest };
49
+ };
50
+ }
51
+ exports.modifyURLPrefixTransform = modifyURLPrefixTransform;
tools/ui/node_modules/workbox-build/build/lib/module-registry.d.ts ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * Class for keeping track of which Workbox modules are used by the generated
3
+ * service worker script.
4
+ *
5
+ * @private
6
+ */
7
+ export declare class ModuleRegistry {
8
+ private readonly _modulesUsed;
9
+ /**
10
+ * @private
11
+ */
12
+ constructor();
13
+ /**
14
+ * @return {Array<string>} A list of all of the import statements that are
15
+ * needed for the modules being used.
16
+ * @private
17
+ */
18
+ getImportStatements(): Array<string>;
19
+ /**
20
+ * @param {string} pkg The workbox package that the module belongs to.
21
+ * @param {string} moduleName The name of the module to import.
22
+ * @return {string} The local variable name that corresponds to that module.
23
+ * @private
24
+ */
25
+ getLocalName(pkg: string, moduleName: string): string;
26
+ /**
27
+ * @param {string} pkg The workbox package that the module belongs to.
28
+ * @param {string} moduleName The name of the module to import.
29
+ * @return {string} The local variable name that corresponds to that module.
30
+ * @private
31
+ */
32
+ use(pkg: string, moduleName: string): string;
33
+ }
tools/ui/node_modules/workbox-build/build/lib/module-registry.js ADDED
@@ -0,0 +1,70 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ "use strict";
2
+ /*
3
+ Copyright 2019 Google LLC
4
+
5
+ Use of this source code is governed by an MIT-style
6
+ license that can be found in the LICENSE file or at
7
+ https://opensource.org/licenses/MIT.
8
+ */
9
+ var __importDefault = (this && this.__importDefault) || function (mod) {
10
+ return (mod && mod.__esModule) ? mod : { "default": mod };
11
+ };
12
+ Object.defineProperty(exports, "__esModule", { value: true });
13
+ exports.ModuleRegistry = void 0;
14
+ const common_tags_1 = require("common-tags");
15
+ const upath_1 = __importDefault(require("upath"));
16
+ /**
17
+ * Class for keeping track of which Workbox modules are used by the generated
18
+ * service worker script.
19
+ *
20
+ * @private
21
+ */
22
+ class ModuleRegistry {
23
+ /**
24
+ * @private
25
+ */
26
+ constructor() {
27
+ this._modulesUsed = new Map();
28
+ }
29
+ /**
30
+ * @return {Array<string>} A list of all of the import statements that are
31
+ * needed for the modules being used.
32
+ * @private
33
+ */
34
+ getImportStatements() {
35
+ const workboxModuleImports = [];
36
+ for (const [localName, { moduleName, pkg }] of this._modulesUsed) {
37
+ // By default require.resolve returns the resolved path of the 'main'
38
+ // field, which might be deeper than the package root. To work around
39
+ // this, we can find the package's root by resolving its package.json and
40
+ // strip the '/package.json' from the resolved path.
41
+ const pkgJsonPath = require.resolve(`${pkg}/package.json`);
42
+ const pkgRoot = upath_1.default.dirname(pkgJsonPath);
43
+ const importStatement = (0, common_tags_1.oneLine) `import {${moduleName} as ${localName}} from
44
+ '${pkgRoot}/${moduleName}.mjs';`;
45
+ workboxModuleImports.push(importStatement);
46
+ }
47
+ return workboxModuleImports;
48
+ }
49
+ /**
50
+ * @param {string} pkg The workbox package that the module belongs to.
51
+ * @param {string} moduleName The name of the module to import.
52
+ * @return {string} The local variable name that corresponds to that module.
53
+ * @private
54
+ */
55
+ getLocalName(pkg, moduleName) {
56
+ return `${pkg.replace(/-/g, '_')}_${moduleName}`;
57
+ }
58
+ /**
59
+ * @param {string} pkg The workbox package that the module belongs to.
60
+ * @param {string} moduleName The name of the module to import.
61
+ * @return {string} The local variable name that corresponds to that module.
62
+ * @private
63
+ */
64
+ use(pkg, moduleName) {
65
+ const localName = this.getLocalName(pkg, moduleName);
66
+ this._modulesUsed.set(localName, { moduleName, pkg });
67
+ return localName;
68
+ }
69
+ }
70
+ exports.ModuleRegistry = ModuleRegistry;
tools/ui/node_modules/workbox-build/build/lib/no-revision-for-urls-matching-transform.d.ts ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ import { ManifestTransform } from '../types';
2
+ export declare function noRevisionForURLsMatchingTransform(regexp: RegExp): ManifestTransform;
tools/ui/node_modules/workbox-build/build/lib/no-revision-for-urls-matching-transform.js ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ "use strict";
2
+ /*
3
+ Copyright 2018 Google LLC
4
+
5
+ Use of this source code is governed by an MIT-style
6
+ license that can be found in the LICENSE file or at
7
+ https://opensource.org/licenses/MIT.
8
+ */
9
+ Object.defineProperty(exports, "__esModule", { value: true });
10
+ exports.noRevisionForURLsMatchingTransform = void 0;
11
+ const errors_1 = require("./errors");
12
+ function noRevisionForURLsMatchingTransform(regexp) {
13
+ if (!(regexp instanceof RegExp)) {
14
+ throw new Error(errors_1.errors['invalid-dont-cache-bust']);
15
+ }
16
+ return (originalManifest) => {
17
+ const manifest = originalManifest.map((entry) => {
18
+ if (typeof entry.url !== 'string') {
19
+ throw new Error(errors_1.errors['manifest-entry-bad-url']);
20
+ }
21
+ if (entry.url.match(regexp)) {
22
+ entry.revision = null;
23
+ }
24
+ return entry;
25
+ });
26
+ return { manifest };
27
+ };
28
+ }
29
+ exports.noRevisionForURLsMatchingTransform = noRevisionForURLsMatchingTransform;
tools/ui/node_modules/workbox-build/build/lib/populate-sw-template.d.ts ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ import { GeneratePartial, ManifestEntry } from '../types';
2
+ export declare function populateSWTemplate({ cacheId, cleanupOutdatedCaches, clientsClaim, directoryIndex, disableDevLogs, ignoreURLParametersMatching, importScripts, manifestEntries, navigateFallback, navigateFallbackDenylist, navigateFallbackAllowlist, navigationPreload, offlineGoogleAnalytics, runtimeCaching, skipWaiting, }: GeneratePartial & {
3
+ manifestEntries?: Array<ManifestEntry>;
4
+ }): string;
tools/ui/node_modules/workbox-build/build/lib/populate-sw-template.js ADDED
@@ -0,0 +1,80 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ "use strict";
2
+ /*
3
+ Copyright 2018 Google LLC
4
+
5
+ Use of this source code is governed by an MIT-style
6
+ license that can be found in the LICENSE file or at
7
+ https://opensource.org/licenses/MIT.
8
+ */
9
+ Object.defineProperty(exports, "__esModule", { value: true });
10
+ exports.populateSWTemplate = void 0;
11
+ const eta_1 = require("eta");
12
+ const errors_1 = require("./errors");
13
+ const module_registry_1 = require("./module-registry");
14
+ const runtime_caching_converter_1 = require("./runtime-caching-converter");
15
+ const stringify_without_comments_1 = require("./stringify-without-comments");
16
+ const sw_template_1 = require("../templates/sw-template");
17
+ const eta = new eta_1.Eta({
18
+ useWith: true,
19
+ autoEscape: false,
20
+ });
21
+ function populateSWTemplate({ cacheId, cleanupOutdatedCaches, clientsClaim, directoryIndex, disableDevLogs, ignoreURLParametersMatching, importScripts, manifestEntries = [], navigateFallback, navigateFallbackDenylist, navigateFallbackAllowlist, navigationPreload, offlineGoogleAnalytics, runtimeCaching = [], skipWaiting, }) {
22
+ // There needs to be at least something to precache, or else runtime caching.
23
+ if (!((manifestEntries === null || manifestEntries === void 0 ? void 0 : manifestEntries.length) > 0 || runtimeCaching.length > 0)) {
24
+ throw new Error(errors_1.errors['no-manifest-entries-or-runtime-caching']);
25
+ }
26
+ // These are all options that can be passed to the precacheAndRoute() method.
27
+ const precacheOptions = {
28
+ directoryIndex,
29
+ // An array of RegExp objects can't be serialized by JSON.stringify()'s
30
+ // default behavior, so if it's given, convert it manually.
31
+ ignoreURLParametersMatching: ignoreURLParametersMatching
32
+ ? []
33
+ : undefined,
34
+ };
35
+ let precacheOptionsString = JSON.stringify(precacheOptions, null, 2);
36
+ if (ignoreURLParametersMatching) {
37
+ precacheOptionsString = precacheOptionsString.replace(`"ignoreURLParametersMatching": []`, `"ignoreURLParametersMatching": [` +
38
+ `${ignoreURLParametersMatching.join(', ')}]`);
39
+ }
40
+ let offlineAnalyticsConfigString = undefined;
41
+ if (offlineGoogleAnalytics) {
42
+ // If offlineGoogleAnalytics is a truthy value, we need to convert it to the
43
+ // format expected by the template.
44
+ offlineAnalyticsConfigString =
45
+ offlineGoogleAnalytics === true
46
+ ? // If it's the literal value true, then use an empty config string.
47
+ '{}'
48
+ : // Otherwise, convert the config object into a more complex string, taking
49
+ // into account the fact that functions might need to be stringified.
50
+ (0, stringify_without_comments_1.stringifyWithoutComments)(offlineGoogleAnalytics);
51
+ }
52
+ const moduleRegistry = new module_registry_1.ModuleRegistry();
53
+ try {
54
+ const populatedTemplate = eta.renderString(sw_template_1.swTemplate, {
55
+ cacheId,
56
+ cleanupOutdatedCaches,
57
+ clientsClaim,
58
+ disableDevLogs,
59
+ importScripts,
60
+ manifestEntries,
61
+ navigateFallback,
62
+ navigateFallbackDenylist,
63
+ navigateFallbackAllowlist,
64
+ navigationPreload,
65
+ offlineAnalyticsConfigString,
66
+ precacheOptionsString,
67
+ runtimeCaching: (0, runtime_caching_converter_1.runtimeCachingConverter)(moduleRegistry, runtimeCaching),
68
+ skipWaiting,
69
+ use: moduleRegistry.use.bind(moduleRegistry),
70
+ });
71
+ const workboxImportStatements = moduleRegistry.getImportStatements();
72
+ // We need the import statements for all of the Workbox runtime modules
73
+ // prepended, so that the correct bundle can be created.
74
+ return workboxImportStatements.join('\n') + populatedTemplate;
75
+ }
76
+ catch (error) {
77
+ throw new Error(`${errors_1.errors['populating-sw-tmpl-failed']} '${error instanceof Error && error.message ? error.message : ''}'`);
78
+ }
79
+ }
80
+ exports.populateSWTemplate = populateSWTemplate;
tools/ui/node_modules/workbox-build/build/lib/rebase-path.d.ts ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ export declare function rebasePath({ baseDirectory, file, }: {
2
+ baseDirectory: string;
3
+ file: string;
4
+ }): string;
tools/ui/node_modules/workbox-build/build/lib/rebase-path.js ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ "use strict";
2
+ /*
3
+ Copyright 2019 Google LLC
4
+
5
+ Use of this source code is governed by an MIT-style
6
+ license that can be found in the LICENSE file or at
7
+ https://opensource.org/licenses/MIT.
8
+ */
9
+ var __importDefault = (this && this.__importDefault) || function (mod) {
10
+ return (mod && mod.__esModule) ? mod : { "default": mod };
11
+ };
12
+ Object.defineProperty(exports, "__esModule", { value: true });
13
+ exports.rebasePath = void 0;
14
+ const upath_1 = __importDefault(require("upath"));
15
+ function rebasePath({ baseDirectory, file, }) {
16
+ // The initial path is relative to the current directory, so make it absolute.
17
+ const absolutePath = upath_1.default.resolve(file);
18
+ // Convert the absolute path so that it's relative to the baseDirectory.
19
+ const relativePath = upath_1.default.relative(baseDirectory, absolutePath);
20
+ // Remove any leading ./ as it won't work in a glob pattern.
21
+ const normalizedPath = upath_1.default.normalize(relativePath);
22
+ return normalizedPath;
23
+ }
24
+ exports.rebasePath = rebasePath;
tools/ui/node_modules/workbox-build/build/lib/replace-and-update-source-map.d.ts ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { RawSourceMap } from 'source-map';
2
+ /**
3
+ * Adapted from https://github.com/nsams/sourcemap-aware-replace, with modern
4
+ * JavaScript updates, along with additional properties copied from originalMap.
5
+ *
6
+ * @param {Object} options
7
+ * @param {string} options.jsFilename The name for the file whose contents
8
+ * correspond to originalSource.
9
+ * @param {Object} options.originalMap The sourcemap for originalSource,
10
+ * prior to any replacements.
11
+ * @param {string} options.originalSource The source code, prior to any
12
+ * replacements.
13
+ * @param {string} options.replaceString A string to swap in for searchString.
14
+ * @param {string} options.searchString A string in originalSource to replace.
15
+ * Only the first occurrence will be replaced.
16
+ * @return {{source: string, map: string}} An object containing both
17
+ * originalSource with the replacement applied, and the modified originalMap.
18
+ *
19
+ * @private
20
+ */
21
+ export declare function replaceAndUpdateSourceMap({ jsFilename, originalMap, originalSource, replaceString, searchString, }: {
22
+ jsFilename: string;
23
+ originalMap: RawSourceMap;
24
+ originalSource: string;
25
+ replaceString: string;
26
+ searchString: string;
27
+ }): Promise<{
28
+ map: string;
29
+ source: string;
30
+ }>;
tools/ui/node_modules/workbox-build/build/lib/replace-and-update-source-map.js ADDED
@@ -0,0 +1,98 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ "use strict";
2
+ /*
3
+ Copyright 2019 Google LLC
4
+
5
+ Use of this source code is governed by an MIT-style
6
+ license that can be found in the LICENSE file or at
7
+ https://opensource.org/licenses/MIT.
8
+ */
9
+ Object.defineProperty(exports, "__esModule", { value: true });
10
+ exports.replaceAndUpdateSourceMap = void 0;
11
+ const source_map_1 = require("source-map");
12
+ /**
13
+ * Adapted from https://github.com/nsams/sourcemap-aware-replace, with modern
14
+ * JavaScript updates, along with additional properties copied from originalMap.
15
+ *
16
+ * @param {Object} options
17
+ * @param {string} options.jsFilename The name for the file whose contents
18
+ * correspond to originalSource.
19
+ * @param {Object} options.originalMap The sourcemap for originalSource,
20
+ * prior to any replacements.
21
+ * @param {string} options.originalSource The source code, prior to any
22
+ * replacements.
23
+ * @param {string} options.replaceString A string to swap in for searchString.
24
+ * @param {string} options.searchString A string in originalSource to replace.
25
+ * Only the first occurrence will be replaced.
26
+ * @return {{source: string, map: string}} An object containing both
27
+ * originalSource with the replacement applied, and the modified originalMap.
28
+ *
29
+ * @private
30
+ */
31
+ async function replaceAndUpdateSourceMap({ jsFilename, originalMap, originalSource, replaceString, searchString, }) {
32
+ const generator = new source_map_1.SourceMapGenerator({
33
+ file: jsFilename,
34
+ });
35
+ const consumer = await new source_map_1.SourceMapConsumer(originalMap);
36
+ let pos;
37
+ let src = originalSource;
38
+ const replacements = [];
39
+ let lineNum = 0;
40
+ let filePos = 0;
41
+ const lines = src.split('\n');
42
+ for (let line of lines) {
43
+ lineNum++;
44
+ let searchPos = 0;
45
+ while ((pos = line.indexOf(searchString, searchPos)) !== -1) {
46
+ src =
47
+ src.substring(0, filePos + pos) +
48
+ replaceString +
49
+ src.substring(filePos + pos + searchString.length);
50
+ line =
51
+ line.substring(0, pos) +
52
+ replaceString +
53
+ line.substring(pos + searchString.length);
54
+ replacements.push({ line: lineNum, column: pos });
55
+ searchPos = pos + replaceString.length;
56
+ }
57
+ filePos += line.length + 1;
58
+ }
59
+ replacements.reverse();
60
+ consumer.eachMapping((mapping) => {
61
+ for (const replacement of replacements) {
62
+ if (replacement.line === mapping.generatedLine &&
63
+ mapping.generatedColumn > replacement.column) {
64
+ const offset = searchString.length - replaceString.length;
65
+ mapping.generatedColumn -= offset;
66
+ }
67
+ }
68
+ if (mapping.source) {
69
+ const newMapping = {
70
+ generated: {
71
+ line: mapping.generatedLine,
72
+ column: mapping.generatedColumn,
73
+ },
74
+ original: {
75
+ line: mapping.originalLine,
76
+ column: mapping.originalColumn,
77
+ },
78
+ source: mapping.source,
79
+ };
80
+ return generator.addMapping(newMapping);
81
+ }
82
+ return mapping;
83
+ });
84
+ consumer.destroy();
85
+ // JSON.parse returns any.
86
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
87
+ const updatedSourceMap = Object.assign(JSON.parse(generator.toString()), {
88
+ names: originalMap.names,
89
+ sourceRoot: originalMap.sourceRoot,
90
+ sources: originalMap.sources,
91
+ sourcesContent: originalMap.sourcesContent,
92
+ });
93
+ return {
94
+ map: JSON.stringify(updatedSourceMap),
95
+ source: src,
96
+ };
97
+ }
98
+ exports.replaceAndUpdateSourceMap = replaceAndUpdateSourceMap;
tools/ui/node_modules/workbox-build/build/lib/runtime-caching-converter.d.ts ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ import { ModuleRegistry } from './module-registry';
2
+ import { RuntimeCaching } from '../types';
3
+ export declare function runtimeCachingConverter(moduleRegistry: ModuleRegistry, runtimeCaching: Array<RuntimeCaching>): Array<string>;
tools/ui/node_modules/workbox-build/build/lib/runtime-caching-converter.js ADDED
@@ -0,0 +1,142 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ "use strict";
2
+ /*
3
+ Copyright 2018 Google LLC
4
+
5
+ Use of this source code is governed by an MIT-style
6
+ license that can be found in the LICENSE file or at
7
+ https://opensource.org/licenses/MIT.
8
+ */
9
+ Object.defineProperty(exports, "__esModule", { value: true });
10
+ exports.runtimeCachingConverter = void 0;
11
+ const common_tags_1 = require("common-tags");
12
+ const errors_1 = require("./errors");
13
+ const stringify_without_comments_1 = require("./stringify-without-comments");
14
+ /**
15
+ * Given a set of options that configures runtime caching behavior, convert it
16
+ * to the equivalent Workbox method calls.
17
+ *
18
+ * @param {ModuleRegistry} moduleRegistry
19
+ * @param {Object} options See
20
+ * https://developers.google.com/web/tools/workbox/modules/workbox-build#generateSW-runtimeCaching
21
+ * @return {string} A JSON string representing the equivalent options.
22
+ *
23
+ * @private
24
+ */
25
+ function getOptionsString(moduleRegistry, options = {}) {
26
+ const plugins = [];
27
+ const handlerOptions = {};
28
+ for (const optionName of Object.keys(options)) {
29
+ if (options[optionName] === undefined) {
30
+ continue;
31
+ }
32
+ switch (optionName) {
33
+ // Using a library here because JSON.stringify won't handle functions.
34
+ case 'plugins': {
35
+ plugins.push(...options.plugins.map(stringify_without_comments_1.stringifyWithoutComments));
36
+ break;
37
+ }
38
+ // These are the option properties that we want to pull out, so that
39
+ // they're passed to the handler constructor.
40
+ case 'cacheName':
41
+ case 'networkTimeoutSeconds':
42
+ case 'fetchOptions':
43
+ case 'matchOptions': {
44
+ handlerOptions[optionName] = options[optionName];
45
+ break;
46
+ }
47
+ // The following cases are all shorthands for creating a plugin with a
48
+ // given configuration.
49
+ case 'backgroundSync': {
50
+ const name = options.backgroundSync.name;
51
+ const plugin = moduleRegistry.use('workbox-background-sync', 'BackgroundSyncPlugin');
52
+ let pluginCode = `new ${plugin}(${JSON.stringify(name)}`;
53
+ if (options.backgroundSync.options) {
54
+ pluginCode += `, ${(0, stringify_without_comments_1.stringifyWithoutComments)(options.backgroundSync.options)}`;
55
+ }
56
+ pluginCode += `)`;
57
+ plugins.push(pluginCode);
58
+ break;
59
+ }
60
+ case 'broadcastUpdate': {
61
+ const channelName = options.broadcastUpdate.channelName;
62
+ const opts = Object.assign({ channelName }, options.broadcastUpdate.options);
63
+ const plugin = moduleRegistry.use('workbox-broadcast-update', 'BroadcastUpdatePlugin');
64
+ plugins.push(`new ${plugin}(${(0, stringify_without_comments_1.stringifyWithoutComments)(opts)})`);
65
+ break;
66
+ }
67
+ case 'cacheableResponse': {
68
+ const plugin = moduleRegistry.use('workbox-cacheable-response', 'CacheableResponsePlugin');
69
+ plugins.push(`new ${plugin}(${(0, stringify_without_comments_1.stringifyWithoutComments)(options.cacheableResponse)})`);
70
+ break;
71
+ }
72
+ case 'expiration': {
73
+ const plugin = moduleRegistry.use('workbox-expiration', 'ExpirationPlugin');
74
+ plugins.push(`new ${plugin}(${(0, stringify_without_comments_1.stringifyWithoutComments)(options.expiration)})`);
75
+ break;
76
+ }
77
+ case 'precacheFallback': {
78
+ const plugin = moduleRegistry.use('workbox-precaching', 'PrecacheFallbackPlugin');
79
+ plugins.push(`new ${plugin}(${(0, stringify_without_comments_1.stringifyWithoutComments)(options.precacheFallback)})`);
80
+ break;
81
+ }
82
+ case 'rangeRequests': {
83
+ const plugin = moduleRegistry.use('workbox-range-requests', 'RangeRequestsPlugin');
84
+ // There are no configuration options for the constructor.
85
+ plugins.push(`new ${plugin}()`);
86
+ break;
87
+ }
88
+ default: {
89
+ throw new Error(
90
+ // In the default case optionName is typed as 'never'.
91
+ // eslint-disable-next-line @typescript-eslint/restrict-template-expressions
92
+ `${errors_1.errors['bad-runtime-caching-config']} ${optionName}`);
93
+ }
94
+ }
95
+ }
96
+ if (Object.keys(handlerOptions).length > 0 || plugins.length > 0) {
97
+ const optionsString = JSON.stringify(handlerOptions).slice(1, -1);
98
+ return (0, common_tags_1.oneLine) `{
99
+ ${optionsString ? optionsString + ',' : ''}
100
+ plugins: [${plugins.join(', ')}]
101
+ }`;
102
+ }
103
+ else {
104
+ return '';
105
+ }
106
+ }
107
+ function runtimeCachingConverter(moduleRegistry, runtimeCaching) {
108
+ return runtimeCaching
109
+ .map((entry) => {
110
+ const method = entry.method || 'GET';
111
+ if (!entry.urlPattern) {
112
+ throw new Error(errors_1.errors['urlPattern-is-required']);
113
+ }
114
+ if (!entry.handler) {
115
+ throw new Error(errors_1.errors['handler-is-required']);
116
+ }
117
+ if (entry.options &&
118
+ entry.options.networkTimeoutSeconds &&
119
+ entry.handler !== 'NetworkFirst') {
120
+ throw new Error(errors_1.errors['invalid-network-timeout-seconds']);
121
+ }
122
+ // urlPattern might be a string, a RegExp object, or a function.
123
+ // If it's a string, it needs to be quoted.
124
+ const matcher = typeof entry.urlPattern === 'string'
125
+ ? JSON.stringify(entry.urlPattern)
126
+ : entry.urlPattern;
127
+ const registerRoute = moduleRegistry.use('workbox-routing', 'registerRoute');
128
+ if (typeof entry.handler === 'string') {
129
+ const optionsString = getOptionsString(moduleRegistry, entry.options);
130
+ const handler = moduleRegistry.use('workbox-strategies', entry.handler);
131
+ const strategyString = `new ${handler}(${optionsString})`;
132
+ return `${registerRoute}(${matcher.toString()}, ${strategyString}, '${method}');\n`;
133
+ }
134
+ else if (typeof entry.handler === 'function') {
135
+ return `${registerRoute}(${matcher.toString()}, ${entry.handler.toString()}, '${method}');\n`;
136
+ }
137
+ // '' will be filtered out.
138
+ return '';
139
+ })
140
+ .filter((entry) => Boolean(entry));
141
+ }
142
+ exports.runtimeCachingConverter = runtimeCachingConverter;
tools/ui/node_modules/workbox-build/build/lib/stringify-without-comments.d.ts ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ export declare function stringifyWithoutComments(obj: {
2
+ [key: string]: any;
3
+ }): string;
tools/ui/node_modules/workbox-build/build/lib/stringify-without-comments.js ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ "use strict";
2
+ /*
3
+ Copyright 2021 Google LLC
4
+
5
+ Use of this source code is governed by an MIT-style
6
+ license that can be found in the LICENSE file or at
7
+ https://opensource.org/licenses/MIT.
8
+ */
9
+ var __importDefault = (this && this.__importDefault) || function (mod) {
10
+ return (mod && mod.__esModule) ? mod : { "default": mod };
11
+ };
12
+ Object.defineProperty(exports, "__esModule", { value: true });
13
+ exports.stringifyWithoutComments = void 0;
14
+ const stringify_object_1 = __importDefault(require("stringify-object"));
15
+ const strip_comments_1 = __importDefault(require("strip-comments"));
16
+ function stringifyWithoutComments(obj) {
17
+ return (0, stringify_object_1.default)(obj, {
18
+ // See https://github.com/yeoman/stringify-object#transformobject-property-originalresult
19
+ transform: (_obj, _prop, str) => {
20
+ if (typeof _prop !== 'symbol' && typeof _obj[_prop] === 'function') {
21
+ // Can't typify correctly stripComments
22
+ return (0, strip_comments_1.default)(str); // eslint-disable-line
23
+ }
24
+ return str;
25
+ },
26
+ });
27
+ }
28
+ exports.stringifyWithoutComments = stringifyWithoutComments;