jekyll-pwa-workbox 5.1.4 → 5.1.41
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/jekyll-pwa-workbox.rb +1 -1
- data/lib/vendor/workbox-v5.1.4/workbox-background-sync.dev.js +818 -818
- data/lib/vendor/workbox-v5.1.4/workbox-background-sync.prod.js +2 -2
- data/lib/vendor/workbox-v5.1.4/workbox-broadcast-update.dev.js +288 -288
- data/lib/vendor/workbox-v5.1.4/workbox-broadcast-update.prod.js +2 -2
- data/lib/vendor/workbox-v5.1.4/workbox-cacheable-response.dev.js +191 -191
- data/lib/vendor/workbox-v5.1.4/workbox-cacheable-response.prod.js +2 -2
- data/lib/vendor/workbox-v5.1.4/workbox-core.dev.js +1858 -1858
- data/lib/vendor/workbox-v5.1.4/workbox-core.prod.js +2 -2
- data/lib/vendor/workbox-v5.1.4/workbox-expiration.dev.js +649 -649
- data/lib/vendor/workbox-v5.1.4/workbox-expiration.prod.js +2 -2
- data/lib/vendor/workbox-v5.1.4/workbox-navigation-preload.dev.js +102 -102
- data/lib/vendor/workbox-v5.1.4/workbox-navigation-preload.prod.js +2 -2
- data/lib/vendor/workbox-v5.1.4/workbox-offline-ga.dev.js +235 -235
- data/lib/vendor/workbox-v5.1.4/workbox-offline-ga.prod.js +2 -2
- data/lib/vendor/workbox-v5.1.4/workbox-precaching.dev.js +1210 -1210
- data/lib/vendor/workbox-v5.1.4/workbox-precaching.prod.js +2 -2
- data/lib/vendor/workbox-v5.1.4/workbox-range-requests.dev.js +262 -262
- data/lib/vendor/workbox-v5.1.4/workbox-range-requests.prod.js +2 -2
- data/lib/vendor/workbox-v5.1.4/workbox-routing.dev.js +923 -923
- data/lib/vendor/workbox-v5.1.4/workbox-routing.prod.js +2 -2
- data/lib/vendor/workbox-v5.1.4/workbox-strategies.dev.js +923 -923
- data/lib/vendor/workbox-v5.1.4/workbox-strategies.prod.js +2 -2
- data/lib/vendor/workbox-v5.1.4/workbox-streams.dev.js +318 -318
- data/lib/vendor/workbox-v5.1.4/workbox-streams.prod.js +2 -2
- data/lib/vendor/workbox-v5.1.4/workbox-sw.js +2 -2
- data/lib/vendor/workbox-v5.1.4/workbox-window.dev.es5.mjs +1125 -1125
- data/lib/vendor/workbox-v5.1.4/workbox-window.dev.mjs +943 -943
- data/lib/vendor/workbox-v5.1.4/workbox-window.dev.umd.js +1136 -1136
- data/lib/vendor/workbox-v5.1.4/workbox-window.prod.es5.mjs +2 -2
- data/lib/vendor/workbox-v5.1.4/workbox-window.prod.mjs +2 -2
- data/lib/vendor/workbox-v5.1.4/workbox-window.prod.umd.js +2 -2
- metadata +2 -2
@@ -1,2 +1,2 @@
|
|
1
|
-
this.workbox=this.workbox||{},this.workbox.expiration=function(t,e,s,i,a,n,h){"use strict";try{self["workbox:expiration:5.1.4"]&&_()}catch(t){}const r=t=>{const e=new URL(t,location.href);return e.hash="",e.href};class c{constructor(t){this.t=t,this.s=new i.DBWrapper("workbox-expiration",1,{onupgradeneeded:t=>this.i(t)})}i(t){const e=t.target.result.createObjectStore("cache-entries",{keyPath:"id"});e.createIndex("cacheName","cacheName",{unique:!1}),e.createIndex("timestamp","timestamp",{unique:!1}),a.deleteDatabase(this.t)}async setTimestamp(t,e){const s={url:t=r(t),timestamp:e,cacheName:this.t,id:this.h(t)};await this.s.put("cache-entries",s)}async getTimestamp(t){return(await this.s.get("cache-entries",this.h(t))).timestamp}async expireEntries(t,e){const s=await this.s.transaction("cache-entries","readwrite",(s,i)=>{const a=s.objectStore("cache-entries").index("timestamp").openCursor(null,"prev"),n=[];let h=0;a.onsuccess=()=>{const s=a.result;if(s){const i=s.value;i.cacheName===this.t&&(t&&i.timestamp<t||e&&h>=e?n.push(s.value):h++),s.continue()}else i(n)}}),i=[];for(const t of s)await this.s.delete("cache-entries",t.id),i.push(t.url);return i}h(t){return this.t+"|"+r(t)}}class o{constructor(t,e={}){this.o=!1,this.u=!1,this.l=e.maxEntries,this.m=e.maxAgeSeconds,this.t=t,this.p=new c(t)}async expireEntries(){if(this.o)return void(this.u=!0);this.o=!0;const t=this.m?Date.now()-1e3*this.m:0,s=await this.p.expireEntries(t,this.l),i=await self.caches.open(this.t);for(const t of s)await i.delete(t);this.o=!1,this.u&&(this.u=!1,e.dontWaitFor(this.expireEntries()))}async updateTimestamp(t){await this.p.setTimestamp(t,Date.now())}async isURLExpired(t){if(this.m){return await this.p.getTimestamp(t)<Date.now()-1e3*this.m}return!1}async delete(){this.u=!1,await this.p.expireEntries(1/0)}}return t.CacheExpiration=o,t.ExpirationPlugin=class{constructor(t={}){this.cachedResponseWillBeUsed=async({event:t,request:s,cacheName:i,cachedResponse:a})=>{if(!a)return null;const n=this.k(a),h=this.D(i);e.dontWaitFor(h.expireEntries());const r=h.updateTimestamp(s.url);if(t)try{t.waitUntil(r)}catch(t){}return n?a:null},this.cacheDidUpdate=async({cacheName:t,request:e})=>{const s=this.D(t);await s.updateTimestamp(e.url),await s.expireEntries()},this.N=t,this.m=t.maxAgeSeconds,this.g=new Map,t.purgeOnQuotaError&&h.registerQuotaErrorCallback(()=>this.deleteCacheAndMetadata())}D(t){if(t===n.cacheNames.getRuntimeName())throw new s.WorkboxError("expire-custom-caches-only");let e=this.g.get(t);return e||(e=new o(t,this.N),this.g.set(t,e)),e}k(t){if(!this.m)return!0;const e=this._(t);if(null===e)return!0;return e>=Date.now()-1e3*this.m}_(t){if(!t.headers.has("date"))return null;const e=t.headers.get("date"),s=new Date(e).getTime();return isNaN(s)?null:s}async deleteCacheAndMetadata(){for(const[t,e]of this.g)await self.caches.delete(t),await e.delete();this.g=new Map}},t}({},workbox.core._private,workbox.core._private,workbox.core._private,workbox.core._private,workbox.core._private,workbox.core);
|
2
|
-
//# sourceMappingURL=workbox-expiration.prod.js.map
|
1
|
+
this.workbox=this.workbox||{},this.workbox.expiration=function(t,e,s,i,a,n,h){"use strict";try{self["workbox:expiration:5.1.4"]&&_()}catch(t){}const r=t=>{const e=new URL(t,location.href);return e.hash="",e.href};class c{constructor(t){this.t=t,this.s=new i.DBWrapper("workbox-expiration",1,{onupgradeneeded:t=>this.i(t)})}i(t){const e=t.target.result.createObjectStore("cache-entries",{keyPath:"id"});e.createIndex("cacheName","cacheName",{unique:!1}),e.createIndex("timestamp","timestamp",{unique:!1}),a.deleteDatabase(this.t)}async setTimestamp(t,e){const s={url:t=r(t),timestamp:e,cacheName:this.t,id:this.h(t)};await this.s.put("cache-entries",s)}async getTimestamp(t){return(await this.s.get("cache-entries",this.h(t))).timestamp}async expireEntries(t,e){const s=await this.s.transaction("cache-entries","readwrite",(s,i)=>{const a=s.objectStore("cache-entries").index("timestamp").openCursor(null,"prev"),n=[];let h=0;a.onsuccess=()=>{const s=a.result;if(s){const i=s.value;i.cacheName===this.t&&(t&&i.timestamp<t||e&&h>=e?n.push(s.value):h++),s.continue()}else i(n)}}),i=[];for(const t of s)await this.s.delete("cache-entries",t.id),i.push(t.url);return i}h(t){return this.t+"|"+r(t)}}class o{constructor(t,e={}){this.o=!1,this.u=!1,this.l=e.maxEntries,this.m=e.maxAgeSeconds,this.t=t,this.p=new c(t)}async expireEntries(){if(this.o)return void(this.u=!0);this.o=!0;const t=this.m?Date.now()-1e3*this.m:0,s=await this.p.expireEntries(t,this.l),i=await self.caches.open(this.t);for(const t of s)await i.delete(t);this.o=!1,this.u&&(this.u=!1,e.dontWaitFor(this.expireEntries()))}async updateTimestamp(t){await this.p.setTimestamp(t,Date.now())}async isURLExpired(t){if(this.m){return await this.p.getTimestamp(t)<Date.now()-1e3*this.m}return!1}async delete(){this.u=!1,await this.p.expireEntries(1/0)}}return t.CacheExpiration=o,t.ExpirationPlugin=class{constructor(t={}){this.cachedResponseWillBeUsed=async({event:t,request:s,cacheName:i,cachedResponse:a})=>{if(!a)return null;const n=this.k(a),h=this.D(i);e.dontWaitFor(h.expireEntries());const r=h.updateTimestamp(s.url);if(t)try{t.waitUntil(r)}catch(t){}return n?a:null},this.cacheDidUpdate=async({cacheName:t,request:e})=>{const s=this.D(t);await s.updateTimestamp(e.url),await s.expireEntries()},this.N=t,this.m=t.maxAgeSeconds,this.g=new Map,t.purgeOnQuotaError&&h.registerQuotaErrorCallback(()=>this.deleteCacheAndMetadata())}D(t){if(t===n.cacheNames.getRuntimeName())throw new s.WorkboxError("expire-custom-caches-only");let e=this.g.get(t);return e||(e=new o(t,this.N),this.g.set(t,e)),e}k(t){if(!this.m)return!0;const e=this._(t);if(null===e)return!0;return e>=Date.now()-1e3*this.m}_(t){if(!t.headers.has("date"))return null;const e=t.headers.get("date"),s=new Date(e).getTime();return isNaN(s)?null:s}async deleteCacheAndMetadata(){for(const[t,e]of this.g)await self.caches.delete(t),await e.delete();this.g=new Map}},t}({},workbox.core._private,workbox.core._private,workbox.core._private,workbox.core._private,workbox.core._private,workbox.core);
|
2
|
+
//# sourceMappingURL=workbox-expiration.prod.js.map
|
@@ -1,102 +1,102 @@
|
|
1
|
-
this.workbox = this.workbox || {};
|
2
|
-
this.workbox.navigationPreload = (function (exports, logger_js) {
|
3
|
-
'use strict';
|
4
|
-
|
5
|
-
try {
|
6
|
-
self['workbox:navigation-preload:5.1.4'] && _();
|
7
|
-
} catch (e) {}
|
8
|
-
|
9
|
-
/*
|
10
|
-
Copyright 2018 Google LLC
|
11
|
-
|
12
|
-
Use of this source code is governed by an MIT-style
|
13
|
-
license that can be found in the LICENSE file or at
|
14
|
-
https://opensource.org/licenses/MIT.
|
15
|
-
*/
|
16
|
-
/**
|
17
|
-
* @return {boolean} Whether or not the current browser supports enabling
|
18
|
-
* navigation preload.
|
19
|
-
*
|
20
|
-
* @memberof module:workbox-navigation-preload
|
21
|
-
*/
|
22
|
-
|
23
|
-
function isSupported() {
|
24
|
-
return Boolean(self.registration && self.registration.navigationPreload);
|
25
|
-
}
|
26
|
-
|
27
|
-
/*
|
28
|
-
Copyright 2018 Google LLC
|
29
|
-
|
30
|
-
Use of this source code is governed by an MIT-style
|
31
|
-
license that can be found in the LICENSE file or at
|
32
|
-
https://opensource.org/licenses/MIT.
|
33
|
-
*/
|
34
|
-
/**
|
35
|
-
* If the browser supports Navigation Preload, then this will disable it.
|
36
|
-
*
|
37
|
-
* @memberof module:workbox-navigation-preload
|
38
|
-
*/
|
39
|
-
|
40
|
-
function disable() {
|
41
|
-
if (isSupported()) {
|
42
|
-
self.addEventListener('activate', event => {
|
43
|
-
event.waitUntil(self.registration.navigationPreload.disable().then(() => {
|
44
|
-
{
|
45
|
-
logger_js.logger.log(`Navigation preload is disabled.`);
|
46
|
-
}
|
47
|
-
}));
|
48
|
-
});
|
49
|
-
} else {
|
50
|
-
{
|
51
|
-
logger_js.logger.log(`Navigation preload is not supported in this browser.`);
|
52
|
-
}
|
53
|
-
}
|
54
|
-
}
|
55
|
-
|
56
|
-
/*
|
57
|
-
Copyright 2018 Google LLC
|
58
|
-
|
59
|
-
Use of this source code is governed by an MIT-style
|
60
|
-
license that can be found in the LICENSE file or at
|
61
|
-
https://opensource.org/licenses/MIT.
|
62
|
-
*/
|
63
|
-
/**
|
64
|
-
* If the browser supports Navigation Preload, then this will enable it.
|
65
|
-
*
|
66
|
-
* @param {string} [headerValue] Optionally, allows developers to
|
67
|
-
* [override](https://developers.google.com/web/updates/2017/02/navigation-preload#changing_the_header)
|
68
|
-
* the value of the `Service-Worker-Navigation-Preload` header which will be
|
69
|
-
* sent to the server when making the navigation request.
|
70
|
-
*
|
71
|
-
* @memberof module:workbox-navigation-preload
|
72
|
-
*/
|
73
|
-
|
74
|
-
function enable(headerValue) {
|
75
|
-
if (isSupported()) {
|
76
|
-
self.addEventListener('activate', event => {
|
77
|
-
event.waitUntil(self.registration.navigationPreload.enable().then(() => {
|
78
|
-
// Defaults to Service-Worker-Navigation-Preload: true if not set.
|
79
|
-
if (headerValue) {
|
80
|
-
self.registration.navigationPreload.setHeaderValue(headerValue);
|
81
|
-
}
|
82
|
-
|
83
|
-
{
|
84
|
-
logger_js.logger.log(`Navigation preload is enabled.`);
|
85
|
-
}
|
86
|
-
}));
|
87
|
-
});
|
88
|
-
} else {
|
89
|
-
{
|
90
|
-
logger_js.logger.log(`Navigation preload is not supported in this browser.`);
|
91
|
-
}
|
92
|
-
}
|
93
|
-
}
|
94
|
-
|
95
|
-
exports.disable = disable;
|
96
|
-
exports.enable = enable;
|
97
|
-
exports.isSupported = isSupported;
|
98
|
-
|
99
|
-
return exports;
|
100
|
-
|
101
|
-
}({}, workbox.core._private));
|
102
|
-
//# sourceMappingURL=workbox-navigation-preload.dev.js.map
|
1
|
+
this.workbox = this.workbox || {};
|
2
|
+
this.workbox.navigationPreload = (function (exports, logger_js) {
|
3
|
+
'use strict';
|
4
|
+
|
5
|
+
try {
|
6
|
+
self['workbox:navigation-preload:5.1.4'] && _();
|
7
|
+
} catch (e) {}
|
8
|
+
|
9
|
+
/*
|
10
|
+
Copyright 2018 Google LLC
|
11
|
+
|
12
|
+
Use of this source code is governed by an MIT-style
|
13
|
+
license that can be found in the LICENSE file or at
|
14
|
+
https://opensource.org/licenses/MIT.
|
15
|
+
*/
|
16
|
+
/**
|
17
|
+
* @return {boolean} Whether or not the current browser supports enabling
|
18
|
+
* navigation preload.
|
19
|
+
*
|
20
|
+
* @memberof module:workbox-navigation-preload
|
21
|
+
*/
|
22
|
+
|
23
|
+
function isSupported() {
|
24
|
+
return Boolean(self.registration && self.registration.navigationPreload);
|
25
|
+
}
|
26
|
+
|
27
|
+
/*
|
28
|
+
Copyright 2018 Google LLC
|
29
|
+
|
30
|
+
Use of this source code is governed by an MIT-style
|
31
|
+
license that can be found in the LICENSE file or at
|
32
|
+
https://opensource.org/licenses/MIT.
|
33
|
+
*/
|
34
|
+
/**
|
35
|
+
* If the browser supports Navigation Preload, then this will disable it.
|
36
|
+
*
|
37
|
+
* @memberof module:workbox-navigation-preload
|
38
|
+
*/
|
39
|
+
|
40
|
+
function disable() {
|
41
|
+
if (isSupported()) {
|
42
|
+
self.addEventListener('activate', event => {
|
43
|
+
event.waitUntil(self.registration.navigationPreload.disable().then(() => {
|
44
|
+
{
|
45
|
+
logger_js.logger.log(`Navigation preload is disabled.`);
|
46
|
+
}
|
47
|
+
}));
|
48
|
+
});
|
49
|
+
} else {
|
50
|
+
{
|
51
|
+
logger_js.logger.log(`Navigation preload is not supported in this browser.`);
|
52
|
+
}
|
53
|
+
}
|
54
|
+
}
|
55
|
+
|
56
|
+
/*
|
57
|
+
Copyright 2018 Google LLC
|
58
|
+
|
59
|
+
Use of this source code is governed by an MIT-style
|
60
|
+
license that can be found in the LICENSE file or at
|
61
|
+
https://opensource.org/licenses/MIT.
|
62
|
+
*/
|
63
|
+
/**
|
64
|
+
* If the browser supports Navigation Preload, then this will enable it.
|
65
|
+
*
|
66
|
+
* @param {string} [headerValue] Optionally, allows developers to
|
67
|
+
* [override](https://developers.google.com/web/updates/2017/02/navigation-preload#changing_the_header)
|
68
|
+
* the value of the `Service-Worker-Navigation-Preload` header which will be
|
69
|
+
* sent to the server when making the navigation request.
|
70
|
+
*
|
71
|
+
* @memberof module:workbox-navigation-preload
|
72
|
+
*/
|
73
|
+
|
74
|
+
function enable(headerValue) {
|
75
|
+
if (isSupported()) {
|
76
|
+
self.addEventListener('activate', event => {
|
77
|
+
event.waitUntil(self.registration.navigationPreload.enable().then(() => {
|
78
|
+
// Defaults to Service-Worker-Navigation-Preload: true if not set.
|
79
|
+
if (headerValue) {
|
80
|
+
self.registration.navigationPreload.setHeaderValue(headerValue);
|
81
|
+
}
|
82
|
+
|
83
|
+
{
|
84
|
+
logger_js.logger.log(`Navigation preload is enabled.`);
|
85
|
+
}
|
86
|
+
}));
|
87
|
+
});
|
88
|
+
} else {
|
89
|
+
{
|
90
|
+
logger_js.logger.log(`Navigation preload is not supported in this browser.`);
|
91
|
+
}
|
92
|
+
}
|
93
|
+
}
|
94
|
+
|
95
|
+
exports.disable = disable;
|
96
|
+
exports.enable = enable;
|
97
|
+
exports.isSupported = isSupported;
|
98
|
+
|
99
|
+
return exports;
|
100
|
+
|
101
|
+
}({}, workbox.core._private));
|
102
|
+
//# sourceMappingURL=workbox-navigation-preload.dev.js.map
|
@@ -1,2 +1,2 @@
|
|
1
|
-
this.workbox=this.workbox||{},this.workbox.navigationPreload=function(t){"use strict";try{self["workbox:navigation-preload:5.1.4"]&&_()}catch(t){}function e(){return Boolean(self.registration&&self.registration.navigationPreload)}return t.disable=function(){e()&&self.addEventListener("activate",t=>{t.waitUntil(self.registration.navigationPreload.disable().then(()=>{}))})},t.enable=function(t){e()&&self.addEventListener("activate",e=>{e.waitUntil(self.registration.navigationPreload.enable().then(()=>{t&&self.registration.navigationPreload.setHeaderValue(t)}))})},t.isSupported=e,t}({});
|
2
|
-
//# sourceMappingURL=workbox-navigation-preload.prod.js.map
|
1
|
+
this.workbox=this.workbox||{},this.workbox.navigationPreload=function(t){"use strict";try{self["workbox:navigation-preload:5.1.4"]&&_()}catch(t){}function e(){return Boolean(self.registration&&self.registration.navigationPreload)}return t.disable=function(){e()&&self.addEventListener("activate",t=>{t.waitUntil(self.registration.navigationPreload.disable().then(()=>{}))})},t.enable=function(t){e()&&self.addEventListener("activate",e=>{e.waitUntil(self.registration.navigationPreload.enable().then(()=>{t&&self.registration.navigationPreload.setHeaderValue(t)}))})},t.isSupported=e,t}({});
|
2
|
+
//# sourceMappingURL=workbox-navigation-preload.prod.js.map
|
@@ -1,235 +1,235 @@
|
|
1
|
-
this.workbox = this.workbox || {};
|
2
|
-
this.workbox.googleAnalytics = (function (exports, BackgroundSyncPlugin_js, cacheNames_js, getFriendlyURL_js, logger_js, Route_js, Router_js, NetworkFirst_js, NetworkOnly_js) {
|
3
|
-
'use strict';
|
4
|
-
|
5
|
-
try {
|
6
|
-
self['workbox:google-analytics:5.1.4'] && _();
|
7
|
-
} catch (e) {}
|
8
|
-
|
9
|
-
/*
|
10
|
-
Copyright 2018 Google LLC
|
11
|
-
|
12
|
-
Use of this source code is governed by an MIT-style
|
13
|
-
license that can be found in the LICENSE file or at
|
14
|
-
https://opensource.org/licenses/MIT.
|
15
|
-
*/
|
16
|
-
const QUEUE_NAME = 'workbox-google-analytics';
|
17
|
-
const MAX_RETENTION_TIME = 60 * 48; // Two days in minutes
|
18
|
-
|
19
|
-
const GOOGLE_ANALYTICS_HOST = 'www.google-analytics.com';
|
20
|
-
const GTM_HOST = 'www.googletagmanager.com';
|
21
|
-
const ANALYTICS_JS_PATH = '/analytics.js';
|
22
|
-
const GTAG_JS_PATH = '/gtag/js';
|
23
|
-
const GTM_JS_PATH = '/gtm.js';
|
24
|
-
// endpoints. Most of the time the default path (/collect) is used, but
|
25
|
-
// occasionally an experimental endpoint is used when testing new features,
|
26
|
-
// (e.g. /r/collect or /j/collect)
|
27
|
-
|
28
|
-
const COLLECT_PATHS_REGEX = /^\/(\w+\/)?collect/;
|
29
|
-
|
30
|
-
/*
|
31
|
-
Copyright 2018 Google LLC
|
32
|
-
|
33
|
-
Use of this source code is governed by an MIT-style
|
34
|
-
license that can be found in the LICENSE file or at
|
35
|
-
https://opensource.org/licenses/MIT.
|
36
|
-
*/
|
37
|
-
/**
|
38
|
-
* Creates the requestWillDequeue callback to be used with the background
|
39
|
-
* sync plugin. The callback takes the failed request and adds the
|
40
|
-
* `qt` param based on the current time, as well as applies any other
|
41
|
-
* user-defined hit modifications.
|
42
|
-
*
|
43
|
-
* @param {Object} config See {@link module:workbox-google-analytics.initialize}.
|
44
|
-
* @return {Function} The requestWillDequeue callback function.
|
45
|
-
*
|
46
|
-
* @private
|
47
|
-
*/
|
48
|
-
|
49
|
-
const createOnSyncCallback = config => {
|
50
|
-
return async ({
|
51
|
-
queue
|
52
|
-
}) => {
|
53
|
-
let entry;
|
54
|
-
|
55
|
-
while (entry = await queue.shiftRequest()) {
|
56
|
-
const {
|
57
|
-
request,
|
58
|
-
timestamp
|
59
|
-
} = entry;
|
60
|
-
const url = new URL(request.url);
|
61
|
-
|
62
|
-
try {
|
63
|
-
// Measurement protocol requests can set their payload parameters in
|
64
|
-
// either the URL query string (for GET requests) or the POST body.
|
65
|
-
const params = request.method === 'POST' ? new URLSearchParams(await request.clone().text()) : url.searchParams; // Calculate the qt param, accounting for the fact that an existing
|
66
|
-
// qt param may be present and should be updated rather than replaced.
|
67
|
-
|
68
|
-
const originalHitTime = timestamp - (Number(params.get('qt')) || 0);
|
69
|
-
const queueTime = Date.now() - originalHitTime; // Set the qt param prior to applying hitFilter or parameterOverrides.
|
70
|
-
|
71
|
-
params.set('qt', String(queueTime)); // Apply `parameterOverrides`, if set.
|
72
|
-
|
73
|
-
if (config.parameterOverrides) {
|
74
|
-
for (const param of Object.keys(config.parameterOverrides)) {
|
75
|
-
const value = config.parameterOverrides[param];
|
76
|
-
params.set(param, value);
|
77
|
-
}
|
78
|
-
} // Apply `hitFilter`, if set.
|
79
|
-
|
80
|
-
|
81
|
-
if (typeof config.hitFilter === 'function') {
|
82
|
-
config.hitFilter.call(null, params);
|
83
|
-
} // Retry the fetch. Ignore URL search params from the URL as they're
|
84
|
-
// now in the post body.
|
85
|
-
|
86
|
-
|
87
|
-
await fetch(new Request(url.origin + url.pathname, {
|
88
|
-
body: params.toString(),
|
89
|
-
method: 'POST',
|
90
|
-
mode: 'cors',
|
91
|
-
credentials: 'omit',
|
92
|
-
headers: {
|
93
|
-
'Content-Type': 'text/plain'
|
94
|
-
}
|
95
|
-
}));
|
96
|
-
|
97
|
-
if ("dev" !== 'production') {
|
98
|
-
logger_js.logger.log(`Request for '${getFriendlyURL_js.getFriendlyURL(url.href)}'` + `has been replayed`);
|
99
|
-
}
|
100
|
-
} catch (err) {
|
101
|
-
await queue.unshiftRequest(entry);
|
102
|
-
|
103
|
-
{
|
104
|
-
logger_js.logger.log(`Request for '${getFriendlyURL_js.getFriendlyURL(url.href)}'` + `failed to replay, putting it back in the queue.`);
|
105
|
-
}
|
106
|
-
|
107
|
-
throw err;
|
108
|
-
}
|
109
|
-
}
|
110
|
-
|
111
|
-
{
|
112
|
-
logger_js.logger.log(`All Google Analytics request successfully replayed; ` + `the queue is now empty!`);
|
113
|
-
}
|
114
|
-
};
|
115
|
-
};
|
116
|
-
/**
|
117
|
-
* Creates GET and POST routes to catch failed Measurement Protocol hits.
|
118
|
-
*
|
119
|
-
* @param {BackgroundSyncPlugin} bgSyncPlugin
|
120
|
-
* @return {Array<Route>} The created routes.
|
121
|
-
*
|
122
|
-
* @private
|
123
|
-
*/
|
124
|
-
|
125
|
-
|
126
|
-
const createCollectRoutes = bgSyncPlugin => {
|
127
|
-
const match = ({
|
128
|
-
url
|
129
|
-
}) => url.hostname === GOOGLE_ANALYTICS_HOST && COLLECT_PATHS_REGEX.test(url.pathname);
|
130
|
-
|
131
|
-
const handler = new NetworkOnly_js.NetworkOnly({
|
132
|
-
plugins: [bgSyncPlugin]
|
133
|
-
});
|
134
|
-
return [new Route_js.Route(match, handler, 'GET'), new Route_js.Route(match, handler, 'POST')];
|
135
|
-
};
|
136
|
-
/**
|
137
|
-
* Creates a route with a network first strategy for the analytics.js script.
|
138
|
-
*
|
139
|
-
* @param {string} cacheName
|
140
|
-
* @return {Route} The created route.
|
141
|
-
*
|
142
|
-
* @private
|
143
|
-
*/
|
144
|
-
|
145
|
-
|
146
|
-
const createAnalyticsJsRoute = cacheName => {
|
147
|
-
const match = ({
|
148
|
-
url
|
149
|
-
}) => url.hostname === GOOGLE_ANALYTICS_HOST && url.pathname === ANALYTICS_JS_PATH;
|
150
|
-
|
151
|
-
const handler = new NetworkFirst_js.NetworkFirst({
|
152
|
-
cacheName
|
153
|
-
});
|
154
|
-
return new Route_js.Route(match, handler, 'GET');
|
155
|
-
};
|
156
|
-
/**
|
157
|
-
* Creates a route with a network first strategy for the gtag.js script.
|
158
|
-
*
|
159
|
-
* @param {string} cacheName
|
160
|
-
* @return {Route} The created route.
|
161
|
-
*
|
162
|
-
* @private
|
163
|
-
*/
|
164
|
-
|
165
|
-
|
166
|
-
const createGtagJsRoute = cacheName => {
|
167
|
-
const match = ({
|
168
|
-
url
|
169
|
-
}) => url.hostname === GTM_HOST && url.pathname === GTAG_JS_PATH;
|
170
|
-
|
171
|
-
const handler = new NetworkFirst_js.NetworkFirst({
|
172
|
-
cacheName
|
173
|
-
});
|
174
|
-
return new Route_js.Route(match, handler, 'GET');
|
175
|
-
};
|
176
|
-
/**
|
177
|
-
* Creates a route with a network first strategy for the gtm.js script.
|
178
|
-
*
|
179
|
-
* @param {string} cacheName
|
180
|
-
* @return {Route} The created route.
|
181
|
-
*
|
182
|
-
* @private
|
183
|
-
*/
|
184
|
-
|
185
|
-
|
186
|
-
const createGtmJsRoute = cacheName => {
|
187
|
-
const match = ({
|
188
|
-
url
|
189
|
-
}) => url.hostname === GTM_HOST && url.pathname === GTM_JS_PATH;
|
190
|
-
|
191
|
-
const handler = new NetworkFirst_js.NetworkFirst({
|
192
|
-
cacheName
|
193
|
-
});
|
194
|
-
return new Route_js.Route(match, handler, 'GET');
|
195
|
-
};
|
196
|
-
/**
|
197
|
-
* @param {Object=} [options]
|
198
|
-
* @param {Object} [options.cacheName] The cache name to store and retrieve
|
199
|
-
* analytics.js. Defaults to the cache names provided by `workbox-core`.
|
200
|
-
* @param {Object} [options.parameterOverrides]
|
201
|
-
* [Measurement Protocol parameters](https://developers.google.com/analytics/devguides/collection/protocol/v1/parameters),
|
202
|
-
* expressed as key/value pairs, to be added to replayed Google Analytics
|
203
|
-
* requests. This can be used to, e.g., set a custom dimension indicating
|
204
|
-
* that the request was replayed.
|
205
|
-
* @param {Function} [options.hitFilter] A function that allows you to modify
|
206
|
-
* the hit parameters prior to replaying
|
207
|
-
* the hit. The function is invoked with the original hit's URLSearchParams
|
208
|
-
* object as its only argument.
|
209
|
-
*
|
210
|
-
* @memberof module:workbox-google-analytics
|
211
|
-
*/
|
212
|
-
|
213
|
-
|
214
|
-
const initialize = (options = {}) => {
|
215
|
-
const cacheName = cacheNames_js.cacheNames.getGoogleAnalyticsName(options.cacheName);
|
216
|
-
const bgSyncPlugin = new BackgroundSyncPlugin_js.BackgroundSyncPlugin(QUEUE_NAME, {
|
217
|
-
maxRetentionTime: MAX_RETENTION_TIME,
|
218
|
-
onSync: createOnSyncCallback(options)
|
219
|
-
});
|
220
|
-
const routes = [createGtmJsRoute(cacheName), createAnalyticsJsRoute(cacheName), createGtagJsRoute(cacheName), ...createCollectRoutes(bgSyncPlugin)];
|
221
|
-
const router = new Router_js.Router();
|
222
|
-
|
223
|
-
for (const route of routes) {
|
224
|
-
router.registerRoute(route);
|
225
|
-
}
|
226
|
-
|
227
|
-
router.addFetchListener();
|
228
|
-
};
|
229
|
-
|
230
|
-
exports.initialize = initialize;
|
231
|
-
|
232
|
-
return exports;
|
233
|
-
|
234
|
-
}({}, workbox.backgroundSync, workbox.core._private, workbox.core._private, workbox.core._private, workbox.routing, workbox.routing, workbox.strategies, workbox.strategies));
|
235
|
-
//# sourceMappingURL=workbox-offline-ga.dev.js.map
|
1
|
+
this.workbox = this.workbox || {};
|
2
|
+
this.workbox.googleAnalytics = (function (exports, BackgroundSyncPlugin_js, cacheNames_js, getFriendlyURL_js, logger_js, Route_js, Router_js, NetworkFirst_js, NetworkOnly_js) {
|
3
|
+
'use strict';
|
4
|
+
|
5
|
+
try {
|
6
|
+
self['workbox:google-analytics:5.1.4'] && _();
|
7
|
+
} catch (e) {}
|
8
|
+
|
9
|
+
/*
|
10
|
+
Copyright 2018 Google LLC
|
11
|
+
|
12
|
+
Use of this source code is governed by an MIT-style
|
13
|
+
license that can be found in the LICENSE file or at
|
14
|
+
https://opensource.org/licenses/MIT.
|
15
|
+
*/
|
16
|
+
const QUEUE_NAME = 'workbox-google-analytics';
|
17
|
+
const MAX_RETENTION_TIME = 60 * 48; // Two days in minutes
|
18
|
+
|
19
|
+
const GOOGLE_ANALYTICS_HOST = 'www.google-analytics.com';
|
20
|
+
const GTM_HOST = 'www.googletagmanager.com';
|
21
|
+
const ANALYTICS_JS_PATH = '/analytics.js';
|
22
|
+
const GTAG_JS_PATH = '/gtag/js';
|
23
|
+
const GTM_JS_PATH = '/gtm.js';
|
24
|
+
// endpoints. Most of the time the default path (/collect) is used, but
|
25
|
+
// occasionally an experimental endpoint is used when testing new features,
|
26
|
+
// (e.g. /r/collect or /j/collect)
|
27
|
+
|
28
|
+
const COLLECT_PATHS_REGEX = /^\/(\w+\/)?collect/;
|
29
|
+
|
30
|
+
/*
|
31
|
+
Copyright 2018 Google LLC
|
32
|
+
|
33
|
+
Use of this source code is governed by an MIT-style
|
34
|
+
license that can be found in the LICENSE file or at
|
35
|
+
https://opensource.org/licenses/MIT.
|
36
|
+
*/
|
37
|
+
/**
|
38
|
+
* Creates the requestWillDequeue callback to be used with the background
|
39
|
+
* sync plugin. The callback takes the failed request and adds the
|
40
|
+
* `qt` param based on the current time, as well as applies any other
|
41
|
+
* user-defined hit modifications.
|
42
|
+
*
|
43
|
+
* @param {Object} config See {@link module:workbox-google-analytics.initialize}.
|
44
|
+
* @return {Function} The requestWillDequeue callback function.
|
45
|
+
*
|
46
|
+
* @private
|
47
|
+
*/
|
48
|
+
|
49
|
+
const createOnSyncCallback = config => {
|
50
|
+
return async ({
|
51
|
+
queue
|
52
|
+
}) => {
|
53
|
+
let entry;
|
54
|
+
|
55
|
+
while (entry = await queue.shiftRequest()) {
|
56
|
+
const {
|
57
|
+
request,
|
58
|
+
timestamp
|
59
|
+
} = entry;
|
60
|
+
const url = new URL(request.url);
|
61
|
+
|
62
|
+
try {
|
63
|
+
// Measurement protocol requests can set their payload parameters in
|
64
|
+
// either the URL query string (for GET requests) or the POST body.
|
65
|
+
const params = request.method === 'POST' ? new URLSearchParams(await request.clone().text()) : url.searchParams; // Calculate the qt param, accounting for the fact that an existing
|
66
|
+
// qt param may be present and should be updated rather than replaced.
|
67
|
+
|
68
|
+
const originalHitTime = timestamp - (Number(params.get('qt')) || 0);
|
69
|
+
const queueTime = Date.now() - originalHitTime; // Set the qt param prior to applying hitFilter or parameterOverrides.
|
70
|
+
|
71
|
+
params.set('qt', String(queueTime)); // Apply `parameterOverrides`, if set.
|
72
|
+
|
73
|
+
if (config.parameterOverrides) {
|
74
|
+
for (const param of Object.keys(config.parameterOverrides)) {
|
75
|
+
const value = config.parameterOverrides[param];
|
76
|
+
params.set(param, value);
|
77
|
+
}
|
78
|
+
} // Apply `hitFilter`, if set.
|
79
|
+
|
80
|
+
|
81
|
+
if (typeof config.hitFilter === 'function') {
|
82
|
+
config.hitFilter.call(null, params);
|
83
|
+
} // Retry the fetch. Ignore URL search params from the URL as they're
|
84
|
+
// now in the post body.
|
85
|
+
|
86
|
+
|
87
|
+
await fetch(new Request(url.origin + url.pathname, {
|
88
|
+
body: params.toString(),
|
89
|
+
method: 'POST',
|
90
|
+
mode: 'cors',
|
91
|
+
credentials: 'omit',
|
92
|
+
headers: {
|
93
|
+
'Content-Type': 'text/plain'
|
94
|
+
}
|
95
|
+
}));
|
96
|
+
|
97
|
+
if ("dev" !== 'production') {
|
98
|
+
logger_js.logger.log(`Request for '${getFriendlyURL_js.getFriendlyURL(url.href)}'` + `has been replayed`);
|
99
|
+
}
|
100
|
+
} catch (err) {
|
101
|
+
await queue.unshiftRequest(entry);
|
102
|
+
|
103
|
+
{
|
104
|
+
logger_js.logger.log(`Request for '${getFriendlyURL_js.getFriendlyURL(url.href)}'` + `failed to replay, putting it back in the queue.`);
|
105
|
+
}
|
106
|
+
|
107
|
+
throw err;
|
108
|
+
}
|
109
|
+
}
|
110
|
+
|
111
|
+
{
|
112
|
+
logger_js.logger.log(`All Google Analytics request successfully replayed; ` + `the queue is now empty!`);
|
113
|
+
}
|
114
|
+
};
|
115
|
+
};
|
116
|
+
/**
|
117
|
+
* Creates GET and POST routes to catch failed Measurement Protocol hits.
|
118
|
+
*
|
119
|
+
* @param {BackgroundSyncPlugin} bgSyncPlugin
|
120
|
+
* @return {Array<Route>} The created routes.
|
121
|
+
*
|
122
|
+
* @private
|
123
|
+
*/
|
124
|
+
|
125
|
+
|
126
|
+
const createCollectRoutes = bgSyncPlugin => {
|
127
|
+
const match = ({
|
128
|
+
url
|
129
|
+
}) => url.hostname === GOOGLE_ANALYTICS_HOST && COLLECT_PATHS_REGEX.test(url.pathname);
|
130
|
+
|
131
|
+
const handler = new NetworkOnly_js.NetworkOnly({
|
132
|
+
plugins: [bgSyncPlugin]
|
133
|
+
});
|
134
|
+
return [new Route_js.Route(match, handler, 'GET'), new Route_js.Route(match, handler, 'POST')];
|
135
|
+
};
|
136
|
+
/**
|
137
|
+
* Creates a route with a network first strategy for the analytics.js script.
|
138
|
+
*
|
139
|
+
* @param {string} cacheName
|
140
|
+
* @return {Route} The created route.
|
141
|
+
*
|
142
|
+
* @private
|
143
|
+
*/
|
144
|
+
|
145
|
+
|
146
|
+
const createAnalyticsJsRoute = cacheName => {
|
147
|
+
const match = ({
|
148
|
+
url
|
149
|
+
}) => url.hostname === GOOGLE_ANALYTICS_HOST && url.pathname === ANALYTICS_JS_PATH;
|
150
|
+
|
151
|
+
const handler = new NetworkFirst_js.NetworkFirst({
|
152
|
+
cacheName
|
153
|
+
});
|
154
|
+
return new Route_js.Route(match, handler, 'GET');
|
155
|
+
};
|
156
|
+
/**
|
157
|
+
* Creates a route with a network first strategy for the gtag.js script.
|
158
|
+
*
|
159
|
+
* @param {string} cacheName
|
160
|
+
* @return {Route} The created route.
|
161
|
+
*
|
162
|
+
* @private
|
163
|
+
*/
|
164
|
+
|
165
|
+
|
166
|
+
const createGtagJsRoute = cacheName => {
|
167
|
+
const match = ({
|
168
|
+
url
|
169
|
+
}) => url.hostname === GTM_HOST && url.pathname === GTAG_JS_PATH;
|
170
|
+
|
171
|
+
const handler = new NetworkFirst_js.NetworkFirst({
|
172
|
+
cacheName
|
173
|
+
});
|
174
|
+
return new Route_js.Route(match, handler, 'GET');
|
175
|
+
};
|
176
|
+
/**
|
177
|
+
* Creates a route with a network first strategy for the gtm.js script.
|
178
|
+
*
|
179
|
+
* @param {string} cacheName
|
180
|
+
* @return {Route} The created route.
|
181
|
+
*
|
182
|
+
* @private
|
183
|
+
*/
|
184
|
+
|
185
|
+
|
186
|
+
const createGtmJsRoute = cacheName => {
|
187
|
+
const match = ({
|
188
|
+
url
|
189
|
+
}) => url.hostname === GTM_HOST && url.pathname === GTM_JS_PATH;
|
190
|
+
|
191
|
+
const handler = new NetworkFirst_js.NetworkFirst({
|
192
|
+
cacheName
|
193
|
+
});
|
194
|
+
return new Route_js.Route(match, handler, 'GET');
|
195
|
+
};
|
196
|
+
/**
|
197
|
+
* @param {Object=} [options]
|
198
|
+
* @param {Object} [options.cacheName] The cache name to store and retrieve
|
199
|
+
* analytics.js. Defaults to the cache names provided by `workbox-core`.
|
200
|
+
* @param {Object} [options.parameterOverrides]
|
201
|
+
* [Measurement Protocol parameters](https://developers.google.com/analytics/devguides/collection/protocol/v1/parameters),
|
202
|
+
* expressed as key/value pairs, to be added to replayed Google Analytics
|
203
|
+
* requests. This can be used to, e.g., set a custom dimension indicating
|
204
|
+
* that the request was replayed.
|
205
|
+
* @param {Function} [options.hitFilter] A function that allows you to modify
|
206
|
+
* the hit parameters prior to replaying
|
207
|
+
* the hit. The function is invoked with the original hit's URLSearchParams
|
208
|
+
* object as its only argument.
|
209
|
+
*
|
210
|
+
* @memberof module:workbox-google-analytics
|
211
|
+
*/
|
212
|
+
|
213
|
+
|
214
|
+
const initialize = (options = {}) => {
|
215
|
+
const cacheName = cacheNames_js.cacheNames.getGoogleAnalyticsName(options.cacheName);
|
216
|
+
const bgSyncPlugin = new BackgroundSyncPlugin_js.BackgroundSyncPlugin(QUEUE_NAME, {
|
217
|
+
maxRetentionTime: MAX_RETENTION_TIME,
|
218
|
+
onSync: createOnSyncCallback(options)
|
219
|
+
});
|
220
|
+
const routes = [createGtmJsRoute(cacheName), createAnalyticsJsRoute(cacheName), createGtagJsRoute(cacheName), ...createCollectRoutes(bgSyncPlugin)];
|
221
|
+
const router = new Router_js.Router();
|
222
|
+
|
223
|
+
for (const route of routes) {
|
224
|
+
router.registerRoute(route);
|
225
|
+
}
|
226
|
+
|
227
|
+
router.addFetchListener();
|
228
|
+
};
|
229
|
+
|
230
|
+
exports.initialize = initialize;
|
231
|
+
|
232
|
+
return exports;
|
233
|
+
|
234
|
+
}({}, workbox.backgroundSync, workbox.core._private, workbox.core._private, workbox.core._private, workbox.routing, workbox.routing, workbox.strategies, workbox.strategies));
|
235
|
+
//# sourceMappingURL=workbox-offline-ga.dev.js.map
|