@lalalic/markcut 3.2.31 → 3.2.32
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 +5 -1
- package/package.json +1 -1
- package/src/descriptive/compiler.test.ts +3 -0
- package/src/descriptive/compiler.ts +4 -2
- package/src/descriptive/markdown.ts +2 -1
- package/src/descriptive/resolve.ts +4 -0
- package/src/mcp/audio-preview-tree.ts +22 -4
- package/src/mcp/browser-speech-preview.ts +20 -7
- package/src/mcp/preview.mjs +5 -2
- package/src/mcp/remotion-app.bundle.js +300 -300
- package/src/mcp/remotion-app.tsx +1 -1
- package/src/mcp/web-audio-preview.ts +16 -5
- package/src/player/bundle/player.js +1875 -1826
- package/src/player/pipeline.mjs +62 -31
- package/src/schema/index.ts +2 -1
- package/src/types/Map.tsx +7 -3
- package/src/utils/map-viewport.ts +47 -0
- package/tests/map-viewport.test.ts +57 -0
- package/tests/mcp-preview.test.ts +1 -1
- package/tests/mcp-web-audio-preview.test.ts +35 -13
package/AGENTS.md
CHANGED
|
@@ -304,4 +304,8 @@ Whenever Markcut MCP server, preview UI, bridge, or bundled player code changes,
|
|
|
304
304
|
|
|
305
305
|
## MCP background-audio regression guard
|
|
306
306
|
|
|
307
|
-
When extracting HTTPS BGM from a preview tree, traverse the tree **before** returning the captured audio variable. JavaScript evaluates object properties left-to-right: returning `{audio, playbackRoot: strip(root)}` silently loses the BGM handle while removing the native audio node. Keep the pure extraction in `src/mcp/audio-preview-tree.ts` and run `tests/mcp-web-audio-preview.test.ts`. For user-style playback verification, check network HTTP 200, decoded duration, a running AudioContext, advancing Remotion frames, and nonzero Web Audio analyser RMS; a decoded source alone does not establish audible playback.
|
|
307
|
+
When extracting HTTPS BGM from a preview tree, traverse the tree **before** returning the captured audio variable. JavaScript evaluates object properties left-to-right: returning `{audio, playbackRoot: strip(root)}` silently loses the BGM handle while removing the native audio node. Keep the pure extraction in `src/mcp/audio-preview-tree.ts` and run `tests/mcp-web-audio-preview.test.ts`. For user-style playback verification, check network HTTP 200, decoded duration, a running AudioContext, advancing Remotion frames, and nonzero Web Audio analyser RMS; a decoded source alone does not establish audible playback. Browser TTS must retain BGM and environmental audio, and only generated narration can be removed; listen for speech start/end to duck and restore Web Audio music gain.
|
|
308
|
+
|
|
309
|
+
## Route map framing
|
|
310
|
+
|
|
311
|
+
For `map view:route`, omit `zoom` to auto-fit geotagged stops to the Remotion composition dimensions, including 9:16 vertical output; auto-fit reserves 14% padding. The route schema and both descriptive compiler paths must leave omitted zoom undefined, or their old `zoom:10` defaults silently override the runtime fit. Explicit `zoom` and camera tweens still override fit. Verify the real browser map's zoom/center and rendered tiles, not just a successful Markdown compile or Google API HTTP response. A calculated Directions line is not proof of a recorded GPS track.
|
package/package.json
CHANGED
|
@@ -771,6 +771,7 @@ describe("compileDescriptiveRoot", () => {
|
|
|
771
771
|
children: [
|
|
772
772
|
{ id: "bgm", type: "audio", src: "bg.mp3", duration: 5, volume: 0.3, foreground: false },
|
|
773
773
|
{ id: "sfx", type: "audio", src: "sfx.wav", duration: 1, volume: 1, start: 2 },
|
|
774
|
+
{ id: "tts", type: "audio", src: "tts.mp3", duration: 1, isNarration: true },
|
|
774
775
|
],
|
|
775
776
|
});
|
|
776
777
|
|
|
@@ -783,6 +784,8 @@ describe("compileDescriptiveRoot", () => {
|
|
|
783
784
|
const sfx = compiled.children.find((c: any) => c.id === "sfx") as any;
|
|
784
785
|
expect(sfx.start).toBe(2);
|
|
785
786
|
expect(sfx.end).toBe(3);
|
|
787
|
+
const tts=compiled.children.find((c:any)=>c.id==='tts') as any;
|
|
788
|
+
expect(tts.isNarration).toBe(true);
|
|
786
789
|
});
|
|
787
790
|
|
|
788
791
|
it("compiles component node with props", () => {
|
|
@@ -72,6 +72,7 @@ export interface DescriptiveAudio extends DescriptiveBaseNode {
|
|
|
72
72
|
* `SpeakerName: text` format scripts. Used for per-speaker voice selection and
|
|
73
73
|
* subtitle prefix. */
|
|
74
74
|
speaker?: string;
|
|
75
|
+
isNarration?: boolean;
|
|
75
76
|
volume?: number;
|
|
76
77
|
foreground?: boolean;
|
|
77
78
|
startFrom?: number;
|
|
@@ -596,6 +597,7 @@ function compileLeaf(node: Exclude<DescriptiveNode, DescriptiveContainer | Descr
|
|
|
596
597
|
volume: node.volume ?? 1,
|
|
597
598
|
foreground: node.foreground,
|
|
598
599
|
speaker: node.speaker,
|
|
600
|
+
isNarration: node.isNarration,
|
|
599
601
|
};
|
|
600
602
|
return { stream, duration: end ?? 0 };
|
|
601
603
|
}
|
|
@@ -649,7 +651,7 @@ function compileLeaf(node: Exclude<DescriptiveNode, DescriptiveContainer | Descr
|
|
|
649
651
|
waypoints: node.waypoints,
|
|
650
652
|
routeColor: node.routeColor ?? "#4285F4",
|
|
651
653
|
routeWeight: node.routeWeight ?? 4,
|
|
652
|
-
zoom: node.zoom
|
|
654
|
+
zoom: node.zoom,
|
|
653
655
|
center: node.center,
|
|
654
656
|
mapType: node.mapType ?? "roadmap",
|
|
655
657
|
language: node.language,
|
|
@@ -934,7 +936,7 @@ function compileMap(
|
|
|
934
936
|
waypoints: node.waypoints,
|
|
935
937
|
routeColor: node.routeColor ?? "#4285F4",
|
|
936
938
|
routeWeight: node.routeWeight ?? 4,
|
|
937
|
-
zoom: node.zoom
|
|
939
|
+
zoom: node.zoom,
|
|
938
940
|
center: node.center,
|
|
939
941
|
mapType: node.mapType ?? "roadmap",
|
|
940
942
|
language: node.language,
|
|
@@ -103,7 +103,7 @@ function preserveVariantAttrs(node: Record<string, unknown>, attrs: Record<strin
|
|
|
103
103
|
"travelMode", "zoom", "center", "mapType", "data", "prompt",
|
|
104
104
|
"view", "camera", "cinematic", "streetView",
|
|
105
105
|
"name", "title", "transition", "transitionTime", "layout",
|
|
106
|
-
"componentName", "props", "speaker",
|
|
106
|
+
"componentName", "props", "speaker", "isNarration",
|
|
107
107
|
]);
|
|
108
108
|
for (const [k, v] of Object.entries(attrs)) {
|
|
109
109
|
if (!STANDARD.has(k)) {
|
|
@@ -217,6 +217,7 @@ function parseNodeLine(content: string, lineNum?: number): DescriptiveNode {
|
|
|
217
217
|
id: attrs.id as any,
|
|
218
218
|
src,
|
|
219
219
|
speaker: attrs.speaker as string | undefined,
|
|
220
|
+
isNarration: attrs.isNarration as boolean | undefined,
|
|
220
221
|
duration: attrs.duration as any,
|
|
221
222
|
start: attrs.start as any,
|
|
222
223
|
startFrom: attrs.startFrom as any,
|
|
@@ -448,6 +448,10 @@ export async function resolveScripts(
|
|
|
448
448
|
// Set resolved src (absolute for reliable probing; the final
|
|
449
449
|
// relativizeAssetsUnder pass in resolveAll makes it md-folder-relative)
|
|
450
450
|
node.src = resolvePath(generated);
|
|
451
|
+
// Preserve speech provenance after script text is removed and the asset
|
|
452
|
+
// is published under an opaque HTTPS filename. The MCP Browser TTS mixer
|
|
453
|
+
// uses this marker to suppress duplicate recorded narration.
|
|
454
|
+
node.isNarration = true;
|
|
451
455
|
delete node.script;
|
|
452
456
|
}
|
|
453
457
|
|
|
@@ -4,8 +4,10 @@ export function extractRemotePreviewAudio(root:any) {
|
|
|
4
4
|
let audio:any=null;
|
|
5
5
|
const strip=(node:any):any=>{
|
|
6
6
|
if(!node||typeof node!=='object')return node;
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
// Only take the global HTTPS music bed. Preserve environmental/SFX tracks
|
|
8
|
+
// in the Remotion tree instead of silently dropping all remote audio.
|
|
9
|
+
if(node.type==='audio'&&node.isBackground&&String(node.src).startsWith('https://')&&!audio){
|
|
10
|
+
audio=node;
|
|
9
11
|
return null;
|
|
10
12
|
}
|
|
11
13
|
return {...node,...(Array.isArray(node.children)?{children:node.children.map(strip).filter(Boolean)}:{})};
|
|
@@ -16,10 +18,26 @@ export function extractRemotePreviewAudio(root:any) {
|
|
|
16
18
|
return {audio,playbackRoot};
|
|
17
19
|
}
|
|
18
20
|
|
|
19
|
-
//
|
|
21
|
+
// Suppress only identified generated narration, not arbitrary non-background
|
|
22
|
+
// sounds. Resolution deletes script text but retains speaker, and generated
|
|
23
|
+
// narration paths use the tts directory.
|
|
24
|
+
export function isRecordedNarration(node:any):boolean {
|
|
25
|
+
if(node?.type!=='audio'||node.isBackground)return false;
|
|
26
|
+
if(node.isNarration===true)return true;
|
|
27
|
+
const label=String(node.role||node.kind||node.name||node.id||'').toLowerCase();
|
|
28
|
+
const src=String(node.src||'');
|
|
29
|
+
return Boolean(node.speaker) || /^(narration|voiceover|tts)(?:[-_ ]|$)/.test(label)
|
|
30
|
+
|| /(?:^|[/\\])tts[/\\]/i.test(src);
|
|
31
|
+
}
|
|
32
|
+
|
|
20
33
|
export function withoutRecordedNarration(root:any):any {
|
|
21
34
|
if(!root||typeof root!=='object')return root;
|
|
22
|
-
if(root
|
|
35
|
+
if(isRecordedNarration(root))return null;
|
|
23
36
|
return {...root,...(Array.isArray(root.children)?{children:root.children.map(withoutRecordedNarration).filter(Boolean)}:{}),
|
|
24
37
|
...(root.type==='root'?{subtitle:undefined}:{})};
|
|
25
38
|
}
|
|
39
|
+
|
|
40
|
+
export const NARRATION_DUCK_FACTOR=0.28;
|
|
41
|
+
export function previewBgmGain(playerVolume:number,trackVolume:number,muted:boolean,narrationSpeaking:boolean){
|
|
42
|
+
return muted?0:Math.max(0,playerVolume)*Math.max(0,trackVolume)*(narrationSpeaking?NARRATION_DUCK_FACTOR:1);
|
|
43
|
+
}
|
|
@@ -30,30 +30,43 @@ export function useBrowserSpeechPreview(root:any,playerRef:React.RefObject<Playe
|
|
|
30
30
|
React.useEffect(()=>{
|
|
31
31
|
if(!enabled||typeof window==="undefined"||!("speechSynthesis" in window))return;
|
|
32
32
|
const synth=window.speechSynthesis;
|
|
33
|
-
let player:PlayerRef|null=null,disposed=false,lastIndex=-1;
|
|
34
|
-
const
|
|
33
|
+
let player:PlayerRef|null=null,disposed=false,lastIndex=-1,turn=0,active=false;
|
|
34
|
+
const notify=(next:boolean)=>{
|
|
35
|
+
if(active===next)return;
|
|
36
|
+
active=next;
|
|
37
|
+
window.dispatchEvent(new CustomEvent('markcut:tts-speaking',{detail:{active:next}}));
|
|
38
|
+
};
|
|
39
|
+
const stop=()=>{turn++;synth.cancel();lastIndex=-1;notify(false);};
|
|
35
40
|
const update=()=>{
|
|
36
41
|
if(!player||disposed)return;
|
|
37
42
|
const t=player.getCurrentFrame()/(root?.fps||30);
|
|
38
43
|
setTime(t);
|
|
39
|
-
if(!player.isPlaying()){stop();return;}
|
|
44
|
+
if(!player.isPlaying()||player.isMuted()){stop();return;}
|
|
40
45
|
const index=cues.findIndex(c=>t>=c.start&&t<c.end);
|
|
41
46
|
if(index===lastIndex)return;
|
|
42
|
-
synth.cancel();lastIndex=index;
|
|
43
|
-
|
|
47
|
+
synth.cancel();notify(false);lastIndex=index;
|
|
48
|
+
const token=++turn;
|
|
49
|
+
if(index>=0){
|
|
44
50
|
const utterance=new SpeechSynthesisUtterance(cues[index].text);
|
|
45
51
|
utterance.rate=1;utterance.volume=player.getVolume();
|
|
52
|
+
utterance.onstart=()=>{if(!disposed&&token===turn)notify(true);};
|
|
53
|
+
const done=()=>{if(!disposed&&token===turn)notify(false);};
|
|
54
|
+
utterance.onend=done;utterance.onerror=done;
|
|
46
55
|
synth.speak(utterance);
|
|
47
56
|
}
|
|
48
57
|
};
|
|
49
58
|
const attach=()=>{
|
|
50
59
|
if(player||!playerRef.current)return;
|
|
51
60
|
player=playerRef.current;
|
|
52
|
-
for(const event of [
|
|
61
|
+
for(const event of ['frameupdate','play','pause','seeked','ended','mutechange','volumechange'])player.addEventListener(event,update);
|
|
53
62
|
};
|
|
54
63
|
attach();
|
|
55
64
|
const poll=setInterval(attach,150);
|
|
56
|
-
return()=>{
|
|
65
|
+
return()=>{
|
|
66
|
+
disposed=true;clearInterval(poll);
|
|
67
|
+
if(player)for(const event of ['frameupdate','play','pause','seeked','ended','mutechange','volumechange'])player.removeEventListener(event,update);
|
|
68
|
+
stop();
|
|
69
|
+
};
|
|
57
70
|
},[enabled,cues,root?.fps,playerRef]);
|
|
58
71
|
const active=cues.find(c=>time>=c.start&&time<c.end);
|
|
59
72
|
return {caption:enabled?active?.text||"":""};
|
package/src/mcp/preview.mjs
CHANGED
|
@@ -8,7 +8,8 @@ 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-
|
|
11
|
+
export const RESOURCE_URI = "ui://markcut/video-preview-v38.html";
|
|
12
|
+
const PREVIEW_VERSION = RESOURCE_URI.match(/video-preview-(v\d+)/)?.[1] ?? "unknown";
|
|
12
13
|
// Legacy entrypoints remain registered, but serve the current implementation.
|
|
13
14
|
export const LEGACY_RESOURCE_URIS = [
|
|
14
15
|
"ui://markcut/video-preview-v3.html",
|
|
@@ -44,6 +45,8 @@ export const LEGACY_RESOURCE_URIS = [
|
|
|
44
45
|
"ui://markcut/video-preview-v33.html",
|
|
45
46
|
"ui://markcut/video-preview-v34.html",
|
|
46
47
|
"ui://markcut/video-preview-v35.html",
|
|
48
|
+
"ui://markcut/video-preview-v36.html",
|
|
49
|
+
"ui://markcut/video-preview-v37.html",
|
|
47
50
|
];
|
|
48
51
|
export const RESOURCE_MIME_TYPE = "text/html;profile=mcp-app";
|
|
49
52
|
// Google Maps JS loads libraries, tiles and Routes RPCs from these HTTPS origins.
|
|
@@ -293,7 +296,7 @@ export function buildPreviewHtml() {
|
|
|
293
296
|
<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>
|
|
294
297
|
<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:-28px!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>
|
|
295
298
|
<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;text-align:center;text-align-last:center;line-height:28px}#comment-mode:has(option[value=spot]:checked){color:#b45309}#comment-mode:has(option[value=scene]:checked){color:#2563eb}#overall-mode{width:70px;height:28px;line-height:28px;text-align:center;font-size:12px;font-weight:650;color:#7c3aed}</style>
|
|
296
|
-
<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"
|
|
299
|
+
<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">${PREVIEW_VERSION}</span></div></header><div class="path" id="path-label" hidden></div><div id="interactive-ui" hidden><div id="remotion-root"></div>
|
|
297
300
|
<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>
|
|
298
301
|
<div style="display:flex;justify-content:flex-end"><span id="comment-count" aria-live="polite">0 comments</span></div>
|
|
299
302
|
<div id="status" role="status">Starting preview…</div>
|