@lalalic/markcut 3.2.60 → 3.2.62

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.
Files changed (54) hide show
  1. package/README.md +48 -5
  2. package/bin/markcut +15 -0
  3. package/docs/developer-reference.md +41 -1
  4. package/package.json +8 -2
  5. package/recipes/markcut/map-cinematic-follow.json +17 -0
  6. package/recipes/markcut/map-location-reveal.json +17 -0
  7. package/recipes/markcut/map-route-journey.json +18 -0
  8. package/recipes/markcut/map-streetview-explore.json +17 -0
  9. package/skills/markcut/SKILL.md +8 -3
  10. package/skills/markcut/docs/markdown-descriptive.md +68 -1
  11. package/skills/markcut/docs/recipes.md +45 -0
  12. package/skills/markcut/references/mobile-event-preview-cli.md +9 -5
  13. package/src/descriptive/compiler.ts +38 -2
  14. package/src/descriptive/markdown.ts +30 -0
  15. package/src/descriptive/model3d.test.ts +38 -0
  16. package/src/editor-decision/cli.mjs +21 -0
  17. package/src/editor-decision/editor-decision.schema.json +41 -0
  18. package/src/editor-decision/index.mjs +115 -0
  19. package/src/editor-decision/index.test.mjs +63 -0
  20. package/src/mcp/bridge.mjs +92 -12
  21. package/src/mcp/compile-worker.mjs +2 -2
  22. package/src/mcp/design-cli.mjs +126 -0
  23. package/src/mcp/mobile-review-cli.mjs +40 -33
  24. package/src/mcp/preview-mobile.css +21 -8
  25. package/src/mcp/preview.mjs +97 -57
  26. package/src/mcp/remote-assets.mjs +85 -7
  27. package/src/mcp/remotion-app.bundle.js +5013 -1117
  28. package/src/mcp/remotion-app.tsx +132 -10
  29. package/src/mcp/server.mjs +4 -2
  30. package/src/player/browser.tsx +1 -3
  31. package/src/player/bundle/player.js +73054 -17357
  32. package/src/player/components/HeaderBar.tsx +3 -1
  33. package/src/player/components/VariantBar.tsx +20 -21
  34. package/src/player/pipeline.mjs +133 -77
  35. package/src/player/server.mjs +43 -23
  36. package/src/recipes/catalog.mjs +115 -0
  37. package/src/recipes/cli.mjs +87 -0
  38. package/src/render/cli.mjs +40 -1
  39. package/src/schema/index.ts +21 -0
  40. package/src/types/Folder.tsx +2 -0
  41. package/src/types/Model3D.tsx +91 -0
  42. package/src/vision/cli.mjs +63 -50
  43. package/tests/mcp-design-mode.test.ts +100 -0
  44. package/tests/mcp-editor-decisions-mobile.test.ts +35 -0
  45. package/tests/mcp-preview-bridge.test.ts +44 -3
  46. package/tests/mcp-preview-proxy-version.test.mjs +80 -0
  47. package/tests/mcp-preview.test.ts +43 -8
  48. package/tests/mcp-remote-assets.test.ts +17 -0
  49. package/tests/mcp-static-preview.test.ts +1 -1
  50. package/tests/mcp-video-selector.test.ts +55 -0
  51. package/tests/mobile-preview-cli.test.ts +10 -15
  52. package/tests/recipes-catalog.test.ts +141 -0
  53. package/tests/vision-generic-vtt-hooks.test.ts +7 -7
  54. package/tests/vision-normalized-metadata.test.ts +23 -0
@@ -1,4 +1,6 @@
1
1
  import * as React from 'react';
2
+ import ReactMarkdown from 'react-markdown';
3
+ import remarkGfm from 'remark-gfm';
2
4
  import {createRoot} from 'react-dom/client';
3
5
  import {createPortal} from 'react-dom';
4
6
  import type {PlayerRef} from '@remotion/player';
@@ -7,17 +9,106 @@ import {SceneThumbnails} from '../player/components/SceneThumbnails';
7
9
  import {useWebAudioPreview} from './web-audio-preview';
