dsh-pdf-workbench 1.3.2 → 1.3.4

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/README.md CHANGED
@@ -139,7 +139,7 @@
139
139
  ### npm(推荐给市场与一键更新)
140
140
 
141
141
  ```bash
142
- dsh plugin add dsh-pdf-workbench@1.3.2
142
+ dsh plugin add dsh-pdf-workbench@1.3.4
143
143
  ```
144
144
 
145
145
  ### 本地目录(开发)
@@ -174,7 +174,7 @@ Markdown → PDF 需要本机 **Python 3 + TeX(xelatex、ctex)**;翻译还
174
174
  答:不会。插件没有云同步;需要备份就把书库和 `~/.dsh/pdfdesk/` 一起复制。
175
175
 
176
176
  **问:从哪里安装?**
177
- 答:三种方式任选:**npm**(`dsh plugin add dsh-pdf-workbench@1.3.2`)、[GitHub Releases](https://github.com/minggemofashi/dsh-pdf-workbench/releases) 的 zip,或等插件市场收录后在 dsh-market 搜索「PDF 阅读」。旧包 `dsh-pdf-math-desk` 已从 npm 删除,请用新包名。
177
+ 答:三种方式任选:**npm**(`dsh plugin add dsh-pdf-workbench@1.3.4`)、[GitHub Releases](https://github.com/minggemofashi/dsh-pdf-workbench/releases) 的 zip,或等插件市场收录后在 dsh-market 搜索「PDF 阅读」。旧包 `dsh-pdf-math-desk` 已从 npm 删除,请用新包名。
178
178
 
179
179
  **问:形状能像 Excalidraw 一样多选 / 绑定箭头吗?**
180
180
  答:目前没有多选、没有箭头绑定和曲线。现有的是单元素选择、移动、四角缩放、样式、复制和层级。
package/client.js CHANGED
@@ -11554,7 +11554,7 @@ html[data-platform='darwin'] .md-head { padding-top: calc(var(--dsh-frame-top-cl
11554
11554
  useEffect(() => {
11555
11555
  if (!settingsOpen) return undefined
11556
11556
  const onDown = event => {
11557
- if (event.target instanceof Element && event.target.closest('.md-settings, .md-settings-page, .md-picker') !== null) return
11557
+ if (event.target instanceof Element && event.target.closest('.md-settings, .md-settings-modal, .md-settings-content, .md-settings-page, .md-picker') !== null) return
11558
11558
  setSettingsOpen(false)
11559
11559
  }
11560
11560
  const onKey = event => {
@@ -12922,6 +12922,10 @@ html[data-platform='darwin'] .md-head { padding-top: calc(var(--dsh-frame-top-cl
12922
12922
  if (archivedIds.has(id)) continue
12923
12923
  const summary = list.byId[id]
12924
12924
  if (summary === undefined || summary.blank !== true || summary.origin === 'subagent') continue
12925
+ // A workbench-created pending blank already carries one preset prompt
12926
+ // (or is about to). Reusing it for another mode would append the next
12927
+ // preset to that draft; leave it for cleanup instead.
12928
+ if (id in (pendingRef.current ?? {}) || freshPending.current.has(id)) continue
12925
12929
  if (pendingDrafts.current.has(id)) continue
12926
12930
  if (typeof summary.title === 'string' && summary.title !== '') continue
12927
12931
  if (typeof summary.cwd === 'string' && summary.cwd !== '' && target.cwd !== '' && !sameDirectory(summary.cwd, target.cwd)) continue
@@ -14330,17 +14334,6 @@ html[data-platform='darwin'] .md-head { padding-top: calc(var(--dsh-frame-top-cl
14330
14334
  book === null ? null : h(KitButton, {
14331
14335
  type: 'button', className: 'md-btn md-btn-ghost', onClick: backToShelf,
14332
14336
  }, `‹ ${format('back')}`),
14333
- h(KitButton, {
14334
- type: 'button', className: 'md-btn md-btn-ghost',
14335
- title: GITHUB_URL,
14336
- onClick: () => {
14337
- try {
14338
- window.open(GITHUB_URL, '_blank', 'noopener')
14339
- } catch {
14340
- // popup blocked: ignore
14341
- }
14342
- },
14343
- }, 'GitHub'),
14344
14337
  h('div', { className: 'md-settings' },
14345
14338
  h(KitButton, {
14346
14339
  type: 'button', className: 'md-btn md-btn-ghost',
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 is the only hard dependency. */
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,6 +116,13 @@ 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'),
119
127
  pending,
120
128
  links,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-pdf-workbench",
3
- "version": "1.3.2",
3
+ "version": "1.3.4",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "description": "PDF reading workbench for DSH: books and chapters, ask-as-you-read conversations, annotations, and a built-in pdf.js reader.",
@@ -268,6 +268,16 @@ async function activeLibrary() {
268
268
 
269
269
  return async function handle(request, response) {
270
270
  try {
271
+ // DSH's trust fence: Host/Origin validation and browser authentication.
272
+ // The loopback check below is defence-in-depth, not the authentication.
273
+ if (typeof options.requestRejection === 'function') {
274
+ const rejection = options.requestRejection(request)
275
+ if (rejection !== undefined) {
276
+ response.statusCode = rejection
277
+ response.end()
278
+ return
279
+ }
280
+ }
271
281
  if (!isLoopback(request)) {
272
282
  fail(response, 403, 'forbidden', '只接受本机请求')
273
283
  return
@@ -26,7 +26,7 @@
26
26
  ## 方式 C:npm(推荐给市场与更新)
27
27
 
28
28
  ```bash
29
- dsh plugin add dsh-pdf-workbench@1.3.2
29
+ dsh plugin add dsh-pdf-workbench@1.3.4
30
30
  ```
31
31
 
32
32
  旧包 `dsh-pdf-math-desk` 已从 npm 删除,请用新包名 `dsh-pdf-workbench`。