dsh-linked-workspace 0.34.0 → 0.35.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/CHANGELOG.md +65 -0
- package/docs/API.md +19 -0
- package/docs/VERIFY.md +70 -0
- package/lib/client.js +460 -127
- package/lib/index.js +441 -6
- package/lib/office.js +118 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,70 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.35.0 — 2026-12-03
|
|
4
|
+
|
|
5
|
+
- **The PDF page view lost its title/author row** — it was a preview pretending to be a form, and nothing wrote
|
|
6
|
+
those fields back.
|
|
7
|
+
- **The page counter shows real numbers**: `docPageOf` used single braces while `makeT` fills `{{name}}`, so the
|
|
8
|
+
counter rendered the placeholders; page responses also carry `pageCount` now, and switching a PDF to the page
|
|
9
|
+
view fetches page 1 when nothing was loaded yet (before, the stepper had no total to work with).
|
|
10
|
+
- **PDF, Office pages and the framed viewer zoom**: `−` / `+` / percentage in the toolbar; the frame is widened
|
|
11
|
+
instead of scaled so the browser viewer re-lays out the text, and the frame body scrolls.
|
|
12
|
+
- **An image that fails through the byte route falls back to the JSON read** (`media.read`, base64): the error now
|
|
13
|
+
reports the route status and body instead of repeating "无法预览图片".
|
|
14
|
+
|
|
15
|
+
- **Opening an HTML file no longer crashes the tab**: the HTML preview counted bytes with `Buffer`, a Node
|
|
16
|
+
global that does not exist in the browser, so the first render threw "Buffer is not defined" and the whole
|
|
17
|
+
directory tab went down (and stayed down after a restart, because the tab is restored and re-rendered).
|
|
18
|
+
The count now goes through `TextEncoder`.
|
|
19
|
+
- **A render error stays inside the tab**: both tab types are wrapped in a boundary that explains the failure
|
|
20
|
+
and offers "Retry", instead of letting the exception reach `dsh-better-sidebar`, which then showed its own
|
|
21
|
+
error for the tab and kept re-rendering the broken subtree on every restart.
|
|
22
|
+
- The client bundle is now checked for Node-only globals: `test/client-smoke.mjs` fails if `Buffer` appears in
|
|
23
|
+
it, and asserts the boundary and the byte-count helper are present.
|
|
24
|
+
|
|
25
|
+
- **CSV tables render only the visible window**: a 20k-row sheet no longer becomes 20k DOM rows, and the
|
|
26
|
+
1000-row cap is now 20000 with the note saying so.
|
|
27
|
+
- **Markdown gets an outline**: the document toolbar grows a "Outline" toggle for previews with two or more
|
|
28
|
+
headings; entries jump to their heading.
|
|
29
|
+
- **The local half of a workspace no longer dials the host** before serving bytes: `/fs/…/local/…` reads from
|
|
30
|
+
disk, so a workspace whose machine is unreachable still shows local images and PDFs.
|
|
31
|
+
|
|
32
|
+
- **One type table for every document family**: `.docx`/`.doc`/`.odt`, `.xlsx`/`.xls`/`.ods`, `.pptx`/`.ppt`/`.odp`
|
|
33
|
+
are all "office" now. The legacy binary formats go through LibreOffice for text extraction as well, so `read_doc`
|
|
34
|
+
and the preview no longer refuse them.
|
|
35
|
+
- **A read-only byte route**: `GET /dsh-linked-workspace/fs/linked/<id>/remote/…`, `…/local/…` and
|
|
36
|
+
`/fs/remote/<id>/…` serve files straight from the workspace (Range, `content-length`, `nosniff`,
|
|
37
|
+
`Cache-Control: no-store`, and `Content-Security-Policy: sandbox` for HTML/SVG). Paths are re-encoded per
|
|
38
|
+
segment and escapes are refused.
|
|
39
|
+
- **Images are streamed, not embedded**: the image tab loads through the route, so the 24 MB inline cap and the
|
|
40
|
+
base64 copy are gone and animated GIF/SVG work again.
|
|
41
|
+
- **HTML preview loads the real file**: the iframe now has a `src` (still `sandbox="allow-scripts"`), so relative
|
|
42
|
+
css/js/img resolve. Source editing and `expectedMtime` saving are unchanged.
|
|
43
|
+
- **PDF opens in the browser's viewer** (selection, search, outline, zoom) instead of a page image; the old
|
|
44
|
+
page-by-page view with rotate/delete stays one click away.
|
|
45
|
+
- **Office documents are framed from the converted PDF**: new `docs.officePdf { path }` returns
|
|
46
|
+
`/dsh-linked-workspace/cache/<sha1>.pdf` plus the page count, backed by the existing content-hash cache.
|
|
47
|
+
Machines without LibreOffice fall back to the per-page raster path.
|
|
48
|
+
- **Markdown relative images work**: `docs.mdPreview` rewrites relative `img src` to the byte route, and the
|
|
49
|
+
preview cache key now includes the document path (the same text in two folders renders differently).
|
|
50
|
+
- **Host**: `apiRevision` 17 → 18.
|
|
51
|
+
|
|
52
|
+
## 0.34.1 — 2026-12-02
|
|
53
|
+
|
|
54
|
+
- **Word / Excel / PowerPoint 现在能直接看了**:文档面板不再把 .docx/.xlsx/.pptx 拆成段落、单元格、文字块来编辑,
|
|
55
|
+
而是交给 LibreOffice 转成 PDF、再按页渲染成图片 —— 版式、表格、配色、公式位置都保持原样,只读。
|
|
56
|
+
工具栏有 ‹ 页码 › 与「重新加载」;同一份文件第二次打开走缓存(首次约 8–11 秒,之后约 0.5 秒一页)。
|
|
57
|
+
- **网页(HTML)可以编辑了**:HTML 标签页多了「编辑 / 预览」切换,编辑用的是源码文本框,`Ctrl/⌘+S` 保存,
|
|
58
|
+
预览仍在 `sandbox="allow-scripts"` 的 iframe 里跑,不碰 DSH 界面。保存走 `fs.write` / `local.write`,
|
|
59
|
+
带 `expectedMtime` 冲突检查。
|
|
60
|
+
- **依赖说明**:Office 预览需要本机有 LibreOffice(`soffice`);没有时该标签页会明确说明「这台机器上没有
|
|
61
|
+
LibreOffice」,不再默默显示文字视图。可用 `DSH_LINKED_WORKSPACE_SOFFICE` 指定路径。
|
|
62
|
+
- **Host**:新增 `docs.officePage { path, page }`(转换 + 分页渲染,按内容哈希缓存 PDF),`apiRevision` 16 → 17。
|
|
63
|
+
|
|
64
|
+
- **Markdown 编辑模式也能批量替换了**:在文档面板点「编辑」后按 `Ctrl/⌘+F`,查找条里多了替换框、「替换」
|
|
65
|
+
与「全部替换」。匹配规则与查找一致(不区分大小写的纯文本,不支持正则);「替换」只改当前命中并保持光标位置,
|
|
66
|
+
「全部替换」从后往前改,避免偏移互相影响。改完仍是原来的保存路径(`Ctrl/⌘+S` 或「保存」)。
|
|
67
|
+
|
|
3
68
|
## 0.34.0 — 2026-12-01
|
|
4
69
|
|
|
5
70
|
- **工作区外下载不会再点出两份**:下载期间按钮变成「下载中…」并禁用,结束后恢复;下载完成的页脚多一个
|
package/docs/API.md
CHANGED
|
@@ -26,6 +26,8 @@ Codes: `BAD_REQUEST`, `NOT_FOUND`, `SSH_CONNECT`, `AUTH_FAILED`,
|
|
|
26
26
|
| `docs.create` | `{ path, kind?, linkedId?, remoteId? }` | `{ kind, path, size, mtime }` |
|
|
27
27
|
| `docs.mdPreview` | `{ path, text?, linkedId?, remoteId? }` | `{ kind: 'markdown-preview', html }` (rendered in-process; the fragment carries the KaTeX stylesheet and expects the plugin's `/dsh-linked-workspace/assets/katex/` fonts; the last 3 renders are cached by content hash) or `{ kind: 'markdown-preview-too-large', chars \| bytes, limit }` for a document above 512 Ki characters — the viewer must show the editor instead |
|
|
28
28
|
| `docs.mdPdf` | `{ path, text?, linkedId?, remoteId? }` | `{ kind: "pdf", path, size, mtime }` |
|
|
29
|
+
| `docs.officePage` | `{ path, linkedId?/remoteId?, page }` | `{ kind, engine, pageCount, pages[{ index, png }] }` (docx/xlsx/pptx only: converts to PDF with LibreOffice, caches the PDF per content hash, renders the page as a PNG) |
|
|
30
|
+
| `docs.officePdf` | `{ path, linkedId?/remoteId? }` | `{ kind, engine, path, mtime, size, pageCount, url }` (converts once, caches by content hash, returns `/dsh-linked-workspace/cache/<sha1>.pdf`) |
|
|
29
31
|
|
|
30
32
|
## Records
|
|
31
33
|
|
|
@@ -177,6 +179,23 @@ Under `$DSH_HOME/linked-workspace/`:
|
|
|
177
179
|
- Local linked directories also hold `.local/linked.json` (same binding without
|
|
178
180
|
secrets) and the optional `.remote/` mirror.
|
|
179
181
|
|
|
182
|
+
## HTTP routes
|
|
183
|
+
|
|
184
|
+
Read-only, no JSON envelope, same trust gate as `/api`:
|
|
185
|
+
|
|
186
|
+
| Route | Purpose |
|
|
187
|
+
| --- | --- |
|
|
188
|
+
| `GET /dsh-linked-workspace/fs/linked/<id>/remote/<relative>` | a file under a linked workspace remote root |
|
|
189
|
+
| `GET /dsh-linked-workspace/fs/linked/<id>/local/<relative>` | a file under that workspace local directory |
|
|
190
|
+
| `GET /dsh-linked-workspace/fs/remote/<id>/<relative>` | a file under a remote workspace |
|
|
191
|
+
| `GET /dsh-linked-workspace/fs/local/<absolute segments>` | any absolute local path inside a configured workspace |
|
|
192
|
+
| `GET /dsh-linked-workspace/cache/<sha1>.pdf` | a converted Office document |
|
|
193
|
+
|
|
194
|
+
All of them answer `GET`/`HEAD` only, honour a single-range `Range` request (`206` + `Content-Range`), send
|
|
195
|
+
`Cache-Control: no-store` and `X-Content-Type-Options: nosniff`, and add `Content-Security-Policy: sandbox` for
|
|
196
|
+
`text/html` and `image/svg+xml`. Path segments are decoded individually and any `..`, empty segment, backslash or
|
|
197
|
+
NUL is refused.
|
|
198
|
+
|
|
180
199
|
## Agent tools
|
|
181
200
|
|
|
182
201
|
`linked_workspace` (Host tool, JSON-Schema parameters) actions: `list`, `info`,
|
package/docs/VERIFY.md
CHANGED
|
@@ -1,5 +1,75 @@
|
|
|
1
1
|
# Manual verification checklist
|
|
2
2
|
|
|
3
|
+
## PDF 页码、图片与缩放(未发布)
|
|
4
|
+
|
|
5
|
+
16. 打开一个多页 PDF:默认是浏览器查看器;点「逐页视图」→ 页码应显示 `第 1 / N 页`(N 与真实页数一致),
|
|
6
|
+
工具栏有 `−` `+` 与百分比,点 `+` 页图变大且可横向滚动。
|
|
7
|
+
17. 切回渲染视图后点 `+`:iframe 变宽、文字随之放大,容器可滚动。
|
|
8
|
+
18. PDF 逐页视图里不再出现「标题 / 作者」输入框。
|
|
9
|
+
19. 打开一张 workspace 里的 PNG(几百 KB):正常显示;断网或把主机改坏后再打开同一张,应回退到
|
|
10
|
+
`media.read`(图片仍显示),或在错误里给出路由的 4xx/5xx 与响应文字。
|
|
11
|
+
20. 图片预览:`Ctrl + 滚轮` 缩放,工具栏「适应」「1:1」有效。
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
## HTML 预览与标签页崩溃(未发布)
|
|
15
|
+
|
|
16
|
+
13. 在联动工作区的**本地**目录里放一个 `probe.html`,从本地树点开:应显示渲染后的页面(带样式),
|
|
17
|
+
状态栏显示 `HTML` 与文件大小,控制台没有 `Buffer is not defined`。
|
|
18
|
+
14. 把该文件的样式改坏或塞入非法 JS 后再次打开:最多显示一条错误提示,标签页本身仍可切换、可关闭。
|
|
19
|
+
15. 重启 DSH 后再次打开同一标签页:应正常渲染(错误边界把问题留在标签内,不再需要清状态)。
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
## 阶段 3 与 iframe 真机验证(未发布)
|
|
23
|
+
|
|
24
|
+
9. 打开一个 2 万行的 CSV:首屏立刻出现,滚动到中部/底部时行内容跟着出现(只渲染可视窗口),
|
|
25
|
+
底部提示「仅显示前 20000 行」。
|
|
26
|
+
10. 打开一篇有多级标题的 Markdown:工具栏出现「目录」,点一下弹出浮动目录;点条目跳到对应标题;
|
|
27
|
+
只有一两个标题时不出现该按钮。
|
|
28
|
+
11. 断网或把某个联动工作区的主机改坏,再用本地树打开 `E:\…` 下的图片/PDF:仍应正常显示
|
|
29
|
+
(本地字节不再先拨 SSH)。
|
|
30
|
+
12. 在真实浏览器里打开 PDF 标签:应出现浏览器自带的 PDF 阅读器(可选中文字、搜索),
|
|
31
|
+
而不是空白或「无法加载」的破图。
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
## 只读字节路由与真实渲染(未发布)
|
|
35
|
+
|
|
36
|
+
1. 在联动工作区里放一张 PNG 与一张动图 GIF:在目录栏打开它们 → 图片正常显示、GIF 会动;状态栏不再显示 24 MB 上限相关的报错。
|
|
37
|
+
2. 放一个 `page.html`(引用同目录 `style.css` 与 `img.png`):打开后预览应带上样式与图片;点「编辑」改一行保存,刷新后仍是新内容。
|
|
38
|
+
3. 打开一个 `.pdf`:默认是浏览器查看器(可选中文字、搜索、翻页),点工具栏「逐页视图」切回原来的页图模式(旋转/删页仍可用)。
|
|
39
|
+
4. 打开 `.docx`/`.pptx`/`.xlsx`:默认直接显示 PDF 渲染结果(`‹ 页码 ›` 在「逐页视图」下出现);同一文件再开一次应在 1 秒内出图。
|
|
40
|
+
5. 旧格式:把 `probe.docx` 改名为 `probe.doc` 或复制为 `.odt`,打开后仍应渲染(类型表已含 `.doc/.odt` 等)。
|
|
41
|
+
6. Markdown 里写 ``:预览中图片正常显示(相对路径已重写到字节路由)。
|
|
42
|
+
7. 安全:在浏览器地址栏把路由改成 `…/fs/linked/<id>/remote/../../etc/passwd` → 应返回 400/404,不泄露任何文件;
|
|
43
|
+
对同一路由发 `POST` → 405。
|
|
44
|
+
8. 本地文件:在联动工作区的本地目录里放一张图,用本地标签打开 → 正常显示;把地址改成 `C:\Windows\win.ini` → 400。
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
## Office 渲染预览与 HTML 编辑(未发布)
|
|
48
|
+
|
|
49
|
+
1. **准备**:本机需装 LibreOffice(`C:\Program Files\LibreOffice\program\soffice.exe`)。没有时打开 Office 文件应显示
|
|
50
|
+
「这台机器上没有 LibreOffice,无法渲染 Office 文档」,而不是空白或文字视图。
|
|
51
|
+
2. 在目录栏打开一个 `.pptx`(3 页、含标题/项目符号/表格):应直接看到**渲染后的第 1 页**,标题居中、表格带表头底色;
|
|
52
|
+
工具栏右侧有 `‹ 1 / 3 ›` 与「重新加载」,**没有**「保存」按钮。
|
|
53
|
+
3. 点 `›` 翻到第 2、3 页:每页约 0.5 秒(已转换过),版式与 PowerPoint 里一致。
|
|
54
|
+
4. 打开一个 `.docx`:标题、正文、列表、表格都应正确渲染;打开 `.xlsx`:两个 sheet 各一页、列宽与换行正确。
|
|
55
|
+
5. 关掉再打开同一个文件:不走重新转换(< 1 秒出图)。
|
|
56
|
+
6. 打开一个 `.html`:默认预览(iframe),点「编辑」切到源码文本框,改一行后 `Ctrl/⌘+S`(或点「保存」),
|
|
57
|
+
状态栏「未保存」消失、出现「已保存」;再点「预览」应看到改动。
|
|
58
|
+
7. 让 `.html` 在别处被改动后再保存:应报冲突并要求重新加载(`expectedMtime` 生效)。
|
|
59
|
+
8. Markdown 行为不变:默认预览、可切编辑、`Ctrl/⌘+F` 有查找与替换。
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
## Markdown 编辑模式的替换(未发布)
|
|
63
|
+
|
|
64
|
+
1. 在目录栏打开一个 `.md`,点工具栏「编辑」进入编辑模式,按 `Ctrl/⌘+F`:查找条里应有第二个输入框(替换)
|
|
65
|
+
和「替换」「全部替换」两个按钮。
|
|
66
|
+
2. 查找框输入 `alpha`:计数器显示命中数(不区分大小写,`ALPHA` 也算)。
|
|
67
|
+
3. 替换框输入 `OMEGA`,点「全部替换」:正文里所有命中都变成 `OMEGA`,计数器变「无匹配」。
|
|
68
|
+
4. 再查 `gamma`、替换为 `delta`,点「替换」(或在替换框按 Enter):只改当前这一处,光标落在 `delta` 之后。
|
|
69
|
+
5. `Ctrl/⌘+S` 或点「保存」:重新打开该文件确认改动已写回远端。
|
|
70
|
+
6. 预览模式下按 `Ctrl/⌘+F` 不应弹出查找条(替换只在编辑模式可用)。
|
|
71
|
+
|
|
72
|
+
|
|
3
73
|
## 工作区外:下载、图片与额外根目录搜索(未发布)
|
|
4
74
|
|
|
5
75
|
1. 额外根目录里放一个 3 MB 以上的 `big.txt`,点击它的聊天链接,然后连点两次「下载到默认文件夹」:
|