textbrowser 0.54.7 → 0.54.9
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/CHANGES.md +8 -0
- package/dist/sw-helper.js +25 -4
- package/package.json +1 -1
package/CHANGES.md
CHANGED
package/dist/sw-helper.js
CHANGED
|
@@ -56,8 +56,8 @@ function swHelper (self) {
|
|
|
56
56
|
*/
|
|
57
57
|
|
|
58
58
|
'node_modules/intl-locale-textinfo-polyfill/lib/Locale.js',
|
|
59
|
-
'node_modules/textbrowser/dist/assets/languages-
|
|
60
|
-
'node_modules/textbrowser/dist/assets/index-
|
|
59
|
+
'node_modules/textbrowser/dist/assets/languages-DWwAAJMo.json',
|
|
60
|
+
'node_modules/textbrowser/dist/assets/index-D_XVedS3.css',
|
|
61
61
|
|
|
62
62
|
'node_modules/textbrowser/dist/index-es.js'
|
|
63
63
|
];
|
|
@@ -237,11 +237,26 @@ function swHelper (self) {
|
|
|
237
237
|
...userDataFiles,
|
|
238
238
|
...stylesheets
|
|
239
239
|
];
|
|
240
|
+
log(`Install: Pre-fetching ${urlsToPrefetch.length} assets`);
|
|
241
|
+
const pendingAssets = new Set();
|
|
242
|
+
const pendingLogTimer = setInterval(() => {
|
|
243
|
+
if (pendingAssets.size) {
|
|
244
|
+
log(
|
|
245
|
+
`Install: Still pending ${pendingAssets.size} assets: ` +
|
|
246
|
+
JSON.stringify([...pendingAssets])
|
|
247
|
+
);
|
|
248
|
+
}
|
|
249
|
+
}, 10000);
|
|
240
250
|
// .map((url) => url === 'index.html' ? new Request(url, {cache: 'reload'}) : url)
|
|
241
251
|
try {
|
|
242
|
-
const cachePromises = urlsToPrefetch.map(async (urlToPrefetch) => {
|
|
252
|
+
const cachePromises = urlsToPrefetch.map(async (urlToPrefetch, idx) => {
|
|
243
253
|
// This constructs a new URL object using the service worker's script
|
|
244
254
|
// location as the base for relative URLs.
|
|
255
|
+
pendingAssets.add(urlToPrefetch);
|
|
256
|
+
log(
|
|
257
|
+
`Install: Fetching asset ${idx + 1}/` +
|
|
258
|
+
`${urlsToPrefetch.length}: ${urlToPrefetch}`
|
|
259
|
+
);
|
|
245
260
|
const url = new URL(urlToPrefetch, location.href);
|
|
246
261
|
url.search += (url.search ? '&' : '?') + 'cache-bust=' + now;
|
|
247
262
|
const request = new Request(url, {mode: 'no-cors'});
|
|
@@ -251,8 +266,12 @@ function swHelper (self) {
|
|
|
251
266
|
throw new Error('request for ' + urlToPrefetch +
|
|
252
267
|
' failed with status ' + response.statusText);
|
|
253
268
|
}
|
|
254
|
-
|
|
269
|
+
await cache.put(urlToPrefetch, response);
|
|
270
|
+
log(`Install: Cached asset ${idx + 1}/${urlsToPrefetch.length}: ${urlToPrefetch}`);
|
|
271
|
+
pendingAssets.delete(urlToPrefetch);
|
|
272
|
+
return;
|
|
255
273
|
} catch (error) {
|
|
274
|
+
pendingAssets.delete(urlToPrefetch);
|
|
256
275
|
logError(
|
|
257
276
|
/** @type {Error} */
|
|
258
277
|
(error),
|
|
@@ -271,6 +290,8 @@ function swHelper (self) {
|
|
|
271
290
|
);
|
|
272
291
|
// Failing gives chance for a new client to re-trigger install?
|
|
273
292
|
throw error;
|
|
293
|
+
} finally {
|
|
294
|
+
clearInterval(pendingLogTimer);
|
|
274
295
|
}
|
|
275
296
|
|
|
276
297
|
// An install update event will not be reported until controlled,
|