8
10
  import {withoutRecordedNarration} from './audio-preview-tree';
9
11
  import {useBrowserSpeechPreview} from './browser-speech-preview';
12
+ // The question text is stored as base64 UTF-8 in the normal compiled Scene title.
13
+ function QuestionsPanel({data,revisionId}:{data:any;revisionId:string}){
14
+ const scenes=React.useMemo(()=> (data?.children||[]).filter((scene:any)=>scene.type==='scene').map((scene:any,index:number)=>({
15
+ name:String(scene.name||'Q'+(index+1)),id:scene.id,
16
+ markdown:decodeQuestion(String(scene.title||'')),
17
+ })),[data]);
18
+ const [answers,setAnswers]=React.useState<Record<string,string>>({});
19
+ const emit=(next:Record<string,string>)=>window.dispatchEvent(new CustomEvent('markcut:questions-change',{detail:{answers:next}}));
20
+ React.useEffect(()=>{setAnswers({});emit({});},[revisionId]);
21
+ return <section id="markcut-questions" aria-label="Questions" style={{display:'grid',gap:18,padding:'10px 0 18px'}}>
22
+ {scenes.map((q:{name:string;id:string;markdown:string},index:number)=><div key={q.name} className="markcut-question" style={{borderTop:"1px solid #e2e8f0",paddingTop:10}}>
23
+ <div style={{color:'#64748b',fontSize:12,fontWeight:600}}>Q{index+1}</div>
24
+ <div className="markcut-question-md" style={{lineHeight:1.55,overflowWrap:"anywhere"}}><ReactMarkdown remarkPlugins={[remarkGfm]}>{q.markdown}</ReactMarkdown></div>
25
+ <textarea aria-label={'Answer '+(index+1)} placeholder="Your answer…" rows={3} style={{boxSizing:"border-box",width:"100%",minHeight:75,border:"1px solid #b5bdc8",borderRadius:6,padding:9,font:"inherit",resize:"vertical"}} value={answers[q.name]||''}
26
+ onChange={e=>{const next={...answers,[q.name]:e.target.value};setAnswers(next);emit(next);}}/>
27
+ </div>)}
28
+ </section>;
29
+ }
30
+ function decodeQuestion(value:string){
31
+ if(!value.startsWith('md64:'))return value;
32
+ try{return new TextDecoder().decode(Uint8Array.from(atob(value.slice(5)),char=>char.charCodeAt(0)));}
33
+ catch{return 'Question unavailable';}
34
+ }
10
35
  const PLAYER_VERSION='v38';
11
36
  const contextTime=(scene:{start:number;end:number}|undefined,time:number)=>
12
37
  Math.round(Math.max(scene?.start??0,Math.min(scene?.end??time,time))*10)/10;
