UNPKG

62.5 kBJSONView Raw
1{"version":3,"sources":["node_modules/browser-pack/_prelude.js","lib/sw-toolbox.js","lib/options.js","lib/router.js","lib/helpers.js","lib/strategies/index.js","lib/route.js","lib/idb-cache-expiration.js","node_modules/serviceworker-cache-polyfill/index.js","lib/strategies/networkOnly.js","lib/strategies/cacheOnly.js","lib/strategies/networkFirst.js","lib/strategies/cacheFirst.js","lib/strategies/fastest.js","node_modules/path-to-regexp/index.js","node_modules/isarray/index.js"],"names":["cache","url","options","helpers","openCache","then","add","uncache","precache","items","Promise","validatePrecacheInput","preCacheItems","concat","require","router","strategies","debug","flatten","reduce","a","b","isValid","Array","isArray","forEach","item","Request","TypeError","self","addEventListener","event","inactiveCache","name","waitUntil","all","join","addAll","renameCache","handler","match","request","respondWith","method","module","exports","networkOnly","networkFirst","cacheOnly","cacheFirst","fastest","scope","registration","URL","location","href","maxAgeSeconds","maxEntries","networkTimeoutSeconds","successResponses","regexEscape","s","replace","Route","keyMatch","map","string","entriesIterator","entries","next","matches","done","pattern","RegExp","value","test","push","Router","this","routes","Map","set","prototype","path","origin","source","toLowerCase","route","has","methodMap","get","routeMap","regExp","regexp","fullUrlRegExp","matchMethod","urlObject","pathname","_match","methodMaps","pathOrUrl","length","i","makeHandler","message","flag","globalOptions","console","log","cacheName","caches","open","fetchAndCache","fetch","clone","response","status","put","cacheOptions","queueCacheExpiration","cleanup","cleanupCache","bind","cleanupQueue","requestUrl","now","Date","idbCacheExpiration","getDb","db","setTimestampForUrl","expireEntries","urlsToDelete","deletionPromises","urlToDelete","error","destination","results","sourceCache","destCache","keys","requests","basePath","pathRegexp","indexOf","values","exec","key","index","openDb","resolve","reject","indexedDB","DB_PREFIX","DB_VERSION","onupgradeneeded","objectStore","result","createObjectStore","STORE_NAME","keyPath","URL_PROPERTY","createIndex","TIMESTAMP_PROPERTY","unique","onsuccess","onerror","cacheNameToDbPromise","transaction","timestamp","oncomplete","onabort","expireOldEntries","maxAgeMillis","urls","openCursor","cursorEvent","cursor","target","expireExtraEntries","countRequest","count","initialCount","oldUrls","extraUrls","nativeAddAll","Cache","userAgent","navigator","agent","version","parseInt","NetworkError","code","Object","create","Error","arguments","String","scheme","protocol","responses","some","ok","timeoutId","originalResponse","promises","cacheWhenTimedOutPromise","setTimeout","networkPromise","clearTimeout","statusText","race","rejected","reasons","maybeReject","reason","toString","maybeResolve","Response","parse","str","res","tokens","PATH_REGEXP","m","escaped","offset","slice","prefix","capture","group","modifier","asterisk","partial","repeat","optional","delimiter","escapeGroup","substr","compile","tokensToFunction","encodeURIComponentPretty","encodeURI","c","charCodeAt","toUpperCase","encodeAsterisk","obj","opts","data","encode","pretty","encodeURIComponent","token","segment","isarray","JSON","stringify","j","escapeString","attachKeys","re","flags","sensitive","regexpToRegexp","groups","arrayToRegexp","parts","pathToRegexp","stringToRegexp","tokensToRegExp","strict","end","lastToken","endsWithSlash","arr","call"],"mappings":"AAAA;AIeA,YAKA,SAASiB,OAAMuF,EAAStG,GACtBA,EAAUA,KACV,IAAIuG,GAAOvG,EAAQe,OAASyF,cAAczF,KACtCwF,IACFE,QAAQC,IAAI,gBAAkBJ,GAIlC,QAASpG,WAAUF,GACjB,GAAI2G,EAMJ,OALI3G,IAAWA,EAAQF,QACrB6G,EAAY3G,EAAQF,MAAMiC,MAE5B4E,EAAYA,GAAaH,cAAc1G,MAAMiC,KAEtC6E,OAAOC,KAAKF,GAGrB,QAASG,eAAcvE,EAASvC,GAC9BA,EAAUA,KACV,IAAIyD,GAAmBzD,EAAQyD,kBAC3B+C,cAAc/C,gBAElB,OAAOsD,OAAMxE,EAAQyE,SAAS7G,KAAK,SAAS8G,GAwB1C,MAnBuB,QAAnB1E,EAAQE,QAAoBgB,EAAiBgB,KAAKwC,EAASC,SAC7DhH,UAAUF,GAASG,KAAK,SAASL,GAC/BA,EAAMqH,IAAI5E,EAAS0E,GAAU9G,KAAK,WAIhC,GAAIiH,GAAepH,EAAQF,OAAS0G,cAAc1G,OAK7CsH,EAAa7D,YAAc6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GAAIa,QAGjC9G,KAAK,eAKVqL,MAAMxG,UAAU5E,IAAM,SAAamC,GACjC,MAAOqC,MAAKzC,QAAQI","file":"bundle.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\nrequire('serviceworker-cache-polyfill');\nvar options = require('./options');\nvar router = require('./router');\nvar helpers = require('./helpers');\nvar strategies = require('./strategies');\n\nhelpers.debug('Service Worker Toolbox is loading');\n\n// Install\nvar flatten = function(items) {\n return items.reduce(function(a, b) {\n return a.concat(b);\n }, []);\n};\n\nvar validatePrecacheInput = function(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\nself.addEventListener('install', function(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(validatePrecacheInput)\n .then(function(preCacheItems) {\n helpers.debug('preCache list: ' +\n (preCacheItems.join(', ') || '(none)'));\n return cache.addAll(preCacheItems);\n });\n })\n );\n});\n\n// Activate\n\nself.addEventListener('activate', function(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\n// Fetch\n\nself.addEventListener('fetch', function(event) {\n var handler = router.match(event.request);\n\n if (handler) {\n event.respondWith(handler(event.request));\n } else if (router.default && event.request.method === 'GET') {\n event.respondWith(router.default(event.request));\n }\n});\n\n// Caching\n\nfunction cache(url, options) {\n return helpers.openCache(options).then(function(cache) {\n return cache.add(url);\n });\n}\n\nfunction uncache(url, options) {\n return helpers.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 options.preCacheItems = options.preCacheItems.concat(items);\n}\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: cache,\n uncache: uncache,\n precache: precache\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 },\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\nvar Route = require('./route');\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 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 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\nmodule.exports = {\n debug: debug,\n fetchAndCache: fetchAndCache,\n openCache: openCache,\n renameCache: renameCache\n};\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 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 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 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}());","/*\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\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 cacheOnly(request, values, options) {\n helpers.debug('Strategy: cache only [' + request.url + ']', options);\n return helpers.openCache(options).then(function(cache) {\n return cache.match(request);\n });\n}\n\nmodule.exports = cacheOnly;\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 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).then(function(response) {\n if (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 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).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 cacheFirst(request, values, options) {\n helpers.debug('Strategy: cache first [' + request.url + ']', options);\n return helpers.openCache(options).then(function(cache) {\n return cache.match(request).then(function(response) {\n if (response) {\n return response;\n }\n\n return helpers.fetchAndCache(request, options);\n });\n });\n}\n\nmodule.exports = cacheFirst;\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","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 * @return {!Array}\n */\nfunction parse (str) {\n var tokens = []\n var key = 0\n var index = 0\n var path = ''\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] || '/'\n var pattern = capture || group || (asterisk ? '.*' : '[^' + delimiter + ']+?')\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: escapeGroup(pattern)\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 * @return {!function(Object=, Object=)}\n */\nfunction compile (str) {\n return tokensToFunction(parse(str))\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 var tokens = parse(path)\n var re = tokensToRegExp(tokens, options)\n\n // Attach keys back to the regexp.\n for (var i = 0; i < tokens.length; i++) {\n if (typeof tokens[i] !== 'string') {\n keys.push(tokens[i])\n }\n }\n\n return attachKeys(re, keys)\n}\n\n/**\n * Expose a function for taking tokens and returning a RegExp.\n *\n * @param {!Array} tokens\n * @param {Object=} options\n * @return {!RegExp}\n */\nfunction tokensToRegExp (tokens, options) {\n options = options || {}\n\n var strict = options.strict\n var end = options.end !== false\n var route = ''\n var lastToken = tokens[tokens.length - 1]\n var endsWithSlash = typeof lastToken === 'string' && /\\/$/.test(lastToken)\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 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 // 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 = (endsWithSlash ? route.slice(0, -2) : route) + '(?:\\\\/(?=$))?'\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 && endsWithSlash ? '' : '(?=\\\\/|$)'\n }\n\n return new RegExp('^' + route, flags(options))\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 keys = keys || []\n\n if (!isarray(keys)) {\n options = /** @type {!Object} */ (keys)\n keys = []\n } else if (!options) {\n options = {}\n }\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","module.exports = Array.isArray || function (arr) {\n return Object.prototype.toString.call(arr) == '[object Array]';\n};\n"]}
\No newline at end of file