forked from GoogleChromeLabs/sw-toolbox
-
Notifications
You must be signed in to change notification settings - Fork 0
/
sw-toolbox.js.map
1 lines (1 loc) · 66.5 KB
/
sw-toolbox.js.map
1
{"version":3,"sources":["node_modules/browser-pack/_prelude.js","lib/helpers.js","lib/idb-cache-expiration.js","lib/listeners.js","lib/options.js","lib/route.js","lib/router.js","lib/strategies/cacheFirst.js","lib/strategies/cacheOnly.js","lib/strategies/fastest.js","lib/strategies/index.js","lib/strategies/networkFirst.js","lib/strategies/networkOnly.js","lib/sw-toolbox.js","node_modules/isarray/index.js","node_modules/path-to-regexp/index.js","node_modules/serviceworker-cache-polyfill/index.js"],"names":["f","exports","module","define","amd","g","window","global","self","this","toolbox","e","t","n","r","s","o","u","a","require","i","Error","code","l","call","length","1","debug","message","options","globalOptions","console","log","openCache","cacheName","cache","name","caches","open","fetchAndCache","request","successResponses","fetch","clone","then","response","method","test","status","put","cacheOptions","maxEntries","maxAgeSeconds","queueCacheExpiration","cleanup","cleanupCache","bind","cleanupQueue","requestUrl","url","now","Date","idbCacheExpiration","getDb","db","setTimestampForUrl","expireEntries","urlsToDelete","deletionPromises","map","urlToDelete","delete","Promise","all","catch","error","renameCache","source","destination","results","sourceCache","destCache","keys","requests","match","add","uncache","precache","items","validatePrecacheInput","preCacheItems","concat","isValid","Array","isArray","forEach","item","Request","TypeError","isResponseFresh","dateHeader","headers","get","getTime","openDb","resolve","reject","indexedDB","DB_PREFIX","DB_VERSION","onupgradeneeded","result","createObjectStore","STORE_NAME","keyPath","URL_PROPERTY","createIndex","TIMESTAMP_PROPERTY","unique","onsuccess","onerror","cacheNameToDbPromise","transaction","objectStore","timestamp","oncomplete","onabort","expireOldEntries","maxAgeMillis","urls","index","openCursor","cursorEvent","cursor","target","value","push","continue","expireExtraEntries","countRequest","count","initialCount","oldUrls","extraUrls","fetchListener","event","handler","router","respondWith","default","indexOf","activateListener","helpers","inactiveCache","waitUntil","flatten","reduce","b","installListener","join","addAll","scope","registration","URL","location","href","queryOptions","networkTimeoutSeconds","basePath","pathname","pathRegexp","Route","path","RegExp","fullUrlRegExp","regexp","prototype","makeHandler","values","exec","key","regexEscape","replace","keyMatch","string","entriesIterator","entries","next","matches","done","Router","routes","Map","set","origin","toLowerCase","route","has","methodMap","routeMap","regExp","matchMethod","urlObject","_match","methodMaps","pathOrUrl","cacheFirst","cacheQueryOptions","cacheOnly","fastest","rejected","reasons","maybeReject","reason","toString","maybeResolve","Response","networkOnly","networkFirst","timeoutId","originalResponse","promises","cacheWhenTimedOutPromise","setTimeout","networkPromise","clearTimeout","statusText","race","strategies","listeners","addEventListener","arr","Object","parse","str","res","tokens","defaultDelimiter","delimiter","PATH_REGEXP","m","escaped","offset","slice","prefix","capture","group","modifier","asterisk","partial","repeat","optional","pattern","escapeGroup","escapeString","substr","compile","tokensToFunction","encodeURIComponentPretty","encodeURI","c","charCodeAt","toUpperCase","encodeAsterisk","obj","opts","data","encode","pretty","encodeURIComponent","token","segment","isarray","JSON","stringify","j","attachKeys","re","flags","sensitive","regexpToRegexp","groups","arrayToRegexp","parts","pathToRegexp","stringToRegexp","tokensToRegExp","strict","end","endsWithDelimiter","nativeAddAll","Cache","userAgent","navigator","agent","version","parseInt","NetworkError","create","arguments","String","scheme","protocol","responses","some","ok"],"mappings":";;;;;;;;;;;;;;GAAA,SAAAA,GAAA,GAAA,gBAAAC,UAAA,mBAAAC,QAAAA,OAAAD,QAAAD,QAAA,IAAA,kBAAAG,SAAAA,OAAAC,IAAAD,UAAAH,OAAA,CAAA,GAAAK,EAAAA,GAAA,mBAAAC,QAAAA,OAAA,mBAAAC,QAAAA,OAAA,mBAAAC,MAAAA,KAAAC,KAAAJ,EAAAK,QAAAV,MAAA,WAAA,MAAA,SAAAW,GAAAC,EAAAC,EAAAC,GAAA,QAAAC,GAAAC,EAAAC,GAAA,IAAAJ,EAAAG,GAAA,CAAA,IAAAJ,EAAAI,GAAA,CAAA,GAAAE,GAAA,kBAAAC,UAAAA,OAAA,KAAAF,GAAAC,EA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AA,IAAAyE,UAcA,OATAf,GAAAA,EAAAd,IAAA,SAAA7B,GACA,MAAAA,aAAAyD,SACAzD,EAGAoQ,OAAApQ,KAIAgC,QAAAC,IACAU,EAAAd,IAAA,SAAA7B,GACA,gBAAAA,KACAA,EAAA,GAAAyD,SAAAzD,GAGA,IAAAqQ,GAAA,GAAA1I,KAAA3H,EAAAmB,KAAAmP,QAEA,IAAA,UAAAD,GAAA,WAAAA,EACA,KAAA,IAAAJ,GAAA,iBAGA,OAAA/P,OAAAF,EAAAG,cAGAC,KAAA,SAAAmQ,GAGA,GAAAA,EAAAC,KAAA,SAAAnQ,GACA,OAAAA,EAAAoQ,KAEA,KAAA,IAAAR,GAAA,4BAKA,OAAAjO,SAAAC,IACAsO,EAAA1O,IAAA,SAAAxB,EAAAzB,GACA,MAAAe,GAAAc,IAAAkC,EAAA/D,GAAAyB,QAGAD,KAAA,eAKAuP,MAAAnH,UAAA3F,IAAA,SAAA7C,GACA,MAAA/B,MAAAuJ,QAAAxH","file":"sw-toolbox.js","sourcesContent":["(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require==\"function\"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error(\"Cannot find module '\"+o+\"'\");throw f.code=\"MODULE_NOT_FOUND\",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require==\"function\"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})","/*\n Copyright 2014 Google Inc. All Rights Reserved.\n\n Licensed under the Apache License, Version 2.0 (the \"License\");\n you may not use this file except in compliance with the License.\n You may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\n Unless required by applicable law or agreed to in writing, software\n distributed under the License is distributed on an \"AS IS\" BASIS,\n WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n See the License for the specific language governing permissions and\n limitations under the License.\n*/\n'use strict';\n\nvar globalOptions = require('./options');\nvar idbCacheExpiration = require('./idb-cache-expiration');\n\nfunction debug(message, options) {\n options = options || {};\n var flag = options.debug || globalOptions.debug;\n if (flag) {\n console.log('[sw-toolbox] ' + message);\n }\n}\n\nfunction openCache(options) {\n var cacheName;\n if (options && options.cache) {\n cacheName = options.cache.name;\n }\n cacheName = cacheName || globalOptions.cache.name;\n\n return caches.open(cacheName);\n}\n\nfunction fetchAndCache(request, options) {\n options = options || {};\n var successResponses = options.successResponses ||\n globalOptions.successResponses;\n\n return fetch(request.clone()).then(function(response) {\n // Only cache GET requests with successful responses.\n // Since this is not part of the promise chain, it will be done\n // asynchronously and will not block the response from being returned to the\n // page.\n if (request.method === 'GET' && successResponses.test(response.status)) {\n openCache(options).then(function(cache) {\n cache.put(request, response).then(function() {\n // If any of the options are provided in options.cache then use them.\n // Do not fallback to the global options for any that are missing\n // unless they are all missing.\n var cacheOptions = options.cache || globalOptions.cache;\n\n // Only run the cache expiration logic if at least one of the maximums\n // is set, and if we have a name for the cache that the options are\n // being applied to.\n if ((cacheOptions.maxEntries || cacheOptions.maxAgeSeconds) &&\n cacheOptions.name) {\n queueCacheExpiration(request, cache, cacheOptions);\n }\n });\n });\n }\n\n return response.clone();\n });\n}\n\nvar cleanupQueue;\nfunction queueCacheExpiration(request, cache, cacheOptions) {\n var cleanup = cleanupCache.bind(null, request, cache, cacheOptions);\n\n if (cleanupQueue) {\n cleanupQueue = cleanupQueue.then(cleanup);\n } else {\n cleanupQueue = cleanup();\n }\n}\n\nfunction cleanupCache(request, cache, cacheOptions) {\n var requestUrl = request.url;\n var maxAgeSeconds = cacheOptions.maxAgeSeconds;\n var maxEntries = cacheOptions.maxEntries;\n var cacheName = cacheOptions.name;\n\n var now = Date.now();\n debug('Updating LRU order for ' + requestUrl + '. Max entries is ' +\n maxEntries + ', max age is ' + maxAgeSeconds);\n\n return idbCacheExpiration.getDb(cacheName).then(function(db) {\n return idbCacheExpiration.setTimestampForUrl(db, requestUrl, now);\n }).then(function(db) {\n return idbCacheExpiration.expireEntries(db, maxEntries, maxAgeSeconds, now);\n }).then(function(urlsToDelete) {\n debug('Successfully updated IDB.');\n\n var deletionPromises = urlsToDelete.map(function(urlToDelete) {\n return cache.delete(urlToDelete);\n });\n\n return Promise.all(deletionPromises).then(function() {\n debug('Done with cache cleanup.');\n });\n }).catch(function(error) {\n debug(error);\n });\n}\n\nfunction renameCache(source, destination, options) {\n debug('Renaming cache: [' + source + '] to [' + destination + ']', options);\n return caches.delete(destination).then(function() {\n return Promise.all([\n caches.open(source),\n caches.open(destination)\n ]).then(function(results) {\n var sourceCache = results[0];\n var destCache = results[1];\n\n return sourceCache.keys().then(function(requests) {\n return Promise.all(requests.map(function(request) {\n return sourceCache.match(request).then(function(response) {\n return destCache.put(request, response);\n });\n }));\n }).then(function() {\n return caches.delete(source);\n });\n });\n });\n}\n\nfunction cache(url, options) {\n return openCache(options).then(function(cache) {\n return cache.add(url);\n });\n}\n\nfunction uncache(url, options) {\n return openCache(options).then(function(cache) {\n return cache.delete(url);\n });\n}\n\nfunction precache(items) {\n if (!(items instanceof Promise)) {\n validatePrecacheInput(items);\n }\n\n globalOptions.preCacheItems = globalOptions.preCacheItems.concat(items);\n}\n\nfunction validatePrecacheInput(items) {\n var isValid = Array.isArray(items);\n if (isValid) {\n items.forEach(function(item) {\n if (!(typeof item === 'string' || (item instanceof Request))) {\n isValid = false;\n }\n });\n }\n\n if (!isValid) {\n throw new TypeError('The precache method expects either an array of ' +\n 'strings and/or Requests or a Promise that resolves to an array of ' +\n 'strings and/or Requests.');\n }\n\n return items;\n}\n\nfunction isResponseFresh(response, maxAgeSeconds, now) {\n // If we don't have a response, then it's not fresh.\n if (!response) {\n return false;\n }\n\n // Only bother checking the age of the response if maxAgeSeconds is set.\n if (maxAgeSeconds) {\n var dateHeader = response.headers.get('date');\n // If there's no Date: header, then fall through and return true.\n if (dateHeader) {\n var parsedDate = new Date(dateHeader);\n // If the Date: header was invalid for some reason, parsedDate.getTime()\n // will return NaN, and the comparison will always be false. That means\n // that an invalid date will be treated as if the response is fresh.\n if ((parsedDate.getTime() + (maxAgeSeconds * 1000)) < now) {\n // Only return false if all the other conditions are met.\n return false;\n }\n }\n }\n\n // Fall back on returning true by default, to match the previous behavior in\n // which we never bothered checking to see whether the response was fresh.\n return true;\n}\n\nmodule.exports = {\n debug: debug,\n fetchAndCache: fetchAndCache,\n openCache: openCache,\n renameCache: renameCache,\n cache: cache,\n uncache: uncache,\n precache: precache,\n validatePrecacheInput: validatePrecacheInput,\n isResponseFresh: isResponseFresh\n};\n","/*\n Copyright 2015 Google Inc. All Rights Reserved.\n\n Licensed under the Apache License, Version 2.0 (the \"License\");\n you may not use this file except in compliance with the License.\n You may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\n Unless required by applicable law or agreed to in writing, software\n distributed under the License is distributed on an \"AS IS\" BASIS,\n WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n See the License for the specific language governing permissions and\n limitations under the License.\n*/\n'use strict';\n\nvar DB_PREFIX = 'sw-toolbox-';\nvar DB_VERSION = 1;\nvar STORE_NAME = 'store';\nvar URL_PROPERTY = 'url';\nvar TIMESTAMP_PROPERTY = 'timestamp';\nvar cacheNameToDbPromise = {};\n\nfunction openDb(cacheName) {\n return new Promise(function(resolve, reject) {\n var request = indexedDB.open(DB_PREFIX + cacheName, DB_VERSION);\n\n request.onupgradeneeded = function() {\n var objectStore = request.result.createObjectStore(STORE_NAME,\n {keyPath: URL_PROPERTY});\n objectStore.createIndex(TIMESTAMP_PROPERTY, TIMESTAMP_PROPERTY,\n {unique: false});\n };\n\n request.onsuccess = function() {\n resolve(request.result);\n };\n\n request.onerror = function() {\n reject(request.error);\n };\n });\n}\n\nfunction getDb(cacheName) {\n if (!(cacheName in cacheNameToDbPromise)) {\n cacheNameToDbPromise[cacheName] = openDb(cacheName);\n }\n\n return cacheNameToDbPromise[cacheName];\n}\n\nfunction setTimestampForUrl(db, url, now) {\n return new Promise(function(resolve, reject) {\n var transaction = db.transaction(STORE_NAME, 'readwrite');\n var objectStore = transaction.objectStore(STORE_NAME);\n objectStore.put({url: url, timestamp: now});\n\n transaction.oncomplete = function() {\n resolve(db);\n };\n\n transaction.onabort = function() {\n reject(transaction.error);\n };\n });\n}\n\nfunction expireOldEntries(db, maxAgeSeconds, now) {\n // Bail out early by resolving with an empty array if we're not using\n // maxAgeSeconds.\n if (!maxAgeSeconds) {\n return Promise.resolve([]);\n }\n\n return new Promise(function(resolve, reject) {\n var maxAgeMillis = maxAgeSeconds * 1000;\n var urls = [];\n\n var transaction = db.transaction(STORE_NAME, 'readwrite');\n var objectStore = transaction.objectStore(STORE_NAME);\n var index = objectStore.index(TIMESTAMP_PROPERTY);\n\n index.openCursor().onsuccess = function(cursorEvent) {\n var cursor = cursorEvent.target.result;\n if (cursor) {\n if (now - maxAgeMillis > cursor.value[TIMESTAMP_PROPERTY]) {\n var url = cursor.value[URL_PROPERTY];\n urls.push(url);\n objectStore.delete(url);\n cursor.continue();\n }\n }\n };\n\n transaction.oncomplete = function() {\n resolve(urls);\n };\n\n transaction.onabort = reject;\n });\n}\n\nfunction expireExtraEntries(db, maxEntries) {\n // Bail out early by resolving with an empty array if we're not using\n // maxEntries.\n if (!maxEntries) {\n return Promise.resolve([]);\n }\n\n return new Promise(function(resolve, reject) {\n var urls = [];\n\n var transaction = db.transaction(STORE_NAME, 'readwrite');\n var objectStore = transaction.objectStore(STORE_NAME);\n var index = objectStore.index(TIMESTAMP_PROPERTY);\n\n var countRequest = index.count();\n index.count().onsuccess = function() {\n var initialCount = countRequest.result;\n\n if (initialCount > maxEntries) {\n index.openCursor().onsuccess = function(cursorEvent) {\n var cursor = cursorEvent.target.result;\n if (cursor) {\n var url = cursor.value[URL_PROPERTY];\n urls.push(url);\n objectStore.delete(url);\n if (initialCount - urls.length > maxEntries) {\n cursor.continue();\n }\n }\n };\n }\n };\n\n transaction.oncomplete = function() {\n resolve(urls);\n };\n\n transaction.onabort = reject;\n });\n}\n\nfunction expireEntries(db, maxEntries, maxAgeSeconds, now) {\n return expireOldEntries(db, maxAgeSeconds, now).then(function(oldUrls) {\n return expireExtraEntries(db, maxEntries).then(function(extraUrls) {\n return oldUrls.concat(extraUrls);\n });\n });\n}\n\nmodule.exports = {\n getDb: getDb,\n setTimestampForUrl: setTimestampForUrl,\n expireEntries: expireEntries\n};\n","/*\n Copyright 2014 Google Inc. All Rights Reserved.\n\n Licensed under the Apache License, Version 2.0 (the \"License\");\n you may not use this file except in compliance with the License.\n You may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\n Unless required by applicable law or agreed to in writing, software\n distributed under the License is distributed on an \"AS IS\" BASIS,\n WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n See the License for the specific language governing permissions and\n limitations under the License.\n*/\n'use strict';\n\n// For cache.addAll.\nrequire('serviceworker-cache-polyfill');\n\nvar helpers = require('./helpers');\nvar router = require('./router');\nvar options = require('./options');\n\n// Event listeners\n\nfunction fetchListener(event) {\n var handler = router.match(event.request);\n\n if (handler) {\n event.respondWith(handler(event.request));\n } else if (router.default &&\n event.request.method === 'GET' &&\n // Ensure that chrome-extension:// requests don't trigger the default route.\n event.request.url.indexOf('http') === 0) {\n event.respondWith(router.default(event.request));\n }\n}\n\nfunction activateListener(event) {\n helpers.debug('activate event fired');\n var inactiveCache = options.cache.name + '$$$inactive$$$';\n event.waitUntil(helpers.renameCache(inactiveCache, options.cache.name));\n}\n\nfunction flatten(items) {\n return items.reduce(function(a, b) {\n return a.concat(b);\n }, []);\n}\n\nfunction installListener(event) {\n var inactiveCache = options.cache.name + '$$$inactive$$$';\n helpers.debug('install event fired');\n helpers.debug('creating cache [' + inactiveCache + ']');\n event.waitUntil(\n helpers.openCache({cache: {name: inactiveCache}})\n .then(function(cache) {\n return Promise.all(options.preCacheItems)\n .then(flatten)\n .then(helpers.validatePrecacheInput)\n .then(function(preCacheItems) {\n helpers.debug('preCache list: ' +\n (preCacheItems.join(', ') || '(none)'));\n return cache.addAll(preCacheItems);\n });\n })\n );\n}\n\nmodule.exports = {\n fetchListener: fetchListener,\n activateListener: activateListener,\n installListener: installListener\n};\n","/*\n\tCopyright 2015 Google Inc. All Rights Reserved.\n\n\tLicensed under the Apache License, Version 2.0 (the \"License\");\n\tyou may not use this file except in compliance with the License.\n\tYou may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\n\tUnless required by applicable law or agreed to in writing, software\n\tdistributed under the License is distributed on an \"AS IS\" BASIS,\n\tWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n\tSee the License for the specific language governing permissions and\n\tlimitations under the License.\n*/\n'use strict';\n\n// TODO: This is necessary to handle different implementations in the wild\n// The spec defines self.registration, but it was not implemented in Chrome 40.\nvar scope;\nif (self.registration) {\n scope = self.registration.scope;\n} else {\n scope = self.scope || new URL('./', self.location).href;\n}\n\nmodule.exports = {\n cache: {\n name: '$$$toolbox-cache$$$' + scope + '$$$',\n maxAgeSeconds: null,\n maxEntries: null,\n queryOptions: null\n },\n debug: false,\n networkTimeoutSeconds: null,\n preCacheItems: [],\n // A regular expression to apply to HTTP response codes. Codes that match\n // will be considered successes, while others will not, and will not be\n // cached.\n successResponses: /^0|([123]\\d\\d)|(40[14567])|410$/\n};\n","/*\n Copyright 2014 Google Inc. All Rights Reserved.\n\n Licensed under the Apache License, Version 2.0 (the \"License\");\n you may not use this file except in compliance with the License.\n You may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\n Unless required by applicable law or agreed to in writing, software\n distributed under the License is distributed on an \"AS IS\" BASIS,\n WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n See the License for the specific language governing permissions and\n limitations under the License.\n*/\n'use strict';\n\n// TODO: Use self.registration.scope instead of self.location\nvar url = new URL('./', self.location);\nvar basePath = url.pathname;\nvar pathRegexp = require('path-to-regexp');\n\nvar Route = function(method, path, handler, options) {\n if (path instanceof RegExp) {\n this.fullUrlRegExp = path;\n } else {\n // The URL() constructor can't parse express-style routes as they are not\n // valid urls. This means we have to manually manipulate relative urls into\n // absolute ones. This check is extremely naive but implementing a tweaked\n // version of the full algorithm seems like overkill\n // (https://url.spec.whatwg.org/#concept-basic-url-parser)\n if (path.indexOf('/') !== 0) {\n path = basePath + path;\n }\n\n this.keys = [];\n this.regexp = pathRegexp(path, this.keys);\n }\n\n this.method = method;\n this.options = options;\n this.handler = handler;\n};\n\nRoute.prototype.makeHandler = function(url) {\n var values;\n if (this.regexp) {\n var match = this.regexp.exec(url);\n values = {};\n this.keys.forEach(function(key, index) {\n values[key.name] = match[index + 1];\n });\n }\n\n return function(request) {\n return this.handler(request, values, this.options);\n }.bind(this);\n};\n\nmodule.exports = Route;\n","/*\n Copyright 2014 Google Inc. All Rights Reserved.\n\n Licensed under the Apache License, Version 2.0 (the \"License\");\n you may not use this file except in compliance with the License.\n You may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\n Unless required by applicable law or agreed to in writing, software\n distributed under the License is distributed on an \"AS IS\" BASIS,\n WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n See the License for the specific language governing permissions and\n limitations under the License.\n*/\n'use strict';\n\nvar Route = require('./route');\nvar helpers = require('./helpers');\n\nfunction regexEscape(s) {\n return s.replace(/[-\\/\\\\^$*+?.()|[\\]{}]/g, '\\\\$&');\n}\n\nvar keyMatch = function(map, string) {\n // This would be better written as a for..of loop, but that would break the\n // minifyify process in the build.\n var entriesIterator = map.entries();\n var item = entriesIterator.next();\n var matches = [];\n while (!item.done) {\n var pattern = new RegExp(item.value[0]);\n if (pattern.test(string)) {\n matches.push(item.value[1]);\n }\n item = entriesIterator.next();\n }\n return matches;\n};\n\nvar Router = function() {\n this.routes = new Map();\n // Create the dummy origin for RegExp-based routes\n this.routes.set(RegExp, new Map());\n this.default = null;\n};\n\n['get', 'post', 'put', 'delete', 'head', 'any'].forEach(function(method) {\n Router.prototype[method] = function(path, handler, options) {\n return this.add(method, path, handler, options);\n };\n});\n\nRouter.prototype.add = function(method, path, handler, options) {\n options = options || {};\n var origin;\n\n if (path instanceof RegExp) {\n // We need a unique key to use in the Map to distinguish RegExp paths\n // from Express-style paths + origins. Since we can use any object as the\n // key in a Map, let's use the RegExp constructor!\n origin = RegExp;\n } else {\n origin = options.origin || self.location.origin;\n if (origin instanceof RegExp) {\n origin = origin.source;\n } else {\n origin = regexEscape(origin);\n }\n }\n\n method = method.toLowerCase();\n\n var route = new Route(method, path, handler, options);\n\n if (!this.routes.has(origin)) {\n this.routes.set(origin, new Map());\n }\n\n var methodMap = this.routes.get(origin);\n if (!methodMap.has(method)) {\n methodMap.set(method, new Map());\n }\n\n var routeMap = methodMap.get(method);\n var regExp = route.regexp || route.fullUrlRegExp;\n\n if (routeMap.has(regExp.source)) {\n helpers.debug('\"' + path + '\" resolves to same regex as existing route.');\n }\n\n routeMap.set(regExp.source, route);\n};\n\nRouter.prototype.matchMethod = function(method, url) {\n var urlObject = new URL(url);\n var origin = urlObject.origin;\n var path = urlObject.pathname;\n\n // We want to first check to see if there's a match against any\n // \"Express-style\" routes (string for the path, RegExp for the origin).\n // Checking for Express-style matches first maintains the legacy behavior.\n // If there's no match, we next check for a match against any RegExp routes,\n // where the RegExp in question matches the full URL (both origin and path).\n return this._match(method, keyMatch(this.routes, origin), path) ||\n this._match(method, [this.routes.get(RegExp)], url);\n};\n\nRouter.prototype._match = function(method, methodMaps, pathOrUrl) {\n if (methodMaps.length === 0) {\n return null;\n }\n\n for (var i = 0; i < methodMaps.length; i++) {\n var methodMap = methodMaps[i];\n var routeMap = methodMap && methodMap.get(method.toLowerCase());\n if (routeMap) {\n var routes = keyMatch(routeMap, pathOrUrl);\n if (routes.length > 0) {\n return routes[0].makeHandler(pathOrUrl);\n }\n }\n }\n\n return null;\n};\n\nRouter.prototype.match = function(request) {\n return this.matchMethod(request.method, request.url) ||\n this.matchMethod('any', request.url);\n};\n\nmodule.exports = new Router();\n","/*\n\tCopyright 2014 Google Inc. All Rights Reserved.\n\n\tLicensed under the Apache License, Version 2.0 (the \"License\");\n\tyou may not use this file except in compliance with the License.\n\tYou may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\n\tUnless required by applicable law or agreed to in writing, software\n\tdistributed under the License is distributed on an \"AS IS\" BASIS,\n\tWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n\tSee the License for the specific language governing permissions and\n\tlimitations under the License.\n*/\n'use strict';\nvar globalOptions = require('../options');\nvar helpers = require('../helpers');\n\nfunction cacheFirst(request, values, options) {\n options = options || {};\n var cacheOptions = options.cache || globalOptions.cache;\n var cacheQueryOptions = cacheOptions.queryOptions;\n helpers.debug('Strategy: cache first [' + request.url + ']', options);\n return helpers.openCache(options).then(function(cache) {\n return cache.match(request, cacheQueryOptions).then(function(response) {\n var now = Date.now();\n if (helpers.isResponseFresh(response, cacheOptions.maxAgeSeconds, now)) {\n return response;\n }\n\n return helpers.fetchAndCache(request, options);\n });\n });\n}\n\nmodule.exports = cacheFirst;\n","/*\n\tCopyright 2014 Google Inc. All Rights Reserved.\n\n\tLicensed under the Apache License, Version 2.0 (the \"License\");\n\tyou may not use this file except in compliance with the License.\n\tYou may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\n\tUnless required by applicable law or agreed to in writing, software\n\tdistributed under the License is distributed on an \"AS IS\" BASIS,\n\tWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n\tSee the License for the specific language governing permissions and\n\tlimitations under the License.\n*/\n'use strict';\nvar globalOptions = require('../options');\nvar helpers = require('../helpers');\n\nfunction cacheOnly(request, values, options) {\n options = options || {};\n var cacheOptions = options.cache || globalOptions.cache;\n var cacheQueryOptions = cacheOptions.queryOptions;\n helpers.debug('Strategy: cache only [' + request.url + ']', options);\n return helpers.openCache(options).then(function(cache) {\n return cache.match(request, cacheQueryOptions).then(function(response) {\n var now = Date.now();\n if (helpers.isResponseFresh(response, cacheOptions.maxAgeSeconds, now)) {\n return response;\n }\n\n return undefined;\n });\n });\n}\n\nmodule.exports = cacheOnly;\n","/*\n Copyright 2014 Google Inc. All Rights Reserved.\n\n Licensed under the Apache License, Version 2.0 (the \"License\");\n you may not use this file except in compliance with the License.\n You may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\n Unless required by applicable law or agreed to in writing, software\n distributed under the License is distributed on an \"AS IS\" BASIS,\n WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n See the License for the specific language governing permissions and\n limitations under the License.\n*/\n'use strict';\nvar helpers = require('../helpers');\nvar cacheOnly = require('./cacheOnly');\n\nfunction fastest(request, values, options) {\n helpers.debug('Strategy: fastest [' + request.url + ']', options);\n\n return new Promise(function(resolve, reject) {\n var rejected = false;\n var reasons = [];\n\n var maybeReject = function(reason) {\n reasons.push(reason.toString());\n if (rejected) {\n reject(new Error('Both cache and network failed: \"' +\n reasons.join('\", \"') + '\"'));\n } else {\n rejected = true;\n }\n };\n\n var maybeResolve = function(result) {\n if (result instanceof Response) {\n resolve(result);\n } else {\n maybeReject('No result returned');\n }\n };\n\n helpers.fetchAndCache(request.clone(), options)\n .then(maybeResolve, maybeReject);\n\n cacheOnly(request, values, options)\n .then(maybeResolve, maybeReject);\n });\n}\n\nmodule.exports = fastest;\n","/*\n\tCopyright 2014 Google Inc. All Rights Reserved.\n\n\tLicensed under the Apache License, Version 2.0 (the \"License\");\n\tyou may not use this file except in compliance with the License.\n\tYou may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\n\tUnless required by applicable law or agreed to in writing, software\n\tdistributed under the License is distributed on an \"AS IS\" BASIS,\n\tWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n\tSee the License for the specific language governing permissions and\n\tlimitations under the License.\n*/\nmodule.exports = {\n networkOnly: require('./networkOnly'),\n networkFirst: require('./networkFirst'),\n cacheOnly: require('./cacheOnly'),\n cacheFirst: require('./cacheFirst'),\n fastest: require('./fastest')\n};\n","/*\n Copyright 2015 Google Inc. All Rights Reserved.\n\n Licensed under the Apache License, Version 2.0 (the \"License\");\n you may not use this file except in compliance with the License.\n You may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\n Unless required by applicable law or agreed to in writing, software\n distributed under the License is distributed on an \"AS IS\" BASIS,\n WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n See the License for the specific language governing permissions and\n limitations under the License.\n*/\n'use strict';\nvar globalOptions = require('../options');\nvar helpers = require('../helpers');\n\nfunction networkFirst(request, values, options) {\n options = options || {};\n var cacheOptions = options.cache || globalOptions.cache;\n var cacheQueryOptions = cacheOptions.queryOptions;\n var successResponses = options.successResponses ||\n globalOptions.successResponses;\n // This will bypass options.networkTimeout if it's set to a false-y value like\n // 0, but that's the sane thing to do anyway.\n var networkTimeoutSeconds = options.networkTimeoutSeconds ||\n globalOptions.networkTimeoutSeconds;\n helpers.debug('Strategy: network first [' + request.url + ']', options);\n\n return helpers.openCache(options).then(function(cache) {\n var timeoutId;\n var promises = [];\n var originalResponse;\n\n if (networkTimeoutSeconds) {\n var cacheWhenTimedOutPromise = new Promise(function(resolve) {\n timeoutId = setTimeout(function() {\n cache.match(request, cacheQueryOptions).then(function(response) {\n // Only resolve this promise if there's a valid response in the\n // cache. This ensures that we won't time out a network request\n // unless there's a cached entry to fallback on, which is arguably\n // the preferable behavior.\n var now = Date.now();\n var maxAgeSeconds = cacheOptions.maxAgeSeconds;\n if (helpers.isResponseFresh(response, maxAgeSeconds, now)) {\n resolve(response);\n }\n });\n }, networkTimeoutSeconds * 1000);\n });\n promises.push(cacheWhenTimedOutPromise);\n }\n\n var networkPromise = helpers.fetchAndCache(request, options)\n .then(function(response) {\n // We've got a response, so clear the network timeout if there is one.\n if (timeoutId) {\n clearTimeout(timeoutId);\n }\n\n if (successResponses.test(response.status)) {\n return response;\n }\n\n helpers.debug('Response was an HTTP error: ' + response.statusText,\n options);\n originalResponse = response;\n throw new Error('Bad response');\n }).catch(function(error) {\n helpers.debug('Network or response error, fallback to cache [' +\n request.url + ']', options);\n return cache.match(request, cacheQueryOptions).then(function(response) {\n // If there's a match in the cache, resolve with that.\n if (response) {\n return response;\n }\n\n // If we have a Response object from the previous fetch, then resolve\n // with that, even though it corresponds to an error status code.\n if (originalResponse) {\n return originalResponse;\n }\n\n // If we don't have a Response object from the previous fetch, likely\n // due to a network failure, then reject with the failure error.\n throw error;\n });\n });\n\n promises.push(networkPromise);\n\n return Promise.race(promises);\n });\n}\n\nmodule.exports = networkFirst;\n","/*\n\tCopyright 2014 Google Inc. All Rights Reserved.\n\n\tLicensed under the Apache License, Version 2.0 (the \"License\");\n\tyou may not use this file except in compliance with the License.\n\tYou may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\n\tUnless required by applicable law or agreed to in writing, software\n\tdistributed under the License is distributed on an \"AS IS\" BASIS,\n\tWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n\tSee the License for the specific language governing permissions and\n\tlimitations under the License.\n*/\n'use strict';\nvar helpers = require('../helpers');\n\nfunction networkOnly(request, values, options) {\n helpers.debug('Strategy: network only [' + request.url + ']', options);\n return fetch(request);\n}\n\nmodule.exports = networkOnly;\n","/*\n Copyright 2014 Google Inc. All Rights Reserved.\n\n Licensed under the Apache License, Version 2.0 (the \"License\");\n you may not use this file except in compliance with the License.\n You may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\n Unless required by applicable law or agreed to in writing, software\n distributed under the License is distributed on an \"AS IS\" BASIS,\n WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n See the License for the specific language governing permissions and\n limitations under the License.\n*/\n'use strict';\n\n// This is the entrypoint for the sw-toolbox bundle. All code with\n// side effects (e.g. adding event listeners) should be in this file.\n\nvar options = require('./options');\nvar router = require('./router');\nvar helpers = require('./helpers');\nvar strategies = require('./strategies');\nvar listeners = require('./listeners');\n\nhelpers.debug('Service Worker Toolbox is loading');\n\n// Set up listeners.\n\nself.addEventListener('install', listeners.installListener);\nself.addEventListener('activate', listeners.activateListener);\nself.addEventListener('fetch', listeners.fetchListener);\n\nmodule.exports = {\n networkOnly: strategies.networkOnly,\n networkFirst: strategies.networkFirst,\n cacheOnly: strategies.cacheOnly,\n cacheFirst: strategies.cacheFirst,\n fastest: strategies.fastest,\n router: router,\n options: options,\n cache: helpers.cache,\n uncache: helpers.uncache,\n precache: helpers.precache\n};\n","module.exports = Array.isArray || function (arr) {\n return Object.prototype.toString.call(arr) == '[object Array]';\n};\n","var isarray = require('isarray')\n\n/**\n * Expose `pathToRegexp`.\n */\nmodule.exports = pathToRegexp\nmodule.exports.parse = parse\nmodule.exports.compile = compile\nmodule.exports.tokensToFunction = tokensToFunction\nmodule.exports.tokensToRegExp = tokensToRegExp\n\n/**\n * The main path matching regexp utility.\n *\n * @type {RegExp}\n */\nvar PATH_REGEXP = new RegExp([\n // Match escaped characters that would otherwise appear in future matches.\n // This allows the user to escape special characters that won't transform.\n '(\\\\\\\\.)',\n // Match Express-style parameters and un-named parameters with a prefix\n // and optional suffixes. Matches appear as:\n //\n // \"/:test(\\\\d+)?\" => [\"/\", \"test\", \"\\d+\", undefined, \"?\", undefined]\n // \"/route(\\\\d+)\" => [undefined, undefined, undefined, \"\\d+\", undefined, undefined]\n // \"/*\" => [\"/\", undefined, undefined, undefined, undefined, \"*\"]\n '([\\\\/.])?(?:(?:\\\\:(\\\\w+)(?:\\\\(((?:\\\\\\\\.|[^\\\\\\\\()])+)\\\\))?|\\\\(((?:\\\\\\\\.|[^\\\\\\\\()])+)\\\\))([+*?])?|(\\\\*))'\n].join('|'), 'g')\n\n/**\n * Parse a string for the raw tokens.\n *\n * @param {string} str\n * @param {Object=} options\n * @return {!Array}\n */\nfunction parse (str, options) {\n var tokens = []\n var key = 0\n var index = 0\n var path = ''\n var defaultDelimiter = options && options.delimiter || '/'\n var res\n\n while ((res = PATH_REGEXP.exec(str)) != null) {\n var m = res[0]\n var escaped = res[1]\n var offset = res.index\n path += str.slice(index, offset)\n index = offset + m.length\n\n // Ignore already escaped sequences.\n if (escaped) {\n path += escaped[1]\n continue\n }\n\n var next = str[index]\n var prefix = res[2]\n var name = res[3]\n var capture = res[4]\n var group = res[5]\n var modifier = res[6]\n var asterisk = res[7]\n\n // Push the current path onto the tokens.\n if (path) {\n tokens.push(path)\n path = ''\n }\n\n var partial = prefix != null && next != null && next !== prefix\n var repeat = modifier === '+' || modifier === '*'\n var optional = modifier === '?' || modifier === '*'\n var delimiter = res[2] || defaultDelimiter\n var pattern = capture || group\n\n tokens.push({\n name: name || key++,\n prefix: prefix || '',\n delimiter: delimiter,\n optional: optional,\n repeat: repeat,\n partial: partial,\n asterisk: !!asterisk,\n pattern: pattern ? escapeGroup(pattern) : (asterisk ? '.*' : '[^' + escapeString(delimiter) + ']+?')\n })\n }\n\n // Match any characters still remaining.\n if (index < str.length) {\n path += str.substr(index)\n }\n\n // If the path exists, push it onto the end.\n if (path) {\n tokens.push(path)\n }\n\n return tokens\n}\n\n/**\n * Compile a string to a template function for the path.\n *\n * @param {string} str\n * @param {Object=} options\n * @return {!function(Object=, Object=)}\n */\nfunction compile (str, options) {\n return tokensToFunction(parse(str, options))\n}\n\n/**\n * Prettier encoding of URI path segments.\n *\n * @param {string}\n * @return {string}\n */\nfunction encodeURIComponentPretty (str) {\n return encodeURI(str).replace(/[\\/?#]/g, function (c) {\n return '%' + c.charCodeAt(0).toString(16).toUpperCase()\n })\n}\n\n/**\n * Encode the asterisk parameter. Similar to `pretty`, but allows slashes.\n *\n * @param {string}\n * @return {string}\n */\nfunction encodeAsterisk (str) {\n return encodeURI(str).replace(/[?#]/g, function (c) {\n return '%' + c.charCodeAt(0).toString(16).toUpperCase()\n })\n}\n\n/**\n * Expose a method for transforming tokens into the path function.\n */\nfunction tokensToFunction (tokens) {\n // Compile all the tokens into regexps.\n var matches = new Array(tokens.length)\n\n // Compile all the patterns before compilation.\n for (var i = 0; i < tokens.length; i++) {\n if (typeof tokens[i] === 'object') {\n matches[i] = new RegExp('^(?:' + tokens[i].pattern + ')$')\n }\n }\n\n return function (obj, opts) {\n var path = ''\n var data = obj || {}\n var options = opts || {}\n var encode = options.pretty ? encodeURIComponentPretty : encodeURIComponent\n\n for (var i = 0; i < tokens.length; i++) {\n var token = tokens[i]\n\n if (typeof token === 'string') {\n path += token\n\n continue\n }\n\n var value = data[token.name]\n var segment\n\n if (value == null) {\n if (token.optional) {\n // Prepend partial segment prefixes.\n if (token.partial) {\n path += token.prefix\n }\n\n continue\n } else {\n throw new TypeError('Expected \"' + token.name + '\" to be defined')\n }\n }\n\n if (isarray(value)) {\n if (!token.repeat) {\n throw new TypeError('Expected \"' + token.name + '\" to not repeat, but received `' + JSON.stringify(value) + '`')\n }\n\n if (value.length === 0) {\n if (token.optional) {\n continue\n } else {\n throw new TypeError('Expected \"' + token.name + '\" to not be empty')\n }\n }\n\n for (var j = 0; j < value.length; j++) {\n segment = encode(value[j])\n\n if (!matches[i].test(segment)) {\n throw new TypeError('Expected all \"' + token.name + '\" to match \"' + token.pattern + '\", but received `' + JSON.stringify(segment) + '`')\n }\n\n path += (j === 0 ? token.prefix : token.delimiter) + segment\n }\n\n continue\n }\n\n segment = token.asterisk ? encodeAsterisk(value) : encode(value)\n\n if (!matches[i].test(segment)) {\n throw new TypeError('Expected \"' + token.name + '\" to match \"' + token.pattern + '\", but received \"' + segment + '\"')\n }\n\n path += token.prefix + segment\n }\n\n return path\n }\n}\n\n/**\n * Escape a regular expression string.\n *\n * @param {string} str\n * @return {string}\n */\nfunction escapeString (str) {\n return str.replace(/([.+*?=^!:${}()[\\]|\\/\\\\])/g, '\\\\$1')\n}\n\n/**\n * Escape the capturing group by escaping special characters and meaning.\n *\n * @param {string} group\n * @return {string}\n */\nfunction escapeGroup (group) {\n return group.replace(/([=!:$\\/()])/g, '\\\\$1')\n}\n\n/**\n * Attach the keys as a property of the regexp.\n *\n * @param {!RegExp} re\n * @param {Array} keys\n * @return {!RegExp}\n */\nfunction attachKeys (re, keys) {\n re.keys = keys\n return re\n}\n\n/**\n * Get the flags for a regexp from the options.\n *\n * @param {Object} options\n * @return {string}\n */\nfunction flags (options) {\n return options.sensitive ? '' : 'i'\n}\n\n/**\n * Pull out keys from a regexp.\n *\n * @param {!RegExp} path\n * @param {!Array} keys\n * @return {!RegExp}\n */\nfunction regexpToRegexp (path, keys) {\n // Use a negative lookahead to match only capturing groups.\n var groups = path.source.match(/\\((?!\\?)/g)\n\n if (groups) {\n for (var i = 0; i < groups.length; i++) {\n keys.push({\n name: i,\n prefix: null,\n delimiter: null,\n optional: false,\n repeat: false,\n partial: false,\n asterisk: false,\n pattern: null\n })\n }\n }\n\n return attachKeys(path, keys)\n}\n\n/**\n * Transform an array into a regexp.\n *\n * @param {!Array} path\n * @param {Array} keys\n * @param {!Object} options\n * @return {!RegExp}\n */\nfunction arrayToRegexp (path, keys, options) {\n var parts = []\n\n for (var i = 0; i < path.length; i++) {\n parts.push(pathToRegexp(path[i], keys, options).source)\n }\n\n var regexp = new RegExp('(?:' + parts.join('|') + ')', flags(options))\n\n return attachKeys(regexp, keys)\n}\n\n/**\n * Create a path regexp from string input.\n *\n * @param {string} path\n * @param {!Array} keys\n * @param {!Object} options\n * @return {!RegExp}\n */\nfunction stringToRegexp (path, keys, options) {\n return tokensToRegExp(parse(path, options), keys, options)\n}\n\n/**\n * Expose a function for taking tokens and returning a RegExp.\n *\n * @param {!Array} tokens\n * @param {(Array|Object)=} keys\n * @param {Object=} options\n * @return {!RegExp}\n */\nfunction tokensToRegExp (tokens, keys, options) {\n if (!isarray(keys)) {\n options = /** @type {!Object} */ (keys || options)\n keys = []\n }\n\n options = options || {}\n\n var strict = options.strict\n var end = options.end !== false\n var route = ''\n\n // Iterate over the tokens and create our regexp string.\n for (var i = 0; i < tokens.length; i++) {\n var token = tokens[i]\n\n if (typeof token === 'string') {\n route += escapeString(token)\n } else {\n var prefix = escapeString(token.prefix)\n var capture = '(?:' + token.pattern + ')'\n\n keys.push(token)\n\n if (token.repeat) {\n capture += '(?:' + prefix + capture + ')*'\n }\n\n if (token.optional) {\n if (!token.partial) {\n capture = '(?:' + prefix + '(' + capture + '))?'\n } else {\n capture = prefix + '(' + capture + ')?'\n }\n } else {\n capture = prefix + '(' + capture + ')'\n }\n\n route += capture\n }\n }\n\n var delimiter = escapeString(options.delimiter || '/')\n var endsWithDelimiter = route.slice(-delimiter.length) === delimiter\n\n // In non-strict mode we allow a slash at the end of match. If the path to\n // match already ends with a slash, we remove it for consistency. The slash\n // is valid at the end of a path match, not in the middle. This is important\n // in non-ending mode, where \"/test/\" shouldn't match \"/test//route\".\n if (!strict) {\n route = (endsWithDelimiter ? route.slice(0, -delimiter.length) : route) + '(?:' + delimiter + '(?=$))?'\n }\n\n if (end) {\n route += '$'\n } else {\n // In non-ending mode, we need the capturing groups to match as much as\n // possible by using a positive lookahead to the end or next path segment.\n route += strict && endsWithDelimiter ? '' : '(?=' + delimiter + '|$)'\n }\n\n return attachKeys(new RegExp('^' + route, flags(options)), keys)\n}\n\n/**\n * Normalize the given path string, returning a regular expression.\n *\n * An empty array can be passed in for the keys, which will hold the\n * placeholder key descriptions. For example, using `/user/:id`, `keys` will\n * contain `[{ name: 'id', delimiter: '/', optional: false, repeat: false }]`.\n *\n * @param {(string|RegExp|Array)} path\n * @param {(Array|Object)=} keys\n * @param {Object=} options\n * @return {!RegExp}\n */\nfunction pathToRegexp (path, keys, options) {\n if (!isarray(keys)) {\n options = /** @type {!Object} */ (keys || options)\n keys = []\n }\n\n options = options || {}\n\n if (path instanceof RegExp) {\n return regexpToRegexp(path, /** @type {!Array} */ (keys))\n }\n\n if (isarray(path)) {\n return arrayToRegexp(/** @type {!Array} */ (path), /** @type {!Array} */ (keys), options)\n }\n\n return stringToRegexp(/** @type {string} */ (path), /** @type {!Array} */ (keys), options)\n}\n","/**\n * Copyright 2015 Google Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n */\n\n(function() {\n var nativeAddAll = Cache.prototype.addAll;\n var userAgent = navigator.userAgent.match(/(Firefox|Chrome)\\/(\\d+\\.)/);\n\n // Has nice behavior of `var` which everyone hates\n if (userAgent) {\n var agent = userAgent[1];\n var version = parseInt(userAgent[2]);\n }\n\n if (\n nativeAddAll && (!userAgent ||\n (agent === 'Firefox' && version >= 46) ||\n (agent === 'Chrome' && version >= 50)\n )\n ) {\n return;\n }\n\n Cache.prototype.addAll = function addAll(requests) {\n var cache = this;\n\n // Since DOMExceptions are not constructable:\n function NetworkError(message) {\n this.name = 'NetworkError';\n this.code = 19;\n this.message = message;\n }\n\n NetworkError.prototype = Object.create(Error.prototype);\n\n return Promise.resolve().then(function() {\n if (arguments.length < 1) throw new TypeError();\n\n // Simulate sequence<(Request or USVString)> binding:\n var sequence = [];\n\n requests = requests.map(function(request) {\n if (request instanceof Request) {\n return request;\n }\n else {\n return String(request); // may throw TypeError\n }\n });\n\n return Promise.all(\n requests.map(function(request) {\n if (typeof request === 'string') {\n request = new Request(request);\n }\n\n var scheme = new URL(request.url).protocol;\n\n if (scheme !== 'http:' && scheme !== 'https:') {\n throw new NetworkError(\"Invalid scheme\");\n }\n\n return fetch(request.clone());\n })\n );\n }).then(function(responses) {\n // If some of the responses has not OK-eish status,\n // then whole operation should reject\n if (responses.some(function(response) {\n return !response.ok;\n })) {\n throw new NetworkError('Incorrect response status');\n }\n\n // TODO: check that requests don't overwrite one another\n // (don't think this is possible to polyfill due to opaque responses)\n return Promise.all(\n responses.map(function(response, i) {\n return cache.put(requests[i], response);\n })\n );\n }).then(function() {\n return undefined;\n });\n };\n\n Cache.prototype.add = function add(request) {\n return this.addAll([request]);\n };\n}());"]}