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.
package/dist/index-umd.js CHANGED
@@ -2,21 +2,16 @@
2
2
  typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
3
3
  typeof define === 'function' && define.amd ? define(factory) :
4
4
  (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.TextBrowser = factory());
5
- }(this, (function () { 'use strict';
5
+ })(this, (function () { 'use strict';
6
6
 
7
7
  function ownKeys(object, enumerableOnly) {
8
8
  var keys = Object.keys(object);
9
9
 
10
10
  if (Object.getOwnPropertySymbols) {
11
11
  var symbols = Object.getOwnPropertySymbols(object);
12
-
13
- if (enumerableOnly) {
14
- symbols = symbols.filter(function (sym) {
15
- return Object.getOwnPropertyDescriptor(object, sym).enumerable;
16
- });
17
- }
18
-
19
- keys.push.apply(keys, symbols);
12
+ enumerableOnly && (symbols = symbols.filter(function (sym) {
13
+ return Object.getOwnPropertyDescriptor(object, sym).enumerable;
14
+ })), keys.push.apply(keys, symbols);
20
15
  }
21
16
 
22
17
  return keys;
@@ -24,19 +19,12 @@
24
19
 
25
20
  function _objectSpread2(target) {
26
21
  for (var i = 1; i < arguments.length; i++) {
27
- var source = arguments[i] != null ? arguments[i] : {};
28
-
29
- if (i % 2) {
30
- ownKeys(Object(source), true).forEach(function (key) {
31
- _defineProperty(target, key, source[key]);
32
- });
33
- } else if (Object.getOwnPropertyDescriptors) {
34
- Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
35
- } else {
36
- ownKeys(Object(source)).forEach(function (key) {
37
- Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
38
- });
39
- }
22
+ var source = null != arguments[i] ? arguments[i] : {};
23
+ i % 2 ? ownKeys(Object(source), !0).forEach(function (key) {
24
+ _defineProperty(target, key, source[key]);
25
+ }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) {
26
+ Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
27
+ });
40
28
  }
41
29
 
42
30
  return target;
@@ -1491,15 +1479,15 @@
1491
1479
  result.maximumSignificantDigits = g1.length;
1492
1480
  } // @@@+ case
1493
1481
  else if (g2 === '+') {
1494
- result.minimumSignificantDigits = g1.length;
1495
- } // .### case
1496
- else if (g1[0] === '#') {
1497
- result.maximumSignificantDigits = g1.length;
1498
- } // .@@## or .@@@ case
1499
- else {
1500
- result.minimumSignificantDigits = g1.length;
1501
- result.maximumSignificantDigits = g1.length + (typeof g2 === 'string' ? g2.length : 0);
1502
- }
1482
+ result.minimumSignificantDigits = g1.length;
1483
+ } // .### case
1484
+ else if (g1[0] === '#') {
1485
+ result.maximumSignificantDigits = g1.length;
1486
+ } // .@@## or .@@@ case
1487
+ else {
1488
+ result.minimumSignificantDigits = g1.length;
1489
+ result.maximumSignificantDigits = g1.length + (typeof g2 === 'string' ? g2.length : 0);
1490
+ }
1503
1491
 
1504
1492
  return '';
1505
1493
  });
@@ -1739,15 +1727,15 @@
1739
1727
  result.minimumFractionDigits = g1.length;
1740
1728
  } // .### case
1741
1729
  else if (g3 && g3[0] === '#') {
1742
- result.maximumFractionDigits = g3.length;
1743
- } // .00## case
1744
- else if (g4 && g5) {
1745
- result.minimumFractionDigits = g4.length;
1746
- result.maximumFractionDigits = g4.length + g5.length;
1747
- } else {
1748
- result.minimumFractionDigits = g1.length;
1749
- result.maximumFractionDigits = g1.length;
1750
- }
1730
+ result.maximumFractionDigits = g3.length;
1731
+ } // .00## case
1732
+ else if (g4 && g5) {
1733
+ result.minimumFractionDigits = g4.length;
1734
+ result.maximumFractionDigits = g4.length + g5.length;
1735
+ } else {
1736
+ result.minimumFractionDigits = g1.length;
1737
+ result.maximumFractionDigits = g1.length;
1738
+ }
1751
1739
 
