{"size": 5303, "ext": "js", "max_stars_repo_path": "web/frontend/node_modules/workbox-build/build/lib/filter-files.js", "max_stars_repo_name": "atesbilgin/ENELPI---Soru-Cevap-Sistemi", "max_stars_repo_stars_event_min_datetime": "2020-01-07T13:37:29.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-26T11:22:35.000Z", "max_issues_repo_path": "web/frontend/node_modules/workbox-build/build/lib/filter-files.js", "max_issues_repo_name": "atesbilgin/ENELPI---Soru-Cevap-Sistemi", "max_issues_repo_issues_event_min_datetime": "2020-09-24T23:53:29.000Z", "max_issues_repo_issues_event_max_datetime": "2020-10-31T09:19:29.000Z", "max_forks_repo_path": "web/frontend/node_modules/workbox-build/build/lib/filter-files.js", "max_forks_repo_name": "atesbilgin/ENELPI---Soru-Cevap-Sistemi", "max_forks_repo_forks_event_min_datetime": "2020-09-24T23:59:38.000Z", "max_forks_repo_forks_event_max_datetime": "2021-10-31T13:24:30.000Z"}
{"max_stars_count": 177, "max_issues_count": 153, "max_forks_count": 481, "avg_line_length": 32.1393939394, "max_line_length": 177, "alphanum_fraction": 0.6931925325}
"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.
*/
const maximumSizeTransform = require('./maximum-size-transform');

const modifyURLPrefixTranform = require('./modify-url-prefix-transform');

const noRevisionForURLsMatchingTransform = require('./no-revision-for-urls-matching-transform');
/**
 * A `ManifestTransform` function can be used to modify the modify the `url` or
 * `revision` properties of some or all of the
 * {@link module:workbox-build#ManifestEntry|ManifestEntries} in the manifest.
 *
 * Deleting the `revision` property of an entry will cause
 * the corresponding `url` to be precached without cache-busting parameters
 * applied, which is to say, it implies that the URL itself contains
 * proper versioning info. If the `revision` property is present, it must be
 * set to a string.
 *
 * @example <caption>A transformation that prepended the origin of a CDN for any
 * URL starting with '/assets/' could be implemented as:</caption>
 *
 * const cdnTransform = (manifestEntries) => {
 *   const manifest = manifestEntries.map(entry => {
 *     const cdnOrigin = 'https://example.com';
 *     if (entry.url.startsWith('/assets/')) {
 *       entry.url = cdnOrigin + entry.url;
 *     }
 *     return entry;
 *   });
 *   return {manifest, warnings: []};
 * };
 *
 * @example <caption>A transformation that removes the revision field when the
 * URL contains an 8-character hash surrounded by '.', indicating that it
 * already contains revision information:</caption>
 *
 * const removeRevisionTransform = (manifestEntries) => {
 *   const manifest = manifestEntries.map(entry => {
 *     const hashRegExp = /\.\w{8}\./;
 *     if (entry.url.match(hashRegExp)) {
 *       delete entry.revision;
 *     }
 *     return entry;
 *   });
 *   return {manifest, warnings: []};
 * };
 *
 * @callback ManifestTransform
 * @param {Array<module:workbox-build.ManifestEntry>} manifestEntries The full
 * array of entries, prior to the current transformation.
 * @return {module:workbox-build.ManifestTransformResult}
 * The array of entries with the transformation applied, and optionally, any
 * warnings that should be reported back to the build tool.
 *
 * @memberof module:workbox-build
 */


module.exports = ({
  dontCacheBustURLsMatching,
  fileDetails,
  manifestTransforms,
  maximumFileSizeToCacheInBytes,
  modifyURLPrefix
}) => {
  let allWarnings = []; // Take the array of fileDetail objects and convert it into an array of
  // {url, revision, size} objects, with \ replaced with /.

  const normalizedManifest = fileDetails.map(fileDetails => {
    return {
      url: fileDetails.file.replace(/\\/g, '/'),
      revision: fileDetails.hash,
      size: fileDetails.size
    };
  });
  let transformsToApply = [];

  if (maximumFileSizeToCacheInBytes) {
    transformsToApply.push(maximumSizeTransform(maximumFileSizeToCacheInBytes));
  }

  if (modifyURLPrefix) {
    transformsToApply.push(modifyURLPrefixTranform(modifyURLPrefix));
  }

  if (dontCacheBustURLsMatching) {
    transformsToApply.push(noRevisionForURLsMatchingTransform(dontCacheBustURLsMatching));
  } // Any additional manifestTransforms that were passed will be applied last.


  transformsToApply = transformsToApply.concat(manifestTransforms || []);
  let transformedManifest = normalizedManifest;
  var _iteratorNormalCompletion = true;
  var _didIteratorError = false;
  var _iteratorError = undefined;

  try {
    for (var _iterator = transformsToApply[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
      const transform = _step.value;

      const _transform = transform(transformedManifest),
            manifest = _transform.manifest,
            warnings = _transform.warnings;

      transformedManifest = manifest;
      allWarnings = allWarnings.concat(warnings || []);
    } // Generate some metadata about the manifest before we clear out the size
    // properties from each entry.

  } catch (err) {
    _didIteratorError = true;
    _iteratorError = err;
  } finally {
    try {
      if (!_iteratorNormalCompletion && _iterator.return != null) {
        _iterator.return();
      }
    } finally {
      if (_didIteratorError) {
        throw _iteratorError;
      }
    }
  }

  const count = transformedManifest.length;
  let size = 0;
  var _iteratorNormalCompletion2 = true;
  var _didIteratorError2 = false;
  var _iteratorError2 = undefined;

  try {
    for (var _iterator2 = transformedManifest[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {
      const manifestEntry = _step2.value;
      size += manifestEntry.size;
      delete manifestEntry.size;
    }
  } catch (err) {
    _didIteratorError2 = true;
    _iteratorError2 = err;
  } finally {
    try {
      if (!_iteratorNormalCompletion2 && _iterator2.return != null) {
        _iterator2.return();
      }
    } finally {
      if (_didIteratorError2) {
        throw _iteratorError2;
      }
    }
  }

  return {
    count,
    size,
    manifestEntries: transformedManifest,
    warnings: allWarnings
  };
};