@lalalic/markcut 3.2.60 → 3.2.61

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 (52) hide show
  1. package/README.md +20 -4
  2. package/bin/markcut +10 -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 +5 -1
  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 +46 -9
  21. package/src/mcp/compile-worker.mjs +2 -2
  22. package/src/mcp/mobile-review-cli.mjs +40 -33
  23. package/src/mcp/preview-mobile.css +21 -8
  24. package/src/mcp/preview.mjs +95 -57
  25. package/src/mcp/remote-assets.mjs +85 -7
  26. package/src/mcp/remotion-app.bundle.js +5013 -1117
  27. package/src/mcp/remotion-app.tsx +117 -10
  28. package/src/mcp/server.mjs +4 -2
  29. package/src/player/browser.tsx +1 -3
  30. package/src/player/bundle/player.js +73054 -17357
  31. package/src/player/components/HeaderBar.tsx +3 -1
  32. package/src/player/components/VariantBar.tsx +20 -21
  33. package/src/player/pipeline.mjs +133 -77
  34. package/src/player/server.mjs +43 -23
  35. package/src/recipes/catalog.mjs +115 -0
  36. package/src/recipes/cli.mjs +87 -0
  37. package/src/render/cli.mjs +38 -1
  38. package/src/schema/index.ts +21 -0
  39. package/src/types/Folder.tsx +2 -0
  40. package/src/types/Model3D.tsx +91 -0
  41. package/src/vision/cli.mjs +63 -50
  42. package/tests/mcp-editor-decisions-mobile.test.ts +35 -0
  43. package/tests/mcp-preview-bridge.test.ts +44 -3
  44. package/tests/mcp-preview-proxy-version.test.mjs +80 -0
  45. package/tests/mcp-preview.test.ts +41 -8
  46. package/tests/mcp-remote-assets.test.ts +17 -0
  47. package/tests/mcp-static-preview.test.ts +1 -1
  48. package/tests/mcp-video-selector.test.ts +55 -0
  49. package/tests/mobile-preview-cli.test.ts +10 -15
  50. package/tests/recipes-catalog.test.ts +141 -0
  51. package/tests/vision-generic-vtt-hooks.test.ts +7 -7
  52. 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,105 @@ 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(()=>{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);
17
107
  const [browserTts,setBrowserTts]=React.useState(true);
18
- const [compact,setCompact]=React.useState(()=>window.matchMedia('(max-width: 640px), (max-height: 520px)').matches);
108
+ const [compact,setCompact]=React.useState(()=>window.matchMedia('(max-width: 640px), (max-width: 900px) and (max-height: 520px)').matches);
19
109
  React.useEffect(()=>{
20
- const query=window.matchMedia('(max-width: 640px), (max-height: 520px)');
110
+ const query=window.matchMedia('(max-width: 640px), (max-width: 900px) and (max-height: 520px)');
21
111
  const update=()=>setCompact(query.matches);
22
112
  query.addEventListener('change',update);
23
113
  return ()=>query.removeEventListener('change',update);
@@ -36,7 +126,10 @@ function App(){
36
126
  return ()=>window.removeEventListener('markcut:spots-change',listener);
37
127
  },[]);
38
128
  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;
129
+ const data=editorView&&editorTree?editorTree:
130
+ selectedVideo!=="default"&&variantTrees[selectedVideo]?
131
+ (variantTrees[selectedVideo].root||variantTrees[selectedVideo]):
132
+ (revision?.compiled?.root||revision?.compiled);
40
133
  const useBrowserTts=browserTts&&Boolean(data?.subtitle?.src);
41
134
  const {playbackRoot:generatedRoot}=useWebAudioPreview(data,ref);
42
135
  const playbackRoot=React.useMemo(()=>{
@@ -61,7 +154,7 @@ function App(){
61
154
  const listener=(e:any)=>{if(typeof e.detail?.frame==='number')setCurrentTime(e.detail.frame/fps);};
62
155
  player.addEventListener('frameupdate',listener);
63
156
  return ()=>player.removeEventListener('frameupdate',listener);
64
- },[revision?.revisionId,playbackRoot,fps]);
157
+ },[revision?.revisionId,selectedVideo,playbackRoot,fps]);
65
158
  React.useEffect(()=>{
66
159
  const active=[...scenes].reverse().find(scene=>currentTime>=scene.start);
67
160
  (window as any).__markcutPlaybackContext={
@@ -81,10 +174,10 @@ function App(){
81
174
  };
82
175
  find();timer=window.setInterval(find,150);
83
176
  return ()=>window.clearInterval(timer);
84
- },[revision?.revisionId]);
177
+ },[revision?.revisionId,selectedVideo]);
85
178
  React.useEffect(()=>{
86
179
  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]);
