textbrowser 0.39.0 → 0.40.3

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/sw-sample.js CHANGED
@@ -1,22 +1,11 @@
1
- /* eslint-env browser, serviceworker */
2
-
3
- 'use strict';
4
-
5
- /* globals getJSON, activateCallback, WorkInfo */
6
- // Todo: Replace with ES6 modules (and remove Rollup routines) once browsers
7
- // support:
8
- // https://stackoverflow.com/a/45578811/271577
9
- // https://bugs.chromium.org/p/chromium/issues/detail?id=824647
10
- // import getJSON from './node_modules/simple-get-json/dist/index-es.js';
11
- // import activateCallback from 'node_modules/textbrowser/resources/activateCallback.js';
12
- // import {getWorkFiles} from './WorkInfo.js';
13
- importScripts('node_modules/simple-get-json/dist/index.js');
14
- importScripts('node_modules/textbrowser/dist/WorkInfo-umd.js');
15
- importScripts('node_modules/textbrowser/dist/activateCallback-umd.js');
16
-
17
- const CACHE_VERSION = '0.34.0';
1
+ /* eslint-env browser, serviceworker -- Service worker */
2
+
3
+ import {getJSON} from './node_modules/simple-get-json/dist/index-es.js';
4
+ import activateCallback from './node_modules/textbrowser/dist/activateCallback-es.js';
5
+ import {getWorkFiles} from './node_modules/textbrowser/dist/WorkInfo-es.js';
6
+
18
7
  const CURRENT_CACHES = {
19
- prefetch: 'prefetch-cache-v' + CACHE_VERSION
8
+ prefetch: 'prefetch-cache-v'
20
9
  };
21
10
  const minutes = 60 * 1000;
22
11
 
@@ -41,6 +30,7 @@ async function post ({type, message = type}) {
41
30
  clients.forEach((client) => {
42
31
  // Although we only need one client to which to send
43
32
  // arguments, we want to signal phase complete to all
33
+ // eslint-disable-next-line unicorn/require-post-message-target-origin -- In worker
44
34
  client.postMessage({message, type});
45
35
  });
46
36
  }
@@ -60,7 +50,7 @@ function log (...messages) {
60
50
  *
61
51
  * @param {Error} error
62
52
  * @param {string[]} messages
63
- * @returns {Promise<void>}
53
+ * @returns {Promise<void>}
64
54
  */
65
55
  function logError (error, ...messages) {
66
56
  const message = messages.join(' ');
@@ -192,14 +182,16 @@ async function install (time) {
192
182
  namespace, languages, files, userStaticFiles
193
183
  } = getConfigDefaults(json);
194
184
 
195
- console.log('opening cache', namespace + CURRENT_CACHES.prefetch);
185
+ const {version} = await getJSON('./package.json');
186
+
187
+ console.log('opening cache', namespace + CURRENT_CACHES.prefetch + version);
196
188
  const [
197
189
  cache,
198
190
  userDataFiles,
199
191
  {languages: langs}
200
192
  ] = await Promise.all([
201
- caches.open(namespace + CURRENT_CACHES.prefetch),
202
- WorkInfo.getWorkFiles(files),
193
+ caches.open(namespace + CURRENT_CACHES.prefetch + version),
194
+ getWorkFiles(files),
203
195
  getJSON(languages)
204
196
  ]);
205
197
  log('Install: Retrieved dependency values');
@@ -240,7 +232,7 @@ async function install (time) {
240
232
  return cache.put(urlToPrefetch, response);
241
233
  } catch (error) {
242
234
  logError(error, 'Not caching ' + urlToPrefetch + ' due to ' + error);
243
- return Promise.reject(error);
235
+ throw error;
244
236
  }
245
237
  });
246
238
  await Promise.all(cachePromises);
@@ -273,8 +265,9 @@ async function activate (time) {
273
265
  caches.keys()
274
266
  ]);
275
267
  const {namespace, files, basePath} = getConfigDefaults(json);
268
+ const {version} = await getJSON('./package.json');
276
269
 
277
- const expectedCacheNames = Object.values(CURRENT_CACHES).map((n) => namespace + n);
270
+ const expectedCacheNames = Object.values(CURRENT_CACHES).map((n) => namespace + n + version);
278
271
  cacheNames.map(async (cacheName) => {
279
272
  if (!expectedCacheNames.includes(cacheName)) {
280
273
  log('Activate: Deleting out of date cache:', cacheName);
package/.remarkrc DELETED
@@ -1,11 +0,0 @@
1
- {
2
- "plugins": {
3
- "lint": {
4
- "no-multiple-toplevel-headings": false,
5
- "ordered-list-marker-value": "one",
6
- "no-missing-blank-lines": false,
7
- "list-item-spacing": false,
8
- "list-item-indent": false
9
- }
10
- }
11
- }