@waterwx/dsh-novel-forge 1.10.1 → 2.0.1-alpha

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 (56) hide show
  1. package/README.md +8 -3
  2. package/assets/styles/guoman-2d-gufeng.webp +0 -0
  3. package/assets/styles/guoman-3d-tianyuan.webp +0 -0
  4. package/assets/styles/guoman-3d-xuanhuan.webp +0 -0
  5. package/assets/styles/hyperreal-3d.webp +0 -0
  6. package/assets/styles/sandiao-qban.webp +0 -0
  7. package/assets/styles/urban-lightreal-3d.webp +0 -0
  8. package/lib/client.js +3456 -2133
  9. package/lib/index.js +1975 -438
  10. package/lib/types/ai-scan.d.ts +36 -0
  11. package/lib/types/assets.d.ts +1 -1
  12. package/lib/types/client/api.d.ts +8 -1
  13. package/lib/types/client/index.d.ts +1 -1
  14. package/lib/types/client/panel/AuthorHome.d.ts +4 -2
  15. package/lib/types/client/panel/FlowGuide.d.ts +6 -5
  16. package/lib/types/client/panel/MangaRoleLibrary.d.ts +3 -1
  17. package/lib/types/client/panel/MangaWorkspace.d.ts +2 -5
  18. package/lib/types/client/panel/PropLibrary.d.ts +8 -0
  19. package/lib/types/client/panel/SceneLibrary.d.ts +3 -1
  20. package/lib/types/client/panel/SettingsView.d.ts +4 -2
  21. package/lib/types/engine.d.ts +50 -21
  22. package/lib/types/index.d.ts +2 -2
  23. package/lib/types/manga-genre-rules.d.ts +22 -0
  24. package/lib/types/novel-context.d.ts +80 -0
  25. package/lib/types/prompt-utils.d.ts +35 -0
  26. package/lib/types/protocol.d.ts +104 -12
  27. package/lib/types/review-policy.d.ts +97 -0
  28. package/lib/types/style-library.d.ts +3 -3
  29. package/package.json +21 -24
  30. package/src/ai-scan.ts +179 -0
  31. package/src/assets.ts +353 -9
  32. package/src/client/api.ts +11 -1
  33. package/src/client/index.ts +1 -1
  34. package/src/client/mount.tsx +1 -1
  35. package/src/client/panel/AdaptModeView.tsx +2 -2
  36. package/src/client/panel/AssistantTab.tsx +1 -1
  37. package/src/client/panel/AuthorHome.tsx +5 -3
  38. package/src/client/panel/FlowGuide.tsx +15 -14
  39. package/src/client/panel/MangaRoleLibrary.tsx +1002 -810
  40. package/src/client/panel/MangaWorkspace.tsx +715 -359
  41. package/src/client/panel/ModelManager.tsx +1 -1
  42. package/src/client/panel/NovelPanel.tsx +4620 -4655
  43. package/src/client/panel/PropLibrary.tsx +175 -0
  44. package/src/client/panel/SceneLibrary.tsx +453 -396
  45. package/src/client/panel/SettingsView.tsx +24 -30
  46. package/src/client/panel/StoryboardTab.tsx +6 -0
  47. package/src/client/panel/panel.module.css +165 -4
  48. package/src/engine.ts +796 -286
  49. package/src/index.ts +9 -7
  50. package/src/manga-genre-rules.ts +87 -0
  51. package/src/novel-context.ts +287 -0
  52. package/src/prompt-utils.ts +73 -0
  53. package/src/protocol.ts +2233 -2148
  54. package/src/review-policy.ts +161 -0
  55. package/src/routes.ts +3419 -3359
  56. package/src/style-library.ts +32 -26
