Fix editor regressions and add Blender scene and animated material import
This commit is contained in:
+8
-3
@@ -2,10 +2,15 @@ import { type Project, clone, validateProject } from '../engine/schema.ts';
|
||||
import { defaultProject } from '../engine/templates.ts';
|
||||
import { loadDraft } from './persistence.ts';
|
||||
|
||||
export interface EditorStartupOptions { initialProject?: Project; browserOnly?: boolean; }
|
||||
export interface EditorStartupOptions { initialProject?: Project; browserOnly?: boolean; draftScope?: string; }
|
||||
export function editorDraftKey(options: EditorStartupOptions, base = typeof document === "undefined" ? "http://localhost/" : document.baseURI) {
|
||||
if (!options.browserOnly) return "active";
|
||||
const scope = options.draftScope ?? new URL(".", base).pathname;
|
||||
return `hosted:${scope}:${options.initialProject?.id ?? "blank"}`;
|
||||
}
|
||||
export async function loadEditorProject(
|
||||
options: EditorStartupOptions = {},
|
||||
dependencies: { request: typeof fetch; draft: () => Promise<Project | null> } = { request: fetch, draft: loadDraft },
|
||||
dependencies: { request: typeof fetch; draft: (key: string) => Promise<Project | null> } = { request: fetch, draft: loadDraft },
|
||||
) {
|
||||
if (!options.browserOnly) {
|
||||
try {
|
||||
@@ -23,7 +28,7 @@ export async function loadEditorProject(
|
||||
} catch {}
|
||||
}
|
||||
try {
|
||||
const project = await dependencies.draft();
|
||||
const project = await dependencies.draft(editorDraftKey(options));
|
||||
if (project) {
|
||||
validateProject(project);
|
||||
return { project, status: null, restored: true };
|
||||
|
||||
Reference in New Issue
Block a user