konstantin-paulus c8583eda7f Enhance audio generation options with optional duration parameter
Updated the audio generation functionality to include an optional `duration` parameter in the `GenerateAudioOptions` type. This change allows users to specify the duration for audio prompts, improving flexibility in audio generation. Additionally, validation was added to ensure the duration is a positive number. Updated related documentation to reflect this new option.
2026-07-26 15:18:09 +02:00
..

@diffusionstudio/jsx

JSX runtime, types, and declarative generated assets for authoring Diffusion Studio compositions as code. Projects written against this package are compiled and mounted into the running editor with dapi mount; every JSX element becomes an editable node in the composition — there is no hidden DOM, no CSS resolution, and no measuring pass.

import { generate } from "@diffusionstudio/jsx";

const hero = generate.image({ prompt: "A neon city at night, cinematic" });

export default function Project() {
  return (
    <rect scene="intro" name="Intro" width={1920} height={1080}>
      <image src={hero} />
      <text textAlign="center" textBaseline="middle" fontSize={128} fontWeight="bold">
        Hello World
      </text>
      <captions />
    </rect>
  );
}

Setup

The editor supplies the runtime when a project is mounted, so this package is needed for types and tooling — IntelliSense, tsc --noEmit, and testing components outside the editor.

npm install --save-dev @diffusionstudio/jsx solid-js
// tsconfig.json
{
  "compilerOptions": {
    "jsx": "preserve",
    "jsxImportSource": "@diffusionstudio/jsx"
  }
}

Generated assets

A generate.* call is pure: it validates its options and returns an AssetRef value that is passed wherever a source is expected (src, startFrame, endFrame, refs). Nothing generates until the mounted tree commits; refs never used by a mounted element are dropped.

Documentation

See the JSX API specification shipped with the Diffusion Studio CLI for the full element reference, timing model, media source resolution, and the generate.* declaration API.

Testing outside the editor

renderProject renders a component into any ProjectDocument implementation, so a test can supply a lightweight in-memory document and assert on what the renderer wrote into it:

import { renderProject } from "@diffusionstudio/jsx";
import type { ProjectDocument } from "@diffusionstudio/jsx";
import Project from "./project";

const document: ProjectDocument = /* your in-memory implementation */;
const dispose = renderProject(Project, document);
dispose();

License

MPL-2.0