@lalalic/markcut 3.2.23 → 3.2.24

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lalalic/markcut",
3
- "version": "3.2.23",
3
+ "version": "3.2.24",
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,53 @@ 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;
19
+ window.dispatchEvent(new CustomEvent('markcut:spots-change',{detail:{spots:comments.map(x=>({...x,selected:x.id===selectedId}))}}));
40
20
  }
41
21
  function clearComments(){
42
- drafts.clear();spots.length=0;editingSpot=null;currentScene={sceneId:null,sceneName:null,timeSeconds:0};feedback.value='';redrawComments();
22
+ comments.length=0;selectedId=null;currentScene={sceneId:null,sceneName:null,sceneStart:0,timeSeconds:0};feedback.value='';mode.value='spot';redrawComments();
43
23
  }
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();
24
+ window.addEventListener('markcut:scene-change',event=>{currentScene={...(event.detail||{})};});
25
+ window.addEventListener('markcut:spot-select',event=>{
26
+ const note=comments.find(x=>x.id===event.detail?.id);
27
+ if(!note)return;
28
+ selectedId=note.id;feedback.value=note.text;mode.value=note.scope;
29
+ if(note.scope!=='overall')window.dispatchEvent(new CustomEvent('markcut:comment-select',{detail:note.context}));
30
+ redrawComments();
49
31
  });
32
+ mode.onchange=()=>redrawComments();
33
+ document.getElementById('remove-spot').onclick=()=>{
34
+ if(selectedId===null)return;
35
+ const at=comments.findIndex(x=>x.id===selectedId);
36
+ if(at>=0)comments.splice(at,1);
37
+ selectedId=null;feedback.value='';
38
+ redrawComments();
39
+ };
50
40
  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();
41
+ const value=feedback.value.trim(),scope=mode.value;
42
+ if(!value){status.textContent='Write a comment first.';return;}
43
+ const live=window.__markcutPlaybackContext||currentScene;
44
+ if(scope!=='overall'&&!live.sceneId&&!live.sceneName){status.textContent='Choose a scene first.';return;}
45
+ const context=scope==='overall'?{sceneId:null,sceneName:null,timeSeconds:0}:
46
+ {...live,timeSeconds:scope==='scene'?(Number(live.sceneStart)||0):(Number(live.timeSeconds)||0)};
47
+ if(selectedId!==null){
48
+ const note=comments.find(x=>x.id===selectedId);
49
+ if(note){note.text=value;note.scope=scope;note.context=context;}
50
+ }else comments.push({id:++nextCommentId,scope,text:value,context});
51
+ selectedId=null;feedback.value='';status.textContent='';redrawComments();
59
52
  };
60
53
  const pending=new Map();
61
54
  const resultsByPath=new Map();
@@ -201,9 +194,10 @@ async function initialize(){
201
194
  }
202
195
  async function submit(decision){
203
196
  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;}
197
+ 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;}
198
+ const preparedComments=allComments();
199
+ if(decision==='changes_requested'&&!preparedComments.length){status.textContent='Feedback is required.';return;}
200
+ if(decision==='approved'&&preparedComments.length){status.textContent='Submit or remove draft comments before approval.';return;}
207
201
  if(!identity){status.textContent='Preview identity unavailable.';return;}
208
202
  if(window.__markcutRevision?.compiledUrl){
209
203
  try{if(!await currentRevisionMatches(activePath,identity.contentHash)){reviewReadonly(true,'Historical Preview · Read-only');return;}}
@@ -213,8 +207,8 @@ async function submit(decision){
213
207
  if(activePath)result.path=activePath;
214
208
  if(activeRelay)result.relay=activeRelay;
215
209
  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');
210
+ result.comments=preparedComments;
211
+ 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
212
  if(window.__markcutPlaybackContext)result.playbackContext=window.__markcutPlaybackContext;
219
213
  }
220
214
  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-v31.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,12 @@ 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",
36
42
  ];
37
43
  export const RESOURCE_MIME_TYPE = "text/html;profile=mcp-app";
38
44
  // Google Maps JS loads libraries, tiles and Routes RPCs from these HTTPS origins.
@@ -279,12 +285,13 @@ export function buildPreviewHtml() {
279
285
  // from terminating the embedding script tag or leaking source into the DOM.
280
286
  return `<!doctype html><html><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1">
281
287
  <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>
288
+ <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>
289
+ <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.selected::after,.comment-marker:focus-visible::after{outline:2px solid #2563eb;outline-offset:2px}.comment-marker:hover::after{transform:scale(1.2)}</style>
290
+ <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}#comment-mode:has(option[value=overall]:checked){color:#7c3aed}</style>
291
+ <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">v31</span></div></header><div class="path" id="path-label" hidden></div><div id="interactive-ui" hidden><div id="remotion-root"></div>
292
+ <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><option value="overall" style="color:#7c3aed">Overall</option></select><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>
293
+ <div style="display:flex;justify-content:flex-end"><span id="comment-count" aria-live="polite">0 comments</span></div>
294
+ <div id="status" role="status">Starting preview…</div>
288
295
  <div class="review-actions"><button id="changes">Submit all feedback</button><button id="approve">Approve</button></div></div></main>
289
296
  <script src="${playerScriptUrl}"></script>
290
297
  <script>${buildPreviewBridgeScript().replaceAll("__MARKCUT_ORIGIN__",JSON.stringify(publicOrigin()))}</script></body></html>`;