The VS Code of video editing, built for agents.
TypeScript
Update project dependencies and enhance JSX support
konstantin-paulus585c2aa4ca83
diff --git a/apps/desktop/src/projects.ts b/apps/desktop/src/projects.tsindex 977a7f7a..68325a5c 100644--- a/apps/desktop/src/projects.ts+++ b/apps/desktop/src/projects.ts@@ -152,6 +152,10 @@ function packageName(name: string): string {return cleaned || "diffusion-project";}+// Types only: the editor supplies the runtime when it mounts the project.+const JSX_VERSION = "^0.1.0";+const SOLID_VERSION = "^1.9.10";+const packageJson = (name: string, displayName: string): PackageJson => ({name: packageName(name),displayName,@@ -159,7 +163,8 @@ const packageJson = (name: string, displayName: string): PackageJson => ({type: "module",main: "index.tsx",devDependencies: {- "solid-js": "^1.9.10",+ "@diffusionstudio/jsx": JSX_VERSION,+ "solid-js": SOLID_VERSION,},});@@ -170,6 +175,7 @@ const TSCONFIG = `{"module": "ESNext","moduleResolution": "bundler","jsx": "preserve",+ "jsxImportSource": "@diffusionstudio/jsx","strict": true,"noEmit": true,"skipLibCheck": true@@ -187,34 +193,6 @@ const STARTER = `export default function Project() {}`;-// Types for the tags the editor renders. Owned by the app and re-synced on-// every open, so projects can't drift from the supported vocabulary.-const TYPES = `// Generated by Diffusion Studio. Types for the tags rendered on the canvas.-// Edits here are overwritten.--/** The infinite canvas. */-interface StageProps {- /** Canvas color, any CSS color. */- background?: string- children?: unknown-}--interface RectProps {- x?: number- y?: number- width?: number- height?: number- fill?: string-}--declare namespace JSX {- interface IntrinsicElements {- stage: StageProps- rect: RectProps- }-}-`;-async function writeIfMissing(dir: string, name: string, content: string): Promise<void> {const path = join(dir, name);if (await exists(path)) return;@@ -234,17 +212,10 @@ async function ensurePackage(dir: string, name: string, displayName: string, entif (next.displayName !== pkg.displayName || next.main !== pkg.main) await writePackage(dir, next);}-async function writeIfChanged(dir: string, name: string, content: string): Promise<void> {- const path = join(dir, name);- const current = await readFile(path, "utf8").catch(() => undefined);- if (current === content) return;- await writeFile(path, content, "utf8");-}-/*** Turns `dir` into a starter TypeScript project: files the project owns are- * written once, the generated types are kept in sync. Opening an up-to-date- * project writes nothing.+ * written once, so opening an up-to-date project writes nothing. Types come+ * from @diffusionstudio/jsx (jsxImportSource), installed by the project.*/export async function scaffold(dir: string, displayName = basename(dir)): Promise<void> {const name = basename(dir);@@ -258,7 +229,6 @@ export async function scaffold(dir: string, displayName = basename(dir)): Promis}await ensurePackage(dir, name, displayName, entry);await writeIfMissing(dir, "tsconfig.json", TSCONFIG);- await writeIfChanged(dir, "jsx.d.ts", TYPES);}/** Creates a fresh project folder under `root`. Fails if the folder exists. */@@ -349,7 +319,7 @@ export async function compileProject(dir: string): Promise<CompileResult> {const entry = await findEntry(dir);if (!entry) return { ok: false, error: noEntryError() };- // Generated types may have drifted since the project was created.+ // Fills in package.json/tsconfig for folders that predate the record.await scaffold(dir);// esbuild resolves symlinks, so the loader has to match on real paths.diff --git a/packages/jsx/src/index.ts b/packages/jsx/src/index.tsindex 41345211..5da0c8d6 100644--- a/packages/jsx/src/index.ts+++ b/packages/jsx/src/index.ts@@ -57,6 +57,7 @@ export type {SequenceProps,ShaderPaintProps,SolidPaintProps,+ StageProps,SurfacePaintProps,SurfaceProps,TextProps,diff --git a/packages/jsx/src/jsx-runtime.ts b/packages/jsx/src/jsx-runtime.tsindex 4681a7ed..64fa0894 100644--- a/packages/jsx/src/jsx-runtime.ts+++ b/packages/jsx/src/jsx-runtime.ts@@ -33,6 +33,7 @@ import type {SequenceProps,ShaderPaintProps,SolidPaintProps,+ StageProps,SurfacePaintProps,SurfaceProps,TextProps,@@ -65,6 +66,7 @@ export declare namespace JSX {export interface IntrinsicElements extends HtmlElementTags, SvgElementTags {img: ImgTag;+ stage: StageProps;group: GroupProps;rect: RectProps | SolidJSX.SVGElementTags["rect"];video: VideoProps;diff --git a/packages/jsx/src/types.ts b/packages/jsx/src/types.tsindex 50b142d1..a434b2cb 100644--- a/packages/jsx/src/types.ts+++ b/packages/jsx/src/types.ts@@ -288,6 +288,13 @@ type CommonProps = TimingProps &| "opacity" | "cornerRadius" | "transition" | "animations">;+/** The infinite canvas every project renders into; only allowed as the root element. */+export type StageProps = {+ /** Canvas color, any CSS color. */+ background?: string;+ children?: SolidJSX.Element;+};+export type GroupProps = CommonProps & Pick<PatchProps, "fill"> & {children?: SolidJSX.Element;};