{"_id":"@dsh-plug/dsh-sidebar-epub","name":"@dsh-plug/dsh-sidebar-epub","dist-tags":{"latest":"0.1.0"},"versions":{"0.1.0":{"name":"@dsh-plug/dsh-sidebar-epub","version":"0.1.0","publishConfig":{"access":"public"},"keywords":["dsh-plugin"],"description":"DSH web plugin: EPUB ebook previewer for the better-sidebar editor. Registers the epub file viewer through ctx.betterSidebar.registerFileViewer, keeping the epub.js render library out of the better-sidebar bundle.","type":"module","license":"AGPL-3.0","main":"./lib/index.js","types":"./lib/types/index.d.ts","exports":{".":{"types":"./lib/types/index.d.ts","import":"./lib/index.js"},"./client":"./lib/client.js","./cordis.patch.yml":"./cordis.patch.yml","./package.json":"./package.json"},"dsh":{"bundle":{"patch":"./cordis.patch.yml"},"client":{"inject":["@deepseek-ai/dsh-client-runtime"],"platform":"web"}},"scripts":{"typecheck":"tsc --noEmit","test":"vitest run","build":"tsdown --config tsdown.config.ts && tsc -p tsconfig.build.json","bundle:client":"tsdown --config tsdown.config.ts","watch":"tsdown --config tsdown.config.ts --watch"},"dependencies":{"epubjs":"^0.3.93"},"peerDependencies":{"@deepseek-ai/dsh-client-runtime":"^0.0.1-rc.1 || ^0.1.0-rc.8","dsh-better-sidebar":">= 0.6.0","react":"^18.2.0"},"peerDependenciesMeta":{"@deepseek-ai/dsh-client-runtime":{"optional":true},"dsh-better-sidebar":{"optional":true},"react":{"optional":true}},"devDependencies":{"@deepseek-ai/dsh-client-runtime":"0.1.1-rc.1","@types/node":"^24.0.0","@types/react":"~18.3.1","@types/react-dom":"~18.3.1","dsh-better-sidebar":"link:../dsh-better-sidebar","react":"^18.2.0","react-dom":"18.2.0","tsdown":"^0.22.2","typescript":"^5.6.0","vitest":"^4.1.8"},"engines":{"node":">=20"},"_id":"@dsh-plug/dsh-sidebar-epub@0.1.0","gitHead":"c07eaf4c8f80721fdc93ed9bf075a927d3bea0de","_nodeVersion":"22.22.3","_npmVersion":"10.9.8","dist":{"integrity":"sha512-VTARV1Ni++QIwXJp3V0h2NI45zV8F377wOi0Un3FM5lTYWs7IURe3UKCdzdetAm18ukxodLtStYzIE9RBNCpxw==","shasum":"c052b280a7aa38b5538f92237b2fb8d57f36cd36","tarball":"https://registry.npmjs.org/@dsh-plug/dsh-sidebar-epub/-/dsh-sidebar-epub-0.1.0.tgz","fileCount":19,"unpackedSize":904369,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIQDkyqjbamDMU34RFnbD5hf/8TGQ3G5aHQCEqWNF5j3B7wIgGN9giRSO3rScyFEmeNddgD9ztySIrRbs5EbUbC+6LSs="}]},"_npmUser":{"name":"xingyunli","email":"371524136@qq.com"},"directories":{},"maintainers":[{"name":"xingyunli","email":"371524136@qq.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/dsh-sidebar-epub_0.1.0_1788310411936_0.2839478223806098"},"_hasShrinkwrap":false}},"time":{"created":"2026-09-02T00:53:31.825Z","0.1.0":"2026-09-02T00:53:32.167Z","modified":"2026-09-02T00:53:32.425Z"},"maintainers":[{"name":"xingyunli","email":"371524136@qq.com"}],"description":"DSH web plugin: EPUB ebook previewer for the better-sidebar editor. Registers the epub file viewer through ctx.betterSidebar.registerFileViewer, keeping the epub.js render library out of the better-sidebar bundle.","keywords":["dsh-plugin"],"license":"AGPL-3.0","readme":"# @dsh-plug/dsh-sidebar-epub\n\nDSH web 插件：为 [dsh-better-sidebar](https://www.npmjs.com/package/dsh-better-sidebar) 的侧边栏编辑器提供 **EPUB 电子书预览**。通过 `ctx.betterSidebar.registerFileViewer` 注册 `.epub` 文件预览器，渲染库 epub.js（连同 jszip）只进本插件的 bundle，不拖大 better-sidebar 主包。\n\nDSH web plugin: an **EPUB ebook previewer** for the better-sidebar editor. Registers the `.epub` file viewer through `ctx.betterSidebar.registerFileViewer`; the epub.js render library (with jszip) lives in this plugin's bundle only, keeping better-sidebar's own client bundle small.\n\n## 功能 / Features\n\n- 点击 `.epub` 文件即在侧边栏阅读器中打开（分页双栏 / 连续滚动两种版式）\n- 目录抽屉（TOC，当前章节高亮）、上一页/下一页与键盘 ←/→ 翻页、章节内页码或全书进度百分比\n- 阅读进度（CFI）按文件路径持久化，重开/跨会话自动续读\n- 设置行（DSH 设置页「侧边卡片」→ EPUB 卡片齿轮）：主题（明亮/护眼/暗黑）、字号、版式、双栏对开、页边距\n- 错误降级：损坏或非 EPUB 文件显示原因 + 下载按钮（与 office 插件同款兜底）\n- zh / en 界面文案，随 DSH locale 切换；安装 [@huanlin/dsh-plugin-better-locale](https://www.npmjs.com/package/@huanlin/dsh-plugin-better-locale) 后可加 ja 等覆盖语言（`src/client/dictionaries.ts`）\n\n## 安装 / Install\n\n市场受管安装（在 DSH 所在环境的终端执行）：\n\n```sh\ndsh plugin --profile web add @dsh-plug/dsh-sidebar-epub\n```\n\n本地开发挂载（link 方式）：\n\n1. 本仓库 `pnpm install && pnpm build`（typecheck 前需已构建 `dsh-better-sidebar` 的 `lib/types`）。\n2. `~/.dsh/profiles/web/package.json` 的 `dependencies` 加 `\"@dsh-plug/dsh-sidebar-epub\": \"link:<本仓库绝对路径>\"`，并在 `dsh.profile.bundles` 数组追加包名。\n3. `cd ~/.dsh/profiles/web && pnpm install`。\n4. 浏览器硬刷新（Cmd/Ctrl+Shift+R）。client-only 改动无需重启 DSH。\n\n## 开发 / Development\n\n```sh\npnpm install\npnpm build        # tsdown 双产物（lib/index.js + lib/client.js）+ tsc 声明\npnpm typecheck    # tsc --noEmit（需 better-sidebar 的 lib/types 已构建）\npnpm test         # vitest（registration / toc / progress / settings）\npnpm watch        # tsdown --watch\n```\n\nclient bundle 是单文件 CJS closure（`codeSplitting: false`），经 `window.__ModuleLoader__.load` 注册；react / dsh-client-runtime 等 externals 走 DSH 模块表，其余（epub.js + jszip 等）全部内联。jszip 别名到其浏览器预构建产物（Rolldown CJS 降级后不遵守其 `browser` remap，见 `tsdown.config.ts`）。\n\n## 已知限制 / Known limitations\n\n- **设置热生效**：设置行写入后需重新打开书才生效（`flow` 变更需要重建 rendition）；字号/主题的实时调节在路线图内。\n- **分页版式忽略页边距**（epub.js 的分栏布局不支持 body padding；页边距仅作用于连续滚动版式）。\n- **竖排 / RTL**：epub.js 对 `writing-mode: vertical-rl` 支持有限，命中时排版可能降级为横排。\n- **换肤不实时**：iframe 内容调色板是字面值（iframe 文档读不到宿主 CSS 变量），换肤后重开书才跟随；阅读器外壳（工具条/目录/翻页条）令牌驱动，实时跟随。\n- **内容安全模型**：EPUB 内容在 epub.js 的**同源 iframe** 内渲染，与常见桌面阅读器同级信任模型——只打开你信任的电子书。\n\n## 路线图 / Roadmap\n\n- 书内搜索（spine 逐节加载 + 命中列表跳转）\n- 与 `@hongling/dsh-search-plugin` 协同：host 半 EPUB 全文抽取 → `openFile` reveal 跳节高亮（本插件已预留 `reveal` 结构镜像与 `<mark>` 高亮管线）\n- 书签/批注、封面书架 tab\n\n## 仓库约束 / Repository rules\n\n- 禁止修改 DSH 官方源码（`~/.dsh/source/current` 零写入）；只消费 better-sidebar 的公开服务与 `/sidebar/file`、`/sidebar/api/settings.get` 路由。\n- 代码改动走 `feat/*` / `fix/*` 分支 + PR；仅纯文档改动可直接推 main。\n- 发布清单的依赖字段不得出现 `cordis`；scripts 不得含 install hooks。\n- 挂载只走 `cordis.patch.yml` + profile 机制。\n\n## License\n\nAGPL-3.0（见 [LICENSE](./LICENSE)）\n","readmeFilename":"README.md","_rev":"1-d8fc293e0e2306fc8b563ff01e7e7f8b"}