@lalalic/markcut 3.2.23 → 3.2.25

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.
@@ -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='v25';
9
+ const PLAYER_VERSION='v32';
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;placeholder?:boolean}>>([{id:0,scope:'overall',text:'',context:{timeSeconds:0},selected:false,placeholder:true}]);
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
- window.dispatchEvent(new CustomEvent('markcut:scene-change',{detail:{sceneId:activeScene?.id||null,sceneName:activeScene?.name||null,timeSeconds:contextTime(activeScene,currentTime)}}));
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':'')+(note.placeholder?' placeholder':'')}
112
+ style={{left}} title={note.placeholder?'Add overall comment':note.scope+' · '+time+'s · '+note.text}
113
+ aria-label={note.placeholder?'Add overall comment':'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-list':element()
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(),'overall-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
 
@@ -71,7 +72,9 @@ describe('MCP Remotion bridge',()=>{
71
72
  a.nodes.changes.onclick?.();
72
73
  expect(a.nodes.status.textContent).toBe('Feedback is required.');
73
74
  expect(a.messages.filter(m=>m.method==='ui/message')).toHaveLength(0);
75
+ a.selectSpot(0);
74
76
  a.nodes.feedback.value='Shorten the opening';
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.selectSpot(0);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.selectSpot(0);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,37 @@ describe('MCP Remotion bridge',()=>{
133
136
  });
134
137
 
135
138
 
136
- it('restores scene drafts, marks commented scenes, and submits all comments once',()=>{
139
+ it('keeps an empty overall marker and defaults to Spot, with Overall edited through its dot',()=>{
137
140
  const h=harness();
138
- h.result({id:'multi',revisionId:'r1',contentHash:'hash',compiled:{children:[]}});
139
- h.scene({sceneId:'s1',sceneName:'Scene-A',timeSeconds:0});
140
- h.nodes.feedback.value='Improve intro';
141
- h.nodes.feedback.listeners.input();
142
- h.scene({sceneId:'s2',sceneName:'Scene-B',timeSeconds:4});
143
- h.nodes.feedback.value='Use ambient sound';
144
- h.nodes.feedback.listeners.input();
145
- const marked=h.events.filter(e=>e.type==='markcut:comments-change').at(-1).detail.sceneNames;
146
- expect([...marked].sort()).toEqual(['Scene-A','Scene-B']);
147
- h.scene({sceneId:'s1',sceneName:'Scene-A',timeSeconds:1});
148
- expect(h.nodes.feedback.value).toBe('Improve intro');
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');
141
+ expect(h.nodes['comment-mode'].value).toBe('spot');
142
+ h.selectSpot(0);
143
+ expect(h.nodes['comment-mode'].hidden).toBe(true);
144
+ expect(h.nodes['overall-mode'].hidden).toBe(false);
145
+ expect(h.nodes['remove-spot'].disabled).toBe(true);
146
+ h.nodes.feedback.value='Overall note';h.nodes['save-spot'].onclick?.();
147
+ let dots=h.events.filter(e=>e.type==='markcut:spots-change').at(-1).detail.spots;
148
+ expect(dots.filter((x:any)=>x.scope==='overall')).toHaveLength(1);
149
+ expect(dots[0].placeholder).toBeUndefined();
150
+ h.selectSpot(dots[0].id);h.nodes['remove-spot'].onclick?.();
151
+ dots=h.events.filter(e=>e.type==='markcut:spots-change').at(-1).detail.spots;
152
+ expect(dots[0]).toMatchObject({id:0,scope:'overall',placeholder:true});
153
+ });
154
+ it('saves overall, scene and spot scopes at their canonical timeline positions',()=>{
155
+ const h=harness();h.result({id:'multi',revisionId:'r1',contentHash:'hash',compiled:{children:[]}});
156
+ h.selectSpot(0);
157
+ h.nodes.feedback.value='Improve pacing';h.nodes['save-spot'].onclick?.();
158
+ h.scene({sceneId:'s1',sceneName:'Scene-A',sceneStart:3,timeSeconds:4});
159
+ h.nodes['comment-mode'].value='scene';
160
+ h.nodes.feedback.value='Improve intro';h.nodes['save-spot'].onclick?.();
161
+ h.nodes['comment-mode'].value='spot';
162
+ h.nodes.feedback.value='Delay subtitle';h.nodes['save-spot'].onclick?.();
163
+ const markers=h.events.filter(e=>e.type==='markcut:spots-change').at(-1).detail.spots;
164
+ expect(markers.map((x:any)=>[x.scope,x.context.timeSeconds])).toEqual([['overall',0],['scene',3],['spot',4]]);
165
+ expect(h.events.filter(e=>e.type==='markcut:comments-change').at(-1).detail.sceneNames).toEqual(['Scene-A']);
166
+ h.nodes.approve.onclick?.();expect(h.nodes.status.textContent).toContain('Submit or remove');
152
167
  h.nodes.changes.onclick?.();
153
- const sent=h.messages.filter(m=>m.method==='ui/message');
154
- expect(sent).toHaveLength(1);
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
- ]);
168
+ const payload=JSON.parse(h.messages.filter(m=>m.method==='ui/message').at(-1).params.content[0].text);
169
+ expect(payload.comments.map((x:any)=>x.scope)).toEqual(['overall','scene','spot']);
160
170
  });
161
171
  it('supports multiple timed notes on one scene and restores a saved note',()=>{
162
172
  const h=harness();
@@ -169,12 +179,13 @@ describe('MCP Remotion bridge',()=>{
169
179
  h.scene({sceneId:'s1',sceneName:'Scene-A',timeSeconds:7});
170
180
  h.nodes.feedback.value='Keep reaction';
171
181
  h.nodes['save-spot'].onclick?.();
172
- expect(h.nodes['comment-list'].children).toHaveLength(2);
173
- const firstEdit=h.nodes['comment-list'].children[0].children[0];
174
- firstEdit.onclick();
182
+ const markers=h.events.filter(e=>e.type==='markcut:spots-change').at(-1).detail.spots;
183
+ expect(markers).toHaveLength(3);
184
+ expect(markers.filter((x:any)=>!x.placeholder).map((x:any)=>x.context.timeSeconds)).toEqual([1,7]);
185
+ h.selectSpot(markers.find((x:any)=>!x.placeholder).id);
175
186
  expect(h.nodes.feedback.value).toBe('Trim opening');
176
187
  h.nodes.feedback.value='Trim first second';
177
- h.nodes.feedback.listeners.input();
188
+ h.nodes['save-spot'].onclick?.();
178
189
  h.nodes.changes.onclick?.();
179
190
  const payload=JSON.parse(h.messages.at(-1).params.content[0].text);
180
191
  expect(payload.comments).toHaveLength(2);
@@ -182,6 +193,35 @@ describe('MCP Remotion bridge',()=>{
182
193
  expect(payload.comments.map((x:any)=>x.text)).toContain('Trim first second');
183
194
  expect(payload.comments.map((x:any)=>x.text)).toContain('Keep reaction');
184
195
  });
196
+ it('keeps typed text across scope switches and blocks unsaved submission',()=>{
197
+ const h=harness();h.result({id:'draft',revisionId:'r',contentHash:'hash',compiled:{children:[]}});
198
+ h.scene({sceneId:'s1',sceneName:'Scene-A',sceneStart:2,timeSeconds:3});
199
+ h.nodes.feedback.value='Keep this text';
200
+ h.nodes['comment-mode'].value='scene';h.nodes['comment-mode'].onchange?.();
201
+ expect(h.nodes.feedback.value).toBe('Keep this text');
202
+ h.nodes.changes.onclick?.();
203
+ expect(h.nodes.status.textContent).toContain('Add or remove');
204
+ h.nodes['save-spot'].onclick?.();
205
+ const note=h.events.filter(e=>e.type==='markcut:spots-change').at(-1).detail.spots.find((x:any)=>!x.placeholder);
206
+ h.selectSpot(note.id);
207
+ h.nodes.changes.onclick?.();
208
+ expect(h.messages.filter(m=>m.method==='ui/message')).toHaveLength(1);
209
+ });
210
+ it('deletes only the selected timeline marker',()=>{
211
+ const h=harness();h.result({id:'dots',revisionId:'r1',contentHash:'hash',compiled:{children:[]}});
212
+ h.scene({sceneId:'s1',sceneName:'Scene-A',timeSeconds:1});
213
+ h.nodes.feedback.value='First';h.nodes['save-spot'].onclick?.();
214
+ h.scene({sceneId:'s2',sceneName:'Scene-B',timeSeconds:3});
215
+ h.nodes.feedback.value='Second';h.nodes['save-spot'].onclick?.();
216
+ const markers=h.events.filter(e=>e.type==='markcut:spots-change').at(-1).detail.spots;
217
+ h.selectSpot(markers.find((x:any)=>!x.placeholder).id);
218
+ expect(h.nodes['remove-spot'].disabled).toBe(false);
219
+ h.nodes['remove-spot'].onclick?.();
220
+ expect(h.nodes['remove-spot'].disabled).toBe(true);
221
+ expect(h.events.filter(e=>e.type==='markcut:spots-change').at(-1).detail.spots).toHaveLength(2);
222
+ h.nodes.changes.onclick?.();
223
+ expect(JSON.parse(h.messages.at(-1).params.content[0].text).comments.map((x:any)=>x.text)).toEqual(['Second']);
224
+ });
185
225
  describe('static compiled-JSON bridge',()=>{
186
226
  const base='https://neoy.qili2.com/files/_neoy/markcut/cache/';
187
227
  const staticData={width:640,height:480,fps:30,children:[{name:'Static-Scene'}]};
@@ -11,8 +11,13 @@ 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('>v25</span>');
14
+ expect(html).toContain('>v32</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('id="overall-mode" hidden>Overall');
19
+ expect(html).not.toContain('<option value="overall"');
20
+ expect(html).toContain('#comment-tools>*{width:30px;height:28px;padding:0;border:0');
16
21
  expect(html).toContain('https://neoy.example.test/files/_neoy/markcut/player/');
17
22
  expect(html).not.toContain('id="remotion-bundle"');
18
23
  expect(html.length).toBeLessThan(20000);