Merge pull request #986 from heygen-com/fix/studio-edit-persistence-and-render-css

fix(studio): server-side DOM patching, render CSS scoping, and resilience
This commit is contained in:
Miguel Ángel
2026-05-21 05:53:32 +02:00
committed by GitHub
32 changed files with 1120 additions and 67 deletions
+20 -5
View File
@@ -1,5 +1,3 @@
import { Input, UrlSource, ALL_FORMATS } from "mediabunny";
export interface MediaProbeResult {
duration: number;
width?: number;
@@ -11,6 +9,20 @@ export interface MediaProbeResult {
const cache = new Map<string, MediaProbeResult>();
const inflight = new Map<string, Promise<MediaProbeResult | null>>();
let mediabunnyModule: typeof import("mediabunny") | null | false = null;
async function loadMediabunny() {
if (mediabunnyModule === false) return null;
if (mediabunnyModule) return mediabunnyModule;
try {
mediabunnyModule = await import("mediabunny");
return mediabunnyModule;
} catch {
mediabunnyModule = false;
return null;
}
}
function normalizeUrl(url: string): string {
try {
return new URL(url, window.location.href).href;
@@ -20,9 +32,12 @@ function normalizeUrl(url: string): string {
}
async function probeOne(url: string): Promise<MediaProbeResult | null> {
const input = new Input({
source: new UrlSource(url),
formats: ALL_FORMATS,
const mb = await loadMediabunny();
if (!mb) return null;
const input = new mb.Input({
source: new mb.UrlSource(url),
formats: mb.ALL_FORMATS,
});
try {
const duration = await input.getDurationFromMetadata();