The VS Code of video editing, built for agents.
TypeScript
Add effects management to Inspector with new effect types integration
konstantin-paulus95d8bc9e345f
diff --git a/apps/web/src/components/sidebar-right/inspector/effect-types.ts b/apps/web/src/components/sidebar-right/inspector/effect-types.tsnew file mode 100644index 00000000..67d96204--- /dev/null+++ b/apps/web/src/components/sidebar-right/inspector/effect-types.ts@@ -0,0 +1,52 @@+/* This Source Code Form is subject to the terms of the Mozilla Public+ * 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 { EFFECT_TYPES } from "@diffusionstudio/reconciler";++import type { EffectType as EffectName } from "@diffusionstudio/jsx";+import type { EffectType } from "@diffusionstudio/runtime";++/**+ * What an `<effect>`'s `value` means, which is what a type switch has to+ * answer for: the amount filters share a 0-1 scale, `blur` is a radius in px+ * and `hueRotate` an angle in degrees. Within a unit the value carries over,+ * across one it cannot.+ */+export type EffectUnit = "amount" | "px" | "deg";++export type EffectOption = {+ name: EffectName;+ label: string;+ unit: EffectUnit;+ /** What "Add effect", and a switch into this type, authors. */+ value: number;+};++/** The effect types, in menu order. */+export const EFFECT_OPTIONS: EffectOption[] = [+ { name: "blur", label: "Layer Blur", unit: "px", value: 8 },+ { name: "brightness", label: "Brightness", unit: "amount", value: 0.8 },+ { name: "contrast", label: "Contrast", unit: "amount", value: 0.8 },+ { name: "grayscale", label: "Grayscale", unit: "amount", value: 0.5 },+ { name: "hueRotate", label: "Hue Rotation", unit: "deg", value: 100 },+ { name: "invert", label: "Invert", unit: "amount", value: 0.5 },+ { name: "saturate", label: "Saturate", unit: "amount", value: 0.8 },+ { name: "sepia", label: "Sepia", unit: "amount", value: 0.5 },+];++/** What the panel's plus inserts, spelled out. */+export const DEFAULT_EFFECT: EffectOption = EFFECT_OPTIONS[0]!;++const BY_TYPE = new Map<EffectType, EffectOption>(+ EFFECT_OPTIONS.map((option) => [EFFECT_TYPES[option.name]!, option]),+);++/**+ * The option for the type an `Effect` trait holds. Identity matters: the+ * type select compares its value against the array it was given, so this+ * hands back the option itself rather than a copy.+ */+export function effectOption(type: EffectType | undefined): EffectOption {+ return (type === undefined ? undefined : BY_TYPE.get(type)) ?? DEFAULT_EFFECT;+}diff --git a/apps/web/src/components/sidebar-right/inspector/effects-inspector.tsx b/apps/web/src/components/sidebar-right/inspector/effects-inspector.tsxindex 4c88151a..2b148f23 100644--- a/apps/web/src/components/sidebar-right/inspector/effects-inspector.tsx+++ b/apps/web/src/components/sidebar-right/inspector/effects-inspector.tsx@@ -2,6 +2,7 @@* 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 { Show, createMemo } from "solid-js";import { Button } from "@/components/ui/button";import { Tooltip, TooltipContent, TooltipTrigger } from "@/components/ui/tooltip";import { ControlRow } from "@/components/ui/control-group";@@ -10,77 +11,107 @@ import {FloatingInspectorContent,FloatingInspectorHeader,FloatingInspectorSeparator,- FloatingInspectorTitle,} from "@/components/ui/floating-inspector";import { Icon } from "@/components/ui/icon";import { IncrementDecrementControl } from "@/components/ui/increment-decrement-control";-import { Keyframe } from "@/components/ui/keyframe-bitecs";+import { Keyframe } from "@/components/ui/keyframe";+import {+ Select,+ SelectContent,+ SelectItem,+ SelectPortal,+ SelectTrigger,+ SelectValue,+} from "@/components/ui/select";import { SliderInput } from "@/components/ui/slider-input";import { ControlledTextField } from "@/components/ui/text-field";-import { useEngine } from "@/context/engine";-import { useEntityState, useEntityTag, EffectType, addComponent, removeComponent, setComponent } from "@/components/engine";-import { hasComponent } from 'bitecs';+import { useHas, useTrait, useWorld } from "@diffusionstudio/koota-solid";+import { Computed, Effect, Hidden } from "@diffusionstudio/runtime";+import { useDerived, useEditor } from "@/engine/hooks";+import { removeKeyframeTrack, syncKeyframe } from "@/engine/keyframes";+import { EFFECT_OPTIONS, effectOption } from "./effect-types";++import type { EffectOption } from "./effect-types";+import type { Entity } from "koota";++const clampUnit = (value: number) => Math.min(1, Math.max(0, value));type EffectsInspectorProps = {+ effect: Entity;anchorRef: HTMLElement;onClose(): void;- effectEid: number;- nodeEid: number;};-type Effects = Exclude<EffectType, EffectType.DROP_SHADOW>;--export const EFFECT_DEFAULTS: Record<Effects, { label: string; value: number }> = {- [EffectType.LAYER_BLUR]: { label: "Layer Blur", value: 8 },- [EffectType.BRIGHTNESS]: { label: "Brightness", value: 0.8 },- [EffectType.CONTRAST]: { label: "Contrast", value: 0.8 },- [EffectType.GRAYSCALE]: { label: "Grayscale", value: 0.5 },- [EffectType.HUE_ROTATION]: { label: "Hue Rotation", value: 100 },- [EffectType.INVERT]: { label: "Invert", value: 0.5 },- [EffectType.SATURATE]: { label: "Saturate", value: 0.8 },- [EffectType.SEPIA]: { label: "Sepia", value: 0.5 },-};--const clampUnit = (value: number) => Math.min(1, Math.max(0, value));--const AMOUNT_EFFECTS: Effects[] = [- EffectType.BRIGHTNESS,- EffectType.CONTRAST,- EffectType.GRAYSCALE,- EffectType.INVERT,- EffectType.SATURATE,- EffectType.SEPIA,-];-+/**+ * One `<effect>`: which filter it is and how much of it. Both are required+ * props, so neither is ever unset — an effect that says nothing is not an+ * effect. The type select stands where the title would (the export+ * inspector's shape): it names the effect *and* changes it, so a separate+ * heading would only say the same word twice. `value` is one number in three+ * units (px, degrees, a 0-1 amount), which is why the control below the type+ * changes with it.+ */export function EffectsInspector(props: EffectsInspectorProps) {- const { world } = useEngine();- const c = world.components;+ const world = useWorld();+ const editor = useEditor();++ const effect = useTrait(() => props.effect, Effect);+ const hidden = useHas(() => props.effect, Hidden);- const effectValue = useEntityState(c.Computed.value, props.effectEid, 0);- const hidden = useEntityTag(c.Hidden, props.effectEid);- const type = useEntityState(c.Effect.type, props.effectEid, EffectType.BRIGHTNESS);+ const option = createMemo(() => effectOption(effect()?.type));+ const value = useDerived(() => props.effect.get(Computed)?.value ?? 0);- const updateValue = (v: number) => {- setComponent(world, props.effectEid, c.Effect, { value: v });+ const editValue = (next: number) => {+ editor.editProperty(props.effect, "value", next);+ syncKeyframe(world, editor, props.effect, "value", next);};- const toggleVisible = () => {- if (hasComponent(world, props.effectEid, c.Hidden)) {- removeComponent(world, props.effectEid, c.Hidden);- } else {- addComponent(world, props.effectEid, c.Hidden);+ /**+ * Switches the filter. A value only means the same thing across types of+ * the same unit; crossing one (a 4px blur becoming 4 turns of sepia) takes+ * the new type's default, and the track goes with the numbers it held.+ */+ const handleTypeChange = (next: EffectOption | null) => {+ const previous = option();+ if (next === null || next.name === previous.name) return;++ if (next.unit !== previous.unit) {+ removeKeyframeTrack(world, editor, props.effect, "value");+ }+ editor.editProperty(props.effect, "type", next.name);+ if (next.unit !== previous.unit) {+ editor.editProperty(props.effect, "value", next.value);}};- const isAmountEffect = () => AMOUNT_EFFECTS.includes(type() ?? EffectType.BRIGHTNESS);- const isBlurEffect = () => type() === EffectType.LAYER_BLUR;- const isHueRotationEffect = () => type() === EffectType.HUE_ROTATION;- const label = () => EFFECT_DEFAULTS[type() as Effects]?.label ?? "";+ const toggleHidden = () => {+ editor.editProperty(props.effect, "hidden", !hidden());+ };return (- <FloatingInspector open={true} anchorRef={props.anchorRef} width={248}>- <FloatingInspectorHeader class="items-center justify-between">- <FloatingInspectorTitle>{label()}</FloatingInspectorTitle>+ <FloatingInspector open anchorRef={props.anchorRef} width={248}>+ <FloatingInspectorHeader class="items-center justify-between px-2">+ <Select<EffectOption>+ value={option()}+ onChange={handleTypeChange}+ options={EFFECT_OPTIONS}+ optionValue="name"+ optionTextValue="label"+ itemComponent={(itemProps) => (+ <SelectItem item={itemProps.item}>+ {itemProps.item.rawValue.label}+ </SelectItem>+ )}+ >+ <SelectTrigger>+ <SelectValue<EffectOption>>+ {(state) => state.selectedOption()?.label}+ </SelectValue>+ </SelectTrigger>+ <SelectPortal>+ <SelectContent />+ </SelectPortal>+ </Select><div class="flex items-center gap-1"><Tooltip><TooltipTrigger@@ -88,9 +119,11 @@ export function EffectsInspector(props: EffectsInspectorProps) {size="icon"variant="ghost"class="text-muted-foreground"- onClick={toggleVisible}+ onClick={toggleHidden}>- {!hidden() ? <Icon name="eye-on" /> : <Icon name="eye-off" />}+ <Show when={!hidden()} fallback={<Icon name="eye-off" />}>+ <Icon name="eye-on" />+ </Show></TooltipTrigger><TooltipContent>{hidden() ? "Show effect" : "Hide effect"}</TooltipContent></Tooltip>@@ -110,58 +143,54 @@ export function EffectsInspector(props: EffectsInspectorProps) {</FloatingInspectorHeader><FloatingInspectorSeparator /><FloatingInspectorContent class="flex flex-col gap-2 p-4">- {isAmountEffect() && (+ <Show when={option().unit === "amount"}><ControlRow label="Amount"><SliderInput- value={Math.round(clampUnit(effectValue()) * 100)}+ value={Math.round(clampUnit(value()) * 100)}min={0}max={100}- onChange={(v) => updateValue(clampUnit(v / 100))}- onDragStart={() => world.history.startTransaction("Edit effect amount")}- onDragEnd={() => world.history.commitTransaction()}- format={(v) => `${v}%`}- keyframe={<Keyframe target={props.effectEid} property="effect.value" />}+ onChange={(next) => editValue(clampUnit(next / 100))}+ format={(next) => `${next}%`}+ keyframe={<Keyframe target={props.effect} property="value" />}/></ControlRow>- )}+ </Show>- {isBlurEffect() && (- <ControlRow label="Radius">- <div class="grid grid-cols-2 gap-2">- <ControlledTextField- value={effectValue()}- onNumber={(v) => updateValue(Math.max(0, v))}- min={0}- autoSelect- sliderEnabled- limitEvents- keyframe={<Keyframe target={props.effectEid} property="effect.value" />}- />- <IncrementDecrementControl- onDecrement={() => updateValue(Math.max(0, (effectValue() ?? 0) - 1))}- onIncrement={() => updateValue((effectValue() ?? 0) + 1)}- decrementLabel="Decrease blur radius"- incrementLabel="Increase blur radius"- />- </div>+ <Show when={option().unit === "px"}>+ <ControlRow label="Radius" contentClass="grid grid-cols-2 gap-2">+ <ControlledTextField+ value={value()}+ onNumber={(next) => editValue(Math.max(0, next))}+ min={0}+ autoSelect+ sliderEnabled+ limitEvents+ keyframe={<Keyframe target={props.effect} property="value" />}+ />+ <IncrementDecrementControl+ onDecrement={() => editValue(Math.max(0, value() - 1))}+ onIncrement={() => editValue(value() + 1)}+ decrementLabel="Decrease blur radius"+ incrementLabel="Increase blur radius"+ /></ControlRow>- )}+ </Show>- {isHueRotationEffect() && (+ <Show when={option().unit === "deg"}><ControlRow label="Angle"><ControlledTextFieldicon={<Icon name="rotate-angle" class="size-6" />}- value={effectValue()}- onNumber={(v) => updateValue(v)}+ value={value()}+ onNumber={editValue}unit="deg"step={1}autoSelectsliderEnabledlimitEvents- keyframe={<Keyframe target={props.effectEid} property="effect.value" />}+ keyframe={<Keyframe target={props.effect} property="value" />}/></ControlRow>- )}+ </Show></FloatingInspectorContent></FloatingInspector>);diff --git a/apps/web/src/components/sidebar-right/inspector/effects.tsx b/apps/web/src/components/sidebar-right/inspector/effects.tsxindex 025ca388..b66e015e 100644--- a/apps/web/src/components/sidebar-right/inspector/effects.tsx+++ b/apps/web/src/components/sidebar-right/inspector/effects.tsx@@ -2,18 +2,9 @@* 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, Show, createMemo, createSignal } from "solid-js";import { Button } from "@/components/ui/button";import { Tooltip, TooltipContent, TooltipTrigger } from "@/components/ui/tooltip";-import {- DropdownMenu,- DropdownMenuContent,- DropdownMenuItem,- DropdownMenuPortal,- DropdownMenuTrigger,-} from "@/components/ui/dropdown-menu";-import { Icon } from "@/components/ui/icon";-import { ItemRow } from "@/components/ui/item-row";-import { PanelSection } from "@/components/ui/panel-section";import {ContextMenu,ContextMenuContent,@@ -21,51 +12,140 @@ import {ContextMenuSeparator,ContextMenuTrigger,} from "@/components/ui/context-menu";-import { For, Show, createMemo, createSignal } from "solid-js";-import { EFFECT_DEFAULTS, EffectsInspector } from "./effects-inspector";-import { useEntityState, useEntityTag, EffectType, createEntity, deleteEntity, getSiblingEntities, addComponent, appendChild, removeComponent, setComponent } from "@/components/engine";-import { useEngine } from "@/context/engine";-import { hasComponent } from 'bitecs';+import { Icon } from "@/components/ui/icon";+import { ItemRow } from "@/components/ui/item-row";+import { PanelSection } from "@/components/ui/panel-section";+import { useHas, useTrait } from "@diffusionstudio/koota-solid";+import { Effect as EffectElement } from "@diffusionstudio/reconciler";+import { Cache, Effect, Hidden } from "@diffusionstudio/runtime";+import { useDerived, useEditor } from "@/engine/hooks";+import { DEFAULT_EFFECT, effectOption } from "./effect-types";+import { EffectsInspector } from "./effects-inspector";++import type { Entity } from "koota";++// Stable identity, so a node without effects does not resample every tick.+const NO_EFFECTS: Entity[] = [];type EffectsSettingsProps = {- selection: Set<number>;+ selection: Entity[];};-type Effects = Exclude<EffectType, EffectType.DROP_SHADOW>;--const EFFECT_TYPE_BUNDLES: Record<Effects, number> = {- [EffectType.LAYER_BLUR]: EffectType.LAYER_BLUR,- [EffectType.BRIGHTNESS]: EffectType.BRIGHTNESS,- [EffectType.CONTRAST]: EffectType.CONTRAST,- [EffectType.GRAYSCALE]: EffectType.GRAYSCALE,- [EffectType.HUE_ROTATION]: EffectType.HUE_ROTATION,- [EffectType.INVERT]: EffectType.INVERT,- [EffectType.SATURATE]: EffectType.SATURATE,- [EffectType.SEPIA]: EffectType.SEPIA,-};+/**+ * The `<effect>` children of the selected node, in filter order (the list is+ * shown topmost first, so the last element in the file is the first row).+ * A row opens the effect's own inspector, where its type and its amount live.+ * The plus authors an effect outright rather than asking which one first:+ * every type takes the same one number, so switching is a control in the+ * inspector like any other, and adding one is a single click.+ */+export function EffectsSettings(props: EffectsSettingsProps) {+ const editor = useEditor();+ const entity = () => props.selection[0]!;++ let anchorRef!: HTMLDivElement;++ const [picked, setPicked] = createSignal<Entity>();++ // Cache is derived state, written without change events.+ const effects = useDerived(() => entity().get(Cache)?.effects ?? NO_EFFECTS);++ const handleAppendEffect = () => {+ const [effect] = editor.insertElement(entity(), () => (+ <EffectElement type={DEFAULT_EFFECT.name} value={DEFAULT_EFFECT.value} />+ ));+ // Which filter it is, is the one thing the default cannot answer, so the+ // inspector opens on the new effect for it to be said.+ if (effect) setPicked(effect);+ };++ // Read back off the list, so removing an effect closes the inspector on it.+ const editing = createMemo(() => {+ const effect = picked();+ return effect !== undefined && effects().includes(effect) ? effect : undefined;+ });++ /**+ * Swaps `effect` 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 handleReorderEffect = (effect: Entity, direction: number) => {+ const siblings = effects();+ const index = siblings.indexOf(effect);+ const target = index + direction;+ if (index === -1 || target < 0 || target >= siblings.length) return;++ if (direction > 0) {+ editor.reparent(siblings[target]!, entity(), effect);+ } else {+ editor.reparent(effect, entity(), siblings[target]!);+ }+ };++ return (+ <>+ <PanelSection+ title="Effects"+ ref={anchorRef}+ actions={+ <Tooltip>+ <TooltipTrigger+ as={Button}+ size="icon"+ variant="ghost"+ class="text-muted-foreground"+ onClick={handleAppendEffect}+ >+ <Icon name="plus-add" />+ </TooltipTrigger>+ <TooltipContent>Add effect</TooltipContent>+ </Tooltip>+ }+ >+ <For each={effects().toReversed()}>+ {(effect) => (+ <EffectRow+ effect={effect}+ onSelect={() => setPicked(effect)}+ onRemove={() => editor.remove(effect)}+ onMoveUp={() => handleReorderEffect(effect, 1)}+ onMoveDown={() => handleReorderEffect(effect, -1)}+ />+ )}+ </For>+ </PanelSection>++ <Show when={editing() !== undefined}>+ <EffectsInspector+ effect={editing()!}+ anchorRef={anchorRef}+ onClose={() => setPicked(undefined)}+ />+ </Show>+ </>+ );+}type EffectRowProps = {- effectEid: number;- onInspect(): void;+ effect: Entity;+ onSelect(): void;onRemove(): void;onMoveUp(): void;onMoveDown(): void;-}+};function EffectRow(props: EffectRowProps) {- const { world } = useEngine();- const c = world.components;- const type = useEntityState(c.Effect.type, props.effectEid, EffectType.BRIGHTNESS);- const hidden = useEntityTag(c.Hidden, () => props.effectEid);+ const editor = useEditor();++ const effect = useTrait(() => props.effect, Effect);+ const hidden = useHas(() => props.effect, Hidden);- const label = createMemo(() => (EFFECT_DEFAULTS[type() as Effects]?.label ?? ""));+ const label = createMemo(() => effectOption(effect()?.type).label);const toggleHidden = () => {- if (hasComponent(world, props.effectEid, c.Hidden)) {- removeComponent(world, props.effectEid, c.Hidden);- } else {- addComponent(world, props.effectEid, c.Hidden);- }+ editor.editProperty(props.effect, "hidden", !hidden());};return (@@ -75,7 +155,7 @@ function EffectRow(props: EffectRowProps) {label="FX"value={label()}icon={<Icon name="fx" />}- onClick={props.onInspect}+ onClick={props.onSelect}disabled={hidden()}><Tooltip>@@ -93,124 +173,15 @@ function EffectRow(props: EffectRowProps) {</ItemRow></ContextMenuTrigger><ContextMenuContent>- <ContextMenuItem onSelect={props.onMoveUp}>- Move Up- </ContextMenuItem>- <ContextMenuItem onSelect={props.onMoveDown}>- Move Down- </ContextMenuItem>+ <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>+ <ContextMenuItem onSelect={props.onRemove}>Remove</ContextMenuItem></ContextMenuContent></ContextMenu>);}--export function EffectsSettings(props: EffectsSettingsProps) {- const { world } = useEngine();- const [inspectingEffect, setInspectingEffect] = createSignal<number>();- const c = world.components;-- let anchorRef: HTMLDivElement | undefined;-- const eid = () => props.selection.values().next().value!;- const effectEids = useEntityState(world.components.Cache.effects, eid, []);-- const handleAddEffect = (typeName: Effects) => {- const defaults = EFFECT_DEFAULTS[typeName];-- world.history.transaction('Add effect', () => {- const effectEid = createEntity(world);- setComponent(world, effectEid, c.Effect, {- type: EFFECT_TYPE_BUNDLES[typeName],- value: defaults.value,- });- appendChild(world, effectEid, eid())- });- };-- const handleRemoveEffect = (effectEid: number) => deleteEntity(world, effectEid);- const openInspector = (effectEid: number) => setInspectingEffect(effectEid);- const handleReorderEffect = (effectEid: number, direction: number) => {- const effects = getSiblingEntities(world, effectEid, c.Effect);- const index = effects.indexOf(effectEid);- const newIndex = index + direction;- if (newIndex >= 0 && newIndex < effects.length) {- effects.splice(newIndex, 0, effects.splice(index, 1)[0]);- for (const [idx, eid] of effects.entries()) {- setComponent(world, eid, c.ItemIndex, idx);- }- }- };-- return (- <>- <PanelSection- title="Effects"- ref={anchorRef}- actions={- <DropdownMenu placement="bottom-end">- <Tooltip>- <TooltipTrigger<typeof DropdownMenuTrigger>- as={(triggerProps: object) => (- <DropdownMenuTrigger<typeof Button>- {...triggerProps}- as={(buttonProps) => (- <Button- size="icon"- variant="ghost"- class="text-muted-foreground"- {...buttonProps}- >- <Icon name="plus-add" />- </Button>- )}- />- )}- />- <TooltipContent>Add effect</TooltipContent>- </Tooltip>- <DropdownMenuPortal>- <DropdownMenuContent class="w-44">- <For each={Object.values(EffectType).filter((v): v is Effects => typeof v === 'number' && v !== EffectType.DROP_SHADOW)}>- {(t) => (- <DropdownMenuItem onSelect={() => handleAddEffect(t)}>- {EFFECT_DEFAULTS[t].label}- </DropdownMenuItem>- )}- </For>- </DropdownMenuContent>- </DropdownMenuPortal>- </DropdownMenu>- }- >- <For each={effectEids().toReversed()}>- {(effectEid) => (- <EffectRow- effectEid={effectEid}- onInspect={() => openInspector(effectEid)}- onRemove={() => handleRemoveEffect(effectEid)}- onMoveUp={() => handleReorderEffect(effectEid, 1)}- onMoveDown={() => handleReorderEffect(effectEid, -1)}- />- )}- </For>- </PanelSection>-- <Show when={inspectingEffect()}>- <EffectsInspector- onClose={() => setInspectingEffect(undefined)}- anchorRef={anchorRef!}- effectEid={inspectingEffect()!}- nodeEid={eid()}- />- </Show>- </>- );-}diff --git a/apps/web/src/components/sidebar-right/inspector/inspector.tsx b/apps/web/src/components/sidebar-right/inspector/inspector.tsxindex 6c326999..31c6eb60 100644--- a/apps/web/src/components/sidebar-right/inspector/inspector.tsx+++ b/apps/web/src/components/sidebar-right/inspector/inspector.tsx@@ -33,7 +33,7 @@ import { TextPanel } from "./text";// import { FillsSettings } from "./fills";import { StrokesSettings } from "./strokes";import { ShadowsSettings } from "./shadows";-// import { EffectsSettings } from "./effects";+import { EffectsSettings } from "./effects";// import { AnimationsSettings } from "./animations";// import { TransitionSettings } from "./transition";// import { MasksSettings } from "./masks";@@ -161,9 +161,9 @@ export function Inspector() {<ShadowsSettings selection={nodes()} /></Show>- {/* <Show when={includesTarget("shape", "text", "scene", "caption")}>+ <Show when={includesTarget("shape", "text", "scene", "caption")}><EffectsSettings selection={nodes()} />- </Show> */}+ </Show>{/* <Show when={includesTarget("shape", "text", "caption", "group", "mask")}><AnimationsSettings selection={nodes()} />diff --git a/apps/web/src/components/timeline/layers/sub-item.tsx b/apps/web/src/components/timeline/layers/sub-item.tsxindex e37b7fec..5012cb8b 100644--- a/apps/web/src/components/timeline/layers/sub-item.tsx+++ b/apps/web/src/components/timeline/layers/sub-item.tsx@@ -7,12 +7,25 @@ import { hasComponent } from 'bitecs';import { Icon } from '@/components/ui/icon';import { useEngine } from '@/context/engine';import { addComponent, clearComponent, removeComponent, useEntityTag, EffectType, PaintType } from '@/components/engine';-import { EFFECT_DEFAULTS } from '@/components/sidebar-right/inspector/effects-inspector';import { NESTED_INDENT_PX } from './config';import type { TimelineNode } from '@/components/engine/api/timeline-index';import { KEYFRAME_TRACK_HEIGHT } from '@/components/engine/timeline/config';+// The bitecs world's effect labels. The koota panel keeps its own+// ("../sidebar-right/inspector/effect-types"), keyed by the runtime's enum;+// this row goes with the rest of the bitecs timeline.+const EFFECT_LABELS: Partial<Record<EffectType, string>> = {+ [EffectType.LAYER_BLUR]: 'Layer Blur',+ [EffectType.BRIGHTNESS]: 'Brightness',+ [EffectType.CONTRAST]: 'Contrast',+ [EffectType.GRAYSCALE]: 'Grayscale',+ [EffectType.HUE_ROTATION]: 'Hue Rotation',+ [EffectType.INVERT]: 'Invert',+ [EffectType.SATURATE]: 'Saturate',+ [EffectType.SEPIA]: 'Sepia',+};+type SubItemLayerProps = {layer: TimelineNode;depth?: number;@@ -50,8 +63,8 @@ export function SubItemLayer(props: SubItemLayerProps) {}if (hasComponent(world, eid(), c.ColorStop)) return 'Stop';if (hasComponent(world, eid(), c.Effect)) {- const type = c.Effect.type[eid()] as Exclude<EffectType, EffectType.DROP_SHADOW>;- return EFFECT_DEFAULTS[type]?.label ?? `Sub-item ${eid()}`;+ const type = c.Effect.type[eid()] as EffectType;+ return EFFECT_LABELS[type] ?? `Sub-item ${eid()}`;}return `Sub-item ${eid()}`;});diff --git a/packages/jsx/src/types.ts b/packages/jsx/src/types.tsindex 702ce4b0..d77d8752 100644--- a/packages/jsx/src/types.ts+++ b/packages/jsx/src/types.ts@@ -448,7 +448,7 @@ export type ShadowProps = ColorProps & OpacityProps & Pick<CompositeProps, "hidd* and children together), a sub-entity like a paint. Several stack in* document order.*/-export type EffectProps = TrackChildren & {+export type EffectProps = Pick<CompositeProps, "hidden"> & TrackChildren & {/** Which filter to apply. */type: EffectType;/** The amount: px for "blur", degrees for "hueRotate", 0–1 otherwise. */diff --git a/packages/reconciler/src/document.ts b/packages/reconciler/src/document.tsindex 15c45ba9..92164d88 100644--- a/packages/reconciler/src/document.ts+++ b/packages/reconciler/src/document.ts@@ -266,7 +266,7 @@ const ANIMATION_TYPES: Record<string, AnimationType> = {scramble: AnimationType.SCRAMBLE,};-const EFFECT_TYPES: Record<string, EffectType> = {+export const EFFECT_TYPES: Record<string, EffectType> = {blur: EffectType.LAYER_BLUR,brightness: EffectType.BRIGHTNESS,contrast: EffectType.CONTRAST,diff --git a/packages/runtime/MIGRATION.md b/packages/runtime/MIGRATION.mdindex 36aa3239..d2f8c443 100644--- a/packages/runtime/MIGRATION.md+++ b/packages/runtime/MIGRATION.md@@ -76,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, strokes, shadows | `components/sidebar-right/inspector/` |+| Panels: header, background, scene template, asset info, time, appearance, alignment, export, layout, text, strokes, shadows, effects | `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.@@ -95,10 +95,12 @@ Conventions worth repeating when migrating the next panel:- 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, effects, animations, transition, masks, audio, interpolation panels; the timeline's keyframe layer; the whole timeline UI.+Still on bitecs: transform, caption-settings, fills, 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).+The effects panel dropped its add menu: the plus authors an `<effect type="blur" value={8}>` outright and opens the inspector on it, where a select in the header (standing where a title would, as the export inspector's does) changes which filter it is. Every effect is the same one number under a different name, so the type is a control like any other rather than a question asked before the element exists. What that select has to answer for is the unit: `value` is px for `blur`, degrees for `hueRotate` and a 0-1 amount for the six others (`effect-types.ts` carries the table), so a switch within a unit keeps the value while one across it takes the new type's default and drops the `value` track, whose numbers meant the old unit. `type` and `value` are both required props and so are always written, never unset. `<effect>` gained `hidden` (`Pick<CompositeProps, "hidden">`, as `<shadow>` has it): the renderer already skipped a hidden effect, and the panel's row menu had no way to say so.+The shadow panel kept the shape it had: a row per `<shadow>` opening a floating inspector, since nothing in the shadow model moved the way the stroke's line style did. The one thing it says that the file does not is what "Add shadow" authors (`opacity` 0.25, `blur` 4, `offsetY` 4): `<shadow>`'s own defaults are all zero, which casts the silhouette back onto itself, so a shadow added from the panel has to spell out where it sits. Every control unsets at the prop's default (0 for the offsets and the blur, 1 for opacity); `color` is required and always written.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.