q78kgblog 0.0.0-1720441708496 → 0.0.0-1720859005089
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/404.html +3 -3
- package/about/index.html +5 -5
- package/archives/2023/02/index.html +4 -4
- package/archives/2023/04/index.html +4 -4
- package/archives/2023/05/index.html +4 -4
- package/archives/2023/08/index.html +4 -4
- package/archives/2023/09/index.html +4 -4
- package/archives/2023/index.html +4 -4
- package/archives/2024/01/index.html +4 -4
- package/archives/2024/02/index.html +4 -4
- package/archives/2024/index.html +4 -4
- package/archives/index.html +4 -4
- package/atom.xml +9 -9
- package/baidusitemap.xml +8 -8
- package/bangumis/index.html +4 -4
- package/bigpie/index.html +3 -3
- package/categories/Hexo/index.html +4 -4
- package/categories/index.html +3 -3
- package/categories//345/271/264/347/273/210/346/200/273/347/273/223/index.html +4 -4
- package/categories//347/264/240/346/235/220/index.html +4 -4
- package/categories//351/227/262/350/201/212/346/235/202/350/260/210/index.html +4 -4
- package/content.json +1 -1
- package/css/404page.css +1 -65
- package/css/ariasakablog.css +1 -6669
- package/css/commentBarrage.css +1 -118
- package/css/danmaku.css +1 -106
- package/css/essay.css +1 -306
- package/css/iconfont.css +1 -55
- package/css/index.css +1 -7006
- package/css/people.css +1 -18
- package/css/stylessimple.css +1 -40
- package/css/swiperstyle.css +1 -567
- package/fcircle/index.html +3 -3
- package/fontawesome/index.html +3 -3
- package/index.html +11 -11
- package/js/aplayersave.js +1 -268
- package/js/baiduhistory.js +1 -76
- package/js/browser.js +1 -35
- package/js/calendar.js +1 -380
- package/js/cate.js +1 -22
- package/js/commentBarrage.js +17 -232
- package/js/commentsCount.js +1 -43
- package/js/copy.js +1 -23
- package/js/countup.js +1 -209
- package/js/cursor.js +1 -82
- package/js/danmaku.js +0 -106
- package/js/day.js +13 -195
- package/js/dianzan.js +1 -249
- package/js/dis.js +4 -252
- package/js/dist/baiduhistory.dev.js +1 -102
- package/js/dist/bbtalk.dev.js +159 -12872
- package/js/dist/bbtalklunbo.dev.js +1 -45
- package/js/dist/calendar.dev.js +1 -395
- package/js/dist/fixbugpjax.dev.js +1 -8
- package/js/dist/gongnong.dev.js +1 -565
- package/js/dist/heimu.dev.js +1 -19
- package/js/dist/links.dev.js +1 -13
- package/js/dist/main.dev.js +5 -843
- package/js/dist/resizeTop.dev.js +1 -50
- package/js/dist/seo.dev.js +1 -33
- package/js/dist/twikoo.all.min.dev.js +946 -1
- package/js/fixbugpjax.js +1 -7
- package/js/fixed_card_widget.js +1 -46
- package/js/fps.js +1 -58
- package/js/gitalker.js +1 -11
- package/js/heimu.js +1 -16
- package/js/hide.show.js +1 -17
- package/js/languages.js +1 -511
- package/js/latest.js +1 -49
- package/js/local-search.js +2 -476
- package/js/lunar.js +1 -1071
- package/js/lyxTalk.js +1 -12
- package/js/main.js +5 -781
- package/js/nav.js +1 -30
- package/js/noie.js +1 -3
- package/js/owo.js +1 -52
- package/js/people.js +2 -175
- package/js/randomFriend.js +1 -95
- package/js/resizeTop.js +1 -43
- package/js/rightmenu.js +3 -333
- package/js/sakura.js +1 -164
- package/js/search/algolia.js +4 -154
- package/js/search/local-search.js +1 -188
- package/js/settings.js +3 -343
- package/js/sitetime.js +1 -25
- package/js/smooth-scrolling.js +1 -546
- package/js/sw-toolbox.js +1 -16
- package/js/swiperinit.js +1 -23
- package/js/tw_cn.js +1 -100
- package/js/utils.js +1 -278
- package/js/welcome.js +1 -107
- package/js/welcomeconsole.js +1 -23
- package/links/index.html +3 -3
- package/othersite/index.html +3 -3
- package/package.json +1 -1
- package/posts/164ef646/index.html +6 -6
- package/posts/228c2ef8/index.html +6 -6
- package/posts/a9a6c1fb/index.html +6 -6
- package/posts/c262e439/index.html +6 -6
- package/posts/c81531cf/index.html +6 -6
- package/posts/ccdf7cfc/index.html +6 -6
- package/posts/de1f83f4/index.html +6 -6
- package/posts/e54f7476/index.html +6 -6
- package/sitemap.xml +49 -49
- package/sw.js +2 -193
- package/swReg.js +1 -29
- package/tags/AI/index.html +5 -5
- package/tags/Butterfly/index.html +5 -5
- package/tags/Cloudflare/index.html +5 -5
- package/tags/DiffSinger/index.html +5 -5
- package/tags/Hexo/index.html +5 -5
- package/tags/Next/index.html +5 -5
- package/tags/RAID/index.html +5 -5
- package/tags/Vercel/index.html +5 -5
- package/tags/Workers/index.html +5 -5
- package/tags/index.html +3 -3
- package/tags//344/270/273/351/242/230/index.html +5 -5
- package/tags//345/206/231/344/275/234/index.html +5 -5
- package/tags//345/245/263/346/200/247/346/204/217/350/257/206/index.html +5 -5
- package/tags//345/255/246/344/271/240/index.html +5 -5
- package/tags//345/256/266/351/207/214/344/272/221/index.html +5 -5
- package/tags//345/271/264/347/273/210/346/200/273/347/273/223/index.html +5 -5
- package/tags//346/212/230/350/205/276/index.html +5 -5
- package/tags//346/227/245/345/270/270/index.html +5 -5
- package/tags//346/234/215/345/212/241/345/231/250/index.html +5 -5
- package/tags//346/265/252/346/275/256/index.html +5 -5
- package/tags//347/256/200/347/210/261/index.html +5 -5
- package/tags//350/207/252/345/212/250/346/240/207/346/263/250/index.html +5 -5
- package/tags//350/256/272/346/226/207/index.html +5 -5
- package/tags//350/260/267/346/255/214/347/277/273/350/257/221/index.html +5 -5
- package/tags//350/264/237/350/275/275/345/235/207/350/241/241/index.html +5 -5
- package/tags//351/207/221/345/217/245/index.html +5 -5
- package/tags//351/255/224/346/224/271/index.html +5 -5
package/js/smooth-scrolling.js
CHANGED
@@ -1,546 +1 @@
|
|
1
|
-
(function () {
|
2
|
-
var defaultOptions = {
|
3
|
-
frameRate: 150,
|
4
|
-
animationTime: 400,
|
5
|
-
stepSize: 100,
|
6
|
-
pulseAlgorithm: true,
|
7
|
-
pulseScale: 4,
|
8
|
-
pulseNormalize: 1,
|
9
|
-
accelerationDelta: 50,
|
10
|
-
accelerationMax: 3,
|
11
|
-
keyboardSupport: true,
|
12
|
-
arrowScroll: 50,
|
13
|
-
fixedBackground: true,
|
14
|
-
excluded: ''
|
15
|
-
};
|
16
|
-
var options = defaultOptions;
|
17
|
-
var isExcluded = false;
|
18
|
-
var isFrame = false;
|
19
|
-
var direction = {
|
20
|
-
x: 0,
|
21
|
-
y: 0
|
22
|
-
};
|
23
|
-
var initDone = false;
|
24
|
-
var root = document.documentElement;
|
25
|
-
var activeElement;
|
26
|
-
var observer;
|
27
|
-
var refreshSize;
|
28
|
-
var deltaBuffer = [];
|
29
|
-
var deltaBufferTimer;
|
30
|
-
var isMac = /^Mac/.test(navigator.platform);
|
31
|
-
var key = {
|
32
|
-
left: 37,
|
33
|
-
up: 38,
|
34
|
-
right: 39,
|
35
|
-
down: 40,
|
36
|
-
spacebar: 32,
|
37
|
-
pageup: 33,
|
38
|
-
pagedown: 34,
|
39
|
-
end: 35,
|
40
|
-
home: 36
|
41
|
-
};
|
42
|
-
var arrowKeys = {
|
43
|
-
37: 1,
|
44
|
-
38: 1,
|
45
|
-
39: 1,
|
46
|
-
40: 1
|
47
|
-
};
|
48
|
-
|
49
|
-
function initTest() {
|
50
|
-
if (options.keyboardSupport) {
|
51
|
-
addEvent('keydown', keydown);
|
52
|
-
}
|
53
|
-
}
|
54
|
-
|
55
|
-
function init() {
|
56
|
-
if (initDone || !document.body) return;
|
57
|
-
initDone = true;
|
58
|
-
var body = document.body;
|
59
|
-
var html = document.documentElement;
|
60
|
-
var windowHeight = window.innerHeight;
|
61
|
-
var scrollHeight = body.scrollHeight;
|
62
|
-
root = (document.compatMode.indexOf('CSS') >= 0) ? html : body;
|
63
|
-
activeElement = body;
|
64
|
-
initTest();
|
65
|
-
if (top != self) {
|
66
|
-
isFrame = true;
|
67
|
-
} else if (isOldSafari && scrollHeight > windowHeight && (body.offsetHeight <= windowHeight || html.offsetHeight <= windowHeight)) {
|
68
|
-
var fullPageElem = document.createElement('div');
|
69
|
-
fullPageElem.style.cssText = 'position:absolute; z-index:-10000; ' +
|
70
|
-
'top:0; left:0; right:0; height:' +
|
71
|
-
root.scrollHeight + 'px';
|
72
|
-
document.body.appendChild(fullPageElem);
|
73
|
-
var pendingRefresh;
|
74
|
-
refreshSize = function () {
|
75
|
-
if (pendingRefresh) return;
|
76
|
-
pendingRefresh = setTimeout(function () {
|
77
|
-
if (isExcluded) return;
|
78
|
-
fullPageElem.style.height = '0';
|
79
|
-
fullPageElem.style.height = root.scrollHeight + 'px';
|
80
|
-
pendingRefresh = null;
|
81
|
-
}, 500);
|
82
|
-
};
|
83
|
-
setTimeout(refreshSize, 10);
|
84
|
-
addEvent('resize', refreshSize);
|
85
|
-
var config = {
|
86
|
-
attributes: true,
|
87
|
-
childList: true,
|
88
|
-
characterData: false
|
89
|
-
};
|
90
|
-
observer = new MutationObserver(refreshSize);
|
91
|
-
observer.observe(body, config);
|
92
|
-
if (root.offsetHeight <= windowHeight) {
|
93
|
-
var clearfix = document.createElement('div');
|
94
|
-
clearfix.style.clear = 'both';
|
95
|
-
body.appendChild(clearfix);
|
96
|
-
}
|
97
|
-
}
|
98
|
-
if (!options.fixedBackground && !isExcluded) {
|
99
|
-
body.style.backgroundAttachment = 'scroll';
|
100
|
-
html.style.backgroundAttachment = 'scroll';
|
101
|
-
}
|
102
|
-
}
|
103
|
-
|
104
|
-
function cleanup() {
|
105
|
-
observer && observer.disconnect();
|
106
|
-
removeEvent(wheelEvent, wheel);
|
107
|
-
removeEvent('mousedown', mousedown);
|
108
|
-
removeEvent('keydown', keydown);
|
109
|
-
removeEvent('resize', refreshSize);
|
110
|
-
removeEvent('load', init);
|
111
|
-
}
|
112
|
-
var que = [];
|
113
|
-
var pending = false;
|
114
|
-
var lastScroll = Date.now();
|
115
|
-
|
116
|
-
function scrollArray(elem, left, top) {
|
117
|
-
directionCheck(left, top);
|
118
|
-
if (options.accelerationMax != 1) {
|
119
|
-
var now = Date.now();
|
120
|
-
var elapsed = now - lastScroll;
|
121
|
-
if (elapsed < options.accelerationDelta) {
|
122
|
-
var factor = (1 + (50 / elapsed)) / 2;
|
123
|
-
if (factor > 1) {
|
124
|
-
factor = Math.min(factor, options.accelerationMax);
|
125
|
-
left *= factor;
|
126
|
-
top *= factor;
|
127
|
-
}
|
128
|
-
}
|
129
|
-
lastScroll = Date.now();
|
130
|
-
}
|
131
|
-
que.push({
|
132
|
-
x: left,
|
133
|
-
y: top,
|
134
|
-
lastX: (left < 0) ? 0.99 : -0.99,
|
135
|
-
lastY: (top < 0) ? 0.99 : -0.99,
|
136
|
-
start: Date.now()
|
137
|
-
});
|
138
|
-
if (pending) {
|
139
|
-
return;
|
140
|
-
}
|
141
|
-
var scrollRoot = getScrollRoot();
|
142
|
-
var isWindowScroll = (elem === scrollRoot || elem === document.body);
|
143
|
-
if (elem.$scrollBehavior == null && isScrollBehaviorSmooth(elem)) {
|
144
|
-
elem.$scrollBehavior = elem.style.scrollBehavior;
|
145
|
-
elem.style.scrollBehavior = 'auto';
|
146
|
-
}
|
147
|
-
var step = function (time) {
|
148
|
-
var now = Date.now();
|
149
|
-
var scrollX = 0;
|
150
|
-
var scrollY = 0;
|
151
|
-
for (var i = 0; i < que.length; i++) {
|
152
|
-
var item = que[i];
|
153
|
-
var elapsed = now - item.start;
|
154
|
-
var finished = (elapsed >= options.animationTime);
|
155
|
-
var position = (finished) ? 1 : elapsed / options.animationTime;
|
156
|
-
if (options.pulseAlgorithm) {
|
157
|
-
position = pulse(position);
|
158
|
-
}
|
159
|
-
var x = (item.x * position - item.lastX) >> 0;
|
160
|
-
var y = (item.y * position - item.lastY) >> 0;
|
161
|
-
scrollX += x;
|
162
|
-
scrollY += y;
|
163
|
-
item.lastX += x;
|
164
|
-
item.lastY += y;
|
165
|
-
if (finished) {
|
166
|
-
que.splice(i, 1);
|
167
|
-
i--;
|
168
|
-
}
|
169
|
-
}
|
170
|
-
if (isWindowScroll) {
|
171
|
-
window.scrollBy(scrollX, scrollY);
|
172
|
-
} else {
|
173
|
-
if (scrollX) elem.scrollLeft += scrollX;
|
174
|
-
if (scrollY) elem.scrollTop += scrollY;
|
175
|
-
}
|
176
|
-
if (!left && !top) {
|
177
|
-
que = [];
|
178
|
-
}
|
179
|
-
if (que.length) {
|
180
|
-
requestFrame(step, elem, (1000 / options.frameRate + 1));
|
181
|
-
} else {
|
182
|
-
pending = false;
|
183
|
-
if (elem.$scrollBehavior != null) {
|
184
|
-
elem.style.scrollBehavior = elem.$scrollBehavior;
|
185
|
-
elem.$scrollBehavior = null;
|
186
|
-
}
|
187
|
-
}
|
188
|
-
};
|
189
|
-
requestFrame(step, elem, 0);
|
190
|
-
pending = true;
|
191
|
-
}
|
192
|
-
|
193
|
-
function wheel(event) {
|
194
|
-
if (!initDone) {
|
195
|
-
init();
|
196
|
-
}
|
197
|
-
var target = event.target;
|
198
|
-
if (event.defaultPrevented || event.ctrlKey) {
|
199
|
-
return true;
|
200
|
-
}
|
201
|
-
if (isNodeName(activeElement, 'embed') || (isNodeName(target, 'embed') && /\.pdf/i.test(target.src)) || isNodeName(activeElement, 'object') || target.shadowRoot) {
|
202
|
-
return true;
|
203
|
-
}
|
204
|
-
var deltaX = -event.wheelDeltaX || event.deltaX || 0;
|
205
|
-
var deltaY = -event.wheelDeltaY || event.deltaY || 0;
|
206
|
-
if (isMac) {
|
207
|
-
if (event.wheelDeltaX && isDivisible(event.wheelDeltaX, 120)) {
|
208
|
-
deltaX = -120 * (event.wheelDeltaX / Math.abs(event.wheelDeltaX));
|
209
|
-
}
|
210
|
-
if (event.wheelDeltaY && isDivisible(event.wheelDeltaY, 120)) {
|
211
|
-
deltaY = -120 * (event.wheelDeltaY / Math.abs(event.wheelDeltaY));
|
212
|
-
}
|
213
|
-
}
|
214
|
-
if (!deltaX && !deltaY) {
|
215
|
-
deltaY = -event.wheelDelta || 0;
|
216
|
-
}
|
217
|
-
if (event.deltaMode === 1) {
|
218
|
-
deltaX *= 40;
|
219
|
-
deltaY *= 40;
|
220
|
-
}
|
221
|
-
var overflowing = overflowingAncestor(target);
|
222
|
-
if (!overflowing) {
|
223
|
-
if (isFrame && isChrome) {
|
224
|
-
Object.defineProperty(event, "target", {
|
225
|
-
value: window.frameElement
|
226
|
-
});
|
227
|
-
return parent.wheel(event);
|
228
|
-
}
|
229
|
-
return true;
|
230
|
-
}
|
231
|
-
if (isTouchpad(deltaY)) {
|
232
|
-
return true;
|
233
|
-
}
|
234
|
-
if (Math.abs(deltaX) > 1.2) {
|
235
|
-
deltaX *= options.stepSize / 120;
|
236
|
-
}
|
237
|
-
if (Math.abs(deltaY) > 1.2) {
|
238
|
-
deltaY *= options.stepSize / 120;
|
239
|
-
}
|
240
|
-
scrollArray(overflowing, deltaX, deltaY);
|
241
|
-
event.preventDefault();
|
242
|
-
scheduleClearCache();
|
243
|
-
}
|
244
|
-
|
245
|
-
function keydown(event) {
|
246
|
-
var target = event.target;
|
247
|
-
var modifier = event.ctrlKey || event.altKey || event.metaKey || (event.shiftKey && event.keyCode !== key.spacebar);
|
248
|
-
if (!document.body.contains(activeElement)) {
|
249
|
-
activeElement = document.activeElement;
|
250
|
-
}
|
251
|
-
var inputNodeNames = /^(textarea|select|embed|object)$/i;
|
252
|
-
var buttonTypes = /^(button|submit|radio|checkbox|file|color|image)$/i;
|
253
|
-
if (event.defaultPrevented || inputNodeNames.test(target.nodeName) || isNodeName(target, 'input') && !buttonTypes.test(target.type) || isNodeName(activeElement, 'video') || isInsideYoutubeVideo(event) || target.isContentEditable || modifier) {
|
254
|
-
return true;
|
255
|
-
}
|
256
|
-
if ((isNodeName(target, 'button') || isNodeName(target, 'input') && buttonTypes.test(target.type)) && event.keyCode === key.spacebar) {
|
257
|
-
return true;
|
258
|
-
}
|
259
|
-
if (isNodeName(target, 'input') && target.type == 'radio' && arrowKeys[event.keyCode]) {
|
260
|
-
return true;
|
261
|
-
}
|
262
|
-
var shift, x = 0,
|
263
|
-
y = 0;
|
264
|
-
var overflowing = overflowingAncestor(activeElement);
|
265
|
-
if (!overflowing) {
|
266
|
-
return (isFrame && isChrome) ? parent.keydown(event) : true;
|
267
|
-
}
|
268
|
-
var clientHeight = overflowing.clientHeight;
|
269
|
-
if (overflowing == document.body) {
|
270
|
-
clientHeight = window.innerHeight;
|
271
|
-
}
|
272
|
-
switch (event.keyCode) {
|
273
|
-
case key.up:
|
274
|
-
y = -options.arrowScroll;
|
275
|
-
break;
|
276
|
-
case key.down:
|
277
|
-
y = options.arrowScroll;
|
278
|
-
break;
|
279
|
-
case key.spacebar:
|
280
|
-
shift = event.shiftKey ? 1 : -1;
|
281
|
-
y = -shift * clientHeight * 0.9;
|
282
|
-
break;
|
283
|
-
case key.pageup:
|
284
|
-
y = -clientHeight * 0.9;
|
285
|
-
break;
|
286
|
-
case key.pagedown:
|
287
|
-
y = clientHeight * 0.9;
|
288
|
-
break;
|
289
|
-
case key.home:
|
290
|
-
if (overflowing == document.body && document.scrollingElement)
|
291
|
-
overflowing = document.scrollingElement;
|
292
|
-
y = -overflowing.scrollTop;
|
293
|
-
break;
|
294
|
-
case key.end:
|
295
|
-
var scroll = overflowing.scrollHeight - overflowing.scrollTop;
|
296
|
-
var scrollRemaining = scroll - clientHeight;
|
297
|
-
y = (scrollRemaining > 0) ? scrollRemaining + 10 : 0;
|
298
|
-
break;
|
299
|
-
case key.left:
|
300
|
-
x = -options.arrowScroll;
|
301
|
-
break;
|
302
|
-
case key.right:
|
303
|
-
x = options.arrowScroll;
|
304
|
-
break;
|
305
|
-
default:
|
306
|
-
return true;
|
307
|
-
}
|
308
|
-
scrollArray(overflowing, x, y);
|
309
|
-
event.preventDefault();
|
310
|
-
scheduleClearCache();
|
311
|
-
}
|
312
|
-
|
313
|
-
function mousedown(event) {
|
314
|
-
activeElement = event.target;
|
315
|
-
}
|
316
|
-
var uniqueID = (function () {
|
317
|
-
var i = 0;
|
318
|
-
return function (el) {
|
319
|
-
return el.uniqueID || (el.uniqueID = i++);
|
320
|
-
};
|
321
|
-
})();
|
322
|
-
var cacheX = {};
|
323
|
-
var cacheY = {};
|
324
|
-
var clearCacheTimer;
|
325
|
-
var smoothBehaviorForElement = {};
|
326
|
-
|
327
|
-
function scheduleClearCache() {
|
328
|
-
clearTimeout(clearCacheTimer);
|
329
|
-
clearCacheTimer = setInterval(function () {
|
330
|
-
cacheX = cacheY = smoothBehaviorForElement = {};
|
331
|
-
}, 1 * 1000);
|
332
|
-
}
|
333
|
-
|
334
|
-
function setCache(elems, overflowing, x) {
|
335
|
-
var cache = x ? cacheX : cacheY;
|
336
|
-
for (var i = elems.length; i--;)
|
337
|
-
cache[uniqueID(elems[i])] = overflowing;
|
338
|
-
return overflowing;
|
339
|
-
}
|
340
|
-
|
341
|
-
function getCache(el, x) {
|
342
|
-
return (x ? cacheX : cacheY)[uniqueID(el)];
|
343
|
-
}
|
344
|
-
|
345
|
-
function overflowingAncestor(el) {
|
346
|
-
var elems = [];
|
347
|
-
var body = document.body;
|
348
|
-
var rootScrollHeight = root.scrollHeight;
|
349
|
-
do {
|
350
|
-
var cached = getCache(el, false);
|
351
|
-
if (cached) {
|
352
|
-
return setCache(elems, cached);
|
353
|
-
}
|
354
|
-
elems.push(el);
|
355
|
-
if (rootScrollHeight === el.scrollHeight) {
|
356
|
-
var topOverflowsNotHidden = overflowNotHidden(root) && overflowNotHidden(body);
|
357
|
-
var isOverflowCSS = topOverflowsNotHidden || overflowAutoOrScroll(root);
|
358
|
-
if (isFrame && isContentOverflowing(root) || !isFrame && isOverflowCSS) {
|
359
|
-
return setCache(elems, getScrollRoot());
|
360
|
-
}
|
361
|
-
} else if (isContentOverflowing(el) && overflowAutoOrScroll(el)) {
|
362
|
-
return setCache(elems, el);
|
363
|
-
}
|
364
|
-
} while ((el = el.parentElement));
|
365
|
-
}
|
366
|
-
|
367
|
-
function isContentOverflowing(el) {
|
368
|
-
return (el.clientHeight + 10 < el.scrollHeight);
|
369
|
-
}
|
370
|
-
|
371
|
-
function overflowNotHidden(el) {
|
372
|
-
var overflow = getComputedStyle(el, '').getPropertyValue('overflow-y');
|
373
|
-
return (overflow !== 'hidden');
|
374
|
-
}
|
375
|
-
|
376
|
-
function overflowAutoOrScroll(el) {
|
377
|
-
var overflow = getComputedStyle(el, '').getPropertyValue('overflow-y');
|
378
|
-
return (overflow === 'scroll' || overflow === 'auto');
|
379
|
-
}
|
380
|
-
|
381
|
-
function isScrollBehaviorSmooth(el) {
|
382
|
-
var id = uniqueID(el);
|
383
|
-
if (smoothBehaviorForElement[id] == null) {
|
384
|
-
var scrollBehavior = getComputedStyle(el, '')['scroll-behavior'];
|
385
|
-
smoothBehaviorForElement[id] = ('smooth' == scrollBehavior);
|
386
|
-
}
|
387
|
-
return smoothBehaviorForElement[id];
|
388
|
-
}
|
389
|
-
|
390
|
-
function addEvent(type, fn, arg) {
|
391
|
-
window.addEventListener(type, fn, arg || false);
|
392
|
-
}
|
393
|
-
|
394
|
-
function removeEvent(type, fn, arg) {
|
395
|
-
window.removeEventListener(type, fn, arg || false);
|
396
|
-
}
|
397
|
-
|
398
|
-
function isNodeName(el, tag) {
|
399
|
-
return el && (el.nodeName || '').toLowerCase() === tag.toLowerCase();
|
400
|
-
}
|
401
|
-
|
402
|
-
function directionCheck(x, y) {
|
403
|
-
x = (x > 0) ? 1 : -1;
|
404
|
-
y = (y > 0) ? 1 : -1;
|
405
|
-
if (direction.x !== x || direction.y !== y) {
|
406
|
-
direction.x = x;
|
407
|
-
direction.y = y;
|
408
|
-
que = [];
|
409
|
-
lastScroll = 0;
|
410
|
-
}
|
411
|
-
}
|
412
|
-
if (window.localStorage && localStorage.SS_deltaBuffer) {
|
413
|
-
try {
|
414
|
-
deltaBuffer = localStorage.SS_deltaBuffer.split(',');
|
415
|
-
} catch (e) {}
|
416
|
-
}
|
417
|
-
|
418
|
-
function isTouchpad(deltaY) {
|
419
|
-
if (!deltaY) return;
|
420
|
-
if (!deltaBuffer.length) {
|
421
|
-
deltaBuffer = [deltaY, deltaY, deltaY];
|
422
|
-
}
|
423
|
-
deltaY = Math.abs(deltaY);
|
424
|
-
deltaBuffer.push(deltaY);
|
425
|
-
deltaBuffer.shift();
|
426
|
-
clearTimeout(deltaBufferTimer);
|
427
|
-
deltaBufferTimer = setTimeout(function () {
|
428
|
-
try {
|
429
|
-
localStorage.SS_deltaBuffer = deltaBuffer.join(',');
|
430
|
-
} catch (e) {}
|
431
|
-
}, 1000);
|
432
|
-
var dpiScaledWheelDelta = deltaY > 120 && allDeltasDivisableBy(deltaY);
|
433
|
-
return !allDeltasDivisableBy(120) && !allDeltasDivisableBy(100) && !dpiScaledWheelDelta;
|
434
|
-
}
|
435
|
-
|
436
|
-
function isDivisible(n, divisor) {
|
437
|
-
return (Math.floor(n / divisor) == n / divisor);
|
438
|
-
}
|
439
|
-
|
440
|
-
function allDeltasDivisableBy(divisor) {
|
441
|
-
return (isDivisible(deltaBuffer[0], divisor) && isDivisible(deltaBuffer[1], divisor) && isDivisible(deltaBuffer[2], divisor));
|
442
|
-
}
|
443
|
-
|
444
|
-
function isInsideYoutubeVideo(event) {
|
445
|
-
var elem = event.target;
|
446
|
-
var isControl = false;
|
447
|
-
if (document.URL.indexOf('www.youtube.com/watch') != -1) {
|
448
|
-
do {
|
449
|
-
isControl = (elem.classList && elem.classList.contains('html5-video-controls'));
|
450
|
-
if (isControl) break;
|
451
|
-
} while ((elem = elem.parentNode));
|
452
|
-
}
|
453
|
-
return isControl;
|
454
|
-
}
|
455
|
-
var requestFrame = (function () {
|
456
|
-
return (window.requestAnimationFrame || window.webkitRequestAnimationFrame || window.mozRequestAnimationFrame || function (callback, element, delay) {
|
457
|
-
window.setTimeout(callback, delay || (1000 / 60));
|
458
|
-
});
|
459
|
-
})();
|
460
|
-
var MutationObserver = (window.MutationObserver || window.WebKitMutationObserver || window.MozMutationObserver);
|
461
|
-
var getScrollRoot = (function () {
|
462
|
-
var SCROLL_ROOT = document.scrollingElement;
|
463
|
-
return function () {
|
464
|
-
if (!SCROLL_ROOT) {
|
465
|
-
var dummy = document.createElement('div');
|
466
|
-
dummy.style.cssText = 'height:10000px;width:1px;';
|
467
|
-
document.body.appendChild(dummy);
|
468
|
-
var bodyScrollTop = document.body.scrollTop;
|
469
|
-
var docElScrollTop = document.documentElement.scrollTop;
|
470
|
-
window.scrollBy(0, 3);
|
471
|
-
if (document.body.scrollTop != bodyScrollTop)
|
472
|
-
(SCROLL_ROOT = document.body);
|
473
|
-
else
|
474
|
-
(SCROLL_ROOT = document.documentElement);
|
475
|
-
window.scrollBy(0, -3);
|
476
|
-
document.body.removeChild(dummy);
|
477
|
-
}
|
478
|
-
return SCROLL_ROOT;
|
479
|
-
};
|
480
|
-
})();
|
481
|
-
|
482
|
-
function pulse_(x) {
|
483
|
-
var val, start, expx;
|
484
|
-
x = x * options.pulseScale;
|
485
|
-
if (x < 1) {
|
486
|
-
val = x - (1 - Math.exp(-x));
|
487
|
-
} else {
|
488
|
-
start = Math.exp(-1);
|
489
|
-
x -= 1;
|
490
|
-
expx = 1 - Math.exp(-x);
|
491
|
-
val = start + (expx * (1 - start));
|
492
|
-
}
|
493
|
-
return val * options.pulseNormalize;
|
494
|
-
}
|
495
|
-
|
496
|
-
function pulse(x) {
|
497
|
-
if (x >= 1) return 1;
|
498
|
-
if (x <= 0) return 0;
|
499
|
-
if (options.pulseNormalize == 1) {
|
500
|
-
options.pulseNormalize /= pulse_(1);
|
501
|
-
}
|
502
|
-
return pulse_(x);
|
503
|
-
}
|
504
|
-
var userAgent = window.navigator.userAgent;
|
505
|
-
var isEdge = /Edge/.test(userAgent);
|
506
|
-
var isChrome = /chrome/i.test(userAgent) && !isEdge;
|
507
|
-
var isSafari = /safari/i.test(userAgent) && !isEdge;
|
508
|
-
var isMobile = /mobile/i.test(userAgent);
|
509
|
-
var isIEWin7 = /Windows NT 6.1/i.test(userAgent) && /rv:11/i.test(userAgent);
|
510
|
-
var isOldSafari = isSafari && (/Version\/8/i.test(userAgent) || /Version\/9/i.test(userAgent));
|
511
|
-
var isEnabledForBrowser = (isChrome || isSafari || isIEWin7) && !isMobile;
|
512
|
-
var supportsPassive = false;
|
513
|
-
try {
|
514
|
-
window.addEventListener("test", null, Object.defineProperty({}, 'passive', {
|
515
|
-
get: function () {
|
516
|
-
supportsPassive = true;
|
517
|
-
}
|
518
|
-
}));
|
519
|
-
} catch (e) {}
|
520
|
-
var wheelOpt = supportsPassive ? {
|
521
|
-
passive: false
|
522
|
-
} : false;
|
523
|
-
var wheelEvent = 'onwheel' in document.createElement('div') ? 'wheel' : 'mousewheel';
|
524
|
-
if (wheelEvent && isEnabledForBrowser) {
|
525
|
-
addEvent(wheelEvent, wheel, wheelOpt);
|
526
|
-
addEvent('mousedown', mousedown);
|
527
|
-
addEvent('load', init);
|
528
|
-
}
|
529
|
-
|
530
|
-
function SmoothScroll(optionsToSet) {
|
531
|
-
for (var key in optionsToSet)
|
532
|
-
if (defaultOptions.hasOwnProperty(key))
|
533
|
-
options[key] = optionsToSet[key];
|
534
|
-
}
|
535
|
-
SmoothScroll.destroy = cleanup;
|
536
|
-
if (window.SmoothScrollOptions)
|
537
|
-
SmoothScroll(window.SmoothScrollOptions);
|
538
|
-
if (typeof define === 'function' && define.amd)
|
539
|
-
define(function () {
|
540
|
-
return SmoothScroll;
|
541
|
-
});
|
542
|
-
else if ('object' == typeof exports)
|
543
|
-
module.exports = SmoothScroll;
|
544
|
-
else
|
545
|
-
window.SmoothScroll = SmoothScroll;
|
546
|
-
})();
|
1
|
+
(function(){var P={frameRate:150,animationTime:400,stepSize:100,pulseAlgorithm:!0,pulseScale:4,pulseNormalize:1,accelerationDelta:50,accelerationMax:3,keyboardSupport:!0,arrowScroll:50,fixedBackground:!0,excluded:""},a=P,V=!1,g=!1,M={x:0,y:0},z=!1,f=document.documentElement,h,B,S,u=[],W,he=/^Mac/.test(navigator.platform),c={left:37,up:38,right:39,down:40,spacebar:32,pageup:33,pagedown:34,end:35,home:36},ve={37:1,38:1,39:1,40:1};function we(){a.keyboardSupport&&D("keydown",U)}function N(){if(!(z||!document.body)){z=!0;var e=document.body,t=document.documentElement,r=window.innerHeight,o=e.scrollHeight;if(f=document.compatMode.indexOf("CSS")>=0?t:e,h=e,we(),top!=self)g=!0;else if(Te&&o>r&&(e.offsetHeight<=r||t.offsetHeight<=r)){var i=document.createElement("div");i.style.cssText="position:absolute; z-index:-10000; top:0; left:0; right:0; height:"+f.scrollHeight+"px",document.body.appendChild(i);var n;S=function(){n||(n=setTimeout(function(){V||(i.style.height="0",i.style.height=f.scrollHeight+"px",n=null)},500))},setTimeout(S,10),D("resize",S);var d={attributes:!0,childList:!0,characterData:!1};if(B=new De(S),B.observe(e,d),f.offsetHeight<=r){var l=document.createElement("div");l.style.clear="both",e.appendChild(l)}}!a.fixedBackground&&!V&&(e.style.backgroundAttachment="scroll",t.style.backgroundAttachment="scroll")}}function me(){B&&B.disconnect(),k(j,_),k("mousedown",G),k("keydown",U),k("resize",S),k("load",N)}var m=[],A=!1,L=Date.now();function Y(e,t,r){if(ye(t,r),a.accelerationMax!=1){var o=Date.now(),i=o-L;if(i<a.accelerationDelta){var n=(1+50/i)/2;n>1&&(n=Math.min(n,a.accelerationMax),t*=n,r*=n)}L=Date.now()}if(m.push({x:t,y:r,lastX:t<0?.99:-.99,lastY:r<0?.99:-.99,start:Date.now()}),!A){var d=ae(),l=e===d||e===document.body;e.$scrollBehavior==null&&be(e)&&(e.$scrollBehavior=e.style.scrollBehavior,e.style.scrollBehavior="auto");var s=function(y){for(var I=Date.now(),p=0,O=0,T=0;T<m.length;T++){var b=m[T],ce=I-b.start,ue=ce>=a.animationTime,x=ue?1:ce/a.animationTime;a.pulseAlgorithm&&(x=ke(x));var de=b.x*x-b.lastX>>0,fe=b.y*x-b.lastY>>0;p+=de,O+=fe,b.lastX+=de,b.lastY+=fe,ue&&(m.splice(T,1),T--)}l?window.scrollBy(p,O):(p&&(e.scrollLeft+=p),O&&(e.scrollTop+=O)),!t&&!r&&(m=[]),m.length?oe(s,e,1e3/a.frameRate+1):(A=!1,e.$scrollBehavior!=null&&(e.style.scrollBehavior=e.$scrollBehavior,e.$scrollBehavior=null))};oe(s,e,0),A=!0}}function _(e){z||N();var t=e.target;if(e.defaultPrevented||e.ctrlKey||v(h,"embed")||v(t,"embed")&&/\.pdf/i.test(t.src)||v(h,"object")||t.shadowRoot)return!0;var r=-e.wheelDeltaX||e.deltaX||0,o=-e.wheelDeltaY||e.deltaY||0;he&&(e.wheelDeltaX&&E(e.wheelDeltaX,120)&&(r=-120*(e.wheelDeltaX/Math.abs(e.wheelDeltaX))),e.wheelDeltaY&&E(e.wheelDeltaY,120)&&(o=-120*(e.wheelDeltaY/Math.abs(e.wheelDeltaY)))),!r&&!o&&(o=-e.wheelDelta||0),e.deltaMode===1&&(r*=40,o*=40);var i=Z(t);if(!i)return g&&$?(Object.defineProperty(e,"target",{value:window.frameElement}),parent.wheel(e)):!0;if(ge(o))return!0;Math.abs(r)>1.2&&(r*=a.stepSize/120),Math.abs(o)>1.2&&(o*=a.stepSize/120),Y(i,r,o),e.preventDefault(),Q()}function U(e){var t=e.target,r=e.ctrlKey||e.altKey||e.metaKey||e.shiftKey&&e.keyCode!==c.spacebar;document.body.contains(h)||(h=document.activeElement);var o=/^(textarea|select|embed|object)$/i,i=/^(button|submit|radio|checkbox|file|color|image)$/i;if(e.defaultPrevented||o.test(t.nodeName)||v(t,"input")&&!i.test(t.type)||v(h,"video")||Se(e)||t.isContentEditable||r||(v(t,"button")||v(t,"input")&&i.test(t.type))&&e.keyCode===c.spacebar||v(t,"input")&&t.type=="radio"&&ve[e.keyCode])return!0;var n,d=0,l=0,s=Z(h);if(!s)return g&&$?parent.keydown(e):!0;var y=s.clientHeight;switch(s==document.body&&(y=window.innerHeight),e.keyCode){case c.up:l=-a.arrowScroll;break;case c.down:l=a.arrowScroll;break;case c.spacebar:n=e.shiftKey?1:-1,l=-n*y*.9;break;case c.pageup:l=-y*.9;break;case c.pagedown:l=y*.9;break;case c.home:s==document.body&&document.scrollingElement&&(s=document.scrollingElement),l=-s.scrollTop;break;case c.end:var I=s.scrollHeight-s.scrollTop,p=I-y;l=p>0?p+10:0;break;case c.left:d=-a.arrowScroll;break;case c.right:d=a.arrowScroll;break;default:return!0}Y(s,d,l),e.preventDefault(),Q()}function G(e){h=e.target}var X=function(){var e=0;return function(t){return t.uniqueID||(t.uniqueID=e++)}}(),q={},K={},J,H={};function Q(){clearTimeout(J),J=setInterval(function(){q=K=H={}},1*1e3)}function F(e,t,r){for(var o=r?q:K,i=e.length;i--;)o[X(e[i])]=t;return t}function pe(e,t){return(t?q:K)[X(e)]}function Z(e){var t=[],r=document.body,o=f.scrollHeight;do{var i=pe(e,!1);if(i)return F(t,i);if(t.push(e),o===e.scrollHeight){var n=te(f)&&te(r),d=n||re(f);if(g&&ee(f)||!g&&d)return F(t,ae())}else if(ee(e)&&re(e))return F(t,e)}while(e=e.parentElement)}function ee(e){return e.clientHeight+10<e.scrollHeight}function te(e){var t=getComputedStyle(e,"").getPropertyValue("overflow-y");return t!=="hidden"}function re(e){var t=getComputedStyle(e,"").getPropertyValue("overflow-y");return t==="scroll"||t==="auto"}function be(e){var t=X(e);if(H[t]==null){var r=getComputedStyle(e,"")["scroll-behavior"];H[t]=r=="smooth"}return H[t]}function D(e,t,r){window.addEventListener(e,t,r||!1)}function k(e,t,r){window.removeEventListener(e,t,r||!1)}function v(e,t){return e&&(e.nodeName||"").toLowerCase()===t.toLowerCase()}function ye(e,t){e=e>0?1:-1,t=t>0?1:-1,(M.x!==e||M.y!==t)&&(M.x=e,M.y=t,m=[],L=0)}if(window.localStorage&&localStorage.SS_deltaBuffer)try{u=localStorage.SS_deltaBuffer.split(",")}catch{}function ge(e){if(e){u.length||(u=[e,e,e]),e=Math.abs(e),u.push(e),u.shift(),clearTimeout(W),W=setTimeout(function(){try{localStorage.SS_deltaBuffer=u.join(",")}catch{}},1e3);var t=e>120&&R(e);return!R(120)&&!R(100)&&!t}}function E(e,t){return Math.floor(e/t)==e/t}function R(e){return E(u[0],e)&&E(u[1],e)&&E(u[2],e)}function Se(e){var t=e.target,r=!1;if(document.URL.indexOf("www.youtube.com/watch")!=-1)do if(r=t.classList&&t.classList.contains("html5-video-controls"),r)break;while(t=t.parentNode);return r}var oe=function(){return window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||function(e,t,r){window.setTimeout(e,r||1e3/60)}}(),De=window.MutationObserver||window.WebKitMutationObserver||window.MozMutationObserver,ae=function(){var e=document.scrollingElement;return function(){if(!e){var t=document.createElement("div");t.style.cssText="height:10000px;width:1px;",document.body.appendChild(t);var r=document.body.scrollTop,o=document.documentElement.scrollTop;window.scrollBy(0,3),document.body.scrollTop!=r?e=document.body:e=document.documentElement,window.scrollBy(0,-3),document.body.removeChild(t)}return e}}();function ie(e){var t,r,o;return e=e*a.pulseScale,e<1?t=e-(1-Math.exp(-e)):(r=Math.exp(-1),e-=1,o=1-Math.exp(-e),t=r+o*(1-r)),t*a.pulseNormalize}function ke(e){return e>=1?1:e<=0?0:(a.pulseNormalize==1&&(a.pulseNormalize/=ie(1)),ie(e))}var w=window.navigator.userAgent,ne=/Edge/.test(w),$=/chrome/i.test(w)&&!ne,le=/safari/i.test(w)&&!ne,Ee=/mobile/i.test(w),Ce=/Windows NT 6.1/i.test(w)&&/rv:11/i.test(w),Te=le&&(/Version\/8/i.test(w)||/Version\/9/i.test(w)),Me=($||le||Ce)&&!Ee,se=!1;try{window.addEventListener("test",null,Object.defineProperty({},"passive",{get:function(){se=!0}}))}catch{}var Be=se?{passive:!1}:!1,j="onwheel"in document.createElement("div")?"wheel":"mousewheel";j&&Me&&(D(j,_,Be),D("mousedown",G),D("load",N));function C(e){for(var t in e)P.hasOwnProperty(t)&&(a[t]=e[t])}C.destroy=me,window.SmoothScrollOptions&&C(window.SmoothScrollOptions),typeof define=="function"&&define.amd?define(function(){return C}):typeof exports=="object"?module.exports=C:window.SmoothScroll=C})();
|
package/js/sw-toolbox.js
CHANGED
@@ -1,16 +1 @@
|
|
1
|
-
/*
|
2
|
-
Copyright 2016 Google Inc. All Rights Reserved.
|
3
|
-
|
4
|
-
Licensed under the Apache License, Version 2.0 (the "License");
|
5
|
-
you may not use this file except in compliance with the License.
|
6
|
-
You may obtain a copy of the License at
|
7
|
-
|
8
|
-
http://www.apache.org/licenses/LICENSE-2.0
|
9
|
-
|
10
|
-
Unless required by applicable law or agreed to in writing, software
|
11
|
-
distributed under the License is distributed on an "AS IS" BASIS,
|
12
|
-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13
|
-
See the License for the specific language governing permissions and
|
14
|
-
limitations under the License.
|
15
|
-
*/!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var t;t="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,t.toolbox=e()}}(function(){return function e(t,n,r){function o(c,s){if(!n[c]){if(!t[c]){var a="function"==typeof require&&require;if(!s&&a)return a(c,!0);if(i)return i(c,!0);var u=new Error("Cannot find module '"+c+"'");throw u.code="MODULE_NOT_FOUND",u}var f=n[c]={exports:{}};t[c][0].call(f.exports,function(e){var n=t[c][1][e];return o(n?n:e)},f,f.exports,e,t,n,r)}return n[c].exports}for(var i="function"==typeof require&&require,c=0;c<r.length;c++)o(r[c]);return o}({1:[function(e,t,n){"use strict";function r(e,t){t=t||{};var n=t.debug||m.debug;n&&console.log("[sw-toolbox] "+e)}function o(e){var t;return e&&e.cache&&(t=e.cache.name),t=t||m.cache.name,caches.open(t)}function i(e,t){t=t||{};var n=t.successResponses||m.successResponses;return fetch(e.clone()).then(function(r){return"GET"===e.method&&n.test(r.status)&&o(t).then(function(n){n.put(e,r).then(function(){var r=t.cache||m.cache;(r.maxEntries||r.maxAgeSeconds)&&r.name&&c(e,n,r)})}),r.clone()})}function c(e,t,n){var r=s.bind(null,e,t,n);d=d?d.then(r):r()}function s(e,t,n){var o=e.url,i=n.maxAgeSeconds,c=n.maxEntries,s=n.name,a=Date.now();return r("Updating LRU order for "+o+". Max entries is "+c+", max age is "+i),g.getDb(s).then(function(e){return g.setTimestampForUrl(e,o,a)}).then(function(e){return g.expireEntries(e,c,i,a)}).then(function(e){r("Successfully updated IDB.");var n=e.map(function(e){return t.delete(e)});return Promise.all(n).then(function(){r("Done with cache cleanup.")})}).catch(function(e){r(e)})}function a(e,t,n){return r("Renaming cache: ["+e+"] to ["+t+"]",n),caches.delete(t).then(function(){return Promise.all([caches.open(e),caches.open(t)]).then(function(t){var n=t[0],r=t[1];return n.keys().then(function(e){return Promise.all(e.map(function(e){return n.match(e).then(function(t){return r.put(e,t)})}))}).then(function(){return caches.delete(e)})})})}function u(e,t){return o(t).then(function(t){return t.add(e)})}function f(e,t){return o(t).then(function(t){return t.delete(e)})}function h(e){e instanceof Promise||p(e),m.preCacheItems=m.preCacheItems.concat(e)}function p(e){var t=Array.isArray(e);if(t&&e.forEach(function(e){"string"==typeof e||e instanceof Request||(t=!1)}),!t)throw new TypeError("The precache method expects either an array of strings and/or Requests or a Promise that resolves to an array of strings and/or Requests.");return e}function l(e,t,n){if(!e)return!1;if(t){var r=e.headers.get("date");if(r){var o=new Date(r);if(o.getTime()+1e3*t<n)return!1}}return!0}var d,m=e("./options"),g=e("./idb-cache-expiration");t.exports={debug:r,fetchAndCache:i,openCache:o,renameCache:a,cache:u,uncache:f,precache:h,validatePrecacheInput:p,isResponseFresh:l}},{"./idb-cache-expiration":2,"./options":4}],2:[function(e,t,n){"use strict";function r(e){return new Promise(function(t,n){var r=indexedDB.open(u+e,f);r.onupgradeneeded=function(){var e=r.result.createObjectStore(h,{keyPath:p});e.createIndex(l,l,{unique:!1})},r.onsuccess=function(){t(r.result)},r.onerror=function(){n(r.error)}})}function o(e){return e in d||(d[e]=r(e)),d[e]}function i(e,t,n){return new Promise(function(r,o){var i=e.transaction(h,"readwrite"),c=i.objectStore(h);c.put({url:t,timestamp:n}),i.oncomplete=function(){r(e)},i.onabort=function(){o(i.error)}})}function c(e,t,n){return t?new Promise(function(r,o){var i=1e3*t,c=[],s=e.transaction(h,"readwrite"),a=s.objectStore(h),u=a.index(l);u.openCursor().onsuccess=function(e){var t=e.target.result;if(t&&n-i>t.value[l]){var r=t.value[p];c.push(r),a.delete(r),t.continue()}},s.oncomplete=function(){r(c)},s.onabort=o}):Promise.resolve([])}function s(e,t){return t?new Promise(function(n,r){var o=[],i=e.transaction(h,"readwrite"),c=i.objectStore(h),s=c.index(l),a=s.count();s.count().onsuccess=function(){var e=a.result;e>t&&(s.openCursor().onsuccess=function(n){var r=n.target.result;if(r){var i=r.value[p];o.push(i),c.delete(i),e-o.length>t&&r.continue()}})},i.oncomplete=function(){n(o)},i.onabort=r}):Promise.resolve([])}function a(e,t,n,r){return c(e,n,r).then(function(n){return s(e,t).then(function(e){return n.concat(e)})})}var u="sw-toolbox-",f=1,h="store",p="url",l="timestamp",d={};t.exports={getDb:o,setTimestampForUrl:i,expireEntries:a}},{}],3:[function(e,t,n){"use strict";function r(e){var t=a.match(e.request);t?e.respondWith(t(e.request)):a.default&&"GET"===e.request.method&&0===e.request.url.indexOf("http")&&e.respondWith(a.default(e.request))}function o(e){s.debug("activate event fired");var t=u.cache.name+"$$$inactive$$$";e.waitUntil(s.renameCache(t,u.cache.name))}function i(e){return e.reduce(function(e,t){return e.concat(t)},[])}function c(e){var t=u.cache.name+"$$$inactive$$$";s.debug("install event fired"),s.debug("creating cache ["+t+"]"),e.waitUntil(s.openCache({cache:{name:t}}).then(function(e){return Promise.all(u.preCacheItems).then(i).then(s.validatePrecacheInput).then(function(t){return s.debug("preCache list: "+(t.join(", ")||"(none)")),e.addAll(t)})}))}e("serviceworker-cache-polyfill");var s=e("./helpers"),a=e("./router"),u=e("./options");t.exports={fetchListener:r,activateListener:o,installListener:c}},{"./helpers":1,"./options":4,"./router":6,"serviceworker-cache-polyfill":16}],4:[function(e,t,n){"use strict";var r;r=self.registration?self.registration.scope:self.scope||new URL("./",self.location).href,t.exports={cache:{name:"$$$toolbox-cache$$$"+r+"$$$",maxAgeSeconds:null,maxEntries:null},debug:!1,networkTimeoutSeconds:null,preCacheItems:[],successResponses:/^0|([123]\d\d)|(40[14567])|410$/}},{}],5:[function(e,t,n){"use strict";var r=new URL("./",self.location),o=r.pathname,i=e("path-to-regexp"),c=function(e,t,n,r){t instanceof RegExp?this.fullUrlRegExp=t:(0!==t.indexOf("/")&&(t=o+t),this.keys=[],this.regexp=i(t,this.keys)),this.method=e,this.options=r,this.handler=n};c.prototype.makeHandler=function(e){var t;if(this.regexp){var n=this.regexp.exec(e);t={},this.keys.forEach(function(e,r){t[e.name]=n[r+1]})}return function(e){return this.handler(e,t,this.options)}.bind(this)},t.exports=c},{"path-to-regexp":15}],6:[function(e,t,n){"use strict";function r(e){return e.replace(/[-\/\\^$*+?.()|[\]{}]/g,"\\$&")}var o=e("./route"),i=e("./helpers"),c=function(e,t){for(var n=e.entries(),r=n.next(),o=[];!r.done;){var i=new RegExp(r.value[0]);i.test(t)&&o.push(r.value[1]),r=n.next()}return o},s=function(){this.routes=new Map,this.routes.set(RegExp,new Map),this.default=null};["get","post","put","delete","head","any"].forEach(function(e){s.prototype[e]=function(t,n,r){return this.add(e,t,n,r)}}),s.prototype.add=function(e,t,n,c){c=c||{};var s;t instanceof RegExp?s=RegExp:(s=c.origin||self.location.origin,s=s instanceof RegExp?s.source:r(s)),e=e.toLowerCase();var a=new o(e,t,n,c);this.routes.has(s)||this.routes.set(s,new Map);var u=this.routes.get(s);u.has(e)||u.set(e,new Map);var f=u.get(e),h=a.regexp||a.fullUrlRegExp;f.has(h.source)&&i.debug('"'+t+'" resolves to same regex as existing route.'),f.set(h.source,a)},s.prototype.matchMethod=function(e,t){var n=new URL(t),r=n.origin,o=n.pathname;return this._match(e,c(this.routes,r),o)||this._match(e,[this.routes.get(RegExp)],t)},s.prototype._match=function(e,t,n){if(0===t.length)return null;for(var r=0;r<t.length;r++){var o=t[r],i=o&&o.get(e.toLowerCase());if(i){var s=c(i,n);if(s.length>0)return s[0].makeHandler(n)}}return null},s.prototype.match=function(e){return this.matchMethod(e.method,e.url)||this.matchMethod("any",e.url)},t.exports=new s},{"./helpers":1,"./route":5}],7:[function(e,t,n){"use strict";function r(e,t,n){return n=n||{},i.debug("Strategy: cache first ["+e.url+"]",n),i.openCache(n).then(function(t){return t.match(e).then(function(t){var r=n.cache||o.cache,c=Date.now();return i.isResponseFresh(t,r.maxAgeSeconds,c)?t:i.fetchAndCache(e,n)})})}var o=e("../options"),i=e("../helpers");t.exports=r},{"../helpers":1,"../options":4}],8:[function(e,t,n){"use strict";function r(e,t,n){return n=n||{},i.debug("Strategy: cache only ["+e.url+"]",n),i.openCache(n).then(function(t){return t.match(e).then(function(e){var t=n.cache||o.cache,r=Date.now();if(i.isResponseFresh(e,t.maxAgeSeconds,r))return e})})}var o=e("../options"),i=e("../helpers");t.exports=r},{"../helpers":1,"../options":4}],9:[function(e,t,n){"use strict";function r(e,t,n){return o.debug("Strategy: fastest ["+e.url+"]",n),new Promise(function(r,c){var s=!1,a=[],u=function(e){a.push(e.toString()),s?c(new Error('Both cache and network failed: "'+a.join('", "')+'"')):s=!0},f=function(e){e instanceof Response?r(e):u("No result returned")};o.fetchAndCache(e.clone(),n).then(f,u),i(e,t,n).then(f,u)})}var o=e("../helpers"),i=e("./cacheOnly");t.exports=r},{"../helpers":1,"./cacheOnly":8}],10:[function(e,t,n){t.exports={networkOnly:e("./networkOnly"),networkFirst:e("./networkFirst"),cacheOnly:e("./cacheOnly"),cacheFirst:e("./cacheFirst"),fastest:e("./fastest")}},{"./cacheFirst":7,"./cacheOnly":8,"./fastest":9,"./networkFirst":11,"./networkOnly":12}],11:[function(e,t,n){"use strict";function r(e,t,n){n=n||{};var r=n.successResponses||o.successResponses,c=n.networkTimeoutSeconds||o.networkTimeoutSeconds;return i.debug("Strategy: network first ["+e.url+"]",n),i.openCache(n).then(function(t){var s,a,u=[];if(c){var f=new Promise(function(r){s=setTimeout(function(){t.match(e).then(function(e){var t=n.cache||o.cache,c=Date.now(),s=t.maxAgeSeconds;i.isResponseFresh(e,s,c)&&r(e)})},1e3*c)});u.push(f)}var h=i.fetchAndCache(e,n).then(function(e){if(s&&clearTimeout(s),r.test(e.status))return e;throw i.debug("Response was an HTTP error: "+e.statusText,n),a=e,new Error("Bad response")}).catch(function(r){return i.debug("Network or response error, fallback to cache ["+e.url+"]",n),t.match(e).then(function(e){if(e)return e;if(a)return a;throw r})});return u.push(h),Promise.race(u)})}var o=e("../options"),i=e("../helpers");t.exports=r},{"../helpers":1,"../options":4}],12:[function(e,t,n){"use strict";function r(e,t,n){return o.debug("Strategy: network only ["+e.url+"]",n),fetch(e)}var o=e("../helpers");t.exports=r},{"../helpers":1}],13:[function(e,t,n){"use strict";var r=e("./options"),o=e("./router"),i=e("./helpers"),c=e("./strategies"),s=e("./listeners");i.debug("Service Worker Toolbox is loading"),self.addEventListener("install",s.installListener),self.addEventListener("activate",s.activateListener),self.addEventListener("fetch",s.fetchListener),t.exports={networkOnly:c.networkOnly,networkFirst:c.networkFirst,cacheOnly:c.cacheOnly,cacheFirst:c.cacheFirst,fastest:c.fastest,router:o,options:r,cache:i.cache,uncache:i.uncache,precache:i.precache}},{"./helpers":1,"./listeners":3,"./options":4,"./router":6,"./strategies":10}],14:[function(e,t,n){t.exports=Array.isArray||function(e){return"[object Array]"==Object.prototype.toString.call(e)}},{}],15:[function(e,t,n){function r(e,t){for(var n,r=[],o=0,i=0,c="",s=t&&t.delimiter||"/";null!=(n=x.exec(e));){var f=n[0],h=n[1],p=n.index;if(c+=e.slice(i,p),i=p+f.length,h)c+=h[1];else{var l=e[i],d=n[2],m=n[3],g=n[4],v=n[5],w=n[6],y=n[7];c&&(r.push(c),c="");var b=null!=d&&null!=l&&l!==d,E="+"===w||"*"===w,R="?"===w||"*"===w,k=n[2]||s,$=g||v;r.push({name:m||o++,prefix:d||"",delimiter:k,optional:R,repeat:E,partial:b,asterisk:!!y,pattern:$?u($):y?".*":"[^"+a(k)+"]+?"})}}return i<e.length&&(c+=e.substr(i)),c&&r.push(c),r}function o(e,t){return s(r(e,t))}function i(e){return encodeURI(e).replace(/[\/?#]/g,function(e){return"%"+e.charCodeAt(0).toString(16).toUpperCase()})}function c(e){return encodeURI(e).replace(/[?#]/g,function(e){return"%"+e.charCodeAt(0).toString(16).toUpperCase()})}function s(e){for(var t=new Array(e.length),n=0;n<e.length;n++)"object"==typeof e[n]&&(t[n]=new RegExp("^(?:"+e[n].pattern+")$"));return function(n,r){for(var o="",s=n||{},a=r||{},u=a.pretty?i:encodeURIComponent,f=0;f<e.length;f++){var h=e[f];if("string"!=typeof h){var p,l=s[h.name];if(null==l){if(h.optional){h.partial&&(o+=h.prefix);continue}throw new TypeError('Expected "'+h.name+'" to be defined')}if(v(l)){if(!h.repeat)throw new TypeError('Expected "'+h.name+'" to not repeat, but received `'+JSON.stringify(l)+"`");if(0===l.length){if(h.optional)continue;throw new TypeError('Expected "'+h.name+'" to not be empty')}for(var d=0;d<l.length;d++){if(p=u(l[d]),!t[f].test(p))throw new TypeError('Expected all "'+h.name+'" to match "'+h.pattern+'", but received `'+JSON.stringify(p)+"`");o+=(0===d?h.prefix:h.delimiter)+p}}else{if(p=h.asterisk?c(l):u(l),!t[f].test(p))throw new TypeError('Expected "'+h.name+'" to match "'+h.pattern+'", but received "'+p+'"');o+=h.prefix+p}}else o+=h}return o}}function a(e){return e.replace(/([.+*?=^!:${}()[\]|\/\\])/g,"\\$1")}function u(e){return e.replace(/([=!:$\/()])/g,"\\$1")}function f(e,t){return e.keys=t,e}function h(e){return e.sensitive?"":"i"}function p(e,t){var n=e.source.match(/\((?!\?)/g);if(n)for(var r=0;r<n.length;r++)t.push({name:r,prefix:null,delimiter:null,optional:!1,repeat:!1,partial:!1,asterisk:!1,pattern:null});return f(e,t)}function l(e,t,n){for(var r=[],o=0;o<e.length;o++)r.push(g(e[o],t,n).source);var i=new RegExp("(?:"+r.join("|")+")",h(n));return f(i,t)}function d(e,t,n){return m(r(e,n),t,n)}function m(e,t,n){v(t)||(n=t||n,t=[]),n=n||{};for(var r=n.strict,o=n.end!==!1,i="",c=0;c<e.length;c++){var s=e[c];if("string"==typeof s)i+=a(s);else{var u=a(s.prefix),p="(?:"+s.pattern+")";t.push(s),s.repeat&&(p+="(?:"+u+p+")*"),p=s.optional?s.partial?u+"("+p+")?":"(?:"+u+"("+p+"))?":u+"("+p+")",i+=p}}var l=a(n.delimiter||"/"),d=i.slice(-l.length)===l;return r||(i=(d?i.slice(0,-l.length):i)+"(?:"+l+"(?=$))?"),i+=o?"$":r&&d?"":"(?="+l+"|$)",f(new RegExp("^"+i,h(n)),t)}function g(e,t,n){return v(t)||(n=t||n,t=[]),n=n||{},e instanceof RegExp?p(e,t):v(e)?l(e,t,n):d(e,t,n)}var v=e("isarray");t.exports=g,t.exports.parse=r,t.exports.compile=o,t.exports.tokensToFunction=s,t.exports.tokensToRegExp=m;var x=new RegExp(["(\\\\.)","([\\/.])?(?:(?:\\:(\\w+)(?:\\(((?:\\\\.|[^\\\\()])+)\\))?|\\(((?:\\\\.|[^\\\\()])+)\\))([+*?])?|(\\*))"].join("|"),"g")},{isarray:14}],16:[function(e,t,n){!function(){var e=Cache.prototype.addAll,t=navigator.userAgent.match(/(Firefox|Chrome)\/(\d+\.)/);if(t)var n=t[1],r=parseInt(t[2]);e&&(!t||"Firefox"===n&&r>=46||"Chrome"===n&&r>=50)||(Cache.prototype.addAll=function(e){function t(e){this.name="NetworkError",this.code=19,this.message=e}var n=this;return t.prototype=Object.create(Error.prototype),Promise.resolve().then(function(){if(arguments.length<1)throw new TypeError;return e=e.map(function(e){return e instanceof Request?e:String(e)}),Promise.all(e.map(function(e){"string"==typeof e&&(e=new Request(e));var n=new URL(e.url).protocol;if("http:"!==n&&"https:"!==n)throw new t("Invalid scheme");return fetch(e.clone())}))}).then(function(r){if(r.some(function(e){return!e.ok}))throw new t("Incorrect response status");return Promise.all(r.map(function(t,r){return n.put(e[r],t)}))}).then(function(){})},Cache.prototype.add=function(e){return this.addAll([e])})}()},{}]},{},[13])(13)});
|
16
|
-
//# sourceMappingURL=sw-toolbox.js.map
|
1
|
+
(function(u){if(typeof exports=="object"&&typeof module<"u")module.exports=u();else if(typeof define=="function"&&define.amd)define([],u);else{var l;l=typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:this,l.toolbox=u()}})(function(){return function u(l,$,m){function g(c,e){if(!$[c]){if(!l[c]){var d=typeof require=="function"&&require;if(!e&&d)return d(c,!0);if(p)return p(c,!0);var n=new Error("Cannot find module '"+c+"'");throw n.code="MODULE_NOT_FOUND",n}var o=$[c]={exports:{}};l[c][0].call(o.exports,function(f){var y=l[c][1][f];return g(y||f)},o,o.exports,u,l,$,m)}return $[c].exports}for(var p=typeof require=="function"&&require,h=0;h<m.length;h++)g(m[h]);return g}({1:[function(u,l,$){"use strict";function m(s,a){a=a||{};var t=a.debug||v.debug;t&&console.log("[sw-toolbox] "+s)}function g(s){var a;return s&&s.cache&&(a=s.cache.name),a=a||v.cache.name,caches.open(a)}function p(s,a){a=a||{};var t=a.successResponses||v.successResponses;return fetch(s.clone()).then(function(r){return s.method==="GET"&&t.test(r.status)&&g(a).then(function(i){i.put(s,r).then(function(){var x=a.cache||v.cache;(x.maxEntries||x.maxAgeSeconds)&&x.name&&h(s,i,x)})}),r.clone()})}function h(s,a,t){var r=c.bind(null,s,a,t);k=k?k.then(r):r()}function c(s,a,t){var r=s.url,i=t.maxAgeSeconds,x=t.maxEntries,S=t.name,w=Date.now();return m("Updating LRU order for "+r+". Max entries is "+x+", max age is "+i),R.getDb(S).then(function(b){return R.setTimestampForUrl(b,r,w)}).then(function(b){return R.expireEntries(b,x,i,w)}).then(function(b){m("Successfully updated IDB.");var C=b.map(function(T){return a.delete(T)});return Promise.all(C).then(function(){m("Done with cache cleanup.")})}).catch(function(b){m(b)})}function e(s,a,t){return m("Renaming cache: ["+s+"] to ["+a+"]",t),caches.delete(a).then(function(){return Promise.all([caches.open(s),caches.open(a)]).then(function(r){var i=r[0],x=r[1];return i.keys().then(function(S){return Promise.all(S.map(function(w){return i.match(w).then(function(b){return x.put(w,b)})}))}).then(function(){return caches.delete(s)})})})}function d(s,a){return g(a).then(function(t){return t.add(s)})}function n(s,a){return g(a).then(function(t){return t.delete(s)})}function o(s){s instanceof Promise||f(s),v.preCacheItems=v.preCacheItems.concat(s)}function f(s){var a=Array.isArray(s);if(a&&s.forEach(function(t){typeof t=="string"||t instanceof Request||(a=!1)}),!a)throw new TypeError("The precache method expects either an array of strings and/or Requests or a Promise that resolves to an array of strings and/or Requests.");return s}function y(s,a,t){if(!s)return!1;if(a){var r=s.headers.get("date");if(r){var i=new Date(r);if(i.getTime()+1e3*a<t)return!1}}return!0}var k,v=u("./options"),R=u("./idb-cache-expiration");l.exports={debug:m,fetchAndCache:p,openCache:g,renameCache:e,cache:d,uncache:n,precache:o,validatePrecacheInput:f,isResponseFresh:y}},{"./idb-cache-expiration":2,"./options":4}],2:[function(u,l,$){"use strict";function m(v){return new Promise(function(R,s){var a=indexedDB.open(d+v,n);a.onupgradeneeded=function(){var t=a.result.createObjectStore(o,{keyPath:f});t.createIndex(y,y,{unique:!1})},a.onsuccess=function(){R(a.result)},a.onerror=function(){s(a.error)}})}function g(v){return v in k||(k[v]=m(v)),k[v]}function p(v,R,s){return new Promise(function(a,t){var r=v.transaction(o,"readwrite"),i=r.objectStore(o);i.put({url:R,timestamp:s}),r.oncomplete=function(){a(v)},r.onabort=function(){t(r.error)}})}function h(v,R,s){return R?new Promise(function(a,t){var r=1e3*R,i=[],x=v.transaction(o,"readwrite"),S=x.objectStore(o),w=S.index(y);w.openCursor().onsuccess=function(b){var C=b.target.result;if(C&&s-r>C.value[y]){var T=C.value[f];i.push(T),S.delete(T),C.continue()}},x.oncomplete=function(){a(i)},x.onabort=t}):Promise.resolve([])}function c(v,R){return R?new Promise(function(s,a){var t=[],r=v.transaction(o,"readwrite"),i=r.objectStore(o),x=i.index(y),S=x.count();x.count().onsuccess=function(){var w=S.result;w>R&&(x.openCursor().onsuccess=function(b){var C=b.target.result;if(C){var T=C.value[f];t.push(T),i.delete(T),w-t.length>R&&C.continue()}})},r.oncomplete=function(){s(t)},r.onabort=a}):Promise.resolve([])}function e(v,R,s,a){return h(v,s,a).then(function(t){return c(v,R).then(function(r){return t.concat(r)})})}var d="sw-toolbox-",n=1,o="store",f="url",y="timestamp",k={};l.exports={getDb:g,setTimestampForUrl:p,expireEntries:e}},{}],3:[function(u,l,$){"use strict";function m(n){var o=e.match(n.request);o?n.respondWith(o(n.request)):e.default&&n.request.method==="GET"&&n.request.url.indexOf("http")===0&&n.respondWith(e.default(n.request))}function g(n){c.debug("activate event fired");var o=d.cache.name+"$$$inactive$$$";n.waitUntil(c.renameCache(o,d.cache.name))}function p(n){return n.reduce(function(o,f){return o.concat(f)},[])}function h(n){var o=d.cache.name+"$$$inactive$$$";c.debug("install event fired"),c.debug("creating cache ["+o+"]"),n.waitUntil(c.openCache({cache:{name:o}}).then(function(f){return Promise.all(d.preCacheItems).then(p).then(c.validatePrecacheInput).then(function(y){return c.debug("preCache list: "+(y.join(", ")||"(none)")),f.addAll(y)})}))}u("serviceworker-cache-polyfill");var c=u("./helpers"),e=u("./router"),d=u("./options");l.exports={fetchListener:m,activateListener:g,installListener:h}},{"./helpers":1,"./options":4,"./router":6,"serviceworker-cache-polyfill":16}],4:[function(u,l,$){"use strict";var m;m=self.registration?self.registration.scope:self.scope||new URL("./",self.location).href,l.exports={cache:{name:"$$$toolbox-cache$$$"+m+"$$$",maxAgeSeconds:null,maxEntries:null},debug:!1,networkTimeoutSeconds:null,preCacheItems:[],successResponses:/^0|([123]\d\d)|(40[14567])|410$/}},{}],5:[function(u,l,$){"use strict";var m=new URL("./",self.location),g=m.pathname,p=u("path-to-regexp"),h=function(c,e,d,n){e instanceof RegExp?this.fullUrlRegExp=e:(e.indexOf("/")!==0&&(e=g+e),this.keys=[],this.regexp=p(e,this.keys)),this.method=c,this.options=n,this.handler=d};h.prototype.makeHandler=function(c){var e;if(this.regexp){var d=this.regexp.exec(c);e={},this.keys.forEach(function(n,o){e[n.name]=d[o+1]})}return function(n){return this.handler(n,e,this.options)}.bind(this)},l.exports=h},{"path-to-regexp":15}],6:[function(u,l,$){"use strict";function m(e){return e.replace(/[-\/\\^$*+?.()|[\]{}]/g,"\\$&")}var g=u("./route"),p=u("./helpers"),h=function(e,d){for(var n=e.entries(),o=n.next(),f=[];!o.done;){var y=new RegExp(o.value[0]);y.test(d)&&f.push(o.value[1]),o=n.next()}return f},c=function(){this.routes=new Map,this.routes.set(RegExp,new Map),this.default=null};["get","post","put","delete","head","any"].forEach(function(e){c.prototype[e]=function(d,n,o){return this.add(e,d,n,o)}}),c.prototype.add=function(e,d,n,o){o=o||{};var f;d instanceof RegExp?f=RegExp:(f=o.origin||self.location.origin,f=f instanceof RegExp?f.source:m(f)),e=e.toLowerCase();var y=new g(e,d,n,o);this.routes.has(f)||this.routes.set(f,new Map);var k=this.routes.get(f);k.has(e)||k.set(e,new Map);var v=k.get(e),R=y.regexp||y.fullUrlRegExp;v.has(R.source)&&p.debug('"'+d+'" resolves to same regex as existing route.'),v.set(R.source,y)},c.prototype.matchMethod=function(e,d){var n=new URL(d),o=n.origin,f=n.pathname;return this._match(e,h(this.routes,o),f)||this._match(e,[this.routes.get(RegExp)],d)},c.prototype._match=function(e,d,n){if(d.length===0)return null;for(var o=0;o<d.length;o++){var f=d[o],y=f&&f.get(e.toLowerCase());if(y){var k=h(y,n);if(k.length>0)return k[0].makeHandler(n)}}return null},c.prototype.match=function(e){return this.matchMethod(e.method,e.url)||this.matchMethod("any",e.url)},l.exports=new c},{"./helpers":1,"./route":5}],7:[function(u,l,$){"use strict";function m(h,c,e){return e=e||{},p.debug("Strategy: cache first ["+h.url+"]",e),p.openCache(e).then(function(d){return d.match(h).then(function(n){var o=e.cache||g.cache,f=Date.now();return p.isResponseFresh(n,o.maxAgeSeconds,f)?n:p.fetchAndCache(h,e)})})}var g=u("../options"),p=u("../helpers");l.exports=m},{"../helpers":1,"../options":4}],8:[function(u,l,$){"use strict";function m(h,c,e){return e=e||{},p.debug("Strategy: cache only ["+h.url+"]",e),p.openCache(e).then(function(d){return d.match(h).then(function(n){var o=e.cache||g.cache,f=Date.now();if(p.isResponseFresh(n,o.maxAgeSeconds,f))return n})})}var g=u("../options"),p=u("../helpers");l.exports=m},{"../helpers":1,"../options":4}],9:[function(u,l,$){"use strict";function m(h,c,e){return g.debug("Strategy: fastest ["+h.url+"]",e),new Promise(function(d,n){var o=!1,f=[],y=function(v){f.push(v.toString()),o?n(new Error('Both cache and network failed: "'+f.join('", "')+'"')):o=!0},k=function(v){v instanceof Response?d(v):y("No result returned")};g.fetchAndCache(h.clone(),e).then(k,y),p(h,c,e).then(k,y)})}var g=u("../helpers"),p=u("./cacheOnly");l.exports=m},{"../helpers":1,"./cacheOnly":8}],10:[function(u,l,$){l.exports={networkOnly:u("./networkOnly"),networkFirst:u("./networkFirst"),cacheOnly:u("./cacheOnly"),cacheFirst:u("./cacheFirst"),fastest:u("./fastest")}},{"./cacheFirst":7,"./cacheOnly":8,"./fastest":9,"./networkFirst":11,"./networkOnly":12}],11:[function(u,l,$){"use strict";function m(h,c,e){e=e||{};var d=e.successResponses||g.successResponses,n=e.networkTimeoutSeconds||g.networkTimeoutSeconds;return p.debug("Strategy: network first ["+h.url+"]",e),p.openCache(e).then(function(o){var f,y,k=[];if(n){var v=new Promise(function(s){f=setTimeout(function(){o.match(h).then(function(a){var t=e.cache||g.cache,r=Date.now(),i=t.maxAgeSeconds;p.isResponseFresh(a,i,r)&&s(a)})},1e3*n)});k.push(v)}var R=p.fetchAndCache(h,e).then(function(s){if(f&&clearTimeout(f),d.test(s.status))return s;throw p.debug("Response was an HTTP error: "+s.statusText,e),y=s,new Error("Bad response")}).catch(function(s){return p.debug("Network or response error, fallback to cache ["+h.url+"]",e),o.match(h).then(function(a){if(a)return a;if(y)return y;throw s})});return k.push(R),Promise.race(k)})}var g=u("../options"),p=u("../helpers");l.exports=m},{"../helpers":1,"../options":4}],12:[function(u,l,$){"use strict";function m(p,h,c){return g.debug("Strategy: network only ["+p.url+"]",c),fetch(p)}var g=u("../helpers");l.exports=m},{"../helpers":1}],13:[function(u,l,$){"use strict";var m=u("./options"),g=u("./router"),p=u("./helpers"),h=u("./strategies"),c=u("./listeners");p.debug("Service Worker Toolbox is loading"),self.addEventListener("install",c.installListener),self.addEventListener("activate",c.activateListener),self.addEventListener("fetch",c.fetchListener),l.exports={networkOnly:h.networkOnly,networkFirst:h.networkFirst,cacheOnly:h.cacheOnly,cacheFirst:h.cacheFirst,fastest:h.fastest,router:g,options:m,cache:p.cache,uncache:p.uncache,precache:p.precache}},{"./helpers":1,"./listeners":3,"./options":4,"./router":6,"./strategies":10}],14:[function(u,l,$){l.exports=Array.isArray||function(m){return Object.prototype.toString.call(m)=="[object Array]"}},{}],15:[function(u,l,$){function m(t,r){for(var i,x=[],S=0,w=0,b="",C=r&&r.delimiter||"/";(i=a.exec(t))!=null;){var T=i[0],A=i[1],E=i.index;if(b+=t.slice(w,E),w=E+T.length,A)b+=A[1];else{var O=t[w],P=i[2],F=i[3],j=i[4],D=i[5],U=i[6],L=i[7];b&&(x.push(b),b="");var M=P!=null&&O!=null&&O!==P,N=U==="+"||U==="*",_=U==="?"||U==="*",q=i[2]||C,I=j||D;x.push({name:F||S++,prefix:P||"",delimiter:q,optional:_,repeat:N,partial:M,asterisk:!!L,pattern:I?d(I):L?".*":"[^"+e(q)+"]+?"})}}return w<t.length&&(b+=t.substr(w)),b&&x.push(b),x}function g(t,r){return c(m(t,r))}function p(t){return encodeURI(t).replace(/[\/?#]/g,function(r){return"%"+r.charCodeAt(0).toString(16).toUpperCase()})}function h(t){return encodeURI(t).replace(/[?#]/g,function(r){return"%"+r.charCodeAt(0).toString(16).toUpperCase()})}function c(t){for(var r=new Array(t.length),i=0;i<t.length;i++)typeof t[i]=="object"&&(r[i]=new RegExp("^(?:"+t[i].pattern+")$"));return function(x,S){for(var w="",b=x||{},C=S||{},T=C.pretty?p:encodeURIComponent,A=0;A<t.length;A++){var E=t[A];if(typeof E!="string"){var O,P=b[E.name];if(P==null){if(E.optional){E.partial&&(w+=E.prefix);continue}throw new TypeError('Expected "'+E.name+'" to be defined')}if(s(P)){if(!E.repeat)throw new TypeError('Expected "'+E.name+'" to not repeat, but received `'+JSON.stringify(P)+"`");if(P.length===0){if(E.optional)continue;throw new TypeError('Expected "'+E.name+'" to not be empty')}for(var F=0;F<P.length;F++){if(O=T(P[F]),!r[A].test(O))throw new TypeError('Expected all "'+E.name+'" to match "'+E.pattern+'", but received `'+JSON.stringify(O)+"`");w+=(F===0?E.prefix:E.delimiter)+O}}else{if(O=E.asterisk?h(P):T(P),!r[A].test(O))throw new TypeError('Expected "'+E.name+'" to match "'+E.pattern+'", but received "'+O+'"');w+=E.prefix+O}}else w+=E}return w}}function e(t){return t.replace(/([.+*?=^!:${}()[\]|\/\\])/g,"\\$1")}function d(t){return t.replace(/([=!:$\/()])/g,"\\$1")}function n(t,r){return t.keys=r,t}function o(t){return t.sensitive?"":"i"}function f(t,r){var i=t.source.match(/\((?!\?)/g);if(i)for(var x=0;x<i.length;x++)r.push({name:x,prefix:null,delimiter:null,optional:!1,repeat:!1,partial:!1,asterisk:!1,pattern:null});return n(t,r)}function y(t,r,i){for(var x=[],S=0;S<t.length;S++)x.push(R(t[S],r,i).source);var w=new RegExp("(?:"+x.join("|")+")",o(i));return n(w,r)}function k(t,r,i){return v(m(t,i),r,i)}function v(t,r,i){s(r)||(i=r||i,r=[]),i=i||{};for(var x=i.strict,S=i.end!==!1,w="",b=0;b<t.length;b++){var C=t[b];if(typeof C=="string")w+=e(C);else{var T=e(C.prefix),A="(?:"+C.pattern+")";r.push(C),C.repeat&&(A+="(?:"+T+A+")*"),A=C.optional?C.partial?T+"("+A+")?":"(?:"+T+"("+A+"))?":T+"("+A+")",w+=A}}var E=e(i.delimiter||"/"),O=w.slice(-E.length)===E;return x||(w=(O?w.slice(0,-E.length):w)+"(?:"+E+"(?=$))?"),w+=S?"$":x&&O?"":"(?="+E+"|$)",n(new RegExp("^"+w,o(i)),r)}function R(t,r,i){return s(r)||(i=r||i,r=[]),i=i||{},t instanceof RegExp?f(t,r):s(t)?y(t,r,i):k(t,r,i)}var s=u("isarray");l.exports=R,l.exports.parse=m,l.exports.compile=g,l.exports.tokensToFunction=c,l.exports.tokensToRegExp=v;var a=new RegExp(["(\\\\.)","([\\/.])?(?:(?:\\:(\\w+)(?:\\(((?:\\\\.|[^\\\\()])+)\\))?|\\(((?:\\\\.|[^\\\\()])+)\\))([+*?])?|(\\*))"].join("|"),"g")},{isarray:14}],16:[function(u,l,$){(function(){var m=Cache.prototype.addAll,g=navigator.userAgent.match(/(Firefox|Chrome)\/(\d+\.)/);if(g)var p=g[1],h=parseInt(g[2]);m&&(!g||p==="Firefox"&&h>=46||p==="Chrome"&&h>=50)||(Cache.prototype.addAll=function(c){function e(n){this.name="NetworkError",this.code=19,this.message=n}var d=this;return e.prototype=Object.create(Error.prototype),Promise.resolve().then(function(){if(arguments.length<1)throw new TypeError;return c=c.map(function(n){return n instanceof Request?n:String(n)}),Promise.all(c.map(function(n){typeof n=="string"&&(n=new Request(n));var o=new URL(n.url).protocol;if(o!=="http:"&&o!=="https:")throw new e("Invalid scheme");return fetch(n.clone())}))}).then(function(n){if(n.some(function(o){return!o.ok}))throw new e("Incorrect response status");return Promise.all(n.map(function(o,f){return d.put(c[f],o)}))}).then(function(){})},Cache.prototype.add=function(c){return this.addAll([c])})})()},{}]},{},[13])(13)});
|