textbrowser 0.51.0 → 0.52.1
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/CHANGES.md +9 -0
- package/dist/WorkInfo-es.js +318 -78
- package/dist/activateCallback-es.js +9 -0
- package/dist/index-es.js +2569 -1732
- package/dist/index-es.min.js +4 -4
- package/dist/resources/activateCallback.d.ts.map +1 -1
- package/dist/resources/index.d.ts +1 -1
- package/dist/resources/index.d.ts.map +1 -1
- package/dist/resources/resultsDisplay.d.ts +4 -4
- package/dist/resources/resultsDisplay.d.ts.map +1 -1
- package/dist/resources/templates/index.d.ts.map +1 -1
- package/dist/resources/templates/utils/dom.d.ts +1 -1
- package/dist/resources/templates/utils/dom.d.ts.map +1 -1
- package/dist/resources/templates/workDisplay.d.ts.map +1 -1
- package/dist/resources/utils/IntlURLSearchParams.d.ts +4 -4
- package/dist/resources/utils/IntlURLSearchParams.d.ts.map +1 -1
- package/dist/resources/utils/Metadata.d.ts +2 -2
- package/dist/resources/utils/Metadata.d.ts.map +1 -1
- package/dist/resources/utils/Params.d.ts.map +1 -1
- package/dist/resources/utils/Plugin.d.ts +14 -10
- package/dist/resources/utils/Plugin.d.ts.map +1 -1
- package/dist/resources/utils/ServiceWorker.d.ts.map +1 -1
- package/dist/resources/utils/dialogs.d.ts +2 -2
- package/dist/resources/utils/dialogs.d.ts.map +1 -1
- package/dist/resources/utils/getLocaleFallbackResults.d.ts +1 -1
- package/dist/resources/utils/getLocaleFallbackResults.d.ts.map +1 -1
- package/dist/server/main.d.ts +2 -1
- package/dist/server/main.d.ts.map +1 -1
- package/package.json +34 -34
- package/resources/activateCallback.js +6 -0
- package/resources/index.js +10 -11
- package/resources/resultsDisplay.js +4 -2
- package/resources/templates/index.js +0 -1
- package/resources/templates/workDisplay.js +0 -1
- package/resources/user-sample.js +1 -0
- package/resources/utils/Metadata.js +3 -1
- package/resources/utils/Plugin.js +11 -5
- package/resources/utils/ServiceWorker.js +1 -2
- package/resources/utils/WorkInfo.js +1 -1
- package/resources/utils/getLocaleFallbackResults.js +3 -1
- package/server/main.js +10 -5
- package/sw-sample.js +2 -1
|
@@ -1121,7 +1121,6 @@ export default {
|
|
|
1121
1121
|
const url = replaceHash(paramsCopy) + `&work=${work}&${work}-startEnd1=%s`; // %s will be escaped if set as param; also add changeable workName here
|
|
1122
1122
|
try {
|
|
1123
1123
|
await navigator.clipboard.writeText(url);
|
|
1124
|
-
// eslint-disable-next-line no-unused-vars -- Okay to ignore
|
|
1125
1124
|
} catch (err) {
|
|
1126
1125
|
// User rejected
|
|
1127
1126
|
}
|
package/resources/user-sample.js
CHANGED
|
@@ -3,7 +3,7 @@ import {getPreferredLanguages} from './Languages.js';
|
|
|
3
3
|
import JsonRefs from 'json-refs'; // // eslint-disable-line import/order
|
|
4
4
|
|
|
5
5
|
const getCurrDir = () => {
|
|
6
|
-
return
|
|
6
|
+
return globalThis.location.href.replace(/(index\.html)?#.*$/, '');
|
|
7
7
|
};
|
|
8
8
|
|
|
9
9
|
/**
|
|
@@ -105,6 +105,7 @@ export const getMetadata = async (file, property, basePath) => {
|
|
|
105
105
|
url.toString(),
|
|
106
106
|
{
|
|
107
107
|
loaderOptions: {
|
|
108
|
+
/* eslint-disable jsdoc/reject-any-type -- How to resolve? */
|
|
108
109
|
/**
|
|
109
110
|
* @param {{
|
|
110
111
|
* text: string,
|
|
@@ -113,6 +114,7 @@ export const getMetadata = async (file, property, basePath) => {
|
|
|
113
114
|
* @param {(err?: Error, cbValue: any) => void} callback
|
|
114
115
|
*/
|
|
115
116
|
processContent (res, callback) {
|
|
117
|
+
/* eslint-enable jsdoc/reject-any-type -- How to resolve? */
|
|
116
118
|
callback(undefined, JSON.parse(
|
|
117
119
|
res.text ||
|
|
118
120
|
// `.metadata` not a recognized extension, so
|
|
@@ -40,6 +40,12 @@ export const escapePlugin = ({pluginName, applicableField, targetLanguage}) => {
|
|
|
40
40
|
(targetLanguage ? '-' + escapePluginComponent(targetLanguage) : '');
|
|
41
41
|
};
|
|
42
42
|
|
|
43
|
+
/* eslint-disable jsdoc/reject-any-type -- How to resolve? */
|
|
44
|
+
/**
|
|
45
|
+
* @typedef {any} MetaValue
|
|
46
|
+
*/
|
|
47
|
+
/* eslint-enable jsdoc/reject-any-type -- Arbitrary */
|
|
48
|
+
|
|
43
49
|
/**
|
|
44
50
|
* @todo Complete
|
|
45
51
|
* @typedef {{
|
|
@@ -66,7 +72,7 @@ export const escapePlugin = ({pluginName, applicableField, targetLanguage}) => {
|
|
|
66
72
|
* },
|
|
67
73
|
* $p: import('./IntlURLSearchParams.js').default,
|
|
68
74
|
* thisObj: import('../index.js').default|import('../../server/main.js').ResultsDisplayServerContext
|
|
69
|
-
* }) =>
|
|
75
|
+
* }) => string|Integer,
|
|
70
76
|
* done: (info: {
|
|
71
77
|
* $p: import('./IntlURLSearchParams.js').default,
|
|
72
78
|
* applicableField: string|undefined,
|
|
@@ -87,7 +93,7 @@ export const escapePlugin = ({pluginName, applicableField, targetLanguage}) => {
|
|
|
87
93
|
* targetLanguage: string,
|
|
88
94
|
* applicableField: string,
|
|
89
95
|
* applicableFieldI18N: string|string[]|import("../../server/main.js").LocalizationStrings,
|
|
90
|
-
* meta:
|
|
96
|
+
* meta: MetaValue,
|
|
91
97
|
* metaApplicableField: {
|
|
92
98
|
* [key: string]: string
|
|
93
99
|
* },
|
|
@@ -100,7 +106,7 @@ export const escapePlugin = ({pluginName, applicableField, targetLanguage}) => {
|
|
|
100
106
|
* @typedef {{
|
|
101
107
|
* path: string,
|
|
102
108
|
* lang: string,
|
|
103
|
-
* meta:
|
|
109
|
+
* meta: MetaValue,
|
|
104
110
|
* onByDefault: boolean
|
|
105
111
|
* }} PluginInfo
|
|
106
112
|
*/
|
|
@@ -157,7 +163,7 @@ export class PluginsForWork {
|
|
|
157
163
|
* [applicableField: string]: {
|
|
158
164
|
* targetLanguage: string|string[],
|
|
159
165
|
* onByDefault: boolean,
|
|
160
|
-
* meta:
|
|
166
|
+
* meta: MetaValue
|
|
161
167
|
* }
|
|
162
168
|
* },
|
|
163
169
|
* pluginName: string,
|
|
@@ -199,7 +205,7 @@ export class PluginsForWork {
|
|
|
199
205
|
* [applicableField: string]: {
|
|
200
206
|
* targetLanguage: string|string[],
|
|
201
207
|
* onByDefault: boolean,
|
|
202
|
-
* meta:
|
|
208
|
+
* meta: MetaValue
|
|
203
209
|
* }
|
|
204
210
|
* }} applicableFields
|
|
205
211
|
* @param {(cfg: {
|
|
@@ -125,7 +125,7 @@ export const respondToState = async ({
|
|
|
125
125
|
// We use this promise for rejecting (inside a listener)
|
|
126
126
|
// to a common catch and to prevent continuation by
|
|
127
127
|
// failing to return
|
|
128
|
-
return new Promise(async () => { // eslint-disable-line no-async-promise-executor
|
|
128
|
+
return new Promise(async () => { // eslint-disable-line no-async-promise-executor -- See above
|
|
129
129
|
navigator.serviceWorker.addEventListener('message', ({data}) => {
|
|
130
130
|
const {message, type, name, errorType} = data;
|
|
131
131
|
console.log('msg1', message, r);
|
|
@@ -292,7 +292,6 @@ export const registerServiceWorker = async ({
|
|
|
292
292
|
type: 'module'
|
|
293
293
|
}
|
|
294
294
|
);
|
|
295
|
-
// eslint-disable-next-line no-unused-vars -- Ok
|
|
296
295
|
} catch (err) {
|
|
297
296
|
console.log('serviceWorkerPath', serviceWorkerPath);
|
|
298
297
|
await dialogs.alert(`
|
|
@@ -93,7 +93,7 @@ export const getWorkFiles = async function getWorkFiles (files) {
|
|
|
93
93
|
filesObj.groups.forEach((fileGroup) => {
|
|
94
94
|
fileGroup.files.forEach((fileData) => {
|
|
95
95
|
const {file, schemaFile, metadataFile} =
|
|
96
|
-
|
|
96
|
+
getFilePaths(filesObj, fileGroup, fileData);
|
|
97
97
|
dataFiles.push(file, schemaFile, metadataFile);
|
|
98
98
|
});
|
|
99
99
|
});
|
package/server/main.js
CHANGED
|
@@ -3,8 +3,7 @@
|
|
|
3
3
|
/* eslint-env node -- Environment here */
|
|
4
4
|
import http from 'node:http';
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
import statik from '@brettz9/node-static';
|
|
6
|
+
import * as statik from '@node-static/node-static';
|
|
8
7
|
import fetch from 'node-fetch';
|
|
9
8
|
// @ts-expect-error Todo: Needs Types
|
|
10
9
|
import commandLineArgs from 'command-line-args';
|
|
@@ -93,13 +92,19 @@ const port = 'port' in userParams ? userParams.port : 8000;
|
|
|
93
92
|
const domain = userParams.domain || `localhost`;
|
|
94
93
|
const basePath = userParams.basePath || `http://${domain}${port ? ':' + port : ''}/`;
|
|
95
94
|
|
|
95
|
+
/* eslint-disable jsdoc/reject-any-type -- Arbitrary */
|
|
96
|
+
/**
|
|
97
|
+
* @typedef {any} AnyValue
|
|
98
|
+
*/
|
|
99
|
+
/* eslint-enable jsdoc/reject-any-type -- Arbitrary */
|
|
100
|
+
|
|
96
101
|
/**
|
|
97
102
|
* @typedef {import('../resources/utils/ServiceWorker.js').ServiceWorkerConfig &
|
|
98
103
|
* UserOptions & {
|
|
99
104
|
* lang: string[],
|
|
100
105
|
* langs: LanguageInfo[],
|
|
101
106
|
* fallbackLanguages: string[],
|
|
102
|
-
* log: (...args:
|
|
107
|
+
* log: (...args: AnyValue[]) => void,
|
|
103
108
|
* nodeActivate?: boolean,
|
|
104
109
|
* port?: number,
|
|
105
110
|
* skipIndexedDB: false,
|
|
@@ -117,7 +122,7 @@ const userParamsWithDefaults = {
|
|
|
117
122
|
}),
|
|
118
123
|
...userParams,
|
|
119
124
|
/**
|
|
120
|
-
* @param {...
|
|
125
|
+
* @param {...AnyValue} args
|
|
121
126
|
*/
|
|
122
127
|
log (...args) {
|
|
123
128
|
console.log(...args);
|
|
@@ -272,7 +277,7 @@ const srv = http.createServer(async (req, res) => {
|
|
|
272
277
|
const languages = (req.headers['accept-language']?.replace(/;q=.*$/, '') ?? 'en-US').split(',');
|
|
273
278
|
// @ts-expect-error Polyglot reasons
|
|
274
279
|
// eslint-disable-next-line n/no-unsupported-features/node-builtins -- Polyglot reasons
|
|
275
|
-
|
|
280
|
+
globalThis.navigator = {
|
|
276
281
|
language: languages[0],
|
|
277
282
|
languages
|
|
278
283
|
};
|
package/sw-sample.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
/* eslint-env serviceworker -- Service worker */
|
|
2
2
|
|
|
3
|
+
// eslint-disable-next-line sonarjs/no-internal-api-use -- Demo
|
|
3
4
|
import swHelper from './node_modules/textbrowser/dist/sw-helper.js';
|
|
4
5
|
|
|
5
6
|
// IMPORTANT: Keep this comment and increment this number to trigger
|
|
6
7
|
// a worker change: 1
|
|
7
8
|
|
|
8
|
-
swHelper(
|
|
9
|
+
swHelper(globalThis);
|