textbrowser 0.41.0 → 0.42.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/.editorconfig +3 -0
- package/.eslintignore +0 -1
- package/{.eslintrc.js → .eslintrc.cjs} +0 -0
- package/CHANGES.md +19 -0
- package/README.md +27 -21
- package/dist/WorkInfo-es.js +0 -22
- package/dist/index-es.js +8 -1003
- package/dist/index-es.min.js +3 -3
- package/dist/index-umd.js +8 -1003
- package/dist/index-umd.min.js +3 -3
- package/general-schemas/array-of-arrays.jsonschema +11 -1
- package/general-schemas/table.jsonschema +29 -1
- package/package.json +39 -40
- 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/site.json +3 -0
- package/sw-sample.js +6 -10
- package/server/main-cjs.js +0 -4052
package/.editorconfig
CHANGED
package/.eslintignore
CHANGED
|
File without changes
|
package/CHANGES.md
CHANGED
|
@@ -1,5 +1,24 @@
|
|
|
1
1
|
# textbrowser CHANGES
|
|
2
2
|
|
|
3
|
+
## 0.42.0
|
|
4
|
+
|
|
5
|
+
- BREAKING CHANGE: refactor: Native ESM (plugins must be ESM also)
|
|
6
|
+
- chore: removes babel/register, `url-search-params-polyfill` and dialog-polyfill
|
|
7
|
+
- chore: bumps @babel/core (patch) and `simple-get-json` (minor), pins rtl-detect
|
|
8
|
+
|
|
9
|
+
## 0.41.2
|
|
10
|
+
|
|
11
|
+
- fix: fix dialog polyfill CSS link
|
|
12
|
+
|
|
13
|
+
## 0.41.1
|
|
14
|
+
|
|
15
|
+
- fix: fix dialog polyfill CSS link
|
|
16
|
+
- refactor: make array-of-arrays schema more precise
|
|
17
|
+
- refactor: make table.jsonschema more precise
|
|
18
|
+
- refactor: drop redundant locale file listing in sample service worker
|
|
19
|
+
- chore: update `.editorconfig`, devDeps. and deps. (babel-related,
|
|
20
|
+
`command-line-args`)
|
|
21
|
+
|
|
3
22
|
## 0.41.0
|
|
4
23
|
|
|
5
24
|
- feat: factor out undocumented Bahá'í Writings-specific bookmark generator
|
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
|
|
@@ -509,8 +513,8 @@ Plugin file designated within `files.json` may have any of the following
|
|
|
509
513
|
exports. See the subsection below for details on arguments shared by multiple
|
|
510
514
|
methods.
|
|
511
515
|
|
|
512
|
-
- `getCellData({tr, tableData, i, j, applicableField, fieldInfo, applicableFieldIdx, applicableFieldText, fieldLang, getLangDir, meta, metaApplicableField, $p, thisObj})`
|
|
513
|
-
Used to build the plugin field's cell contents. The return value will
|
|
516
|
+
- `getCellData({tr, tableData, i, j, applicableField, fieldInfo, applicableFieldIdx, applicableFieldText, fieldLang, getLangDir, meta, metaApplicableField, $p, thisObj})`
|
|
517
|
+
- Used to build the plugin field's cell contents. The return value will
|
|
514
518
|
set `tr[j]` unless the return is falsy in which case `applicableFieldText`
|
|
515
519
|
will be used. Invoked for each cell of the data. To return HTML, must use
|
|
516
520
|
in conjunction with `escapeColumn: false`. Besides properties shared with
|
|
@@ -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
|
|
|
@@ -1046,6 +1050,8 @@ it supports the following arguments:
|
|
|
1046
1050
|
|
|
1047
1051
|
## To-dos (Medium Priority)
|
|
1048
1052
|
|
|
1053
|
+
1. Build "Preferred language(s)" to use awareness of content languages rather
|
|
1054
|
+
than locales.
|
|
1049
1055
|
1. Remove need for separate metadata
|
|
1050
1056
|
files per
|
|
1051
1057
|
<https://github.com/json-schema-org/json-schema-spec/issues/587#issuecomment-389726603>
|
package/dist/WorkInfo-es.js
CHANGED
|
@@ -4400,14 +4400,6 @@ class PluginsForWork {
|
|
|
4400
4400
|
}
|
|
4401
4401
|
}
|
|
4402
4402
|
|
|
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
4403
|
const getWorkFiles = async function getWorkFiles (files = this.files) {
|
|
4412
4404
|
const filesObj = await getJSON$1(files);
|
|
4413
4405
|
const dataFiles = [];
|
|
@@ -4532,20 +4524,6 @@ const getWorkData = async function ({
|
|
|
4532
4524
|
getPlugins
|
|
4533
4525
|
? Promise.all(
|
|
4534
4526
|
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
4527
|
// eslint-disable-next-line no-unsanitized/method
|
|
4550
4528
|
return import(pluginPath);
|
|
4551
4529
|
})
|