textbrowser 0.40.2 → 0.41.2

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.
@@ -2,6 +2,16 @@
2
2
  "$schema": "http://json-schema.org/schema#",
3
3
  "type": "array",
4
4
  "items": {
5
- "type": "array"
5
+ "type": "array",
6
+ "items": {
7
+ "anyOf": [
8
+ {
9
+ "type": "integer"
10
+ },
11
+ {
12
+ "type": "string"
13
+ }
14
+ ]
15
+ }
6
16
  }
7
17
  }
@@ -21,7 +21,35 @@
21
21
  "properties": {
22
22
  "type": {"$ref": "#/definitions/typeArray"},
23
23
  "items": {
24
- "type": "array"
24
+ "type": "array",
25
+ "items": {
26
+ "type": "object",
27
+ "properties": {
28
+ "type": {
29
+ "type": "string",
30
+ "enum": ["string", "integer"]
31
+ },
32
+ "enum": {
33
+ "type": "array",
34
+ "items": {
35
+ "type": "string"
36
+ }
37
+ },
38
+ "format": {
39
+ "type": "string",
40
+ "enum": ["html"]
41
+ },
42
+ "title": {
43
+ "type": "string"
44
+ },
45
+ "minimum": {
46
+ "type": "integer"
47
+ },
48
+ "maximum": {
49
+ "type": "integer"
50
+ }
51
+ }
52
+ }
25
53
  }
26
54
  }
27
55
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "textbrowser",
3
- "version": "0.40.2",
3
+ "version": "0.41.2",
4
4
  "description": "Multilinear text browser",
5
5
  "main": "dist/index-umd.min.js",
6
6
  "module": "resources/index.js",
@@ -39,62 +39,62 @@
39
39
  "text"
40
40
  ],
41
41
  "dependencies": {
42
- "@babel/core": "^7.14.6",
43
- "@babel/register": "^7.14.5",
42
+ "@babel/core": "^7.17.2",
43
+ "@babel/register": "^7.17.0",
44
44
  "@brettz9/node-static": "^0.1.1",
45
- "command-line-args": "^5.1.1",
45
+ "command-line-args": "^5.2.1",
46
46
  "dialog-polyfill": "^0.5.6",
47
47
  "dom-parser": "^0.1.6",
48
48
  "form-serialization": "^0.11.0",
49
49
  "imf": "5.0.2",
50
- "indexeddbshim": "^8.0.0",
50
+ "indexeddbshim": "^9.0.0",
51
51
  "jamilih": "0.54.0",
52
- "jsdom": "^16.6.0",
52
+ "jsdom": "^19.0.0",
53
53
  "json-refs": "git+https://github.com/brettz9/json-refs.git#browser",
54
54
  "load-stylesheets": "0.10.0",
55
- "node-fetch": "^2.6.1",
55
+ "node-fetch": "^2.6.6",
56
56
  "node-serviceworker": "^0.3.0",
57
- "rtl-detect": "^1.0.3",
57
+ "rtl-detect": "^1.0.4",
58
58
  "simple-get-json": "8.1.1",
59
59
  "url-search-params-polyfill": "^8.1.1"
60
60
  },
