dsh-half-page 0.3.34 → 0.3.36

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
@@ -40,6 +40,7 @@ dsh plugin add dsh-half-page
40
40
  ~/.dsh/reading/
41
41
  ├── books/ 书(.txt / .md)
42
42
  │ └── .trash/ 下架的书挪到这儿,可手工找回
43
+ ├── books/<id>.toc.json 章表:每章的字符偏移 + 字节偏移
43
44
  ├── 读后感.md 所有读后感,按 ## 书名 / ### 章名 分块
44
45
  ├── 作品/ 它自己写的东西
45
46
  └── state.json 读到哪了
@@ -57,6 +58,21 @@ dsh plugin add dsh-half-page
57
58
  | `reading_search` | 在书里搜词,返回第几章、哪一行 |
58
59
  | `reading_recap` | 已读部分压成一页 |
59
60
 
61
+ ## 章表(读一章不整本 decode)
62
+
63
+ 第一次打开某本书时扫一遍,把每章的位置换算成字节偏移,落成 `books/<id>.toc.json`:
64
+
65
+ ```json
66
+ { "version": 1, "encoding": "gb18030", "bytes": 9638898, "chars": 3123456,
67
+ "chapters": [{ "title": "第一章 小二上酒", "charStart": 0, "charEnd": 3201, "byteStart": 0, "byteEnd": 6430 }] }
68
+ ```
69
+
70
+ 以后 `reading_next` 只 `fs.open` + 读 `byteStart..byteEnd` 那一段,再单独解这一段的编码——14MB 的书读一章不再把整本读进内存。
71
+
72
+ - 章表过期(文件 mtime 或字节数变了)会自动重建;删掉也能自动重建。
73
+ - `reading_next` 的返回里带 `tocPath`,能看到表在哪。
74
+ - `reading_search` 还是要整本,它是搜全文的。
75
+
60
76
  ## License
61
77
 
62
78
  MIT