An open-source, self-hosted system for apps built with web technologies.
Motions start once the change they show is drawn; Shell popovers leave as they came
zohayrslilehb0772be5fbd0
diff --git a/source/client/view/structure/desktop/drawn.ts b/source/client/view/structure/desktop/drawn.tsnew file mode 100644index 0000000..4b1cad8--- /dev/null+++ b/source/client/view/structure/desktop/drawn.ts@@ -0,0 +1,45 @@+import { useEffect, useState } from "react"++/**+ * Runs `callback` once what changed now has been laid out and drawn: the frame after the next one.+ *+ * A motion starts its clock when it starts. Started together with work that reveals or lays out+ * content, it would spend its first frames waiting for that work and appear already late, often at+ * its end. Safari makes this common: it lays out and draws Program frames on the Desktop's own+ * thread. So a motion starts once the change it shows is on the screen. Returns a cancel.+ */+export function afterDrawn(callback: () => void): () => void {++ let handle = 0++ handle = requestAnimationFrame(() => {+ handle = requestAnimationFrame(() => {+ handle = 0+ callback()+ })+ })++ return () => cancelAnimationFrame(handle)+}++/**+ * The value as last drawn: a new value takes effect once the change that brought it is on the+ * screen (see `afterDrawn`). Give it to what starts a motion, such as a pose, never to what lays+ * out the content the motion reveals. `immediate` takes a new value at once, where nothing moves.+ */+export function useDrawn<Value>(value: Value, { initial = value, immediate = false }: Readonly<{ initial?: Value, immediate?: boolean }> = {}): Value {++ const [drawn, setDrawn] = useState(initial)++ useEffect(function () {++ if (Object.is(drawn, value)) return++ if (immediate) return setDrawn(value)++ return afterDrawn(() => setDrawn(value))++ }, [value, drawn, immediate])++ return immediate ? value : drawn+}diff --git a/source/client/view/structure/desktop/layers/shell/shell-popover.ts b/source/client/view/structure/desktop/layers/shell/shell-popover.tsnew file mode 100644index 0000000..a74225b--- /dev/null+++ b/source/client/view/structure/desktop/layers/shell/shell-popover.ts@@ -0,0 +1,125 @@+import { useCallback, useEffect, useRef, useState } from "react"+import { useReducedMotion } from "@libs/react-motion"+import { surfaceLifecyclePose } from "@client/view/appearance/surface-presence"+import { useDrawn } from "../../drawn"++/**+ * A Shell surface opened from its Taskbar button, such as the Start Menu or the map: a popover, so+ * it stands above every Window. Pressing anything else, Escape, or focus crossing into a Program+ * frame closes it, and the press goes on to what it was meant for.+ *+ * The Desktop hides it itself, once its leaving motion ends: a browser closing a popover hides it at+ * once, and Safari keeps nothing of it on the screen while it leaves. So the popover is manual, and+ * dismissing it is the Desktop's. Its button names it with `aria-controls` and toggles it.+ */+export function useShellPopover(onOpenChange?: (open: boolean) => void) {++ const surface = useRef<HTMLDivElement>(null)+ const [open, setOpenState] = useState(false)+ const reducedMotion = useReducedMotion()+ const shown = useDrawn(open, { immediate: reducedMotion })+ const current = useRef({ open, shown, reducedMotion, onOpenChange })++ current.current = { open, shown, reducedMotion, onOpenChange }++ const setOpen = useCallback(function (next: boolean) {++ if (current.current.open === next) return++ current.current.open = next+ setOpenState(next)+ current.current.onOpenChange?.(next)+ }, [])++ // Hides it once nothing is left to see: closed, and its leaving motion over or never begun.+ const hide = useCallback(function () {++ const element = surface.current++ if (!current.current.open && element?.matches(":popover-open")) element.hidePopover()+ }, [])++ const show = useCallback(function () {++ const element = surface.current++ if (!element) return++ if (!element.matches(":popover-open")) element.showPopover()++ setOpen(true)+ }, [setOpen])++ const close = useCallback(function () {++ if (!current.current.open) return++ setOpen(false)++ // Not yet entered, or without motion, it has no leaving to wait for.+ if (!current.current.shown || current.current.reducedMotion) hide()+ }, [setOpen, hide])++ const toggle = useCallback(function () {++ if (current.current.open) close()+ else show()+ }, [close, show])++ useEffect(function () {++ if (!open) return++ function press(event: PointerEvent) {++ const target = event.target instanceof Element ? event.target : null+ const element = surface.current++ if (!target || !element || element.contains(target)) return++ // Its own button toggles it.+ if (element.id && target.closest(`[aria-controls="${CSS.escape(element.id)}"]`)) return++ close()+ }++ function key(event: KeyboardEvent) {++ // Something inside that answers Escape itself, such as an open menu, keeps it open.+ if (event.key === "Escape" && !event.defaultPrevented) close()+ }++ // Program frames are separate documents: focus crossing into one is the press there.+ function blur() {++ if (document.activeElement instanceof HTMLIFrameElement && !surface.current?.contains(document.activeElement)) close()+ }++ document.addEventListener("pointerdown", press, true)+ document.addEventListener("keydown", key)+ window.addEventListener("blur", blur)++ return function () {++ document.removeEventListener("pointerdown", press, true)+ document.removeEventListener("keydown", key)+ window.removeEventListener("blur", blur)+ }++ }, [open, close])++ return {+ surface,+ open,+ show,+ close,+ toggle,+ /** Spread on the surface's `motion` element, with its own transition. */+ motion: {+ popover: "manual" as const,+ initial: false as const,+ animate: shown ? surfaceLifecyclePose.visible : surfaceLifecyclePose.hidden,+ onAnimationComplete: hide+ }+ }+}diff --git a/source/client/view/structure/desktop/layers/shell/start-menu/start-menu.tsx b/source/client/view/structure/desktop/layers/shell/start-menu/start-menu.tsxindex 74d3d14..3930219 100644--- a/source/client/view/structure/desktop/layers/shell/start-menu/start-menu.tsx+++ b/source/client/view/structure/desktop/layers/shell/start-menu/start-menu.tsx@@ -1,15 +1,15 @@import PhreshOSIcon from "@client/view/components/phreshos-icon"-import { createContext, memo, useCallback, useContext, useEffect, useId, useRef, useState, type CSSProperties, type PropsWithChildren, type RefObject } from "react"+import { createContext, memo, useContext, useId, type CSSProperties, type PropsWithChildren } from "react"import StartMenuPanel from "./start-menu-panel"import { name } from "@/source/identity"import { type AppearanceTaskbar } from "@phreshos/core"import { useReducedMotion } from "@libs/react-motion"import { motion } from "motion/react"import { shellSurfaceClassName } from "../shell-surface"+import { useShellPopover } from "../shell-popover"import TaskbarButton from "../taskbar/taskbar-button"import { useTiming } from "@phreshos/react-ui"-import { cssEasing } from "@phreshos/core"-import { surfaceLifecyclePose, surfacePresenceTransition } from "@client/view/appearance/surface-presence"+import { surfacePresenceTransition } from "@client/view/appearance/surface-presence"import { usePortrait } from "../../../orientation"import { useDesktopScale } from "../../../desktop-scale"@@ -23,59 +23,9 @@ export function StartMenuProvider({ taskbar, spacing, children }: PropsWithChildconst id = useId()- const surface = useRef<HTMLDivElement>(null)+ const popover = useShellPopover()- const [open, setOpen] = useState(false)-- const openAtPressStart = useRef(false)-- const close = useCallback(function () {-- const element = surface.current-- if (element?.matches(":popover-open")) element.hidePopover()-- }, [])-- const beginToggle = useCallback(function () {-- openAtPressStart.current = surface.current?.matches(":popover-open") ?? false-- }, [])-- const toggle = useCallback(function () {-- const element = surface.current-- if (!element) return-- if (openAtPressStart.current) {-- if (element.matches(":popover-open")) element.hidePopover()-- return- }-- if (!element.matches(":popover-open")) element.showPopover()-- }, [])-- useEffect(function () {-- // Program frames are separate documents, so focus crossing the iframe- // boundary is the signal that replaces native popover light dismissal.- function closeForProgramFrame() {-- if (document.activeElement instanceof HTMLIFrameElement && !surface.current?.contains(document.activeElement)) close()- }-- window.addEventListener("blur", closeForProgramFrame)-- return () => window.removeEventListener("blur", closeForProgramFrame)-- }, [close])-- return <StartMenuContext.Provider value={{ id, surface, taskbar, spacing, open, setOpen, close, beginToggle, toggle }}>+ return <StartMenuContext.Provider value={{ id, taskbar, spacing, popover }}>{children}@@ -94,11 +44,10 @@ export const StartMenuButton = memo(function StartMenuButton({ showLabel = truecolor="default:base"material="extended"aria-controls={control.id}- aria-expanded={control.open}+ aria-expanded={control.popover.open}aria-haspopup="dialog"aria-label={name}- onPressStart={control.beginToggle}- onPress={control.toggle}+ onPress={control.popover.toggle}/>})@@ -116,24 +65,15 @@ export default memo(function StartMenu() {const scale = useDesktopScale()return <motion.div- ref={control.surface}+ ref={control.popover.surface}id={control.id}role="dialog"- popover="auto"aria-labelledby={`${control.id}-label`}tabIndex={-1}className={`${shellSurfaceClassName} pointer-events-auto fixed hidden open:block`}- style={{- ...startMenuStyle(control.taskbar, control.spacing, portrait, scale),- transitionBehavior: "allow-discrete",- transitionDuration: reducedMotion ? "0ms" : String(transaction.duration) + "ms",- transitionTimingFunction: cssEasing(transaction.easing),- transitionProperty: "display, overlay"- }}- initial={false}- animate={control.open ? surfaceLifecyclePose.visible : surfaceLifecyclePose.hidden}+ style={startMenuStyle(control.taskbar, control.spacing, portrait, scale)}+ {...control.popover.motion}transition={surfacePresenceTransition(reducedMotion, transaction)}- onBeforeToggle={event => control.setOpen(event.newState === "open")}onToggle={event => {if (event.newState !== "open") return@@ -147,7 +87,7 @@ export default memo(function StartMenu() {<StartMenuPanellabelId={`${control.id}-label`}- onChoose={control.close}+ onChoose={control.popover.close}/></motion.div>@@ -204,17 +144,12 @@ function useStartMenuControl() {/** Whether the default Shell's Start Menu currently retains its Taskbar anchor. */export function useStartMenuOpen() {- return useStartMenuControl().open+ return useStartMenuControl().popover.open}interface StartMenuControl {id: string- surface: RefObject<HTMLDivElement | null>taskbar: AppearanceTaskbarspacing: number- open: boolean- setOpen: (open: boolean) => void- close: () => void- beginToggle: () => void- toggle: () => void+ popover: ReturnType<typeof useShellPopover>}diff --git a/source/client/view/structure/desktop/layers/shell/taskbar/map/map-control.tsx b/source/client/view/structure/desktop/layers/shell/taskbar/map/map-control.tsxindex 9a6d7ea..736b354 100644--- a/source/client/view/structure/desktop/layers/shell/taskbar/map/map-control.tsx+++ b/source/client/view/structure/desktop/layers/shell/taskbar/map/map-control.tsx@@ -1,9 +1,8 @@-import { cssEasing } from "@phreshos/core"import { Button, ContextMenu, Panel, Surface, Text, Tooltip, useAppearance, useColor, useScale, useTiming } from "@phreshos/react-ui"import { Map as MapIcon, Maximize2 } from "@phreshos/react-ui/icons"import WindowMenu from "../../window-menu"import TaskbarTooltip from "../taskbar-tooltip"-import { useCallback, useEffect, useId, useLayoutEffect, useRef, useState, type CSSProperties, type PointerEvent as ReactPointerEvent } from "react"+import { useEffect, useId, useLayoutEffect, useRef, useState, type CSSProperties, type PointerEvent as ReactPointerEvent } from "react"import { planeReach, snapPlacement, type WindowRegion } from "@client/view/components/window-manager/window-geometry"import { type AppearanceTaskbar } from "@phreshos/core"import { useReducedMotion } from "@libs/react-motion"@@ -13,7 +12,8 @@ import { EdgeHold, against, useViewTravel } from "../../../../edge-hold"import { createPortal } from "react-dom"import SnapPreview, { type SnapTarget } from "../../../../windows/snap-preview"import { desktopMargins } from "../../../desktop-layers"-import { surfaceLifecyclePose, surfacePresenceTransition } from "@client/view/appearance/surface-presence"+import { surfacePresenceTransition } from "@client/view/appearance/surface-presence"+import { useShellPopover } from "../../shell-popover"import { shellSurfaceClassName } from "../../shell-surface"import { floatingShadow } from "@client/view/appearance/floating-shadow"import { type Viewport } from "../../../../viewport-offset"@@ -63,10 +63,9 @@ export interface MappedWindow {* above them, and the Windows above both. Choosing a view moves there; dragging the frame* moves the view anywhere.*- * The map opens and closes as the Start Menu does: a native popover, which the- * browser closes when something else on the Desktop is pressed, and which closes- * itself when focus crosses into a Program frame; either way the press goes on- * to what it was meant for.+ * The map opens and closes as the Start Menu does, a Shell popover: pressing+ * anything else, Escape, or focus crossing into a Program frame closes it, and+ * the press goes on to what it was meant for.*/export default function MapControl({ viewport, windows, taskbar, spacing, onOpenChange }: Readonly<{viewport: Viewport@@ -80,9 +79,9 @@ export default function MapControl({ viewport, windows, taskbar, spacing, onOpenconst trigger = useRef<HTMLButtonElement>(null)- const surface = useRef<HTMLDivElement>(null)+ const popover = useShellPopover(onOpenChange)- const [open, setOpen] = useState(false)+ const { surface, open, close } = popover// Where the map opens, measured from the button when it opens, and the room it has there.const [anchor, setAnchor] = useState<CSSProperties>({})@@ -92,8 +91,6 @@ export default function MapControl({ viewport, windows, taskbar, spacing, onOpen// How far the map moves inward so it stays on the screen, once it is drawn.const [inward, setInward] = useState(0)- const openAtPressStart = useRef(false)-const reducedMotion = useReducedMotion()const transaction = useTiming()("change")@@ -104,26 +101,6 @@ export default function MapControl({ viewport, windows, taskbar, spacing, onOpenconst place = `${viewport.view.x}, ${viewport.view.y}`- const close = useCallback(function () {-- if (surface.current?.matches(":popover-open")) surface.current.hidePopover()-- }, [])-- useEffect(function () {-- // Program frames are separate documents, so focus crossing into one is what closes the map there.- function closeForProgramFrame() {-- if (document.activeElement instanceof HTMLIFrameElement && !surface.current?.contains(document.activeElement)) close()- }-- window.addEventListener("blur", closeForProgramFrame)-- return () => window.removeEventListener("blur", closeForProgramFrame)-- }, [close])-// The map's button can be carried: dragged out, it leaves a ghost in the hand, and held against an// edge of the screen, the ghost takes the view that way, as a held Window does. It is what the// hand holds when there is no Window to carry, and it belongs to the Shell, so no Program under@@ -240,12 +217,9 @@ export default function MapControl({ viewport, windows, taskbar, spacing, onOpenif (carried.current) return- const element = surface.current-- if (!element || !trigger.current) return+ if (!trigger.current) return- // A press on the button while the map is open already closed it.- if (openAtPressStart.current) return close()+ if (open) return close()setAnchor(anchorStyle(trigger.current, taskbar, spacing))@@ -253,7 +227,7 @@ export default function MapControl({ viewport, windows, taskbar, spacing, onOpensetInward(0)- element.showPopover()+ popover.show()}// It starts where its button starts; where it would pass the screen's far edge, it moves back just@@ -286,7 +260,6 @@ export default function MapControl({ viewport, windows, taskbar, spacing, onOpen<Button ref={trigger} size="small" iconOnly={centered && !vertical} className={vertical ? "px-0" : undefined} color={centered ? undefined : "primary:soft"}style={ghost ? { opacity: 0.35 } : undefined}aria-label={centered ? "Map" : `Map, near ${place}`} aria-controls={id} aria-expanded={open} aria-haspopup="dialog"- onPressStart={() => { openAtPressStart.current = surface.current?.matches(":popover-open") ?? false }}onPress={toggle}><MapIcon />{!centered && !vertical && <span className="tabular-nums">{place}</span>}</Button>@@ -315,22 +288,15 @@ export default function MapControl({ viewport, windows, taskbar, spacing, onOpenref={surface}id={id}role="dialog"- popover="auto"aria-labelledby={`${id}-label`}tabIndex={-1}className={`${shellSurfaceClassName} pointer-events-auto fixed hidden open:block`}style={{...anchor,- ...(vertical ? { top: Number(anchor.top ?? 0) - inward } : { left: Number(anchor.left ?? 0) - inward }),- transitionBehavior: "allow-discrete",- transitionDuration: reducedMotion ? "0ms" : String(transaction.duration) + "ms",- transitionTimingFunction: cssEasing(transaction.easing),- transitionProperty: "display, overlay"+ ...(vertical ? { top: Number(anchor.top ?? 0) - inward } : { left: Number(anchor.left ?? 0) - inward })}}- initial={false}- animate={open ? surfaceLifecyclePose.visible : surfaceLifecyclePose.hidden}+ {...popover.motion}transition={surfacePresenceTransition(reducedMotion, transaction)}- onBeforeToggle={event => { setOpen(event.newState === "open"); onOpenChange(event.newState === "open") }}onToggle={event => { if (event.newState === "open") event.currentTarget.focus() }}>diff --git a/source/client/view/structure/desktop/windows/window-geometry-animation.ts b/source/client/view/structure/desktop/windows/window-geometry-animation.tsindex ac79e56..5c5f4fb 100644--- a/source/client/view/structure/desktop/windows/window-geometry-animation.ts+++ b/source/client/view/structure/desktop/windows/window-geometry-animation.ts@@ -2,6 +2,7 @@ import type { WindowRegion } from "@client/view/components/window-manager/windowimport type { Transaction } from "@phreshos/core"import { animate, type AnimationPlaybackControls, type MotionValue } from "motion/react"import { motionTransition } from "@client/view/appearance/motion"+import { afterDrawn } from "../drawn"const axes = ["x", "y", "width", "height"] as constconst sizeAxes = ["width", "height"] as const@@ -18,7 +19,7 @@ export class WindowGeometryAnimation {private flights = new Map<Axis, Flight>()private complete?: () => voidprivate updating = false- private waiting = 0+ private waiting: (() => void) | null = nullconstructor(private values: Record<Axis, MotionValue<number>>,@@ -88,16 +89,16 @@ export class WindowGeometryAnimation {this.layout.width.set(width)this.layout.height.set(height)- // Content laid out anew may take a while, and Safari lays out a Program's frame on the- // Desktop's own thread: a tween started with it would find its time spent and jump to its- // end. Starting from rest, it waits for that layout to be drawn; a running one retargets.+ // Starting from rest, the tween waits for the content laid out anew to be drawn; a running+ // one retargets at once.if (reflows) {- this.waiting = requestAnimationFrame(() => {- this.waiting = requestAnimationFrame(() => {- this.waiting = 0- this.fly(region, transaction, animatedAxes)- })+ let drawn = false+ const cancel = afterDrawn(() => {+ drawn = true+ this.waiting = null+ this.fly(region, transaction, animatedAxes)})+ if (!drawn) this.waiting = cancelreturn}@@ -146,8 +147,8 @@ export class WindowGeometryAnimation {}private cancelWait() {- cancelAnimationFrame(this.waiting)- this.waiting = 0+ this.waiting?.()+ this.waiting = null}private settleLayout() {diff --git a/source/client/view/structure/desktop/windows/window-geometry-motion.ts b/source/client/view/structure/desktop/windows/window-geometry-motion.tsindex 4721ae8..4ceb636 100644--- a/source/client/view/structure/desktop/windows/window-geometry-motion.ts+++ b/source/client/view/structure/desktop/windows/window-geometry-motion.ts@@ -2,8 +2,8 @@ import { constrainWindowGeometry, resolveWindowGeometry, type WindowRegion, typeimport { type PresentationAnimation } from "@client/view/components/desktop-host/presentation"import { resolvePresentationTransaction } from "@client/view/appearance/motion"import { type Transaction, type Position, type Size, type PresentationTransaction } from "@phreshos/core"-import { useMotionValue, useTransform, type MotionStyle } from "motion/react"-import { useLayoutEffect, useRef } from "react"+import { useMotionValue, type MotionStyle } from "motion/react"+import { useEffect, useLayoutEffect, useRef } from "react"import { WindowGeometryAnimation } from "./window-geometry-animation"import { timing, useAppearance } from "@phreshos/react-ui"@@ -36,8 +36,26 @@ export default function useWindowGeometryMotion({ position, size, animation, traconst layoutWidth = useMotionValue(width.get())const layoutHeight = useMotionValue(height.get())const transformOrigin = useMotionValue("0px 0px")- const scaleX = useTransform(() => layoutWidth.get() === 0 ? 1 : width.get() / layoutWidth.get())- const scaleY = useTransform(() => layoutHeight.get() === 0 ? 1 : height.get() / layoutHeight.get())+ const scaleX = useMotionValue(1)+ const scaleY = useMotionValue(1)++ // The scale reads the shown size against the laid-out one. It is set the moment either changes,+ // so both reach the screen in the same frame: a derived value would follow a frame later, and the+ // Window would flash once at its laid-out size when a resize starts.+ useEffect(function () {++ const fit = () => {+ scaleX.set(layoutWidth.get() === 0 ? 1 : width.get() / layoutWidth.get())+ scaleY.set(layoutHeight.get() === 0 ? 1 : height.get() / layoutHeight.get())+ }++ fit()++ const stops = [width, height, layoutWidth, layoutHeight].map(value => value.on("change", fit))++ return () => stops.forEach(stop => stop())++ }, [width, height, layoutWidth, layoutHeight, scaleX, scaleY])const animator = useRef<WindowGeometryAnimation | null>(null)if (!animator.current) animator.current = new WindowGeometryAnimation({ x, y, width, height }, { width: layoutWidth, height: layoutHeight })const gesturing = useRef(false)diff --git a/source/client/view/structure/desktop/windows/window-surface.tsx b/source/client/view/structure/desktop/windows/window-surface.tsxindex 0d6d857..868b76d 100644--- a/source/client/view/structure/desktop/windows/window-surface.tsx+++ b/source/client/view/structure/desktop/windows/window-surface.tsx@@ -8,6 +8,7 @@ import { surfaceLifecyclePose, surfacePresenceTransition } from "@client/view/apimport { resolvePresentationTransaction } from "@client/view/appearance/motion"import { floatingShadow } from "@client/view/appearance/floating-shadow"import { useAppearance, useTiming } from "@phreshos/react-ui"+import { useDrawn } from "../drawn"/** Paints the optional Desktop-owned backing surface for a supported presentation. */export default function WindowSurface({ surface, active = true, floating = false, animation, onComplete }: WindowSurfaceProps) {@@ -25,6 +26,9 @@ export default function WindowSurface({ surface, active = true, floating = falseif (surface !== false) retained.current = surface+ // Its motion starts once the change it shows is drawn.+ const shown = useDrawn(visible, { initial: animated && visible && !reducedMotion ? false : visible, immediate: reducedMotion || !animated })+useLayoutEffect(function () {if (visible) setHidden(false)@@ -48,7 +52,7 @@ export default function WindowSurface({ surface, active = true, floating = falsereturn <motion.divinitial={animated && visible && !reducedMotion ? surfaceLifecyclePose.hidden : surfaceLifecyclePose.visible}- animate={visible ? surfaceLifecyclePose.visible : surfaceLifecyclePose.hidden}+ animate={shown ? surfaceLifecyclePose.visible : surfaceLifecyclePose.hidden}transition={animated? surfacePresenceTransition(reducedMotion, transaction): { duration: 0 }}diff --git a/source/client/view/structure/desktop/windows/window.tsx b/source/client/view/structure/desktop/windows/window.tsxindex 2af54bc..49c0fe0 100644--- a/source/client/view/structure/desktop/windows/window.tsx+++ b/source/client/view/structure/desktop/windows/window.tsx@@ -17,6 +17,7 @@ import SnapPreview, { type SnapTarget } from "./snap-preview"import useWindowGeometryMotion from "./window-geometry-motion"import WindowGestureCommit from "./window-gesture-commit"import { physicalToDesktopPixels, useDesktopScale } from "../desktop-scale"+import { useDrawn } from "../drawn"/*** One drawing on the Desktop: a standard Window, which the Desktop designs, or a Program's own drawing@@ -282,12 +283,19 @@ export default function ({ title, header = true, surface, layer, icon, children,? opening ? windowSurfaceLifecyclePose.hidden : windowSurfaceLifecyclePose.visible: opening ? surfaceLifecyclePose.hidden : surfaceLifecyclePose.visible- const presencePose = closing && standard+ // Each presence motion starts once the change it shows is drawn; the state itself is current.+ const shownClosing = useDrawn(closing, { immediate: reducedMotion })+ const shownMinimized = useDrawn(minimized, { immediate: reducedMotion })+ const arrived = useDrawn(true, { initial: opening === null, immediate: reducedMotion })++ const presencePose = shownClosing && standard? windowSurfaceLifecyclePose.hidden- : minimized+ : shownMinimized// Only a standard Window is ever minimized.? windowMinimizePose(taskbarPosition)- : standard ? windowSurfaceLifecyclePose.visible : surfaceLifecyclePose.visible+ : !arrived+ ? initialPresence+ : standard ? windowSurfaceLifecyclePose.visible : surfaceLifecyclePose.visibleconst presenceTransition = reducedMotion? { duration: 0 }