dsh-pdf-workbench 1.3.3 → 1.4.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 -21
- package/README.md +225 -199
- package/assets/screenshot-attachments.jpg +0 -0
- package/assets/screenshot-canvas.jpg +0 -0
- package/assets/screenshot-questions.jpg +0 -0
- package/assets/screenshot-settings-data.jpg +0 -0
- package/assets/screenshot-settings-mode.jpg +0 -0
- package/assets/screenshot-settings-reading.jpg +0 -0
- package/client.js +5700 -849
- package/docs/DETAIL.md +1 -69
- package/docs/RELEASE.md +119 -119
- package/docs/SIDE-PREVIEW.md +5 -1
- package/docs/preview.svg +86 -0
- package/icon.svg +7 -6
- package/index.js +18 -2
- package/locale/en.json +1 -1
- package/locale/zh.json +1 -1
- package/package.json +1 -1
- package/screenshots.json +13 -8
- package/src/client/host-ui-entry.js +11 -11
- package/src/client/react-jsx-runtime.cjs +21 -21
- package/src/client/viewer.js +80 -80
- package/src/host/artifacts.js +31 -3
- package/src/host/attachments.js +159 -0
- package/src/host/backup.js +457 -0
- package/src/host/base-session.js +146 -0
- package/src/host/book-import.js +98 -0
- package/src/host/chapter-sessions.js +154 -0
- package/src/host/chapter-text.js +91 -0
- package/src/host/fonts.js +190 -0
- package/src/host/pdf-stream.js +168 -0
- package/src/host/ppt.js +153 -0
- package/src/host/print.js +191 -0
- package/src/host/questions.js +186 -0
- package/src/host/routes.js +671 -25
- package/src/host/state.js +1 -1
- package/src/host/zip.js +186 -0
- package/tools/AGENTS.md +33 -33
- package/tools/README.md +138 -138
- package/tools/auto_chapters.py +122 -122
- package/tools/dsfile.mjs +198 -198
- package/tools/export_chapter.py +108 -108
- package/tools/export_page.py +91 -91
- package/tools/md2overlay.py +200 -200
- package/tools/md2tex.py +422 -422
- package/tools/pdf_blocks.py +110 -110
- package/tools/pdf_fontsize.py +20 -20
- package/tools/pdf_merge.py +15 -15
- package/tools/pdf_pagesizes.py +8 -8
- package/tools/pdf_raster.py +21 -21
- package/tools/pdf_text.py +34 -0
- package/tools/pdfkit.py +896 -896
- package/tools/realign_overlay.py +248 -248
- package/tools/rebuild_overlay.py +55 -55
- package/tools/rename_chapters.py +93 -93
- package/tools//350/247/204/350/214/203/00_/345/205/261/345/220/214/347/272/246/345/256/232.md +142 -142
- package/tools//350/247/204/350/214/203/01_/346/226/207/346/234/254/346/217/220/345/217/226.md +204 -204
- package/tools//350/247/204/350/214/203/02_/347/255/224/347/226/221.md +61 -61
- package/tools//350/247/204/350/214/203/03_/344/271/240/351/242/230/350/247/243/347/255/224.md +77 -77
- package/tools//350/247/204/350/214/203/api/346/217/220/347/244/272/350/257/215_/346/217/220/345/217/226.md +11 -11
- package/vendor/cmaps/LICENSE.txt +36 -36
- package/vendor/fonts/excalifont/OFL.txt +98 -98
- package/vendor/fonts/zhhand/OFL.txt +99 -99
- package/vendor/host-ui.cjs +1719 -1719
- package/vendor/host-ui.css +799 -799
- package/vendor/pdf.min.mjs +28 -28
- package/vendor/pdf.worker.min.mjs +28 -28
- package/vendor/pdfjs-LICENSE.txt +177 -177
- package/vendor/rough/LICENSE +21 -21
- package/vendor/rough/rough.mjs +1 -1
- package/vendor/wasm/LICENSE_JBIG2 +196 -196
- package/vendor/wasm/LICENSE_OPENJPEG +39 -39
- package/vendor/wasm/LICENSE_PDFJS_JBIG2 +13 -13
- package/vendor/wasm/LICENSE_PDFJS_OPENJPEG +22 -22
- package/vendor/wasm/LICENSE_PDFJS_QCMS +19 -19
- package/vendor/wasm/LICENSE_QCMS +21 -21
- package/vendor/wasm/jbig2_nowasm_fallback.js +15 -15
- package/vendor/wasm/openjpeg_nowasm_fallback.js +17 -17
- package//345/256/211/350/243/205/344/270/216/345/210/206/345/217/221.md +1 -1
- package/tools/node.cmd +0 -3
- package/tools/py.cmd +0 -3
- package/vendor/fonts/zhhand/Xiaolai-Regular.ttf +0 -0
package/docs/DETAIL.md
CHANGED
|
@@ -1,69 +1 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
以「书 → 章」为骨架的整页PDF阅读。点左侧栏的工作台图标打开:书架列出书,点书卡进入章节页。
|
|
4
|
-
|
|
5
|
-
## 功能
|
|
6
|
-
|
|
7
|
-
- **书库**:可添加多个书库;分片目录 `<库根>\分片\<书 id>\`、整本 PDF 放 `<库根>\整本\`;
|
|
8
|
-
分片文件名带页码范围即可(如 `概率论_积分和数学期望_97-138.pdf`),按页序自动编号。
|
|
9
|
-
- **书架**:单击选中、双击进入章节;空白处拖拽框选;隐藏书籍、自定义多文件书架(可嵌套)、右键删除书架并释放书。
|
|
10
|
-
- **章节会话**:提取 / 答疑 / 习题三组;「+ 新建」优先进已有会话,上下文接近上限才续开;
|
|
11
|
-
支持导入已有会话、重命名、取消挂载;标题形如 `[书 id c04] 答疑`。
|
|
12
|
-
- **产物**:目录 `<库根>\产物\<书 id>\<章号>\`;文本类文件在右侧预览;md 可一键转 PDF(需 Python + TeX Live);
|
|
13
|
-
产物会话挂在对应 PDF 行下,可折叠、可「另起」。
|
|
14
|
-
- **阅读器**:内置 pdf.js,单页/连续、翻页、缩放、页码跳转、键盘操作;右栏预览可开关。
|
|
15
|
-
- **清理**:产物删除进 `<库根>\回收站\`;会话归档后工作台不再列出;隐藏书架可整体释放。
|
|
16
|
-
- **其他**:设置菜单显示版本号、右侧预览与「非PDF删除」保护开关;底部使用提示可折叠。
|
|
17
|
-
|
|
18
|
-
## 使用
|
|
19
|
-
|
|
20
|
-
1. 添加书库(选库根目录),进入书架;
|
|
21
|
-
2. 按目录拆分章节 PDF,或直接放整本 PDF;
|
|
22
|
-
3. 展开章节 → 打开 PDF 或新建会话;会话自带书名/章名/产物目录上下文。
|
|
23
|
-
|
|
24
|
-
## 限制
|
|
25
|
-
|
|
26
|
-
- 仅面向数学书工作流;PDF 阅读器只读,不做标注/笔记;
|
|
27
|
-
- Markdown→PDF 需要本机 Python 与 TeX Live(xelatex),插件运行时不依赖;
|
|
28
|
-
- 书 id 由目录/文件名推导,添加书库后不要重命名该目录,否则旧会话与产物会对不上;
|
|
29
|
-
- 界面只显示本机真实路径;跨机器需重新添加书库。
|
|
30
|
-
|
|
31
|
-
## 作者想说
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
开发这一个插件是为了契合我自己学习数学的工作流!
|
|
35
|
-
|
|
36
|
-
虽然数学看起来已经没有什么前景了,但是学习数学带来的思维上的好处还是很明显的:第一是应用的场景也会对数学能力有进一步的要求,以前可能学个线性代数,凑合能干活就行了,但是现在不学习到抽象代数,可能连如何向AI去问问题,让它干活都不足够;第二是数学教育和美的体会都还在,只是前进、探索的路会有AI走一遍而已。
|
|
37
|
-
|
|
38
|
-
读数学书则是学习数学的最好方式之一,而为什么不让AI去辅助解答,去给出标答,去辅助笔记呢?有了这个插件,我们不再需要事事与别人讨论,我们拥有至少一条的实现问题的路径,我们不再需要做摘抄这样费时费力的事情!
|
|
39
|
-
|
|
40
|
-
当然这个插件不是必须的,我早就在用这套工作流了,只是把这套工作流以插件集成的形式体现出来而已,希望大家用的愉快,有问题也可以随时反馈。
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
GitHub: https://github.com/minggemofashi/dsh-pdf-workbench
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
## Token 消耗
|
|
47
|
-
|
|
48
|
-
- 打开书架、展开章节、预览产物、右侧 PDF 预览:不进入模型上下文,不消耗对话 token。
|
|
49
|
-
- 新建会话草稿只带一行上下文(书名 / 章名 / PDF / 产物目录),约几百 token 级。
|
|
50
|
-
- 会话问答按对话长度计费;「整理提纲」会把该章多个会话再汇总一次。
|
|
51
|
-
- 整本 PDF 会话很贵(一次可能几十万 token),只适合小文件/小论文。
|
|
52
|
-
- 插件不会自动把 PDF 塞进上下文;AI 需要时会自己读取,读多少取决于它。
|
|
53
|
-
|
|
54
|
-
## 不能做什么
|
|
55
|
-
|
|
56
|
-
- 阅读器只读:无标注、高亮、批注、笔记,也不写回 PDF。
|
|
57
|
-
- 不做 OCR、不整本拆分;整本 PDF 只作为一本书显示。
|
|
58
|
-
- 章节与三种会话的语义面向数学书,不是通用阅读器。
|
|
59
|
-
- 书库在本机,跨机器需重新添加;没有全书语义搜索。
|
|
60
|
-
|
|
61
|
-
## 归档不是删除
|
|
62
|
-
|
|
63
|
-
会话行的「归档」只把会话移出工作台列表,不会删除会话本身;已归档会话仍保存在 DSH 中,可从 DSH 的归档恢复或在 DSH 里清理。工作台的「清理空会话」只处理没有发过消息的空白会话。
|
|
64
|
-
|
|
65
|
-
## 平台支持
|
|
66
|
-
|
|
67
|
-
- **仅支持 Windows 10 / 11(x64)**,且只在这两个系统上验证过。
|
|
68
|
-
- macOS / Linux 未适配、未测试:路径分隔符、`py`/`python` 启动器、TeX 检测目录都按 Windows 编写,其他系统上大概率无法正常工作。
|
|
69
|
-
- 可选环境:Python 3 + TeX Live(xelatex、ctex);缺失时「md→PDF」按钮隐藏,其余功能正常。
|
|
1
|
+

|
package/docs/RELEASE.md
CHANGED
|
@@ -1,119 +1,119 @@
|
|
|
1
|
-
# 发版流程(固定版)
|
|
2
|
-
|
|
3
|
-
> 用户说「更新 / 发版 / 发布」时,**按本文执行**,不要重新设计流程。
|
|
4
|
-
> 日常修改仍然只本地提交;本流程只在明确发版时启动。
|
|
5
|
-
|
|
6
|
-
## 0. 发版前
|
|
7
|
-
|
|
8
|
-
1. 确认 `package.json` 版本:修复 +补丁位,新功能 +次版本位。
|
|
9
|
-
2. `CHANGELOG.md` 顶部新增 `## vX.Y.Z`,写清改了什么。
|
|
10
|
-
3. 如果界面有变化:更新 `README.md` 截图与 `screenshots.json`(市场从仓库读取,不需要为截图提 PR)。
|
|
11
|
-
4. 跑检查:
|
|
12
|
-
|
|
13
|
-
```powershell
|
|
14
|
-
cd math-desk
|
|
15
|
-
node --check client.js
|
|
16
|
-
node --check index.js
|
|
17
|
-
Get-ChildItem src\host\*.js | ForEach-Object { node --check $_.FullName }
|
|
18
|
-
cd ..
|
|
19
|
-
node .dsh-scratch\check-keys.mjs
|
|
20
|
-
node .dsh-scratch\check-deps.mjs
|
|
21
|
-
node .dsh-scratch\side-smoke.mjs
|
|
22
|
-
node .dsh-scratch\notes-test.mjs
|
|
23
|
-
node .dsh-scratch\session-seed-test.mjs
|
|
24
|
-
node .dsh-scratch\page-store-test.mjs
|
|
25
|
-
node .dsh-scratch\annotation-store-test.mjs
|
|
26
|
-
node .dsh-scratch\host-test.mjs
|
|
27
|
-
```
|
|
28
|
-
|
|
29
|
-
## 1. GitHub Release(默认渠道)
|
|
30
|
-
|
|
31
|
-
先构建宿主 primitives 产物(构建依赖只在开发时安装,不随插件安装):
|
|
32
|
-
|
|
33
|
-
```powershell
|
|
34
|
-
cd math-desk
|
|
35
|
-
npm install
|
|
36
|
-
npm run build:host-ui
|
|
37
|
-
```
|
|
38
|
-
|
|
39
|
-
然后构建 zip:
|
|
40
|
-
|
|
41
|
-
```powershell
|
|
42
|
-
powershell -ExecutionPolicy Bypass -File .\build-dist.ps1
|
|
43
|
-
# 产出 ..\dist\dsh-pdf-workbench-X.Y.Z.zip
|
|
44
|
-
|
|
45
|
-
git add -A
|
|
46
|
-
git commit -m "vX.Y.Z: <一句话>"
|
|
47
|
-
git tag vX.Y.Z
|
|
48
|
-
git push origin main
|
|
49
|
-
git push --tags origin
|
|
50
|
-
```
|
|
51
|
-
|
|
52
|
-
创建 GitHub Release `vX.Y.Z`,上传:
|
|
53
|
-
|
|
54
|
-
- `dsh-pdf-workbench-X.Y.Z.zip`(必须)
|
|
55
|
-
- 可选 `dsh-pdf-workbench-X.Y.Z.tgz`(干净 worktree 里 `npm pack`,作为市场 npm 失败时的回退)
|
|
56
|
-
|
|
57
|
-
Release 说明直接复制 `CHANGELOG` 的该版本条目。
|
|
58
|
-
|
|
59
|
-
## 2. npm
|
|
60
|
-
|
|
61
|
-
npm 包名固定 **`dsh-pdf-workbench`**。必须从**干净 worktree / 干净 clone**发布,避免带上本机 `tools/py.cmd`、`tools/node.cmd`、`__pycache__`:
|
|
62
|
-
|
|
63
|
-
```powershell
|
|
64
|
-
cd <工作区>\math-desk
|
|
65
|
-
git worktree add ..\dist\npm-release vX.Y.Z
|
|
66
|
-
cd ..\dist\npm-release
|
|
67
|
-
npm login --auth-type=web
|
|
68
|
-
npm stage publish --access public
|
|
69
|
-
```
|
|
70
|
-
|
|
71
|
-
然后批准:
|
|
72
|
-
|
|
73
|
-
- 网页:https://www.npmjs.com/settings/minggemofashi/staged
|
|
74
|
-
- 或:`npm stage approve <stage-id>`(真实 6 位 OTP)
|
|
75
|
-
|
|
76
|
-
批准后验证:
|
|
77
|
-
|
|
78
|
-
```powershell
|
|
79
|
-
npm view dsh-pdf-workbench@X.Y.Z version
|
|
80
|
-
```
|
|
81
|
-
|
|
82
|
-
清理:
|
|
83
|
-
|
|
84
|
-
```powershell
|
|
85
|
-
cd <工作区>
|
|
86
|
-
git -C math-desk worktree remove ..\dist\npm-release
|
|
87
|
-
```
|
|
88
|
-
|
|
89
|
-
> 注意:npm 的 granular token 不能代替 2FA 发布;必须交互登录。不要用字面量 `你的6位验证码`。
|
|
90
|
-
|
|
91
|
-
## 3. 插件市场
|
|
92
|
-
|
|
93
|
-
首次上架:向 `awesome-dsh-plugin` 提交 `data/plugins/<owner>__<repo>.yml`;本插件条目已提交(PR 保留)。
|
|
94
|
-
|
|
95
|
-
首次之后:
|
|
96
|
-
|
|
97
|
-
- npm 包 `repository` 指向同一仓库时,dsh-market 自动做 npm 映射,**版本更新不需要再提 PR**;
|
|
98
|
-
- 只有改仓库地址、包名、分类或描述时才改 awesome 条目;
|
|
99
|
-
- 截图换图只需更新仓库 `screenshots.json`;
|
|
100
|
-
- 若 npm 发布失败,才回退到 tarball:上传新版本 `.tgz` 并更新条目的 `tarball` 字段(需要 PR)。
|
|
101
|
-
|
|
102
|
-
## 4. 一致性检查
|
|
103
|
-
|
|
104
|
-
- `package.json` 版本 = tag = GitHub Release = npm 版本;
|
|
105
|
-
- Release 的 zip / tgz 能下载;
|
|
106
|
-
- `README.md` 安装命令版本正确;
|
|
107
|
-
- 远程 `main` 包含发版提交;
|
|
108
|
-
- npm 页面可见,market 能搜到(缓存可能有延迟)。
|
|
109
|
-
|
|
110
|
-
## 5. 旧包处理(已完成)
|
|
111
|
-
|
|
112
|
-
旧包 `dsh-pdf-math-desk` 已从 npm 删除(`npm view` 返回 404),无需再处理;不要重新发布这个名称。
|
|
113
|
-
|
|
114
|
-
## 6. 不要做
|
|
115
|
-
|
|
116
|
-
- 不重新引入 `market/index.json`(收录由 awesome 列表负责);
|
|
117
|
-
- 不发 npm 前不更新市场条目的 npm 映射;
|
|
118
|
-
- 不用本机工作目录直接 `npm publish`(会带上未跟踪的包装脚本/pycache);
|
|
119
|
-
- 不在用户没说“发版”时升版本/tag/push/Release/npm。
|
|
1
|
+
# 发版流程(固定版)
|
|
2
|
+
|
|
3
|
+
> 用户说「更新 / 发版 / 发布」时,**按本文执行**,不要重新设计流程。
|
|
4
|
+
> 日常修改仍然只本地提交;本流程只在明确发版时启动。
|
|
5
|
+
|
|
6
|
+
## 0. 发版前
|
|
7
|
+
|
|
8
|
+
1. 确认 `package.json` 版本:修复 +补丁位,新功能 +次版本位。
|
|
9
|
+
2. `CHANGELOG.md` 顶部新增 `## vX.Y.Z`,写清改了什么。
|
|
10
|
+
3. 如果界面有变化:更新 `README.md` 截图与 `screenshots.json`(市场从仓库读取,不需要为截图提 PR)。
|
|
11
|
+
4. 跑检查:
|
|
12
|
+
|
|
13
|
+
```powershell
|
|
14
|
+
cd math-desk
|
|
15
|
+
node --check client.js
|
|
16
|
+
node --check index.js
|
|
17
|
+
Get-ChildItem src\host\*.js | ForEach-Object { node --check $_.FullName }
|
|
18
|
+
cd ..
|
|
19
|
+
node .dsh-scratch\check-keys.mjs
|
|
20
|
+
node .dsh-scratch\check-deps.mjs
|
|
21
|
+
node .dsh-scratch\side-smoke.mjs
|
|
22
|
+
node .dsh-scratch\notes-test.mjs
|
|
23
|
+
node .dsh-scratch\session-seed-test.mjs
|
|
24
|
+
node .dsh-scratch\page-store-test.mjs
|
|
25
|
+
node .dsh-scratch\annotation-store-test.mjs
|
|
26
|
+
node .dsh-scratch\host-test.mjs
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## 1. GitHub Release(默认渠道)
|
|
30
|
+
|
|
31
|
+
先构建宿主 primitives 产物(构建依赖只在开发时安装,不随插件安装):
|
|
32
|
+
|
|
33
|
+
```powershell
|
|
34
|
+
cd math-desk
|
|
35
|
+
npm install
|
|
36
|
+
npm run build:host-ui
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
然后构建 zip:
|
|
40
|
+
|
|
41
|
+
```powershell
|
|
42
|
+
powershell -ExecutionPolicy Bypass -File .\build-dist.ps1
|
|
43
|
+
# 产出 ..\dist\dsh-pdf-workbench-X.Y.Z.zip
|
|
44
|
+
|
|
45
|
+
git add -A
|
|
46
|
+
git commit -m "vX.Y.Z: <一句话>"
|
|
47
|
+
git tag vX.Y.Z
|
|
48
|
+
git push origin main
|
|
49
|
+
git push --tags origin
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
创建 GitHub Release `vX.Y.Z`,上传:
|
|
53
|
+
|
|
54
|
+
- `dsh-pdf-workbench-X.Y.Z.zip`(必须)
|
|
55
|
+
- 可选 `dsh-pdf-workbench-X.Y.Z.tgz`(干净 worktree 里 `npm pack`,作为市场 npm 失败时的回退)
|
|
56
|
+
|
|
57
|
+
Release 说明直接复制 `CHANGELOG` 的该版本条目。
|
|
58
|
+
|
|
59
|
+
## 2. npm
|
|
60
|
+
|
|
61
|
+
npm 包名固定 **`dsh-pdf-workbench`**。必须从**干净 worktree / 干净 clone**发布,避免带上本机 `tools/py.cmd`、`tools/node.cmd`、`__pycache__`:
|
|
62
|
+
|
|
63
|
+
```powershell
|
|
64
|
+
cd <工作区>\math-desk
|
|
65
|
+
git worktree add ..\dist\npm-release vX.Y.Z
|
|
66
|
+
cd ..\dist\npm-release
|
|
67
|
+
npm login --auth-type=web
|
|
68
|
+
npm stage publish --access public
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
然后批准:
|
|
72
|
+
|
|
73
|
+
- 网页:https://www.npmjs.com/settings/minggemofashi/staged
|
|
74
|
+
- 或:`npm stage approve <stage-id>`(真实 6 位 OTP)
|
|
75
|
+
|
|
76
|
+
批准后验证:
|
|
77
|
+
|
|
78
|
+
```powershell
|
|
79
|
+
npm view dsh-pdf-workbench@X.Y.Z version
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
清理:
|
|
83
|
+
|
|
84
|
+
```powershell
|
|
85
|
+
cd <工作区>
|
|
86
|
+
git -C math-desk worktree remove ..\dist\npm-release
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
> 注意:npm 的 granular token 不能代替 2FA 发布;必须交互登录。不要用字面量 `你的6位验证码`。
|
|
90
|
+
|
|
91
|
+
## 3. 插件市场
|
|
92
|
+
|
|
93
|
+
首次上架:向 `awesome-dsh-plugin` 提交 `data/plugins/<owner>__<repo>.yml`;本插件条目已提交(PR 保留)。
|
|
94
|
+
|
|
95
|
+
首次之后:
|
|
96
|
+
|
|
97
|
+
- npm 包 `repository` 指向同一仓库时,dsh-market 自动做 npm 映射,**版本更新不需要再提 PR**;
|
|
98
|
+
- 只有改仓库地址、包名、分类或描述时才改 awesome 条目;
|
|
99
|
+
- 截图换图只需更新仓库 `screenshots.json`;
|
|
100
|
+
- 若 npm 发布失败,才回退到 tarball:上传新版本 `.tgz` 并更新条目的 `tarball` 字段(需要 PR)。
|
|
101
|
+
|
|
102
|
+
## 4. 一致性检查
|
|
103
|
+
|
|
104
|
+
- `package.json` 版本 = tag = GitHub Release = npm 版本;
|
|
105
|
+
- Release 的 zip / tgz 能下载;
|
|
106
|
+
- `README.md` 安装命令版本正确;
|
|
107
|
+
- 远程 `main` 包含发版提交;
|
|
108
|
+
- npm 页面可见,market 能搜到(缓存可能有延迟)。
|
|
109
|
+
|
|
110
|
+
## 5. 旧包处理(已完成)
|
|
111
|
+
|
|
112
|
+
旧包 `dsh-pdf-math-desk` 已从 npm 删除(`npm view` 返回 404),无需再处理;不要重新发布这个名称。
|
|
113
|
+
|
|
114
|
+
## 6. 不要做
|
|
115
|
+
|
|
116
|
+
- 不重新引入 `market/index.json`(收录由 awesome 列表负责);
|
|
117
|
+
- 不发 npm 前不更新市场条目的 npm 映射;
|
|
118
|
+
- 不用本机工作目录直接 `npm publish`(会带上未跟踪的包装脚本/pycache);
|
|
119
|
+
- 不在用户没说“发版”时升版本/tag/push/Release/npm。
|
package/docs/SIDE-PREVIEW.md
CHANGED
|
@@ -252,6 +252,9 @@ ctx.contextMenus.register({
|
|
|
252
252
|
- **同一章多个标签**:地址即内容 id,同一章在同一栏只有一张标签;重复打开是「指向同页」而不是新标签。
|
|
253
253
|
- **跨书跳转**:`openFromSide` 会先切书页再开阅读器,避免「返回章节」落到旧书。
|
|
254
254
|
- **桌面挂件遮挡**:`dsh-whale-widget-bowl` 的根节点是 `.dshwv-root`(`position:fixed; z-index:9999`,本身 `pointer-events:none`),跨插件无法把它压到页面下方,所以做成**悬停淡化**:指针进入预览时给 `body` 打 `data-pdfdesk-reading`,注入的样式把它淡到 28%;该插件不在时规则匹配不到元素。若以后挂件类名变了,淡化失效但不影响阅读功能。
|
|
255
|
+
- **不再重复打开同一份 PDF(2026-11-24)**:右栏以前是第二个独立 `getDocument`——同一章要下载两次、起两个 worker、解析两遍(38 MB 扫描章节实测首屏 327 ms,其中 233 ms 是重复加载)。现在阅读器、右栏、双语、遮罩都走 `sharedDocuments.claim(url, …)`:以完整 URL 为键,引用计数,最后一个视图离开后保留 30 s(最多 2 份)再销毁——跳到会话时「阅读器卸载 → 右栏挂载」正好落在保留窗口内,右栏只剩一次页面渲染(同文件实测 ~94 ms)。阅读器「重试」带 `retry=`、译文/叠加带 `rev=`,不同版本不会误用旧文档。
|
|
256
|
+
- **Host 侧按 Range 发送(2026-11-24)**:`/pdfdesk/pdf` 改由 `src/host/pdf-stream.js` 处理——`ETag`(大小+mtime)+ `If-None-Match → 304`、`Range → 206`、越界 `416`、`HEAD` 只回头,并用 `createReadStream` 流式发送而不是整份读进内存;`/pdfdesk/vendor/*` 加 `max-age=300` + `ETag`,pdf.js 的 1.26 MB worker 不再每开一个文档重下。响应头不再是 `cache-control: no-store` / `accept-ranges: none`。
|
|
257
|
+
- **同章批注同步只跑一次**:打开会话时阅读器和右栏都会调 `syncChapterAnnotations`(扫全章 localStorage + 拉镜像),10 s 内同章复用第一次结果。
|
|
255
258
|
|
|
256
259
|
## 10. 关键代码位置(`client.js`)
|
|
257
260
|
|
|
@@ -267,5 +270,6 @@ ctx.contextMenus.register({
|
|
|
267
270
|
| 注册 | `registerSidePreview(ctx)`(`apply` 末尾调用) |
|
|
268
271
|
| 打开右侧 | `openPdfInSession`(`sideTabAvailable` 判定后走自建地址) |
|
|
269
272
|
| 阅读器同步 | `WorkbenchPage` 的 `readerViewKey` / `readerLinkKey`;`ReaderView` 的 `docRev`、`remoteAnnotRev` 与写回判据 |
|
|
270
|
-
| 取数路由 | `src/host/routes.js` 的 `/pdf`(`variant`、`rev
|
|
273
|
+
| 取数路由 | `src/host/routes.js` 的 `/pdf`(`variant`、`rev`),文件由 `src/host/pdf-stream.js` 发送 |
|
|
274
|
+
| 共享文档 | `createDocumentCache` / `sharedDocuments` / `chapterPdfUrl`(阅读器、右栏、双语、遮罩共用) |
|
|
271
275
|
| 样式 | `CSS` 里的 `.md-side*`、`.md-annot-readonly`、`.md-annot-edit` |
|
package/docs/preview.svg
ADDED
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="640" height="300" viewBox="0 0 640 300" role="img" aria-label="A reading workbench: books on a shelf, an annotated PDF page, and a side conversation">
|
|
2
|
+
<defs>
|
|
3
|
+
<filter id="soft" x="-20%" y="-20%" width="140%" height="140%">
|
|
4
|
+
<feDropShadow dx="0" dy="10" stdDeviation="14" flood-color="#12202b" flood-opacity=".12"/>
|
|
5
|
+
</filter>
|
|
6
|
+
<linearGradient id="cover" x1="0" y1="0" x2="1" y2="1">
|
|
7
|
+
<stop offset="0" stop-color="#12202b"/>
|
|
8
|
+
<stop offset="1" stop-color="#2a4a5e"/>
|
|
9
|
+
</linearGradient>
|
|
10
|
+
<linearGradient id="blue" x1="0" y1="0" x2="0" y2="1">
|
|
11
|
+
<stop offset="0" stop-color="#5b8cff"/>
|
|
12
|
+
<stop offset="1" stop-color="#2f6df6"/>
|
|
13
|
+
</linearGradient>
|
|
14
|
+
</defs>
|
|
15
|
+
|
|
16
|
+
<rect x="0" y="0" width="640" height="300" rx="18" fill="#f6f8fa"/>
|
|
17
|
+
|
|
18
|
+
<!-- shelf / books -->
|
|
19
|
+
<g filter="url(#soft)">
|
|
20
|
+
<rect x="42" y="66" width="86" height="150" rx="7" fill="#ffffff" stroke="#dbe3e9"/>
|
|
21
|
+
<rect x="53" y="78" width="64" height="88" rx="4" fill="url(#cover)"/>
|
|
22
|
+
<path d="M62 96h46M62 106h34" stroke="#8fa9b9" stroke-width="3" stroke-linecap="round" opacity=".8"/>
|
|
23
|
+
<circle cx="85" cy="132" r="13" fill="none" stroke="#5b8cff" stroke-width="2" opacity=".8"/>
|
|
24
|
+
<rect x="59" y="180" width="52" height="5" rx="2.5" fill="#cfd9e1"/>
|
|
25
|
+
<rect x="59" y="191" width="34" height="5" rx="2.5" fill="#e2e8ed"/>
|
|
26
|
+
|
|
27
|
+
<rect x="142" y="86" width="86" height="130" rx="7" fill="#ffffff" stroke="#dbe3e9"/>
|
|
28
|
+
<rect x="153" y="98" width="64" height="78" rx="4" fill="#eef3f7" stroke="#d7e0e7"/>
|
|
29
|
+
<path d="M166 118h38M166 127h26" stroke="#aab8c3" stroke-width="3" stroke-linecap="round"/>
|
|
30
|
+
<path d="M166 148c8-14 14-16 18-8 4 7 8 8 14 1" fill="none" stroke="#2f6df6" stroke-width="2.4" stroke-linecap="round"/>
|
|
31
|
+
<rect x="159" y="192" width="52" height="5" rx="2.5" fill="#cfd9e1"/>
|
|
32
|
+
<rect x="159" y="203" width="30" height="5" rx="2.5" fill="#e2e8ed"/>
|
|
33
|
+
</g>
|
|
34
|
+
|
|
35
|
+
<!-- page -->
|
|
36
|
+
<g filter="url(#soft)">
|
|
37
|
+
<rect x="258" y="38" width="200" height="222" rx="10" fill="#ffffff" stroke="#dfe6ec"/>
|
|
38
|
+
<rect x="274" y="56" width="168" height="6" rx="3" fill="#c9d4dd"/>
|
|
39
|
+
<rect x="274" y="72" width="120" height="6" rx="3" fill="#e2e8ee"/>
|
|
40
|
+
<rect x="274" y="94" width="150" height="5" rx="2.5" fill="#dde5eb"/>
|
|
41
|
+
<rect x="274" y="106" width="160" height="5" rx="2.5" fill="#dde5eb"/>
|
|
42
|
+
<rect x="274" y="118" width="132" height="5" rx="2.5" fill="#dde5eb"/>
|
|
43
|
+
<rect x="274" y="136" width="156" height="5" rx="2.5" fill="#dde5eb"/>
|
|
44
|
+
<rect x="274" y="148" width="144" height="5" rx="2.5" fill="#dde5eb"/>
|
|
45
|
+
|
|
46
|
+
<!-- ink mark -->
|
|
47
|
+
<path d="M286 196c12-22 24-27 32-16 7 9 12 11 20 2 8-9 16-3 19 8 2 8 10 9 18 3" fill="none" stroke="#2f6df6" stroke-width="3.2" stroke-linecap="round"/>
|
|
48
|
+
<path d="M296 218c18-2 38-2 56 0" fill="none" stroke="#12202b" stroke-width="2.4" stroke-linecap="round" opacity=".55"/>
|
|
49
|
+
|
|
50
|
+
<!-- selection box -->
|
|
51
|
+
<rect x="316" y="174" width="88" height="54" rx="4" fill="#2f6df6" fill-opacity=".05" stroke="#2f6df6" stroke-width="1.4" stroke-dasharray="5 4"/>
|
|
52
|
+
|
|
53
|
+
<!-- corner plus handles -->
|
|
54
|
+
<g fill="#ffffff" stroke="#2f6df6" stroke-width="1.3">
|
|
55
|
+
<rect x="352" y="28" width="12" height="12" rx="2"/>
|
|
56
|
+
<rect x="352" y="258" width="12" height="12" rx="2"/>
|
|
57
|
+
<rect x="248" y="143" width="12" height="12" rx="2"/>
|
|
58
|
+
<rect x="456" y="143" width="12" height="12" rx="2"/>
|
|
59
|
+
</g>
|
|
60
|
+
<g stroke="#2f6df6" stroke-width="1.5" stroke-linecap="round">
|
|
61
|
+
<path d="M358 31v6M355 34h6M358 261v6M355 264h6M251 146v6M248 149h6M459 146v6M456 149h6"/>
|
|
62
|
+
</g>
|
|
63
|
+
</g>
|
|
64
|
+
|
|
65
|
+
<!-- conversation -->
|
|
66
|
+
<g filter="url(#soft)">
|
|
67
|
+
<rect x="486" y="72" width="118" height="154" rx="12" fill="#ffffff" stroke="#dfe6ec"/>
|
|
68
|
+
<circle cx="508" cy="96" r="9" fill="#12202b"/>
|
|
69
|
+
<path d="M504.5 96l2.5 2.5 4.5-5" fill="none" stroke="#ffffff" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"/>
|
|
70
|
+
<rect x="524" y="91" width="52" height="6" rx="3" fill="#cfd9e1"/>
|
|
71
|
+
<rect x="502" y="116" width="84" height="5" rx="2.5" fill="#e1e8ee"/>
|
|
72
|
+
<rect x="502" y="128" width="70" height="5" rx="2.5" fill="#e1e8ee"/>
|
|
73
|
+
<rect x="502" y="140" width="78" height="5" rx="2.5" fill="#e1e8ee"/>
|
|
74
|
+
|
|
75
|
+
<rect x="502" y="164" width="72" height="42" rx="10" fill="#2f6df6" fill-opacity=".1" stroke="#2f6df6" stroke-opacity=".25"/>
|
|
76
|
+
<rect x="512" y="176" width="50" height="4" rx="2" fill="#2f6df6" opacity=".55"/>
|
|
77
|
+
<rect x="512" y="186" width="36" height="4" rx="2" fill="#2f6df6" opacity=".35"/>
|
|
78
|
+
|
|
79
|
+
<path d="M536 212c0 6-6 10-13 10l-9 6 2-9c-4-2-6-5-6-9 0-7 7-12 13-12s13 5 13 14z" fill="#12202b"/>
|
|
80
|
+
</g>
|
|
81
|
+
|
|
82
|
+
<!-- baseline accents -->
|
|
83
|
+
<path d="M42 266h556" stroke="#e1e7ec" stroke-width="1.5" stroke-linecap="round"/>
|
|
84
|
+
<circle cx="42" cy="266" r="3" fill="#2f6df6"/>
|
|
85
|
+
<circle cx="598" cy="266" r="3" fill="#cfd9e1"/>
|
|
86
|
+
</svg>
|
package/icon.svg
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
<svg xmlns="http://www.w3.org/2000/svg" width="36" height="36" viewBox="0 0
|
|
2
|
-
<rect x="
|
|
3
|
-
<rect x="9
|
|
4
|
-
<
|
|
5
|
-
<path d="
|
|
6
|
-
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="36" height="36" viewBox="0 0 36 36" role="img" aria-label="PDF reading workbench">
|
|
2
|
+
<rect x="5" y="7" width="20" height="24" rx="2.5" fill="#12202b"/>
|
|
3
|
+
<rect x="9" y="4" width="22" height="26" rx="2.5" fill="#ffffff" stroke="#d5dde3" stroke-width="1.2"/>
|
|
4
|
+
<path d="M13 11h14M13 15h10" stroke="#9aa8b3" stroke-width="1.6" stroke-linecap="round"/>
|
|
5
|
+
<path d="M12.5 24.5c2.2-3.6 4.2-4.6 5.6-2.8 1.1 1.4 2 1.8 3.4.6 1.5-1.3 2.8-.6 3.5 1.1" fill="none" stroke="#2f6df6" stroke-width="2.2" stroke-linecap="round"/>
|
|
6
|
+
<path d="M8 31.5h20" stroke="#2f6df6" stroke-width="2" stroke-linecap="round"/>
|
|
7
|
+
</svg>
|
package/index.js
CHANGED
|
@@ -30,8 +30,8 @@ import { purgeArchivedBlanks } from './src/host/purge.js'
|
|
|
30
30
|
/** Cordis plugin name. */
|
|
31
31
|
export const name = 'pdfdesk'
|
|
32
32
|
|
|
33
|
-
/** The browser carrier
|
|
34
|
-
export const inject = ['webServer']
|
|
33
|
+
/** The browser carrier and the trust fence guarding its routes. */
|
|
34
|
+
export const inject = ['webServer', 'connection']
|
|
35
35
|
|
|
36
36
|
/**
|
|
37
37
|
* Mount the `/pdfdesk/*` routes and name pending sessions on their first turn.
|
|
@@ -41,6 +41,7 @@ export const inject = ['webServer']
|
|
|
41
41
|
*/
|
|
42
42
|
export function apply(ctx, rawConfig) {
|
|
43
43
|
const config = resolveConfig(rawConfig)
|
|
44
|
+
const connection = ctx.get('connection')
|
|
44
45
|
const pending = new PendingStore(config.pendingPath)
|
|
45
46
|
const links = new LinksStore(config.linksPath)
|
|
46
47
|
const pressure = new PressureStore(config.pressurePath)
|
|
@@ -115,7 +116,20 @@ export function apply(ctx, rawConfig) {
|
|
|
115
116
|
}
|
|
116
117
|
|
|
117
118
|
const handler = createHandler(config, {
|
|
119
|
+
// Every route sits behind DSH's own Host/Origin and browser-login fence.
|
|
120
|
+
// A website open in the user's browser cannot call the workbench API, even
|
|
121
|
+
// on loopback; without this the routes rely on the socket address alone.
|
|
122
|
+
requestRejection: request => {
|
|
123
|
+
if (connection === undefined || connection === null || typeof connection.requestRejection !== 'function') return undefined
|
|
124
|
+
return connection.requestRejection(request)
|
|
125
|
+
},
|
|
118
126
|
md2texScript: join(dirname(fileURLToPath(import.meta.url)), 'tools', 'md2tex.py'),
|
|
127
|
+
// Session services the base-session route drives (stage 7.6).
|
|
128
|
+
sessionServices: () => ({
|
|
129
|
+
agents: ctx.get('agents'),
|
|
130
|
+
query: ctx.get('sessionQuery'),
|
|
131
|
+
workspace: ctx.get('workspaceRegistry'),
|
|
132
|
+
}),
|
|
119
133
|
pending,
|
|
120
134
|
links,
|
|
121
135
|
libraries,
|
|
@@ -173,6 +187,8 @@ export function apply(ctx, rawConfig) {
|
|
|
173
187
|
|
|
174
188
|
ctx.effect(() => ctx.webServer.register({ kind: 'prefix', path: PREFIX, handler }), 'pdfdesk: routes')
|
|
175
189
|
|
|
190
|
+
|
|
191
|
+
|
|
176
192
|
// The first turn names a created session; every finished turn records how full
|
|
177
193
|
// its context is, so "New" can decide between continuing and starting over.
|
|
178
194
|
ctx.effect(() => ctx.on('session/event', (session, event) => {
|
package/locale/en.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"meta": {
|
|
3
3
|
"title": "PDF reading · ask as you read",
|
|
4
|
-
"description": "A PDF reading
|
|
4
|
+
"description": "A workbench for close reading of full-page PDFs, opened from the “PDF reading” sidebar entry. Libraries and shelves are organised as book → chapter; the reader supports single/continuous pages, ink and marquee annotations, an off-page canvas, bilingual view and translation overlays. Each chapter can start extract, Q&A and exercise conversations, and also carries attachments, printing and machine-to-machine migration. Libraries and notes stay on this machine; PDFs are never pushed into model context automatically. Translation needs Python + a DeepSeek API key; PPT-to-PDF optionally uses local Office or LibreOffice.",
|
|
5
5
|
"detail": "docs/DETAIL.md"
|
|
6
6
|
}
|
|
7
7
|
}
|
package/locale/zh.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"meta": {
|
|
3
3
|
"title": "PDF 阅读 · 随时问答",
|
|
4
|
-
"description": "
|
|
4
|
+
"description": "面向整页 PDF 精读的工作台,从左侧栏「PDF 阅读」进入。书库与书架按「书 → 章」组织;阅读器支持单页/连续、手写与框选批注、页外画布、双语对照和覆盖层;每章可直接提取、答疑、习题,并带附件、打印与整机数据迁移。所有书库与笔记保存在本机,PDF 不会自动进入模型上下文;翻译需要 Python + DeepSeek API Key,PPT 转 PDF 可选本机 Office/LibreOffice。",
|
|
5
5
|
"detail": "docs/DETAIL.md"
|
|
6
6
|
}
|
|
7
7
|
}
|
package/package.json
CHANGED
package/screenshots.json
CHANGED
|
@@ -1,8 +1,13 @@
|
|
|
1
|
-
[
|
|
2
|
-
"assets/screenshot-hero.jpg",
|
|
3
|
-
"assets/screenshot-shelf.jpg",
|
|
4
|
-
"assets/screenshot-reader.jpg",
|
|
5
|
-
"assets/screenshot-bilingual.jpg",
|
|
6
|
-
"assets/screenshot-overlay.jpg",
|
|
7
|
-
"assets/screenshot-qa.jpg"
|
|
8
|
-
|
|
1
|
+
[
|
|
2
|
+
"assets/screenshot-hero.jpg",
|
|
3
|
+
"assets/screenshot-shelf.jpg",
|
|
4
|
+
"assets/screenshot-reader.jpg",
|
|
5
|
+
"assets/screenshot-bilingual.jpg",
|
|
6
|
+
"assets/screenshot-overlay.jpg",
|
|
7
|
+
"assets/screenshot-qa.jpg",
|
|
8
|
+
"assets/screenshot-settings-reading.jpg",
|
|
9
|
+
"assets/screenshot-settings-data.jpg",
|
|
10
|
+
"assets/screenshot-attachments.jpg",
|
|
11
|
+
"assets/screenshot-canvas.jpg",
|
|
12
|
+
"assets/screenshot-questions.jpg"
|
|
13
|
+
]
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The subset of the host primitives used by the workbench.
|
|
3
|
-
*
|
|
4
|
-
* Kept deliberately narrow: importing the package root and letting esbuild
|
|
5
|
-
* tree-shake keeps the vendor bundle small and avoids pulling in Markdown,
|
|
6
|
-
* Shiki and KaTeX for three controls.
|
|
7
|
-
*/
|
|
8
|
-
export { Button } from '@deepseek-ai/dsh-client-ui-primitives/src/Button.tsx'
|
|
9
|
-
export { Input } from '@deepseek-ai/dsh-client-ui-primitives/src/Input.tsx'
|
|
10
|
-
export { Modal } from '@deepseek-ai/dsh-client-ui-primitives/src/Modal.tsx'
|
|
11
|
-
export { Menu } from '@deepseek-ai/dsh-client-ui-primitives/src/Menu.tsx'
|
|
1
|
+
/**
|
|
2
|
+
* The subset of the host primitives used by the workbench.
|
|
3
|
+
*
|
|
4
|
+
* Kept deliberately narrow: importing the package root and letting esbuild
|
|
5
|
+
* tree-shake keeps the vendor bundle small and avoids pulling in Markdown,
|
|
6
|
+
* Shiki and KaTeX for three controls.
|
|
7
|
+
*/
|
|
8
|
+
export { Button } from '@deepseek-ai/dsh-client-ui-primitives/src/Button.tsx'
|
|
9
|
+
export { Input } from '@deepseek-ai/dsh-client-ui-primitives/src/Input.tsx'
|
|
10
|
+
export { Modal } from '@deepseek-ai/dsh-client-ui-primitives/src/Modal.tsx'
|
|
11
|
+
export { Menu } from '@deepseek-ai/dsh-client-ui-primitives/src/Menu.tsx'
|
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
'use strict'
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Minimal react/jsx-runtime shim for the host-primitives bundle.
|
|
5
|
-
*
|
|
6
|
-
* The primitives package is compiled against React's automatic runtime, but
|
|
7
|
-
* the DSH client module table exposes only `react`. This shim keeps the bundle
|
|
8
|
-
* on that single React instance instead of shipping a second copy.
|
|
9
|
-
*/
|
|
10
|
-
const React = require('react')
|
|
11
|
-
|
|
12
|
-
function normalize(props, key) {
|
|
13
|
-
const next = props === null || props === undefined ? {} : { ...props }
|
|
14
|
-
if (key !== undefined && key !== null) next.key = key
|
|
15
|
-
return next
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
exports.Fragment = React.Fragment
|
|
19
|
-
exports.jsx = (type, props, key) => React.createElement(type, normalize(props, key))
|
|
20
|
-
exports.jsxs = (type, props, key) => React.createElement(type, normalize(props, key))
|
|
21
|
-
exports.jsxDEV = (type, props, key) => React.createElement(type, normalize(props, key))
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Minimal react/jsx-runtime shim for the host-primitives bundle.
|
|
5
|
+
*
|
|
6
|
+
* The primitives package is compiled against React's automatic runtime, but
|
|
7
|
+
* the DSH client module table exposes only `react`. This shim keeps the bundle
|
|
8
|
+
* on that single React instance instead of shipping a second copy.
|
|
9
|
+
*/
|
|
10
|
+
const React = require('react')
|
|
11
|
+
|
|
12
|
+
function normalize(props, key) {
|
|
13
|
+
const next = props === null || props === undefined ? {} : { ...props }
|
|
14
|
+
if (key !== undefined && key !== null) next.key = key
|
|
15
|
+
return next
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
exports.Fragment = React.Fragment
|
|
19
|
+
exports.jsx = (type, props, key) => React.createElement(type, normalize(props, key))
|
|
20
|
+
exports.jsxs = (type, props, key) => React.createElement(type, normalize(props, key))
|
|
21
|
+
exports.jsxDEV = (type, props, key) => React.createElement(type, normalize(props, key))
|