dsh-happy-reader 0.2.3 → 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 +13 -3
  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.3'
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,8 +319,18 @@ 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
- // 行距:把简写里字号后的"/行高"按倍率改写(0.5px 步进),字号本身不动
323
- if (lineH !== null) next = next.replace(/(\/\s*)(\d+(?:\.\d+)?)px/g, (m, lead, n) => lead + Math.round(Number(n) * lineH * 2) / 2 + 'px')
322
+ // 行距:官方行高 token 有两种真实形态(简写里的 "/ 行高" 段,均出自 asar 实测)——
323
+ // 正文/标题:"/ calc(Npx + var(--dsh-content-font-delta))"(增量由官方自管、随字号缩放)
324
+ // 代码类: "/ Npx"(纯 px,不随字号)
325
+ // 两种都按倍率放大;calc 形先行(其产物不含 "/数字px" 段,两步互不误伤)
326
+ if (lineH !== null) {
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')
333
+ }
324
334
  if (next !== value) parts.push(name + ':' + next)
325
335
  }
326
336
  if (letterSp !== null) parts.push('letter-spacing:' + letterSp + 'px')
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-happy-reader",
3
- "version": "0.2.3",
3
+ "version": "0.2.5",
4
4
  "description": "Happy Reader(阅读增强):隐藏输入框 / 上边栏、全屏切换、字号 10–40px、行距/字距微调、面板可拖动可拉高、复制为 Markdown(公式→LaTeX)、内容宽度扩展、中英文分别选正文字体 + 代码字体(仅列本机已装)—— 与官方设置协同,不冲突",
5
5
  "type": "module",
6
6
  "license": "MIT",