textbrowser 0.54.8 → 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 CHANGED
@@ -1,5 +1,9 @@
1
1
  # CHANGES to `textbrowser`
2
2
 
3
+ ## 0.54.9
4
+
5
+ - fix: logging worker issues
6
+
3
7
  ## 0.54.8
4
8
 
5
9
  - fix: worker issues
package/dist/sw-helper.js CHANGED
@@ -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
- return cache.put(urlToPrefetch, response);
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,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "textbrowser",
3
- "version": "0.54.8",
3
+ "version": "0.54.9",
4
4
  "description": "Multilinear text browser",
5
5
  "type": "module",
6
6
  "main": "dist/index-es.min.js",