workbox-core
Advanced tools
Comparing version 6.0.0-alpha.2 to 6.0.0-alpha.3
import { assert } from './_private/assert.js'; | ||
import { cacheNames } from './_private/cacheNames.js'; | ||
import { cacheMatchIgnoreParams } from './_private/cacheMatchIgnoreParams.js'; | ||
import { canConstructReadableStream } from './_private/canConstructReadableStream.js'; | ||
@@ -14,4 +15,5 @@ import { canConstructResponseFromBodyStream } from './_private/canConstructResponseFromBodyStream.js'; | ||
import { timeout } from './_private/timeout.js'; | ||
import { waitUntil } from './_private/waitUntil.js'; | ||
import { WorkboxError } from './_private/WorkboxError.js'; | ||
import './_version.js'; | ||
export { assert, cacheNames, canConstructReadableStream, canConstructResponseFromBodyStream, dontWaitFor, DBWrapper, Deferred, deleteDatabase, executeQuotaErrorCallbacks, getFriendlyURL, logger, resultingClientExists, timeout, WorkboxError, }; | ||
export { assert, cacheMatchIgnoreParams, cacheNames, canConstructReadableStream, canConstructResponseFromBodyStream, dontWaitFor, DBWrapper, Deferred, deleteDatabase, executeQuotaErrorCallbacks, getFriendlyURL, logger, resultingClientExists, timeout, waitUntil, WorkboxError, }; |
@@ -11,2 +11,3 @@ /* | ||
import { cacheNames } from './_private/cacheNames.js'; | ||
import { cacheMatchIgnoreParams } from './_private/cacheMatchIgnoreParams.js'; | ||
import { canConstructReadableStream } from './_private/canConstructReadableStream.js'; | ||
@@ -23,4 +24,5 @@ import { canConstructResponseFromBodyStream } from './_private/canConstructResponseFromBodyStream.js'; | ||
import { timeout } from './_private/timeout.js'; | ||
import { waitUntil } from './_private/waitUntil.js'; | ||
import { WorkboxError } from './_private/WorkboxError.js'; | ||
import './_version.js'; | ||
export { assert, cacheNames, canConstructReadableStream, canConstructResponseFromBodyStream, dontWaitFor, DBWrapper, Deferred, deleteDatabase, executeQuotaErrorCallbacks, getFriendlyURL, logger, resultingClientExists, timeout, WorkboxError, }; | ||
export { assert, cacheMatchIgnoreParams, cacheNames, canConstructReadableStream, canConstructResponseFromBodyStream, dontWaitFor, DBWrapper, Deferred, deleteDatabase, executeQuotaErrorCallbacks, getFriendlyURL, logger, resultingClientExists, timeout, waitUntil, WorkboxError, }; |
"use strict"; | ||
// @ts-ignore | ||
try { | ||
self['workbox:core:6.0.0-alpha.1'] && _(); | ||
self['workbox:core:6.0.0-alpha.2'] && _(); | ||
} | ||
catch (e) { } |
@@ -6,3 +6,3 @@ this.workbox = this.workbox || {}; | ||
try { | ||
self['workbox:core:6.0.0-alpha.1'] && _(); | ||
self['workbox:core:6.0.0-alpha.2'] && _(); | ||
} catch (e) {} | ||
@@ -572,2 +572,68 @@ | ||
function _extends() { | ||
_extends = Object.assign || function (target) { | ||
for (var i = 1; i < arguments.length; i++) { | ||
var source = arguments[i]; | ||
for (var key in source) { | ||
if (Object.prototype.hasOwnProperty.call(source, key)) { | ||
target[key] = source[key]; | ||
} | ||
} | ||
} | ||
return target; | ||
}; | ||
return _extends.apply(this, arguments); | ||
} | ||
function stripParams(fullURL, ignoreParams) { | ||
const strippedURL = new URL(fullURL); | ||
for (const param of ignoreParams) { | ||
strippedURL.searchParams.delete(param); | ||
} | ||
return strippedURL.href; | ||
} | ||
/** | ||
* Matches an item in the cache, ignoring specific URL params. This is similar | ||
* to the `ignoreSearch` option, but it allows you to ignore just specific | ||
* params (while continuing to match on the others). | ||
* | ||
* @private | ||
* @param {Cache} cache | ||
* @param {Request} request | ||
* @param {Object} matchOptions | ||
* @param {Array<string>} ignoreParams | ||
* @return {Promise<Response|undefined>} | ||
*/ | ||
async function cacheMatchIgnoreParams(cache, request, ignoreParams, matchOptions) { | ||
const strippedRequestURL = stripParams(request.url, ignoreParams); // If the request doesn't include any ignored params, match as normal. | ||
if (request.url === strippedRequestURL) { | ||
return cache.match(request, matchOptions); | ||
} // Otherwise, match by comparing keys | ||
const keysOptions = _extends({}, matchOptions, { | ||
ignoreSearch: true | ||
}); | ||
const cacheKeys = await cache.keys(request, keysOptions); | ||
for (const cacheKey of cacheKeys) { | ||
const strippedCacheKeyURL = stripParams(cacheKey.url, ignoreParams); | ||
if (strippedRequestURL === strippedCacheKeyURL) { | ||
return cache.match(cacheKey, matchOptions); | ||
} | ||
} | ||
return; | ||
} | ||
/* | ||
@@ -1146,2 +1212,24 @@ Copyright 2019 Google LLC | ||
/* | ||
Copyright 2020 Google LLC | ||
Use of this source code is governed by an MIT-style | ||
license that can be found in the LICENSE file or at | ||
https://opensource.org/licenses/MIT. | ||
*/ | ||
/** | ||
* A utility method that makes it easier to use `event.waitUntil` with | ||
* async functions and return the result. | ||
* | ||
* @param {ExtendableEvent} event | ||
* @param {Function} asyncFn | ||
* @return {Function} | ||
* @private | ||
*/ | ||
function waitUntil(event, asyncFn) { | ||
const returnPromise = asyncFn(); | ||
event.waitUntil(returnPromise); | ||
return returnPromise; | ||
} | ||
/* | ||
Copyright 2018 Google LLC | ||
@@ -1157,2 +1245,3 @@ | ||
assert: finalAssertExports, | ||
cacheMatchIgnoreParams: cacheMatchIgnoreParams, | ||
cacheNames: cacheNames, | ||
@@ -1170,2 +1259,3 @@ canConstructReadableStream: canConstructReadableStream, | ||
timeout: timeout, | ||
waitUntil: waitUntil, | ||
WorkboxError: WorkboxError | ||
@@ -1172,0 +1262,0 @@ }); |
@@ -1,2 +0,2 @@ | ||
this.workbox=this.workbox||{},this.workbox.core=function(t){"use strict";try{self["workbox:core:6.0.0-alpha.1"]&&_()}catch(t){}const e=(t,...e)=>{let n=t;return e.length>0&&(n+=" :: "+JSON.stringify(e)),n};class n extends Error{constructor(t,n){super(e(t,n)),this.name=t,this.details=n}}const s=new Set;const r={googleAnalytics:"googleAnalytics",precache:"precache-v2",prefix:"workbox",runtime:"runtime",suffix:"undefined"!=typeof registration?registration.scope:""},i=t=>[r.prefix,t,r.suffix].filter(t=>t&&t.length>0).join("-"),o={updateDetails:t=>{(t=>{for(const e of Object.keys(r))t(e)})(e=>{"string"==typeof t[e]&&(r[e]=t[e])})},getGoogleAnalyticsName:t=>t||i(r.googleAnalytics),getPrecacheName:t=>t||i(r.precache),getPrefix:()=>r.prefix,getRuntimeName:t=>t||i(r.runtime),getSuffix:()=>r.suffix};let a,c;function u(){if(void 0===c){const t=new Response("");if("body"in t)try{new Response(t.body),c=!0}catch(t){c=!1}c=!1}return c}class l{constructor(t,e,{onupgradeneeded:n,onversionchange:s}={}){this.t=null,this.s=t,this.i=e,this.o=n,this.u=s||(()=>this.close())}get db(){return this.t}async open(){if(!this.t)return this.t=await new Promise((t,e)=>{let n=!1;setTimeout(()=>{n=!0,e(new Error("The open request was blocked and timed out"))},this.OPEN_TIMEOUT);const s=indexedDB.open(this.s,this.i);s.onerror=()=>e(s.error),s.onupgradeneeded=t=>{n?(s.transaction.abort(),s.result.close()):"function"==typeof this.o&&this.o(t)},s.onsuccess=()=>{const e=s.result;n?e.close():(e.onversionchange=this.u.bind(this),t(e))}}),this}async getKey(t,e){return(await this.getAllKeys(t,e,1))[0]}async getAll(t,e,n){return await this.getAllMatching(t,{query:e,count:n})}async getAllKeys(t,e,n){return(await this.getAllMatching(t,{query:e,count:n,includeKeys:!0})).map(t=>t.key)}async getAllMatching(t,{index:e,query:n=null,direction:s="next",count:r,includeKeys:i=!1}={}){return await this.transaction([t],"readonly",(o,a)=>{const c=o.objectStore(t),u=e?c.index(e):c,l=[],f=u.openCursor(n,s);f.onsuccess=()=>{const t=f.result;t?(l.push(i?t:t.value),r&&l.length>=r?a(l):t.continue()):a(l)}})}async transaction(t,e,n){return await this.open(),await new Promise((s,r)=>{const i=this.t.transaction(t,e);i.onabort=()=>r(i.error),i.oncomplete=()=>s(),n(i,t=>s(t))})}async l(t,e,n,...s){return await this.transaction([e],n,(n,r)=>{const i=n.objectStore(e),o=i[t].apply(i,s);o.onsuccess=()=>r(o.result)})}close(){this.t&&(this.t.close(),this.t=null)}}l.prototype.OPEN_TIMEOUT=2e3;const f={readonly:["get","count","getKey","getAll","getAllKeys"],readwrite:["add","put","clear","delete"]};for(const[t,e]of Object.entries(f))for(const n of e)n in IDBObjectStore.prototype&&(l.prototype[n]=async function(e,...s){return await this.l(n,e,t,...s)});function h(t){return new Promise(e=>setTimeout(e,t))}var w=Object.freeze({__proto__:null,assert:null,cacheNames:o,canConstructReadableStream:function(){if(void 0===a)try{new ReadableStream({start(){}}),a=!0}catch(t){a=!1}return a},canConstructResponseFromBodyStream:u,dontWaitFor:function(t){t.then(()=>{})},DBWrapper:l,Deferred:class{constructor(){this.promise=new Promise((t,e)=>{this.resolve=t,this.reject=e})}},deleteDatabase:async t=>{await new Promise((e,n)=>{const s=indexedDB.deleteDatabase(t);s.onerror=()=>{n(s.error)},s.onblocked=()=>{n(new Error("Delete blocked"))},s.onsuccess=()=>{e()}})},executeQuotaErrorCallbacks:async function(){for(const t of s)await t()},getFriendlyURL:t=>new URL(String(t),location.href).href.replace(new RegExp("^"+location.origin),""),logger:null,resultingClientExists:async function(t){if(!t)return;let e=await self.clients.matchAll({type:"window"});const n=new Set(e.map(t=>t.id));let s;const r=performance.now();for(;performance.now()-r<2e3&&(e=await self.clients.matchAll({type:"window"}),s=e.find(e=>t?e.id===t:!n.has(e.id)),!s);)await h(100);return s},timeout:h,WorkboxError:n});const d={get googleAnalytics(){return o.getGoogleAnalyticsName()},get precache(){return o.getPrecacheName()},get prefix(){return o.getPrefix()},get runtime(){return o.getRuntimeName()},get suffix(){return o.getSuffix()}};return t._private=w,t.cacheNames=d,t.clientsClaim=function(){self.addEventListener("activate",()=>self.clients.claim())},t.copyResponse=async function(t,e){let s=null;if(t.url){s=new URL(t.url).origin}if(s!==self.location.origin)throw new n("cross-origin-copy-response",{origin:s});const r=t.clone(),i={headers:new Headers(r.headers),status:r.status,statusText:r.statusText},o=e?e(i):i,a=u()?r.body:await r.blob();return new Response(a,o)},t.registerQuotaErrorCallback=function(t){s.add(t)},t.setCacheNameDetails=function(t){o.updateDetails(t)},t.skipWaiting=function(){self.skipWaiting()},t}({}); | ||
this.workbox=this.workbox||{},this.workbox.core=function(t){"use strict";try{self["workbox:core:6.0.0-alpha.2"]&&_()}catch(t){}const e=(t,...e)=>{let n=t;return e.length>0&&(n+=" :: "+JSON.stringify(e)),n};class n extends Error{constructor(t,n){super(e(t,n)),this.name=t,this.details=n}}const r=new Set;const s={googleAnalytics:"googleAnalytics",precache:"precache-v2",prefix:"workbox",runtime:"runtime",suffix:"undefined"!=typeof registration?registration.scope:""},o=t=>[s.prefix,t,s.suffix].filter((t=>t&&t.length>0)).join("-"),i={updateDetails:t=>{(t=>{for(const e of Object.keys(s))t(e)})((e=>{"string"==typeof t[e]&&(s[e]=t[e])}))},getGoogleAnalyticsName:t=>t||o(s.googleAnalytics),getPrecacheName:t=>t||o(s.precache),getPrefix:()=>s.prefix,getRuntimeName:t=>t||o(s.runtime),getSuffix:()=>s.suffix};function c(){return(c=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t}).apply(this,arguments)}function a(t,e){const n=new URL(t);for(const t of e)n.searchParams.delete(t);return n.href}let u,l;function f(){if(void 0===l){const t=new Response("");if("body"in t)try{new Response(t.body),l=!0}catch(t){l=!1}l=!1}return l}class h{constructor(t,e,{onupgradeneeded:n,onversionchange:r}={}){this.t=null,this.o=t,this.i=e,this.u=n,this.l=r||(()=>this.close())}get db(){return this.t}async open(){if(!this.t)return this.t=await new Promise(((t,e)=>{let n=!1;setTimeout((()=>{n=!0,e(new Error("The open request was blocked and timed out"))}),this.OPEN_TIMEOUT);const r=indexedDB.open(this.o,this.i);r.onerror=()=>e(r.error),r.onupgradeneeded=t=>{n?(r.transaction.abort(),r.result.close()):"function"==typeof this.u&&this.u(t)},r.onsuccess=()=>{const e=r.result;n?e.close():(e.onversionchange=this.l.bind(this),t(e))}})),this}async getKey(t,e){return(await this.getAllKeys(t,e,1))[0]}async getAll(t,e,n){return await this.getAllMatching(t,{query:e,count:n})}async getAllKeys(t,e,n){return(await this.getAllMatching(t,{query:e,count:n,includeKeys:!0})).map((t=>t.key))}async getAllMatching(t,{index:e,query:n=null,direction:r="next",count:s,includeKeys:o=!1}={}){return await this.transaction([t],"readonly",((i,c)=>{const a=i.objectStore(t),u=e?a.index(e):a,l=[],f=u.openCursor(n,r);f.onsuccess=()=>{const t=f.result;t?(l.push(o?t:t.value),s&&l.length>=s?c(l):t.continue()):c(l)}}))}async transaction(t,e,n){return await this.open(),await new Promise(((r,s)=>{const o=this.t.transaction(t,e);o.onabort=()=>s(o.error),o.oncomplete=()=>r(),n(o,(t=>r(t)))}))}async h(t,e,n,...r){return await this.transaction([e],n,((n,s)=>{const o=n.objectStore(e),i=o[t].apply(o,r);i.onsuccess=()=>s(i.result)}))}close(){this.t&&(this.t.close(),this.t=null)}}h.prototype.OPEN_TIMEOUT=2e3;const w={readonly:["get","count","getKey","getAll","getAllKeys"],readwrite:["add","put","clear","delete"]};for(const[t,e]of Object.entries(w))for(const n of e)n in IDBObjectStore.prototype&&(h.prototype[n]=async function(e,...r){return await this.h(n,e,t,...r)});function g(t){return new Promise((e=>setTimeout(e,t)))}var d=Object.freeze({__proto__:null,assert:null,cacheMatchIgnoreParams:async function(t,e,n,r){const s=a(e.url,n);if(e.url===s)return t.match(e,r);const o=c({},r,{ignoreSearch:!0}),i=await t.keys(e,o);for(const e of i){if(s===a(e.url,n))return t.match(e,r)}},cacheNames:i,canConstructReadableStream:function(){if(void 0===u)try{new ReadableStream({start(){}}),u=!0}catch(t){u=!1}return u},canConstructResponseFromBodyStream:f,dontWaitFor:function(t){t.then((()=>{}))},DBWrapper:h,Deferred:class{constructor(){this.promise=new Promise(((t,e)=>{this.resolve=t,this.reject=e}))}},deleteDatabase:async t=>{await new Promise(((e,n)=>{const r=indexedDB.deleteDatabase(t);r.onerror=()=>{n(r.error)},r.onblocked=()=>{n(new Error("Delete blocked"))},r.onsuccess=()=>{e()}}))},executeQuotaErrorCallbacks:async function(){for(const t of r)await t()},getFriendlyURL:t=>new URL(String(t),location.href).href.replace(new RegExp("^"+location.origin),""),logger:null,resultingClientExists:async function(t){if(!t)return;let e=await self.clients.matchAll({type:"window"});const n=new Set(e.map((t=>t.id)));let r;const s=performance.now();for(;performance.now()-s<2e3&&(e=await self.clients.matchAll({type:"window"}),r=e.find((e=>t?e.id===t:!n.has(e.id))),!r);)await g(100);return r},timeout:g,waitUntil:function(t,e){const n=e();return t.waitUntil(n),n},WorkboxError:n});const y={get googleAnalytics(){return i.getGoogleAnalyticsName()},get precache(){return i.getPrecacheName()},get prefix(){return i.getPrefix()},get runtime(){return i.getRuntimeName()},get suffix(){return i.getSuffix()}};return t._private=d,t.cacheNames=y,t.clientsClaim=function(){self.addEventListener("activate",(()=>self.clients.claim()))},t.copyResponse=async function(t,e){let r=null;if(t.url){r=new URL(t.url).origin}if(r!==self.location.origin)throw new n("cross-origin-copy-response",{origin:r});const s=t.clone(),o={headers:new Headers(s.headers),status:s.status,statusText:s.statusText},i=e?e(o):o,c=f()?s.body:await s.blob();return new Response(c,i)},t.registerQuotaErrorCallback=function(t){r.add(t)},t.setCacheNameDetails=function(t){i.updateDetails(t)},t.skipWaiting=function(){self.skipWaiting()},t}({}); | ||
//# sourceMappingURL=workbox-core.prod.js.map |
{ | ||
"name": "workbox-core", | ||
"version": "6.0.0-alpha.2", | ||
"version": "6.0.0-alpha.3", | ||
"license": "MIT", | ||
@@ -23,3 +23,3 @@ "author": "Google's Web DevRel Team", | ||
"types": "index.d.ts", | ||
"gitHead": "45f41a2d2f9870c49837923bb5c5854917da3a08" | ||
"gitHead": "00ba07467b253751e874f53f424f2adb1c06e176" | ||
} |
@@ -12,2 +12,3 @@ /* | ||
import {cacheNames} from './_private/cacheNames.js'; | ||
import {cacheMatchIgnoreParams} from './_private/cacheMatchIgnoreParams.js'; | ||
import {canConstructReadableStream} from './_private/canConstructReadableStream.js'; | ||
@@ -24,2 +25,3 @@ import {canConstructResponseFromBodyStream} from './_private/canConstructResponseFromBodyStream.js'; | ||
import {timeout} from './_private/timeout.js'; | ||
import {waitUntil} from './_private/waitUntil.js'; | ||
import {WorkboxError} from './_private/WorkboxError.js'; | ||
@@ -31,2 +33,3 @@ | ||
assert, | ||
cacheMatchIgnoreParams, | ||
cacheNames, | ||
@@ -44,3 +47,4 @@ canConstructReadableStream, | ||
timeout, | ||
waitUntil, | ||
WorkboxError, | ||
}; |
@@ -15,5 +15,5 @@ /* | ||
**/ | ||
export function dontWaitFor(promise: Promise<any>) { | ||
export function dontWaitFor(promise: Promise<any>): void { | ||
// Effective no-op. | ||
promise.then(() => {}); | ||
} |
// @ts-ignore | ||
try{self['workbox:core:6.0.0-alpha.1']&&_()}catch(e){} | ||
try{self['workbox:core:6.0.0-alpha.2']&&_()}catch(e){} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Unidentified License
License(Experimental) Something that seems like a license was found, but its contents could not be matched with a known license.
Found 3 instances in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Unidentified License
License(Experimental) Something that seems like a license was found, but its contents could not be matched with a known license.
Found 1 instance in 1 package
137
5149
397878
10