@gongfpp/dsh-novel-fish 1.0.0 → 1.1.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/README.md +42 -14
- package/docs/community-markets.md +18 -1
- package/docs/compatibility-101.md +41 -0
- package/docs/ebook-tests.md +99 -0
- package/docs/evidence/reading-demo-110.png +0 -0
- package/docs/evidence/reading-two-expansions-110.gif +0 -0
- package/docs/evidence/reading-two-expansions-110.json +89 -0
- package/docs/evidence/samples-110-capture.json +49 -0
- package/docs/evidence/settings-110.png +0 -0
- package/docs/marketplace.md +4 -4
- package/docs/release.md +25 -0
- package/index.json +24 -0
- package/lib/client.js +523 -95
- package/locale/en.json +6 -0
- package/locale/zh.json +6 -0
- package/package.json +10 -9
- package/samples/ebooks/LICENSE.md +355 -0
- package/samples/ebooks/NOTICE.md +33 -0
- package/samples/ebooks/aq-zheng-zhuan-wikisource.md +998 -0
- package/samples/ebooks/million-pound-bank-note-pg61522.txt +6970 -0
- package/samples/ebooks/sources.json +58 -0
- package/scripts/build.mjs +1 -0
- package/scripts/check-host-contracts.mjs +3 -2
- package/scripts/make-readme-gif.mjs +69 -0
- package/scripts/test-browser-samples.mjs +665 -0
- package/scripts/test-candidate-books.mjs +71 -0
- package/scripts/test-ebook-corpus.mjs +161 -0
- package/src/bundled-books.js +42 -0
- package/src/chat-adapter.js +34 -9
- package/src/client.js +8 -2
- package/src/novel-content.js +8 -0
- package/src/persistence.js +144 -3
- package/src/pg-notice.js +19 -0
- package/src/segments.js +115 -65
- package/src/settings.js +32 -8
- package/src/store.js +61 -3
- package/test/bundled-library.test.js +526 -0
- package/test/chat-adapter.test.js +87 -2
- package/test/client.test.js +49 -7
- package/test/ebooks.test.js +192 -0
- package/test/pg-notice.test.js +109 -0
- package/test/release.test.js +21 -7
- package/test/segments.test.js +136 -2
- package/test/settings.test.js +42 -1
package/test/settings.test.js
CHANGED
|
@@ -7,6 +7,7 @@ import { DEFAULT_SETTINGS } from '../src/store.js'
|
|
|
7
7
|
import { HostSwitch, HostMenu, HostModal, hostPrimitives } from './helpers/host-primitives.js'
|
|
8
8
|
import zh from '../locale/zh.json' with { type: 'json' }
|
|
9
9
|
import en from '../locale/en.json' with { type: 'json' }
|
|
10
|
+
import manifest from '../samples/ebooks/sources.json' with { type: 'json' }
|
|
10
11
|
|
|
11
12
|
const t = (key, vars = {}) => key.split('.').reduce((value, field) => value?.[field], zh)?.replace(/\{(\w+)\}/gu, (_, key) => String(vars[key])) ?? key
|
|
12
13
|
const SettingsRow = createSettingsRow(React, hostPrimitives)
|
|
@@ -79,7 +80,7 @@ test('图标跟随 DSH,标题使用原生菜单,自定义后才出现宿主
|
|
|
79
80
|
try {
|
|
80
81
|
assert.equal(view.root.findAllByType('input').filter(node => node.props.type !== 'file').length, 0)
|
|
81
82
|
assert.equal(view.root.findAllByProps({ 'data-novel-preset': 'icon' }).length, 0)
|
|
82
|
-
assert.
|
|
83
|
+
assert.doesNotMatch(JSON.stringify(view.toJSON()), /图标与折叠交互跟随 DSH/u)
|
|
83
84
|
assert.deepEqual(model.options, [])
|
|
84
85
|
await act(async () => menu(view, 'data-novel-preset', 'title').props.onSelect('__custom'))
|
|
85
86
|
await act(async () => control(view, 'data-novel-title').props.onChange({ currentTarget: { value: '我的标题' } }))
|
|
@@ -157,6 +158,42 @@ test('原生导入按钮触发隐藏文件选择;导入失败清空文件值
|
|
|
157
158
|
} finally { await act(async () => view.unmount()) }
|
|
158
159
|
})
|
|
159
160
|
|
|
161
|
+
test('书籍统一选择和删除,默认无说明块,书源许可只在菜单次级弹窗内', async () => {
|
|
162
|
+
const model = setup()
|
|
163
|
+
model.props.sampleBooks = manifest.books
|
|
164
|
+
model.props.getSampleLicenseHref = () => 'data:text/plain;charset=utf-8,Combined%20licenses%20and%20attribution'
|
|
165
|
+
model.state.books.push(...manifest.books.map(book => ({ ...book, id: `bundled:${book.id}`, bundledId: book.id, progress: 0, segmentCount: 8 })))
|
|
166
|
+
const view = await mount(model)
|
|
167
|
+
try {
|
|
168
|
+
assert.equal(view.root.findAllByType('h3').length, 3)
|
|
169
|
+
assert.equal(menu(view, 'data-novel-sample-select'), undefined)
|
|
170
|
+
assert.equal(view.root.findAllByType('a').length, 0, 'No ordinary source/license links')
|
|
171
|
+
assert.equal(view.root.findAllByType('progress')[0].props.value, 1)
|
|
172
|
+
assert.doesNotMatch(JSON.stringify(view.toJSON()), /离线按需导入|各书许可|This eBook|预设,无需打字/u)
|
|
173
|
+
const picker = () => menu(view, 'data-novel-book-select')
|
|
174
|
+
assert.deepEqual(picker().props.items.map(item => item.id), ['', 'book-a', ...manifest.books.map(book => `bundled:${book.id}`)])
|
|
175
|
+
const id = `bundled:${manifest.books[0].id}`
|
|
176
|
+
await act(async () => picker().props.onSelect(id))
|
|
177
|
+
assert.deepEqual(model.books, [id])
|
|
178
|
+
assert.equal(model.state.books.find(book => book.id === id).progress, 0)
|
|
179
|
+
await act(async () => view.update(React.createElement(SettingsRow, model.props)))
|
|
180
|
+
await act(async () => control(view, 'data-novel-delete').props.onClick())
|
|
181
|
+
assert.equal(view.root.findByType(HostModal).props.open, true, 'Bundled books use the normal deletion modal')
|
|
182
|
+
await act(async () => view.root.findByType(HostModal).props.onClose())
|
|
183
|
+
assert.deepEqual(picker().props.footer.map(item => item.id), ['__book-info'])
|
|
184
|
+
await act(async () => picker().props.onSelect('__book-info'))
|
|
185
|
+
assert.deepEqual(model.books, [id], 'Information is not a book selection')
|
|
186
|
+
const info = view.root.findAllByType(HostModal).find(modal => modal.props.title === t('settings.bookInfo'))
|
|
187
|
+
assert.equal(info.props.open, true)
|
|
188
|
+
const links = view.root.findAllByType('a')
|
|
189
|
+
assert.equal(links.find(link => link.props.download)?.props.href, model.props.getSampleLicenseHref())
|
|
190
|
+
for (const book of manifest.books) assert.equal(links.find(link => link.props.href === book.source)?.children.join(''), book.title)
|
|
191
|
+
assert.match(control(view, 'data-novel-sample-license').children.join(''), /This eBook/u)
|
|
192
|
+
await act(async () => info.props.onClose())
|
|
193
|
+
assert.equal(view.root.findAllByType('a').length, 0)
|
|
194
|
+
} finally { await act(async () => view.unmount()) }
|
|
195
|
+
})
|
|
196
|
+
|
|
160
197
|
test('删除使用宿主 Modal;取消不删除、保存失败可重试、快速确认不重复删除', async () => {
|
|
161
198
|
const model = setup(), deleted = []
|
|
162
199
|
let reject
|
|
@@ -268,4 +305,8 @@ test('中英文设置文案键一致,不再含位置选择翻译', () => {
|
|
|
268
305
|
assert.equal(typeof en.settings[key], 'string')
|
|
269
306
|
}
|
|
270
307
|
assert.equal(Object.hasOwn(zh.settings, 'targetKey'), false)
|
|
308
|
+
for (const key of ['bookInfo', 'close', 'readingProgress']) assert.ok(zh.settings[key] && en.settings[key])
|
|
309
|
+
assert.equal(zh.settings.sampleHint, undefined)
|
|
310
|
+
assert.equal(en.settings.sampleHint, undefined)
|
|
311
|
+
assert.match(en.settings.samplePgNotice, /only to the English collection.*not to the other bundled books/u)
|
|
271
312
|
})
|