textbrowser 0.54.0 → 0.54.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/CHANGES.md +8 -0
- package/dist/WorkInfo-es.js +172 -355
- package/dist/activateCallback-es.js +0 -1
- package/dist/index-es.js +3294 -3414
- package/dist/index-es.min.js +4 -4
- package/eslint.config.js +2 -2
- package/package.json +44 -38
- package/resources/activateCallback.js +0 -1
- package/resources/index.js +0 -1
- package/resources/resultsDisplay.js +1 -9
- package/resources/templates/workDisplay.js +0 -1
- package/resources/utils/Plugin.js +2 -5
- package/resources/utils/WorkInfo.js +7 -15
- package/resources/workDisplay.js +0 -1
- package/resources/workSelect.js +0 -1
- package/server/main.js +15 -7
- package/sw-sample.js +0 -2
- package/tsconfig.json +2 -1
- package/dist/assets/index-_11XnUty.css +0 -9
- package/dist/assets/languages-1sAACTKG.json +0 -67
- package/dist/dist/WorkInfo-es.d.ts +0 -331
- package/dist/dist/WorkInfo-es.d.ts.map +0 -1
- package/dist/dist/activateCallback-es.d.ts +0 -17
- package/dist/dist/activateCallback-es.d.ts.map +0 -1
- package/dist/dist/index-es.d.ts +0 -619
- package/dist/dist/index-es.d.ts.map +0 -1
- package/dist/dist/sw-helper.d.ts +0 -3
- package/dist/dist/sw-helper.d.ts.map +0 -1
- package/dist/eslint.config.d.ts +0 -126
- package/dist/eslint.config.d.ts.map +0 -1
- package/dist/resources/activateCallback.d.ts +0 -23
- package/dist/resources/activateCallback.d.ts.map +0 -1
- package/dist/resources/index.d.ts +0 -128
- package/dist/resources/index.d.ts.map +0 -1
- package/dist/resources/resultsDisplay.d.ts +0 -110
- package/dist/resources/resultsDisplay.d.ts.map +0 -1
- package/dist/resources/templates/index.d.ts +0 -59
- package/dist/resources/templates/index.d.ts.map +0 -1
- package/dist/resources/templates/languageSelect.d.ts +0 -18
- package/dist/resources/templates/languageSelect.d.ts.map +0 -1
- package/dist/resources/templates/resultsDisplayClient.d.ts +0 -26
- package/dist/resources/templates/resultsDisplayClient.d.ts.map +0 -1
- package/dist/resources/templates/resultsDisplayServerOrClient.d.ts +0 -131
- package/dist/resources/templates/resultsDisplayServerOrClient.d.ts.map +0 -1
- package/dist/resources/templates/utils/dom.d.ts +0 -15
- package/dist/resources/templates/utils/dom.d.ts.map +0 -1
- package/dist/resources/templates/utils/html.d.ts +0 -3
- package/dist/resources/templates/utils/html.d.ts.map +0 -1
- package/dist/resources/templates/workDisplay.d.ts +0 -183
- package/dist/resources/templates/workDisplay.d.ts.map +0 -1
- package/dist/resources/templates/workSelect.d.ts +0 -18
- package/dist/resources/templates/workSelect.d.ts.map +0 -1
- package/dist/resources/user-sample.d.ts +0 -2
- package/dist/resources/user-sample.d.ts.map +0 -1
- package/dist/resources/user.d.ts +0 -2
- package/dist/resources/user.d.ts.map +0 -1
- package/dist/resources/utils/IntlURLSearchParams.d.ts +0 -56
- package/dist/resources/utils/IntlURLSearchParams.d.ts.map +0 -1
- package/dist/resources/utils/Languages.d.ts +0 -81
- package/dist/resources/utils/Languages.d.ts.map +0 -1
- package/dist/resources/utils/Metadata.d.ts +0 -133
- package/dist/resources/utils/Metadata.d.ts.map +0 -1
- package/dist/resources/utils/Params.d.ts +0 -30
- package/dist/resources/utils/Params.d.ts.map +0 -1
- package/dist/resources/utils/Plugin.d.ts +0 -278
- package/dist/resources/utils/Plugin.d.ts.map +0 -1
- package/dist/resources/utils/ServiceWorker.d.ts +0 -26
- package/dist/resources/utils/ServiceWorker.d.ts.map +0 -1
- package/dist/resources/utils/WorkInfo.d.ts +0 -104
- package/dist/resources/utils/WorkInfo.d.ts.map +0 -1
- package/dist/resources/utils/dialogs.d.ts +0 -155
- package/dist/resources/utils/dialogs.d.ts.map +0 -1
- package/dist/resources/utils/getLocaleFallbackResults.d.ts +0 -19
- package/dist/resources/utils/getLocaleFallbackResults.d.ts.map +0 -1
- package/dist/resources/utils/sanitize.d.ts +0 -6
- package/dist/resources/utils/sanitize.d.ts.map +0 -1
- package/dist/resources/vendor/json-refs-min.d.ts +0 -3
- package/dist/resources/vendor/json-refs-min.d.ts.map +0 -1
- package/dist/resources/workDisplay.d.ts +0 -81
- package/dist/resources/workDisplay.d.ts.map +0 -1
- package/dist/resources/workSelect.d.ts +0 -17
- package/dist/resources/workSelect.d.ts.map +0 -1
- package/dist/rollup.config.d.ts +0 -19
- package/dist/rollup.config.d.ts.map +0 -1
- package/dist/server/main.d.ts +0 -47
- package/dist/server/main.d.ts.map +0 -1
- package/dist/sw-helper.d.ts +0 -3
- package/dist/sw-helper.d.ts.map +0 -1
- package/dist/sw-helper.js +0 -355
- package/dist/sw-sample.d.ts +0 -2
- package/dist/sw-sample.d.ts.map +0 -1
package/CHANGES.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# CHANGES to `textbrowser`
|
|
2
2
|
|
|
3
|
+
## 0.52.2
|
|
4
|
+
|
|
5
|
+
- chore: update simple-get-json, jsdom, devDeps., fix rollup, rebuild
|
|
6
|
+
|
|
7
|
+
## 0.54.1
|
|
8
|
+
|
|
9
|
+
- fix: redefine `navigator.languages`
|
|
10
|
+
|
|
3
11
|
## 0.54.0
|
|
4
12
|
|
|
5
13
|
- fix: avoid defining `navigator.languages` as reserved now by Node
|
package/dist/WorkInfo-es.js
CHANGED
|
@@ -1,338 +1,166 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
function
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
1
|
+
var dist$1 = {exports: {}};
|
|
2
|
+
|
|
3
|
+
var dist = dist$1.exports;
|
|
4
|
+
|
|
5
|
+
var hasRequiredDist;
|
|
6
|
+
|
|
7
|
+
function requireDist () {
|
|
8
|
+
if (hasRequiredDist) return dist$1.exports;
|
|
9
|
+
hasRequiredDist = 1;
|
|
10
|
+
(function (module, exports) {
|
|
11
|
+
(function (global, factory) {
|
|
12
|
+
module.exports = factory() ;
|
|
13
|
+
})(dist, (function () {
|
|
14
|
+
function _arrayLikeToArray(r, a) {
|
|
15
|
+
(null == a || a > r.length) && (a = r.length);
|
|
16
|
+
for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e];
|
|
17
|
+
return n;
|
|
18
|
+
}
|
|
19
|
+
function _arrayWithoutHoles(r) {
|
|
20
|
+
if (Array.isArray(r)) return _arrayLikeToArray(r);
|
|
21
|
+
}
|
|
22
|
+
function _iterableToArray(r) {
|
|
23
|
+
if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r);
|
|
24
|
+
}
|
|
25
|
+
function _nonIterableSpread() {
|
|
26
|
+
throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
27
|
+
}
|
|
28
|
+
function _toConsumableArray(r) {
|
|
29
|
+
return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread();
|
|
30
|
+
}
|
|
31
|
+
function _unsupportedIterableToArray(r, a) {
|
|
32
|
+
if (r) {
|
|
33
|
+
if ("string" == typeof r) return _arrayLikeToArray(r, a);
|
|
34
|
+
var t = {}.toString.call(r).slice(8, -1);
|
|
35
|
+
return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* @typedef {JSONValue[]} JSONArray
|
|
41
|
+
*/
|
|
42
|
+
/**
|
|
43
|
+
* @typedef {null|boolean|number|string|JSONArray|{[key: string]: JSONValue}} JSONValue
|
|
44
|
+
*/
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* @callback SimpleJSONCallback
|
|
48
|
+
* @param {...JSONValue} json
|
|
49
|
+
* @returns {void}
|
|
50
|
+
*/
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* @callback SimpleJSONErrback
|
|
54
|
+
* @param {Error} err
|
|
55
|
+
* @param {string|string[]} jsonURL
|
|
56
|
+
* @returns {JSONValue}
|
|
57
|
+
*/
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* @typedef {((
|
|
61
|
+
* jsonURL: string|string[],
|
|
62
|
+
* cb?: SimpleJSONCallback,
|
|
63
|
+
* errBack?: SimpleJSONErrback
|
|
64
|
+
* ) => Promise<JSONValue>) & {
|
|
65
|
+
* _fetch?: import('./index-polyglot.js').SimpleFetch,
|
|
66
|
+
* hasURLBasePath?: boolean,
|
|
67
|
+
* basePath?: string|false
|
|
68
|
+
* }} getJSONCallback
|
|
69
|
+
*/
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* @param {object} [cfg]
|
|
73
|
+
* @param {import('./index-polyglot.js').SimpleFetch} [cfg.fetch]
|
|
74
|
+
* @returns {getJSONCallback}
|
|
75
|
+
*/
|
|
76
|
+
|
|
77
|
+
function _await(value, then, direct) {
|
|
78
|
+
if (!value || !value.then) {
|
|
79
|
+
value = Promise.resolve(value);
|
|
80
|
+
}
|
|
81
|
+
return then ? value.then(then) : value;
|
|
82
|
+
}
|
|
83
|
+
function _invoke(body, then) {
|
|
84
|
+
var result = body();
|
|
85
|
+
if (result && result.then) {
|
|
86
|
+
return result.then(then);
|
|
87
|
+
}
|
|
88
|
+
return then(result);
|
|
89
|
+
}
|
|
90
|
+
function _catch(body, recover) {
|
|
91
|
+
try {
|
|
92
|
+
var result = body();
|
|
93
|
+
} catch (e) {
|
|
94
|
+
return recover(e);
|
|
95
|
+
}
|
|
96
|
+
if (result && result.then) {
|
|
97
|
+
return result.then(void 0, recover);
|
|
98
|
+
}
|
|
99
|
+
return result;
|
|
100
|
+
}
|
|
101
|
+
function buildGetJSONWithFetch() {
|
|
102
|
+
var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
|
|
103
|
+
_ref$fetch = _ref.fetch,
|
|
104
|
+
fetch = _ref$fetch === void 0 ? typeof window !== 'undefined' ? window.fetch : self.fetch : _ref$fetch;
|
|
105
|
+
/**
|
|
106
|
+
* @type {getJSONCallback}
|
|
107
|
+
*/
|
|
108
|
+
return function getJSON(jsonURL, cb, errBack) {
|
|
109
|
+
try {
|
|
110
|
+
var _exit = false;
|
|
111
|
+
return _await(_catch(function () {
|
|
112
|
+
return _invoke(function () {
|
|
113
|
+
if (Array.isArray(jsonURL)) {
|
|
114
|
+
return _await(Promise.all(jsonURL.map(function (url) {
|
|
115
|
+
return /** @type {getJSONCallback} */getJSON(url);
|
|
116
|
+
})), function (arrResult) {
|
|
117
|
+
if (cb) {
|
|
118
|
+
// eslint-disable-next-line promise/prefer-await-to-callbacks -- Old-style API
|
|
119
|
+
cb.apply(void 0, _toConsumableArray(arrResult));
|
|
120
|
+
}
|
|
121
|
+
_exit = true;
|
|
122
|
+
return arrResult;
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
}, function (_result) {
|
|
126
|
+
return _exit ? _result : _await(fetch(jsonURL), function (resp) {
|
|
127
|
+
return _await(resp.json(), function (result) {
|
|
128
|
+
return typeof cb === 'function'
|
|
129
|
+
// eslint-disable-next-line promise/prefer-await-to-callbacks -- Old-style API
|
|
130
|
+
? cb(result) : result;
|
|
131
|
+
// https://github.com/bcoe/c8/issues/135
|
|
132
|
+
/* c8 ignore next */
|
|
133
|
+
});
|
|
134
|
+
});
|
|
135
|
+
});
|
|
136
|
+
}, function (err) {
|
|
137
|
+
var e = /** @type {Error} */err;
|
|
138
|
+
e.message += " (File: ".concat(jsonURL, ")");
|
|
139
|
+
if (errBack) {
|
|
140
|
+
return errBack(e, jsonURL);
|
|
141
|
+
}
|
|
142
|
+
throw e;
|
|
143
|
+
// https://github.com/bcoe/c8/issues/135
|
|
144
|
+
/* c8 ignore next */
|
|
145
|
+
}));
|
|
146
|
+
/* c8 ignore next */
|
|
147
|
+
} catch (e) {
|
|
148
|
+
return Promise.reject(e);
|
|
149
|
+
}
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
var getJSON = buildGetJSONWithFetch();
|
|
154
|
+
|
|
155
|
+
return getJSON;
|
|
156
|
+
|
|
157
|
+
}));
|
|
158
|
+
|
|
159
|
+
} (dist$1));
|
|
160
|
+
return dist$1.exports;
|
|
159
161
|
}
|
|
160
|
-
const setDirname = _async$1$1(function () {
|
|
161
|
-
return _invokeIgnored(function () {
|
|
162
|
-
if (!dirname) {
|
|
163
|
-
return _await$1$1(import('node:path'), function (_import) {
|
|
164
|
-
({
|
|
165
|
-
dirname
|
|
166
|
-
} = _import);
|
|
167
|
-
});
|
|
168
|
-
}
|
|
169
|
-
});
|
|
170
|
-
});
|
|
171
|
-
function fixWindowsPath(path) {
|
|
172
|
-
if (!isWindows) {
|
|
173
|
-
isWindows = process.platform === 'win32';
|
|
174
|
-
}
|
|
175
|
-
return path.slice(
|
|
176
|
-
// https://github.com/bcoe/c8/issues/135
|
|
177
|
-
/* c8 ignore next */
|
|
178
|
-
isWindows ? 1 : 0);
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
/**
|
|
182
|
-
* @param {string} url
|
|
183
|
-
* @returns {string}
|
|
184
|
-
*/
|
|
185
|
-
function getDirectoryForURL(url) {
|
|
186
|
-
// Node should be ok with this, but transpiling
|
|
187
|
-
// to `require` doesn't work, so detect Windows
|
|
188
|
-
// to remove slash instead
|
|
189
|
-
// "file://" +
|
|
190
|
-
return fixWindowsPath(dirname(new URL(url).pathname));
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
/* globals window, self -- Polyglot */
|
|
194
|
-
|
|
195
|
-
/**
|
|
196
|
-
* @typedef {(url: string) => Promise<Response>} SimpleFetch
|
|
197
|
-
*/
|
|
198
162
|
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
function _await$3(value, then, direct) {
|
|
202
|
-
if (!value || !value.then) {
|
|
203
|
-
value = Promise.resolve(value);
|
|
204
|
-
}
|
|
205
|
-
return then ? value.then(then) : value;
|
|
206
|
-
}
|
|
207
|
-
let nodeFetch;
|
|
208
|
-
/**
|
|
209
|
-
* @param {object} [cfg]
|
|
210
|
-
* @param {string} [cfg.baseURL]
|
|
211
|
-
* @param {string|false} [cfg.cwd]
|
|
212
|
-
* @returns {import('./buildGetJSONWithFetch.js').getJSONCallback}
|
|
213
|
-
*/
|
|
214
|
-
|
|
215
|
-
function _invoke$2(body, then) {
|
|
216
|
-
var result = body();
|
|
217
|
-
if (result && result.then) {
|
|
218
|
-
return result.then(then);
|
|
219
|
-
}
|
|
220
|
-
return then(result);
|
|
221
|
-
}
|
|
222
|
-
function _call(body, then, direct) {
|
|
223
|
-
try {
|
|
224
|
-
var result = Promise.resolve(body());
|
|
225
|
-
return then ? result.then(then) : result;
|
|
226
|
-
} catch (e) {
|
|
227
|
-
return Promise.reject(e);
|
|
228
|
-
}
|
|
229
|
-
}
|
|
230
|
-
function _async$2(f) {
|
|
231
|
-
return function () {
|
|
232
|
-
for (var args = [], i = 0; i < arguments.length; i++) {
|
|
233
|
-
args[i] = arguments[i];
|
|
234
|
-
}
|
|
235
|
-
try {
|
|
236
|
-
return Promise.resolve(f.apply(this, args));
|
|
237
|
-
} catch (e) {
|
|
238
|
-
return Promise.reject(e);
|
|
239
|
-
}
|
|
240
|
-
};
|
|
241
|
-
}
|
|
242
|
-
function buildGetJSON({
|
|
243
|
-
baseURL,
|
|
244
|
-
cwd: basePath
|
|
245
|
-
} = {}) {
|
|
246
|
-
const _fetch = typeof window !== 'undefined' || typeof self !== 'undefined' ? typeof window !== 'undefined' ? window.fetch : self.fetch
|
|
247
|
-
// eslint-disable-next-line @stylistic/operator-linebreak -- TS
|
|
248
|
-
:
|
|
249
|
-
/**
|
|
250
|
-
* @param {string} jsonURL
|
|
251
|
-
* @returns {Promise<Response>}
|
|
252
|
-
*/
|
|
253
|
-
_async$2(function (jsonURL) {
|
|
254
|
-
let _exit = false;
|
|
255
|
-
return _invoke$2(function () {
|
|
256
|
-
if (/^https?:/u.test(jsonURL)) {
|
|
257
|
-
return _invoke$2(function () {
|
|
258
|
-
if (!nodeFetch) {
|
|
259
|
-
return _await$3(import('node-fetch'), function (
|
|
260
|
-
/** @type {{default: SimpleFetch}} */
|
|
261
|
-
/** @type {unknown} */
|
|
262
|
-
_import) {
|
|
263
|
-
nodeFetch = _import;
|
|
264
|
-
});
|
|
265
|
-
}
|
|
266
|
-
}, function () {
|
|
267
|
-
const _nodeFetch$default = /** @type {SimpleFetch} */nodeFetch.default(jsonURL);
|
|
268
|
-
_exit = true;
|
|
269
|
-
return _nodeFetch$default;
|
|
270
|
-
});
|
|
271
|
-
}
|
|
272
|
-
}, function (_result) {
|
|
273
|
-
return _exit ? _result : _invoke$2(function () {
|
|
274
|
-
if (!basePath) {
|
|
275
|
-
return _call(setDirname, function () {
|
|
276
|
-
basePath = baseURL ? getDirectoryForURL(baseURL) : typeof window === 'undefined' && process.cwd();
|
|
277
|
-
});
|
|
278
|
-
}
|
|
279
|
-
}, function () {
|
|
280
|
-
// Filed https://github.com/bergos/file-fetch/issues/12 to see
|
|
281
|
-
// about getting relative basePaths in `file-fetch` and using
|
|
282
|
-
// that better-tested package instead
|
|
283
|
-
// @ts-expect-error Todo
|
|
284
|
-
// Don't change to an import as won't resolve for browser testing
|
|
285
|
-
// eslint-disable-next-line promise/avoid-new -- own API
|
|
286
|
-
/* c8 ignore next */
|
|
287
|
-
return _await$3(import('local-xmlhttprequest'), function (localXMLHttpRequest) {
|
|
288
|
-
const XMLHttpRequest = /* eslint-disable jsdoc/valid-types -- Bug */
|
|
289
|
-
/**
|
|
290
|
-
* @type {{
|
|
291
|
-
* prototype: XMLHttpRequest;
|
|
292
|
-
* new(): XMLHttpRequest
|
|
293
|
-
* }}
|
|
294
|
-
*/localXMLHttpRequest.default({
|
|
295
|
-
/* eslint-enable jsdoc/valid-types -- Bug */
|
|
296
|
-
basePath
|
|
297
|
-
});
|
|
298
|
-
return new Promise((resolve, reject) => {
|
|
299
|
-
const r = new XMLHttpRequest();
|
|
300
|
-
r.open('GET', jsonURL, true);
|
|
301
|
-
// r.responseType = 'json';
|
|
302
|
-
// eslint-disable-next-line unicorn/prefer-add-event-listener -- May not be available
|
|
303
|
-
r.onreadystatechange = function () {
|
|
304
|
-
// Not sure how to simulate `if`
|
|
305
|
-
/* c8 ignore next 3 */
|
|
306
|
-
if (r.readyState !== 4) {
|
|
307
|
-
return;
|
|
308
|
-
}
|
|
309
|
-
if (r.status === 200) {
|
|
310
|
-
// var json = r.json;
|
|
311
|
-
const response = r.responseText;
|
|
312
|
-
resolve(/** @type {Response} */{
|
|
313
|
-
json: () => JSON.parse(response)
|
|
314
|
-
});
|
|
315
|
-
return;
|
|
316
|
-
}
|
|
317
|
-
reject(new SyntaxError('Failed to fetch URL: ' + jsonURL + 'state: ' + r.readyState + '; status: ' + r.status));
|
|
318
|
-
};
|
|
319
|
-
r.send();
|
|
320
|
-
// https://github.com/bcoe/c8/issues/135
|
|
321
|
-
/* c8 ignore next */
|
|
322
|
-
});
|
|
323
|
-
});
|
|
324
|
-
});
|
|
325
|
-
});
|
|
326
|
-
});
|
|
327
|
-
const ret = buildGetJSONWithFetch({
|
|
328
|
-
fetch: _fetch
|
|
329
|
-
});
|
|
330
|
-
ret._fetch = _fetch;
|
|
331
|
-
ret.hasURLBasePath = Boolean(baseURL);
|
|
332
|
-
ret.basePath = basePath;
|
|
333
|
-
return ret;
|
|
334
|
-
}
|
|
335
|
-
const getJSON = buildGetJSON();
|
|
163
|
+
var distExports = requireDist();
|
|
336
164
|
|
|
337
165
|
function _iterableToArrayLimit(arr, i) {
|
|
338
166
|
var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"];
|
|
@@ -3560,11 +3388,8 @@ const escapePlugin = ({pluginName, applicableField, targetLanguage}) => {
|
|
|
3560
3388
|
* onByDefault: boolean,
|
|
3561
3389
|
* meta: {
|
|
3562
3390
|
* [key: string]: string
|
|
3563
|
-
* }
|
|
3564
|
-
* [args: string]: {}
|
|
3391
|
+
* }
|
|
3565
3392
|
* }
|
|
3566
|
-
* },
|
|
3567
|
-
* [fieldArgs: string]: {
|
|
3568
3393
|
* }
|
|
3569
3394
|
* }} PluginFieldMappingForWork
|
|
3570
3395
|
*/
|
|
@@ -3609,7 +3434,7 @@ class PluginsForWork {
|
|
|
3609
3434
|
* pluginName: string,
|
|
3610
3435
|
* pluginLang: string,
|
|
3611
3436
|
* onByDefaultDefault: boolean,
|
|
3612
|
-
* meta:
|
|
3437
|
+
* meta: MetaValue
|
|
3613
3438
|
* }) => void} cb
|
|
3614
3439
|
* @returns {void}
|
|
3615
3440
|
*/
|
|
@@ -3767,7 +3592,9 @@ class PluginsForWork {
|
|
|
3767
3592
|
* INCOMPLETE typing.
|
|
3768
3593
|
* @typedef {{
|
|
3769
3594
|
* "localization-strings": {
|
|
3770
|
-
* [key: string]: {
|
|
3595
|
+
* [key: string]: {
|
|
3596
|
+
* [key: string]: string
|
|
3597
|
+
* }
|
|
3771
3598
|
* }
|
|
3772
3599
|
* groups: FileGroup[],
|
|
3773
3600
|
* plugins: {[key: string]: import('./Plugin.js').PluginInfo},
|
|
@@ -3794,7 +3621,7 @@ class PluginsForWork {
|
|
|
3794
3621
|
* @returns {Promise<string[]>}
|
|
3795
3622
|
*/
|
|
3796
3623
|
const getWorkFiles = async function getWorkFiles (files) {
|
|
3797
|
-
const filesObj = /** @type {FilesObject} */ (await getJSON(files));
|
|
3624
|
+
const filesObj = /** @type {FilesObject} */ (await distExports.getJSON(files));
|
|
3798
3625
|
const dataFiles = /** @type {string[]} */ ([]);
|
|
3799
3626
|
filesObj.groups.forEach((fileGroup) => {
|
|
3800
3627
|
fileGroup.files.forEach((fileData) => {
|
|
@@ -3868,12 +3695,14 @@ const getWorkData = async function ({
|
|
|
3868
3695
|
lang, fallbackLanguages, work, files, allowPlugins, basePath,
|
|
3869
3696
|
languages, preferredLocale
|
|
3870
3697
|
}) {
|
|
3871
|
-
const filesObj = /** @type {FilesObject} */ (await getJSON(files));
|
|
3698
|
+
const filesObj = /** @type {FilesObject} */ (await distExports.getJSON(files));
|
|
3872
3699
|
const localizationStrings =
|
|
3873
3700
|
/**
|
|
3874
3701
|
* @type {{
|
|
3875
3702
|
* "localization-strings": {
|
|
3876
|
-
* [key: string]: {
|
|
3703
|
+
* [key: string]: {
|
|
3704
|
+
* [key: string]: string
|
|
3705
|
+
* }
|
|
3877
3706
|
* }
|
|
3878
3707
|
* }}
|
|
3879
3708
|
*/ (
|
|
@@ -3895,7 +3724,6 @@ const getWorkData = async function ({
|
|
|
3895
3724
|
return language in localizationStrings;
|
|
3896
3725
|
});
|
|
3897
3726
|
return {
|
|
3898
|
-
// eslint-disable-next-line object-shorthand -- TS
|
|
3899
3727
|
locale: /** @type {string} */ (locale),
|
|
3900
3728
|
strings: {
|
|
3901
3729
|
head: {},
|
|
@@ -4015,7 +3843,7 @@ const getWorkData = async function ({
|
|
|
4015
3843
|
getPlugins
|
|
4016
3844
|
? Promise.all(
|
|
4017
3845
|
pluginPaths.map(async (pluginPath) => {
|
|
4018
|
-
//
|
|
3846
|
+
// eslint-disable-next-line no-unsanitized/method -- Through trusted plugins
|
|
4019
3847
|
return /** @type {import('./Plugin.js').PluginObject} */ await (import(
|
|
4020
3848
|
cwd +
|
|
4021
3849
|
pluginPath
|
|
@@ -4079,22 +3907,18 @@ const getWorkData = async function ({
|
|
|
4079
3907
|
);
|
|
4080
3908
|
if (plugin.getTargetLanguage) {
|
|
4081
3909
|
targetLanguage = plugin.getTargetLanguage({
|
|
4082
|
-
// eslint-disable-next-line object-shorthand -- TS
|
|
4083
3910
|
applicableField: /** @type {string} */ (applicableField),
|
|
4084
|
-
// eslint-disable-next-line object-shorthand -- TS
|
|
4085
3911
|
targetLanguage: /** @type {string} */ (targetLanguage),
|
|
4086
3912
|
// Default lang for plug-in (from files.json)
|
|
4087
3913
|
pluginLang,
|
|
4088
3914
|
// Default lang when no target language or
|
|
4089
3915
|
// plugin lang; using the lang of the applicable
|
|
4090
3916
|
// field
|
|
4091
|
-
// eslint-disable-next-line object-shorthand -- TS
|
|
4092
3917
|
applicableFieldLang: /** @type {string} */ (applicableFieldLang)
|
|
4093
3918
|
});
|
|
4094
3919
|
}
|
|
4095
3920
|
const field = escapePlugin({
|
|
4096
3921
|
pluginName,
|
|
4097
|
-
// eslint-disable-next-line object-shorthand -- TS
|
|
4098
3922
|
applicableField: /** @type {string} */ (applicableField),
|
|
4099
3923
|
targetLanguage: /** @type {string} */ (targetLanguage || pluginLang ||
|
|
4100
3924
|
applicableFieldLang)
|
|
@@ -4109,13 +3933,10 @@ const getWorkData = async function ({
|
|
|
4109
3933
|
? plugin.getFieldAliasOrName({
|
|
4110
3934
|
locales: lang,
|
|
4111
3935
|
workI18n,
|
|
4112
|
-
// eslint-disable-next-line object-shorthand -- TS
|
|
4113
3936
|
targetLanguage: /** @type {string} */ (targetLanguage),
|
|
4114
|
-
// eslint-disable-next-line object-shorthand -- TS
|
|
4115
3937
|
applicableField: /** @type {string} */ (applicableField),
|
|
4116
3938
|
applicableFieldI18N,
|
|
4117
3939
|
meta,
|
|
4118
|
-
// eslint-disable-next-line object-shorthand -- TS
|
|
4119
3940
|
metaApplicableField:
|
|
4120
3941
|
/**
|
|
4121
3942
|
* @type {{
|
|
@@ -4131,13 +3952,10 @@ const getWorkData = async function ({
|
|
|
4131
3952
|
pluginName,
|
|
4132
3953
|
// locales: lang,
|
|
4133
3954
|
workI18n,
|
|
4134
|
-
// eslint-disable-next-line object-shorthand -- TS
|
|
4135
3955
|
targetLanguage: /** @type {string} */ (targetLanguage),
|
|
4136
|
-
// eslint-disable-next-line object-shorthand -- TS
|
|
4137
3956
|
applicableFieldI18N: /** @type {string|string[]} */ (applicableFieldI18N),
|
|
4138
3957
|
// Todo: Should have formal way to i18nize meta
|
|
4139
3958
|
meta,
|
|
4140
|
-
// eslint-disable-next-line object-shorthand -- TS
|
|
4141
3959
|
metaApplicableField:
|
|
4142
3960
|
/**
|
|
4143
3961
|
* @type {{
|
|
@@ -4176,7 +3994,6 @@ const getWorkData = async function ({
|
|
|
4176
3994
|
}
|
|
4177
3995
|
return {
|
|
4178
3996
|
// @ts-expect-error Ok
|
|
4179
|
-
// eslint-disable-next-line object-shorthand -- TS
|
|
4180
3997
|
fileData: /** @type {FileData} */ (fileData),
|
|
4181
3998
|
workI18n, getFieldAliasOrName, metadataObj,
|
|
4182
3999
|
schemaObj, schemaItems, fieldInfo,
|