@lalalic/markcut 3.2.60 → 3.2.61
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/README.md +20 -4
- package/bin/markcut +10 -0
- package/docs/developer-reference.md +41 -1
- package/package.json +8 -2
- package/recipes/markcut/map-cinematic-follow.json +17 -0
- package/recipes/markcut/map-location-reveal.json +17 -0
- package/recipes/markcut/map-route-journey.json +18 -0
- package/recipes/markcut/map-streetview-explore.json +17 -0
- package/skills/markcut/SKILL.md +5 -1
- package/skills/markcut/docs/markdown-descriptive.md +68 -1
- package/skills/markcut/docs/recipes.md +45 -0
- package/skills/markcut/references/mobile-event-preview-cli.md +9 -5
- package/src/descriptive/compiler.ts +38 -2
- package/src/descriptive/markdown.ts +30 -0
- package/src/descriptive/model3d.test.ts +38 -0
- package/src/editor-decision/cli.mjs +21 -0
- package/src/editor-decision/editor-decision.schema.json +41 -0
- package/src/editor-decision/index.mjs +115 -0
- package/src/editor-decision/index.test.mjs +63 -0
- package/src/mcp/bridge.mjs +46 -9
- package/src/mcp/compile-worker.mjs +2 -2
- package/src/mcp/mobile-review-cli.mjs +40 -33
- package/src/mcp/preview-mobile.css +21 -8
- package/src/mcp/preview.mjs +95 -57
- package/src/mcp/remote-assets.mjs +85 -7
- package/src/mcp/remotion-app.bundle.js +5013 -1117
- package/src/mcp/remotion-app.tsx +117 -10
- package/src/mcp/server.mjs +4 -2
- package/src/player/browser.tsx +1 -3
- package/src/player/bundle/player.js +73054 -17357
- package/src/player/components/HeaderBar.tsx +3 -1
- package/src/player/components/VariantBar.tsx +20 -21
- package/src/player/pipeline.mjs +133 -77
- package/src/player/server.mjs +43 -23
- package/src/recipes/catalog.mjs +115 -0
- package/src/recipes/cli.mjs +87 -0
- package/src/render/cli.mjs +38 -1
- package/src/schema/index.ts +21 -0
- package/src/types/Folder.tsx +2 -0
- package/src/types/Model3D.tsx +91 -0
- package/src/vision/cli.mjs +63 -50
- package/tests/mcp-editor-decisions-mobile.test.ts +35 -0
- package/tests/mcp-preview-bridge.test.ts +44 -3
- package/tests/mcp-preview-proxy-version.test.mjs +80 -0
- package/tests/mcp-preview.test.ts +41 -8
- package/tests/mcp-remote-assets.test.ts +17 -0
- package/tests/mcp-static-preview.test.ts +1 -1
- package/tests/mcp-video-selector.test.ts +55 -0
- package/tests/mobile-preview-cli.test.ts +10 -15
- package/tests/recipes-catalog.test.ts +141 -0
- package/tests/vision-generic-vtt-hooks.test.ts +7 -7
- package/tests/vision-normalized-metadata.test.ts +23 -0
package/src/mcp/preview.mjs
CHANGED
|
@@ -1,63 +1,26 @@
|
|
|
1
1
|
import { createHash } from "node:crypto";
|
|
2
2
|
import { mkdir, writeFile, readdir, rename, rm, stat, utimes } from "node:fs/promises";
|
|
3
3
|
import { access, readFile } from "node:fs/promises";
|
|
4
|
-
import { constants as fsConstants, readFileSync } from "node:fs";
|
|
4
|
+
import { constants as fsConstants, readFileSync, existsSync } from "node:fs";
|
|
5
5
|
import { isAbsolute, extname, dirname, resolve, basename } from "node:path";
|
|
6
6
|
import { fileURLToPath } from "node:url";
|
|
7
7
|
import { buildPreviewBridgeScript } from "./bridge.mjs";
|
|
8
|
-
import { externalizePreviewMedia, publicOrigin, resolveMountedFile, resolvePreviewPath, publishPlayerBundle, publishCompiledCache, prunePublishedCache, EXPORT_ROOT } from "./remote-assets.mjs";
|
|
8
|
+
import { externalizePreviewMedia, publicOrigin, resolveMountedFile, resolvePreviewPath, publishPlayerBundle, publishCompiledCache, prunePublishedCache, versionPreviewMedia, EXPORT_ROOT } from "./remote-assets.mjs";
|
|
9
9
|
import {fingerprintInputs} from "./source-fingerprint.mjs";
|
|
10
|
+
import {loadEditorDecision,editorDecisionToMarkdown} from "../editor-decision/index.mjs";
|
|
10
11
|
|
|
11
12
|
export const TOOL_NAME = "markcut.preview";
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
//
|
|
13
|
+
// One source of truth for preview resources. Every historical version (and
|
|
14
|
+
// the versionless alias) serves the same current UI and player bundle.
|
|
15
|
+
// Increment the version only to bypass clients that cache an already-open UI.
|
|
16
|
+
export const PREVIEW_VERSION_NUMBER = 55;
|
|
17
|
+
export const RESOURCE_URI = `ui://markcut/video-preview-v${PREVIEW_VERSION_NUMBER}.html`;
|
|
18
|
+
export const STABLE_RESOURCE_URI = "ui://markcut/video-preview.html";
|
|
19
|
+
const PREVIEW_VERSION = `v${PREVIEW_VERSION_NUMBER}`;
|
|
15
20
|
export const LEGACY_RESOURCE_URIS = [
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
"ui://markcut/video-preview-v44.html",
|
|
20
|
-
"ui://markcut/video-preview-v3.html",
|
|
21
|
-
"ui://markcut/video-preview-v4.html",
|
|
22
|
-
"ui://markcut/video-preview-v5.html",
|
|
23
|
-
"ui://markcut/video-preview-v6.html",
|
|
24
|
-
"ui://markcut/video-preview-v7.html",
|
|
25
|
-
"ui://markcut/video-preview-v8.html",
|
|
26
|
-
"ui://markcut/video-preview-v9.html",
|
|
27
|
-
"ui://markcut/video-preview-v10.html",
|
|
28
|
-
"ui://markcut/video-preview-v11.html",
|
|
29
|
-
"ui://markcut/video-preview-v12.html",
|
|
30
|
-
"ui://markcut/video-preview-v13.html",
|
|
31
|
-
"ui://markcut/video-preview-v14.html",
|
|
32
|
-
"ui://markcut/video-preview-v15.html",
|
|
33
|
-
"ui://markcut/video-preview-v16.html",
|
|
34
|
-
"ui://markcut/video-preview-v17.html",
|
|
35
|
-
"ui://markcut/video-preview-v18.html",
|
|
36
|
-
"ui://markcut/video-preview-v19.html",
|
|
37
|
-
"ui://markcut/video-preview-v20.html",
|
|
38
|
-
"ui://markcut/video-preview-v21.html",
|
|
39
|
-
"ui://markcut/video-preview-v22.html",
|
|
40
|
-
"ui://markcut/video-preview-v23.html",
|
|
41
|
-
"ui://markcut/video-preview-v24.html",
|
|
42
|
-
"ui://markcut/video-preview-v25.html",
|
|
43
|
-
"ui://markcut/video-preview-v26.html",
|
|
44
|
-
"ui://markcut/video-preview-v27.html",
|
|
45
|
-
"ui://markcut/video-preview-v28.html",
|
|
46
|
-
"ui://markcut/video-preview-v29.html",
|
|
47
|
-
"ui://markcut/video-preview-v30.html",
|
|
48
|
-
"ui://markcut/video-preview-v31.html",
|
|
49
|
-
"ui://markcut/video-preview-v32.html",
|
|
50
|
-
"ui://markcut/video-preview-v33.html",
|
|
51
|
-
"ui://markcut/video-preview-v34.html",
|
|
52
|
-
"ui://markcut/video-preview-v35.html",
|
|
53
|
-
"ui://markcut/video-preview-v36.html",
|
|
54
|
-
"ui://markcut/video-preview-v37.html",
|
|
55
|
-
"ui://markcut/video-preview-v40.html",
|
|
56
|
-
"ui://markcut/video-preview-v41.html",
|
|
57
|
-
"ui://markcut/video-preview-v42.html",
|
|
58
|
-
"ui://markcut/video-preview-v43.html",
|
|
59
|
-
"ui://markcut/video-preview-v39.html",
|
|
60
|
-
"ui://markcut/video-preview-v38.html",
|
|
21
|
+
STABLE_RESOURCE_URI,
|
|
22
|
+
...Array.from({length: PREVIEW_VERSION_NUMBER - 1}, (_, index) =>
|
|
23
|
+
`ui://markcut/video-preview-v${index + 1}.html`),
|
|
61
24
|
];
|
|
62
25
|
export const RESOURCE_MIME_TYPE = "text/html;profile=mcp-app";
|
|
63
26
|
// Google Maps JS loads libraries, tiles and Routes RPCs from these HTTPS origins.
|
|
@@ -84,7 +47,17 @@ const KEEP = 10;
|
|
|
84
47
|
export function getPreviewMedia(contentHash) {
|
|
85
48
|
if (!/^[a-f0-9]{64}$/.test(contentHash)) throw new Error("Invalid Markcut content hash");
|
|
86
49
|
try {
|
|
87
|
-
|
|
50
|
+
const compiled=versionPreviewMedia(JSON.parse(readFileSync(resolve(EXPORT_ROOT,"cache",contentHash+".json"),"utf8")));
|
|
51
|
+
// A preview may include its independent, playable editorial-decision tree.
|
|
52
|
+
// The existing app-only media tool returns both trees; no extra MCP tool.
|
|
53
|
+
const sidecar=resolve(EXPORT_ROOT,"cache",contentHash+".editor-decisions.json");
|
|
54
|
+
const editorDecisions=existsSync(sidecar)
|
|
55
|
+
? versionPreviewMedia(JSON.parse(readFileSync(sidecar,"utf8"))) : null;
|
|
56
|
+
const variantsFile=resolve(EXPORT_ROOT,"cache",contentHash+".variants.json");
|
|
57
|
+
const variants=existsSync(variantsFile)
|
|
58
|
+
? Object.fromEntries(Object.entries(JSON.parse(readFileSync(variantsFile,"utf8")))
|
|
59
|
+
.map(([name,tree])=>[name,versionPreviewMedia(tree)])) : null;
|
|
60
|
+
return {compiled,...(variants?{variants}:{}),...(editorDecisions?{editorDecisions}:{})};
|
|
88
61
|
} catch {throw new Error("Unknown or expired Markcut compiled scenes");}
|
|
89
62
|
}
|
|
90
63
|
|
|
@@ -191,7 +164,7 @@ export async function ensureVideoPreview(path, options = {}) {
|
|
|
191
164
|
if(pendingCompiles.has(key))return pendingCompiles.get(key);
|
|
192
165
|
const prior=activeCompilesByPath.get(validatedPath)||Promise.resolve();
|
|
193
166
|
const task=prior.catch(()=>{}).then(async()=>{
|
|
194
|
-
const {parseMarkdownDescriptive,resolveAll,compileDescriptiveRoot}=await import("../player/pipeline.mjs");
|
|
167
|
+
const {parseMarkdownDescriptive,parseMarkdownVariants,resolveVariantOverrides,resolveAll,compileDescriptiveRoot}=await import("../player/pipeline.mjs");
|
|
195
168
|
const report=typeof options.onProgress==="function" ? options.onProgress : ()=>{};
|
|
196
169
|
report("checking-cache");
|
|
197
170
|
const baseDir=dirname(validatedPath);
|
|
@@ -201,6 +174,7 @@ export async function ensureVideoPreview(path, options = {}) {
|
|
|
201
174
|
const cacheDir=resolve(outputRoot,"cache");
|
|
202
175
|
const indexFile=resolve(dir,"cache-index.json");
|
|
203
176
|
const audio=await readPreviewAudio(validatedPath);
|
|
177
|
+
const sidecar=loadEditorDecision(validatedPath,source);
|
|
204
178
|
const referencedAssets=input.assets;
|
|
205
179
|
referencedAssets.sort((a,b)=>String(a[0]).localeCompare(String(b[0])));
|
|
206
180
|
// Compilation generates random scene ids. Identity must be based on inputs,
|
|
@@ -242,16 +216,80 @@ export async function ensureVideoPreview(path, options = {}) {
|
|
|
242
216
|
});
|
|
243
217
|
report("freezing-preview-assets");
|
|
244
218
|
const external=externalizePreviewMedia(footage.compiled,id,publicOrigin(),baseDir);
|
|
245
|
-
finalCompiled=external.compiled;
|
|
219
|
+
finalCompiled=versionPreviewMedia(external.compiled);
|
|
246
220
|
await mkdir(cacheDir,{recursive:true});
|
|
247
221
|
try {await writeFile(cached,JSON.stringify(finalCompiled,null,2),{flag:"wx"});}
|
|
248
222
|
catch(error){if(error.code!=="EEXIST")throw error;}
|
|
249
223
|
}
|
|
224
|
+
// Source identities are immutable, but transport routes can improve (for
|
|
225
|
+
// example, a later version adds preview proxies to old /files/ URLs).
|
|
226
|
+
// Publish a new immutable transport variant when the scene tree changes.
|
|
227
|
+
finalCompiled=versionPreviewMedia(finalCompiled);
|
|
250
228
|
const currentSource=await readFile(validatedPath,"utf8");
|
|
251
229
|
const current=fingerprintInputs(validatedPath,Buffer.from(currentSource));
|
|
252
230
|
const currentHash=createHash("sha256").update(current.source).update("\0").update(JSON.stringify(current.assets)).digest("hex");
|
|
253
231
|
if(currentHash!==sourceHash)
|
|
254
232
|
throw new Error("Source changed during compilation; retry preview");
|
|
233
|
+
// Publish every named Markdown variant alongside Original. These use the
|
|
234
|
+
// same native override semantics as the local Previewer's --variant path.
|
|
235
|
+
// They are ordinary playable videos, not separate markdown documents.
|
|
236
|
+
const parsedVariants=parseMarkdownVariants(source);
|
|
237
|
+
const variantTrees=Object.create(null);
|
|
238
|
+
for(const [name,rootConfig] of parsedVariants.variants){
|
|
239
|
+
// Only genuine named headings are variants; reject accidentally parsed
|
|
240
|
+
// source text such as a literal backslash-n embedded in an H1.
|
|
241
|
+
if(!/^[\p{L}\p{N}][\p{L}\p{N}_-]{0,63}$/u.test(name))continue;
|
|
242
|
+
if(["default","editor-decisions","__proto__","constructor","prototype"].includes(name))
|
|
243
|
+
throw new Error("Reserved Markcut video variant name: "+name);
|
|
244
|
+
const {children:_unused,...overrides}=rootConfig;
|
|
245
|
+
const authored={...parsedVariants.base,...overrides};
|
|
246
|
+
const descriptive=resolveVariantOverrides(authored,[name]);
|
|
247
|
+
report("compiling-variant:"+name);
|
|
248
|
+
const resolved=await resolveAll(descriptive,{
|
|
249
|
+
sourcePath:validatedPath,baseDir,
|
|
250
|
+
seed:parseInt(sourceHash.slice(0,8),16),
|
|
251
|
+
scriptOutputDir:resolve(generated,"tts"),
|
|
252
|
+
mediaOutputDir:resolve(generated,"media"),
|
|
253
|
+
includeOutputDir:resolve(generated,"includes"),
|
|
254
|
+
variants:[name],
|
|
255
|
+
});
|
|
256
|
+
const built=compileDescriptiveRoot(resolved,{googleMapsApiKey:process.env.GOOGLE_MAPS_API_KEY});
|
|
257
|
+
const mixed=withPreviewAudio(built,audio.audioSrc);
|
|
258
|
+
const {renderMapFootage}=await import("./map-footage.mjs");
|
|
259
|
+
const footage=await renderMapFootage(mixed,{
|
|
260
|
+
generatedDir:resolve(generated,"map-footage",id+"-"+createHash("sha256").update(name).digest("hex").slice(0,12)),
|
|
261
|
+
key:process.env.GOOGLE_MAPS_API_KEY,onProgress:report,
|
|
262
|
+
});
|
|
263
|
+
const published=externalizePreviewMedia(footage.compiled,id,publicOrigin(),baseDir);
|
|
264
|
+
variantTrees[name]=versionPreviewMedia(published.compiled);
|
|
265
|
+
}
|
|
266
|
+
if(Object.keys(variantTrees).length){
|
|
267
|
+
await mkdir(resolve(EXPORT_ROOT,"cache"),{recursive:true});
|
|
268
|
+
await atomicJson(resolve(EXPORT_ROOT,"cache",hash+".variants.json"),variantTrees);
|
|
269
|
+
}
|
|
270
|
+
// The Editor Decision view is a separate real Markcut compilation, sharing
|
|
271
|
+
// the same source footage but never replacing the authoritative video tree.
|
|
272
|
+
let edlCompiledUrl;
|
|
273
|
+
if(sidecar){
|
|
274
|
+
report("compiling-editor-decisions");
|
|
275
|
+
const edlMd=editorDecisionToMarkdown(validatedPath,sidecar.edl,source);
|
|
276
|
+
const edlInput=parseMarkdownDescriptive(edlMd);
|
|
277
|
+
const edlResolved=await resolveAll(edlInput,{
|
|
278
|
+
sourcePath:validatedPath,baseDir,seed:parseInt(sourceHash.slice(0,8),16),
|
|
279
|
+
scriptOutputDir:resolve(generated,"tts"),
|
|
280
|
+
mediaOutputDir:resolve(generated,"media"),
|
|
281
|
+
includeOutputDir:resolve(generated,"includes"),
|
|
282
|
+
});
|
|
283
|
+
const edlTree=compileDescriptiveRoot(edlResolved,{googleMapsApiKey:process.env.GOOGLE_MAPS_API_KEY});
|
|
284
|
+
const edlPublished=externalizePreviewMedia(edlTree,id,publicOrigin(),baseDir);
|
|
285
|
+
const edlFrozen=versionPreviewMedia(edlPublished.compiled);
|
|
286
|
+
// Content-addressed output is for immutable preview storage only.
|
|
287
|
+
// No EDL/video version-fingerprint comparison or synchronization gate.
|
|
288
|
+
const edlHash=createHash("sha256").update(hash).update(JSON.stringify(sidecar.edl)).digest("hex");
|
|
289
|
+
edlCompiledUrl=publishCompiledCache(edlHash,edlFrozen);
|
|
290
|
+
await mkdir(cacheDir,{recursive:true});
|
|
291
|
+
await atomicJson(resolve(EXPORT_ROOT,"cache",hash+".editor-decisions.json"),edlFrozen);
|
|
292
|
+
}
|
|
255
293
|
await mkdir(dir,{recursive:true});
|
|
256
294
|
report("publishing-static-preview");
|
|
257
295
|
// Static publication is completed before updating the latest pointer.
|
|
@@ -261,7 +299,7 @@ export async function ensureVideoPreview(path, options = {}) {
|
|
|
261
299
|
await pruneCache(cacheDir,indexFile,index.entries||[],hash);
|
|
262
300
|
const preview={
|
|
263
301
|
id,revisionId:id,contentHash:hash,sourceHash,path:validatedPath,
|
|
264
|
-
compiledUrl, resourceUri:RESOURCE_URI,
|
|
302
|
+
compiledUrl, ...(edlCompiledUrl ? {edlCompiledUrl} : {}), resourceUri:RESOURCE_URI,
|
|
265
303
|
assetBaseUrl:publicOrigin()+"/files/_neoy/markcut/generated/"+id+"/",
|
|
266
304
|
};
|
|
267
305
|
return preview;
|
|
@@ -286,10 +324,10 @@ export function buildPreviewHtml() {
|
|
|
286
324
|
<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-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{flex:1;min-width:0;font-size:12px;color:#526071;text-align:center;overflow-wrap:anywhere}#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{font-size:12px;color:#526071;margin:8px 0}</style>
|
|
287
325
|
<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>
|
|
288
326
|
<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>
|
|
289
|
-
<style>${readFileSync(resolve(moduleDir,'preview-mobile.css'),'utf8')}</style>
|
|
290
|
-
</head><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="
|
|
327
|
+
<style>${readFileSync(resolve(moduleDir,'preview-mobile.css'),'utf8').replace(/\/\*[\s\S]*?\*\//g,'')}</style>
|
|
328
|
+
</head><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="markcut-video-selector-slot"></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>
|
|
291
329
|
<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>
|
|
292
|
-
<div class="review-actions"><button id="changes">Submit feedback</button><span id="status" role="status">Starting preview…</span><button id="approve">Approve</button></div></div></main>
|
|
330
|
+
<div class="review-actions"><button id="questions-submit" type="button" hidden>Submit</button><button id="changes">Submit feedback</button><span id="status" role="status">Starting preview…</span><button id="approve">Approve</button></div></div></main>
|
|
293
331
|
<script src="${playerScriptUrl}"></script>
|
|
294
332
|
<script>${buildPreviewBridgeScript().replaceAll("__MARKCUT_ORIGIN__",JSON.stringify(publicOrigin()))}</script></body></html>`;
|
|
295
333
|
}
|
|
@@ -72,6 +72,75 @@ export function publishPlayerBundle(bundlePath, origin=publicOrigin()) {
|
|
|
72
72
|
return origin+"/files/_neoy/markcut/player/"+filename;
|
|
73
73
|
}
|
|
74
74
|
|
|
75
|
+
// Preview media URLs are a transport view, not the authored Markdown source.
|
|
76
|
+
// Include a stable revision of the source file in their cache key. A CDN may
|
|
77
|
+
// otherwise keep serving an old large original after the Master activates a
|
|
78
|
+
// smaller preview proxy under the same mounted source path.
|
|
79
|
+
export function versionPreviewMedia(compiled, origin=publicOrigin(), mountedRoots=null, exportRoot=EXPORT_ROOT) {
|
|
80
|
+
const prefix=origin+"/preview-files/";
|
|
81
|
+
const originalPrefix=origin+"/files/";
|
|
82
|
+
let mounts=mountedRoots;
|
|
83
|
+
if(!mounts)try{mounts=JSON.parse(readFileSync(join(supportDir,"file-mounts.json"),"utf8"));}catch{mounts={};}
|
|
84
|
+
const versioned=(value)=>{
|
|
85
|
+
if(typeof value!=="string"||(!value.startsWith(prefix)&&!value.startsWith(originalPrefix)))return value;
|
|
86
|
+
let url;
|
|
87
|
+
try {url=new URL(value);}catch{return value;}
|
|
88
|
+
if(url.origin!==origin)return value;
|
|
89
|
+
// Old previews and generated snapshots used regular /files/ URLs, which
|
|
90
|
+
// bypassed the proxy entirely. Redirect only real video source URLs;
|
|
91
|
+
// /files/ still returns the original outside the Markcut preview tree.
|
|
92
|
+
if(url.pathname.startsWith("/files/")){
|
|
93
|
+
if(!/\.(?:mp4|mov|m4v|webm|png|jpe?g|heic|webp)$/i.test(url.pathname))return value;
|
|
94
|
+
const mount=url.pathname.slice("/files/".length).split("/")[0];
|
|
95
|
+
const generated=url.pathname.startsWith("/files/_neoy/markcut/generated/");
|
|
96
|
+
if(!generated && (mount==="_neoy" || typeof mounts[mount]!=="string"))return value;
|
|
97
|
+
url.pathname="/preview-files/"+url.pathname.slice("/files/".length);
|
|
98
|
+
}
|
|
99
|
+
if(!url.pathname.startsWith("/preview-files/"))return value;
|
|
100
|
+
const parts=url.pathname.slice("/preview-files/".length).split("/");
|
|
101
|
+
let mount,relative;
|
|
102
|
+
try {[mount,...relative]=parts.map(decodeURIComponent);}catch{return value;}
|
|
103
|
+
let fingerprint="unmounted";
|
|
104
|
+
if(/^[A-Za-z0-9_-]{1,64}$/.test(mount) && relative.length &&
|
|
105
|
+
relative.every(s=>s&&!s.startsWith(".")&&s!==".."&&!s.includes("/")&&!s.includes("\\"))){
|
|
106
|
+
try{
|
|
107
|
+
let root, pathParts;
|
|
108
|
+
if(mount==="_neoy" && relative[0]==="markcut" && relative[1]==="generated" && relative.length>=4){
|
|
109
|
+
root=realpathSync(join(exportRoot,"generated"));
|
|
110
|
+
pathParts=relative.slice(2);
|
|
111
|
+
} else if(mount!=="_neoy" && typeof mounts[mount]==="string"){
|
|
112
|
+
root=realpathSync(mounts[mount]);
|
|
113
|
+
pathParts=relative;
|
|
114
|
+
}
|
|
115
|
+
if(root && pathParts){
|
|
116
|
+
const source=realpathSync(resolve(root,...pathParts));
|
|
117
|
+
if(source.startsWith(root+sep)){
|
|
118
|
+
const stats=statSync(source);
|
|
119
|
+
fingerprint=`${stats.size}:${stats.mtimeMs}`;
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
}catch{}
|
|
123
|
+
}
|
|
124
|
+
const version=createHash("sha256").update("markcut-preview-proxy-v2\0")
|
|
125
|
+
.update(url.pathname).update("\0").update(fingerprint).digest("hex").slice(0,16);
|
|
126
|
+
url.searchParams.set("pv",version);
|
|
127
|
+
return url.href;
|
|
128
|
+
};
|
|
129
|
+
const walk=(value)=>{
|
|
130
|
+
if(typeof value==="string"){
|
|
131
|
+
if(value.includes("<video") && value.includes("src=")){
|
|
132
|
+
return value.replace(/(\bsrc\s*=\s*)(['"])(https:\/\/[^'"\n]+)\2/g,
|
|
133
|
+
(all,prefix,quote,uri)=>prefix+quote+versioned(uri)+quote);
|
|
134
|
+
}
|
|
135
|
+
return versioned(value);
|
|
136
|
+
}
|
|
137
|
+
if(Array.isArray(value))return value.map(walk);
|
|
138
|
+
if(value&&typeof value==="object")return Object.fromEntries(Object.entries(value).map(([k,v])=>[k,walk(v)]));
|
|
139
|
+
return value;
|
|
140
|
+
};
|
|
141
|
+
return walk(compiled);
|
|
142
|
+
}
|
|
143
|
+
|
|
75
144
|
export function resolvePreviewSource(src,sourceDir,origin=publicOrigin(),mounts=null) {
|
|
76
145
|
if(src.startsWith("data:"))return src;
|
|
77
146
|
if(src.startsWith("https://"))return src;
|
|
@@ -91,9 +160,9 @@ export function externalizePreviewMedia(compiled,revisionId,origin=publicOrigin(
|
|
|
91
160
|
let bytes=0;
|
|
92
161
|
const frozenPaths=new Map();
|
|
93
162
|
function snapshotSource(src){
|
|
94
|
-
if(!sourceDir||src.startsWith("https://")||src.startsWith("data:"))return src;
|
|
95
163
|
if(src.startsWith("http://")||src.startsWith("blob:"))
|
|
96
164
|
throw new Error("Preview media must use HTTPS or local source files");
|
|
165
|
+
if(!sourceDir||src.startsWith("https://")||src.startsWith("data:"))return src;
|
|
97
166
|
const full=src.startsWith("file://")?fileURLToPath(src):isAbsolute(src)?src:resolve(sourceDir,src);
|
|
98
167
|
const root=realpathSync(sourceDir);
|
|
99
168
|
let real;
|
|
@@ -102,7 +171,7 @@ export function externalizePreviewMedia(compiled,revisionId,origin=publicOrigin(
|
|
|
102
171
|
if(frozenPaths.has(real))return frozenPaths.get(real);
|
|
103
172
|
// Dedicated preview route lets NeoY reuse Visioner proxies without changing video.md.
|
|
104
173
|
// If no proxy exists, NeoY serves the original media at the same preview URL.
|
|
105
|
-
if(/\.(mov|mp4|webm)$/i.test(real)) {
|
|
174
|
+
if(/\.(mov|mp4|m4v|webm|png|jpe?g|heic|webp)$/i.test(real)) {
|
|
106
175
|
const mounted=resolveMountedFile(real,origin);
|
|
107
176
|
if(mounted) {
|
|
108
177
|
const previewUrl=mounted.replace(origin+"/files/",origin+"/preview-files/");
|
|
@@ -113,7 +182,7 @@ export function externalizePreviewMedia(compiled,revisionId,origin=publicOrigin(
|
|
|
113
182
|
const stats=statSync(real);
|
|
114
183
|
if(!stats.isFile()||stats.size>512*1024*1024)throw new Error("Preview local media must be a file of at most 512 MB");
|
|
115
184
|
const ext=extname(real).toLowerCase();
|
|
116
|
-
if(!/^[.](png|jpg|jpeg|webp|svg|gif|mp4|mov|webm|wav|mp3|m4a|ogg|vtt|srt)$/.test(ext))
|
|
185
|
+
if(!/^[.](png|jpg|jpeg|webp|svg|gif|mp4|mov|webm|wav|mp3|m4a|ogg|vtt|srt|glb)$/.test(ext))
|
|
117
186
|
throw new Error("Unsupported local preview media extension: "+ext);
|
|
118
187
|
mkdirSync(directory,{recursive:true});
|
|
119
188
|
const filename="file-"+frozenPaths.size+ext;
|
|
@@ -179,17 +248,26 @@ export function publishCompiledCache(hash, compiled, origin=publicOrigin()) {
|
|
|
179
248
|
if(!/^[a-f0-9]{64}$/.test(hash))throw new Error("Invalid compiled hash");
|
|
180
249
|
const dir=join(EXPORT_ROOT,"cache");
|
|
181
250
|
mkdirSync(dir,{recursive:true});
|
|
182
|
-
const file=join(dir,hash+".json");
|
|
183
251
|
const bytes=JSON.stringify(compiled);
|
|
252
|
+
const canonical=join(dir,hash+".json");
|
|
253
|
+
// An old immutable revision may reference the pre-proxy scene tree. Never
|
|
254
|
+
// overwrite it: publish a content-addressed transport variant instead.
|
|
255
|
+
const suffix=existsSync(canonical) && readFileSync(canonical,"utf8")!==bytes
|
|
256
|
+
? "-"+createHash("sha256").update(bytes).digest("hex").slice(0,16) : "";
|
|
257
|
+
const filename=hash+suffix+".json";
|
|
258
|
+
const file=join(dir,filename);
|
|
184
259
|
if(existsSync(file)){
|
|
185
260
|
if(readFileSync(file,"utf8")!==bytes)throw new Error("Immutable compiled cache collision");
|
|
186
261
|
}else writeFileSync(file,bytes,{flag:"wx",mode:0o644});
|
|
187
|
-
return origin+"/files/_neoy/markcut/cache/"+
|
|
262
|
+
return origin+"/files/_neoy/markcut/cache/"+filename;
|
|
188
263
|
}
|
|
189
264
|
|
|
190
265
|
export async function prunePublishedCache(hash) {
|
|
191
266
|
if(!/^[a-f0-9]{64}$/.test(hash))throw new Error("Invalid compiled hash");
|
|
192
|
-
const {rm}=await import("node:fs/promises");
|
|
193
|
-
|
|
267
|
+
const {rm,readdir}=await import("node:fs/promises");
|
|
268
|
+
const cache=join(EXPORT_ROOT,"cache");
|
|
269
|
+
const variants=(await readdir(cache).catch(()=>[])).filter(name=>
|
|
270
|
+
name===hash+".json" || new RegExp("^"+hash+"-[a-f0-9]{16}\\.json$").test(name));
|
|
271
|
+
await Promise.all(variants.map(name=>rm(join(cache,name),{force:true})));
|
|
194
272
|
await rm(join(EXPORT_ROOT,"generated",hash),{recursive:true,force:true});
|
|
195
273
|
}
|