@lalalic/markcut 3.2.63 → 3.2.64
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
|
@@ -231,16 +231,31 @@ export function externalizePreviewMedia(compiled,revisionId,origin=publicOrigin(
|
|
|
231
231
|
return {compiled:replace(compiled),assets};
|
|
232
232
|
}
|
|
233
233
|
|
|
234
|
-
//
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
234
|
+
// The MCP iframe identifies a preview by the requested path. The standalone
|
|
235
|
+
// NeoY viewer identifies the *same* video by its mounted /files/... path.
|
|
236
|
+
// Publish both pointers with identical content, preserving old callers.
|
|
237
|
+
export function publishPreviewRevision(requestedPath,payload,{
|
|
238
|
+
root=EXPORT_ROOT,origin=publicOrigin(),mount=resolveMountedFile,
|
|
239
|
+
}={}) {
|
|
240
|
+
const dir=join(root,"revisions");
|
|
238
241
|
mkdirSync(dir,{recursive:true});
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
242
|
+
function writePointer(identity,data){
|
|
243
|
+
const key=createHash("sha256").update(identity).digest("hex");
|
|
244
|
+
const target=join(dir,key+".json");
|
|
245
|
+
const temp=join(dir,key+"."+process.pid+".tmp");
|
|
246
|
+
writeFileSync(temp,JSON.stringify(data),{mode:0o644});
|
|
247
|
+
renameSync(temp,target);
|
|
248
|
+
return origin+"/files/_neoy/markcut/revisions/"+key+".json";
|
|
249
|
+
}
|
|
250
|
+
const url=writePointer(requestedPath,payload);
|
|
251
|
+
if(typeof payload?.path==="string"){
|
|
252
|
+
const mounted=mount(payload.path,origin);
|
|
253
|
+
if(mounted){
|
|
254
|
+
const canonical=new URL(mounted).pathname;
|
|
255
|
+
if(canonical!==requestedPath)writePointer(canonical,{...payload,requestedPath:canonical});
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
return url;
|
|
244
259
|
}
|
|
245
260
|
|
|
246
261
|
|
|
@@ -4,7 +4,8 @@ import {tmpdir} from 'node:os';
|
|
|
4
4
|
import {join} from 'node:path';
|
|
5
5
|
import {readFileSync} from 'node:fs';
|
|
6
6
|
import vm from 'node:vm';
|
|
7
|
-
import {webcrypto} from 'node:crypto';
|
|
7
|
+
import {webcrypto,createHash} from 'node:crypto';
|
|
8
|
+
import {publishPreviewRevision} from '../src/mcp/remote-assets.mjs';
|
|
8
9
|
import {designViewerUrl,publishDesignViewer} from '../src/mcp/design-viewer.mjs';
|
|
9
10
|
import {buildPreviewBridgeScript} from '../src/mcp/bridge.mjs';
|
|
10
11
|
|
|
@@ -22,6 +23,22 @@ describe('NeoY standalone Markcut design mode',()=>{
|
|
|
22
23
|
expect(()=>designViewerUrl(file,origin,()=>origin+'/files/_neoy/markcut/cache/evil.md')).toThrow();
|
|
23
24
|
expect(()=>designViewerUrl(file,origin,()=>origin+'/files/vlog/../secret.md')).toThrow();
|
|
24
25
|
});
|
|
26
|
+
it('publishes the same revision by both caller path and canonical mounted video.md identity',async()=>{
|
|
27
|
+
const root=await mkdtemp(join(tmpdir(),'markcut-design-revisions-'));
|
|
28
|
+
const caller='/home/source/video.md',canonical='/files/vlog/video.md';
|
|
29
|
+
const payload={requestedPath:caller,path:caller,contentHash:hash,compiledUrl:'https://neoy.example.test/files/_neoy/markcut/cache/'+hash+'.json'};
|
|
30
|
+
const key=value=>createHash('sha256').update(value).digest('hex');
|
|
31
|
+
try {
|
|
32
|
+
const url=publishPreviewRevision(caller,payload,{root,origin:'https://neoy.example.test',
|
|
33
|
+
mount:()=> 'https://neoy.example.test'+canonical});
|
|
34
|
+
expect(url).toContain('/revisions/'+key(caller)+'.json');
|
|
35
|
+
const local=JSON.parse(await readFile(join(root,'revisions',key(caller)+'.json'),'utf8'));
|
|
36
|
+
const mounted=JSON.parse(await readFile(join(root,'revisions',key(canonical)+'.json'),'utf8'));
|
|
37
|
+
expect(local.requestedPath).toBe(caller);
|
|
38
|
+
expect(mounted.requestedPath).toBe(canonical);
|
|
39
|
+
expect(mounted.compiledUrl).toBe(local.compiledUrl);
|
|
40
|
+
}finally{await rm(root,{recursive:true,force:true});}
|
|
41
|
+
});
|
|
25
42
|
it('publishes the same player without creating a second viewer',async()=>{
|
|
26
43
|
const root=await mkdtemp(join(tmpdir(),'markcut-design-ui-'));
|
|
27
44
|
try{
|