13
38
  function App(){
14
39
  const [revision,setRevision]=React.useState<any>(()=>(window as any).__markcutRevision||null);
40
+ const [selectedVideo,setSelectedVideo]=React.useState("default");
41
+ const [variantTrees,setVariantTrees]=React.useState<Record<string,any>>({});
42
+ const editorView=selectedVideo==="editor-decisions";
43
+ const [editorTree,setEditorTree]=React.useState<any>(null);
44
+ const [editorError,setEditorError]=React.useState('');
45
+ React.useEffect(()=>{
46
+ let active=true;
47
+ setEditorTree(null);setEditorError('');
48
+ const direct=revision?.editorDecisions;
49
+ if(direct){setEditorTree(direct.root||direct);return;}
50
+ // Published companions are discoverable by the existing content hash.
51
+ // Some embedded hosts replay only compiledUrl/contentHash and omit optional
52
+ // revision metadata: do not silently hide the Editor Decisions view.
53
+ const explicit=revision?.edlCompiledUrl;
54
+ const videoUrl=revision?.compiledUrl;
55
+ try {
56
+ if(!videoUrl)return;
57
+ const expected=new URL(videoUrl);
58
+ if(!expected.pathname.startsWith('/files/_neoy/markcut/cache/'))throw Error('Invalid Video preview URL');
59
+ const hash=revision?.contentHash;
60
+ const inferred=!explicit && typeof hash==='string' && /^[a-f0-9]{64}$/.test(hash);
61
+ const candidate=explicit?new URL(explicit):inferred?new URL('/files/_neoy/markcut/cache/'+hash+'.editor-decisions.json',expected.origin):null;
62
+ if(!candidate)return;
63
+ if(candidate.origin!==expected.origin||!candidate.pathname.startsWith('/files/_neoy/markcut/cache/')||
64
+ !/^[a-f0-9]{64}(?:-[a-f0-9]{16})?[.]json$|^[a-f0-9]{64}[.]editor-decisions[.]json$/.test(candidate.pathname.split('/').pop()||''))
65
+ throw Error('Invalid Editor Decision preview URL');
66
+ fetch(candidate.href,{cache:'force-cache'}).then(async response=>{
67
+ // The companion is optional for ordinary films, but an explicitly
68
+ // declared EDL must report a real error if its published asset is missing.
69
+ if(!response.ok){if(inferred&&response.status===404)return null;throw Error('Editor Decision HTTP '+response.status);}
70
+ return response.json();
71
+ }).then(tree=>{if(active&&tree)setEditorTree(tree.root||tree);})
72
+ .catch(error=>{if(active)setEditorError(String(error));});
73
+ }catch(error){setEditorError(String(error));}
74
+ return ()=>{active=false;};
75
+ },[revision?.revisionId,revision?.edlCompiledUrl,revision?.editorDecisions,revision?.contentHash,revision?.compiledUrl]);
76
+ React.useEffect(()=>{if(!(window as any).__markcutDesignMode)setSelectedVideo("default");},[revision?.revisionId]);
77
+ React.useEffect(()=>{
78
+ // Host and Neo Mobile can provide variants inline. Hosted previews also
79
+ // discover a published companion when optional revision metadata is omitted.
80
+ let active=true;setVariantTrees({});
81
+ if(!revision)return;
82
+ if(revision.variants && typeof revision.variants==="object"&&!Array.isArray(revision.variants)){
83
+ setVariantTrees(revision.variants);return;
84
+ }
85
+ const hash=revision.contentHash;
86
+ if(typeof hash!=="string"||!/^[a-f0-9]{64}$/.test(hash)||!revision.compiledUrl)return;
87
+ try{
88
+ const base=new URL(revision.compiledUrl);
89
+ if(!base.pathname.startsWith('/files/_neoy/markcut/cache/'))return;
90
+ const url=new URL('/files/_neoy/markcut/cache/'+hash+'.variants.json',base.origin);
91
+ fetch(url.href,{cache:'force-cache'}).then(async response=>{
92
+ if(response.status===404)return null;
93
+ if(!response.ok)throw Error('Variant HTTP '+response.status);
94
+ return response.json();
95
+ }).then(value=>{
96
+ if(active&&value&&typeof value==='object'&&!Array.isArray(value))
97
+ setVariantTrees(value);
98
+ }).catch(error=>{if(active)console.warn('Video variants unavailable:',error);});
99
+ }catch{}
100
+ return ()=>{active=false;};
101
+ },[revision?.revisionId,revision?.contentHash,revision?.compiledUrl,revision?.variants]);
102
+ React.useEffect(()=>{
103
+ window.dispatchEvent(new CustomEvent('markcut:edl-view',{detail:{active:editorView}}));
104
+ },[revision?.revisionId,selectedVideo]);
15
105
  const ref=React.useRef<PlayerRef|null>(null);
16
106
  const [currentTime,setCurrentTime]=React.useState(0);
107
+
17
108
  const [browserTts,setBrowserTts]=React.useState(true);
18
- const [compact,setCompact]=React.useState(()=>window.matchMedia('(max-width: 640px), (max-height: 520px)').matches);
109
+ const [compact,setCompact]=React.useState(()=>window.matchMedia('(max-width: 640px), (max-width: 900px) and (max-height: 520px)').matches);
19
110
  React.useEffect(()=>{
20
- const query=window.matchMedia('(max-width: 640px), (max-height: 520px)');
111
+ const query=window.matchMedia('(max-width: 640px), (max-width: 900px) and (max-height: 520px)');
21
112
  const update=()=>setCompact(query.matches);
22
113
  query.addEventListener('change',update);
23
114
  return ()=>query.removeEventListener('change',update);
@@ -36,7 +127,10 @@ function App(){
36
127
  return ()=>window.removeEventListener('markcut:spots-change',listener);
37
128
  },[]);
38
129
  React.useEffect(()=>{const receive=(e:Event)=>setRevision((e as CustomEvent).detail);window.addEventListener('markcut:revision',receive);return ()=>window.removeEventListener('markcut:revision',receive)},[]);
39
- const data=revision?.compiled?.root||revision?.compiled;
130
+ const data=editorView&&editorTree?editorTree:
131
+ selectedVideo!=="default"&&variantTrees[selectedVideo]?
132
+ (variantTrees[selectedVideo].root||variantTrees[selectedVideo]):
133
+ (revision?.compiled?.root||revision?.compiled);
40
134
  const useBrowserTts=browserTts&&Boolean(data?.subtitle?.src);
41
135
  const {playbackRoot:generatedRoot}=useWebAudioPreview(data,ref);
42
136
  const playbackRoot=React.useMemo(()=>{
@@ -45,6 +139,20 @@ function App(){
45
139
  },[data,generatedRoot,useBrowserTts]);
46
140
  const {caption}=useBrowserSpeechPreview(data,ref,useBrowserTts);
47
141
  const fps=data?.fps||30;
142
+ React.useEffect(()=>{
143
+ if(!(window as any).__markcutDesignMode || !revision)return;
144
+ const saved=Number((window as any).__markcutDesignRestoreTime);
145
+ if(!Number.isFinite(saved) || saved<=0)return;
146
+ (window as any).__markcutDesignRestoreTime=0;
147
+ const handle=window.setTimeout(()=>{
148
+ const total=Math.max(0,Number((playbackRoot as any)?.durationInSeconds)||0);
149
+ const time=Math.max(0,Math.min(saved,total||saved));
150
+ ref.current?.seekTo(Math.round(time*(fps)));
151
+ setCurrentTime(time);
152
+ },200);
153
+ return ()=>window.clearTimeout(handle);
154
+ },[revision?.revisionId,playbackRoot,fps]);
155
+
48
156
  const scenes=React.useMemo(()=>{
49
157
  const children=(data?.children||[]).filter((x:any)=>x.type==='scene'&&x.visible!==false);
50
158
  const overlap=data?.transition?Math.max(0,Number(data?.transitionTime)||0):0;
@@ -61,7 +169,7 @@ function App(){
61
169
  const listener=(e:any)=>{if(typeof e.detail?.frame==='number')setCurrentTime(e.detail.frame/fps);};
62
170
  player.addEventListener('frameupdate',listener);
63
171
  return ()=>player.removeEventListener('frameupdate',listener);
64
- },[revision?.revisionId,playbackRoot,fps]);
172
+ },[revision?.revisionId,selectedVideo,playbackRoot,fps]);
65
173
  React.useEffect(()=>{
66
174
  const active=[...scenes].reverse().find(scene=>currentTime>=scene.start);
67
175
  (window as any).__markcutPlaybackContext={
@@ -81,10 +189,10 @@ function App(){
81
189
  };
82
190
  find();timer=window.setInterval(find,150);
83
191
  return ()=>window.clearInterval(timer);
84
- },[revision?.revisionId]);
192
+ },[revision?.revisionId,selectedVideo]);
85
193
  React.useEffect(()=>{
86
194
  window.dispatchEvent(new CustomEvent('markcut:scene-change',{detail:{sceneId:activeScene?.id||null,sceneName:activeScene?.name||null,sceneStart:activeScene?.start||0,timeSeconds:contextTime(activeScene,currentTime)}}));
87
- },[revision?.revisionId,activeScene?.id,activeScene?.name]);
195
+ },[revision?.revisionId,selectedVideo,activeScene?.id,activeScene?.name]);
88
196
  React.useEffect(()=>{
89
197
  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);
90
198
  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);}
