textbrowser 0.42.0 → 0.42.3

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 CHANGED
@@ -1,5 +1,18 @@
1
1
  # textbrowser CHANGES
2
2
 
3
+ ## 0.42.3
4
+
5
+ - fix: server import path fix
6
+
7
+ ## 0.42.2
8
+
9
+ - fix: server import path fix
10
+
11
+ ## 0.42.1
12
+
13
+ - fix: tweak for Node `import()` path
14
+ - fix: rollup issues with `import()`
15
+
3
16
  ## 0.42.0
4
17
 
5
18
  - BREAKING CHANGE: refactor: Native ESM (plugins must be ESM also)
@@ -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$3(value, then, direct) {
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$2(body, then) {
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$2(function () {
75
+ return _await$2$1(_catch$1(function () {
76
+ return _invoke$1$1(function () {
129
77
  if (Array.isArray(jsonURL)) {
130
- return _await$3(Promise.all(jsonURL.map(url => {
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$3(fetch(jsonURL), function (resp) {
144
- return _await$3(resp.json(), function (result) {
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$2(f) {
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$2(function () {
168
+ const setDirname$1 = _async$1$1(function () {
221
169
  return _invokeIgnored$1(function () {
222
170
  if (!dirname$1) {
223
- return _await$1$1(Promise.resolve().then(() => _interopRequireWildcard$1(require('path'))), function (_import) {
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
- function _await$2$1(value, then, direct) {
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$1$1(body, then) {
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$1$1(f) {
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$1$1(function (jsonURL) {
267
+ const _fetch = typeof fetch !== 'undefined' ? fetch : _async$2(function (jsonURL) {
318
268
  let _exit = false;
319
- return _invoke$1$1(function () {
269
+ return _invoke$2(function () {
320
270
  if (/^https?:/u.test(jsonURL)) {
321
- return _invoke$1$1(function () {
271
+ return _invoke$2(function () {
322
272
  if (!nodeFetch$1) {
323
- return _await$2$1(Promise.resolve().then(() => _interopRequireWildcard$1(require('node-fetch'))), function (_import) {
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 nodeFetch$1.default(jsonURL);
281
+ return _nodeFetch$default;
330
282
  });
331
283
  }
332
284
  }, function (_result) {
333
- return _exit ? _result : _invoke$1$1(function () {
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$2$1(Promise.resolve().then(() => _interopRequireWildcard$1(require('local-xmlhttprequest'))), function (localXMLHttpRequest) {
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`
@@ -4525,7 +4478,7 @@ const getWorkData = async function ({
4525
4478
  ? Promise.all(
4526
4479
  pluginPaths.map((pluginPath) => {
4527
4480
  // eslint-disable-next-line no-unsanitized/method
4528
- return import(pluginPath);
4481
+ return import(typeof process === 'undefined' ? pluginPath : '../' + pluginPath);
4529
4482
  })
4530
4483
  )
4531
4484
  : null
package/dist/index-es.js CHANGED
@@ -75,57 +75,6 @@ function _objectWithoutProperties(source, excluded) {
75
75
  return target;
76
76
  }
77
77
 
78
- function _getRequireWildcardCache$1() {
79
- if (typeof WeakMap !== "function") return null;
80
- var cache = new WeakMap();
81
-
82
- _getRequireWildcardCache$1 = function () {
83
- return cache;
84
- };
85
-
86
- return cache;
87
- }
88
-
89
- function _interopRequireWildcard$1(obj) {
90
- if (obj && obj.__esModule) {
91
- return obj;
92
- }
93
-
94
- if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
95
- return {
96
- default: obj
97
- };
98
- }
99
-
100
- var cache = _getRequireWildcardCache$1();
101
-
102
- if (cache && cache.has(obj)) {
103
- return cache.get(obj);
104
- }
105
-
106
- var newObj = {};
107
- var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
108
-
109
- for (var key in obj) {
110
- if (Object.prototype.hasOwnProperty.call(obj, key)) {
111
- var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
112
-
113
- if (desc && (desc.get || desc.set)) {
114
- Object.defineProperty(newObj, key, desc);
115
- } else {
116
- newObj[key] = obj[key];
117
- }
118
- }
119
- }
120
-
121
- newObj.default = obj;
122
-
123
- if (cache) {
124
- cache.set(obj, newObj);
125
- }
126
-
127
- return newObj;
128
- }
129
78
  /* eslint-disable node/no-unsupported-features/es-syntax */
130
79
 
131
80
  /**
@@ -141,9 +90,7 @@ function _interopRequireWildcard$1(obj) {
141
90
  * @param {fetch} cfg.fetch
142
91
  * @returns {getJSONCallback}
143
92
  */
144
-
145
-
146
- function _await$3(value, then, direct) {
93
+ function _await$2$1(value, then, direct) {
147
94
  if (direct) {
148
95
  return then ? then(value) : value;
149
96
  }
@@ -155,7 +102,7 @@ function _await$3(value, then, direct) {
155
102
  return then ? value.then(then) : value;
156
103
  }
157
104
 
158
- function _invoke$2(body, then) {
105
+ function _invoke$1$1(body, then) {
159
106
  var result = body();
160
107
 
161
108
  if (result && result.then) {
@@ -202,10 +149,10 @@ function buildGetJSONWithFetch$1({
202
149
  return function getJSON(jsonURL, cb, errBack) {
203
150
  try {
204
151
  let _exit = false;
205
- return _catch$1(function () {
206
- return _invoke$2(function () {
152
+ return _await$2$1(_catch$1(function () {
153
+ return _invoke$1$1(function () {
207
154
  if (Array.isArray(jsonURL)) {
208
- return _await$3(Promise.all(jsonURL.map(url => {
155
+ return _await$2$1(Promise.all(jsonURL.map(url => {
209
156
  return getJSON(url);
210
157
  })), function (arrResult) {
211
158
  if (cb) {
@@ -218,8 +165,8 @@ function buildGetJSONWithFetch$1({
218
165
  });
219
166
  }
220
167
  }, function (_result) {
221
- return _exit ? _result : _await$3(fetch(jsonURL), function (resp) {
222
- return _await$3(resp.json(), function (result) {
168
+ return _exit ? _result : _await$2$1(fetch(jsonURL), function (resp) {
169
+ return _await$2$1(resp.json(), function (result) {
223
170
  return typeof cb === 'function' // eslint-disable-next-line promise/prefer-await-to-callbacks
224
171
  ? cb(result) : result; // https://github.com/bcoe/c8/issues/135
225
172
 
@@ -237,7 +184,7 @@ function buildGetJSONWithFetch$1({
237
184
  throw e; // https://github.com/bcoe/c8/issues/135
238
185
 
239
186
  /* c8 ignore next */
240
- });
187
+ }));
241
188
  /* c8 ignore next */
242
189
  } catch (e) {
243
190
  return Promise.reject(e);
@@ -282,7 +229,7 @@ function _invokeIgnored$1(body) {
282
229
  }
283
230
  }
284
231
 
285
- function _async$2(f) {
232
+ function _async$1$1(f) {
286
233
  return function () {
287
234
  for (var args = [], i = 0; i < arguments.length; i++) {
288
235
  args[i] = arguments[i];
@@ -296,10 +243,10 @@ function _async$2(f) {
296
243
  };
297
244
  }
298
245
 
299
- const setDirname$1 = _async$2(function () {
246
+ const setDirname$1 = _async$1$1(function () {
300
247
  return _invokeIgnored$1(function () {
301
248
  if (!dirname$1) {
302
- return _await$1$1(Promise.resolve().then(() => _interopRequireWildcard$1(require('path'))), function (_import) {
249
+ return _await$1$1(import('path'), function (_import) {
303
250
  ({
304
251
  dirname: dirname$1
305
252
  } = _import);
@@ -331,8 +278,10 @@ function getDirectoryForURL$1(url) {
331
278
  // "file://" +
332
279
  return fixWindowsPath$1(dirname$1(new URL(url).pathname));
333
280
  }
281
+ /* eslint-disable node/no-unsupported-features/es-syntax */
334
282
 
335
- function _await$2$1(value, then, direct) {
283
+
284
+ function _await$3(value, then, direct) {
336
285
  if (direct) {
337
286
  return then ? then(value) : value;
338
287
  }
@@ -352,7 +301,7 @@ let nodeFetch$1;
352
301
  * @returns {getJSONCallback}
353
302
  */
354
303
 
355
- function _invoke$1$1(body, then) {
304
+ function _invoke$2(body, then) {
356
305
  var result = body();
357
306
 
358
307
  if (result && result.then) {
@@ -375,7 +324,7 @@ function _call$1(body, then, direct) {
375
324
  }
376
325
  }
377
326
 
378
- function _async$1$1(f) {
327
+ function _async$2(f) {
379
328
  return function () {
380
329
  for (var args = [], i = 0; i < arguments.length; i++) {
381
330
  args[i] = arguments[i];
@@ -393,23 +342,25 @@ function buildGetJSON$1({
393
342
  baseURL,
394
343
  cwd: basePath
395
344
  } = {}) {
396
- const _fetch = typeof fetch !== 'undefined' ? fetch : _async$1$1(function (jsonURL) {
345
+ const _fetch = typeof fetch !== 'undefined' ? fetch : _async$2(function (jsonURL) {
397
346
  let _exit = false;
398
- return _invoke$1$1(function () {
347
+ return _invoke$2(function () {
399
348
  if (/^https?:/u.test(jsonURL)) {
400
- return _invoke$1$1(function () {
349
+ return _invoke$2(function () {
401
350
  if (!nodeFetch$1) {
402
- return _await$2$1(Promise.resolve().then(() => _interopRequireWildcard$1(require('node-fetch'))), function (_import) {
351
+ return _await$3(import('node-fetch'), function (_import) {
403
352
  nodeFetch$1 = _import;
404
353
  });
405
354
  }
406
355
  }, function () {
356
+ const _nodeFetch$default = nodeFetch$1.default(jsonURL);
357
+
407
358
  _exit = true;
408
- return nodeFetch$1.default(jsonURL);
359
+ return _nodeFetch$default;
409
360
  });
410
361
  }
411
362
  }, function (_result) {
412
- return _exit ? _result : _invoke$1$1(function () {
363
+ return _exit ? _result : _invoke$2(function () {
413
364
  if (!basePath) {
414
365
  return _call$1(setDirname$1, function () {
415
366
  basePath = baseURL ? getDirectoryForURL$1(baseURL) : typeof fetch === 'undefined' && process.cwd();
@@ -419,7 +370,7 @@ function buildGetJSON$1({
419
370
  // Filed https://github.com/bergos/file-fetch/issues/12 to see
420
371
  // about getting relative basePaths in `file-fetch` and using
421
372
  // that better-tested package instead
422
- return _await$2$1(Promise.resolve().then(() => _interopRequireWildcard$1(require('local-xmlhttprequest'))), function (localXMLHttpRequest) {
373
+ return _await$3(import('local-xmlhttprequest'), function (localXMLHttpRequest) {
423
374
  // eslint-disable-next-line no-shadow
424
375
  const XMLHttpRequest = localXMLHttpRequest.default({
425
376
  basePath
@@ -429,6 +380,7 @@ function buildGetJSON$1({
429
380
  return new Promise((resolve, reject) => {
430
381
  const r = new XMLHttpRequest();
431
382
  r.open('GET', jsonURL, true); // r.responseType = 'json';
383
+ // eslint-disable-next-line unicorn/prefer-add-event-listener -- May not be available
432
384
 
433
385
  r.onreadystatechange = function () {
434
386
  // Not sure how to simulate `if`
@@ -14641,7 +14593,7 @@ const getWorkData = async function ({
14641
14593
  const pluginFieldMappings = pluginFieldMappingForWork;
14642
14594
  const [schemaObj, pluginObjects] = await Promise.all([getMetadata(schemaFile, schemaProperty, basePath), getPlugins ? Promise.all(pluginPaths.map(pluginPath => {
14643
14595
  // eslint-disable-next-line no-unsanitized/method
14644
- return import(pluginPath);
14596
+ return import(typeof process === 'undefined' ? pluginPath : '../' + pluginPath);
14645
14597
  })) : null]);
14646
14598
  const pluginsForWork = new PluginsForWork({
14647
14599
  pluginsInWork,