Skip to content

The VS Code of video editing, built for agents.

TypeScript

Refactor project structure and remove deprecated components

konstantin-paulusc419c4bc3b56
diff --git a/apps/web/src/components/canvas/canvas.tsx b/apps/web/src/components/canvas/canvas.tsx
index e4764303..9caa448d 100644
--- a/apps/web/src/components/canvas/canvas.tsx
+++ b/apps/web/src/components/canvas/canvas.tsx
@@ -156,10 +156,10 @@ export function Canvas() {
<Toolbar />
<DesktopAppBanner />
<DrawOverlay />
- <SceneInitOverlay
+ {/* <SceneInitOverlay
onDrop={handleDropEvent}
onDragOver={handleDragOver}
- />
+ /> */}
<EngineCanvas />
{/** Deprecated bitecs canvas */}
diff --git a/apps/web/src/pages/editor.tsx b/apps/web/src/pages/editor.tsx
index 7dfb2359..c355947d 100644
--- a/apps/web/src/pages/editor.tsx
+++ b/apps/web/src/pages/editor.tsx
@@ -10,10 +10,15 @@ import { FloatingProjectHeader, SidebarLeft } from "@/components/sidebar-left";
import { useLayout, MIN_TIMELINE_HEIGHT } from "@/context/layout";
import { useEditorApi } from "@/context/dapi";
import { RULER_HEIGHT } from "@/components/engine/timeline/config";
+import { useProjectId } from "@/hooks/use-project-id";
+import { useProject } from "@/projects";
const MIN_CANVAS_HEIGHT = 200;
export function EditorPage() {
+ // The project folder from the route, rendered into the koota world.
+ useProject(useProjectId());
+
const { uiVisible, timelineMinimized, timelineHeight, setTimelineHeight } = useLayout();
const { isDesktop, isFullscreen } = useEditorApi();
const [resizing, setResizing] = createSignal(false);
diff --git a/apps/web/src/pages/project.tsx b/apps/web/src/pages/project.tsx
index 54678771..a790191c 100644
--- a/apps/web/src/pages/project.tsx
+++ b/apps/web/src/pages/project.tsx
@@ -14,7 +14,6 @@ import { useProjectId } from '@/hooks/use-project-id';
import { ECSProvider } from '@/context/ecs';
import { TimelineProvider } from '@/context/timeline';
import { EngineProvider as KootaEngineProvider } from '@/engine';
-import { ProjectLoader } from '@/projects';
/** `/projects/*name` — the editor, with the project folder `name` loaded. */
export function ProjectPage() {
@@ -27,7 +26,6 @@ export function ProjectPage() {
<Show when={projectId()} keyed fallback={<Navigate href="/" />}>
{(id) => (
<KootaEngineProvider projectId={id}>
- <ProjectLoader name={id} />
<EngineProvider projectId={id}>
<EditorApiProvider>
<TimelineProvider>
diff --git a/apps/web/src/projects/index.ts b/apps/web/src/projects/index.ts
index d09e4898..528f3d89 100644
--- a/apps/web/src/projects/index.ts
+++ b/apps/web/src/projects/index.ts
@@ -3,4 +3,4 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
export * from './host';
-export * from './loader';
+export * from './use-project';
diff --git a/apps/web/src/projects/loader.tsx b/apps/web/src/projects/use-project.ts
similarity index 78%
rename from apps/web/src/projects/loader.tsx
rename to apps/web/src/projects/use-project.ts
index ccac5a94..d3dfa008 100644
--- a/apps/web/src/projects/loader.tsx
+++ b/apps/web/src/projects/use-project.ts
@@ -9,23 +9,19 @@ import { mount } from '@diffusionstudio/reconciler';
import { compileProject, projectDir, watchProject } from './host';
+import type { Accessor } from 'solid-js';
import type { Mount } from '@diffusionstudio/reconciler';
-export interface ProjectLoaderProps {
- /** Project folder name under the projects root. */
- name: string;
-}
-
/**
- * Compiles the project folder, renders its JSX into the runtime world, and
- * re-renders on every change on disk. Renders nothing itself; mount it under
- * the koota EngineProvider.
+ * Loads the project folder `name` into the runtime world: compiles it, renders
+ * its JSX, and re-renders on every change on disk. Call under the koota
+ * EngineProvider; the mount follows `name` and is torn down with the owner.
*/
-export function ProjectLoader(props: ProjectLoaderProps): null {
+export function useProject(name: Accessor<string>): void {
const world = useWorld();
createEffect(() => {
- const dir = projectDir(props.name);
+ const dir = projectDir(name());
if (!dir) return;
let mounted: Mount | undefined;
@@ -66,6 +62,4 @@ export function ProjectLoader(props: ProjectLoaderProps): null {
unmount();
});
});
-
- return null;
}
diff --git a/packages/runtime/MIGRATION.md b/packages/runtime/MIGRATION.md
index df450feb..e0340a43 100644
--- a/packages/runtime/MIGRATION.md
+++ b/packages/runtime/MIGRATION.md
@@ -108,7 +108,7 @@ apps/web now depends on `@diffusionstudio/runtime` and `@diffusionstudio/koota-s
- **Engine shell** (`apps/web/src/engine/`, not in this package — it's browser/DOM-coupled, which this package deliberately isn't): `Engine` (`create-engine.ts`) is a class wrapping `createRuntimeWorld` + `runSystems`; it owns canvas mount/resize/DPR, an AudioContext (created or injected, closed on `dispose()` only if it created it), and its own `requestAnimationFrame` loop (`start`/`stop`, plus a public `step(timestamp)` escape hatch for a future host to drive the tick itself and interleave app-side input/HUD systems around it). `context.tsx` (`EngineProvider`/`useEngineContext`) composes koota-solid's `WorldProvider` around `engine.world`, so trait state is read via `useTrait`/`useQuery` directly against the world, not funneled through a context bag. `canvas.tsx` (`EngineCanvas`) is the reusable mount/resize/start component. `hooks/` has a few illustrative per-trait wrappers so far: `useCamera`, `useActiveScene`, `useRunning`.
- **Wired into the live app**: `KootaEngineProvider` (the new `EngineProvider`, aliased) is mounted in `pages/home.tsx` at the same level and lifetime as the old bitecs `EngineProvider` (both keyed on `projectId`), so anything under `EditorPage` can reach the koota world as more gets migrated. In `components/canvas/canvas.tsx`, the koota `EngineCanvas` now occupies the visible `z-1` canvas slot. The old bitecs `<canvas id="engine-canvas">` stays mounted at the same DOM id (so its `EngineProvider`'s `init()` still finds it and keeps initializing, and everything still on `useEngine()`/`useECS()` — Toolbar, drag/drop, sidebars, timeline — keeps working) but is `opacity-0 pointer-events-none`: no longer visible or interactive. Drag/drop handlers moved from the canvas element to its wrapping div so `pointer-events-none` didn't silently kill them.
-- **Projects on disk (desktop only)**: `apps/web/src/projects/` loads real content into the koota world. A project is a folder under a user-picked root (persisted in `dspro.ui.projects.root`) holding an `index.tsx` whose default export renders `<stage>`; the electron main process (`apps/desktop/src/projects.ts`) scans the root, scaffolds new folders (`index.tsx`, `package.json`, `tsconfig.json`, generated `jsx.d.ts`), bundles with esbuild + babel-preset-solid (universal, moduleName `@diffusionstudio/jsx`) and watches for changes. The new `@diffusionstudio/reconciler` package (`packages/reconciler`, modeled on ds-next's `src/reconciler/`) evaluates the CJS bundle against the app's solid-js and `@diffusionstudio/jsx`, and its `RuntimeDocument` implements `ProjectDocument` over the world (`mount(code, world)` wraps both): `<stage>` = the infinite canvas, i.e. the document root itself (`background` sets the Background world trait; no size, no camera fitting), `<rect>` = top-level RECT entity (x/y/width/height/fill as a solid Paint child). Host nodes wrap entities in objects because Solid's universal renderer treats numbers as text. `ProjectLoader` (mounted in `pages/project.tsx`) compiles → renders → re-renders on disk changes. Routes: `/` is the full-screen dashboard (`pages/home.tsx`, no longer a dialog), `/projects/*name` is the editor with the project folder `name` loaded (`useProjectId()` reads it from the route); the old default project id is gone, so there is no editor without a project. Only those two tags/five props so far; no write-back from canvas edits to source yet.
+- **Projects on disk (desktop only)**: `apps/web/src/projects/` loads real content into the koota world. A project is a folder under a user-picked root (persisted in `dspro.ui.projects.root`) holding an `index.tsx` whose default export renders `<stage>`; the electron main process (`apps/desktop/src/projects.ts`) scans the root, scaffolds new folders (`index.tsx`, `package.json`, `tsconfig.json`, generated `jsx.d.ts`), bundles with esbuild + babel-preset-solid (universal, moduleName `@diffusionstudio/jsx`) and watches for changes. The new `@diffusionstudio/reconciler` package (`packages/reconciler`, modeled on ds-next's `src/reconciler/`) evaluates the CJS bundle against the app's solid-js and `@diffusionstudio/jsx`, and its `RuntimeDocument` implements `ProjectDocument` over the world (`mount(code, world)` wraps both): `<stage>` = the infinite canvas, i.e. the document root itself (`background` sets the Background world trait; no size, no camera fitting), `<rect>` = top-level RECT entity (x/y/width/height/fill as a solid Paint child). Host nodes wrap entities in objects because Solid's universal renderer treats numbers as text. `useProject(name)` (`apps/web/src/projects/use-project.ts`, called from `pages/editor.tsx`) compiles → renders → re-renders on disk changes. Routes: `/` is the full-screen dashboard (`pages/home.tsx`, no longer a dialog), `/projects/*name` is the editor with the project folder `name` loaded (`useProjectId()` reads it from the route); the old default project id is gone, so there is no editor without a project. Only those two tags/five props so far; no write-back from canvas edits to source yet.
## Remaining work (suggested order)