@@ -94,21 +202,35 @@ function App(){
94
202
  },[scenes,fps]);
95
203
  if(!revision)return <div id="remotion-waiting">Player {PLAYER_VERSION} · Waiting for compiled scenes…</div>;
96
204
  if(!data)return <div>Missing compiled scene tree</div>;
205
+ if(revision.review?.mode==='questions')return <QuestionsPanel key={revision.revisionId} data={data} revisionId={revision.revisionId}/>;
97
206
  const videoName=String(revision.title||revision.videoTitle||revision.path?.split('/').pop()?.replace(/\.md$/i,'').replace(/[-_]+/g,' ')||'Video');
207
+ const variantNames=Object.keys(variantTrees).filter(name=>name!=="default"&&name!=="editor-decisions");
208
+ const choices=["default",...variantNames,...(editorTree?["editor-decisions"]:[])];
209
+ const selector=<select id="markcut-video-selector" aria-label="Video selector" title="Select video"
210
+ value={choices.includes(selectedVideo)?selectedVideo:"default"}
211
+ onChange={event=>{setSelectedVideo(event.currentTarget.value);setCurrentTime(0);}}
212
+ style={{minWidth:105,maxWidth:190,padding:"6px 26px 6px 9px",border:"1px solid #a8b3c1",borderRadius:7,
213
+ background:"var(--markcut-select-bg, #f7f9fc)",color:"var(--markcut-select-fg, #17202a)",
214
+ font:"inherit",fontSize:12,textOverflow:"ellipsis",cursor:"pointer"}}>
215
+ {choices.map(name=><option value={name} key={name}>{name==="default"?"Original":name==="editor-decisions"?"Editor Decisions":name}</option>)}
216
+ </select>;
217
+ const selectorSlot=document.getElementById("markcut-video-selector-slot");
98
218
  return <div id="remotion-preview" data-revision={revision.revisionId}>