61
61
  "devDependencies": {
62
- "@babel/eslint-parser": "^7.14.5",
63
- "@babel/plugin-proposal-object-rest-spread": "^7.14.5",
62
+ "@babel/eslint-parser": "^7.17.0",
63
+ "@babel/plugin-proposal-object-rest-spread": "^7.16.7",
64
64
  "@babel/plugin-syntax-dynamic-import": "^7.8.3",
65
- "@babel/preset-env": "^7.14.5",
66
- "@brettz9/eslint-plugin": "^1.0.3",
65
+ "@babel/preset-env": "^7.16.11",
66
+ "@brettz9/eslint-plugin": "^1.0.4",
67
67
  "@rollup/plugin-babel": "^5.3.0",
68
- "@rollup/plugin-commonjs": "^19.0.0",
68
+ "@rollup/plugin-commonjs": "^21.0.1",
69
69
  "@rollup/plugin-json": "^4.1.0",
70
- "@rollup/plugin-node-resolve": "^13.0.0",
70
+ "@rollup/plugin-node-resolve": "^13.1.3",
71
71
  "@stadtlandnetz/rollup-plugin-postprocess": "1.1.0",
72
- "ajv": "8.6.0",
72
+ "ajv": "8.10.0",
73
73
  "babel-plugin-dynamic-import-node": "^2.3.3",
74
- "chai": "^4.3.4",
75
- "eslint": "^7.28.0",
76
- "eslint-config-ash-nazg": "^29.17.0",
74
+ "chai": "^4.3.6",
75
+ "eslint": "^8.9.0",
76
+ "eslint-config-ash-nazg": "^32.3.0",
77
77
  "eslint-config-standard": "^16.0.3",
78
78
  "eslint-plugin-array-func": "^3.1.7",
79
- "eslint-plugin-compat": "^3.9.0",
79
+ "eslint-plugin-compat": "^4.0.2",
80
80
  "eslint-plugin-eslint-comments": "^3.2.0",
81
- "eslint-plugin-html": "^6.1.2",
82
- "eslint-plugin-import": "^2.23.4",
83
- "eslint-plugin-jsdoc": "^35.2.0",
84
- "eslint-plugin-markdown": "^2.2.0",
85
- "eslint-plugin-no-unsanitized": "^3.1.5",
81
+ "eslint-plugin-html": "^6.2.0",
82
+ "eslint-plugin-import": "^2.25.4",
83
+ "eslint-plugin-jsdoc": "^37.9.1",
84
+ "eslint-plugin-markdown": "^2.2.1",
85
+ "eslint-plugin-no-unsanitized": "^4.0.1",
86
86
  "eslint-plugin-no-use-extend-native": "^0.5.0",
87
87
  "eslint-plugin-node": "^11.1.0",
88
- "eslint-plugin-promise": "^5.1.0",
89
- "eslint-plugin-radar": "^0.2.1",
88
+ "eslint-plugin-promise": "^6.0.0",
89
+ "eslint-plugin-sonarjs": "^0.11.0",
90
90
  "eslint-plugin-standard": "^4.1.0",
91
- "eslint-plugin-unicorn": "^33.0.1",
92
- "fast-json-patch": "2.2.1",
91
+ "eslint-plugin-unicorn": "^40.1.0",
92
+ "fast-json-patch": "3.1.0",
93
93
  "json-metaschema": "1.3.0",
94
- "mocha": "^9.0.0",
94
+ "mocha": "^9.2.0",
95
95
  "npm-run-all": "^4.1.5",
96
- "open-cli": "^7.0.0",
97
- "rollup": "2.51.2",
96
+ "open-cli": "^7.0.1",
97
+ "rollup": "2.67.2",
98
98
  "rollup-plugin-re": "^1.0.7",
99
99
  "rollup-plugin-terser": "^7.0.2"
100
100
  }
@@ -137,7 +137,7 @@ async function requestPermissions (langs, l) {
137
137
  // rememberRefusal();
138
138
  resolve();
139
139
  return;
140
- // eslint-disable-next-line radar/no-duplicated-branches
140
+ // eslint-disable-next-line sonarjs/no-duplicated-branches
141
141
  case 'default':
142
142
  resolve();
143
143
  return;
@@ -191,6 +191,8 @@ class TextBrowser {
191
191
  ? true
192
192
  : options.localizeParamNames;
193
193
  this.hideFormattingSection = Boolean(options.hideFormattingSection);
194
+
195
+ this.preferencesPlugin = options.preferencesPlugin;
194
196
  this.interlinearSeparator = options.interlinearSeparator;
195
197
  // Todo: Make these user facing options
196
198
  this.showEmptyInterlinear = options.showEmptyInterlinear;
@@ -532,7 +534,8 @@ class TextBrowser {
532
534
  lang, preferredLocale,
533
535
  fallbackLanguages,
534
536
  languageParam,
535
- $p, languages
537
+ $p, languages,
538
+ preferencesPlugin: this.preferencesPlugin
536
539
  });
537
540
  return true;
538
541
  }
