Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions src/react/original.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions src/shared/hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 };
}