219
+ {choices.length>1&&(selectorSlot?createPortal(selector,selectorSlot):
220
+ <div id="markcut-video-selector-slot" style={{alignSelf:"flex-end",margin:"6px 8px"}}>{selector}</div>)}
99
221
  {Boolean(data?.subtitle?.src)&&document.getElementById("header-tts")&&createPortal(
100
222
  <label style={{display:"flex",gap:5,alignItems:"center",fontSize:12,whiteSpace:"nowrap",cursor:"pointer"}} title="Use browser narration with captions from the script">
101
223
  <input type="checkbox" checked={useBrowserTts} disabled={!data?.subtitle?.src} onChange={e=>setBrowserTts(e.target.checked)}/>
102
224
  Browser TTS
103
225
  </label>,document.getElementById("header-tts")!)}
104
- <div id="remotion-canvas" style={{position:'relative',width:'100%',aspectRatio:`${data.width||1080}/${data.height||1920}`,maxHeight:'65vh',margin:'auto', '--markcut-player-ratio':String((data.width||1080)/(data.height||1920))} as React.CSSProperties}>
105
- <SharedPlayer key={revision.revisionId} root={playbackRoot} playerRef={ref} numberOfSharedAudioTags={0} showPlaybackRateControl={!compact} style={{width:'100%',height:'100%'}} />
226
+ <div id="remotion-canvas" style={{position:'relative',aspectRatio:`${data.width||1080}/${data.height||1920}`,margin:'auto', '--markcut-player-ratio':String((data.width||1080)/(data.height||1920))} as React.CSSProperties}>
227
+ <SharedPlayer key={revision.revisionId+":"+selectedVideo} root={playbackRoot} playerRef={ref} numberOfSharedAudioTags={0} showPlaybackRateControl={!compact} style={{width:'100%',height:'100%'}} />
106
228
  {useBrowserTts&&caption&&<div id="browser-tts-caption" aria-live="off" style={{position:'absolute',bottom:50,left:12,right:12,zIndex:5,pointerEvents:'none',textAlign:'center'}}>
107
229
  <span style={{display:'inline-block',maxWidth:'90%',padding:'5px 10px',borderRadius:5,background:'rgba(0,0,0,.72)',color:'#fff',fontSize:'clamp(12px,1.6vw,18px)',lineHeight:1.4,textShadow:'0 1px 2px #000',overflowWrap:'anywhere'}}>{caption}</span>
108
230
  </div>}