180
+ },[revision?.revisionId,selectedVideo,activeScene?.id,activeScene?.name]);
88
181
  React.useEffect(()=>{
89
182
  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
183
  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 +187,35 @@ function App(){
94
187
  },[scenes,fps]);
95
188
  if(!revision)return <div id="remotion-waiting">Player {PLAYER_VERSION} · Waiting for compiled scenes…</div>;
96
189
  if(!data)return <div>Missing compiled scene tree</div>;
190
+ if(revision.review?.mode==='questions')return <QuestionsPanel key={revision.revisionId} data={data} revisionId={revision.revisionId}/>;
97
191
  const videoName=String(revision.title||revision.videoTitle||revision.path?.split('/').pop()?.replace(/\.md$/i,'').replace(/[-_]+/g,' ')||'Video');
192
+ const variantNames=Object.keys(variantTrees).filter(name=>name!=="default"&&name!=="editor-decisions");
193
+ const choices=["default",...variantNames,...(editorTree?["editor-decisions"]:[])];
194
+ const selector=<select id="markcut-video-selector" aria-label="Video selector" title="Select video"
195
+ value={choices.includes(selectedVideo)?selectedVideo:"default"}
196
+ onChange={event=>{setSelectedVideo(event.currentTarget.value);setCurrentTime(0);}}
197
+ style={{minWidth:105,maxWidth:190,padding:"6px 26px 6px 9px",border:"1px solid #a8b3c1",borderRadius:7,
198
+ background:"var(--markcut-select-bg, #f7f9fc)",color:"var(--markcut-select-fg, #17202a)",
199
+ font:"inherit",fontSize:12,textOverflow:"ellipsis",cursor:"pointer"}}>
200
+ {choices.map(name=><option value={name} key={name}>{name==="default"?"Original":name==="editor-decisions"?"Editor Decisions":name}</option>)}
201
+ </select>;
202
+ const selectorSlot=document.getElementById("markcut-video-selector-slot");
98
203
  return <div id="remotion-preview" data-revision={revision.revisionId}>
204
+ {choices.length>1&&(selectorSlot?createPortal(selector,selectorSlot):
205
+ <div id="markcut-video-selector-slot" style={{alignSelf:"flex-end",margin:"6px 8px"}}>{selector}</div>)}
99
206
  {Boolean(data?.subtitle?.src)&&document.getElementById("header-tts")&&createPortal(
100
207
  <label style={{display:"flex",gap:5,alignItems:"center",fontSize:12,whiteSpace:"nowrap",cursor:"pointer"}} title="Use browser narration with captions from the script">
101
208
  <input type="checkbox" checked={useBrowserTts} disabled={!data?.subtitle?.src} onChange={e=>setBrowserTts(e.target.checked)}/>
102
209
  Browser TTS
103
210
  </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%'}} />
211
+ <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}>
212
+ <SharedPlayer key={revision.revisionId+":"+selectedVideo} root={playbackRoot} playerRef={ref} numberOfSharedAudioTags={0} showPlaybackRateControl={!compact} style={{width:'100%',height:'100%'}} />
106
213
  {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
214
  <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
215
  </div>}
109
216
  </div>
110
- <SceneThumbnails sceneData={scenes} commentedScenes={commentedScenes} currentTime={currentTime} onSeek={t=>{ref.current?.seekTo(Math.round(t*fps));setCurrentTime(t);}} />
111
- {seekBar&&createPortal(<>
217
+ <SceneThumbnails sceneData={scenes} commentedScenes={editorView?[]:commentedScenes} currentTime={currentTime} onSeek={t=>{ref.current?.seekTo(Math.round(t*fps));setCurrentTime(t);}} />
218
+ {!editorView&&seekBar&&createPortal(<>
112
219
  {spotMarkers.map(note=>{
113
220
  const duration=Math.max(0.001,Number(data.durationInSeconds)||scenes.at(-1)?.end||1);
114
221
  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} />