@@ -0,0 +1,175 @@
1
+ /**
2
+ * 道具库:从已写章节自动提炼「常驻道具」(跨镜头需保持一致)→ 注入每个分镜提示词。
3
+ * 支持:AI 提炼 / 手动增删改 / 保存;道具一行统一外观描述,提示词按此外观保持跨镜头一致。
4
+ */
5
+ import { useState } from 'react'
6
+ import type { NovelApi } from '../api.ts'
7
+ import type { ProjectState, Prop } from '../../protocol.ts'
8
+ import css from './panel.module.css'
9
+
10
+ export function PropLibrary({
11
+ api,
12
+ project,
13
+ refresh,
14
+ onProgress,
15
+ }: {
16
+ api: NovelApi
17
+ project: ProjectState | null
18
+ refresh: () => void | Promise<void>
19
+ onProgress?: (text: string, kind?: 'info' | 'done' | 'error') => void
20
+ }) {
21
+ const [busy, setBusy] = useState(false)
22
+ const [error, setError] = useState('')
23
+ const [notice, setNotice] = useState('')
24
+ const [editing, setEditing] = useState<Prop | null>(null)
25
+ const [extracted, setExtracted] = useState<Prop[] | null>(null)
26
+
27
+ const notify = (msg: string): void => { setNotice(msg); setTimeout(() => { setNotice('') }, 3000) }
28
+ const report = (text: string, kind: 'info' | 'done' | 'error' = 'info'): void => { onProgress?.(text, kind) }
29
+
30
+ const props = (project?.props ?? []).map(p => ({ ...p }))
31
+
32
+ /** AI 提炼:从已写章节识别常驻道具,暂存为候选,待保存采纳。 */
33
+ const extract = async (): Promise<void> => {
34
+ setBusy(true); setError('')
35
+ report('从已写章节提炼常驻道具…')
36
+ try {
37
+ const res = await api.mangaProps({ op: 'extract' })
38
+ setExtracted(res.props ?? [])
39
+ await refresh()
40
+ report('道具提炼完成:' + (res.props ?? []).length + ' 个常驻道具', 'done')
41
+ } catch (err) {
42
+ const m = (err as Error).message
43
+ setError(m)
44
+ report('道具提炼失败:' + m, 'error')
45
+ } finally { setBusy(false) }
46
+ }
47
+
48
+ /** 保存:整体替换道具库(候选 / 手动清单)。 */
49
+ const save = async (list: Prop[]): Promise<void> => {
50
+ const cleaned = list.map(p => ({ name: p.name.trim(), desc: p.desc.trim() })).filter(p => p.name !== '')
51
+ if (cleaned.length === 0) { setError('道具名为空,无法保存'); return }
52
+ setBusy(true); setError('')
53
+ report('保存道具库…')
54
+ try {
55
+ await api.mangaProps({ op: 'save', props: cleaned })
56
+ await refresh()
57
+ setExtracted(null)
58
+ setEditing(null)
59
+ report('道具库已保存:' + cleaned.length + ' 个', 'done')
60
+ } catch (err) {
61
+ const m = (err as Error).message
62
+ setError(m)
63
+ report('保存道具库失败:' + m, 'error')
64
+ } finally { setBusy(false) }
65
+ }
66
+
67
+ if (project === null) {
68
+ return <div className={css.card}><span className={css.meta}>请先开书或选择一本书,再进入道具库。</span></div>
69
+ }
70
+
71
+ const editingList: Prop[] = extracted ?? props
72
+
73
+ return (
74
+ <div className={css.card} style={{ flex: 1, minHeight: 0 }}>
75
+ <div className={css.row} style={{ justifyContent: 'space-between', flexWrap: 'wrap' }}>
76
+ <span className={css.cardTitle} style={{ fontSize: 'var(--nf-fs-16)', fontWeight: 700 }}>🎒 道具库</span>
77
+ <span className={css.meta}>常驻道具(跨镜头需保持一致):提炼自已写章节,自动注入每个分镜提示词</span>
78
+ </div>
79
+ <span className={css.meta} style={{ display: 'block', marginTop: 'var(--nf-space-2)' }}>
80
+ 流程位置:道具库(选做) · 前置:已写章节 · 作用:分镜提示词里道具外观跨镜头统一
81
+ </span>
82
+
83
+ <div className={css.row} style={{ flexWrap: 'wrap', gap: 'var(--nf-space-6)', margin: '8px 0' }}>
84
+ <button type="button" className={`${css.button} ${css.buttonPrimary}`} disabled={busy} onClick={() => { void extract() }}>
85
+ {busy ? '⏳ 提炼中…' : '✨ 提炼道具'}
86
+ </button>
87
+ <button type="button" className={`${css.button} ${css.buttonSmall}`} onClick={() => { setEditing({ name: '', desc: '' }) }}>+ 手动添加</button>
88
+ <button type="button" className={`${css.button} ${css.buttonSmall}`} onClick={() => { void refresh(); report('道具库已刷新', 'done') }}>🔄 刷新</button>
89
+ </div>
90
+
91
+ {error !== '' && <div className={css.importError}>{error}</div>}
92
+ {notice !== '' && <div className={css.importResult} style={{ padding: 'var(--nf-space-6) var(--nf-space-10)' }}>{notice}</div>}
93
+
94
+ {/* 提炼候选:待保存 */}
95
+ {extracted !== null && (
96
+ <div style={{ border: '1px solid var(--nf-accent)', borderRadius: 'var(--nf-radius-10)', padding: 'var(--nf-space-10)', marginBottom: 'var(--nf-space-10)' }}>
97
+ <div className={css.row} style={{ justifyContent: 'space-between', flexWrap: 'wrap' }}>
98
+ <b style={{ fontSize: 'var(--nf-fs-14)' }}>✨ AI 提炼结果(确认/编辑后保存)</b>
99
+ <button type="button" className={`${css.button} ${css.buttonSmall}`} onClick={() => { setExtracted(null) }}>取消</button>
100
+ </div>
101
+ {extracted.length === 0
102
+ ? <span className={css.meta} style={{ display: 'block', marginTop: 'var(--nf-space-6)' }}>未识别到明显常驻道具(仅一次性出现的道具不列入)。可手动添加。</span>
103
+ : <PropRows rows={editingList} setRows={setExtracted} />}
104
+ {extracted.length > 0 && (
105
+ <div className={css.row} style={{ marginTop: 'var(--nf-space-8)', gap: 'var(--nf-space-6)' }}>
106
+ <button type="button" className={`${css.button} ${css.buttonSmall} ${css.buttonPrimary}`} disabled={busy} onClick={() => { void save(extracted) }}>保存道具库</button>
107
+ <span className={css.meta}>保存后会注入所有分镜提示词,跨镜头统一此道具外观</span>
108
+ </div>
109
+ )}
110
+ </div>
111
+ )}
112
+
113
+ {/* 手动添加/编辑行 */}
114
+ {editing !== null && extracted === null && (
115
+ <div style={{ border: '1px solid var(--nf-accent)', borderRadius: 'var(--nf-radius-10)', padding: 'var(--nf-space-10)', marginBottom: 'var(--nf-space-10)', display: 'flex', flexDirection: 'column', gap: 'var(--nf-space-6)' }}>
116
+ <b style={{ fontSize: 'var(--nf-fs-14)' }}>编辑道具</b>
117
+ <input className={css.input} style={{ fontSize: 'var(--nf-fs-12)', padding: 'var(--nf-space-4) var(--nf-space-8)' }} placeholder="道具名(如 外卖电动车)" value={editing.name} onChange={e => { setEditing({ ...editing, name: e.target.value }) }} />
118
+ <input className={css.input} style={{ fontSize: 'var(--nf-fs-12)', padding: 'var(--nf-space-4) var(--nf-space-8)' }} placeholder="一行统一外观描述(颜色/材质/状态)" value={editing.desc} onChange={e => { setEditing({ ...editing, desc: e.target.value }) }} />
119
+ <div className={css.row} style={{ gap: 'var(--nf-space-6)' }}>
120
+ <button type="button" className={`${css.button} ${css.buttonPrimary}`} disabled={busy || editing.name.trim() === ''} onClick={() => {
121
+ const list = props
122
+ const idx = list.findIndex(p => p.name === editing.name)
123
+ if (idx >= 0) list[idx] = editing
124
+ else list.push(editing)
125
+ void save(list)
126
+ }}>保存</button>
127
+ <button type="button" className={`${css.button} ${css.buttonSmall}`} onClick={() => { setEditing(null) }}>取消</button>
128
+ </div>
129
+ </div>
130
+ )}
131
+
132
+ {props.length === 0 && extracted === null ? (
133
+ <div className={css.shelfEmpty} style={{ minHeight: 140, flex: 1 }}>
134
+ <span className={css.shelfEmptyIcon}>🎒</span>
135
+ <span className={css.shelfEmptyTitle}>道具库为空</span>
136
+ <span className={css.meta}>点「✨ 提炼道具」自动识别,或「+ 手动添加」</span>
137
+ </div>
138
+ ) : (
139
+ <div style={{ display: 'flex', flexDirection: 'column', gap: 'var(--nf-space-6)' }}>
140
+ {props.map(p => (
141
+ <div key={p.name} style={{ border: '1px solid var(--nf-border)', borderRadius: 'var(--nf-radius-10)', padding: 'var(--nf-space-8) var(--nf-space-10)', display: 'flex', alignItems: 'center', gap: 'var(--nf-space-10)' }}>
142
+ <span style={{ fontSize: 'var(--nf-fs-14)', fontWeight: 600, minWidth: 110 }}>{p.name}</span>
143
+ <span className={css.meta} style={{ flex: 1 }}>{p.desc}</span>
144
+ <span className={css.row} style={{ gap: 'var(--nf-space-4)' }}>
145
+ <button type="button" className={`${css.button} ${css.buttonSmall}`} onClick={() => { setEditing({ ...p }) }}>✏️ 编辑</button>
146
+ <button type="button" className={`${css.button} ${css.buttonSmall}`} style={{ color: 'var(--nf-danger, #e05)' }} onClick={() => { void save(props.filter(x => x.name !== p.name)) }}>🗑</button>
147
+ </span>
148
+ </div>
149
+ ))}
150
+ <button type="button" className={`${css.button} ${css.buttonSmall}`} style={{ alignSelf: 'flex-start' }} onClick={() => { void refresh() }}>已是最新</button>
151
+ </div>
152
+ )}
153
+ </div>
154
+ )
155
+ }
156
+
157
+ /** 可编辑道具行(提炼候选用)。 */
158
+ function PropRows({ rows, setRows }: { rows: Prop[]; setRows: (r: Prop[]) => void }) {
159
+ const set = (idx: number, patch: Partial<Prop>): void => {
160
+ const next = rows.map((r, i) => (i === idx ? { ...r, ...patch } : r))
161
+ setRows(next)
162
+ }
163
+ return (
164
+ <div style={{ display: 'flex', flexDirection: 'column', gap: 'var(--nf-space-4)', marginTop: 'var(--nf-space-6)' }}>
165
+ {rows.map((p, i) => (
166
+ <div key={i} className={css.row} style={{ gap: 'var(--nf-space-6)' }}>
167
+ <input className={css.input} style={{ flex: '0 0 140px', fontSize: 'var(--nf-fs-12)', padding: 'var(--nf-space-4) var(--nf-space-8)' }} value={p.name} onChange={e => { set(i, { name: e.target.value }) }} />
168
+ <input className={css.input} style={{ flex: 1, fontSize: 'var(--nf-fs-12)', padding: 'var(--nf-space-4) var(--nf-space-8)' }} value={p.desc} onChange={e => { set(i, { desc: e.target.value }) }} />
169
+ <button type="button" className={`${css.button} ${css.buttonSmall}`} onClick={() => { setRows(rows.filter((_, idx) => idx !== i)) }}>删</button>
170
+ </div>
171
+ ))}
172
+ <button type="button" className={`${css.button} ${css.buttonSmall}`} style={{ alignSelf: 'flex-start' }} onClick={() => { setRows([...rows, { name: '', desc: '' }]) }}>+ 添加</button>
173
+ </div>
174
+ )
175
+ }