textbrowser 0.40.2 → 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/.eslintrc.js CHANGED
@@ -15,6 +15,7 @@ module.exports = {
15
15
  'document.dir',
16
16
  'document.querySelector',
17
17
  'document.querySelectorAll',
18
+ 'document.title',
18
19
  'DOMParser',
19
20
  'Error',
20
21
  'fetch',
package/.ncurc.js ADDED
@@ -0,0 +1,8 @@
1
+ 'use strict';
2
+
3
+ module.exports = {
4
+ reject: [
5
+ // Wait until making this package ESM and ESM-only
6
+ 'node-fetch'
7
+ ]
8
+ };
package/CHANGES.md CHANGED
@@ -1,5 +1,18 @@
1
1
  # textbrowser CHANGES
2
2
 
3
+ ## 0.40.3
4
+
5
+ ### User-facing
6
+
7
+ - fix: clear out extra query string, e.g., from Facebook when querying for
8
+ metadata file
9
+ - chore: update deps.
10
+
11
+ ### Dev-facing
12
+
13
+ - chore: lint and add ncurc.js
14
+ - chore: update devDeps.
15
+
3
16
  ## 0.40.2
4
17
 
5
18
  - Fix: Add ESM `dist` versions for `activateCallback` and `WorkInfo`
package/README.md CHANGED
@@ -736,6 +736,11 @@ it supports the following arguments:
736
736
 
737
737
  ## To-dos (Highest priority)
738
738
 
739
+ 1. Document and add **screen-casts** along with one for developers showing
740
+ JSON format, metadata, and schemas); also use with shortcuts (including
741
+ Bahá'í Library Online ones)
742
+ 1. Fix so as to ignore other items of query string such as `?fbclid=...`
743
+ from Facebook.
739
744
  0. Progressive web app? / Electron?
740
745
  1. Adapt approach of <https://suttacentral.net/offline> in providing form for
741
746
  choice of items to offline (also add to individual work pages).
@@ -751,12 +756,10 @@ it supports the following arguments:
751
756
  1. Ensure works with `pnpm` in all environments (didn't work when deployed,
752
757
  but would need to recall the problem and resolve)
753
758
  1. Simplify `languages.json` by using `Intl.DisplayNames` (`type: 'language'`)
754
- to localize language names (and can avoid direction if [intl-locale-info proposal](https://github.com/tc39/proposal-intl-locale-info) is
755
- implemented); consider using with plugins so can, e.g., show language
759
+ to localize language names (and can avoid direction if
760
+ [intl-locale-info proposal](https://github.com/tc39/proposal-intl-locale-info)
761
+ is implemented); consider using with plugins so can, e.g., show language
756
762
  visibly into which a targeted content language field was translated
757
- 1. Document and add screen-casts along with one for developers showing
758
- JSON format, metadata, and schemas); also use with shortcuts (including
759
- Bahá'í Library Online ones)
760
763
  1. For plugins, allow export of `stylesheets` array to add to
761
764
  `loadStylesheets`, so they don't have to do the importing and executing.
762
765
  1. **Progress meter** with hidden console to avoid intimidating loading
@@ -777,7 +780,7 @@ it supports the following arguments:
777
780
  1. Fix limitation that 0's don't change to 1's if
778
781
  not present as a minimum (e.g., if no 0 for Chapter
779
782
  number, then won't show anything).
780
- 1. Avoid need for separate `startEnd` for browse set;
783
+ 1. Avoid need for separate `<work name>-startEnd` for browse set;
781
784
  e.g., parse Rodwell or Sale?
782
785
  1. Ideally work across even book
783
786
  1. Support anchor portion (e.g., `1:2:3-1:2:5#1:2:4`)
@@ -785,6 +788,7 @@ it supports the following arguments:
785
788
  `activateCallback.js`
786
789
  1. Have **IndexedDB handle all pages** language select, work select, and
787
790
  work display be part of too?
791
+ 1. `indexedDB` for JSON data
788
792
  1. **Node.js** (or PHP?)
789
793
  1. Delivery of HTML content by same URL so third parties can
790
794
  consume without JavaScript and optimized when not offline
@@ -910,7 +914,9 @@ it supports the following arguments:
910
914
  and/or syntax (generic to *TextBrowser* and/or canonical, ideally
911
915
  human-readable based on JSON-supplied information; e.g., for the
912
916
  Bible, `Matt. 5:10-12`); use with `postMessage` to-do to supply
913
- syntax back to another site
917
+ syntax back to another site; see
918
+ [Scroll To Text fragment](https://wicg.github.io/ScrollToTextFragment/);
919
+ [Stack answer](https://stackoverflow.com/a/62162093/271577)
914
920
  1. Correct any field easily by links within TB to editing interface
915
921
  1. Add an "overlay" column like interlinear, but which overlays by
916
922
  tooltip if any data is present; can also use metadata if the
@@ -966,11 +972,13 @@ it supports the following arguments:
966
972
  <https://github.com/json-schema-org/json-schema-spec/issues/587#issuecomment-389726603>
967
973
  by using initial `$`?
968
974
  1. Find way to avoid need for `!important` in column CSS
969
- 1. Offer more border styling tuning controls (including right/left/top/bottom,
975
+ 1. Redirect automatically by accepted language, though have a link or
976
+ preference to change the default
977
+ 1. Offer more **border styling** tuning controls (including right/left/top/bottom,
970
978
  color, etc.); then offer this along with other styles if we replace CSS
971
979
  input box with pop-up styling form (like Advanced Formatting, but for columns)
972
- 1. Refactoring: Try to use `deserialize` of `form-serialization` fork for initial population
973
- or hash change?
980
+ 1. Refactoring: Try to use `deserialize` of `form-serialization` fork for
981
+ initial population or hash change? (if not `FormData`)
974
982
  1. We should try to allow `onByDefault` and `placement` for non-plugin
975
983
  fields also
976
984
  1. [ES6 Modules in browser](https://jakearchibald.com/2017/es-modules-in-browsers/):
@@ -1044,8 +1052,8 @@ it supports the following arguments:
1044
1052
  with multiselect
1045
1053
  1. Preview styling changes (or move all controls to results page for
1046
1054
  immediate real feedback)
1047
- 1. Separate formatting within Jamilih code to CSS; unit test and performance
1048
- by being able to use a natively stringifying version of Jamilih
1055
+ 1. Separate **formatting within Jamilih code** to CSS; unit test and
1056
+ performance by being able to use a natively stringifying version of Jamilih
1049
1057
  (once complete)
1050
1058
  1. Utilize meta-data properties, `primary_text_field`, `orig_lang_field`,
1051
1059
  `orig_langs`, e.g., to allow for user to display main language and
@@ -1105,7 +1113,7 @@ it supports the following arguments:
1105
1113
 
1106
1114
  1. Waiting: Avoid superagent warning:
1107
1115
  <https://github.com/whitlockjc/path-loader/issues/17>
1108
- 1. Remember columns enabled, etc. since last visit, and/or saved as
1116
+ 1. **Remember columns enabled**, etc. since last visit, and/or saved as
1109
1117
  preferences.
1110
1118
  1. Allow copy-pasting a search as a custom web protocol (make
1111
1119
  site-configurable), e.g., to support `web+bahaiwritings:` links per
@@ -1124,8 +1132,6 @@ it supports the following arguments:
1124
1132
  1. Preference to remember enabled checkboxes and formatting
1125
1133
  1. Change to utilize history.pushState?
1126
1134
  <https://developer.mozilla.org/en-US/docs/Web/API/History_API>
1127
- 1. Use ES6 modules (babel)
1128
- 1. dynamic or hierarchical loading of CSS too?
1129
1135
  1. Sort file selection listing per locale?
1130
1136
  1. Node.js synchronization of locale files?
1131
1137
  1. Could allow Node to built schemas, optionally allowing or disallowing
@@ -1142,7 +1148,6 @@ it supports the following arguments:
1142
1148
  the i18n of "lang"?).
1143
1149
  1. `window.postMessage` API (since CORS is only for Ajax and
1144
1150
  `document.domain` is only for subdomains).
1145
- 1. `indexedDB` for JSON data
1146
1151
  1. Restore `tabindex` usage
1147
1152
  1. Restore option from work page to have a checkbox on whether to go to
1148
1153
  "Advanced mode", opening the styling options by default or not.
@@ -4229,9 +4229,14 @@ const getMetaProp = function getMetaProp (lang, metadataObj, properties, allowOb
4229
4229
  // file.anyOf.splice(1, 1, {$ref: schemaFile});
4230
4230
  // Todo: Allow use of dbs and fileGroup together in base directories?
4231
4231
  const getMetadata = async (file, property, basePath) => {
4232
+ const url = new URL(basePath || getCurrDir());
4233
+ url.search = ''; // Clear out query string, e.g., `?fbclid` from Facebook
4234
+ url.pathname = file;
4235
+ url.hash = property ? '#/' + property : '';
4236
+
4232
4237
  return (await JsonRefs
4233
4238
  .resolveRefsAt(
4234
- (basePath || getCurrDir()) + file + (property ? '#/' + property : ''),
4239
+ url.toString(),
4235
4240
  {
4236
4241
  loaderOptions: {
4237
4242
  processContent (res, callback) {
@@ -155,4 +155,4 @@ async function activateCallback ({
155
155
  });
156
156
  }
157
157
 
158
- export default activateCallback;
158
+ export { activateCallback as default };
package/dist/index-es.js CHANGED
@@ -3,14 +3,9 @@ function ownKeys(object, enumerableOnly) {
3
3
 
4
4
  if (Object.getOwnPropertySymbols) {
5
5
  var symbols = Object.getOwnPropertySymbols(object);
6
-
7
- if (enumerableOnly) {
8
- symbols = symbols.filter(function (sym) {
9
- return Object.getOwnPropertyDescriptor(object, sym).enumerable;
10
- });
11
- }
12
-
13
- keys.push.apply(keys, symbols);
6
+ enumerableOnly && (symbols = symbols.filter(function (sym) {
7
+ return Object.getOwnPropertyDescriptor(object, sym).enumerable;
8
+ })), keys.push.apply(keys, symbols);
14
9
  }
15
10
 
16
11
  return keys;
@@ -18,19 +13,12 @@ function ownKeys(object, enumerableOnly) {
18
13
 
19
14
  function _objectSpread2(target) {
20
15
  for (var i = 1; i < arguments.length; i++) {
21
- var source = arguments[i] != null ? arguments[i] : {};
22
-
23
- if (i % 2) {
24
- ownKeys(Object(source), true).forEach(function (key) {
25
- _defineProperty(target, key, source[key]);
26
- });
27
- } else if (Object.getOwnPropertyDescriptors) {
28
- Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
29
- } else {
30
- ownKeys(Object(source)).forEach(function (key) {
31
- Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
32
- });
33
- }
16
+ var source = null != arguments[i] ? arguments[i] : {};
17
+ i % 2 ? ownKeys(Object(source), !0).forEach(function (key) {
18
+ _defineProperty(target, key, source[key]);
19
+ }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) {
20
+ Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
21
+ });
34
22
  }
35
23
 
36
24
  return target;
@@ -1485,15 +1473,15 @@ var number = createCommonjsModule(function (module, exports) {
1485
1473
  result.maximumSignificantDigits = g1.length;
1486
1474
  } // @@@+ case
1487
1475
  else if (g2 === '+') {
1488
- result.minimumSignificantDigits = g1.length;
1489
- } // .### case
1490
- else if (g1[0] === '#') {
1491
- result.maximumSignificantDigits = g1.length;
1492
- } // .@@## or .@@@ case
1493
- else {
1494
- result.minimumSignificantDigits = g1.length;
1495
- result.maximumSignificantDigits = g1.length + (typeof g2 === 'string' ? g2.length : 0);
1496
- }
1476
+ result.minimumSignificantDigits = g1.length;
1477
+ } // .### case
1478
+ else if (g1[0] === '#') {
1479
+ result.maximumSignificantDigits = g1.length;
1480
+ } // .@@## or .@@@ case
1481
+ else {
1482
+ result.minimumSignificantDigits = g1.length;
1483
+ result.maximumSignificantDigits = g1.length + (typeof g2 === 'string' ? g2.length : 0);
1484
+ }
1497
1485
 
1498
1486
  return '';
1499
1487
  });
@@ -1733,15 +1721,15 @@ var number = createCommonjsModule(function (module, exports) {
1733
1721
  result.minimumFractionDigits = g1.length;
1734
1722
  } // .### case
1735
1723
  else if (g3 && g3[0] === '#') {
1736
- result.maximumFractionDigits = g3.length;
1737
- } // .00## case
1738
- else if (g4 && g5) {
1739
- result.minimumFractionDigits = g4.length;
1740
- result.maximumFractionDigits = g4.length + g5.length;
1741
- } else {
1742
- result.minimumFractionDigits = g1.length;
1743
- result.maximumFractionDigits = g1.length;
1744
- }
1724
+ result.maximumFractionDigits = g3.length;
1725
+ } // .00## case
1726
+ else if (g4 && g5) {
1727
+ result.minimumFractionDigits = g4.length;
1728
+ result.maximumFractionDigits = g4.length + g5.length;
1729
+ } else {
1730
+ result.minimumFractionDigits = g1.length;
1731
+ result.maximumFractionDigits = g1.length;
1732
+ }
1745
1733
 
1746
1734
  return '';
1747
1735
  });
@@ -1966,14 +1954,14 @@ var parser = createCommonjsModule(function (module, exports) {
1966
1954
  if (char === 123
1967
1955
  /* `{` */
1968
1956
  ) {
1969
- var result = this.parseArgument(nestingLevel, expectingCloseTag);
1957
+ var result = this.parseArgument(nestingLevel, expectingCloseTag);
1970
1958
 
1971
- if (result.err) {
1972
- return result;
1973
- }
1959
+ if (result.err) {
1960
+ return result;
1961
+ }
1974
1962
 
1975
- elements.push(result.val);
1976
- } else if (char === 125
1963
+ elements.push(result.val);
1964
+ } else if (char === 125
1977
1965
  /* `}` */
1978
1966
  && nestingLevel > 0) {
1979
1967
  break;
@@ -1990,12 +1978,12 @@ var parser = createCommonjsModule(function (module, exports) {
1990
1978
  /* `<` */
1991
1979
  && !this.ignoreTag && this.peek() === 47 // char code for '/'
1992
1980
  ) {
1993
- if (expectingCloseTag) {
1994
- break;
1995
- } else {
1996
- return this.error(error.ErrorKind.UNMATCHED_CLOSING_TAG, createLocation(this.clonePosition(), this.clonePosition()));
1997
- }
1998
- } else if (char === 60
1981
+ if (expectingCloseTag) {
1982
+ break;
1983
+ } else {
1984
+ return this.error(error.ErrorKind.UNMATCHED_CLOSING_TAG, createLocation(this.clonePosition(), this.clonePosition()));
1985
+ }
1986
+ } else if (char === 60
1999
1987
  /* `<` */
2000
1988
  && !this.ignoreTag && _isAlpha(this.peek() || 0)) {
2001
1989
  var result = this.parseTag(nestingLevel, parentArgType);
@@ -2180,8 +2168,8 @@ var parser = createCommonjsModule(function (module, exports) {
2180
2168
  if (this.isEOF() || this.char() !== 39
2181
2169
  /* `'` */
2182
2170
  ) {
2183
- return null;
2184
- } // Parse escaped char following the apostrophe, or early return if there is no escaped char.
2171
+ return null;
2172
+ } // Parse escaped char following the apostrophe, or early return if there is no escaped char.
2185
2173
  // Check if is valid escaped character
2186
2174
 
2187
2175
 
@@ -2225,18 +2213,18 @@ var parser = createCommonjsModule(function (module, exports) {
2225
2213
  if (ch === 39
2226
2214
  /* `'` */
2227
2215
  ) {
2228
- if (this.peek() === 39
2229
- /* `'` */
2230
- ) {
2231
- codePoints.push(39); // Bump one more time because we need to skip 2 characters.
2216
+ if (this.peek() === 39
2217
+ /* `'` */
2218
+ ) {
2219
+ codePoints.push(39); // Bump one more time because we need to skip 2 characters.
2232
2220
 
2233
- this.bump();
2234
- } else {
2235
- // Optional closing apostrophe.
2236
- this.bump();
2237
- break;
2238
- }
2221
+ this.bump();
2239
2222
  } else {
2223
+ // Optional closing apostrophe.
2224
+ this.bump();
2225
+ break;
2226
+ }
2227
+ } else {
2240
2228
  codePoints.push(ch);
2241
2229
  }
2242
2230
 
@@ -2282,9 +2270,9 @@ var parser = createCommonjsModule(function (module, exports) {
2282
2270
  if (this.char() === 125
2283
2271
  /* `}` */
2284
2272
  ) {
2285
- this.bump();
2286
- return this.error(error.ErrorKind.EMPTY_ARGUMENT, createLocation(openingBracePosition, this.clonePosition()));
2287
- } // argument name
2273
+ this.bump();
2274
+ return this.error(error.ErrorKind.EMPTY_ARGUMENT, createLocation(openingBracePosition, this.clonePosition()));
2275
+ } // argument name
2288
2276
 
2289
2277
 
2290
2278
  var value = this.parseIdentifierIfPossible().value;
@@ -2563,8 +2551,8 @@ var parser = createCommonjsModule(function (module, exports) {
2563
2551
  if (this.isEOF() || this.char() !== 125
2564
2552
  /* `}` */
2565
2553
  ) {
2566
- return this.error(error.ErrorKind.EXPECT_ARGUMENT_CLOSING_BRACE, createLocation(openingBracePosition, this.clonePosition()));
2567
- }
2554
+ return this.error(error.ErrorKind.EXPECT_ARGUMENT_CLOSING_BRACE, createLocation(openingBracePosition, this.clonePosition()));
2555
+ }
2568
2556
 
2569
2557
  this.bump(); // `}`
2570
2558
 
@@ -2774,10 +2762,10 @@ var parser = createCommonjsModule(function (module, exports) {
2774
2762
  && ch <= 57
2775
2763
  /* `9` */
2776
2764
  ) {
2777
- hasDigits = true;
2778
- decimal = decimal * 10 + (ch - 48);
2779
- this.bump();
2780
- } else {
2765
+ hasDigits = true;
2766
+ decimal = decimal * 10 + (ch - 48);
2767
+ this.bump();
2768
+ } else {
2781
2769
  break;
2782
2770
  }
2783
2771
  }
@@ -2861,10 +2849,10 @@ var parser = createCommonjsModule(function (module, exports) {
2861
2849
  if (code === 10
2862
2850
  /* '\n' */
2863
2851
  ) {
2864
- this.position.line += 1;
2865
- this.position.column = 1;
2866
- this.position.offset += 1;
2867
- } else {
2852
+ this.position.line += 1;
2853
+ this.position.column = 1;
2854
+ this.position.offset += 1;
2855
+ } else {
2868
2856
  this.position.column += 1; // 0 ~ 0x10000 -> unicode BMP, otherwise skip the surrogate pair.
2869
2857
 
2870
2858
  this.position.offset += code < 0x10000 ? 1 : 2;
@@ -15179,7 +15167,12 @@ const getMetaProp = function getMetaProp(lang, metadataObj, properties, allowObj
15179
15167
  // Todo: Allow use of dbs and fileGroup together in base directories?
15180
15168
 
15181
15169
  const getMetadata = async (file, property, basePath) => {
15182
- return (await JsonRefs.resolveRefsAt((basePath || getCurrDir()) + file + (property ? '#/' + property : ''), {
15170
+ const url = new URL(basePath || getCurrDir());
15171
+ url.search = ''; // Clear out query string, e.g., `?fbclid` from Facebook
15172
+
15173
+ url.pathname = file;
15174
+ url.hash = property ? '#/' + property : '';
15175
+ return (await JsonRefs.resolveRefsAt(url.toString(), {
15183
15176
  loaderOptions: {
15184
15177
  processContent(res, callback) {
15185
15178
  callback(undefined, JSON.parse(res.text || // `.metadata` not a recognized extension, so
@@ -17966,8 +17959,7 @@ async function workDisplay({
17966
17959
  groupsToWorks
17967
17960
  }) {
17968
17961
  const il = localizeParamNames ? key => l(['params', key]) : key => key;
17969
- const iil = localizeParamNames ? key => l(['params', 'indexed', key]) : key => key; // eslint-disable-next-line unicorn/prefer-prototype-methods -- Convenient
17970
-
17962
+ const iil = localizeParamNames ? key => l(['params', 'indexed', key]) : key => key;
17971
17963
  const localeFromLangData = languages.localeFromLangData.bind(languages);
17972
17964
  const imfLang = IMF({
17973
17965
  locales: lang.map(localeFromLangData),
@@ -18307,6 +18299,8 @@ Object.defineProperty(self$1, '_BIDI_RTL_LANGS', {
18307
18299
  /* 'فارسی', Persian */
18308
18300
  'glk',
18309
18301
  /* 'گیلکی', Gilaki */
18302
+ 'he',
18303
+ /* 'עברית', Hebrew */
18310
18304
  'ku',
18311
18305
  /* 'Kurdî / كوردی', Kurdish */
18312
18306
  'mzn',
@@ -18321,8 +18315,10 @@ Object.defineProperty(self$1, '_BIDI_RTL_LANGS', {
18321
18315
  /* 'سنڌي', Sindhi */
18322
18316
  'ug',
18323
18317
  /* 'Uyghurche / ئۇيغۇرچە', Uyghur */
18324
- 'ur'
18318
+ 'ur',
18325
18319
  /* 'اردو', Urdu */
18320
+ 'yi'
18321
+ /* 'ייִדיש', Yiddish */
18326
18322
  ],
18327
18323
  writable: false,
18328
18324
  enumerable: true,
@@ -18384,8 +18380,8 @@ const setAnchor = ({
18384
18380
  if (i === max || // No more field sets to check
18385
18381
  anchors.length // Already had anchors found
18386
18382
  ) {
18387
- breakout = true;
18388
- }
18383
+ breakout = true;
18384
+ }
18389
18385
 
18390
18386
  break;
18391
18387
  }
@@ -19436,7 +19432,7 @@ async function requestPermissions(langs, l) {
19436
19432
  // rememberRefusal();
19437
19433
  resolve();
19438
19434
  return;
19439
- // eslint-disable-next-line radar/no-duplicated-branches
19435
+ // eslint-disable-next-line sonarjs/no-duplicated-branches
19440
19436
 
19441
19437
  case 'default':
19442
19438
  resolve();
@@ -19900,4 +19896,4 @@ TextBrowser.prototype.workDisplay = workDisplay;
19900
19896
  TextBrowser.prototype.resultsDisplayClient = resultsDisplayClient;
19901
19897
  TextBrowser.prototype.getWorkFiles = getWorkFiles;
19902
19898
 
19903
- export default TextBrowser;
19899
+ export { TextBrowser as default };