@@ -547,7 +547,7 @@ export default {
547
547
  languageParam, lf, paramsSetter, replaceHash,
548
548
  getFieldAliasOrNames, work,
549
549
  langs, imfl, l, localizeParamNames, namespace,
550
- hideFormattingSection, groups
550
+ hideFormattingSection, groups, preferencesPlugin
551
551
  }) => ['div', {
552
552
  style: {textAlign: 'left'}, id: 'preferences', hidden: 'true'
553
553
  }, [
@@ -611,85 +611,10 @@ export default {
611
611
  ]];
612
612
  })]
613
613
  ]],
614
- ['div', [
615
- ['button', {
616
- title: l('bookmark_generation_tooltip'),
617
- $on: {
618
- async click () { // Todo: Give option to edit (keywords and work URLs)
619
- const date = Date.now();
620
- const ADD_DATE = date;
621
- const LAST_MODIFIED = date;
622
- const blob = new Blob([
623
- new XMLSerializer().serializeToString(
624
- jml({$document: {
625
- $DOCTYPE: {name: 'NETSCAPE-Bookmark-file-1'},
626
- title: l('Bookmarks'),
627
- body: [
628
- ['h1', [l('Bookmarks_Menu')]],
629
- ...(await getFieldAliasOrNames()).flatMap(({groupName, worksToFields}) => {
630
- return [
631
- ['dt', [
632
- ['h3', {
633
- ADD_DATE,
634
- LAST_MODIFIED
635
- }, [
636
- groupName
637
- ]]
638
- ]],
639
- ['dl', [
640
- ['p'],
641
- ...worksToFields.map(({fieldAliasOrNames, workName, shortcut: SHORTCUTURL}) => {
642
- // Todo (low): Add anchor, etc. (until handled by `work-startEnd`); &aqdas-anchor1-1=2&anchorfield1=Paragraph
643
- // Todo: option for additional browse field groups (startEnd2, etc.)
644
- // Todo: For link text, use `heading` or `alias` from metadata files in place of workName (requires loading all metadata files though)
645
- // Todo: Make Chrome NativeExt add-on to manipulate its search engines (to read a bookmarks file from Firefox properly, i.e., including keywords) https://www.makeuseof.com/answers/export-google-chrome-search-engines-address-bar/
646
-
647
- const paramsCopy = paramsSetter({
648
- ...getDataForSerializingParamsAsURL(),
649
- fieldAliasOrNames,
650
- workName: work, // Delete work of current page
651
- type: 'shortcutResult'
652
- });
653
- const url = replaceHash(paramsCopy) + `&work=${workName}&${workName}-startEnd1=%s`; // %s will be escaped if set as param; also add changeable workName here
654
-
655
- return ['dt', [
656
- ['a', {
657
- href: url,
658
- ADD_DATE,
659
- LAST_MODIFIED,
660
- SHORTCUTURL
661
- }, [
662
- workName
663
- ]]
664
- ]];
665
- })
666
- ]]
667
- ];
668
- })
669
- ]
670
- }})
671
- ).replace(
672
- // Chrome has a quirk that requires this (and not
673
- // just any whitespace)
674
- // We're not getting the keywords with Chrome,
675
- // but at least usable for bookmarks (though
676
- // not the groups apparently)
677
- /<dt>/g,
678
- '\n<dt>'
679
- )
680
- ], {type: 'text/html'});
681
- const url = window.URL.createObjectURL(blob);
682
- const a = jml('a', {
683
- hidden: true,
684
- download: 'bookmarks.html',
685
- href: url
686
- }, $('#main'));
687
- a.click();
688
- URL.revokeObjectURL(url);
689
- }
690
- }
691
- }, [l('Generate_bookmarks')]]
692
- ]]
614
+ (preferencesPlugin ? preferencesPlugin({
615
+ $, l, jml, paramsSetter, getDataForSerializingParamsAsURL, work,
616
+ replaceHash, getFieldAliasOrNames
617
+ }) : '')
693
618
  ]],