109
231
  </div>
110
- <SceneThumbnails sceneData={scenes} commentedScenes={commentedScenes} currentTime={currentTime} onSeek={t=>{ref.current?.seekTo(Math.round(t*fps));setCurrentTime(t);}} />
111
- {seekBar&&createPortal(<>
232
+ <SceneThumbnails sceneData={scenes} commentedScenes={editorView?[]:commentedScenes} currentTime={currentTime} onSeek={t=>{ref.current?.seekTo(Math.round(t*fps));setCurrentTime(t);}} />
233
+ {!editorView&&seekBar&&createPortal(<>
112
234
  {spotMarkers.map(note=>{
113
235
  const duration=Math.max(0.001,Number(data.durationInSeconds)||scenes.at(-1)?.end||1);
114
236
  const time=Number(note.context.timeSeconds)||0;
@@ -50,6 +50,8 @@ registerAppTool(
50
50
  description: "Compile and publish an immutable Markcut preview revision for this ChatGPT conversation. Review delivery defaults to ui/message, or submits an authorized caller-bound event when explicitly configured. Event-mode decisions use the caller-provided event envelope; Markcut does not interpret the event type or payload.",
51
51
  inputSchema: z.object({
52
52
  path: z.string().describe("Absolute .md path or NeoY HTTPS mounted file URL; Neo Wrapper also accepts single local image/audio/video files"),
53
+ title: z.string().trim().min(1).max(160).optional().describe("Optional display title for Preview and mobile Review Inbox."),
54
+ mode: z.enum(["questions"]).optional().describe("Render scene titles as Markdown questions, with answer fields and only Submit."),
53
55
  readonly: z.boolean().optional().describe("View-only preview: no review controls, Relay binding, Git checkpoint, or mobile review notification."),
54
56
  review: z.object({delivery:z.enum(["text","event"]).optional(),eventTemplate:z.object({type:z.string(),source:z.string(),data:z.record(z.string(),z.unknown()),responseKey:z.string().optional()}).optional(),
55
57
  }).optional(),
@@ -58,11 +60,11 @@ registerAppTool(
58
60
  ui: { resourceUri: RESOURCE_URI },
59
61
  },
60
62
  },
61
- async ({ path, review, readonly }) => {
63
+ async ({ path, title, mode, review, readonly }) => {
62
64
  try {
63
65
  if (readonly && review !== undefined)
64
66
  throw new Error("Read-only preview cannot request Relay or review delivery");
65
- const config={...normalizeReviewConfig(review),...(readonly ? {readonly:true} : {})};
67
+ const config={...normalizeReviewConfig(review),...(readonly ? {readonly:true} : {}),...(title ? {title} : {}),...(mode ? {mode} : {})};
66
68
  const operation=startCompileOperation(path,config);
67
69
  const payload=operation;
68
70
  return {
@@ -522,11 +522,9 @@ function PlayerApp() {
522
522
  sseConnected={sseConnected}
523
523
  sceneInfo={mode === "label" ? labelSceneInfo : undefined}
524
524
  locale={locale}
525
+ selector={<VariantBar />}
525
526
  />
526
527
 
527
- {/* ── Variant switcher ── */}
528
- <VariantBar />
529
-
530
528
  {/* ── Player frame ── */}
531
529
  <div id="player-frame" style={{ flex: 1, width: "100%", maxWidth: 480, minHeight: 0 }}>
532
530
  <SharedPlayer root={data} playerRef={playerRef} style={{ width: "100%", height: "100%" }} autoPlay={autoPlay} />