textbrowser 0.47.0 → 0.48.0
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/.eslintignore +2 -1
- package/CHANGES.md +4 -0
- package/dist/WorkInfo-es.js +6 -1
- package/dist/activateCallback-es.js +4 -0
- package/dist/assets/index-c987c995.css +9 -0
- package/dist/assets/languages-fcf1c836.json +67 -0
- package/dist/index-es.js +26 -30
- package/dist/index-es.min.js +1 -1
- package/dist/sw-helper.js +310 -0
- package/package.json +15 -14
- package/resources/activateCallback.js +4 -0
- package/resources/index.js +2 -10
- package/resources/resultsDisplay.js +5 -1
- package/resources/utils/IntlURLSearchParams.js +3 -0
- package/resources/utils/Languages.js +3 -0
- package/resources/utils/ServiceWorker.js +14 -3
- package/resources/utils/WorkInfo.js +6 -1
- package/resources/utils/getLocaleFallbackResults.js +3 -0
- package/server/main.js +0 -1
- package/sw-sample.js +5 -307
package/.eslintignore
CHANGED
package/CHANGES.md
CHANGED
package/dist/WorkInfo-es.js
CHANGED
|
@@ -2841,7 +2841,12 @@ class PluginsForWork {
|
|
|
2841
2841
|
}
|
|
2842
2842
|
}
|
|
2843
2843
|
|
|
2844
|
-
|
|
2844
|
+
/**
|
|
2845
|
+
* Imported by the `dist/sw-helper.js`
|
|
2846
|
+
* @param {string} files The files.json file path
|
|
2847
|
+
* @returns {PlainObject}
|
|
2848
|
+
*/
|
|
2849
|
+
const getWorkFiles = async function getWorkFiles (files) {
|
|
2845
2850
|
const filesObj = await getJSON(files);
|
|
2846
2851
|
const dataFiles = [];
|
|
2847
2852
|
filesObj.groups.forEach((fileGroup) => {
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
{
|
|
2
|
+
"localeFileBasePath": "node_modules/textbrowser/locales/",
|
|
3
|
+
"localization-strings": {
|
|
4
|
+
"en-US": {
|
|
5
|
+
"chooselanguage": "Your interface language",
|
|
6
|
+
"all-langs": "All languages",
|
|
7
|
+
"languages": {
|
|
8
|
+
"en-US": "English",
|
|
9
|
+
"ar": "Arabic",
|
|
10
|
+
"fa": "Persian",
|
|
11
|
+
"ru": "Russian"
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
"fa": {
|
|
15
|
+
"chooselanguage": "زبان انتخاب شده",
|
|
16
|
+
"all-langs": "All languages",
|
|
17
|
+
"languages": {
|
|
18
|
+
"en-US": "English",
|
|
19
|
+
"ar": "Arabic",
|
|
20
|
+
"fa": "فارسي",
|
|
21
|
+
"ru": "Russian"
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
"ar": {
|
|
25
|
+
"chooselanguage": "لغتك",
|
|
26
|
+
"all-langs": "All languages",
|
|
27
|
+
"languages": {
|
|
28
|
+
"en-US": "English",
|
|
29
|
+
"ar": "عربي",
|
|
30
|
+
"fa": "Persian",
|
|
31
|
+
"ru": "Russian"
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
"ru": {
|
|
35
|
+
"chooselanguage": "Your interface language",
|
|
36
|
+
"all-langs": "Все языки",
|
|
37
|
+
"languages": {
|
|
38
|
+
"en-US": "Английский",
|
|
39
|
+
"ar": "Arabic",
|
|
40
|
+
"fa": "Persian",
|
|
41
|
+
"ru": "русский"
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
},
|
|
45
|
+
"languages": [
|
|
46
|
+
{
|
|
47
|
+
"code": "en-US",
|
|
48
|
+
"direction": "ltr",
|
|
49
|
+
"locale": {"$ref": "../locales/en-US.json"}
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
"code": "fa",
|
|
53
|
+
"direction": "rtl",
|
|
54
|
+
"locale": {"$ref": "../locales/fa.json"}
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
"code": "ar",
|
|
58
|
+
"direction": "rtl",
|
|
59
|
+
"locale": {"$ref": "../locales/ar.json"}
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
"code": "ru",
|
|
63
|
+
"direction": "ltr",
|
|
64
|
+
"locale": {"$ref": "../locales/ru.json"}
|
|
65
|
+
}
|
|
66
|
+
]
|
|
67
|
+
}
|
package/dist/index-es.js
CHANGED
|
@@ -3143,6 +3143,9 @@ function deserialize(form, hash) {
|
|
|
3143
3143
|
});
|
|
3144
3144
|
}
|
|
3145
3145
|
|
|
3146
|
+
/**
|
|
3147
|
+
* @file Note that this should be kept as a polyglot client-server file.
|
|
3148
|
+
*/
|
|
3146
3149
|
async function getLocaleFallbackResults({
|
|
3147
3150
|
$p,
|
|
3148
3151
|
lang,
|
|
@@ -5073,6 +5076,10 @@ const getPreferredLanguages = ({
|
|
|
5073
5076
|
});
|
|
5074
5077
|
return langArr;
|
|
5075
5078
|
};
|
|
5079
|
+
|
|
5080
|
+
/**
|
|
5081
|
+
* @classdesc Note that this should be kept as a polyglot client-server class.
|
|
5082
|
+
*/
|
|
5076
5083
|
class Languages {
|
|
5077
5084
|
constructor({
|
|
5078
5085
|
langData
|
|
@@ -13369,22 +13376,6 @@ class PluginsForWork {
|
|
|
13369
13376
|
}
|
|
13370
13377
|
}
|
|
13371
13378
|
|
|
13372
|
-
const getWorkFiles = async function getWorkFiles(files = this.files) {
|
|
13373
|
-
const filesObj = await getJSON(files);
|
|
13374
|
-
const dataFiles = [];
|
|
13375
|
-
filesObj.groups.forEach(fileGroup => {
|
|
13376
|
-
fileGroup.files.forEach(fileData => {
|
|
13377
|
-
const {
|
|
13378
|
-
file,
|
|
13379
|
-
schemaFile,
|
|
13380
|
-
metadataFile
|
|
13381
|
-
} = getFilePaths(filesObj, fileGroup, fileData);
|
|
13382
|
-
dataFiles.push(file, schemaFile, metadataFile);
|
|
13383
|
-
});
|
|
13384
|
-
});
|
|
13385
|
-
dataFiles.push(...Object.values(filesObj.plugins).map(pl => pl.path));
|
|
13386
|
-
return dataFiles;
|
|
13387
|
-
};
|
|
13388
13379
|
const getFilePaths = function getFilePaths(filesObj, fileGroup, fileData) {
|
|
13389
13380
|
const baseDir = (filesObj.baseDirectory || '') + (fileGroup.baseDirectory || '') + '/';
|
|
13390
13381
|
const schemaBaseDir = (filesObj.schemaBaseDirectory || '') + (fileGroup.schemaBaseDirectory || '') + '/';
|
|
@@ -13636,11 +13627,22 @@ const getWorkData = async function ({
|
|
|
13636
13627
|
};
|
|
13637
13628
|
|
|
13638
13629
|
/* globals console, location, URL */
|
|
13630
|
+
|
|
13631
|
+
/**
|
|
13632
|
+
* Note that this function be kept as a polyglot client-server file.
|
|
13633
|
+
* @param {PlainObject} target
|
|
13634
|
+
* @param {PlainObject} source
|
|
13635
|
+
* @returns {{
|
|
13636
|
+
* userJSON: string,
|
|
13637
|
+
* languages: string,
|
|
13638
|
+
* serviceWorkerPath: string,
|
|
13639
|
+
* files: string,
|
|
13640
|
+
* namespace: string
|
|
13641
|
+
* }}
|
|
13642
|
+
*/
|
|
13639
13643
|
const setServiceWorkerDefaults = (target, source) => {
|
|
13640
13644
|
target.userJSON = source.userJSON || 'resources/user.json';
|
|
13641
|
-
target.languages = source.languages || new URL('
|
|
13642
|
-
// Todo: Substitute with `import.meta.url`
|
|
13643
|
-
new URL('node_modules/textbrowser/resources/index.js', location)).href;
|
|
13645
|
+
target.languages = source.languages || new URL(new URL('assets/languages-fcf1c836.json', import.meta.url).href, import.meta.url).href;
|
|
13644
13646
|
target.serviceWorkerPath = source.serviceWorkerPath || `sw.js?pathToUserJSON=${encodeURIComponent(target.userJSON)}&stylesheets=${encodeURIComponent(JSON.stringify(target.stylesheets || []))}`;
|
|
13645
13647
|
target.files = source.files || 'files.json';
|
|
13646
13648
|
target.namespace = source.namespace || 'textbrowser';
|
|
@@ -15397,6 +15399,9 @@ const Templates = {
|
|
|
15397
15399
|
}
|
|
15398
15400
|
};
|
|
15399
15401
|
|
|
15402
|
+
/**
|
|
15403
|
+
* @file Note that this should be kept as a polyglot client-server file.
|
|
15404
|
+
*/
|
|
15400
15405
|
/**
|
|
15401
15406
|
*
|
|
15402
15407
|
* @param {string} param
|
|
@@ -16034,8 +16039,6 @@ var rtlDetect_1 = {
|
|
|
16034
16039
|
getLangDir: rtlDetect.getLangDir
|
|
16035
16040
|
};
|
|
16036
16041
|
|
|
16037
|
-
// Keep this as the last import for Rollup
|
|
16038
|
-
|
|
16039
16042
|
const {
|
|
16040
16043
|
getLangDir
|
|
16041
16044
|
} = rtlDetect_1;
|
|
@@ -17080,15 +17083,11 @@ async function requestPermissions(langs, l) {
|
|
|
17080
17083
|
}
|
|
17081
17084
|
class TextBrowser {
|
|
17082
17085
|
constructor(options) {
|
|
17083
|
-
// Todo: Replace the `languages` default with `import.meta.url`
|
|
17084
|
-
// (`new URL('../appdata/languages.json', import.meta.url).href`?)
|
|
17085
|
-
// https://github.com/tc39/proposal-import-meta
|
|
17086
|
-
const moduleURL = new URL('node_modules/textbrowser/resources/index.js', location);
|
|
17087
17086
|
this.site = options.site || 'site.json';
|
|
17088
17087
|
const stylesheets = options.stylesheets || ['@builtin'];
|
|
17089
17088
|
const builtinIndex = stylesheets.indexOf('@builtin');
|
|
17090
17089
|
if (builtinIndex !== -1) {
|
|
17091
|
-
stylesheets.splice(builtinIndex, 1, new URL('index.css',
|
|
17090
|
+
stylesheets.splice(builtinIndex, 1, new URL(new URL('assets/index-c987c995.css', import.meta.url).href, import.meta.url).href);
|
|
17092
17091
|
}
|
|
17093
17092
|
this.stylesheets = stylesheets;
|
|
17094
17093
|
setServiceWorkerDefaults(this, options);
|
|
@@ -17108,9 +17107,7 @@ class TextBrowser {
|
|
|
17108
17107
|
}
|
|
17109
17108
|
async init() {
|
|
17110
17109
|
this._stylesheetElements = await loadStylesheets(this.stylesheets);
|
|
17111
|
-
|
|
17112
|
-
}
|
|
17113
|
-
async displayLanguages() {
|
|
17110
|
+
|
|
17114
17111
|
// We use getJSON instead of JsonRefs as we do not need to resolve the locales here
|
|
17115
17112
|
try {
|
|
17116
17113
|
const [langData, siteData] = await getJSON([this.languages, this.site]);
|
|
@@ -17497,6 +17494,5 @@ class TextBrowser {
|
|
|
17497
17494
|
// Todo: Definable as public fields?
|
|
17498
17495
|
TextBrowser.prototype.workDisplay = workDisplay;
|
|
17499
17496
|
TextBrowser.prototype.resultsDisplayClient = resultsDisplayClient;
|
|
17500
|
-
TextBrowser.prototype.getWorkFiles = getWorkFiles;
|
|
17501
17497
|
|
|
17502
17498
|
export { TextBrowser as default };
|