@lalalic/markcut 3.2.20 → 3.2.22

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,12 +6,18 @@ 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='v24';
9
+ const PLAYER_VERSION='v25';
10
10
  function App(){
11
11
  const [revision,setRevision]=React.useState<any>(()=>(window as any).__markcutRevision||null);
12
12
  const ref=React.useRef<PlayerRef|null>(null);
13
13
  const [currentTime,setCurrentTime]=React.useState(0);
14
14
  const [browserTts,setBrowserTts]=React.useState(true);
15
+ const [commentedScenes,setCommentedScenes]=React.useState<string[]>([]);
16
+ React.useEffect(()=>{
17
+ const listener=(event:Event)=>setCommentedScenes((event as CustomEvent).detail?.sceneNames||[]);
18
+ window.addEventListener('markcut:comments-change',listener);
19
+ return ()=>window.removeEventListener('markcut:comments-change',listener);
20
+ },[]);
15
21
  React.useEffect(()=>{const receive=(e:Event)=>setRevision((e as CustomEvent).detail);window.addEventListener('markcut:revision',receive);return ()=>window.removeEventListener('markcut:revision',receive)},[]);
16
22
  const data=revision?.compiled?.root||revision?.compiled;
17
23
  const useBrowserTts=browserTts&&Boolean(data?.subtitle?.src);
@@ -51,6 +57,17 @@ function App(){
51
57
  timeSeconds:Math.round(currentTime*10)/10
52
58
  };
53
59
  },[scenes,currentTime]);
60
+ const activeScene=[...scenes].reverse().find(scene=>currentTime>=scene.start);
61
+ React.useEffect(()=>{
62
+ window.dispatchEvent(new CustomEvent('markcut:scene-change',{detail:{sceneId:activeScene?.id||null,sceneName:activeScene?.name||null,timeSeconds:Math.round(currentTime*10)/10}}));
63
+ },[revision?.revisionId,activeScene?.id,activeScene?.name]);
64
+ React.useEffect(()=>{
65
+ const listener=(event:Event)=>{const context=(event as CustomEvent).detail;const scene=scenes.find(x=>x.id===context?.sceneId||x.name===context?.sceneName);
66
+ 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);}
67
+ };
68
+ window.addEventListener('markcut:comment-select',listener);
69
+ return ()=>window.removeEventListener('markcut:comment-select',listener);
70
+ },[scenes,fps]);
54
71
  if(!revision)return <div id="remotion-waiting">Player {PLAYER_VERSION} · Waiting for compiled scenes…</div>;
55
72
  if(!data)return <div>Missing compiled scene tree</div>;
56
73
  const videoName=String(revision.title||revision.videoTitle||revision.path?.split('/').pop()?.replace(/\.md$/i,'').replace(/[-_]+/g,' ')||'Video');
@@ -64,7 +81,7 @@ function App(){
64
81
  <SharedPlayer key={revision.revisionId} root={playbackRoot} playerRef={ref} numberOfSharedAudioTags={0} style={{width:'100%',height:'100%'}} />
65
82
  </div>
66
83
  {useBrowserTts&&caption&&<div role="status" style={{textAlign:"center",padding:"6px 12px",fontSize:13}}>{caption}</div>}
67
- <SceneThumbnails sceneData={scenes} currentTime={currentTime} onSeek={t=>{ref.current?.seekTo(Math.round(t*fps));setCurrentTime(t);}} />
84
+ <SceneThumbnails sceneData={scenes} commentedScenes={commentedScenes} currentTime={currentTime} onSeek={t=>{ref.current?.seekTo(Math.round(t*fps));setCurrentTime(t);}} />
68
85
  {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>}
69
86
  </div>;
70
87
  }
@@ -10,6 +10,7 @@ interface Scene {
10
10
  name: string;
11
11
  start: number;
12
12
  end: number;
13
+ id?: string;
13
14
  }
14
15
 
