The VS Code of video editing, built for agents.
TypeScript
Refactor mount and node insert functions for improved clarity
konstantin-paulus6c436b965859
diff --git a/apps/cli/jstemp.jsx b/apps/cli/jstemp.jsxnew file mode 100644index 00000000..e2b15ff3--- /dev/null+++ b/apps/cli/jstemp.jsx@@ -0,0 +1,7 @@+export default function Project() {+ return (+ <scene key="my-first-scene" name="MyFirstScene" fill="red" width={1920} height={1080}>++ </scene>+ );+}\ No newline at end of filediff --git a/apps/web/src/context/editor-api/mount.ts b/apps/web/src/context/editor-api/mount.tsindex 23de95ad..0e6023e4 100644--- a/apps/web/src/context/editor-api/mount.ts+++ b/apps/web/src/context/editor-api/mount.ts@@ -22,7 +22,7 @@ export function handleMount(engine: Accessor<Engine>) {const e = engine();const world = e.world;const c = world.components;- let dispose = () => {};+ let dispose = () => { };try {// Evaluate — top-level code (including top-level await) runs here.@@ -50,7 +50,7 @@ export function handleMount(engine: Accessor<Engine>) {if (document.rootEid && hasComponent(world, document.rootEid, c.Scene)) {switchActiveScene(world, document.rootEid);- if (document.rootCreated) e.camera.fitToActiveScene();+ e.camera.fitToActiveScene();}} catch (error) {return { status: "rejected", error: error instanceof Error ? error.message : String(error) };@@ -73,7 +73,7 @@ export function handleNodeInsert(engine: Accessor<Engine>) {return async ({ code, parentId, index }: NodeInsertRequest): Promise<MountResult> => {const e = engine();const world = e.world;- let dispose = () => {};+ let dispose = () => { };try {const parentEid = resolveEntityEid(world, parentId);diff --git a/apps/web/src/utils/jsx.ts b/apps/web/src/utils/jsx.tsindex 5eb1e591..c80c3abf 100644--- a/apps/web/src/utils/jsx.ts+++ b/apps/web/src/utils/jsx.ts@@ -199,8 +199,6 @@ export class WorldDocument implements ProjectDocument<DocumentNode> {public promises: Promise<void>[] = [];public stage: DocumentNode;public rootEid: number | null = null;- /** Whether the root was created fresh rather than reconciled onto an existing keyed node. */- public rootCreated = false;public engine: Engine;private queue: GenaiQueueItem[] = [];@@ -824,8 +822,6 @@ export class WorldDocument implements ProjectDocument<DocumentNode> {const existing = query(this.world, [c.Key, Not(c.Deleted)]).find((eid) => eid !== node.eid && c.Key[eid] === key);- this.rootCreated = existing === undefined;-if (existing === undefined) {const width = c.Computed.width[node.eid] ?? 0;const height = c.Computed.height[node.eid] ?? 0;