@lincyaw/workbench 0.2.0-rc.12 → 0.2.0-rc.120
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 +1 -1
- package/package.json +5 -4
- package/src/AgentActivityBar.tsx +25 -0
- package/src/MediaClipEditor.tsx +7 -6
- package/src/StepProductionEditor.tsx +16 -7
- 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 +28 -7
- package/src/body-draft-actions.ts +60 -0
- package/src/caption-timing-drafts.ts +20 -3
- package/src/caption-timing-messages.ts +2 -2
- package/src/caption-timing.ts +2 -2
- package/src/component-draft-actions.ts +1 -1
- package/src/component-properties.ts +3 -3
- package/src/component-property-drafts.ts +6 -6
- package/src/components.tsx +43 -38
- 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 +30 -21
- package/src/document-editing.ts +485 -0
- package/src/document-editor/BlockNoteSurface.tsx +40 -14
- package/src/document-editor/CommentComposer.tsx +24 -0
- package/src/document-editor/ComponentMaterials.tsx +4 -10
- package/src/document-editor/ComponentPropertiesDialog.tsx +12 -12
- package/src/document-editor/DocumentBlockFallback.tsx +4 -3
- package/src/document-editor/DocumentBlockPreview.tsx +11 -4
- package/src/document-editor/DocumentComments.tsx +87 -17
- package/src/document-editor/DocumentEditor.tsx +66 -14
- package/src/document-editor/DocumentStepNarration.tsx +39 -27
- package/src/document-editor/NarrationEditor.tsx +55 -21
- 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 +75 -27
- package/src/document-editor/comments.ts +34 -14
- 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/inline.ts +1 -0
- 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 +21 -19
- package/src/document-editor/rich-text.ts +3 -2
- package/src/document-editor/selection.ts +13 -0
- package/src/document-editor/style.css +8 -3
- package/src/document-editor/table-identities.ts +2 -1
- package/src/document-preview.ts +3 -2
- package/src/document-production.ts +492 -0
- package/src/document-return-point.ts +2 -2
- package/src/document-session.ts +216 -67
- package/src/document-timing-drafts.ts +26 -6
- package/src/effective-settings.ts +12 -0
- package/src/history.ts +5 -5
- package/src/import-messages.ts +40 -0
- 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 +39 -18
- package/src/outline.ts +5 -5
- package/src/panels/DocumentImportDialog.tsx +59 -0
- package/src/panels/DocumentNarrationPanel.tsx +2 -2
- package/src/panels/DocumentView.tsx +106 -77
- package/src/panels/DocumentVoiceDialog.tsx +29 -12
- package/src/panels/DocumentVoiceField.tsx +3 -2
- package/src/panels/ExportPanel.tsx +2 -10
- package/src/panels/HistoryPanel.tsx +36 -10
- package/src/panels/HomePanel.tsx +12 -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 +4 -7
- package/src/panels/ProductionCaptionSize.tsx +20 -0
- package/src/panels/ProductionCaptionTiming.tsx +12 -9
- package/src/panels/ProductionMediaClips.tsx +25 -9
- package/src/panels/ProductionPanel.tsx +21 -17
- package/src/panels/ProductionRecording.tsx +86 -9
- package/src/panels/ProductionRecordingRange.tsx +26 -23
- package/src/panels/ProductionTimeline.tsx +6 -1
- package/src/panels/ProductionTranscription.tsx +8 -6
- package/src/panels/SourceDocumentPanel.tsx +24 -40
- package/src/panels/SpeechSettingsPanel.tsx +2 -2
- package/src/panels/TranscriptionAdoption.tsx +42 -36
- package/src/panels/VoiceCloneDialog.tsx +2 -1
- package/src/panels/VoicePreviewDialog.tsx +1 -1
- package/src/panels/VoiceScopeField.tsx +2 -2
- package/src/panels/VoiceoverDialog.tsx +11 -10
- 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/recording-adoption.ts +4 -4
- package/src/sha256.ts +9 -0
- package/src/speech-settings-messages.ts +6 -6
- package/src/step-production.ts +4 -4
- package/src/styles.css +43 -92
- package/src/transcription-drafts.ts +124 -0
- package/src/use-recording-adoption.ts +5 -4
- 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 +323 -956
- package/src/workspace-client.ts +41 -12
- package/src/assistant-mascot.ts +0 -62
- package/src/mascot-preference.ts +0 -37
- package/src/panels/ChangeTrail.tsx +0 -79
|
@@ -1,9 +1,10 @@
|
|
|
1
|
+
import { hasRole } from '@lincyaw/kernel'
|
|
1
2
|
import type { HistoryRevision } from '@lincyaw/kernel'
|
|
2
|
-
import { PmBadge, PmButton, PmEmpty, PmIcon, PmIconButton, PmNotice } from '../components.tsx'
|
|
3
|
+
import { PmBadge, PmButton, PmEmpty, PmIcon, PmIconButton, PmNotice, PmPanelHeader } from '../components.tsx'
|
|
3
4
|
import type { IconName } from '@lincyaw/design'
|
|
4
5
|
import { useMessages, useWorkbench, useWorkbenchState } from '../context.tsx'
|
|
5
6
|
import { timeAgo } from '../messages.ts'
|
|
6
|
-
import { isAgentChanging } from '../workbench.ts'
|
|
7
|
+
import { isAgentChanging } from '../workbench-state.ts'
|
|
7
8
|
|
|
8
9
|
/** A host-owned operation on a version, such as restoring an entire saved snapshot. This never replaces selective undo. */
|
|
9
10
|
export interface HistoryRevisionAction {
|
|
@@ -26,11 +27,15 @@ export function HistoryPanel({ onClose, revisionAction }: HistoryPanelProps) {
|
|
|
26
27
|
const workbench = useWorkbench()
|
|
27
28
|
const history = useWorkbenchState(state => state.history)
|
|
28
29
|
const outside = useWorkbenchState(state => state.outside)
|
|
30
|
+
const source = useWorkbenchState(state => state.authoring)
|
|
29
31
|
const changing = useWorkbenchState(state => state.isHistoryBusy || state.isHistoryPreparing || isAgentChanging(state))
|
|
30
|
-
const busy = changing || revisionAction?.pendingRevision !== undefined
|
|
32
|
+
const busy = changing || revisionAction?.pendingRevision !== undefined || Boolean(source?.recovering)
|
|
31
33
|
const readOnly = workbench.client.capabilities?.readOnly === true
|
|
32
34
|
const locale = useWorkbenchState(state => state.locale)
|
|
33
35
|
const memberId = useWorkbenchState(state => state.authoring?.member?.id)
|
|
36
|
+
const drafts = source?.recoveryDrafts ?? []
|
|
37
|
+
const draftBusy = busy || readOnly || Boolean(source?.member && !hasRole(source.member, 'editor'))
|
|
38
|
+
|| !source?.identity || Boolean(source.loading || source.saving || source.composing || source.recovering)
|
|
34
39
|
const revisions = history?.revisions ?? []
|
|
35
40
|
// Undoing and redoing are not versions of their own: they mark the change they act on.
|
|
36
41
|
const changes = revisions.filter(revision => !revision.reverts)
|
|
@@ -38,16 +43,37 @@ export function HistoryPanel({ onClose, revisionAction }: HistoryPanelProps) {
|
|
|
38
43
|
const icon = (revision: HistoryRevision): IconName => (revision.origin.kind === 'agent' ? 'sparkle' : revision.origin.kind === 'document' ? 'document' : 'edit')
|
|
39
44
|
return (
|
|
40
45
|
<section className="pmw-pane" aria-labelledby="pmw-history-title">
|
|
41
|
-
<
|
|
42
|
-
<h2 id="pmw-history-title" className="pmw-pane__title">{t.versionHistory}</h2>
|
|
43
|
-
<PmIconButton small icon="close" label={t.close} onClick={onClose} />
|
|
44
|
-
</header>
|
|
46
|
+
<PmPanelHeader className="pmw-pane__header" titleId="pmw-history-title" title={t.versionHistory} actions={<PmIconButton small icon="close" label={t.close} onClick={onClose} />} />
|
|
45
47
|
{outside && outside.length > 0 && (
|
|
46
|
-
<PmNotice tone="warn">
|
|
47
|
-
|
|
48
|
-
<PmButton small disabled={busy} onClick={() => void workbench.recordOutsideChanges()}>{t.recordOutside}</PmButton>
|
|
48
|
+
<PmNotice tone="warn" action={<PmButton small disabled={busy} onClick={() => void workbench.recordOutsideChanges()}>{t.recordOutside}</PmButton>}>
|
|
49
|
+
{t.outside(outside.length)}
|
|
49
50
|
</PmNotice>
|
|
50
51
|
)}
|
|
52
|
+
{source?.recoveryReadFailure && <PmNotice tone="warn">{t.documentDraftUnreadable}</PmNotice>}
|
|
53
|
+
{source?.recoveryChanged && <PmNotice tone="accent">{t.documentDraftChanged}</PmNotice>}
|
|
54
|
+
{drafts.length > 0 && <section className="pmw-history-group" aria-labelledby="pmw-history-drafts">
|
|
55
|
+
<header className="pmw-history-group__header">
|
|
56
|
+
<h3 id="pmw-history-drafts" className="pmw-pane__title">{t.documentDrafts} <PmBadge>{drafts.length}</PmBadge></h3>
|
|
57
|
+
{drafts.length > 1 && <PmButton small disabled={draftBusy} onClick={() => { if (source?.identity) workbench.forgetDocumentDrafts(drafts, source.identity) }}>{t.documentDraftDiscardAll}</PmButton>}
|
|
58
|
+
</header>
|
|
59
|
+
<ol className="pmw-versions">
|
|
60
|
+
{drafts.map((draft, index) => <li key={JSON.stringify([draft.id, draft.revision, draft.token])} className="pmw-version">
|
|
61
|
+
<span className="pmw-version__icon" aria-hidden="true"><PmIcon name="edit" /></span>
|
|
62
|
+
<div className="pmw-version__body">
|
|
63
|
+
<p className="pmw-version__summary">{t.documentDraftName(index + 1)}</p>
|
|
64
|
+
<p className="pmw-version__meta">
|
|
65
|
+
<span>{t.unsaved}</span><span>·</span>
|
|
66
|
+
<time dateTime={new Date(draft.updatedAt).toISOString()} title={new Date(draft.updatedAt).toLocaleString(locale)}>{timeAgo(new Date(draft.updatedAt).toISOString(), locale)}</time>
|
|
67
|
+
</p>
|
|
68
|
+
</div>
|
|
69
|
+
<div className="pmw-version__actions">
|
|
70
|
+
<PmButton small disabled={draftBusy} onClick={() => { if (source?.identity) void workbench.recoverDocumentDraft(draft, source.identity) }}>{t.documentDraftRestore}</PmButton>
|
|
71
|
+
<PmButton small disabled={draftBusy} onClick={() => { if (source?.identity) workbench.forgetDocumentDrafts([draft], source.identity) }}>{t.narrationDiscard}</PmButton>
|
|
72
|
+
</div>
|
|
73
|
+
</li>)}
|
|
74
|
+
</ol>
|
|
75
|
+
</section>}
|
|
76
|
+
{drafts.length > 0 && <div className="pmw-history-group__header"><h3 className="pmw-pane__title">{t.historySavedVersions}</h3></div>}
|
|
51
77
|
{changes.length === 0
|
|
52
78
|
? <PmEmpty icon="versions">{t.noHistory}</PmEmpty>
|
|
53
79
|
: (
|
package/src/panels/HomePanel.tsx
CHANGED
|
@@ -1,16 +1,19 @@
|
|
|
1
1
|
import { useEffect, useRef, useState } from 'react'
|
|
2
|
+
import type { ReactNode } from 'react'
|
|
2
3
|
import { errorMessage } from '@lincyaw/kernel'
|
|
3
4
|
import type { DocumentSummary, ProjectPlan } from '@lincyaw/kernel'
|
|
4
5
|
import { PmButton, PmDialog, PmEmpty, PmInput, PmSelect, PmIcon, PmMenu, PmNotice } from '../components.tsx'
|
|
5
6
|
import { useMessages, useWorkbench, useWorkbenchState } from '../context.tsx'
|
|
6
7
|
import { contentText } from '../messages.ts'
|
|
8
|
+
import { IMPORT_MESSAGES } from '../import-messages.ts'
|
|
9
|
+
import { DocumentImportDialog } from './DocumentImportDialog.tsx'
|
|
7
10
|
|
|
8
11
|
type Editing =
|
|
9
12
|
| { op: 'create' }
|
|
10
13
|
| { op: 'rename' | 'delete', doc: DocumentSummary }
|
|
11
14
|
|
|
12
15
|
/** The documents of the workspace: open one, make a new one, rename, copy or delete one. */
|
|
13
|
-
export function HomePanel() {
|
|
16
|
+
export function HomePanel({ actions }: { actions?: ReactNode } = {}) {
|
|
14
17
|
const t = useMessages()
|
|
15
18
|
const workbench = useWorkbench()
|
|
16
19
|
const answer = useWorkbenchState(state => state.documents)
|
|
@@ -21,6 +24,8 @@ export function HomePanel() {
|
|
|
21
24
|
const [done, setDone] = useState<string>()
|
|
22
25
|
const [error, setError] = useState<string>()
|
|
23
26
|
const [working, setWorking] = useState(false)
|
|
27
|
+
const [importing, setImporting] = useState(false)
|
|
28
|
+
const importMessages = IMPORT_MESSAGES[useWorkbenchState(state => state.locale)]
|
|
24
29
|
const handingOff = useRef(false)
|
|
25
30
|
useEffect(() => {
|
|
26
31
|
void workbench.loadDocuments()
|
|
@@ -46,12 +51,15 @@ export function HomePanel() {
|
|
|
46
51
|
<section className="pmw-home" aria-labelledby="pmw-home-title">
|
|
47
52
|
<header className="pmw-home__bar">
|
|
48
53
|
<h1 id="pmw-home-title" className="pmw-home__title">{answer?.title ?? t.documents}</h1>
|
|
54
|
+
{actions}
|
|
55
|
+
{operable && workbench.client.importDocuments && <PmButton icon="upload" disabled={working || workbench.client.capabilities?.readOnly} onClick={() => setImporting(true)}>{importMessages.title}</PmButton>}
|
|
49
56
|
{operable && <PmButton variant="primary" icon="plus" disabled={working} onClick={() => { handingOff.current = false; setError(undefined); setEditing({ op: 'create' }) }}>{t.newDocument}</PmButton>}
|
|
50
57
|
</header>
|
|
51
58
|
{failure && <PmNotice tone="danger">{bundleDisabled ? t.bundleDisabled : failure}</PmNotice>}
|
|
52
59
|
{done && <PmNotice tone="ok">{done}</PmNotice>}
|
|
53
60
|
{error && !editing && <PmNotice tone="danger">{error}</PmNotice>}
|
|
54
61
|
{answer && !answer.git && !answer.single && <PmNotice tone="warn">{t.notGit}</PmNotice>}
|
|
62
|
+
{answer?.migration && workbench.client.migrateWorkspace && <PmNotice tone="warn" action={<PmButton disabled={working} onClick={() => void run(async () => t.upgraded((await workbench.migrateWorkspace()).documents.length))}>{t.upgrade}</PmButton>}>{t.formatUpgrade}</PmNotice>}
|
|
55
63
|
<div className="pmw-home__heading-row">
|
|
56
64
|
<h2 className="pmw-home__heading">{t.allDocuments}</h2>
|
|
57
65
|
{documents.length > 6 && (
|
|
@@ -89,6 +97,9 @@ export function HomePanel() {
|
|
|
89
97
|
))}
|
|
90
98
|
</ul>
|
|
91
99
|
)}
|
|
100
|
+
{importing && <DocumentImportDialog onClose={() => setImporting(false)} onImported={answer => {
|
|
101
|
+
setImporting(false); setQuery(''); setDone(importMessages.done(answer.documents.length, answer.unresolved, answer.warnings))
|
|
102
|
+
}} />}
|
|
92
103
|
{editing && (
|
|
93
104
|
<DocumentDialog
|
|
94
105
|
editing={editing}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { useEffect, useRef, useState } from 'react'
|
|
2
|
+
import type { McpConnectionSettings } from '@lincyaw/kernel'
|
|
3
|
+
import { PmButton, PmCard, PmInput, PmNotice, PmPanelHeader, PmSelect, PmTextarea } from '../components.tsx'
|
|
4
|
+
import { useWorkbench, useWorkbenchState } from '../context.tsx'
|
|
5
|
+
import { MCP_SETTINGS_MESSAGES } from '../mcp-settings-messages.ts'
|
|
6
|
+
import { WorkspaceServerError } from '../workspace-client.ts'
|
|
7
|
+
|
|
8
|
+
export function McpSettingsPanel() {
|
|
9
|
+
const workbench = useWorkbench(), locale = useWorkbenchState(state => state.locale), t = MCP_SETTINGS_MESSAGES[locale]
|
|
10
|
+
const [settings, setSettings] = useState<McpConnectionSettings>(), [transport, setTransport] = useState<'stdio' | 'http'>('stdio'), [port, setPort] = useState('0')
|
|
11
|
+
const [busy, setBusy] = useState(false), [failure, setFailure] = useState<string>(), [status, setStatus] = useState<string>(), [output, setOutput] = useState('')
|
|
12
|
+
const owner = useRef(true), request = useRef<AbortController>()
|
|
13
|
+
const accept = (value: McpConnectionSettings) => { setSettings(value); setTransport(value.transport); setPort(String(value.port)); setOutput('') }
|
|
14
|
+
const load = async () => {
|
|
15
|
+
request.current?.abort(); const controller = new AbortController(); request.current = controller
|
|
16
|
+
setBusy(true); setFailure(undefined); setStatus(undefined)
|
|
17
|
+
try {
|
|
18
|
+
if (!workbench.client.readMcpSettings) throw new Error('unsupported')
|
|
19
|
+
const value = await workbench.client.readMcpSettings(controller.signal)
|
|
20
|
+
if (owner.current && !controller.signal.aborted) accept(value)
|
|
21
|
+
} catch (error) {
|
|
22
|
+
if (owner.current && !controller.signal.aborted) setFailure(error instanceof WorkspaceServerError && error.status === 404 ? t.outdatedService : t.unavailable)
|
|
23
|
+
}
|
|
24
|
+
finally { if (owner.current && !controller.signal.aborted) setBusy(false) }
|
|
25
|
+
}
|
|
26
|
+
useEffect(() => { owner.current = true; void load(); return () => { owner.current = false; request.current?.abort() } }, [workbench])
|
|
27
|
+
const dirty = settings && (transport !== settings.transport || Number(port) !== settings.port)
|
|
28
|
+
const valid = /^\d+$/.test(port) && Number(port) <= 65535
|
|
29
|
+
const save = async () => {
|
|
30
|
+
if (!settings || !valid || !workbench.client.changeMcpSettings) return
|
|
31
|
+
request.current?.abort(); const controller = new AbortController(); request.current = controller
|
|
32
|
+
setBusy(true); setFailure(undefined); setStatus(undefined); setOutput('')
|
|
33
|
+
try {
|
|
34
|
+
const value = await workbench.client.changeMcpSettings({ revision: settings.revision, transport, port: Number(port) }, controller.signal)
|
|
35
|
+
if (owner.current && !controller.signal.aborted) { accept(value); setStatus(t.saved) }
|
|
36
|
+
} catch (error) {
|
|
37
|
+
if (owner.current && !controller.signal.aborted) {
|
|
38
|
+
const code = error instanceof WorkspaceServerError ? error.answer.error : undefined
|
|
39
|
+
setFailure(code === 'mcp-port-unavailable' ? t.portBusy : code === 'mcp-settings-conflict' ? t.conflict : t.failed)
|
|
40
|
+
}
|
|
41
|
+
} finally { if (owner.current && !controller.signal.aborted) setBusy(false) }
|
|
42
|
+
}
|
|
43
|
+
const copy = async (prompt: boolean) => {
|
|
44
|
+
if (!settings || dirty || !workbench.client.exportMcpSettings || !workbench.client.readMcpSettings) return
|
|
45
|
+
setBusy(true); setFailure(undefined); setStatus(undefined)
|
|
46
|
+
request.current?.abort(); const controller = new AbortController(); request.current = controller
|
|
47
|
+
try {
|
|
48
|
+
const fresh = await workbench.client.readMcpSettings(controller.signal)
|
|
49
|
+
if (!owner.current || controller.signal.aborted) return
|
|
50
|
+
accept(fresh)
|
|
51
|
+
const content = prompt ? t.prompt.replace('{root}', fresh.root) + '\n\n' + (fresh.transport === 'stdio'
|
|
52
|
+
? JSON.stringify({ mcpServers: { presmium: fresh.stdio } }, null, 2)
|
|
53
|
+
: t.httpPrompt.replace('{url}', fresh.url ?? '').replace('{stateFile}', fresh.stateFile))
|
|
54
|
+
: JSON.stringify(await workbench.client.exportMcpSettings(fresh.revision, controller.signal), null, 2)
|
|
55
|
+
if (!owner.current || controller.signal.aborted) return
|
|
56
|
+
setOutput(content)
|
|
57
|
+
try { await navigator.clipboard.writeText(content); if (owner.current) setStatus(t.copied) }
|
|
58
|
+
catch { if (owner.current) setStatus(t.manualCopy) }
|
|
59
|
+
} catch (error) { if (owner.current && !controller.signal.aborted) setFailure(error instanceof WorkspaceServerError && error.answer.error === 'mcp-settings-conflict' ? t.conflict : t.failed) }
|
|
60
|
+
finally { if (owner.current && !controller.signal.aborted) setBusy(false) }
|
|
61
|
+
}
|
|
62
|
+
const ready = settings && !dirty && (settings.transport === 'stdio' ? settings.stdio : settings.url)
|
|
63
|
+
return <section className="pmw-speech-settings pm-ui" aria-label={t.title}>
|
|
64
|
+
<PmPanelHeader title={t.title} />
|
|
65
|
+
<div className="pmw-speech-settings__content">
|
|
66
|
+
<p>{t.description}</p>
|
|
67
|
+
{!settings && busy && <PmNotice>{t.loading}</PmNotice>}
|
|
68
|
+
{failure && <PmNotice tone="danger">{failure} <PmButton small disabled={busy} onClick={() => void load()}>{t.retry}</PmButton></PmNotice>}
|
|
69
|
+
{status && <PmNotice tone="accent">{status}</PmNotice>}
|
|
70
|
+
{settings && <PmCard><div className="pmw-speech-settings__fields">
|
|
71
|
+
<PmSelect label={t.transport} hint={transport === 'stdio' ? t.stdioHint : t.httpHint} value={transport} disabled={busy} onChange={event => { setTransport(event.target.value as 'stdio' | 'http'); setStatus(undefined); setOutput('') }}>
|
|
72
|
+
<option value="stdio" disabled={!settings.stdio}>{t.stdio}</option><option value="http">{t.http}</option>
|
|
73
|
+
</PmSelect>
|
|
74
|
+
{!settings.stdio && <PmNotice>{t.noCommand}</PmNotice>}
|
|
75
|
+
{transport === 'http' && <PmInput label={t.port} hint={t.portHint} error={valid ? undefined : t.invalid} inputMode="numeric" value={port} disabled={busy} onChange={event => { setPort(event.target.value); setStatus(undefined); setOutput('') }} />}
|
|
76
|
+
{settings.url && <PmInput label={t.address} value={settings.url} readOnly />}
|
|
77
|
+
{settings.issue && <PmNotice tone="danger">{t.portBusy}</PmNotice>}
|
|
78
|
+
<div className="pmw-speech-settings__actions"><PmButton small variant="primary" disabled={busy || !valid || !dirty && !settings.issue} onClick={() => void save()}>{t.save}</PmButton></div>
|
|
79
|
+
</div></PmCard>}
|
|
80
|
+
<p>{t.local}</p>
|
|
81
|
+
{dirty && <PmNotice>{t.applyFirst}</PmNotice>}
|
|
82
|
+
<div className="pmw-speech-settings__actions"><PmButton small variant="ghost" icon="copy" disabled={busy || !ready} onClick={() => void copy(false)}>{t.copyConfig}</PmButton><PmButton small variant="ghost" icon="sparkle" disabled={busy || !ready} onClick={() => void copy(true)}>{t.copyPrompt}</PmButton></div>
|
|
83
|
+
{output && <PmTextarea label={t.output} readOnly rows={10} value={output} onFocus={event => event.target.select()} />}
|
|
84
|
+
</div>
|
|
85
|
+
</section>
|
|
86
|
+
}
|
|
@@ -12,7 +12,7 @@ export function PageDeleteDialog({ section, title, trigger, onClose }: { section
|
|
|
12
12
|
useEffect(() => {
|
|
13
13
|
let current = true
|
|
14
14
|
setLoading(true); setError(undefined)
|
|
15
|
-
void workbench.preparePageDeletion(section).then(answer => { if (current) setPlan(answer) }, () => { if (current) setError(t.pageEditRequestFailed) }).finally(() => { if (current) setLoading(false) })
|
|
15
|
+
void workbench.editing.preparePageDeletion(section).then(answer => { if (current) setPlan(answer) }, () => { if (current) setError(t.pageEditRequestFailed) }).finally(() => { if (current) setLoading(false) })
|
|
16
16
|
return () => { current = false }
|
|
17
17
|
}, [workbench, section, attempt])
|
|
18
18
|
return <PmDialog open label={t.pageDeleteTitle(title)} description={plan ? t.pageDeleteHint(plan.counts.steps, plan.counts.narration) : t.pageDeleteLoading} busy={busy} closeLabel={t.close} onClose={onClose} onCloseAutoFocus={event => {
|
|
@@ -21,12 +21,12 @@ export function PageDeleteDialog({ section, title, trigger, onClose }: { section
|
|
|
21
21
|
}}>
|
|
22
22
|
<div className="pmw-operation">
|
|
23
23
|
{plan?.last && <PmNotice>{t.pageDeleteLast}</PmNotice>}
|
|
24
|
-
{plan && !plan.allowed && <PmNotice tone="warn">{workbench.
|
|
24
|
+
{plan && !plan.allowed && <PmNotice tone="warn">{workbench.editing.deletionMessage(plan.reason ?? 'page-boundary')}</PmNotice>}
|
|
25
25
|
{(error || failure) && <PmNotice tone="danger">{error || failure}</PmNotice>}
|
|
26
26
|
<div className="pmw-operation__actions">
|
|
27
27
|
<PmButton disabled={busy} onClick={onClose}>{t.cancel}</PmButton>
|
|
28
|
-
{error || failure ? <PmButton disabled={busy} onClick={() => { workbench.
|
|
29
|
-
: <PmButton variant="danger" loading={loading || busy} disabled={!plan?.allowed || loading} onClick={() => { if (plan) void workbench.deletePage(plan).then(saved => { if (saved) onClose() }) }}>{t.pageDelete}</PmButton>}
|
|
28
|
+
{error || failure ? <PmButton disabled={busy} onClick={() => { workbench.editing.clearFailure(); setAttempt(value => value + 1) }}>{t.retry}</PmButton>
|
|
29
|
+
: <PmButton variant="danger" loading={loading || busy} disabled={!plan?.allowed || loading} onClick={() => { if (plan) void workbench.editing.deletePage(plan).then(saved => { if (saved) onClose() }) }}>{t.pageDelete}</PmButton>}
|
|
30
30
|
</div>
|
|
31
31
|
</div>
|
|
32
32
|
</PmDialog>
|
|
@@ -15,7 +15,7 @@ export function PageRenameDialog({ section, title: original, trigger, onClose }:
|
|
|
15
15
|
}} onSubmit={event => {
|
|
16
16
|
event.preventDefault()
|
|
17
17
|
if (busy || !title.trim()) return
|
|
18
|
-
void workbench.renamePage(section, title.trim()).then(saved => { if (saved) onClose() })
|
|
18
|
+
void workbench.editing.renamePage(section, title.trim()).then(saved => { if (saved) onClose() })
|
|
19
19
|
}}>
|
|
20
20
|
<PmInput label={t.pageTitle} density="regular" value={title} error={failure} required autoFocus readOnly={busy} onChange={event => setTitle(event.target.value)} />
|
|
21
21
|
<div className="pmw-operation__actions">
|
|
@@ -6,7 +6,6 @@ import { PmButton, PmNotice } from '../components.tsx'
|
|
|
6
6
|
import { useMessages, useWorkbench, useWorkbenchState } from '../context.tsx'
|
|
7
7
|
import { slideAspect } from '../workbench.ts'
|
|
8
8
|
import { failureReason } from '../messages.ts'
|
|
9
|
-
import { PreviewChangeTrail } from './ChangeTrail.tsx'
|
|
10
9
|
|
|
11
10
|
/**
|
|
12
11
|
* The open document as its readers see it (the web form or the slides), with the tools for what the author points at.
|
|
@@ -29,7 +28,6 @@ export function PreviewPanel({ active = true, onPresentationAction, presentation
|
|
|
29
28
|
const reload = useWorkbenchState(state => state.previewReload)
|
|
30
29
|
const aspect = useWorkbenchState(state => (state.previewRenderer === 'slides' ? slideAspect(state.ir) : undefined))
|
|
31
30
|
const container = useRef<HTMLDivElement>(null)
|
|
32
|
-
const stage = useRef<HTMLDivElement>(null)
|
|
33
31
|
const pool = useRef<ReturnType<typeof createPreviewPool>>()
|
|
34
32
|
const [loads, setLoads] = useState(0)
|
|
35
33
|
const [{ ready, mismatch, identityFailure, handshakeFailure, canvasGate }, setStatus] = useState<PreviewFrameStatus>({ ready: false })
|
|
@@ -65,14 +63,13 @@ export function PreviewPanel({ active = true, onPresentationAction, presentation
|
|
|
65
63
|
return (
|
|
66
64
|
<section className="pmw-preview" aria-label={t.preview} data-ready={(active && document !== undefined && ready && snapshotMatches) || undefined}>
|
|
67
65
|
{mismatch && <PmNotice tone="warn">{t.versionMismatch}</PmNotice>}
|
|
68
|
-
{identityFailure && <PmNotice tone="danger"
|
|
69
|
-
{handshakeFailure && <PmNotice tone="danger"
|
|
70
|
-
{failure && <PmNotice tone="danger"
|
|
66
|
+
{identityFailure && <PmNotice tone="danger" action={<PmButton small onClick={() => workbench.reloadPreview()}>{t.reloadPreview}</PmButton>}>{t.previewIdentityMismatch}</PmNotice>}
|
|
67
|
+
{handshakeFailure && <PmNotice tone="danger" action={<PmButton small onClick={() => workbench.reloadPreview()}>{t.reloadPreview}</PmButton>}>{t.previewStalled}</PmNotice>}
|
|
68
|
+
{failure && <PmNotice tone="danger" action={<PmButton small onClick={() => workbench.retryPreview()}>{t.retry}</PmButton>}>{t.previewFailed(failureReason(t, failure))}</PmNotice>}
|
|
71
69
|
{(!ready || !snapshotMatches) && !failure && !handshakeFailure && !(renderer === 'slides' && preview && !preview.slides) && <p className="pmw-muted pmw-preview__loading">{presentation && ready && !snapshotMatches && !preparing ? t.presentationOutdated : address ? t.previewLoading : t.previewPreparing}</p>}
|
|
72
70
|
{renderer === 'slides' && preview && !preview.slides && <p className="pmw-muted pmw-preview__loading">{t.noSlides}</p>}
|
|
73
|
-
<div
|
|
71
|
+
<div className="pmw-preview__stage">
|
|
74
72
|
<div ref={container} className="pmw-preview__frames" data-renderer={renderer} data-pending-snapshot={!snapshotMatches || undefined} data-presentation-gated={presentation && canvasGate || undefined} style={aspect === undefined ? undefined : { '--pmw-slide-aspect': aspect } as CSSProperties} />
|
|
75
|
-
{!presentation && <PreviewChangeTrail stage={stage} frames={container} />}
|
|
76
73
|
</div>
|
|
77
74
|
</section>
|
|
78
75
|
)
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { useState } from 'react'
|
|
2
|
+
import { captionScale, CAPTION_SCALE_MAX, CAPTION_SCALE_MIN } from '@lincyaw/kernel'
|
|
3
|
+
import type { PresmiumDocument } from '@lincyaw/kernel'
|
|
4
|
+
import { PmField, PmRange } from '../components.tsx'
|
|
5
|
+
import { useWorkbench, useWorkbenchState } from '../context.tsx'
|
|
6
|
+
import { PRODUCTION_MESSAGES } from '../production-messages.ts'
|
|
7
|
+
|
|
8
|
+
/** The document's caption size in percent steps of ten; a released drag or a key records it once. */
|
|
9
|
+
export function ProductionCaptionSize({ identity, document, disabled, onChanged }: { identity: string, document: PresmiumDocument, disabled: boolean, onChanged(): void }) {
|
|
10
|
+
const workbench = useWorkbench(), locale = useWorkbenchState(state => state.locale), p = PRODUCTION_MESSAGES[locale]
|
|
11
|
+
const [preview, setPreview] = useState<number>()
|
|
12
|
+
const percent = Math.round(captionScale(document.production) * 100)
|
|
13
|
+
return <PmField label={p.captionSize} group hint={p.captionSizeHint}>
|
|
14
|
+
<div className="pm-ui-range-row">
|
|
15
|
+
<PmRange label={p.captionSize} value={percent} min={Math.round(CAPTION_SCALE_MIN * 100)} max={Math.round(CAPTION_SCALE_MAX * 100)} step={10} disabled={disabled} valueText={value => `${Math.round(value)}%`}
|
|
16
|
+
onPreviewChange={setPreview} onValueCommit={value => { workbench.production.setCaptionScale(value / 100, identity); onChanged() }} />
|
|
17
|
+
<output>{Math.round(preview ?? percent)}%</output>
|
|
18
|
+
</div>
|
|
19
|
+
</PmField>
|
|
20
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { useEffect, useRef, useState } from 'react'
|
|
2
|
-
import { CAPTION_TIMING_MAX_SEGMENTS, captionSourceFingerprint, captionTimingProblem, stepCaptionText } from '@lincyaw/kernel'
|
|
2
|
+
import { CAPTION_TIMING_MAX_SEGMENTS, captionSourceFingerprint, captionTimingProblem, randomUUID, stepCaptionText } from '@lincyaw/kernel'
|
|
3
3
|
import type { CaptionTiming, CaptionTimingSource, DocumentCaptionTimingAction, ProductionPlan } from '@lincyaw/kernel'
|
|
4
4
|
import { PmButton, PmCard, PmDialog, PmInput, PmNotice } from '../components.tsx'
|
|
5
5
|
import { useWorkbench, useWorkbenchState } from '../context.tsx'
|
|
@@ -23,7 +23,7 @@ function lineRows(text: string): Row[] {
|
|
|
23
23
|
else if (ranges.length && !text.slice(ranges.at(-1)!.from, ranges.at(-1)!.to).trim()) ranges[ranges.length - 1]!.to = to
|
|
24
24
|
else ranges.push({ from, to })
|
|
25
25
|
}
|
|
26
|
-
return ranges.map(range => ({ ...range, id:
|
|
26
|
+
return ranges.map(range => ({ ...range, id: randomUUID(), start: '', end: '' }))
|
|
27
27
|
}
|
|
28
28
|
function valueOf(draft: Draft): CaptionTiming | undefined {
|
|
29
29
|
if (!draft.basis.available || !draft.basis.playbackFingerprint || draft.basis.durationMs === undefined) return
|
|
@@ -43,14 +43,17 @@ export function ProductionCaptionTiming({ identity, stepId, plan, current, loadi
|
|
|
43
43
|
const pendingSteps = useWorkbenchState(state => state.captionTimingDraftSteps), storageFailure = useWorkbenchState(state => state.captionTimingDraftStorageFailure)
|
|
44
44
|
const [open, setOpen] = useState(false), [busy, setBusy] = useState(false), [failure, setFailure] = useState<string>(), [saved, setSaved] = useState(false), [, render] = useState(0)
|
|
45
45
|
const drafts = useRef(new Map<string, Draft>()), alive = useRef(true), request = useRef<AbortController>(), needsRefresh = useRef(false), openRef = useRef(false), composing = useRef(false)
|
|
46
|
+
useEffect(() => workbench.production.registerDraftView({ identity, kind: 'caption-timing', has: target => drafts.current.has(target),
|
|
47
|
+
blocked: () => composing.current || Boolean(request.current), clear: target => { drafts.current.delete(target); setSaved(false); setFailure(undefined); render(n => n + 1) } }), [workbench, identity])
|
|
48
|
+
useEffect(() => workbench.refreshAuthoringClientControls(), [workbench, open, busy, stepId, disabled])
|
|
46
49
|
const latest = useRef({ stepId, onChanged }); latest.current = { stepId, onChanged }
|
|
47
|
-
if (!drafts.current.has(stepId)) { const savedDraft = workbench.captionTimingDraft(stepId, identity); if (savedDraft) drafts.current.set(stepId, savedDraft) }
|
|
50
|
+
if (!drafts.current.has(stepId)) { const savedDraft = workbench.production.captionTimingDraft(stepId, identity); if (savedDraft) drafts.current.set(stepId, savedDraft) }
|
|
48
51
|
const draft = drafts.current.get(stepId), value = draft && valueOf(draft), canonical = document?.production.captionTimings?.[stepId], hasDraft = Boolean(pendingSteps?.includes(stepId))
|
|
49
52
|
const changed = draft && source?.version !== draft.version || draft && basis && (!same(draft.basis, basis) || draft.text !== (document && stepCaptionText(document, stepId)))
|
|
50
53
|
const writable = Boolean(source?.version && source.fingerprint && !source.loading && !source.dirty && !source.saving && !source.composing && !source.restored && !source.recovering && !source.error && !disabled)
|
|
51
54
|
useEffect(() => { alive.current = true; return () => { alive.current = false; request.current?.abort() } }, [])
|
|
52
55
|
useEffect(() => { request.current?.abort(); openRef.current = false; setOpen(false); setBusy(false); setFailure(undefined); setSaved(false) }, [stepId])
|
|
53
|
-
const pending = (next: Draft, changedByAuthor = true) => { drafts.current.set(stepId, next); if (changedByAuthor) workbench.setCaptionTimingDraft(stepId, next, identity); setSaved(false); setFailure(undefined); render(n => n + 1) }
|
|
56
|
+
const pending = (next: Draft, changedByAuthor = true) => { drafts.current.set(stepId, next); if (changedByAuthor) workbench.production.setCaptionTimingDraft(stepId, next, identity); setSaved(false); setFailure(undefined); render(n => n + 1) }
|
|
54
57
|
const initialize = () => {
|
|
55
58
|
if (!document || !source?.version || !basis) return
|
|
56
59
|
const text = stepCaptionText(document, stepId), existing = document.production.captionTimings?.[stepId]
|
|
@@ -61,7 +64,7 @@ export function ProductionCaptionTiming({ identity, stepId, plan, current, loadi
|
|
|
61
64
|
// A plan may arrive after opening. Step/close effects fence the original opening;
|
|
62
65
|
// an existing target draft always wins over this passive initialization.
|
|
63
66
|
if (open && openRef.current && !saved && current && basis && source?.identity === identity && !drafts.current.has(stepId)) initialize()
|
|
64
|
-
}, [open, saved, current, basis, source?.identity, source?.version, identity, stepId])
|
|
67
|
+
}, [open, saved, current, basis, source?.identity, source?.version, identity, stepId, hasDraft])
|
|
65
68
|
const close = () => {
|
|
66
69
|
request.current?.abort(); setBusy(false); openRef.current = false; setOpen(false)
|
|
67
70
|
if (needsRefresh.current) { needsRefresh.current = false; latest.current.onChanged() }
|
|
@@ -72,12 +75,12 @@ export function ProductionCaptionTiming({ identity, stepId, plan, current, loadi
|
|
|
72
75
|
const action: DocumentCaptionTimingAction = automatic ? { type: 'caption.timing.reset', stepId } : { type: 'caption.timing.set', stepId, value: value! }
|
|
73
76
|
request.current = controller; setBusy(true); setFailure(undefined)
|
|
74
77
|
try {
|
|
75
|
-
const answer = await workbench.
|
|
78
|
+
const answer = await workbench.production.applyCaptionTiming(action, randomUUID(), expected, controller.signal)
|
|
76
79
|
needsRefresh.current = true
|
|
77
80
|
if (!alive.current || workbench.getState().authoring?.identity !== identity) return
|
|
78
81
|
const ownsInput = drafts.current.get(target) === sent
|
|
79
82
|
if (ownsInput) {
|
|
80
|
-
workbench.setCaptionTimingDraft(target, undefined, identity)
|
|
83
|
+
workbench.production.setCaptionTimingDraft(target, undefined, identity)
|
|
81
84
|
if (automatic) drafts.current.delete(target)
|
|
82
85
|
else if (sent) drafts.current.set(target, { ...sent, version: answer.version })
|
|
83
86
|
}
|
|
@@ -94,7 +97,7 @@ export function ProductionCaptionTiming({ identity, stepId, plan, current, loadi
|
|
|
94
97
|
<PmButton small onClick={close}>{saved ? t.done : t.cancel}</PmButton>
|
|
95
98
|
<PmButton small variant="primary" loading={busy} disabled={!writable || !current || !value || Boolean(changed) || same(value, canonical)} onClick={() => void apply()}>{t.apply}</PmButton>
|
|
96
99
|
</>}>
|
|
97
|
-
<div className="pmw-caption-times" onCompositionStart={() => { composing.current = true }} onCompositionEnd={() => { composing.current = false }}>
|
|
100
|
+
<div className="pmw-caption-times" onCompositionStart={() => { composing.current = true; workbench.refreshAuthoringClientControls() }} onCompositionEnd={() => { composing.current = false; workbench.refreshAuthoringClientControls() }}>
|
|
98
101
|
<span>{t.step}</span>
|
|
99
102
|
{!saved && basis?.available === false && <PmNotice tone="warn">{t.unavailable}</PmNotice>}
|
|
100
103
|
{!saved && !basis && <PmNotice>{loading ? t.loading : t.prepare}</PmNotice>}
|
|
@@ -111,7 +114,7 @@ export function ProductionCaptionTiming({ identity, stepId, plan, current, loadi
|
|
|
111
114
|
<div className="pmw-caption-times__actions">
|
|
112
115
|
<PmButton small disabled={!basis?.available || busy || !writable} onClick={() => { if (document && basis && source?.version) pending({ version: source.version, text: stepCaptionText(document, stepId), basis: structuredClone(basis), rows: lineRows(stepCaptionText(document, stepId)) }) }}>{t.split}</PmButton>
|
|
113
116
|
<PmButton small disabled={!canonical || busy || !writable} onClick={() => void apply(true)}>{t.automatic}</PmButton>
|
|
114
|
-
{hasDraft && <PmButton small disabled={busy} onClick={() => { workbench.
|
|
117
|
+
{hasDraft && <PmButton small disabled={busy} onClick={() => { if (workbench.production.discardCaptionTimingDraft(stepId, identity)) { drafts.current.delete(stepId); initialize() } }}>{t.discard}</PmButton>}
|
|
115
118
|
</div>
|
|
116
119
|
{storageFailure && <PmNotice tone="warn">{t.storageFailed}</PmNotice>}
|
|
117
120
|
{saved && <PmNotice tone="ok">{t.saved}</PmNotice>}
|
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
import { useEffect, useRef, useState } from 'react'
|
|
2
|
-
import type { DocumentChangeAnswer, MediaClip, ProductionAssetInspection, ProductionBinding,
|
|
2
|
+
import type { DocumentChangeAnswer, MediaClip, ProductionAssetInspection, ProductionBinding, PresmiumDocument } from '@lincyaw/kernel'
|
|
3
|
+
import { randomUUID } from '@lincyaw/kernel'
|
|
3
4
|
import { MediaClipEditor } from '../MediaClipEditor.tsx'
|
|
4
5
|
import type { MediaClipDraft } from '../MediaClipEditor.tsx'
|
|
5
6
|
import { useWorkbench, useWorkbenchState } from '../context.tsx'
|
|
6
|
-
import {
|
|
7
|
+
import { mediaDraftStorageFailed, readMediaDrafts } from '../media-drafts.ts'
|
|
7
8
|
import type { MediaDrafts } from '../media-drafts.ts'
|
|
8
9
|
import { MEDIA_MESSAGES, mediaFailure } from '../media-messages.ts'
|
|
9
10
|
|
|
10
11
|
interface Props {
|
|
11
12
|
identity: string
|
|
12
13
|
version: string
|
|
13
|
-
document:
|
|
14
|
+
document: PresmiumDocument
|
|
14
15
|
sectionId: string
|
|
15
16
|
stepId: string
|
|
16
17
|
binding?: ProductionBinding
|
|
@@ -18,7 +19,7 @@ interface Props {
|
|
|
18
19
|
disabled: boolean
|
|
19
20
|
onChanged(): void
|
|
20
21
|
}
|
|
21
|
-
const newDraft = (version: string, stepId: string): MediaClipDraft => ({ version, clip: { id: `clip_${
|
|
22
|
+
const newDraft = (version: string, stepId: string): MediaClipDraft => ({ version, clip: { id: `clip_${randomUUID().replaceAll('-', '')}`, assetId: '', sourceRange: { startMs: 0, endMs: 0 }, attachment: { stepId, offsetMs: 0 }, volume: 1, muted: false } })
|
|
22
23
|
const fromClip = (version: string, clip: MediaClip): MediaClipDraft => ({ version, clip: structuredClone(clip), baseClip: structuredClone(clip) })
|
|
23
24
|
const same = (a: unknown, b: unknown) => JSON.stringify(a) === JSON.stringify(b)
|
|
24
25
|
const draftKey = (clipId?: string) => clipId === undefined ? 'new' : `clip:${clipId}`
|
|
@@ -41,9 +42,23 @@ export function ProductionMediaClips({ identity, version, document, sectionId, s
|
|
|
41
42
|
snapshot.current = draft; selected.current = key; latest.current = session
|
|
42
43
|
const assets = Object.values(document.assets).filter(asset => asset.kind === 'audio').map(asset => ({ id: asset.id, label: asset.title || asset.location.split('/').at(-1) || asset.id }))
|
|
43
44
|
const active = () => owner.current.active && workbench.getState().authoring?.identity === identity
|
|
45
|
+
const interacting = useRef(false), unavailable = useRef(false)
|
|
46
|
+
unavailable.current = disabled || Boolean(busy)
|
|
47
|
+
useEffect(() => workbench.production.registerDraftView({ identity, kind: 'media-clip', has: target => {
|
|
48
|
+
const [ownerStep, name] = JSON.parse(target) as [string, string]
|
|
49
|
+
return active() && ownerStep === stepId && Object.hasOwn(latest.current.entries, name)
|
|
50
|
+
}, blocked: () => interacting.current || Boolean(request.current) || unavailable.current,
|
|
51
|
+
clear: () => {
|
|
52
|
+
owner.current.revision++
|
|
53
|
+
const value = readMediaDrafts(workbench.client, identity, stepId)
|
|
54
|
+
latest.current = value; setSession(value); setStorageFailed(false); setFailure(undefined); setStatus(undefined)
|
|
55
|
+
blank.current = newDraft(workbench.getState().authoring?.version ?? version, stepId)
|
|
56
|
+
} }), [workbench, identity, stepId])
|
|
57
|
+
useEffect(() => workbench.registerNavigationGuard(() => active() && (interacting.current || Boolean(request.current))), [workbench, identity])
|
|
58
|
+
useEffect(() => { workbench.refreshAuthoringClientControls() }, [workbench, disabled, busy])
|
|
44
59
|
const remember = (value: MediaDrafts) => {
|
|
45
60
|
latest.current = value; setSession(value)
|
|
46
|
-
setStorageFailed(!keepMediaDrafts(
|
|
61
|
+
setStorageFailed(!workbench.production.keepMediaDrafts(identity, stepId, value))
|
|
47
62
|
}
|
|
48
63
|
const edit = (value: MediaClipDraft) => {
|
|
49
64
|
owner.current.revision++; setFailure(undefined); setStatus(undefined)
|
|
@@ -55,7 +70,7 @@ export function ProductionMediaClips({ identity, version, document, sectionId, s
|
|
|
55
70
|
const assetId = draft.clip.assetId, controller = new AbortController(), requestKey = key
|
|
56
71
|
if (!assetId || disabled || !version || inspection?.version === version && inspection.value.assetId === assetId) { setLoading(false); return }
|
|
57
72
|
setLoading(true)
|
|
58
|
-
void workbench.
|
|
73
|
+
void workbench.production.inspectAudio(assetId, { identity, version }, controller.signal).then(answer => {
|
|
59
74
|
if (controller.signal.aborted || !active()) return
|
|
60
75
|
setInspection({ version: answer.version, value: answer.inspection })
|
|
61
76
|
const current = ownDraft(latest.current.entries, requestKey)
|
|
@@ -84,7 +99,7 @@ export function ProductionMediaClips({ identity, version, document, sectionId, s
|
|
|
84
99
|
if (!sent) return
|
|
85
100
|
file.current = value; setRetryImport(false)
|
|
86
101
|
try {
|
|
87
|
-
const answer = await workbench.
|
|
102
|
+
const answer = await workbench.production.ensureAudio(value, sent.expected, sent.controller.signal)
|
|
88
103
|
if (!active() || sent.controller.signal.aborted) return
|
|
89
104
|
const next = acknowledge(answer, sent.expected.version)
|
|
90
105
|
if (owner.current.revision === sent.revision && selected.current === sent.key) {
|
|
@@ -102,7 +117,7 @@ export function ProductionMediaClips({ identity, version, document, sectionId, s
|
|
|
102
117
|
const sent = start('apply')
|
|
103
118
|
if (!sent) return
|
|
104
119
|
try {
|
|
105
|
-
const answer = await workbench.
|
|
120
|
+
const answer = await workbench.production.applyMediaClip(clip, { ...sent.expected, binding }, sent.controller.signal)
|
|
106
121
|
if (!active() || sent.controller.signal.aborted) return
|
|
107
122
|
const next = acknowledge(answer, sent.expected.version), current = ownDraft(latest.current.entries, sent.key)
|
|
108
123
|
if (sent.key === 'new') blank.current = newDraft(answer.version, stepId)
|
|
@@ -122,7 +137,7 @@ export function ProductionMediaClips({ identity, version, document, sectionId, s
|
|
|
122
137
|
const sent = start('remove')
|
|
123
138
|
if (!sent) return
|
|
124
139
|
try {
|
|
125
|
-
const answer = await workbench.
|
|
140
|
+
const answer = await workbench.production.removeMediaClip(canonical.id, sent.expected, sent.controller.signal)
|
|
126
141
|
if (!active() || sent.controller.signal.aborted) return
|
|
127
142
|
const next = acknowledge(answer, sent.expected.version), current = ownDraft(latest.current.entries, sent.key)
|
|
128
143
|
if (!current || same(current, sent.draft)) {
|
|
@@ -137,6 +152,7 @@ export function ProductionMediaClips({ identity, version, document, sectionId, s
|
|
|
137
152
|
return <MediaClipEditor locale={locale} assets={assets} clips={clips} selectedClipId={selectedClipId} draft={draft} inspection={inspectCurrent} stepDurationMs={stepDurationMs}
|
|
138
153
|
disabled={disabled} canApply={Boolean(binding && stepDurationMs !== undefined)} loading={loading} busy={busy} pending={Boolean(ownDraft(session.entries, key))} review={Boolean(ownDraft(session.entries, key) && draft.version !== version)}
|
|
139
154
|
failure={failure} storageFailed={storageFailed} status={status} retryImport={retryImport}
|
|
155
|
+
onInteraction={value => { if (value === interacting.current) return; interacting.current = value; workbench.refreshAuthoringClientControls() }}
|
|
140
156
|
onEditStart={pause} onChange={edit} onImport={value => void importAudio(value)} onRetryImport={() => { if (file.current) void importAudio(file.current) }}
|
|
141
157
|
onRead={() => { setFailure(undefined); setInspection(undefined); setReload(value => value + 1) }}
|
|
142
158
|
onReview={() => { if (inspectCurrent && (!draft.baseClip || canonical)) edit({ ...draft, version, ...canonical ? { baseClip: structuredClone(canonical) } : {} }) }}
|