@lincyaw/workbench 0.2.0-rc.11 → 0.2.0-rc.110
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/package.json +5 -4
- package/src/AgentActivityBar.tsx +25 -0
- package/src/MediaClipEditor.tsx +4 -3
- package/src/StepProductionEditor.tsx +13 -4
- package/src/agent-activity-messages.ts +14 -0
- package/src/agent-activity.ts +38 -0
- package/src/approvals.tsx +6 -1
- package/src/audio-recording-messages.ts +5 -5
- package/src/audio-recording.ts +27 -5
- package/src/authoring-client.ts +10 -10
- package/src/authoring-draft-fragment.ts +3 -1
- package/src/authoring-window.ts +100 -0
- package/src/base-controls.tsx +2 -2
- package/src/body-draft-actions.ts +60 -0
- package/src/caption-timing-drafts.ts +18 -1
- package/src/caption-timing-messages.ts +2 -2
- package/src/component-property-drafts.ts +5 -5
- package/src/components.tsx +34 -36
- package/src/container-layout.ts +21 -0
- package/src/context.tsx +5 -3
- package/src/diagnostics.ts +1 -1
- package/src/document-draft-store.ts +45 -18
- package/src/document-drafts.ts +28 -19
- package/src/document-editing.ts +484 -0
- package/src/document-editor/BlockNoteSurface.tsx +39 -13
- package/src/document-editor/CommentComposer.tsx +24 -0
- package/src/document-editor/ComponentMaterials.tsx +3 -9
- package/src/document-editor/ComponentPropertiesDialog.tsx +4 -4
- package/src/document-editor/DocumentBlockPreview.tsx +11 -4
- package/src/document-editor/DocumentComments.tsx +85 -14
- package/src/document-editor/DocumentEditor.tsx +56 -7
- package/src/document-editor/DocumentStepNarration.tsx +37 -26
- package/src/document-editor/NarrationEditor.tsx +54 -20
- package/src/document-editor/NewCommentDrafts.tsx +120 -37
- package/src/document-editor/PlaceComment.tsx +252 -0
- package/src/document-editor/agent-targets.ts +34 -0
- package/src/document-editor/blocknote-messages.ts +2 -0
- package/src/document-editor/comment-draft-actions.ts +40 -20
- package/src/document-editor/comment-draft-inspection.ts +2 -2
- package/src/document-editor/comment-drafts.ts +73 -25
- package/src/document-editor/comments.ts +30 -10
- package/src/document-editor/component-label.ts +11 -0
- package/src/document-editor/file-input.ts +2 -2
- package/src/document-editor/focus.ts +0 -2
- package/src/document-editor/insertion-place.ts +60 -0
- package/src/document-editor/messages.ts +3 -3
- package/src/document-editor/narration-schema.tsx +12 -6
- package/src/document-editor/narration.ts +19 -3
- package/src/document-editor/page-body.ts +60 -0
- package/src/document-editor/popover.tsx +4 -2
- package/src/document-editor/projection.ts +2 -2
- package/src/document-editor/rich-text.ts +3 -2
- package/src/document-editor/selection.ts +13 -0
- package/src/document-editor/style.css +7 -1
- package/src/document-editor/table-identities.ts +2 -1
- package/src/document-production.ts +491 -0
- package/src/document-session.ts +202 -56
- package/src/document-timing-drafts.ts +22 -2
- package/src/history.ts +5 -5
- package/src/index.ts +11 -5
- package/src/jobs.ts +1 -1
- package/src/mcp-settings-messages.ts +39 -0
- package/src/media-drafts.ts +43 -1
- package/src/messages.ts +33 -16
- package/src/panels/DocumentNarrationPanel.tsx +2 -2
- package/src/panels/DocumentView.tsx +97 -65
- package/src/panels/DocumentVoiceDialog.tsx +25 -9
- package/src/panels/DocumentVoiceField.tsx +1 -1
- package/src/panels/ExportPanel.tsx +2 -10
- package/src/panels/HistoryPanel.tsx +34 -7
- package/src/panels/HomePanel.tsx +3 -1
- package/src/panels/McpSettingsPanel.tsx +86 -0
- package/src/panels/PageDeleteDialog.tsx +4 -4
- package/src/panels/PageRenameDialog.tsx +1 -1
- package/src/panels/PreviewPanel.tsx +1 -4
- package/src/panels/ProductionCaptionSize.tsx +20 -0
- package/src/panels/ProductionCaptionTiming.tsx +12 -9
- package/src/panels/ProductionMediaClips.tsx +23 -7
- package/src/panels/ProductionPanel.tsx +16 -13
- package/src/panels/ProductionRecording.tsx +86 -9
- package/src/panels/ProductionRecordingRange.tsx +21 -19
- package/src/panels/ProductionTimeline.tsx +6 -1
- package/src/panels/ProductionTranscription.tsx +5 -4
- package/src/panels/SourceDocumentPanel.tsx +18 -36
- package/src/panels/SpeechSettingsPanel.tsx +1 -1
- package/src/panels/TranscriptionAdoption.tsx +40 -34
- package/src/panels/VoiceCloneDialog.tsx +2 -1
- package/src/panels/VoiceoverDialog.tsx +1 -1
- package/src/places.ts +1 -36
- package/src/preview-playback.ts +1 -1
- package/src/production-draft-actions.ts +37 -0
- package/src/production-messages.ts +6 -0
- package/src/production-playback.ts +1 -1
- package/src/production-voice-playback.ts +3 -2
- package/src/sha256.ts +9 -0
- package/src/speech-settings-messages.ts +5 -5
- package/src/styles.css +43 -79
- package/src/transcription-drafts.ts +124 -0
- package/src/use-recording-adoption.ts +2 -2
- package/src/voice-drafts.ts +32 -8
- package/src/voice-messages.ts +9 -9
- package/src/voiceover-jobs.ts +1 -1
- package/src/workbench-state.ts +159 -0
- package/src/workbench.ts +303 -952
- package/src/workspace-client.ts +30 -11
- package/src/assistant-mascot.ts +0 -62
- package/src/mascot-preference.ts +0 -37
- package/src/panels/ChangeTrail.tsx +0 -79
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import { isRecord, randomUUID } from '@lincyaw/kernel'
|
|
2
|
+
import type { NarrationNode, TranscriptionAdoptionDraft } from '@lincyaw/kernel'
|
|
3
|
+
|
|
4
|
+
export interface TranscriptionCorrection { id: string, revision: number, nodes?: NarrationNode[], discarded: string[], shared: 'fork' | 'edit-shared', baseVersion?: string, applied?: boolean }
|
|
5
|
+
export interface TranscriptionCorrectionTarget { identity: string, candidate: TranscriptionAdoptionDraft['candidate'], stepId: string, narrationId?: string, segmentIds: string[] }
|
|
6
|
+
interface Entry { target: TranscriptionCorrectionTarget, draft?: TranscriptionCorrection, raw?: string | null, failed: boolean, corrupt: boolean }
|
|
7
|
+
const prefix = 'presmium.transcription-draft.v1:'
|
|
8
|
+
export const transcriptionCorrectionKey = (target: TranscriptionCorrectionTarget): string => JSON.stringify([target.identity, target.candidate.id, target.candidate.revision, target.stepId, target.narrationId ?? null, target.segmentIds])
|
|
9
|
+
const fresh = (): TranscriptionCorrection => ({ id: randomUUID(), revision: 0, discarded: [], shared: 'fork' })
|
|
10
|
+
function valid(value: unknown): value is TranscriptionCorrection {
|
|
11
|
+
return isRecord(value) && typeof value.id === 'string' && Number.isSafeInteger(value.revision) && Number(value.revision) >= 0 && Array.isArray(value.discarded) && value.discarded.every(key => typeof key === 'string') && ['fork', 'edit-shared'].includes(String(value.shared))
|
|
12
|
+
&& (value.baseVersion === undefined || typeof value.baseVersion === 'string') && (value.applied === undefined || typeof value.applied === 'boolean')
|
|
13
|
+
&& (value.nodes === undefined || Array.isArray(value.nodes) && value.nodes.every(node => isRecord(node) && (node.type === 'text' && typeof node.text === 'string' || node.type === 'pronunciation' && typeof node.display === 'string' && typeof node.spoken === 'string' || node.type === 'cue' && typeof node.id === 'string' && typeof node.action === 'string')))
|
|
14
|
+
}
|
|
15
|
+
function parseTarget(key: string): TranscriptionCorrectionTarget | undefined {
|
|
16
|
+
try {
|
|
17
|
+
const value: unknown = JSON.parse(key)
|
|
18
|
+
if (!Array.isArray(value) || value.length !== 6) return
|
|
19
|
+
const [identity, id, revision, stepId, narrationId, segmentIds] = value
|
|
20
|
+
if (typeof identity !== 'string' || typeof id !== 'string' || typeof revision !== 'string' || typeof stepId !== 'string' || narrationId !== null && typeof narrationId !== 'string' || !Array.isArray(segmentIds) || !segmentIds.every(id => typeof id === 'string')) return
|
|
21
|
+
return { identity, candidate: { id, revision }, stepId, ...narrationId !== null ? { narrationId } : {}, segmentIds }
|
|
22
|
+
} catch { return }
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/** The native correction bank uses its existing localStorage keys; no MCP copy or provider result is changed. */
|
|
26
|
+
export class TranscriptionCorrections {
|
|
27
|
+
readonly #entries = new Map<string, Entry>()
|
|
28
|
+
#load(target: TranscriptionCorrectionTarget): Entry {
|
|
29
|
+
const key = transcriptionCorrectionKey(target), known = this.#entries.get(key)
|
|
30
|
+
if (known) return known
|
|
31
|
+
const entry: Entry = { target: structuredClone(target), failed: false, corrupt: false }
|
|
32
|
+
this.#entries.set(key, entry)
|
|
33
|
+
try {
|
|
34
|
+
entry.raw = localStorage.getItem(prefix + key)
|
|
35
|
+
if (entry.raw !== null) {
|
|
36
|
+
const value: unknown = JSON.parse(entry.raw)
|
|
37
|
+
if (!valid(value)) throw new Error('invalid-draft')
|
|
38
|
+
entry.draft = value
|
|
39
|
+
}
|
|
40
|
+
} catch { entry.failed = true; entry.corrupt = entry.raw != null }
|
|
41
|
+
return entry
|
|
42
|
+
}
|
|
43
|
+
read(target: TranscriptionCorrectionTarget): { draft: TranscriptionCorrection, failed: boolean } {
|
|
44
|
+
const entry = this.#load(target)
|
|
45
|
+
// A reopened native form adopts another window's saved value, retaining failed local input.
|
|
46
|
+
try {
|
|
47
|
+
const raw = localStorage.getItem(prefix + transcriptionCorrectionKey(target))
|
|
48
|
+
if (raw !== entry.raw && !(entry.failed && entry.draft)) {
|
|
49
|
+
const value: unknown = raw === null ? undefined : JSON.parse(raw)
|
|
50
|
+
if (value !== undefined && !valid(value)) throw new Error('invalid-draft')
|
|
51
|
+
entry.raw = raw; entry.draft = value as TranscriptionCorrection | undefined; entry.failed = false; entry.corrupt = false
|
|
52
|
+
} else if (raw !== entry.raw) entry.failed = true
|
|
53
|
+
} catch { entry.failed = true }
|
|
54
|
+
return { draft: entry.draft ? structuredClone(entry.draft) : fresh(), failed: entry.failed }
|
|
55
|
+
}
|
|
56
|
+
keep(target: TranscriptionCorrectionTarget, draft: TranscriptionCorrection): boolean {
|
|
57
|
+
if (!valid(draft)) throw new Error('invalid-draft')
|
|
58
|
+
const entry = this.#load(target), key = prefix + transcriptionCorrectionKey(target)
|
|
59
|
+
entry.draft = structuredClone(draft)
|
|
60
|
+
try {
|
|
61
|
+
if (entry.raw === undefined || localStorage.getItem(key) !== entry.raw) throw new Error('changed-draft')
|
|
62
|
+
if (entry.corrupt && entry.raw != null) localStorage.setItem(key + ':unreadable', entry.raw)
|
|
63
|
+
const raw = JSON.stringify(draft)
|
|
64
|
+
localStorage.setItem(key, raw)
|
|
65
|
+
entry.raw = raw; entry.failed = false; entry.corrupt = false
|
|
66
|
+
return true
|
|
67
|
+
} catch { entry.failed = true; return false }
|
|
68
|
+
}
|
|
69
|
+
/** A completed native adoption cannot retire input changed in another form/window while it ran. */
|
|
70
|
+
complete(target: TranscriptionCorrectionTarget, expected: TranscriptionCorrection, next: TranscriptionCorrection): boolean {
|
|
71
|
+
const key = transcriptionCorrectionKey(target), entry = this.#entries.get(key)
|
|
72
|
+
if (!entry || entry.corrupt || JSON.stringify(entry.draft) !== JSON.stringify(expected)) return false
|
|
73
|
+
try {
|
|
74
|
+
if (entry.raw === undefined || localStorage.getItem(prefix + key) !== entry.raw) return false
|
|
75
|
+
const raw = JSON.stringify(next)
|
|
76
|
+
localStorage.setItem(prefix + key, raw)
|
|
77
|
+
entry.raw = raw; entry.draft = structuredClone(next); entry.failed = false
|
|
78
|
+
return true
|
|
79
|
+
} catch { entry.failed = true; return false }
|
|
80
|
+
}
|
|
81
|
+
discard(key: string, expected: TranscriptionCorrection): boolean {
|
|
82
|
+
const entry = this.#entries.get(key)
|
|
83
|
+
if (!entry || entry.corrupt || JSON.stringify(entry.draft) !== JSON.stringify(expected)) return false
|
|
84
|
+
try {
|
|
85
|
+
if (entry.raw === undefined || localStorage.getItem(prefix + key) !== entry.raw) return false
|
|
86
|
+
localStorage.removeItem(prefix + key)
|
|
87
|
+
this.#entries.delete(key)
|
|
88
|
+
return true
|
|
89
|
+
} catch { entry.failed = true; return false }
|
|
90
|
+
}
|
|
91
|
+
snapshot(identity: string) {
|
|
92
|
+
const keys = new Set([...this.#entries].filter(([, entry]) => entry.target.identity === identity).map(([key]) => key))
|
|
93
|
+
let partial = false
|
|
94
|
+
const head = prefix + JSON.stringify([identity]).slice(0, -1) + ','
|
|
95
|
+
try {
|
|
96
|
+
for (let i = 0; i < localStorage.length; i++) {
|
|
97
|
+
const key = localStorage.key(i)
|
|
98
|
+
if (key?.startsWith(head) && !key.endsWith(':unreadable')) keys.add(key.slice(prefix.length))
|
|
99
|
+
}
|
|
100
|
+
} catch { partial = true }
|
|
101
|
+
const entries: { key: string, target: TranscriptionCorrectionTarget, draft: TranscriptionCorrection, persisted: boolean }[] = [], observed: [string, string | null][] = []
|
|
102
|
+
for (const key of keys) {
|
|
103
|
+
const target = parseTarget(key)
|
|
104
|
+
if (!target || target.identity !== identity) { partial = true; continue }
|
|
105
|
+
const entry = this.#load(target)
|
|
106
|
+
let persisted = false
|
|
107
|
+
try {
|
|
108
|
+
const raw = localStorage.getItem(prefix + key)
|
|
109
|
+
observed.push([key, raw])
|
|
110
|
+
persisted = !entry.failed && !entry.corrupt && raw === entry.raw
|
|
111
|
+
if (raw !== entry.raw) partial = true
|
|
112
|
+
} catch { partial = true }
|
|
113
|
+
if (entry.corrupt || entry.raw === undefined) partial = true
|
|
114
|
+
if (entry.draft && !entry.draft.applied) entries.push({ key, target: structuredClone(target), draft: structuredClone(entry.draft), persisted })
|
|
115
|
+
}
|
|
116
|
+
return { entries, partial, guard: () => {
|
|
117
|
+
for (const [key, raw] of observed) {
|
|
118
|
+
try { if (localStorage.getItem(prefix + key) === raw) continue } catch { /* Cannot verify the same persisted input. */ }
|
|
119
|
+
throw new Error('client-production-drafts-changed')
|
|
120
|
+
}
|
|
121
|
+
} }
|
|
122
|
+
}
|
|
123
|
+
close(): void { this.#entries.clear() }
|
|
124
|
+
}
|
|
@@ -58,13 +58,13 @@ export function useRecordingAdoption({ identity, sectionId, stepId, active, disa
|
|
|
58
58
|
if (!owns()) return
|
|
59
59
|
const source = workbench.getState().authoring
|
|
60
60
|
if (!source?.version || !source.fingerprint || !source.content || source.identity !== identity || source.dirty || source.saving || source.composing || source.restored || source.error) throw new Error('production-source-changed')
|
|
61
|
-
const expected = { identity, version: source.version }, inspection = await workbench.
|
|
61
|
+
const expected = { identity, version: source.version }, inspection = await workbench.production.inspectAudio(target.assetId, expected, controller.signal)
|
|
62
62
|
if (!owns()) return
|
|
63
63
|
const canonical = { documentId: source.content.id, version: source.version, fingerprint: source.fingerprint }, previous = retry.current
|
|
64
64
|
sent = previous && previous.source.documentId === canonical.documentId && previous.source.version === canonical.version && previous.source.fingerprint === canonical.fingerprint && previous.stepId === target.stepId && previous.assetId === target.assetId && previous.sha256 === inspection.inspection.sha256
|
|
65
65
|
? previous : { id: requestId(), source: canonical, stepId: target.stepId, assetId: target.assetId, sha256: inspection.inspection.sha256 }
|
|
66
66
|
retry.current = sent; submitted.current = sent
|
|
67
|
-
await workbench.
|
|
67
|
+
await workbench.production.adoptRecording(sent, expected, controller.signal)
|
|
68
68
|
if (!owns()) return
|
|
69
69
|
if (retry.current === sent) retry.current = undefined
|
|
70
70
|
setFailure(undefined)
|
package/src/voice-drafts.ts
CHANGED
|
@@ -5,7 +5,7 @@ import type { WorkspaceClient } from './workspace-client.ts'
|
|
|
5
5
|
|
|
6
6
|
export interface VoiceDraft { version: string, scope: DocumentVoiceScope, source: VoiceSource | null, replaceOverrides: boolean, rateInput?: string }
|
|
7
7
|
export type VoiceDraftStorageStatus = 'available' | 'unavailable' | 'corrupt'
|
|
8
|
-
interface StoredDraft { draft?: VoiceDraft, status: VoiceDraftStorageStatus, unreadable?: string }
|
|
8
|
+
interface StoredDraft { draft?: VoiceDraft, status: VoiceDraftStorageStatus, unreadable?: string, raw?: string | null }
|
|
9
9
|
const drafts = new WeakMap<WorkspaceClient, Map<string, StoredDraft>>()
|
|
10
10
|
const keyOf = (identity: string, stepId: string) => JSON.stringify([identity, stepId])
|
|
11
11
|
const storageKey = (key: string) => `presmium.voice-draft.v2:${key}`
|
|
@@ -36,6 +36,7 @@ function load(client: WorkspaceClient, key: string): StoredDraft {
|
|
|
36
36
|
known.set(key, entry)
|
|
37
37
|
try {
|
|
38
38
|
const raw = sessionStorage.getItem(storageKey(key))
|
|
39
|
+
entry.raw = raw
|
|
39
40
|
if (raw !== null) {
|
|
40
41
|
entry.unreadable = raw
|
|
41
42
|
const value: unknown = JSON.parse(raw)
|
|
@@ -64,7 +65,9 @@ export function keepVoiceDraft(client: WorkspaceClient, identity: string, stepId
|
|
|
64
65
|
entry.draft = structuredClone(value)
|
|
65
66
|
try {
|
|
66
67
|
if (entry.unreadable !== undefined) sessionStorage.setItem(`${storageKey(key)}:unreadable`, entry.unreadable)
|
|
67
|
-
|
|
68
|
+
const raw = JSON.stringify(entry.draft)
|
|
69
|
+
sessionStorage.setItem(storageKey(key), raw)
|
|
70
|
+
entry.raw = raw
|
|
68
71
|
entry.status = 'available'; delete entry.unreadable
|
|
69
72
|
return true
|
|
70
73
|
} catch { entry.status = 'unavailable'; return false }
|
|
@@ -76,14 +79,35 @@ export function clearVoiceDraft(client: WorkspaceClient, identity: string, stepI
|
|
|
76
79
|
if (expected && JSON.stringify(entry.draft) !== JSON.stringify(expected)) return false
|
|
77
80
|
try {
|
|
78
81
|
const raw = sessionStorage.getItem(storageKey(key))
|
|
79
|
-
if (expected && raw !==
|
|
80
|
-
let persisted: unknown
|
|
81
|
-
try { persisted = JSON.parse(raw) } catch { entry.status = 'corrupt'; entry.unreadable = raw; return false }
|
|
82
|
-
if (!valid(persisted)) { entry.status = 'corrupt'; entry.unreadable = raw; return false }
|
|
83
|
-
if (JSON.stringify(persisted) !== JSON.stringify(expected)) return false
|
|
84
|
-
}
|
|
82
|
+
if (expected && (entry.unreadable !== undefined || raw !== entry.raw)) return false
|
|
85
83
|
sessionStorage.removeItem(storageKey(key))
|
|
84
|
+
entry.raw = null
|
|
86
85
|
delete entry.draft; delete entry.unreadable; entry.status = 'available'
|
|
87
86
|
return true
|
|
88
87
|
} catch { entry.status = 'unavailable'; return false }
|
|
89
88
|
}
|
|
89
|
+
|
|
90
|
+
/** Enumerate this native bank, including offscreen forms; callers receive no second persisted copy. */
|
|
91
|
+
export function voiceDraftSnapshot(client: WorkspaceClient, identity: string): { entries: { stepId: string, value: VoiceDraft, persisted: boolean }[], partial: boolean } {
|
|
92
|
+
const keys = new Set([...store(client).keys()].filter(key => key.startsWith(`${JSON.stringify([identity]).slice(0, -1)},`)))
|
|
93
|
+
let partial = false
|
|
94
|
+
try {
|
|
95
|
+
const prefix = `presmium.voice-draft.v2:${JSON.stringify([identity]).slice(0, -1)},`
|
|
96
|
+
for (let index = 0; index < sessionStorage.length; index++) {
|
|
97
|
+
const key = sessionStorage.key(index)
|
|
98
|
+
if (key?.startsWith(prefix) && !key.endsWith(':unreadable')) keys.add(key.slice('presmium.voice-draft.v2:'.length))
|
|
99
|
+
}
|
|
100
|
+
} catch { partial = true }
|
|
101
|
+
const entries: { stepId: string, value: VoiceDraft, persisted: boolean }[] = []
|
|
102
|
+
for (const key of keys) {
|
|
103
|
+
let target: unknown
|
|
104
|
+
try { target = JSON.parse(key) } catch { partial = true; continue }
|
|
105
|
+
if (!Array.isArray(target) || target.length !== 2 || target[0] !== identity || typeof target[1] !== 'string') { partial = true; continue }
|
|
106
|
+
const entry = load(client, key)
|
|
107
|
+
let persisted = false
|
|
108
|
+
try { const raw = sessionStorage.getItem(storageKey(key)); persisted = entry.status === 'available' && raw === entry.raw; if (raw !== entry.raw) partial = true } catch { partial = true }
|
|
109
|
+
if (entry.status === 'corrupt' || entry.raw === undefined) partial = true
|
|
110
|
+
if (entry.draft) entries.push({ stepId: target[1], value: structuredClone(entry.draft), persisted })
|
|
111
|
+
}
|
|
112
|
+
return { entries, partial }
|
|
113
|
+
}
|
package/src/voice-messages.ts
CHANGED
|
@@ -31,21 +31,21 @@ const zh = {
|
|
|
31
31
|
auditionFailed: '无法试听,请重试。音色设置未更改。',
|
|
32
32
|
pauseUnavailable: '预览尚不支持暂停播放,暂时无法试听。请重新加载文稿。',
|
|
33
33
|
pauseTimeout: '无法确认播放已暂停,请重试。',
|
|
34
|
-
changed: '
|
|
34
|
+
changed: '文稿或音色设置已更新。草稿已保留,请重新检查范围。',
|
|
35
35
|
draftRecovered: '已恢复尚未应用的音色设置草稿,请检查范围后应用。', recoveryFailed: '无法在此浏览器保留音色草稿,请在关闭前应用或复制设置。',
|
|
36
|
-
recheck: '
|
|
36
|
+
recheck: '重新检查', scope: '应用范围', scopes: { step: '当前步骤', steps: '所选步骤', page: '当前页', document: '整份文稿' },
|
|
37
37
|
selectedSteps: '选择步骤', step: (page: number, step: number) => `第 ${page} 页,步骤 ${step}`,
|
|
38
38
|
selected: (count: number) => `已选择 ${count} 个步骤`, inherit: '使用继承的音色', inheritHint: '改用最近的页面或文稿默认音色。',
|
|
39
39
|
pageScript: (page: number) => `第 ${page} 页,关联讲稿(按页生成)`,
|
|
40
40
|
replace: '已有覆盖', preserve: '保留独立设置', replaceAll: '替换独立设置',
|
|
41
41
|
counts: (updated: number, preserved: number) => `将更新 ${updated} 个步骤,保留 ${preserved} 个独立设置。`,
|
|
42
|
-
check: '
|
|
42
|
+
check: '检查范围', checking: '正在检查范围…', apply: '应用', saved: '音色设置已保存。', cachedPreview: '本次使用已有配音缓存。', clearDefault: '清除默认音色',
|
|
43
43
|
rate: '语速', rateInvalid: (min: number, max: number) => `请输入 ${min}–${max} 之间的数值。`, style: '朗读风格', styleDefault: '服务默认',
|
|
44
44
|
cueStep: '此讲稿包含跨步骤提示,暂不支持单独覆盖音色。可设置页面或文稿默认音色。',
|
|
45
45
|
disclosure: (provider: string, local: boolean) => local ? `本次在本机通过 ${provider} 合成。` : `本次将所示讲稿发送至 ${provider} 合成配音。`,
|
|
46
|
-
confirmPreview: '
|
|
46
|
+
confirmPreview: '试听', sampleText: '标准示例文本', source: '声音来源', previewHint: '确认后播放已有缓存或请求合成;选择音色本身不会生成配音。',
|
|
47
47
|
refreshing: '正在加载配音状态…', refresh: '刷新状态', missingOnly: '只生成缺失与需要更新的片段',
|
|
48
|
-
confirmGenerate: '
|
|
48
|
+
confirmGenerate: '生成配音', cancelJob: '取消生成', oldVersion: '较早文稿版本', noScript: '当前范围没有可生成的讲稿。',
|
|
49
49
|
statuses: { ready: '可播放', missing: '需要生成', blocked: '暂不可生成', empty: '没有讲稿' },
|
|
50
50
|
jobs: { queued: '等待生成', running: '正在生成', cancelling: '正在取消', cancelled: '已取消', done: '已完成', failed: '生成失败', stale: '文稿已更新' },
|
|
51
51
|
progress: (done: number, total: number, failed: number) => `已完成 ${done} / ${total}${failed ? `,失败 ${failed}` : ''}`,
|
|
@@ -89,19 +89,19 @@ const en: VoiceMessages = {
|
|
|
89
89
|
pauseTimeout: 'Couldn’t confirm that playback paused. Try again.',
|
|
90
90
|
changed: 'The document or voice settings changed. Your draft is kept; check the scope again for the current step.',
|
|
91
91
|
draftRecovered: 'Your draft voice settings were recovered. Check the scope before applying them.', recoveryFailed: 'Voice drafts can’t be kept in this browser. Apply or copy your settings before closing.',
|
|
92
|
-
recheck: '
|
|
92
|
+
recheck: 'Recheck', scope: 'Apply to', scopes: { step: 'Current step', steps: 'Selected steps', page: 'Current page', document: 'Entire document' },
|
|
93
93
|
selectedSteps: 'Select Steps', step: (page, step) => `Page ${page}, step ${step}`, selected: count => `${count} steps selected`,
|
|
94
94
|
pageScript: page => `Page ${page}, linked script (generate by page)`,
|
|
95
95
|
inherit: 'Use Inherited Voice', inheritHint: 'Use the nearest page or document default voice.',
|
|
96
96
|
replace: 'Existing overrides', preserve: 'Keep independent settings', replaceAll: 'Replace independent settings',
|
|
97
97
|
counts: (updated, preserved) => `${updated} steps will update; ${preserved} independent settings will be kept.`,
|
|
98
|
-
check: 'Check Scope', checking: 'Checking scope…', apply: 'Apply
|
|
98
|
+
check: 'Check Scope', checking: 'Checking scope…', apply: 'Apply', saved: 'Voice settings saved.', cachedPreview: 'This preview uses an existing voiceover cache.', clearDefault: 'Clear Default Voice',
|
|
99
99
|
rate: 'Speaking rate', rateInvalid: (min, max) => `Enter a number between ${min} and ${max}.`, style: 'Reading style', styleDefault: 'Service default',
|
|
100
100
|
cueStep: 'This script has cues across steps. A step voice override is not supported yet; set a page or document default instead.',
|
|
101
101
|
disclosure: (provider, local) => local ? `The voiceover is generated on this device with ${provider}.` : `The script shown is sent to ${provider} to generate the voiceover.`,
|
|
102
|
-
confirmPreview: '
|
|
102
|
+
confirmPreview: 'Play Sample', sampleText: 'Standard sample text', source: 'Voice source', previewHint: 'After you confirm, a saved voiceover plays or a new one is generated. Choosing a voice doesn’t generate voiceover.',
|
|
103
103
|
refreshing: 'Loading voiceover status…', refresh: 'Refresh Status', missingOnly: 'Generate only missing clips and clips that need updating',
|
|
104
|
-
confirmGenerate: '
|
|
104
|
+
confirmGenerate: 'Generate', cancelJob: 'Cancel Generating', oldVersion: 'Earlier document version', noScript: 'There is no script to generate in this scope.',
|
|
105
105
|
statuses: { ready: 'Playable', missing: 'Needs generation', blocked: 'Unavailable', empty: 'No script' },
|
|
106
106
|
jobs: { queued: 'Queued', running: 'Generating', cancelling: 'Canceling', cancelled: 'Canceled', done: 'Completed', failed: 'Generation failed', stale: 'Document changed' },
|
|
107
107
|
progress: (done, total, failed) => `${done} / ${total} completed${failed ? `; ${failed} failed` : ''}`,
|
package/src/voiceover-jobs.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { errorMessage } from '@lincyaw/kernel'
|
|
2
2
|
import type { VoiceoverJob } from '@lincyaw/kernel'
|
|
3
|
-
import type { WorkbenchStore } from './workbench.ts'
|
|
3
|
+
import type { WorkbenchStore } from './workbench-state.ts'
|
|
4
4
|
import type { WorkspaceClient } from './workspace-client.ts'
|
|
5
5
|
|
|
6
6
|
const active = (job: VoiceoverJob) => ['queued', 'running', 'cancelling'].includes(job.state)
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
import type { CanonicalSource, DiagnosticSnapshot, DocumentsAnswer, FocusReport, IrAnswer, JobsAnswer, PreviewAnchor, PreviewAnswer, PreviewCommand, PreviewPoint, PreviewPosition, PreviewRect, PreviewRenderer, ProductionPlan, ProductionPlaybackState, ReviewSnapshot, RevisionsAnswer, UncommittedFile, VoiceoverJob } from '@lincyaw/kernel'
|
|
2
|
+
import type { DocumentSessionState } from './document-session.ts'
|
|
3
|
+
import type { Locale } from './messages.ts'
|
|
4
|
+
|
|
5
|
+
/** `editing`: the canonical document is edited in the parent; `viewing`: a derived snapshot is presented. */
|
|
6
|
+
export type WorkbenchMode = 'editing' | 'viewing'
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* How the web form is shown: as a page or as its presentation, whose controls can play a configured lecture.
|
|
10
|
+
* Both share one preview page and switch in place with `go.view`.
|
|
11
|
+
*/
|
|
12
|
+
export type WebView = 'document' | 'scrolly' | 'present'
|
|
13
|
+
|
|
14
|
+
/** A playback key pressed in a preview that the workbench plays: Space, and the left and right arrows. */
|
|
15
|
+
export type PlaybackKey = 'play-pause' | 'previous' | 'next'
|
|
16
|
+
|
|
17
|
+
/** What the author points at in the document: a block (or a section), or a passage selected in it. */
|
|
18
|
+
export interface Pointer {
|
|
19
|
+
target: PreviewAnchor
|
|
20
|
+
step?: number
|
|
21
|
+
/** The selected passage. */
|
|
22
|
+
quote?: string
|
|
23
|
+
/** Its box in the preview's viewport; none while it is out of sight. */
|
|
24
|
+
rect?: PreviewRect
|
|
25
|
+
obstacles?: PreviewRect[]
|
|
26
|
+
point?: PreviewPoint
|
|
27
|
+
/** Its text can be edited in place. */
|
|
28
|
+
isEditable: boolean
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export type SaveState =
|
|
32
|
+
| { kind: 'idle' }
|
|
33
|
+
| { kind: 'saving' }
|
|
34
|
+
| { kind: 'saved', at: string }
|
|
35
|
+
| { kind: 'locked' }
|
|
36
|
+
| { kind: 'failed', message: string }
|
|
37
|
+
|
|
38
|
+
/** A request for the agent of the conversation: its text and what it is about. */
|
|
39
|
+
export interface AgentRequest {
|
|
40
|
+
text: string
|
|
41
|
+
focus: FocusReport[]
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/** A request for the author to finish and send in the conversation, and what it is about: the host only shows it. */
|
|
45
|
+
export interface AgentDraft {
|
|
46
|
+
text: string
|
|
47
|
+
focus: FocusReport[]
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/** Where the host put a request: the conversation's session and the request's id, which its user message carries. */
|
|
51
|
+
export interface AgentAnswer {
|
|
52
|
+
session: string
|
|
53
|
+
request: string
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export interface WorkbenchState {
|
|
57
|
+
agentActivities?: import('@lincyaw/kernel').AgentActivity[]
|
|
58
|
+
agentFollowing?: boolean
|
|
59
|
+
locale: Locale
|
|
60
|
+
authoring?: DocumentSessionState
|
|
61
|
+
/** Unaccepted numeric form input is retained separately from saved canonical timing. */
|
|
62
|
+
hasDocumentTimingDrafts?: boolean
|
|
63
|
+
documentTimingDraftStorageFailure?: boolean
|
|
64
|
+
captionTimingDraftSteps?: string[]
|
|
65
|
+
captionTimingDraftStorageFailure?: boolean
|
|
66
|
+
isDark: boolean
|
|
67
|
+
documents?: DocumentsAnswer
|
|
68
|
+
documentsFailure?: string
|
|
69
|
+
/** The workspace's routes answer 404: `@lincyaw/dsh` is turned off on the plugins page. */
|
|
70
|
+
isBundleDisabled?: boolean
|
|
71
|
+
document?: string
|
|
72
|
+
ir?: IrAnswer
|
|
73
|
+
mode: WorkbenchMode
|
|
74
|
+
previewRenderer: PreviewRenderer
|
|
75
|
+
/** In the web form: the page or the presentation, both in the same page, switched without loading it again. */
|
|
76
|
+
webView: WebView
|
|
77
|
+
previewReload: number
|
|
78
|
+
preview?: PreviewAnswer
|
|
79
|
+
previewFailure?: string
|
|
80
|
+
/** The IR revision the preview shows. */
|
|
81
|
+
previewIrRevision?: string
|
|
82
|
+
isPreparingPresentation?: boolean
|
|
83
|
+
presentationFailure?: string
|
|
84
|
+
presentationSnapshot?: { version: string, fingerprint: string, revision: string, project: number }
|
|
85
|
+
productionPlan?: ProductionPlan
|
|
86
|
+
productionPlayback?: ProductionPlaybackState
|
|
87
|
+
productionFailure?: string
|
|
88
|
+
voiceoverJobs?: VoiceoverJob[]
|
|
89
|
+
voiceoverJobsFailure?: string
|
|
90
|
+
/** A cache refresh that actually changed the current production binding; it never starts playback. */
|
|
91
|
+
voiceoverCacheRefresh?: { source: CanonicalSource, revision: string, sequence: number }
|
|
92
|
+
/** Changes when an acknowledged preview connection is attached or detached, including same-revision reloads. */
|
|
93
|
+
previewConnection: number
|
|
94
|
+
/** Where the preview is: the section the author reads, or the slide and its step. */
|
|
95
|
+
position?: PreviewPosition
|
|
96
|
+
/** Changes on every position intent, including A → B → A, without changing the source. */
|
|
97
|
+
documentPositionToken: string
|
|
98
|
+
/** Explicit author navigation, distinct from the player's passive cursor and frame reload reports. */
|
|
99
|
+
productionNavigationVersion: number
|
|
100
|
+
documentPositionIntent: 'seek' | 'pause'
|
|
101
|
+
/** An explicit source navigation request; scrolling updates position without issuing another request. */
|
|
102
|
+
documentNavigation?: { section: string, block?: string, request: string }
|
|
103
|
+
documentPositionFailure?: 'removed'
|
|
104
|
+
isCreatingPage?: boolean
|
|
105
|
+
isEditingPage?: boolean
|
|
106
|
+
editorHistory?: EditorHistoryState
|
|
107
|
+
isHistoryPreparing?: boolean
|
|
108
|
+
pageEditFailure?: string
|
|
109
|
+
diagnostics?: DiagnosticSnapshot
|
|
110
|
+
isDiagnosticsUnavailable: boolean
|
|
111
|
+
canRepairDiagnostics: boolean
|
|
112
|
+
isRepairingDiagnostics: boolean
|
|
113
|
+
diagnosticsRepairFailure?: string
|
|
114
|
+
pointer?: Pointer
|
|
115
|
+
save: SaveState
|
|
116
|
+
/** What the conversation's agent is told the author points at. */
|
|
117
|
+
focus: FocusReport[]
|
|
118
|
+
isFocusPending: boolean
|
|
119
|
+
focusFailure?: string
|
|
120
|
+
review?: ReviewSnapshot
|
|
121
|
+
history?: RevisionsAnswer
|
|
122
|
+
/** Files changed elsewhere and not yet in the history. */
|
|
123
|
+
outside?: UncommittedFile[]
|
|
124
|
+
historyFailure?: string
|
|
125
|
+
isHistoryBusy: boolean
|
|
126
|
+
isAsking: boolean
|
|
127
|
+
askFailure?: string
|
|
128
|
+
/** What the document can be made into, and its builds and exports (the author's and the AI's). */
|
|
129
|
+
jobs?: JobsAnswer
|
|
130
|
+
jobsFailure?: string
|
|
131
|
+
voiceServiceVersion?: number
|
|
132
|
+
jobPreparing?: { target: string, canCancel: boolean }
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
export interface PreviewSink {
|
|
136
|
+
readonly generation?: number
|
|
137
|
+
readonly capabilities?: readonly PreviewCommand['type'][]
|
|
138
|
+
send(command: PreviewCommand): void
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
export interface EditorHistoryState { section: string, undo: boolean, redo: boolean, field?: boolean }
|
|
142
|
+
|
|
143
|
+
|
|
144
|
+
/** The workbench's state as its parts read and change it. */
|
|
145
|
+
export interface WorkbenchStore {
|
|
146
|
+
readonly state: WorkbenchState
|
|
147
|
+
set(patch: Partial<WorkbenchState>): void
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
/** The document the conversation works on: none when no document is open. */
|
|
151
|
+
export function selectedDocument(state: WorkbenchState): string | null {
|
|
152
|
+
return state.document ?? null
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
/** Whether the AI is changing the workspace now, or its change waits for the author. */
|
|
156
|
+
export function isAgentChanging(state: WorkbenchState): boolean {
|
|
157
|
+
return Boolean(state.review?.engine === 'git' && (state.review.running || state.review.changes.length > 0))
|
|
158
|
+
}
|
|
159
|
+
|