694
619
  addBrowseFields ({browseFields, fieldInfo, ld, i, iil, $p, content}) {
695
620
  const work = $p.get('work');
@@ -830,7 +755,7 @@ export default {
830
755
  getFieldAliasOrNames,
831
756
  hideFormattingSection, $p,
832
757
  metadataObj, il, le, ld, iil, fieldMatchesLocale,
833
- preferredLocale, schemaItems, content, groups
758
+ preferredLocale, schemaItems, content, groups, preferencesPlugin
834
759
  }) {
835
760
  const work = $p.get('work');
836
761
  const serializeParamsAsURLWithData = ({type}) => {
@@ -863,7 +788,7 @@ export default {
863
788
  languageParam, lf, paramsSetter, replaceHash,
864
789
  getFieldAliasOrNames, work,
865
790
  langs, imfl, l, localizeParamNames, namespace,
866
- groups, hideFormattingSection
791
+ groups, hideFormattingSection, preferencesPlugin
867
792
  })
868
793
  ]],
869
794
  ['h2', [heading]],
@@ -33,9 +33,14 @@ export const getMetaProp = function getMetaProp (lang, metadataObj, properties,
33
33
  // file.anyOf.splice(1, 1, {$ref: schemaFile});
34
34
  // Todo: Allow use of dbs and fileGroup together in base directories?
35
35
  export const getMetadata = async (file, property, basePath) => {
36
+ const url = new URL(basePath || getCurrDir());
37
+ url.search = ''; // Clear out query string, e.g., `?fbclid` from Facebook
38
+ url.pathname = file;
39
+ url.hash = property ? '#/' + property : '';
40
+
36
41
  return (await JsonRefs
37
42
  .resolveRefsAt(
38
- (basePath || getCurrDir()) + file + (property ? '#/' + property : ''),
43
+ url.toString(),
39
44
  {
40
45
  loaderOptions: {
41
46
  processContent (res, callback) {
@@ -12,6 +12,7 @@ export default async function workDisplay ({
12
12
  l, languageParam,
13
13
  lang, preferredLocale, languages, fallbackLanguages, $p
14
14
  }) {
15
+ const {preferencesPlugin} = this;
15
16
  const langs = this.langData.languages;
16
17
 
17
18
  const fallbackDirection = this.getDirectionForLanguageCode(fallbackLanguages[0]);
@@ -41,7 +42,6 @@ export default async function workDisplay ({
41
42
  ? key => l(['params', 'indexed', key])
42
43
  : key => key;
43
44
 
44
- // eslint-disable-next-line unicorn/prefer-prototype-methods -- Convenient
45
45
  const localeFromLangData = languages.localeFromLangData.bind(languages);
46
46
  const imfLang = IMF({
47
47
  locales: lang.map(localeFromLangData),
@@ -137,7 +137,8 @@ export default async function workDisplay ({
137
137
  hideFormattingSection, $p,
138
138
  metadataObj, il, le, ld, iil,
139
139
  fieldMatchesLocale,
140
- preferredLocale, schemaItems, content
140
+ preferredLocale, schemaItems, content,
141
+ preferencesPlugin
141
142
  });
142
143
  }
143
144
 
@@ -13,14 +13,9 @@ function ownKeys(object, enumerableOnly) {
13
13
 
14
14
  if (Object.getOwnPropertySymbols) {
15
15
  var symbols = Object.getOwnPropertySymbols(object);
16
-
17
- if (enumerableOnly) {
18
- symbols = symbols.filter(function (sym) {
19
- return Object.getOwnPropertyDescriptor(object, sym).enumerable;
20
- });
21
- }
22
-
23
- keys.push.apply(keys, symbols);
16
+ enumerableOnly && (symbols = symbols.filter(function (sym) {
17
+ return Object.getOwnPropertyDescriptor(object, sym).enumerable;
18
+ })), keys.push.apply(keys, symbols);
24
19
  }
25
20
 
26
21
  return keys;
@@ -28,19 +23,12 @@ function ownKeys(object, enumerableOnly) {
28
23
 
29
24
  function _objectSpread2(target) {
30
25
  for (var i = 1; i < arguments.length; i++) {
31
- var source = arguments[i] != null ? arguments[i] : {};
32
-
33
- if (i % 2) {
34
- ownKeys(Object(source), true).forEach(function (key) {
35
- _defineProperty(target, key, source[key]);
36
- });
37
- } else if (Object.getOwnPropertyDescriptors) {
38
- Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
39
- } else {
40
- ownKeys(Object(source)).forEach(function (key) {
41
- Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
42
- });
43
- }
26
+ var source = null != arguments[i] ? arguments[i] : {};
27
+ i % 2 ? ownKeys(Object(source), !0).forEach(function (key) {
28
+ _defineProperty(target, key, source[key]);
29
+ }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) {
30
+ Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
31
+ });
44
32
  }
45
33
 
46
34
  return target;
@@ -772,7 +760,8 @@ var workDisplay = {
772
760
  localizeParamNames,
773
761
  namespace,
774
762
  hideFormattingSection,
775
- groups
763
+ groups,
764
+ preferencesPlugin
776
765
  }) => ['div', {
777
766
  style: {
778
767
  textAlign: 'left'
@@ -839,73 +828,16 @@ var workDisplay = {
839
828
  }
840
829
 
841
830
  return ['option', atts, [imfl(['languages', lan.code])]];
842
- })]]], ['div', [['button', {
843
- title: l('bookmark_generation_tooltip'),
844
- $on: {
845
- async click() {
846
- // Todo: Give option to edit (keywords and work URLs)
847
- const date = Date.now();
848
- const ADD_DATE = date;
849
- const LAST_MODIFIED = date;
850
- const blob = new Blob([new XMLSerializer().serializeToString(jamilih.jml({
851
- $document: {
852
- $DOCTYPE: {
853
- name: 'NETSCAPE-Bookmark-file-1'
854
- },
855
- title: l('Bookmarks'),
856
- body: [['h1', [l('Bookmarks_Menu')]], ...(await getFieldAliasOrNames()).flatMap(({
857
- groupName,
858
- worksToFields
859
- }) => {
860
- return [['dt', [['h3', {
861
- ADD_DATE,
862
- LAST_MODIFIED
863
- }, [groupName]]]], ['dl', [['p'], ...worksToFields.map(({
864
- fieldAliasOrNames,
865
- workName,
866
- shortcut: SHORTCUTURL
867
- }) => {
868
- // Todo (low): Add anchor, etc. (until handled by `work-startEnd`); &aqdas-anchor1-1=2&anchorfield1=Paragraph
869
- // Todo: option for additional browse field groups (startEnd2, etc.)
870
- // Todo: For link text, use `heading` or `alias` from metadata files in place of workName (requires loading all metadata files though)
871
- // Todo: Make Chrome NativeExt add-on to manipulate its search engines (to read a bookmarks file from Firefox properly, i.e., including keywords) https://www.makeuseof.com/answers/export-google-chrome-search-engines-address-bar/
872
- const paramsCopy = paramsSetter(_objectSpread2(_objectSpread2({}, getDataForSerializingParamsAsURL()), {}, {
873
- fieldAliasOrNames,
874
- workName: work,
875
- // Delete work of current page
876
- type: 'shortcutResult'
877
- }));
878
- const url = replaceHash(paramsCopy) + `&work=${workName}&${workName}-startEnd1=%s`; // %s will be escaped if set as param; also add changeable workName here
879
-
880
- return ['dt', [['a', {
881
- href: url,
882
- ADD_DATE,
883
- LAST_MODIFIED,
884
- SHORTCUTURL
885
- }, [workName]]]];
886
- })]]];
887
- })]
888
- }
889
- })).replace( // Chrome has a quirk that requires this (and not
890
- // just any whitespace)
891
- // We're not getting the keywords with Chrome,
892
- // but at least usable for bookmarks (though
893
- // not the groups apparently)
894
- /<dt>/g, '\n<dt>')], {
895
- type: 'text/html'
896
- });
897
- const url = window.URL.createObjectURL(blob);
898
- const a = jamilih.jml('a', {
899
- hidden: true,
900
- download: 'bookmarks.html',
901
- href: url
902
- }, jamilih.$('#main'));
903
- a.click();
904
- URL.revokeObjectURL(url);
905
- }
906
-
907
- }
908
- }, [l('Generate_bookmarks')]]]]]],
831
+ })]]], preferencesPlugin ? preferencesPlugin({
832
+ $: jamilih.$,
833
+ l,
834
+ jml: jamilih.jml,
835
+ paramsSetter,
836
+ getDataForSerializingParamsAsURL,
837
+ work,
838
+ replaceHash,
839
+ getFieldAliasOrNames
840
+ }) : '']],
909
841
 
910
842
  addBrowseFields({
911
843
  browseFields,
@@ -1057,7 +989,8 @@ var workDisplay = {
1057
989
  preferredLocale,
1058
990
  schemaItems,
1059
991
  content,
1060
- groups
992
+ groups,
993
+ preferencesPlugin
1061
994
  }) {
1062
995
  const work = $p.get('work');
1063
996
 
@@ -1108,7 +1041,8 @@ var workDisplay = {
1108
1041
  localizeParamNames,
1109
1042
  namespace,
1110
1043
  groups,
1111
- hideFormattingSection
1044
+ hideFormattingSection,
1045
+ preferencesPlugin
1112
1046
  })]], ['h2', [heading]], ['br'], ['form', {
1113
1047
  id: 'browse',
1114
1048
  $custom: {
@@ -2182,7 +2116,12 @@ const getMetaProp = function getMetaProp(lang, metadataObj, properties, allowObj
2182
2116
  // Todo: Allow use of dbs and fileGroup together in base directories?
2183
2117
 
2184
2118
  const getMetadata = async (file, property, basePath) => {
2185
- return (await JsonRefs$1.resolveRefsAt((basePath || getCurrDir()) + file + (property ? '#/' + property : ''), {
2119
+ const url = new URL(basePath || getCurrDir());
2120
+ url.search = ''; // Clear out query string, e.g., `?fbclid` from Facebook
2121
+
2122
+ url.pathname = file;
2123
+ url.hash = property ? '#/' + property : '';
2124
+ return (await JsonRefs$1.resolveRefsAt(url.toString(), {
2186
2125
  loaderOptions: {
2187
2126
  processContent(res, callback) {
2188
2127
  callback(undefined, JSON.parse(res.text || // `.metadata` not a recognized extension, so
package/site.json CHANGED
@@ -75,6 +75,9 @@
75
75
  "fa": {
76
76
  "browser-title": "برازر اثار و الواح",
77
77
  "removecookies": "زبان دیگری را انتخاب فرمایید"
78
+ },
79
+ "ru": {
80
+ "browser-title": "Sacred Writings Browser"
78
81
  }
79
82
  }
80
83
  }
package/sw-sample.js CHANGED
@@ -1,15 +1,16 @@
1
1
  /* eslint-env browser, serviceworker -- Service worker */
2
2
 
3
3
  import {getJSON} from './node_modules/simple-get-json/dist/index-es.js';
4
- import activateCallback from './node_modules/textbrowser/resources/activateCallback.js';
5
- import {getWorkFiles} from './node_modules/textbrowser/resources/utils/WorkInfo.js';
4
+ import activateCallback from './node_modules/textbrowser/dist/activateCallback-es.js';
5
+ import {getWorkFiles} from './node_modules/textbrowser/dist/WorkInfo-es.js';
6
6
 
7
- const CACHE_VERSION = '0.40.0';
8
7
  const CURRENT_CACHES = {
9
- prefetch: 'prefetch-cache-v' + CACHE_VERSION
8
+ prefetch: 'prefetch-cache-v'
10
9
  };
11
10
  const minutes = 60 * 1000;
12
11
 
12
+ // Changeable text to trigger worker change: 1
13
+
13
14
  // Utilities
14
15
 
15
16
  /**
@@ -31,6 +32,7 @@ async function post ({type, message = type}) {
31
32
  clients.forEach((client) => {
32
33
  // Although we only need one client to which to send
33
34
  // arguments, we want to signal phase complete to all
35
+ // eslint-disable-next-line unicorn/require-post-message-target-origin -- In worker
34
36
  client.postMessage({message, type});
35
37
  });
36
38
  }
@@ -50,7 +52,7 @@ function log (...messages) {
50
52
  *
51
53
  * @param {Error} error
52
54
  * @param {string[]} messages
53
- * @returns {Promise<void>}
55
+ * @returns {Promise<void>}
54
56
  */
55
57
  function logError (error, ...messages) {
56
58
  const message = messages.join(' ');
@@ -147,14 +149,6 @@ const textbrowserStaticResourceFiles = [
147
149
  'node_modules/textbrowser/general-schemas/table.jsonschema', // Not currently using for validation or meta-data
148
150
  */
149
151
 
150
- // Todo: Ought to make these locales only conditionally required and
151
- // then only show those specified in languages menu or go directly
152
- // to work selection
153
- 'node_modules/textbrowser/locales/ar.json',
154
- 'node_modules/textbrowser/locales/en-US.json',
155
- 'node_modules/textbrowser/locales/fa.json',
156
- 'node_modules/textbrowser/locales/ru.json',
157
-
158
152
  'node_modules/textbrowser/dist/index-es.js'
159
153
  ];
160
154
 
@@ -182,19 +176,25 @@ async function install (time) {
182
176
  namespace, languages, files, userStaticFiles
183
177
  } = getConfigDefaults(json);
184
178
 
185
- console.log('opening cache', namespace + CURRENT_CACHES.prefetch);
179
+ const {version} = await getJSON('./package.json');
180
+
181
+ console.log('opening cache', namespace + CURRENT_CACHES.prefetch + version);
186
182
  const [
187
183
  cache,
188
184
  userDataFiles,
189
185
  {languages: langs}
190
186
  ] = await Promise.all([
191
- caches.open(namespace + CURRENT_CACHES.prefetch),
187
+ caches.open(namespace + CURRENT_CACHES.prefetch + version),
192
188
  getWorkFiles(files),
193
189
  getJSON(languages)
194
190
  ]);
195
191
  log('Install: Retrieved dependency values');
196
192
 
197
193
  const langPathParts = languages.split('/');
194
+
195
+ // Todo: Ought to make these locales only conditionally required and
196
+ // then only show those specified in languages menu or go directly
197
+ // to work selection
198
198
  // Todo: We might give option to only download
199
199
  // one locale and avoid language splash page
200
200
  const localeFiles = langs.map(
@@ -230,7 +230,7 @@ async function install (time) {
230
230
  return cache.put(urlToPrefetch, response);
231
231
  } catch (error) {
232
232
  logError(error, 'Not caching ' + urlToPrefetch + ' due to ' + error);
233
- return Promise.reject(error);
233
+ throw error;
234
234
  }
235
235
  });
236
236
  await Promise.all(cachePromises);
@@ -263,8 +263,9 @@ async function activate (time) {
263
263
  caches.keys()
264
264
  ]);
265
265
  const {namespace, files, basePath} = getConfigDefaults(json);
266
+ const {version} = await getJSON('./package.json');
266
267
 
267
- const expectedCacheNames = Object.values(CURRENT_CACHES).map((n) => namespace + n);
268
+ const expectedCacheNames = Object.values(CURRENT_CACHES).map((n) => namespace + n + version);
268
269
  cacheNames.map(async (cacheName) => {
269
270
  if (!expectedCacheNames.includes(cacheName)) {
270
271
  log('Activate: Deleting out of date cache:', cacheName);