An open-source, self-hosted system for apps built with web technologies.
Presentation events tell the drawing as it moves, in real time; rename to the Presentation family
zohayrslilehcb0059cb3eba
diff --git a/source/client/view/appearance/motion.ts b/source/client/view/appearance/motion.tsindex e1bec94..093818a 100644--- a/source/client/view/appearance/motion.ts+++ b/source/client/view/appearance/motion.ts@@ -1,4 +1,4 @@-import { type AppearanceTransaction, type Easing, type WindowPresentationTransaction } from "@phreshos/core"+import { type AppearanceTransaction, type Easing, type PresentationTransaction } from "@phreshos/core"import { type Transition } from "motion/react"const easings: Record<Exclude<Easing, readonly number[]>, Transition["ease"]> = {@@ -20,7 +20,7 @@ export function motionTransition(transaction: AppearanceTransaction, reduced = f}/** Resolves an optional presentation timing against the current Appearance. */-export function resolveWindowTransaction(transaction: WindowPresentationTransaction | undefined, appearance: AppearanceTransaction): AppearanceTransaction {+export function resolveWindowTransaction(transaction: PresentationTransaction | undefined, appearance: AppearanceTransaction): AppearanceTransaction {if (transaction === undefined) return appearancediff --git a/source/client/view/components/desktop-host/client-host.ts b/source/client/view/components/desktop-host/client-host.tsindex a83be73..c5ef6b7 100644--- a/source/client/view/components/desktop-host/client-host.ts+++ b/source/client/view/components/desktop-host/client-host.ts@@ -7,7 +7,7 @@ import { type DesktopViewportHost } from "./host"import { type RefObject, useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState } from "react"import useViewportOffset from "@client/view/structure/desktop/viewport-offset"import { type default as AuthManager } from "@client/core/link-manager/auth-manager/auth-manager"-import { type WindowPresentationHost } from "./window-presentation"+import { type PresentationHost } from "./presentation"import messagepack from "@the-link/messagepack"/**@@ -15,7 +15,7 @@ import messagepack from "@the-link/messagepack"* It owns frame messages and the measured desktop containing those frames;* neither fact participates in rendering.*/-export default function useClientHost(authManager: AuthManager, desktop: RefObject<HTMLDivElement | null>, sources: Map<string, HTMLIFrameElement | null>, presentation: WindowPresentationHost) {+export default function useClientHost(authManager: AuthManager, desktop: RefObject<HTMLDivElement | null>, sources: Map<string, HTMLIFrameElement | null>, presentation: PresentationHost) {const windowSurfaceRef = useRef<HTMLDivElement>(null)diff --git a/source/client/view/components/desktop-host/client-process-boundary.ts b/source/client/view/components/desktop-host/client-process-boundary.tsindex 6943eab..60767df 100644--- a/source/client/view/components/desktop-host/client-process-boundary.ts+++ b/source/client/view/components/desktop-host/client-process-boundary.ts@@ -4,8 +4,8 @@ import host, { TransferredAnswer, type DesktopViewportHost } from "./host"import ClientTraffic from "./client-traffic"import { failed, succeeded } from "@libs/request-outcome"import { type TrafficKind } from "@server/core/link-manager/auth-manager/process-manager/process-traffic"-import { isServiceAddress, parseProgramInstallOptions, type ServiceAddress, type ShellOptions, type WindowMovePoint } from "@phreshos/core"-import { type PresentationFrame, type PresentationMovePoint, type WindowPresentationHost } from "./window-presentation"+import { isServiceAddress, parseProgramInstallOptions, type ServiceAddress, type ShellOptions, type PresentationMovePoint } from "@phreshos/core"+import { type PresentationFrame, type DesktopMovePoint, type PresentationHost } from "./presentation"import messagepack from "@the-link/messagepack"import { sdkProcess, type SdkProcessSource } from "./sdk-records"import SystemAccess from "./system-access"@@ -23,7 +23,7 @@ export default class ClientProcessBoundary extends TheLink {private readonly traffic: ClientTraffic- private readonly presentation: WindowPresentationHost+ private readonly presentation: PresentationHostprivate readonly frame: PresentationFrame@@ -77,7 +77,7 @@ export default class ClientProcessBoundary extends TheLink {private leased: string | null = null- public constructor(pane: string, element: HTMLIFrameElement, authManager: AuthManager, viewport: DesktopViewportHost, traffic: ClientTraffic, presentation: WindowPresentationHost) {+ public constructor(pane: string, element: HTMLIFrameElement, authManager: AuthManager, viewport: DesktopViewportHost, traffic: ClientTraffic, presentation: PresentationHost) {super()@@ -1057,9 +1057,9 @@ export default class ClientProcessBoundary extends TheLink {}/**- * Tells the Client each change in how it is drawn: whatever this Desktop draws changes, or the- * frame or the Desktop changes size. A change is told once the drawing has arrived, not along- * the motion that carries it there.+ * Tells the Client each change in how it is drawn, as it happens: whatever this Desktop draws+ * changes, its box moves a step, or the frame or the Desktop changes size. Changes within one+ * frame are told once, as they stand when it is drawn.*/private followDrawing() {@@ -1076,20 +1076,17 @@ export default class ClientProcessBoundary extends TheLink {if (scheduled) return- // The layout of the change is read after it is drawn.scheduled = requestAnimationFrame(() => {scheduled = 0const drawing = read()- if (!drawing || !this.presentation.settled(this.pane)) return-const before = toldtold = drawing- if (!before) return+ if (!drawing || !before) returnif (drawing.position.x !== before.position.x || drawing.position.y !== before.position.y) this.deliver("host-presentation", "move", drawing.position).catch(() => undefined)@@ -1173,7 +1170,7 @@ export default class ClientProcessBoundary extends TheLink {}-export function frameMovePoint(frame: HTMLIFrameElement, point: PresentationMovePoint): PresentationMovePoint {+export function frameMovePoint(frame: HTMLIFrameElement, point: DesktopMovePoint): DesktopMovePoint {const bounds = frame.getBoundingClientRect()// Frame-local CSS pixels must enter the same physical viewport coordinate// space as pointer events captured directly by the Desktop.@@ -1185,7 +1182,7 @@ export function frameMovePoint(frame: HTMLIFrameElement, point: PresentationMoveexport class ClientFrame implements PresentationFrame {public constructor(public readonly element: HTMLIFrameElement) {}- public point(point: WindowMovePoint) {+ public point(point: PresentationMovePoint) {return frameMovePoint(this.element, point)}}diff --git a/source/client/view/components/desktop-host/host.ts b/source/client/view/components/desktop-host/host.tsindex 126801e..b675ba9 100644--- a/source/client/view/components/desktop-host/host.ts+++ b/source/client/view/components/desktop-host/host.ts@@ -31,8 +31,8 @@ import {presentationSize,presentationTransaction,type PresentationFrame,- type WindowPresentationHost-} from "./window-presentation"+ type PresentationHost+} from "./presentation"import SystemAccess from "./system-access"import { allowsSynchronizedPermission } from "@shared/permission-state"@@ -51,7 +51,7 @@ export interface DesktopViewportHost {move(offset: DesktopOffset): void}-export default function host(authManager: AuthManager, pane: string, viewport: DesktopViewportHost, frameOwner: () => string | null, frame: PresentationFrame, presentation: WindowPresentationHost) {+export default function host(authManager: AuthManager, pane: string, viewport: DesktopViewportHost, frameOwner: () => string | null, frame: PresentationFrame, presentation: PresentationHost) {const { processManager, programManager } = authManager@@ -163,7 +163,7 @@ export default function host(authManager: AuthManager, pane: string, viewport: Dconst found = holdProcess(value)- if (found !== process()) throw new Error("Window presentation operations belong to the current Client Context")+ if (found !== process()) throw new Error("Presentation operations belong to the current Client Context")clientOf(found)@@ -904,12 +904,12 @@ export default function host(authManager: AuthManager, pane: string, viewport: Dreturn [pane]}- if (word === "windowPresentation") {+ if (word === "presentation") {const target = presentationProcess(args[0])return [presentation.drawing(target.identity, frame.element)]}- if (word === "windowPresentationMoveGestureBegin") {+ if (word === "presentationMoveGestureBegin") {const target = presentationProcess(args[0])const gesture = gestureIdentity(args[1])const start = presentationMoveGestureStart(args[2])@@ -922,14 +922,14 @@ export default function host(authManager: AuthManager, pane: string, viewport: Dreturn []}- if (word === "windowPresentationMoveGestureWait") {+ if (word === "presentationMoveGestureWait") {const target = presentationProcess(args[0])const gesture = gestureIdentity(args[1])await presentation.waitMoveGesture(target.identity, gesture)return []}- if (word === "windowPresentationMoveGestureCancel") {+ if (word === "presentationMoveGestureCancel") {const target = presentationProcess(args[0])const gesture = gestureIdentity(args[1])presentation.cancelMoveGesture(target.identity, gesture)@@ -938,7 +938,7 @@ export default function host(authManager: AuthManager, pane: string, viewport: Dconst selectedTransaction = () => presentationTransaction(args[2])- if (word === "windowPresentationMove") {+ if (word === "presentationMove") {const target = presentationProcess(args[0])await presentation.move(target.identity, presentationPosition(args[1]), selectedTransaction())@@ -946,7 +946,7 @@ export default function host(authManager: AuthManager, pane: string, viewport: Dreturn []}- if (word === "windowPresentationResize") {+ if (word === "presentationResize") {const target = presentationProcess(args[0])await presentation.resize(target.identity, presentationSize(args[1]), selectedTransaction())@@ -954,7 +954,7 @@ export default function host(authManager: AuthManager, pane: string, viewport: Dreturn []}- if (word === "windowPresentationGeometry") {+ if (word === "presentationGeometry") {const target = presentationProcess(args[0])await presentation.setGeometry(target.identity, presentationGeometry(args[1]), selectedTransaction())@@ -962,20 +962,20 @@ export default function host(authManager: AuthManager, pane: string, viewport: Dreturn []}- if (word === "windowPresentationSurface") {+ if (word === "presentationSurface") {const target = presentationProcess(args[0])await presentation.setSurface(target.identity, presentationSurface(args[1]), selectedTransaction())return []}- if (word === "windowPresentationInteractive") {+ if (word === "presentationInteractive") {const target = presentationProcess(args[0])- if (typeof args[1] !== "boolean") throw new Error("Window presentation interaction must be true or false")+ if (typeof args[1] !== "boolean") throw new Error("Presentation interaction must be true or false")presentation.setInteractive(target.identity, args[1])return []}- if (word === "windowPresentationRaise") {+ if (word === "presentationRaise") {const target = presentationProcess(args[0])presentation.raise(target.identity)diff --git a/source/client/view/components/desktop-host/window-presentation.ts b/source/client/view/components/desktop-host/presentation.tssimilarity index 55%rename from source/client/view/components/desktop-host/window-presentation.tsrename to source/client/view/components/desktop-host/presentation.tsindex b9ec607..cd4e5e1 100644--- a/source/client/view/components/desktop-host/window-presentation.ts+++ b/source/client/view/components/desktop-host/presentation.ts@@ -1,120 +1,119 @@import {- parseWindowPresentationSurface,- parseWindowPresentationTransaction,+ parsePresentationSurface,+ parsePresentationTransaction,type WindowLayer,- type WindowMoveGestureStart,- type WindowMovePoint,- type WindowPresentationGeometry,- type WindowPresentationPosition,- type WindowPresentationSize,- type WindowPresentationSurface,- type WindowPresentationTransaction+ type PresentationMoveGestureStart,+ type PresentationMovePoint,+ type PresentationGeometry,+ type PresentationPosition,+ type PresentationSize,+ type PresentationSurface,+ type PresentationTransaction} from "@phreshos/core"export type PresentationAnimation = Readonly<{revision: number- transaction?: WindowPresentationTransaction+ transaction?: PresentationTransaction}>export type PresentationTransactionRequest = Readonly<{- transaction?: WindowPresentationTransaction+ transaction?: PresentationTransactionwait: boolean}>-export type PresentationMovePoint = Readonly<{ x: number, y: number }>+export type DesktopMovePoint = Readonly<{ x: number, y: number }>/** The frame one Client document is drawn in, as the Desktop sees it. */export interface PresentationFrame {readonly element: HTMLIFrameElement/** Where a point of the Client document is in the Desktop's viewport. */- point(point: WindowMovePoint): PresentationMovePoint+ point(point: PresentationMovePoint): DesktopMovePoint}-export interface PresentationMoveGestureController {- begin(origin: PresentationMovePoint, point: PresentationMovePoint): PresentationMoveGesture+export interface DesktopMoveGestureController {+ begin(origin: DesktopMovePoint, point: DesktopMovePoint): DesktopMoveGesturecancel(): void}-export interface PresentationMoveGesture {+export interface DesktopMoveGesture {ready: Promise<void>finished: Promise<void>cancel(): void}/** How one Client is actually drawn on this Desktop, as its presentation reads it. */-export type WindowPresentationDrawing = Readonly<{+export type PresentationState = Readonly<{layer: WindowLayer- position: WindowPresentationPosition- size: WindowPresentationSize+ position: PresentationPosition+ size: PresentationSizefront: booleaninteractive: boolean- surface: WindowPresentationSurface+ surface: PresentationSurface}>/** Local commands available to the current Client representation. */-export interface WindowPresentationHost {+export interface PresentationHost {begin(identity: string): void- drawing(identity: string, frame: HTMLIFrameElement): WindowPresentationDrawing- settled(identity: string): boolean+ drawing(identity: string, frame: HTMLIFrameElement): PresentationStateobserve(listener: () => void): () => void- beginMoveGesture(identity: string, gesture: string, origin: PresentationMovePoint, point: PresentationMovePoint): Promise<void>+ beginMoveGesture(identity: string, gesture: string, origin: DesktopMovePoint, point: DesktopMovePoint): Promise<void>waitMoveGesture(identity: string, gesture: string): Promise<void>cancelMoveGesture(identity: string, gesture: string): voidcancelMoveGestures(identity: string): void- move(identity: string, position: WindowPresentationPosition, transaction?: PresentationTransactionRequest): Promise<void>- resize(identity: string, size: WindowPresentationSize, transaction?: PresentationTransactionRequest): Promise<void>- setGeometry(identity: string, geometry: WindowPresentationGeometry, transaction?: PresentationTransactionRequest): Promise<void>- setSurface(identity: string, surface: WindowPresentationSurface, transaction?: PresentationTransactionRequest): Promise<void>+ move(identity: string, position: PresentationPosition, transaction?: PresentationTransactionRequest): Promise<void>+ resize(identity: string, size: PresentationSize, transaction?: PresentationTransactionRequest): Promise<void>+ setGeometry(identity: string, geometry: PresentationGeometry, transaction?: PresentationTransactionRequest): Promise<void>+ setSurface(identity: string, surface: PresentationSurface, transaction?: PresentationTransactionRequest): Promise<void>setInteractive(identity: string, interactive: boolean): voidraise(identity: string): voidcomplete(identity: string, kind: "geometry" | "surface", revision: number): void}-export function presentationMovePoint(value: unknown): WindowMovePoint {+export function presentationMovePoint(value: unknown): PresentationMovePoint {const record = plain(value, "Window move point")if (typeof record.x !== "number" || !Number.isFinite(record.x)) throw new Error("Window move point x must be a finite number")if (typeof record.y !== "number" || !Number.isFinite(record.y)) throw new Error("Window move point y must be a finite number")return Object.freeze({ x: record.x, y: record.y })}-export function presentationMoveGestureStart(value: unknown): WindowMoveGestureStart {+export function presentationMoveGestureStart(value: unknown): PresentationMoveGestureStart {const record = plain(value, "Window move gesture start")return Object.freeze({ origin: presentationMovePoint(record.origin), point: presentationMovePoint(record.point) })}/** The drawing is written in pixels; shares belong to the Window, which every Desktop resolves itself. */-export function presentationPosition(value: unknown): WindowPresentationPosition {- const record = plain(value, "Window presentation position")+export function presentationPosition(value: unknown): PresentationPosition {+ const record = plain(value, "Presentation position")return Object.freeze({ x: pixels(record.x, "x"), y: pixels(record.y, "y") })}-export function presentationSize(value: unknown): WindowPresentationSize {- const record = plain(value, "Window presentation size")+export function presentationSize(value: unknown): PresentationSize {+ const record = plain(value, "Presentation size")return Object.freeze({ width: pixels(record.width, "width"), height: pixels(record.height, "height") })}-export function presentationGeometry(value: unknown): WindowPresentationGeometry {- const record = plain(value, "Window presentation geometry")+export function presentationGeometry(value: unknown): PresentationGeometry {+ const record = plain(value, "Presentation geometry")return Object.freeze({ x: pixels(record.x, "x"), y: pixels(record.y, "y"), width: pixels(record.width, "width"), height: pixels(record.height, "height") })}export function presentationSurface(value: unknown) {- return parseWindowPresentationSurface(value)+ return parsePresentationSurface(value)}export function presentationTransaction(value: unknown): PresentationTransactionRequest | undefined {if (value === null || value === undefined) return undefined- const selected = plain(value, "Window presentation transaction selection")- if (typeof selected.wait !== "boolean") throw new Error("A Window presentation wait value must be true or false")+ const selected = plain(value, "Presentation transaction selection")+ if (typeof selected.wait !== "boolean") throw new Error("A presentation wait value must be true or false")return Object.freeze({- ...selected.transaction === undefined ? {} : { transaction: parseWindowPresentationTransaction(selected.transaction) },+ ...selected.transaction === undefined ? {} : { transaction: parsePresentationTransaction(selected.transaction) },wait: selected.wait})}function pixels(value: unknown, name: string) {- if (typeof value !== "number" || !Number.isFinite(value)) throw new Error(`Window presentation ${name} must be a finite number of pixels`)+ if (typeof value !== "number" || !Number.isFinite(value)) throw new Error(`Presentation ${name} must be a finite number of pixels`)return value}diff --git a/source/client/view/components/window-manager/window-presentations.ts b/source/client/view/components/window-manager/presentations.tssimilarity index 89%rename from source/client/view/components/window-manager/window-presentations.tsrename to source/client/view/components/window-manager/presentations.tsindex 6a53580..e05c4fd 100644--- a/source/client/view/components/window-manager/window-presentations.ts+++ b/source/client/view/components/window-manager/presentations.ts@@ -4,23 +4,23 @@ import type {Size,WindowGeometry,WindowLayer,- WindowPresentationGeometry,- WindowPresentationPosition,- WindowPresentationSize,- WindowPresentationSurface+ PresentationGeometry,+ PresentationPosition,+ PresentationSize,+ PresentationSurface} from "@phreshos/core"import type {PresentationAnimation,- PresentationMoveGestureController,- PresentationMovePoint,+ DesktopMoveGestureController,+ DesktopMovePoint,PresentationTransactionRequest,- WindowPresentationDrawing,- WindowPresentationHost-} from "../desktop-host/window-presentation"+ PresentationState,+ PresentationHost+} from "../desktop-host/presentation"import { resolveWindowGeometry, type WindowRegion } from "./window-geometry"-import { requireRawWindowPresentation, requireWindowMoveGesture } from "@shared/window-layers"+import { requireRawPresentation, requirePresentationMoveGesture } from "@shared/window-layers"-export interface WindowPresentationEntry {+export interface PresentationEntry {identity: stringclient: ClientState}@@ -29,7 +29,7 @@ export interface WindowPresentationEntry {export interface PresentedWindow {title: stringheader: boolean- surface: WindowPresentationSurface+ surface: PresentationSurfaceposition: Positionsize: Sizeminimized: boolean@@ -54,28 +54,29 @@ export interface AnticipatedWindow {}/** Owns only the local representations of one Desktop. */-export default class WindowPresentations implements WindowPresentationHost {+export default class Presentations implements PresentationHost {public windows: ReadonlyMap<string, PresentedWindow>private readonly live = new Map<string, string>()private readonly waiting = new Map<string, WaitingAnimation>()private readonly representations = new Map<string, PresentationGeometryRepresentation>()- private readonly moveGestureControllers = new Map<string, PresentationMoveGestureController>()+ private readonly moveGestureControllers = new Map<string, DesktopMoveGestureController>()private readonly moveGestures = new Map<string, ActiveMoveGesture>()private readonly anticipated = new Map<string, { change: AnticipatedWindow, pending: number }>()private readonly observers = new Set<() => void>()+ private readonly watching = new Map<string, () => void>()private fronts = 0private revision = 0private changed: (windows: ReadonlyMap<string, PresentedWindow>) => void = () => undefined- public constructor(initial: ReadonlyMap<string, WindowPresentationEntry>, private readonly client: (process: string) => ClientState | null) {+ public constructor(initial: ReadonlyMap<string, PresentationEntry>, private readonly client: (process: string) => ClientState | null) {this.windows = new Map()this.reconcile(initial)}public listen(changed: (windows: ReadonlyMap<string, PresentedWindow>) => void) { this.changed = changed }- public reconcile(current: ReadonlyMap<string, WindowPresentationEntry>) {+ public reconcile(current: ReadonlyMap<string, PresentationEntry>) {const previousLive = new Map(this.live)this.live.clear()const next = new Map(this.windows)@@ -83,7 +84,7 @@ export default class WindowPresentations implements WindowPresentationHost {for (const [process, identity] of previousLive) {if (current.get(process)?.identity === identity) continuenext.delete(identity)- this.release(identity, "The Window presentation was removed")+ this.release(identity, "The presentation was removed")}for (const [process, { identity, client }] of current) {@@ -100,7 +101,7 @@ export default class WindowPresentations implements WindowPresentationHost {if (!this.windows.has(identity)) returnconst next = new Map(this.windows)next.delete(identity)- this.release(identity, "The Window presentation was removed")+ this.release(identity, "The presentation was removed")this.publish(next)}@@ -139,18 +140,12 @@ export default class WindowPresentations implements WindowPresentationHost {return () => { this.observers.delete(listener) }}- /** Whether a Client's drawing has arrived where it is going, with no motion still carrying it. */- public settled(process: string) {- const { state } = this.existing(process)- return !state.geometryAnimation && !state.surfaceAnimation && !state.minimizeAnimation- }-/*** How a Client is actually drawn: its frame, in pixels, counted from the center of the Desktop.* The Window's box is read where the Desktop draws it, and the frame's place inside the box from* the layout, so a scale the box is entering with does not change what is read.*/- public drawing(process: string, frame: HTMLIFrameElement): WindowPresentationDrawing {+ public drawing(process: string, frame: HTMLIFrameElement): PresentationState {const { identity, state } = this.existing(process)const surface = frame.closest<HTMLElement>("[data-desktop-layers]")const width = surface?.offsetWidth ?? 0@@ -170,12 +165,16 @@ export default class WindowPresentations implements WindowPresentationHost {public readonly represent = (process: string, representation: PresentationGeometryRepresentation | null) => {const identity = this.live.get(process)if (!identity) return- this.representations.delete(identity)- if (representation) this.representations.set(identity, representation)+ this.unrepresent(identity)+ if (representation) {+ this.representations.set(identity, representation)+ // A drawing moves with its box at every step, so its Client hears where it is as it goes.+ this.watching.set(identity, representation.watch(() => this.notify()))+ }this.publish(new Map(this.windows))}- public readonly registerMoveGesture = (process: string, controller: PresentationMoveGestureController | null) => {+ public readonly registerMoveGesture = (process: string, controller: DesktopMoveGestureController | null) => {const identity = this.live.get(process)if (!identity) returnif (this.moveGestureControllers.get(identity) === controller) return@@ -184,9 +183,9 @@ export default class WindowPresentations implements WindowPresentationHost {else this.moveGestureControllers.delete(identity)}- public beginMoveGesture(process: string, gesture: string, origin: PresentationMovePoint, point: PresentationMovePoint) {+ public beginMoveGesture(process: string, gesture: string, origin: DesktopMovePoint, point: DesktopMovePoint) {const { identity, state } = this.existing(process)- requireWindowMoveGesture(state.layer)+ requirePresentationMoveGesture(state.layer)if ([...this.moveGestures.values()].some(active => active.identity === identity)) throw new Error("This Window already has an active move gesture")const controller = this.moveGestureControllers.get(identity)if (!controller) throw new Error("This Window cannot currently begin a move gesture")@@ -249,22 +248,22 @@ export default class WindowPresentations implements WindowPresentationHost {if (identity) this.representations.get(identity)?.cancel()}- public move(process: string, position: WindowPresentationPosition, transaction?: PresentationTransactionRequest) {+ public move(process: string, position: PresentationPosition, transaction?: PresentationTransactionRequest) {const { identity, state } = this.raw(process)return this.changeGeometry(identity, { ...position, ...state.size }, transaction)}- public resize(process: string, size: WindowPresentationSize, transaction?: PresentationTransactionRequest) {+ public resize(process: string, size: PresentationSize, transaction?: PresentationTransactionRequest) {const { identity, state } = this.raw(process)return this.changeGeometry(identity, { ...state.position, ...size }, transaction)}- public setGeometry(process: string, geometry: WindowPresentationGeometry, transaction?: PresentationTransactionRequest) {+ public setGeometry(process: string, geometry: PresentationGeometry, transaction?: PresentationTransactionRequest) {const { identity } = this.raw(process)return this.changeGeometry(identity, geometry, transaction)}- public setSurface(process: string, surface: WindowPresentationSurface, transaction?: PresentationTransactionRequest) {+ public setSurface(process: string, surface: PresentationSurface, transaction?: PresentationTransactionRequest) {const { identity, state } = this.raw(process)if (JSON.stringify(state.surface) === JSON.stringify(surface)) return Promise.resolve()this.cancel(identity, "surface")@@ -323,20 +322,20 @@ export default class WindowPresentations implements WindowPresentationHost {return}- this.releaseTransient(identity, "The Window presentation was replaced")+ this.releaseTransient(identity, "The presentation was replaced")this.replace(identity, initialPresentationState(client))}private raw(process: string) {const found = this.existing(process)- requireRawWindowPresentation(found.state.layer)+ requireRawPresentation(found.state.layer)return found}private existing(process: string) {const identity = this.live.get(process)const state = identity ? this.windows.get(identity) : null- if (!identity || !state) throw new Error("This Client has no Window presentation")+ if (!identity || !state) throw new Error("This Client has no presentation")return { identity, state }}@@ -363,7 +362,7 @@ export default class WindowPresentations implements WindowPresentationHost {private changeGeometry(identity: string, value: WindowGeometry, transaction?: PresentationTransactionRequest) {const state = this.windows.get(identity)- if (!state) throw new Error("This Client has no Window presentation")+ if (!state) throw new Error("This Client has no presentation")const position = { x: value.x, y: value.y }const size = { width: value.width, height: value.height }if (JSON.stringify([state.position, state.size]) === JSON.stringify([position, size])) return Promise.resolve()@@ -381,10 +380,20 @@ export default class WindowPresentations implements WindowPresentationHost {private publish(next: ReadonlyMap<string, PresentedWindow>) {this.windows = nextthis.changed(next)+ this.notify()+ }++ private notify() {for (const observer of this.observers) observer()}- private cancel(identity: string, kind: AnimationKind, reason = "The Window presentation transaction was interrupted") {+ private unrepresent(identity: string) {+ this.watching.get(identity)?.()+ this.watching.delete(identity)+ this.representations.delete(identity)+ }++ private cancel(identity: string, kind: AnimationKind, reason = "The presentation transaction was interrupted") {const key = animationKey(identity, kind)const waiting = this.waiting.get(key)if (!waiting) return@@ -409,14 +418,14 @@ export default class WindowPresentations implements WindowPresentationHost {this.releaseTransient(identity, reason)// The geometry representation belongs to the mounted Desktop Window,// not to an iframe document that may be replaced inside it.- this.representations.delete(identity)+ this.unrepresent(identity)this.moveGestureControllers.delete(identity)}}interface ActiveMoveGesture {identity: string- movement: ReturnType<PresentationMoveGestureController["begin"]>+ movement: ReturnType<DesktopMoveGestureController["begin"]>}type AnimationKind = "geometry" | "surface" | "minimize"@@ -520,6 +529,7 @@ function followStandardWindow(current: PresentedWindow, client: ClientState, revexport interface PresentationGeometryRepresentation {read: () => WindowRegion+ watch: (listener: () => void) => () => voidpresent: (geometry: WindowRegion) => voidbegin: () => WindowRegion | nullfinish: () => voiddiff --git a/source/client/view/components/window-manager/window-manager.ts b/source/client/view/components/window-manager/window-manager.tsindex a58f4bc..e3e2893 100644--- a/source/client/view/components/window-manager/window-manager.ts+++ b/source/client/view/components/window-manager/window-manager.ts@@ -3,7 +3,7 @@ import Process from "@client/core/link-manager/auth-manager/process-manager/procimport { type Layer, type Position, type Size, type Value, type WindowGeometry } from "@phreshos/core"import { useCallback, useLayoutEffect, useRef, useState } from "react"import { type default as AuthManager } from "@client/core/link-manager/auth-manager/auth-manager"-import WindowPresentations, { type PresentedWindow } from "./window-presentations"+import Presentations, { type PresentedWindow } from "./presentations"import { isDesktopReplacementLayer } from "@shared/window-layers"import { type SharedResizeWindow } from "./shared-resize"import { type WindowRegion } from "./window-geometry"@@ -53,9 +53,9 @@ export default function useWindows(authManager: AuthManager) {const initialClients = initialIncarnations.current- const presentationController = useRef<WindowPresentations | null>(null)+ const presentationController = useRef<Presentations | null>(null)- if (!presentationController.current) presentationController.current = new WindowPresentations(initialClients, process => peer.processes.get(process)?.client ?? null)+ if (!presentationController.current) presentationController.current = new Presentations(initialClients, process => peer.processes.get(process)?.client ?? null)const presentation = presentationController.currentdiff --git a/source/client/view/structure/desktop/windows/process-window.tsx b/source/client/view/structure/desktop/windows/process-window.tsxindex 5bd5ab5..e9ebbf3 100644--- a/source/client/view/structure/desktop/windows/process-window.tsx+++ b/source/client/view/structure/desktop/windows/process-window.tsx@@ -1,9 +1,9 @@import Process from "@client/core/link-manager/auth-manager/process-manager/process"import ClientState from "@client/core/link-manager/auth-manager/process-manager/client-state"import { type PaintMargins, type WindowSurfaceSize } from "@client/view/components/window-manager/window-geometry"-import { type PresentationAnimation, type PresentationMoveGestureController } from "@client/view/components/desktop-host/window-presentation"-import { type PresentationGeometryRepresentation } from "@client/view/components/window-manager/window-presentations"-import { type Position, type Size, type TaskbarPosition, type Theme, type WindowPresentationSurface, type WindowLayer } from "@phreshos/core"+import { type PresentationAnimation, type DesktopMoveGestureController } from "@client/view/components/desktop-host/presentation"+import { type PresentationGeometryRepresentation } from "@client/view/components/window-manager/presentations"+import { type Position, type Size, type TaskbarPosition, type Theme, type PresentationSurface, type WindowLayer } from "@phreshos/core"import Spinner from "@client/view/components/spinner"import Window from "./window"import useDragHold from "../drag-hold"@@ -49,7 +49,7 @@ export default memo(function ({ identity, record, assetId, client, title, headerconst represent = useCallback((representation: PresentationGeometryRepresentation | null) => onPresentationRepresentation(record.identity, representation), [onPresentationRepresentation, record])- const moveGesture = useCallback((controller: PresentationMoveGestureController | null) => onPresentationMoveGesture(record.identity, controller), [onPresentationMoveGesture, record])+ const moveGesture = useCallback((controller: DesktopMoveGestureController | null) => onPresentationMoveGesture(record.identity, controller), [onPresentationMoveGesture, record])const frameSource = programFrameSource(assetId, door)@@ -240,7 +240,7 @@ interface ProcessWindowProps {header: boolean- surface: WindowPresentationSurface+ surface: PresentationSurfacelayer: WindowLayer@@ -263,7 +263,7 @@ interface ProcessWindowProps {onPresentationRepresentation: (identity: string, representation: PresentationGeometryRepresentation | null) => void- onPresentationMoveGesture: (identity: string, controller: PresentationMoveGestureController | null) => void+ onPresentationMoveGesture: (identity: string, controller: DesktopMoveGestureController | null) => voidpaintSurfaceSize?: WindowSurfaceSizediff --git a/source/client/view/structure/desktop/windows/window-geometry-motion.ts b/source/client/view/structure/desktop/windows/window-geometry-motion.tsindex 397fbd6..4902d16 100644--- a/source/client/view/structure/desktop/windows/window-geometry-motion.ts+++ b/source/client/view/structure/desktop/windows/window-geometry-motion.ts@@ -1,7 +1,7 @@import { constrainWindowGeometry, resolveWindowGeometry, type WindowRegion, type WindowSurfaceSize } from "@client/view/components/window-manager/window-geometry"-import { type PresentationAnimation } from "@client/view/components/desktop-host/window-presentation"+import { type PresentationAnimation } from "@client/view/components/desktop-host/presentation"import { resolveWindowTransaction } from "@client/view/appearance/motion"-import { type AppearanceTransaction, type Position, type Size, type WindowPresentationTransaction } from "@phreshos/core"+import { type AppearanceTransaction, type Position, type Size, type PresentationTransaction } from "@phreshos/core"import { useMotionValue, useTransform, type MotionStyle } from "motion/react"import { useLayoutEffect, useRef } from "react"import { WindowGeometryAnimation } from "./window-geometry-animation"@@ -11,7 +11,7 @@ interface WindowGeometryMotionOptions {position: Positionsize: Sizeanimation?: PresentationAnimation | null- transaction?: WindowPresentationTransaction | null+ transaction?: PresentationTransaction | nullimmediate: booleanminimumSize?: WindowSurfaceSizeonComplete?: (revision: number) => void@@ -52,6 +52,18 @@ export default function useWindowGeometryMotion({ position, size, animation, trareturn { x: x.get(), y: y.get(), width: width.get(), height: height.get() }}+ /** Hears every step of the box's position: at rest, along a motion, and with the pointer. */+ function watch(listener: () => void) {++ const stopX = x.on("change", listener)+ const stopY = y.on("change", listener)++ return () => {+ stopX()+ stopY()+ }+ }+function stop() {animator.current!.stop()@@ -273,6 +285,7 @@ export default function useWindowGeometryMotion({ position, size, animation, traframe,style: { x, y, width: layoutWidth, height: layoutHeight, scaleX, scaleY, transformOrigin } satisfies MotionStyle,read,+ watch,present,beginGesture,updateGesture,diff --git a/source/client/view/structure/desktop/windows/window-header.tsx b/source/client/view/structure/desktop/windows/window-header.tsxindex bf28768..0953a0c 100644--- a/source/client/view/structure/desktop/windows/window-header.tsx+++ b/source/client/view/structure/desktop/windows/window-header.tsx@@ -1,5 +1,5 @@import type { ReactNode } from "react"-import type { BeginWindowMoveGesture } from "@phreshos/core"+import type { BeginPresentationMoveGesture } from "@phreshos/core"import { Window } from "@phreshos/react-ui"/** Connects Desktop Window behavior to React UI's shared header. */@@ -23,7 +23,7 @@ interface WindowHeaderProps {active: booleanwhole: booleanstopping: boolean- beginMoveGesture: BeginWindowMoveGesture+ beginMoveGesture: BeginPresentationMoveGestureonMinimize?: () => voidonMaximize?: () => voidonClose?: () => voiddiff --git a/source/client/view/structure/desktop/windows/window-surface.tsx b/source/client/view/structure/desktop/windows/window-surface.tsxindex 4c0ea9e..1755b20 100644--- a/source/client/view/structure/desktop/windows/window-surface.tsx+++ b/source/client/view/structure/desktop/windows/window-surface.tsx@@ -2,8 +2,8 @@ import { useReducedMotion } from "@libs/react-motion"import { resolveRadius, Surface, type Appearance, type Color, type MaterialOptions } from "@phreshos/react-ui"import { useLayoutEffect, useRef, useState } from "react"import { motion } from "motion/react"-import { type PresentationAnimation } from "@client/view/components/desktop-host/window-presentation"-import { type AppearanceColor, type WindowPresentationSurface as WindowSurfaceDefinition } from "@phreshos/core"+import { type PresentationAnimation } from "@client/view/components/desktop-host/presentation"+import { type AppearanceColor, type PresentationSurface as WindowSurfaceDefinition } from "@phreshos/core"import { surfaceLifecyclePose, surfacePresenceTransition } from "@client/view/appearance/surface-presence"import { resolveWindowTransaction } from "@client/view/appearance/motion"import { useAppearance } from "@phreshos/react-ui"diff --git a/source/client/view/structure/desktop/windows/window.tsx b/source/client/view/structure/desktop/windows/window.tsxindex 33c35ad..911742c 100644--- a/source/client/view/structure/desktop/windows/window.tsx+++ b/source/client/view/structure/desktop/windows/window.tsx@@ -3,11 +3,11 @@ import { useReducedMotion } from "@libs/react-motion"import { surfaceLifecyclePose, surfacePresencePose, surfacePresenceTransition } from "@client/view/appearance/surface-presence"import WindowPanel from "./window-panel"import { absoluteWindowGeometry, constrainWindowGeometry, minimumWindowSize, noPaintMargins, planeGeometry, resolveWindowGeometry, windowPaintInsets, type PaintMargins, type WindowRegion, type WindowSurfaceSize } from "@client/view/components/window-manager/window-geometry"-import { type BeginWindowMoveGesture, type Position, type Size, type TaskbarPosition, type WindowPresentationSurface as WindowSurfaceDefinition, type WindowLayer } from "@phreshos/core"+import { type BeginPresentationMoveGesture, type Position, type Size, type TaskbarPosition, type PresentationSurface as WindowSurfaceDefinition, type WindowLayer } from "@phreshos/core"import WindowHeader from "./window-header"import WindowSurface, { windowSurfaceRadius } from "./window-surface"-import { type PresentationAnimation, type PresentationMoveGestureController, type PresentationMovePoint } from "@client/view/components/desktop-host/window-presentation"-import { type PresentationGeometryRepresentation } from "@client/view/components/window-manager/window-presentations"+import { type PresentationAnimation, type DesktopMoveGestureController, type DesktopMovePoint } from "@client/view/components/desktop-host/presentation"+import { type PresentationGeometryRepresentation } from "@client/view/components/window-manager/presentations"import { motion } from "motion/react"import { motionTransition, resolveWindowTransaction } from "@client/view/appearance/motion"import { useAppearance, Window as UIWindow } from "@phreshos/react-ui"@@ -107,7 +107,7 @@ export default function ({ title, header = true, surface, layer, icon, children,const [settlingGeometry, setSettlingGeometry] = useState<WindowRegion | null>(null)const [externalMoveActive, setExternalMoveActive] = useState(false)const externalMove = useRef<ExternalMove | null>(null)- const beginPointerGesture = useRef<(point: PresentationMovePoint) => ActivePointerGesture | null>(() => null)+ const beginPointerGesture = useRef<(point: DesktopMovePoint) => ActivePointerGesture | null>(() => null)beginPointerGesture.current = point => {let active: ActivePointerGesture | null = nullgrab(point, null, gesture => { active = gesture })@@ -120,6 +120,7 @@ export default function ({ title, header = true, surface, layer, icon, children,const representation: PresentationGeometryRepresentation = {read: geometryMotion.read,+ watch: geometryMotion.watch,present: geometryMotion.present,begin: () => geometryMotion.beginGesture()?.region ?? null,finish: geometryMotion.finishGesture,@@ -132,7 +133,7 @@ export default function ({ title, header = true, surface, layer, icon, children,}, [onPresentationRepresentation])- const moveGestureController = useRef<PresentationMoveGestureController | null>(null)+ const moveGestureController = useRef<DesktopMoveGestureController | null>(null)if (!moveGestureController.current) {moveGestureController.current = {begin(origin, point) {@@ -152,11 +153,11 @@ export default function ({ title, header = true, surface, layer, icon, children,}}- const beginWindowMoveGesture = useCallback<BeginWindowMoveGesture>(start => {+ const beginWindowMoveGesture = useCallback<BeginPresentationMoveGesture>(start => {return moveGestureController.current!.begin(start.origin, start.point)}, [])- function finishExternalMove(point: PresentationMovePoint | null) {+ function finishExternalMove(point: DesktopMovePoint | null) {const active = externalMove.currentif (!active) returnexternalMove.current = null@@ -287,13 +288,13 @@ export default function ({ title, header = true, surface, layer, icon, children,}}- function grab(event: ReactPointerEvent<HTMLElement> | PresentationMovePoint, edge: WindowEdge | null, receive?: (gesture: ActivePointerGesture) => void) {+ function grab(event: ReactPointerEvent<HTMLElement> | DesktopMovePoint, edge: WindowEdge | null, receive?: (gesture: ActivePointerGesture) => void) {if (maximized && edge !== null) returnconst external = receive !== undefinedconst pointer = external- ? event as PresentationMovePoint+ ? event as DesktopMovePoint: { x: (event as ReactPointerEvent<HTMLElement>).clientX, y: (event as ReactPointerEvent<HTMLElement>).clientY }// A cancelled pointerdown suppresses double-click synthesis, and@@ -374,7 +375,7 @@ export default function ({ title, header = true, surface, layer, icon, children,// Zones are where the pointer is — within 16px of an edge — and// they name shares of the surface, which each client resolves in// its own space.- function snapTerm(motion: PresentationMovePoint): Snap | null {+ function snapTerm(motion: DesktopMovePoint): Snap | null {const pointerX = physicalToDesktopPixels(motion.x - bounds!.left, desktopScale)@@ -398,7 +399,7 @@ export default function ({ title, header = true, surface, layer, icon, children,}}- function move(motion: PresentationMovePoint) {+ function move(motion: DesktopMovePoint) {const physicalX = motion.x - start.pointerX@@ -494,7 +495,7 @@ export default function ({ title, header = true, surface, layer, icon, children,renderGesture()}- function release(motion: PresentationMovePoint, committed: boolean) {+ function release(motion: DesktopMovePoint, committed: boolean) {if (renderFrame) cancelAnimationFrame(renderFrame)@@ -816,7 +817,7 @@ interface WindowProps extends Omit<ComponentProps<"div">, "onAnimationStart" | "onPresentationRepresentation?: (representation: PresentationGeometryRepresentation | null) => void- onPresentationMoveGesture?: (controller: PresentationMoveGestureController | null) => void+ onPresentationMoveGesture?: (controller: DesktopMoveGestureController | null) => void/** Surface used only to decide which painted edges receive an inset. */paintSurfaceSize?: WindowSurfaceSize@@ -845,8 +846,8 @@ interface Gesture {}interface ActivePointerGesture {- update(point: PresentationMovePoint): void- end(point: PresentationMovePoint): void+ update(point: DesktopMovePoint): void+ end(point: DesktopMovePoint): voidcancel(): void}diff --git a/source/shared/window-layers.ts b/source/shared/window-layers.tsindex 097a7d3..2504449 100644--- a/source/shared/window-layers.ts+++ b/source/shared/window-layers.ts@@ -1,15 +1,15 @@import type { WindowLayer } from "@phreshos/core"-export function isRawWindowPresentationLayer(layer: WindowLayer) {+export function isRawPresentationLayer(layer: WindowLayer) {return layer === "under" || layer === "over" || layer === "shell"}-export function requireRawWindowPresentation(layer: WindowLayer) {- if (!isRawWindowPresentationLayer(layer)) throw new Error(`The ${layer} layer does not support raw presentation operations`)+export function requireRawPresentation(layer: WindowLayer) {+ if (!isRawPresentationLayer(layer)) throw new Error(`The ${layer} layer does not support raw presentation operations`)}/** A move gesture hands a pointer move to the Desktop in every layer but the wallpaper, which has nowhere to move. */-export function requireWindowMoveGesture(layer: WindowLayer) {+export function requirePresentationMoveGesture(layer: WindowLayer) {if (layer === "wallpaper") throw new Error("The wallpaper has nowhere to move")}diff --git a/tests/client-process-boundary-lifecycle.test.ts b/tests/client-process-boundary-lifecycle.test.tsindex a8b4ee9..8338049 100644--- a/tests/client-process-boundary-lifecycle.test.ts+++ b/tests/client-process-boundary-lifecycle.test.ts@@ -3,7 +3,7 @@ import messagepack from "@the-link/messagepack"import ClientProcessBoundary, { ClientFrame, frameMovePoint } from "@client/view/components/desktop-host/client-process-boundary"import type AuthManager from "@client/core/link-manager/auth-manager/auth-manager"import type ClientTraffic from "@client/view/components/desktop-host/client-traffic"-import type { WindowPresentationHost } from "@client/view/components/desktop-host/window-presentation"+import type { PresentationHost } from "@client/view/components/desktop-host/presentation"import { test, vi } from "vitest"test("frame pointer positions map into the Desktop's physical viewport space", () => {@@ -45,7 +45,7 @@ test("a Client question expectation survives initial iframe ownership", async ()authManager,{ state: () => ({ size: { width: 800, height: 600 }, offset: { x: 0, y: 0 } }), move: () => undefined },{} as ClientTraffic,- { begin() {} } as unknown as WindowPresentationHost+ { begin() {} } as unknown as PresentationHost)const question = "client:process:question"@@ -83,7 +83,7 @@ test("a later Client request cannot overtake its Service subscription registratiauthManager,{ state: () => ({ size: { width: 800, height: 600 }, offset: { x: 0, y: 0 } }), move: () => undefined },{} as ClientTraffic,- { begin() {} } as unknown as WindowPresentationHost+ { begin() {} } as unknown as PresentationHost)const address = { program: "flambo", process: "browser-server", endpoint: "server" } as const@@ -127,7 +127,7 @@ test("a registered Service event is delivered without a second permission round-authManager,{ state: () => ({ size: { width: 800, height: 600 }, offset: { x: 0, y: 0 } }), move: () => undefined },traffic,- { begin() {} } as unknown as WindowPresentationHost+ { begin() {} } as unknown as PresentationHost)await boundary.own("document")diff --git a/tests/window-presentation-layers.test.ts b/tests/presentation-layers.test.tssimilarity index 93%rename from tests/window-presentation-layers.test.tsrename to tests/presentation-layers.test.tsindex 13fb6b1..91da435 100644--- a/tests/window-presentation-layers.test.ts+++ b/tests/presentation-layers.test.ts@@ -1,6 +1,6 @@import { expect, test } from "vitest"import type { WindowLayer } from "@phreshos/core"-import WindowPresentations, { type WindowPresentationEntry } from "@client/view/components/window-manager/window-presentations"+import Presentations, { type PresentationEntry } from "@client/view/components/window-manager/presentations"function fixture(layer: WindowLayer) {const client = { window: {@@ -13,8 +13,8 @@ function fixture(layer: WindowLayer) {maximized: false,depth: 5} }- const entries = new Map([["own", { identity: "own:0", client }]]) as unknown as ReadonlyMap<string, WindowPresentationEntry>- return { client, entries, presentations: new WindowPresentations(entries, () => client as never) }+ const entries = new Map([["own", { identity: "own:0", client }]]) as unknown as ReadonlyMap<string, PresentationEntry>+ return { client, entries, presentations: new Presentations(entries, () => client as never) }}test("wallpaper is fixed and rejects both raw operations and move gestures", () => {diff --git a/tests/window-presentation.test.ts b/tests/presentation.test.tssimilarity index 83%rename from tests/window-presentation.test.tsrename to tests/presentation.test.tsindex 686e328..cfbfc6b 100644--- a/tests/window-presentation.test.ts+++ b/tests/presentation.test.ts@@ -1,7 +1,7 @@import assert from "node:assert/strict"import ClientProcessBoundary from "@client/view/components/desktop-host/client-process-boundary"-import { presentationTransaction } from "@client/view/components/desktop-host/window-presentation"-import WindowPresentations, { type WindowPresentationEntry } from "@client/view/components/window-manager/window-presentations"+import { presentationTransaction } from "@client/view/components/desktop-host/presentation"+import Presentations, { type PresentationEntry } from "@client/view/components/window-manager/presentations"import type { WindowLayer } from "@phreshos/core"import { test } from "vitest"@@ -18,8 +18,8 @@ test("presentation transaction selection has no boolean compatibility values", (test("each Desktop owns an independent raw presentation initialized at zero", async () => {const overlay = client("over")const entries = entry("overlay", overlay)- const first = new WindowPresentations(entries, () => overlay as never)- const second = new WindowPresentations(entries, () => overlay as never)+ const first = new Presentations(entries, () => overlay as never)+ const second = new Presentations(entries, () => overlay as never)assert.deepEqual(first.projection("overlay").position, { x: 0, y: 0 })assert.deepEqual(first.projection("overlay").size, { width: 0, height: 0 })@@ -44,7 +44,7 @@ test("each Desktop owns an independent raw presentation initialized at zero", astest("transactionAndWait resolves only after the matching local animation", async () => {const overlay = client("over")- const presentations = new WindowPresentations(entry("overlay", overlay), () => overlay as never)+ const presentations = new Presentations(entry("overlay", overlay), () => overlay as never)const request = { transaction: { duration: 200, easing: "ease-out" } as const, wait: true }const moving = presentations.move("overlay", { x: 30, y: 40 }, request)@@ -67,7 +67,7 @@ test("transactionAndWait resolves only after the matching local animation", asyntest("a standard Window follows authoritative state but accepts only move gestures", async () => {const ordinary = client("window")const entries = entry("ordinary", ordinary)- const presentations = new WindowPresentations(entries, () => ordinary as never)+ const presentations = new Presentations(entries, () => ordinary as never)ordinary.window.position = { x: 80, y: 90 }ordinary.window.size = { width: 500, height: 350 }@@ -132,11 +132,12 @@ test("a Client boundary initializes each new document exactly once", async () =>test("a new Client document preserves its mounted Desktop geometry representation", () => {const ordinary = client("window")const entries = entry("ordinary", ordinary)- const presentations = new WindowPresentations(entries, () => ordinary as never)+ const presentations = new Presentations(entries, () => ordinary as never)const geometry = { x: 20, y: 30, width: 400, height: 300 }presentations.represent("ordinary", {read: () => geometry,+ watch: () => () => undefined,present() {},begin: () => geometry,finish() {},@@ -155,7 +156,7 @@ test("a new Client document preserves its mounted Desktop geometry representatiotest("a standard Window presentation survives its iframe document load", () => {const ordinary = client("window")const entries = entry("ordinary", ordinary)- const presentations = new WindowPresentations(entries, () => ordinary as never)+ const presentations = new Presentations(entries, () => ordinary as never)ordinary.window.position = { x: 80, y: 90 }ordinary.window.maximized = true@@ -170,7 +171,7 @@ test("a standard Window presentation survives its iframe document load", () => {})function entry(process: string, selected: ReturnType<typeof client>) {- return new Map([[process, { identity: `${process}:0`, client: selected }]]) as unknown as ReadonlyMap<string, WindowPresentationEntry>+ return new Map([[process, { identity: `${process}:0`, client: selected }]]) as unknown as ReadonlyMap<string, PresentationEntry>}function client(layer: WindowLayer) {@@ -187,3 +188,27 @@ function client(layer: WindowLayer) {}}}++test("a drawing's box is heard at every step it moves, not only when it settles", () => {+ const ordinary = client("window")+ const presentations = new Presentations(entry("ordinary", ordinary), () => ordinary as never)+ let step: () => void = () => undefined+ let stopped = false+ presentations.represent("ordinary", {+ read: () => ({ x: 20, y: 30, width: 400, height: 300 }),+ watch: listener => { step = listener; return () => { stopped = true } },+ present() {},+ begin: () => null,+ finish() {},+ cancel() {}+ })+ let heard = 0+ presentations.observe(() => { heard++ })++ step()+ step()+ assert.equal(heard, 2)++ presentations.reconcile(new Map())+ assert.equal(stopped, true)+})