@lalalic/markcut 3.2.61 → 3.2.63

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;
@@ -7,6 +7,7 @@ import {normalizeReviewConfig} from "./review-delivery.mjs";
7
7
  import {publishPreviewRevision,publishPlayerBundle,publicOrigin} from "./remote-assets.mjs";
8
8
  import {fileURLToPath} from "node:url";
9
9
  import {startCompileOperation} from "./compile-operation.mjs";
10
+ import {designViewerUrl,publishDesignViewer} from "./design-viewer.mjs";
10
11
  import {
11
12
  TOOL_NAME, RESOURCE_URI, LEGACY_RESOURCE_URIS, buildPreviewResourceResult, previewCsp, getPreviewMedia, stopManagedVideoPreview,
12
13
  } from "./preview.mjs";
@@ -47,7 +48,7 @@ registerAppTool(
47
48
  server,
48
49
  TOOL_NAME,
49
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
+ description: "Compile and publish Markcut preview from video.md. With readonly:true, publish without review; mounted sources return designUrl for a separate NeoY player. WebHelm/browser lifecycle is caller-owned. With review enabled, use ui/message or a caller-bound event envelope; Markcut does not interpret event type or payload.",
51
52
  inputSchema: z.object({
52
53
  path: z.string().describe("Absolute .md path or NeoY HTTPS mounted file URL; Neo Wrapper also accepts single local image/audio/video files"),
53
54
  title: z.string().trim().min(1).max(160).optional().describe("Optional display title for Preview and mobile Review Inbox."),
@@ -66,7 +67,11 @@ registerAppTool(
66
67
  throw new Error("Read-only preview cannot request Relay or review delivery");
67
68
  const config={...normalizeReviewConfig(review),...(readonly ? {readonly:true} : {}),...(title ? {title} : {}),...(mode ? {mode} : {})};
68
69
  const operation=startCompileOperation(path,config);
69
- const payload=operation;
70
+ const designUrl=designViewerUrl(operation.path);
71
+ // Only publish the standalone HTML when a mounted source needs it;
72
+ // provider startup and ordinary unmounted previews stay independent.
73
+ if(designUrl)publishDesignViewer();
74
+ const payload={...operation,...(designUrl?{designUrl}:{})};
70
75
  return {
71
76
  content: [{ type: "text", text: `Compilation started: ${operation.path}` }],
72
77
  structuredContent: payload,
@@ -0,0 +1,80 @@
1
+ import {describe,it,expect} from 'vitest';
2
+ import {mkdtemp,readFile,rm} from 'node:fs/promises';
3
+ import {tmpdir} from 'node:os';
4
+ import {join} from 'node:path';
5
+ import {readFileSync} from 'node:fs';
6
+ import vm from 'node:vm';
7
+ import {webcrypto} from 'node:crypto';
8
+ import {designViewerUrl,publishDesignViewer} from '../src/mcp/design-viewer.mjs';
9
+ import {buildPreviewBridgeScript} from '../src/mcp/bridge.mjs';
10
+
11
+ const hash='a'.repeat(64);
12
+ const digest='b'.repeat(64);
13
+
14
+ describe('NeoY standalone Markcut design mode',()=>{
15
+ it('returns a viewer URL only for an existing mounted video.md',()=>{
16
+ const origin='https://neoy.example.test';
17
+ const file='/mounted/vlog/video.md';
18
+ const url=designViewerUrl(file,origin,()=>origin+'/files/vlog/video.md');
19
+ expect(new URL(url!).searchParams.get('path')).toBe('/files/vlog/video.md');
20
+ expect(url).not.toMatch(/session|revision|review/);
21
+ expect(designViewerUrl(file,origin,()=>null)).toBeNull();
22
+ expect(()=>designViewerUrl(file,origin,()=>origin+'/files/_neoy/markcut/cache/evil.md')).toThrow();
23
+ expect(()=>designViewerUrl(file,origin,()=>origin+'/files/vlog/../secret.md')).toThrow();
24
+ });
25
+ it('publishes the same player without creating a second viewer',async()=>{
26
+ const root=await mkdtemp(join(tmpdir(),'markcut-design-ui-'));
27
+ try{
28
+ const html='<!doctype html><html><body>Markcut existing player</body></html>';
29
+ const file=publishDesignViewer({root,html});
30
+ expect(await readFile(file,'utf8')).toBe(html);
31
+ expect(publishDesignViewer({root,html})).toBe(file);
32
+ }finally{await rm(root,{force:true,recursive:true});}
33
+ });
34
+ it('uses the existing preview provider and does not couple Markcut CLI to browser lifecycle',()=>{
35
+ const server=readFileSync(new URL('../src/mcp/server.mjs',import.meta.url),'utf8');
36
+ const cli=readFileSync(new URL('../bin/markcut',import.meta.url),'utf8');
37
+ const viewer=readFileSync(new URL('../src/mcp/design-viewer.mjs',import.meta.url),'utf8');
38
+ expect(server).toContain('designUrl=designViewerUrl(operation.path)');
39
+ expect(server).toContain('if(designUrl)publishDesignViewer();');
40
+ expect(server).toContain('readonly');
41
+ expect(cli).not.toContain('--design');
42
+ expect(viewer).not.toContain('webhelm');
43
+ expect(viewer).not.toContain('spawn(');
44
+ expect(viewer).not.toContain('SIGINT');
45
+ });
46
+ it('loads and refreshes the original player without MCP initialize or review messages',async()=>{
47
+ const path='/files/vlog/video.md';
48
+ let current=hash;
49
+ let poll:()=>unknown=()=>{};
50
+ const dispatched:any[]=[];
51
+ const node=()=>({value:'',hidden:false,disabled:false,textContent:'',style:{display:''},onclick:null,
52
+ addEventListener(){},replaceChildren(){}});
53
+ const elements=new Map<string,ReturnType<typeof node>>();
54
+ const document={body:{classList:{add:()=>{}}},querySelector:()=>node(),getElementById:(id:string)=>{
55
+ if(!elements.has(id))elements.set(id,node());return elements.get(id)!;
56
+ }};
57
+ const window:any={
58
+ parent:{postMessage:(m:any)=>dispatched.push(m)},
59
+ addEventListener(){},dispatchEvent:(event:any)=>{dispatched.push(event);},
60
+ setInterval:(callback:()=>unknown)=>{poll=callback;return 1;},
61
+ };
62
+ const fetch=async (url:string)=>{
63
+ if(url.includes('/revisions/'))return {ok:true,json:async()=>({requestedPath:path,revisionId:current,contentHash:current,
64
+ compiledUrl:'https://neoy.example.test/files/_neoy/markcut/cache/'+current+'.json'})};
65
+ if(url.includes('/cache/'))return {ok:true,json:async()=>({width:640,height:360,fps:30,children:[]})};
66
+ throw Error('Unexpected URL '+url);
67
+ };
68
+ const context=vm.createContext({window,document,location:{pathname:'/files/_neoy/markcut/design.html',search:'?path='+encodeURIComponent(path)},
69
+ fetch,crypto:webcrypto,TextEncoder,URL,URLSearchParams,setTimeout,clearTimeout,CustomEvent:class {type:string;detail:any;
70
+ constructor(type:string,options:any){this.type=type;this.detail=options.detail;}}});
71
+ vm.runInContext(buildPreviewBridgeScript().replaceAll('__MARKCUT_ORIGIN__',JSON.stringify('https://neoy.example.test')),context);
72
+ await new Promise(done=>setTimeout(done,50));
73
+ expect(window.__markcutRevision?.contentHash).toBe(hash);
74
+ expect(window.__markcutDesignMode).toBe(true);
75
+ expect(dispatched.some(x=>x.method==='ui/initialize'||x.method==='ui/message')).toBe(false);
76
+ current=digest;await poll();await new Promise(done=>setTimeout(done,50));
77
+ expect(window.__markcutRevision?.contentHash).toBe(digest);
78
+ expect(dispatched.some(x=>x.method==='ui/message')).toBe(false);
79
+ });
80
+ });
@@ -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);