textbrowser 0.52.1 → 0.53.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 +8 -0
- package/package.json +17 -17
- package/server/main.js +12 -6
package/CHANGES.md
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "textbrowser",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.53.1",
|
|
4
4
|
"description": "Multilinear text browser",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index-es.min.js",
|
|
@@ -14,19 +14,6 @@
|
|
|
14
14
|
"bin": {
|
|
15
15
|
"textbrowser": "./server/main.js"
|
|
16
16
|
},
|
|
17
|
-
"scripts": {
|
|
18
|
-
"tsc": "tsc",
|
|
19
|
-
"server": "./server/main.js --allowPlugins --namespace=test",
|
|
20
|
-
"start": "static -p 8081",
|
|
21
|
-
"rollup": "rollup -c",
|
|
22
|
-
"lint": "npm run eslint",
|
|
23
|
-
"eslint": "eslint .",
|
|
24
|
-
"mocha": "node_modules/.bin/_mocha --require test/bootstrap/node.js --require chai/register-assert.js test/textbrowserTests.js",
|
|
25
|
-
"node": "npm run eslint && npm run rollup && npm run mocha",
|
|
26
|
-
"open-test": "open-cli http://127.0.0.1:8081/test/",
|
|
27
|
-
"start-open-test": "run-p start open-test",
|
|
28
|
-
"test": "npm run eslint && npm run rollup && npm run start-open-test"
|
|
29
|
-
},
|
|
30
17
|
"browserslist": [
|
|
31
18
|
"defaults, not op_mini all"
|
|
32
19
|
],
|
|
@@ -39,7 +26,7 @@
|
|
|
39
26
|
"url": "git+https://github.com/bahaidev/textbrowser.git"
|
|
40
27
|
},
|
|
41
28
|
"engines": {
|
|
42
|
-
"node": ">=
|
|
29
|
+
"node": ">=22.16.0"
|
|
43
30
|
},
|
|
44
31
|
"author": "Brett Zamir",
|
|
45
32
|
"contributors": [],
|
|
@@ -49,7 +36,6 @@
|
|
|
49
36
|
],
|
|
50
37
|
"dependencies": {
|
|
51
38
|
"@babel/core": "^7.28.4",
|
|
52
|
-
"@node-static/node-static": "^0.8.0",
|
|
53
39
|
"command-line-args": "^6.0.1",
|
|
54
40
|
"dom-parser": "^1.1.5",
|
|
55
41
|
"form-serialization": "^0.11.0",
|
|
@@ -61,6 +47,7 @@
|
|
|
61
47
|
"json-refs": "^3.0.15",
|
|
62
48
|
"load-stylesheets": "0.12.5",
|
|
63
49
|
"node-fetch": "^3.3.2",
|
|
50
|
+
"serve-static": "^2.2.0",
|
|
64
51
|
"simple-get-json": "^10.0.0"
|
|
65
52
|
},
|
|
66
53
|
"devDependencies": {
|
|
@@ -92,5 +79,18 @@
|
|
|
92
79
|
"rollup-plugin-re": "^1.0.7",
|
|
93
80
|
"textbrowser-data-schemas": "^0.2.0",
|
|
94
81
|
"typescript": "^5.9.3"
|
|
82
|
+
},
|
|
83
|
+
"scripts": {
|
|
84
|
+
"tsc": "tsc",
|
|
85
|
+
"server": "./server/main.js --allowPlugins --namespace=test",
|
|
86
|
+
"start": "static -p 8081",
|
|
87
|
+
"rollup": "rollup -c",
|
|
88
|
+
"lint": "npm run eslint",
|
|
89
|
+
"eslint": "eslint .",
|
|
90
|
+
"mocha": "node_modules/.bin/_mocha --require test/bootstrap/node.js --require chai/register-assert.js test/textbrowserTests.js",
|
|
91
|
+
"node": "npm run eslint && npm run rollup && npm run mocha",
|
|
92
|
+
"open-test": "open-cli http://127.0.0.1:8081/test/",
|
|
93
|
+
"start-open-test": "run-p start open-test",
|
|
94
|
+
"test": "npm run eslint && npm run rollup && npm run start-open-test"
|
|
95
95
|
}
|
|
96
|
-
}
|
|
96
|
+
}
|
package/server/main.js
CHANGED
|
@@ -3,7 +3,10 @@
|
|
|
3
3
|
/* eslint-env node -- Environment here */
|
|
4
4
|
import http from 'node:http';
|
|
5
5
|
|
|
6
|
-
import
|
|
6
|
+
import statik from 'serve-static';
|
|
7
|
+
import {fileURLToPath} from 'url';
|
|
8
|
+
import {dirname} from 'path';
|
|
9
|
+
|
|
7
10
|
import fetch from 'node-fetch';
|
|
8
11
|
// @ts-expect-error Todo: Needs Types
|
|
9
12
|
import commandLineArgs from 'command-line-args';
|
|
@@ -153,7 +156,6 @@ setGlobalVars(null, {
|
|
|
153
156
|
|
|
154
157
|
if (userParams.nodeActivate) {
|
|
155
158
|
// @ts-expect-error Ok
|
|
156
|
-
// eslint-disable-next-line n/no-unsupported-features/node-builtins -- node-fetch
|
|
157
159
|
globalThis.fetch = /** @type {fetch} */ (fetch);
|
|
158
160
|
setTimeout(async () => {
|
|
159
161
|
await activateCallback({...userParamsWithDefaults, basePath});
|
|
@@ -165,8 +167,6 @@ console.log('past activate check');
|
|
|
165
167
|
// @ts-expect-error Ok
|
|
166
168
|
globalThis.DOMParser = DOMParser; // potentially used within resultsDisplay.js
|
|
167
169
|
|
|
168
|
-
const fileServer = new statik.Server(); // Pass path; otherwise uses current directory
|
|
169
|
-
|
|
170
170
|
/**
|
|
171
171
|
* @typedef {{
|
|
172
172
|
* code: string,
|
|
@@ -199,6 +199,12 @@ let langData;
|
|
|
199
199
|
/** @type {Languages} */
|
|
200
200
|
let languagesInstance;
|
|
201
201
|
|
|
202
|
+
// `import.meta.dirname` not working on server despite hosting high enough
|
|
203
|
+
// version of Node and being `type: "module"`
|
|
204
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
205
|
+
const dir = dirname(__filename);
|
|
206
|
+
const fileServer = statik(import.meta.dirname ?? dir);
|
|
207
|
+
|
|
202
208
|
const srv = http.createServer(async (req, res) => {
|
|
203
209
|
// console.log('URL::', new URL(req.url));
|
|
204
210
|
const {pathname, search} = new URL(/** @type {string} */ (req.url), basePath);
|
|
@@ -207,7 +213,7 @@ const srv = http.createServer(async (req, res) => {
|
|
|
207
213
|
if (pathname.includes('.git')) {
|
|
208
214
|
req.url = '/index.html';
|
|
209
215
|
}
|
|
210
|
-
fileServer
|
|
216
|
+
fileServer(req, res, next);
|
|
211
217
|
};
|
|
212
218
|
|
|
213
219
|
const next = function () {
|
|
@@ -240,7 +246,7 @@ const srv = http.createServer(async (req, res) => {
|
|
|
240
246
|
({regexp}) => {
|
|
241
247
|
// Hack to ignore middleware like jsonParser (and hopefully
|
|
242
248
|
// not get any other)
|
|
243
|
-
return regexp.source !== String.raw`^\/?(
|
|
249
|
+
return regexp.source !== String.raw`^\/?(?=\/|$)` &&
|
|
244
250
|
regexp.test(/** @type {string} */ (req.url));
|
|
245
251
|
}
|
|
246
252
|
))) {
|