An open-source, self-hosted system for apps built with web technologies.
One door for what the Desktop does to a standard Window; the Desktop owns its view
zohayrslileh34b10931ed2d
diff --git a/source/client/view/components/desktop-host/client-host.ts b/source/client/view/components/desktop-host/client-host.tsindex 77ead52..fa4eeba 100644--- a/source/client/view/components/desktop-host/client-host.ts+++ b/source/client/view/components/desktop-host/client-host.ts@@ -1,25 +1,22 @@import { planeSize } from "@client/view/components/window-manager/window-geometry"import { ReactTunnel } from "@the-link/react"-import { type DesktopSize } from "@phreshos/core"import useAnnouncements from "./announcements"import ClientProcessBoundary from "./client-process-boundary"import ClientTraffic from "./client-traffic"-import { type DesktopViewportHost } from "./host"-import { type RefObject, useCallback, useLayoutEffect, useMemo, useRef, useState } from "react"-import useViewportOffset from "@client/view/structure/desktop/viewport-offset"+import { type DesktopViewportHost, type DesktopWindowActions } from "./host"+import { useCallback, useLayoutEffect, useMemo, useRef, useState } from "react"+import { type Viewport } from "@client/view/structure/desktop/viewport-offset"import { useReducedMotion } from "@libs/react-motion"import { type default as AuthManager } from "@client/core/link-manager/auth-manager/auth-manager"import { type PresentationHost } from "./presentation"import messagepack from "@the-link/messagepack"/**- * The browser boundary between a program pane and the desktop that hosts it.- * It owns frame messages and the measured desktop containing those frames;- * neither fact participates in rendering.+ * The browser boundary between Program frames and the Desktop that hosts them: it carries frame+ * messages, and tells each frame what the Desktop it is drawn in does. The Desktop owns its view and+ * its windows; this boundary only passes them on.*/-export default function useClientHost(authManager: AuthManager, desktop: RefObject<HTMLDivElement | null>, sources: Map<string, HTMLIFrameElement | null>, presentation: PresentationHost) {-- const windowSurfaceRef = useRef<HTMLDivElement>(null)+export default function useClientHost(authManager: AuthManager, sources: Map<string, HTMLIFrameElement | null>, presentation: PresentationHost, viewport: Viewport, actions: DesktopWindowActions) {const frameOwners = useRef(new Map<string, string>())@@ -29,34 +26,18 @@ export default function useClientHost(authManager: AuthManager, desktop: RefObjeconst [traffic] = useState(() => new ClientTraffic())- const [windowSurfaceSize, setWindowSurfaceSize] = useState<SurfaceSize>({ width: 0, height: 0 })-- const latestDesktopSize = useRef<DesktopSize>({ width: 0, height: 0 })-- // Where this Desktop looks on the plane of standard Windows. It is this connection's alone.- const viewport = useViewportOffset(windowSurfaceSize)-- const offset = useRef(viewport.offset)-- offset.current = viewport.offset-- const place = useRef(viewport.place)+ const latest = useRef(viewport)- place.current = viewport.place+ latest.current = viewport// What a Client reaches of this viewport: both values, and moving the view once it is permitted.const desktopViewport = useMemo<DesktopViewportHost>(() => ({- state() {+ state: () => ({ size: latest.current.size, offset: latest.current.offset }),- const element = desktop.current+ move: offset => latest.current.place(offset)- return { size: element ? measureElement(element) : latestDesktopSize.current, offset: offset.current }- },-- move: offset => place.current(offset)-- }), [desktop])+ }), [])// Every Client following this Desktop hears that its view moved, as it sets off, with the motion// it takes; with animations off it is there at once. It is told before the move is drawn, so@@ -77,72 +58,21 @@ export default function useClientHost(authManager: AuthManager, desktop: RefObje}, [viewport.offset, viewport.transaction, reducedMotion, sources, traffic])- useLayoutEffect(function () {-- if (!desktop.current || !windowSurfaceRef.current) return-- function measure(bounds: { width: number, height: number }): DesktopSize {-- return { width: Math.round(bounds.width), height: Math.round(bounds.height) }- }-- function announceDesktop(size: DesktopSize) {-- const previous = latestDesktopSize.current-- if (previous.width === size.width && previous.height === size.height) return-- latestDesktopSize.current = size-- // Announcements leave directly from the full desktop measurement.- // Traffic carries them only to boundaries with a live interest.- if (!size.width) return-- for (const identity of sources.keys()) {-- traffic.emit(identity, "host-desktop-viewport", "resize", size).catch(() => undefined)-- // The plane grows and shrinks with the Desktop.- traffic.emit(identity, "host-desktop-plane", "resize", planeSize(size)).catch(() => undefined)- }- }+ // Every Client hears the Desktop's new size, and the plane's, which grows and shrinks with it.+ const { width, height } = viewport.size- function rememberWindowSurfaceSize({ width, height }: SurfaceSize) {-- setWindowSurfaceSize(current => current.width === width && current.height === height ? current : { width, height })- }-- const initialDesktop = measureElement(desktop.current)-- latestDesktopSize.current = initialDesktop-- const initialWindowSurface = measureElement(windowSurfaceRef.current)-- rememberWindowSurfaceSize(initialWindowSurface)-- const desktopObserver = new ResizeObserver(function ([entry]) {-- announceDesktop(measure(entry.contentRect))- })-- const windowObserver = new ResizeObserver(function ([entry]) {-- rememberWindowSurfaceSize(entry.contentRect)-- })-- desktopObserver.observe(desktop.current)+ useLayoutEffect(function () {- windowObserver.observe(windowSurfaceRef.current)+ if (!width) return- return function () {+ for (const identity of sources.keys()) {- desktopObserver.disconnect()+ traffic.emit(identity, "host-desktop-viewport", "resize", { width, height }).catch(() => undefined)- windowObserver.disconnect()+ traffic.emit(identity, "host-desktop-plane", "resize", planeSize({ width, height })).catch(() => undefined)}- }, [authManager, desktop, sources, traffic])+ }, [width, height, sources, traffic])useAnnouncements(authManager, boundaries.current, traffic)@@ -242,7 +172,7 @@ export default function useClientHost(authManager: AuthManager, desktop: RefObjeboundaries.current.get(identity)?.release().catch(() => undefined)- boundaries.current.set(identity, new ClientProcessBoundary(identity, element, authManager, desktopViewport, traffic, presentation))+ boundaries.current.set(identity, new ClientProcessBoundary(identity, element, authManager, desktopViewport, actions, traffic, presentation))return}@@ -257,7 +187,7 @@ export default function useClientHost(authManager: AuthManager, desktop: RefObjeboundary?.release().catch(() => undefined)- }, [authManager, desktopViewport, presentation, sources, traffic])+ }, [authManager, desktopViewport, actions, presentation, sources, traffic])const frameLoaded = useCallback(function (identity: string, element: HTMLIFrameElement) {@@ -348,18 +278,7 @@ export default function useClientHost(authManager: AuthManager, desktop: RefObje}, [authManager, sources])- return { windowSurfaceRef, windowSurfaceSize, viewport, frame, frameLoaded }+ return { frame, frameLoaded }}export type ClientHost = ReturnType<typeof useClientHost>--export interface SurfaceSize {-- width: number-- height: number-}--function measureElement(element: HTMLElement): DesktopSize {- return { width: element.clientWidth, height: element.clientHeight }-}diff --git a/source/client/view/components/desktop-host/client-process-boundary.ts b/source/client/view/components/desktop-host/client-process-boundary.tsindex 1b45b18..8714ef8 100644--- a/source/client/view/components/desktop-host/client-process-boundary.ts+++ b/source/client/view/components/desktop-host/client-process-boundary.ts@@ -1,6 +1,6 @@import AuthManager from "@client/core/link-manager/auth-manager/auth-manager"import { StreamRelay, TheLink } from "@the-link/core"-import host, { TransferredAnswer, type DesktopViewportHost } from "./host"+import host, { TransferredAnswer, type DesktopViewportHost, type DesktopWindowActions } 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"@@ -21,6 +21,8 @@ export default class ClientProcessBoundary extends TheLink {private readonly viewport: DesktopViewportHost+ private readonly actions: DesktopWindowActions+private readonly traffic: ClientTrafficprivate readonly presentation: PresentationHost@@ -77,7 +79,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: PresentationHost) {+ public constructor(pane: string, element: HTMLIFrameElement, authManager: AuthManager, viewport: DesktopViewportHost, actions: DesktopWindowActions, traffic: ClientTraffic, presentation: PresentationHost) {super()@@ -89,6 +91,8 @@ export default class ClientProcessBoundary extends TheLink {this.viewport = viewport+ this.actions = actions+this.traffic = trafficthis.presentation = presentation@@ -311,6 +315,7 @@ export default class ClientProcessBoundary extends TheLink {this.authManager,this.pane,this.viewport,+ this.actions,() => this.owner,this.frame,this.presentationdiff --git a/source/client/view/components/desktop-host/host.ts b/source/client/view/components/desktop-host/host.tsindex 46c945e..55da759 100644--- a/source/client/view/components/desktop-host/host.ts+++ b/source/client/view/components/desktop-host/host.ts@@ -43,7 +43,6 @@ export class TransferredAnswer {public constructor(public readonly result: unknown[], public readonly transfer: Transferable[]) { }}-/** Adapts the complete System contract and contextual Desktop capabilities to one Client frame. *//** This Desktop's viewport as a Client reaches it: read both values, or move the view. */export interface DesktopViewportHost {@@ -52,7 +51,22 @@ export interface DesktopViewportHost {move(offset: DesktopOffset): void}-export default function host(authManager: AuthManager, pane: string, viewport: DesktopViewportHost, frameOwner: () => string | null, frame: PresentationFrame, presentation: PresentationHost) {+/**+ * What this Desktop does to a standard Window, from wherever it is asked: the Window's own header, the+ * Taskbar, the Map, or the Program inside it. Each shows at once on this Desktop, with what it brings+ * here, while the request goes to the System.+ */+export interface DesktopWindowActions {++ raise(process: ClientProcess): Promise<void>++ minimize(process: ClientProcess, minimized: boolean): Promise<void>++ maximize(process: ClientProcess, maximized: boolean): Promise<void>+}++/** Adapts the complete System contract and contextual Desktop capabilities to one Client frame. */+export default function host(authManager: AuthManager, pane: string, viewport: DesktopViewportHost, actions: DesktopWindowActions, frameOwner: () => string | null, frame: PresentationFrame, presentation: PresentationHost) {const { processManager, programManager } = authManager@@ -1059,25 +1073,36 @@ export default function host(authManager: AuthManager, pane: string, viewport: Dreturn [pane]}+ // A standard Window is the Desktop's: it acts on it as it does from the Window's own header. A+ // drawing in another layer is its Program's, and the request goes to the System as it is.if (word === "raise") {- await windowOf(await permittedProcess(args[0])).raise()+ const target = await permittedProcess(args[0])+ const window = windowOf(target)++ await (window.layer === "window" ? actions.raise(target) : window.raise())return [pane]}if (word === "maximize") {+const target = await permittedProcess(args[0])+ const window = windowOf(target)const maximized = args[1] !== false- const request = windowOf(target).maximize(maximized)- presentation.maximize(target.identity, maximized, request)- await request++ await (window.layer === "window" ? actions.maximize(target, maximized) : window.maximize(maximized))+return [pane]}if (word === "minimize") {- await windowOf(await permittedProcess(args[0])).minimize(args[1] !== false)+ const target = await permittedProcess(args[0])+ const window = windowOf(target)+ const minimized = args[1] !== false++ await (window.layer === "window" ? actions.minimize(target, minimized) : window.minimize(minimized))return [pane]}diff --git a/source/client/view/components/desktop-host/presentation.ts b/source/client/view/components/desktop-host/presentation.tsindex 34db159..5d5b988 100644--- a/source/client/view/components/desktop-host/presentation.ts+++ b/source/client/view/components/desktop-host/presentation.ts@@ -70,8 +70,6 @@ export interface PresentationHost {setInteractive(identity: string, interactive: boolean): voidsetAnchor(identity: string, anchor: PresentationAnchor): voidraise(identity: string): void- /** This Desktop maximizes or restores a Process's Window; `request` is the request to the System. */- maximize(process: string, maximized: boolean, request: Promise<unknown>): voidcomplete(identity: string, kind: "geometry" | "surface", revision: number): void}diff --git a/source/client/view/components/window-manager/presentations.ts b/source/client/view/components/window-manager/presentations.tsindex 7ce0684..4828357 100644--- a/source/client/view/components/window-manager/presentations.ts+++ b/source/client/view/components/window-manager/presentations.ts@@ -66,13 +66,12 @@ export default class Presentations implements PresentationHost {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 maximizedHere = new Set<string>()private readonly observers = new Set<() => void>()private readonly watching = new Map<string, () => void>()private fronts = 0private revision = 0/** How far this Desktop's view is moved across the plane, in pixels. */- private view = { x: 0, y: 0 }+ private offset = { x: 0, y: 0 }private changed: (windows: ReadonlyMap<string, PresentedWindow>) => void = () => undefinedpublic constructor(initial: ReadonlyMap<string, PresentationEntry>, private readonly client: (process: string) => ClientState | null) {@@ -138,29 +137,12 @@ export default class Presentations implements PresentationHost {})}- /**- * This Desktop maximizes or restores a Window, from its header or from the Program inside it. The- * change shows at once, and a Window maximized from here is known as such until its request settles,- * so this Desktop's view follows it; a Window maximized from another Desktop leaves this view alone.- */- public maximize(process: string, maximized: boolean, request: Promise<unknown>) {- const identity = this.live.get(process)- if (maximized && identity) {- this.maximizedHere.add(identity)- request.catch(() => undefined).finally(() => this.maximizedHere.delete(identity))- }- this.anticipate(process, { maximized }, request)- }-- /** Whether this Desktop is maximizing this Window: it asked, and the System has not answered yet. */- public maximizingHere(identity: string) { return this.maximizedHere.has(identity) }-public projection(process: string) { return this.existing(process).state }- /** Where this Desktop looks on the plane, which drawings fixed to it are shown against. */- public follow(view: Readonly<{ x: number, y: number }>) {- if (view.x === this.view.x && view.y === this.view.y) return- this.view = { x: view.x, y: view.y }+ /** Where this Desktop looks on the plane, in pixels, which drawings fixed to it are shown against. */+ public follow(offset: Readonly<{ x: number, y: number }>) {+ if (offset.x === this.offset.x && offset.y === this.offset.y) return+ this.offset = { x: offset.x, y: offset.y }this.notify()}@@ -183,7 +165,7 @@ export default class Presentations implements PresentationHost {const box = this.representations.get(identity)?.read() ?? resolveWindowGeometry(state.position, state.size, { width, height })const inside = offsetWithin(frame, "[data-window-box]")// Counted from the center of what the drawing is fixed to: the viewport, or the plane.- const from = state.anchor === "plane" ? this.view : { x: 0, y: 0 }+ const from = state.anchor === "plane" ? this.offset : { x: 0, y: 0 }return {layer: state.layer,anchor: state.anchor,@@ -321,7 +303,7 @@ export default class Presentations implements PresentationHost {if (state.anchor === anchor) returnconst shift = anchor === "plane" ? 1 : -1const position = state.position as PresentationPosition- this.replace(identity, { ...state, anchor, position: { x: position.x + shift * this.view.x, y: position.y + shift * this.view.y } })+ this.replace(identity, { ...state, anchor, position: { x: position.x + shift * this.offset.x, y: position.y + shift * this.offset.y } })}public raise(process: string) {diff --git a/source/client/view/components/window-manager/window-geometry.ts b/source/client/view/components/window-manager/window-geometry.tsindex 6eea294..cd84738 100644--- a/source/client/view/components/window-manager/window-geometry.ts+++ b/source/client/view/components/window-manager/window-geometry.ts@@ -11,7 +11,7 @@ export interface WindowRegion {height: number}-export interface WindowSurfaceSize {+export interface ViewSize {width: number@@ -51,7 +51,7 @@ export function absoluteWindowGeometry(position: Position, size: Size) {* of the surface its layer provides; the region it returns is measured from* the surface's top-left corner, where the Desktop paints it.*/-export function resolveWindowGeometry(position: Position, size: Size, surface: WindowSurfaceSize): WindowRegion {+export function resolveWindowGeometry(position: Position, size: Size, surface: ViewSize): WindowRegion {return {x: surface.width / 2 + pixels(position.x, surface.width),@@ -73,7 +73,7 @@ export function planeSize(desktop: Readonly<{ width: number, height: number }>)/** The largest a standard Window is shown, in views, in each dimension. */export const largestWindowViews = 2-const boundedGeometries = new WeakMap<Position, { size: Size, surface: WindowSurfaceSize, bounded: { position: Position, size: Size } }>()+const boundedGeometries = new WeakMap<Position, { size: Size, surface: ViewSize, bounded: { position: Position, size: Size } }>()/*** The Desktop shows standard Windows only on its plane, which reaches two views from the center in each@@ -81,7 +81,7 @@ const boundedGeometries = new WeakMap<Position, { size: Size, surface: WindowSur* at its edge, and one recorded larger is shown at that size; what the System records stays as it is,* until the Window is moved or resized here.*/-export function boundedGeometry(position: Position, size: Size, surface: WindowSurfaceSize): { position: Position, size: Size } {+export function boundedGeometry(position: Position, size: Size, surface: ViewSize): { position: Position, size: Size } {if (!surface.width || !surface.height) return { position, size }@@ -138,7 +138,7 @@ export function shiftPosition(position: Position, views: ViewportOffset): Positi}/** The whole view a Window's center is in, counted from the plane's center. */-export function viewOfGeometry(position: Position, size: Size, surface: WindowSurfaceSize): ViewportOffset {+export function viewOfGeometry(position: Position, size: Size, surface: ViewSize): ViewportOffset {if (!surface.width || !surface.height) return { x: 0, y: 0 }@@ -151,7 +151,7 @@ export function viewOfGeometry(position: Position, size: Size, surface: WindowSu}/** A point of the plane in pixels, recorded as the view it is in plus pixels within that view, so it keeps to its view on every Desktop. */-export function recordedPosition(point: { x: number, y: number }, surface: WindowSurfaceSize): Position {+export function recordedPosition(point: { x: number, y: number }, surface: ViewSize): Position {const views = { x: surface.width ? Math.round(point.x / surface.width) : 0, y: surface.height ? Math.round(point.y / surface.height) : 0 }@@ -175,7 +175,7 @@ function shiftValue(value: Value, views: number): Value {}/** The inverse at the other end: a painted region's position on the plane, whose zero is the surface's center. */-export function planeGeometry(region: WindowRegion, surface: WindowSurfaceSize): WindowRegion {+export function planeGeometry(region: WindowRegion, surface: ViewSize): WindowRegion {return { ...region, x: region.x - surface.width / 2, y: region.y - surface.height / 2 }}@@ -184,7 +184,7 @@ export function planeGeometry(region: WindowRegion, surface: WindowSurfaceSize):* Applies a presentation-owned minimum without rewriting authoritative values.* A smaller workspace is the only case where the Desktop cannot provide it.*/-export function constrainWindowGeometry(region: WindowRegion, surface: WindowSurfaceSize, minimum: WindowSurfaceSize): WindowRegion {+export function constrainWindowGeometry(region: WindowRegion, surface: ViewSize, minimum: ViewSize): WindowRegion {return {...region,@@ -221,7 +221,7 @@ export const noPaintMargins: PaintMargins = Object.freeze({ top: 0, right: 0, bo* `shift` pixels away from what is shown when the Desktop looks between two views; so a Window keeps* its margins wherever the view looks from.*/-export function windowPaintInsets(position: Position, size: Size, surface: WindowSurfaceSize, inset: number, margins: PaintMargins, current?: WindowRegion, shift: Readonly<{ x: number, y: number }> = noShift) {+export function windowPaintInsets(position: Position, size: Size, surface: ViewSize, inset: number, margins: PaintMargins, current?: WindowRegion, shift: Readonly<{ x: number, y: number }> = noShift) {const x = current?.x ?? surface.width / 2 + pixels(position.x, surface.width)diff --git a/source/client/view/components/window-manager/window-manager.ts b/source/client/view/components/window-manager/window-manager.tsindex 056e131..dfbc717 100644--- a/source/client/view/components/window-manager/window-manager.ts+++ b/source/client/view/components/window-manager/window-manager.ts@@ -9,13 +9,9 @@ import { type SharedResizeWindow } from "./shared-resize"import { type WindowRegion } from "./window-geometry"/**- * The authorized view's windows: processes that have one. A window is a- * process whose program has a client half, so the process itself says- * whether it is shown — nothing else is consulted.- *- * The Desktop presentation and authoritative counterpart are distinct.- * Following starts enabled for ordinary windows and disabled for the other layers.- * Each Client can subsequently follow an authoritative Window or detach.+ * Everything this Desktop draws: every Process with a running Client, in its layer. A standard Window+ * follows the System's Window and shows this Desktop's own actions on it at once; a drawing in another+ * layer is its Program's, drawn as the Program says.** Departure is representation. Stopping a Client invalidates its live Window* state. The last desktop-owned representation is kept until its exit@@ -182,14 +178,6 @@ export default function useWindows(authManager: AuthManager) {if (!bestWindow || bestWindow.depth <= window.depth) fronts[window.layer] = process}- // Presentation and authoritative mutation are two explicit acts.- // Standard Window control always crosses the authoritative handle. Pointer- // motion may already show the gesture, but the server echo owns its result.- const commit = useCallback(function (request: Promise<void>) {-- request.catch(() => undefined)- }, [])-// A pointer gesture must retain its visible result until the authoritative// request settles. Returning failure as data keeps ignored button presses// handled while allowing the gesture owner to restore authoritative state.@@ -235,50 +223,59 @@ export default function useWindows(authManager: AuthManager) {}, [])+ // This Desktop's actions on a standard Window: each shows at once, and the System's answer follows+ // when it settles. They answer with the request, so whoever asked can wait for the System.const raise = useCallback(function (process: Process) {const window = process.client?.window- if (!window || window.layer !== "window") return-- const highest = summit(window.layer)-- if (window.depth === highest) return+ if (!window || window.layer !== "window" || window.depth === summit(window.layer)) return Promise.resolve()// Shown in front at once; the System's ranking follows when it answers.const request = window.raise()presentation.anticipate(process.identity, { front: true }, request)- commit(request)+ return request- }, [commit, summit, presentation])+ }, [summit, presentation])const minimize = useCallback(function (process: Process, minimized: boolean) {const window = process.client?.window- if (!window || window.layer !== "window") return+ if (!window || window.layer !== "window") return Promise.resolve()const request = window.minimize(minimized)presentation.anticipate(process.identity, { minimized }, request)- commit(request)+ return request- }, [commit, presentation])+ }, [presentation])- const show = useCallback(function (process: Process) {+ const maximize = useCallback(function (process: Process, maximized: boolean) {const window = process.client?.window- if (!window || window.layer !== "window") return+ if (!window || window.layer !== "window") return Promise.resolve()++ const request = window.maximize(maximized)++ presentation.anticipate(process.identity, { maximized }, request)++ return request++ }, [presentation])++ // What a person means by showing a Window: shown, if it was minimized, and in front.+ const bringForward = useCallback(function (process: Process) {- if (presentation.projection(process.identity).minimized) minimize(process, false)+ if (presentation.projection(process.identity).minimized) minimize(process, false).catch(() => undefined)- raise(process)+ raise(process).catch(() => undefined)- }, [minimize, raise])+ }, [minimize, raise, presentation])const move = useCallback(function (process: Process, x: Value, y: Value) {@@ -319,15 +316,6 @@ export default function useWindows(authManager: AuthManager) {}, [settle])- const fill = useCallback(function (process: Process) {- const window = process.client?.window- if (!window || window.layer !== "window") return Promise.resolve(false)- const maximized = !presentation.projection(process.identity).maximized- const request = window.maximize(maximized)- presentation.maximize(process.identity, maximized, request)- return settle(request)- }, [presentation, settle])-// Every window on the desktop, in one list and one order.//// A closing client incarnation keeps the place it had. A restarted@@ -420,11 +408,10 @@ export default function useWindows(authManager: AuthManager) {if (!window || window.layer !== "window") continue- const geometry = { ...region }- commit(window.setGeometry(geometry))+ window.setGeometry({ ...region }).catch(() => undefined)}- }, [commit, peer])+ }, [peer])return {@@ -451,24 +438,13 @@ export default function useWindows(authManager: AuthManager) {closed,- // ── The primitives, one act each ─────────────────────────────- //- // The window manager composes them below; nothing here does two- // things at once, because the system beneath does not either.raise,minimize,- // ── And the policy, which is the window manager's ────────────- //- // A person pressing a taskbar item means *show me this one*, so- // it is shown and brought to the front — two primitives, said- // here, where a person's expectation belongs. The system knows- // nothing about the pairing.- show,+ maximize,- // Toggle authoritative maximization and its local presentation.- fill,+ bringForward,move,diff --git a/source/client/view/structure/desktop/desktop.tsx b/source/client/view/structure/desktop/desktop.tsxindex edddc64..d4ec5d9 100644--- a/source/client/view/structure/desktop/desktop.tsx+++ b/source/client/view/structure/desktop/desktop.tsx@@ -1,6 +1,9 @@import { useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState } from "react"import { ApplicationContext, AuthManagerContext, LinkManagerContext } from "../../contexts"import useClientHost from "../../components/desktop-host/client-host"+import { type DesktopWindowActions } from "../../components/desktop-host/host"+import useViewportOffset from "./viewport-offset"+import useViewSize from "./view-size"import DesktopLayers, { desktopMargins } from "./layers/desktop-layers"import useDesktopFocus from "./desktop-focus"import programIcon from "./programs/program-icon"@@ -21,7 +24,7 @@ import { LaunchPlacementContext, type LaunchPlacement } from "./launch-placementimport { CellShiftStore, PlaneSlide, PlaneSlideContext, ViewCellShift, usePlaneSlide } from "./plane-slide"import { useViewTravel } from "./edge-hold"import { boundedGeometry, planeGeometry, recordedPosition, resolveWindowGeometry, shiftPosition, viewOfGeometry, type WindowRegion } from "@client/view/components/window-manager/window-geometry"-import { type MappedWindow } from "./layers/shell/taskbar/viewport/viewport-control"+import { type MappedWindow } from "./layers/shell/taskbar/map/map-control"import type Process from "@client/core/link-manager/auth-manager/process-manager/process"import { type Layer, type Position, type PresentationAnchor, type Size } from "@phreshos/core"@@ -69,11 +72,49 @@ export default function Workspace() {}, [completePrograms, initialProgramsReady])- // Each frame, by process identity. This resolves a message's sender and- // lets the desktop announce the surface that actually contains it.+ // Each frame, by process identity, so a message's sender is known.const sources = useRef(new Map<string, HTMLIFrameElement | null>())- const { windowSurfaceRef, windowSurfaceSize, viewport, frame, frameLoaded } = useClientHost(authManager, desktop, sources.current, windows.presentation)+ // One view of the plane, and where this Desktop looks on it: both this Desktop's own.+ const viewSize = useViewSize(desktop)++ const viewport = useViewportOffset(viewSize)++ /**+ * Moves the view to the whole view a Window at this position and size is in. It never centers on the+ * Window itself: a view resting between two would put a maximized Window, which fills its own view,+ * off the screen's edges. Moving within or between views stays the person's choice.+ */+ const reveal = useCallback(function (position: Position, size: Size | null) {++ if (!viewSize.width || !viewSize.height) return++ const shown = boundedGeometry(position, size ?? { width: 0, height: 0 }, viewSize)++ viewport.moveTo(viewOfGeometry(shown.position, shown.size, viewSize))++ }, [viewSize, viewport.moveTo])++ // A Window maximized from this Desktop fills the whole view it is in, so this Desktop's view goes+ // there with it. One maximized from another Desktop, or by the System, leaves this view alone.+ const maximize = useCallback(function (record: Process, maximized: boolean) {++ const request = windows.maximize(record, maximized)++ const window = windows.presentation.projection(record.identity)++ if (maximized && window.layer === "window") reveal(window.position, window.size)++ return request++ }, [windows.maximize, windows.presentation, reveal])++ const toggleMaximized = useCallback((record: Process) => maximize(record, !windows.presentation.projection(record.identity).maximized).then(() => true, () => false), [maximize, windows.presentation])++ // What this Desktop does to a standard Window, from its header, the Taskbar, the Map, or the Program inside it.+ const actions = useMemo<DesktopWindowActions>(() => ({ raise: windows.raise, minimize: windows.minimize, maximize }), [windows.raise, windows.minimize, maximize])++ const { frame, frameLoaded } = useClientHost(authManager, sources.current, windows.presentation, viewport, actions)// Standard Windows are shown moved by this Desktop's offset, and what is done to them is recorded// moved back. Nothing else knows it: a Window works only in what it shows.@@ -115,7 +156,7 @@ export default function Workspace() {function maximizedPosition(position: Position, size: Size) {- const view = viewOfGeometry(position, size, windowSurfaceSize)+ const view = viewOfGeometry(position, size, viewSize)const key = `${view.x},${view.y}`@@ -200,25 +241,25 @@ export default function Workspace() {neighboursNow.current = identity => windows.panesByLayer.window.filter(pane => pane.identity !== identity && !pane.closing && !pane.presentation.minimized).map(pane => {- const bounded = boundedGeometry(pane.presentation.position, pane.presentation.size, windowSurfaceSize)- return resolveWindowGeometry(shownPosition(bounded.position), bounded.size, windowSurfaceSize)+ const bounded = boundedGeometry(pane.presentation.position, pane.presentation.size, viewSize)+ return resolveWindowGeometry(shownPosition(bounded.position), bounded.size, viewSize)})const neighboursOf = useCallback((identity: string) => neighboursNow.current(identity), [])// What lives on the plane glides with the view; see usePlaneSlide.- const slide = usePlaneSlide(viewport.views, viewport.transaction, windowSurfaceSize)+ const slide = usePlaneSlide(viewport.views, viewport.transaction, viewSize)// How far the shown view is from the grid of whole views: Windows paint their margins at the// edges of their own view, wherever the Desktop looks from.const [cellShift] = useState(() => new CellShiftStore())cellShift.take({- x: (views.x - Math.round(views.x)) * windowSurfaceSize.width,- y: (views.y - Math.round(views.y)) * windowSurfaceSize.height+ x: (views.x - Math.round(views.x)) * viewSize.width,+ y: (views.y - Math.round(views.y)) * viewSize.height})- useLayoutEffect(() => cellShift.announce(), [cellShift, views.x, views.y, windowSurfaceSize.width, windowSurfaceSize.height])+ useLayoutEffect(() => cellShift.announce(), [cellShift, views.x, views.y, viewSize.width, viewSize.height])// A Window held against an edge takes the view one whole view that way; see useViewTravel.const edgeHold = useViewTravel(viewport)@@ -236,7 +277,7 @@ export default function Workspace() {return windows.panesByLayer[layer].filter(({ presentation }) => anchor === undefined || presentation.anchor === anchor).map(({ identity, record, client, presentation, closing, entering, stopping }) => {- const bounded = boundedGeometry(presentation.position, presentation.size, windowSurfaceSize)+ const bounded = boundedGeometry(presentation.position, presentation.size, viewSize)return <ProcessWindow@@ -280,7 +321,7 @@ export default function Workspace() {// Only system-painted windows need to know which paint edges// touch their surface. Positioning is identical in every layer.- paintSurfaceSize={layer === "window" ? windowSurfaceSize : undefined}+ paintSurfaceSize={layer === "window" ? viewSize : undefined}paintMargins={layer === "window" ? margins : undefined}@@ -316,11 +357,11 @@ export default function Workspace() {onReady={programReady}- onRaise={windows.raise}+ onRaise={record => void windows.raise(record).catch(() => undefined)}onMinimize={focus.minimize}- onFill={windows.fill}+ onMaximize={toggleMaximized}onClose={focus.close}@@ -345,12 +386,12 @@ export default function Workspace() {const taskbarOrientation = appearance.taskbar.position === "top" || appearance.taskbar.position === "bottom" ? "horizontal" : "vertical"// Each standard Window where it is on the plane, minimized or not, for the map of views.- const mappedWindows: MappedWindow[] = windowSurfaceSize.width && windowSurfaceSize.height+ const mappedWindows: MappedWindow[] = viewSize.width && viewSize.height? windows.panesByLayer.window.filter(pane => !pane.closing).map(({ identity, record, presentation }) => {- const shown = boundedGeometry(presentation.position, presentation.size, windowSurfaceSize)+ const shown = boundedGeometry(presentation.position, presentation.size, viewSize)- const region = planeGeometry(resolveWindowGeometry(shown.position, shown.size, windowSurfaceSize), windowSurfaceSize)+ const region = planeGeometry(resolveWindowGeometry(shown.position, shown.size, viewSize), viewSize)return {identity,@@ -360,14 +401,14 @@ export default function Workspace() {front: fronts.window?.identity === record.identity,minimized: presentation.minimized,maximized: presentation.maximized,- show: () => show(record),+ goTo: () => goTo(record),bringHere: () => bringHere(record),toggleMinimized: () => toggleMinimized(record),- fill: () => void windows.fill(record),+ toggleMaximized: () => void toggleMaximized(record),close: () => focus.close(record),moveTo: center => {- const recorded = recordedPosition({ x: center.x - region.width / 2, y: center.y - region.height / 2 }, windowSurfaceSize)+ const recorded = recordedPosition({ x: center.x - region.width / 2, y: center.y - region.height / 2 }, viewSize)void windows.move(record, recorded.x, recorded.y)}@@ -379,7 +420,7 @@ export default function Workspace() {// view's shorter side. Shares of the view would stretch it with the screen's own proportions.function launchSize(): Size {- const side = Math.round(Math.min(windowSurfaceSize.width, windowSurfaceSize.height) * 0.6)+ const side = Math.round(Math.min(viewSize.width, viewSize.height) * 0.6)return { width: side, height: side }}@@ -390,76 +431,33 @@ export default function Workspace() {const size = declared ?? launchSize()- const shown = resolveWindowGeometry({ x: 0, y: 0 }, size, windowSurfaceSize)+ const shown = resolveWindowGeometry({ x: 0, y: 0 }, size, viewSize)const inView = mappedWindows.filter(({ region }) =>- Math.abs(region.x + region.width / 2 - offset.x) < windowSurfaceSize.width / 2 &&- Math.abs(region.y + region.height / 2 - offset.y) < windowSurfaceSize.height / 2).length+ Math.abs(region.x + region.width / 2 - offset.x) < viewSize.width / 2 &&+ Math.abs(region.y + region.height / 2 - offset.y) < viewSize.height / 2).lengthconst step = inView % 8 * appearance.spacing * 2- const position = recordedPosition({ x: offset.x - shown.width / 2 + step, y: offset.y - shown.height / 2 + step }, windowSurfaceSize)+ const position = recordedPosition({ x: offset.x - shown.width / 2 + step, y: offset.y - shown.height / 2 + step }, viewSize)return declared ? { position } : { position, size }- }, [mappedWindows, offset.x, offset.y, windowSurfaceSize, appearance.spacing])-- /**- * Moves the view to the whole view a Window at this position and size is in. It never centers on the- * Window itself: a view resting between two would put a maximized Window, which fills its own view,- * off the screen's edges. Moving within or between views stays the person's choice.- */- const reveal = useCallback(function (position: Position, size: Size | null) {-- if (!windowSurfaceSize.width || !windowSurfaceSize.height) return-- const shown = boundedGeometry(position, size ?? { width: 0, height: 0 }, windowSurfaceSize)-- viewport.moveTo(viewOfGeometry(shown.position, shown.size, windowSurfaceSize))-- }, [windowSurfaceSize, viewport.moveTo])+ }, [mappedWindows, offset.x, offset.y, viewSize, appearance.spacing])const launchPlacement = useMemo<LaunchPlacement>(() => ({ place, reveal }), [place, reveal])- // A Window maximized from this Desktop fills the whole view it is in: unless the view rests on- // exactly that view, this view goes with it there, so the Window fills the screen. A Window- // maximized from another Desktop, or by the System, leaves this view where the person is.- const wasMaximized = useRef(new Map<string, boolean>())-- useLayoutEffect(function () {-- const before = wasMaximized.current- const now = new Map<string, boolean>()-- for (const window of mappedWindows) {-- now.set(window.identity, window.maximized)-- if (!window.maximized || before.get(window.identity) !== false || window.minimized) continue- if (!windows.presentation.maximizingHere(window.identity)) continue-- const { region } = window- const view = { x: Math.round((region.x + region.width / 2) / windowSurfaceSize.width), y: Math.round((region.y + region.height / 2) / windowSurfaceSize.height) }-- // Against where the view exactly is, not the view nearest to it: a view resting between two- // would show the maximized Window cut at the edges of its own view.- if (view.x !== views.x || view.y !== views.y) viewport.moveTo(view)- }-- wasMaximized.current = now- })-// Going to a Window brings the view to the view it is in, whether it was minimized or only out of- // view, and brings it to the front.- const show = useCallback(function (record: Process) {+ // view, and brings it forward.+ const goTo = useCallback(function (record: Process) {const window = windows.presentation.projection(record.identity)if (window.layer === "window") reveal(window.position, window.size)- windows.show(record)+ windows.bringForward(record)- }, [windows.presentation, windows.show, reveal])+ }, [windows.presentation, windows.bringForward, reveal])// Bringing a Window here moves it by whole views into the view on screen, so it keeps its place// within a view: a Window on the left half arrives on the left half, a maximized one fills this view.@@ -469,26 +467,26 @@ export default function Workspace() {if (window.layer !== "window") return- const shown = boundedGeometry(window.position, window.size, windowSurfaceSize)+ const shown = boundedGeometry(window.position, window.size, viewSize)- const from = viewOfGeometry(shown.position, shown.size, windowSurfaceSize)+ const from = viewOfGeometry(shown.position, shown.size, viewSize)const brought = shiftPosition(shown.position, { x: viewport.view.x - from.x, y: viewport.view.y - from.y })void windows.move(record, brought.x, brought.y)- windows.show(record)+ windows.bringForward(record)- }, [windows.presentation, windows.move, windows.show, viewport.view.x, viewport.view.y, windowSurfaceSize])+ }, [windows.presentation, windows.move, windows.bringForward, viewport.view.x, viewport.view.y, viewSize])// Showing and hiding in place, as the Taskbar does.const toggleMinimized = useCallback(function (record: Process) {- if (windows.presentation.projection(record.identity).minimized) windows.show(record)+ if (windows.presentation.projection(record.identity).minimized) windows.bringForward(record)else focus.minimize(record, true)- }, [windows.presentation, windows.show, focus.minimize])+ }, [windows.presentation, windows.bringForward, focus.minimize])const taskbarItems = <OverflowRoworientation={taskbarOrientation}@@ -527,13 +525,13 @@ export default function Workspace() {onMinimize={focus.minimize}- onShow={windows.show}+ onShow={windows.bringForward}- onGoTo={show}+ onGoTo={goTo}onBringHere={bringHere}- onFill={windows.fill}+ onMaximize={toggleMaximized}onClose={focus.close}@@ -572,8 +570,6 @@ export default function Workspace() {overWindows={renderAnchored("over")}- windowSurfaceRef={windowSurfaceRef}-spacing={appearance.spacing}shell={<>diff --git a/source/client/view/structure/desktop/edge-hold.ts b/source/client/view/structure/desktop/edge-hold.tsindex 224001c..74f778c 100644--- a/source/client/view/structure/desktop/edge-hold.ts+++ b/source/client/view/structure/desktop/edge-hold.ts@@ -2,7 +2,7 @@ import { useCallback } from "react"import { useReducedMotion } from "@libs/react-motion"import { planeReach } from "@client/view/components/window-manager/window-geometry"import { timing, useAppearance } from "@phreshos/react-ui"-import { type ViewportControl } from "./viewport-offset"+import { type Viewport } from "./viewport-offset"export type Direction = Readonly<{ x: number, y: number }>@@ -11,13 +11,13 @@ export type Direction = Readonly<{ x: number, y: number }>* the view takes to get there, so whoever holds it there waits for it, or null when there is nowhere* further to go.*/-export function useViewTravel(viewport: ViewportControl) {+export function useViewTravel(viewport: Viewport) {const reducedMotion = useReducedMotion()const tempo = useAppearance().tempo- const { view, moveTo, surface } = viewport+ const { view, moveTo, size } = viewportreturn useCallback(function (direction: Direction) {@@ -27,9 +27,9 @@ export function useViewTravel(viewport: ViewportControl) {moveTo(next)- return reducedMotion ? 0 : timing("view", { distance: Math.hypot(direction.x * surface.width, direction.y * surface.height), tempo }).duration+ return reducedMotion ? 0 : timing("view", { distance: Math.hypot(direction.x * size.width, direction.y * size.height), tempo }).duration- }, [view.x, view.y, moveTo, reducedMotion, tempo, surface.width, surface.height])+ }, [view.x, view.y, moveTo, reducedMotion, tempo, size.width, size.height])}/** Which edges of a box a point is held against, within 16 pixels: -1, 0 or 1 in each direction. */diff --git a/source/client/view/structure/desktop/layers/desktop-layers.tsx b/source/client/view/structure/desktop/layers/desktop-layers.tsxindex 11ee484..27f8c16 100644--- a/source/client/view/structure/desktop/layers/desktop-layers.tsx+++ b/source/client/view/structure/desktop/layers/desktop-layers.tsx@@ -1,4 +1,4 @@-import { type CSSProperties, type ReactNode, type Ref } from "react"+import { type CSSProperties, type ReactNode } from "react"import { type AppearanceTaskbar } from "@phreshos/core"import { type PaintMargins } from "@client/view/components/window-manager/window-geometry"import { useDesktopScale } from "../desktop-scale"@@ -7,7 +7,7 @@ import { useDesktopScale } from "../desktop-scale"* Five coextensive Desktop layers ordered from back to front. No layer owns* layout space for another; each receives the complete Desktop bounds.*/-export default function DesktopLayers({ wallpaper, underWindows, windows, sharedResizeBoundaries, overWindows, shell, windowSurfaceRef, spacing }: DesktopLayersProps) {+export default function DesktopLayers({ wallpaper, underWindows, windows, sharedResizeBoundaries, overWindows, shell, spacing }: DesktopLayersProps) {// The Desktop's zoom multiplies viewport units too: what sizes itself by the viewport divides by it.const scale = useDesktopScale()@@ -32,15 +32,11 @@ export default function DesktopLayers({ wallpaper, underWindows, windows, shared<div data-desktop-layer="window" className="pointer-events-none absolute inset-0 z-2 overflow-hidden">- {/* Standard Windows measure in the whole Desktop, like every other- layer; the margins around it are painted, not measured. */}- <div ref={windowSurfaceRef} data-window-surface="" className="absolute inset-0">+ {/* Standard Windows measure in the whole view, like every other layer; the margins+ around them are painted, not measured. */}+ {windows}- {windows}-- {sharedResizeBoundaries}-- </div>+ {sharedResizeBoundaries}</div>@@ -71,8 +67,6 @@ interface DesktopLayersProps {overWindows: ReactNode- windowSurfaceRef: Ref<HTMLDivElement>-spacing: numbershell: ReactNodediff --git a/source/client/view/structure/desktop/layers/shell/default-shell.tsx b/source/client/view/structure/desktop/layers/shell/default-shell.tsxindex 7b6b2d4..2115426 100644--- a/source/client/view/structure/desktop/layers/shell/default-shell.tsx+++ b/source/client/view/structure/desktop/layers/shell/default-shell.tsx@@ -6,8 +6,8 @@ import OpenRequests from "./dialogs/open-requests"import StartMenu, { StartMenuButton, StartMenuProvider, useStartMenuOpen } from "./start-menu/start-menu"import SignOut from "./taskbar/sign-out"import Taskbar from "./taskbar/taskbar"-import ViewportControl, { type MappedWindow } from "./taskbar/viewport/viewport-control"-import { type ViewportControl as Viewport } from "../../viewport-offset"+import MapControl, { type MappedWindow } from "./taskbar/map/map-control"+import { type Viewport } from "../../viewport-offset"/** Built-in Shell entities composed as siblings in the complete Shell layer. */export default function DefaultShell({ spacing, taskbar, viewport, mappedWindows, children }: Readonly<{@@ -55,7 +55,7 @@ function DefaultTaskbar({ spacing, taskbar, viewport, mappedWindows, horizontal,return <Taskbarleading={<StartMenuButton showLabel={horizontal} />}- navigation={<ViewportControl viewport={viewport} windows={mappedWindows} taskbar={taskbar} spacing={spacing} onOpenChange={setMapOpen} />}+ navigation={<MapControl viewport={viewport} windows={mappedWindows} taskbar={taskbar} spacing={spacing} onOpenChange={setMapOpen} />}trailing={<SignOut showLabel={horizontal} />}spacing={spacing}taskbar={taskbar}diff --git a/source/client/view/structure/desktop/layers/shell/taskbar/viewport/viewport-control.tsx b/source/client/view/structure/desktop/layers/shell/taskbar/map/map-control.tsxsimilarity index 96%rename from source/client/view/structure/desktop/layers/shell/taskbar/viewport/viewport-control.tsxrename to source/client/view/structure/desktop/layers/shell/taskbar/map/map-control.tsxindex ddf71c9..c58f086 100644--- a/source/client/view/structure/desktop/layers/shell/taskbar/viewport/viewport-control.tsx+++ b/source/client/view/structure/desktop/layers/shell/taskbar/map/map-control.tsx@@ -16,7 +16,7 @@ import { desktopMargins } from "../../../desktop-layers"import { surfaceLifecyclePose, surfacePresenceTransition } from "@client/view/appearance/surface-presence"import { shellSurfaceClassName } from "../../shell-surface"import { floatingShadow } from "@client/view/appearance/floating-shadow"-import { type ViewportControl as Viewport } from "../../../../viewport-offset"+import { type Viewport } from "../../../../viewport-offset"/** A standard Window as the map shows it: where it is on the plane. */export interface MappedWindow {@@ -38,7 +38,7 @@ export interface MappedWindow {maximized: boolean/** Brings the view to the Window and the Window to the front. */- show(): void+ goTo(): void/** Moves the Window into the view on screen and brings it to the front. */bringHere(): void@@ -47,7 +47,7 @@ export interface MappedWindow {toggleMinimized(): void/** Maximizes the Window in its view, or restores it. */- fill(): void+ toggleMaximized(): void/** Closes the Window, which exits its Process. */close(): void@@ -68,7 +68,7 @@ export interface MappedWindow {* itself when focus crosses into a Program frame; either way the press goes on* to what it was meant for.*/-export default function ViewportControl({ viewport, windows, taskbar, spacing, onOpenChange }: Readonly<{+export default function MapControl({ viewport, windows, taskbar, spacing, onOpenChange }: Readonly<{viewport: Viewportwindows: readonly MappedWindow[]taskbar: AppearanceTaskbar@@ -146,7 +146,7 @@ export default function ViewportControl({ viewport, windows, taskbar, spacing, o// Where the ghost is held against the Desktop's edges: the placement a Window would take there,// shown as a Window's is, but only as a sign; nothing is placed when the hand lets go. It turns to// danger where the plane goes no further.- const [edge, setEdge] = useState<{ zone: SnapTarget | null, shown: SnapTarget | null, blocked: boolean, surface: HTMLElement | null }>({ zone: null, shown: null, blocked: false, surface: null })+ const [edge, setEdge] = useState<{ zone: SnapTarget | null, shown: SnapTarget | null, blocked: boolean, layer: HTMLElement | null }>({ zone: null, shown: null, blocked: false, layer: null })function carry(event: ReactPointerEvent<HTMLElement>) {@@ -160,7 +160,7 @@ export default function ViewportControl({ viewport, windows, taskbar, spacing, oconst edges = new EdgeHold(direction => travelNow.current(direction), blocked => setEdge(current => ({ ...current, blocked })))- const windowSurface = document.querySelector<HTMLElement>("[data-window-surface]")+ const windowLayer = document.querySelector<HTMLElement>("[data-desktop-layer=\"window\"]")const button = trigger.current@@ -192,13 +192,13 @@ export default function ViewportControl({ viewport, windows, taskbar, spacing, osetGhost({ x: motion.clientX, y: motion.clientY, ...lifted.current })// Measured as the Desktop measures a Window's drag: in its own pixels, at its scale.- const bounds = windowSurface?.getBoundingClientRect()+ const bounds = windowLayer?.getBoundingClientRect()- const scale = bounds && windowSurface?.clientWidth ? bounds.width / windowSurface.clientWidth : 1+ const scale = bounds && windowLayer?.clientWidth ? bounds.width / windowLayer.clientWidth : 1- const width = windowSurface?.clientWidth ?? window.innerWidth+ const width = windowLayer?.clientWidth ?? window.innerWidth- const height = windowSurface?.clientHeight ?? window.innerHeight+ const height = windowLayer?.clientHeight ?? window.innerHeightconst direction = against((motion.clientX - (bounds?.left ?? 0)) / scale, (motion.clientY - (bounds?.top ?? 0)) / scale, width, height)@@ -206,7 +206,7 @@ export default function ViewportControl({ viewport, windows, taskbar, spacing, oconst zone = direction.x || direction.y ? placementAt(direction) : null- setEdge(current => ({ ...current, zone, shown: zone ?? current.shown, surface: windowSurface }))+ setEdge(current => ({ ...current, zone, shown: zone ?? current.shown, layer: windowLayer }))}function end(motion: PointerEvent) {@@ -293,17 +293,17 @@ export default function ViewportControl({ viewport, windows, taskbar, spacing, o</TaskbarTooltip></span>- {edge.shown && edge.surface && createPortal(<SnapPreview+ {edge.shown && edge.layer && createPortal(<SnapPreviewshown={edge.shown}visible={edge.zone !== null}blocked={edge.blocked}bare={false}- paintSurfaceSize={{ width: edge.surface.clientWidth, height: edge.surface.clientHeight }}+ paintSurfaceSize={{ width: edge.layer.clientWidth, height: edge.layer.clientHeight }}paintInset={spacing / 2}paintMargins={desktopMargins(spacing, taskbar)}reducedMotion={reducedMotion}zIndex={2147483646}- />, edge.surface)}+ />, edge.layer)}{ghost && createPortal(<div aria-hidden="true" inert className="pointer-events-none fixed"style={{ left: ghost.x - ghost.grip.x, top: ghost.y - ghost.grip.y, transform: `scale(${ghost.scale})`, transformOrigin: "0 0", zIndex: 2147483647 }}>@@ -402,7 +402,7 @@ function ViewMap({ labelId, viewport, windows, centered, menus, room }: Readonly// The lines between views, as faint as React UI's separators.const line = `color-mix(in oklab, ${useColor("foreground").base} 10%, transparent)`- const { surface } = viewport+ const { size: surface } = viewportconst columns = range.maxX - range.minX + 1@@ -633,7 +633,7 @@ function MapWindow({ window, viewport, menus, mapX, mapY, cell }: Readonly<{const space = useScale(useAppearance().spacing)- const { surface } = viewport+ const { size: surface } = viewportconst center = { x: window.region.x + window.region.width / 2, y: window.region.y + window.region.height / 2 }@@ -727,7 +727,7 @@ function MapWindow({ window, viewport, menus, mapX, mapY, cell }: Readonly<{{/* The front Window is apricot; a minimized one fades; a maximized one carries the title bar's maximize mark. */}<Button size="xsmall" iconOnly depth="flat" color={window.front ? "primary:soft" : "secondary:subtle"}aria-label={windowState(window) ? `${window.title}, ${windowState(window)}` : window.title}- onPress={() => { if (!moved.current) window.show() }}+ onPress={() => { if (!moved.current) window.goTo() }}style={{ width: card, height: card, paddingInline: 0, opacity: window.minimized ? 0.45 : 1 }}><img src={window.icon} alt="" draggable={false} className="object-contain" style={{ width: icon, height: icon }} /></Button>@@ -737,7 +737,7 @@ function MapWindow({ window, viewport, menus, mapX, mapY, cell }: Readonly<{<ContextMenu.Content portalContainer={menus ?? undefined}><WindowMenu title={window.title} minimized={window.minimized} maximized={window.maximized}- onGoTo={window.show} onBringHere={window.bringHere} onToggleMinimized={window.toggleMinimized} onFill={window.fill} onClose={window.close} />+ onGoTo={window.goTo} onBringHere={window.bringHere} onToggleMinimized={window.toggleMinimized} onToggleMaximized={window.toggleMaximized} onClose={window.close} /></ContextMenu.Content>diff --git a/source/client/view/structure/desktop/layers/shell/taskbar/programs/window-taskbar-item.tsx b/source/client/view/structure/desktop/layers/shell/taskbar/programs/window-taskbar-item.tsxindex f1b612b..c10ac1b 100644--- a/source/client/view/structure/desktop/layers/shell/taskbar/programs/window-taskbar-item.tsx+++ b/source/client/view/structure/desktop/layers/shell/taskbar/programs/window-taskbar-item.tsx@@ -9,7 +9,7 @@ import useDragHold from "../../../../drag-hold"import { memo, useCallback } from "react"/** A taskbar entry rerenders only when what that entry shows changes. */-export default memo(function ({ record, title, icon, position, active, minimized, maximized, onElement, onMinimize, onShow, onGoTo, onBringHere, onFill, onClose }: WindowTaskbarItemProps) {+export default memo(function ({ record, title, icon, position, active, minimized, maximized, onElement, onMinimize, onShow, onGoTo, onBringHere, onMaximize, onClose }: WindowTaskbarItemProps) {const scaleContainer = useDesktopScaleContainer()@@ -35,7 +35,7 @@ export default memo(function ({ record, title, icon, position, active, minimizedelse onMinimize(record, true)}, [minimized, onMinimize, onShow, record])- const fill = useCallback(() => onFill(record), [onFill, record])+ const maximize = useCallback(() => void onMaximize(record), [onMaximize, record])const bringHere = useCallback(() => onBringHere(record), [onBringHere, record])const close = useCallback(() => onClose(record), [onClose, record])@@ -55,7 +55,7 @@ export default memo(function ({ record, title, icon, position, active, minimized<ContextMenu.Content portalContainer={scaleContainer ?? undefined}><WindowMenu title={title} minimized={minimized} maximized={maximized}- onGoTo={goTo} onBringHere={bringHere} onToggleMinimized={changeVisibility} onFill={fill} onClose={close} />+ onGoTo={goTo} onBringHere={bringHere} onToggleMinimized={changeVisibility} onToggleMaximized={maximize} onClose={close} /></ContextMenu.Content>@@ -90,7 +90,7 @@ interface WindowTaskbarItemProps {/** Moves the Window into the view on screen and brings it to the front. */onBringHere: (record: Process) => void- onFill: (record: Process) => void+ onMaximize: (record: Process) => unknownonClose: (record: Process) => void}diff --git a/source/client/view/structure/desktop/layers/shell/window-menu.tsx b/source/client/view/structure/desktop/layers/shell/window-menu.tsxindex 530cc18..bb38b6b 100644--- a/source/client/view/structure/desktop/layers/shell/window-menu.tsx+++ b/source/client/view/structure/desktop/layers/shell/window-menu.tsx@@ -6,14 +6,14 @@ import { ArrowDownLeft, ArrowUpRight, LocateFixed, Magnet, Maximize2, Minimize2,* icon on the Map. Going to it and bringing it here move between views; the rest act on the Window* where it is, with the same icons as the Window's own title bar controls.*/-export default function WindowMenu({ title, minimized, maximized, onGoTo, onBringHere, onToggleMinimized, onFill, onClose }: Readonly<{+export default function WindowMenu({ title, minimized, maximized, onGoTo, onBringHere, onToggleMinimized, onToggleMaximized, onClose }: Readonly<{title: stringminimized: booleanmaximized: booleanonGoTo: () => voidonBringHere: () => voidonToggleMinimized: () => void- onFill: () => void+ onToggleMaximized: () => voidonClose: () => void}>) {@@ -21,7 +21,7 @@ export default function WindowMenu({ title, minimized, maximized, onGoTo, onBrinif (action === "goTo") onGoTo()else if (action === "bringHere") onBringHere()else if (action === "visibility") onToggleMinimized()- else if (action === "fill") onFill()+ else if (action === "maximize") onToggleMaximized()else if (action === "close") onClose()}}>@@ -33,7 +33,7 @@ export default function WindowMenu({ title, minimized, maximized, onGoTo, onBrin<Menu.Item id="visibility" textValue={minimized ? "Show" : "Minimize"}>{minimized ? <><ArrowUpRight aria-hidden />Show</> : <><ArrowDownLeft aria-hidden />Minimize</>}</Menu.Item>- <Menu.Item id="fill" textValue={maximized ? "Restore" : "Maximize"}>{maximized ? <><Minimize2 aria-hidden />Restore</> : <><Maximize2 aria-hidden />Maximize</>}</Menu.Item>+ <Menu.Item id="maximize" textValue={maximized ? "Restore" : "Maximize"}>{maximized ? <><Minimize2 aria-hidden />Restore</> : <><Maximize2 aria-hidden />Maximize</>}</Menu.Item><Menu.Separator />diff --git a/source/client/view/structure/desktop/plane-slide.tsx b/source/client/view/structure/desktop/plane-slide.tsxindex 433b4a2..b0bcd10 100644--- a/source/client/view/structure/desktop/plane-slide.tsx+++ b/source/client/view/structure/desktop/plane-slide.tsx@@ -3,7 +3,7 @@ import { animate, motion, useMotionValue, type MotionValue } from "motion/react"import { type Transaction } from "@phreshos/core"import { useReducedMotion } from "@libs/react-motion"import { motionTransition } from "@client/view/appearance/motion"-import { type ViewportOffset, type WindowSurfaceSize } from "@client/view/components/window-manager/window-geometry"+import { type ViewportOffset, type ViewSize } from "@client/view/components/window-manager/window-geometry"export type PlaneSlideValue = Readonly<{ x: MotionValue<number>, y: MotionValue<number> }>@@ -54,7 +54,7 @@ export const PlaneSlideContext = createContext<PlaneSlideValue | null>(null)* transform moves the whole plane. A resize changes the pixels of the view, not where it looks,* so it does not glide, and neither does a view placed under a hand that drags it.*/-export function usePlaneSlide(views: ViewportOffset, transaction: Transaction | null, surface: WindowSurfaceSize): PlaneSlideValue {+export function usePlaneSlide(views: ViewportOffset, transaction: Transaction | null, surface: ViewSize): PlaneSlideValue {const x = useMotionValue(0)diff --git a/source/client/view/structure/desktop/view-size.ts b/source/client/view/structure/desktop/view-size.tsnew file mode 100644index 0000000..3534a12--- /dev/null+++ b/source/client/view/structure/desktop/view-size.ts@@ -0,0 +1,33 @@+import { useLayoutEffect, useState, type RefObject } from "react"+import { type ViewSize } from "@client/view/components/window-manager/window-geometry"++/**+ * The size of this Desktop's view, in its own pixels: one view of the plane, which every layer is+ * drawn in and every standard Window is measured against.+ */+export default function useViewSize(desktop: RefObject<HTMLElement | null>): ViewSize {++ const [size, setSize] = useState<ViewSize>({ width: 0, height: 0 })++ useLayoutEffect(function () {++ const element = desktop.current++ if (!element) return++ const measure = () => setSize(current => current.width === element.clientWidth && current.height === element.clientHeight+ ? current+ : { width: element.clientWidth, height: element.clientHeight })++ measure()++ const observer = new ResizeObserver(measure)++ observer.observe(element)++ return () => observer.disconnect()++ }, [desktop])++ return size+}diff --git a/source/client/view/structure/desktop/viewport-offset.ts b/source/client/view/structure/desktop/viewport-offset.tsindex 7ddaf53..b642b8a 100644--- a/source/client/view/structure/desktop/viewport-offset.ts+++ b/source/client/view/structure/desktop/viewport-offset.ts@@ -1,7 +1,7 @@import { useCallback, useMemo, useRef, useState } from "react"import { progressAt, type Transaction } from "@phreshos/core"import { timing, useAppearance } from "@phreshos/react-ui"-import { planeReach, type ViewportOffset, type WindowSurfaceSize } from "@client/view/components/window-manager/window-geometry"+import { planeReach, type ViewportOffset, type ViewSize } from "@client/view/components/window-manager/window-geometry"/*** Where this Desktop looks on the plane of standard Windows: the point shown at@@ -12,7 +12,7 @@ import { planeReach, type ViewportOffset, type WindowSurfaceSize } from "@client* view has: a Desktop that is resized, or rescaled, keeps looking at the same* Windows. Its pixels follow from the current size.*/-export default function useViewportOffset(surface: WindowSurfaceSize) {+export default function useViewportOffset(size: ViewSize) {// How the view gets to where it goes: a move to a whole view takes a motion chosen from how far// it goes; placing the view under a hand that drags it follows the hand at once, with none. The@@ -20,9 +20,9 @@ export default function useViewportOffset(surface: WindowSurfaceSize) {// carries on at the speed it already has.const [{ views, transaction }, setState] = useState<ViewportState>({ views: origin, transaction: null, journey: null })- const size = useRef(surface)+ const latestSize = useRef(size)- size.current = surface+ latestSize.current = sizeconst tempo = useRef(1)@@ -34,7 +34,7 @@ export default function useViewportOffset(surface: WindowSurfaceSize) {const now = performance.now()- const { width, height } = size.current+ const { width, height } = latestSize.current// Where the view is shown now, and how fast it moves there, in pixels a second.let from = { x: current.views.x * width, y: current.views.y * height }@@ -82,25 +82,25 @@ export default function useViewportOffset(surface: WindowSurfaceSize) {/** Places the view at any point of the plane in pixels, not only whole views; its center stays over the plane's outer views. */const place = useCallback(function (point: ViewportOffset) {- if (!surface.width || !surface.height) return+ if (!size.width || !size.height) return- setViews({ x: within(point.x / surface.width), y: within(point.y / surface.height) }, false)+ setViews({ x: within(point.x / size.width), y: within(point.y / size.height) }, false)- }, [surface.width, surface.height, setViews])+ }, [size.width, size.height, setViews])/** Returns the view to the plane's center. */const home = useCallback(() => setViews(origin), [setViews])// The same place in pixels, at the current size.- const offset = useMemo<ViewportOffset>(() => ({ x: Math.round(views.x * surface.width), y: Math.round(views.y * surface.height) }), [views, surface.width, surface.height])+ const offset = useMemo<ViewportOffset>(() => ({ x: Math.round(views.x * size.width), y: Math.round(views.y * size.height) }), [views, size.width, size.height])// The nearest whole view from the center, which is what a person counts.const view = { x: Math.round(views.x), y: Math.round(views.y) }- return { views, transaction, offset, view, surface, moveTo, place, home }+ return { views, transaction, offset, view, size, moveTo, place, home }}-export type ViewportControl = ReturnType<typeof useViewportOffset>+export type Viewport = ReturnType<typeof useViewportOffset>type ViewportState = Readonly<{views: ViewportOffsetdiff --git a/source/client/view/structure/desktop/windows/process-window.tsx b/source/client/view/structure/desktop/windows/process-window.tsxindex f3d0fdd..bb4cd6f 100644--- a/source/client/view/structure/desktop/windows/process-window.tsx+++ b/source/client/view/structure/desktop/windows/process-window.tsx@@ -1,7 +1,7 @@import { type WindowRegion } from "@client/view/components/window-manager/window-geometry"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 PaintMargins, type ViewSize } from "@client/view/components/window-manager/window-geometry"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"@@ -26,7 +26,7 @@ export function processWindowProgress(layer: WindowLayer, loading: boolean, stop* props so memoization can see which process actually changed even though* the peer deliberately keeps each Process instance alive and mutates it.*/-export default memo(function ({ identity, record, assetId, client, title, header, surface, layer, icon, position, size, taskbarPosition, surfaceAnimation, geometryAnimation, minimizeAnimation, onPresentationAnimationComplete, onPresentationRepresentation, onPresentationMoveGesture, paintSurfaceSize, paintMargins, spacing, depth, active, minimized, maximized, maximizedPosition, interactive, closing, stopping, entering, door, programAccess, theme, onFrame, onFrameLoad, onReady, onRaise, onMinimize, onFill, onClose, onClosed, onUnavailable, onMove, onResize, onSnap, onEdgeHold, onNeighbours }: ProcessWindowProps) {+export default memo(function ({ identity, record, assetId, client, title, header, surface, layer, icon, position, size, taskbarPosition, surfaceAnimation, geometryAnimation, minimizeAnimation, onPresentationAnimationComplete, onPresentationRepresentation, onPresentationMoveGesture, paintSurfaceSize, paintMargins, spacing, depth, active, minimized, maximized, maximizedPosition, interactive, closing, stopping, entering, door, programAccess, theme, onFrame, onFrameLoad, onReady, onRaise, onMinimize, onMaximize, onClose, onClosed, onUnavailable, onMove, onResize, onSnap, onEdgeHold, onNeighbours }: ProcessWindowProps) {const activate = useCallback(() => onRaise(record), [onRaise, record])@@ -34,7 +34,7 @@ export default memo(function ({ identity, record, assetId, client, title, headerconst minimize = useCallback(() => onMinimize(record, true), [onMinimize, record])- const fill = useCallback(() => onFill(record), [onFill, record])+ const maximize = useCallback(() => onMaximize(record), [onMaximize, record])const close = useCallback(() => onClose(record), [onClose, record])@@ -165,7 +165,7 @@ export default memo(function ({ identity, record, assetId, client, title, headeronMinimize={minimize}- onMaximize={fill}+ onMaximize={maximize}onClose={close}@@ -268,7 +268,7 @@ interface ProcessWindowProps {onPresentationMoveGesture: (identity: string, controller: DesktopMoveGestureController | null) => void- paintSurfaceSize?: WindowSurfaceSize+ paintSurfaceSize?: ViewSizepaintMargins?: PaintMargins@@ -308,7 +308,7 @@ interface ProcessWindowProps {onMinimize: (record: Process, minimized: boolean) => void- onFill: (record: Process) => Promise<boolean>+ onMaximize: (record: Process) => Promise<boolean>onClose: (record: Process) => voiddiff --git a/source/client/view/structure/desktop/windows/snap-preview.tsx b/source/client/view/structure/desktop/windows/snap-preview.tsxindex 32e0fe1..2eac0f4 100644--- a/source/client/view/structure/desktop/windows/snap-preview.tsx+++ b/source/client/view/structure/desktop/windows/snap-preview.tsx@@ -1,6 +1,6 @@import { type CSSProperties } from "react"import { motion } from "motion/react"-import { windowPaintInsets, type PaintMargins, type WindowSurfaceSize } from "@client/view/components/window-manager/window-geometry"+import { windowPaintInsets, type PaintMargins, type ViewSize } from "@client/view/components/window-manager/window-geometry"import { type Position, type Size } from "@phreshos/core"import { Surface, useTiming } from "@phreshos/react-ui"import { motionTransition } from "@client/view/appearance/motion"@@ -56,8 +56,8 @@ interface SnapPreviewProps {/** The hand holds the Window against the plane's end. */blocked?: booleanbare: boolean- minimumSize?: WindowSurfaceSize- paintSurfaceSize: WindowSurfaceSize+ minimumSize?: ViewSize+ paintSurfaceSize: ViewSizepaintInset: numberpaintMargins: PaintMarginsreducedMotion: booleandiff --git a/source/client/view/structure/desktop/windows/window-geometry-motion.ts b/source/client/view/structure/desktop/windows/window-geometry-motion.tsindex a09aae7..4d2ea8d 100644--- a/source/client/view/structure/desktop/windows/window-geometry-motion.ts+++ b/source/client/view/structure/desktop/windows/window-geometry-motion.ts@@ -1,4 +1,4 @@-import { constrainWindowGeometry, resolveWindowGeometry, type WindowRegion, type WindowSurfaceSize } from "@client/view/components/window-manager/window-geometry"+import { constrainWindowGeometry, resolveWindowGeometry, type WindowRegion, type ViewSize } from "@client/view/components/window-manager/window-geometry"import { 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"@@ -15,7 +15,7 @@ interface WindowGeometryMotionOptions {immediate: boolean/** Moves visibly only when the person can see where it starts or where it ends; otherwise it is simply there. */seenOnly?: boolean- minimumSize?: WindowSurfaceSize+ minimumSize?: ViewSizeonComplete?: (revision: number) => void}diff --git a/source/client/view/structure/desktop/windows/window.tsx b/source/client/view/structure/desktop/windows/window.tsxindex b051d96..8609995 100644--- a/source/client/view/structure/desktop/windows/window.tsx+++ b/source/client/view/structure/desktop/windows/window.tsx@@ -2,7 +2,7 @@ import { ComponentProps, PointerEvent as ReactPointerEvent, ReactNode, useCallbaimport { 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 { absoluteWindowGeometry, constrainWindowGeometry, minimumWindowSize, noPaintMargins, planeGeometry, resolveWindowGeometry, windowPaintInsets, type PaintMargins, type WindowRegion, type ViewSize } from "@client/view/components/window-manager/window-geometry"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"@@ -80,7 +80,7 @@ export default function ({ title, header = true, surface, layer, icon, children,const surfaceRadius = surfaceDefinition === false ? undefined : windowSurfaceRadius(surfaceDefinition, appearance)const presentationMinimum = standard ? { width: minWidth, height: minHeight } : undefined- function resolvePresentedGeometry(selectedPosition: Position, selectedSize: Size, surface: WindowSurfaceSize) {+ function resolvePresentedGeometry(selectedPosition: Position, selectedSize: Size, surface: ViewSize) {const region = resolveWindowGeometry(selectedPosition, selectedSize, surface)@@ -964,7 +964,7 @@ interface WindowProps extends Omit<ComponentProps<"div">, "onAnimationStart" | "onPresentationMoveGesture?: (controller: DesktopMoveGestureController | null) => void/** Surface used only to decide which painted edges receive an inset. */- paintSurfaceSize?: WindowSurfaceSize+ paintSurfaceSize?: ViewSize/** Space kept from each edge of the Desktop when painting an edge that touches it. */paintMargins?: PaintMarginsdiff --git a/tests/client-layer-permissions.test.ts b/tests/client-layer-permissions.test.tsindex 0bad79c..7b67488 100644--- a/tests/client-layer-permissions.test.ts+++ b/tests/client-layer-permissions.test.ts@@ -63,7 +63,7 @@ function fixture() {authentication, connection, session,grantsPermission: async <Name extends PermissionName>(_pane: string, name: Name, values: readonly PermissionValue<Name>[]) => permissionCatalog.allows(name, values, permissions)} as unknown as AuthManager- const answer = host(auth, process.identity, { state: () => ({ size: { width: 100, height: 100 }, offset: { x: 0, y: 0 } }), move: () => undefined }, () => "frame", clientFrame(), {} as never)+ const answer = host(auth, process.identity, { state: () => ({ size: { width: 100, height: 100 }, offset: { x: 0, y: 0 } }), move: () => undefined }, {} as never, () => "frame", clientFrame(), {} as never)return {auth, program, process, answer, createProcess, findOrCreateProcess, startup, startEndpoint, command, connection,permissions(value: Permissions) { permissions = value }@@ -155,7 +155,7 @@ test("Client layer authorization validates explicit choices without reinterpretitest.each(restrictedLayers)("Client run streams authorize %s before creating an iterator", async layer => {const f = fixture()const boundary = new ClientProcessBoundary(f.process.identity, { contentWindow: null } as HTMLIFrameElement, f.auth,- { state: () => ({ size: { width: 100, height: 100 }, offset: { x: 0, y: 0 } }), move: () => undefined }, {} as never, { begin: vi.fn(), cancelMoveGestures: vi.fn() } as never)+ { state: () => ({ size: { width: 100, height: 100 }, offset: { x: 0, y: 0 } }), move: () => undefined }, {} as never, {} as never, { begin: vi.fn(), cancelMoveGestures: vi.fn() } as never)const deliver = vi.spyOn(boundary, "deliver").mockResolvedValue()await boundary.own("frame")const program = { identity: f.program.identity, reference: f.program.reference }diff --git a/tests/client-permission-boundary.test.ts b/tests/client-permission-boundary.test.tsindex f63c19e..7aa9d10 100644--- a/tests/client-permission-boundary.test.ts+++ b/tests/client-permission-boundary.test.ts@@ -26,7 +26,7 @@ test("Client Program creation requires all before reaching the creation boundaryprocessManager: { processes: new Map([["caller", { identity: "caller", program: program.identity }]]) },grantsPermission: async (_pane: string, name: PermissionName, values: never[]) => permissionCatalog.allows(name, values, permissions)} as unknown as AuthManager- const answer = host(auth, "caller", { state: () => { throw new Error("unused viewport") }, move: () => { throw new Error("unused viewport") } }, () => null, clientFrame(), {} as never)+ const answer = host(auth, "caller", { state: () => { throw new Error("unused viewport") }, move: () => { throw new Error("unused viewport") } }, {} as never, () => null, clientFrame(), {} as never)const source = { identity: "created" }for (const operation of ["host-program-create", "host-program-force-create"]) {await expect(answer(operation, source)).rejects.toThrow("Execution is not permitted")@@ -56,7 +56,7 @@ test("Program and Process discovery exposes only the accessible scope", async ()processManager: { processes: new Map([[current.identity, current], [hidden.identity, hidden]]) },grantsPermission: async (_pane: string, name: PermissionName, values: never[]) => permissionCatalog.allows(name, values, permissions)} as unknown as AuthManager- const answer = host(auth, current.identity, { state: () => { throw new Error("unused viewport") }, move: () => { throw new Error("unused viewport") } }, () => null, clientFrame(), {} as never)+ const answer = host(auth, current.identity, { state: () => { throw new Error("unused viewport") }, move: () => { throw new Error("unused viewport") } }, {} as never, () => null, clientFrame(), {} as never)await expect(answer("host-program-list")).resolves.toEqual([[expect.objectContaining({ identity: owner.identity })]])await expect(answer("host-process-list")).resolves.toEqual([[expect.objectContaining({ identity: current.identity })]])@@ -97,7 +97,7 @@ test("Program permission reads require Program access while owner decisions requprocessManager: { processes: new Map([[current.identity, current]]) },grantsPermission: async (_pane: string, name: PermissionName, values: never[]) => permissionCatalog.allows(name, values, permissions)} as unknown as AuthManager- const answer = host(auth, current.identity, { state: () => { throw new Error("unused viewport") }, move: () => { throw new Error("unused viewport") } }, () => null, clientFrame(), {} as never)+ const answer = host(auth, current.identity, { state: () => { throw new Error("unused viewport") }, move: () => { throw new Error("unused viewport") } }, {} as never, () => null, clientFrame(), {} as never)const target = { identity: outside.identity, reference: outside.reference }await expect(answer("program-permissions", target, "get", "network")).resolves.toEqual([["https://example.com"]])@@ -125,7 +125,7 @@ test("Program log access follows the Program handle while System logs require lologs: systemLogs,grantsPermission: async (_pane: string, name: PermissionName, values: never[]) => permissionCatalog.allows(name, values, permissions)} as unknown as AuthManager- const answer = host(auth, current.identity, { state: () => { throw new Error("unused viewport") }, move: () => { throw new Error("unused viewport") } }, () => null, clientFrame(), {} as never)+ const answer = host(auth, current.identity, { state: () => { throw new Error("unused viewport") }, move: () => { throw new Error("unused viewport") } }, {} as never, () => null, clientFrame(), {} as never)const own = { identity: owner.identity, reference: owner.reference }const other = { identity: outside.identity, reference: outside.reference }@@ -150,7 +150,7 @@ test("a Client Context requests only for its own Endpoint Program", async () =>processManager: { processes: new Map([[current.identity, current]]) },requestPermission} as unknown as AuthManager- const answer = host(auth, current.identity, { state: () => { throw new Error("unused viewport") }, move: () => { throw new Error("unused viewport") } }, () => null, clientFrame(), {} as never)+ const answer = host(auth, current.identity, { state: () => { throw new Error("unused viewport") }, move: () => { throw new Error("unused viewport") } }, {} as never, () => null, clientFrame(), {} as never)const timeout = 1_000await expect(answer("context-permission-request", "request", "network", ["https://example.com"], timeout))@@ -170,7 +170,7 @@ test("the system-wide permission registry requires all", async () => {permissionManager: { list },grantsPermission: async (_pane: string, name: PermissionName, values: never[]) => permissionCatalog.allows(name, values, permissions)} as unknown as AuthManager- const answer = host(auth, current.identity, { state: () => { throw new Error("unused viewport") }, move: () => { throw new Error("unused viewport") } }, () => null, clientFrame(), {} as never)+ const answer = host(auth, current.identity, { state: () => { throw new Error("unused viewport") }, move: () => { throw new Error("unused viewport") } }, {} as never, () => null, clientFrame(), {} as never)await expect(answer("host-permission-requests")).rejects.toThrow("Execution is not permitted")expect(list).not.toHaveBeenCalled()@@ -226,7 +226,7 @@ test.each([},grantsPermission: async (_pane: string, name: PermissionName, values: never[]) => permissionCatalog.allows(name, values, permissions)} as unknown as AuthManager- const answer = host(auth, "caller", { state: () => { throw new Error("unused viewport") }, move: () => { throw new Error("unused viewport") } }, () => "frame", clientFrame(), {} as never)+ const answer = host(auth, "caller", { state: () => { throw new Error("unused viewport") }, move: () => { throw new Error("unused viewport") } }, {} as never, () => "frame", clientFrame(), {} as never)const key = { program: owningProgram, process: "main", endpoint: "server" } as constconst operations = [["service-available", key],@@ -267,7 +267,7 @@ test("Service discovery filters ready addresses only by Service-name authority",},grantsPermission: async (_pane: string, name: PermissionName, values: never[]) => permissionCatalog.allows(name, values, permissions)} as unknown as AuthManager- const answer = host(auth, "caller", { state: () => { throw new Error("unused viewport") }, move: () => { throw new Error("unused viewport") } }, () => "frame", clientFrame(), {} as never)+ const answer = host(auth, "caller", { state: () => { throw new Error("unused viewport") }, move: () => { throw new Error("unused viewport") } }, {} as never, () => "frame", clientFrame(), {} as never)await expect(answer("host-service-list")).resolves.toEqual([[]])await expect(answer("host-service-list", { name: "main" })).resolves.toEqual([[]])@@ -323,7 +323,7 @@ test("Reading the Desktop view is open, and moving it requires desktopViewport",} as unknown as AuthManagerconst state = { size: { width: 1200, height: 800 }, offset: { x: 0, y: 0 } }const move = vi.fn()- const answer = host(auth, "caller", { state: () => state, move }, () => null, clientFrame(), {} as never)+ const answer = host(auth, "caller", { state: () => state, move }, {} as never, () => null, clientFrame(), {} as never)expect(await answer("desktopViewport")).toEqual([state])await expect(answer("moveDesktopViewport", { x: 1200, y: 0 })).rejects.toThrow("Execution is not permitted")@@ -338,7 +338,7 @@ test("Reading the Desktop view is open, and moving it requires desktopViewport",test("a Client reads what the System is from the System itself, when it started included", async () => {const about = Object.freeze({ name: "PhreshOS", version: "1.0.0", release: { name: "Sprout", program: "sprout" }, startedAt: new Date("2026-09-30T08:00:00.000Z") })const auth = { about: vi.fn(async () => about) } as unknown as AuthManager- const answer = host(auth, "caller", { state: () => { throw new Error("unused viewport") }, move: () => { throw new Error("unused viewport") } }, () => null, clientFrame(), {} as never)+ const answer = host(auth, "caller", { state: () => { throw new Error("unused viewport") }, move: () => { throw new Error("unused viewport") } }, {} as never, () => null, clientFrame(), {} as never)await expect(answer("about")).resolves.toEqual([about])})@@ -347,7 +347,7 @@ test("a Client reads the System's icon from the System itself", async () => {const bytes = [137, 80, 78, 71]const icon = vi.fn(async () => bytes)const auth = { icon } as unknown as AuthManager- const answer = host(auth, "caller", { state: () => { throw new Error("unused viewport") }, move: () => { throw new Error("unused viewport") } }, () => null, clientFrame(), {} as never)+ const answer = host(auth, "caller", { state: () => { throw new Error("unused viewport") }, move: () => { throw new Error("unused viewport") } }, {} as never, () => null, clientFrame(), {} as never)await expect(answer("system-icon", "large")).resolves.toEqual([bytes])expect(icon).toHaveBeenCalledWith("large")diff --git a/tests/client-process-boundary-lifecycle.test.ts b/tests/client-process-boundary-lifecycle.test.tsindex 8338049..10f6631 100644--- a/tests/client-process-boundary-lifecycle.test.ts+++ b/tests/client-process-boundary-lifecycle.test.ts@@ -44,6 +44,7 @@ test("a Client question expectation survives initial iframe ownership", async ()element,authManager,{ state: () => ({ size: { width: 800, height: 600 }, offset: { x: 0, y: 0 } }), move: () => undefined },+ {} as never,{} as ClientTraffic,{ begin() {} } as unknown as PresentationHost)@@ -82,6 +83,7 @@ test("a later Client request cannot overtake its Service subscription registrati{ contentWindow: null } as unknown as HTMLIFrameElement,authManager,{ state: () => ({ size: { width: 800, height: 600 }, offset: { x: 0, y: 0 } }), move: () => undefined },+ {} as never,{} as ClientTraffic,{ begin() {} } as unknown as PresentationHost)@@ -126,6 +128,7 @@ test("a registered Service event is delivered without a second permission round-element,authManager,{ state: () => ({ size: { width: 800, height: 600 }, offset: { x: 0, y: 0 } }), move: () => undefined },+ {} as never,traffic,{ begin() {} } as unknown as PresentationHost)diff --git a/tests/desktop-replacements.test.tsx b/tests/desktop-replacements.test.tsxindex 62a59b3..a5df8bd 100644--- a/tests/desktop-replacements.test.tsx+++ b/tests/desktop-replacements.test.tsx@@ -30,7 +30,7 @@ vi.mock("@the-link/react", () => ({ReactTunnel: { useFactory: () => ({ useSubscribe() {} }) },useProperty: (property: { value: unknown }) => property.value}))-vi.mock("@client/view/components/desktop-host/client-host", () => ({ default: () => ({ windowSurfaceSize: { width: 0, height: 0 }, viewport: { views: { x: 0, y: 0 }, offset: { x: 0, y: 0 }, view: { x: 0, y: 0 }, surface: { width: 0, height: 0 }, moveTo: () => undefined, place: () => undefined, home: () => undefined } }) }))+vi.mock("@client/view/components/desktop-host/client-host", () => ({ default: () => ({ viewSize: { width: 0, height: 0 }, viewport: { views: { x: 0, y: 0 }, offset: { x: 0, y: 0 }, view: { x: 0, y: 0 }, surface: { width: 0, height: 0 }, moveTo: () => undefined, place: () => undefined, home: () => undefined } }) }))vi.mock("@client/view/components/program-access", () => ({ default: () => null }))vi.mock("@libs/readiness", () => ({ useRequirement: () => () => {} }))vi.mock("@client/view/structure/desktop/layers/shell/default-shell", () => ({@@ -57,11 +57,9 @@ test("Desktop composes five full-bound stacked layers without a layout track", (const windowLayer = markup.match(/<div[^>]*data-desktop-layer="window"[^>]*>/)?.[0]expect(display).toContain("absolute inset-0")expect(display).not.toContain("grid")+ // Standard Windows measure in the whole view, the layer they are drawn in; their margins are painted.expect(windowLayer).toContain("absolute inset-0")- const windowSurface = markup.match(/<div[^>]*data-window-surface=""[^>]*>/)?.[0]- expect(windowSurface).not.toContain("overflow-hidden")- // Standard Windows measure in the whole Desktop; their margins are painted.- expect(windowSurface).toContain("absolute inset-0")+ expect(markup).not.toContain("data-window-surface")})test.each(["top", "right", "bottom", "left"] as const)("standard windows keep clear of the %s Taskbar edge when painting", position => {diff --git a/tests/presentation.test.ts b/tests/presentation.test.tsindex 26ea348..df12e6e 100644--- a/tests/presentation.test.ts+++ b/tests/presentation.test.ts@@ -67,36 +67,6 @@ test("transactionAndWait resolves only after the matching local animation", asynawait usingAppearance})-test("only a Window this Desktop maximizes is known as maximized from here, until its request settles", async () => {- const ordinary = client("window")- const entries = entry("ordinary", ordinary)- const presentations = new Presentations(entries, () => ordinary as never)- const [identity] = [...presentations.windows.keys()]-- // Maximized from another Desktop: the System's state changes, and this Desktop asked nothing.- ordinary.window.maximized = true- presentations.reconcile(entries)- assert.equal(presentations.projection("ordinary").maximized, true)- assert.equal(presentations.maximizingHere(identity!), false)-- ordinary.window.maximized = false- presentations.reconcile(entries)- let answer!: () => void- const request = new Promise<void>(resolve => { answer = resolve })- presentations.maximize("ordinary", true, request)- assert.equal(presentations.projection("ordinary").maximized, true)- assert.equal(presentations.maximizingHere(identity!), true)-- answer()- await request- await Promise.resolve()- assert.equal(presentations.maximizingHere(identity!), false)-- // Restoring from here is not maximizing.- presentations.maximize("ordinary", false, Promise.resolve())- assert.equal(presentations.maximizingHere(identity!), false)-})-test("a standard Window follows authoritative state but accepts only move gestures", async () => {const ordinary = client("window")const entries = entry("ordinary", ordinary)@@ -154,6 +124,7 @@ test("a Client boundary initializes each new document exactly once", async () =>{ processManager: { async ownFrame() {}, async releaseFrame() {} } } as never,{ state: () => ({ size: { width: 1, height: 1 }, offset: { x: 0, y: 0 } }), move: () => undefined },{} as never,+ {} as never,{ begin(identity: string) { lifecycle.push(identity) }, cancelMoveGestures() {} } as never)await boundary.own("first-owner")