1752
1740
  return '';
1753
1741
  });
@@ -1972,14 +1960,14 @@
1972
1960
  if (char === 123
1973
1961
  /* `{` */
1974
1962
  ) {
1975
- var result = this.parseArgument(nestingLevel, expectingCloseTag);
1963
+ var result = this.parseArgument(nestingLevel, expectingCloseTag);
1976
1964
 
1977
- if (result.err) {
1978
- return result;
1979
- }
1965
+ if (result.err) {
1966
+ return result;
1967
+ }
1980
1968
 
1981
- elements.push(result.val);
1982
- } else if (char === 125
1969
+ elements.push(result.val);
1970
+ } else if (char === 125
1983
1971
  /* `}` */
1984
1972
  && nestingLevel > 0) {
1985
1973
  break;
@@ -1996,12 +1984,12 @@
1996
1984
  /* `<` */
1997
1985
  && !this.ignoreTag && this.peek() === 47 // char code for '/'
1998
1986
  ) {
1999
- if (expectingCloseTag) {
2000
- break;
2001
- } else {
2002
- return this.error(error.ErrorKind.UNMATCHED_CLOSING_TAG, createLocation(this.clonePosition(), this.clonePosition()));
2003
- }
2004
- } else if (char === 60
1987
+ if (expectingCloseTag) {
1988
+ break;
1989
+ } else {
1990
+ return this.error(error.ErrorKind.UNMATCHED_CLOSING_TAG, createLocation(this.clonePosition(), this.clonePosition()));
1991
+ }
1992
+ } else if (char === 60
2005
1993
  /* `<` */
2006
1994
  && !this.ignoreTag && _isAlpha(this.peek() || 0)) {
2007
1995
  var result = this.parseTag(nestingLevel, parentArgType);
@@ -2186,8 +2174,8 @@
2186
2174
  if (this.isEOF() || this.char() !== 39
2187
2175
  /* `'` */
2188
2176
  ) {
2189
- return null;
2190
- } // Parse escaped char following the apostrophe, or early return if there is no escaped char.
2177
+ return null;
2178
+ } // Parse escaped char following the apostrophe, or early return if there is no escaped char.
2191
2179
  // Check if is valid escaped character
2192
2180
 
2193
2181
 
@@ -2231,18 +2219,18 @@
2231
2219
  if (ch === 39
2232
2220
  /* `'` */
2233
2221
  ) {
2234
- if (this.peek() === 39
2235
- /* `'` */
2236
- ) {
2237
- codePoints.push(39); // Bump one more time because we need to skip 2 characters.
2222
+ if (this.peek() === 39
2223
+ /* `'` */
2224
+ ) {
2225
+ codePoints.push(39); // Bump one more time because we need to skip 2 characters.
2238
2226
 
2239
- this.bump();
2240
- } else {
2241
- // Optional closing apostrophe.
2242
- this.bump();
2243
- break;
2244
- }
2227
+ this.bump();
2245
2228
  } else {
2229
+ // Optional closing apostrophe.
2230
+ this.bump();
2231
+ break;
2232
+ }
2233
+ } else {
2246
2234
  codePoints.push(ch);
2247
2235
  }
2248
2236
 
@@ -2288,9 +2276,9 @@
2288
2276
  if (this.char() === 125
2289
2277
  /* `}` */
2290
2278
  ) {
2291
- this.bump();
2292
- return this.error(error.ErrorKind.EMPTY_ARGUMENT, createLocation(openingBracePosition, this.clonePosition()));
2293
- } // argument name
2279
+ this.bump();
2280
+ return this.error(error.ErrorKind.EMPTY_ARGUMENT, createLocation(openingBracePosition, this.clonePosition()));
2281
+ } // argument name
2294
2282
 