15
16
  interface SceneThumbnailsProps {
@@ -18,9 +19,10 @@ interface SceneThumbnailsProps {
18
19
  /** Called when a thumbnail is clicked; receives scene start time in seconds */
19
20
  onSeek?: (timeSeconds: number) => void;
20
21
  sceneData?: Scene[];
22
+ commentedScenes?: string[];
21
23
  }
22
24
 
23
- export function SceneThumbnails({ currentTime, onSeek, sceneData }: SceneThumbnailsProps) {
25
+ export function SceneThumbnails({ currentTime, onSeek, sceneData, commentedScenes=[] }: SceneThumbnailsProps) {
24
26
  const [scenes, setScenes] = React.useState<Scene[]>([]);
25
27
 
26
28
  React.useEffect(() => {
@@ -56,7 +58,8 @@ export function SceneThumbnails({ currentTime, onSeek, sceneData }: SceneThumbna
56
58
  return (
57
59
  <span
58
60
  key={i}
59
- className={"scene-pill" + (isActive ? " active" : "")}
61
+ className={"scene-pill" + (isActive ? " active" : "") + (commentedScenes.includes(scene.name) ? " commented" : "")}
62
+ title={commentedScenes.includes(scene.name) ? "Has review comments" : undefined}
60
63
  onClick={() => onSeek?.(scene.start)}
61
64
  >
62
65
  {scene.name || "Scene " + (i + 1)}
@@ -6,9 +6,13 @@ import {buildPreviewBridgeScript} from '../src/mcp/bridge.mjs';
6
6
  function harness(remoteData?:any, fetchOverride?:(url:string)=>Promise<any>) {
7
7
  const messages:any[]=[];
8
8
  const listeners:Record<string,Array<(evt:any)=>void>>={};
9
- const element=()=>({value:'',textContent:'',onclick:null as null|(()=>void)});
9
+ const element=()=>({value:'',textContent:'',onclick:null as null|(()=>void),oninput:null as null|(()=>void),
10
+ disabled:false,hidden:false,type:'',children:[] as any[],listeners:{} as Record<string,Function>,
11
+ addEventListener(type:string,listener:Function){this.listeners[type]=listener},
12
+ replaceChildren(){this.children=[]},append(...items:any[]){this.children.push(...items)}
13
+ });
10
14
  const nodes:Record<string,ReturnType<typeof element>>={
11
- feedback:element(),status:element(),'path-label':element(),'video-md-version':element(),'interactive-ui':element(),approve:element(),changes: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()
12
16
  };
13
17
  const parent={postMessage:(m:any)=>messages.push(m)};
14
18
  const events:any[]=[];
@@ -18,12 +22,12 @@ function harness(remoteData?:any, fetchOverride?:(url:string)=>Promise<any>) {
18
22
  dispatchEvent:(evt:any)=>{events.push(evt);return true},
19
23
  };
20
24
  const fetch=fetchOverride|| (async()=>({ok:true,json:async()=>remoteData}));
21
- const context=vm.createContext({crypto:webcrypto,TextEncoder,URL,fetch,setTimeout,window,document:{getElementById:(id:string)=>nodes[id]},CustomEvent:class {type:string;detail:any;constructor(t:string,opts:any){this.type=t;this.detail=opts.detail}}});
25
+ const context=vm.createContext({crypto:webcrypto,TextEncoder,URL,fetch,setTimeout,window,document:{getElementById:(id:string)=>nodes[id],createElement:()=>element()},CustomEvent:class {type:string;detail:any;constructor(t:string,opts:any){this.type=t;this.detail=opts.detail}}});
22
26
  const dispatch=(message:any,source=parent)=>(listeners.message??[]).forEach(listener=>listener({source,data:{jsonrpc:'2.0',...message}}));
23
27
  const result=(data:any)=>dispatch({method:'ui/notifications/tool-result',params:{result:{structuredContent:data}}});
24
28
  const respond=(id:number,result:any={})=>dispatch({id,result});
25
29
  vm.runInContext(buildPreviewBridgeScript().replaceAll("__MARKCUT_ORIGIN__",JSON.stringify("https://neoy.qili2.com")),context);
26
- return {messages,nodes,events,dispatch,result,respond};
30
+ return {messages,nodes,events,dispatch,result,respond,scene:(detail:any)=>(listeners['markcut:scene-change']||[]).forEach(listener=>listener({detail}))};
27
31
  }
28
32
  const nextTick=()=>new Promise(resolve=>setTimeout(resolve,0));
29
33
 
@@ -129,6 +133,55 @@ describe('MCP Remotion bridge',()=>{
129
133
  });
130
134
 
131
135
 
136
+ it('restores scene drafts, marks commented scenes, and submits all comments once',()=>{
137
+ 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');
152
+ 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
+ ]);
160
+ });
161
+ it('supports multiple timed notes on one scene and restores a saved note',()=>{
162
+ const h=harness();
163
+ h.result({id:'spots',revisionId:'r1',contentHash:'hash',compiled:{children:[]}});
164
+ h.scene({sceneId:'s1',sceneName:'Scene-A',timeSeconds:1});
165
+ h.nodes.feedback.value='Trim opening';
166
+ h.nodes['save-spot'].onclick?.();
167
+ expect(h.nodes.feedback.value).toBe('');
168
+ h.scene({sceneId:'s2',sceneName:'Scene-B',timeSeconds:5});
169
+ h.scene({sceneId:'s1',sceneName:'Scene-A',timeSeconds:7});
170
+ h.nodes.feedback.value='Keep reaction';
171
+ 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();
175
+ expect(h.nodes.feedback.value).toBe('Trim opening');
176
+ h.nodes.feedback.value='Trim first second';
177
+ h.nodes.feedback.listeners.input();
178
+ h.nodes.changes.onclick?.();
179
+ const payload=JSON.parse(h.messages.at(-1).params.content[0].text);
180
+ expect(payload.comments).toHaveLength(2);
181
+ expect(h.nodes['comment-count'].textContent).toBe('2 comments');
182
+ expect(payload.comments.map((x:any)=>x.text)).toContain('Trim first second');
183
+ expect(payload.comments.map((x:any)=>x.text)).toContain('Keep reaction');
184
+ });
132
185
  describe('static compiled-JSON bridge',()=>{
133
186
  const base='https://neoy.qili2.com/files/_neoy/markcut/cache/';
134
187
  const staticData={width:640,height:480,fps:30,children:[{name:'Static-Scene'}]};
@@ -11,7 +11,7 @@ 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('>v24</span>');
14
+ expect(html).toContain('>v25</span>');
15
15
  expect(html).toContain('id="video-md-version"');
16
16
  expect(html).toContain('https://neoy.example.test/files/_neoy/markcut/player/');
17
17
  expect(html).not.toContain('id="remotion-bundle"');