mirror of
https://github.com/nexu-io/openmotion.git
synced 2026-12-01 23:51:42 +08:00
* feat(studio): support browser export under isolated preview origin Run client-side browser export inside a hidden cookie-less preview iframe mounted on PREVIEW_PUBLIC_ORIGIN so deployments with preview isolation can export MP4/WebM without relaxing origin isolation. - Build a standalone lazy-loaded runner bundle (studio/build/preview-browser-export.js) during build:studio and serve it read-only at /api/vendor/browser-export.js with ETag/no-cache on the isolated preview origin. - Extend preview-bridge with origin-checked browser-export-start / browser-export-cancel handlers and progress / Transferable ArrayBuffer responses. - Keep original media fetches authenticated inside isolated preview documents via active ~assets/<lease>/ bases (or ?pt=) + ?original=1 and downgrade snapdom preview fetch credentials for S3 302 redirects. - Gate RenderQueue and useRenderQueue on configured openmotion-preview-origin while continuing to reject opaque sandboxes and unrecognized cross-origin frames, and sanitize returned MIME types strictly to video/mp4 or video/webm. * fix(studio): harden isolated preview browser export bridge validation * docs(architecture): document isolated preview browser export bundle * fix(studio): size isolated export frame from authored dimensions and add stall watchdog --------- Co-authored-by: 罗高 <luogao@users.noreply.github.com>
38 lines
1.3 KiB
JavaScript
38 lines
1.3 KiB
JavaScript
import { build } from 'esbuild';
|
|
import { fileURLToPath } from 'node:url';
|
|
|
|
const root = new URL('../', import.meta.url);
|
|
|
|
// @hyperframes/parsers re-exports AST/DOM parsers from its root barrel, while
|
|
// preview-browser-export only reads pure helpers (decodedUrlPath, CANVAS_DIMENSIONS).
|
|
// Stubbing those unused CJS/Node-only parser imports mirrors studio/vite.config.ts's
|
|
// treeshake rule and keeps preview-browser-export.js lean and browser-safe.
|
|
const UNUSED_PARSER_DEPS = /^(?:@babel\/parser|recast|acorn|acorn-walk|esprima|linkedom|cssomnom|os)$/;
|
|
|
|
await build({
|
|
entryPoints: [fileURLToPath(new URL('studio/src/render/previewBrowserExportEntry.ts', root))],
|
|
outfile: fileURLToPath(new URL('studio/build/preview-browser-export.js', root)),
|
|
bundle: true,
|
|
format: 'iife',
|
|
platform: 'browser',
|
|
target: ['es2022'],
|
|
define: { 'import.meta.env': '{}' },
|
|
minify: true,
|
|
logLevel: 'silent',
|
|
plugins: [
|
|
{
|
|
name: 'drop-unused-hyperframes-parsers',
|
|
setup(b) {
|
|
b.onResolve({ filter: UNUSED_PARSER_DEPS }, (args) => ({
|
|
path: args.path,
|
|
namespace: 'unused-parser-stub',
|
|
sideEffects: false,
|
|
}));
|
|
b.onLoad({ filter: /.*/, namespace: 'unused-parser-stub' }, () => ({
|
|
contents: 'module.exports = {};',
|
|
}));
|
|
},
|
|
},
|
|
],
|
|
});
|