@lalalic/markcut 3.2.23 → 3.2.24
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 +1 -1
- package/src/mcp/bridge.mjs +42 -48
- package/src/mcp/preview.mjs +14 -7
- package/src/mcp/remotion-app.bundle.js +279 -279
- package/src/mcp/remotion-app.tsx +34 -4
- package/tests/mcp-preview-bridge.test.ts +56 -31
- package/tests/mcp-preview.test.ts +4 -1
package/src/mcp/remotion-app.tsx
CHANGED
|
@@ -6,7 +6,7 @@ import {SharedPlayer} from '../player/SharedPlayer';
|
|
|
6
6
|
import {SceneThumbnails} from '../player/components/SceneThumbnails';
|
|
7
7
|
import {useWebAudioPreview} from './web-audio-preview';
|
|
8
8
|
import {useBrowserSpeechPreview} from './browser-speech-preview';
|
|
9
|
-
const PLAYER_VERSION='
|
|
9
|
+
const PLAYER_VERSION='v31';
|
|
10
10
|
const contextTime=(scene:{start:number;end:number}|undefined,time:number)=>
|
|
11
11
|
Math.round(Math.max(scene?.start??0,Math.min(scene?.end??time,time))*10)/10;
|
|
12
12
|
function App(){
|
|
@@ -15,11 +15,18 @@ function App(){
|
|
|
15
15
|
const [currentTime,setCurrentTime]=React.useState(0);
|
|
16
16
|
const [browserTts,setBrowserTts]=React.useState(true);
|
|
17
17
|
const [commentedScenes,setCommentedScenes]=React.useState<string[]>([]);
|
|
18
|
+
const [spotMarkers,setSpotMarkers]=React.useState<Array<{id:number;scope:'overall'|'scene'|'spot';text:string;context:{timeSeconds:number;sceneName?:string};selected:boolean}>>([]);
|
|
19
|
+
const [seekBar,setSeekBar]=React.useState<HTMLElement|null>(null);
|
|
18
20
|
React.useEffect(()=>{
|
|
19
21
|
const listener=(event:Event)=>setCommentedScenes((event as CustomEvent).detail?.sceneNames||[]);
|
|
20
22
|
window.addEventListener('markcut:comments-change',listener);
|
|
21
23
|
return ()=>window.removeEventListener('markcut:comments-change',listener);
|
|
22
24
|
},[]);
|
|
25
|
+
React.useEffect(()=>{
|
|
26
|
+
const listener=(event:Event)=>setSpotMarkers((event as CustomEvent).detail?.spots||[]);
|
|
27
|
+
window.addEventListener('markcut:spots-change',listener);
|
|
28
|
+
return ()=>window.removeEventListener('markcut:spots-change',listener);
|
|
29
|
+
},[]);
|
|
23
30
|
React.useEffect(()=>{const receive=(e:Event)=>setRevision((e as CustomEvent).detail);window.addEventListener('markcut:revision',receive);return ()=>window.removeEventListener('markcut:revision',receive)},[]);
|
|
24
31
|
const data=revision?.compiled?.root||revision?.compiled;
|
|
25
32
|
const useBrowserTts=browserTts&&Boolean(data?.subtitle?.src);
|
|
@@ -55,16 +62,28 @@ function App(){
|
|
|
55
62
|
React.useEffect(()=>{
|
|
56
63
|
const active=[...scenes].reverse().find(scene=>currentTime>=scene.start);
|
|
57
64
|
(window as any).__markcutPlaybackContext={
|
|
58
|
-
sceneId:active?.id||null,sceneName:active?.name||null,
|
|
65
|
+
sceneId:active?.id||null,sceneName:active?.name||null,sceneStart:active?.start||0,
|
|
59
66
|
timeSeconds:contextTime(active,currentTime)
|
|
60
67
|
};
|
|
61
68
|
},[scenes,currentTime]);
|
|
62
69
|
const activeScene=[...scenes].reverse().find(scene=>currentTime>=scene.start);
|
|
63
70
|
React.useEffect(()=>{
|
|
64
|
-
|
|
71
|
+
let timer:number;
|
|
72
|
+
const find=()=>{
|
|
73
|
+
const bar=Array.from(document.querySelectorAll<HTMLElement>('#remotion-canvas div')).find(el=>
|
|
74
|
+
el.style.cursor==='pointer'&&el.style.touchAction==='none'&&el.style.position==='relative');
|
|
75
|
+
if(bar){
|
|
76
|
+
bar.style.marginLeft='22px';setSeekBar(bar);window.clearInterval(timer);
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
find();timer=window.setInterval(find,150);
|
|
80
|
+
return ()=>window.clearInterval(timer);
|
|
81
|
+
},[revision?.revisionId]);
|
|
82
|
+
React.useEffect(()=>{
|
|
83
|
+
window.dispatchEvent(new CustomEvent('markcut:scene-change',{detail:{sceneId:activeScene?.id||null,sceneName:activeScene?.name||null,sceneStart:activeScene?.start||0,timeSeconds:contextTime(activeScene,currentTime)}}));
|
|
65
84
|
},[revision?.revisionId,activeScene?.id,activeScene?.name]);
|
|
66
85
|
React.useEffect(()=>{
|
|
67
|
-
const listener=(event:Event)=>{const context=(event as CustomEvent).detail;const scene=scenes.find(x=>x.id===context?.sceneId||x.name===context?.sceneName);
|
|
86
|
+
const listener=(event:Event)=>{const context=(event as CustomEvent).detail;const scene=scenes.find((x:{id?:string;name:string;start:number;end:number})=>x.id===context?.sceneId||x.name===context?.sceneName);
|
|
68
87
|
if(scene){const second=Number(context.timeSeconds);const time=Number.isFinite(second)?Math.max(scene.start,Math.min(scene.end,second)):scene.start;ref.current?.seekTo(Math.round(time*fps));setCurrentTime(time);}
|
|
69
88
|
};
|
|
70
89
|
window.addEventListener('markcut:comment-select',listener);
|
|
@@ -84,6 +103,17 @@ function App(){
|
|
|
84
103
|
</div>
|
|
85
104
|
{useBrowserTts&&caption&&<div role="status" style={{textAlign:"center",padding:"6px 12px",fontSize:13}}>{caption}</div>}
|
|
86
105
|
<SceneThumbnails sceneData={scenes} commentedScenes={commentedScenes} currentTime={currentTime} onSeek={t=>{ref.current?.seekTo(Math.round(t*fps));setCurrentTime(t);}} />
|
|
106
|
+
{seekBar&&createPortal(<>
|
|
107
|
+
{spotMarkers.map(note=>{
|
|
108
|
+
const duration=Math.max(0.001,Number(data.durationInSeconds)||scenes.at(-1)?.end||1);
|
|
109
|
+
const time=Number(note.context.timeSeconds)||0;
|
|
110
|
+
const left=note.scope==='overall'?'0px':(Math.max(0,Math.min(1,time/duration))*100)+'%';
|
|
111
|
+
return <button key={note.id} type="button" className={'comment-marker scope-'+note.scope+(note.selected?' selected':'')}
|
|
112
|
+
style={{left}} title={note.scope+' · '+time+'s · '+note.text}
|
|
113
|
+
aria-label={'Edit '+note.scope+' comment at '+time+' seconds'}
|
|
114
|
+
onPointerDown={e=>e.stopPropagation()} onClick={e=>{e.stopPropagation();window.dispatchEvent(new CustomEvent('markcut:spot-select',{detail:{id:note.id}}));}}/>;
|
|
115
|
+
})}
|
|
116
|
+
</>,seekBar)}
|
|
87
117
|
{status && !/initializing|ready|paused/i.test(status) && <div id="preview-audio-status" role="status" style={{fontSize:12,padding:'4px 0'}}>{status.replace(/^Web Audio /,'Audio ')}</div>}
|
|
88
118
|
</div>;
|
|
89
119
|
}
|
|
@@ -12,8 +12,9 @@ function harness(remoteData?:any, fetchOverride?:(url:string)=>Promise<any>) {
|
|
|
12
12
|
replaceChildren(){this.children=[]},append(...items:any[]){this.children.push(...items)}
|
|
13
13
|
});
|
|
14
14
|
const nodes:Record<string,ReturnType<typeof element>>={
|
|
15
|
-
feedback:element(),status:element(),'path-label':element(),'video-md-version':element(),'interactive-ui':element(),approve:element(),changes:element(),'save-spot':element(),'comment-target':element(),'comment-count':element(),'comment-
|
|
15
|
+
feedback:element(),status:element(),'path-label':element(),'video-md-version':element(),'interactive-ui':element(),approve:element(),changes:element(),'save-spot':element(),'remove-spot':element(),'comment-target':element(),'comment-count':element(),'comment-mode':element()
|
|
16
16
|
};
|
|
17
|
+
nodes['comment-mode'].value='spot';
|
|
17
18
|
const parent={postMessage:(m:any)=>messages.push(m)};
|
|
18
19
|
const events:any[]=[];
|
|
19
20
|
const window={
|
|
@@ -27,7 +28,7 @@ function harness(remoteData?:any, fetchOverride?:(url:string)=>Promise<any>) {
|
|
|
27
28
|
const result=(data:any)=>dispatch({method:'ui/notifications/tool-result',params:{result:{structuredContent:data}}});
|
|
28
29
|
const respond=(id:number,result:any={})=>dispatch({id,result});
|
|
29
30
|
vm.runInContext(buildPreviewBridgeScript().replaceAll("__MARKCUT_ORIGIN__",JSON.stringify("https://neoy.qili2.com")),context);
|
|
30
|
-
return {messages,nodes,events,dispatch,result,respond,scene:(detail:any)=>(listeners['markcut:scene-change']||[]).forEach(listener=>listener({detail}))};
|
|
31
|
+
return {messages,nodes,events,dispatch,result,respond,scene:(detail:any)=>(listeners['markcut:scene-change']||[]).forEach(listener=>listener({detail})),selectSpot:(id:number)=>(listeners['markcut:spot-select']||[]).forEach(listener=>listener({detail:{id}}))};
|
|
31
32
|
}
|
|
32
33
|
const nextTick=()=>new Promise(resolve=>setTimeout(resolve,0));
|
|
33
34
|
|
|
@@ -72,6 +73,8 @@ describe('MCP Remotion bridge',()=>{
|
|
|
72
73
|
expect(a.nodes.status.textContent).toBe('Feedback is required.');
|
|
73
74
|
expect(a.messages.filter(m=>m.method==='ui/message')).toHaveLength(0);
|
|
74
75
|
a.nodes.feedback.value='Shorten the opening';
|
|
76
|
+
a.nodes['comment-mode'].value='overall';
|
|
77
|
+
a.nodes['save-spot'].onclick?.();
|
|
75
78
|
a.nodes.changes.onclick?.();
|
|
76
79
|
expect(JSON.parse(a.messages[2].params.content[0].text)).toMatchObject({previewId:'a',decision:'changes_requested',feedback:'Shorten the opening'});
|
|
77
80
|
expect(b.messages.filter(m=>m.method==='ui/message')).toHaveLength(0);
|
|
@@ -109,7 +112,7 @@ describe('MCP Remotion bridge',()=>{
|
|
|
109
112
|
const h=harness();
|
|
110
113
|
const relay={jobId:'job-7',taskId:19,executionId:'exec-1'};
|
|
111
114
|
h.result({id:'r',revisionId:'r',contentHash:'hash',path:'/video.md',relay,compiled:{children:[]}});
|
|
112
|
-
h.nodes.feedback.value='shorter title';h.nodes.changes.onclick?.();
|
|
115
|
+
h.nodes['comment-mode'].value='overall';h.nodes.feedback.value='shorter title';h.nodes['save-spot'].onclick?.();h.nodes.changes.onclick?.();
|
|
113
116
|
expect(JSON.parse(h.messages.at(-1).params.content[0].text).relay).toEqual(relay);
|
|
114
117
|
});
|
|
115
118
|
it('handles request changes followed by a new revision and approval in the same app',async()=>{
|
|
@@ -117,7 +120,7 @@ describe('MCP Remotion bridge',()=>{
|
|
|
117
120
|
const first={id:'first',revisionId:'r1',contentHash:'sha1',path:'/video.md',compiled:{children:[{name:'First'}]}};
|
|
118
121
|
const next={id:'second',revisionId:'r2',contentHash:'sha2',path:'/video.md',compiled:{children:[{name:'Next'}]}};
|
|
119
122
|
h.result(first);
|
|
120
|
-
h.nodes.feedback.value='lowercase title';h.nodes.changes.onclick?.();
|
|
123
|
+
h.nodes['comment-mode'].value='overall';h.nodes.feedback.value='lowercase title';h.nodes['save-spot'].onclick?.();h.nodes.changes.onclick?.();
|
|
121
124
|
expect(JSON.parse(h.messages[2].params.content[0].text)).toMatchObject({path:'/video.md',revisionId:'r1',decision:'changes_requested',feedback:'lowercase title'});
|
|
122
125
|
h.respond(2);await nextTick();
|
|
123
126
|
expect(h.nodes.status.textContent).toContain('Waiting for the updated preview');
|
|
@@ -133,30 +136,22 @@ describe('MCP Remotion bridge',()=>{
|
|
|
133
136
|
});
|
|
134
137
|
|
|
135
138
|
|
|
136
|
-
it('
|
|
137
|
-
const h=harness();
|
|
138
|
-
h.
|
|
139
|
-
h.
|
|
140
|
-
h.
|
|
141
|
-
h.nodes.
|
|
142
|
-
h.
|
|
143
|
-
h.nodes.
|
|
144
|
-
h.nodes.feedback.
|
|
145
|
-
const
|
|
146
|
-
expect(
|
|
147
|
-
h.
|
|
148
|
-
expect(h.nodes.
|
|
149
|
-
expect(h.nodes['comment-count'].textContent).toBe('2 comments');
|
|
150
|
-
h.nodes.approve.onclick?.();
|
|
151
|
-
expect(h.nodes.status.textContent).toContain('Submit or remove');
|
|
139
|
+
it('saves overall, scene and spot scopes at their canonical timeline positions',()=>{
|
|
140
|
+
const h=harness();h.result({id:'multi',revisionId:'r1',contentHash:'hash',compiled:{children:[]}});
|
|
141
|
+
h.nodes['comment-mode'].value='overall';
|
|
142
|
+
h.nodes.feedback.value='Improve pacing';h.nodes['save-spot'].onclick?.();
|
|
143
|
+
h.scene({sceneId:'s1',sceneName:'Scene-A',sceneStart:3,timeSeconds:4});
|
|
144
|
+
h.nodes['comment-mode'].value='scene';
|
|
145
|
+
h.nodes.feedback.value='Improve intro';h.nodes['save-spot'].onclick?.();
|
|
146
|
+
h.nodes['comment-mode'].value='spot';
|
|
147
|
+
h.nodes.feedback.value='Delay subtitle';h.nodes['save-spot'].onclick?.();
|
|
148
|
+
const markers=h.events.filter(e=>e.type==='markcut:spots-change').at(-1).detail.spots;
|
|
149
|
+
expect(markers.map((x:any)=>[x.scope,x.context.timeSeconds])).toEqual([['overall',0],['scene',3],['spot',4]]);
|
|
150
|
+
expect(h.events.filter(e=>e.type==='markcut:comments-change').at(-1).detail.sceneNames).toEqual(['Scene-A']);
|
|
151
|
+
h.nodes.approve.onclick?.();expect(h.nodes.status.textContent).toContain('Submit or remove');
|
|
152
152
|
h.nodes.changes.onclick?.();
|
|
153
|
-
const
|
|
154
|
-
expect(
|
|
155
|
-
const payload=JSON.parse(sent[0].params.content[0].text);
|
|
156
|
-
expect(payload.comments).toMatchObject([
|
|
157
|
-
{text:'Improve intro',playbackContext:{sceneName:'Scene-A'}},
|
|
158
|
-
{text:'Use ambient sound',playbackContext:{sceneName:'Scene-B'}}
|
|
159
|
-
]);
|
|
153
|
+
const payload=JSON.parse(h.messages.filter(m=>m.method==='ui/message').at(-1).params.content[0].text);
|
|
154
|
+
expect(payload.comments.map((x:any)=>x.scope)).toEqual(['overall','scene','spot']);
|
|
160
155
|
});
|
|
161
156
|
it('supports multiple timed notes on one scene and restores a saved note',()=>{
|
|
162
157
|
const h=harness();
|
|
@@ -169,12 +164,13 @@ describe('MCP Remotion bridge',()=>{
|
|
|
169
164
|
h.scene({sceneId:'s1',sceneName:'Scene-A',timeSeconds:7});
|
|
170
165
|
h.nodes.feedback.value='Keep reaction';
|
|
171
166
|
h.nodes['save-spot'].onclick?.();
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
167
|
+
const markers=h.events.filter(e=>e.type==='markcut:spots-change').at(-1).detail.spots;
|
|
168
|
+
expect(markers).toHaveLength(2);
|
|
169
|
+
expect(markers.map((x:any)=>x.context.timeSeconds)).toEqual([1,7]);
|
|
170
|
+
h.selectSpot(markers[0].id);
|
|
175
171
|
expect(h.nodes.feedback.value).toBe('Trim opening');
|
|
176
172
|
h.nodes.feedback.value='Trim first second';
|
|
177
|
-
h.nodes.
|
|
173
|
+
h.nodes['save-spot'].onclick?.();
|
|
178
174
|
h.nodes.changes.onclick?.();
|
|
179
175
|
const payload=JSON.parse(h.messages.at(-1).params.content[0].text);
|
|
180
176
|
expect(payload.comments).toHaveLength(2);
|
|
@@ -182,6 +178,35 @@ describe('MCP Remotion bridge',()=>{
|
|
|
182
178
|
expect(payload.comments.map((x:any)=>x.text)).toContain('Trim first second');
|
|
183
179
|
expect(payload.comments.map((x:any)=>x.text)).toContain('Keep reaction');
|
|
184
180
|
});
|
|
181
|
+
it('keeps typed text across scope switches and blocks unsaved submission',()=>{
|
|
182
|
+
const h=harness();h.result({id:'draft',revisionId:'r',contentHash:'hash',compiled:{children:[]}});
|
|
183
|
+
h.scene({sceneId:'s1',sceneName:'Scene-A',sceneStart:2,timeSeconds:3});
|
|
184
|
+
h.nodes.feedback.value='Keep this text';
|
|
185
|
+
h.nodes['comment-mode'].value='scene';h.nodes['comment-mode'].onchange?.();
|
|
186
|
+
expect(h.nodes.feedback.value).toBe('Keep this text');
|
|
187
|
+
h.nodes.changes.onclick?.();
|
|
188
|
+
expect(h.nodes.status.textContent).toContain('Add or remove');
|
|
189
|
+
h.nodes['save-spot'].onclick?.();
|
|
190
|
+
const note=h.events.filter(e=>e.type==='markcut:spots-change').at(-1).detail.spots[0];
|
|
191
|
+
h.selectSpot(note.id);
|
|
192
|
+
h.nodes.changes.onclick?.();
|
|
193
|
+
expect(h.messages.filter(m=>m.method==='ui/message')).toHaveLength(1);
|
|
194
|
+
});
|
|
195
|
+
it('deletes only the selected timeline marker',()=>{
|
|
196
|
+
const h=harness();h.result({id:'dots',revisionId:'r1',contentHash:'hash',compiled:{children:[]}});
|
|
197
|
+
h.scene({sceneId:'s1',sceneName:'Scene-A',timeSeconds:1});
|
|
198
|
+
h.nodes.feedback.value='First';h.nodes['save-spot'].onclick?.();
|
|
199
|
+
h.scene({sceneId:'s2',sceneName:'Scene-B',timeSeconds:3});
|
|
200
|
+
h.nodes.feedback.value='Second';h.nodes['save-spot'].onclick?.();
|
|
201
|
+
const markers=h.events.filter(e=>e.type==='markcut:spots-change').at(-1).detail.spots;
|
|
202
|
+
h.selectSpot(markers[0].id);
|
|
203
|
+
expect(h.nodes['remove-spot'].disabled).toBe(false);
|
|
204
|
+
h.nodes['remove-spot'].onclick?.();
|
|
205
|
+
expect(h.nodes['remove-spot'].disabled).toBe(true);
|
|
206
|
+
expect(h.events.filter(e=>e.type==='markcut:spots-change').at(-1).detail.spots).toHaveLength(1);
|
|
207
|
+
h.nodes.changes.onclick?.();
|
|
208
|
+
expect(JSON.parse(h.messages.at(-1).params.content[0].text).comments.map((x:any)=>x.text)).toEqual(['Second']);
|
|
209
|
+
});
|
|
185
210
|
describe('static compiled-JSON bridge',()=>{
|
|
186
211
|
const base='https://neoy.qili2.com/files/_neoy/markcut/cache/';
|
|
187
212
|
const staticData={width:640,height:480,fps:30,children:[{name:'Static-Scene'}]};
|
|
@@ -11,8 +11,11 @@ describe('Markcut Remotion MCP App',()=>{
|
|
|
11
11
|
const html=buildPreviewHtml();
|
|
12
12
|
expect(html).toContain('id="remotion-root"');
|
|
13
13
|
expect(html).toContain('id="player-version"');
|
|
14
|
-
expect(html).toContain('>
|
|
14
|
+
expect(html).toContain('>v31</span>');
|
|
15
15
|
expect(html).toContain('id="video-md-version"');
|
|
16
|
+
expect(html).toContain('<textarea id="feedback" rows="3"');
|
|
17
|
+
expect(html).toContain('id="comment-tools"');
|
|
18
|
+
expect(html).toContain('#comment-tools>*{width:30px;height:28px;padding:0;border:0');
|
|
16
19
|
expect(html).toContain('https://neoy.example.test/files/_neoy/markcut/player/');
|
|
17
20
|
expect(html).not.toContain('id="remotion-bundle"');
|
|
18
21
|
expect(html.length).toBeLessThan(20000);
|