textbrowser 0.52.1 → 0.53.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/CHANGES.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # CHANGES to `textbrowser`
2
2
 
3
+ ## 0.53.0
4
+
5
+ - fix: switch to serve-static to avoid headers problem
6
+
3
7
  ## 0.52.1
4
8
 
5
9
  - fix: proper use of node-static fork
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "textbrowser",
3
- "version": "0.52.1",
3
+ "version": "0.53.0",
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": ">=14.19.1"
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,7 @@
3
3
  /* eslint-env node -- Environment here */
4
4
  import http from 'node:http';
5
5
 
6
- import * as statik from '@node-static/node-static';
6
+ import statik from 'serve-static';
7
7
  import fetch from 'node-fetch';
8
8
  // @ts-expect-error Todo: Needs Types
9
9
  import commandLineArgs from 'command-line-args';
@@ -153,7 +153,6 @@ setGlobalVars(null, {
153
153
 
154
154
  if (userParams.nodeActivate) {
155
155
  // @ts-expect-error Ok
156
- // eslint-disable-next-line n/no-unsupported-features/node-builtins -- node-fetch
157
156
  globalThis.fetch = /** @type {fetch} */ (fetch);
158
157
  setTimeout(async () => {
159
158
  await activateCallback({...userParamsWithDefaults, basePath});
@@ -165,8 +164,6 @@ console.log('past activate check');
165
164
  // @ts-expect-error Ok
166
165
  globalThis.DOMParser = DOMParser; // potentially used within resultsDisplay.js
167
166
 
168
- const fileServer = new statik.Server(); // Pass path; otherwise uses current directory
169
-
170
167
  /**
171
168
  * @typedef {{
172
169
  * code: string,
@@ -199,6 +196,8 @@ let langData;
199
196
  /** @type {Languages} */
200
197
  let languagesInstance;
201
198
 
199
+ const fileServer = statik(import.meta.dirname);
200
+
202
201
  const srv = http.createServer(async (req, res) => {
203
202
  // console.log('URL::', new URL(req.url));
204
203
  const {pathname, search} = new URL(/** @type {string} */ (req.url), basePath);
@@ -207,7 +206,7 @@ const srv = http.createServer(async (req, res) => {
207
206
  if (pathname.includes('.git')) {
208
207
  req.url = '/index.html';
209
208
  }
210
- fileServer.serve(req, res);
209
+ fileServer(req, res, next);
211
210
  };
212
211
 
213
212
  const next = function () {