textbrowser 0.41.2 → 0.42.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/.eslintignore +0 -1
- package/{.eslintrc.js → .eslintrc.cjs} +0 -0
- package/CHANGES.md +15 -0
- package/README.md +23 -19
- package/dist/WorkInfo-es.js +26 -95
- package/dist/index-es.js +233 -1276
- package/dist/index-es.min.js +3 -3
- package/dist/index-umd.js +8 -1003
- package/dist/index-umd.min.js +3 -3
- package/package.json +35 -35
- package/resources/index.js +1 -2
- package/resources/resultsDisplay.js +3 -2
- package/resources/utils/Metadata.js +1 -1
- package/resources/utils/WorkInfo.js +0 -22
- package/resources/utils/dialogs.js +0 -4
- package/server/main.js +14 -12
- package/sw-sample.js +0 -2
- package/server/main-cjs.js +0 -4052
package/.eslintignore
CHANGED
|
File without changes
|
package/CHANGES.md
CHANGED
|
@@ -1,5 +1,20 @@
|
|
|
1
1
|
# textbrowser CHANGES
|
|
2
2
|
|
|
3
|
+
## 0.42.2
|
|
4
|
+
|
|
5
|
+
- fix: server import path fix
|
|
6
|
+
|
|
7
|
+
## 0.42.1
|
|
8
|
+
|
|
9
|
+
- fix: tweak for Node `import()` path
|
|
10
|
+
- fix: rollup issues with `import()`
|
|
11
|
+
|
|
12
|
+
## 0.42.0
|
|
13
|
+
|
|
14
|
+
- BREAKING CHANGE: refactor: Native ESM (plugins must be ESM also)
|
|
15
|
+
- chore: removes babel/register, `url-search-params-polyfill` and dialog-polyfill
|
|
16
|
+
- chore: bumps @babel/core (patch) and `simple-get-json` (minor), pins rtl-detect
|
|
17
|
+
|
|
3
18
|
## 0.41.2
|
|
4
19
|
|
|
5
20
|
- fix: fix dialog polyfill CSS link
|
package/README.md
CHANGED
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
# TextBrowser
|
|
2
2
|
|
|
3
3
|
*Please note that this project, while now preliminarily functional,
|
|
4
|
-
is in its early stages.
|
|
5
|
-
with
|
|
4
|
+
is in its early stages. It is currently unstyled, Chromium-only, and
|
|
5
|
+
potentially intimidating to those unfamiliar with how to work it. There are
|
|
6
|
+
also some bugs to iron out such as with localization.*
|
|
7
|
+
|
|
8
|
+
See the [web app within an app using TextBrowser](https://bahai-browser.org/)
|
|
9
|
+
or see some videos [introducing the app](https://bahai-library.com/zamir_textbrowser_bahaiwritings_browser).
|
|
6
10
|
|
|
7
11
|
*TextBrowser* supports power-user browsing of arbitrary multi-linear
|
|
8
12
|
texts following the "offline first" motto.
|
|
@@ -172,15 +176,15 @@ project.
|
|
|
172
176
|
|
|
173
177
|
Projects derivative to *TextBrowser* will need to adhere to the following:
|
|
174
178
|
|
|
175
|
-
1. Add the *TextBrowser* dependency per the [Installation](#
|
|
179
|
+
1. Add the *TextBrowser* dependency per the [Installation](#installation)
|
|
176
180
|
section.
|
|
177
181
|
|
|
178
182
|
1. Prepare JSON data files, JSON Schema files, and JSON meta-data files
|
|
179
183
|
to represent your texts. See the section
|
|
180
|
-
[JSON Formats](#
|
|
184
|
+
[JSON Formats](#json-formats).
|
|
181
185
|
To provide a common naming mechanism across projects and to avoid
|
|
182
186
|
the need to tweak the default `TextBrowser` JavaScript class set-up, a
|
|
183
|
-
[specific directory structure](#
|
|
187
|
+
[specific directory structure](#recommended-project-directory-structure)
|
|
184
188
|
is recommended for hosting these files.
|
|
185
189
|
|
|
186
190
|
1. Prepare JSON files to indicate the specific grouping of files you wish
|
|
@@ -188,13 +192,13 @@ Projects derivative to *TextBrowser* will need to adhere to the following:
|
|
|
188
192
|
make available (and for which you have locales), and after it may be
|
|
189
193
|
ready, and if you wish, the JSON files to indicate your site hierarchy.
|
|
190
194
|
See the
|
|
191
|
-
[recommended directory structure](#
|
|
195
|
+
[recommended directory structure](#recommended-project-directory-structure)
|
|
192
196
|
section for more.
|
|
193
197
|
|
|
194
198
|
1. Create an HTML page (see `index-sample.html` for an example) which includes
|
|
195
199
|
*TextBrowser*'s own project scripts and your own script to instantiate
|
|
196
200
|
the `TextBrowser` class (and if you did not follow the
|
|
197
|
-
[recommended directory structure](#
|
|
201
|
+
[recommended directory structure](#recommended-project-directory-structure),
|
|
198
202
|
you will need to point to the above-mentioned JSON
|
|
199
203
|
files). Page titles are set dynamically for each page, so there is no
|
|
200
204
|
need to provide a `<title>`.
|
|
@@ -225,9 +229,9 @@ The recommended project directory structure (which are used by default by the
|
|
|
225
229
|
service worker
|
|
226
230
|
- ***plugins/*** - While *not yet in use*, this is the convention we wish
|
|
227
231
|
to begin enforcing for hosting plugins (e.g., for automated columns).
|
|
228
|
-
See [Plugin Format](#
|
|
232
|
+
See [Plugin Format](#plugin-format).
|
|
229
233
|
- ***sw.js*** - Although you can change the name of this file via
|
|
230
|
-
`serviceWorkerPath` (see [JavaScript API](#
|
|
234
|
+
`serviceWorkerPath` (see [JavaScript API](#javascript-api)), this
|
|
231
235
|
file should be at or higher than the files you are caching (including
|
|
232
236
|
*TextBrowser*'s). Copying `sw-sample.js` as `sw.js` at your project
|
|
233
237
|
root is the recommended approach.
|
|
@@ -236,18 +240,18 @@ The recommended project directory structure (which are used by default by the
|
|
|
236
240
|
file group, and within each file group, have the JSON data files
|
|
237
241
|
as well as "schema" and "metadata" subdirectories containing the
|
|
238
242
|
specific JSON schemas for each data file and the
|
|
239
|
-
*TextBrowser*-specific meta-data files. See [JSON Formats](#
|
|
240
|
-
- ***files.json*** - See [JSON Formats](#
|
|
241
|
-
- ***site.json*** - See [JSON Formats](#
|
|
243
|
+
*TextBrowser*-specific meta-data files. See [JSON Formats](#json-formats).
|
|
244
|
+
- ***files.json*** - See [JSON Formats](#json-formats).
|
|
245
|
+
- ***site.json*** - See [JSON Formats](#json-formats).
|
|
242
246
|
- ***locales/*** - Only needed if providing an alternate to *TextBrowser*'s
|
|
243
247
|
own built-in `locales/`. It is recommended to rely on the default
|
|
244
248
|
files and not add any custom files (contributing back here any
|
|
245
249
|
localization fixes or additions you may have done!). See
|
|
246
|
-
[JSON Formats](#
|
|
250
|
+
[JSON Formats](#json-formats).
|
|
247
251
|
- ***languages.json*** - As with `locales/`, only needed if providing an
|
|
248
252
|
alternate to *TextBrowser*'s own built-in `appdata/languages.json` file.
|
|
249
253
|
It is recommended to rely on the default and not add any custom file. See
|
|
250
|
-
[JSON Formats](#
|
|
254
|
+
[JSON Formats](#json-formats).
|
|
251
255
|
|
|
252
256
|
## JSON Formats
|
|
253
257
|
|
|
@@ -280,9 +284,9 @@ and its simple
|
|
|
280
284
|
to which they adhere):
|
|
281
285
|
|
|
282
286
|
1. A `schema` JSON reference pointer to your data's JSON schema.
|
|
283
|
-
See [JSON Schema](#
|
|
287
|
+
See [JSON Schema](#json-schema).
|
|
284
288
|
2. A `metadata` JSON reference pointer to your data's JSON metadata.
|
|
285
|
-
See [JSON Metadata](#
|
|
289
|
+
See [JSON Metadata](#json-metadata).
|
|
286
290
|
3. A `data` property which is an an array of arrays containing your tabular
|
|
287
291
|
text itself. This property must adhere to the specific JSON schema
|
|
288
292
|
referenced in the `schema` property above for this file.
|
|
@@ -433,7 +437,7 @@ Its keys are plug-in names and whose value objects have the required property
|
|
|
433
437
|
code string. There may also be a `meta` key which is used to pass data to the
|
|
434
438
|
plug-in. This object currently only allows string keys.
|
|
435
439
|
|
|
436
|
-
See [Plugin Format](#
|
|
440
|
+
See [Plugin Format](#plugin-format) for the structure of the plug-in pointed
|
|
437
441
|
to by the path.
|
|
438
442
|
|
|
439
443
|
The `plugin-field-mapping` object property has keys which act as groups and
|
|
@@ -458,7 +462,7 @@ changes you may need of the generic localizations within `locales/` and
|
|
|
458
462
|
`appdata/languages.json`, if you need to provide your own interface
|
|
459
463
|
localization, you may supply a `languages` property when creating the
|
|
460
464
|
`TextBrowser` object to point to a languages JSON file of your own
|
|
461
|
-
choosing (see the [JavaScript API](#
|
|
465
|
+
choosing (see the [JavaScript API](#javascript-api)).
|
|
462
466
|
|
|
463
467
|
*TextBrowser* comes with the `languages.json` file at
|
|
464
468
|
[`appdata/languages.json`](https://github.com/brettz9/textbrowser/blob/master/appdata/languages.json) which, as mentioned, is used by default. It adheres to
|
|
@@ -725,7 +729,7 @@ The properties are:
|
|
|
725
729
|
- `userStaticFiles` - Array of files additional to those of
|
|
726
730
|
*TextBrowser* which you will need offline. Defaults to the minimum
|
|
727
731
|
recommended files:
|
|
728
|
-
`['/', 'index.html', 'files.json', 'site.json', 'resources/user.js'
|
|
732
|
+
`['/', 'index.html', 'files.json', 'site.json', 'resources/user.js']`
|
|
729
733
|
|
|
730
734
|
## Server API
|
|
731
735
|
|
package/dist/WorkInfo-es.js
CHANGED
|
@@ -1,55 +1,3 @@
|
|
|
1
|
-
function _getRequireWildcardCache$1() {
|
|
2
|
-
if (typeof WeakMap !== "function") return null;
|
|
3
|
-
var cache = new WeakMap();
|
|
4
|
-
|
|
5
|
-
_getRequireWildcardCache$1 = function () {
|
|
6
|
-
return cache;
|
|
7
|
-
};
|
|
8
|
-
|
|
9
|
-
return cache;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
function _interopRequireWildcard$1(obj) {
|
|
13
|
-
if (obj && obj.__esModule) {
|
|
14
|
-
return obj;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
|
|
18
|
-
return {
|
|
19
|
-
default: obj
|
|
20
|
-
};
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
var cache = _getRequireWildcardCache$1();
|
|
24
|
-
|
|
25
|
-
if (cache && cache.has(obj)) {
|
|
26
|
-
return cache.get(obj);
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
var newObj = {};
|
|
30
|
-
var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
|
|
31
|
-
|
|
32
|
-
for (var key in obj) {
|
|
33
|
-
if (Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
34
|
-
var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
|
|
35
|
-
|
|
36
|
-
if (desc && (desc.get || desc.set)) {
|
|
37
|
-
Object.defineProperty(newObj, key, desc);
|
|
38
|
-
} else {
|
|
39
|
-
newObj[key] = obj[key];
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
newObj.default = obj;
|
|
45
|
-
|
|
46
|
-
if (cache) {
|
|
47
|
-
cache.set(obj, newObj);
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
return newObj;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
1
|
/* eslint-disable node/no-unsupported-features/es-syntax */
|
|
54
2
|
|
|
55
3
|
/**
|
|
@@ -65,7 +13,7 @@ function _interopRequireWildcard$1(obj) {
|
|
|
65
13
|
* @param {fetch} cfg.fetch
|
|
66
14
|
* @returns {getJSONCallback}
|
|
67
15
|
*/
|
|
68
|
-
function _await$
|
|
16
|
+
function _await$2$1(value, then, direct) {
|
|
69
17
|
if (direct) {
|
|
70
18
|
return then ? then(value) : value;
|
|
71
19
|
}
|
|
@@ -77,7 +25,7 @@ function _await$3(value, then, direct) {
|
|
|
77
25
|
return then ? value.then(then) : value;
|
|
78
26
|
}
|
|
79
27
|
|
|
80
|
-
function _invoke$
|
|
28
|
+
function _invoke$1$1(body, then) {
|
|
81
29
|
var result = body();
|
|
82
30
|
|
|
83
31
|
if (result && result.then) {
|
|
@@ -124,10 +72,10 @@ function buildGetJSONWithFetch$1({
|
|
|
124
72
|
return function getJSON(jsonURL, cb, errBack) {
|
|
125
73
|
try {
|
|
126
74
|
let _exit = false;
|
|
127
|
-
return _catch$1(function () {
|
|
128
|
-
return _invoke$
|
|
75
|
+
return _await$2$1(_catch$1(function () {
|
|
76
|
+
return _invoke$1$1(function () {
|
|
129
77
|
if (Array.isArray(jsonURL)) {
|
|
130
|
-
return _await$
|
|
78
|
+
return _await$2$1(Promise.all(jsonURL.map(url => {
|
|
131
79
|
return getJSON(url);
|
|
132
80
|
})), function (arrResult) {
|
|
133
81
|
if (cb) {
|
|
@@ -140,8 +88,8 @@ function buildGetJSONWithFetch$1({
|
|
|
140
88
|
});
|
|
141
89
|
}
|
|
142
90
|
}, function (_result) {
|
|
143
|
-
return _exit ? _result : _await$
|
|
144
|
-
return _await$
|
|
91
|
+
return _exit ? _result : _await$2$1(fetch(jsonURL), function (resp) {
|
|
92
|
+
return _await$2$1(resp.json(), function (result) {
|
|
145
93
|
return typeof cb === 'function' // eslint-disable-next-line promise/prefer-await-to-callbacks
|
|
146
94
|
? cb(result) : result; // https://github.com/bcoe/c8/issues/135
|
|
147
95
|
|
|
@@ -159,7 +107,7 @@ function buildGetJSONWithFetch$1({
|
|
|
159
107
|
throw e; // https://github.com/bcoe/c8/issues/135
|
|
160
108
|
|
|
161
109
|
/* c8 ignore next */
|
|
162
|
-
});
|
|
110
|
+
}));
|
|
163
111
|
/* c8 ignore next */
|
|
164
112
|
} catch (e) {
|
|
165
113
|
return Promise.reject(e);
|
|
@@ -203,7 +151,7 @@ function _invokeIgnored$1(body) {
|
|
|
203
151
|
}
|
|
204
152
|
}
|
|
205
153
|
|
|
206
|
-
function _async$
|
|
154
|
+
function _async$1$1(f) {
|
|
207
155
|
return function () {
|
|
208
156
|
for (var args = [], i = 0; i < arguments.length; i++) {
|
|
209
157
|
args[i] = arguments[i];
|
|
@@ -217,10 +165,10 @@ function _async$2(f) {
|
|
|
217
165
|
};
|
|
218
166
|
}
|
|
219
167
|
|
|
220
|
-
const setDirname$1 = _async$
|
|
168
|
+
const setDirname$1 = _async$1$1(function () {
|
|
221
169
|
return _invokeIgnored$1(function () {
|
|
222
170
|
if (!dirname$1) {
|
|
223
|
-
return _await$1$1(
|
|
171
|
+
return _await$1$1(import('path'), function (_import) {
|
|
224
172
|
({
|
|
225
173
|
dirname: dirname$1
|
|
226
174
|
} = _import);
|
|
@@ -253,7 +201,9 @@ function getDirectoryForURL$1(url) {
|
|
|
253
201
|
return fixWindowsPath$1(dirname$1(new URL(url).pathname));
|
|
254
202
|
}
|
|
255
203
|
|
|
256
|
-
|
|
204
|
+
/* eslint-disable node/no-unsupported-features/es-syntax */
|
|
205
|
+
|
|
206
|
+
function _await$3(value, then, direct) {
|
|
257
207
|
if (direct) {
|
|
258
208
|
return then ? then(value) : value;
|
|
259
209
|
}
|
|
@@ -273,7 +223,7 @@ let nodeFetch$1;
|
|
|
273
223
|
* @returns {getJSONCallback}
|
|
274
224
|
*/
|
|
275
225
|
|
|
276
|
-
function _invoke$
|
|
226
|
+
function _invoke$2(body, then) {
|
|
277
227
|
var result = body();
|
|
278
228
|
|
|
279
229
|
if (result && result.then) {
|
|
@@ -296,7 +246,7 @@ function _call$1(body, then, direct) {
|
|
|
296
246
|
}
|
|
297
247
|
}
|
|
298
248
|
|
|
299
|
-
function _async$
|
|
249
|
+
function _async$2(f) {
|
|
300
250
|
return function () {
|
|
301
251
|
for (var args = [], i = 0; i < arguments.length; i++) {
|
|
302
252
|
args[i] = arguments[i];
|
|
@@ -314,23 +264,25 @@ function buildGetJSON$1({
|
|
|
314
264
|
baseURL,
|
|
315
265
|
cwd: basePath
|
|
316
266
|
} = {}) {
|
|
317
|
-
const _fetch = typeof fetch !== 'undefined' ? fetch : _async$
|
|
267
|
+
const _fetch = typeof fetch !== 'undefined' ? fetch : _async$2(function (jsonURL) {
|
|
318
268
|
let _exit = false;
|
|
319
|
-
return _invoke$
|
|
269
|
+
return _invoke$2(function () {
|
|
320
270
|
if (/^https?:/u.test(jsonURL)) {
|
|
321
|
-
return _invoke$
|
|
271
|
+
return _invoke$2(function () {
|
|
322
272
|
if (!nodeFetch$1) {
|
|
323
|
-
return _await$
|
|
273
|
+
return _await$3(import('node-fetch'), function (_import) {
|
|
324
274
|
nodeFetch$1 = _import;
|
|
325
275
|
});
|
|
326
276
|
}
|
|
327
277
|
}, function () {
|
|
278
|
+
const _nodeFetch$default = nodeFetch$1.default(jsonURL);
|
|
279
|
+
|
|
328
280
|
_exit = true;
|
|
329
|
-
return
|
|
281
|
+
return _nodeFetch$default;
|
|
330
282
|
});
|
|
331
283
|
}
|
|
332
284
|
}, function (_result) {
|
|
333
|
-
return _exit ? _result : _invoke$
|
|
285
|
+
return _exit ? _result : _invoke$2(function () {
|
|
334
286
|
if (!basePath) {
|
|
335
287
|
return _call$1(setDirname$1, function () {
|
|
336
288
|
basePath = baseURL ? getDirectoryForURL$1(baseURL) : typeof fetch === 'undefined' && process.cwd();
|
|
@@ -340,7 +292,7 @@ function buildGetJSON$1({
|
|
|
340
292
|
// Filed https://github.com/bergos/file-fetch/issues/12 to see
|
|
341
293
|
// about getting relative basePaths in `file-fetch` and using
|
|
342
294
|
// that better-tested package instead
|
|
343
|
-
return _await$
|
|
295
|
+
return _await$3(import('local-xmlhttprequest'), function (localXMLHttpRequest) {
|
|
344
296
|
// eslint-disable-next-line no-shadow
|
|
345
297
|
const XMLHttpRequest = localXMLHttpRequest.default({
|
|
346
298
|
basePath
|
|
@@ -350,6 +302,7 @@ function buildGetJSON$1({
|
|
|
350
302
|
return new Promise((resolve, reject) => {
|
|
351
303
|
const r = new XMLHttpRequest();
|
|
352
304
|
r.open('GET', jsonURL, true); // r.responseType = 'json';
|
|
305
|
+
// eslint-disable-next-line unicorn/prefer-add-event-listener -- May not be available
|
|
353
306
|
|
|
354
307
|
r.onreadystatechange = function () {
|
|
355
308
|
// Not sure how to simulate `if`
|
|
@@ -4400,14 +4353,6 @@ class PluginsForWork {
|
|
|
4400
4353
|
}
|
|
4401
4354
|
}
|
|
4402
4355
|
|
|
4403
|
-
let path, babelRegister;
|
|
4404
|
-
if (typeof process !== 'undefined') {
|
|
4405
|
-
/* eslint-disable node/global-require */
|
|
4406
|
-
path = require('path');
|
|
4407
|
-
babelRegister = require('@babel/register');
|
|
4408
|
-
/* eslint-enable node/global-require */
|
|
4409
|
-
}
|
|
4410
|
-
|
|
4411
4356
|
const getWorkFiles = async function getWorkFiles (files = this.files) {
|
|
4412
4357
|
const filesObj = await getJSON$1(files);
|
|
4413
4358
|
const dataFiles = [];
|
|
@@ -4532,20 +4477,6 @@ const getWorkData = async function ({
|
|
|
4532
4477
|
getPlugins
|
|
4533
4478
|
? Promise.all(
|
|
4534
4479
|
pluginPaths.map((pluginPath) => {
|
|
4535
|
-
if (typeof process !== 'undefined') {
|
|
4536
|
-
pluginPath = path.resolve(path.join(
|
|
4537
|
-
process.cwd(), 'node_modules/textbrowser/server', pluginPath
|
|
4538
|
-
));
|
|
4539
|
-
babelRegister({
|
|
4540
|
-
presets: ['@babel/env']
|
|
4541
|
-
});
|
|
4542
|
-
return Promise.resolve().then(() => {
|
|
4543
|
-
return require(pluginPath); // eslint-disable-line node/global-require, import/no-dynamic-require
|
|
4544
|
-
}).catch((err) => {
|
|
4545
|
-
// E.g., with tooltips plugin
|
|
4546
|
-
console.log('err', err);
|
|
4547
|
-
});
|
|
4548
|
-
}
|
|
4549
4480
|
// eslint-disable-next-line no-unsanitized/method
|
|
4550
4481
|
return import(pluginPath);
|
|
4551
4482
|
})
|