2295
2283
 
2296
2284
  var value = this.parseIdentifierIfPossible().value;
@@ -2569,8 +2557,8 @@
2569
2557
  if (this.isEOF() || this.char() !== 125
2570
2558
  /* `}` */
2571
2559
  ) {
2572
- return this.error(error.ErrorKind.EXPECT_ARGUMENT_CLOSING_BRACE, createLocation(openingBracePosition, this.clonePosition()));
2573
- }
2560
+ return this.error(error.ErrorKind.EXPECT_ARGUMENT_CLOSING_BRACE, createLocation(openingBracePosition, this.clonePosition()));
2561
+ }
2574
2562
 
2575
2563
  this.bump(); // `}`
2576
2564
 
@@ -2780,10 +2768,10 @@
2780
2768
  && ch <= 57
2781
2769
  /* `9` */
2782
2770
  ) {
2783
- hasDigits = true;
2784
- decimal = decimal * 10 + (ch - 48);
2785
- this.bump();
2786
- } else {
2771
+ hasDigits = true;
2772
+ decimal = decimal * 10 + (ch - 48);
2773
+ this.bump();
2774
+ } else {
2787
2775
  break;
2788
2776
  }
2789
2777
  }
@@ -2867,10 +2855,10 @@
2867
2855
  if (code === 10
2868
2856
  /* '\n' */
2869
2857
  ) {
2870
- this.position.line += 1;
2871
- this.position.column = 1;
2872
- this.position.offset += 1;
2873
- } else {
2858
+ this.position.line += 1;
2859
+ this.position.column = 1;
2860
+ this.position.offset += 1;
2861
+ } else {
2874
2862
  this.position.column += 1; // 0 ~ 0x10000 -> unicode BMP, otherwise skip the surrogate pair.
2875
2863
 
2876
2864
  this.position.offset += code < 0x10000 ? 1 : 2;
@@ -15185,7 +15173,12 @@
15185
15173
  // Todo: Allow use of dbs and fileGroup together in base directories?
15186
15174
 
15187
15175
  const getMetadata = async (file, property, basePath) => {
15188
- return (await JsonRefs.resolveRefsAt((basePath || getCurrDir()) + file + (property ? '#/' + property : ''), {
15176
+ const url = new URL(basePath || getCurrDir());
15177
+ url.search = ''; // Clear out query string, e.g., `?fbclid` from Facebook
15178
+
15179
+ url.pathname = file;
15180
+ url.hash = property ? '#/' + property : '';
15181
+ return (await JsonRefs.resolveRefsAt(url.toString(), {
15189
15182
  loaderOptions: {
15190
15183
  processContent(res, callback) {
15191
15184
  callback(undefined, JSON.parse(res.text || // `.metadata` not a recognized extension, so
@@ -16610,7 +16603,8 @@ Please refresh the page if you wish to reattempt.
16610
16603
  localizeParamNames,
16611
16604
  namespace,
16612
16605
  hideFormattingSection,
16613
- groups
16606
+ groups,
16607
+ preferencesPlugin
16614
16608
  }) => ['div', {
16615
16609
  style: {
16616
16610
  textAlign: 'left'
@@ -16677,73 +16671,16 @@ Please refresh the page if you wish to reattempt.
16677
16671
  }
16678
16672
 
16679
16673
  return ['option', atts, [imfl(['languages', lan.code])]];
16680
- })]]], ['div', [['button', {
16681
- title: l('bookmark_generation_tooltip'),
16682
- $on: {
16683
- async click() {
16684
- // Todo: Give option to edit (keywords and work URLs)
16685
- const date = Date.now();
16686
- const ADD_DATE = date;
16687
- const LAST_MODIFIED = date;
16688
- const blob = new Blob([new XMLSerializer().serializeToString(jml({
16689
- $document: {
16690
- $DOCTYPE: {
16691
- name: 'NETSCAPE-Bookmark-file-1'
16692
- },
16693
- title: l('Bookmarks'),
16694
- body: [['h1', [l('Bookmarks_Menu')]], ...(await getFieldAliasOrNames()).flatMap(({
16695
- groupName,
16696
- worksToFields
16697
- }) => {
16698
- return [['dt', [['h3', {
16699
- ADD_DATE,
16700
- LAST_MODIFIED
16701
- }, [groupName]]]], ['dl', [['p'], ...worksToFields.map(({
16702
- fieldAliasOrNames,
16703
- workName,
16704
- shortcut: SHORTCUTURL
16705
- }) => {
16706
- // Todo (low): Add anchor, etc. (until handled by `work-startEnd`); &aqdas-anchor1-1=2&anchorfield1=Paragraph
16707
- // Todo: option for additional browse field groups (startEnd2, etc.)
16708
- // Todo: For link text, use `heading` or `alias` from metadata files in place of workName (requires loading all metadata files though)
16709
- // 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/
16710
- const paramsCopy = paramsSetter(_objectSpread2(_objectSpread2({}, getDataForSerializingParamsAsURL()), {}, {
16711
- fieldAliasOrNames,
16712
- workName: work,
16713
- // Delete work of current page
16714
- type: 'shortcutResult'
16715
- }));
16716
- const url = replaceHash(paramsCopy) + `&work=${workName}&${workName}-startEnd1=%s`; // %s will be escaped if set as param; also add changeable workName here
16717
-
16718
- return ['dt', [['a', {
16719
- href: url,
16720
- ADD_DATE,
16721
- LAST_MODIFIED,
16722
- SHORTCUTURL
16723
- }, [workName]]]];
16724
- })]]];
16725
- })]
16726
- }
16727
- })).replace( // Chrome has a quirk that requires this (and not
16728
- // just any whitespace)
16729
- // We're not getting the keywords with Chrome,
16730
- // but at least usable for bookmarks (though
16731
- // not the groups apparently)
16732
- /<dt>/g, '\n<dt>')], {
16733
- type: 'text/html'
16734
- });
16735
- const url = window.URL.createObjectURL(blob);
16736
- const a = jml('a', {
16737
- hidden: true,
16738
- download: 'bookmarks.html',
16739
- href: url
16740
- }, $$1('#main'));
16741
- a.click();
16742
- URL.revokeObjectURL(url);
16743
- }
16744
-
16745
- }
16746
- }, [l('Generate_bookmarks')]]]]]],
16674
+ })]]], preferencesPlugin ? preferencesPlugin({
16675
+ $: $$1,
16676
+ l,
16677
+ jml,
16678
+ paramsSetter,
16679
+ getDataForSerializingParamsAsURL,
16680
+ work,
16681
+ replaceHash,
16682
+ getFieldAliasOrNames
16683
+ }) : '']],
16747
16684
 
