bell-reader 0.0.0-stage → 1.0.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/LICENSE +202 -0
- package/NOTICE +8 -0
- package/README.md +75 -2
- package/README.zh-TW.md +55 -0
- package/TRADEMARKS.md +32 -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-BO29bkMJ.js +84 -0
- package/dist/assets/index-DtC09ml8.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 +79 -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,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
package/NOTICE
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
BELL Web Reader
|
|
2
|
+
Copyright 2026 Suzu1Dev and the BELL Web Reader contributors
|
|
3
|
+
|
|
4
|
+
This product is licensed under the Apache License, Version 2.0 (see LICENSE).
|
|
5
|
+
|
|
6
|
+
The names "BELL Web Reader", "bell-reader", "BELL", "BELL Suite", and "Bell1Dev", and
|
|
7
|
+
all associated logos and brand assets, are not licensed for use under the
|
|
8
|
+
Apache License (Section 6). See TRADEMARKS.md.
|
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
|
+
[Apache-2.0](./LICENSE) · [Trademarks](./TRADEMARKS.md)
|
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
|
+
[Apache-2.0](./LICENSE) · [Trademarks](./TRADEMARKS.md)
|
package/TRADEMARKS.md
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
# BELL Web Reader Trademark Policy
|
|
2
|
+
|
|
3
|
+
The source code of BELL Web Reader is licensed under the Apache License 2.0
|
|
4
|
+
([LICENSE](LICENSE)). That license gives you broad rights to use, modify, and
|
|
5
|
+
redistribute the source code. It does **not** grant any rights to the
|
|
6
|
+
"BELL Web Reader", "bell-reader", "BELL", "BELL Suite", or "Bell1Dev" names, logos, or
|
|
7
|
+
brand marks (Apache License 2.0, Section 6).
|
|
8
|
+
|
|
9
|
+
## You may, without asking
|
|
10
|
+
|
|
11
|
+
- State accurately in plain text that your software is **compatible with** or
|
|
12
|
+
**built on** BELL Web Reader, provided it does not imply official endorsement or
|
|
13
|
+
affiliation ("Built on BELL Web Reader", "A fork of BELL Web Reader").
|
|
14
|
+
- Refer to BELL Web Reader in articles, talks, tutorials, benchmarks, and reviews.
|
|
15
|
+
- Install, self-host for personal or internal team use, and redistribute
|
|
16
|
+
**unmodified** copies obtained from official releases while keeping notices.
|
|
17
|
+
|
|
18
|
+
## You need written permission for
|
|
19
|
+
|
|
20
|
+
- Using "BELL Web Reader", "bell-reader", "BELL", "BELL Suite", "Bell1Dev", or any
|
|
21
|
+
confusingly similar name or logo for a product, package, CLI command,
|
|
22
|
+
domain, organization, or modified build.
|
|
23
|
+
- Offering a **hosted, managed, or commercial cloud service** under the
|
|
24
|
+
"BELL Web Reader", "bell-reader", "BELL", "BELL Suite", or "Bell1Dev" name or marks.
|
|
25
|
+
- Selling or distributing a **modified** version under the BELL Web Reader name.
|
|
26
|
+
- Suggesting that Suzu1Dev or Bell1Dev endorses, certifies, or operates your
|
|
27
|
+
deployment or service.
|
|
28
|
+
|
|
29
|
+
## If you fork BELL Web Reader
|
|
30
|
+
|
|
31
|
+
Rename your fork and replace the brand marks and logos, while retaining the
|
|
32
|
+
copyright and license notices in `LICENSE` and `NOTICE`.
|
|
@@ -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
|