bell-reader 0.0.0-stage → 1.0.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/LICENSE +21 -0
- package/README.md +75 -2
- package/README.zh-TW.md +55 -0
- package/bin/bell-reader.mjs +202 -0
- package/dist/assets/caveat-cyrillic-400-normal-9cDH9rLW.woff2 +0 -0
- package/dist/assets/caveat-cyrillic-400-normal-CebvvJET.woff +0 -0
- package/dist/assets/caveat-cyrillic-500-normal-DLSfp5IU.woff +0 -0
- package/dist/assets/caveat-cyrillic-500-normal-DpMZbbjM.woff2 +0 -0
- package/dist/assets/caveat-cyrillic-ext-400-normal-3iEGd-c5.woff2 +0 -0
- package/dist/assets/caveat-cyrillic-ext-400-normal-Cg0RnRQ5.woff +0 -0
- package/dist/assets/caveat-cyrillic-ext-500-normal-DcrB4vVx.woff2 +0 -0
- package/dist/assets/caveat-cyrillic-ext-500-normal-DqTXtm5N.woff +0 -0
- package/dist/assets/caveat-latin-400-normal-BzhAQZkN.woff +0 -0
- package/dist/assets/caveat-latin-400-normal-D6LQsQ_v.woff2 +0 -0
- package/dist/assets/caveat-latin-500-normal-B9SDL8cy.woff2 +0 -0
- package/dist/assets/caveat-latin-500-normal-Do9veZfZ.woff +0 -0
- package/dist/assets/caveat-latin-ext-400-normal-D7hBUiug.woff2 +0 -0
- package/dist/assets/caveat-latin-ext-400-normal-DtiRFvw0.woff +0 -0
- package/dist/assets/caveat-latin-ext-500-normal-jKqJW7bC.woff2 +0 -0
- package/dist/assets/caveat-latin-ext-500-normal-wUUXxlbS.woff +0 -0
- package/dist/assets/index-D9OudjOw.js +84 -0
- package/dist/assets/index-KEOK2cPN.css +1 -0
- package/dist/assets/newsreader-latin-ext-opsz-normal-BQn1nviT.woff2 +0 -0
- package/dist/assets/newsreader-latin-opsz-normal-s-izfB6B.woff2 +0 -0
- package/dist/assets/newsreader-vietnamese-opsz-normal-BjhtXyW2.woff2 +0 -0
- package/dist/fonts/LICENSE-geist-mono.txt +93 -0
- package/dist/fonts/LICENSE-geist.txt +93 -0
- package/dist/fonts/geist-latin-wght.woff2 +0 -0
- package/dist/fonts/geist-mono-latin-wght.woff2 +0 -0
- package/dist/fonts/iansui-tc.ttf +0 -0
- package/dist/fonts/naikai-tc.woff2 +0 -0
- package/dist/index.html +13 -0
- package/package.json +77 -4
- package/server/ai.ts +1391 -0
- package/server/app.ts +644 -0
- package/server/config.ts +140 -0
- package/server/errors.ts +22 -0
- package/server/explain-bridge.ts +320 -0
- package/server/extractor.ts +548 -0
- package/server/index.ts +28 -0
- package/server/security.ts +78 -0
- package/server/store.ts +595 -0
- package/shared/suite.ts +248 -0
- package/shared/types.ts +132 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 BELL contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,76 @@
|
|
|
1
|
-
#
|
|
1
|
+
# BELL Web Reader
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
**English** · [繁體中文](./README.zh-TW.md)
|
|
4
|
+
|
|
5
|
+
Local-first web article snapshot and organic ink annotation reader. Capture public HTTPS articles (with DNS-pinned SSRF protection) or paste Markdown/prose into a clean offline SQLite library, then annotate directly on the page with hand-drawn SVG highlights, underlines, boxes, brackets, margin notes, and sketches.
|
|
6
|
+
|
|
7
|
+
Runs out-of-the-box as an **independent Standalone App** (zero environment variables required) or as part of **[BELL Suite](https://github.com/Suzu1Dev/bell-suite)** alongside Personal, Explain, BELL PR, and Campaign.
|
|
8
|
+
|
|
9
|
+
## Quick Start
|
|
10
|
+
|
|
11
|
+
### Install in One Line (macOS / Linux / WSL)
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
curl -fsSL https://raw.githubusercontent.com/Suzu1Dev/bell-reader/main/install.sh | sh
|
|
15
|
+
bell-reader
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
The installer checks npm first and automatically falls back to cloning from GitHub (`~/.local/share/bell-reader/app`) and symlinking `~/.local/bin/bell-reader`, bootstrapping Node.js 24 if needed.
|
|
19
|
+
|
|
20
|
+
### Windows (PowerShell)
|
|
21
|
+
|
|
22
|
+
```powershell
|
|
23
|
+
irm https://raw.githubusercontent.com/Suzu1Dev/bell-reader/main/install.ps1 | iex
|
|
24
|
+
bell-reader
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
### Run via `npx` or From Source
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
# Run directly with npx
|
|
31
|
+
npx bell-reader
|
|
32
|
+
|
|
33
|
+
# Or clone and run from source
|
|
34
|
+
git clone https://github.com/Suzu1Dev/bell-reader.git
|
|
35
|
+
cd bell-reader
|
|
36
|
+
npm install && npm run build
|
|
37
|
+
./bin/bell-reader.mjs start
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
## CLI Usage
|
|
41
|
+
|
|
42
|
+
```text
|
|
43
|
+
bell-reader [start] [--port <n>] [--host <h>] [--no-open] [--suite]
|
|
44
|
+
bell-reader doctor [--json]
|
|
45
|
+
bell-reader --version | --help
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
- **Standalone Edition (default)**: listens on `http://127.0.0.1:4630` with local SQLite storage in `./data/` (checkout) or `~/.bell-reader/data/` (global install).
|
|
49
|
+
- **BELL Suite Edition (`--suite` or `bell-suite start`)**: listens on `http://127.0.0.1:4604`, matches reading topics against local BELL Explain notes, accepts `#/read?text=...` handoffs, and sends pages/annotations to BELL Explain (`#/explain`), BELL Personal (`#/tasks`), or BELL PR (`#/discover`).
|
|
50
|
+
|
|
51
|
+
## Architecture Overview
|
|
52
|
+
|
|
53
|
+
```text
|
|
54
|
+
bin/bell-reader.mjs Standalone & Suite CLI (start, doctor, --version, --help)
|
|
55
|
+
src/ React 19 editorial reader, Range-anchored RoughJS/freehand ink stage,
|
|
56
|
+
margin cards, bilingual translation view, and Suite switcher
|
|
57
|
+
shared/ TypeScript page/annotation schemas and Suite Contract v1 routes
|
|
58
|
+
server/ Express 5 API, SSRF-hardened HTML extractor, SQLite store (node:sqlite),
|
|
59
|
+
optional AI doodle/selection/translation runners, Explain topic bridge
|
|
60
|
+
Formula/ Homebrew formula template
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
## Development & Verification
|
|
64
|
+
|
|
65
|
+
Requires **Node.js 22.13+** (Node.js 24 LTS recommended) for built-in `node:sqlite`.
|
|
66
|
+
|
|
67
|
+
```bash
|
|
68
|
+
npm install
|
|
69
|
+
npm run dev # Vite frontend + API watch
|
|
70
|
+
npm test # Unit & integration test suite
|
|
71
|
+
npm run build # TypeScript check + production Vite bundle
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
## License
|
|
75
|
+
|
|
76
|
+
[MIT](./LICENSE)
|
package/README.zh-TW.md
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
# BELL Web Reader
|
|
2
|
+
|
|
3
|
+
[English](./README.md) · **繁體中文**
|
|
4
|
+
|
|
5
|
+
本機優先的網頁擷取與紙上手繪塗鴉標註閱讀器:擷取公開 HTTPS 文章或貼上 Markdown/文字為離線閱讀快照,疊加有機手繪螢光筆、波浪線、圈選框與頁邊批註卡。可單獨執行(Standalone Edition),也可與 [BELL Suite](https://github.com/Suzu1Dev/bell-suite)(Personal、Explain、PR、Campaign)串聯運作。
|
|
6
|
+
|
|
7
|
+
## 一鍵安裝與 CLI 啟動
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
# macOS / Linux / WSL
|
|
11
|
+
curl -fsSL https://raw.githubusercontent.com/Suzu1Dev/bell-reader/main/install.sh | sh
|
|
12
|
+
bell-reader
|
|
13
|
+
|
|
14
|
+
# 或直接透過 npx 啟動
|
|
15
|
+
npx bell-reader
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
Windows PowerShell:
|
|
19
|
+
|
|
20
|
+
```powershell
|
|
21
|
+
irm https://raw.githubusercontent.com/Suzu1Dev/bell-reader/main/install.ps1 | iex
|
|
22
|
+
bell-reader
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
常用 CLI 指令:
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
bell-reader start # 獨立模式啟動(預設 http://127.0.0.1:4630)
|
|
29
|
+
bell-reader start --suite # BELL Suite 模式啟動(預設 http://127.0.0.1:4604)
|
|
30
|
+
bell-reader doctor # 檢查 Node、SQLite、資料目錄與選用 AI CLI 狀態
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
## 核心設計
|
|
34
|
+
|
|
35
|
+
1. **乾淨閱讀快照 + 動態錨點 SVG 塗鴉層**:
|
|
36
|
+
- 後端以 SSRF 防護(DNS 釘定公開 IP、禁止內網與重新導向濫用)擷取公開 HTTPS 網頁正文、程式碼與附圖,或直接解析貼上的文章/Markdown,離線保存於本機 SQLite(`data/bell-reader.sqlite`)。
|
|
37
|
+
- 前端不破壞內容排版,以 `Range.getClientRects()` 綁定精確文字範圍,即時疊加有機手繪 SVG 圖層(螢光筆 `highlight`、波浪線 `underline`、圈選框 `box`、段落括號 `bracket`)與跨欄手繪曲線箭頭,連至右側手寫風格頁邊批註卡。
|
|
38
|
+
2. **保存即快取,不重複燒 Token**:
|
|
39
|
+
- 已讀取的網址再次輸入時直接載入本機快照與既有標註;重新開啟頁面 0 AI 呼叫。
|
|
40
|
+
- 支援整頁一鍵「AI 塗鴉標註」、雙語翻譯、選取單句「AI 說明」或 0 Token「手寫批註」。
|
|
41
|
+
3. **資料夾歸納 + BELL Suite 雙向交接**:
|
|
42
|
+
- 支援將頁面與批註透過 Suite 契約送到 **BELL Explain**(`#/explain`)、**BELL Personal**(`#/tasks`)或 **BELL PR**(`#/discover`),並接收來自姊妹應用的 `#/read?text=...` 閱讀交接。
|
|
43
|
+
|
|
44
|
+
## 開發與測試
|
|
45
|
+
|
|
46
|
+
```bash
|
|
47
|
+
npm install
|
|
48
|
+
npm run dev
|
|
49
|
+
npm test
|
|
50
|
+
npm run build
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
## 授權
|
|
54
|
+
|
|
55
|
+
[MIT](./LICENSE)
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { spawn, spawnSync } from "node:child_process";
|
|
3
|
+
import { existsSync, mkdirSync, readFileSync, unlinkSync, writeFileSync } from "node:fs";
|
|
4
|
+
import { homedir } from "node:os";
|
|
5
|
+
import { dirname, join, resolve } from "node:path";
|
|
6
|
+
import { fileURLToPath } from "node:url";
|
|
7
|
+
|
|
8
|
+
const rootDir = resolve(dirname(fileURLToPath(import.meta.url)), "..");
|
|
9
|
+
const pkg = JSON.parse(readFileSync(join(rootDir, "package.json"), "utf8"));
|
|
10
|
+
|
|
11
|
+
const HELP = `BELL Web Reader v${pkg.version} — Local-first web snapshot & ink annotation reader
|
|
12
|
+
|
|
13
|
+
Usage:
|
|
14
|
+
bell-reader [start] [options] Start BELL Web Reader locally
|
|
15
|
+
bell-reader doctor [--json] Verify Node, SQLite, data dir, and AI CLIs
|
|
16
|
+
bell-reader --version, -v Print version
|
|
17
|
+
bell-reader --help, -h Show this help
|
|
18
|
+
|
|
19
|
+
Options (start):
|
|
20
|
+
--port <n> Port to listen on (default: 4630 standalone, 4604 with --suite)
|
|
21
|
+
--host <host> Host to bind (default: 127.0.0.1)
|
|
22
|
+
--no-open Do not open the browser automatically
|
|
23
|
+
--suite Enable BELL Suite edition with default local sibling links
|
|
24
|
+
`;
|
|
25
|
+
|
|
26
|
+
function parseArgs(argv) {
|
|
27
|
+
const opts = { cmd: "start", port: undefined, host: undefined, open: true, suite: false, json: false };
|
|
28
|
+
const rest = [...argv];
|
|
29
|
+
if (rest[0] && !rest[0].startsWith("-")) {
|
|
30
|
+
opts.cmd = rest.shift();
|
|
31
|
+
}
|
|
32
|
+
while (rest.length > 0) {
|
|
33
|
+
const arg = rest.shift();
|
|
34
|
+
if (arg === "--help" || arg === "-h") { opts.cmd = "help"; }
|
|
35
|
+
else if (arg === "--version" || arg === "-v") { opts.cmd = "version"; }
|
|
36
|
+
else if (arg === "--no-open") { opts.open = false; }
|
|
37
|
+
else if (arg === "--suite") { opts.suite = true; }
|
|
38
|
+
else if (arg === "--json") { opts.json = true; }
|
|
39
|
+
else if (arg === "--port" && rest.length > 0) { opts.port = Number(rest.shift()); }
|
|
40
|
+
else if (arg.startsWith("--port=")) { opts.port = Number(arg.slice(7)); }
|
|
41
|
+
else if (arg === "--host" && rest.length > 0) { opts.host = rest.shift(); }
|
|
42
|
+
else if (arg.startsWith("--host=")) { opts.host = arg.slice(7); }
|
|
43
|
+
else { throw new Error(`Unknown or incomplete option: ${arg}`); }
|
|
44
|
+
}
|
|
45
|
+
return opts;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
function defaultDataDir() {
|
|
49
|
+
if (process.env.BELL_READER_DATA_DIR) return resolve(process.env.BELL_READER_DATA_DIR);
|
|
50
|
+
if (existsSync(join(rootDir, "data")) || existsSync(join(rootDir, ".git"))) return join(rootDir, "data");
|
|
51
|
+
return join(homedir(), ".bell-reader", "data");
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
function checkCmd(bin, args = ["--version"]) {
|
|
55
|
+
const res = spawnSync(bin, args, { encoding: "utf8", timeout: 4000, stdio: ["ignore", "pipe", "pipe"] });
|
|
56
|
+
return res.status === 0 ? (res.stdout || res.stderr || "").trim().split("\n")[0] : null;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
async function runDoctor(json) {
|
|
60
|
+
const nodeVersion = process.versions.node;
|
|
61
|
+
const [major] = nodeVersion.split(".").map(Number);
|
|
62
|
+
const nodeOk = major >= 20;
|
|
63
|
+
let sqliteOk = false;
|
|
64
|
+
let sqliteDetail = "unavailable (requires Node >= 22.13)";
|
|
65
|
+
try {
|
|
66
|
+
await import("node:sqlite");
|
|
67
|
+
sqliteOk = true;
|
|
68
|
+
sqliteDetail = `node:sqlite ready (Node v${nodeVersion})`;
|
|
69
|
+
} catch (err) {
|
|
70
|
+
sqliteDetail = err instanceof Error ? err.message : String(err);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
const dataDir = defaultDataDir();
|
|
74
|
+
let dataWritable = false;
|
|
75
|
+
try {
|
|
76
|
+
mkdirSync(dataDir, { recursive: true });
|
|
77
|
+
const probe = join(dataDir, `.doctor-${process.pid}`);
|
|
78
|
+
writeFileSync(probe, "ok");
|
|
79
|
+
unlinkSync(probe);
|
|
80
|
+
dataWritable = true;
|
|
81
|
+
} catch {}
|
|
82
|
+
|
|
83
|
+
const distReady = existsSync(join(rootDir, "dist", "index.html"));
|
|
84
|
+
const codex = checkCmd("codex");
|
|
85
|
+
const claude = checkCmd("claude");
|
|
86
|
+
|
|
87
|
+
const checks = [
|
|
88
|
+
{ name: "node", ok: nodeOk && sqliteOk, detail: sqliteOk ? `v${nodeVersion} (${sqliteDetail})` : `v${nodeVersion} — ${sqliteDetail}` },
|
|
89
|
+
{ name: "dataDir", ok: dataWritable, detail: dataDir },
|
|
90
|
+
{ name: "frontendBuild", ok: distReady, detail: distReady ? join(rootDir, "dist") : "not built yet (auto-builds on start)" },
|
|
91
|
+
{
|
|
92
|
+
name: "aiProvider",
|
|
93
|
+
ok: true,
|
|
94
|
+
detail: [codex ? `codex (${codex})` : null, claude ? `claude (${claude})` : null].filter(Boolean).join(", ")
|
|
95
|
+
|| "none detected (web capture, offline reading, and manual ink annotations work without AI)",
|
|
96
|
+
},
|
|
97
|
+
];
|
|
98
|
+
const ok = checks.every(c => c.ok || c.name === "frontendBuild");
|
|
99
|
+
if (json) {
|
|
100
|
+
console.log(JSON.stringify({ app: "bell-reader", version: pkg.version, ok, checks }, null, 2));
|
|
101
|
+
} else {
|
|
102
|
+
console.log(`BELL Web Reader v${pkg.version} doctor\n`);
|
|
103
|
+
for (const c of checks) {
|
|
104
|
+
const mark = c.ok ? "[OK]" : c.name === "frontendBuild" ? "[WARN]" : "[FAIL]";
|
|
105
|
+
console.log(` ${mark} ${c.name.padEnd(15)} ${c.detail}`);
|
|
106
|
+
}
|
|
107
|
+
console.log(ok ? "\nReady to start: bell-reader start" : "\nFix the failing checks above before starting.");
|
|
108
|
+
}
|
|
109
|
+
process.exit(ok ? 0 : 1);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
function canOpenBrowser(openFlag) {
|
|
113
|
+
if (!openFlag || process.env.CI || process.env.SSH_CONNECTION || process.env.SSH_TTY) return false;
|
|
114
|
+
if (process.platform === "linux" && !process.env.DISPLAY && !process.env.WAYLAND_DISPLAY) return false;
|
|
115
|
+
return true;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
function openBrowser(url) {
|
|
119
|
+
const cmd = process.platform === "darwin" ? "open" : process.platform === "win32" ? "cmd" : "xdg-open";
|
|
120
|
+
const args = process.platform === "win32" ? ["/c", "start", "", url] : [url];
|
|
121
|
+
const child = spawn(cmd, args, { stdio: "ignore", detached: true });
|
|
122
|
+
child.on("error", () => {});
|
|
123
|
+
child.unref();
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
async function waitAndOpen(url, openFlag) {
|
|
127
|
+
for (let i = 0; i < 40; i++) {
|
|
128
|
+
try {
|
|
129
|
+
const res = await fetch(`${url}/api/health`);
|
|
130
|
+
if (res.ok) {
|
|
131
|
+
if (canOpenBrowser(openFlag)) openBrowser(url);
|
|
132
|
+
return;
|
|
133
|
+
}
|
|
134
|
+
} catch {}
|
|
135
|
+
await new Promise(r => setTimeout(r, 250));
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
async function runStart(opts) {
|
|
140
|
+
const distIndex = join(rootDir, "dist", "index.html");
|
|
141
|
+
if (!existsSync(distIndex)) {
|
|
142
|
+
console.log("Building BELL Web Reader frontend (dist/)...");
|
|
143
|
+
const npmCmd = process.platform === "win32" ? "npm.cmd" : "npm";
|
|
144
|
+
const build = spawnSync(npmCmd, ["run", "build"], { cwd: rootDir, stdio: "inherit" });
|
|
145
|
+
if (build.status !== 0) process.exit(build.status ?? 1);
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
const suiteMode = opts.suite || process.env.BELL_READER_EDITION === "suite" || Boolean(process.env.BELL_READER_SUITE_LINKS?.trim());
|
|
149
|
+
const port = opts.port ?? (process.env.BELL_READER_PORT || process.env.PORT ? Number(process.env.BELL_READER_PORT || process.env.PORT) : suiteMode ? 4604 : 4630);
|
|
150
|
+
const host = opts.host ?? process.env.BELL_READER_HOST ?? process.env.HOST ?? "127.0.0.1";
|
|
151
|
+
if (!Number.isInteger(port) || port < 1 || port > 65535) {
|
|
152
|
+
throw new Error(`Invalid port: ${port}`);
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
const dataDir = defaultDataDir();
|
|
156
|
+
mkdirSync(dataDir, { recursive: true });
|
|
157
|
+
|
|
158
|
+
const env = {
|
|
159
|
+
...process.env,
|
|
160
|
+
HOST: host,
|
|
161
|
+
PORT: String(port),
|
|
162
|
+
BELL_READER_HOST: host,
|
|
163
|
+
BELL_READER_PORT: String(port),
|
|
164
|
+
BELL_READER_DATA_DIR: dataDir,
|
|
165
|
+
BELL_READER_EDITION: suiteMode ? "suite" : "standalone",
|
|
166
|
+
};
|
|
167
|
+
if (opts.suite && !env.BELL_READER_SUITE_LINKS) {
|
|
168
|
+
env.BELL_READER_SUITE_LINKS = "personal=http://127.0.0.1:4601,explain=http://127.0.0.1:4602,pr=http://127.0.0.1:4603,campaign=http://127.0.0.1:4605";
|
|
169
|
+
if (!env.BELL_READER_SUITE_FETCH) {
|
|
170
|
+
env.BELL_READER_SUITE_FETCH = "explain=http://127.0.0.1:4602,pr=http://127.0.0.1:4603";
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
const localTsx = join(rootDir, "node_modules", ".bin", process.platform === "win32" ? "tsx.cmd" : "tsx");
|
|
175
|
+
const bin = existsSync(localTsx) ? localTsx : (process.platform === "win32" ? "npx.cmd" : "npx");
|
|
176
|
+
const args = existsSync(localTsx)
|
|
177
|
+
? ["--env-file-if-exists=.env", "server/index.ts"]
|
|
178
|
+
: ["tsx", "--env-file-if-exists=.env", "server/index.ts"];
|
|
179
|
+
|
|
180
|
+
const browseHost = host === "0.0.0.0" || host === "::" ? "127.0.0.1" : host.includes(":") ? `[${host}]` : host;
|
|
181
|
+
const url = `http://${browseHost}:${port}`;
|
|
182
|
+
console.log(`Starting BELL Web Reader (${suiteMode ? "Suite edition" : "Standalone edition"}) at ${url}`);
|
|
183
|
+
|
|
184
|
+
const child = spawn(bin, args, { cwd: rootDir, stdio: "inherit", env });
|
|
185
|
+
for (const sig of ["SIGINT", "SIGTERM"]) {
|
|
186
|
+
process.on(sig, () => { if (!child.killed) child.kill(sig); });
|
|
187
|
+
}
|
|
188
|
+
void waitAndOpen(url, opts.open);
|
|
189
|
+
child.on("exit", (code) => process.exit(code ?? 0));
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
try {
|
|
193
|
+
const opts = parseArgs(process.argv.slice(2));
|
|
194
|
+
if (opts.cmd === "version") console.log(pkg.version);
|
|
195
|
+
else if (opts.cmd === "help") console.log(HELP);
|
|
196
|
+
else if (opts.cmd === "doctor") await runDoctor(opts.json);
|
|
197
|
+
else if (opts.cmd === "start") await runStart(opts);
|
|
198
|
+
else throw new Error(`Unknown command: ${opts.cmd}`);
|
|
199
|
+
} catch (err) {
|
|
200
|
+
console.error(err instanceof Error ? err.message : String(err));
|
|
201
|
+
process.exit(1);
|
|
202
|
+
}
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|