Skip to content

The VS Code of video editing, built for agents.

TypeScript

Update Electron version and enhance documentation for JSX elements

konstantin-paulus7c6406c8e73e
diff --git a/apps/cli/jstemp.jsx b/apps/cli/jstemp.jsx
deleted file mode 100644
index e2b15ff3..00000000
--- a/apps/cli/jstemp.jsx
+++ /dev/null
@@ -1,7 +0,0 @@
-export default function Project() {
- return (
- <scene key="my-first-scene" name="MyFirstScene" fill="red" width={1920} height={1080}>
-
- </scene>
- );
-}
\ No newline at end of file
diff --git a/apps/cli/reference/jsx/README.md b/apps/cli/reference/jsx/README.md
index bc5518ef..c2c5b3df 100644
--- a/apps/cli/reference/jsx/README.md
+++ b/apps/cli/reference/jsx/README.md
@@ -17,7 +17,7 @@ The pipeline is driven by two commands: [`dapi mount`](../mount.md) renders the
| [elements.md](./elements.md) | Element-to-node mapping, coordinates and sizing, the shared property table |
| [scene.md](./scene.md), [group.md](./group.md), [rect.md](./rect.md), [text.md](./text.md), [video.md](./video.md), [image.md](./image.md), [audio.md](./audio.md) | Per-element props |
| [paints.md](./paints.md) | `<solidPaint>`, gradients, `<colorStop>` |
-| [html-paint.md](./html-paint.md) | `<htmlPaint>`: reactive HTML children drawn into the box |
+| [html-paint.md](./html-paint.md) | `<html>`: reactive HTML children drawn into the box |
| [media.md](./media.md) | `src` resolution (paths, URLs, asset ids, `AssetRef`) |
| [timing.md](./timing.md) | `start` / `end` / `sourceIn` / `sourceOut`, time formats |
| [keyframes.md](./keyframes.md) | Keyframe animation and easing |
diff --git a/apps/cli/reference/jsx/elements.md b/apps/cli/reference/jsx/elements.md
index a55479e6..792708a3 100644
--- a/apps/cli/reference/jsx/elements.md
+++ b/apps/cli/reference/jsx/elements.md
@@ -13,10 +13,10 @@ Lowercase intrinsic elements map 1:1 onto internal node types:
| [`<text>`](./text.md) | **Geometry with Text component** | Children become editable glyphs. |
| [`<sequence>`](./sequences.md) | **Sequential group** | Track container for back-to-back clips; positions are explicit. |
| [`<captions>`](./captions.md) | **Caption node** | Transcribes the enclosing scene's audio. |
-| [`<solidPaint>`](./paints.md) | **Solid paint** | Paint child. |
-| [`<linearGradientPaint>` / `<radialGradientPaint>`](./paints.md) | **Gradient paint** | Paint child; takes `<colorStop>` children. |
-| [`<colorStop>`](./paints.md) | **Gradient color stop** | Valid only inside gradient paints. |
-| [`<htmlPaint>`](./html-paint.md) | **Html paint** | Paint child whose children are real, reactive HTML drawn by the browser (html-in-canvas, flagged Chromium API). |
+| [`<solidPaint>`](./paints.md) (alias `<solid>`) | **Solid paint** | Paint child. |
+| [`<linearGradientPaint>` / `<radialGradientPaint>`](./paints.md) (aliases `<linearGradient>` / `<radialGradient>`) | **Gradient paint** | Paint child; takes `<colorStop>` children. |
+| [`<colorStop>`](./paints.md) (alias `<stop>`) | **Gradient color stop** | Valid only inside gradient paints. |
+| [`<html>`](./html-paint.md) (long form `<htmlPaint>`) | **Html paint** | Paint child whose children are real, reactive HTML drawn by the browser (html-in-canvas, flagged Chromium API). |
User-defined components are ordinary Solid components; they compose intrinsics and carry no runtime cost. Only intrinsic elements produce entities.
diff --git a/apps/cli/reference/jsx/html-paint.md b/apps/cli/reference/jsx/html-paint.md
index 6b79333f..5a2f80e6 100644
--- a/apps/cli/reference/jsx/html-paint.md
+++ b/apps/cli/reference/jsx/html-paint.md
@@ -1,19 +1,19 @@
-# `<htmlPaint>`
+# `<html>`
-A paint whose children are **real HTML**. The browser lays them out at the parent geometry's box size and the result is drawn into the box via the [html-in-canvas](https://github.com/WICG/html-in-canvas) API. Use it for content that is painful to build from `<rect>` and `<text>`: styled cards, tables, code blocks, flex/grid layouts.
+A paint whose children are **real HTML** (long form: `<htmlPaint>`). The browser lays them out at the parent geometry's box size and the result is drawn into the box via the [html-in-canvas](https://github.com/WICG/html-in-canvas) API. Use it for content that is painful to build from `<rect>` and `<text>`: styled cards, tables, code blocks, flex/grid layouts.
```tsx
<rect x={40} y={40} width={800} height={120} cornerRadius={24}>
- <htmlPaint>
+ <html>
<div style="display:flex;align-items:center;gap:16px;height:100%;
background:#111;color:#fff;font:500 40px Inter;padding:0 32px;">
<span style="color:#7c9cff;">01</span> Introduction
</div>
- </htmlPaint>
+ </html>
</rect>
```
-Inside `<htmlPaint>`, lowercase tags are DOM elements with Solid's own HTML typings, not composition elements (`<audio>` and `<video>` stay the editor's). Composition elements cannot nest inside it, and HTML tags are invalid outside it.
+Inside `<html>`, every tag is a DOM element: names the editor also uses (`<rect>`, `<text>`, and inside `<svg>` also `<linearGradient>` and `<stop>`) become plain HTML/SVG here, because tags resolve by environment. HTML tags remain invalid outside it.
## Reactivity
@@ -24,9 +24,9 @@ const [count, setCount] = createSignal(0);
setInterval(() => setCount((c) => c + 1), 1000);
<rect width={400} height={200}>
- <htmlPaint>
+ <html>
<div style="font:700 96px Inter;color:#fff;">{count()}</div>
- </htmlPaint>
+ </html>
</rect>
```
@@ -40,7 +40,7 @@ Like all paints it stacks with siblings in document order and clips to the paren
## Requirements and limitations
-- Requires Chromium's html-in-canvas API, currently behind `chrome://flags/#canvas-draw-element`. Mounting `<htmlPaint>` fails with an explicit error when the API is unavailable.
+- Requires Chromium's html-in-canvas API, currently behind `chrome://flags/#canvas-draw-element`. Mounting `<html>` fails with an explicit error when the API is unavailable.
- Markup renders with the page's fonts and full CSS. Event handlers are dropped — the content is painted, not interactive.
- The content lives only as long as its mount: it is not persisted and does not render in exports yet.
- CSS animations in the markup play on the wall clock, not the composition playhead. Animate the parent element's props with [keyframes](./keyframes.md) for frame-accurate motion.
diff --git a/apps/cli/reference/jsx/paints.md b/apps/cli/reference/jsx/paints.md
index 4d018eef..5e4327a8 100644
--- a/apps/cli/reference/jsx/paints.md
+++ b/apps/cli/reference/jsx/paints.md
@@ -13,13 +13,15 @@ Internally a node's fill is not a property but a **paint child**: a sub-entity a
Paint elements are valid inside any filled visual element (`<rect>`, `<scene>`, `<text>`, `<video>`, `<image>`); a `<group>` has no fill of its own, so it takes none. Multiple paints stack in document order; later paints render on top, and a paint child on a `<video>`/`<image>` draws over the media paint created by `src`.
-| Element | Props | Meaning |
-| ------- | ----- | ------- |
-| `<solidPaint>` | `color` (**required**), `opacity` | Solid fill; equivalent to the `fill` prop. |
-| `<linearGradientPaint>` | `rotation`, `opacity` | Linear gradient across the parent's box; `rotation` in degrees, `0` = left to right. |
-| `<radialGradientPaint>` | `rotation`, `opacity` | Radial gradient centered in the parent's box. |
-| `<colorStop>` | `offset` (**required**, `0`-`1`), `color` (**required**), `opacity` | Gradient color stop. Valid only inside gradient paints, which take no other children. |
-| [`<htmlPaint>`](./html-paint.md) | `opacity`, HTML children | Reactive HTML laid out and drawn into the parent's box (flagged Chromium API). |
+| Element | Alias | Props | Meaning |
+| ------- | ----- | ----- | ------- |
+| `<solidPaint>` | `<solid>` | `color` (**required**), `opacity` | Solid fill; equivalent to the `fill` prop. |
+| `<linearGradientPaint>` | `<linearGradient>` | `rotation`, `opacity` | Linear gradient across the parent's box; `rotation` in degrees, `0` = left to right. |
+| `<radialGradientPaint>` | `<radialGradient>` | `rotation`, `opacity` | Radial gradient centered in the parent's box. |
+| `<colorStop>` | `<stop>` | `offset` (**required**, `0`-`1`), `color` (**required**), `opacity` | Gradient color stop. Valid only inside gradient paints, which take no other children. |
+| [`<html>`](./html-paint.md) | `<htmlPaint>` | `opacity`, HTML children | Reactive HTML laid out and drawn into the parent's box (flagged Chromium API). |
+
+Both names of a pair work everywhere; names shared with SVG (`<linearGradient>`, `<stop>`) are unambiguous because tags resolve by environment: inside an [`<html>`](./html-paint.md) paint they are the real SVG elements, anywhere else the paints.
Colors accept any CSS color; alpha is ignored (use `opacity`). `color`, `opacity`, and `offset` are animatable (see [keyframes.md](./keyframes.md)), so gradients can animate. Paints have no spatial or timing props and cannot be document roots.
diff --git a/apps/desktop/package.json b/apps/desktop/package.json
index 994ec3f4..6daa1a8b 100644
--- a/apps/desktop/package.json
+++ b/apps/desktop/package.json
@@ -28,7 +28,7 @@
"@electron-forge/maker-zip": "^7.11.1",
"@electron-forge/publisher-github": "^7.11.1",
"@types/node": "^24.10.1",
- "electron": "^35.1.2",
+ "electron": "^43.1.1",
"esbuild": "^0.28.1",
"typescript": "~5.9.3"
},
diff --git a/apps/web/src/context/editor-api/mount.ts b/apps/web/src/context/editor-api/mount.ts
index eabb92a2..229d10ed 100644
--- a/apps/web/src/context/editor-api/mount.ts
+++ b/apps/web/src/context/editor-api/mount.ts
@@ -16,8 +16,8 @@ import type { Engine } from "@/components/engine";
function documentRootKeys(world: Engine["world"], document: WorldDocument): string[] {
const keys: string[] = [];
- for (const node of document.stage.children ?? []) {
- if (node.kind !== "element") continue;
+ for (const node of document.stage.children) {
+ if (node.eid === undefined) continue;
const key = world.components.Key[node.eid];
if (key !== undefined) keys.push(key);
}
diff --git a/apps/web/src/context/editor-api/selection.ts b/apps/web/src/context/editor-api/selection.ts
index 2f3298c4..ca021fe7 100644
--- a/apps/web/src/context/editor-api/selection.ts
+++ b/apps/web/src/context/editor-api/selection.ts
@@ -54,6 +54,7 @@ export function entityType(world: EngineWorld, eid: number): string {
case PaintType.RADIAL_GRADIENT: return "radialGradientPaint";
case PaintType.IMAGE: return "imagePaint";
case PaintType.VIDEO: return "videoPaint";
+ case PaintType.HTML: return "htmlPaint";
default: return "paint";
}
}
diff --git a/apps/web/src/utils/jsx.ts b/apps/web/src/utils/jsx.ts
index addecee1..e4a4937a 100644
--- a/apps/web/src/utils/jsx.ts
+++ b/apps/web/src/utils/jsx.ts
@@ -48,35 +48,49 @@ import type { AssetRef, AssetSpecInput, ProjectDocument, ProjectTick } from "@di
import type { Engine, EngineWorld } from "@/components/engine";
import type { GenerationMemo } from "@/utils/jsx-generation";
+/**
+ * Shadow node: the renderer's host tree, kept as plain objects. Lifecycle
+ * calls update this representation first; entities and DOM nodes are only
+ * created when a node is inserted into the live tree, at which point its
+ * environment (ECS world vs DOM under an <htmlPaint>) is known and all
+ * initial props have been recorded — Solid attaches a subtree's root last.
+ */
type DocumentNode = {
- kind: "element";
- eid: number;
- start?: number;
- end?: number;
- sourceIn?: number;
- sourceOut?: number;
- objectFit?: keyof typeof SCALE_MODE_MAP;
- host?: HtmlHost;
+ id: number;
+ tag?: string;
+ text?: string;
+ props: Record<string, unknown>;
+ children: DocumentNode[];
parent?: DocumentNode;
- children?: DocumentNode[];
-} | {
- kind: "root";
eid?: number;
- parent?: undefined;
- children?: DocumentNode[];
-} | {
- kind: "text";
- text: string;
- dom?: Text;
- parent?: DocumentNode;
- children?: DocumentNode[];
-} | {
- kind: "dom";
- el: Element;
- parent?: DocumentNode;
- children?: DocumentNode[];
+ dom?: Element | Text;
+ host?: HtmlHost;
};
+let nextNodeId = 1;
+
+function makeNode(init: Pick<DocumentNode, "tag" | "text" | "eid">): DocumentNode {
+ return { id: nextNodeId++, ...init, props: {}, children: [] };
+}
+
+/**
+ * Reads a timing prop as local frames. The record always holds raw `Time`
+ * values (numbers are seconds), so every read parses; an unparsable value
+ * reads as absent until its own apply rejects it.
+ */
+function timingProp(node: DocumentNode, name: "start" | "end" | "sourceIn" | "sourceOut"): number | undefined {
+ const value = node.props[name];
+ return value === undefined ? undefined : parseFrames(String(value), 30);
+}
+
+const SVG_NS = "http://www.w3.org/2000/svg";
+
+// Children of an SVG element stay in the SVG namespace, except under
+// <foreignObject>, which switches back to HTML.
+function isSvgContext(el: Element): boolean {
+ return el.namespaceURI === SVG_NS && el.localName !== "foreignObject";
+}
+
// Multiple new scenes are laid side by side in render order.
const PLACEMENT_GAP = 40;
@@ -302,7 +316,7 @@ export class WorldDocument implements ProjectDocument<DocumentNode> {
}
public constructor(engine: Engine, target?: { parentEid: number }) {
- this.stage = { kind: "root", eid: target?.parentEid };
+ this.stage = makeNode({ tag: "#root", eid: target?.parentEid });
this.engine = engine;
}
@@ -335,15 +349,16 @@ export class WorldDocument implements ProjectDocument<DocumentNode> {
// be generated), before captions read the scene's final placement.
{
for (const { node, targetKey, type } of this.queue) {
- if (node.kind !== "element" || type !== "sync" || !targetKey) continue;
+ if (node.eid === undefined || type !== "sync" || !targetKey) continue;
+ const nodeEid = node.eid;
const targetEid = query(world, [c.Key, Not(c.Deleted)]).find(eid => c.Key[eid] === targetKey);
assert(targetEid !== undefined, `syncTo: no other element carries key "${targetKey}"`);
- const source = findGeometryAsset(world, node.eid);
+ const source = findGeometryAsset(world, nodeEid);
assert(
source !== null && (source.type === "AUDIO" || source.type === "VIDEO"),
- `syncTo: node ${node.eid} has no audio or video source to align`,
+ `syncTo: node ${nodeEid} has no audio or video source to align`,
);
const targetSource = findGeometryAsset(world, targetEid);
assert(
@@ -354,41 +369,44 @@ export class WorldDocument implements ProjectDocument<DocumentNode> {
const { offsetSeconds } = await computeAudioSyncOffsetCached(source, targetSource);
const offsetFrames = Math.round(offsetSeconds * world.frameRate);
- const parentEid = getParentEntity(world, node.eid);
+ const parentEid = getParentEntity(world, nodeEid);
const parentDelay = parentEid !== null ? (c.Computed.delay[parentEid] ?? 0) : 0;
const delay = (c.Computed.delay[targetEid] ?? 0) + offsetFrames - parentDelay;
- setComponent(world, node.eid, c.Delay, delay);
+ setComponent(world, nodeEid, c.Delay, delay);
const targetStart = (c.Computed.start[targetEid] ?? 0) - parentDelay;
const targetEnd = (c.Computed.end[targetEid] ?? 0) - parentDelay;
- const duration = findAssetDuration(world, node.eid);
+ const duration = findAssetDuration(world, nodeEid);
// `sourceIn`/`sourceOut` are source-relative; default to the overlap
// with the target window. `end` (timeline) converts through `delay`.
- const trimStart = node.sourceIn ?? Math.max(0, targetStart - delay);
- const trimEnd = node.sourceOut
- ?? (node.end !== undefined
- ? node.end - delay
+ const end = timingProp(node, "end");
+ const trimStart = timingProp(node, "sourceIn") ?? Math.max(0, targetStart - delay);
+ const trimEnd = timingProp(node, "sourceOut")
+ ?? (end !== undefined
+ ? end - delay
: (duration !== null ? Math.min(duration, targetEnd - delay) : targetEnd - delay));
assert(trimEnd > trimStart, `syncTo: the aligned clip does not overlap the window of "${targetKey}"`);
- setComponent(world, node.eid, c.Trim, { start: trimStart, end: trimEnd });
- node.sourceIn = trimStart;
- node.sourceOut = trimEnd;
- node.start = delay + trimStart;
+ setComponent(world, nodeEid, c.Trim, { start: trimStart, end: trimEnd });
+ node.props.sourceIn = `${trimStart}f`;
+ node.props.sourceOut = `${trimEnd}f`;
+ delete node.props.end;
+ node.props.start = `${delay + trimStart}f`;
}
}
// Handle captioning queue
{
for (const { node, type } of this.queue) {
- if (node.kind !== "element" || hasComponent(world, node.eid, c.Deleted) || type !== "caption" || c.AssetId[node.eid]) continue;
- const sceneEid = getSceneAncestor(world, node.eid);
+ if (node.eid === undefined || hasComponent(world, node.eid, c.Deleted) || type !== "caption" || c.AssetId[node.eid]) continue;
+ const nodeEid = node.eid;
+ const sceneEid = getSceneAncestor(world, nodeEid);
if (!sceneEid || !hasAudioSources(world, sceneEid)) continue;
const { asset, trim } = await transcribeScene(this.engine, sceneEid);
- setComponent(world, node.eid, c.AssetId, asset.id);
- setComponent(world, node.eid, c.Trim, trim);
+ setComponent(world, nodeEid, c.AssetId, asset.id);
+ setComponent(world, nodeEid, c.Trim, trim);
}
}
@@ -436,7 +454,7 @@ export class WorldDocument implements ProjectDocument<DocumentNode> {
const world = this.world;
const c = world.components;
- let current = this.rootEid ?? (this.stage.kind === "root" ? this.stage.eid : undefined) ?? null;
+ let current = this.rootEid ?? this.stage.eid ?? null;
while (current !== null && !hasComponent(world, current, c.Deleted)) {
if (hasComponent(world, current, c.Playback)) return current;
current = getParentEntity(world, current);
@@ -451,133 +469,109 @@ export class WorldDocument implements ProjectDocument<DocumentNode> {
private async generateInto(node: DocumentNode, ref: AssetRef, memo: GenerationMemo): Promise<void> {
const world = this.world;
const c = world.components;
- if (node.kind !== "element" || hasComponent(world, node.eid, c.Deleted)) return;
+ if (node.eid === undefined || hasComponent(world, node.eid, c.Deleted)) return;
+ const eid = node.eid;
try {
const asset = await resolveGeneratedAsset(world, ref, memo);
await this.mountSource(node, asset.id);
} finally {
- world.history.untrack(() => removeComponent(world, node.eid, c.Generating));
+ world.history.untrack(() => removeComponent(world, eid, c.Generating));
}
}
public createElement(tag: string): DocumentNode {
- return this.track(() => this.createElementImpl(tag));
+ return makeNode({ tag });
+ }
+
+ public createTextNode(text: string): DocumentNode {
+ return makeNode({ text });
}
- private createElementImpl(tag: string): DocumentNode {
+ /** Tag-specific entity setup for a node materializing into the ECS world. */
+ private createEntityForTag(node: DocumentNode): number {
const world = this.world;
const c = world.components;
+ const eid = createEntity(world);
- switch (tag) {
+ switch (node.tag) {
case "scene": {
- const eid = createEntity(world);
- const node: DocumentNode = { kind: "element", eid };
setComponent(world, eid, c.Geometry, GeometryType.RECT);
addComponent(world, eid, c.Scene);
addComponent(world, eid, c.ClipsContent);
setComponent(world, eid, c.Playback, {});
setComponent(world, eid, c.Name, getNextName(world, "Scene"));
- return node;
+ break;
} case "group": {
- const eid = createEntity(world);
- const node: DocumentNode = { kind: "element", eid };
setComponent(world, eid, c.Geometry, GeometryType.RECT);
addComponent(world, eid, c.Group);
setComponent(world, eid, c.Name, getNextName(world, "Group"));
- return node;
+ break;
} case "rect": {
- const eid = createEntity(world);
- const node: DocumentNode = { kind: "element", eid };
setComponent(world, eid, c.Geometry, GeometryType.RECT);
setComponent(world, eid, c.Name, getNextName(world, "Rect"));
- return node;
+ break;
} case "sequence": {
- const eid = createEntity(world);
- const node: DocumentNode = { kind: "element", eid };
addComponent(world, eid, c.Group);
addComponent(world, eid, c.Sequential);
setComponent(world, eid, c.Name, getNextName(world, "Sequence"));
- return node;
+ break;
} case "video": {
- const eid = createEntity(world);
- const node: DocumentNode = { kind: "element", eid };
setComponent(world, eid, c.Geometry, GeometryType.RECT);
setComponent(world, eid, c.Name, getNextName(world, "Video"));
- return node;
+ break;
} case "image": {
- const eid = createEntity(world);
- const node: DocumentNode = { kind: "element", eid };
setComponent(world, eid, c.Geometry, GeometryType.RECT);
setComponent(world, eid, c.Name, getNextName(world, "Image"));
- return node;
+ break;
} case "audio": {
- const eid = createEntity(world);
- const node: DocumentNode = { kind: "element", eid };
addComponent(world, eid, c.Audio);
setComponent(world, eid, c.Geometry, GeometryType.RECT);
setComponent(world, eid, c.Name, getNextName(world, "Audio"));
- return node;
+ break;
} case "text": {
- const eid = createEntity(world);
- const node: DocumentNode = { kind: "element", eid };
setComponent(world, eid, c.Geometry, GeometryType.TEXT);
const fid = createEntity(world);
setComponent(world, fid, c.Paint, PaintType.SOLID);
setComponent(world, fid, c.Color, 0xffffff);
appendChild(world, fid, eid);
- return node;
+ break;
} case "captions": {
assert(!this.committed, "<captions> cannot be created after commit; re-mount instead");
- const eid = createEntity(world);
- const node: DocumentNode = { kind: "element", eid };
setComponent(world, eid, c.Geometry, GeometryType.TEXT);
setComponent(world, eid, c.Caption, {});
setComponent(world, eid, c.Name, getNextName(world, "Captions"));
this.queue.push({ node, type: "caption" });
- return node;
- } case "solidPaint": {
- const eid = createEntity(world);
- const node: DocumentNode = { kind: "element", eid };
+ break;
+ } case "solidPaint": case "solid": {
setComponent(world, eid, c.Paint, PaintType.SOLID);
setComponent(world, eid, c.Color, 0xE0E0E0);
- return node;
- } case "linearGradientPaint": {
- const eid = createEntity(world);
- const node: DocumentNode = { kind: "element", eid };
+ break;
+ } case "linearGradientPaint": case "linearGradient": {
setComponent(world, eid, c.Paint, PaintType.LINEAR_GRADIENT);
- return node;
- } case "radialGradientPaint": {
- const eid = createEntity(world);
- const node: DocumentNode = { kind: "element", eid };
+ break;
+ } case "radialGradientPaint": case "radialGradient": {
setComponent(world, eid, c.Paint, PaintType.RADIAL_GRADIENT);
- return node;
- } case "colorStop": {
- const eid = createEntity(world);
- const node: DocumentNode = { kind: "element", eid };
+ break;
+ } case "colorStop": case "stop": {
setComponent(world, eid, c.ColorStop, {});
- return node;
- } case "htmlPaint": {
+ break;
+ } case "htmlPaint": case "html": {
assert(
isHtmlInCanvasSupported(),
- "<htmlPaint> requires the html-in-canvas API; enable chrome://flags/#canvas-draw-element",
+ "<html> requires the html-in-canvas API; enable chrome://flags/#canvas-draw-element",
);
- const eid = createEntity(world);
setComponent(world, eid, c.Paint, PaintType.HTML);
const host = new HtmlHost(world);
addComponent(world, eid, c.HtmlHost, false);
c.HtmlHost[eid] = host;
- return { kind: "element", eid, host };
+ node.host = host;
+ break;
} default: {
- // Any tag outside the editor's vocabulary is HTML: a real DOM
- // element, valid only inside <htmlPaint> (enforced on insert).
- return { kind: "dom", el: document.createElement(tag) };
+ assert(false, `<${node.tag}> is only valid inside <html> content`);
}
}
- }
- public createTextNode(text: string): DocumentNode {
- // This is the text inside a tag, there is no engine equivalent
- return { kind: "text", text };
+ return eid;
}
/**
@@ -589,81 +583,108 @@ export class WorldDocument implements ProjectDocument<DocumentNode> {
public element(eid: number): DocumentNode {
const world = this.world;
const c = world.components;
- const node: DocumentNode = { kind: "element", eid };
+ const node = makeNode({ tag: "#entity", eid });
const delay = hasComponent(world, eid, c.Delay) ? c.Delay[eid] : 0;
if (hasComponent(world, eid, c.Trim)) {
const start = c.Trim.start[eid];
const end = c.Trim.end[eid];
if (start !== undefined) {
- node.sourceIn = start;
+ node.props.sourceIn = `${start}f`;
}
if (end !== undefined) {
- node.sourceOut = end;
+ node.props.sourceOut = `${end}f`;
}
}
// start = timeline placement of source-0 (Delay) shifted by the source in point.
- if (hasComponent(world, eid, c.Delay) || node.sourceIn !== undefined) {
- node.start = delay + (node.sourceIn ?? 0);
+ if (hasComponent(world, eid, c.Delay) || node.props.sourceIn !== undefined) {
+ node.props.start = `${delay + (timingProp(node, "sourceIn") ?? 0)}f`;
}
return node;
}
private reconcileTiming(node: DocumentNode) {
- if (node.kind !== "element") return;
+ if (node.eid === undefined) return;
const world = this.world;
const c = world.components;
const eid = node.eid;
- const sourceIn = node.sourceIn ?? 0;
- const start = node.start ?? 0;
+ const sourceIn = timingProp(node, "sourceIn") ?? 0;
+ const start = timingProp(node, "start") ?? 0;
+ const end = timingProp(node, "end");
+ const sourceOut = timingProp(node, "sourceOut");
const delay = start - sourceIn;
setComponent(world, eid, c.Delay, delay);
- if (node.sourceIn !== undefined) {
- setComponent(world, eid, c.Trim, { start: node.sourceIn });
+ if (timingProp(node, "sourceIn") !== undefined) {
+ setComponent(world, eid, c.Trim, { start: sourceIn });
}
- if (node.sourceOut !== undefined) {
- setComponent(world, eid, c.Trim, { end: node.sourceOut });
- } else if (node.end !== undefined) {
- const trimEnd = node.end - delay;
- assert(trimEnd > sourceIn, `\`end\` must be after \`start\`, got start=${start}, end=${node.end}`);
+ if (sourceOut !== undefined) {
+ setComponent(world, eid, c.Trim, { end: sourceOut });
+ } else if (end !== undefined) {
+ const trimEnd = end - delay;
+ assert(trimEnd > sourceIn, `\`end\` must be after \`start\`, got start=${start}, end=${end}`);
setComponent(world, eid, c.Trim, { end: trimEnd });
}
}
public replaceText(node: DocumentNode, text: string) {
- assert(node.kind === "text", "replaceText target is not a text node");
+ assert(node.text !== undefined, "replaceText target is not a text node");
node.text = text;
// Text inside HTML content is backed by a live DOM node.
- if (node.dom) {
- node.dom.data = text;
+ if (node.dom !== undefined) {
+ (node.dom as Text).data = text;
return;
}
- // Already-inserted text (a live mount updating a signal inside <text>)
- // must land in the world too; insertNode only writes Chars on insert.
+ // Already-materialized text inside a <text> element (a live mount
+ // updating a signal) must land in the world too.
const parent = node.parent;
- if (parent?.kind === "element") {
- this.track(() => setComponent(this.world, parent.eid, this.world.components.Chars, text));
+ if (parent !== undefined && this.isTextEntity(parent)) {
+ this.track(() => this.assignChars(parent));
}
}
public isTextNode(node: DocumentNode): boolean {
- return node.kind === "text";
+ return node.text !== undefined;
+ }
+
+ private isTextEntity(node: DocumentNode): boolean {
+ const c = this.world.components;
+ return c.Geometry[node.eid ?? -1] === GeometryType.TEXT;
+ }
+
+ /**
+ * Chars mirrors the concatenation of a text element's text children — a
+ * reactive segment compiles to its own text node (`frame {frame()}` is two).
+ */
+ private assignChars(parent: DocumentNode): void {
+ const c = this.world.components;
+ const texts = parent.children.filter((child) => child.text !== undefined);
+ assert(parent.eid !== undefined, "syncChars parent is not a text entity");
+
+ if (texts.length === 0) {
+ removeComponent(this.world, parent.eid, c.Chars);
+ } else {
+ setComponent(this.world, parent.eid, c.Chars, texts.map((child) => child.text).join(""));
+ }
}
public setProperty(node: DocumentNode, name: string, value: unknown) {
- if (name === "children" || name === "ref" || value === undefined) return;
- if (node.kind === "dom") {
- setDomProperty(node.el, name, value);
- return;
+ if (name === "children" || name === "ref" || value === undefined || node.text !== undefined) return;
+ // update shadow node props
+ node.props[name] = value;
+
+ // dom path
+ if (node.dom !== undefined) {
+ setDomProperty(node.dom as Element, name, value);
+ } else if (node.eid !== undefined) {
+ // ecs path
+ this.track(() => this.applyEcsProperty(node, name, value));
}
- if (node.kind !== "element") return;
- this.track(() => this.setPropertyImpl(node, name, value));
}
- private setPropertyImpl(node: DocumentNode & { kind: "element" }, name: string, value: unknown) {
+ private applyEcsProperty(node: DocumentNode, name: string, value: unknown) {
const world = this.world;
const c = world.components;
- const eid = node.eid;
+ const eid = node.eid!;
switch (name) {
case "name": {
@@ -785,28 +806,27 @@ export class WorldDocument implements ProjectDocument<DocumentNode> {
} case "start": {
const parsed = parseFrames(String(value), 30);
assert(typeof parsed === "number", "`start` must be a string or number" + `, value: ${value}`);
- node.start = parsed;
+ node.props.start = value;
this.reconcileTiming(node);
break;
} case "end": {
const parsed = parseFrames(String(value), 30);
assert(typeof parsed === "number", "`end` must be a string or number" + `, value: ${value}`);
- node.end = parsed;
- // `end` and `sourceOut` are two spellings of the clip's out edge.
- node.sourceOut = undefined;
+ node.props.end = value;
+ delete node.props.sourceOut;
this.reconcileTiming(node);
break;
} case "sourceIn": {
const parsed = parseFrames(String(value), 30);
assert(typeof parsed === "number", "`sourceIn` must be a string or number" + `, value: ${value}`);
- node.sourceIn = parsed;
+ node.props.sourceIn = value;
this.reconcileTiming(node);
break;
} case "sourceOut": {
const parsed = parseFrames(String(value), 30);
assert(typeof parsed === "number", "`sourceOut` must be a string or number" + `, value: ${value}`);
- node.sourceOut = parsed;
- node.end = undefined;
+ node.props.sourceOut = value;
+ delete node.props.end;
this.reconcileTiming(node);
break;
}
@@ -913,19 +933,18 @@ export class WorldDocument implements ProjectDocument<DocumentNode> {
if (this.committed) this.mountSource(node, value).catch(console.error);
else this.promises.push(this.mountSource(node, value));
break;
- } case "objectFit":
+ } case "objectFit": {
assert(typeof value === "string", "`objectFit` must be a string" + `, value: ${value}`);
assert(value in SCALE_MODE_MAP, `invalid objectFit value: "${value}"`);
-
- // The media paint is attached asynchronously
- node.objectFit = value as keyof typeof SCALE_MODE_MAP;
+ const mode = SCALE_MODE_MAP[value as keyof typeof SCALE_MODE_MAP];
for (const pid of query(world, [c.Paint, ChildOf(eid), Not(c.Deleted)])) {
if (c.Paint[pid] === PaintType.IMAGE || c.Paint[pid] === PaintType.VIDEO) {
- setComponent(world, pid, c.ScaleMode, SCALE_MODE_MAP[node.objectFit]);
+ setComponent(world, pid, c.ScaleMode, mode);
}
}
break;
+ }
case "key": {
assert(typeof value === "string", "`key` must be a string" + `, value: ${value}`);
assert(value.trim().length > 0, "`key` must be a non-empty string");
@@ -945,7 +964,8 @@ export class WorldDocument implements ProjectDocument<DocumentNode> {
case "fontWeight":
if (value === "normal") value = "400";
else if (value === "bold") value = "700";
- assert(typeof value === "string", "`fontWeight` must be a string" + `, value: ${value}`);
+ else if (typeof value === "number") value = String(value);
+ assert(typeof value === "string", "`fontWeight` must be a number, \"normal\", or \"bold\"" + `, value: ${value}`);
assert(Number.isFinite(Number(value)), "`fontWeight` must be a number");
setComponent(world, eid, c.TextStyle, { fontWeight: value });
break;
@@ -1028,91 +1048,138 @@ export class WorldDocument implements ProjectDocument<DocumentNode> {
}
public insertNode(parent: DocumentNode, node: DocumentNode, anchor?: DocumentNode) {
- this.track(() => this.insertNodeImpl(parent, node, anchor));
+ // Shadow first — re-inserting an attached node moves it (how the
+ // renderer reorders), so detach it from its previous position.
+ if (node.parent) {
+ node.parent.children = node.parent.children.filter((child) => child !== node);
+ }
+ const index = anchor !== undefined ? parent.children.indexOf(anchor) : -1;
+ if (index === -1) parent.children.push(node);
+ else parent.children.splice(index, 0, node);
+ node.parent = parent;
+
+ if (parent === this.stage || parent.eid !== undefined || parent.dom !== undefined) {
+ this.track(() => this.attach(parent, node, anchor));
+ }
}
- private insertNodeImpl(parent: DocumentNode, node: DocumentNode, anchor?: DocumentNode) {
- const c = this.world.components;
+ /**
+ * Inserts `node` under a live parent, materializing it first if needed.
+ * The environment is the parent's: children of an <htmlPaint> (or of any
+ * DOM node) become real DOM, everything else lands in the ECS world.
+ */
+ private attach(parent: DocumentNode, node: DocumentNode, anchor?: DocumentNode): void {
+ const world = this.world;
+ const c = world.components;
- // HTML content: the parent is <htmlPaint>'s host or a DOM node within it.
- const domParent = parent.kind === "dom" ? parent.el
- : parent.kind === "element" && parent.host ? parent.host.element
- : null;
-
- if (domParent !== null && node.kind !== "root") {
- assert(node.kind !== "element", "composition elements cannot nest inside <htmlPaint>");
- const el = node.kind === "dom" ? node.el : (node.dom ??= document.createTextNode(node.text));
- const anchorEl = anchor?.kind === "dom" ? anchor.el
- : anchor?.kind === "text" ? anchor.dom ?? null
- : null;
- domParent.insertBefore(el, anchorEl);
- } else if (node.kind === "dom") {
- assert(false, `<${node.el.tagName.toLowerCase()}> is only valid inside <htmlPaint>`);
- } else if (parent.kind === "root" && node.kind === "element") {
- if (parent.eid === undefined) {
- assert(hasComponent(this.world, node.eid, c.Geometry), "this element cannot be a document root");
- const key = c.Key[node.eid];
- assert(key !== undefined, "`key` is required for `root` nodes");
-
- // Find and replace node with the same key
- const existing = query(this.world, [c.Key, Not(c.Deleted)])
- .find((eid) => eid !== node.eid && c.Key[eid] === key);
-
- if (existing === undefined) {
- const width = c.Computed.width[node.eid] ?? 0;
- const height = c.Computed.height[node.eid] ?? 0;
- const position = this.findPlacement(width, height);
- setComponent(this.world, node.eid, c.Position, position);
- } else {
- setComponent(this.world, node.eid, c.Position, {
- x: c.Position.x[existing] ?? 0,
- y: c.Position.y[existing] ?? 0,
- });
- deleteEntity(this.world, existing);
- }
+ const domParent = parent.host?.element ?? parent.dom;
+ if (domParent !== undefined) {
+ assert(domParent instanceof Element, "text nodes cannot contain children");
+ if (node.dom === undefined) this.materializeDom(node, isSvgContext(domParent));
+ domParent.insertBefore(node.dom!, anchor?.dom ?? null);
+ return;
+ }
+
+ // Text in the ECS world is the content of a text element; anywhere else
+ // only the empty placeholders Solid's control flow leaves behind pass.
+ if (node.text !== undefined) {
+ if (parent === this.stage) return;
+ if (this.isTextEntity(parent)) this.assignChars(parent);
+ else assert(node.text === "", `<${parent.tag}> cannot contain text`);
+ return;
+ }
+
+ if (node.eid === undefined) this.materializeEcs(node);
+ const eid = node.eid!;
+
+ if (parent !== this.stage) {
+ this.attachEntity(eid, parent.eid!);
+ return;
+ }
+
+ if (this.stage.eid !== undefined) {
+ this.attachEntity(eid, this.stage.eid);
+ } else {
+ assert(hasComponent(world, eid, c.Geometry), "this element cannot be a document root");
+ const key = c.Key[eid];
+ assert(key !== undefined, "`key` is required for `root` nodes");
+
+ // Find and replace node with the same key
+ const existing = query(world, [c.Key, Not(c.Deleted)])
+ .find((other) => other !== eid && c.Key[other] === key);
+
+ if (existing === undefined) {
+ const width = c.Computed.width[eid] ?? 0;
+ const height = c.Computed.height[eid] ?? 0;
+ setComponent(world, eid, c.Position, this.findPlacement(width, height));
} else {
- appendChild(this.world, node.eid, parent.eid);
+ setComponent(world, eid, c.Position, {
+ x: c.Position.x[existing] ?? 0,
+ y: c.Position.y[existing] ?? 0,
+ });
+ deleteEntity(world, existing);
}
+ }
+
+ this.rootEid = eid;
+ }
- this.rootEid = node.eid;
- } else if (parent.kind === "element" && node.kind === "text") {
- assert(hasComponent(this.world, parent.eid, c.Geometry), `<${parent.kind}> cannot contain text`);
- assert(c.Geometry[parent.eid] === GeometryType.TEXT, `<${parent.kind}> is not a text element`);
- setComponent(this.world, parent.eid, c.Chars, node.text);
- } else if (parent.kind === "element" && node.kind === "element") {
- appendChild(this.world, node.eid, parent.eid);
+ // Fresh entities append; an entity that already has a parent is a Solid
+ // reorder or reparent (e.g. a <For> moving rows in a live mount).
+ private attachEntity(eid: number, parentEid: number): void {
+ const currentParent = getParentEntity(this.world, eid);
+ if (currentParent === null) {
+ appendChild(this.world, eid, parentEid);
+ return;
+ }
+ if (currentParent !== parentEid) {
+ removeChild(this.world, eid, currentParent);
+ appendChild(this.world, eid, parentEid);
}
+ }
- // Re-inserting an attached node moves it (how the renderer reorders),
- // so detach it from its previous position first.
- if (node.parent) {
- node.parent.children = node.parent.children?.filter((child) => child !== node);
+ /**
+ * Creates the entity for an element and replays its shadow state: tag
+ * components, children (attached while the subtree is still detached from
+ * the stage), then recorded props in authored order.
+ */
+ private materializeEcs(node: DocumentNode): void {
+ node.eid = this.createEntityForTag(node);
+ for (const child of node.children) this.attach(node, child);
+ for (const [name, value] of Object.entries(node.props)) this.applyEcsProperty(node, name, value);
+ }
+
+ /** Builds the DOM subtree for a node under an <htmlPaint>, props applied. */
+ private materializeDom(node: DocumentNode, svg: boolean): void {
+ if (node.text !== undefined) {
+ node.dom = document.createTextNode(node.text);
+ return;
}
- parent.children ??= [];
- const index = anchor !== undefined ? parent.children.indexOf(anchor) : -1;
- if (index === -1) parent.children.push(node);
- else parent.children.splice(index, 0, node);
- node.parent = parent;
+ const tag = node.tag!;
+ const inSvg = svg || tag === "svg";
+ const el = inSvg ? document.createElementNS(SVG_NS, tag) : document.createElement(tag);
+ node.dom = el;
+ for (const child of node.children) {
+ this.materializeDom(child, inSvg && tag !== "foreignObject");
+ el.appendChild(child.dom!);
+ }
+ for (const [name, value] of Object.entries(node.props)) setDomProperty(el, name, value);
}
public removeNode(parent: DocumentNode, node: DocumentNode) {
- const c = this.world.components;
+ parent.children = parent.children.filter((child) => child !== node);
+ node.parent = undefined;
this.track(() => {
- if (node.kind === "dom") {
- node.el.remove();
- } else if (node.kind === "text" && node.dom) {
+ if (node.dom !== undefined) {
node.dom.remove();
- } else if (parent.kind === "element" && node.kind === "text") {
- removeComponent(this.world, parent.eid, c.Chars);
- } else if (parent.kind === "element" && node.kind === "element") {
+ } else if (node.text !== undefined) {
+ if (this.isTextEntity(parent)) this.assignChars(parent);
+ } else if (node.eid !== undefined && parent !== this.stage && parent.eid !== undefined) {
removeChild(this.world, node.eid, parent.eid);
deleteEntity(this.world, node.eid);
}
});
-
- parent.children = parent.children?.filter((child) => child !== node);
- node.parent = undefined;
}
public getParentNode(node: DocumentNode): DocumentNode | undefined {
@@ -1120,16 +1187,14 @@ export class WorldDocument implements ProjectDocument<DocumentNode> {
}
public getFirstChild(node: DocumentNode): DocumentNode | undefined {
- return node.children?.[0];
+ return node.children[0];
}
public getNextSibling(node: DocumentNode): DocumentNode | undefined {
- const index = node.parent?.children?.indexOf(node);
- if (index === undefined || index == -1) {
- return undefined;
- }
-
- return node.parent?.children?.[index + 1];
+ const siblings = node.parent?.children;
+ if (siblings === undefined) return undefined;
+ const index = siblings.indexOf(node);
+ return index === -1 ? undefined : siblings[index + 1];
}
private findPlacement(width: number, height: number): { x: number; y: number } {
@@ -1145,7 +1210,8 @@ export class WorldDocument implements ProjectDocument<DocumentNode> {
* (resolved during mount) and generated assets (landing after commit).
*/
private async mountSource(node: DocumentNode, src: string) {
- if (node.kind !== "element") return;
+ if (node.eid === undefined) return;
+ const eid = node.eid;
const asset = await resolveAsset(this.world, src);
const transcript = asset.type === 'TRANSCRIPT' ? await resolveTranscript(asset) : null;
@@ -1153,7 +1219,6 @@ export class WorldDocument implements ProjectDocument<DocumentNode> {
this.track(() => {
const world = this.world;
const c = world.components;
- const eid = node.eid;
if (asset.type === 'TRANSCRIPT') {
// AssetId set here makes commit's caption phase skip transcription.
@@ -1165,7 +1230,8 @@ export class WorldDocument implements ProjectDocument<DocumentNode> {
} else if (asset.type === 'IMAGE' || asset.type === 'VIDEO') {
const fid = createEntity(world);
setComponent(world, fid, c.Paint, asset.type === 'IMAGE' ? PaintType.IMAGE : PaintType.VIDEO);
- setComponent(world, fid, c.ScaleMode, node.objectFit ? SCALE_MODE_MAP[node.objectFit] : ScaleMode.COVER);
+ const objectFit = node.props.objectFit as keyof typeof SCALE_MODE_MAP | undefined;
+ setComponent(world, fid, c.ScaleMode, objectFit ? SCALE_MODE_MAP[objectFit] : ScaleMode.COVER);
setComponent(world, fid, c.AssetId, asset.id);
appendChild(world, fid, eid);
@@ -1193,7 +1259,7 @@ function setDomProperty(el: Element, name: string, value: unknown): void {
if (typeof value === "string") style.cssText = value;
else if (typeof value === "object" && value !== null) Object.assign(style, value);
} else if (name === "class" || name === "className") {
- el.className = String(value);
+ el.setAttribute("class", String(value));
} else if (name === "classList") {
if (typeof value === "object" && value !== null) {
for (const [key, on] of Object.entries(value)) {
diff --git a/docs/composition.md b/docs/composition.md
index 76b8f679..7e81e5d1 100644
--- a/docs/composition.md
+++ b/docs/composition.md
@@ -38,7 +38,7 @@ The first rendered root becomes the active scene. New roots are auto-placed on t
| `<audio>` | Sound only, no spatial props. |
| `<sequence>` | Track container for back-to-back clips (positions are explicit); hosts transitions. |
| `<captions>` | Styled captions: transcribes the scene's audio, or mounts a transcript given via `src`. |
-| `<solidPaint>`, `<linearGradientPaint>`, `<radialGradientPaint>`, `<colorStop>` | Fills, declared as children; see [Paints](#paints). |
+| `<solidPaint>`, `<linearGradientPaint>`, `<radialGradientPaint>`, `<colorStop>` (aliases `<solid>`, `<linearGradient>`, `<radialGradient>`, `<stop>`) | Fills, declared as children; see [Paints](#paints). |
User-defined components are ordinary Solid components; only intrinsic elements produce nodes.
@@ -180,7 +180,7 @@ A node's fill is a **paint child**; the `fill` prop is shorthand for a solid pai
</rect>
```
-`<solidPaint>` takes `color` (required) and `opacity`; gradient paints take `rotation` and `opacity` and only `<colorStop>` children (`offset` and `color` required). Colors are any CSS color; alpha is ignored, use `opacity`.
+`<solidPaint>` takes `color` (required) and `opacity`; gradient paints take `rotation` and `opacity` and only `<colorStop>` children (`offset` and `color` required). Colors are any CSS color; alpha is ignored, use `opacity`. Each paint tag has a short alias (`<solid>`, `<linearGradient>`, `<radialGradient>`, `<stop>`, `<html>`); the SVG name overlap is unambiguous because tags resolve by environment.
## Generated assets
diff --git a/package-lock.json b/package-lock.json
index 681aad69..50ddb836 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -51,7 +51,7 @@
"@electron-forge/maker-zip": "^7.11.1",
"@electron-forge/publisher-github": "^7.11.1",
"@types/node": "^24.10.1",
- "electron": "^35.1.2",
+ "electron": "^43.1.1",
"esbuild": "^0.28.1",
"typescript": "~5.9.3"
}
@@ -941,6 +941,16 @@
"node": ">= 14.17.5"
}
},
+ "node_modules/@electron-internal/extract-zip": {
+ "version": "1.0.4",
+ "resolved": "https://registry.npmjs.org/@electron-internal/extract-zip/-/extract-zip-1.0.4.tgz",
+ "integrity": "sha512-Zr1Vs7E9tpCNhZHDAbFVXc2gEVCG9RqPDjrno5+bdgB6LRAuvgyMHJut4NCVyYwtAieapMzc3fiQ3CSTi75ARg==",
+ "dev": true,
+ "license": "BSD-2-Clause",
+ "engines": {
+ "node": ">=22.12.0"
+ }
+ },
"node_modules/@electron/asar": {
"version": "3.4.1",
"resolved": "https://registry.npmjs.org/@electron/asar/-/asar-3.4.1.tgz",
@@ -5940,22 +5950,22 @@
"license": "MIT"
},
"node_modules/electron": {
- "version": "35.7.5",
- "resolved": "https://registry.npmjs.org/electron/-/electron-35.7.5.tgz",
- "integrity": "sha512-dnL+JvLraKZl7iusXTVTGYs10TKfzUi30uEDTqsmTm0guN9V2tbOjTzyIZbh9n3ygUjgEYyo+igAwMRXIi3IPw==",
+ "version": "43.1.1",
+ "resolved": "https://registry.npmjs.org/electron/-/electron-43.1.1.tgz",
+ "integrity": "sha512-I5c5vfuVvaXpWx3IZdwvXgxQW44+e7OP1wXGVQkogLeSFSkUZ6sLCcWV05AdEcs65AO5tAIJJwbp7ixw+LdarA==",
"dev": true,
- "hasInstallScript": true,
"license": "MIT",
"dependencies": {
- "@electron/get": "^2.0.0",
- "@types/node": "^22.7.7",
- "extract-zip": "^2.0.1"
+ "@electron-internal/extract-zip": "^1.0.1",
+ "@electron/get": "^5.0.0",
+ "@types/node": "^24.9.0"
},
"bin": {
- "electron": "cli.js"
+ "electron": "cli.js",
+ "install-electron": "install.js"
},
"engines": {
- "node": ">= 12.20.55"
+ "node": ">= 22.12.0"
}
},
"node_modules/electron-installer-dmg": {
@@ -5987,87 +5997,37 @@
"license": "ISC"
},
"node_modules/electron/node_modules/@electron/get": {
- "version": "2.0.3",
- "resolved": "https://registry.npmjs.org/@electron/get/-/get-2.0.3.tgz",
- "integrity": "sha512-Qkzpg2s9GnVV2I2BjRksUi43U5e6+zaQMcjoJy0C+C5oxaKl+fmckGDQFtRpZpZV0NQekuZZ+tGz7EA9TVnQtQ==",
+ "version": "5.0.0",
+ "resolved": "https://registry.npmjs.org/@electron/get/-/get-5.0.0.tgz",
+ "integrity": "sha512-pjoBpru1KdEtcExBnuHAP1cAc/5faoedw0hzJkL3o4/IJp7HNF1+fbrdxT3gMYRX2oJfvnA/WXeCTVQpYYxyJA==",
"dev": true,
"license": "MIT",
"dependencies": {
"debug": "^4.1.1",
- "env-paths": "^2.2.0",
- "fs-extra": "^8.1.0",
- "got": "^11.8.5",
+ "env-paths": "^3.0.0",
+ "graceful-fs": "^4.2.11",
"progress": "^2.0.3",
- "semver": "^6.2.0",
+ "semver": "^7.6.3",
"sumchecker": "^3.0.1"
},
"engines": {
- "node": ">=12"
+ "node": ">=22.12.0"
},
"optionalDependencies": {
- "global-agent": "^3.0.0"
- }
- },
- "node_modules/electron/node_modules/@types/node": {
- "version": "22.20.0",
- "resolved": "https://registry.npmjs.org/@types/node/-/node-22.20.0.tgz",
- "integrity": "sha512-QWlFW2wf3nTjC13/DqRnBpR4ZO36VJH/JVBkA/vcnmbTBNQIlnObqyqZE1tUR7+Ni23Lda8R1BxMfbXRpCUx5g==",
- "dev": true,
- "license": "MIT",
- "dependencies": {
- "undici-types": "~6.21.0"
- }
- },
- "node_modules/electron/node_modules/fs-extra": {
- "version": "8.1.0",
- "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-8.1.0.tgz",
- "integrity": "sha512-yhlQgA6mnOJUKOsRUFsgJdQCvkKhcz8tlZG5HBQfReYZy46OwLcY+Zia0mtdHsOo9y/hP+CxMN0TU9QxoOtG4g==",
- "dev": true,
- "license": "MIT",
- "dependencies": {
- "graceful-fs": "^4.2.0",
- "jsonfile": "^4.0.0",
- "universalify": "^0.1.0"
- },
- "engines": {
- "node": ">=6 <7 || >=8"
+ "undici": "^7.24.4"
}
},
- "node_modules/electron/node_modules/jsonfile": {
- "version": "4.0.0",
- "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-4.0.0.tgz",
- "integrity": "sha512-m6F1R3z8jjlf2imQHS2Qez5sjKWQzbuuhuJ/FKYFRZvPE3PuHcSMVZzfsLhGVOkfd20obL5SWEBew5ShlquNxg==",
- "dev": true,
- "license": "MIT",
- "optionalDependencies": {
- "graceful-fs": "^4.1.6"
- }
- },
- "node_modules/electron/node_modules/semver": {
- "version": "6.3.1",
- "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.1.tgz",
- "integrity": "sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==",
- "dev": true,
- "license": "ISC",
- "bin": {
- "semver": "bin/semver.js"
- }
- },
- "node_modules/electron/node_modules/undici-types": {
- "version": "6.21.0",
- "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-6.21.0.tgz",
- "integrity": "sha512-iwDZqg0QAGrg9Rav5H4n0M64c3mkR59cJ6wQp+7C4nI0gsmExaedaYLNO44eT4AtBBwjbTiGPMlt2Md0T9H9JQ==",
- "dev": true,
- "license": "MIT"
- },
- "node_modules/electron/node_modules/universalify": {
- "version": "0.1.2",
- "resolved": "https://registry.npmjs.org/universalify/-/universalify-0.1.2.tgz",
- "integrity": "sha512-rBJeI5CXAlmy1pV+617WB9J63U6XcazHHF2f2dbJix4XzpUF0RS3Zbj0FGIOCAva5P/d/GBOYaACQ1w+0azUkg==",
+ "node_modules/electron/node_modules/env-paths": {
+ "version": "3.0.0",
+ "resolved": "https://registry.npmjs.org/env-paths/-/env-paths-3.0.0.tgz",
+ "integrity": "sha512-dtJUTepzMW3Lm/NPxRf3wP4642UWhjL2sQxc+ym2YMj1m/H2zDNQOlezafzkHwn6sMstjHTwG6iQQsctDW/b1A==",
"dev": true,
"license": "MIT",
"engines": {
- "node": ">= 4.0.0"
+ "node": "^12.20.0 || ^14.13.1 || >=16.0.0"
+ },
+ "funding": {
+ "url": "https://github.com/sponsors/sindresorhus"
}
},
"node_modules/emoji-regex": {
@@ -11068,6 +11028,17 @@
"node": ">=14.17"
}
},
+ "node_modules/undici": {
+ "version": "7.28.0",
+ "resolved": "https://registry.npmjs.org/undici/-/undici-7.28.0.tgz",
+ "integrity": "sha512-cRZYrTDwWznlnRiPjggAGxZXanty6M8RV1ff8Wm4LWXBp7/IG8v5DnOm74DtUBp9OONpK75YlPnIjQqX0dBDtA==",
+ "dev": true,
+ "license": "MIT",
+ "optional": true,
+ "engines": {
+ "node": ">=20.18.1"
+ }
+ },
"node_modules/undici-types": {
"version": "7.18.2",
"resolved": "https://registry.npmjs.org/undici-types/-/undici-types-7.18.2.tgz",
diff --git a/packages/jsx/src/jsx-runtime.ts b/packages/jsx/src/jsx-runtime.ts
index cfe99f62..8fdd335d 100644
--- a/packages/jsx/src/jsx-runtime.ts
+++ b/packages/jsx/src/jsx-runtime.ts
@@ -26,7 +26,17 @@ import type {
VideoProps,
} from "./types";
-type HtmlElementTags = Omit<SolidJSX.HTMLElementTags, "audio" | "video">;
+// "html" is dropped alongside the media tags: in composition context it is
+// the <htmlPaint> alias, and as a DOM tag it is useless inside a paint host.
+type HtmlElementTags = Omit<SolidJSX.HTMLElementTags, "audio" | "video" | "html">;
+
+// SVG vocabulary for <htmlPaint> content. Tags the editor also declares keep
+// their composition types below; the runtime resolves the actual meaning by
+// environment, the type system approximates with the composition side.
+type SvgElementTags = Omit<
+ SolidJSX.SVGElementTags,
+ "image" | "linearGradient" | "radialGradient" | "rect" | "stop" | "text"
+>;
export declare namespace JSX {
// Solid's Element type keeps Solid's control flow (<For>, <Show>, …) and
@@ -37,7 +47,7 @@ export declare namespace JSX {
children: unknown;
}
- export interface IntrinsicElements extends HtmlElementTags {
+ export interface IntrinsicElements extends HtmlElementTags, SvgElementTags {
scene: SceneProps;
group: GroupProps;
rect: RectProps;
@@ -48,9 +58,14 @@ export declare namespace JSX {
sequence: SequenceProps;
captions: CaptionsProps;
solidPaint: SolidPaintProps;
+ solid: SolidPaintProps;
linearGradientPaint: GradientPaintProps;
+ linearGradient: GradientPaintProps;
radialGradientPaint: GradientPaintProps;
+ radialGradient: GradientPaintProps;
colorStop: ColorStopProps;
+ stop: ColorStopProps;
htmlPaint: HtmlPaintProps;
+ html: HtmlPaintProps;
}
}
diff --git a/samples/reconciler/01-static-tree.tsx b/samples/reconciler/01-static-tree.tsx
new file mode 100644
index 00000000..606c7885
--- /dev/null
+++ b/samples/reconciler/01-static-tree.tsx
@@ -0,0 +1,41 @@
+/* @jsxImportSource @diffusionstudio/jsx */
+/* Static materialization: a deep tree lands in one mount, fully formed.
+ *
+ * dapi mount samples/reconciler/01-static-tree.tsx
+ *
+ * Check with `dapi node tree`:
+ * - nested group with children, props replayed in authored order
+ * - `fill` prop and explicit paint children coexist (no duplicate paints)
+ * - multi-segment text renders "sum = 42" (concatenated, not last-wins)
+ * - timing props land as Delay/Trim ("start: 1s; in: 1s; out: 3s")
+ * Re-mounting replaces the scene in place (same key, same position).
+ */
+
+export default () => (
+ <scene key="sample-static" name="Static tree" width={960} height={540} fill="#101014">
+ <group x={40} y={40}>
+ <rect width={200} height={120} cornerRadius={16} fill="#ff4466" />
+ <rect x={220} width={200} height={120} rotation={8} opacity={0.8}>
+ <linearGradient>
+ <stop offset={0} color="#22ccff" />
+ <stop offset={1} color="#7744ff" opacity={0.5} />
+ </linearGradient>
+ </rect>
+ </group>
+
+ <text x={40} y={220} fontSize={48} fontFamily="Inter" fontWeight={700}>
+ sum = {6 * 7}
+ </text>
+
+ <rect
+ x={40}
+ y={320}
+ width={160}
+ height={90}
+ fill="#44dd88"
+ start={1}
+ end={3}
+ animations={[{ type: "fade", phase: "in", duration: 0.5 }]}
+ />
+ </scene>
+);
diff --git a/samples/reconciler/02-live-signals.tsx b/samples/reconciler/02-live-signals.tsx
new file mode 100644
index 00000000..3eeb92b5
--- /dev/null
+++ b/samples/reconciler/02-live-signals.tsx
@@ -0,0 +1,39 @@
+/* @jsxImportSource @diffusionstudio/jsx */
+/* Live reactivity: post-commit updates flow through the materialized nodes.
+ *
+ * dapi mount --live samples/reconciler/02-live-signals.tsx
+ *
+ * Watch the stage:
+ * - the blue rect slides and recolors (reactive setProperty)
+ * - the counter text updates in place (replaceText into Chars)
+ * - the green badge blinks (Show insert/remove; its placeholder text node
+ * sits under the scene without crashing the ECS side)
+ * Re-mount without --live to freeze and dispose the graph.
+ */
+
+import { Show, createSignal } from "solid-js";
+
+const [n, setN] = createSignal(0);
+setInterval(() => setN(n() + 1), 400);
+
+export default () => (
+ <scene key="sample-live" name="Live signals" width={960} height={540} fill="#101014">
+ <rect
+ x={40 + (n() * 24) % 700}
+ y={60}
+ width={120}
+ height={120}
+ cornerRadius={n() % 2 === 0 ? 8 : 60}
+ fill={n() % 2 === 0 ? "#2288ff" : "#22ccff"}
+ />
+
+ <text x={40} y={260} fontSize={64} fontFamily="Inter">
+ tick {n()}
+ </text>
+
+ <Show when={n() % 4 < 2}>
+ <rect x={40} y={380} width={80} height={80} fill="#44dd88" />
+ <text x={140} y={400} fontSize={36}>on air</text>
+ </Show>
+ </scene>
+);
diff --git a/samples/reconciler/03-live-list.tsx b/samples/reconciler/03-live-list.tsx
new file mode 100644
index 00000000..18781555
--- /dev/null
+++ b/samples/reconciler/03-live-list.tsx
@@ -0,0 +1,42 @@
+/* @jsxImportSource @diffusionstudio/jsx */
+/* Keyed list: <For> reorders, inserts, and removes materialized subtrees.
+ *
+ * dapi mount --live samples/reconciler/03-live-list.tsx
+ *
+ * Every 1.2s the first card cycles to the back: Solid MOVES the existing
+ * nodes (reorder/reparent path, not delete + recreate; entity ids in
+ * `dapi node tree` stay stable across shuffles). Every 4s card E is
+ * removed or re-inserted (fresh subtree each time).
+ */
+
+import { For, createSignal } from "solid-js";
+
+const COLORS: Record<string, string> = {
+ A: "#ff4466",
+ B: "#22ccff",
+ C: "#44dd88",
+ D: "#ffaa22",
+ E: "#aa66ff",
+};
+
+const [items, setItems] = createSignal(["A", "B", "C", "D"]);
+
+setInterval(() => setItems((prev) => [...prev.slice(1), prev[0]]), 1200);
+setInterval(() => {
+ setItems((prev) => (prev.includes("E") ? prev.filter((x) => x !== "E") : [...prev, "E"]));
+}, 4000);
+
+export default () => (
+ <scene key="sample-list" name="Live list" width={960} height={540} fill="#101014">
+ <For each={items()}>
+ {(label, i) => (
+ <group x={40 + i() * 180} y={180}>
+ <rect width={150} height={150} cornerRadius={16} fill={COLORS[label]} />
+ <text x={55} y={45} fontSize={56} fontFamily="Inter" fontWeight={700}>
+ {label}
+ </text>
+ </group>
+ )}
+ </For>
+ </scene>
+);
diff --git a/samples/reconciler/04-ticker.tsx b/samples/reconciler/04-ticker.tsx
new file mode 100644
index 00000000..20a13415
--- /dev/null
+++ b/samples/reconciler/04-ticker.tsx
@@ -0,0 +1,37 @@
+/* @jsxImportSource @diffusionstudio/jsx */
+/* Timeline clock: useTicker drives props from the scene's playhead.
+ *
+ * dapi mount --live samples/reconciler/04-ticker.tsx
+ *
+ * Values only move during playback: press play in the editor. The orange
+ * rect orbits with the frame, the readout shows time/frame, and the
+ * "PLAYING" badge exists only while the transport runs.
+ */
+
+import { Show } from "solid-js";
+import { useTicker } from "@diffusionstudio/jsx";
+
+export default () => {
+ const { time, frame, playing } = useTicker();
+
+ return (
+ <scene key="sample-ticker" name="Ticker" width={960} height={540} fill="#101014">
+ <rect
+ x={420 + Math.round(Math.cos(time() * 2) * 300)}
+ y={220 + Math.round(Math.sin(time() * 2) * 150)}
+ width={100}
+ height={100}
+ cornerRadius={50}
+ fill="#ffaa22"
+ />
+
+ <text x={40} y={40} fontSize={40} fontFamily="Inter">
+ t = {time().toFixed(2)}s / frame {frame()}
+ </text>
+
+ <Show when={playing()}>
+ <text x={40} y={460} fontSize={36} fontWeight={700}>PLAYING</text>
+ </Show>
+ </scene>
+ );
+};
diff --git a/samples/reconciler/05-html-paint.tsx b/samples/reconciler/05-html-paint.tsx
new file mode 100644
index 00000000..d291395f
--- /dev/null
+++ b/samples/reconciler/05-html-paint.tsx
@@ -0,0 +1,40 @@
+/* @jsxImportSource @diffusionstudio/jsx */
+/* Environment split: the same tags mean different things per context.
+ *
+ * dapi mount --live samples/reconciler/05-html-paint.tsx
+ *
+ * Requires the html-in-canvas API (chrome://flags/#canvas-draw-element;
+ * not available in Electron 35, so use a supporting build): without it the
+ * mount fails cleanly at <html> materialization.
+ *
+ * The left <rect> is an ECS entity. Inside <html> (long form <htmlPaint>),
+ * <rect> is an SVG element (namespace inherited from <svg>), <div> is plain
+ * HTML, and the counter text updates reactively in the drawn DOM. Note the
+ * type-level approximation: shared tag names keep their composition prop
+ * types everywhere, so the SVG <rect> below sticks to numeric props that
+ * satisfy both sides.
+ */
+
+import { createSignal } from "solid-js";
+
+const [n, setN] = createSignal(0);
+setInterval(() => setN(n() + 1), 500);
+
+export default () => (
+ <scene key="sample-html" name="HTML paint" width={960} height={540} fill="#101014">
+ <rect x={40} y={120} width={200} height={300} cornerRadius={16} fill="#22ccff" />
+
+ <rect x={280} y={60} width={640} height={420}>
+ <html>
+ <div style={{ color: "white", "font-family": "Inter", "font-size": "28px", padding: "16px" }}>
+ DOM counter: {n()}
+ </div>
+ <svg viewBox="0 0 200 100" width={640} height={320}>
+ <rect x={10} y={10} width={80} height={50} fill="#ff4466" />
+ <circle cx={140 + (n() % 3) * 15} cy={35} r={20} fill="#44dd88" />
+ <path d="M 10 80 H 190" stroke="#ffaa22" stroke-width={4} />
+ </svg>
+ </html>
+ </rect>
+ </scene>
+);
diff --git a/samples/reconciler/README.md b/samples/reconciler/README.md
new file mode 100644
index 00000000..cac52ee5
--- /dev/null
+++ b/samples/reconciler/README.md
@@ -0,0 +1,16 @@
+# Reconciler samples
+
+Mountable projects exercising the shadow-tree reconciler (`WorldDocument`).
+Run from the repo root with the editor open:
+
+| Sample | Command | Exercises |
+| --- | --- | --- |
+| [01-static-tree.tsx](01-static-tree.tsx) | `dapi mount samples/reconciler/01-static-tree.tsx` | deferred materialization, prop replay, paints, text segments, timing |
+| [02-live-signals.tsx](02-live-signals.tsx) | `dapi mount --live samples/reconciler/02-live-signals.tsx` | reactive props, replaceText, Show insert/remove |
+| [03-live-list.tsx](03-live-list.tsx) | `dapi mount --live samples/reconciler/03-live-list.tsx` | \<For\> moves (reorder without recreate), list insert/remove |
+| [04-ticker.tsx](04-ticker.tsx) | `dapi mount --live samples/reconciler/04-ticker.tsx` | useTicker playhead reactivity (press play) |
+| [05-html-paint.tsx](05-html-paint.tsx) | `dapi mount --live samples/reconciler/05-html-paint.tsx` | DOM/SVG materialization under \<html\>; needs html-in-canvas |
+
+Each root scene carries a stable key, so re-mounting a sample replaces its
+scene in place. Inspect results with `dapi node tree`; entity ids in sample 03
+stay stable across shuffles (moves, not recreates).