dsh-happy-reader 0.2.4 → 0.2.5

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.
Files changed (2) hide show
  1. package/lib/client.js +11 -7
  2. package/package.json +1 -1
package/lib/client.js CHANGED
@@ -29,7 +29,7 @@ window.__ModuleLoader__.load({
29
29
  var exports = module.exports
30
30
 
31
31
  // ── 常量 ────────────────────────────────────────────────────────────
32
- const VERSION = '0.2.4'
32
+ const VERSION = '0.2.5'
33
33
  const STATE_KEY = 'dsh.reader-boost.v1'
34
34
  const FAB_ID = 'dsrb-fab'
35
35
  const PANEL_ID = 'dsrb-panel'
@@ -319,13 +319,17 @@ window.__ModuleLoader__.load({
319
319
  let next = value
320
320
  if (famNames.length && next.indexOf('var(--dsw-font-family)') !== -1) next = next.split('var(--dsw-font-family)').join(fam)
321
321
  if (code && next.indexOf('var(--ds-font-family-code)') !== -1) next = next.split('var(--ds-font-family-code)').join(cod)
322
- // 行距:官方行高 token 的真实形态是简写里的 "/ calc(Npx + var(--dsh-content-font-delta))"
323
- //(增量由官方自管、随字号缩放);按倍率整段放大,字号本身不动
322
+ // 行距:官方行高 token 有两种真实形态(简写里的 "/ 行高" 段,均出自 asar 实测)——
323
+ // 正文/标题:"/ calc(Npx + var(--dsh-content-font-delta))"(增量由官方自管、随字号缩放)
324
+ // 代码类: "/ Npx"(纯 px,不随字号)
325
+ // 两种都按倍率放大;calc 形先行(其产物不含 "/数字px" 段,两步互不误伤)
324
326
  if (lineH !== null) {
325
- next = next.replace(
326
- /(\/\s*)calc\((\d+(?:\.\d+)?)px \+ var\(--dsh-content-font-delta\)\)/g,
327
- (m, lead, n) => lead + 'calc((' + n + 'px + var(--dsh-content-font-delta)) * ' + lineH + ')',
328
- )
327
+ next = next
328
+ .replace(
329
+ /(\/\s*)calc\((\d+(?:\.\d+)?)px \+ var\(--dsh-content-font-delta\)\)/g,
330
+ (m, lead, n) => lead + 'calc((' + n + 'px + var(--dsh-content-font-delta)) * ' + lineH + ')',
331
+ )
332
+ .replace(/(\/\s*)(\d+(?:\.\d+)?)px/g, (m, lead, n) => lead + Math.round(Number(n) * lineH * 2) / 2 + 'px')
329
333
  }
330
334
  if (next !== value) parts.push(name + ':' + next)
331
335
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-happy-reader",
3
- "version": "0.2.4",
3
+ "version": "0.2.5",
4
4
  "description": "Happy Reader(阅读增强):隐藏输入框 / 上边栏、全屏切换、字号 10–40px、行距/字距微调、面板可拖动可拉高、复制为 Markdown(公式→LaTeX)、内容宽度扩展、中英文分别选正文字体 + 代码字体(仅列本机已装)—— 与官方设置协同,不冲突",
5
5
  "type": "module",
6
6
  "license": "MIT",