@lalalic/markcut 3.2.61 → 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.
@@ -73,7 +73,7 @@ function App(){
73
73
  }catch(error){setEditorError(String(error));}
74
74
  return ()=>{active=false;};
75
75
  },[revision?.revisionId,revision?.edlCompiledUrl,revision?.editorDecisions,revision?.contentHash,revision?.compiledUrl]);
76
- React.useEffect(()=>{setSelectedVideo("default");},[revision?.revisionId]);
76
+ React.useEffect(()=>{if(!(window as any).__markcutDesignMode)setSelectedVideo("default");},[revision?.revisionId]);
77
77
  React.useEffect(()=>{
78
78
  // Host and Neo Mobile can provide variants inline. Hosted previews also
79
79
  // discover a published companion when optional revision metadata is omitted.
@@ -104,6 +104,7 @@ function App(){
104
104
  },[revision?.revisionId,selectedVideo]);
105
105
  const ref=React.useRef<PlayerRef|null>(null);
106
106
  const [currentTime,setCurrentTime]=React.useState(0);
107
+
107
108
  const [browserTts,setBrowserTts]=React.useState(true);
108
109
  const [compact,setCompact]=React.useState(()=>window.matchMedia('(max-width: 640px), (max-width: 900px) and (max-height: 520px)').matches);
109
110
  React.useEffect(()=>{
@@ -138,6 +139,20 @@ function App(){
138
139
  },[data,generatedRoot,useBrowserTts]);
139
140
  const {caption}=useBrowserSpeechPreview(data,ref,useBrowserTts);
140
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
+
141
156
  const scenes=React.useMemo(()=>{
142
157
  const children=(data?.children||[]).filter((x:any)=>x.type==='scene'&&x.visible!==false);
143
158
  const overlap=data?.transition?Math.max(0,Number(data?.transitionTime)||0):0;
@@ -71,6 +71,8 @@ Commands:
71
71
  verify <file> Parse + validate descriptive file and linked EDL\n edl <video.md> [--output <file>] Convert Editor Decision sidecar to playable Markcut Markdown
72
72
 
73
73
  preview <file.json|.md> Open player with live preview
74
+ --design Open NeoY standalone player, live-recompile video.md and split with ChatGPT
75
+ --no-split Open NeoY design viewer without WebHelm Split View
74
76
  --delivery event Headless human review via Neo Mobile (requires .md)
75
77
  --event-template <file.json> Relay task.interactive_decision envelope from current Task
76
78
  (No phone URL) Neo Master stores and notifies through APNs
@@ -0,0 +1,100 @@
1
+ import {describe,it,expect} from 'vitest';
2
+ import {mkdtemp,writeFile,readFile,rm,mkdir} from 'node:fs/promises';
3
+ import {tmpdir} from 'node:os';
4
+ import {join} from 'node:path';
5
+ import vm from 'node:vm';
6
+ import {webcrypto} from 'node:crypto';
7
+ import {parseDesignArgs,designSourceUrl,designViewerUrl,publishDesignViewer,designInputStamp,compileDesign} from '../src/mcp/design-cli.mjs';
8
+ import {buildPreviewBridgeScript} from '../src/mcp/bridge.mjs';
9
+
10
+ const hash='a'.repeat(64);
11
+ const digest='b'.repeat(64);
12
+
13
+ describe('NeoY standalone Markcut design mode',()=>{
14
+ it('uses only a mounted video.md path, not a Session or Revision ID',()=>{
15
+ expect(parseDesignArgs(['preview','/tmp/video.md','--design','--no-split'])).toEqual({file:'/tmp/video.md',split:false});
16
+ expect(()=>parseDesignArgs(['preview','/tmp/video.md','--design','--delivery','event'])).toThrow();
17
+ expect(()=>parseDesignArgs(['preview','/tmp/video.json','--design'])).toThrow();
18
+ const origin='https://neoy.example.test';
19
+ const file='/mounted/vlog/video.md';
20
+ const path=designSourceUrl(file,origin,()=>origin+'/files/vlog/video.md');
21
+ expect(path).toBe('/files/vlog/video.md');
22
+ const url=designViewerUrl(path,origin);
23
+ expect(new URL(url).searchParams.get('path')).toBe(path);
24
+ expect(url).not.toMatch(/session|revision|review/);
25
+ expect(()=>designSourceUrl(file,origin,()=>undefined)).toThrow(/NeoY file mount/);
26
+ expect(()=>designViewerUrl('/files/_neoy/markcut/cache/evil.md',origin)).toThrow();
27
+ });
28
+ it('publishes the same player without creating a second viewer',async()=>{
29
+ const root=await mkdtemp(join(tmpdir(),'markcut-design-ui-'));
30
+ try{
31
+ const html='<!doctype html><html><body>Markcut existing player</body></html>';
32
+ const file=publishDesignViewer({root,html});
33
+ expect(await readFile(file,'utf8')).toBe(html);
34
+ expect(publishDesignViewer({root,html})).toBe(file);
35
+ }finally{await rm(root,{force:true,recursive:true});}
36
+ });
37
+ it('detects source and editor-decision sidecar edits',async()=>{
38
+ const root=await mkdtemp(join(tmpdir(),'markcut-design-watch-'));
39
+ try{
40
+ const file=join(root,'video.md');
41
+ await writeFile(file,'# video\n## Intro\n- component duration:1 jsx:"Hello"\n---\nedl: video.edl.json\n---\n');
42
+ const first=designInputStamp(file);
43
+ await writeFile(join(root,'video.edl.json'),'{}');
44
+ expect(designInputStamp(file)).not.toBe(first);
45
+ const second=designInputStamp(file);
46
+ await writeFile(file,'# video\n## Intro\n- component duration:1 jsx:"World"\n');
47
+ expect(designInputStamp(file)).not.toBe(second);
48
+ }finally{await rm(root,{force:true,recursive:true});}
49
+ });
50
+ it('observes existing Markcut compilation result instead of publishing a review',async()=>{
51
+ const root=await mkdtemp(join(tmpdir(),'markcut-design-compile-'));
52
+ try{
53
+ await mkdir(join(root,'operations'));
54
+ const output={revisionId:hash,contentHash:hash,compiledUrl:'https://neoy.example.test/files/_neoy/markcut/cache/'+hash+'.json'};
55
+ const result=await compileDesign('/tmp/video.md','/files/vlog/video.md',{
56
+ root,start:(input,review)=>{
57
+ expect(input).toBe('/files/vlog/video.md');
58
+ expect(review).toEqual({delivery:'text'});
59
+ void writeFile(join(root,'operations','test.json'),JSON.stringify({state:'ready',result:output}));
60
+ return {operationId:'test'};
61
+ },limitMs:2000,
62
+ });
63
+ expect(result).toEqual(output);
64
+ }finally{await rm(root,{force:true,recursive:true});}
65
+ });
66
+ it('loads and refreshes the original player without MCP initialize or review messages',async()=>{
67
+ const path='/files/vlog/video.md';
68
+ let current=hash;
69
+ let poll:()=>unknown=()=>{};
70
+ const dispatched:any[]=[];
71
+ const node=()=>({value:'',hidden:false,disabled:false,textContent:'',style:{display:''},onclick:null,
72
+ addEventListener(){},replaceChildren(){}});
73
+ const elements=new Map<string,ReturnType<typeof node>>();
74
+ const document={body:{classList:{add:()=>{}}},querySelector:()=>node(),getElementById:(id:string)=>{
75
+ if(!elements.has(id))elements.set(id,node());return elements.get(id)!;
76
+ }};
77
+ const window:any={
78
+ parent:{postMessage:(m:any)=>dispatched.push(m)},
79
+ addEventListener(){},dispatchEvent:(event:any)=>{dispatched.push(event);},
80
+ setInterval:(callback:()=>unknown)=>{poll=callback;return 1;},
81
+ };
82
+ const fetch=async (url:string)=>{
83
+ if(url.includes('/revisions/'))return {ok:true,json:async()=>({requestedPath:path,revisionId:current,contentHash:current,
84
+ compiledUrl:'https://neoy.example.test/files/_neoy/markcut/cache/'+current+'.json'})};
85
+ if(url.includes('/cache/'))return {ok:true,json:async()=>({width:640,height:360,fps:30,children:[]})};
86
+ throw Error('Unexpected URL '+url);
87
+ };
88
+ const context=vm.createContext({window,document,location:{pathname:'/files/_neoy/markcut/design.html',search:'?path='+encodeURIComponent(path)},
89
+ fetch,crypto:webcrypto,TextEncoder,URL,URLSearchParams,setTimeout,clearTimeout,CustomEvent:class {type:string;detail:any;
90
+ constructor(type:string,options:any){this.type=type;this.detail=options.detail;}}});
91
+ vm.runInContext(buildPreviewBridgeScript().replaceAll('__MARKCUT_ORIGIN__',JSON.stringify('https://neoy.example.test')),context);
92
+ await new Promise(done=>setTimeout(done,50));
93
+ expect(window.__markcutRevision?.contentHash).toBe(hash);
94
+ expect(window.__markcutDesignMode).toBe(true);
95
+ expect(dispatched.some(x=>x.method==='ui/initialize'||x.method==='ui/message')).toBe(false);
96
+ current=digest;await poll();await new Promise(done=>setTimeout(done,50));
97
+ expect(window.__markcutRevision?.contentHash).toBe(digest);
98
+ expect(dispatched.some(x=>x.method==='ui/message')).toBe(false);
99
+ });
100
+ });
@@ -35,7 +35,9 @@ describe('Markcut Remotion MCP App',()=>{
35
35
 
36
36
  expect(html).not.toContain('id="remotion-bundle"');
37
37
  // The generic event contract requires client-side identity and reserved-field validation.
38
- expect(html.length).toBeLessThan(33000);
38
+ // Shared Previewer now also handles standalone source-path polling. The
39
+ // React/Remotion bundle remains a separate, content-addressed HTTPS asset.
40
+ expect(html.length).toBeLessThan(35000);
39
41
  expect(html).not.toContain('<video id="video-player"');
40
42
  expect(html).not.toContain('data:video/mp4');
41
43
  expect(html).not.toContain('127.0.0.1');
@@ -71,8 +73,8 @@ describe('Markcut Remotion MCP App',()=>{
71
73
  expect(audio).toContain("p.addEventListener('play',play)");
72
74
  });
73
75
  it('maps every historical preview version and the stable URI to the latest',()=>{
74
- expect(PREVIEW_VERSION_NUMBER).toBe(55);
75
- expect(RESOURCE_URI).toBe('ui://markcut/video-preview-v55.html');
76
+ expect(PREVIEW_VERSION_NUMBER).toBe(56);
77
+ expect(RESOURCE_URI).toBe('ui://markcut/video-preview-v56.html');
76
78
  expect(STABLE_RESOURCE_URI).toBe('ui://markcut/video-preview.html');
77
79
  expect(LEGACY_RESOURCE_URIS).toHaveLength(PREVIEW_VERSION_NUMBER);
78
80
  expect(new Set([RESOURCE_URI,...LEGACY_RESOURCE_URIS]).size).toBe(PREVIEW_VERSION_NUMBER+1);