@lalalic/markcut 3.2.23 → 3.2.25

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.
package/AGENTS.md CHANGED
@@ -293,3 +293,7 @@ The speaker name is matched against `voices` map and the extra flags are appende
293
293
  - **immer** — state management (player app)
294
294
  - **vitest** — test runner
295
295
  - **TypeScript 5.6** — strict mode with `noUncheckedIndexedAccess`
296
+
297
+ ## MCP Review UI Verification
298
+
299
+ For comment-editor or timeline-dot changes, verify the built MCP player in a real browser: multiline input and overlay controls, then add/select/edit/remove Overall, Scene and Spot markers on the Remotion seek bar. Unit tests alone do not prove the hosted iframe is updated.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lalalic/markcut",
3
- "version": "3.2.23",
3
+ "version": "3.2.25",
4
4
  "description": "Markdown-to-video engine. Describe scenes in markdown, get a rendered video.",
5
5
  "bin": {
6
6
  "markcut": "bin/markcut"
@@ -2,60 +2,58 @@ export function buildPreviewBridgeScript() {
2
2
  return `
3
3
  const feedback=document.getElementById('feedback'),status=document.getElementById('status'),pathLabel=document.getElementById('path-label');
4
4
  let nextId=0,identity=null,busy=false,expectedPath=null,activePath=null,activeRelay=null,submittedRevision=null;
5
- // Draft comments stay inside this preview revision until one final submission.
6
- const drafts=new Map(),spots=[];
7
- let currentScene={sceneId:null,sceneName:null,timeSeconds:0},editingSpot=null,nextSpotId=0;
8
- const sceneKey=c=>String(c?.sceneName||c?.sceneId||'General');
9
- function storeInput(){
10
- if(editingSpot!==null){const found=spots.find(x=>x.id===editingSpot);if(found)found.text=feedback.value;}
11
- else drafts.set(sceneKey(currentScene),{text:feedback.value,context:{...currentScene}});
12
- }
5
+ const comments=[];
6
+ let currentScene={sceneId:null,sceneName:null,sceneStart:0,timeSeconds:0},selectedId=null,nextCommentId=0;
7
+ const mode=document.getElementById('comment-mode');
8
+ const sceneKey=c=>String(c?.sceneName||c?.sceneId||'Overall');
13
9
  function allComments(){
14
- storeInput();
15
- return [
16
- ...Array.from(drafts.values()).filter(x=>x.text.trim()).map(x=>({text:x.text.trim(),playbackContext:x.context})),
17
- ...spots.filter(x=>x.text.trim()).map(x=>({text:x.text.trim(),playbackContext:x.context}))
18
- ];
10
+ return comments.filter(x=>x.text.trim()).map(({scope,text,context})=>({scope,text:text.trim(),playbackContext:context}));
19
11
  }
20
12
  function redrawComments(){
21
- const comments=allComments();
22
- const names=[...new Set(comments.map(x=>sceneKey(x.playbackContext)))];
13
+ const names=[...new Set(comments.filter(x=>x.text.trim()&&x.scope!=='overall').map(x=>sceneKey(x.context)))];
23
14
  window.dispatchEvent(new CustomEvent('markcut:comments-change',{detail:{sceneNames:names}}));
24
15
  const count=document.getElementById('comment-count');
25
16
  if(count)count.textContent=comments.length+' comment'+(comments.length===1?'':'s');
26
- const target=document.getElementById('comment-target');
27
- if(target)target.textContent=sceneKey(currentScene)+(editingSpot===null?' · scene comment':' · timed comment');
28
- const list=document.getElementById('comment-list');
29
- if(!list)return;
30
- list.replaceChildren();
31
- for(const note of spots){
32
- if(!note.text.trim())continue;
33
- const row=document.createElement('div'),edit=document.createElement('button'),remove=document.createElement('button');
34
- edit.type='button';edit.textContent=sceneKey(note.context)+' · '+(note.context.timeSeconds??0)+'s · '+note.text.slice(0,80);
35
- edit.onclick=()=>{storeInput();currentScene={...note.context};editingSpot=note.id;feedback.value=note.text;window.dispatchEvent(new CustomEvent('markcut:comment-select',{detail:note.context}));redrawComments();};
36
- remove.type='button';remove.textContent='Remove';
37
- remove.onclick=()=>{const at=spots.findIndex(x=>x.id===note.id);if(at>=0)spots.splice(at,1);if(editingSpot===note.id){editingSpot=null;feedback.value=drafts.get(sceneKey(currentScene))?.text||'';}redrawComments();};
38
- row.append(edit,remove);list.append(row);
39
- }
17
+ const remove=document.getElementById('remove-spot');
18
+ if(remove)remove.disabled=selectedId===null||selectedId===0;
19
+ const overall=selectedId===0||comments.some(x=>x.id===selectedId&&x.scope==='overall');
20
+ mode.hidden=overall;document.getElementById('overall-mode').hidden=!overall;
21
+ const spots=comments.map(x=>({...x,selected:x.id===selectedId}));
22
+ if(!spots.some(x=>x.scope==='overall'))spots.unshift({id:0,scope:'overall',text:'',context:{timeSeconds:0},selected:selectedId===0,placeholder:true});
23
+ window.dispatchEvent(new CustomEvent('markcut:spots-change',{detail:{spots}}));
40
24
  }
41
25
  function clearComments(){
42
- drafts.clear();spots.length=0;editingSpot=null;currentScene={sceneId:null,sceneName:null,timeSeconds:0};feedback.value='';redrawComments();
26
+ comments.length=0;selectedId=null;currentScene={sceneId:null,sceneName:null,sceneStart:0,timeSeconds:0};feedback.value='';mode.value='spot';redrawComments();
43
27
  }
44
- feedback.addEventListener('input',redrawComments);
45
- window.addEventListener('markcut:scene-change',event=>{
46
- const next=event.detail||{};
47
- if(sceneKey(next)===sceneKey(currentScene))return;
48
- storeInput();editingSpot=null;currentScene={...next};feedback.value=drafts.get(sceneKey(next))?.text||'';redrawComments();
28
+ window.addEventListener('markcut:scene-change',event=>{currentScene={...(event.detail||{})};});
29
+ window.addEventListener('markcut:spot-select',event=>{
30
+ const id=event.detail?.id;
31
+ const note=comments.find(x=>x.id===id);
32
+ if(!note&&id!==0)return;
33
+ selectedId=id;feedback.value=note?.text||'';if(note&&note.scope!=='overall')mode.value=note.scope;
34
+ if(note&&note.scope!=='overall')window.dispatchEvent(new CustomEvent('markcut:comment-select',{detail:note.context}));
35
+ redrawComments();
49
36
  });
37
+ mode.onchange=()=>redrawComments();
38
+ document.getElementById('remove-spot').onclick=()=>{
39
+ if(selectedId===null)return;
40
+ const at=comments.findIndex(x=>x.id===selectedId);
41
+ if(at>=0)comments.splice(at,1);
42
+ selectedId=null;feedback.value='';
43
+ redrawComments();
44
+ };
50
45
  document.getElementById('save-spot').onclick=()=>{
51
- storeInput();const value=feedback.value.trim();
52
- if(!value){status.textContent='Write a comment before adding a timed note.';return;}
53
- if(editingSpot!==null){
54
- editingSpot=null;feedback.value=drafts.get(sceneKey(currentScene))?.text||'';redrawComments();return;
55
- }
56
- drafts.delete(sceneKey(currentScene));
57
- spots.push({id:++nextSpotId,text:value,context:{...(window.__markcutPlaybackContext||currentScene)}});
58
- feedback.value='';redrawComments();
46
+ const value=feedback.value.trim(),scope=(selectedId===0||comments.some(x=>x.id===selectedId&&x.scope==='overall'))?'overall':mode.value;
47
+ if(!value){status.textContent='Write a comment first.';return;}
48
+ const live=window.__markcutPlaybackContext||currentScene;
49
+ if(scope!=='overall'&&!live.sceneId&&!live.sceneName){status.textContent='Choose a scene first.';return;}
50
+ const context=scope==='overall'?{sceneId:null,sceneName:null,timeSeconds:0}:
51
+ {...live,timeSeconds:scope==='scene'?(Number(live.sceneStart)||0):(Number(live.timeSeconds)||0)};
52
+ if(selectedId!==null&&selectedId!==0){
53
+ const note=comments.find(x=>x.id===selectedId);
54
+ if(note){note.text=value;note.scope=scope;note.context=context;}
55
+ }else comments.push({id:++nextCommentId,scope,text:value,context});
56
+ selectedId=null;feedback.value='';status.textContent='';redrawComments();
59
57
  };
60
58
  const pending=new Map();
61
59
  const resultsByPath=new Map();
@@ -201,9 +199,10 @@ async function initialize(){
201
199
  }
202
200
  async function submit(decision){
203
201
  if(busy)return;
204
- const comments=allComments();
205
- if(decision==='changes_requested'&&!comments.length){status.textContent='Feedback is required.';return;}
206
- if(decision==='approved'&&comments.length){status.textContent='Submit or remove draft comments before approval.';return;}
202
+ if(feedback.value.trim()&&(selectedId===null||comments.find(x=>x.id===selectedId)?.text!==feedback.value.trim())){status.textContent='Add or remove the current comment before submitting.';return;}
203
+ const preparedComments=allComments();
204
+ if(decision==='changes_requested'&&!preparedComments.length){status.textContent='Feedback is required.';return;}
205
+ if(decision==='approved'&&preparedComments.length){status.textContent='Submit or remove draft comments before approval.';return;}
207
206
  if(!identity){status.textContent='Preview identity unavailable.';return;}
208
207
  if(window.__markcutRevision?.compiledUrl){
209
208
  try{if(!await currentRevisionMatches(activePath,identity.contentHash)){reviewReadonly(true,'Historical Preview · Read-only');return;}}
@@ -213,8 +212,8 @@ async function submit(decision){
213
212
  if(activePath)result.path=activePath;
214
213
  if(activeRelay)result.relay=activeRelay;
215
214
  if(decision==='changes_requested'){
216
- result.comments=comments;
217
- result.feedback=comments.length===1?comments[0].text:comments.map((item,index)=>String(index+1)+'. ['+sceneKey(item.playbackContext)+' @ '+(item.playbackContext.timeSeconds??0)+'s] '+item.text).join('\\n');
215
+ result.comments=preparedComments;
216
+ result.feedback=preparedComments.length===1?preparedComments[0].text:preparedComments.map((item,index)=>String(index+1)+'. ['+sceneKey(item.playbackContext)+' @ '+(item.playbackContext.timeSeconds??0)+'s] '+item.text).join('\\n');
218
217
  if(window.__markcutPlaybackContext)result.playbackContext=window.__markcutPlaybackContext;
219
218
  }
220
219
  busy=true;status.textContent='Submitting…';
@@ -8,7 +8,7 @@ import { buildPreviewBridgeScript } from "./bridge.mjs";
8
8
  import { externalizePreviewMedia, publicOrigin, resolveMountedFile, resolvePreviewPath, publishPlayerBundle, publishCompiledCache, prunePublishedCache, EXPORT_ROOT } from "./remote-assets.mjs";
9
9
 
10
10
  export const TOOL_NAME = "markcut.preview";
11
- export const RESOURCE_URI = "ui://markcut/video-preview-v25.html";
11
+ export const RESOURCE_URI = "ui://markcut/video-preview-v32.html";
12
12
  // Legacy entrypoints remain registered, but serve the current implementation.
13
13
  export const LEGACY_RESOURCE_URIS = [
14
14
  "ui://markcut/video-preview-v3.html",
@@ -33,6 +33,13 @@ export const LEGACY_RESOURCE_URIS = [
33
33
  "ui://markcut/video-preview-v22.html",
34
34
  "ui://markcut/video-preview-v23.html",
35
35
  "ui://markcut/video-preview-v24.html",
36
+ "ui://markcut/video-preview-v25.html",
37
+ "ui://markcut/video-preview-v26.html",
38
+ "ui://markcut/video-preview-v27.html",
39
+ "ui://markcut/video-preview-v28.html",
40
+ "ui://markcut/video-preview-v29.html",
41
+ "ui://markcut/video-preview-v30.html",
42
+ "ui://markcut/video-preview-v31.html",
36
43
  ];
37
44
  export const RESOURCE_MIME_TYPE = "text/html;profile=mcp-app";
38
45
  // Google Maps JS loads libraries, tiles and Routes RPCs from these HTTPS origins.
@@ -279,12 +286,13 @@ export function buildPreviewHtml() {
279
286
  // from terminating the embedding script tag or leaking source into the DOM.
280
287
  return `<!doctype html><html><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1">
281
288
  <title>Markcut</title>
282
- <style>body{font:14px system-ui;margin:0;background:#fff;color:#17202a}main{padding:12px;max-width:960px;margin:auto}h1{font-size:17px}.path{font-size:12px;overflow-wrap:anywhere}.transport{display:flex;align-items:center;gap:10px;padding:12px 0}.transport input{flex:1;min-width:50px}button{cursor:pointer;padding:8px;border-radius:6px;border:1px solid #a8a8a8}#approve{background:#198038;color:white}#changes{background:#c72b29;color:white}textarea{width:100%;box-sizing:border-box;min-height:66px}.review-actions{display:flex;justify-content:space-between;align-items:center;width:100%;gap:16px}.review-actions button{min-width:150px}#remotion-canvas{background:#090b12}#status{padding:8px 0}#status:empty{display:none}#scene-thumbnails{display:flex;gap:7px;overflow-x:auto;padding:12px 2px;scrollbar-width:thin} .scene-pill{flex-shrink:0;padding:7px 11px;border:1px solid #d4dbe4;border-radius:9px;cursor:pointer;background:#f5f7fa;color:#475569;font-size:12px;white-space:nowrap} .scene-pill.active{background:#e7f0ff;color:#125ea2;border-color:#408bd7} .scene-pill.commented{border-color:#cc8b12;background:#fff4d6;color:#764900;font-weight:650} .scene-pill.commented::after{content:' •';color:#ad5b00} #comment-list{display:grid;gap:4px;margin:8px 0} #comment-list>div{display:flex;gap:8px} #comment-list button:first-child{flex:1;text-align:left;overflow:hidden;text-overflow:ellipsis} #comment-target,#comment-count{font-size:12px;color:#526071;margin:8px 0}</style></head>
283
- <body><main><header style="display:flex;justify-content:space-between;align-items:center"><h1>Markcut · <span id="video-md-version">video</span></h1><div style="display:flex;align-items:center;gap:14px;margin-left:auto"><span id="header-tts"></span><span id="player-version" style="font-size:12px;color:#667">v25</span></div></header><div class="path" id="path-label" hidden></div><div id="interactive-ui" hidden><div id="remotion-root"></div>
284
- <div id="comment-target" aria-live="polite">Current scene · general</div>
285
- <textarea id="feedback" aria-label="Feedback" placeholder="Comment on this scene; navigate freely before submitting…"></textarea>
286
- <div class="review-actions"><button id="save-spot" type="button">Add timed comment</button><span id="comment-count" aria-live="polite">0 comments</span></div>
287
- <div id="comment-list" aria-label="Saved review comments"></div><div id="status" role="status">Starting preview…</div>
289
+ <style>body{font:14px system-ui;margin:0;background:#fff;color:#17202a}main{padding:12px;max-width:960px;margin:auto}h1{font-size:17px}.path{font-size:12px;overflow-wrap:anywhere}.transport{display:flex;align-items:center;gap:10px;padding:12px 0}.transport input{flex:1;min-width:50px}button{cursor:pointer;padding:8px;border-radius:6px;border:1px solid #a8a8a8}#approve{background:#198038;color:white}#changes{background:#c72b29;color:white}#comment-entry{display:flex;align-items:center;gap:6px;margin:5px 0}#feedback{flex:1;min-width:0;box-sizing:border-box;height:34px;padding:6px 9px;border:1px solid #b5bdc8;border-radius:6px}#comment-mode{max-width:102px;height:34px;border:1px solid #b5bdc8;border-radius:6px;background:white}#save-spot,#remove-spot{width:34px;height:34px;padding:0;font-size:19px}#comment-count{white-space:nowrap}#comment-entry button:disabled{opacity:.4;cursor:default}.review-actions{display:flex;justify-content:space-between;align-items:center;width:100%;gap:16px}.review-actions button{min-width:110px}#remotion-canvas{background:#090b12}#status{padding:8px 0}#status:empty{display:none}#scene-thumbnails{display:flex;gap:7px;overflow-x:auto;padding:12px 2px;scrollbar-width:thin} .scene-pill{flex-shrink:0;padding:7px 11px;border:1px solid #d4dbe4;border-radius:9px;cursor:pointer;background:#f5f7fa;color:#475569;font-size:12px;white-space:nowrap} .scene-pill.active{background:#e7f0ff;color:#125ea2;border-color:#408bd7} .scene-pill.commented{border-color:#cc8b12;background:#fff4d6;color:#764900;font-weight:650} .scene-pill.commented::after{content:' •';color:#ad5b00} #comment-list{display:grid;gap:4px;margin:8px 0} #comment-list>div{display:flex;gap:8px} #comment-list button:first-child{flex:1;text-align:left;overflow:hidden;text-overflow:ellipsis} #comment-target,#comment-count{font-size:12px;color:#526071;margin:8px 0}</style></head>
290
+ <style>.comment-marker{position:absolute;top:50%;transform:translate(-50%,-50%);width:20px;height:20px;min-width:20px;padding:0;border:0;border-radius:50%;background:transparent;z-index:10;cursor:pointer;touch-action:none}.comment-marker::after{content:'';display:block;width:14px;height:14px;border-radius:50%;margin:auto;background:#f59e0b;border:2px solid white;box-sizing:border-box}.comment-marker.scope-scene::after{background:#3b82f6}.comment-marker.scope-overall{left:-12px!important}.comment-marker.scope-overall::after{background:#8b5cf6}.comment-marker.scope-overall.placeholder::after{background:transparent;border-color:#8b5cf6}.comment-marker.selected::after,.comment-marker:focus-visible::after{outline:2px solid #2563eb;outline-offset:2px}.comment-marker:hover::after{transform:scale(1.2)}</style>
291
+ <style>#comment-entry{position:relative;display:block}#feedback{display:block;width:100%;height:auto;min-height:76px;max-height:240px;field-sizing:content;resize:none;padding:9px 112px 32px 9px;font:inherit}#comment-tools{position:absolute;bottom:6px;right:8px;display:flex;align-items:center;gap:2px;background:white}#comment-tools>*{width:30px;height:28px;padding:0;border:0;background:transparent;color:#526071;font:inherit;text-align:center}#comment-tools button{font-size:20px}#comment-tools>*:focus-visible{outline:2px solid #408bd7;outline-offset:-2px}#comment-mode{width:70px;max-width:none;font-size:12px;font-weight:650}#comment-mode:has(option[value=spot]:checked){color:#b45309}#comment-mode:has(option[value=scene]:checked){color:#2563eb}#overall-mode{width:70px;text-align:center;font-size:12px;font-weight:650;color:#7c3aed}</style>
292
+ <body><main><header style="display:flex;justify-content:space-between;align-items:center"><h1>Markcut · <span id="video-md-version">video</span></h1><div style="display:flex;align-items:center;gap:14px;margin-left:auto"><span id="header-tts"></span><span id="player-version" style="font-size:12px;color:#667">v32</span></div></header><div class="path" id="path-label" hidden></div><div id="interactive-ui" hidden><div id="remotion-root"></div>
293
+ <div id="comment-entry"><textarea id="feedback" rows="3" aria-label="Feedback" placeholder="Add a comment…"></textarea><div id="comment-tools"><select id="comment-mode" aria-label="Comment scope" title="Comment scope"><option value="spot" style="color:#b45309">Spot</option><option value="scene" style="color:#2563eb">Scene</option></select><span id="overall-mode" hidden>Overall</span><button id="save-spot" type="button" title="Add or update comment" aria-label="Add or update comment">+</button><button id="remove-spot" type="button" title="Remove selected comment" aria-label="Remove selected comment" disabled>−</button></div></div>
294
+ <div style="display:flex;justify-content:flex-end"><span id="comment-count" aria-live="polite">0 comments</span></div>
295
+ <div id="status" role="status">Starting preview…</div>
288
296
  <div class="review-actions"><button id="changes">Submit all feedback</button><button id="approve">Approve</button></div></div></main>
289
297
  <script src="${playerScriptUrl}"></script>
290
298
  <script>${buildPreviewBridgeScript().replaceAll("__MARKCUT_ORIGIN__",JSON.stringify(publicOrigin()))}</script></body></html>`;