diff --git a/src/react/original.js b/src/react/original.js index 7b5bfda..bdd7ca0 100644 --- a/src/react/original.js +++ b/src/react/original.js @@ -7467,11 +7467,18 @@ while loading this video: } } function et(n) { + // Ensure we have a valid data source to avoid fetching with a null project id + if (!n.rawJson && !n.projectId && !n.filePath) { + return Promise.reject( + new Error("No project ID, JSON file path, or raw JSON data provided") + ); + } + let e = n.projectId ? n.projectId.split("?")[0] : null, t = n.projectId ? n.projectId.split("?")[1] : null; return new Promise((s, i) => { // NEW: If rawJson is provided, use it directly - const dataPromise = n.rawJson + const dataPromise = n.rawJson ? Promise.resolve(n.rawJson) : ts(e, t, n.filePath, i, n.production); @@ -7501,7 +7508,10 @@ while loading this video: fps: n.fps || a.fps || 60, dpi: d, name: a.name, - projectId: e || (n.filePath && n.filePath.split(".")[0]) || "custom-scene", + projectId: + e || + (n.filePath && n.filePath.split(".")[0]) || + (n.rawJson ? "raw-json" : "custom-scene"), renderingScale: l, element: h, lazyLoad: n.lazyLoad, diff --git a/src/shared/hooks.ts b/src/shared/hooks.ts index 31561ca..69f1822 100644 --- a/src/shared/hooks.ts +++ b/src/shared/hooks.ts @@ -231,14 +231,14 @@ export function useUnicornScene({ // Reset state when projectId or jsonFilePath changes useEffect(() => { - const newKey = `${projectId || ""}-${jsonFilePath || ""}-${scale}-${dpi}-${fps}-${production ? "prod" : "dev"}`; + const newKey = `${projectId || ""}-${jsonFilePath || ""}-${rawJson ? "rawJson" : ""}-${scale}-${dpi}-${fps}-${production ? "prod" : "dev"}`; if (initializationKeyRef.current !== newKey) { hasAttemptedRef.current = false; setInitError(null); isInitializingRef.current = false; initializationKeyRef.current = ""; // Reset the key to allow fresh initialization } - }, [projectId, jsonFilePath, scale, dpi, fps, production]); + }, [projectId, jsonFilePath, rawJson, scale, dpi, fps, production]); return { error: initError }; }