16748
16685
  addBrowseFields({
16749
16686
  browseFields,
@@ -16895,7 +16832,8 @@ Please refresh the page if you wish to reattempt.
16895
16832
  preferredLocale,
16896
16833
  schemaItems,
16897
16834
  content,
16898
- groups
16835
+ groups,
16836
+ preferencesPlugin
16899
16837
  }) {
16900
16838
  const work = $p.get('work');
16901
16839
 
@@ -16946,7 +16884,8 @@ Please refresh the page if you wish to reattempt.
16946
16884
  localizeParamNames,
16947
16885
  namespace,
16948
16886
  groups,
16949
- hideFormattingSection
16887
+ hideFormattingSection,
16888
+ preferencesPlugin
16950
16889
  })]], ['h2', [heading]], ['br'], ['form', {
16951
16890
  id: 'browse',
16952
16891
  $custom: {
@@ -17953,6 +17892,9 @@ body {
17953
17892
  fallbackLanguages,
17954
17893
  $p
17955
17894
  }) {
17895
+ const {
17896
+ preferencesPlugin
17897
+ } = this;
17956
17898
  const langs = this.langData.languages;
17957
17899
  const fallbackDirection = this.getDirectionForLanguageCode(fallbackLanguages[0]);
17958
17900
  const prefI18n = localStorage.getItem(this.namespace + '-localizeParamNames');
@@ -17972,8 +17914,7 @@ body {
17972
17914
  groupsToWorks
17973
17915
  }) {
17974
17916
  const il = localizeParamNames ? key => l(['params', key]) : key => key;
17975
- const iil = localizeParamNames ? key => l(['params', 'indexed', key]) : key => key; // eslint-disable-next-line unicorn/prefer-prototype-methods -- Convenient
17976
-
17917
+ const iil = localizeParamNames ? key => l(['params', 'indexed', key]) : key => key;
17977
17918
  const localeFromLangData = languages.localeFromLangData.bind(languages);
17978
17919
  const imfLang = IMF({
17979
17920
  locales: lang.map(localeFromLangData),
@@ -18120,7 +18061,8 @@ body {
18120
18061
  fieldMatchesLocale,
18121
18062
  preferredLocale,
18122
18063
  schemaItems,
18123
- content
18064
+ content,
18065
+ preferencesPlugin
18124
18066
  });
18125
18067
  }
18126
18068
 
@@ -18313,6 +18255,8 @@ body {
18313
18255
  /* 'فارسی', Persian */
18314
18256
  'glk',
18315
18257
  /* 'گیلکی', Gilaki */
18258
+ 'he',
18259
+ /* 'עברית', Hebrew */
18316
18260
  'ku',
18317
18261
  /* 'Kurdî / كوردی', Kurdish */
18318
18262
  'mzn',
@@ -18327,8 +18271,10 @@ body {
18327
18271
  /* 'سنڌي', Sindhi */
18328
18272
  'ug',
18329
18273
  /* 'Uyghurche / ئۇيغۇرچە', Uyghur */
18330
- 'ur'
18274
+ 'ur',
18331
18275
  /* 'اردو', Urdu */
18276
+ 'yi'
18277
+ /* 'ייִדיש', Yiddish */
18332
18278
  ],
18333
18279
  writable: false,
18334
18280
  enumerable: true,
@@ -18390,8 +18336,8 @@ body {
18390
18336
  if (i === max || // No more field sets to check
18391
18337
  anchors.length // Already had anchors found
18392
18338
  ) {
18393
- breakout = true;
18394
- }
18339
+ breakout = true;
18340
+ }
18395
18341
 
18396
18342
  break;
18397
18343
  }
@@ -19442,7 +19388,7 @@ body {
19442
19388
  // rememberRefusal();
19443
19389
  resolve();
19444
19390
  return;
19445
- // eslint-disable-next-line radar/no-duplicated-branches
19391
+ // eslint-disable-next-line sonarjs/no-duplicated-branches
19446
19392
 
19447
19393
  case 'default':
19448
19394
  resolve();
@@ -19498,6 +19444,7 @@ body {
19498
19444
  this.requestPersistentStorage = options.requestPersistentStorage;
19499
19445
  this.localizeParamNames = options.localizeParamNames === undefined ? true : options.localizeParamNames;
19500
19446
  this.hideFormattingSection = Boolean(options.hideFormattingSection);
19447
+ this.preferencesPlugin = options.preferencesPlugin;
19501
19448
  this.interlinearSeparator = options.interlinearSeparator; // Todo: Make these user facing options
19502
19449
 
19503
19450
  this.showEmptyInterlinear = options.showEmptyInterlinear;
@@ -19869,7 +19816,8 @@ body {
19869
19816
  fallbackLanguages,
19870
19817
  languageParam,
19871
19818
  $p,
19872
- languages
19819
+ languages,
19820
+ preferencesPlugin: this.preferencesPlugin
19873
19821
  });
19874
19822
  return true;
19875
19823
  }
@@ -19908,4 +19856,4 @@ body {
19908
19856
 
19909
19857
  return TextBrowser;
19910
19858
 
19911
- })));
19859
+ }));