@gongfpp/dsh-novel-fish 1.1.0 → 1.2.0
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/CHANGELOG.md +21 -0
- package/README.md +41 -20
- package/docs/evidence/settings-reliability.png +0 -0
- package/index.json +12 -0
- package/lib/client.js +734 -128
- package/locale/en.json +15 -0
- package/locale/zh.json +15 -0
- package/package.json +5 -7
- package/screenshots.json +6 -0
- package/docs/acceptance.md +0 -42
- package/docs/community-markets.md +0 -88
- package/docs/compatibility-017.md +0 -70
- package/docs/compatibility-101.md +0 -41
- package/docs/continuous-reading-020.md +0 -46
- package/docs/ebook-tests.md +0 -99
- package/docs/evidence/abc-result.json +0 -9
- package/docs/evidence/banner-100.png +0 -0
- package/docs/evidence/community-market-014-result.json +0 -170
- package/docs/evidence/compatibility-017-result.json +0 -65
- package/docs/evidence/continuous-reading-020-result.json +0 -72
- package/docs/evidence/formats-result.json +0 -12
- package/docs/evidence/live-ab.png +0 -0
- package/docs/evidence/live-collapsed.png +0 -0
- package/docs/evidence/live-disabled.png +0 -0
- package/docs/evidence/live-epub.png +0 -0
- package/docs/evidence/live-market.png +0 -0
- package/docs/evidence/live-resume.png +0 -0
- package/docs/evidence/live-unloaded.png +0 -0
- package/docs/evidence/long-result.json +0 -11
- package/docs/evidence/multi-region-014-result.json +0 -47
- package/docs/evidence/native-disclosure-013-result.json +0 -36
- package/docs/evidence/native-disclosures-013.png +0 -0
- package/docs/evidence/native-open-013.png +0 -0
- package/docs/evidence/native-settings-sample.md +0 -11
- package/docs/evidence/native-settings-types-015.png +0 -0
- package/docs/evidence/npm-market-014-result.json +0 -132
- package/docs/evidence/plugin-settings-details.png +0 -0
- package/docs/evidence/public-release-014-result.json +0 -51
- package/docs/evidence/public-release-015-result.json +0 -36
- package/docs/evidence/public-release-result.json +0 -48
- package/docs/evidence/reading-demo-100.png +0 -0
- package/docs/evidence/reading-two-expansions-110.gif +0 -0
- package/docs/evidence/reading-two-expansions-110.json +0 -89
- package/docs/evidence/samples-110-capture.json +0 -49
- package/docs/evidence/settings-011-result.json +0 -28
- package/docs/evidence/settings-011.png +0 -0
- package/docs/evidence/settings-100.png +0 -0
- package/docs/evidence/settings-110.png +0 -0
- package/docs/evidence/settings-chat-011.png +0 -0
- package/docs/evidence/type-append-012-result.json +0 -30
- package/docs/evidence/type-append-012.png +0 -0
- package/docs/evidence/type-settings-012.png +0 -0
- package/docs/evidence/unload-result.json +0 -7
- package/docs/host-adapter.md +0 -43
- package/docs/icon-metadata-021.md +0 -40
- package/docs/interaction-paths-020.md +0 -39
- package/docs/marketplace.md +0 -42
- package/docs/multi-region-update.md +0 -53
- package/docs/native-disclosure-update.md +0 -39
- package/docs/native-settings-update.md +0 -48
- package/docs/plugin-settings-update.md +0 -61
- package/docs/release.md +0 -151
- package/docs/settings-update.md +0 -49
- package/docs/type-append-update.md +0 -50
- package/pnpm-workspace.yaml +0 -5
- package/scripts/build.mjs +0 -70
- package/scripts/check-host-contracts.mjs +0 -247
- package/scripts/licenses/path-webpack.txt +0 -28
- package/scripts/make-readme-gif.mjs +0 -69
- package/scripts/test-browser-samples.mjs +0 -665
- package/scripts/test-candidate-books.mjs +0 -71
- package/scripts/test-ebook-corpus.mjs +0 -161
- package/src/bundled-books.js +0 -42
- package/src/chat-adapter.js +0 -278
- package/src/client.js +0 -61
- package/src/epub.js +0 -166
- package/src/novel-content.js +0 -28
- package/src/persistence.js +0 -271
- package/src/pg-notice.js +0 -19
- package/src/segments.js +0 -185
- package/src/settings.js +0 -243
- package/src/store.js +0 -429
- package/src/text-decoding.js +0 -28
- package/test/bundled-library.test.js +0 -526
- package/test/chat-adapter.test.js +0 -518
- package/test/client.test.js +0 -124
- package/test/ebooks.test.js +0 -192
- package/test/epub.test.js +0 -185
- package/test/helpers/host-primitives.js +0 -28
- package/test/helpers/memory-storage.js +0 -48
- package/test/host-contracts.test.js +0 -32
- package/test/import.test.js +0 -102
- package/test/persistence.test.js +0 -27
- package/test/pg-notice.test.js +0 -109
- package/test/release.test.js +0 -87
- package/test/segments.test.js +0 -182
- package/test/settings.test.js +0 -312
- package/test/store.test.js +0 -617
- package/test/text-decoding.test.js +0 -49
package/test/store.test.js
DELETED
|
@@ -1,617 +0,0 @@
|
|
|
1
|
-
import test from 'node:test'
|
|
2
|
-
import assert from 'node:assert/strict'
|
|
3
|
-
import { DEFAULT_SETTINGS, NovelStore, TARGET_TYPES, passageSnapshotKey } from '../src/store.js'
|
|
4
|
-
import { MemoryStorage } from './helpers/memory-storage.js'
|
|
5
|
-
|
|
6
|
-
function makeStore({ delayReads = 0 } = {}) {
|
|
7
|
-
const storage = new MemoryStorage({
|
|
8
|
-
books: [
|
|
9
|
-
{ id: 'book-a', title: 'A/B/C', format: 'txt', segmentCount: 3, progress: 0 },
|
|
10
|
-
{ id: 'book-b', title: 'Other', format: 'md', segmentCount: 2, progress: 0 },
|
|
11
|
-
],
|
|
12
|
-
settings: { ...DEFAULT_SETTINGS, currentBookId: 'book-a' },
|
|
13
|
-
passages: {
|
|
14
|
-
'book-a': [{ text: 'A' }, { text: 'B' }, { text: 'C' }],
|
|
15
|
-
'book-b': [{ text: 'X' }, { text: 'Y' }],
|
|
16
|
-
},
|
|
17
|
-
delayReads,
|
|
18
|
-
})
|
|
19
|
-
return { store: new NovelStore(storage), storage }
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
test('initialization and history-like observation do not consume passages', async () => {
|
|
23
|
-
const { store, storage } = makeStore()
|
|
24
|
-
await store.ready
|
|
25
|
-
assert.equal(storage.books.get('book-a').progress, 0)
|
|
26
|
-
assert.equal(store.getPassageStatus('book-a', 'A').kind, 'empty')
|
|
27
|
-
assert.equal(storage.reads, 0)
|
|
28
|
-
})
|
|
29
|
-
|
|
30
|
-
test('injected snapshot sources stay stable and passage subscriptions do not consume text', async () => {
|
|
31
|
-
const { store, storage } = makeStore()
|
|
32
|
-
const source = store.passageSource
|
|
33
|
-
const initialSnapshot = source.getSnapshot()
|
|
34
|
-
let notifications = 0
|
|
35
|
-
const unsubscribe = source.subscribe(() => { notifications += 1 })
|
|
36
|
-
await store.ready
|
|
37
|
-
|
|
38
|
-
assert.equal(storage.reads, 0)
|
|
39
|
-
assert.strictEqual(store.passageSource, source)
|
|
40
|
-
assert.strictEqual(source.getSnapshot(), initialSnapshot)
|
|
41
|
-
const result = await store.claimPassage('A')
|
|
42
|
-
const loadedSnapshot = source.getSnapshot()
|
|
43
|
-
assert.equal(result.passage.text, 'A')
|
|
44
|
-
assert.equal(loadedSnapshot[passageSnapshotKey('book-a', 'A')].kind, 'ready')
|
|
45
|
-
assert.notStrictEqual(loadedSnapshot, initialSnapshot)
|
|
46
|
-
assert.ok(notifications >= 2)
|
|
47
|
-
|
|
48
|
-
const afterReady = notifications
|
|
49
|
-
await store.claimPassage('A')
|
|
50
|
-
assert.strictEqual(source.getSnapshot(), loadedSnapshot)
|
|
51
|
-
assert.equal(notifications, afterReady)
|
|
52
|
-
assert.equal(storage.books.get('book-a').progress, 1)
|
|
53
|
-
unsubscribe()
|
|
54
|
-
store.dispose()
|
|
55
|
-
})
|
|
56
|
-
|
|
57
|
-
test('A repeats from its page cache; the first expansion of B gets the next passage', async () => {
|
|
58
|
-
const { store, storage } = makeStore()
|
|
59
|
-
await store.ready
|
|
60
|
-
const a1 = await store.claimPassage('A')
|
|
61
|
-
const a2 = await store.claimPassage('A')
|
|
62
|
-
assert.equal(a1.passage.text, 'A')
|
|
63
|
-
assert.equal(a2.passage.text, 'A')
|
|
64
|
-
assert.equal(storage.books.get('book-a').progress, 1)
|
|
65
|
-
assert.equal(storage.reads, 1)
|
|
66
|
-
|
|
67
|
-
const b = await store.claimPassage('B')
|
|
68
|
-
assert.equal(b.passage.text, 'B')
|
|
69
|
-
assert.equal(storage.books.get('book-a').progress, 2)
|
|
70
|
-
})
|
|
71
|
-
|
|
72
|
-
test('concurrent repeated clicks on one target share a single passage load', async () => {
|
|
73
|
-
const { store, storage } = makeStore({ delayReads: 20 })
|
|
74
|
-
await store.ready
|
|
75
|
-
const [first, repeated] = await Promise.all([
|
|
76
|
-
store.claimPassage('A'),
|
|
77
|
-
store.claimPassage('A'),
|
|
78
|
-
])
|
|
79
|
-
assert.equal(first.passage.text, 'A')
|
|
80
|
-
assert.equal(repeated.passage.text, 'A')
|
|
81
|
-
assert.equal(storage.reads, 1)
|
|
82
|
-
assert.equal(storage.books.get('book-a').progress, 1)
|
|
83
|
-
})
|
|
84
|
-
|
|
85
|
-
test('a failed passage read leaves progress unchanged and can be retried', async () => {
|
|
86
|
-
const { store, storage } = makeStore()
|
|
87
|
-
await store.ready
|
|
88
|
-
storage.failNextRead = true
|
|
89
|
-
const failed = await store.claimPassage('A')
|
|
90
|
-
assert.equal(failed.kind, 'error')
|
|
91
|
-
assert.equal(storage.books.get('book-a').progress, 0)
|
|
92
|
-
assert.equal(store.getPassageStatus('book-a', 'A').kind, 'error')
|
|
93
|
-
|
|
94
|
-
const retried = await store.claimPassage('A')
|
|
95
|
-
assert.equal(retried.passage.text, 'A')
|
|
96
|
-
assert.equal(storage.books.get('book-a').progress, 1)
|
|
97
|
-
})
|
|
98
|
-
|
|
99
|
-
test('page remount clears step cache but resumes from stored per-book progress', async () => {
|
|
100
|
-
const { store, storage } = makeStore()
|
|
101
|
-
await store.ready
|
|
102
|
-
assert.equal((await store.claimPassage('old-step')).passage.text, 'A')
|
|
103
|
-
store.dispose()
|
|
104
|
-
|
|
105
|
-
const remounted = new NovelStore(storage)
|
|
106
|
-
await remounted.ready
|
|
107
|
-
assert.equal(remounted.getPassageStatus('book-a', 'old-step').kind, 'empty')
|
|
108
|
-
const result = await remounted.claimPassage('old-step')
|
|
109
|
-
assert.equal(result.passage.text, 'B')
|
|
110
|
-
assert.equal(result.index, 1)
|
|
111
|
-
assert.equal(storage.books.get('book-a').progress, 2)
|
|
112
|
-
})
|
|
113
|
-
|
|
114
|
-
test('book switching clears temporary passages and keeps each book progress separate', async () => {
|
|
115
|
-
const { store, storage } = makeStore()
|
|
116
|
-
await store.ready
|
|
117
|
-
assert.equal((await store.claimPassage('A')).passage.text, 'A')
|
|
118
|
-
await store.selectBook('book-b')
|
|
119
|
-
assert.equal(store.getPassageStatus('book-b', 'A').kind, 'empty')
|
|
120
|
-
assert.equal((await store.claimPassage('A')).passage.text, 'X')
|
|
121
|
-
assert.equal(storage.books.get('book-a').progress, 1)
|
|
122
|
-
assert.equal(storage.books.get('book-b').progress, 1)
|
|
123
|
-
|
|
124
|
-
await store.selectBook('book-a')
|
|
125
|
-
assert.equal((await store.claimPassage('B')).passage.text, 'B')
|
|
126
|
-
assert.equal(storage.books.get('book-a').progress, 2)
|
|
127
|
-
})
|
|
128
|
-
|
|
129
|
-
function gateNextCall(storage, method) {
|
|
130
|
-
let release
|
|
131
|
-
let entered
|
|
132
|
-
const blocked = new Promise(resolve => { release = resolve })
|
|
133
|
-
const started = new Promise(resolve => { entered = resolve })
|
|
134
|
-
const original = storage[method].bind(storage)
|
|
135
|
-
let gated = false
|
|
136
|
-
storage[method] = async (...args) => {
|
|
137
|
-
if (!gated) {
|
|
138
|
-
gated = true
|
|
139
|
-
entered(args)
|
|
140
|
-
await blocked
|
|
141
|
-
}
|
|
142
|
-
return original(...args)
|
|
143
|
-
}
|
|
144
|
-
return { entered: started, release }
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
test('deleting while a progress save is pending cannot resurrect the removed book', async () => {
|
|
148
|
-
const { store, storage } = makeStore()
|
|
149
|
-
await store.ready
|
|
150
|
-
const gate = gateNextCall(storage, 'updateBook')
|
|
151
|
-
const reading = store.claimPassage('A')
|
|
152
|
-
await gate.entered
|
|
153
|
-
const deleting = store.deleteBook('book-a')
|
|
154
|
-
gate.release()
|
|
155
|
-
assert.equal((await reading).kind, 'empty')
|
|
156
|
-
await deleting
|
|
157
|
-
assert.equal(storage.books.has('book-a'), false)
|
|
158
|
-
assert.equal(await storage.getSegment('book-a', 0), null)
|
|
159
|
-
assert.deepEqual(store.getSnapshot().books.map(book => book.id), ['book-b'])
|
|
160
|
-
assert.equal(store.getSettingsSnapshot().currentBookId, 'book-b')
|
|
161
|
-
store.dispose()
|
|
162
|
-
})
|
|
163
|
-
|
|
164
|
-
test('switching during a pending progress save rolls back the undisplayed passage', async () => {
|
|
165
|
-
const { store, storage } = makeStore()
|
|
166
|
-
await store.ready
|
|
167
|
-
const gate = gateNextCall(storage, 'updateBook')
|
|
168
|
-
const reading = store.claimPassage('A')
|
|
169
|
-
await gate.entered
|
|
170
|
-
const switching = store.selectBook('book-b')
|
|
171
|
-
gate.release()
|
|
172
|
-
assert.equal((await reading).kind, 'empty')
|
|
173
|
-
await switching
|
|
174
|
-
assert.equal(storage.books.get('book-a').progress, 0)
|
|
175
|
-
assert.equal(store.getPassageStatus('book-a', 'A').kind, 'empty')
|
|
176
|
-
assert.equal(store.getSettingsSnapshot().currentBookId, 'book-b')
|
|
177
|
-
await store.selectBook('book-a')
|
|
178
|
-
assert.equal((await store.claimPassage('A')).passage.text, 'A')
|
|
179
|
-
store.dispose()
|
|
180
|
-
})
|
|
181
|
-
|
|
182
|
-
test('rapid type and title settings merge with the latest queued settings', async () => {
|
|
183
|
-
const { store, storage } = makeStore()
|
|
184
|
-
await store.ready
|
|
185
|
-
const gate = gateNextCall(storage, 'saveSettings')
|
|
186
|
-
const first = store.setOption('mainTitle', '思考')
|
|
187
|
-
await gate.entered
|
|
188
|
-
const second = store.setOption('targetTypes', ['reasoning', 'command'])
|
|
189
|
-
const third = store.setOption('extraTitle', 'Checking project structure')
|
|
190
|
-
gate.release()
|
|
191
|
-
await Promise.all([first, second, third])
|
|
192
|
-
assert.equal(store.getSettingsSnapshot().mainTitle, '思考')
|
|
193
|
-
assert.deepEqual(store.getSettingsSnapshot().targetTypes, ['reasoning', 'command'])
|
|
194
|
-
assert.equal(store.getSettingsSnapshot().extraTitle, 'Checking project structure')
|
|
195
|
-
assert.deepEqual(storage.settings, store.getSettingsSnapshot())
|
|
196
|
-
store.dispose()
|
|
197
|
-
})
|
|
198
|
-
|
|
199
|
-
test('rapid book B then A selection honors the final queued choice', async () => {
|
|
200
|
-
const { store, storage } = makeStore()
|
|
201
|
-
await store.ready
|
|
202
|
-
const gate = gateNextCall(storage, 'saveSettings')
|
|
203
|
-
const first = store.selectBook('book-b')
|
|
204
|
-
await gate.entered
|
|
205
|
-
const second = store.selectBook('book-a')
|
|
206
|
-
gate.release()
|
|
207
|
-
await Promise.all([first, second])
|
|
208
|
-
assert.equal(store.getSettingsSnapshot().currentBookId, 'book-a')
|
|
209
|
-
assert.equal(storage.settings.currentBookId, 'book-a')
|
|
210
|
-
store.dispose()
|
|
211
|
-
})
|
|
212
|
-
|
|
213
|
-
test('concurrent book deletions use serialized current state without restoring removed rows', async () => {
|
|
214
|
-
const { store, storage } = makeStore()
|
|
215
|
-
await store.ready
|
|
216
|
-
const gate = gateNextCall(storage, 'deleteBook')
|
|
217
|
-
const first = store.deleteBook('book-a')
|
|
218
|
-
await gate.entered
|
|
219
|
-
const second = store.deleteBook('book-b')
|
|
220
|
-
gate.release()
|
|
221
|
-
await Promise.all([first, second])
|
|
222
|
-
assert.deepEqual(store.getSnapshot().books, [])
|
|
223
|
-
assert.equal(store.getSettingsSnapshot().currentBookId, null)
|
|
224
|
-
assert.deepEqual([...storage.books.keys()], [])
|
|
225
|
-
assert.equal(storage.settings.currentBookId, null)
|
|
226
|
-
store.dispose()
|
|
227
|
-
})
|
|
228
|
-
|
|
229
|
-
test('an unchanged selection or deletion of another book preserves the ready page cache', async () => {
|
|
230
|
-
const { store, storage } = makeStore()
|
|
231
|
-
await store.ready
|
|
232
|
-
const first = await store.claimPassage('A')
|
|
233
|
-
await store.selectBook('book-a')
|
|
234
|
-
assert.equal(await store.claimPassage('A'), first)
|
|
235
|
-
await store.deleteBook('book-b')
|
|
236
|
-
assert.equal(await store.claimPassage('A'), first)
|
|
237
|
-
assert.equal(storage.books.get('book-a').progress, 1)
|
|
238
|
-
store.dispose()
|
|
239
|
-
})
|
|
240
|
-
|
|
241
|
-
test('a claim requested after a book-switch intent reads the newly selected book', async () => {
|
|
242
|
-
const { store } = makeStore()
|
|
243
|
-
await store.ready
|
|
244
|
-
const switching = store.selectBook('book-b')
|
|
245
|
-
const reading = store.claimPassage('B')
|
|
246
|
-
await switching
|
|
247
|
-
assert.equal((await reading).passage.text, 'X')
|
|
248
|
-
store.dispose()
|
|
249
|
-
})
|
|
250
|
-
|
|
251
|
-
test('failed selection persistence prevents deletion and leaves the selected book usable', async () => {
|
|
252
|
-
const { store, storage } = makeStore()
|
|
253
|
-
await store.ready
|
|
254
|
-
const first = await store.claimPassage('A')
|
|
255
|
-
storage.saveSettings = async () => { throw new Error('settings quota failure') }
|
|
256
|
-
await assert.rejects(store.deleteBook('book-a'), /settings quota failure/u)
|
|
257
|
-
assert.equal(storage.books.has('book-a'), true)
|
|
258
|
-
assert.equal(store.getSnapshot().books.some(book => book.id === 'book-a'), true)
|
|
259
|
-
assert.equal(store.getSettingsSnapshot().currentBookId, 'book-a')
|
|
260
|
-
assert.equal(storage.settings.currentBookId, 'book-a')
|
|
261
|
-
assert.equal(await store.claimPassage('A'), first)
|
|
262
|
-
assert.equal(storage.books.get('book-a').progress, 1)
|
|
263
|
-
store.dispose()
|
|
264
|
-
})
|
|
265
|
-
|
|
266
|
-
test('failed switching cancels an unfinished read without leaving a stuck loading status', async () => {
|
|
267
|
-
const { store, storage } = makeStore()
|
|
268
|
-
await store.ready
|
|
269
|
-
const gate = gateNextCall(storage, 'updateBook')
|
|
270
|
-
const reading = store.claimPassage('A')
|
|
271
|
-
await gate.entered
|
|
272
|
-
storage.saveSettings = async () => { throw new Error('settings quota failure') }
|
|
273
|
-
const switching = store.selectBook('book-b')
|
|
274
|
-
const rejected = assert.rejects(switching, /settings quota failure/u)
|
|
275
|
-
gate.release()
|
|
276
|
-
assert.equal((await reading).kind, 'empty')
|
|
277
|
-
await rejected
|
|
278
|
-
assert.equal(store.getPassageStatus('book-a', 'A').kind, 'empty')
|
|
279
|
-
assert.equal(storage.books.get('book-a').progress, 0)
|
|
280
|
-
assert.equal((await store.claimPassage('A')).passage.text, 'A')
|
|
281
|
-
store.dispose()
|
|
282
|
-
})
|
|
283
|
-
|
|
284
|
-
test('failed hydration blocks later mutations instead of replacing stored settings with defaults', async () => {
|
|
285
|
-
const { storage } = makeStore()
|
|
286
|
-
let writes = 0
|
|
287
|
-
storage.load = async () => { throw new Error('read unavailable') }
|
|
288
|
-
storage.saveSettings = async () => { writes += 1 }
|
|
289
|
-
const store = new NovelStore(storage)
|
|
290
|
-
await store.ready
|
|
291
|
-
assert.match(store.getSnapshot().error, /read unavailable/u)
|
|
292
|
-
await assert.rejects(store.setOption('mainTitle', '思考'), /本地书库不可用/u)
|
|
293
|
-
await assert.rejects(store.selectBook('book-b'), /本地书库不可用/u)
|
|
294
|
-
await assert.rejects(store.deleteBook('book-a'), /本地书库不可用/u)
|
|
295
|
-
await assert.rejects(store.importFile({ name: 'new.txt', text: async () => 'Text.' }), /本地书库不可用/u)
|
|
296
|
-
assert.equal((await store.claimPassage('A')).kind, 'error')
|
|
297
|
-
assert.equal(writes, 0)
|
|
298
|
-
assert.equal(storage.settings.currentBookId, 'book-a')
|
|
299
|
-
store.dispose()
|
|
300
|
-
})
|
|
301
|
-
|
|
302
|
-
test('type settings preserve existing books/progress while dropping obsolete location lists', async () => {
|
|
303
|
-
const storage = new MemoryStorage({
|
|
304
|
-
books: [{ id: 'existing', title: '原书库', format: 'txt', segmentCount: 3, progress: 2 }],
|
|
305
|
-
settings: { enabled: true, targetType: 'reasoning', currentBookId: 'existing', mainTitle: '原自定义标题', targets: [{ sessionId: 'old-session', nodeKey: 'old-step' }], targetKey: 'old-step' },
|
|
306
|
-
passages: { existing: [{ text: 'A' }, { text: 'B' }, { text: 'C' }] },
|
|
307
|
-
})
|
|
308
|
-
const store = new NovelStore(storage)
|
|
309
|
-
await store.ready
|
|
310
|
-
assert.deepEqual(store.getSettingsSnapshot().targetTypes, ['reasoning'])
|
|
311
|
-
assert.equal(Object.hasOwn(store.getSettingsSnapshot(), 'targetType'), false)
|
|
312
|
-
assert.equal(store.getSettingsSnapshot().mainTitle, '原自定义标题')
|
|
313
|
-
assert.equal(Object.hasOwn(store.getSettingsSnapshot(), 'targets'), false)
|
|
314
|
-
assert.equal(Object.hasOwn(store.getSettingsSnapshot(), 'targetKey'), false)
|
|
315
|
-
assert.equal(store.getSnapshot().books[0].progress, 2)
|
|
316
|
-
assert.equal(storage.reads, 0)
|
|
317
|
-
await assert.rejects(store.setOption('targetType', 'reasoning'), /未知设置项/u)
|
|
318
|
-
await assert.rejects(store.setOption('targetKey', 'another-step'), /未知设置项/u)
|
|
319
|
-
await store.setOption('targetTypes', ['reasoning'])
|
|
320
|
-
assert.equal(Object.hasOwn(storage.settings, 'targetType'), false)
|
|
321
|
-
assert.equal(Object.hasOwn(storage.settings, 'targets'), false)
|
|
322
|
-
assert.equal(Object.hasOwn(storage.settings, 'targetKey'), false)
|
|
323
|
-
assert.equal(storage.books.get('existing').progress, 2)
|
|
324
|
-
store.dispose()
|
|
325
|
-
})
|
|
326
|
-
|
|
327
|
-
test('disabling before a queued claim executes prevents the audited progress leak', async () => {
|
|
328
|
-
const { store, storage } = makeStore()
|
|
329
|
-
await store.ready
|
|
330
|
-
const gate = gateNextCall(storage, 'saveSettings')
|
|
331
|
-
const disabling = store.setOption('enabled', false)
|
|
332
|
-
await gate.entered
|
|
333
|
-
const reading = store.claimPassage('queued')
|
|
334
|
-
gate.release()
|
|
335
|
-
await disabling
|
|
336
|
-
assert.equal((await reading).kind, 'empty')
|
|
337
|
-
assert.equal(store.getSettingsSnapshot().enabled, false)
|
|
338
|
-
assert.equal(storage.books.get('book-a').progress, 0)
|
|
339
|
-
assert.equal(storage.reads, 0)
|
|
340
|
-
store.dispose()
|
|
341
|
-
})
|
|
342
|
-
|
|
343
|
-
for (const boundary of ['getSegment', 'updateBook']) {
|
|
344
|
-
test(`disable intent cancels a pending ${boundary} and preserves ready passages`, async () => {
|
|
345
|
-
const { store, storage } = makeStore()
|
|
346
|
-
await store.ready
|
|
347
|
-
const ready = await store.claimPassage('cached')
|
|
348
|
-
const gate = gateNextCall(storage, boundary)
|
|
349
|
-
const reading = store.claimPassage('pending')
|
|
350
|
-
await gate.entered
|
|
351
|
-
const disabling = store.setOption('enabled', false)
|
|
352
|
-
assert.equal(store.getPassageStatus('book-a', 'pending').kind, 'empty')
|
|
353
|
-
assert.strictEqual(store.getPassageStatus('book-a', 'cached'), ready)
|
|
354
|
-
gate.release()
|
|
355
|
-
assert.equal((await reading).kind, 'empty')
|
|
356
|
-
await disabling
|
|
357
|
-
assert.equal(storage.books.get('book-a').progress, 1)
|
|
358
|
-
assert.equal(store.getSnapshot().books[0].progress, 1)
|
|
359
|
-
await store.setOption('enabled', true)
|
|
360
|
-
assert.strictEqual(await store.claimPassage('cached'), ready)
|
|
361
|
-
assert.equal((await store.claimPassage('pending')).passage.text, 'B')
|
|
362
|
-
store.dispose()
|
|
363
|
-
})
|
|
364
|
-
}
|
|
365
|
-
|
|
366
|
-
test('a failed disable write still cancels the unfinished read without losing ready cache', async () => {
|
|
367
|
-
const { store, storage } = makeStore()
|
|
368
|
-
await store.ready
|
|
369
|
-
const ready = await store.claimPassage('cached')
|
|
370
|
-
const gate = gateNextCall(storage, 'updateBook')
|
|
371
|
-
const reading = store.claimPassage('pending')
|
|
372
|
-
await gate.entered
|
|
373
|
-
storage.saveSettings = async () => { throw new Error('settings quota failure') }
|
|
374
|
-
const rejected = assert.rejects(store.setOption('enabled', false), /settings quota failure/u)
|
|
375
|
-
gate.release()
|
|
376
|
-
assert.equal((await reading).kind, 'empty')
|
|
377
|
-
await rejected
|
|
378
|
-
assert.equal(store.getSettingsSnapshot().enabled, true)
|
|
379
|
-
assert.equal(storage.books.get('book-a').progress, 1)
|
|
380
|
-
assert.equal(store.getPassageStatus('book-a', 'pending').kind, 'empty')
|
|
381
|
-
assert.strictEqual(await store.claimPassage('cached'), ready)
|
|
382
|
-
assert.equal((await store.claimPassage('pending')).passage.text, 'B')
|
|
383
|
-
store.dispose()
|
|
384
|
-
})
|
|
385
|
-
|
|
386
|
-
test('a canceled read failure stays empty and does not consume progress', async () => {
|
|
387
|
-
const { store, storage } = makeStore()
|
|
388
|
-
await store.ready
|
|
389
|
-
const gate = gateNextCall(storage, 'getSegment')
|
|
390
|
-
const reading = store.claimPassage('pending')
|
|
391
|
-
await gate.entered
|
|
392
|
-
storage.failNextRead = true
|
|
393
|
-
const disabling = store.setOption('enabled', false)
|
|
394
|
-
gate.release()
|
|
395
|
-
assert.equal((await reading).kind, 'empty')
|
|
396
|
-
await disabling
|
|
397
|
-
assert.equal(store.getPassageStatus('book-a', 'pending').kind, 'empty')
|
|
398
|
-
assert.equal(storage.books.get('book-a').progress, 0)
|
|
399
|
-
store.dispose()
|
|
400
|
-
})
|
|
401
|
-
|
|
402
|
-
test('a failed progress save does not publish or consume a passage and remains retryable', async () => {
|
|
403
|
-
const { store, storage } = makeStore()
|
|
404
|
-
await store.ready
|
|
405
|
-
const updateBook = storage.updateBook.bind(storage)
|
|
406
|
-
storage.updateBook = async () => { throw new Error('progress quota failure') }
|
|
407
|
-
const failed = await store.claimPassage('pending')
|
|
408
|
-
assert.equal(failed.kind, 'error')
|
|
409
|
-
assert.match(failed.message, /progress quota failure/u)
|
|
410
|
-
assert.equal(storage.books.get('book-a').progress, 0)
|
|
411
|
-
assert.equal(store.getSnapshot().books[0].progress, 0)
|
|
412
|
-
storage.updateBook = updateBook
|
|
413
|
-
assert.equal((await store.claimPassage('pending')).passage.text, 'A')
|
|
414
|
-
store.dispose()
|
|
415
|
-
})
|
|
416
|
-
|
|
417
|
-
test('all selected types persist and accept reads, including an intentionally empty selection', async () => {
|
|
418
|
-
const { store, storage } = makeStore()
|
|
419
|
-
await store.ready
|
|
420
|
-
const selected = [...TARGET_TYPES]
|
|
421
|
-
await store.setOption('targetTypes', selected)
|
|
422
|
-
selected.length = 0
|
|
423
|
-
assert.deepEqual(store.getSettingsSnapshot().targetTypes, TARGET_TYPES)
|
|
424
|
-
assert.deepEqual(storage.settings.targetTypes, TARGET_TYPES)
|
|
425
|
-
assert.equal(Object.hasOwn(storage.settings, 'targetType'), false)
|
|
426
|
-
for (const [index, type] of TARGET_TYPES.entries()) {
|
|
427
|
-
assert.equal((await store.claimPassage(type, type)).kind, index < 3 ? 'ready' : 'end')
|
|
428
|
-
}
|
|
429
|
-
assert.equal(storage.reads, 3)
|
|
430
|
-
await store.setOption('targetTypes', [])
|
|
431
|
-
assert.equal((await store.claimPassage('not-selected', 'command')).kind, 'empty')
|
|
432
|
-
assert.equal(storage.reads, 3)
|
|
433
|
-
store.dispose()
|
|
434
|
-
const remounted = new NovelStore(storage)
|
|
435
|
-
await remounted.ready
|
|
436
|
-
assert.deepEqual(remounted.getSettingsSnapshot().targetTypes, [])
|
|
437
|
-
assert.equal((await remounted.claimPassage('not-selected')).kind, 'empty')
|
|
438
|
-
remounted.dispose()
|
|
439
|
-
})
|
|
440
|
-
|
|
441
|
-
for (const type of TARGET_TYPES) {
|
|
442
|
-
test(`${type} can be selected alone and survives remount without consuming unrelated types`, async () => {
|
|
443
|
-
const { store, storage } = makeStore()
|
|
444
|
-
await store.ready
|
|
445
|
-
await store.setOption('targetTypes', [type])
|
|
446
|
-
store.dispose()
|
|
447
|
-
const remounted = new NovelStore(storage)
|
|
448
|
-
await remounted.ready
|
|
449
|
-
assert.deepEqual(remounted.getSettingsSnapshot().targetTypes, [type])
|
|
450
|
-
const otherType = type === 'reasoning' ? 'command' : 'reasoning'
|
|
451
|
-
assert.equal((await remounted.claimPassage('other', otherType)).kind, 'empty')
|
|
452
|
-
assert.equal(storage.reads, 0)
|
|
453
|
-
assert.equal((await remounted.claimPassage(`${type}:step`, type)).passage.text, 'A')
|
|
454
|
-
assert.equal(storage.books.get('book-a').progress, 1)
|
|
455
|
-
remounted.dispose()
|
|
456
|
-
})
|
|
457
|
-
}
|
|
458
|
-
|
|
459
|
-
test('invalid type selections reject without persisting or replacing the current selection', async () => {
|
|
460
|
-
const { store, storage } = makeStore()
|
|
461
|
-
await store.ready
|
|
462
|
-
for (const value of [null, 'reasoning', ['unknown'], ['reasoning', 'reasoning'], [false]]) {
|
|
463
|
-
await assert.rejects(store.setOption('targetTypes', value), /有效且不重复的类型数组/u)
|
|
464
|
-
}
|
|
465
|
-
assert.deepEqual(store.getSettingsSnapshot().targetTypes, ['reasoning'])
|
|
466
|
-
assert.deepEqual(storage.settings.targetTypes, ['reasoning'])
|
|
467
|
-
assert.equal((await store.claimPassage('unselected', 'command')).kind, 'empty')
|
|
468
|
-
assert.equal(storage.reads, 0)
|
|
469
|
-
store.dispose()
|
|
470
|
-
})
|
|
471
|
-
|
|
472
|
-
test('hydration normalizes stored type arrays without resurrecting the old field', async () => {
|
|
473
|
-
const storage = new MemoryStorage({ settings: { targetTypes: ['command', 'command', 'unknown', 'read-file'], targetType: 'reasoning' } })
|
|
474
|
-
const store = new NovelStore(storage)
|
|
475
|
-
await store.ready
|
|
476
|
-
assert.deepEqual(store.getSettingsSnapshot().targetTypes, ['command', 'read-file'])
|
|
477
|
-
assert.equal(Object.hasOwn(store.getSettingsSnapshot(), 'targetType'), false)
|
|
478
|
-
await store.setOption('mainTitle', '工具')
|
|
479
|
-
assert.deepEqual(storage.settings.targetTypes, ['command', 'read-file'])
|
|
480
|
-
assert.equal(Object.hasOwn(storage.settings, 'targetType'), false)
|
|
481
|
-
store.dispose()
|
|
482
|
-
})
|
|
483
|
-
|
|
484
|
-
for (const boundary of ['getSegment', 'updateBook']) {
|
|
485
|
-
test(`deselecting a type cancels its pending ${boundary} but retains its ready passage`, async () => {
|
|
486
|
-
const { store, storage } = makeStore()
|
|
487
|
-
await store.ready
|
|
488
|
-
await store.setOption('targetTypes', ['reasoning', 'command'])
|
|
489
|
-
const ready = await store.claimPassage('command:cached', 'command')
|
|
490
|
-
const gate = gateNextCall(storage, boundary)
|
|
491
|
-
const reading = store.claimPassage('command:pending', 'command')
|
|
492
|
-
await gate.entered
|
|
493
|
-
const deselecting = store.setOption('targetTypes', ['reasoning'])
|
|
494
|
-
assert.equal(store.getPassageStatus('book-a', 'command:pending').kind, 'empty')
|
|
495
|
-
assert.strictEqual(store.getPassageStatus('book-a', 'command:cached'), ready)
|
|
496
|
-
gate.release()
|
|
497
|
-
assert.equal((await reading).kind, 'empty')
|
|
498
|
-
await deselecting
|
|
499
|
-
assert.equal(storage.books.get('book-a').progress, 1)
|
|
500
|
-
assert.equal((await store.claimPassage('command:new', 'command')).kind, 'empty')
|
|
501
|
-
await store.setOption('targetTypes', ['command'])
|
|
502
|
-
assert.strictEqual(await store.claimPassage('command:cached', 'command'), ready)
|
|
503
|
-
assert.equal((await store.claimPassage('command:pending', 'command')).passage.text, 'B')
|
|
504
|
-
store.dispose()
|
|
505
|
-
})
|
|
506
|
-
}
|
|
507
|
-
|
|
508
|
-
test('failed deselection persistence cancels the in-flight claim and allows a clean retry', async () => {
|
|
509
|
-
const { store, storage } = makeStore()
|
|
510
|
-
await store.ready
|
|
511
|
-
await store.setOption('targetTypes', ['command'])
|
|
512
|
-
const gate = gateNextCall(storage, 'updateBook')
|
|
513
|
-
const reading = store.claimPassage('command:pending', 'command')
|
|
514
|
-
await gate.entered
|
|
515
|
-
storage.saveSettings = async () => { throw new Error('settings quota failure') }
|
|
516
|
-
const rejected = assert.rejects(store.setOption('targetTypes', []), /settings quota failure/u)
|
|
517
|
-
gate.release()
|
|
518
|
-
assert.equal((await reading).kind, 'empty')
|
|
519
|
-
await rejected
|
|
520
|
-
assert.deepEqual(store.getSettingsSnapshot().targetTypes, ['command'])
|
|
521
|
-
assert.equal(store.getPassageStatus('book-a', 'command:pending').kind, 'empty')
|
|
522
|
-
assert.equal(storage.books.get('book-a').progress, 0)
|
|
523
|
-
assert.equal((await store.claimPassage('command:pending', 'command')).passage.text, 'A')
|
|
524
|
-
store.dispose()
|
|
525
|
-
})
|
|
526
|
-
|
|
527
|
-
test('failed canceled-progress restoration blocks later writes with an actionable error', async () => {
|
|
528
|
-
const { store, storage } = makeStore()
|
|
529
|
-
await store.ready
|
|
530
|
-
const gate = gateNextCall(storage, 'updateBook')
|
|
531
|
-
const reading = store.claimPassage('pending')
|
|
532
|
-
await gate.entered
|
|
533
|
-
storage.updateBook = async () => { throw new Error('restore quota failure') }
|
|
534
|
-
const rejected = assert.rejects(store.setOption('enabled', false), /本地书库不可用/u)
|
|
535
|
-
gate.release()
|
|
536
|
-
const failed = await reading
|
|
537
|
-
assert.equal(failed.kind, 'error')
|
|
538
|
-
assert.match(failed.message, /restore quota failure/u)
|
|
539
|
-
await rejected
|
|
540
|
-
assert.match(store.getSnapshot().error, /恢复失败.*restore quota failure/u)
|
|
541
|
-
assert.equal(store.getPassageStatus('book-a', 'pending').kind, 'empty')
|
|
542
|
-
assert.equal((await store.claimPassage('later')).kind, 'error')
|
|
543
|
-
await assert.rejects(store.setOption('mainTitle', '不要覆盖'), /本地书库不可用/u)
|
|
544
|
-
assert.equal(storage.settings.mainTitle, '')
|
|
545
|
-
store.dispose()
|
|
546
|
-
})
|
|
547
|
-
|
|
548
|
-
test('a claim queued behind deselection never reads even with the new generation', async () => {
|
|
549
|
-
const { store, storage } = makeStore()
|
|
550
|
-
await store.ready
|
|
551
|
-
const gate = gateNextCall(storage, 'saveSettings')
|
|
552
|
-
const deselecting = store.setOption('targetTypes', [])
|
|
553
|
-
await gate.entered
|
|
554
|
-
const reading = store.claimPassage('queued')
|
|
555
|
-
gate.release()
|
|
556
|
-
await deselecting
|
|
557
|
-
assert.equal((await reading).kind, 'empty')
|
|
558
|
-
assert.equal(storage.reads, 0)
|
|
559
|
-
assert.equal(storage.books.get('book-a').progress, 0)
|
|
560
|
-
store.dispose()
|
|
561
|
-
})
|
|
562
|
-
|
|
563
|
-
test('end of book does not wrap and target settings contain no passage binding', async () => {
|
|
564
|
-
const { store, storage } = makeStore()
|
|
565
|
-
await store.ready
|
|
566
|
-
assert.equal((await store.claimPassage('A')).passage.text, 'A')
|
|
567
|
-
assert.equal((await store.claimPassage('B')).passage.text, 'B')
|
|
568
|
-
assert.equal((await store.claimPassage('C')).passage.text, 'C')
|
|
569
|
-
const ended = await store.claimPassage('D')
|
|
570
|
-
assert.equal(ended.kind, 'end')
|
|
571
|
-
assert.equal(storage.books.get('book-a').progress, 3)
|
|
572
|
-
assert.equal(storage.reads, 3)
|
|
573
|
-
assert.deepEqual(store.getSettingsSnapshot().targetTypes, ['reasoning'])
|
|
574
|
-
assert.equal(Object.hasOwn(store.getSettingsSnapshot(), 'targetType'), false)
|
|
575
|
-
assert.equal(Object.hasOwn(store.getSettingsSnapshot(), 'targets'), false)
|
|
576
|
-
assert.equal(Object.hasOwn(storage.settings, 'targets'), false)
|
|
577
|
-
})
|
|
578
|
-
|
|
579
|
-
test('续读设置默认关闭、按布尔归一化,未知设置项仍被拒绝', async () => {
|
|
580
|
-
const { store } = makeStore()
|
|
581
|
-
await store.ready
|
|
582
|
-
assert.equal(store.getSettingsSnapshot().continueOnReopen, false)
|
|
583
|
-
await store.setOption('continueOnReopen', 'yes')
|
|
584
|
-
assert.equal(store.getSettingsSnapshot().continueOnReopen, true)
|
|
585
|
-
await store.setOption('continueOnReopen', 0)
|
|
586
|
-
assert.equal(store.getSettingsSnapshot().continueOnReopen, false)
|
|
587
|
-
await assert.rejects(() => store.setOption('unknown', true), /未知设置项/u)
|
|
588
|
-
store.dispose()
|
|
589
|
-
})
|
|
590
|
-
|
|
591
|
-
test('claimPassage 保留该区域已读段,continuePassage 才在同一区域推进', async () => {
|
|
592
|
-
const { store, storage } = makeStore()
|
|
593
|
-
await store.ready
|
|
594
|
-
assert.equal((await store.claimPassage('A')).passage.text, 'A')
|
|
595
|
-
assert.equal((await store.claimPassage('A')).passage.text, 'A', '重复展开仍显示这一页')
|
|
596
|
-
assert.equal((await store.continuePassage('A')).passage.text, 'B')
|
|
597
|
-
assert.equal(storage.books.get('book-a').progress, 2)
|
|
598
|
-
assert.equal((await store.claimPassage('A')).passage.text, 'B', '关闭续读后显示该区域最后读到的段落')
|
|
599
|
-
assert.equal((await store.continuePassage('A')).passage.text, 'C')
|
|
600
|
-
assert.equal(storage.books.get('book-a').progress, 3)
|
|
601
|
-
assert.equal((await store.continuePassage('A')).kind, 'end')
|
|
602
|
-
assert.equal((await store.continuePassage('A')).kind, 'end', '读完后不再推进')
|
|
603
|
-
store.dispose()
|
|
604
|
-
})
|
|
605
|
-
|
|
606
|
-
test('continuePassage 对未读区域等同首次读取,并遵守停读与切书', async () => {
|
|
607
|
-
const { store, storage } = makeStore()
|
|
608
|
-
await store.ready
|
|
609
|
-
assert.equal((await store.continuePassage('A')).passage.text, 'A')
|
|
610
|
-
await store.setOption('enabled', false)
|
|
611
|
-
assert.equal((await store.continuePassage('A')).kind, 'empty')
|
|
612
|
-
assert.equal(storage.books.get('book-a').progress, 1, '停读后续读不再推进进度')
|
|
613
|
-
await store.setOption('enabled', true)
|
|
614
|
-
await store.selectBook('book-b')
|
|
615
|
-
assert.equal((await store.continuePassage('A')).passage.text, 'X', '切书后从新书自己的进度续读')
|
|
616
|
-
store.dispose()
|
|
617
|
-
})
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import test from 'node:test'
|
|
2
|
-
import assert from 'node:assert/strict'
|
|
3
|
-
import { decodeBookText } from '../src/text-decoding.js'
|
|
4
|
-
|
|
5
|
-
function utf16(text, bigEndian = false, bom = true) {
|
|
6
|
-
const bytes = new Uint8Array(text.length * 2 + (bom ? 2 : 0))
|
|
7
|
-
const view = new DataView(bytes.buffer)
|
|
8
|
-
if (bom) view.setUint16(0, 0xfeff, !bigEndian)
|
|
9
|
-
for (let i = 0; i < text.length; i++) view.setUint16((bom ? 2 : 0) + i * 2, text.charCodeAt(i), !bigEndian)
|
|
10
|
-
return bytes
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
test('strict UTF-8 accepts buffers, offset views and BOM without leaking the marker', () => {
|
|
14
|
-
const text = '中文小说😀\n第二段'
|
|
15
|
-
assert.equal(decodeBookText(new TextEncoder().encode(text).buffer), text)
|
|
16
|
-
const bytes = new TextEncoder().encode(`x\ufeff${text}x`)
|
|
17
|
-
assert.equal(decodeBookText(bytes.subarray(1, -1)), text)
|
|
18
|
-
})
|
|
19
|
-
|
|
20
|
-
test('UTF-16 LE and BE BOM are decoded without replacement characters', () => {
|
|
21
|
-
for (const bigEndian of [false, true]) assert.equal(decodeBookText(utf16('中文😀', bigEndian)), '中文😀')
|
|
22
|
-
})
|
|
23
|
-
|
|
24
|
-
test('malformed UTF-8, truncated UTF-16 and GBK are rejected explicitly', () => {
|
|
25
|
-
for (const bytes of [Uint8Array.of(0xef, 0xbb, 0xbf, 0xff), Uint8Array.of(0xc3),
|
|
26
|
-
Uint8Array.of(0xd6, 0xd0, 0xce, 0xc4), Uint8Array.of(0xff, 0xfe, 0x61), Uint8Array.of(0xfe, 0xff, 0xd8, 0)]) {
|
|
27
|
-
assert.throws(() => decodeBookText(bytes), /编码/u)
|
|
28
|
-
}
|
|
29
|
-
})
|
|
30
|
-
|
|
31
|
-
test('XML supports UTF-16 byte signatures with and without BOM and matching declarations', () => {
|
|
32
|
-
for (const bigEndian of [false, true]) {
|
|
33
|
-
for (const bom of [false, true]) {
|
|
34
|
-
for (const declaration of ['UTF-16', bigEndian ? 'UTF-16BE' : 'UTF-16LE']) {
|
|
35
|
-
const xml = `<?xml version="1.0" encoding="${declaration}"?><root>中文😀</root>`
|
|
36
|
-
assert.equal(decodeBookText(utf16(xml, bigEndian, bom), { xml: true }), xml)
|
|
37
|
-
}
|
|
38
|
-
assert.equal(decodeBookText(utf16('<root>中文</root>', bigEndian, bom), { xml: true }), '<root>中文</root>')
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
})
|
|
42
|
-
|
|
43
|
-
test('XML rejects unknown declarations and declarations contradictory to actual bytes', () => {
|
|
44
|
-
for (const encoding of ['GBK', 'windows-1252', 'UTF-16', 'UTF-16BE']) {
|
|
45
|
-
assert.throws(() => decodeBookText(new TextEncoder().encode(`<?xml version="1.0" encoding="${encoding}"?><r/>`), { xml: true }), /编码/u)
|
|
46
|
-
}
|
|
47
|
-
assert.throws(() => decodeBookText(utf16('<?xml version="1.0" encoding="UTF-8"?><r/>'), { xml: true }), /编码/u)
|
|
48
|
-
assert.throws(() => decodeBookText(utf16('中文', false, false)), /编码/u)
|
|
49
|
-
})
|