{"size": 3789, "ext": "js", "max_stars_repo_path": "node_modules/workbox-build/build/generate-sw.js", "max_stars_repo_name": "guicardozodasilva/github-api-react", "max_stars_repo_stars_event_min_datetime": "2022-03-29T06:46:53.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-29T06:46:53.000Z", "max_issues_repo_path": "node_modules/workbox-build/build/generate-sw.js", "max_issues_repo_name": "ZagalJ/ReactPortfolio", "max_issues_repo_issues_event_min_datetime": "2022-01-21T10:21:50.000Z", "max_issues_repo_issues_event_max_datetime": "2022-01-28T12:58:53.000Z", "max_forks_repo_path": "node_modules/workbox-build/build/generate-sw.js", "max_forks_repo_name": "SHINZAMONO/Morning_v0.0.1", "max_forks_repo_forks_event_min_datetime": "2022-03-30T00:36:40.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-30T00:36:40.000Z"}
{"max_stars_count": 1, "max_issues_count": 3, "max_forks_count": 1, "avg_line_length": 35.7452830189, "max_line_length": 110, "alphanum_fraction": 0.6286619161}
"use strict";
/*
  Copyright 2018 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.
*/
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.generateSW = void 0;
const upath_1 = __importDefault(require("upath"));
const get_file_manifest_entries_1 = require("./lib/get-file-manifest-entries");
const rebase_path_1 = require("./lib/rebase-path");
const validate_options_1 = require("./lib/validate-options");
const write_sw_using_default_template_1 = require("./lib/write-sw-using-default-template");
/**
 * This method creates a list of URLs to precache, referred to as a "precache
 * manifest", based on the options you provide.
 *
 * It also takes in additional options that configures the service worker's
 * behavior, like any `runtimeCaching` rules it should use.
 *
 * Based on the precache manifest and the additional configuration, it writes
 * a ready-to-use service worker file to disk at `swDest`.
 *
 * ```
 * // The following lists some common options; see the rest of the documentation
 * // for the full set of options and defaults.
 * const {count, size, warnings} = await generateSW({
 *   dontCacheBustURLsMatching: [new RegExp('...')],
 *   globDirectory: '...',
 *   globPatterns: ['...', '...'],
 *   maximumFileSizeToCacheInBytes: ...,
 *   navigateFallback: '...',
 *   runtimeCaching: [{
 *     // Routing via a matchCallback function:
 *     urlPattern: ({request, url}) => ...,
 *     handler: '...',
 *     options: {
 *       cacheName: '...',
 *       expiration: {
 *         maxEntries: ...,
 *       },
 *     },
 *   }, {
 *     // Routing via a RegExp:
 *     urlPattern: new RegExp('...'),
 *     handler: '...',
 *     options: {
 *       cacheName: '...',
 *       plugins: [..., ...],
 *     },
 *   }],
 *   skipWaiting: ...,
 *   swDest: '...',
 * });
 * ```
 *
 * @memberof workbox-build
 */
async function generateSW(config) {
    const options = (0, validate_options_1.validateGenerateSWOptions)(config);
    let entriesResult;
    if (options.globDirectory) {
        // Make sure we leave swDest out of the precache manifest.
        options.globIgnores.push((0, rebase_path_1.rebasePath)({
            baseDirectory: options.globDirectory,
            file: options.swDest,
        }));
        // If we create an extra external runtime file, ignore that, too.
        // See https://rollupjs.org/guide/en/#outputchunkfilenames for naming.
        if (!options.inlineWorkboxRuntime) {
            const swDestDir = upath_1.default.dirname(options.swDest);
            const workboxRuntimeFile = upath_1.default.join(swDestDir, 'workbox-*.js');
            options.globIgnores.push((0, rebase_path_1.rebasePath)({
                baseDirectory: options.globDirectory,
                file: workboxRuntimeFile,
            }));
        }
        // We've previously asserted that options.globDirectory is set, so this
        // should be a safe cast.
        entriesResult = await (0, get_file_manifest_entries_1.getFileManifestEntries)(options);
    }
    else {
        entriesResult = {
            count: 0,
            manifestEntries: [],
            size: 0,
            warnings: [],
        };
    }
    const filePaths = await (0, write_sw_using_default_template_1.writeSWUsingDefaultTemplate)(Object.assign({
        manifestEntries: entriesResult.manifestEntries,
    }, options));
    return {
        filePaths,
        count: entriesResult.count,
        size: entriesResult.size,
        warnings: entriesResult.warnings,
    };
}
exports.generateSW = generateSW;
