The VS Code of video editing, built for agents.
TypeScript
Enhance Inspector components with stroke settings integration
konstantin-paulus6366139e5ac4
diff --git a/apps/web/src/components/sidebar-right/inspector/inspector.tsx b/apps/web/src/components/sidebar-right/inspector/inspector.tsxindex 4b261a05..9c759ac8 100644--- a/apps/web/src/components/sidebar-right/inspector/inspector.tsx+++ b/apps/web/src/components/sidebar-right/inspector/inspector.tsx@@ -31,7 +31,7 @@ import { LayoutPanel } from "./layout";// import { CaptionSettings } from "./caption-settings";import { TextPanel } from "./text";// import { FillsSettings } from "./fills";-// import { StrokesSettings } from "./strokes";+import { StrokesSettings } from "./strokes";// import { ShadowsSettings } from "./shadows";// import { EffectsSettings } from "./effects";// import { AnimationsSettings } from "./animations";@@ -153,9 +153,9 @@ export function Inspector() {<FillsSettings selection={nodes()} /></Show> */}- {/* <Show when={includesTarget("shape", "text", "scene", "caption")}>+ <Show when={includesTarget("shape", "text", "scene", "caption")}><StrokesSettings selection={nodes()} />- </Show> */}+ </Show>{/* <Show when={includesTarget("shape", "text", "scene", "caption")}><ShadowsSettings selection={nodes()} />diff --git a/apps/web/src/components/sidebar-right/inspector/shadow-inspector.tsx b/apps/web/src/components/sidebar-right/inspector/shadow-inspector.tsxindex f2135e3f..c6cf3ef1 100644--- a/apps/web/src/components/sidebar-right/inspector/shadow-inspector.tsx+++ b/apps/web/src/components/sidebar-right/inspector/shadow-inspector.tsx@@ -178,7 +178,6 @@ export function ShadowInspector(props: ShadowInspectorProps) {onOpacityChange={updateOpacity}onBeginChange={(label) => world.history.startTransaction(label)}onEndChange={() => world.history.commitTransaction()}- keyframeTarget={props.shadowEid}/></FloatingInspectorContent></FloatingInspector>diff --git a/apps/web/src/components/sidebar-right/inspector/solid-picker.tsx b/apps/web/src/components/sidebar-right/inspector/solid-picker.tsxindex 1f491348..680ffccb 100644--- a/apps/web/src/components/sidebar-right/inspector/solid-picker.tsx+++ b/apps/web/src/components/sidebar-right/inspector/solid-picker.tsx@@ -35,7 +35,6 @@ export function SolidFillPicker(props: SolidColorPickerProps) {onOpacityChange={updateOpacity}onBeginChange={(label) => world.history.startTransaction(label)}onEndChange={() => world.history.commitTransaction()}- keyframeTarget={props.fillEid}/>);}diff --git a/apps/web/src/components/sidebar-right/inspector/strokes.tsx b/apps/web/src/components/sidebar-right/inspector/strokes.tsxindex b07fbac2..7434ae3f 100644--- a/apps/web/src/components/sidebar-right/inspector/strokes.tsx+++ b/apps/web/src/components/sidebar-right/inspector/strokes.tsx@@ -2,80 +2,110 @@* License, v. 2.0. If a copy of the MPL was not distributed with this* file, You can obtain one at http://mozilla.org/MPL/2.0/. */-import { For, createMemo, createSignal, Show } from "solid-js";+import { For, Show, createMemo, createSignal } from "solid-js";import { Button } from "@/components/ui/button";import { Tooltip, TooltipContent, TooltipTrigger } from "@/components/ui/tooltip";import { ControlRow } from "@/components/ui/control-group";+import { ColorOpacityPicker } from "@/components/ui/color-opacity-picker";+import { ColorOpacityRow } from "@/components/ui/color-opacity-row";+import {+ ContextMenu,+ ContextMenuContent,+ ContextMenuItem,+ ContextMenuSeparator,+ ContextMenuTrigger,+} from "@/components/ui/context-menu";+import {+ FloatingInspector,+ FloatingInspectorContent,+ FloatingInspectorHeader,+ FloatingInspectorTitle,+} from "@/components/ui/floating-inspector";import { Icon } from "@/components/ui/icon";import { PanelSection } from "@/components/ui/panel-section";import { ControlledTextField } from "@/components/ui/text-field";import { SegmentedIconTabs } from "@/components/ui/segmented-icon-tabs";-import { Keyframe } from "@/components/ui/keyframe-bitecs";-import { useEngine } from "@/context/engine";-import { StrokeJoin, useEntityState, createEntity, deleteEntity, getSiblingEntities, addComponent, appendChild, setComponent } from "@/components/engine";-import { FillRow } from "./fill-row";-import { FillPicker } from "./fill-picker";+import { Keyframe } from "@/components/ui/keyframe";+import { useHas, useTrait, useWorld } from "@diffusionstudio/koota-solid";+import { Stroke as StrokeElement } from "@diffusionstudio/reconciler";+import { Cache, Computed, Hidden, StrokeJoin, StrokeStyle, colorToHex } from "@diffusionstudio/runtime";+import { useDerived, useEditor } from "@/engine/hooks";+import { syncKeyframe } from "@/engine/keyframes";+import type { StrokeJoin as StrokeJoinName } from "@diffusionstudio/jsx";+import type { Entity, World } from "koota";+import type { DocumentEditor } from "@/engine/editor";-const STROKE_JOIN_SEGMENTS = [- { value: String(StrokeJoin.MITER), icon: 'line-join-miter', label: "Miter" },- { value: String(StrokeJoin.BEVEL), icon: 'line-join-bevel', label: "Bevel" },- { value: String(StrokeJoin.ROUND), icon: 'line-join-round', label: "Round" },+const JOIN_SEGMENTS: { value: StrokeJoinName; icon: string; label: string }[] = [+ { value: "miter", icon: "line-join-miter", label: "Miter" },+ { value: "bevel", icon: "line-join-bevel", label: "Bevel" },+ { value: "round", icon: "line-join-round", label: "Round" },];+const JOIN_NAMES: Record<StrokeJoin, StrokeJoinName> = {+ [StrokeJoin.MITER]: "miter",+ [StrokeJoin.BEVEL]: "bevel",+ [StrokeJoin.ROUND]: "round",+};++/** `<stroke>`'s defaults; a control left at one of these unsets its prop. */+const DEFAULT_COLOR = "#000000";+const DEFAULT_WIDTH = 1;+const DEFAULT_MITER_LIMIT = 10;++// Stable identity, so a node without strokes does not resample every tick.+const NO_STROKES: Entity[] = [];+type StrokesSettingsProps = {- selection: Set<number>;+ selection: Entity[];};+/**+ * The `<stroke>` children of the selected node, in paint order (the list is+ * shown topmost first, so the last element in the file is the first row).+ * Each stroke is its own element with its own paint *and* its own line style+ * (`width`/`join`/`miterLimit`), which is why the style controls sit under+ * each row rather than once per node as they did while the style belonged to+ * the node. `cap` has no control yet: it only shows on open paths (text+ * glyphs) and there are no icons for it.+ */export function StrokesSettings(props: StrokesSettingsProps) {- const { world } = useEngine();- const c = world.components;- let anchorRef!: HTMLDivElement;+ const editor = useEditor();+ const entity = () => props.selection[0]!;- const eid = () => props.selection.values().next().value!;+ let anchorRef!: HTMLDivElement;- const strokeEids = useEntityState(c.Cache.strokes, eid, []);- const lineJoinId = useEntityState(c.StrokeStyle.join, eid, 0);- const strokeWidth = useEntityState(c.Computed.strokeWidth, eid, 1);- const strokeMiterLimit = useEntityState(c.StrokeStyle.miterLimit, eid, 3);- const [selectedStroke, setSelectedStroke] = createSignal<number>();+ const [picked, setPicked] = createSignal<Entity>();- const lineJoin = createMemo(() => String(lineJoinId()));+ // Cache is derived state, written without change events.+ const strokes = useDerived(() => entity().get(Cache)?.strokes ?? NO_STROKES);const handleAppendStroke = () => {- world.history.transaction('Append stroke', () => {- const solid = createEntity(world);- addComponent(world, solid, c.Stroke);- setComponent(world, solid, c.Color, 0x000000);- appendChild(world, solid, eid());- });- };-- const handleStrokeWidthChange = (value: number) => {- setComponent(world, eid(), c.StrokeStyle, { width: value });+ editor.insertElement(entity(), () => <StrokeElement color={DEFAULT_COLOR} />);};- const handleLineJoinChange = (value: string) => {- setComponent(world, eid(), c.StrokeStyle, { join: Number(value) });- };+ // Read back off the list, so the picker closes with the stroke it edits.+ const editing = createMemo(() => {+ const stroke = picked();+ return stroke !== undefined && strokes().includes(stroke) ? stroke : undefined;+ });- const handleMiterLimitChange = (value: number) => {- setComponent(world, eid(), c.StrokeStyle, { miterLimit: value });- };+ /**+ * Swaps `stroke` with its neighbour, later in the file (`direction` 1, on+ * top) or earlier. Written as a swap because a move needs an anchor:+ * `reparent` appends without one, and refuses an append into the parent the+ * element already has.+ */+ const handleReorderStroke = (stroke: Entity, direction: number) => {+ const siblings = strokes();+ const index = siblings.indexOf(stroke);+ const target = index + direction;+ if (index === -1 || target < 0 || target >= siblings.length) return;- const handleClosePicker = () => setSelectedStroke(undefined);- const handleSelectStroke = (strokeEid: number) => setSelectedStroke(strokeEid);- const handleRemoveStroke = (strokeEid: number) => deleteEntity(world, strokeEid);-- const handleReorderStroke = (strokeEid: number, direction: number) => {- const strokes = getSiblingEntities(world, strokeEid, c.Stroke);- const index = strokes.indexOf(strokeEid);- const newIndex = index + direction;- if (newIndex >= 0 && newIndex < strokes.length) {- strokes.splice(newIndex, 0, strokes.splice(index, 1)[0]);- for (const [idx, eid] of strokes.entries()) {- setComponent(world, eid, c.ItemIndex, idx);- }+ if (direction > 0) {+ editor.reparent(siblings[target]!, entity(), stroke);+ } else {+ editor.reparent(stroke, entity(), siblings[target]!);}};@@ -99,64 +129,199 @@ export function StrokesSettings(props: StrokesSettingsProps) {</Tooltip>}>- <For each={strokeEids().toReversed()}>- {(strokeEid) => (- <FillRow- nodeEid={eid()}- fillEid={strokeEid}- onSelect={() => handleSelectStroke(strokeEid)}- onRemove={() => handleRemoveStroke(strokeEid)}- onMoveUp={() => handleReorderStroke(strokeEid, 1)}- onMoveDown={() => handleReorderStroke(strokeEid, -1)}+ <For each={strokes().toReversed()}>+ {(stroke, index) => (+ <StrokeControls+ stroke={stroke}+ separated={index() > 0}+ onSelect={() => setPicked(stroke)}+ onRemove={() => editor.remove(stroke)}+ onMoveUp={() => handleReorderStroke(stroke, 1)}+ onMoveDown={() => handleReorderStroke(stroke, -1)}/>)}</For>-- <Show when={strokeEids().length > 0}>- <ControlRow label="Weight">- <ControlledTextField- value={strokeWidth()}- onNumber={handleStrokeWidthChange}- step={1}- min={0}- autoSelect- limitEvents- keyframe={<Keyframe target={eid()} property="stroke.width" />}- />- </ControlRow>-- <ControlRow label="Join">- <SegmentedIconTabs- value={lineJoin}- onChange={handleLineJoinChange}- items={STROKE_JOIN_SEGMENTS}- buttonClass="transition-colors"- iconClass="size-3.5 text-muted-foreground"- />- </ControlRow>-- <ControlRow label="Miter">- <ControlledTextField- value={strokeMiterLimit()}- onNumber={handleMiterLimitChange}- step={1}- min={1}- autoSelect- limitEvents- />- </ControlRow>- </Show></PanelSection>- <Show when={selectedStroke()}>- <FillPicker- nodeEid={eid()}- fillEid={selectedStroke()!}++ <Show when={editing() !== undefined}>+ <StrokePicker+ stroke={editing()!}anchorRef={anchorRef}- open={!!selectedStroke()}- onClose={handleClosePicker}- tabs={['solid', 'gradient']}+ onClose={() => setPicked(undefined)}/></Show></>);}++/** Writes `color` and reports it; a stroke's color is required, never unset. */+function editColor(world: World, editor: DocumentEditor, stroke: Entity, value: number) {+ const color = colorToHex(value);+ editor.editProperty(stroke, "color", color);+ syncKeyframe(world, editor, stroke, "color", color);+}++function editOpacity(world: World, editor: DocumentEditor, stroke: Entity, value: number) {+ const opacity = Math.round(value * 100) / 100;+ editor.editProperty(stroke, "opacity", opacity === 1 ? false : opacity);+ syncKeyframe(world, editor, stroke, "opacity", opacity);+}++type StrokeControlsProps = {+ stroke: Entity;+ separated: boolean;+ onSelect(): void;+ onRemove(): void;+ onMoveUp(): void;+ onMoveDown(): void;+};++function StrokeControls(props: StrokeControlsProps) {+ const world = useWorld();+ const editor = useEditor();++ const color = useDerived(() => props.stroke.get(Computed)?.color ?? 0);+ const opacity = useDerived(() => props.stroke.get(Computed)?.opacity ?? 1);+ const width = useDerived(() => props.stroke.get(Computed)?.strokeWidth ?? DEFAULT_WIDTH);++ const style = useTrait(() => props.stroke, StrokeStyle);+ const hidden = useHas(() => props.stroke, Hidden);++ const join = createMemo(() => JOIN_NAMES[style()?.join ?? StrokeJoin.MITER]);+ const miterLimit = () => style()?.miterLimit ?? DEFAULT_MITER_LIMIT;++ const handleWidthChange = (value: number) => {+ // Unlike a node's width this is the line width, not `resizeEntity`, so+ // there is no track of its own to mint and the sync belongs after.+ editor.editProperty(props.stroke, "width", value === DEFAULT_WIDTH ? false : value);+ syncKeyframe(world, editor, props.stroke, "width", value);+ };++ const handleJoinChange = (value: StrokeJoinName) => {+ editor.editProperty(props.stroke, "join", value === "miter" ? false : value);+ };++ const handleMiterLimitChange = (value: number) => {+ editor.editProperty(props.stroke, "miterLimit", value === DEFAULT_MITER_LIMIT ? false : value);+ };++ const toggleHidden = () => {+ editor.editProperty(props.stroke, "hidden", !hidden());+ };++ return (+ <div+ class="flex flex-col gap-2"+ classList={{ "border-t border-border pt-3": props.separated }}+ >+ <ContextMenu>+ <ContextMenuTrigger<typeof ControlRow>+ as={ControlRow}+ label="Stroke"+ class={hidden() ? "opacity-50" : undefined}+ >+ <ColorOpacityRow+ color={color()}+ onChangeColor={(value) => editColor(world, editor, props.stroke, value)}+ opacity={opacity()}+ onChangeOpacity={(value) => editOpacity(world, editor, props.stroke, value)}+ onClick={props.onSelect}+ keyframe={<Keyframe target={props.stroke} property="opacity" />}+ />+ </ContextMenuTrigger>+ <ContextMenuContent>+ <ContextMenuItem onSelect={props.onMoveUp}>Move Up</ContextMenuItem>+ <ContextMenuItem onSelect={props.onMoveDown}>Move Down</ContextMenuItem>+ <ContextMenuSeparator />+ <ContextMenuItem onSelect={toggleHidden}>+ {hidden() ? "Unhide" : "Hide"}+ </ContextMenuItem>+ <ContextMenuSeparator />+ <ContextMenuItem onSelect={props.onRemove}>Remove</ContextMenuItem>+ </ContextMenuContent>+ </ContextMenu>++ <ControlRow label="Weight">+ <ControlledTextField+ value={width()}+ onNumber={handleWidthChange}+ step={1}+ min={0}+ autoSelect+ limitEvents+ keyframe={<Keyframe target={props.stroke} property="width" />}+ />+ </ControlRow>++ <ControlRow label="Join">+ <SegmentedIconTabs+ value={join}+ onChange={handleJoinChange}+ items={JOIN_SEGMENTS}+ buttonClass="transition-colors"+ iconClass="size-3.5 text-muted-foreground"+ />+ </ControlRow>++ <ControlRow label="Miter">+ <ControlledTextField+ value={miterLimit()}+ onNumber={handleMiterLimitChange}+ step={1}+ min={1}+ autoSelect+ limitEvents+ />+ </ControlRow>+ </div>+ );+}++type StrokePickerProps = {+ stroke: Entity;+ anchorRef: HTMLElement;+ onClose(): void;+};++/**+ * A stroke's paint. Solid only: `<stroke>` takes a `color` and takes no paint+ * children, so there is no gradient or asset tab to offer.+ */+function StrokePicker(props: StrokePickerProps) {+ const world = useWorld();+ const editor = useEditor();++ const color = useDerived(() => props.stroke.get(Computed)?.color ?? 0);+ const opacity = useDerived(() => props.stroke.get(Computed)?.opacity ?? 1);++ return (+ <FloatingInspector open anchorRef={props.anchorRef}>+ <FloatingInspectorHeader>+ <FloatingInspectorTitle>Color</FloatingInspectorTitle>+ <div class="ml-auto">+ <Tooltip>+ <TooltipTrigger+ as={Button}+ size="icon"+ variant="ghost"+ class="text-muted-foreground"+ onClick={props.onClose}+ >+ <Icon name="close-remove" class="size-6" />+ </TooltipTrigger>+ <TooltipContent>Close</TooltipContent>+ </Tooltip>+ </div>+ </FloatingInspectorHeader>+ <FloatingInspectorContent class="p-0">+ <ColorOpacityPicker+ color={color()}+ opacity={opacity()}+ onColorChange={(value) => editColor(world, editor, props.stroke, value)}+ onOpacityChange={(value) => editOpacity(world, editor, props.stroke, value)}+ keyframeTarget={props.stroke}+ />+ </FloatingInspectorContent>+ </FloatingInspector>+ );+}diff --git a/apps/web/src/components/ui/color-opacity-picker.tsx b/apps/web/src/components/ui/color-opacity-picker.tsxindex 77d29e33..30034479 100644--- a/apps/web/src/components/ui/color-opacity-picker.tsx+++ b/apps/web/src/components/ui/color-opacity-picker.tsx@@ -4,7 +4,7 @@import { Button } from "@/components/ui/button";import { Icon } from "@/components/ui/icon";-import { Keyframe } from "@/components/ui/keyframe-bitecs";+import { Keyframe } from "@/components/ui/keyframe";import { Tooltip, TooltipContent, TooltipTrigger } from "@/components/ui/tooltip";import { checkerboardStyle } from "@/components/ui/opacity-swatch";import {@@ -30,11 +30,12 @@ import {type Accessor,type Setter,} from "solid-js";-import { useEngine } from "@/context/engine";-import { useQuery } from "@/components/engine/hooks";-import { DEFAULT_BACKGROUND } from "@/components/engine";+import { useQuery } from "@diffusionstudio/koota-solid";+import { Color, DEFAULT_BACKGROUND } from "@diffusionstudio/runtime";import { toast } from "somoto";+import type { Entity } from "koota";+const COLOR_TYPES = ["Hex", "HSL", "RGB"] as const;type ColorType = (typeof COLOR_TYPES)[number];const OPACITY_INPUT_MAX = 100;@@ -52,7 +53,8 @@ export type ColorOpacityPickerProps = {onBeginChange?(label: string): void;onEndChange?(): void;withoutOpacity?: boolean;- keyframeTarget?: number;+ /** The entity the sliders keyframe, when what they edit is a prop of one. */+ keyframeTarget?: Entity;};function getSliderRatio(@@ -77,15 +79,12 @@ export function ColorOpacityPicker(props: ColorOpacityPickerProps) {let hueRef: HTMLDivElement | undefined;let opacityRef: HTMLDivElement | undefined;- const { world } = useEngine();- const c = world.components;-- const colorEntities = useQuery([c.Color]);+ const colorEntities = useQuery(Color);const documentColors = createMemo(() => {const colors = new Set<number>();- for (const eid of colorEntities()) {- colors.add(c.Color[eid] ?? DEFAULT_BACKGROUND); // fallback is background color+ for (const entity of colorEntities()) {+ colors.add(entity.get(Color)?.value ?? DEFAULT_BACKGROUND); // fallback is background colorif (colors.size >= 36) break;}return Array.from(colors);diff --git a/packages/runtime/MIGRATION.md b/packages/runtime/MIGRATION.mdindex b16fa3bb..abf44928 100644--- a/packages/runtime/MIGRATION.md+++ b/packages/runtime/MIGRATION.md@@ -58,6 +58,7 @@ Every world spawns one `Stage` entity; all rendered entities descend from it. "T- Max 16 live worlds; `world.destroy()` in test loops and throwaway offline worlds. Stores are indexed by `entity.id()`; `world.id()` is a world slot, not an entity. World traits sit on a hidden internal entity that is not public API.- `set` throws if the trait is missing and merges partials; `add` is idempotent and never resets values, hence add-then-set everywhere. On an exclusive relation, `add` re-targets in place.- Events: exclusive re-target fires remove(old) then add(new); a redundant same-pair add fires nothing; **remove events fire while the departing child is still in the old target's queries** (hence the `exclude`/`ignore` params in `rebuildCaches` and the timing observers). onAdd fires after initial values are applied and may set traits. onChange fires even when the value is unchanged.+- **`destroy()` strips an entity's traits before it fires the ChildOf removal**, so a handler on that event cannot ask the departing child what it was. `rebuildCaches` files by trait and so filed nothing on the way out, leaving every destroyed entity in its parent's `Cache` lists (a deleted stroke kept its row, a deleted node kept its place in `children`); `evictFromCaches` drops it by identity instead. Anything else keyed on what a child *is* has the same hole.## apps/web integration@@ -75,7 +76,7 @@ Done:| Draw tools + toolbar (armed tool is the `Tool` world trait) | `components/canvas/draw-overlay.tsx` || Input, HUD, camera, alignment | `engine/input/`, `engine/hud/`, `engine/align.ts` || Project config (per-scene export settings in package.json) | `engine/project-config.ts` |-| Panels: header, background, scene template, asset info, time, appearance, alignment, export, layout, text | `components/sidebar-right/inspector/` |+| Panels: header, background, scene template, asset info, time, appearance, alignment, export, layout, text, strokes | `components/sidebar-right/inspector/` || Local font families (web fonts and loading are the runtime's) | `engine/fonts.ts` (`getLocalFonts`) |Hosted JSX surface is `COMPOSITION_TAGS` (`packages/jsx/src/source.ts`): the structural tags, the media tags, `<captions>`, the paint family, `<stroke>`, `<shadow>`, `<effect>`, `<animation>`, `<keyframeTrack>`/`<keyframe>`, `<html>`/`<surface>`. `mask` is a `<rect>` prop, not a tag.@@ -90,8 +91,13 @@ Conventions worth repeating when migrating the next panel:- A picker that previews on hover writes the trait alone, so while it is open the trait holds the hover and not the authored value. Keep the authored one in a signal seeded at mount (panels remount per selection) and move it only on a selection: it is what the control displays *and* what the close restores. Reading it back off the trait restores the hover instead, permanently. `AppearanceSettings`' blend mode and the text panel's family/weight both do this.- What a `<text>` says is its children, not a prop, so it travels as its own edit end to end: `editor.editText` -> `TextEdit` -> the writer's `SourceSet.text` -> `RuntimeDocument.setText`. The document keeps the reconciler's text nodes: the first says all of it and the rest say nothing, so a project that later re-renders one of them still lands.- A text is the one element whose box is optional (`Size` absent = sized to its glyphs), so the text panel's "Grow" toggle is `width`/`height` being authored at all. Unsetting a bound drops `Size` only once neither is left, which is why the toggle writes `width` before `height`.+- `Cache`'s lists are derived like `Computed` (store writes, no events), so a panel listing sub-entities reads them through `useDerived` too. Keep the empty fallback a module constant: a fresh `[]` per sample defeats the memo's comparison.+- Reordering siblings is a swap through `editor.reparent`, not an index write: `ItemIndex` is the document's to assign (`insertNode` renumbers the whole sibling list), and a move needs an anchor, since `reparent` appends without one and refuses an append into the parent the element already has. So "move later" moves the *next* sibling in front of this one.+- A shared control that knows *which* prop it edits keyframes it itself, off an `Entity` (`ColorOpacityPicker`'s `keyframeTarget`, now koota's); only a control that cannot know takes the diamond as a slot (`ControlledTextField`, `ColorOpacityRow`). Moving one of these moves it whole: the bitecs panels still calling it lose their diamonds until they migrate, and its recent-colors palette now queries the koota world for them too (both providers are mounted).-Still on bitecs: transform, caption-settings, fills, strokes, shadows, effects, animations, transition, masks, audio, interpolation panels; the timeline's keyframe layer; the whole timeline UI.+Still on bitecs: transform, caption-settings, fills, shadows, effects, animations, transition, masks, audio, interpolation panels; the timeline's keyframe layer; the whole timeline UI.++The stroke panel moved with the model: `StrokeStyle` is the stroke's, not the node's (as `<stroke width join cap miterLimit>` always was), so Weight/Join/Miter sit under each stroke's row instead of once per node. `<stroke>` is a solid paint that takes no paint children, so its picker is the color one alone, with no gradient or asset tab and no `FillPicker` behind it. `cap` still has no control (it shows only on open paths, and there are no icons for it).Two deliberate departures from the old text panel: `letterSpacing` is shown in px (the trait's unit and the prop's; the bitecs panel showed the same number as a percentage), and the font a text is set in — family, weight, size — is written out plainly rather than unset at its default, since a font is what a text *is* and not a modifier of it. `<captions>` has no host yet, so the caption half of the panel is unreachable and was carried over as it stood.diff --git a/packages/runtime/src/actions/cache.ts b/packages/runtime/src/actions/cache.tsindex e51bb10c..c0b7ac4f 100644--- a/packages/runtime/src/actions/cache.ts+++ b/packages/runtime/src/actions/cache.ts@@ -97,6 +97,35 @@ export function rebuildCaches(world: World, entity: Entity, parent: Entity | nul}}+/** Every list a `Cache` keeps, for the paths that cannot ask which one applies. */+const CACHE_LISTS = [+ 'children', 'fills', 'shadows', 'strokes', 'effects',+ 'textRanges', 'masks', 'keyframeTracks', 'keyframes', 'animations',+] as const;++/**+ * Drop `entity` from every list its parent kept it in. The detach path cannot+ * leave this to `rebuildCaches`, which files by trait: a destroy strips the+ * entity's traits *before* it fires the ChildOf removal, so by then nothing+ * says which lists the child was in and every branch is skipped. Membership+ * still says it, and dropping one entry needs no query and no re-sort.+ */+export function evictFromCaches(world: World, entity: Entity, parent: Entity | null): void {+ if (parent === null || isStage(parent) || !parent.has(Cache)) return;++ const cache = store(world, Cache);+ const pid = parent.id();++ for (const list of CACHE_LISTS) {+ const members = cache[list][pid];+ // A fresh array, not a splice: the lists are read as derived state, and+ // a new identity is the only signal a reader gets that one changed.+ if (members?.includes(entity)) {+ cache[list][pid] = members.filter((member) => member !== entity);+ }+ }+}+/*** Move an attached geometry between its parent's `children` and `masks` when* its `IsMask` tag is toggled in place. `rebuildCaches` files by trait ondiff --git a/packages/runtime/src/world/observers.ts b/packages/runtime/src/world/observers.tsindex 048c58e7..33867cf6 100644--- a/packages/runtime/src/world/observers.ts+++ b/packages/runtime/src/world/observers.ts@@ -28,7 +28,7 @@ import {HtmlHostHandle, SurfaceHostHandle, ShaderHostHandle, AudioBusHandle,} from '../traits';import { getParentEntity } from '../queries/hierarchy';-import { rebuildCaches, refileMask } from '../actions/cache';+import { evictFromCaches, rebuildCaches, refileMask } from '../actions/cache';import { disposeDecoders, disconnectAudioBus } from '../media/dispose';import {reactToChildAttached, reactToChildDetached, reactToAssetChange,@@ -62,10 +62,14 @@ export function observeWorld(world: World): () => void {// still present in the old parent's queries, so it is excluded by hand.// Destroy cascades parent-first through ChildOf (autoDestroy 'orphan'),// so a descendant's parent may already be gone: nothing to rebuild then.+ // The eviction follows the rebuild rather than replacing it: a destroy has+ // already taken the child's traits, so the rebuild files nothing and the+ // child would stay in the lists it was in.subs.push(world.onRemove(ChildOf('*'), (child, parent) => {disconnectAudioBus(world, child);if (!world.has(parent)) return;rebuildCaches(world, child, parent, child);+ evictFromCaches(world, child, parent);reactToChildDetached(world, child);}));